From 54c9cf73462d8779324be3f05673c85e4f446b9b Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Thu, 19 Dec 2024 21:00:29 +0530
Subject: [PATCH 01/14] CM-6 Update

---
 .../server/ExamplesInteractiveServer.kt       |     4 +
 .../resources/static/codemirror-bundle.esm.js | 27514 +++++++
 .../resources/static/codemirror-bundle.js     | 67545 ++++++++++++++++
 .../resources/templates/examples/index.html   |    80 +-
 4 files changed, 95121 insertions(+), 22 deletions(-)
 create mode 100644 core/src/main/resources/static/codemirror-bundle.esm.js
 create mode 100644 core/src/main/resources/static/codemirror-bundle.js

diff --git a/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt b/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt
index db5458cfb..dc06f5c3e 100644
--- a/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt
+++ b/core/src/main/kotlin/io/specmatic/core/examples/server/ExamplesInteractiveServer.kt
@@ -4,6 +4,7 @@ import io.ktor.http.*
 import io.ktor.serialization.jackson.*
 import io.ktor.server.application.*
 import io.ktor.server.engine.*
+import io.ktor.server.http.content.*
 import io.ktor.server.netty.*
 import io.ktor.server.plugins.contentnegotiation.*
 import io.ktor.server.plugins.cors.routing.*
@@ -106,6 +107,9 @@ class ExamplesInteractiveServer(
             configureHealthCheckModule()
 
             routing {
+                static("/_specmatic") {
+                    resources("static")
+                }
                 get("/_specmatic/examples") {
                     val contractFile = getContractFileOrBadRequest(call) ?: return@get
                     try {
diff --git a/core/src/main/resources/static/codemirror-bundle.esm.js b/core/src/main/resources/static/codemirror-bundle.esm.js
new file mode 100644
index 000000000..4f42d8555
--- /dev/null
+++ b/core/src/main/resources/static/codemirror-bundle.esm.js
@@ -0,0 +1,27514 @@
+// These are filled with ranges (rangeFrom[i] up to but not including
+// rangeTo[i]) of code points that count as extending characters.
+let rangeFrom = [], rangeTo = []
+
+;(() => {
+  // Compressed representation of the Grapheme_Cluster_Break=Extend
+  // information from
+  // http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
+  // Each pair of elements represents a range, as an offet from the
+  // previous range and a length. Numbers are in base-36, with the empty
+  // string being a shorthand for 1.
+  let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
+  for (let i = 0, n = 0; i < numbers.length; i++)
+    (i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i]);
+})();
+
+function isExtendingChar(code) {
+  if (code < 768) return false
+  for (let from = 0, to = rangeFrom.length;;) {
+    let mid = (from + to) >> 1;
+    if (code < rangeFrom[mid]) to = mid;
+    else if (code >= rangeTo[mid]) from = mid + 1;
+    else return true
+    if (from == to) return false
+  }
+}
+
+function isRegionalIndicator(code) {
+  return code >= 0x1F1E6 && code <= 0x1F1FF
+}
+
+const ZWJ = 0x200d;
+
+function findClusterBreak$1(str, pos, forward = true, includeExtending = true) {
+  return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
+}
+
+function nextClusterBreak(str, pos, includeExtending) {
+  if (pos == str.length) return pos
+  // If pos is in the middle of a surrogate pair, move to its start
+  if (pos && surrogateLow$1(str.charCodeAt(pos)) && surrogateHigh$1(str.charCodeAt(pos - 1))) pos--;
+  let prev = codePointAt$1(str, pos);
+  pos += codePointSize$1(prev);
+  while (pos < str.length) {
+    let next = codePointAt$1(str, pos);
+    if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
+      pos += codePointSize$1(next);
+      prev = next;
+    } else if (isRegionalIndicator(next)) {
+      let countBefore = 0, i = pos - 2;
+      while (i >= 0 && isRegionalIndicator(codePointAt$1(str, i))) { countBefore++; i -= 2; }
+      if (countBefore % 2 == 0) break
+      else pos += 2;
+    } else {
+      break
+    }
+  }
+  return pos
+}
+
+function prevClusterBreak(str, pos, includeExtending) {
+  while (pos > 0) {
+    let found = nextClusterBreak(str, pos - 2, includeExtending);
+    if (found < pos) return found
+    pos--;
+  }
+  return 0
+}
+
+function codePointAt$1(str, pos) {
+  let code0 = str.charCodeAt(pos);
+  if (!surrogateHigh$1(code0) || pos + 1 == str.length) return code0
+  let code1 = str.charCodeAt(pos + 1);
+  if (!surrogateLow$1(code1)) return code0
+  return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
+}
+
+function surrogateLow$1(ch) { return ch >= 0xDC00 && ch < 0xE000 }
+function surrogateHigh$1(ch) { return ch >= 0xD800 && ch < 0xDC00 }
+function codePointSize$1(code) { return code < 0x10000 ? 1 : 2 }
+
+/**
+The data structure for documents. @nonabstract
+*/
+class Text {
+    /**
+    Get the line description around the given position.
+    */
+    lineAt(pos) {
+        if (pos < 0 || pos > this.length)
+            throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
+        return this.lineInner(pos, false, 1, 0);
+    }
+    /**
+    Get the description for the given (1-based) line number.
+    */
+    line(n) {
+        if (n < 1 || n > this.lines)
+            throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
+        return this.lineInner(n, true, 1, 0);
+    }
+    /**
+    Replace a range of the text with the given content.
+    */
+    replace(from, to, text) {
+        [from, to] = clip(this, from, to);
+        let parts = [];
+        this.decompose(0, from, parts, 2 /* Open.To */);
+        if (text.length)
+            text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);
+        this.decompose(to, this.length, parts, 1 /* Open.From */);
+        return TextNode.from(parts, this.length - (to - from) + text.length);
+    }
+    /**
+    Append another document to this one.
+    */
+    append(other) {
+        return this.replace(this.length, this.length, other);
+    }
+    /**
+    Retrieve the text between the given points.
+    */
+    slice(from, to = this.length) {
+        [from, to] = clip(this, from, to);
+        let parts = [];
+        this.decompose(from, to, parts, 0);
+        return TextNode.from(parts, to - from);
+    }
+    /**
+    Test whether this text is equal to another instance.
+    */
+    eq(other) {
+        if (other == this)
+            return true;
+        if (other.length != this.length || other.lines != this.lines)
+            return false;
+        let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
+        let a = new RawTextCursor(this), b = new RawTextCursor(other);
+        for (let skip = start, pos = start;;) {
+            a.next(skip);
+            b.next(skip);
+            skip = 0;
+            if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
+                return false;
+            pos += a.value.length;
+            if (a.done || pos >= end)
+                return true;
+        }
+    }
+    /**
+    Iterate over the text. When `dir` is `-1`, iteration happens
+    from end to start. This will return lines and the breaks between
+    them as separate strings.
+    */
+    iter(dir = 1) { return new RawTextCursor(this, dir); }
+    /**
+    Iterate over a range of the text. When `from` > `to`, the
+    iterator will run in reverse.
+    */
+    iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); }
+    /**
+    Return a cursor that iterates over the given range of lines,
+    _without_ returning the line breaks between, and yielding empty
+    strings for empty lines.
+    
+    When `from` and `to` are given, they should be 1-based line numbers.
+    */
+    iterLines(from, to) {
+        let inner;
+        if (from == null) {
+            inner = this.iter();
+        }
+        else {
+            if (to == null)
+                to = this.lines + 1;
+            let start = this.line(from).from;
+            inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
+        }
+        return new LineCursor(inner);
+    }
+    /**
+    Return the document as a string, using newline characters to
+    separate lines.
+    */
+    toString() { return this.sliceString(0); }
+    /**
+    Convert the document to an array of lines (which can be
+    deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
+    */
+    toJSON() {
+        let lines = [];
+        this.flatten(lines);
+        return lines;
+    }
+    /**
+    @internal
+    */
+    constructor() { }
+    /**
+    Create a `Text` instance for the given array of lines.
+    */
+    static of(text) {
+        if (text.length == 0)
+            throw new RangeError("A document must have at least one line");
+        if (text.length == 1 && !text[0])
+            return Text.empty;
+        return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
+    }
+}
+// Leaves store an array of line strings. There are always line breaks
+// between these strings. Leaves are limited in size and have to be
+// contained in TextNode instances for bigger documents.
+class TextLeaf extends Text {
+    constructor(text, length = textLength(text)) {
+        super();
+        this.text = text;
+        this.length = length;
+    }
+    get lines() { return this.text.length; }
+    get children() { return null; }
+    lineInner(target, isLine, line, offset) {
+        for (let i = 0;; i++) {
+            let string = this.text[i], end = offset + string.length;
+            if ((isLine ? line : end) >= target)
+                return new Line(offset, end, line, string);
+            offset = end + 1;
+            line++;
+        }
+    }
+    decompose(from, to, target, open) {
+        let text = from <= 0 && to >= this.length ? this
+            : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
+        if (open & 1 /* Open.From */) {
+            let prev = target.pop();
+            let joined = appendText(text.text, prev.text.slice(), 0, text.length);
+            if (joined.length <= 32 /* Tree.Branch */) {
+                target.push(new TextLeaf(joined, prev.length + text.length));
+            }
+            else {
+                let mid = joined.length >> 1;
+                target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
+            }
+        }
+        else {
+            target.push(text);
+        }
+    }
+    replace(from, to, text) {
+        if (!(text instanceof TextLeaf))
+            return super.replace(from, to, text);
+        [from, to] = clip(this, from, to);
+        let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
+        let newLen = this.length + text.length - (to - from);
+        if (lines.length <= 32 /* Tree.Branch */)
+            return new TextLeaf(lines, newLen);
+        return TextNode.from(TextLeaf.split(lines, []), newLen);
+    }
+    sliceString(from, to = this.length, lineSep = "\n") {
+        [from, to] = clip(this, from, to);
+        let result = "";
+        for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
+            let line = this.text[i], end = pos + line.length;
+            if (pos > from && i)
+                result += lineSep;
+            if (from < end && to > pos)
+                result += line.slice(Math.max(0, from - pos), to - pos);
+            pos = end + 1;
+        }
+        return result;
+    }
+    flatten(target) {
+        for (let line of this.text)
+            target.push(line);
+    }
+    scanIdentical() { return 0; }
+    static split(text, target) {
+        let part = [], len = -1;
+        for (let line of text) {
+            part.push(line);
+            len += line.length + 1;
+            if (part.length == 32 /* Tree.Branch */) {
+                target.push(new TextLeaf(part, len));
+                part = [];
+                len = -1;
+            }
+        }
+        if (len > -1)
+            target.push(new TextLeaf(part, len));
+        return target;
+    }
+}
+// Nodes provide the tree structure of the `Text` type. They store a
+// number of other nodes or leaves, taking care to balance themselves
+// on changes. There are implied line breaks _between_ the children of
+// a node (but not before the first or after the last child).
+class TextNode extends Text {
+    constructor(children, length) {
+        super();
+        this.children = children;
+        this.length = length;
+        this.lines = 0;
+        for (let child of children)
+            this.lines += child.lines;
+    }
+    lineInner(target, isLine, line, offset) {
+        for (let i = 0;; i++) {
+            let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
+            if ((isLine ? endLine : end) >= target)
+                return child.lineInner(target, isLine, line, offset);
+            offset = end + 1;
+            line = endLine + 1;
+        }
+    }
+    decompose(from, to, target, open) {
+        for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
+            let child = this.children[i], end = pos + child.length;
+            if (from <= end && to >= pos) {
+                let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));
+                if (pos >= from && end <= to && !childOpen)
+                    target.push(child);
+                else
+                    child.decompose(from - pos, to - pos, target, childOpen);
+            }
+            pos = end + 1;
+        }
+    }
+    replace(from, to, text) {
+        [from, to] = clip(this, from, to);
+        if (text.lines < this.lines)
+            for (let i = 0, pos = 0; i < this.children.length; i++) {
+                let child = this.children[i], end = pos + child.length;
+                // Fast path: if the change only affects one child and the
+                // child's size remains in the acceptable range, only update
+                // that child
+                if (from >= pos && to <= end) {
+                    let updated = child.replace(from - pos, to - pos, text);
+                    let totalLines = this.lines - child.lines + updated.lines;
+                    if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&
+                        updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {
+                        let copy = this.children.slice();
+                        copy[i] = updated;
+                        return new TextNode(copy, this.length - (to - from) + text.length);
+                    }
+                    return super.replace(pos, end, updated);
+                }
+                pos = end + 1;
+            }
+        return super.replace(from, to, text);
+    }
+    sliceString(from, to = this.length, lineSep = "\n") {
+        [from, to] = clip(this, from, to);
+        let result = "";
+        for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
+            let child = this.children[i], end = pos + child.length;
+            if (pos > from && i)
+                result += lineSep;
+            if (from < end && to > pos)
+                result += child.sliceString(from - pos, to - pos, lineSep);
+            pos = end + 1;
+        }
+        return result;
+    }
+    flatten(target) {
+        for (let child of this.children)
+            child.flatten(target);
+    }
+    scanIdentical(other, dir) {
+        if (!(other instanceof TextNode))
+            return 0;
+        let length = 0;
+        let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
+            : [this.children.length - 1, other.children.length - 1, -1, -1];
+        for (;; iA += dir, iB += dir) {
+            if (iA == eA || iB == eB)
+                return length;
+            let chA = this.children[iA], chB = other.children[iB];
+            if (chA != chB)
+                return length + chA.scanIdentical(chB, dir);
+            length += chA.length + 1;
+        }
+    }
+    static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
+        let lines = 0;
+        for (let ch of children)
+            lines += ch.lines;
+        if (lines < 32 /* Tree.Branch */) {
+            let flat = [];
+            for (let ch of children)
+                ch.flatten(flat);
+            return new TextLeaf(flat, length);
+        }
+        let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
+        let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
+        function add(child) {
+            let last;
+            if (child.lines > maxChunk && child instanceof TextNode) {
+                for (let node of child.children)
+                    add(node);
+            }
+            else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
+                flush();
+                chunked.push(child);
+            }
+            else if (child instanceof TextLeaf && currentLines &&
+                (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&
+                child.lines + last.lines <= 32 /* Tree.Branch */) {
+                currentLines += child.lines;
+                currentLen += child.length + 1;
+                currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
+            }
+            else {
+                if (currentLines + child.lines > chunk)
+                    flush();
+                currentLines += child.lines;
+                currentLen += child.length + 1;
+                currentChunk.push(child);
+            }
+        }
+        function flush() {
+            if (currentLines == 0)
+                return;
+            chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
+            currentLen = -1;
+            currentLines = currentChunk.length = 0;
+        }
+        for (let child of children)
+            add(child);
+        flush();
+        return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
+    }
+}
+Text.empty = /*@__PURE__*/new TextLeaf([""], 0);
+function textLength(text) {
+    let length = -1;
+    for (let line of text)
+        length += line.length + 1;
+    return length;
+}
+function appendText(text, target, from = 0, to = 1e9) {
+    for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
+        let line = text[i], end = pos + line.length;
+        if (end >= from) {
+            if (end > to)
+                line = line.slice(0, to - pos);
+            if (pos < from)
+                line = line.slice(from - pos);
+            if (first) {
+                target[target.length - 1] += line;
+                first = false;
+            }
+            else
+                target.push(line);
+        }
+        pos = end + 1;
+    }
+    return target;
+}
+function sliceText(text, from, to) {
+    return appendText(text, [""], from, to);
+}
+class RawTextCursor {
+    constructor(text, dir = 1) {
+        this.dir = dir;
+        this.done = false;
+        this.lineBreak = false;
+        this.value = "";
+        this.nodes = [text];
+        this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];
+    }
+    nextInner(skip, dir) {
+        this.done = this.lineBreak = false;
+        for (;;) {
+            let last = this.nodes.length - 1;
+            let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
+            let size = top instanceof TextLeaf ? top.text.length : top.children.length;
+            if (offset == (dir > 0 ? size : 0)) {
+                if (last == 0) {
+                    this.done = true;
+                    this.value = "";
+                    return this;
+                }
+                if (dir > 0)
+                    this.offsets[last - 1]++;
+                this.nodes.pop();
+                this.offsets.pop();
+            }
+            else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
+                this.offsets[last] += dir;
+                if (skip == 0) {
+                    this.lineBreak = true;
+                    this.value = "\n";
+                    return this;
+                }
+                skip--;
+            }
+            else if (top instanceof TextLeaf) {
+                // Move to the next string
+                let next = top.text[offset + (dir < 0 ? -1 : 0)];
+                this.offsets[last] += dir;
+                if (next.length > Math.max(0, skip)) {
+                    this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
+                    return this;
+                }
+                skip -= next.length;
+            }
+            else {
+                let next = top.children[offset + (dir < 0 ? -1 : 0)];
+                if (skip > next.length) {
+                    skip -= next.length;
+                    this.offsets[last] += dir;
+                }
+                else {
+                    if (dir < 0)
+                        this.offsets[last]--;
+                    this.nodes.push(next);
+                    this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);
+                }
+            }
+        }
+    }
+    next(skip = 0) {
+        if (skip < 0) {
+            this.nextInner(-skip, (-this.dir));
+            skip = this.value.length;
+        }
+        return this.nextInner(skip, this.dir);
+    }
+}
+class PartialTextCursor {
+    constructor(text, start, end) {
+        this.value = "";
+        this.done = false;
+        this.cursor = new RawTextCursor(text, start > end ? -1 : 1);
+        this.pos = start > end ? text.length : 0;
+        this.from = Math.min(start, end);
+        this.to = Math.max(start, end);
+    }
+    nextInner(skip, dir) {
+        if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
+            this.value = "";
+            this.done = true;
+            return this;
+        }
+        skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
+        let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
+        if (skip > limit)
+            skip = limit;
+        limit -= skip;
+        let { value } = this.cursor.next(skip);
+        this.pos += (value.length + skip) * dir;
+        this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
+        this.done = !this.value;
+        return this;
+    }
+    next(skip = 0) {
+        if (skip < 0)
+            skip = Math.max(skip, this.from - this.pos);
+        else if (skip > 0)
+            skip = Math.min(skip, this.to - this.pos);
+        return this.nextInner(skip, this.cursor.dir);
+    }
+    get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
+}
+class LineCursor {
+    constructor(inner) {
+        this.inner = inner;
+        this.afterBreak = true;
+        this.value = "";
+        this.done = false;
+    }
+    next(skip = 0) {
+        let { done, lineBreak, value } = this.inner.next(skip);
+        if (done && this.afterBreak) {
+            this.value = "";
+            this.afterBreak = false;
+        }
+        else if (done) {
+            this.done = true;
+            this.value = "";
+        }
+        else if (lineBreak) {
+            if (this.afterBreak) {
+                this.value = "";
+            }
+            else {
+                this.afterBreak = true;
+                this.next();
+            }
+        }
+        else {
+            this.value = value;
+            this.afterBreak = false;
+        }
+        return this;
+    }
+    get lineBreak() { return false; }
+}
+if (typeof Symbol != "undefined") {
+    Text.prototype[Symbol.iterator] = function () { return this.iter(); };
+    RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =
+        LineCursor.prototype[Symbol.iterator] = function () { return this; };
+}
+/**
+This type describes a line in the document. It is created
+on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
+*/
+class Line {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    The position of the start of the line.
+    */
+    from, 
+    /**
+    The position at the end of the line (_before_ the line break,
+    or at the end of document for the last line).
+    */
+    to, 
+    /**
+    This line's line number (1-based).
+    */
+    number, 
+    /**
+    The line's content.
+    */
+    text) {
+        this.from = from;
+        this.to = to;
+        this.number = number;
+        this.text = text;
+    }
+    /**
+    The length of the line (not including any line break after it).
+    */
+    get length() { return this.to - this.from; }
+}
+function clip(text, from, to) {
+    from = Math.max(0, Math.min(text.length, from));
+    return [from, Math.max(from, Math.min(text.length, to))];
+}
+
+/**
+Returns a next grapheme cluster break _after_ (not equal to)
+`pos`, if `forward` is true, or before otherwise. Returns `pos`
+itself if no further cluster break is available in the string.
+Moves across surrogate pairs, extending characters (when
+`includeExtending` is true), characters joined with zero-width
+joiners, and flag emoji.
+*/
+function findClusterBreak(str, pos, forward = true, includeExtending = true) {
+    return findClusterBreak$1(str, pos, forward, includeExtending);
+}
+function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000; }
+function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00; }
+/**
+Find the code point at the given position in a string (like the
+[`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
+string method).
+*/
+function codePointAt(str, pos) {
+    let code0 = str.charCodeAt(pos);
+    if (!surrogateHigh(code0) || pos + 1 == str.length)
+        return code0;
+    let code1 = str.charCodeAt(pos + 1);
+    if (!surrogateLow(code1))
+        return code0;
+    return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
+}
+/**
+Given a Unicode codepoint, return the JavaScript string that
+respresents it (like
+[`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
+*/
+function fromCodePoint(code) {
+    if (code <= 0xffff)
+        return String.fromCharCode(code);
+    code -= 0x10000;
+    return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
+}
+/**
+The amount of positions a character takes up in a JavaScript string.
+*/
+function codePointSize(code) { return code < 0x10000 ? 1 : 2; }
+
+const DefaultSplit = /\r\n?|\n/;
+/**
+Distinguishes different ways in which positions can be mapped.
+*/
+var MapMode = /*@__PURE__*/(function (MapMode) {
+    /**
+    Map a position to a valid new position, even when its context
+    was deleted.
+    */
+    MapMode[MapMode["Simple"] = 0] = "Simple";
+    /**
+    Return null if deletion happens across the position.
+    */
+    MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
+    /**
+    Return null if the character _before_ the position is deleted.
+    */
+    MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
+    /**
+    Return null if the character _after_ the position is deleted.
+    */
+    MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
+return MapMode})(MapMode || (MapMode = {}));
+/**
+A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
+that doesn't store the inserted text. As such, it can't be
+applied, but is cheaper to store and manipulate.
+*/
+class ChangeDesc {
+    // Sections are encoded as pairs of integers. The first is the
+    // length in the current document, and the second is -1 for
+    // unaffected sections, and the length of the replacement content
+    // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
+    // 0), and a replacement two positive numbers.
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    @internal
+    */
+    sections) {
+        this.sections = sections;
+    }
+    /**
+    The length of the document before the change.
+    */
+    get length() {
+        let result = 0;
+        for (let i = 0; i < this.sections.length; i += 2)
+            result += this.sections[i];
+        return result;
+    }
+    /**
+    The length of the document after the change.
+    */
+    get newLength() {
+        let result = 0;
+        for (let i = 0; i < this.sections.length; i += 2) {
+            let ins = this.sections[i + 1];
+            result += ins < 0 ? this.sections[i] : ins;
+        }
+        return result;
+    }
+    /**
+    False when there are actual changes in this set.
+    */
+    get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
+    /**
+    Iterate over the unchanged parts left by these changes. `posA`
+    provides the position of the range in the old document, `posB`
+    the new position in the changed document.
+    */
+    iterGaps(f) {
+        for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
+            let len = this.sections[i++], ins = this.sections[i++];
+            if (ins < 0) {
+                f(posA, posB, len);
+                posB += len;
+            }
+            else {
+                posB += ins;
+            }
+            posA += len;
+        }
+    }
+    /**
+    Iterate over the ranges changed by these changes. (See
+    [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
+    variant that also provides you with the inserted text.)
+    `fromA`/`toA` provides the extent of the change in the starting
+    document, `fromB`/`toB` the extent of the replacement in the
+    changed document.
+    
+    When `individual` is true, adjacent changes (which are kept
+    separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
+    reported separately.
+    */
+    iterChangedRanges(f, individual = false) {
+        iterChanges(this, f, individual);
+    }
+    /**
+    Get a description of the inverted form of these changes.
+    */
+    get invertedDesc() {
+        let sections = [];
+        for (let i = 0; i < this.sections.length;) {
+            let len = this.sections[i++], ins = this.sections[i++];
+            if (ins < 0)
+                sections.push(len, ins);
+            else
+                sections.push(ins, len);
+        }
+        return new ChangeDesc(sections);
+    }
+    /**
+    Compute the combined effect of applying another set of changes
+    after this one. The length of the document after this set should
+    match the length before `other`.
+    */
+    composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets(this, other); }
+    /**
+    Map this description, which should start with the same document
+    as `other`, over another set of changes, so that it can be
+    applied after it. When `before` is true, map as if the changes
+    in `this` happened before the ones in `other`.
+    */
+    mapDesc(other, before = false) { return other.empty ? this : mapSet(this, other, before); }
+    mapPos(pos, assoc = -1, mode = MapMode.Simple) {
+        let posA = 0, posB = 0;
+        for (let i = 0; i < this.sections.length;) {
+            let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
+            if (ins < 0) {
+                if (endA > pos)
+                    return posB + (pos - posA);
+                posB += len;
+            }
+            else {
+                if (mode != MapMode.Simple && endA >= pos &&
+                    (mode == MapMode.TrackDel && posA < pos && endA > pos ||
+                        mode == MapMode.TrackBefore && posA < pos ||
+                        mode == MapMode.TrackAfter && endA > pos))
+                    return null;
+                if (endA > pos || endA == pos && assoc < 0 && !len)
+                    return pos == posA || assoc < 0 ? posB : posB + ins;
+                posB += ins;
+            }
+            posA = endA;
+        }
+        if (pos > posA)
+            throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
+        return posB;
+    }
+    /**
+    Check whether these changes touch a given range. When one of the
+    changes entirely covers the range, the string `"cover"` is
+    returned.
+    */
+    touchesRange(from, to = from) {
+        for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
+            let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
+            if (ins >= 0 && pos <= to && end >= from)
+                return pos < from && end > to ? "cover" : true;
+            pos = end;
+        }
+        return false;
+    }
+    /**
+    @internal
+    */
+    toString() {
+        let result = "";
+        for (let i = 0; i < this.sections.length;) {
+            let len = this.sections[i++], ins = this.sections[i++];
+            result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
+        }
+        return result;
+    }
+    /**
+    Serialize this change desc to a JSON-representable value.
+    */
+    toJSON() { return this.sections; }
+    /**
+    Create a change desc from its JSON representation (as produced
+    by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
+    */
+    static fromJSON(json) {
+        if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
+            throw new RangeError("Invalid JSON representation of ChangeDesc");
+        return new ChangeDesc(json);
+    }
+    /**
+    @internal
+    */
+    static create(sections) { return new ChangeDesc(sections); }
+}
+/**
+A change set represents a group of modifications to a document. It
+stores the document length, and can only be applied to documents
+with exactly that length.
+*/
+class ChangeSet extends ChangeDesc {
+    constructor(sections, 
+    /**
+    @internal
+    */
+    inserted) {
+        super(sections);
+        this.inserted = inserted;
+    }
+    /**
+    Apply the changes to a document, returning the modified
+    document.
+    */
+    apply(doc) {
+        if (this.length != doc.length)
+            throw new RangeError("Applying change set to a document with the wrong length");
+        iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
+        return doc;
+    }
+    mapDesc(other, before = false) { return mapSet(this, other, before, true); }
+    /**
+    Given the document as it existed _before_ the changes, return a
+    change set that represents the inverse of this set, which could
+    be used to go from the document created by the changes back to
+    the document as it existed before the changes.
+    */
+    invert(doc) {
+        let sections = this.sections.slice(), inserted = [];
+        for (let i = 0, pos = 0; i < sections.length; i += 2) {
+            let len = sections[i], ins = sections[i + 1];
+            if (ins >= 0) {
+                sections[i] = ins;
+                sections[i + 1] = len;
+                let index = i >> 1;
+                while (inserted.length < index)
+                    inserted.push(Text.empty);
+                inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);
+            }
+            pos += len;
+        }
+        return new ChangeSet(sections, inserted);
+    }
+    /**
+    Combine two subsequent change sets into a single set. `other`
+    must start in the document produced by `this`. If `this` goes
+    `docA` → `docB` and `other` represents `docB` → `docC`, the
+    returned value will represent the change `docA` → `docC`.
+    */
+    compose(other) { return this.empty ? other : other.empty ? this : composeSets(this, other, true); }
+    /**
+    Given another change set starting in the same document, maps this
+    change set over the other, producing a new change set that can be
+    applied to the document produced by applying `other`. When
+    `before` is `true`, order changes as if `this` comes before
+    `other`, otherwise (the default) treat `other` as coming first.
+    
+    Given two changes `A` and `B`, `A.compose(B.map(A))` and
+    `B.compose(A.map(B, true))` will produce the same document. This
+    provides a basic form of [operational
+    transformation](https://en.wikipedia.org/wiki/Operational_transformation),
+    and can be used for collaborative editing.
+    */
+    map(other, before = false) { return other.empty ? this : mapSet(this, other, before, true); }
+    /**
+    Iterate over the changed ranges in the document, calling `f` for
+    each, with the range in the original document (`fromA`-`toA`)
+    and the range that replaces it in the new document
+    (`fromB`-`toB`).
+    
+    When `individual` is true, adjacent changes are reported
+    separately.
+    */
+    iterChanges(f, individual = false) {
+        iterChanges(this, f, individual);
+    }
+    /**
+    Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
+    set.
+    */
+    get desc() { return ChangeDesc.create(this.sections); }
+    /**
+    @internal
+    */
+    filter(ranges) {
+        let resultSections = [], resultInserted = [], filteredSections = [];
+        let iter = new SectionIter(this);
+        done: for (let i = 0, pos = 0;;) {
+            let next = i == ranges.length ? 1e9 : ranges[i++];
+            while (pos < next || pos == next && iter.len == 0) {
+                if (iter.done)
+                    break done;
+                let len = Math.min(iter.len, next - pos);
+                addSection(filteredSections, len, -1);
+                let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
+                addSection(resultSections, len, ins);
+                if (ins > 0)
+                    addInsert(resultInserted, resultSections, iter.text);
+                iter.forward(len);
+                pos += len;
+            }
+            let end = ranges[i++];
+            while (pos < end) {
+                if (iter.done)
+                    break done;
+                let len = Math.min(iter.len, end - pos);
+                addSection(resultSections, len, -1);
+                addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
+                iter.forward(len);
+                pos += len;
+            }
+        }
+        return { changes: new ChangeSet(resultSections, resultInserted),
+            filtered: ChangeDesc.create(filteredSections) };
+    }
+    /**
+    Serialize this change set to a JSON-representable value.
+    */
+    toJSON() {
+        let parts = [];
+        for (let i = 0; i < this.sections.length; i += 2) {
+            let len = this.sections[i], ins = this.sections[i + 1];
+            if (ins < 0)
+                parts.push(len);
+            else if (ins == 0)
+                parts.push([len]);
+            else
+                parts.push([len].concat(this.inserted[i >> 1].toJSON()));
+        }
+        return parts;
+    }
+    /**
+    Create a change set for the given changes, for a document of the
+    given length, using `lineSep` as line separator.
+    */
+    static of(changes, length, lineSep) {
+        let sections = [], inserted = [], pos = 0;
+        let total = null;
+        function flush(force = false) {
+            if (!force && !sections.length)
+                return;
+            if (pos < length)
+                addSection(sections, length - pos, -1);
+            let set = new ChangeSet(sections, inserted);
+            total = total ? total.compose(set.map(total)) : set;
+            sections = [];
+            inserted = [];
+            pos = 0;
+        }
+        function process(spec) {
+            if (Array.isArray(spec)) {
+                for (let sub of spec)
+                    process(sub);
+            }
+            else if (spec instanceof ChangeSet) {
+                if (spec.length != length)
+                    throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
+                flush();
+                total = total ? total.compose(spec.map(total)) : spec;
+            }
+            else {
+                let { from, to = from, insert } = spec;
+                if (from > to || from < 0 || to > length)
+                    throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
+                let insText = !insert ? Text.empty : typeof insert == "string" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;
+                let insLen = insText.length;
+                if (from == to && insLen == 0)
+                    return;
+                if (from < pos)
+                    flush();
+                if (from > pos)
+                    addSection(sections, from - pos, -1);
+                addSection(sections, to - from, insLen);
+                addInsert(inserted, sections, insText);
+                pos = to;
+            }
+        }
+        process(changes);
+        flush(!total);
+        return total;
+    }
+    /**
+    Create an empty changeset of the given length.
+    */
+    static empty(length) {
+        return new ChangeSet(length ? [length, -1] : [], []);
+    }
+    /**
+    Create a changeset from its JSON representation (as produced by
+    [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
+    */
+    static fromJSON(json) {
+        if (!Array.isArray(json))
+            throw new RangeError("Invalid JSON representation of ChangeSet");
+        let sections = [], inserted = [];
+        for (let i = 0; i < json.length; i++) {
+            let part = json[i];
+            if (typeof part == "number") {
+                sections.push(part, -1);
+            }
+            else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
+                throw new RangeError("Invalid JSON representation of ChangeSet");
+            }
+            else if (part.length == 1) {
+                sections.push(part[0], 0);
+            }
+            else {
+                while (inserted.length < i)
+                    inserted.push(Text.empty);
+                inserted[i] = Text.of(part.slice(1));
+                sections.push(part[0], inserted[i].length);
+            }
+        }
+        return new ChangeSet(sections, inserted);
+    }
+    /**
+    @internal
+    */
+    static createSet(sections, inserted) {
+        return new ChangeSet(sections, inserted);
+    }
+}
+function addSection(sections, len, ins, forceJoin = false) {
+    if (len == 0 && ins <= 0)
+        return;
+    let last = sections.length - 2;
+    if (last >= 0 && ins <= 0 && ins == sections[last + 1])
+        sections[last] += len;
+    else if (last >= 0 && len == 0 && sections[last] == 0)
+        sections[last + 1] += ins;
+    else if (forceJoin) {
+        sections[last] += len;
+        sections[last + 1] += ins;
+    }
+    else
+        sections.push(len, ins);
+}
+function addInsert(values, sections, value) {
+    if (value.length == 0)
+        return;
+    let index = (sections.length - 2) >> 1;
+    if (index < values.length) {
+        values[values.length - 1] = values[values.length - 1].append(value);
+    }
+    else {
+        while (values.length < index)
+            values.push(Text.empty);
+        values.push(value);
+    }
+}
+function iterChanges(desc, f, individual) {
+    let inserted = desc.inserted;
+    for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
+        let len = desc.sections[i++], ins = desc.sections[i++];
+        if (ins < 0) {
+            posA += len;
+            posB += len;
+        }
+        else {
+            let endA = posA, endB = posB, text = Text.empty;
+            for (;;) {
+                endA += len;
+                endB += ins;
+                if (ins && inserted)
+                    text = text.append(inserted[(i - 2) >> 1]);
+                if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
+                    break;
+                len = desc.sections[i++];
+                ins = desc.sections[i++];
+            }
+            f(posA, endA, posB, endB, text);
+            posA = endA;
+            posB = endB;
+        }
+    }
+}
+function mapSet(setA, setB, before, mkSet = false) {
+    // Produce a copy of setA that applies to the document after setB
+    // has been applied (assuming both start at the same document).
+    let sections = [], insert = mkSet ? [] : null;
+    let a = new SectionIter(setA), b = new SectionIter(setB);
+    // Iterate over both sets in parallel. inserted tracks, for changes
+    // in A that have to be processed piece-by-piece, whether their
+    // content has been inserted already, and refers to the section
+    // index.
+    for (let inserted = -1;;) {
+        if (a.done && b.len || b.done && a.len) {
+            throw new Error("Mismatched change set lengths");
+        }
+        else if (a.ins == -1 && b.ins == -1) {
+            // Move across ranges skipped by both sets.
+            let len = Math.min(a.len, b.len);
+            addSection(sections, len, -1);
+            a.forward(len);
+            b.forward(len);
+        }
+        else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {
+            // If there's a change in B that comes before the next change in
+            // A (ordered by start pos, then len, then before flag), skip
+            // that (and process any changes in A it covers).
+            let len = b.len;
+            addSection(sections, b.ins, -1);
+            while (len) {
+                let piece = Math.min(a.len, len);
+                if (a.ins >= 0 && inserted < a.i && a.len <= piece) {
+                    addSection(sections, 0, a.ins);
+                    if (insert)
+                        addInsert(insert, sections, a.text);
+                    inserted = a.i;
+                }
+                a.forward(piece);
+                len -= piece;
+            }
+            b.next();
+        }
+        else if (a.ins >= 0) {
+            // Process the part of a change in A up to the start of the next
+            // non-deletion change in B (if overlapping).
+            let len = 0, left = a.len;
+            while (left) {
+                if (b.ins == -1) {
+                    let piece = Math.min(left, b.len);
+                    len += piece;
+                    left -= piece;
+                    b.forward(piece);
+                }
+                else if (b.ins == 0 && b.len < left) {
+                    left -= b.len;
+                    b.next();
+                }
+                else {
+                    break;
+                }
+            }
+            addSection(sections, len, inserted < a.i ? a.ins : 0);
+            if (insert && inserted < a.i)
+                addInsert(insert, sections, a.text);
+            inserted = a.i;
+            a.forward(a.len - left);
+        }
+        else if (a.done && b.done) {
+            return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
+        }
+        else {
+            throw new Error("Mismatched change set lengths");
+        }
+    }
+}
+function composeSets(setA, setB, mkSet = false) {
+    let sections = [];
+    let insert = mkSet ? [] : null;
+    let a = new SectionIter(setA), b = new SectionIter(setB);
+    for (let open = false;;) {
+        if (a.done && b.done) {
+            return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
+        }
+        else if (a.ins == 0) { // Deletion in A
+            addSection(sections, a.len, 0, open);
+            a.next();
+        }
+        else if (b.len == 0 && !b.done) { // Insertion in B
+            addSection(sections, 0, b.ins, open);
+            if (insert)
+                addInsert(insert, sections, b.text);
+            b.next();
+        }
+        else if (a.done || b.done) {
+            throw new Error("Mismatched change set lengths");
+        }
+        else {
+            let len = Math.min(a.len2, b.len), sectionLen = sections.length;
+            if (a.ins == -1) {
+                let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
+                addSection(sections, len, insB, open);
+                if (insert && insB)
+                    addInsert(insert, sections, b.text);
+            }
+            else if (b.ins == -1) {
+                addSection(sections, a.off ? 0 : a.len, len, open);
+                if (insert)
+                    addInsert(insert, sections, a.textBit(len));
+            }
+            else {
+                addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
+                if (insert && !b.off)
+                    addInsert(insert, sections, b.text);
+            }
+            open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
+            a.forward2(len);
+            b.forward(len);
+        }
+    }
+}
+class SectionIter {
+    constructor(set) {
+        this.set = set;
+        this.i = 0;
+        this.next();
+    }
+    next() {
+        let { sections } = this.set;
+        if (this.i < sections.length) {
+            this.len = sections[this.i++];
+            this.ins = sections[this.i++];
+        }
+        else {
+            this.len = 0;
+            this.ins = -2;
+        }
+        this.off = 0;
+    }
+    get done() { return this.ins == -2; }
+    get len2() { return this.ins < 0 ? this.len : this.ins; }
+    get text() {
+        let { inserted } = this.set, index = (this.i - 2) >> 1;
+        return index >= inserted.length ? Text.empty : inserted[index];
+    }
+    textBit(len) {
+        let { inserted } = this.set, index = (this.i - 2) >> 1;
+        return index >= inserted.length && !len ? Text.empty
+            : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
+    }
+    forward(len) {
+        if (len == this.len)
+            this.next();
+        else {
+            this.len -= len;
+            this.off += len;
+        }
+    }
+    forward2(len) {
+        if (this.ins == -1)
+            this.forward(len);
+        else if (len == this.ins)
+            this.next();
+        else {
+            this.ins -= len;
+            this.off += len;
+        }
+    }
+}
+
+/**
+A single selection range. When
+[`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
+is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
+multiple ranges. By default, selections hold exactly one range.
+*/
+class SelectionRange {
+    constructor(
+    /**
+    The lower boundary of the range.
+    */
+    from, 
+    /**
+    The upper boundary of the range.
+    */
+    to, flags) {
+        this.from = from;
+        this.to = to;
+        this.flags = flags;
+    }
+    /**
+    The anchor of the range—the side that doesn't move when you
+    extend it.
+    */
+    get anchor() { return this.flags & 32 /* RangeFlag.Inverted */ ? 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 /* RangeFlag.Inverted */ ? 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 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 16 /* RangeFlag.AssocAfter */ ? 1 : 0; }
+    /**
+    The bidirectional text level associated with this cursor, if
+    any.
+    */
+    get bidiLevel() {
+        let level = this.flags & 7 /* RangeFlag.BidiLevelMask */;
+        return level == 7 ? null : level;
+    }
+    /**
+    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 value = this.flags >> 6 /* RangeFlag.GoalColumnOffset */;
+        return value == 16777215 /* RangeFlag.NoGoalColumn */ ? undefined : value;
+    }
+    /**
+    Map this range through a change, producing a valid range in the
+    updated document.
+    */
+    map(change, assoc = -1) {
+        let from, to;
+        if (this.empty) {
+            from = to = change.mapPos(this.from, assoc);
+        }
+        else {
+            from = change.mapPos(this.from, 1);
+            to = change.mapPos(this.to, -1);
+        }
+        return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
+    }
+    /**
+    Extend this range to cover at least `from` to `to`.
+    */
+    extend(from, to = from) {
+        if (from <= this.anchor && to >= this.anchor)
+            return EditorSelection.range(from, to);
+        let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
+        return EditorSelection.range(this.anchor, head);
+    }
+    /**
+    Compare this range to another range.
+    */
+    eq(other, includeAssoc = false) {
+        return this.anchor == other.anchor && this.head == other.head &&
+            (!includeAssoc || !this.empty || this.assoc == other.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(json) {
+        if (!json || typeof json.anchor != "number" || typeof json.head != "number")
+            throw new RangeError("Invalid JSON representation for SelectionRange");
+        return EditorSelection.range(json.anchor, json.head);
+    }
+    /**
+    @internal
+    */
+    static create(from, to, flags) {
+        return new SelectionRange(from, to, flags);
+    }
+}
+/**
+An editor selection holds one or more selection ranges.
+*/
+class EditorSelection {
+    constructor(
+    /**
+    The ranges in the selection, sorted by position. Ranges cannot
+    overlap (but they may touch, if they aren't empty).
+    */
+    ranges, 
+    /**
+    The index of the _main_ range in the selection (which is
+    usually the range that was added last).
+    */
+    mainIndex) {
+        this.ranges = ranges;
+        this.mainIndex = mainIndex;
+    }
+    /**
+    Map a selection through a change. Used to adjust the selection
+    position for changes.
+    */
+    map(change, assoc = -1) {
+        if (change.empty)
+            return this;
+        return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), 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(other, includeAssoc = false) {
+        if (this.ranges.length != other.ranges.length ||
+            this.mainIndex != other.mainIndex)
+            return false;
+        for (let i = 0; i < this.ranges.length; i++)
+            if (!this.ranges[i].eq(other.ranges[i], includeAssoc))
+                return false;
+        return true;
+    }
+    /**
+    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 EditorSelection([this.main], 0);
+    }
+    /**
+    Extend this selection with an extra range.
+    */
+    addRange(range, main = true) {
+        return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
+    }
+    /**
+    Replace a given range with another range, and then normalize the
+    selection to merge and sort ranges if necessary.
+    */
+    replaceRange(range, which = this.mainIndex) {
+        let ranges = this.ranges.slice();
+        ranges[which] = range;
+        return EditorSelection.create(ranges, this.mainIndex);
+    }
+    /**
+    Convert this selection to an object that can be serialized to
+    JSON.
+    */
+    toJSON() {
+        return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
+    }
+    /**
+    Create a selection from a JSON representation.
+    */
+    static fromJSON(json) {
+        if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
+            throw new RangeError("Invalid JSON representation for EditorSelection");
+        return new EditorSelection(json.ranges.map((r) => SelectionRange.fromJSON(r)), json.main);
+    }
+    /**
+    Create a selection holding a single range.
+    */
+    static single(anchor, head = anchor) {
+        return new EditorSelection([EditorSelection.range(anchor, head)], 0);
+    }
+    /**
+    Sort and merge the given set of ranges, creating a valid
+    selection.
+    */
+    static create(ranges, mainIndex = 0) {
+        if (ranges.length == 0)
+            throw new RangeError("A selection needs at least one range");
+        for (let pos = 0, i = 0; i < ranges.length; i++) {
+            let range = ranges[i];
+            if (range.empty ? range.from <= pos : range.from < pos)
+                return EditorSelection.normalized(ranges.slice(), mainIndex);
+            pos = range.to;
+        }
+        return new EditorSelection(ranges, mainIndex);
+    }
+    /**
+    Create a cursor selection range at the given position. You can
+    safely ignore the optional arguments in most situations.
+    */
+    static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
+        return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */) |
+            (bidiLevel == null ? 7 : Math.min(6, bidiLevel)) |
+            ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */));
+    }
+    /**
+    Create a selection range.
+    */
+    static range(anchor, head, goalColumn, bidiLevel) {
+        let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */) |
+            (bidiLevel == null ? 7 : Math.min(6, bidiLevel));
+        return head < anchor ? SelectionRange.create(head, anchor, 32 /* RangeFlag.Inverted */ | 16 /* RangeFlag.AssocAfter */ | flags)
+            : SelectionRange.create(anchor, head, (head > anchor ? 8 /* RangeFlag.AssocBefore */ : 0) | flags);
+    }
+    /**
+    @internal
+    */
+    static normalized(ranges, mainIndex = 0) {
+        let main = ranges[mainIndex];
+        ranges.sort((a, b) => a.from - b.from);
+        mainIndex = ranges.indexOf(main);
+        for (let i = 1; i < ranges.length; i++) {
+            let range = ranges[i], prev = ranges[i - 1];
+            if (range.empty ? range.from <= prev.to : range.from < prev.to) {
+                let from = prev.from, to = Math.max(range.to, prev.to);
+                if (i <= mainIndex)
+                    mainIndex--;
+                ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
+            }
+        }
+        return new EditorSelection(ranges, mainIndex);
+    }
+}
+function checkSelection(selection, docLength) {
+    for (let range of selection.ranges)
+        if (range.to > docLength)
+            throw new RangeError("Selection points outside of document");
+}
+
+let nextID = 0;
+/**
+A facet is a labeled value that is associated with an editor
+state. It takes inputs from any number of extensions, and combines
+those into a single output value.
+
+Examples of uses of facets are the [tab
+size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
+attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
+listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
+
+Note that `Facet` instances can be used anywhere where
+[`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.
+*/
+class Facet {
+    constructor(
+    /**
+    @internal
+    */
+    combine, 
+    /**
+    @internal
+    */
+    compareInput, 
+    /**
+    @internal
+    */
+    compare, isStatic, enables) {
+        this.combine = combine;
+        this.compareInput = compareInput;
+        this.compare = compare;
+        this.isStatic = isStatic;
+        /**
+        @internal
+        */
+        this.id = nextID++;
+        this.default = combine([]);
+        this.extensions = typeof enables == "function" ? enables(this) : enables;
+    }
+    /**
+    Returns a facet reader for this facet, which can be used to
+    [read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
+    */
+    get reader() { return this; }
+    /**
+    Define a new facet.
+    */
+    static define(config = {}) {
+        return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$1 : (a, b) => a === b), !!config.static, config.enables);
+    }
+    /**
+    Returns an extension that adds the given value to this facet.
+    */
+    of(value) {
+        return new FacetProvider([], this, 0 /* Provider.Static */, value);
+    }
+    /**
+    Create an extension that computes a value for the facet from a
+    state. You must take care to declare the parts of the state that
+    this value depends on, since your function is only called again
+    for a new state when one of those parts changed.
+    
+    In cases where your value depends only on a single field, you'll
+    want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
+    */
+    compute(deps, get) {
+        if (this.isStatic)
+            throw new Error("Can't compute a static facet");
+        return new FacetProvider(deps, this, 1 /* Provider.Single */, get);
+    }
+    /**
+    Create an extension that computes zero or more values for this
+    facet from a state.
+    */
+    computeN(deps, get) {
+        if (this.isStatic)
+            throw new Error("Can't compute a static facet");
+        return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);
+    }
+    from(field, get) {
+        if (!get)
+            get = x => x;
+        return this.compute([field], state => get(state.field(field)));
+    }
+}
+function sameArray$1(a, b) {
+    return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
+}
+class FacetProvider {
+    constructor(dependencies, facet, type, value) {
+        this.dependencies = dependencies;
+        this.facet = facet;
+        this.type = type;
+        this.value = value;
+        this.id = nextID++;
+    }
+    dynamicSlot(addresses) {
+        var _a;
+        let getter = this.value;
+        let compare = this.facet.compareInput;
+        let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;
+        let depDoc = false, depSel = false, depAddrs = [];
+        for (let dep of this.dependencies) {
+            if (dep == "doc")
+                depDoc = true;
+            else if (dep == "selection")
+                depSel = true;
+            else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
+                depAddrs.push(addresses[dep.id]);
+        }
+        return {
+            create(state) {
+                state.values[idx] = getter(state);
+                return 1 /* SlotStatus.Changed */;
+            },
+            update(state, tr) {
+                if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {
+                    let newVal = getter(state);
+                    if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
+                        state.values[idx] = newVal;
+                        return 1 /* SlotStatus.Changed */;
+                    }
+                }
+                return 0;
+            },
+            reconfigure: (state, oldState) => {
+                let newVal, oldAddr = oldState.config.address[id];
+                if (oldAddr != null) {
+                    let oldVal = getAddr(oldState, oldAddr);
+                    if (this.dependencies.every(dep => {
+                        return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :
+                            dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
+                    }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {
+                        state.values[idx] = oldVal;
+                        return 0;
+                    }
+                }
+                else {
+                    newVal = getter(state);
+                }
+                state.values[idx] = newVal;
+                return 1 /* SlotStatus.Changed */;
+            }
+        };
+    }
+}
+function compareArray(a, b, compare) {
+    if (a.length != b.length)
+        return false;
+    for (let i = 0; i < a.length; i++)
+        if (!compare(a[i], b[i]))
+            return false;
+    return true;
+}
+function ensureAll(state, addrs) {
+    let changed = false;
+    for (let addr of addrs)
+        if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)
+            changed = true;
+    return changed;
+}
+function dynamicFacetSlot(addresses, facet, providers) {
+    let providerAddrs = providers.map(p => addresses[p.id]);
+    let providerTypes = providers.map(p => p.type);
+    let dynamic = providerAddrs.filter(p => !(p & 1));
+    let idx = addresses[facet.id] >> 1;
+    function get(state) {
+        let values = [];
+        for (let i = 0; i < providerAddrs.length; i++) {
+            let value = getAddr(state, providerAddrs[i]);
+            if (providerTypes[i] == 2 /* Provider.Multi */)
+                for (let val of value)
+                    values.push(val);
+            else
+                values.push(value);
+        }
+        return facet.combine(values);
+    }
+    return {
+        create(state) {
+            for (let addr of providerAddrs)
+                ensureAddr(state, addr);
+            state.values[idx] = get(state);
+            return 1 /* SlotStatus.Changed */;
+        },
+        update(state, tr) {
+            if (!ensureAll(state, dynamic))
+                return 0;
+            let value = get(state);
+            if (facet.compare(value, state.values[idx]))
+                return 0;
+            state.values[idx] = value;
+            return 1 /* SlotStatus.Changed */;
+        },
+        reconfigure(state, oldState) {
+            let depChanged = ensureAll(state, providerAddrs);
+            let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
+            if (oldProviders && !depChanged && sameArray$1(providers, oldProviders)) {
+                state.values[idx] = oldValue;
+                return 0;
+            }
+            let value = get(state);
+            if (facet.compare(value, oldValue)) {
+                state.values[idx] = oldValue;
+                return 0;
+            }
+            state.values[idx] = value;
+            return 1 /* SlotStatus.Changed */;
+        }
+    };
+}
+const initField = /*@__PURE__*/Facet.define({ static: true });
+/**
+Fields can store additional information in an editor state, and
+keep it in sync with the rest of the state.
+*/
+class StateField {
+    constructor(
+    /**
+    @internal
+    */
+    id, createF, updateF, compareF, 
+    /**
+    @internal
+    */
+    spec) {
+        this.id = id;
+        this.createF = createF;
+        this.updateF = updateF;
+        this.compareF = compareF;
+        this.spec = spec;
+        /**
+        @internal
+        */
+        this.provides = undefined;
+    }
+    /**
+    Define a state field.
+    */
+    static define(config) {
+        let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);
+        if (config.provide)
+            field.provides = config.provide(field);
+        return field;
+    }
+    create(state) {
+        let init = state.facet(initField).find(i => i.field == this);
+        return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
+    }
+    /**
+    @internal
+    */
+    slot(addresses) {
+        let idx = addresses[this.id] >> 1;
+        return {
+            create: (state) => {
+                state.values[idx] = this.create(state);
+                return 1 /* SlotStatus.Changed */;
+            },
+            update: (state, tr) => {
+                let oldVal = state.values[idx];
+                let value = this.updateF(oldVal, tr);
+                if (this.compareF(oldVal, value))
+                    return 0;
+                state.values[idx] = value;
+                return 1 /* SlotStatus.Changed */;
+            },
+            reconfigure: (state, oldState) => {
+                if (oldState.config.address[this.id] != null) {
+                    state.values[idx] = oldState.field(this);
+                    return 0;
+                }
+                state.values[idx] = this.create(state);
+                return 1 /* SlotStatus.Changed */;
+            }
+        };
+    }
+    /**
+    Returns an extension that enables this field and overrides the
+    way it is initialized. Can be useful when you need to provide a
+    non-default starting value for the field.
+    */
+    init(create) {
+        return [this, initField.of({ field: this, create })];
+    }
+    /**
+    State field instances can be used as
+    [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
+    given state.
+    */
+    get extension() { return this; }
+}
+const Prec_ = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
+function prec(value) {
+    return (ext) => new PrecExtension(ext, value);
+}
+/**
+By default extensions are registered in the order they are found
+in the flattened form of nested array that was provided.
+Individual extension values can be assigned a precedence to
+override this. Extensions that do not have a precedence set get
+the precedence of the nearest parent with a precedence, or
+[`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
+final ordering of extensions is determined by first sorting by
+precedence and then by order within each precedence.
+*/
+const Prec = {
+    /**
+    The highest precedence level, for extensions that should end up
+    near the start of the precedence ordering.
+    */
+    highest: /*@__PURE__*/prec(Prec_.highest),
+    /**
+    A higher-than-default precedence, for extensions that should
+    come before those with default precedence.
+    */
+    high: /*@__PURE__*/prec(Prec_.high),
+    /**
+    The default precedence, which is also used for extensions
+    without an explicit precedence.
+    */
+    default: /*@__PURE__*/prec(Prec_.default),
+    /**
+    A lower-than-default precedence.
+    */
+    low: /*@__PURE__*/prec(Prec_.low),
+    /**
+    The lowest precedence level. Meant for things that should end up
+    near the end of the extension order.
+    */
+    lowest: /*@__PURE__*/prec(Prec_.lowest)
+};
+class PrecExtension {
+    constructor(inner, prec) {
+        this.inner = inner;
+        this.prec = prec;
+    }
+}
+/**
+Extension compartments can be used to make a configuration
+dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
+configuration in a compartment, you can later
+[replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
+transaction.
+*/
+class Compartment {
+    /**
+    Create an instance of this compartment to add to your [state
+    configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
+    */
+    of(ext) { return new CompartmentInstance(this, ext); }
+    /**
+    Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
+    reconfigures this compartment.
+    */
+    reconfigure(content) {
+        return Compartment.reconfigure.of({ compartment: this, extension: content });
+    }
+    /**
+    Get the current content of the compartment in the state, or
+    `undefined` if it isn't present.
+    */
+    get(state) {
+        return state.config.compartments.get(this);
+    }
+}
+class CompartmentInstance {
+    constructor(compartment, inner) {
+        this.compartment = compartment;
+        this.inner = inner;
+    }
+}
+class Configuration {
+    constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
+        this.base = base;
+        this.compartments = compartments;
+        this.dynamicSlots = dynamicSlots;
+        this.address = address;
+        this.staticValues = staticValues;
+        this.facets = facets;
+        this.statusTemplate = [];
+        while (this.statusTemplate.length < dynamicSlots.length)
+            this.statusTemplate.push(0 /* SlotStatus.Unresolved */);
+    }
+    staticFacet(facet) {
+        let addr = this.address[facet.id];
+        return addr == null ? facet.default : this.staticValues[addr >> 1];
+    }
+    static resolve(base, compartments, oldState) {
+        let fields = [];
+        let facets = Object.create(null);
+        let newCompartments = new Map();
+        for (let ext of flatten(base, compartments, newCompartments)) {
+            if (ext instanceof StateField)
+                fields.push(ext);
+            else
+                (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
+        }
+        let address = Object.create(null);
+        let staticValues = [];
+        let dynamicSlots = [];
+        for (let field of fields) {
+            address[field.id] = dynamicSlots.length << 1;
+            dynamicSlots.push(a => field.slot(a));
+        }
+        let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
+        for (let id in facets) {
+            let providers = facets[id], facet = providers[0].facet;
+            let oldProviders = oldFacets && oldFacets[id] || [];
+            if (providers.every(p => p.type == 0 /* Provider.Static */)) {
+                address[facet.id] = (staticValues.length << 1) | 1;
+                if (sameArray$1(oldProviders, providers)) {
+                    staticValues.push(oldState.facet(facet));
+                }
+                else {
+                    let value = facet.combine(providers.map(p => p.value));
+                    staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
+                }
+            }
+            else {
+                for (let p of providers) {
+                    if (p.type == 0 /* Provider.Static */) {
+                        address[p.id] = (staticValues.length << 1) | 1;
+                        staticValues.push(p.value);
+                    }
+                    else {
+                        address[p.id] = dynamicSlots.length << 1;
+                        dynamicSlots.push(a => p.dynamicSlot(a));
+                    }
+                }
+                address[facet.id] = dynamicSlots.length << 1;
+                dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));
+            }
+        }
+        let dynamic = dynamicSlots.map(f => f(address));
+        return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
+    }
+}
+function flatten(extension, compartments, newCompartments) {
+    let result = [[], [], [], [], []];
+    let seen = new Map();
+    function inner(ext, prec) {
+        let known = seen.get(ext);
+        if (known != null) {
+            if (known <= prec)
+                return;
+            let found = result[known].indexOf(ext);
+            if (found > -1)
+                result[known].splice(found, 1);
+            if (ext instanceof CompartmentInstance)
+                newCompartments.delete(ext.compartment);
+        }
+        seen.set(ext, prec);
+        if (Array.isArray(ext)) {
+            for (let e of ext)
+                inner(e, prec);
+        }
+        else if (ext instanceof CompartmentInstance) {
+            if (newCompartments.has(ext.compartment))
+                throw new RangeError(`Duplicate use of compartment in extensions`);
+            let content = compartments.get(ext.compartment) || ext.inner;
+            newCompartments.set(ext.compartment, content);
+            inner(content, prec);
+        }
+        else if (ext instanceof PrecExtension) {
+            inner(ext.inner, ext.prec);
+        }
+        else if (ext instanceof StateField) {
+            result[prec].push(ext);
+            if (ext.provides)
+                inner(ext.provides, prec);
+        }
+        else if (ext instanceof FacetProvider) {
+            result[prec].push(ext);
+            if (ext.facet.extensions)
+                inner(ext.facet.extensions, Prec_.default);
+        }
+        else {
+            let content = ext.extension;
+            if (!content)
+                throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
+            inner(content, prec);
+        }
+    }
+    inner(extension, Prec_.default);
+    return result.reduce((a, b) => a.concat(b));
+}
+function ensureAddr(state, addr) {
+    if (addr & 1)
+        return 2 /* SlotStatus.Computed */;
+    let idx = addr >> 1;
+    let status = state.status[idx];
+    if (status == 4 /* SlotStatus.Computing */)
+        throw new Error("Cyclic dependency between fields and/or facets");
+    if (status & 2 /* SlotStatus.Computed */)
+        return status;
+    state.status[idx] = 4 /* SlotStatus.Computing */;
+    let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
+    return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;
+}
+function getAddr(state, addr) {
+    return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
+}
+
+const languageData = /*@__PURE__*/Facet.define();
+const allowMultipleSelections = /*@__PURE__*/Facet.define({
+    combine: values => values.some(v => v),
+    static: true
+});
+const lineSeparator = /*@__PURE__*/Facet.define({
+    combine: values => values.length ? values[0] : undefined,
+    static: true
+});
+const changeFilter = /*@__PURE__*/Facet.define();
+const transactionFilter = /*@__PURE__*/Facet.define();
+const transactionExtender = /*@__PURE__*/Facet.define();
+const readOnly = /*@__PURE__*/Facet.define({
+    combine: values => values.length ? values[0] : false
+});
+
+/**
+Annotations are tagged values that are used to add metadata to
+transactions in an extensible way. They should be used to model
+things that effect the entire transaction (such as its [time
+stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
+[origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
+_alongside_ the other changes made by the transaction, [state
+effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
+*/
+class Annotation {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    The annotation type.
+    */
+    type, 
+    /**
+    The value of this annotation.
+    */
+    value) {
+        this.type = type;
+        this.value = value;
+    }
+    /**
+    Define a new type of annotation.
+    */
+    static define() { return new AnnotationType(); }
+}
+/**
+Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
+*/
+class AnnotationType {
+    /**
+    Create an instance of this annotation.
+    */
+    of(value) { return new Annotation(this, value); }
+}
+/**
+Representation of a type of state effect. Defined with
+[`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
+*/
+class StateEffectType {
+    /**
+    @internal
+    */
+    constructor(
+    // The `any` types in these function types are there to work
+    // around TypeScript issue #37631, where the type guard on
+    // `StateEffect.is` mysteriously stops working when these properly
+    // have type `Value`.
+    /**
+    @internal
+    */
+    map) {
+        this.map = map;
+    }
+    /**
+    Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
+    type.
+    */
+    of(value) { return new StateEffect(this, value); }
+}
+/**
+State effects can be used to represent additional effects
+associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
+are often useful to model changes to custom [state
+fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
+document or selection changes.
+*/
+class StateEffect {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    @internal
+    */
+    type, 
+    /**
+    The value of this effect.
+    */
+    value) {
+        this.type = type;
+        this.value = value;
+    }
+    /**
+    Map this effect through a position mapping. Will return
+    `undefined` when that ends up deleting the effect.
+    */
+    map(mapping) {
+        let mapped = this.type.map(this.value, mapping);
+        return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
+    }
+    /**
+    Tells you whether this effect object is of a given
+    [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
+    */
+    is(type) { return this.type == type; }
+    /**
+    Define a new effect type. The type parameter indicates the type
+    of values that his effect holds. It should be a type that
+    doesn't include `undefined`, since that is used in
+    [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
+    removed.
+    */
+    static define(spec = {}) {
+        return new StateEffectType(spec.map || (v => v));
+    }
+    /**
+    Map an array of effects through a change set.
+    */
+    static mapEffects(effects, mapping) {
+        if (!effects.length)
+            return effects;
+        let result = [];
+        for (let effect of effects) {
+            let mapped = effect.map(mapping);
+            if (mapped)
+                result.push(mapped);
+        }
+        return result;
+    }
+}
+/**
+This effect can be used to reconfigure the root extensions of
+the editor. Doing this will discard any extensions
+[appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
+the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
+compartments.
+*/
+StateEffect.reconfigure = /*@__PURE__*/StateEffect.define();
+/**
+Append extensions to the top-level configuration of the editor.
+*/
+StateEffect.appendConfig = /*@__PURE__*/StateEffect.define();
+/**
+Changes to the editor state are grouped into transactions.
+Typically, a user action creates a single transaction, which may
+contain any number of document changes, may change the selection,
+or have other effects. Create a transaction by calling
+[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
+dispatch one by calling
+[`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
+*/
+class Transaction {
+    constructor(
+    /**
+    The state from which the transaction starts.
+    */
+    startState, 
+    /**
+    The document changes made by this transaction.
+    */
+    changes, 
+    /**
+    The selection set by this transaction, or undefined if it
+    doesn't explicitly set a selection.
+    */
+    selection, 
+    /**
+    The effects added to the transaction.
+    */
+    effects, 
+    /**
+    @internal
+    */
+    annotations, 
+    /**
+    Whether the selection should be scrolled into view after this
+    transaction is dispatched.
+    */
+    scrollIntoView) {
+        this.startState = startState;
+        this.changes = changes;
+        this.selection = selection;
+        this.effects = effects;
+        this.annotations = annotations;
+        this.scrollIntoView = scrollIntoView;
+        /**
+        @internal
+        */
+        this._doc = null;
+        /**
+        @internal
+        */
+        this._state = null;
+        if (selection)
+            checkSelection(selection, changes.newLength);
+        if (!annotations.some((a) => a.type == Transaction.time))
+            this.annotations = annotations.concat(Transaction.time.of(Date.now()));
+    }
+    /**
+    @internal
+    */
+    static create(startState, changes, selection, effects, annotations, scrollIntoView) {
+        return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
+    }
+    /**
+    The new document produced by the transaction. Contrary to
+    [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
+    force the entire new state to be computed right away, so it is
+    recommended that [transaction
+    filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
+    when they need to look at the new document.
+    */
+    get newDoc() {
+        return this._doc || (this._doc = this.changes.apply(this.startState.doc));
+    }
+    /**
+    The new selection produced by the transaction. If
+    [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
+    this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
+    current selection through the changes made by the transaction.
+    */
+    get newSelection() {
+        return this.selection || this.startState.selection.map(this.changes);
+    }
+    /**
+    The new state created by the transaction. Computed on demand
+    (but retained for subsequent access), so it is recommended not to
+    access it in [transaction
+    filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
+    */
+    get state() {
+        if (!this._state)
+            this.startState.applyTransaction(this);
+        return this._state;
+    }
+    /**
+    Get the value of the given annotation type, if any.
+    */
+    annotation(type) {
+        for (let ann of this.annotations)
+            if (ann.type == type)
+                return ann.value;
+        return undefined;
+    }
+    /**
+    Indicates whether the transaction changed the document.
+    */
+    get docChanged() { return !this.changes.empty; }
+    /**
+    Indicates whether this transaction reconfigures the state
+    (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
+    with a top-level configuration
+    [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
+    */
+    get reconfigured() { return this.startState.config != this.state.config; }
+    /**
+    Returns true if the transaction has a [user
+    event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
+    or more specific than `event`. For example, if the transaction
+    has `"select.pointer"` as user event, `"select"` and
+    `"select.pointer"` will match it.
+    */
+    isUserEvent(event) {
+        let e = this.annotation(Transaction.userEvent);
+        return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
+    }
+}
+/**
+Annotation used to store transaction timestamps. Automatically
+added to every transaction, holding `Date.now()`.
+*/
+Transaction.time = /*@__PURE__*/Annotation.define();
+/**
+Annotation used to associate a transaction with a user interface
+event. Holds a string identifying the event, using a
+dot-separated format to support attaching more specific
+information. The events used by the core libraries are:
+
+ - `"input"` when content is entered
+   - `"input.type"` for typed input
+     - `"input.type.compose"` for composition
+   - `"input.paste"` for pasted input
+   - `"input.drop"` when adding content with drag-and-drop
+   - `"input.complete"` when autocompleting
+ - `"delete"` when the user deletes content
+   - `"delete.selection"` when deleting the selection
+   - `"delete.forward"` when deleting forward from the selection
+   - `"delete.backward"` when deleting backward from the selection
+   - `"delete.cut"` when cutting to the clipboard
+ - `"move"` when content is moved
+   - `"move.drop"` when content is moved within the editor through drag-and-drop
+ - `"select"` when explicitly changing the selection
+   - `"select.pointer"` when selecting with a mouse or other pointing device
+ - `"undo"` and `"redo"` for history actions
+
+Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
+whether the annotation matches a given event.
+*/
+Transaction.userEvent = /*@__PURE__*/Annotation.define();
+/**
+Annotation indicating whether a transaction should be added to
+the undo history or not.
+*/
+Transaction.addToHistory = /*@__PURE__*/Annotation.define();
+/**
+Annotation indicating (when present and true) that a transaction
+represents a change made by some other actor, not the user. This
+is used, for example, to tag other people's changes in
+collaborative editing.
+*/
+Transaction.remote = /*@__PURE__*/Annotation.define();
+function joinRanges(a, b) {
+    let result = [];
+    for (let iA = 0, iB = 0;;) {
+        let from, to;
+        if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
+            from = a[iA++];
+            to = a[iA++];
+        }
+        else if (iB < b.length) {
+            from = b[iB++];
+            to = b[iB++];
+        }
+        else
+            return result;
+        if (!result.length || result[result.length - 1] < from)
+            result.push(from, to);
+        else if (result[result.length - 1] < to)
+            result[result.length - 1] = to;
+    }
+}
+function mergeTransaction(a, b, sequential) {
+    var _a;
+    let mapForA, mapForB, changes;
+    if (sequential) {
+        mapForA = b.changes;
+        mapForB = ChangeSet.empty(b.changes.length);
+        changes = a.changes.compose(b.changes);
+    }
+    else {
+        mapForA = b.changes.map(a.changes);
+        mapForB = a.changes.mapDesc(b.changes, true);
+        changes = a.changes.compose(mapForA);
+    }
+    return {
+        changes,
+        selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
+        effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),
+        annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
+        scrollIntoView: a.scrollIntoView || b.scrollIntoView
+    };
+}
+function resolveTransactionInner(state, spec, docSize) {
+    let sel = spec.selection, annotations = asArray$1(spec.annotations);
+    if (spec.userEvent)
+        annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));
+    return {
+        changes: spec.changes instanceof ChangeSet ? spec.changes
+            : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),
+        selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),
+        effects: asArray$1(spec.effects),
+        annotations,
+        scrollIntoView: !!spec.scrollIntoView
+    };
+}
+function resolveTransaction(state, specs, filter) {
+    let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);
+    if (specs.length && specs[0].filter === false)
+        filter = false;
+    for (let i = 1; i < specs.length; i++) {
+        if (specs[i].filter === false)
+            filter = false;
+        let seq = !!specs[i].sequential;
+        s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
+    }
+    let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
+    return extendTransaction(filter ? filterTransaction(tr) : tr);
+}
+// Finish a transaction by applying filters if necessary.
+function filterTransaction(tr) {
+    let state = tr.startState;
+    // Change filters
+    let result = true;
+    for (let filter of state.facet(changeFilter)) {
+        let value = filter(tr);
+        if (value === false) {
+            result = false;
+            break;
+        }
+        if (Array.isArray(value))
+            result = result === true ? value : joinRanges(result, value);
+    }
+    if (result !== true) {
+        let changes, back;
+        if (result === false) {
+            back = tr.changes.invertedDesc;
+            changes = ChangeSet.empty(state.doc.length);
+        }
+        else {
+            let filtered = tr.changes.filter(result);
+            changes = filtered.changes;
+            back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;
+        }
+        tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
+    }
+    // Transaction filters
+    let filters = state.facet(transactionFilter);
+    for (let i = filters.length - 1; i >= 0; i--) {
+        let filtered = filters[i](tr);
+        if (filtered instanceof Transaction)
+            tr = filtered;
+        else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction)
+            tr = filtered[0];
+        else
+            tr = resolveTransaction(state, asArray$1(filtered), false);
+    }
+    return tr;
+}
+function extendTransaction(tr) {
+    let state = tr.startState, extenders = state.facet(transactionExtender), spec = tr;
+    for (let i = extenders.length - 1; i >= 0; i--) {
+        let extension = extenders[i](tr);
+        if (extension && Object.keys(extension).length)
+            spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
+    }
+    return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
+}
+const none$2 = [];
+function asArray$1(value) {
+    return value == null ? none$2 : Array.isArray(value) ? value : [value];
+}
+
+/**
+The categories produced by a [character
+categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
+do things like selecting by word.
+*/
+var CharCategory = /*@__PURE__*/(function (CharCategory) {
+    /**
+    Word characters.
+    */
+    CharCategory[CharCategory["Word"] = 0] = "Word";
+    /**
+    Whitespace.
+    */
+    CharCategory[CharCategory["Space"] = 1] = "Space";
+    /**
+    Anything else.
+    */
+    CharCategory[CharCategory["Other"] = 2] = "Other";
+return CharCategory})(CharCategory || (CharCategory = {}));
+const nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
+let wordChar;
+try {
+    wordChar = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
+}
+catch (_) { }
+function hasWordChar(str) {
+    if (wordChar)
+        return wordChar.test(str);
+    for (let i = 0; i < str.length; i++) {
+        let ch = str[i];
+        if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)))
+            return true;
+    }
+    return false;
+}
+function makeCategorizer(wordChars) {
+    return (char) => {
+        if (!/\S/.test(char))
+            return CharCategory.Space;
+        if (hasWordChar(char))
+            return CharCategory.Word;
+        for (let i = 0; i < wordChars.length; i++)
+            if (char.indexOf(wordChars[i]) > -1)
+                return CharCategory.Word;
+        return CharCategory.Other;
+    };
+}
+
+/**
+The editor state class is a persistent (immutable) data structure.
+To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
+[transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
+instance, without modifying the original object.
+
+As such, _never_ mutate properties of a state directly. That'll
+just break things.
+*/
+class EditorState {
+    constructor(
+    /**
+    @internal
+    */
+    config, 
+    /**
+    The current document.
+    */
+    doc, 
+    /**
+    The current selection.
+    */
+    selection, 
+    /**
+    @internal
+    */
+    values, computeSlot, tr) {
+        this.config = config;
+        this.doc = doc;
+        this.selection = selection;
+        this.values = values;
+        this.status = config.statusTemplate.slice();
+        this.computeSlot = computeSlot;
+        // Fill in the computed state immediately, so that further queries
+        // for it made during the update return this state
+        if (tr)
+            tr._state = this;
+        for (let i = 0; i < this.config.dynamicSlots.length; i++)
+            ensureAddr(this, i << 1);
+        this.computeSlot = null;
+    }
+    field(field, require = true) {
+        let addr = this.config.address[field.id];
+        if (addr == null) {
+            if (require)
+                throw new RangeError("Field is not present in this state");
+            return undefined;
+        }
+        ensureAddr(this, addr);
+        return getAddr(this, addr);
+    }
+    /**
+    Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
+    state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
+    can be passed. Unless
+    [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
+    [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
+    are assumed to start in the _current_ document (not the document
+    produced by previous specs), and its
+    [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
+    [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
+    to the document created by its _own_ changes. The resulting
+    transaction contains the combined effect of all the different
+    specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
+    specs take precedence over earlier ones.
+    */
+    update(...specs) {
+        return resolveTransaction(this, specs, true);
+    }
+    /**
+    @internal
+    */
+    applyTransaction(tr) {
+        let conf = this.config, { base, compartments } = conf;
+        for (let effect of tr.effects) {
+            if (effect.is(Compartment.reconfigure)) {
+                if (conf) {
+                    compartments = new Map;
+                    conf.compartments.forEach((val, key) => compartments.set(key, val));
+                    conf = null;
+                }
+                compartments.set(effect.value.compartment, effect.value.extension);
+            }
+            else if (effect.is(StateEffect.reconfigure)) {
+                conf = null;
+                base = effect.value;
+            }
+            else if (effect.is(StateEffect.appendConfig)) {
+                conf = null;
+                base = asArray$1(base).concat(effect.value);
+            }
+        }
+        let startValues;
+        if (!conf) {
+            conf = Configuration.resolve(base, compartments, this);
+            let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
+            startValues = intermediateState.values;
+        }
+        else {
+            startValues = tr.startState.values.slice();
+        }
+        let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();
+        new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);
+    }
+    /**
+    Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
+    replaces every selection range with the given content.
+    */
+    replaceSelection(text) {
+        if (typeof text == "string")
+            text = this.toText(text);
+        return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
+            range: EditorSelection.cursor(range.from + text.length) }));
+    }
+    /**
+    Create a set of changes and a new selection by running the given
+    function for each range in the active selection. The function
+    can return an optional set of changes (in the coordinate space
+    of the start document), plus an updated range (in the coordinate
+    space of the document produced by the call's own changes). This
+    method will merge all the changes and ranges into a single
+    changeset and selection, and return it as a [transaction
+    spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
+    [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
+    */
+    changeByRange(f) {
+        let sel = this.selection;
+        let result1 = f(sel.ranges[0]);
+        let changes = this.changes(result1.changes), ranges = [result1.range];
+        let effects = asArray$1(result1.effects);
+        for (let i = 1; i < sel.ranges.length; i++) {
+            let result = f(sel.ranges[i]);
+            let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
+            for (let j = 0; j < i; j++)
+                ranges[j] = ranges[j].map(newMapped);
+            let mapBy = changes.mapDesc(newChanges, true);
+            ranges.push(result.range.map(mapBy));
+            changes = changes.compose(newMapped);
+            effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray$1(result.effects), mapBy));
+        }
+        return {
+            changes,
+            selection: EditorSelection.create(ranges, sel.mainIndex),
+            effects
+        };
+    }
+    /**
+    Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
+    description, taking the state's document length and line
+    separator into account.
+    */
+    changes(spec = []) {
+        if (spec instanceof ChangeSet)
+            return spec;
+        return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
+    }
+    /**
+    Using the state's [line
+    separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
+    [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
+    */
+    toText(string) {
+        return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
+    }
+    /**
+    Return the given range of the document as a string.
+    */
+    sliceDoc(from = 0, to = this.doc.length) {
+        return this.doc.sliceString(from, to, this.lineBreak);
+    }
+    /**
+    Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
+    */
+    facet(facet) {
+        let addr = this.config.address[facet.id];
+        if (addr == null)
+            return facet.default;
+        ensureAddr(this, addr);
+        return getAddr(this, addr);
+    }
+    /**
+    Convert this state to a JSON-serializable object. When custom
+    fields should be serialized, you can pass them in as an object
+    mapping property names (in the resulting object, which should
+    not use `doc` or `selection`) to fields.
+    */
+    toJSON(fields) {
+        let result = {
+            doc: this.sliceDoc(),
+            selection: this.selection.toJSON()
+        };
+        if (fields)
+            for (let prop in fields) {
+                let value = fields[prop];
+                if (value instanceof StateField && this.config.address[value.id] != null)
+                    result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
+            }
+        return result;
+    }
+    /**
+    Deserialize a state from its JSON representation. When custom
+    fields should be deserialized, pass the same object you passed
+    to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
+    third argument.
+    */
+    static fromJSON(json, config = {}, fields) {
+        if (!json || typeof json.doc != "string")
+            throw new RangeError("Invalid JSON representation for EditorState");
+        let fieldInit = [];
+        if (fields)
+            for (let prop in fields) {
+                if (Object.prototype.hasOwnProperty.call(json, prop)) {
+                    let field = fields[prop], value = json[prop];
+                    fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
+                }
+            }
+        return EditorState.create({
+            doc: json.doc,
+            selection: EditorSelection.fromJSON(json.selection),
+            extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
+        });
+    }
+    /**
+    Create a new state. You'll usually only need this when
+    initializing an editor—updated states are created by applying
+    transactions.
+    */
+    static create(config = {}) {
+        let configuration = Configuration.resolve(config.extensions || [], new Map);
+        let doc = config.doc instanceof Text ? config.doc
+            : Text.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
+        let selection = !config.selection ? EditorSelection.single(0)
+            : config.selection instanceof EditorSelection ? config.selection
+                : EditorSelection.single(config.selection.anchor, config.selection.head);
+        checkSelection(selection, doc.length);
+        if (!configuration.staticFacet(allowMultipleSelections))
+            selection = selection.asSingle();
+        return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
+    }
+    /**
+    The size (in columns) of a tab in the document, determined by
+    the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
+    */
+    get tabSize() { return this.facet(EditorState.tabSize); }
+    /**
+    Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
+    string for this state.
+    */
+    get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
+    /**
+    Returns true when the editor is
+    [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
+    */
+    get readOnly() { return this.facet(readOnly); }
+    /**
+    Look up a translation for the given phrase (via the
+    [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
+    original string if no translation is found.
+    
+    If additional arguments are passed, they will be inserted in
+    place of markers like `$1` (for the first value) and `$2`, etc.
+    A single `$` is equivalent to `$1`, and `$$` will produce a
+    literal dollar sign.
+    */
+    phrase(phrase, ...insert) {
+        for (let map of this.facet(EditorState.phrases))
+            if (Object.prototype.hasOwnProperty.call(map, phrase)) {
+                phrase = map[phrase];
+                break;
+            }
+        if (insert.length)
+            phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
+                if (i == "$")
+                    return "$";
+                let n = +(i || 1);
+                return !n || n > insert.length ? m : insert[n - 1];
+            });
+        return phrase;
+    }
+    /**
+    Find the values for a given language data field, provided by the
+    the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
+    
+    Examples of language data fields are...
+    
+    - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
+      comment syntax.
+    - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
+      for providing language-specific completion sources.
+    - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
+      characters that should be considered part of words in this
+      language.
+    - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
+      bracket closing behavior.
+    */
+    languageDataAt(name, pos, side = -1) {
+        let values = [];
+        for (let provider of this.facet(languageData)) {
+            for (let result of provider(this, pos, side)) {
+                if (Object.prototype.hasOwnProperty.call(result, name))
+                    values.push(result[name]);
+            }
+        }
+        return values;
+    }
+    /**
+    Return a function that can categorize strings (expected to
+    represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
+    into one of:
+    
+     - Word (contains an alphanumeric character or a character
+       explicitly listed in the local language's `"wordChars"`
+       language data, which should be a string)
+     - Space (contains only whitespace)
+     - Other (anything else)
+    */
+    charCategorizer(at) {
+        return makeCategorizer(this.languageDataAt("wordChars", at).join(""));
+    }
+    /**
+    Find the word at the given position, meaning the range
+    containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
+    around it. If no word characters are adjacent to the position,
+    this returns null.
+    */
+    wordAt(pos) {
+        let { text, from, length } = this.doc.lineAt(pos);
+        let cat = this.charCategorizer(pos);
+        let start = pos - from, end = pos - from;
+        while (start > 0) {
+            let prev = findClusterBreak(text, start, false);
+            if (cat(text.slice(prev, start)) != CharCategory.Word)
+                break;
+            start = prev;
+        }
+        while (end < length) {
+            let next = findClusterBreak(text, end);
+            if (cat(text.slice(end, next)) != CharCategory.Word)
+                break;
+            end = next;
+        }
+        return start == end ? null : EditorSelection.range(start + from, end + from);
+    }
+}
+/**
+A facet that, when enabled, causes the editor to allow multiple
+ranges to be selected. Be careful though, because by default the
+editor relies on the native DOM selection, which cannot handle
+multiple selections. An extension like
+[`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
+secondary selections visible to the user.
+*/
+EditorState.allowMultipleSelections = allowMultipleSelections;
+/**
+Configures the tab size to use in this state. The first
+(highest-precedence) value of the facet is used. If no value is
+given, this defaults to 4.
+*/
+EditorState.tabSize = /*@__PURE__*/Facet.define({
+    combine: values => values.length ? values[0] : 4
+});
+/**
+The line separator to use. By default, any of `"\n"`, `"\r\n"`
+and `"\r"` is treated as a separator when splitting lines, and
+lines are joined with `"\n"`.
+
+When you configure a value here, only that precise separator
+will be used, allowing you to round-trip documents through the
+editor without normalizing line separators.
+*/
+EditorState.lineSeparator = lineSeparator;
+/**
+This facet controls the value of the
+[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
+consulted by commands and extensions that implement editing
+functionality to determine whether they should apply. It
+defaults to false, but when its highest-precedence value is
+`true`, such functionality disables itself.
+
+Not to be confused with
+[`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
+controls whether the editor's DOM is set to be editable (and
+thus focusable).
+*/
+EditorState.readOnly = readOnly;
+/**
+Registers translation phrases. The
+[`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
+all objects registered with this facet to find translations for
+its argument.
+*/
+EditorState.phrases = /*@__PURE__*/Facet.define({
+    compare(a, b) {
+        let kA = Object.keys(a), kB = Object.keys(b);
+        return kA.length == kB.length && kA.every(k => a[k] == b[k]);
+    }
+});
+/**
+A facet used to register [language
+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
+*/
+EditorState.languageData = languageData;
+/**
+Facet used to register change filters, which are called for each
+transaction (unless explicitly
+[disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
+part of the transaction's changes.
+
+Such a function can return `true` to indicate that it doesn't
+want to do anything, `false` to completely stop the changes in
+the transaction, or a set of ranges in which changes should be
+suppressed. Such ranges are represented as an array of numbers,
+with each pair of two numbers indicating the start and end of a
+range. So for example `[10, 20, 100, 110]` suppresses changes
+between 10 and 20, and between 100 and 110.
+*/
+EditorState.changeFilter = changeFilter;
+/**
+Facet used to register a hook that gets a chance to update or
+replace transaction specs before they are applied. This will
+only be applied for transactions that don't have
+[`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
+can either return a single transaction spec (possibly the input
+transaction), or an array of specs (which will be combined in
+the same way as the arguments to
+[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
+
+When possible, it is recommended to avoid accessing
+[`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
+since it will force creation of a state that will then be
+discarded again, if the transaction is actually filtered.
+
+(This functionality should be used with care. Indiscriminately
+modifying transaction is likely to break something or degrade
+the user experience.)
+*/
+EditorState.transactionFilter = transactionFilter;
+/**
+This is a more limited form of
+[`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
+which can only add
+[annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
+[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
+of filter runs even if the transaction has disabled regular
+[filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
+for effects that don't need to touch the changes or selection,
+but do want to process every transaction.
+
+Extenders run _after_ filters, when both are present.
+*/
+EditorState.transactionExtender = transactionExtender;
+Compartment.reconfigure = /*@__PURE__*/StateEffect.define();
+
+/**
+Utility function for combining behaviors to fill in a config
+object from an array of provided configs. `defaults` should hold
+default values for all optional fields in `Config`.
+
+The function will, by default, error
+when a field gets two values that aren't `===`-equal, but you can
+provide combine functions per field to do something else.
+*/
+function combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
+combine = {}) {
+    let result = {};
+    for (let config of configs)
+        for (let key of Object.keys(config)) {
+            let value = config[key], current = result[key];
+            if (current === undefined)
+                result[key] = value;
+            else if (current === value || value === undefined) ; // No conflict
+            else if (Object.hasOwnProperty.call(combine, key))
+                result[key] = combine[key](current, value);
+            else
+                throw new Error("Config merge conflict for field " + key);
+        }
+    for (let key in defaults)
+        if (result[key] === undefined)
+            result[key] = defaults[key];
+    return result;
+}
+
+/**
+Each range is associated with a value, which must inherit from
+this class.
+*/
+class RangeValue {
+    /**
+    Compare this value with another value. Used when comparing
+    rangesets. The default implementation compares by identity.
+    Unless you are only creating a fixed number of unique instances
+    of your value type, it is a good idea to implement this
+    properly.
+    */
+    eq(other) { return this == other; }
+    /**
+    Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
+    */
+    range(from, to = from) { return Range$1.create(from, to, this); }
+}
+RangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;
+RangeValue.prototype.point = false;
+RangeValue.prototype.mapMode = MapMode.TrackDel;
+/**
+A range associates a value with a range of positions.
+*/
+let Range$1 = class Range {
+    constructor(
+    /**
+    The range's start position.
+    */
+    from, 
+    /**
+    Its end position.
+    */
+    to, 
+    /**
+    The value associated with this range.
+    */
+    value) {
+        this.from = from;
+        this.to = to;
+        this.value = value;
+    }
+    /**
+    @internal
+    */
+    static create(from, to, value) {
+        return new Range(from, to, value);
+    }
+};
+function cmpRange(a, b) {
+    return a.from - b.from || a.value.startSide - b.value.startSide;
+}
+class Chunk {
+    constructor(from, to, value, 
+    // Chunks are marked with the largest point that occurs
+    // in them (or -1 for no points), so that scans that are
+    // only interested in points (such as the
+    // heightmap-related logic) can skip range-only chunks.
+    maxPoint) {
+        this.from = from;
+        this.to = to;
+        this.value = value;
+        this.maxPoint = maxPoint;
+    }
+    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(pos, side, end, startAt = 0) {
+        let arr = end ? this.to : this.from;
+        for (let lo = startAt, hi = arr.length;;) {
+            if (lo == hi)
+                return lo;
+            let mid = (lo + hi) >> 1;
+            let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
+            if (mid == lo)
+                return diff >= 0 ? lo : hi;
+            if (diff >= 0)
+                hi = mid;
+            else
+                lo = mid + 1;
+        }
+    }
+    between(offset, from, to, f) {
+        for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)
+            if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
+                return false;
+    }
+    map(offset, changes) {
+        let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
+        for (let i = 0; i < this.value.length; i++) {
+            let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
+            if (curFrom == curTo) {
+                let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
+                if (mapped == null)
+                    continue;
+                newFrom = newTo = mapped;
+                if (val.startSide != val.endSide) {
+                    newTo = changes.mapPos(curFrom, val.endSide);
+                    if (newTo < newFrom)
+                        continue;
+                }
+            }
+            else {
+                newFrom = changes.mapPos(curFrom, val.startSide);
+                newTo = changes.mapPos(curTo, val.endSide);
+                if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
+                    continue;
+            }
+            if ((newTo - newFrom || val.endSide - val.startSide) < 0)
+                continue;
+            if (newPos < 0)
+                newPos = newFrom;
+            if (val.point)
+                maxPoint = Math.max(maxPoint, newTo - newFrom);
+            value.push(val);
+            from.push(newFrom - newPos);
+            to.push(newTo - newPos);
+        }
+        return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
+    }
+}
+/**
+A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
+way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
+[update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
+structure.
+*/
+class RangeSet {
+    constructor(
+    /**
+    @internal
+    */
+    chunkPos, 
+    /**
+    @internal
+    */
+    chunk, 
+    /**
+    @internal
+    */
+    nextLayer, 
+    /**
+    @internal
+    */
+    maxPoint) {
+        this.chunkPos = chunkPos;
+        this.chunk = chunk;
+        this.nextLayer = nextLayer;
+        this.maxPoint = maxPoint;
+    }
+    /**
+    @internal
+    */
+    static create(chunkPos, chunk, nextLayer, maxPoint) {
+        return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
+    }
+    /**
+    @internal
+    */
+    get length() {
+        let last = this.chunk.length - 1;
+        return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
+    }
+    /**
+    The number of ranges in the set.
+    */
+    get size() {
+        if (this.isEmpty)
+            return 0;
+        let size = this.nextLayer.size;
+        for (let chunk of this.chunk)
+            size += chunk.value.length;
+        return size;
+    }
+    /**
+    @internal
+    */
+    chunkEnd(index) {
+        return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
+        let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
+        let filter = updateSpec.filter;
+        if (add.length == 0 && !filter)
+            return this;
+        if (sort)
+            add = add.slice().sort(cmpRange);
+        if (this.isEmpty)
+            return add.length ? RangeSet.of(add) : this;
+        let cur = new LayerCursor(this, null, -1).goto(0), i = 0, spill = [];
+        let builder = new RangeSetBuilder();
+        while (cur.value || i < add.length) {
+            if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
+                let range = add[i++];
+                if (!builder.addInner(range.from, range.to, range.value))
+                    spill.push(range);
+            }
+            else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
+                (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
+                (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
+                builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
+                cur.nextChunk();
+            }
+            else {
+                if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
+                    if (!builder.addInner(cur.from, cur.to, cur.value))
+                        spill.push(Range$1.create(cur.from, cur.to, cur.value));
+                }
+                cur.next();
+            }
+        }
+        return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
+            : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
+    }
+    /**
+    Map this range set through a set of changes, return the new set.
+    */
+    map(changes) {
+        if (changes.empty || this.isEmpty)
+            return this;
+        let chunks = [], chunkPos = [], maxPoint = -1;
+        for (let i = 0; i < this.chunk.length; i++) {
+            let start = this.chunkPos[i], chunk = this.chunk[i];
+            let touch = changes.touchesRange(start, start + chunk.length);
+            if (touch === false) {
+                maxPoint = Math.max(maxPoint, chunk.maxPoint);
+                chunks.push(chunk);
+                chunkPos.push(changes.mapPos(start));
+            }
+            else if (touch === true) {
+                let { mapped, pos } = chunk.map(start, changes);
+                if (mapped) {
+                    maxPoint = Math.max(maxPoint, mapped.maxPoint);
+                    chunks.push(mapped);
+                    chunkPos.push(pos);
+                }
+            }
+        }
+        let next = this.nextLayer.map(changes);
+        return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
+    }
+    /**
+    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(from, to, f) {
+        if (this.isEmpty)
+            return;
+        for (let i = 0; i < this.chunk.length; i++) {
+            let start = this.chunkPos[i], chunk = this.chunk[i];
+            if (to >= start && from <= start + chunk.length &&
+                chunk.between(start, from - start, to - start, f) === false)
+                return;
+        }
+        this.nextLayer.between(from, to, f);
+    }
+    /**
+    Iterate over the ranges in this set, in order, including all
+    ranges that end at or after `from`.
+    */
+    iter(from = 0) {
+        return HeapCursor.from([this]).goto(from);
+    }
+    /**
+    @internal
+    */
+    get isEmpty() { return this.nextLayer == this; }
+    /**
+    Iterate over the ranges in a collection of sets, in order,
+    starting from `from`.
+    */
+    static iter(sets, from = 0) {
+        return HeapCursor.from(sets).goto(from);
+    }
+    /**
+    Iterate over two groups of sets, calling methods on `comparator`
+    to notify it of possible differences.
+    */
+    static compare(oldSets, newSets, 
+    /**
+    This indicates how the underlying data changed between these
+    ranges, and is needed to synchronize the iteration.
+    */
+    textDiff, comparator, 
+    /**
+    Can be used to ignore all non-point ranges, and points below
+    the given size. When -1, all ranges are compared.
+    */
+    minPointSize = -1) {
+        let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+        let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+        let sharedChunks = findSharedChunks(a, b, textDiff);
+        let sideA = new SpanCursor(a, sharedChunks, minPointSize);
+        let sideB = new SpanCursor(b, sharedChunks, minPointSize);
+        textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));
+        if (textDiff.empty && textDiff.length == 0)
+            compare(sideA, 0, sideB, 0, 0, comparator);
+    }
+    /**
+    Compare the contents of two groups of range sets, returning true
+    if they are equivalent in the given range.
+    */
+    static eq(oldSets, newSets, from = 0, to) {
+        if (to == null)
+            to = 1000000000 /* C.Far */ - 1;
+        let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
+        let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
+        if (a.length != b.length)
+            return false;
+        if (!a.length)
+            return true;
+        let sharedChunks = findSharedChunks(a, b);
+        let sideA = new SpanCursor(a, sharedChunks, 0).goto(from), sideB = new SpanCursor(b, sharedChunks, 0).goto(from);
+        for (;;) {
+            if (sideA.to != sideB.to ||
+                !sameValues(sideA.active, sideB.active) ||
+                sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
+                return false;
+            if (sideA.to > to)
+                return true;
+            sideA.next();
+            sideB.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(sets, from, to, iterator, 
+    /**
+    When given and greater than -1, only points of at least this
+    size are taken into account.
+    */
+    minPointSize = -1) {
+        let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;
+        let openRanges = cursor.openStart;
+        for (;;) {
+            let curTo = Math.min(cursor.to, to);
+            if (cursor.point) {
+                let active = cursor.activeForPoint(cursor.to);
+                let openCount = cursor.pointFrom < from ? active.length + 1
+                    : cursor.point.startSide < 0 ? active.length
+                        : Math.min(active.length, openRanges);
+                iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);
+                openRanges = Math.min(cursor.openEnd(curTo), active.length);
+            }
+            else if (curTo > pos) {
+                iterator.span(pos, curTo, cursor.active, openRanges);
+                openRanges = cursor.openEnd(curTo);
+            }
+            if (cursor.to > to)
+                return openRanges + (cursor.point && cursor.to > to ? 1 : 0);
+            pos = cursor.to;
+            cursor.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(ranges, sort = false) {
+        let build = new RangeSetBuilder();
+        for (let range of ranges instanceof Range$1 ? [ranges] : sort ? lazySort(ranges) : ranges)
+            build.add(range.from, range.to, range.value);
+        return build.finish();
+    }
+    /**
+    Join an array of range sets into a single set.
+    */
+    static join(sets) {
+        if (!sets.length)
+            return RangeSet.empty;
+        let result = sets[sets.length - 1];
+        for (let i = sets.length - 2; i >= 0; i--) {
+            for (let layer = sets[i]; layer != RangeSet.empty; layer = layer.nextLayer)
+                result = new RangeSet(layer.chunkPos, layer.chunk, result, Math.max(layer.maxPoint, result.maxPoint));
+        }
+        return result;
+    }
+}
+/**
+The empty set of ranges.
+*/
+RangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);
+function lazySort(ranges) {
+    if (ranges.length > 1)
+        for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
+            let cur = ranges[i];
+            if (cmpRange(prev, cur) > 0)
+                return ranges.slice().sort(cmpRange);
+            prev = cur;
+        }
+    return ranges;
+}
+RangeSet.empty.nextLayer = RangeSet.empty;
+/**
+A range set builder is a data structure that helps build up a
+[range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
+an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
+*/
+class RangeSetBuilder {
+    finishChunk(newArrays) {
+        this.chunks.push(new Chunk(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;
+        if (newArrays) {
+            this.from = [];
+            this.to = [];
+            this.value = [];
+        }
+    }
+    /**
+    Create an empty builder.
+    */
+    constructor() {
+        this.chunks = [];
+        this.chunkPos = [];
+        this.chunkStart = -1;
+        this.last = null;
+        this.lastFrom = -1000000000 /* C.Far */;
+        this.lastTo = -1000000000 /* C.Far */;
+        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(from, to, value) {
+        if (!this.addInner(from, to, value))
+            (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
+    }
+    /**
+    @internal
+    */
+    addInner(from, to, value) {
+        let diff = from - this.lastTo || value.startSide - this.last.endSide;
+        if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
+            throw new Error("Ranges must be added sorted by `from` position and `startSide`");
+        if (diff < 0)
+            return false;
+        if (this.from.length == 250 /* C.ChunkSize */)
+            this.finishChunk(true);
+        if (this.chunkStart < 0)
+            this.chunkStart = from;
+        this.from.push(from - this.chunkStart);
+        this.to.push(to - this.chunkStart);
+        this.last = value;
+        this.lastFrom = from;
+        this.lastTo = to;
+        this.value.push(value);
+        if (value.point)
+            this.maxPoint = Math.max(this.maxPoint, to - from);
+        return true;
+    }
+    /**
+    @internal
+    */
+    addChunk(from, chunk) {
+        if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
+            return false;
+        if (this.from.length)
+            this.finishChunk(true);
+        this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
+        this.chunks.push(chunk);
+        this.chunkPos.push(from);
+        let last = chunk.value.length - 1;
+        this.last = chunk.value[last];
+        this.lastFrom = chunk.from[last] + from;
+        this.lastTo = chunk.to[last] + from;
+        return true;
+    }
+    /**
+    Finish the range set. Returns the new set. The builder can't be
+    used anymore after this has been called.
+    */
+    finish() { return this.finishInner(RangeSet.empty); }
+    /**
+    @internal
+    */
+    finishInner(next) {
+        if (this.from.length)
+            this.finishChunk(false);
+        if (this.chunks.length == 0)
+            return next;
+        let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
+        this.from = null; // Make sure further `add` calls produce errors
+        return result;
+    }
+}
+function findSharedChunks(a, b, textDiff) {
+    let inA = new Map();
+    for (let set of a)
+        for (let i = 0; i < set.chunk.length; i++)
+            if (set.chunk[i].maxPoint <= 0)
+                inA.set(set.chunk[i], set.chunkPos[i]);
+    let shared = new Set();
+    for (let set of b)
+        for (let i = 0; i < set.chunk.length; i++) {
+            let known = inA.get(set.chunk[i]);
+            if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
+                !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
+                shared.add(set.chunk[i]);
+        }
+    return shared;
+}
+class LayerCursor {
+    constructor(layer, skip, minPoint, rank = 0) {
+        this.layer = layer;
+        this.skip = skip;
+        this.minPoint = minPoint;
+        this.rank = rank;
+    }
+    get startSide() { return this.value ? this.value.startSide : 0; }
+    get endSide() { return this.value ? this.value.endSide : 0; }
+    goto(pos, side = -1000000000 /* C.Far */) {
+        this.chunkIndex = this.rangeIndex = 0;
+        this.gotoInner(pos, side, false);
+        return this;
+    }
+    gotoInner(pos, side, forward) {
+        while (this.chunkIndex < this.layer.chunk.length) {
+            let next = this.layer.chunk[this.chunkIndex];
+            if (!(this.skip && this.skip.has(next) ||
+                this.layer.chunkEnd(this.chunkIndex) < pos ||
+                next.maxPoint < this.minPoint))
+                break;
+            this.chunkIndex++;
+            forward = false;
+        }
+        if (this.chunkIndex < this.layer.chunk.length) {
+            let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
+            if (!forward || this.rangeIndex < rangeIndex)
+                this.setRangeIndex(rangeIndex);
+        }
+        this.next();
+    }
+    forward(pos, side) {
+        if ((this.to - pos || this.endSide - side) < 0)
+            this.gotoInner(pos, side, true);
+    }
+    next() {
+        for (;;) {
+            if (this.chunkIndex == this.layer.chunk.length) {
+                this.from = this.to = 1000000000 /* C.Far */;
+                this.value = null;
+                break;
+            }
+            else {
+                let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
+                let from = chunkPos + chunk.from[this.rangeIndex];
+                this.from = from;
+                this.to = chunkPos + chunk.to[this.rangeIndex];
+                this.value = chunk.value[this.rangeIndex];
+                this.setRangeIndex(this.rangeIndex + 1);
+                if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
+                    break;
+            }
+        }
+    }
+    setRangeIndex(index) {
+        if (index == this.layer.chunk[this.chunkIndex].value.length) {
+            this.chunkIndex++;
+            if (this.skip) {
+                while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
+                    this.chunkIndex++;
+            }
+            this.rangeIndex = 0;
+        }
+        else {
+            this.rangeIndex = index;
+        }
+    }
+    nextChunk() {
+        this.chunkIndex++;
+        this.rangeIndex = 0;
+        this.next();
+    }
+    compare(other) {
+        return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
+            this.to - other.to || this.endSide - other.endSide;
+    }
+}
+class HeapCursor {
+    constructor(heap) {
+        this.heap = heap;
+    }
+    static from(sets, skip = null, minPoint = -1) {
+        let heap = [];
+        for (let i = 0; i < sets.length; i++) {
+            for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
+                if (cur.maxPoint >= minPoint)
+                    heap.push(new LayerCursor(cur, skip, minPoint, i));
+            }
+        }
+        return heap.length == 1 ? heap[0] : new HeapCursor(heap);
+    }
+    get startSide() { return this.value ? this.value.startSide : 0; }
+    goto(pos, side = -1000000000 /* C.Far */) {
+        for (let cur of this.heap)
+            cur.goto(pos, side);
+        for (let i = this.heap.length >> 1; i >= 0; i--)
+            heapBubble(this.heap, i);
+        this.next();
+        return this;
+    }
+    forward(pos, side) {
+        for (let cur of this.heap)
+            cur.forward(pos, side);
+        for (let i = this.heap.length >> 1; i >= 0; i--)
+            heapBubble(this.heap, i);
+        if ((this.to - pos || this.value.endSide - side) < 0)
+            this.next();
+    }
+    next() {
+        if (this.heap.length == 0) {
+            this.from = this.to = 1000000000 /* C.Far */;
+            this.value = null;
+            this.rank = -1;
+        }
+        else {
+            let top = this.heap[0];
+            this.from = top.from;
+            this.to = top.to;
+            this.value = top.value;
+            this.rank = top.rank;
+            if (top.value)
+                top.next();
+            heapBubble(this.heap, 0);
+        }
+    }
+}
+function heapBubble(heap, index) {
+    for (let cur = heap[index];;) {
+        let childIndex = (index << 1) + 1;
+        if (childIndex >= heap.length)
+            break;
+        let child = heap[childIndex];
+        if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
+            child = heap[childIndex + 1];
+            childIndex++;
+        }
+        if (cur.compare(child) < 0)
+            break;
+        heap[childIndex] = cur;
+        heap[index] = child;
+        index = childIndex;
+    }
+}
+class SpanCursor {
+    constructor(sets, skip, minPoint) {
+        this.minPoint = minPoint;
+        this.active = [];
+        this.activeTo = [];
+        this.activeRank = [];
+        this.minActive = -1;
+        // A currently active point range, if any
+        this.point = null;
+        this.pointFrom = 0;
+        this.pointRank = 0;
+        this.to = -1000000000 /* C.Far */;
+        this.endSide = 0;
+        // The amount of open active ranges at the start of the iterator.
+        // Not including points.
+        this.openStart = -1;
+        this.cursor = HeapCursor.from(sets, skip, minPoint);
+    }
+    goto(pos, side = -1000000000 /* C.Far */) {
+        this.cursor.goto(pos, side);
+        this.active.length = this.activeTo.length = this.activeRank.length = 0;
+        this.minActive = -1;
+        this.to = pos;
+        this.endSide = side;
+        this.openStart = -1;
+        this.next();
+        return this;
+    }
+    forward(pos, side) {
+        while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
+            this.removeActive(this.minActive);
+        this.cursor.forward(pos, side);
+    }
+    removeActive(index) {
+        remove(this.active, index);
+        remove(this.activeTo, index);
+        remove(this.activeRank, index);
+        this.minActive = findMinIndex(this.active, this.activeTo);
+    }
+    addActive(trackOpen) {
+        let i = 0, { value, to, rank } = this.cursor;
+        // Organize active marks by rank first, then by size
+        while (i < this.activeRank.length && (rank - this.activeRank[i] || to - this.activeTo[i]) > 0)
+            i++;
+        insert(this.active, i, value);
+        insert(this.activeTo, i, to);
+        insert(this.activeRank, i, rank);
+        if (trackOpen)
+            insert(trackOpen, i, this.cursor.from);
+        this.minActive = findMinIndex(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 from = this.to, wasPoint = this.point;
+        this.point = null;
+        let trackOpen = this.openStart < 0 ? [] : null;
+        for (;;) {
+            let a = this.minActive;
+            if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
+                if (this.activeTo[a] > from) {
+                    this.to = this.activeTo[a];
+                    this.endSide = this.active[a].endSide;
+                    break;
+                }
+                this.removeActive(a);
+                if (trackOpen)
+                    remove(trackOpen, a);
+            }
+            else if (!this.cursor.value) {
+                this.to = this.endSide = 1000000000 /* C.Far */;
+                break;
+            }
+            else if (this.cursor.from > from) {
+                this.to = this.cursor.from;
+                this.endSide = this.cursor.startSide;
+                break;
+            }
+            else {
+                let nextVal = this.cursor.value;
+                if (!nextVal.point) { // Opening a range
+                    this.addActive(trackOpen);
+                    this.cursor.next();
+                }
+                else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
+                    // Ignore any non-empty points that end precisely at the end of the prev point
+                    this.cursor.next();
+                }
+                else { // New point
+                    this.point = nextVal;
+                    this.pointFrom = this.cursor.from;
+                    this.pointRank = this.cursor.rank;
+                    this.to = this.cursor.to;
+                    this.endSide = nextVal.endSide;
+                    this.cursor.next();
+                    this.forward(this.to, this.endSide);
+                    break;
+                }
+            }
+        }
+        if (trackOpen) {
+            this.openStart = 0;
+            for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)
+                this.openStart++;
+        }
+    }
+    activeForPoint(to) {
+        if (!this.active.length)
+            return this.active;
+        let active = [];
+        for (let i = this.active.length - 1; i >= 0; i--) {
+            if (this.activeRank[i] < this.pointRank)
+                break;
+            if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
+                active.push(this.active[i]);
+        }
+        return active.reverse();
+    }
+    openEnd(to) {
+        let open = 0;
+        for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
+            open++;
+        return open;
+    }
+}
+function compare(a, startA, b, startB, length, comparator) {
+    a.goto(startA);
+    b.goto(startB);
+    let endB = startB + length;
+    let pos = startB, dPos = startB - startA;
+    for (;;) {
+        let dEnd = (a.to + dPos) - b.to, diff = dEnd || a.endSide - b.endSide;
+        let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
+        if (a.point || b.point) {
+            if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
+                sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))
+                comparator.comparePoint(pos, clipEnd, a.point, b.point);
+        }
+        else {
+            if (clipEnd > pos && !sameValues(a.active, b.active))
+                comparator.compareRange(pos, clipEnd, a.active, b.active);
+        }
+        if (end > endB)
+            break;
+        if ((dEnd || a.openEnd != b.openEnd) && comparator.boundChange)
+            comparator.boundChange(end);
+        pos = end;
+        if (diff <= 0)
+            a.next();
+        if (diff >= 0)
+            b.next();
+    }
+}
+function sameValues(a, b) {
+    if (a.length != b.length)
+        return false;
+    for (let i = 0; i < a.length; i++)
+        if (a[i] != b[i] && !a[i].eq(b[i]))
+            return false;
+    return true;
+}
+function remove(array, index) {
+    for (let i = index, e = array.length - 1; i < e; i++)
+        array[i] = array[i + 1];
+    array.pop();
+}
+function insert(array, index, value) {
+    for (let i = array.length - 1; i >= index; i--)
+        array[i + 1] = array[i];
+    array[index] = value;
+}
+function findMinIndex(value, array) {
+    let found = -1, foundPos = 1000000000 /* C.Far */;
+    for (let i = 0; i < array.length; i++)
+        if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
+            found = i;
+            foundPos = array[i];
+        }
+    return found;
+}
+
+/**
+Count the column position at the given offset into the string,
+taking extending characters and tab size into account.
+*/
+function countColumn(string, tabSize, to = string.length) {
+    let n = 0;
+    for (let i = 0; i < to;) {
+        if (string.charCodeAt(i) == 9) {
+            n += tabSize - (n % tabSize);
+            i++;
+        }
+        else {
+            n++;
+            i = findClusterBreak(string, i);
+        }
+    }
+    return n;
+}
+/**
+Find the offset that corresponds to the given column position in a
+string, taking extending characters and tab size into account. By
+default, the string length is returned when it is too short to
+reach the column. Pass `strict` true to make it return -1 in that
+situation.
+*/
+function findColumn(string, col, tabSize, strict) {
+    for (let i = 0, n = 0;;) {
+        if (n >= col)
+            return i;
+        if (i == string.length)
+            break;
+        n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
+        i = findClusterBreak(string, i);
+    }
+    return strict === true ? -1 : string.length;
+}
+
+const C = "\u037c";
+const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C);
+const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
+const top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
+
+// :: - Style modules encapsulate a set of CSS rules defined from
+// JavaScript. Their definitions are only available in a given DOM
+// root after it has been _mounted_ there with `StyleModule.mount`.
+//
+// Style modules should be created once and stored somewhere, as
+// opposed to re-creating them every time you need them. The amount of
+// CSS rules generated for a given DOM root is bounded by the amount
+// of style modules that were used. So to avoid leaking rules, don't
+// create these dynamically, but treat them as one-time allocations.
+class StyleModule {
+  // :: (Object<Style>, ?{finish: ?(string) → string})
+  // Create a style module from the given spec.
+  //
+  // When `finish` is given, it is called on regular (non-`@`)
+  // selectors (after `&` expansion) to compute the final selector.
+  constructor(spec, options) {
+    this.rules = [];
+    let {finish} = options || {};
+
+    function splitSelector(selector) {
+      return /^@/.test(selector) ? [selector] : selector.split(/,\s*/)
+    }
+
+    function render(selectors, spec, target, isKeyframes) {
+      let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
+      if (isAt && spec == null) return target.push(selectors[0] + ";")
+      for (let prop in spec) {
+        let value = spec[prop];
+        if (/&/.test(prop)) {
+          render(prop.split(/,\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),
+                 value, target);
+        } else if (value && typeof value == "object") {
+          if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.")
+          render(splitSelector(prop), value, local, keyframes);
+        } else if (value != null) {
+          local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, l => "-" + l.toLowerCase()) + ": " + value + ";");
+        }
+      }
+      if (local.length || keyframes) {
+        target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") +
+                    " {" + local.join(" ") + "}");
+      }
+    }
+
+    for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
+  }
+
+  // :: () → string
+  // Returns a string containing the module's CSS rules.
+  getRules() { return this.rules.join("\n") }
+
+  // :: () → string
+  // Generate a new unique CSS class name.
+  static newName() {
+    let id = top[COUNT] || 1;
+    top[COUNT] = id + 1;
+    return C + id.toString(36)
+  }
+
+  // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
+  //
+  // Mount the given set of modules in the given DOM root, which ensures
+  // that the CSS rules defined by the module are available in that
+  // context.
+  //
+  // Rules are only added to the document once per root.
+  //
+  // Rule order will follow the order of the modules, so that rules from
+  // modules later in the array take precedence of those from earlier
+  // modules. If you call this function multiple times for the same root
+  // in a way that changes the order of already mounted modules, the old
+  // order will be changed.
+  //
+  // If a Content Security Policy nonce is provided, it is added to
+  // the `<style>` tag generated by the library.
+  static mount(root, modules, options) {
+    let set = root[SET], nonce = options && options.nonce;
+    if (!set) set = new StyleSet(root, nonce);
+    else if (nonce) set.setNonce(nonce);
+    set.mount(Array.isArray(modules) ? modules : [modules], root);
+  }
+}
+
+let adoptedSet = new Map; //<Document, StyleSet>
+
+class StyleSet {
+  constructor(root, nonce) {
+    let doc = root.ownerDocument || root, win = doc.defaultView;
+    if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
+      let adopted = adoptedSet.get(doc);
+      if (adopted) return root[SET] = adopted
+      this.sheet = new win.CSSStyleSheet;
+      adoptedSet.set(doc, this);
+    } else {
+      this.styleTag = doc.createElement("style");
+      if (nonce) this.styleTag.setAttribute("nonce", nonce);
+    }
+    this.modules = [];
+    root[SET] = this;
+  }
+
+  mount(modules, root) {
+    let sheet = this.sheet;
+    let pos = 0 /* Current rule offset */, j = 0; /* Index into this.modules */
+    for (let i = 0; i < modules.length; i++) {
+      let mod = modules[i], index = this.modules.indexOf(mod);
+      if (index < j && index > -1) { // Ordering conflict
+        this.modules.splice(index, 1);
+        j--;
+        index = -1;
+      }
+      if (index == -1) {
+        this.modules.splice(j++, 0, mod);
+        if (sheet) for (let k = 0; k < mod.rules.length; k++)
+          sheet.insertRule(mod.rules[k], pos++);
+      } else {
+        while (j < index) pos += this.modules[j++].rules.length;
+        pos += mod.rules.length;
+        j++;
+      }
+    }
+
+    if (sheet) {
+      if (root.adoptedStyleSheets.indexOf(this.sheet) < 0)
+        root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
+    } else {
+      let text = "";
+      for (let i = 0; i < this.modules.length; i++)
+        text += this.modules[i].getRules() + "\n";
+      this.styleTag.textContent = text;
+      let target = root.head || root;
+      if (this.styleTag.parentNode != target)
+        target.insertBefore(this.styleTag, target.firstChild);
+    }
+  }
+
+  setNonce(nonce) {
+    if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce)
+      this.styleTag.setAttribute("nonce", nonce);
+  }
+}
+
+// Style::Object<union<Style,string>>
+//
+// A style is an object that, in the simple case, maps CSS property
+// names to strings holding their values, as in `{color: "red",
+// fontWeight: "bold"}`. The property names can be given in
+// camel-case—the library will insert a dash before capital letters
+// when converting them to CSS.
+//
+// If you include an underscore in a property name, it and everything
+// after it will be removed from the output, which can be useful when
+// providing a property multiple times, for browser compatibility
+// reasons.
+//
+// A property in a style object can also be a sub-selector, which
+// extends the current context to add a pseudo-selector or a child
+// selector. Such a property should contain a `&` character, which
+// will be replaced by the current selector. For example `{"&:before":
+// {content: '"hi"'}}`. Sub-selectors and regular properties can
+// freely be mixed in a given object. Any property containing a `&` is
+// assumed to be a sub-selector.
+//
+// Finally, a property can specify an @-block to be wrapped around the
+// styles defined inside the object that's the property's value. For
+// example to create a media query you can do `{"@media screen and
+// (min-width: 400px)": {...}}`.
+
+var base = {
+  8: "Backspace",
+  9: "Tab",
+  10: "Enter",
+  12: "NumLock",
+  13: "Enter",
+  16: "Shift",
+  17: "Control",
+  18: "Alt",
+  20: "CapsLock",
+  27: "Escape",
+  32: " ",
+  33: "PageUp",
+  34: "PageDown",
+  35: "End",
+  36: "Home",
+  37: "ArrowLeft",
+  38: "ArrowUp",
+  39: "ArrowRight",
+  40: "ArrowDown",
+  44: "PrintScreen",
+  45: "Insert",
+  46: "Delete",
+  59: ";",
+  61: "=",
+  91: "Meta",
+  92: "Meta",
+  106: "*",
+  107: "+",
+  108: ",",
+  109: "-",
+  110: ".",
+  111: "/",
+  144: "NumLock",
+  145: "ScrollLock",
+  160: "Shift",
+  161: "Shift",
+  162: "Control",
+  163: "Control",
+  164: "Alt",
+  165: "Alt",
+  173: "-",
+  186: ";",
+  187: "=",
+  188: ",",
+  189: "-",
+  190: ".",
+  191: "/",
+  192: "`",
+  219: "[",
+  220: "\\",
+  221: "]",
+  222: "'"
+};
+
+var shift = {
+  48: ")",
+  49: "!",
+  50: "@",
+  51: "#",
+  52: "$",
+  53: "%",
+  54: "^",
+  55: "&",
+  56: "*",
+  57: "(",
+  59: ":",
+  61: "+",
+  173: "_",
+  186: ":",
+  187: "+",
+  188: "<",
+  189: "_",
+  190: ">",
+  191: "?",
+  192: "~",
+  219: "{",
+  220: "|",
+  221: "}",
+  222: "\""
+};
+
+var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
+var ie$1 = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
+
+// Fill in the digit keys
+for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);
+
+// The function keys
+for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i;
+
+// And the alphabetic keys
+for (var i = 65; i <= 90; i++) {
+  base[i] = String.fromCharCode(i + 32);
+  shift[i] = String.fromCharCode(i);
+}
+
+// For each code that doesn't have a shift-equivalent, copy the base name
+for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];
+
+function keyName(event) {
+  // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.
+  // On IE, shift effect is never included in `.key`.
+  var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||
+      ie$1 && event.shiftKey && event.key && event.key.length == 1 ||
+      event.key == "Unidentified";
+  var name = (!ignoreKey && event.key) ||
+    (event.shiftKey ? shift : base)[event.keyCode] ||
+    event.key || "Unidentified";
+  // Edge sometimes produces wrong names (Issue #3)
+  if (name == "Esc") name = "Escape";
+  if (name == "Del") name = "Delete";
+  // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
+  if (name == "Left") name = "ArrowLeft";
+  if (name == "Up") name = "ArrowUp";
+  if (name == "Right") name = "ArrowRight";
+  if (name == "Down") name = "ArrowDown";
+  return name
+}
+
+function getSelection(root) {
+    let target;
+    // Browsers differ on whether shadow roots have a getSelection
+    // method. If it exists, use that, otherwise, call it on the
+    // document.
+    if (root.nodeType == 11) { // Shadow root
+        target = root.getSelection ? root : root.ownerDocument;
+    }
+    else {
+        target = root;
+    }
+    return target.getSelection();
+}
+function contains(dom, node) {
+    return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
+}
+function hasSelection(dom, selection) {
+    if (!selection.anchorNode)
+        return false;
+    try {
+        // Firefox will raise 'permission denied' errors when accessing
+        // properties of `sel.anchorNode` when it's in a generated CSS
+        // element.
+        return contains(dom, selection.anchorNode);
+    }
+    catch (_) {
+        return false;
+    }
+}
+function clientRectsFor(dom) {
+    if (dom.nodeType == 3)
+        return textRange(dom, 0, dom.nodeValue.length).getClientRects();
+    else if (dom.nodeType == 1)
+        return dom.getClientRects();
+    else
+        return [];
+}
+// Scans forward and backward through DOM positions equivalent to the
+// given one to see if the two are in the same place (i.e. after a
+// text node vs at the end of that text node)
+function isEquivalentPosition(node, off, targetNode, targetOff) {
+    return targetNode ? (scanFor(node, off, targetNode, targetOff, -1) ||
+        scanFor(node, off, targetNode, targetOff, 1)) : false;
+}
+function domIndex(node) {
+    for (var index = 0;; index++) {
+        node = node.previousSibling;
+        if (!node)
+            return index;
+    }
+}
+function isBlockElement(node) {
+    return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
+}
+function scanFor(node, off, targetNode, targetOff, dir) {
+    for (;;) {
+        if (node == targetNode && off == targetOff)
+            return true;
+        if (off == (dir < 0 ? 0 : maxOffset(node))) {
+            if (node.nodeName == "DIV")
+                return false;
+            let parent = node.parentNode;
+            if (!parent || parent.nodeType != 1)
+                return false;
+            off = domIndex(node) + (dir < 0 ? 0 : 1);
+            node = parent;
+        }
+        else if (node.nodeType == 1) {
+            node = node.childNodes[off + (dir < 0 ? -1 : 0)];
+            if (node.nodeType == 1 && node.contentEditable == "false")
+                return false;
+            off = dir < 0 ? maxOffset(node) : 0;
+        }
+        else {
+            return false;
+        }
+    }
+}
+function maxOffset(node) {
+    return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
+}
+function flattenRect(rect, left) {
+    let x = left ? rect.left : rect.right;
+    return { left: x, right: x, top: rect.top, bottom: rect.bottom };
+}
+function windowRect(win) {
+    let vp = win.visualViewport;
+    if (vp)
+        return {
+            left: 0, right: vp.width,
+            top: 0, bottom: vp.height
+        };
+    return { left: 0, right: win.innerWidth,
+        top: 0, bottom: win.innerHeight };
+}
+function getScale(elt, rect) {
+    let scaleX = rect.width / elt.offsetWidth;
+    let scaleY = rect.height / elt.offsetHeight;
+    if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX) || Math.abs(rect.width - elt.offsetWidth) < 1)
+        scaleX = 1;
+    if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY) || Math.abs(rect.height - elt.offsetHeight) < 1)
+        scaleY = 1;
+    return { scaleX, scaleY };
+}
+function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
+    let doc = dom.ownerDocument, win = doc.defaultView || window;
+    for (let cur = dom, stop = false; cur && !stop;) {
+        if (cur.nodeType == 1) { // Element
+            let bounding, top = cur == doc.body;
+            let scaleX = 1, scaleY = 1;
+            if (top) {
+                bounding = windowRect(win);
+            }
+            else {
+                if (/^(fixed|sticky)$/.test(getComputedStyle(cur).position))
+                    stop = true;
+                if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
+                    cur = cur.assignedSlot || cur.parentNode;
+                    continue;
+                }
+                let rect = cur.getBoundingClientRect();
+                ({ scaleX, scaleY } = getScale(cur, rect));
+                // Make sure scrollbar width isn't included in the rectangle
+                bounding = { left: rect.left, right: rect.left + cur.clientWidth * scaleX,
+                    top: rect.top, bottom: rect.top + cur.clientHeight * scaleY };
+            }
+            let moveX = 0, moveY = 0;
+            if (y == "nearest") {
+                if (rect.top < bounding.top) {
+                    moveY = -(bounding.top - rect.top + yMargin);
+                    if (side > 0 && rect.bottom > bounding.bottom + moveY)
+                        moveY = rect.bottom - bounding.bottom + moveY + yMargin;
+                }
+                else if (rect.bottom > bounding.bottom) {
+                    moveY = rect.bottom - bounding.bottom + yMargin;
+                    if (side < 0 && (rect.top - moveY) < bounding.top)
+                        moveY = -(bounding.top + moveY - rect.top + yMargin);
+                }
+            }
+            else {
+                let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
+                let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
+                    y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
+                        rect.bottom - boundingHeight + yMargin;
+                moveY = targetTop - bounding.top;
+            }
+            if (x == "nearest") {
+                if (rect.left < bounding.left) {
+                    moveX = -(bounding.left - rect.left + xMargin);
+                    if (side > 0 && rect.right > bounding.right + moveX)
+                        moveX = rect.right - bounding.right + moveX + xMargin;
+                }
+                else if (rect.right > bounding.right) {
+                    moveX = rect.right - bounding.right + xMargin;
+                    if (side < 0 && rect.left < bounding.left + moveX)
+                        moveX = -(bounding.left + moveX - rect.left + xMargin);
+                }
+            }
+            else {
+                let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
+                    (x == "start") == ltr ? rect.left - xMargin :
+                        rect.right - (bounding.right - bounding.left) + xMargin;
+                moveX = targetLeft - bounding.left;
+            }
+            if (moveX || moveY) {
+                if (top) {
+                    win.scrollBy(moveX, moveY);
+                }
+                else {
+                    let movedX = 0, movedY = 0;
+                    if (moveY) {
+                        let start = cur.scrollTop;
+                        cur.scrollTop += moveY / scaleY;
+                        movedY = (cur.scrollTop - start) * scaleY;
+                    }
+                    if (moveX) {
+                        let start = cur.scrollLeft;
+                        cur.scrollLeft += moveX / scaleX;
+                        movedX = (cur.scrollLeft - start) * scaleX;
+                    }
+                    rect = { left: rect.left - movedX, top: rect.top - movedY,
+                        right: rect.right - movedX, bottom: rect.bottom - movedY };
+                    if (movedX && Math.abs(movedX - moveX) < 1)
+                        x = "nearest";
+                    if (movedY && Math.abs(movedY - moveY) < 1)
+                        y = "nearest";
+                }
+            }
+            if (top)
+                break;
+            cur = cur.assignedSlot || cur.parentNode;
+        }
+        else if (cur.nodeType == 11) { // A shadow root
+            cur = cur.host;
+        }
+        else {
+            break;
+        }
+    }
+}
+function scrollableParents(dom) {
+    let doc = dom.ownerDocument, x, y;
+    for (let cur = dom.parentNode; cur;) {
+        if (cur == doc.body || (x && y)) {
+            break;
+        }
+        else if (cur.nodeType == 1) {
+            if (!y && cur.scrollHeight > cur.clientHeight)
+                y = cur;
+            if (!x && cur.scrollWidth > cur.clientWidth)
+                x = cur;
+            cur = cur.assignedSlot || cur.parentNode;
+        }
+        else if (cur.nodeType == 11) {
+            cur = cur.host;
+        }
+        else {
+            break;
+        }
+    }
+    return { x, y };
+}
+class DOMSelectionState {
+    constructor() {
+        this.anchorNode = null;
+        this.anchorOffset = 0;
+        this.focusNode = null;
+        this.focusOffset = 0;
+    }
+    eq(domSel) {
+        return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
+            this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
+    }
+    setRange(range) {
+        let { anchorNode, focusNode } = range;
+        // Clip offsets to node size to avoid crashes when Safari reports bogus offsets (#1152)
+        this.set(anchorNode, Math.min(range.anchorOffset, anchorNode ? maxOffset(anchorNode) : 0), focusNode, Math.min(range.focusOffset, focusNode ? maxOffset(focusNode) : 0));
+    }
+    set(anchorNode, anchorOffset, focusNode, focusOffset) {
+        this.anchorNode = anchorNode;
+        this.anchorOffset = anchorOffset;
+        this.focusNode = focusNode;
+        this.focusOffset = focusOffset;
+    }
+}
+let preventScrollSupported = null;
+// Feature-detects support for .focus({preventScroll: true}), and uses
+// a fallback kludge when not supported.
+function focusPreventScroll(dom) {
+    if (dom.setActive)
+        return dom.setActive(); // in IE
+    if (preventScrollSupported)
+        return dom.focus(preventScrollSupported);
+    let stack = [];
+    for (let cur = dom; cur; cur = cur.parentNode) {
+        stack.push(cur, cur.scrollTop, cur.scrollLeft);
+        if (cur == cur.ownerDocument)
+            break;
+    }
+    dom.focus(preventScrollSupported == null ? {
+        get preventScroll() {
+            preventScrollSupported = { preventScroll: true };
+            return true;
+        }
+    } : undefined);
+    if (!preventScrollSupported) {
+        preventScrollSupported = false;
+        for (let i = 0; i < stack.length;) {
+            let elt = stack[i++], top = stack[i++], left = stack[i++];
+            if (elt.scrollTop != top)
+                elt.scrollTop = top;
+            if (elt.scrollLeft != left)
+                elt.scrollLeft = left;
+        }
+    }
+}
+let scratchRange;
+function textRange(node, from, to = from) {
+    let range = scratchRange || (scratchRange = document.createRange());
+    range.setEnd(node, to);
+    range.setStart(node, from);
+    return range;
+}
+function dispatchKey(elt, name, code, mods) {
+    let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
+    if (mods)
+        ({ altKey: options.altKey, ctrlKey: options.ctrlKey, shiftKey: options.shiftKey, metaKey: options.metaKey } = mods);
+    let down = new KeyboardEvent("keydown", options);
+    down.synthetic = true;
+    elt.dispatchEvent(down);
+    let up = new KeyboardEvent("keyup", options);
+    up.synthetic = true;
+    elt.dispatchEvent(up);
+    return down.defaultPrevented || up.defaultPrevented;
+}
+function getRoot(node) {
+    while (node) {
+        if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
+            return node;
+        node = node.assignedSlot || node.parentNode;
+    }
+    return null;
+}
+function clearAttributes(node) {
+    while (node.attributes.length)
+        node.removeAttributeNode(node.attributes[0]);
+}
+function atElementStart(doc, selection) {
+    let node = selection.focusNode, offset = selection.focusOffset;
+    if (!node || selection.anchorNode != node || selection.anchorOffset != offset)
+        return false;
+    // Safari can report bogus offsets (#1152)
+    offset = Math.min(offset, maxOffset(node));
+    for (;;) {
+        if (offset) {
+            if (node.nodeType != 1)
+                return false;
+            let prev = node.childNodes[offset - 1];
+            if (prev.contentEditable == "false")
+                offset--;
+            else {
+                node = prev;
+                offset = maxOffset(node);
+            }
+        }
+        else if (node == doc) {
+            return true;
+        }
+        else {
+            offset = domIndex(node);
+            node = node.parentNode;
+        }
+    }
+}
+function isScrolledToBottom(elt) {
+    return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);
+}
+function textNodeBefore(startNode, startOffset) {
+    for (let node = startNode, offset = startOffset;;) {
+        if (node.nodeType == 3 && offset > 0) {
+            return { node: node, offset: offset };
+        }
+        else if (node.nodeType == 1 && offset > 0) {
+            if (node.contentEditable == "false")
+                return null;
+            node = node.childNodes[offset - 1];
+            offset = maxOffset(node);
+        }
+        else if (node.parentNode && !isBlockElement(node)) {
+            offset = domIndex(node);
+            node = node.parentNode;
+        }
+        else {
+            return null;
+        }
+    }
+}
+function textNodeAfter(startNode, startOffset) {
+    for (let node = startNode, offset = startOffset;;) {
+        if (node.nodeType == 3 && offset < node.nodeValue.length) {
+            return { node: node, offset: offset };
+        }
+        else if (node.nodeType == 1 && offset < node.childNodes.length) {
+            if (node.contentEditable == "false")
+                return null;
+            node = node.childNodes[offset];
+            offset = 0;
+        }
+        else if (node.parentNode && !isBlockElement(node)) {
+            offset = domIndex(node) + 1;
+            node = node.parentNode;
+        }
+        else {
+            return null;
+        }
+    }
+}
+
+class DOMPos {
+    constructor(node, offset, precise = true) {
+        this.node = node;
+        this.offset = offset;
+        this.precise = precise;
+    }
+    static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom), precise); }
+    static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom) + 1, precise); }
+}
+const noChildren = [];
+class ContentView {
+    constructor() {
+        this.parent = null;
+        this.dom = null;
+        this.flags = 2 /* ViewFlag.NodeDirty */;
+    }
+    get overrideDOMText() { return null; }
+    get posAtStart() {
+        return this.parent ? this.parent.posBefore(this) : 0;
+    }
+    get posAtEnd() {
+        return this.posAtStart + this.length;
+    }
+    posBefore(view) {
+        let pos = this.posAtStart;
+        for (let child of this.children) {
+            if (child == view)
+                return pos;
+            pos += child.length + child.breakAfter;
+        }
+        throw new RangeError("Invalid child in posBefore");
+    }
+    posAfter(view) {
+        return this.posBefore(view) + view.length;
+    }
+    sync(view, track) {
+        if (this.flags & 2 /* ViewFlag.NodeDirty */) {
+            let parent = this.dom;
+            let prev = null, next;
+            for (let child of this.children) {
+                if (child.flags & 7 /* ViewFlag.Dirty */) {
+                    if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
+                        let contentView = ContentView.get(next);
+                        if (!contentView || !contentView.parent && contentView.canReuseDOM(child))
+                            child.reuseDOM(next);
+                    }
+                    child.sync(view, track);
+                    child.flags &= ~7 /* ViewFlag.Dirty */;
+                }
+                next = prev ? prev.nextSibling : parent.firstChild;
+                if (track && !track.written && track.node == parent && next != child.dom)
+                    track.written = true;
+                if (child.dom.parentNode == parent) {
+                    while (next && next != child.dom)
+                        next = rm$1(next);
+                }
+                else {
+                    parent.insertBefore(child.dom, next);
+                }
+                prev = child.dom;
+            }
+            next = prev ? prev.nextSibling : parent.firstChild;
+            if (next && track && track.node == parent)
+                track.written = true;
+            while (next)
+                next = rm$1(next);
+        }
+        else if (this.flags & 1 /* ViewFlag.ChildDirty */) {
+            for (let child of this.children)
+                if (child.flags & 7 /* ViewFlag.Dirty */) {
+                    child.sync(view, track);
+                    child.flags &= ~7 /* ViewFlag.Dirty */;
+                }
+        }
+    }
+    reuseDOM(_dom) { }
+    localPosFromDOM(node, offset) {
+        let after;
+        if (node == this.dom) {
+            after = this.dom.childNodes[offset];
+        }
+        else {
+            let bias = maxOffset(node) == 0 ? 0 : offset == 0 ? -1 : 1;
+            for (;;) {
+                let parent = node.parentNode;
+                if (parent == this.dom)
+                    break;
+                if (bias == 0 && parent.firstChild != parent.lastChild) {
+                    if (node == parent.firstChild)
+                        bias = -1;
+                    else
+                        bias = 1;
+                }
+                node = parent;
+            }
+            if (bias < 0)
+                after = node;
+            else
+                after = node.nextSibling;
+        }
+        if (after == this.dom.firstChild)
+            return 0;
+        while (after && !ContentView.get(after))
+            after = after.nextSibling;
+        if (!after)
+            return this.length;
+        for (let i = 0, pos = 0;; i++) {
+            let child = this.children[i];
+            if (child.dom == after)
+                return pos;
+            pos += child.length + child.breakAfter;
+        }
+    }
+    domBoundsAround(from, to, offset = 0) {
+        let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
+        for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
+            let child = this.children[i], end = pos + child.length;
+            if (pos < from && end > to)
+                return child.domBoundsAround(from, to, pos);
+            if (end >= from && fromI == -1) {
+                fromI = i;
+                fromStart = pos;
+            }
+            if (pos > to && child.dom.parentNode == this.dom) {
+                toI = i;
+                toEnd = prevEnd;
+                break;
+            }
+            prevEnd = end;
+            pos = end + child.breakAfter;
+        }
+        return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
+            startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
+            endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
+    }
+    markDirty(andParent = false) {
+        this.flags |= 2 /* ViewFlag.NodeDirty */;
+        this.markParentsDirty(andParent);
+    }
+    markParentsDirty(childList) {
+        for (let parent = this.parent; parent; parent = parent.parent) {
+            if (childList)
+                parent.flags |= 2 /* ViewFlag.NodeDirty */;
+            if (parent.flags & 1 /* ViewFlag.ChildDirty */)
+                return;
+            parent.flags |= 1 /* ViewFlag.ChildDirty */;
+            childList = false;
+        }
+    }
+    setParent(parent) {
+        if (this.parent != parent) {
+            this.parent = parent;
+            if (this.flags & 7 /* ViewFlag.Dirty */)
+                this.markParentsDirty(true);
+        }
+    }
+    setDOM(dom) {
+        if (this.dom == dom)
+            return;
+        if (this.dom)
+            this.dom.cmView = null;
+        this.dom = dom;
+        dom.cmView = this;
+    }
+    get rootView() {
+        for (let v = this;;) {
+            let parent = v.parent;
+            if (!parent)
+                return v;
+            v = parent;
+        }
+    }
+    replaceChildren(from, to, children = noChildren) {
+        this.markDirty();
+        for (let i = from; i < to; i++) {
+            let child = this.children[i];
+            if (child.parent == this && children.indexOf(child) < 0)
+                child.destroy();
+        }
+        if (children.length < 250)
+            this.children.splice(from, to - from, ...children);
+        else
+            this.children = [].concat(this.children.slice(0, from), children, this.children.slice(to));
+        for (let i = 0; i < children.length; i++)
+            children[i].setParent(this);
+    }
+    ignoreMutation(_rec) { return false; }
+    ignoreEvent(_event) { return false; }
+    childCursor(pos = this.length) {
+        return new ChildCursor(this.children, pos, this.children.length);
+    }
+    childPos(pos, bias = 1) {
+        return this.childCursor().findPos(pos, bias);
+    }
+    toString() {
+        let name = this.constructor.name.replace("View", "");
+        return name + (this.children.length ? "(" + this.children.join() + ")" :
+            this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
+            (this.breakAfter ? "#" : "");
+    }
+    static get(node) { return node.cmView; }
+    get isEditable() { return true; }
+    get isWidget() { return false; }
+    get isHidden() { return false; }
+    merge(from, to, source, hasStart, openStart, openEnd) {
+        return false;
+    }
+    become(other) { return false; }
+    canReuseDOM(other) {
+        return other.constructor == this.constructor && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);
+    }
+    // When this is a zero-length view with a side, this should return a
+    // number <= 0 to indicate it is before its position, or a
+    // number > 0 when after its position.
+    getSide() { return 0; }
+    destroy() {
+        for (let child of this.children)
+            if (child.parent == this)
+                child.destroy();
+        this.parent = null;
+    }
+}
+ContentView.prototype.breakAfter = 0;
+// Remove a DOM node and return its next sibling.
+function rm$1(dom) {
+    let next = dom.nextSibling;
+    dom.parentNode.removeChild(dom);
+    return next;
+}
+class ChildCursor {
+    constructor(children, pos, i) {
+        this.children = children;
+        this.pos = pos;
+        this.i = i;
+        this.off = 0;
+    }
+    findPos(pos, bias = 1) {
+        for (;;) {
+            if (pos > this.pos || pos == this.pos &&
+                (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
+                this.off = pos - this.pos;
+                return this;
+            }
+            let next = this.children[--this.i];
+            this.pos -= next.length + next.breakAfter;
+        }
+    }
+}
+function replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
+    let { children } = parent;
+    let before = children.length ? children[fromI] : null;
+    let last = insert.length ? insert[insert.length - 1] : null;
+    let breakAtEnd = last ? last.breakAfter : breakAtStart;
+    // Change within a single child
+    if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
+        before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
+        return;
+    if (toI < children.length) {
+        let after = children[toI];
+        // Make sure the end of the child after the update is preserved in `after`
+        if (after && (toOff < after.length || after.breakAfter && (last === null || last === void 0 ? void 0 : last.breakAfter))) {
+            // If we're splitting a child, separate part of it to avoid that
+            // being mangled when updating the child before the update.
+            if (fromI == toI) {
+                after = after.split(toOff);
+                toOff = 0;
+            }
+            // If the element after the replacement should be merged with
+            // the last replacing element, update `content`
+            if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
+                insert[insert.length - 1] = after;
+            }
+            else {
+                // Remove the start of the after element, if necessary, and
+                // add it to `content`.
+                if (toOff || after.children.length && !after.children[0].length)
+                    after.merge(0, toOff, null, false, 0, openEnd);
+                insert.push(after);
+            }
+        }
+        else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
+            // The element at `toI` is entirely covered by this range.
+            // Preserve its line break, if any.
+            if (last)
+                last.breakAfter = 1;
+            else
+                breakAtStart = 1;
+        }
+        // Since we've handled the next element from the current elements
+        // now, make sure `toI` points after that.
+        toI++;
+    }
+    if (before) {
+        before.breakAfter = breakAtStart;
+        if (fromOff > 0) {
+            if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
+                before.breakAfter = insert.shift().breakAfter;
+            }
+            else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
+                before.merge(fromOff, before.length, null, false, openStart, 0);
+            }
+            fromI++;
+        }
+    }
+    // Try to merge widgets on the boundaries of the replacement
+    while (fromI < toI && insert.length) {
+        if (children[toI - 1].become(insert[insert.length - 1])) {
+            toI--;
+            insert.pop();
+            openEnd = insert.length ? 0 : openStart;
+        }
+        else if (children[fromI].become(insert[0])) {
+            fromI++;
+            insert.shift();
+            openStart = insert.length ? 0 : openEnd;
+        }
+        else {
+            break;
+        }
+    }
+    if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
+        children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
+        fromI--;
+    if (fromI < toI || insert.length)
+        parent.replaceChildren(fromI, toI, insert);
+}
+function mergeChildrenInto(parent, from, to, insert, openStart, openEnd) {
+    let cur = parent.childCursor();
+    let { i: toI, off: toOff } = cur.findPos(to, 1);
+    let { i: fromI, off: fromOff } = cur.findPos(from, -1);
+    let dLen = from - to;
+    for (let view of insert)
+        dLen += view.length;
+    parent.length += dLen;
+    replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
+}
+
+let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
+let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
+const ie_edge = /*@__PURE__*//Edge\/(\d+)/.exec(nav.userAgent);
+const ie_upto10 = /*@__PURE__*//MSIE \d/.test(nav.userAgent);
+const ie_11up = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
+const ie = !!(ie_upto10 || ie_11up || ie_edge);
+const gecko = !ie && /*@__PURE__*//gecko\/(\d+)/i.test(nav.userAgent);
+const chrome = !ie && /*@__PURE__*//Chrome\/(\d+)/.exec(nav.userAgent);
+const webkit = "webkitFontSmoothing" in doc.documentElement.style;
+const safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);
+const ios = safari && (/*@__PURE__*//Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
+var browser = {
+    mac: ios || /*@__PURE__*//Mac/.test(nav.platform),
+    windows: /*@__PURE__*//Win/.test(nav.platform),
+    linux: /*@__PURE__*//Linux|X11/.test(nav.platform),
+    ie,
+    ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
+    gecko,
+    gecko_version: gecko ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
+    chrome: !!chrome,
+    chrome_version: chrome ? +chrome[1] : 0,
+    ios,
+    android: /*@__PURE__*//Android\b/.test(nav.userAgent),
+    webkit,
+    safari,
+    webkit_version: webkit ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
+    tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
+};
+
+const MaxJoinLen = 256;
+class TextView extends ContentView {
+    constructor(text) {
+        super();
+        this.text = text;
+    }
+    get length() { return this.text.length; }
+    createDOM(textDOM) {
+        this.setDOM(textDOM || document.createTextNode(this.text));
+    }
+    sync(view, track) {
+        if (!this.dom)
+            this.createDOM();
+        if (this.dom.nodeValue != this.text) {
+            if (track && track.node == this.dom)
+                track.written = true;
+            this.dom.nodeValue = this.text;
+        }
+    }
+    reuseDOM(dom) {
+        if (dom.nodeType == 3)
+            this.createDOM(dom);
+    }
+    merge(from, to, source) {
+        if ((this.flags & 8 /* ViewFlag.Composition */) ||
+            source && (!(source instanceof TextView) ||
+                this.length - (to - from) + source.length > MaxJoinLen ||
+                (source.flags & 8 /* ViewFlag.Composition */)))
+            return false;
+        this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
+        this.markDirty();
+        return true;
+    }
+    split(from) {
+        let result = new TextView(this.text.slice(from));
+        this.text = this.text.slice(0, from);
+        this.markDirty();
+        result.flags |= this.flags & 8 /* ViewFlag.Composition */;
+        return result;
+    }
+    localPosFromDOM(node, offset) {
+        return node == this.dom ? offset : offset ? this.text.length : 0;
+    }
+    domAtPos(pos) { return new DOMPos(this.dom, pos); }
+    domBoundsAround(_from, _to, offset) {
+        return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
+    }
+    coordsAt(pos, side) {
+        return textCoords(this.dom, pos, side);
+    }
+}
+class MarkView extends ContentView {
+    constructor(mark, children = [], length = 0) {
+        super();
+        this.mark = mark;
+        this.children = children;
+        this.length = length;
+        for (let ch of children)
+            ch.setParent(this);
+    }
+    setAttrs(dom) {
+        clearAttributes(dom);
+        if (this.mark.class)
+            dom.className = this.mark.class;
+        if (this.mark.attrs)
+            for (let name in this.mark.attrs)
+                dom.setAttribute(name, this.mark.attrs[name]);
+        return dom;
+    }
+    canReuseDOM(other) {
+        return super.canReuseDOM(other) && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);
+    }
+    reuseDOM(node) {
+        if (node.nodeName == this.mark.tagName.toUpperCase()) {
+            this.setDOM(node);
+            this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;
+        }
+    }
+    sync(view, track) {
+        if (!this.dom)
+            this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
+        else if (this.flags & 4 /* ViewFlag.AttrsDirty */)
+            this.setAttrs(this.dom);
+        super.sync(view, track);
+    }
+    merge(from, to, source, _hasStart, openStart, openEnd) {
+        if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
+            (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
+            return false;
+        mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart - 1, openEnd - 1);
+        this.markDirty();
+        return true;
+    }
+    split(from) {
+        let result = [], off = 0, detachFrom = -1, i = 0;
+        for (let elt of this.children) {
+            let end = off + elt.length;
+            if (end > from)
+                result.push(off < from ? elt.split(from - off) : elt);
+            if (detachFrom < 0 && off >= from)
+                detachFrom = i;
+            off = end;
+            i++;
+        }
+        let length = this.length - from;
+        this.length = from;
+        if (detachFrom > -1) {
+            this.children.length = detachFrom;
+            this.markDirty();
+        }
+        return new MarkView(this.mark, result, length);
+    }
+    domAtPos(pos) {
+        return inlineDOMAtPos(this, pos);
+    }
+    coordsAt(pos, side) {
+        return coordsInChildren(this, pos, side);
+    }
+}
+function textCoords(text, pos, side) {
+    let length = text.nodeValue.length;
+    if (pos > length)
+        pos = length;
+    let from = pos, to = pos, flatten = 0;
+    if (pos == 0 && side < 0 || pos == length && side >= 0) {
+        if (!(browser.chrome || browser.gecko)) { // These browsers reliably return valid rectangles for empty ranges
+            if (pos) {
+                from--;
+                flatten = 1;
+            } // FIXME this is wrong in RTL text
+            else if (to < length) {
+                to++;
+                flatten = -1;
+            }
+        }
+    }
+    else {
+        if (side < 0)
+            from--;
+        else if (to < length)
+            to++;
+    }
+    let rects = textRange(text, from, to).getClientRects();
+    if (!rects.length)
+        return null;
+    let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
+    if (browser.safari && !flatten && rect.width == 0)
+        rect = Array.prototype.find.call(rects, r => r.width) || rect;
+    return flatten ? flattenRect(rect, flatten < 0) : rect || null;
+}
+// Also used for collapsed ranges that don't have a placeholder widget!
+class WidgetView extends ContentView {
+    static create(widget, length, side) {
+        return new WidgetView(widget, length, side);
+    }
+    constructor(widget, length, side) {
+        super();
+        this.widget = widget;
+        this.length = length;
+        this.side = side;
+        this.prevWidget = null;
+    }
+    split(from) {
+        let result = WidgetView.create(this.widget, this.length - from, this.side);
+        this.length -= from;
+        return result;
+    }
+    sync(view) {
+        if (!this.dom || !this.widget.updateDOM(this.dom, view)) {
+            if (this.dom && this.prevWidget)
+                this.prevWidget.destroy(this.dom);
+            this.prevWidget = null;
+            this.setDOM(this.widget.toDOM(view));
+            if (!this.widget.editable)
+                this.dom.contentEditable = "false";
+        }
+    }
+    getSide() { return this.side; }
+    merge(from, to, source, hasStart, openStart, openEnd) {
+        if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
+            from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+            return false;
+        this.length = from + (source ? source.length : 0) + (this.length - to);
+        return true;
+    }
+    become(other) {
+        if (other instanceof WidgetView && other.side == this.side &&
+            this.widget.constructor == other.widget.constructor) {
+            if (!this.widget.compare(other.widget))
+                this.markDirty(true);
+            if (this.dom && !this.prevWidget)
+                this.prevWidget = this.widget;
+            this.widget = other.widget;
+            this.length = other.length;
+            return true;
+        }
+        return false;
+    }
+    ignoreMutation() { return true; }
+    ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+    get overrideDOMText() {
+        if (this.length == 0)
+            return Text.empty;
+        let top = this;
+        while (top.parent)
+            top = top.parent;
+        let { view } = top, text = view && view.state.doc, start = this.posAtStart;
+        return text ? text.slice(start, start + this.length) : Text.empty;
+    }
+    domAtPos(pos) {
+        return (this.length ? pos == 0 : this.side > 0)
+            ? DOMPos.before(this.dom)
+            : DOMPos.after(this.dom, pos == this.length);
+    }
+    domBoundsAround() { return null; }
+    coordsAt(pos, side) {
+        let custom = this.widget.coordsAt(this.dom, pos, side);
+        if (custom)
+            return custom;
+        let rects = this.dom.getClientRects(), rect = null;
+        if (!rects.length)
+            return null;
+        let fromBack = this.side ? this.side < 0 : pos > 0;
+        for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {
+            rect = rects[i];
+            if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
+                break;
+        }
+        return flattenRect(rect, !fromBack);
+    }
+    get isEditable() { return false; }
+    get isWidget() { return true; }
+    get isHidden() { return this.widget.isHidden; }
+    destroy() {
+        super.destroy();
+        if (this.dom)
+            this.widget.destroy(this.dom);
+    }
+}
+// These are drawn around uneditable widgets to avoid a number of
+// browser bugs that show up when the cursor is directly next to
+// uneditable inline content.
+class WidgetBufferView extends ContentView {
+    constructor(side) {
+        super();
+        this.side = side;
+    }
+    get length() { return 0; }
+    merge() { return false; }
+    become(other) {
+        return other instanceof WidgetBufferView && other.side == this.side;
+    }
+    split() { return new WidgetBufferView(this.side); }
+    sync() {
+        if (!this.dom) {
+            let dom = document.createElement("img");
+            dom.className = "cm-widgetBuffer";
+            dom.setAttribute("aria-hidden", "true");
+            this.setDOM(dom);
+        }
+    }
+    getSide() { return this.side; }
+    domAtPos(pos) { return this.side > 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom); }
+    localPosFromDOM() { return 0; }
+    domBoundsAround() { return null; }
+    coordsAt(pos) {
+        return this.dom.getBoundingClientRect();
+    }
+    get overrideDOMText() {
+        return Text.empty;
+    }
+    get isHidden() { return true; }
+}
+TextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;
+function inlineDOMAtPos(parent, pos) {
+    let dom = parent.dom, { children } = parent, i = 0;
+    for (let off = 0; i < children.length; i++) {
+        let child = children[i], end = off + child.length;
+        if (end == off && child.getSide() <= 0)
+            continue;
+        if (pos > off && pos < end && child.dom.parentNode == dom)
+            return child.domAtPos(pos - off);
+        if (pos <= off)
+            break;
+        off = end;
+    }
+    for (let j = i; j > 0; j--) {
+        let prev = children[j - 1];
+        if (prev.dom.parentNode == dom)
+            return prev.domAtPos(prev.length);
+    }
+    for (let j = i; j < children.length; j++) {
+        let next = children[j];
+        if (next.dom.parentNode == dom)
+            return next.domAtPos(0);
+    }
+    return new DOMPos(dom, 0);
+}
+// Assumes `view`, if a mark view, has precisely 1 child.
+function joinInlineInto(parent, view, open) {
+    let last, { children } = parent;
+    if (open > 0 && view instanceof MarkView && children.length &&
+        (last = children[children.length - 1]) instanceof MarkView && last.mark.eq(view.mark)) {
+        joinInlineInto(last, view.children[0], open - 1);
+    }
+    else {
+        children.push(view);
+        view.setParent(parent);
+    }
+    parent.length += view.length;
+}
+function coordsInChildren(view, pos, side) {
+    let before = null, beforePos = -1, after = null, afterPos = -1;
+    function scan(view, pos) {
+        for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {
+            let child = view.children[i], end = off + child.length;
+            if (end >= pos) {
+                if (child.children.length) {
+                    scan(child, pos - off);
+                }
+                else if ((!after || after.isHidden && side > 0) &&
+                    (end > pos || off == end && child.getSide() > 0)) {
+                    after = child;
+                    afterPos = pos - off;
+                }
+                else if (off < pos || (off == end && child.getSide() < 0) && !child.isHidden) {
+                    before = child;
+                    beforePos = pos - off;
+                }
+            }
+            off = end;
+        }
+    }
+    scan(view, pos);
+    let target = (side < 0 ? before : after) || before || after;
+    if (target)
+        return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);
+    return fallbackRect(view);
+}
+function fallbackRect(view) {
+    let last = view.dom.lastChild;
+    if (!last)
+        return view.dom.getBoundingClientRect();
+    let rects = clientRectsFor(last);
+    return rects[rects.length - 1] || null;
+}
+
+function combineAttrs(source, target) {
+    for (let name in source) {
+        if (name == "class" && target.class)
+            target.class += " " + source.class;
+        else if (name == "style" && target.style)
+            target.style += ";" + source.style;
+        else
+            target[name] = source[name];
+    }
+    return target;
+}
+const noAttrs$1 = /*@__PURE__*/Object.create(null);
+function attrsEq(a, b, ignore) {
+    if (a == b)
+        return true;
+    if (!a)
+        a = noAttrs$1;
+    if (!b)
+        b = noAttrs$1;
+    let keysA = Object.keys(a), keysB = Object.keys(b);
+    if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) !=
+        keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0))
+        return false;
+    for (let key of keysA) {
+        if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key]))
+            return false;
+    }
+    return true;
+}
+function updateAttrs(dom, prev, attrs) {
+    let changed = false;
+    if (prev)
+        for (let name in prev)
+            if (!(attrs && name in attrs)) {
+                changed = true;
+                if (name == "style")
+                    dom.style.cssText = "";
+                else
+                    dom.removeAttribute(name);
+            }
+    if (attrs)
+        for (let name in attrs)
+            if (!(prev && prev[name] == attrs[name])) {
+                changed = true;
+                if (name == "style")
+                    dom.style.cssText = attrs[name];
+                else
+                    dom.setAttribute(name, attrs[name]);
+            }
+    return changed;
+}
+function getAttrs(dom) {
+    let attrs = Object.create(null);
+    for (let i = 0; i < dom.attributes.length; i++) {
+        let attr = dom.attributes[i];
+        attrs[attr.name] = attr.value;
+    }
+    return attrs;
+}
+
+/**
+Widgets added to the content are described by subclasses of this
+class. Using a description object like that makes it possible to
+delay creating of the DOM structure for a widget until it is
+needed, and to avoid redrawing widgets even if the decorations
+that define them are recreated.
+*/
+class WidgetType {
+    /**
+    Compare this instance to another instance of the same type.
+    (TypeScript can't express this, but only instances of the same
+    specific class will be passed to this method.) This is used to
+    avoid redrawing widgets when they are replaced by a new
+    decoration of the same type. The default implementation just
+    returns `false`, which will cause new instances of the widget to
+    always be redrawn.
+    */
+    eq(widget) { return false; }
+    /**
+    Update a DOM element created by a widget of the same type (but
+    different, non-`eq` content) to reflect this widget. May return
+    true to indicate that it could update, false to indicate it
+    couldn't (in which case the widget will be redrawn). The default
+    implementation just returns false.
+    */
+    updateDOM(dom, view) { return false; }
+    /**
+    @internal
+    */
+    compare(other) {
+        return this == other || this.constructor == other.constructor && this.eq(other);
+    }
+    /**
+    The estimated height this widget will have, to be used when
+    estimating the height of content that hasn't been drawn. May
+    return -1 to indicate you don't know. The default implementation
+    returns -1.
+    */
+    get estimatedHeight() { return -1; }
+    /**
+    For inline widgets that are displayed inline (as opposed to
+    `inline-block`) and introduce line breaks (through `<br>` tags
+    or textual newlines), this must indicate the amount of line
+    breaks they introduce. Defaults to 0.
+    */
+    get lineBreaks() { return 0; }
+    /**
+    Can be used to configure which kinds of events inside the widget
+    should be ignored by the editor. The default is to ignore all
+    events.
+    */
+    ignoreEvent(event) { return true; }
+    /**
+    Override the way screen coordinates for positions at/in the
+    widget are found. `pos` will be the offset into the widget, and
+    `side` the side of the position that is being queried—less than
+    zero for before, greater than zero for after, and zero for
+    directly at that position.
+    */
+    coordsAt(dom, pos, side) { return null; }
+    /**
+    @internal
+    */
+    get isHidden() { return false; }
+    /**
+    @internal
+    */
+    get editable() { return false; }
+    /**
+    This is called when the an instance of the widget is removed
+    from the editor view.
+    */
+    destroy(dom) { }
+}
+/**
+The different types of blocks that can occur in an editor view.
+*/
+var BlockType = /*@__PURE__*/(function (BlockType) {
+    /**
+    A line of text.
+    */
+    BlockType[BlockType["Text"] = 0] = "Text";
+    /**
+    A block widget associated with the position after it.
+    */
+    BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
+    /**
+    A block widget associated with the position before it.
+    */
+    BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
+    /**
+    A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
+    */
+    BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
+return BlockType})(BlockType || (BlockType = {}));
+/**
+A decoration provides information on how to draw or style a piece
+of content. You'll usually use it wrapped in a
+[`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
+@nonabstract
+*/
+class Decoration extends RangeValue {
+    constructor(
+    /**
+    @internal
+    */
+    startSide, 
+    /**
+    @internal
+    */
+    endSide, 
+    /**
+    @internal
+    */
+    widget, 
+    /**
+    The config object used to create this decoration. You can
+    include additional properties in there to store metadata about
+    your decoration.
+    */
+    spec) {
+        super();
+        this.startSide = startSide;
+        this.endSide = endSide;
+        this.widget = widget;
+        this.spec = spec;
+    }
+    /**
+    @internal
+    */
+    get heightRelevant() { return false; }
+    /**
+    Create a mark decoration, which influences the styling of the
+    content in its range. Nested mark decorations will cause nested
+    DOM elements to be created. Nesting order is determined by
+    precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
+    the higher-precedence decorations creating the inner DOM nodes.
+    Such elements are split on line boundaries and on the boundaries
+    of lower-precedence decorations.
+    */
+    static mark(spec) {
+        return new MarkDecoration(spec);
+    }
+    /**
+    Create a widget decoration, which displays a DOM element at the
+    given position.
+    */
+    static widget(spec) {
+        let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;
+        side += (block && !spec.inlineOrder)
+            ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */)
+            : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
+        return new PointDecoration(spec, side, side, block, spec.widget || null, false);
+    }
+    /**
+    Create a replace decoration which replaces the given range with
+    a widget, or simply hides it.
+    */
+    static replace(spec) {
+        let block = !!spec.block, startSide, endSide;
+        if (spec.isBlockGap) {
+            startSide = -500000000 /* Side.GapStart */;
+            endSide = 400000000 /* Side.GapEnd */;
+        }
+        else {
+            let { start, end } = getInclusive(spec, block);
+            startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
+            endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
+        }
+        return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
+    }
+    /**
+    Create a line decoration, which can add DOM attributes to the
+    line starting at the given position.
+    */
+    static line(spec) {
+        return new LineDecoration(spec);
+    }
+    /**
+    Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
+    decorated range or ranges. If the ranges aren't already sorted,
+    pass `true` for `sort` to make the library sort them for you.
+    */
+    static set(of, sort = false) {
+        return RangeSet.of(of, sort);
+    }
+    /**
+    @internal
+    */
+    hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
+}
+/**
+The empty set of decorations.
+*/
+Decoration.none = RangeSet.empty;
+class MarkDecoration extends Decoration {
+    constructor(spec) {
+        let { start, end } = getInclusive(spec);
+        super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
+        this.tagName = spec.tagName || "span";
+        this.class = spec.class || "";
+        this.attrs = spec.attributes || null;
+    }
+    eq(other) {
+        var _a, _b;
+        return this == other ||
+            other instanceof MarkDecoration &&
+                this.tagName == other.tagName &&
+                (this.class || ((_a = this.attrs) === null || _a === void 0 ? void 0 : _a.class)) == (other.class || ((_b = other.attrs) === null || _b === void 0 ? void 0 : _b.class)) &&
+                attrsEq(this.attrs, other.attrs, "class");
+    }
+    range(from, to = from) {
+        if (from >= to)
+            throw new RangeError("Mark decorations may not be empty");
+        return super.range(from, to);
+    }
+}
+MarkDecoration.prototype.point = false;
+class LineDecoration extends Decoration {
+    constructor(spec) {
+        super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
+    }
+    eq(other) {
+        return other instanceof LineDecoration &&
+            this.spec.class == other.spec.class &&
+            attrsEq(this.spec.attributes, other.spec.attributes);
+    }
+    range(from, to = from) {
+        if (to != from)
+            throw new RangeError("Line decoration ranges must be zero-length");
+        return super.range(from, to);
+    }
+}
+LineDecoration.prototype.mapMode = MapMode.TrackBefore;
+LineDecoration.prototype.point = true;
+class PointDecoration extends Decoration {
+    constructor(spec, startSide, endSide, block, widget, isReplace) {
+        super(startSide, endSide, widget, spec);
+        this.block = block;
+        this.isReplace = isReplace;
+        this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter;
+    }
+    // Only relevant when this.block == true
+    get type() {
+        return this.startSide != this.endSide ? BlockType.WidgetRange
+            : this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;
+    }
+    get heightRelevant() {
+        return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
+    }
+    eq(other) {
+        return other instanceof PointDecoration &&
+            widgetsEq(this.widget, other.widget) &&
+            this.block == other.block &&
+            this.startSide == other.startSide && this.endSide == other.endSide;
+    }
+    range(from, to = from) {
+        if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
+            throw new RangeError("Invalid range for replacement decoration");
+        if (!this.isReplace && to != from)
+            throw new RangeError("Widget decorations can only have zero-length ranges");
+        return super.range(from, to);
+    }
+}
+PointDecoration.prototype.point = true;
+function getInclusive(spec, block = false) {
+    let { inclusiveStart: start, inclusiveEnd: end } = spec;
+    if (start == null)
+        start = spec.inclusive;
+    if (end == null)
+        end = spec.inclusive;
+    return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
+}
+function widgetsEq(a, b) {
+    return a == b || !!(a && b && a.compare(b));
+}
+function addRange(from, to, ranges, margin = 0) {
+    let last = ranges.length - 1;
+    if (last >= 0 && ranges[last] + margin >= from)
+        ranges[last] = Math.max(ranges[last], to);
+    else
+        ranges.push(from, to);
+}
+
+class LineView extends ContentView {
+    constructor() {
+        super(...arguments);
+        this.children = [];
+        this.length = 0;
+        this.prevAttrs = undefined;
+        this.attrs = null;
+        this.breakAfter = 0;
+    }
+    // Consumes source
+    merge(from, to, source, hasStart, openStart, openEnd) {
+        if (source) {
+            if (!(source instanceof LineView))
+                return false;
+            if (!this.dom)
+                source.transferDOM(this); // Reuse source.dom when appropriate
+        }
+        if (hasStart)
+            this.setDeco(source ? source.attrs : null);
+        mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart, openEnd);
+        return true;
+    }
+    split(at) {
+        let end = new LineView;
+        end.breakAfter = this.breakAfter;
+        if (this.length == 0)
+            return end;
+        let { i, off } = this.childPos(at);
+        if (off) {
+            end.append(this.children[i].split(off), 0);
+            this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
+            i++;
+        }
+        for (let j = i; j < this.children.length; j++)
+            end.append(this.children[j], 0);
+        while (i > 0 && this.children[i - 1].length == 0)
+            this.children[--i].destroy();
+        this.children.length = i;
+        this.markDirty();
+        this.length = at;
+        return end;
+    }
+    transferDOM(other) {
+        if (!this.dom)
+            return;
+        this.markDirty();
+        other.setDOM(this.dom);
+        other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
+        this.prevAttrs = undefined;
+        this.dom = null;
+    }
+    setDeco(attrs) {
+        if (!attrsEq(this.attrs, attrs)) {
+            if (this.dom) {
+                this.prevAttrs = this.attrs;
+                this.markDirty();
+            }
+            this.attrs = attrs;
+        }
+    }
+    append(child, openStart) {
+        joinInlineInto(this, child, openStart);
+    }
+    // Only called when building a line view in ContentBuilder
+    addLineDeco(deco) {
+        let attrs = deco.spec.attributes, cls = deco.spec.class;
+        if (attrs)
+            this.attrs = combineAttrs(attrs, this.attrs || {});
+        if (cls)
+            this.attrs = combineAttrs({ class: cls }, this.attrs || {});
+    }
+    domAtPos(pos) {
+        return inlineDOMAtPos(this, pos);
+    }
+    reuseDOM(node) {
+        if (node.nodeName == "DIV") {
+            this.setDOM(node);
+            this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;
+        }
+    }
+    sync(view, track) {
+        var _a;
+        if (!this.dom) {
+            this.setDOM(document.createElement("div"));
+            this.dom.className = "cm-line";
+            this.prevAttrs = this.attrs ? null : undefined;
+        }
+        else if (this.flags & 4 /* ViewFlag.AttrsDirty */) {
+            clearAttributes(this.dom);
+            this.dom.className = "cm-line";
+            this.prevAttrs = this.attrs ? null : undefined;
+        }
+        if (this.prevAttrs !== undefined) {
+            updateAttrs(this.dom, this.prevAttrs, this.attrs);
+            this.dom.classList.add("cm-line");
+            this.prevAttrs = undefined;
+        }
+        super.sync(view, track);
+        let last = this.dom.lastChild;
+        while (last && ContentView.get(last) instanceof MarkView)
+            last = last.lastChild;
+        if (!last || !this.length ||
+            last.nodeName != "BR" && ((_a = ContentView.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
+                (!browser.ios || !this.children.some(ch => ch instanceof TextView))) {
+            let hack = document.createElement("BR");
+            hack.cmIgnore = true;
+            this.dom.appendChild(hack);
+        }
+    }
+    measureTextSize() {
+        if (this.children.length == 0 || this.length > 20)
+            return null;
+        let totalWidth = 0, textHeight;
+        for (let child of this.children) {
+            if (!(child instanceof TextView) || /[^ -~]/.test(child.text))
+                return null;
+            let rects = clientRectsFor(child.dom);
+            if (rects.length != 1)
+                return null;
+            totalWidth += rects[0].width;
+            textHeight = rects[0].height;
+        }
+        return !totalWidth ? null : {
+            lineHeight: this.dom.getBoundingClientRect().height,
+            charWidth: totalWidth / this.length,
+            textHeight
+        };
+    }
+    coordsAt(pos, side) {
+        let rect = coordsInChildren(this, pos, side);
+        // Correct rectangle height for empty lines when the returned
+        // height is larger than the text height.
+        if (!this.children.length && rect && this.parent) {
+            let { heightOracle } = this.parent.view.viewState, height = rect.bottom - rect.top;
+            if (Math.abs(height - heightOracle.lineHeight) < 2 && heightOracle.textHeight < height) {
+                let dist = (height - heightOracle.textHeight) / 2;
+                return { top: rect.top + dist, bottom: rect.bottom - dist, left: rect.left, right: rect.left };
+            }
+        }
+        return rect;
+    }
+    become(other) {
+        return other instanceof LineView && this.children.length == 0 && other.children.length == 0 &&
+            attrsEq(this.attrs, other.attrs) && this.breakAfter == other.breakAfter;
+    }
+    covers() { return true; }
+    static find(docView, pos) {
+        for (let i = 0, off = 0; i < docView.children.length; i++) {
+            let block = docView.children[i], end = off + block.length;
+            if (end >= pos) {
+                if (block instanceof LineView)
+                    return block;
+                if (end > pos)
+                    break;
+            }
+            off = end + block.breakAfter;
+        }
+        return null;
+    }
+}
+class BlockWidgetView extends ContentView {
+    constructor(widget, length, deco) {
+        super();
+        this.widget = widget;
+        this.length = length;
+        this.deco = deco;
+        this.breakAfter = 0;
+        this.prevWidget = null;
+    }
+    merge(from, to, source, _takeDeco, openStart, openEnd) {
+        if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
+            from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+            return false;
+        this.length = from + (source ? source.length : 0) + (this.length - to);
+        return true;
+    }
+    domAtPos(pos) {
+        return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);
+    }
+    split(at) {
+        let len = this.length - at;
+        this.length = at;
+        let end = new BlockWidgetView(this.widget, len, this.deco);
+        end.breakAfter = this.breakAfter;
+        return end;
+    }
+    get children() { return noChildren; }
+    sync(view) {
+        if (!this.dom || !this.widget.updateDOM(this.dom, view)) {
+            if (this.dom && this.prevWidget)
+                this.prevWidget.destroy(this.dom);
+            this.prevWidget = null;
+            this.setDOM(this.widget.toDOM(view));
+            if (!this.widget.editable)
+                this.dom.contentEditable = "false";
+        }
+    }
+    get overrideDOMText() {
+        return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;
+    }
+    domBoundsAround() { return null; }
+    become(other) {
+        if (other instanceof BlockWidgetView &&
+            other.widget.constructor == this.widget.constructor) {
+            if (!other.widget.compare(this.widget))
+                this.markDirty(true);
+            if (this.dom && !this.prevWidget)
+                this.prevWidget = this.widget;
+            this.widget = other.widget;
+            this.length = other.length;
+            this.deco = other.deco;
+            this.breakAfter = other.breakAfter;
+            return true;
+        }
+        return false;
+    }
+    ignoreMutation() { return true; }
+    ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+    get isEditable() { return false; }
+    get isWidget() { return true; }
+    coordsAt(pos, side) {
+        let custom = this.widget.coordsAt(this.dom, pos, side);
+        if (custom)
+            return custom;
+        if (this.widget instanceof BlockGapWidget)
+            return null;
+        return flattenRect(this.dom.getBoundingClientRect(), this.length ? pos == 0 : side <= 0);
+    }
+    destroy() {
+        super.destroy();
+        if (this.dom)
+            this.widget.destroy(this.dom);
+    }
+    covers(side) {
+        let { startSide, endSide } = this.deco;
+        return startSide == endSide ? false : side < 0 ? startSide < 0 : endSide > 0;
+    }
+}
+class BlockGapWidget extends WidgetType {
+    constructor(height) {
+        super();
+        this.height = height;
+    }
+    toDOM() {
+        let elt = document.createElement("div");
+        elt.className = "cm-gap";
+        this.updateDOM(elt);
+        return elt;
+    }
+    eq(other) { return other.height == this.height; }
+    updateDOM(elt) {
+        elt.style.height = this.height + "px";
+        return true;
+    }
+    get editable() { return true; }
+    get estimatedHeight() { return this.height; }
+    ignoreEvent() { return false; }
+}
+
+class ContentBuilder {
+    constructor(doc, pos, end, disallowBlockEffectsFor) {
+        this.doc = doc;
+        this.pos = pos;
+        this.end = end;
+        this.disallowBlockEffectsFor = disallowBlockEffectsFor;
+        this.content = [];
+        this.curLine = null;
+        this.breakAtStart = 0;
+        this.pendingBuffer = 0 /* Buf.No */;
+        this.bufferMarks = [];
+        // Set to false directly after a widget that covers the position after it
+        this.atCursorPos = true;
+        this.openStart = -1;
+        this.openEnd = -1;
+        this.text = "";
+        this.textOff = 0;
+        this.cursor = doc.iter();
+        this.skip = pos;
+    }
+    posCovered() {
+        if (this.content.length == 0)
+            return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
+        let last = this.content[this.content.length - 1];
+        return !(last.breakAfter || last instanceof BlockWidgetView && last.deco.endSide < 0);
+    }
+    getLine() {
+        if (!this.curLine) {
+            this.content.push(this.curLine = new LineView);
+            this.atCursorPos = true;
+        }
+        return this.curLine;
+    }
+    flushBuffer(active = this.bufferMarks) {
+        if (this.pendingBuffer) {
+            this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
+            this.pendingBuffer = 0 /* Buf.No */;
+        }
+    }
+    addBlockWidget(view) {
+        this.flushBuffer();
+        this.curLine = null;
+        this.content.push(view);
+    }
+    finish(openEnd) {
+        if (this.pendingBuffer && openEnd <= this.bufferMarks.length)
+            this.flushBuffer();
+        else
+            this.pendingBuffer = 0 /* Buf.No */;
+        if (!this.posCovered() &&
+            !(openEnd && this.content.length && this.content[this.content.length - 1] instanceof BlockWidgetView))
+            this.getLine();
+    }
+    buildText(length, active, openStart) {
+        while (length > 0) {
+            if (this.textOff == this.text.length) {
+                let { value, lineBreak, done } = this.cursor.next(this.skip);
+                this.skip = 0;
+                if (done)
+                    throw new Error("Ran out of text content when drawing inline views");
+                if (lineBreak) {
+                    if (!this.posCovered())
+                        this.getLine();
+                    if (this.content.length)
+                        this.content[this.content.length - 1].breakAfter = 1;
+                    else
+                        this.breakAtStart = 1;
+                    this.flushBuffer();
+                    this.curLine = null;
+                    this.atCursorPos = true;
+                    length--;
+                    continue;
+                }
+                else {
+                    this.text = value;
+                    this.textOff = 0;
+                }
+            }
+            let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
+            this.flushBuffer(active.slice(active.length - openStart));
+            this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
+            this.atCursorPos = true;
+            this.textOff += take;
+            length -= take;
+            openStart = 0;
+        }
+    }
+    span(from, to, active, openStart) {
+        this.buildText(to - from, active, openStart);
+        this.pos = to;
+        if (this.openStart < 0)
+            this.openStart = openStart;
+    }
+    point(from, to, deco, active, openStart, index) {
+        if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration) {
+            if (deco.block)
+                throw new RangeError("Block decorations may not be specified via plugins");
+            if (to > this.doc.lineAt(this.pos).to)
+                throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
+        }
+        let len = to - from;
+        if (deco instanceof PointDecoration) {
+            if (deco.block) {
+                if (deco.startSide > 0 && !this.posCovered())
+                    this.getLine();
+                this.addBlockWidget(new BlockWidgetView(deco.widget || NullWidget.block, len, deco));
+            }
+            else {
+                let view = WidgetView.create(deco.widget || NullWidget.inline, len, len ? 0 : deco.startSide);
+                let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length &&
+                    (from < to || deco.startSide > 0);
+                let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);
+                let line = this.getLine();
+                if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore && !view.isEditable)
+                    this.pendingBuffer = 0 /* Buf.No */;
+                this.flushBuffer(active);
+                if (cursorBefore) {
+                    line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
+                    openStart = active.length + Math.max(0, openStart - active.length);
+                }
+                line.append(wrapMarks(view, active), openStart);
+                this.atCursorPos = cursorAfter;
+                this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to || openStart > active.length ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
+                if (this.pendingBuffer)
+                    this.bufferMarks = active.slice();
+            }
+        }
+        else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
+            this.getLine().addLineDeco(deco);
+        }
+        if (len) {
+            // Advance the iterator past the replaced content
+            if (this.textOff + len <= this.text.length) {
+                this.textOff += len;
+            }
+            else {
+                this.skip += len - (this.text.length - this.textOff);
+                this.text = "";
+                this.textOff = 0;
+            }
+            this.pos = to;
+        }
+        if (this.openStart < 0)
+            this.openStart = openStart;
+    }
+    static build(text, from, to, decorations, dynamicDecorationMap) {
+        let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
+        builder.openEnd = RangeSet.spans(decorations, from, to, builder);
+        if (builder.openStart < 0)
+            builder.openStart = builder.openEnd;
+        builder.finish(builder.openEnd);
+        return builder;
+    }
+}
+function wrapMarks(view, active) {
+    for (let mark of active)
+        view = new MarkView(mark, [view], view.length);
+    return view;
+}
+class NullWidget extends WidgetType {
+    constructor(tag) {
+        super();
+        this.tag = tag;
+    }
+    eq(other) { return other.tag == this.tag; }
+    toDOM() { return document.createElement(this.tag); }
+    updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
+    get isHidden() { return true; }
+}
+NullWidget.inline = /*@__PURE__*/new NullWidget("span");
+NullWidget.block = /*@__PURE__*/new NullWidget("div");
+
+/**
+Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+*/
+var Direction = /*@__PURE__*/(function (Direction) {
+    // (These are chosen to match the base levels, in bidi algorithm
+    // terms, of spans in that direction.)
+    /**
+    Left-to-right.
+    */
+    Direction[Direction["LTR"] = 0] = "LTR";
+    /**
+    Right-to-left.
+    */
+    Direction[Direction["RTL"] = 1] = "RTL";
+return Direction})(Direction || (Direction = {}));
+const LTR = Direction.LTR, RTL = Direction.RTL;
+// Decode a string with each type encoded as log2(type)
+function dec(str) {
+    let result = [];
+    for (let i = 0; i < str.length; i++)
+        result.push(1 << +str[i]);
+    return result;
+}
+// Character types for codepoints 0 to 0xf8
+const LowTypes = /*@__PURE__*/dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
+// Character types for codepoints 0x600 to 0x6f9
+const ArabicTypes = /*@__PURE__*/dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
+const Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];
+// There's a lot more in
+// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
+// which are left out to keep code size down.
+for (let p of ["()", "[]", "{}"]) {
+    let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
+    Brackets[l] = r;
+    Brackets[r] = -l;
+}
+function charType(ch) {
+    return ch <= 0xf7 ? LowTypes[ch] :
+        0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
+            0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
+                0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
+                    0x2000 <= ch && ch <= 0x200c ? 256 /* T.NI */ :
+                        0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ : 1 /* T.L */;
+}
+const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
+/**
+Represents a contiguous range of text that has a single direction
+(as in left-to-right or right-to-left).
+*/
+class BidiSpan {
+    /**
+    The direction of this span.
+    */
+    get dir() { return this.level % 2 ? RTL : LTR; }
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    The start of the span (relative to the start of the line).
+    */
+    from, 
+    /**
+    The end of the span.
+    */
+    to, 
+    /**
+    The ["bidi
+    level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
+    of the span (in this context, 0 means
+    left-to-right, 1 means right-to-left, 2 means left-to-right
+    number inside right-to-left text).
+    */
+    level) {
+        this.from = from;
+        this.to = to;
+        this.level = level;
+    }
+    /**
+    @internal
+    */
+    side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
+    /**
+    @internal
+    */
+    forward(forward, dir) { return forward == (this.dir == dir); }
+    /**
+    @internal
+    */
+    static find(order, index, level, assoc) {
+        let maybe = -1;
+        for (let i = 0; i < order.length; i++) {
+            let span = order[i];
+            if (span.from <= index && span.to >= index) {
+                if (span.level == level)
+                    return i;
+                // When multiple spans match, if assoc != 0, take the one that
+                // covers that side, otherwise take the one with the minimum
+                // level.
+                if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
+                    maybe = i;
+            }
+        }
+        if (maybe < 0)
+            throw new RangeError("Index out of range");
+        return maybe;
+    }
+}
+function isolatesEq(a, b) {
+    if (a.length != b.length)
+        return false;
+    for (let i = 0; i < a.length; i++) {
+        let iA = a[i], iB = b[i];
+        if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))
+            return false;
+    }
+    return true;
+}
+// Reused array of character types
+const types = [];
+// Fill in the character types (in `types`) from `from` to `to` and
+// apply W normalization rules.
+function computeCharTypes(line, rFrom, rTo, isolates, outerType) {
+    for (let iI = 0; iI <= isolates.length; iI++) {
+        let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
+        let prevType = iI ? 256 /* T.NI */ : outerType;
+        // W1. Examine each non-spacing mark (NSM) in the level run, and
+        // change the type of the NSM to the type of the previous
+        // character. If the NSM is at the start of the level run, it will
+        // get the type of sor.
+        // W2. Search backwards from each instance of a European number
+        // until the first strong type (R, L, AL, or sor) is found. If an
+        // AL is found, change the type of the European number to Arabic
+        // number.
+        // W3. Change all ALs to R.
+        // (Left after this: L, R, EN, AN, ET, CS, NI)
+        for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {
+            let type = charType(line.charCodeAt(i));
+            if (type == 512 /* T.NSM */)
+                type = prev;
+            else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
+                type = 16 /* T.AN */;
+            types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
+            if (type & 7 /* T.Strong */)
+                prevStrong = type;
+            prev = type;
+        }
+        // W5. A sequence of European terminators adjacent to European
+        // numbers changes to all European numbers.
+        // W6. Otherwise, separators and terminators change to Other
+        // Neutral.
+        // W7. Search backwards from each instance of a European number
+        // until the first strong type (R, L, or sor) is found. If an L is
+        // found, then change the type of the European number to L.
+        // (Left after this: L, R, EN+AN, NI)
+        for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {
+            let type = types[i];
+            if (type == 128 /* T.CS */) {
+                if (i < to - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
+                    type = types[i] = prev;
+                else
+                    types[i] = 256 /* T.NI */;
+            }
+            else if (type == 64 /* T.ET */) {
+                let end = i + 1;
+                while (end < to && types[end] == 64 /* T.ET */)
+                    end++;
+                let replace = (i && prev == 8 /* T.EN */) || (end < rTo && types[end] == 8 /* T.EN */) ? (prevStrong == 1 /* T.L */ ? 1 /* T.L */ : 8 /* T.EN */) : 256 /* T.NI */;
+                for (let j = i; j < end; j++)
+                    types[j] = replace;
+                i = end - 1;
+            }
+            else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
+                types[i] = 1 /* T.L */;
+            }
+            prev = type;
+            if (type & 7 /* T.Strong */)
+                prevStrong = type;
+        }
+    }
+}
+// Process brackets throughout a run sequence.
+function processBracketPairs(line, rFrom, rTo, isolates, outerType) {
+    let oppositeType = outerType == 1 /* T.L */ ? 2 /* T.R */ : 1 /* T.L */;
+    for (let iI = 0, sI = 0, context = 0; iI <= isolates.length; iI++) {
+        let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
+        // N0. Process bracket pairs in an isolating run sequence
+        // sequentially in the logical order of the text positions of the
+        // opening paired brackets using the logic given below. Within this
+        // scope, bidirectional types EN and AN are treated as R.
+        for (let i = from, ch, br, type; i < to; i++) {
+            // Keeps [startIndex, type, strongSeen] triples for each open
+            // bracket on BracketStack.
+            if (br = Brackets[ch = line.charCodeAt(i)]) {
+                if (br < 0) { // Closing bracket
+                    for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                        if (BracketStack[sJ + 1] == -br) {
+                            let flags = BracketStack[sJ + 2];
+                            let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
+                                !(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
+                                    (flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
+                            if (type)
+                                types[i] = types[BracketStack[sJ]] = type;
+                            sI = sJ;
+                            break;
+                        }
+                    }
+                }
+                else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
+                    break;
+                }
+                else {
+                    BracketStack[sI++] = i;
+                    BracketStack[sI++] = ch;
+                    BracketStack[sI++] = context;
+                }
+            }
+            else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
+                let embed = type == outerType;
+                context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
+                for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                    let cur = BracketStack[sJ + 2];
+                    if (cur & 2 /* Bracketed.EmbedInside */)
+                        break;
+                    if (embed) {
+                        BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
+                    }
+                    else {
+                        if (cur & 4 /* Bracketed.OppositeInside */)
+                            break;
+                        BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
+                    }
+                }
+            }
+        }
+    }
+}
+function processNeutrals(rFrom, rTo, isolates, outerType) {
+    for (let iI = 0, prev = outerType; iI <= isolates.length; iI++) {
+        let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
+        // N1. A sequence of neutrals takes the direction of the
+        // surrounding strong text if the text on both sides has the same
+        // direction. European and Arabic numbers act as if they were R in
+        // terms of their influence on neutrals. Start-of-level-run (sor)
+        // and end-of-level-run (eor) are used at level run boundaries.
+        // N2. Any remaining neutrals take the embedding direction.
+        // (Left after this: L, R, EN+AN)
+        for (let i = from; i < to;) {
+            let type = types[i];
+            if (type == 256 /* T.NI */) {
+                let end = i + 1;
+                for (;;) {
+                    if (end == to) {
+                        if (iI == isolates.length)
+                            break;
+                        end = isolates[iI++].to;
+                        to = iI < isolates.length ? isolates[iI].from : rTo;
+                    }
+                    else if (types[end] == 256 /* T.NI */) {
+                        end++;
+                    }
+                    else {
+                        break;
+                    }
+                }
+                let beforeL = prev == 1 /* T.L */;
+                let afterL = (end < rTo ? types[end] : outerType) == 1 /* T.L */;
+                let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
+                for (let j = end, jI = iI, fromJ = jI ? isolates[jI - 1].to : rFrom; j > i;) {
+                    if (j == fromJ) {
+                        j = isolates[--jI].from;
+                        fromJ = jI ? isolates[jI - 1].to : rFrom;
+                    }
+                    types[--j] = replace;
+                }
+                i = end;
+            }
+            else {
+                prev = type;
+                i++;
+            }
+        }
+    }
+}
+// Find the contiguous ranges of character types in a given range, and
+// emit spans for them. Flip the order of the spans as appropriate
+// based on the level, and call through to compute the spans for
+// isolates at the proper point.
+function emitSpans(line, from, to, level, baseLevel, isolates, order) {
+    let ourType = level % 2 ? 2 /* T.R */ : 1 /* T.L */;
+    if ((level % 2) == (baseLevel % 2)) { // Same dir as base direction, don't flip
+        for (let iCh = from, iI = 0; iCh < to;) {
+            // Scan a section of characters in direction ourType, unless
+            // there's another type of char right after iCh, in which case
+            // we scan a section of other characters (which, if ourType ==
+            // T.L, may contain both T.R and T.AN chars).
+            let sameDir = true, isNum = false;
+            if (iI == isolates.length || iCh < isolates[iI].from) {
+                let next = types[iCh];
+                if (next != ourType) {
+                    sameDir = false;
+                    isNum = next == 16 /* T.AN */;
+                }
+            }
+            // Holds an array of isolates to pass to a recursive call if we
+            // must recurse (to distinguish T.AN inside an RTL section in
+            // LTR text), null if we can emit directly
+            let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;
+            let localLevel = sameDir ? level : level + 1;
+            let iScan = iCh;
+            run: for (;;) {
+                if (iI < isolates.length && iScan == isolates[iI].from) {
+                    if (isNum)
+                        break run;
+                    let iso = isolates[iI];
+                    // Scan ahead to verify that there is another char in this dir after the isolate(s)
+                    if (!sameDir)
+                        for (let upto = iso.to, jI = iI + 1;;) {
+                            if (upto == to)
+                                break run;
+                            if (jI < isolates.length && isolates[jI].from == upto)
+                                upto = isolates[jI++].to;
+                            else if (types[upto] == ourType)
+                                break run;
+                            else
+                                break;
+                        }
+                    iI++;
+                    if (recurse) {
+                        recurse.push(iso);
+                    }
+                    else {
+                        if (iso.from > iCh)
+                            order.push(new BidiSpan(iCh, iso.from, localLevel));
+                        let dirSwap = (iso.direction == LTR) != !(localLevel % 2);
+                        computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
+                        iCh = iso.to;
+                    }
+                    iScan = iso.to;
+                }
+                else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {
+                    break;
+                }
+                else {
+                    iScan++;
+                }
+            }
+            if (recurse)
+                emitSpans(line, iCh, iScan, level + 1, baseLevel, recurse, order);
+            else if (iCh < iScan)
+                order.push(new BidiSpan(iCh, iScan, localLevel));
+            iCh = iScan;
+        }
+    }
+    else {
+        // Iterate in reverse to flip the span order. Same code again, but
+        // going from the back of the section to the front
+        for (let iCh = to, iI = isolates.length; iCh > from;) {
+            let sameDir = true, isNum = false;
+            if (!iI || iCh > isolates[iI - 1].to) {
+                let next = types[iCh - 1];
+                if (next != ourType) {
+                    sameDir = false;
+                    isNum = next == 16 /* T.AN */;
+                }
+            }
+            let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;
+            let localLevel = sameDir ? level : level + 1;
+            let iScan = iCh;
+            run: for (;;) {
+                if (iI && iScan == isolates[iI - 1].to) {
+                    if (isNum)
+                        break run;
+                    let iso = isolates[--iI];
+                    // Scan ahead to verify that there is another char in this dir after the isolate(s)
+                    if (!sameDir)
+                        for (let upto = iso.from, jI = iI;;) {
+                            if (upto == from)
+                                break run;
+                            if (jI && isolates[jI - 1].to == upto)
+                                upto = isolates[--jI].from;
+                            else if (types[upto - 1] == ourType)
+                                break run;
+                            else
+                                break;
+                        }
+                    if (recurse) {
+                        recurse.push(iso);
+                    }
+                    else {
+                        if (iso.to < iCh)
+                            order.push(new BidiSpan(iso.to, iCh, localLevel));
+                        let dirSwap = (iso.direction == LTR) != !(localLevel % 2);
+                        computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
+                        iCh = iso.from;
+                    }
+                    iScan = iso.from;
+                }
+                else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {
+                    break;
+                }
+                else {
+                    iScan--;
+                }
+            }
+            if (recurse)
+                emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);
+            else if (iScan < iCh)
+                order.push(new BidiSpan(iScan, iCh, localLevel));
+            iCh = iScan;
+        }
+    }
+}
+function computeSectionOrder(line, level, baseLevel, isolates, from, to, order) {
+    let outerType = (level % 2 ? 2 /* T.R */ : 1 /* T.L */);
+    computeCharTypes(line, from, to, isolates, outerType);
+    processBracketPairs(line, from, to, isolates, outerType);
+    processNeutrals(from, to, isolates, outerType);
+    emitSpans(line, from, to, level, baseLevel, isolates, order);
+}
+function computeOrder(line, direction, isolates) {
+    if (!line)
+        return [new BidiSpan(0, 0, direction == RTL ? 1 : 0)];
+    if (direction == LTR && !isolates.length && !BidiRE.test(line))
+        return trivialOrder(line.length);
+    if (isolates.length)
+        while (line.length > types.length)
+            types[types.length] = 256 /* T.NI */; // Make sure types array has no gaps
+    let order = [], level = direction == LTR ? 0 : 1;
+    computeSectionOrder(line, level, level, isolates, 0, line.length, order);
+    return order;
+}
+function trivialOrder(length) {
+    return [new BidiSpan(0, length, 0)];
+}
+let movedOver = "";
+// This implementation moves strictly visually, without concern for a
+// traversal visiting every logical position in the string. It will
+// still do so for simple input, but situations like multiple isolates
+// with the same level next to each other, or text going against the
+// main dir at the end of the line, will make some positions
+// unreachable with this motion. Each visible cursor position will
+// correspond to the lower-level bidi span that touches it.
+//
+// The alternative would be to solve an order globally for a given
+// line, making sure that it includes every position, but that would
+// require associating non-canonical (higher bidi span level)
+// positions with a given visual position, which is likely to confuse
+// people. (And would generally be a lot more complicated.)
+function moveVisually(line, order, dir, start, forward) {
+    var _a;
+    let startIndex = start.head - line.from;
+    let spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
+    let span = order[spanI], spanEnd = span.side(forward, dir);
+    // End of span
+    if (startIndex == spanEnd) {
+        let nextI = spanI += forward ? 1 : -1;
+        if (nextI < 0 || nextI >= order.length)
+            return null;
+        span = order[spanI = nextI];
+        startIndex = span.side(!forward, dir);
+        spanEnd = span.side(forward, dir);
+    }
+    let nextIndex = findClusterBreak(line.text, startIndex, span.forward(forward, dir));
+    if (nextIndex < span.from || nextIndex > span.to)
+        nextIndex = spanEnd;
+    movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
+    let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
+    if (nextSpan && nextIndex == spanEnd && nextSpan.level + (forward ? 0 : 1) < span.level)
+        return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
+    return EditorSelection.cursor(nextIndex + line.from, span.forward(forward, dir) ? -1 : 1, span.level);
+}
+function autoDirection(text, from, to) {
+    for (let i = from; i < to; i++) {
+        let type = charType(text.charCodeAt(i));
+        if (type == 1 /* T.L */)
+            return LTR;
+        if (type == 2 /* T.R */ || type == 4 /* T.AL */)
+            return RTL;
+    }
+    return LTR;
+}
+
+const clickAddsSelectionRange = /*@__PURE__*/Facet.define();
+const dragMovesSelection$1 = /*@__PURE__*/Facet.define();
+const mouseSelectionStyle = /*@__PURE__*/Facet.define();
+const exceptionSink = /*@__PURE__*/Facet.define();
+const updateListener = /*@__PURE__*/Facet.define();
+const inputHandler$1 = /*@__PURE__*/Facet.define();
+const focusChangeEffect = /*@__PURE__*/Facet.define();
+const clipboardInputFilter = /*@__PURE__*/Facet.define();
+const clipboardOutputFilter = /*@__PURE__*/Facet.define();
+const perLineTextDirection = /*@__PURE__*/Facet.define({
+    combine: values => values.some(x => x)
+});
+const nativeSelectionHidden = /*@__PURE__*/Facet.define({
+    combine: values => values.some(x => x)
+});
+const scrollHandler = /*@__PURE__*/Facet.define();
+class ScrollTarget {
+    constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5, 
+    // This data structure is abused to also store precise scroll
+    // snapshots, instead of a `scrollIntoView` request. When this
+    // flag is `true`, `range` points at a position in the reference
+    // line, `yMargin` holds the difference between the top of that
+    // line and the top of the editor, and `xMargin` holds the
+    // editor's `scrollLeft`.
+    isSnapshot = false) {
+        this.range = range;
+        this.y = y;
+        this.x = x;
+        this.yMargin = yMargin;
+        this.xMargin = xMargin;
+        this.isSnapshot = isSnapshot;
+    }
+    map(changes) {
+        return changes.empty ? this :
+            new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
+    }
+    clip(state) {
+        return this.range.to <= state.doc.length ? this :
+            new ScrollTarget(EditorSelection.cursor(state.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
+    }
+}
+const scrollIntoView$1 = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });
+const setEditContextFormatting = /*@__PURE__*/StateEffect.define();
+/**
+Log or report an unhandled exception in client code. Should
+probably only be used by extension code that allows client code to
+provide functions, and calls those functions in a context where an
+exception can't be propagated to calling code in a reasonable way
+(for example when in an event handler).
+
+Either calls a handler registered with
+[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
+`window.onerror`, if defined, or `console.error` (in which case
+it'll pass `context`, when given, as first argument).
+*/
+function logException(state, exception, context) {
+    let handler = state.facet(exceptionSink);
+    if (handler.length)
+        handler[0](exception);
+    else if (window.onerror)
+        window.onerror(String(exception), context, undefined, undefined, exception);
+    else if (context)
+        console.error(context + ":", exception);
+    else
+        console.error(exception);
+}
+const editable = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : true });
+let nextPluginID = 0;
+const viewPlugin = /*@__PURE__*/Facet.define();
+/**
+View plugins associate stateful values with a view. They can
+influence the way the content is drawn, and are notified of things
+that happen in the view.
+*/
+class ViewPlugin {
+    constructor(
+    /**
+    @internal
+    */
+    id, 
+    /**
+    @internal
+    */
+    create, 
+    /**
+    @internal
+    */
+    domEventHandlers, 
+    /**
+    @internal
+    */
+    domEventObservers, buildExtensions) {
+        this.id = id;
+        this.create = create;
+        this.domEventHandlers = domEventHandlers;
+        this.domEventObservers = domEventObservers;
+        this.extension = buildExtensions(this);
+    }
+    /**
+    Define a plugin from a constructor function that creates the
+    plugin's value, given an editor view.
+    */
+    static define(create, spec) {
+        const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
+        return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, plugin => {
+            let ext = [viewPlugin.of(plugin)];
+            if (deco)
+                ext.push(decorations.of(view => {
+                    let pluginInst = view.plugin(plugin);
+                    return pluginInst ? deco(pluginInst) : Decoration.none;
+                }));
+            if (provide)
+                ext.push(provide(plugin));
+            return ext;
+        });
+    }
+    /**
+    Create a plugin for a class whose constructor takes a single
+    editor view as argument.
+    */
+    static fromClass(cls, spec) {
+        return ViewPlugin.define(view => new cls(view), spec);
+    }
+}
+class PluginInstance {
+    constructor(spec) {
+        this.spec = spec;
+        // When starting an update, all plugins have this field set to the
+        // update object, indicating they need to be updated. When finished
+        // updating, it is set to `false`. Retrieving a plugin that needs to
+        // be updated with `view.plugin` forces an eager update.
+        this.mustUpdate = null;
+        // This is null when the plugin is initially created, but
+        // initialized on the first update.
+        this.value = null;
+    }
+    update(view) {
+        if (!this.value) {
+            if (this.spec) {
+                try {
+                    this.value = this.spec.create(view);
+                }
+                catch (e) {
+                    logException(view.state, e, "CodeMirror plugin crashed");
+                    this.deactivate();
+                }
+            }
+        }
+        else if (this.mustUpdate) {
+            let update = this.mustUpdate;
+            this.mustUpdate = null;
+            if (this.value.update) {
+                try {
+                    this.value.update(update);
+                }
+                catch (e) {
+                    logException(update.state, e, "CodeMirror plugin crashed");
+                    if (this.value.destroy)
+                        try {
+                            this.value.destroy();
+                        }
+                        catch (_) { }
+                    this.deactivate();
+                }
+            }
+        }
+        return this;
+    }
+    destroy(view) {
+        var _a;
+        if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
+            try {
+                this.value.destroy();
+            }
+            catch (e) {
+                logException(view.state, e, "CodeMirror plugin crashed");
+            }
+        }
+    }
+    deactivate() {
+        this.spec = this.value = null;
+    }
+}
+const editorAttributes = /*@__PURE__*/Facet.define();
+const contentAttributes = /*@__PURE__*/Facet.define();
+// Provide decorations
+const decorations = /*@__PURE__*/Facet.define();
+const outerDecorations = /*@__PURE__*/Facet.define();
+const atomicRanges = /*@__PURE__*/Facet.define();
+const bidiIsolatedRanges = /*@__PURE__*/Facet.define();
+function getIsolatedRanges(view, line) {
+    let isolates = view.state.facet(bidiIsolatedRanges);
+    if (!isolates.length)
+        return isolates;
+    let sets = isolates.map(i => i instanceof Function ? i(view) : i);
+    let result = [];
+    RangeSet.spans(sets, line.from, line.to, {
+        point() { },
+        span(fromDoc, toDoc, active, open) {
+            let from = fromDoc - line.from, to = toDoc - line.from;
+            let level = result;
+            for (let i = active.length - 1; i >= 0; i--, open--) {
+                let direction = active[i].spec.bidiIsolate, update;
+                if (direction == null)
+                    direction = autoDirection(line.text, from, to);
+                if (open > 0 && level.length &&
+                    (update = level[level.length - 1]).to == from && update.direction == direction) {
+                    update.to = to;
+                    level = update.inner;
+                }
+                else {
+                    let add = { from, to, direction, inner: [] };
+                    level.push(add);
+                    level = add.inner;
+                }
+            }
+        }
+    });
+    return result;
+}
+const scrollMargins = /*@__PURE__*/Facet.define();
+function getScrollMargins(view) {
+    let left = 0, right = 0, top = 0, bottom = 0;
+    for (let source of view.state.facet(scrollMargins)) {
+        let m = source(view);
+        if (m) {
+            if (m.left != null)
+                left = Math.max(left, m.left);
+            if (m.right != null)
+                right = Math.max(right, m.right);
+            if (m.top != null)
+                top = Math.max(top, m.top);
+            if (m.bottom != null)
+                bottom = Math.max(bottom, m.bottom);
+        }
+    }
+    return { left, right, top, bottom };
+}
+const styleModule = /*@__PURE__*/Facet.define();
+class ChangedRange {
+    constructor(fromA, toA, fromB, toB) {
+        this.fromA = fromA;
+        this.toA = toA;
+        this.fromB = fromB;
+        this.toB = toB;
+    }
+    join(other) {
+        return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
+    }
+    addToSet(set) {
+        let i = set.length, me = this;
+        for (; i > 0; i--) {
+            let range = set[i - 1];
+            if (range.fromA > me.toA)
+                continue;
+            if (range.toA < me.fromA)
+                break;
+            me = me.join(range);
+            set.splice(i - 1, 1);
+        }
+        set.splice(i, 0, me);
+        return set;
+    }
+    static extendWithRanges(diff, ranges) {
+        if (ranges.length == 0)
+            return diff;
+        let result = [];
+        for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
+            let next = dI == diff.length ? null : diff[dI], off = posA - posB;
+            let end = next ? next.fromB : 1e9;
+            while (rI < ranges.length && ranges[rI] < end) {
+                let from = ranges[rI], to = ranges[rI + 1];
+                let fromB = Math.max(posB, from), toB = Math.min(end, to);
+                if (fromB <= toB)
+                    new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
+                if (to > end)
+                    break;
+                else
+                    rI += 2;
+            }
+            if (!next)
+                return result;
+            new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
+            posA = next.toA;
+            posB = next.toB;
+        }
+    }
+}
+/**
+View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
+class, which describe what happened, whenever the view is updated.
+*/
+class ViewUpdate {
+    constructor(
+    /**
+    The editor view that the update is associated with.
+    */
+    view, 
+    /**
+    The new editor state.
+    */
+    state, 
+    /**
+    The transactions involved in the update. May be empty.
+    */
+    transactions) {
+        this.view = view;
+        this.state = state;
+        this.transactions = transactions;
+        /**
+        @internal
+        */
+        this.flags = 0;
+        this.startState = view.state;
+        this.changes = ChangeSet.empty(this.startState.doc.length);
+        for (let tr of transactions)
+            this.changes = this.changes.compose(tr.changes);
+        let changedRanges = [];
+        this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));
+        this.changedRanges = changedRanges;
+    }
+    /**
+    @internal
+    */
+    static create(view, state, transactions) {
+        return new ViewUpdate(view, state, transactions);
+    }
+    /**
+    Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
+    [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
+    update.
+    */
+    get viewportChanged() {
+        return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
+    }
+    /**
+    Returns true when
+    [`viewportChanged`](https://codemirror.net/6/docs/ref/#view.ViewUpdate.viewportChanged) is true
+    and the viewport change is not just the result of mapping it in
+    response to document changes.
+    */
+    get viewportMoved() {
+        return (this.flags & 8 /* UpdateFlag.ViewportMoved */) > 0;
+    }
+    /**
+    Indicates whether the height of a block element in the editor
+    changed in this update.
+    */
+    get heightChanged() {
+        return (this.flags & 2 /* UpdateFlag.Height */) > 0;
+    }
+    /**
+    Returns true when the document was modified or the size of the
+    editor, or elements within the editor, changed.
+    */
+    get geometryChanged() {
+        return this.docChanged || (this.flags & (16 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
+    }
+    /**
+    True when this update indicates a focus change.
+    */
+    get focusChanged() {
+        return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
+    }
+    /**
+    Whether the document changed in this update.
+    */
+    get docChanged() {
+        return !this.changes.empty;
+    }
+    /**
+    Whether the selection was explicitly set in this update.
+    */
+    get selectionSet() {
+        return this.transactions.some(tr => tr.selection);
+    }
+    /**
+    @internal
+    */
+    get empty() { return this.flags == 0 && this.transactions.length == 0; }
+}
+
+class DocView extends ContentView {
+    get length() { return this.view.state.doc.length; }
+    constructor(view) {
+        super();
+        this.view = view;
+        this.decorations = [];
+        this.dynamicDecorationMap = [false];
+        this.domChanged = null;
+        this.hasComposition = null;
+        this.markedForComposition = new Set;
+        this.editContextFormatting = Decoration.none;
+        this.lastCompositionAfterCursor = false;
+        // Track a minimum width for the editor. When measuring sizes in
+        // measureVisibleLineHeights, this is updated to point at the width
+        // of a given element and its extent in the document. When a change
+        // happens in that range, these are reset. That way, once we've seen
+        // a line/element of a given length, we keep the editor wide enough
+        // to fit at least that element, until it is changed, at which point
+        // we forget it again.
+        this.minWidth = 0;
+        this.minWidthFrom = 0;
+        this.minWidthTo = 0;
+        // Track whether the DOM selection was set in a lossy way, so that
+        // we don't mess it up when reading it back it
+        this.impreciseAnchor = null;
+        this.impreciseHead = null;
+        this.forceSelection = false;
+        // Used by the resize observer to ignore resizes that we caused
+        // ourselves
+        this.lastUpdate = Date.now();
+        this.setDOM(view.contentDOM);
+        this.children = [new LineView];
+        this.children[0].setParent(this);
+        this.updateDeco();
+        this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0, null);
+    }
+    // Update the document view to a given state.
+    update(update) {
+        var _a;
+        let changedRanges = update.changedRanges;
+        if (this.minWidth > 0 && changedRanges.length) {
+            if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
+                this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
+            }
+            else {
+                this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
+                this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
+            }
+        }
+        this.updateEditContextFormatting(update);
+        let readCompositionAt = -1;
+        if (this.view.inputState.composing >= 0 && !this.view.observer.editContext) {
+            if ((_a = this.domChanged) === null || _a === void 0 ? void 0 : _a.newSel)
+                readCompositionAt = this.domChanged.newSel.head;
+            else if (!touchesComposition(update.changes, this.hasComposition) && !update.selectionSet)
+                readCompositionAt = update.state.selection.main.head;
+        }
+        let composition = readCompositionAt > -1 ? findCompositionRange(this.view, update.changes, readCompositionAt) : null;
+        this.domChanged = null;
+        if (this.hasComposition) {
+            this.markedForComposition.clear();
+            let { from, to } = this.hasComposition;
+            changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))
+                .addToSet(changedRanges.slice());
+        }
+        this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;
+        // When the DOM nodes around the selection are moved to another
+        // parent, Chrome sometimes reports a different selection through
+        // getSelection than the one that it actually shows to the user.
+        // This forces a selection update when lines are joined to work
+        // around that. Issue #54
+        if ((browser.ie || browser.chrome) && !composition && update &&
+            update.state.doc.lines != update.startState.doc.lines)
+            this.forceSelection = true;
+        let prevDeco = this.decorations, deco = this.updateDeco();
+        let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
+        changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
+        if (!(this.flags & 7 /* ViewFlag.Dirty */) && changedRanges.length == 0) {
+            return false;
+        }
+        else {
+            this.updateInner(changedRanges, update.startState.doc.length, composition);
+            if (update.transactions.length)
+                this.lastUpdate = Date.now();
+            return true;
+        }
+    }
+    // Used by update and the constructor do perform the actual DOM
+    // update
+    updateInner(changes, oldLength, composition) {
+        this.view.viewState.mustMeasureContent = true;
+        this.updateChildren(changes, oldLength, composition);
+        let { observer } = this.view;
+        observer.ignore(() => {
+            // Lock the height during redrawing, since Chrome sometimes
+            // messes with the scroll position during DOM mutation (though
+            // no relayout is triggered and I cannot imagine how it can
+            // recompute the scroll position without a layout)
+            this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + "px";
+            this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
+            // Chrome will sometimes, when DOM mutations occur directly
+            // around the selection, get confused and report a different
+            // selection from the one it displays (issue #218). This tries
+            // to detect that situation.
+            let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
+            this.sync(this.view, track);
+            this.flags &= ~7 /* ViewFlag.Dirty */;
+            if (track && (track.written || observer.selectionRange.focusNode != track.node))
+                this.forceSelection = true;
+            this.dom.style.height = "";
+        });
+        this.markedForComposition.forEach(cView => cView.flags &= ~8 /* ViewFlag.Composition */);
+        let gaps = [];
+        if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
+            for (let child of this.children)
+                if (child instanceof BlockWidgetView && child.widget instanceof BlockGapWidget)
+                    gaps.push(child.dom);
+        observer.updateGaps(gaps);
+    }
+    updateChildren(changes, oldLength, composition) {
+        let ranges = composition ? composition.range.addToSet(changes.slice()) : changes;
+        let cursor = this.childCursor(oldLength);
+        for (let i = ranges.length - 1;; i--) {
+            let next = i >= 0 ? ranges[i] : null;
+            if (!next)
+                break;
+            let { fromA, toA, fromB, toB } = next, content, breakAtStart, openStart, openEnd;
+            if (composition && composition.range.fromB < toB && composition.range.toB > fromB) {
+                let before = ContentBuilder.build(this.view.state.doc, fromB, composition.range.fromB, this.decorations, this.dynamicDecorationMap);
+                let after = ContentBuilder.build(this.view.state.doc, composition.range.toB, toB, this.decorations, this.dynamicDecorationMap);
+                breakAtStart = before.breakAtStart;
+                openStart = before.openStart;
+                openEnd = after.openEnd;
+                let compLine = this.compositionView(composition);
+                if (after.breakAtStart) {
+                    compLine.breakAfter = 1;
+                }
+                else if (after.content.length &&
+                    compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {
+                    compLine.breakAfter = after.content[0].breakAfter;
+                    after.content.shift();
+                }
+                if (before.content.length &&
+                    compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {
+                    before.content.pop();
+                }
+                content = before.content.concat(compLine).concat(after.content);
+            }
+            else {
+                ({ content, breakAtStart, openStart, openEnd } =
+                    ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap));
+            }
+            let { i: toI, off: toOff } = cursor.findPos(toA, 1);
+            let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
+            replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
+        }
+        if (composition)
+            this.fixCompositionDOM(composition);
+    }
+    updateEditContextFormatting(update) {
+        this.editContextFormatting = this.editContextFormatting.map(update.changes);
+        for (let tr of update.transactions)
+            for (let effect of tr.effects)
+                if (effect.is(setEditContextFormatting)) {
+                    this.editContextFormatting = effect.value;
+                }
+    }
+    compositionView(composition) {
+        let cur = new TextView(composition.text.nodeValue);
+        cur.flags |= 8 /* ViewFlag.Composition */;
+        for (let { deco } of composition.marks)
+            cur = new MarkView(deco, [cur], cur.length);
+        let line = new LineView;
+        line.append(cur, 0);
+        return line;
+    }
+    fixCompositionDOM(composition) {
+        let fix = (dom, cView) => {
+            cView.flags |= 8 /* ViewFlag.Composition */ | (cView.children.some(c => c.flags & 7 /* ViewFlag.Dirty */) ? 1 /* ViewFlag.ChildDirty */ : 0);
+            this.markedForComposition.add(cView);
+            let prev = ContentView.get(dom);
+            if (prev && prev != cView)
+                prev.dom = null;
+            cView.setDOM(dom);
+        };
+        let pos = this.childPos(composition.range.fromB, 1);
+        let cView = this.children[pos.i];
+        fix(composition.line, cView);
+        for (let i = composition.marks.length - 1; i >= -1; i--) {
+            pos = cView.childPos(pos.off, 1);
+            cView = cView.children[pos.i];
+            fix(i >= 0 ? composition.marks[i].node : composition.text, cView);
+        }
+    }
+    // Sync the DOM selection to this.state.selection
+    updateSelection(mustRead = false, fromPointer = false) {
+        if (mustRead || !this.view.observer.selectionRange.focusNode)
+            this.view.observer.readSelectionRange();
+        let activeElt = this.view.root.activeElement, focused = activeElt == this.dom;
+        let selectionNotFocus = !focused && !(this.view.state.facet(editable) || this.dom.tabIndex > -1) &&
+            hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));
+        if (!(focused || fromPointer || selectionNotFocus))
+            return;
+        let force = this.forceSelection;
+        this.forceSelection = false;
+        let main = this.view.state.selection.main;
+        let anchor = this.moveToLine(this.domAtPos(main.anchor));
+        let head = main.empty ? anchor : this.moveToLine(this.domAtPos(main.head));
+        // Always reset on Firefox when next to an uneditable node to
+        // avoid invisible cursor bugs (#111)
+        if (browser.gecko && main.empty && !this.hasComposition && betweenUneditable(anchor)) {
+            let dummy = document.createTextNode("");
+            this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
+            anchor = head = new DOMPos(dummy, 0);
+            force = true;
+        }
+        let domSel = this.view.observer.selectionRange;
+        // If the selection is already here, or in an equivalent position, don't touch it
+        if (force || !domSel.focusNode || (!isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
+            !isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) && !this.suppressWidgetCursorChange(domSel, main)) {
+            this.view.observer.ignore(() => {
+                // Chrome Android will hide the virtual keyboard when tapping
+                // inside an uneditable node, and not bring it back when we
+                // move the cursor to its proper position. This tries to
+                // restore the keyboard by cycling focus.
+                if (browser.android && browser.chrome && this.dom.contains(domSel.focusNode) &&
+                    inUneditable(domSel.focusNode, this.dom)) {
+                    this.dom.blur();
+                    this.dom.focus({ preventScroll: true });
+                }
+                let rawSel = getSelection(this.view.root);
+                if (!rawSel) ;
+                else if (main.empty) {
+                    // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
+                    if (browser.gecko) {
+                        let nextTo = nextToUneditable(anchor.node, anchor.offset);
+                        if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
+                            let text = (nextTo == 1 /* NextTo.Before */ ? textNodeBefore : textNodeAfter)(anchor.node, anchor.offset);
+                            if (text)
+                                anchor = new DOMPos(text.node, text.offset);
+                        }
+                    }
+                    rawSel.collapse(anchor.node, anchor.offset);
+                    if (main.bidiLevel != null && rawSel.caretBidiLevel !== undefined)
+                        rawSel.caretBidiLevel = main.bidiLevel;
+                }
+                else if (rawSel.extend) {
+                    // Selection.extend can be used to create an 'inverted' selection
+                    // (one where the focus is before the anchor), but not all
+                    // browsers support it yet.
+                    rawSel.collapse(anchor.node, anchor.offset);
+                    // Safari will ignore the call above when the editor is
+                    // hidden, and then raise an error on the call to extend
+                    // (#940).
+                    try {
+                        rawSel.extend(head.node, head.offset);
+                    }
+                    catch (_) { }
+                }
+                else {
+                    // Primitive (IE) way
+                    let range = document.createRange();
+                    if (main.anchor > main.head)
+                        [anchor, head] = [head, anchor];
+                    range.setEnd(head.node, head.offset);
+                    range.setStart(anchor.node, anchor.offset);
+                    rawSel.removeAllRanges();
+                    rawSel.addRange(range);
+                }
+                if (selectionNotFocus && this.view.root.activeElement == this.dom) {
+                    this.dom.blur();
+                    if (activeElt)
+                        activeElt.focus();
+                }
+            });
+            this.view.observer.setSelectionRange(anchor, head);
+        }
+        this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);
+        this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);
+    }
+    // If a zero-length widget is inserted next to the cursor during
+    // composition, avoid moving it across it and disrupting the
+    // composition.
+    suppressWidgetCursorChange(sel, cursor) {
+        return this.hasComposition && cursor.empty &&
+            isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset) &&
+            this.posFromDOM(sel.focusNode, sel.focusOffset) == cursor.head;
+    }
+    enforceCursorAssoc() {
+        if (this.hasComposition)
+            return;
+        let { view } = this, cursor = view.state.selection.main;
+        let sel = getSelection(view.root);
+        let { anchorNode, anchorOffset } = view.observer.selectionRange;
+        if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
+            return;
+        let line = LineView.find(this, cursor.head);
+        if (!line)
+            return;
+        let lineStart = line.posAtStart;
+        if (cursor.head == lineStart || cursor.head == lineStart + line.length)
+            return;
+        let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
+        if (!before || !after || before.bottom > after.top)
+            return;
+        let dom = this.domAtPos(cursor.head + cursor.assoc);
+        sel.collapse(dom.node, dom.offset);
+        sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
+        // This can go wrong in corner cases like single-character lines,
+        // so check and reset if necessary.
+        view.observer.readSelectionRange();
+        let newRange = view.observer.selectionRange;
+        if (view.docView.posFromDOM(newRange.anchorNode, newRange.anchorOffset) != cursor.from)
+            sel.collapse(anchorNode, anchorOffset);
+    }
+    // If a position is in/near a block widget, move it to a nearby text
+    // line, since we don't want the cursor inside a block widget.
+    moveToLine(pos) {
+        // Block widgets will return positions before/after them, which
+        // are thus directly in the document DOM element.
+        let dom = this.dom, newPos;
+        if (pos.node != dom)
+            return pos;
+        for (let i = pos.offset; !newPos && i < dom.childNodes.length; i++) {
+            let view = ContentView.get(dom.childNodes[i]);
+            if (view instanceof LineView)
+                newPos = view.domAtPos(0);
+        }
+        for (let i = pos.offset - 1; !newPos && i >= 0; i--) {
+            let view = ContentView.get(dom.childNodes[i]);
+            if (view instanceof LineView)
+                newPos = view.domAtPos(view.length);
+        }
+        return newPos ? new DOMPos(newPos.node, newPos.offset, true) : pos;
+    }
+    nearest(dom) {
+        for (let cur = dom; cur;) {
+            let domView = ContentView.get(cur);
+            if (domView && domView.rootView == this)
+                return domView;
+            cur = cur.parentNode;
+        }
+        return null;
+    }
+    posFromDOM(node, offset) {
+        let view = this.nearest(node);
+        if (!view)
+            throw new RangeError("Trying to find position for a DOM position outside of the document");
+        return view.localPosFromDOM(node, offset) + view.posAtStart;
+    }
+    domAtPos(pos) {
+        let { i, off } = this.childCursor().findPos(pos, -1);
+        for (; i < this.children.length - 1;) {
+            let child = this.children[i];
+            if (off < child.length || child instanceof LineView)
+                break;
+            i++;
+            off = 0;
+        }
+        return this.children[i].domAtPos(off);
+    }
+    coordsAt(pos, side) {
+        let best = null, bestPos = 0;
+        for (let off = this.length, i = this.children.length - 1; i >= 0; i--) {
+            let child = this.children[i], end = off - child.breakAfter, start = end - child.length;
+            if (end < pos)
+                break;
+            if (start <= pos && (start < pos || child.covers(-1)) && (end > pos || child.covers(1)) &&
+                (!best || child instanceof LineView && !(best instanceof LineView && side >= 0))) {
+                best = child;
+                bestPos = start;
+            }
+            else if (best && start == pos && end == pos && child instanceof BlockWidgetView && Math.abs(side) < 2) {
+                if (child.deco.startSide < 0)
+                    break;
+                else if (i)
+                    best = null;
+            }
+            off = start;
+        }
+        return best ? best.coordsAt(pos - bestPos, side) : null;
+    }
+    coordsForChar(pos) {
+        let { i, off } = this.childPos(pos, 1), child = this.children[i];
+        if (!(child instanceof LineView))
+            return null;
+        while (child.children.length) {
+            let { i, off: childOff } = child.childPos(off, 1);
+            for (;; i++) {
+                if (i == child.children.length)
+                    return null;
+                if ((child = child.children[i]).length)
+                    break;
+            }
+            off = childOff;
+        }
+        if (!(child instanceof TextView))
+            return null;
+        let end = findClusterBreak(child.text, off);
+        if (end == off)
+            return null;
+        let rects = textRange(child.dom, off, end).getClientRects();
+        for (let i = 0; i < rects.length; i++) {
+            let rect = rects[i];
+            if (i == rects.length - 1 || rect.top < rect.bottom && rect.left < rect.right)
+                return rect;
+        }
+        return null;
+    }
+    measureVisibleLineHeights(viewport) {
+        let result = [], { from, to } = viewport;
+        let contentWidth = this.view.contentDOM.clientWidth;
+        let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
+        let widest = -1, ltr = this.view.textDirection == Direction.LTR;
+        for (let pos = 0, i = 0; i < this.children.length; i++) {
+            let child = this.children[i], end = pos + child.length;
+            if (end > to)
+                break;
+            if (pos >= from) {
+                let childRect = child.dom.getBoundingClientRect();
+                result.push(childRect.height);
+                if (isWider) {
+                    let last = child.dom.lastChild;
+                    let rects = last ? clientRectsFor(last) : [];
+                    if (rects.length) {
+                        let rect = rects[rects.length - 1];
+                        let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
+                        if (width > widest) {
+                            widest = width;
+                            this.minWidth = contentWidth;
+                            this.minWidthFrom = pos;
+                            this.minWidthTo = end;
+                        }
+                    }
+                }
+            }
+            pos = end + child.breakAfter;
+        }
+        return result;
+    }
+    textDirectionAt(pos) {
+        let { i } = this.childPos(pos, 1);
+        return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction.RTL : Direction.LTR;
+    }
+    measureTextSize() {
+        for (let child of this.children) {
+            if (child instanceof LineView) {
+                let measure = child.measureTextSize();
+                if (measure)
+                    return measure;
+            }
+        }
+        // If no workable line exists, force a layout of a measurable element
+        let dummy = document.createElement("div"), lineHeight, charWidth, textHeight;
+        dummy.className = "cm-line";
+        dummy.style.width = "99999px";
+        dummy.style.position = "absolute";
+        dummy.textContent = "abc def ghi jkl mno pqr stu";
+        this.view.observer.ignore(() => {
+            this.dom.appendChild(dummy);
+            let rect = clientRectsFor(dummy.firstChild)[0];
+            lineHeight = dummy.getBoundingClientRect().height;
+            charWidth = rect ? rect.width / 27 : 7;
+            textHeight = rect ? rect.height : lineHeight;
+            dummy.remove();
+        });
+        return { lineHeight, charWidth, textHeight };
+    }
+    childCursor(pos = this.length) {
+        // Move back to start of last element when possible, so that
+        // `ChildCursor.findPos` doesn't have to deal with the edge case
+        // of being after the last element.
+        let i = this.children.length;
+        if (i)
+            pos -= this.children[--i].length;
+        return new ChildCursor(this.children, pos, i);
+    }
+    computeBlockGapDeco() {
+        let deco = [], vs = this.view.viewState;
+        for (let pos = 0, i = 0;; i++) {
+            let next = i == vs.viewports.length ? null : vs.viewports[i];
+            let end = next ? next.from - 1 : this.length;
+            if (end > pos) {
+                let height = (vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top) / this.view.scaleY;
+                deco.push(Decoration.replace({
+                    widget: new BlockGapWidget(height),
+                    block: true,
+                    inclusive: true,
+                    isBlockGap: true,
+                }).range(pos, end));
+            }
+            if (!next)
+                break;
+            pos = next.to + 1;
+        }
+        return Decoration.set(deco);
+    }
+    updateDeco() {
+        let i = 1;
+        let allDeco = this.view.state.facet(decorations).map(d => {
+            let dynamic = this.dynamicDecorationMap[i++] = typeof d == "function";
+            return dynamic ? d(this.view) : d;
+        });
+        let dynamicOuter = false, outerDeco = this.view.state.facet(outerDecorations).map((d, i) => {
+            let dynamic = typeof d == "function";
+            if (dynamic)
+                dynamicOuter = true;
+            return dynamic ? d(this.view) : d;
+        });
+        if (outerDeco.length) {
+            this.dynamicDecorationMap[i++] = dynamicOuter;
+            allDeco.push(RangeSet.join(outerDeco));
+        }
+        this.decorations = [
+            this.editContextFormatting,
+            ...allDeco,
+            this.computeBlockGapDeco(),
+            this.view.viewState.lineGapDeco
+        ];
+        while (i < this.decorations.length)
+            this.dynamicDecorationMap[i++] = false;
+        return this.decorations;
+    }
+    scrollIntoView(target) {
+        if (target.isSnapshot) {
+            let ref = this.view.viewState.lineBlockAt(target.range.head);
+            this.view.scrollDOM.scrollTop = ref.top - target.yMargin;
+            this.view.scrollDOM.scrollLeft = target.xMargin;
+            return;
+        }
+        for (let handler of this.view.state.facet(scrollHandler)) {
+            try {
+                if (handler(this.view, target.range, target))
+                    return true;
+            }
+            catch (e) {
+                logException(this.view.state, e, "scroll handler");
+            }
+        }
+        let { range } = target;
+        let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
+        if (!rect)
+            return;
+        if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
+            rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
+                right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
+        let margins = getScrollMargins(this.view);
+        let targetRect = {
+            left: rect.left - margins.left, top: rect.top - margins.top,
+            right: rect.right + margins.right, bottom: rect.bottom + margins.bottom
+        };
+        let { offsetWidth, offsetHeight } = this.view.scrollDOM;
+        scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, Math.max(Math.min(target.xMargin, offsetWidth), -offsetWidth), Math.max(Math.min(target.yMargin, offsetHeight), -offsetHeight), this.view.textDirection == Direction.LTR);
+    }
+}
+function betweenUneditable(pos) {
+    return pos.node.nodeType == 1 && pos.node.firstChild &&
+        (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
+        (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
+}
+function findCompositionNode(view, headPos) {
+    let sel = view.observer.selectionRange;
+    if (!sel.focusNode)
+        return null;
+    let textBefore = textNodeBefore(sel.focusNode, sel.focusOffset);
+    let textAfter = textNodeAfter(sel.focusNode, sel.focusOffset);
+    let textNode = textBefore || textAfter;
+    if (textAfter && textBefore && textAfter.node != textBefore.node) {
+        let descAfter = ContentView.get(textAfter.node);
+        if (!descAfter || descAfter instanceof TextView && descAfter.text != textAfter.node.nodeValue) {
+            textNode = textAfter;
+        }
+        else if (view.docView.lastCompositionAfterCursor) {
+            let descBefore = ContentView.get(textBefore.node);
+            if (!(!descBefore || descBefore instanceof TextView && descBefore.text != textBefore.node.nodeValue))
+                textNode = textAfter;
+        }
+    }
+    view.docView.lastCompositionAfterCursor = textNode != textBefore;
+    if (!textNode)
+        return null;
+    let from = headPos - textNode.offset;
+    return { from, to: from + textNode.node.nodeValue.length, node: textNode.node };
+}
+function findCompositionRange(view, changes, headPos) {
+    let found = findCompositionNode(view, headPos);
+    if (!found)
+        return null;
+    let { node: textNode, from, to } = found, text = textNode.nodeValue;
+    // Don't try to preserve multi-line compositions
+    if (/[\n\r]/.test(text))
+        return null;
+    if (view.state.doc.sliceString(found.from, found.to) != text)
+        return null;
+    let inv = changes.invertedDesc;
+    let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);
+    let marks = [];
+    for (let parent = textNode.parentNode;; parent = parent.parentNode) {
+        let parentView = ContentView.get(parent);
+        if (parentView instanceof MarkView)
+            marks.push({ node: parent, deco: parentView.mark });
+        else if (parentView instanceof LineView || parent.nodeName == "DIV" && parent.parentNode == view.contentDOM)
+            return { range, text: textNode, marks, line: parent };
+        else if (parent != view.contentDOM)
+            marks.push({ node: parent, deco: new MarkDecoration({
+                    inclusive: true,
+                    attributes: getAttrs(parent),
+                    tagName: parent.tagName.toLowerCase()
+                }) });
+        else
+            return null;
+    }
+}
+function nextToUneditable(node, offset) {
+    if (node.nodeType != 1)
+        return 0;
+    return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
+        (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
+}
+let DecorationComparator$1 = class DecorationComparator {
+    constructor() {
+        this.changes = [];
+    }
+    compareRange(from, to) { addRange(from, to, this.changes); }
+    comparePoint(from, to) { addRange(from, to, this.changes); }
+    boundChange(pos) { addRange(pos, pos, this.changes); }
+};
+function findChangedDeco(a, b, diff) {
+    let comp = new DecorationComparator$1;
+    RangeSet.compare(a, b, diff, comp);
+    return comp.changes;
+}
+function inUneditable(node, inside) {
+    for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
+        if (cur.nodeType == 1 && cur.contentEditable == 'false') {
+            return true;
+        }
+    }
+    return false;
+}
+function touchesComposition(changes, composition) {
+    let touched = false;
+    if (composition)
+        changes.iterChangedRanges((from, to) => {
+            if (from < composition.to && to > composition.from)
+                touched = true;
+        });
+    return touched;
+}
+
+function groupAt(state, pos, bias = 1) {
+    let categorize = state.charCategorizer(pos);
+    let line = state.doc.lineAt(pos), linePos = pos - line.from;
+    if (line.length == 0)
+        return EditorSelection.cursor(pos);
+    if (linePos == 0)
+        bias = 1;
+    else if (linePos == line.length)
+        bias = -1;
+    let from = linePos, to = linePos;
+    if (bias < 0)
+        from = findClusterBreak(line.text, linePos, false);
+    else
+        to = findClusterBreak(line.text, linePos);
+    let cat = categorize(line.text.slice(from, to));
+    while (from > 0) {
+        let prev = findClusterBreak(line.text, from, false);
+        if (categorize(line.text.slice(prev, from)) != cat)
+            break;
+        from = prev;
+    }
+    while (to < line.length) {
+        let next = findClusterBreak(line.text, to);
+        if (categorize(line.text.slice(to, next)) != cat)
+            break;
+        to = next;
+    }
+    return EditorSelection.range(from + line.from, to + line.from);
+}
+// Search the DOM for the {node, offset} position closest to the given
+// coordinates. Very inefficient and crude, but can usually be avoided
+// by calling caret(Position|Range)FromPoint instead.
+function getdx(x, rect) {
+    return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
+}
+function getdy(y, rect) {
+    return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
+}
+function yOverlap(a, b) {
+    return a.top < b.bottom - 1 && a.bottom > b.top + 1;
+}
+function upTop(rect, top) {
+    return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
+}
+function upBot(rect, bottom) {
+    return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
+}
+function domPosAtCoords(parent, x, y) {
+    let closest, closestRect, closestX, closestY, closestOverlap = false;
+    let above, below, aboveRect, belowRect;
+    for (let child = parent.firstChild; child; child = child.nextSibling) {
+        let rects = clientRectsFor(child);
+        for (let i = 0; i < rects.length; i++) {
+            let rect = rects[i];
+            if (closestRect && yOverlap(closestRect, rect))
+                rect = upTop(upBot(rect, closestRect.bottom), closestRect.top);
+            let dx = getdx(x, rect), dy = getdy(y, rect);
+            if (dx == 0 && dy == 0)
+                return child.nodeType == 3 ? domPosInText(child, x, y) : domPosAtCoords(child, x, y);
+            if (!closest || closestY > dy || closestY == dy && closestX > dx) {
+                closest = child;
+                closestRect = rect;
+                closestX = dx;
+                closestY = dy;
+                let side = dy ? (y < rect.top ? -1 : 1) : dx ? (x < rect.left ? -1 : 1) : 0;
+                closestOverlap = !side || (side > 0 ? i < rects.length - 1 : i > 0);
+            }
+            if (dx == 0) {
+                if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
+                    above = child;
+                    aboveRect = rect;
+                }
+                else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
+                    below = child;
+                    belowRect = rect;
+                }
+            }
+            else if (aboveRect && yOverlap(aboveRect, rect)) {
+                aboveRect = upBot(aboveRect, rect.bottom);
+            }
+            else if (belowRect && yOverlap(belowRect, rect)) {
+                belowRect = upTop(belowRect, rect.top);
+            }
+        }
+    }
+    if (aboveRect && aboveRect.bottom >= y) {
+        closest = above;
+        closestRect = aboveRect;
+    }
+    else if (belowRect && belowRect.top <= y) {
+        closest = below;
+        closestRect = belowRect;
+    }
+    if (!closest)
+        return { node: parent, offset: 0 };
+    let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
+    if (closest.nodeType == 3)
+        return domPosInText(closest, clipX, y);
+    if (closestOverlap && closest.contentEditable != "false")
+        return domPosAtCoords(closest, clipX, y);
+    let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
+        (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
+    return { node: parent, offset };
+}
+function domPosInText(node, x, y) {
+    let len = node.nodeValue.length;
+    let closestOffset = -1, closestDY = 1e9, generalSide = 0;
+    for (let i = 0; i < len; i++) {
+        let rects = textRange(node, i, i + 1).getClientRects();
+        for (let j = 0; j < rects.length; j++) {
+            let rect = rects[j];
+            if (rect.top == rect.bottom)
+                continue;
+            if (!generalSide)
+                generalSide = x - rect.left;
+            let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
+            if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
+                let right = x >= (rect.left + rect.right) / 2, after = right;
+                if (browser.chrome || browser.gecko) {
+                    // Check for RTL on browsers that support getting client
+                    // rects for empty ranges.
+                    let rectBefore = textRange(node, i).getBoundingClientRect();
+                    if (rectBefore.left == rect.right)
+                        after = !right;
+                }
+                if (dy <= 0)
+                    return { node, offset: i + (after ? 1 : 0) };
+                closestOffset = i + (after ? 1 : 0);
+                closestDY = dy;
+            }
+        }
+    }
+    return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
+}
+function posAtCoords(view, coords, precise, bias = -1) {
+    var _a, _b;
+    let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
+    let block, { docHeight } = view.viewState;
+    let { x, y } = coords, yOffset = y - docTop;
+    if (yOffset < 0)
+        return 0;
+    if (yOffset > docHeight)
+        return view.state.doc.length;
+    // Scan for a text block near the queried y position
+    for (let halfLine = view.viewState.heightOracle.textHeight / 2, bounced = false;;) {
+        block = view.elementAtHeight(yOffset);
+        if (block.type == BlockType.Text)
+            break;
+        for (;;) {
+            // Move the y position out of this block
+            yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
+            if (yOffset >= 0 && yOffset <= docHeight)
+                break;
+            // If the document consists entirely of replaced widgets, we
+            // won't find a text block, so return 0
+            if (bounced)
+                return precise ? null : 0;
+            bounced = true;
+            bias = -bias;
+        }
+    }
+    y = docTop + yOffset;
+    let lineStart = block.from;
+    // If this is outside of the rendered viewport, we can't determine a position
+    if (lineStart < view.viewport.from)
+        return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise(view, content, block, x, y);
+    if (lineStart > view.viewport.to)
+        return view.viewport.to == view.state.doc.length ? view.state.doc.length :
+            precise ? null : posAtCoordsImprecise(view, content, block, x, y);
+    // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
+    let doc = view.dom.ownerDocument;
+    let root = view.root.elementFromPoint ? view.root : doc;
+    let element = root.elementFromPoint(x, y);
+    if (element && !view.contentDOM.contains(element))
+        element = null;
+    // If the element is unexpected, clip x at the sides of the content area and try again
+    if (!element) {
+        x = Math.max(content.left + 1, Math.min(content.right - 1, x));
+        element = root.elementFromPoint(x, y);
+        if (element && !view.contentDOM.contains(element))
+            element = null;
+    }
+    // There's visible editor content under the point, so we can try
+    // using caret(Position|Range)FromPoint as a shortcut
+    let node, offset = -1;
+    if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
+        if (doc.caretPositionFromPoint) {
+            let pos = doc.caretPositionFromPoint(x, y);
+            if (pos)
+                ({ offsetNode: node, offset } = pos);
+        }
+        else if (doc.caretRangeFromPoint) {
+            let range = doc.caretRangeFromPoint(x, y);
+            if (range) {
+                ({ startContainer: node, startOffset: offset } = range);
+                if (!view.contentDOM.contains(node) ||
+                    browser.safari && isSuspiciousSafariCaretResult(node, offset, x) ||
+                    browser.chrome && isSuspiciousChromeCaretResult(node, offset, x))
+                    node = undefined;
+            }
+        }
+        // Chrome will return offsets into <input> elements without child
+        // nodes, which will lead to a null deref below, so clip the
+        // offset to the node size.
+        if (node)
+            offset = Math.min(maxOffset(node), offset);
+    }
+    // No luck, do our own (potentially expensive) search
+    if (!node || !view.docView.dom.contains(node)) {
+        let line = LineView.find(view.docView, lineStart);
+        if (!line)
+            return yOffset > block.top + block.height / 2 ? block.to : block.from;
+        ({ node, offset } = domPosAtCoords(line.dom, x, y));
+    }
+    let nearest = view.docView.nearest(node);
+    if (!nearest)
+        return null;
+    if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {
+        let rect = nearest.dom.getBoundingClientRect();
+        return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2
+            ? nearest.posAtStart : nearest.posAtEnd;
+    }
+    else {
+        return nearest.localPosFromDOM(node, offset) + nearest.posAtStart;
+    }
+}
+function posAtCoordsImprecise(view, contentRect, block, x, y) {
+    let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
+    if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
+        let textHeight = view.viewState.heightOracle.textHeight;
+        let line = Math.floor((y - block.top - (view.defaultLineHeight - textHeight) * 0.5) / textHeight);
+        into += line * view.viewState.heightOracle.lineLength;
+    }
+    let content = view.state.sliceDoc(block.from, block.to);
+    return block.from + findColumn(content, into, view.state.tabSize);
+}
+// In case of a high line height, Safari's caretRangeFromPoint treats
+// the space between lines as belonging to the last character of the
+// line before. This is used to detect such a result so that it can be
+// ignored (issue #401).
+function isSuspiciousSafariCaretResult(node, offset, x) {
+    let len;
+    if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
+        return false;
+    for (let next = node.nextSibling; next; next = next.nextSibling)
+        if (next.nodeType != 1 || next.nodeName != "BR")
+            return false;
+    return textRange(node, len - 1, len).getBoundingClientRect().left > x;
+}
+// Chrome will move positions between lines to the start of the next line
+function isSuspiciousChromeCaretResult(node, offset, x) {
+    if (offset != 0)
+        return false;
+    for (let cur = node;;) {
+        let parent = cur.parentNode;
+        if (!parent || parent.nodeType != 1 || parent.firstChild != cur)
+            return false;
+        if (parent.classList.contains("cm-line"))
+            break;
+        cur = parent;
+    }
+    let rect = node.nodeType == 1 ? node.getBoundingClientRect()
+        : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
+    return x - rect.left > 5;
+}
+function blockAt(view, pos) {
+    let line = view.lineBlockAt(pos);
+    if (Array.isArray(line.type))
+        for (let l of line.type) {
+            if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))
+                return l;
+        }
+    return line;
+}
+function moveToLineBoundary(view, start, forward, includeWrap) {
+    let line = blockAt(view, start.head);
+    let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
+        : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
+    if (coords) {
+        let editorRect = view.dom.getBoundingClientRect();
+        let direction = view.textDirectionAt(line.from);
+        let pos = view.posAtCoords({ x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,
+            y: (coords.top + coords.bottom) / 2 });
+        if (pos != null)
+            return EditorSelection.cursor(pos, forward ? -1 : 1);
+    }
+    return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);
+}
+function moveByChar(view, start, forward, by) {
+    let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
+    let direction = view.textDirectionAt(line.from);
+    for (let cur = start, check = null;;) {
+        let next = moveVisually(line, spans, direction, cur, forward), char = movedOver;
+        if (!next) {
+            if (line.number == (forward ? view.state.doc.lines : 1))
+                return cur;
+            char = "\n";
+            line = view.state.doc.line(line.number + (forward ? 1 : -1));
+            spans = view.bidiSpans(line);
+            next = view.visualLineSide(line, !forward);
+        }
+        if (!check) {
+            if (!by)
+                return next;
+            check = by(char);
+        }
+        else if (!check(char)) {
+            return cur;
+        }
+        cur = next;
+    }
+}
+function byGroup(view, pos, start) {
+    let categorize = view.state.charCategorizer(pos);
+    let cat = categorize(start);
+    return (next) => {
+        let nextCat = categorize(next);
+        if (cat == CharCategory.Space)
+            cat = nextCat;
+        return cat == nextCat;
+    };
+}
+function moveVertically(view, start, forward, distance) {
+    let startPos = start.head, dir = forward ? 1 : -1;
+    if (startPos == (forward ? view.state.doc.length : 0))
+        return EditorSelection.cursor(startPos, start.assoc);
+    let goal = start.goalColumn, startY;
+    let rect = view.contentDOM.getBoundingClientRect();
+    let startCoords = view.coordsAtPos(startPos, start.assoc || -1), docTop = view.documentTop;
+    if (startCoords) {
+        if (goal == null)
+            goal = startCoords.left - rect.left;
+        startY = dir < 0 ? startCoords.top : startCoords.bottom;
+    }
+    else {
+        let line = view.viewState.lineBlockAt(startPos);
+        if (goal == null)
+            goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
+        startY = (dir < 0 ? line.top : line.bottom) + docTop;
+    }
+    let resolvedGoal = rect.left + goal;
+    let dist = distance !== null && distance !== void 0 ? distance : (view.viewState.heightOracle.textHeight >> 1);
+    for (let extra = 0;; extra += 10) {
+        let curY = startY + (dist + extra) * dir;
+        let pos = posAtCoords(view, { x: resolvedGoal, y: curY }, false, dir);
+        if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos)) {
+            let charRect = view.docView.coordsForChar(pos);
+            let assoc = !charRect || curY < charRect.top ? -1 : 1;
+            return EditorSelection.cursor(pos, assoc, undefined, goal);
+        }
+    }
+}
+function skipAtomicRanges(atoms, pos, bias) {
+    for (;;) {
+        let moved = 0;
+        for (let set of atoms) {
+            set.between(pos - 1, pos + 1, (from, to, value) => {
+                if (pos > from && pos < to) {
+                    let side = moved || bias || (pos - from < to - pos ? -1 : 1);
+                    pos = side < 0 ? from : to;
+                    moved = side;
+                }
+            });
+        }
+        if (!moved)
+            return pos;
+    }
+}
+function skipAtoms(view, oldPos, pos) {
+    let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);
+    return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);
+}
+
+const LineBreakPlaceholder = "\uffff";
+class DOMReader {
+    constructor(points, state) {
+        this.points = points;
+        this.text = "";
+        this.lineSeparator = state.facet(EditorState.lineSeparator);
+    }
+    append(text) {
+        this.text += text;
+    }
+    lineBreak() {
+        this.text += LineBreakPlaceholder;
+    }
+    readRange(start, end) {
+        if (!start)
+            return this;
+        let parent = start.parentNode;
+        for (let cur = start;;) {
+            this.findPointBefore(parent, cur);
+            let oldLen = this.text.length;
+            this.readNode(cur);
+            let next = cur.nextSibling;
+            if (next == end)
+                break;
+            let view = ContentView.get(cur), nextView = ContentView.get(next);
+            if (view && nextView ? view.breakAfter :
+                (view ? view.breakAfter : isBlockElement(cur)) ||
+                    (isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore) && this.text.length > oldLen))
+                this.lineBreak();
+            cur = next;
+        }
+        this.findPointBefore(parent, end);
+        return this;
+    }
+    readTextNode(node) {
+        let text = node.nodeValue;
+        for (let point of this.points)
+            if (point.node == node)
+                point.pos = this.text.length + Math.min(point.offset, text.length);
+        for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
+            let nextBreak = -1, breakSize = 1, m;
+            if (this.lineSeparator) {
+                nextBreak = text.indexOf(this.lineSeparator, off);
+                breakSize = this.lineSeparator.length;
+            }
+            else if (m = re.exec(text)) {
+                nextBreak = m.index;
+                breakSize = m[0].length;
+            }
+            this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
+            if (nextBreak < 0)
+                break;
+            this.lineBreak();
+            if (breakSize > 1)
+                for (let point of this.points)
+                    if (point.node == node && point.pos > this.text.length)
+                        point.pos -= breakSize - 1;
+            off = nextBreak + breakSize;
+        }
+    }
+    readNode(node) {
+        if (node.cmIgnore)
+            return;
+        let view = ContentView.get(node);
+        let fromView = view && view.overrideDOMText;
+        if (fromView != null) {
+            this.findPointInside(node, fromView.length);
+            for (let i = fromView.iter(); !i.next().done;) {
+                if (i.lineBreak)
+                    this.lineBreak();
+                else
+                    this.append(i.value);
+            }
+        }
+        else if (node.nodeType == 3) {
+            this.readTextNode(node);
+        }
+        else if (node.nodeName == "BR") {
+            if (node.nextSibling)
+                this.lineBreak();
+        }
+        else if (node.nodeType == 1) {
+            this.readRange(node.firstChild, null);
+        }
+    }
+    findPointBefore(node, next) {
+        for (let point of this.points)
+            if (point.node == node && node.childNodes[point.offset] == next)
+                point.pos = this.text.length;
+    }
+    findPointInside(node, length) {
+        for (let point of this.points)
+            if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
+                point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);
+    }
+}
+function isAtEnd(parent, node, offset) {
+    for (;;) {
+        if (!node || offset < maxOffset(node))
+            return false;
+        if (node == parent)
+            return true;
+        offset = domIndex(node) + 1;
+        node = node.parentNode;
+    }
+}
+class DOMPoint {
+    constructor(node, offset) {
+        this.node = node;
+        this.offset = offset;
+        this.pos = -1;
+    }
+}
+
+class DOMChange {
+    constructor(view, start, end, typeOver) {
+        this.typeOver = typeOver;
+        this.bounds = null;
+        this.text = "";
+        this.domChanged = start > -1;
+        let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
+        if (view.state.readOnly && start > -1) {
+            // Ignore changes when the editor is read-only
+            this.newSel = null;
+        }
+        else if (start > -1 && (this.bounds = view.docView.domBoundsAround(start, end, 0))) {
+            let selPoints = iHead || iAnchor ? [] : selectionPoints(view);
+            let reader = new DOMReader(selPoints, view.state);
+            reader.readRange(this.bounds.startDOM, this.bounds.endDOM);
+            this.text = reader.text;
+            this.newSel = selectionFromPoints(selPoints, this.bounds.from);
+        }
+        else {
+            let domSel = view.observer.selectionRange;
+            let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
+                !contains(view.contentDOM, domSel.focusNode)
+                ? view.state.selection.main.head
+                : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
+            let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
+                !contains(view.contentDOM, domSel.anchorNode)
+                ? view.state.selection.main.anchor
+                : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
+            // iOS will refuse to select the block gaps when doing
+            // select-all.
+            // Chrome will put the selection *inside* them, confusing
+            // posFromDOM
+            let vp = view.viewport;
+            if ((browser.ios || browser.chrome) && view.state.selection.main.empty && head != anchor &&
+                (vp.from > 0 || vp.to < view.state.doc.length)) {
+                let from = Math.min(head, anchor), to = Math.max(head, anchor);
+                let offFrom = vp.from - from, offTo = vp.to - to;
+                if ((offFrom == 0 || offFrom == 1 || from == 0) && (offTo == 0 || offTo == -1 || to == view.state.doc.length)) {
+                    head = 0;
+                    anchor = view.state.doc.length;
+                }
+            }
+            this.newSel = EditorSelection.single(anchor, head);
+        }
+    }
+}
+function applyDOMChange(view, domChange) {
+    let change;
+    let { newSel } = domChange, sel = view.state.selection.main;
+    let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;
+    if (domChange.bounds) {
+        let { from, to } = domChange.bounds;
+        let preferredPos = sel.from, preferredSide = null;
+        // Prefer anchoring to end when Backspace is pressed (or, on
+        // Android, when something was deleted)
+        if (lastKey === 8 || browser.android && domChange.text.length < to - from) {
+            preferredPos = sel.to;
+            preferredSide = "end";
+        }
+        let diff = findDiff(view.state.doc.sliceString(from, to, LineBreakPlaceholder), domChange.text, preferredPos - from, preferredSide);
+        if (diff) {
+            // Chrome inserts two newlines when pressing shift-enter at the
+            // end of a line. DomChange drops one of those.
+            if (browser.chrome && lastKey == 13 &&
+                diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)
+                diff.toB--;
+            change = { from: from + diff.from, to: from + diff.toA,
+                insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
+        }
+    }
+    else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
+        newSel = null;
+    }
+    if (!change && !newSel)
+        return false;
+    if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {
+        // Heuristic to notice typing over a selected character
+        change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
+    }
+    else if (change && change.from >= sel.from && change.to <= sel.to &&
+        (change.from != sel.from || change.to != sel.to) &&
+        (sel.to - sel.from) - (change.to - change.from) <= 4) {
+        // If the change is inside the selection and covers most of it,
+        // assume it is a selection replace (with identical characters at
+        // the start/end not included in the diff)
+        change = {
+            from: sel.from, to: sel.to,
+            insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
+        };
+    }
+    else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&
+        /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
+        // Detect insert-period-on-double-space Mac and Android behavior,
+        // and transform it into a regular space insert.
+        if (newSel && change.insert.length == 2)
+            newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
+        change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
+    }
+    else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&
+        change.insert.toString() == "\n " && view.lineWrapping) {
+        // In Chrome, if you insert a space at the start of a wrapped
+        // line, it will actually insert a newline and a space, causing a
+        // bogus new line to be created in CodeMirror (#968)
+        if (newSel)
+            newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
+        change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
+    }
+    if (change) {
+        return applyDOMChangeInner(view, change, newSel, lastKey);
+    }
+    else if (newSel && !newSel.main.eq(sel)) {
+        let scrollIntoView = false, userEvent = "select";
+        if (view.inputState.lastSelectionTime > Date.now() - 50) {
+            if (view.inputState.lastSelectionOrigin == "select")
+                scrollIntoView = true;
+            userEvent = view.inputState.lastSelectionOrigin;
+        }
+        view.dispatch({ selection: newSel, scrollIntoView, userEvent });
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+function applyDOMChangeInner(view, change, newSel, lastKey = -1) {
+    if (browser.ios && view.inputState.flushIOSKey(change))
+        return true;
+    let sel = view.state.selection.main;
+    // Android browsers don't fire reasonable key events for enter,
+    // backspace, or delete. So this detects changes that look like
+    // they're caused by those keys, and reinterprets them as key
+    // events. (Some of these keys are also handled by beforeinput
+    // events and the pendingAndroidKey mechanism, but that's not
+    // reliable in all situations.)
+    if (browser.android &&
+        ((change.to == sel.to &&
+            // GBoard will sometimes remove a space it just inserted
+            // after a completion when you press enter
+            (change.from == sel.from || change.from == sel.from - 1 && view.state.sliceDoc(change.from, sel.from) == " ") &&
+            change.insert.length == 1 && change.insert.lines == 2 &&
+            dispatchKey(view.contentDOM, "Enter", 13)) ||
+            ((change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 ||
+                lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) &&
+                dispatchKey(view.contentDOM, "Backspace", 8)) ||
+            (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
+                dispatchKey(view.contentDOM, "Delete", 46))))
+        return true;
+    let text = change.insert.toString();
+    if (view.inputState.composing >= 0)
+        view.inputState.composing++;
+    let defaultTr;
+    let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));
+    if (!view.state.facet(inputHandler$1).some(h => h(view, change.from, change.to, text, defaultInsert)))
+        view.dispatch(defaultInsert());
+    return true;
+}
+function applyDefaultInsert(view, change, newSel) {
+    let tr, startState = view.state, sel = startState.selection.main;
+    if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
+        (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
+        view.inputState.composing < 0) {
+        let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
+        let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
+        tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
+    }
+    else {
+        let changes = startState.changes(change);
+        let mainSel = newSel && newSel.main.to <= changes.newLength ? newSel.main : undefined;
+        // Try to apply a composition change to all cursors
+        if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
+            change.to <= sel.to && change.to >= sel.to - 10) {
+            let replaced = view.state.sliceDoc(change.from, change.to);
+            let compositionRange, composition = newSel && findCompositionNode(view, newSel.main.head);
+            if (composition) {
+                let dLen = change.insert.length - (change.to - change.from);
+                compositionRange = { from: composition.from, to: composition.to - dLen };
+            }
+            else {
+                compositionRange = view.state.doc.lineAt(sel.head);
+            }
+            let offset = sel.to - change.to, size = sel.to - sel.from;
+            tr = startState.changeByRange(range => {
+                if (range.from == sel.from && range.to == sel.to)
+                    return { changes, range: mainSel || range.map(changes) };
+                let to = range.to - offset, from = to - replaced.length;
+                if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
+                    // Unfortunately, there's no way to make multiple
+                    // changes in the same node work without aborting
+                    // composition, so cursors in the composition range are
+                    // ignored.
+                    range.to >= compositionRange.from && range.from <= compositionRange.to)
+                    return { range };
+                let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
+                return {
+                    changes: rangeChanges,
+                    range: !mainSel ? range.map(rangeChanges) :
+                        EditorSelection.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
+                };
+            });
+        }
+        else {
+            tr = {
+                changes,
+                selection: mainSel && startState.selection.replaceRange(mainSel)
+            };
+        }
+    }
+    let userEvent = "input.type";
+    if (view.composing ||
+        view.inputState.compositionPendingChange && view.inputState.compositionEndedAt > Date.now() - 50) {
+        view.inputState.compositionPendingChange = false;
+        userEvent += ".compose";
+        if (view.inputState.compositionFirstChange) {
+            userEvent += ".start";
+            view.inputState.compositionFirstChange = false;
+        }
+    }
+    return startState.update(tr, { userEvent, scrollIntoView: true });
+}
+function findDiff(a, b, preferredPos, preferredSide) {
+    let minLen = Math.min(a.length, b.length);
+    let from = 0;
+    while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
+        from++;
+    if (from == minLen && a.length == b.length)
+        return null;
+    let toA = a.length, toB = b.length;
+    while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
+        toA--;
+        toB--;
+    }
+    if (preferredSide == "end") {
+        let adjust = Math.max(0, from - Math.min(toA, toB));
+        preferredPos -= toA + adjust - from;
+    }
+    if (toA < from && a.length < b.length) {
+        let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
+        from -= move;
+        toB = from + (toB - toA);
+        toA = from;
+    }
+    else if (toB < from) {
+        let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
+        from -= move;
+        toA = from + (toA - toB);
+        toB = from;
+    }
+    return { from, toA, toB };
+}
+function selectionPoints(view) {
+    let result = [];
+    if (view.root.activeElement != view.contentDOM)
+        return result;
+    let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
+    if (anchorNode) {
+        result.push(new DOMPoint(anchorNode, anchorOffset));
+        if (focusNode != anchorNode || focusOffset != anchorOffset)
+            result.push(new DOMPoint(focusNode, focusOffset));
+    }
+    return result;
+}
+function selectionFromPoints(points, base) {
+    if (points.length == 0)
+        return null;
+    let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
+    return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;
+}
+
+class InputState {
+    setSelectionOrigin(origin) {
+        this.lastSelectionOrigin = origin;
+        this.lastSelectionTime = Date.now();
+    }
+    constructor(view) {
+        this.view = view;
+        this.lastKeyCode = 0;
+        this.lastKeyTime = 0;
+        this.lastTouchTime = 0;
+        this.lastFocusTime = 0;
+        this.lastScrollTop = 0;
+        this.lastScrollLeft = 0;
+        // On iOS, some keys need to have their default behavior happen
+        // (after which we retroactively handle them and reset the DOM) to
+        // avoid messing up the virtual keyboard state.
+        this.pendingIOSKey = undefined;
+        /**
+        When enabled (>-1), tab presses are not given to key handlers,
+        leaving the browser's default behavior. If >0, the mode expires
+        at that timestamp, and any other keypress clears it.
+        Esc enables temporary tab focus mode for two seconds when not
+        otherwise handled.
+        */
+        this.tabFocusMode = -1;
+        this.lastSelectionOrigin = null;
+        this.lastSelectionTime = 0;
+        this.lastContextMenu = 0;
+        this.scrollHandlers = [];
+        this.handlers = Object.create(null);
+        // -1 means not in a composition. Otherwise, this counts the number
+        // of changes made during the composition. The count is used to
+        // avoid treating the start state of the composition, before any
+        // changes have been made, as part of the composition.
+        this.composing = -1;
+        // Tracks whether the next change should be marked as starting the
+        // composition (null means no composition, true means next is the
+        // first, false means first has already been marked for this
+        // composition)
+        this.compositionFirstChange = null;
+        // End time of the previous composition
+        this.compositionEndedAt = 0;
+        // Used in a kludge to detect when an Enter keypress should be
+        // considered part of the composition on Safari, which fires events
+        // in the wrong order
+        this.compositionPendingKey = false;
+        // Used to categorize changes as part of a composition, even when
+        // the mutation events fire shortly after the compositionend event
+        this.compositionPendingChange = false;
+        this.mouseSelection = null;
+        // When a drag from the editor is active, this points at the range
+        // being dragged.
+        this.draggedContent = null;
+        this.handleEvent = this.handleEvent.bind(this);
+        this.notifiedFocused = view.hasFocus;
+        // On Safari adding an input event handler somehow prevents an
+        // issue where the composition vanishes when you press enter.
+        if (browser.safari)
+            view.contentDOM.addEventListener("input", () => null);
+        if (browser.gecko)
+            firefoxCopyCutHack(view.contentDOM.ownerDocument);
+    }
+    handleEvent(event) {
+        if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event))
+            return;
+        if (event.type == "keydown" && this.keydown(event))
+            return;
+        this.runHandlers(event.type, event);
+    }
+    runHandlers(type, event) {
+        let handlers = this.handlers[type];
+        if (handlers) {
+            for (let observer of handlers.observers)
+                observer(this.view, event);
+            for (let handler of handlers.handlers) {
+                if (event.defaultPrevented)
+                    break;
+                if (handler(this.view, event)) {
+                    event.preventDefault();
+                    break;
+                }
+            }
+        }
+    }
+    ensureHandlers(plugins) {
+        let handlers = computeHandlers(plugins), prev = this.handlers, dom = this.view.contentDOM;
+        for (let type in handlers)
+            if (type != "scroll") {
+                let passive = !handlers[type].handlers.length;
+                let exists = prev[type];
+                if (exists && passive != !exists.handlers.length) {
+                    dom.removeEventListener(type, this.handleEvent);
+                    exists = null;
+                }
+                if (!exists)
+                    dom.addEventListener(type, this.handleEvent, { passive });
+            }
+        for (let type in prev)
+            if (type != "scroll" && !handlers[type])
+                dom.removeEventListener(type, this.handleEvent);
+        this.handlers = handlers;
+    }
+    keydown(event) {
+        // Must always run, even if a custom handler handled the event
+        this.lastKeyCode = event.keyCode;
+        this.lastKeyTime = Date.now();
+        if (event.keyCode == 9 && this.tabFocusMode > -1 && (!this.tabFocusMode || Date.now() <= this.tabFocusMode))
+            return true;
+        if (this.tabFocusMode > 0 && event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)
+            this.tabFocusMode = -1;
+        // Chrome for Android usually doesn't fire proper key events, but
+        // occasionally does, usually surrounded by a bunch of complicated
+        // composition changes. When an enter or backspace key event is
+        // seen, hold off on handling DOM events for a bit, and then
+        // dispatch it.
+        if (browser.android && browser.chrome && !event.synthetic &&
+            (event.keyCode == 13 || event.keyCode == 8)) {
+            this.view.observer.delayAndroidKey(event.key, event.keyCode);
+            return true;
+        }
+        // Preventing the default behavior of Enter on iOS makes the
+        // virtual keyboard get stuck in the wrong (lowercase)
+        // state. So we let it go through, and then, in
+        // applyDOMChange, notify key handlers of it and reset to
+        // the state they produce.
+        let pending;
+        if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&
+            ((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||
+                EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {
+            this.pendingIOSKey = pending || event;
+            setTimeout(() => this.flushIOSKey(), 250);
+            return true;
+        }
+        if (event.keyCode != 229)
+            this.view.observer.forceFlush();
+        return false;
+    }
+    flushIOSKey(change) {
+        let key = this.pendingIOSKey;
+        if (!key)
+            return false;
+        // This looks like an autocorrection before Enter
+        if (key.key == "Enter" && change && change.from < change.to && /^\S+$/.test(change.insert.toString()))
+            return false;
+        this.pendingIOSKey = undefined;
+        return dispatchKey(this.view.contentDOM, key.key, key.keyCode, key instanceof KeyboardEvent ? key : undefined);
+    }
+    ignoreDuringComposition(event) {
+        if (!/^key/.test(event.type))
+            return false;
+        if (this.composing > 0)
+            return true;
+        // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
+        // On some input method editors (IMEs), the Enter key is used to
+        // confirm character selection. On Safari, when Enter is pressed,
+        // compositionend and keydown events are sometimes emitted in the
+        // wrong order. The key event should still be ignored, even when
+        // it happens after the compositionend event.
+        if (browser.safari && !browser.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100) {
+            this.compositionPendingKey = false;
+            return true;
+        }
+        return false;
+    }
+    startMouseSelection(mouseSelection) {
+        if (this.mouseSelection)
+            this.mouseSelection.destroy();
+        this.mouseSelection = mouseSelection;
+    }
+    update(update) {
+        this.view.observer.update(update);
+        if (this.mouseSelection)
+            this.mouseSelection.update(update);
+        if (this.draggedContent && update.docChanged)
+            this.draggedContent = this.draggedContent.map(update.changes);
+        if (update.transactions.length)
+            this.lastKeyCode = this.lastSelectionTime = 0;
+    }
+    destroy() {
+        if (this.mouseSelection)
+            this.mouseSelection.destroy();
+    }
+}
+function bindHandler(plugin, handler) {
+    return (view, event) => {
+        try {
+            return handler.call(plugin, event, view);
+        }
+        catch (e) {
+            logException(view.state, e);
+        }
+    };
+}
+function computeHandlers(plugins) {
+    let result = Object.create(null);
+    function record(type) {
+        return result[type] || (result[type] = { observers: [], handlers: [] });
+    }
+    for (let plugin of plugins) {
+        let spec = plugin.spec;
+        if (spec && spec.domEventHandlers)
+            for (let type in spec.domEventHandlers) {
+                let f = spec.domEventHandlers[type];
+                if (f)
+                    record(type).handlers.push(bindHandler(plugin.value, f));
+            }
+        if (spec && spec.domEventObservers)
+            for (let type in spec.domEventObservers) {
+                let f = spec.domEventObservers[type];
+                if (f)
+                    record(type).observers.push(bindHandler(plugin.value, f));
+            }
+    }
+    for (let type in handlers)
+        record(type).handlers.push(handlers[type]);
+    for (let type in observers)
+        record(type).observers.push(observers[type]);
+    return result;
+}
+const PendingKeys = [
+    { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
+    { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
+    { key: "Enter", keyCode: 13, inputType: "insertLineBreak" },
+    { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
+];
+const EmacsyPendingKeys = "dthko";
+// Key codes for modifier keys
+const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
+const dragScrollMargin = 6;
+function dragScrollSpeed(dist) {
+    return Math.max(0, dist) * 0.7 + 8;
+}
+function dist(a, b) {
+    return Math.max(Math.abs(a.clientX - b.clientX), Math.abs(a.clientY - b.clientY));
+}
+class MouseSelection {
+    constructor(view, startEvent, style, mustSelect) {
+        this.view = view;
+        this.startEvent = startEvent;
+        this.style = style;
+        this.mustSelect = mustSelect;
+        this.scrollSpeed = { x: 0, y: 0 };
+        this.scrolling = -1;
+        this.lastEvent = startEvent;
+        this.scrollParents = scrollableParents(view.contentDOM);
+        this.atoms = view.state.facet(atomicRanges).map(f => f(view));
+        let doc = view.contentDOM.ownerDocument;
+        doc.addEventListener("mousemove", this.move = this.move.bind(this));
+        doc.addEventListener("mouseup", this.up = this.up.bind(this));
+        this.extend = startEvent.shiftKey;
+        this.multiple = view.state.facet(EditorState.allowMultipleSelections) && addsSelectionRange(view, startEvent);
+        this.dragging = isInPrimarySelection(view, startEvent) && getClickType(startEvent) == 1 ? null : false;
+    }
+    start(event) {
+        // When clicking outside of the selection, immediately apply the
+        // effect of starting the selection
+        if (this.dragging === false)
+            this.select(event);
+    }
+    move(event) {
+        if (event.buttons == 0)
+            return this.destroy();
+        if (this.dragging || this.dragging == null && dist(this.startEvent, event) < 10)
+            return;
+        this.select(this.lastEvent = event);
+        let sx = 0, sy = 0;
+        let left = 0, top = 0, right = this.view.win.innerWidth, bottom = this.view.win.innerHeight;
+        if (this.scrollParents.x)
+            ({ left, right } = this.scrollParents.x.getBoundingClientRect());
+        if (this.scrollParents.y)
+            ({ top, bottom } = this.scrollParents.y.getBoundingClientRect());
+        let margins = getScrollMargins(this.view);
+        if (event.clientX - margins.left <= left + dragScrollMargin)
+            sx = -dragScrollSpeed(left - event.clientX);
+        else if (event.clientX + margins.right >= right - dragScrollMargin)
+            sx = dragScrollSpeed(event.clientX - right);
+        if (event.clientY - margins.top <= top + dragScrollMargin)
+            sy = -dragScrollSpeed(top - event.clientY);
+        else if (event.clientY + margins.bottom >= bottom - dragScrollMargin)
+            sy = dragScrollSpeed(event.clientY - bottom);
+        this.setScrollSpeed(sx, sy);
+    }
+    up(event) {
+        if (this.dragging == null)
+            this.select(this.lastEvent);
+        if (!this.dragging)
+            event.preventDefault();
+        this.destroy();
+    }
+    destroy() {
+        this.setScrollSpeed(0, 0);
+        let doc = this.view.contentDOM.ownerDocument;
+        doc.removeEventListener("mousemove", this.move);
+        doc.removeEventListener("mouseup", this.up);
+        this.view.inputState.mouseSelection = this.view.inputState.draggedContent = null;
+    }
+    setScrollSpeed(sx, sy) {
+        this.scrollSpeed = { x: sx, y: sy };
+        if (sx || sy) {
+            if (this.scrolling < 0)
+                this.scrolling = setInterval(() => this.scroll(), 50);
+        }
+        else if (this.scrolling > -1) {
+            clearInterval(this.scrolling);
+            this.scrolling = -1;
+        }
+    }
+    scroll() {
+        let { x, y } = this.scrollSpeed;
+        if (x && this.scrollParents.x) {
+            this.scrollParents.x.scrollLeft += x;
+            x = 0;
+        }
+        if (y && this.scrollParents.y) {
+            this.scrollParents.y.scrollTop += y;
+            y = 0;
+        }
+        if (x || y)
+            this.view.win.scrollBy(x, y);
+        if (this.dragging === false)
+            this.select(this.lastEvent);
+    }
+    skipAtoms(sel) {
+        let ranges = null;
+        for (let i = 0; i < sel.ranges.length; i++) {
+            let range = sel.ranges[i], updated = null;
+            if (range.empty) {
+                let pos = skipAtomicRanges(this.atoms, range.from, 0);
+                if (pos != range.from)
+                    updated = EditorSelection.cursor(pos, -1);
+            }
+            else {
+                let from = skipAtomicRanges(this.atoms, range.from, -1);
+                let to = skipAtomicRanges(this.atoms, range.to, 1);
+                if (from != range.from || to != range.to)
+                    updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
+            }
+            if (updated) {
+                if (!ranges)
+                    ranges = sel.ranges.slice();
+                ranges[i] = updated;
+            }
+        }
+        return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;
+    }
+    select(event) {
+        let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
+        if (this.mustSelect || !selection.eq(view.state.selection, this.dragging === false))
+            this.view.dispatch({
+                selection,
+                userEvent: "select.pointer"
+            });
+        this.mustSelect = false;
+    }
+    update(update) {
+        if (update.transactions.some(tr => tr.isUserEvent("input.type")))
+            this.destroy();
+        else if (this.style.update(update))
+            setTimeout(() => this.select(this.lastEvent), 20);
+    }
+}
+function addsSelectionRange(view, event) {
+    let facet = view.state.facet(clickAddsSelectionRange);
+    return facet.length ? facet[0](event) : browser.mac ? event.metaKey : event.ctrlKey;
+}
+function dragMovesSelection(view, event) {
+    let facet = view.state.facet(dragMovesSelection$1);
+    return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;
+}
+function isInPrimarySelection(view, event) {
+    let { main } = view.state.selection;
+    if (main.empty)
+        return false;
+    // On boundary clicks, check whether the coordinates are inside the
+    // selection's client rectangles
+    let sel = getSelection(view.root);
+    if (!sel || sel.rangeCount == 0)
+        return true;
+    let rects = sel.getRangeAt(0).getClientRects();
+    for (let i = 0; i < rects.length; i++) {
+        let rect = rects[i];
+        if (rect.left <= event.clientX && rect.right >= event.clientX &&
+            rect.top <= event.clientY && rect.bottom >= event.clientY)
+            return true;
+    }
+    return false;
+}
+function eventBelongsToEditor(view, event) {
+    if (!event.bubbles)
+        return true;
+    if (event.defaultPrevented)
+        return false;
+    for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
+        if (!node || node.nodeType == 11 || ((cView = ContentView.get(node)) && cView.ignoreEvent(event)))
+            return false;
+    return true;
+}
+const handlers = /*@__PURE__*/Object.create(null);
+const observers = /*@__PURE__*/Object.create(null);
+// This is very crude, but unfortunately both these browsers _pretend_
+// that they have a clipboard API—all the objects and methods are
+// there, they just don't work, and they are hard to test.
+const brokenClipboardAPI = (browser.ie && browser.ie_version < 15) ||
+    (browser.ios && browser.webkit_version < 604);
+function capturePaste(view) {
+    let parent = view.dom.parentNode;
+    if (!parent)
+        return;
+    let target = parent.appendChild(document.createElement("textarea"));
+    target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+    target.focus();
+    setTimeout(() => {
+        view.focus();
+        target.remove();
+        doPaste(view, target.value);
+    }, 50);
+}
+function textFilter(state, facet, text) {
+    for (let filter of state.facet(facet))
+        text = filter(text, state);
+    return text;
+}
+function doPaste(view, input) {
+    input = textFilter(view.state, clipboardInputFilter, input);
+    let { state } = view, changes, i = 1, text = state.toText(input);
+    let byLine = text.lines == state.selection.ranges.length;
+    let linewise = lastLinewiseCopy != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy == text.toString();
+    if (linewise) {
+        let lastLine = -1;
+        changes = state.changeByRange(range => {
+            let line = state.doc.lineAt(range.from);
+            if (line.from == lastLine)
+                return { range };
+            lastLine = line.from;
+            let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
+            return { changes: { from: line.from, insert },
+                range: EditorSelection.cursor(range.from + insert.length) };
+        });
+    }
+    else if (byLine) {
+        changes = state.changeByRange(range => {
+            let line = text.line(i++);
+            return { changes: { from: range.from, to: range.to, insert: line.text },
+                range: EditorSelection.cursor(range.from + line.length) };
+        });
+    }
+    else {
+        changes = state.replaceSelection(text);
+    }
+    view.dispatch(changes, {
+        userEvent: "input.paste",
+        scrollIntoView: true
+    });
+}
+observers.scroll = view => {
+    view.inputState.lastScrollTop = view.scrollDOM.scrollTop;
+    view.inputState.lastScrollLeft = view.scrollDOM.scrollLeft;
+};
+handlers.keydown = (view, event) => {
+    view.inputState.setSelectionOrigin("select");
+    if (event.keyCode == 27 && view.inputState.tabFocusMode != 0)
+        view.inputState.tabFocusMode = Date.now() + 2000;
+    return false;
+};
+observers.touchstart = (view, e) => {
+    view.inputState.lastTouchTime = Date.now();
+    view.inputState.setSelectionOrigin("select.pointer");
+};
+observers.touchmove = view => {
+    view.inputState.setSelectionOrigin("select.pointer");
+};
+handlers.mousedown = (view, event) => {
+    view.observer.flush();
+    if (view.inputState.lastTouchTime > Date.now() - 2000)
+        return false; // Ignore touch interaction
+    let style = null;
+    for (let makeStyle of view.state.facet(mouseSelectionStyle)) {
+        style = makeStyle(view, event);
+        if (style)
+            break;
+    }
+    if (!style && event.button == 0)
+        style = basicMouseSelection(view, event);
+    if (style) {
+        let mustFocus = !view.hasFocus;
+        view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));
+        if (mustFocus)
+            view.observer.ignore(() => {
+                focusPreventScroll(view.contentDOM);
+                let active = view.root.activeElement;
+                if (active && !active.contains(view.contentDOM))
+                    active.blur();
+            });
+        let mouseSel = view.inputState.mouseSelection;
+        if (mouseSel) {
+            mouseSel.start(event);
+            return mouseSel.dragging === false;
+        }
+    }
+    return false;
+};
+function rangeForClick(view, pos, bias, type) {
+    if (type == 1) { // Single click
+        return EditorSelection.cursor(pos, bias);
+    }
+    else if (type == 2) { // Double click
+        return groupAt(view.state, pos, bias);
+    }
+    else { // Triple click
+        let visual = LineView.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
+        let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
+        if (to < view.state.doc.length && to == line.to)
+            to++;
+        return EditorSelection.range(from, to);
+    }
+}
+let inside = (x, y, rect) => y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;
+// Try to determine, for the given coordinates, associated with the
+// given position, whether they are related to the element before or
+// the element after the position.
+function findPositionSide(view, pos, x, y) {
+    let line = LineView.find(view.docView, pos);
+    if (!line)
+        return 1;
+    let off = pos - line.posAtStart;
+    // Line boundaries point into the line
+    if (off == 0)
+        return 1;
+    if (off == line.length)
+        return -1;
+    // Positions on top of an element point at that element
+    let before = line.coordsAt(off, -1);
+    if (before && inside(x, y, before))
+        return -1;
+    let after = line.coordsAt(off, 1);
+    if (after && inside(x, y, after))
+        return 1;
+    // This is probably a line wrap point. Pick before if the point is
+    // above its bottom.
+    return before && before.bottom >= y ? -1 : 1;
+}
+function queryPos(view, event) {
+    let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+    return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };
+}
+const BadMouseDetail = browser.ie && browser.ie_version <= 11;
+let lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;
+function getClickType(event) {
+    if (!BadMouseDetail)
+        return event.detail;
+    let last = lastMouseDown, lastTime = lastMouseDownTime;
+    lastMouseDown = event;
+    lastMouseDownTime = Date.now();
+    return lastMouseDownCount = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
+        Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;
+}
+function basicMouseSelection(view, event) {
+    let start = queryPos(view, event), type = getClickType(event);
+    let startSel = view.state.selection;
+    return {
+        update(update) {
+            if (update.docChanged) {
+                start.pos = update.changes.mapPos(start.pos);
+                startSel = startSel.map(update.changes);
+            }
+        },
+        get(event, extend, multiple) {
+            let cur = queryPos(view, event), removed;
+            let range = rangeForClick(view, cur.pos, cur.bias, type);
+            if (start.pos != cur.pos && !extend) {
+                let startRange = rangeForClick(view, start.pos, start.bias, type);
+                let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
+                range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);
+            }
+            if (extend)
+                return startSel.replaceRange(startSel.main.extend(range.from, range.to));
+            else if (multiple && type == 1 && startSel.ranges.length > 1 && (removed = removeRangeAround(startSel, cur.pos)))
+                return removed;
+            else if (multiple)
+                return startSel.addRange(range);
+            else
+                return EditorSelection.create([range]);
+        }
+    };
+}
+function removeRangeAround(sel, pos) {
+    for (let i = 0; i < sel.ranges.length; i++) {
+        let { from, to } = sel.ranges[i];
+        if (from <= pos && to >= pos)
+            return EditorSelection.create(sel.ranges.slice(0, i).concat(sel.ranges.slice(i + 1)), sel.mainIndex == i ? 0 : sel.mainIndex - (sel.mainIndex > i ? 1 : 0));
+    }
+    return null;
+}
+handlers.dragstart = (view, event) => {
+    let { selection: { main: range } } = view.state;
+    if (event.target.draggable) {
+        let cView = view.docView.nearest(event.target);
+        if (cView && cView.isWidget) {
+            let from = cView.posAtStart, to = from + cView.length;
+            if (from >= range.to || to <= range.from)
+                range = EditorSelection.range(from, to);
+        }
+    }
+    let { inputState } = view;
+    if (inputState.mouseSelection)
+        inputState.mouseSelection.dragging = true;
+    inputState.draggedContent = range;
+    if (event.dataTransfer) {
+        event.dataTransfer.setData("Text", textFilter(view.state, clipboardOutputFilter, view.state.sliceDoc(range.from, range.to)));
+        event.dataTransfer.effectAllowed = "copyMove";
+    }
+    return false;
+};
+handlers.dragend = view => {
+    view.inputState.draggedContent = null;
+    return false;
+};
+function dropText(view, event, text, direct) {
+    text = textFilter(view.state, clipboardInputFilter, text);
+    if (!text)
+        return;
+    let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+    let { draggedContent } = view.inputState;
+    let del = direct && draggedContent && dragMovesSelection(view, event)
+        ? { from: draggedContent.from, to: draggedContent.to } : null;
+    let ins = { from: dropPos, insert: text };
+    let changes = view.state.changes(del ? [del, ins] : ins);
+    view.focus();
+    view.dispatch({
+        changes,
+        selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
+        userEvent: del ? "move.drop" : "input.drop"
+    });
+    view.inputState.draggedContent = null;
+}
+handlers.drop = (view, event) => {
+    if (!event.dataTransfer)
+        return false;
+    if (view.state.readOnly)
+        return true;
+    let files = event.dataTransfer.files;
+    if (files && files.length) { // For a file drop, read the file's text.
+        let text = Array(files.length), read = 0;
+        let finishFile = () => {
+            if (++read == files.length)
+                dropText(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
+        };
+        for (let i = 0; i < files.length; i++) {
+            let reader = new FileReader;
+            reader.onerror = finishFile;
+            reader.onload = () => {
+                if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
+                    text[i] = reader.result;
+                finishFile();
+            };
+            reader.readAsText(files[i]);
+        }
+        return true;
+    }
+    else {
+        let text = event.dataTransfer.getData("Text");
+        if (text) {
+            dropText(view, event, text, true);
+            return true;
+        }
+    }
+    return false;
+};
+handlers.paste = (view, event) => {
+    if (view.state.readOnly)
+        return true;
+    view.observer.flush();
+    let data = brokenClipboardAPI ? null : event.clipboardData;
+    if (data) {
+        doPaste(view, data.getData("text/plain") || data.getData("text/uri-list"));
+        return true;
+    }
+    else {
+        capturePaste(view);
+        return false;
+    }
+};
+function captureCopy(view, text) {
+    // The extra wrapper is somehow necessary on IE/Edge to prevent the
+    // content from being mangled when it is put onto the clipboard
+    let parent = view.dom.parentNode;
+    if (!parent)
+        return;
+    let target = parent.appendChild(document.createElement("textarea"));
+    target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+    target.value = text;
+    target.focus();
+    target.selectionEnd = text.length;
+    target.selectionStart = 0;
+    setTimeout(() => {
+        target.remove();
+        view.focus();
+    }, 50);
+}
+function copiedRange(state) {
+    let content = [], ranges = [], linewise = false;
+    for (let range of state.selection.ranges)
+        if (!range.empty) {
+            content.push(state.sliceDoc(range.from, range.to));
+            ranges.push(range);
+        }
+    if (!content.length) {
+        // Nothing selected, do a line-wise copy
+        let upto = -1;
+        for (let { from } of state.selection.ranges) {
+            let line = state.doc.lineAt(from);
+            if (line.number > upto) {
+                content.push(line.text);
+                ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
+            }
+            upto = line.number;
+        }
+        linewise = true;
+    }
+    return { text: textFilter(state, clipboardOutputFilter, content.join(state.lineBreak)), ranges, linewise };
+}
+let lastLinewiseCopy = null;
+handlers.copy = handlers.cut = (view, event) => {
+    let { text, ranges, linewise } = copiedRange(view.state);
+    if (!text && !linewise)
+        return false;
+    lastLinewiseCopy = linewise ? text : null;
+    if (event.type == "cut" && !view.state.readOnly)
+        view.dispatch({
+            changes: ranges,
+            scrollIntoView: true,
+            userEvent: "delete.cut"
+        });
+    let data = brokenClipboardAPI ? null : event.clipboardData;
+    if (data) {
+        data.clearData();
+        data.setData("text/plain", text);
+        return true;
+    }
+    else {
+        captureCopy(view, text);
+        return false;
+    }
+};
+const isFocusChange = /*@__PURE__*/Annotation.define();
+function focusChangeTransaction(state, focus) {
+    let effects = [];
+    for (let getEffect of state.facet(focusChangeEffect)) {
+        let effect = getEffect(state, focus);
+        if (effect)
+            effects.push(effect);
+    }
+    return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
+}
+function updateForFocusChange(view) {
+    setTimeout(() => {
+        let focus = view.hasFocus;
+        if (focus != view.inputState.notifiedFocused) {
+            let tr = focusChangeTransaction(view.state, focus);
+            if (tr)
+                view.dispatch(tr);
+            else
+                view.update([]);
+        }
+    }, 10);
+}
+observers.focus = view => {
+    view.inputState.lastFocusTime = Date.now();
+    // When focusing reset the scroll position, move it back to where it was
+    if (!view.scrollDOM.scrollTop && (view.inputState.lastScrollTop || view.inputState.lastScrollLeft)) {
+        view.scrollDOM.scrollTop = view.inputState.lastScrollTop;
+        view.scrollDOM.scrollLeft = view.inputState.lastScrollLeft;
+    }
+    updateForFocusChange(view);
+};
+observers.blur = view => {
+    view.observer.clearSelectionRange();
+    updateForFocusChange(view);
+};
+observers.compositionstart = observers.compositionupdate = view => {
+    if (view.observer.editContext)
+        return; // Composition handled by edit context
+    if (view.inputState.compositionFirstChange == null)
+        view.inputState.compositionFirstChange = true;
+    if (view.inputState.composing < 0) {
+        // FIXME possibly set a timeout to clear it again on Android
+        view.inputState.composing = 0;
+    }
+};
+observers.compositionend = view => {
+    if (view.observer.editContext)
+        return; // Composition handled by edit context
+    view.inputState.composing = -1;
+    view.inputState.compositionEndedAt = Date.now();
+    view.inputState.compositionPendingKey = true;
+    view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;
+    view.inputState.compositionFirstChange = null;
+    if (browser.chrome && browser.android) {
+        // Delay flushing for a bit on Android because it'll often fire a
+        // bunch of contradictory changes in a row at end of compositon
+        view.observer.flushSoon();
+    }
+    else if (view.inputState.compositionPendingChange) {
+        // If we found pending records, schedule a flush.
+        Promise.resolve().then(() => view.observer.flush());
+    }
+    else {
+        // Otherwise, make sure that, if no changes come in soon, the
+        // composition view is cleared.
+        setTimeout(() => {
+            if (view.inputState.composing < 0 && view.docView.hasComposition)
+                view.update([]);
+        }, 50);
+    }
+};
+observers.contextmenu = view => {
+    view.inputState.lastContextMenu = Date.now();
+};
+handlers.beforeinput = (view, event) => {
+    var _a, _b;
+    // In EditContext mode, we must handle insertReplacementText events
+    // directly, to make spell checking corrections work
+    if (event.inputType == "insertReplacementText" && view.observer.editContext) {
+        let text = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData("text/plain"), ranges = event.getTargetRanges();
+        if (text && ranges.length) {
+            let r = ranges[0];
+            let from = view.posAtDOM(r.startContainer, r.startOffset), to = view.posAtDOM(r.endContainer, r.endOffset);
+            applyDOMChangeInner(view, { from, to, insert: view.state.toText(text) }, null);
+            return true;
+        }
+    }
+    // Because Chrome Android doesn't fire useful key events, use
+    // beforeinput to detect backspace (and possibly enter and delete,
+    // but those usually don't even seem to fire beforeinput events at
+    // the moment) and fake a key event for it.
+    //
+    // (preventDefault on beforeinput, though supported in the spec,
+    // seems to do nothing at all on Chrome).
+    let pending;
+    if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {
+        view.observer.delayAndroidKey(pending.key, pending.keyCode);
+        if (pending.key == "Backspace" || pending.key == "Delete") {
+            let startViewHeight = ((_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.height) || 0;
+            setTimeout(() => {
+                var _a;
+                // Backspacing near uneditable nodes on Chrome Android sometimes
+                // closes the virtual keyboard. This tries to crudely detect
+                // that and refocus to get it back.
+                if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
+                    view.contentDOM.blur();
+                    view.focus();
+                }
+            }, 100);
+        }
+    }
+    if (browser.ios && event.inputType == "deleteContentForward") {
+        // For some reason, DOM changes (and beforeinput) happen _before_
+        // the key event for ctrl-d on iOS when using an external
+        // keyboard.
+        view.observer.flushSoon();
+    }
+    // Safari will occasionally forget to fire compositionend at the end of a dead-key composition
+    if (browser.safari && event.inputType == "insertText" && view.inputState.composing >= 0) {
+        setTimeout(() => observers.compositionend(view, event), 20);
+    }
+    return false;
+};
+const appliedFirefoxHack = /*@__PURE__*/new Set;
+// In Firefox, when cut/copy handlers are added to the document, that
+// somehow avoids a bug where those events aren't fired when the
+// selection is empty. See https://github.com/codemirror/dev/issues/1082
+// and https://bugzilla.mozilla.org/show_bug.cgi?id=995961
+function firefoxCopyCutHack(doc) {
+    if (!appliedFirefoxHack.has(doc)) {
+        appliedFirefoxHack.add(doc);
+        doc.addEventListener("copy", () => { });
+        doc.addEventListener("cut", () => { });
+    }
+}
+
+const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line", "break-spaces"];
+// Used to track, during updateHeight, if any actual heights changed
+let heightChangeFlag = false;
+function clearHeightChangeFlag() { heightChangeFlag = false; }
+class HeightOracle {
+    constructor(lineWrapping) {
+        this.lineWrapping = lineWrapping;
+        this.doc = Text.empty;
+        this.heightSamples = {};
+        this.lineHeight = 14; // The height of an entire line (line-height)
+        this.charWidth = 7;
+        this.textHeight = 14; // The height of the actual font (font-size)
+        this.lineLength = 30;
+    }
+    heightForGap(from, to) {
+        let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
+        if (this.lineWrapping)
+            lines += Math.max(0, Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength));
+        return this.lineHeight * lines;
+    }
+    heightForLine(length) {
+        if (!this.lineWrapping)
+            return this.lineHeight;
+        let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
+        return lines * this.lineHeight;
+    }
+    setDoc(doc) { this.doc = doc; return this; }
+    mustRefreshForWrapping(whiteSpace) {
+        return (wrappingWhiteSpace.indexOf(whiteSpace) > -1) != this.lineWrapping;
+    }
+    mustRefreshForHeights(lineHeights) {
+        let newHeight = false;
+        for (let i = 0; i < lineHeights.length; i++) {
+            let h = lineHeights[i];
+            if (h < 0) {
+                i++;
+            }
+            else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
+                newHeight = true;
+                this.heightSamples[Math.floor(h * 10)] = true;
+            }
+        }
+        return newHeight;
+    }
+    refresh(whiteSpace, lineHeight, charWidth, textHeight, lineLength, knownHeights) {
+        let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;
+        let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
+        this.lineWrapping = lineWrapping;
+        this.lineHeight = lineHeight;
+        this.charWidth = charWidth;
+        this.textHeight = textHeight;
+        this.lineLength = lineLength;
+        if (changed) {
+            this.heightSamples = {};
+            for (let i = 0; i < knownHeights.length; i++) {
+                let h = knownHeights[i];
+                if (h < 0)
+                    i++;
+                else
+                    this.heightSamples[Math.floor(h * 10)] = true;
+            }
+        }
+        return changed;
+    }
+}
+// This object is used by `updateHeight` to make DOM measurements
+// arrive at the right nides. The `heights` array is a sequence of
+// block heights, starting from position `from`.
+class MeasuredHeights {
+    constructor(from, heights) {
+        this.from = from;
+        this.heights = heights;
+        this.index = 0;
+    }
+    get more() { return this.index < this.heights.length; }
+}
+/**
+Record used to represent information about a block-level element
+in the editor view.
+*/
+class BlockInfo {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    The start of the element in the document.
+    */
+    from, 
+    /**
+    The length of the element.
+    */
+    length, 
+    /**
+    The top position of the element (relative to the top of the
+    document).
+    */
+    top, 
+    /**
+    Its height.
+    */
+    height, 
+    /**
+    @internal Weird packed field that holds an array of children
+    for composite blocks, a decoration for block widgets, and a
+    number indicating the amount of widget-create line breaks for
+    text blocks.
+    */
+    _content) {
+        this.from = from;
+        this.length = length;
+        this.top = top;
+        this.height = height;
+        this._content = _content;
+    }
+    /**
+    The type of element this is. When querying lines, this may be
+    an array of all the blocks that make up the line.
+    */
+    get type() {
+        return typeof this._content == "number" ? BlockType.Text :
+            Array.isArray(this._content) ? this._content : this._content.type;
+    }
+    /**
+    The end of the element as a document position.
+    */
+    get to() { return this.from + this.length; }
+    /**
+    The bottom position of the element.
+    */
+    get bottom() { return this.top + this.height; }
+    /**
+    If this is a widget block, this will return the widget
+    associated with it.
+    */
+    get widget() {
+        return this._content instanceof PointDecoration ? this._content.widget : null;
+    }
+    /**
+    If this is a textblock, this holds the number of line breaks
+    that appear in widgets inside the block.
+    */
+    get widgetLineBreaks() {
+        return typeof this._content == "number" ? this._content : 0;
+    }
+    /**
+    @internal
+    */
+    join(other) {
+        let content = (Array.isArray(this._content) ? this._content : [this])
+            .concat(Array.isArray(other._content) ? other._content : [other]);
+        return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);
+    }
+}
+var QueryType$1 = /*@__PURE__*/(function (QueryType) {
+    QueryType[QueryType["ByPos"] = 0] = "ByPos";
+    QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
+    QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
+return QueryType})(QueryType$1 || (QueryType$1 = {}));
+const Epsilon = 1e-3;
+class HeightMap {
+    constructor(length, // The number of characters covered
+    height, // Height of this part of the document
+    flags = 2 /* Flag.Outdated */) {
+        this.length = length;
+        this.height = height;
+        this.flags = flags;
+    }
+    get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
+    set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
+    setHeight(height) {
+        if (this.height != height) {
+            if (Math.abs(this.height - height) > Epsilon)
+                heightChangeFlag = true;
+            this.height = height;
+        }
+    }
+    // Base case is to replace a leaf node, which simply builds a tree
+    // from the new nodes and returns that (HeightMapBranch and
+    // HeightMapGap override this to actually use from/to)
+    replace(_from, _to, nodes) {
+        return HeightMap.of(nodes);
+    }
+    // Again, these are base cases, and are overridden for branch and gap nodes.
+    decomposeLeft(_to, result) { result.push(this); }
+    decomposeRight(_from, result) { result.push(this); }
+    applyChanges(decorations, oldDoc, oracle, changes) {
+        let me = this, doc = oracle.doc;
+        for (let i = changes.length - 1; i >= 0; i--) {
+            let { fromA, toA, fromB, toB } = changes[i];
+            let start = me.lineAt(fromA, QueryType$1.ByPosNoHeight, oracle.setDoc(oldDoc), 0, 0);
+            let end = start.to >= toA ? start : me.lineAt(toA, QueryType$1.ByPosNoHeight, oracle, 0, 0);
+            toB += end.to - toA;
+            toA = end.to;
+            while (i > 0 && start.from <= changes[i - 1].toA) {
+                fromA = changes[i - 1].fromA;
+                fromB = changes[i - 1].fromB;
+                i--;
+                if (fromA < start.from)
+                    start = me.lineAt(fromA, QueryType$1.ByPosNoHeight, oracle, 0, 0);
+            }
+            fromB += start.from - fromA;
+            fromA = start.from;
+            let nodes = NodeBuilder.build(oracle.setDoc(doc), decorations, fromB, toB);
+            me = replace(me, me.replace(fromA, toA, nodes));
+        }
+        return me.updateHeight(oracle, 0);
+    }
+    static empty() { return new HeightMapText(0, 0); }
+    // nodes uses null values to indicate the position of line breaks.
+    // There are never line breaks at the start or end of the array, or
+    // two line breaks next to each other, and the array isn't allowed
+    // to be empty (same restrictions as return value from the builder).
+    static of(nodes) {
+        if (nodes.length == 1)
+            return nodes[0];
+        let i = 0, j = nodes.length, before = 0, after = 0;
+        for (;;) {
+            if (i == j) {
+                if (before > after * 2) {
+                    let split = nodes[i - 1];
+                    if (split.break)
+                        nodes.splice(--i, 1, split.left, null, split.right);
+                    else
+                        nodes.splice(--i, 1, split.left, split.right);
+                    j += 1 + split.break;
+                    before -= split.size;
+                }
+                else if (after > before * 2) {
+                    let split = nodes[j];
+                    if (split.break)
+                        nodes.splice(j, 1, split.left, null, split.right);
+                    else
+                        nodes.splice(j, 1, split.left, split.right);
+                    j += 2 + split.break;
+                    after -= split.size;
+                }
+                else {
+                    break;
+                }
+            }
+            else if (before < after) {
+                let next = nodes[i++];
+                if (next)
+                    before += next.size;
+            }
+            else {
+                let next = nodes[--j];
+                if (next)
+                    after += next.size;
+            }
+        }
+        let brk = 0;
+        if (nodes[i - 1] == null) {
+            brk = 1;
+            i--;
+        }
+        else if (nodes[i] == null) {
+            brk = 1;
+            j++;
+        }
+        return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
+    }
+}
+function replace(old, val) {
+    if (old == val)
+        return old;
+    if (old.constructor != val.constructor)
+        heightChangeFlag = true;
+    return val;
+}
+HeightMap.prototype.size = 1;
+class HeightMapBlock extends HeightMap {
+    constructor(length, height, deco) {
+        super(length, height);
+        this.deco = deco;
+    }
+    blockAt(_height, _oracle, top, offset) {
+        return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);
+    }
+    lineAt(_value, _type, oracle, top, offset) {
+        return this.blockAt(0, oracle, top, offset);
+    }
+    forEachLine(from, to, oracle, top, offset, f) {
+        if (from <= offset + this.length && to >= offset)
+            f(this.blockAt(0, oracle, top, offset));
+    }
+    updateHeight(oracle, offset = 0, _force = false, measured) {
+        if (measured && measured.from <= offset && measured.more)
+            this.setHeight(measured.heights[measured.index++]);
+        this.outdated = false;
+        return this;
+    }
+    toString() { return `block(${this.length})`; }
+}
+class HeightMapText extends HeightMapBlock {
+    constructor(length, height) {
+        super(length, height, null);
+        this.collapsed = 0; // Amount of collapsed content in the line
+        this.widgetHeight = 0; // Maximum inline widget height
+        this.breaks = 0; // Number of widget-introduced line breaks on the line
+    }
+    blockAt(_height, _oracle, top, offset) {
+        return new BlockInfo(offset, this.length, top, this.height, this.breaks);
+    }
+    replace(_from, _to, nodes) {
+        let node = nodes[0];
+        if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
+            Math.abs(this.length - node.length) < 10) {
+            if (node instanceof HeightMapGap)
+                node = new HeightMapText(node.length, this.height);
+            else
+                node.height = this.height;
+            if (!this.outdated)
+                node.outdated = false;
+            return node;
+        }
+        else {
+            return HeightMap.of(nodes);
+        }
+    }
+    updateHeight(oracle, offset = 0, force = false, measured) {
+        if (measured && measured.from <= offset && measured.more)
+            this.setHeight(measured.heights[measured.index++]);
+        else if (force || this.outdated)
+            this.setHeight(Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +
+                this.breaks * oracle.lineHeight);
+        this.outdated = false;
+        return this;
+    }
+    toString() {
+        return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
+    }
+}
+class HeightMapGap extends HeightMap {
+    constructor(length) { super(length, 0); }
+    heightMetrics(oracle, offset) {
+        let firstLine = oracle.doc.lineAt(offset).number, lastLine = oracle.doc.lineAt(offset + this.length).number;
+        let lines = lastLine - firstLine + 1;
+        let perLine, perChar = 0;
+        if (oracle.lineWrapping) {
+            let totalPerLine = Math.min(this.height, oracle.lineHeight * lines);
+            perLine = totalPerLine / lines;
+            if (this.length > lines + 1)
+                perChar = (this.height - totalPerLine) / (this.length - lines - 1);
+        }
+        else {
+            perLine = this.height / lines;
+        }
+        return { firstLine, lastLine, perLine, perChar };
+    }
+    blockAt(height, oracle, top, offset) {
+        let { firstLine, lastLine, perLine, perChar } = this.heightMetrics(oracle, offset);
+        if (oracle.lineWrapping) {
+            let guess = offset + (height < oracle.lineHeight ? 0
+                : Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length));
+            let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;
+            let lineTop = Math.max(top, height - lineHeight / 2);
+            return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);
+        }
+        else {
+            let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
+            let { from, length } = oracle.doc.line(firstLine + line);
+            return new BlockInfo(from, length, top + perLine * line, perLine, 0);
+        }
+    }
+    lineAt(value, type, oracle, top, offset) {
+        if (type == QueryType$1.ByHeight)
+            return this.blockAt(value, oracle, top, offset);
+        if (type == QueryType$1.ByPosNoHeight) {
+            let { from, to } = oracle.doc.lineAt(value);
+            return new BlockInfo(from, to - from, 0, 0, 0);
+        }
+        let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
+        let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;
+        let linesAbove = line.number - firstLine;
+        let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
+        return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);
+    }
+    forEachLine(from, to, oracle, top, offset, f) {
+        from = Math.max(from, offset);
+        to = Math.min(to, offset + this.length);
+        let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
+        for (let pos = from, lineTop = top; pos <= to;) {
+            let line = oracle.doc.lineAt(pos);
+            if (pos == from) {
+                let linesAbove = line.number - firstLine;
+                lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
+            }
+            let lineHeight = perLine + perChar * line.length;
+            f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));
+            lineTop += lineHeight;
+            pos = line.to + 1;
+        }
+    }
+    replace(from, to, nodes) {
+        let after = this.length - to;
+        if (after > 0) {
+            let last = nodes[nodes.length - 1];
+            if (last instanceof HeightMapGap)
+                nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
+            else
+                nodes.push(null, new HeightMapGap(after - 1));
+        }
+        if (from > 0) {
+            let first = nodes[0];
+            if (first instanceof HeightMapGap)
+                nodes[0] = new HeightMapGap(from + first.length);
+            else
+                nodes.unshift(new HeightMapGap(from - 1), null);
+        }
+        return HeightMap.of(nodes);
+    }
+    decomposeLeft(to, result) {
+        result.push(new HeightMapGap(to - 1), null);
+    }
+    decomposeRight(from, result) {
+        result.push(null, new HeightMapGap(this.length - from - 1));
+    }
+    updateHeight(oracle, offset = 0, force = false, measured) {
+        let end = offset + this.length;
+        if (measured && measured.from <= offset + this.length && measured.more) {
+            // Fill in part of this gap with measured lines. We know there
+            // can't be widgets or collapsed ranges in those lines, because
+            // they would already have been added to the heightmap (gaps
+            // only contain plain text).
+            let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
+            if (measured.from > offset)
+                nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
+            while (pos <= end && measured.more) {
+                let len = oracle.doc.lineAt(pos).length;
+                if (nodes.length)
+                    nodes.push(null);
+                let height = measured.heights[measured.index++];
+                if (singleHeight == -1)
+                    singleHeight = height;
+                else if (Math.abs(height - singleHeight) >= Epsilon)
+                    singleHeight = -2;
+                let line = new HeightMapText(len, height);
+                line.outdated = false;
+                nodes.push(line);
+                pos += len + 1;
+            }
+            if (pos <= end)
+                nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
+            let result = HeightMap.of(nodes);
+            if (singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon ||
+                Math.abs(singleHeight - this.heightMetrics(oracle, offset).perLine) >= Epsilon)
+                heightChangeFlag = true;
+            return replace(this, result);
+        }
+        else if (force || this.outdated) {
+            this.setHeight(oracle.heightForGap(offset, offset + this.length));
+            this.outdated = false;
+        }
+        return this;
+    }
+    toString() { return `gap(${this.length})`; }
+}
+class HeightMapBranch extends HeightMap {
+    constructor(left, brk, right) {
+        super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
+        this.left = left;
+        this.right = right;
+        this.size = left.size + right.size;
+    }
+    get break() { return this.flags & 1 /* Flag.Break */; }
+    blockAt(height, oracle, top, offset) {
+        let mid = top + this.left.height;
+        return height < mid ? this.left.blockAt(height, oracle, top, offset)
+            : this.right.blockAt(height, oracle, mid, offset + this.left.length + this.break);
+    }
+    lineAt(value, type, oracle, top, offset) {
+        let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+        let left = type == QueryType$1.ByHeight ? value < rightTop : value < rightOffset;
+        let base = left ? this.left.lineAt(value, type, oracle, top, offset)
+            : this.right.lineAt(value, type, oracle, rightTop, rightOffset);
+        if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
+            return base;
+        let subQuery = type == QueryType$1.ByPosNoHeight ? QueryType$1.ByPosNoHeight : QueryType$1.ByPos;
+        if (left)
+            return base.join(this.right.lineAt(rightOffset, subQuery, oracle, rightTop, rightOffset));
+        else
+            return this.left.lineAt(rightOffset, subQuery, oracle, top, offset).join(base);
+    }
+    forEachLine(from, to, oracle, top, offset, f) {
+        let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+        if (this.break) {
+            if (from < rightOffset)
+                this.left.forEachLine(from, to, oracle, top, offset, f);
+            if (to >= rightOffset)
+                this.right.forEachLine(from, to, oracle, rightTop, rightOffset, f);
+        }
+        else {
+            let mid = this.lineAt(rightOffset, QueryType$1.ByPos, oracle, top, offset);
+            if (from < mid.from)
+                this.left.forEachLine(from, mid.from - 1, oracle, top, offset, f);
+            if (mid.to >= from && mid.from <= to)
+                f(mid);
+            if (to > mid.to)
+                this.right.forEachLine(mid.to + 1, to, oracle, rightTop, rightOffset, f);
+        }
+    }
+    replace(from, to, nodes) {
+        let rightStart = this.left.length + this.break;
+        if (to < rightStart)
+            return this.balanced(this.left.replace(from, to, nodes), this.right);
+        if (from > this.left.length)
+            return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
+        let result = [];
+        if (from > 0)
+            this.decomposeLeft(from, result);
+        let left = result.length;
+        for (let node of nodes)
+            result.push(node);
+        if (from > 0)
+            mergeGaps(result, left - 1);
+        if (to < this.length) {
+            let right = result.length;
+            this.decomposeRight(to, result);
+            mergeGaps(result, right);
+        }
+        return HeightMap.of(result);
+    }
+    decomposeLeft(to, result) {
+        let left = this.left.length;
+        if (to <= left)
+            return this.left.decomposeLeft(to, result);
+        result.push(this.left);
+        if (this.break) {
+            left++;
+            if (to >= left)
+                result.push(null);
+        }
+        if (to > left)
+            this.right.decomposeLeft(to - left, result);
+    }
+    decomposeRight(from, result) {
+        let left = this.left.length, right = left + this.break;
+        if (from >= right)
+            return this.right.decomposeRight(from - right, result);
+        if (from < left)
+            this.left.decomposeRight(from, result);
+        if (this.break && from < right)
+            result.push(null);
+        result.push(this.right);
+    }
+    balanced(left, right) {
+        if (left.size > 2 * right.size || right.size > 2 * left.size)
+            return HeightMap.of(this.break ? [left, null, right] : [left, right]);
+        this.left = replace(this.left, left);
+        this.right = replace(this.right, right);
+        this.setHeight(left.height + right.height);
+        this.outdated = left.outdated || right.outdated;
+        this.size = left.size + right.size;
+        this.length = left.length + this.break + right.length;
+        return this;
+    }
+    updateHeight(oracle, offset = 0, force = false, measured) {
+        let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
+        if (measured && measured.from <= offset + left.length && measured.more)
+            rebalance = left = left.updateHeight(oracle, offset, force, measured);
+        else
+            left.updateHeight(oracle, offset, force);
+        if (measured && measured.from <= rightStart + right.length && measured.more)
+            rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
+        else
+            right.updateHeight(oracle, rightStart, force);
+        if (rebalance)
+            return this.balanced(left, right);
+        this.height = this.left.height + this.right.height;
+        this.outdated = false;
+        return this;
+    }
+    toString() { return this.left + (this.break ? " " : "-") + this.right; }
+}
+function mergeGaps(nodes, around) {
+    let before, after;
+    if (nodes[around] == null &&
+        (before = nodes[around - 1]) instanceof HeightMapGap &&
+        (after = nodes[around + 1]) instanceof HeightMapGap)
+        nodes.splice(around - 1, 3, new HeightMapGap(before.length + 1 + after.length));
+}
+const relevantWidgetHeight = 5;
+class NodeBuilder {
+    constructor(pos, oracle) {
+        this.pos = pos;
+        this.oracle = oracle;
+        this.nodes = [];
+        this.lineStart = -1;
+        this.lineEnd = -1;
+        this.covering = null;
+        this.writtenTo = pos;
+    }
+    get isCovered() {
+        return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
+    }
+    span(_from, to) {
+        if (this.lineStart > -1) {
+            let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
+            if (last instanceof HeightMapText)
+                last.length += end - this.pos;
+            else if (end > this.pos || !this.isCovered)
+                this.nodes.push(new HeightMapText(end - this.pos, -1));
+            this.writtenTo = end;
+            if (to > end) {
+                this.nodes.push(null);
+                this.writtenTo++;
+                this.lineStart = -1;
+            }
+        }
+        this.pos = to;
+    }
+    point(from, to, deco) {
+        if (from < to || deco.heightRelevant) {
+            let height = deco.widget ? deco.widget.estimatedHeight : 0;
+            let breaks = deco.widget ? deco.widget.lineBreaks : 0;
+            if (height < 0)
+                height = this.oracle.lineHeight;
+            let len = to - from;
+            if (deco.block) {
+                this.addBlock(new HeightMapBlock(len, height, deco));
+            }
+            else if (len || breaks || height >= relevantWidgetHeight) {
+                this.addLineDeco(height, breaks, len);
+            }
+        }
+        else if (to > from) {
+            this.span(from, to);
+        }
+        if (this.lineEnd > -1 && this.lineEnd < this.pos)
+            this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
+    }
+    enterLine() {
+        if (this.lineStart > -1)
+            return;
+        let { from, to } = this.oracle.doc.lineAt(this.pos);
+        this.lineStart = from;
+        this.lineEnd = to;
+        if (this.writtenTo < from) {
+            if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
+                this.nodes.push(this.blankContent(this.writtenTo, from - 1));
+            this.nodes.push(null);
+        }
+        if (this.pos > from)
+            this.nodes.push(new HeightMapText(this.pos - from, -1));
+        this.writtenTo = this.pos;
+    }
+    blankContent(from, to) {
+        let gap = new HeightMapGap(to - from);
+        if (this.oracle.doc.lineAt(from).to == to)
+            gap.flags |= 4 /* Flag.SingleLine */;
+        return gap;
+    }
+    ensureLine() {
+        this.enterLine();
+        let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
+        if (last instanceof HeightMapText)
+            return last;
+        let line = new HeightMapText(0, -1);
+        this.nodes.push(line);
+        return line;
+    }
+    addBlock(block) {
+        this.enterLine();
+        let deco = block.deco;
+        if (deco && deco.startSide > 0 && !this.isCovered)
+            this.ensureLine();
+        this.nodes.push(block);
+        this.writtenTo = this.pos = this.pos + block.length;
+        if (deco && deco.endSide > 0)
+            this.covering = block;
+    }
+    addLineDeco(height, breaks, length) {
+        let line = this.ensureLine();
+        line.length += length;
+        line.collapsed += length;
+        line.widgetHeight = Math.max(line.widgetHeight, height);
+        line.breaks += breaks;
+        this.writtenTo = this.pos = this.pos + length;
+    }
+    finish(from) {
+        let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
+        if (this.lineStart > -1 && !(last instanceof HeightMapText) && !this.isCovered)
+            this.nodes.push(new HeightMapText(0, -1));
+        else if (this.writtenTo < this.pos || last == null)
+            this.nodes.push(this.blankContent(this.writtenTo, this.pos));
+        let pos = from;
+        for (let node of this.nodes) {
+            if (node instanceof HeightMapText)
+                node.updateHeight(this.oracle, pos);
+            pos += node ? node.length : 1;
+        }
+        return this.nodes;
+    }
+    // Always called with a region that on both sides either stretches
+    // to a line break or the end of the document.
+    // The returned array uses null to indicate line breaks, but never
+    // starts or ends in a line break, or has multiple line breaks next
+    // to each other.
+    static build(oracle, decorations, from, to) {
+        let builder = new NodeBuilder(from, oracle);
+        RangeSet.spans(decorations, from, to, builder, 0);
+        return builder.finish(from);
+    }
+}
+function heightRelevantDecoChanges(a, b, diff) {
+    let comp = new DecorationComparator;
+    RangeSet.compare(a, b, diff, comp, 0);
+    return comp.changes;
+}
+class DecorationComparator {
+    constructor() {
+        this.changes = [];
+    }
+    compareRange() { }
+    comparePoint(from, to, a, b) {
+        if (from < to || a && a.heightRelevant || b && b.heightRelevant)
+            addRange(from, to, this.changes, 5);
+    }
+}
+
+function visiblePixelRange(dom, paddingTop) {
+    let rect = dom.getBoundingClientRect();
+    let doc = dom.ownerDocument, win = doc.defaultView || window;
+    let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);
+    let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);
+    for (let parent = dom.parentNode; parent && parent != doc.body;) {
+        if (parent.nodeType == 1) {
+            let elt = parent;
+            let style = window.getComputedStyle(elt);
+            if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
+                style.overflow != "visible") {
+                let parentRect = elt.getBoundingClientRect();
+                left = Math.max(left, parentRect.left);
+                right = Math.min(right, parentRect.right);
+                top = Math.max(top, parentRect.top);
+                bottom = Math.min(parent == dom.parentNode ? win.innerHeight : bottom, parentRect.bottom);
+            }
+            parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
+        }
+        else if (parent.nodeType == 11) { // Shadow root
+            parent = parent.host;
+        }
+        else {
+            break;
+        }
+    }
+    return { left: left - rect.left, right: Math.max(left, right) - rect.left,
+        top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
+}
+function fullPixelRange(dom, paddingTop) {
+    let rect = dom.getBoundingClientRect();
+    return { left: 0, right: rect.right - rect.left,
+        top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
+}
+// Line gaps are placeholder widgets used to hide pieces of overlong
+// lines within the viewport, as a kludge to keep the editor
+// responsive when a ridiculously long line is loaded into it.
+class LineGap {
+    constructor(from, to, size, displaySize) {
+        this.from = from;
+        this.to = to;
+        this.size = size;
+        this.displaySize = displaySize;
+    }
+    static same(a, b) {
+        if (a.length != b.length)
+            return false;
+        for (let i = 0; i < a.length; i++) {
+            let gA = a[i], gB = b[i];
+            if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
+                return false;
+        }
+        return true;
+    }
+    draw(viewState, wrapping) {
+        return Decoration.replace({
+            widget: new LineGapWidget(this.displaySize * (wrapping ? viewState.scaleY : viewState.scaleX), wrapping)
+        }).range(this.from, this.to);
+    }
+}
+class LineGapWidget extends WidgetType {
+    constructor(size, vertical) {
+        super();
+        this.size = size;
+        this.vertical = vertical;
+    }
+    eq(other) { return other.size == this.size && other.vertical == this.vertical; }
+    toDOM() {
+        let elt = document.createElement("div");
+        if (this.vertical) {
+            elt.style.height = this.size + "px";
+        }
+        else {
+            elt.style.width = this.size + "px";
+            elt.style.height = "2px";
+            elt.style.display = "inline-block";
+        }
+        return elt;
+    }
+    get estimatedHeight() { return this.vertical ? this.size : -1; }
+}
+class ViewState {
+    constructor(state) {
+        this.state = state;
+        // These are contentDOM-local coordinates
+        this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
+        this.inView = true;
+        this.paddingTop = 0; // Padding above the document, scaled
+        this.paddingBottom = 0; // Padding below the document, scaled
+        this.contentDOMWidth = 0; // contentDOM.getBoundingClientRect().width
+        this.contentDOMHeight = 0; // contentDOM.getBoundingClientRect().height
+        this.editorHeight = 0; // scrollDOM.clientHeight, unscaled
+        this.editorWidth = 0; // scrollDOM.clientWidth, unscaled
+        this.scrollTop = 0; // Last seen scrollDOM.scrollTop, scaled
+        this.scrolledToBottom = false;
+        // The CSS-transformation scale of the editor (transformed size /
+        // concrete size)
+        this.scaleX = 1;
+        this.scaleY = 1;
+        // The vertical position (document-relative) to which to anchor the
+        // scroll position. -1 means anchor to the end of the document.
+        this.scrollAnchorPos = 0;
+        // The height at the anchor position. Set by the DOM update phase.
+        // -1 means no height available.
+        this.scrollAnchorHeight = -1;
+        // See VP.MaxDOMHeight
+        this.scaler = IdScaler;
+        this.scrollTarget = null;
+        // Briefly set to true when printing, to disable viewport limiting
+        this.printing = false;
+        // Flag set when editor content was redrawn, so that the next
+        // measure stage knows it must read DOM layout
+        this.mustMeasureContent = true;
+        this.defaultTextDirection = Direction.LTR;
+        this.visibleRanges = [];
+        // Cursor 'assoc' is only significant when the cursor is on a line
+        // wrap point, where it must stick to the character that it is
+        // associated with. Since browsers don't provide a reasonable
+        // interface to set or query this, when a selection is set that
+        // might cause this to be significant, this flag is set. The next
+        // measure phase will check whether the cursor is on a line-wrapping
+        // boundary and, if so, reset it to make sure it is positioned in
+        // the right place.
+        this.mustEnforceCursorAssoc = false;
+        let guessWrapping = state.facet(contentAttributes).some(v => typeof v != "function" && v.class == "cm-lineWrapping");
+        this.heightOracle = new HeightOracle(guessWrapping);
+        this.stateDeco = state.facet(decorations).filter(d => typeof d != "function");
+        this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
+        for (let i = 0; i < 2; i++) {
+            this.viewport = this.getViewport(0, null);
+            if (!this.updateForViewport())
+                break;
+        }
+        this.updateViewportLines();
+        this.lineGaps = this.ensureLineGaps([]);
+        this.lineGapDeco = Decoration.set(this.lineGaps.map(gap => gap.draw(this, false)));
+        this.computeVisibleRanges();
+    }
+    updateForViewport() {
+        let viewports = [this.viewport], { main } = this.state.selection;
+        for (let i = 0; i <= 1; i++) {
+            let pos = i ? main.head : main.anchor;
+            if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
+                let { from, to } = this.lineBlockAt(pos);
+                viewports.push(new Viewport(from, to));
+            }
+        }
+        this.viewports = viewports.sort((a, b) => a.from - b.from);
+        return this.updateScaler();
+    }
+    updateScaler() {
+        let scaler = this.scaler;
+        this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
+            new BigScaler(this.heightOracle, this.heightMap, this.viewports);
+        return scaler.eq(this.scaler) ? 0 : 2 /* UpdateFlag.Height */;
+    }
+    updateViewportLines() {
+        this.viewportLines = [];
+        this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, block => {
+            this.viewportLines.push(scaleBlock(block, this.scaler));
+        });
+    }
+    update(update, scrollTarget = null) {
+        this.state = update.state;
+        let prevDeco = this.stateDeco;
+        this.stateDeco = this.state.facet(decorations).filter(d => typeof d != "function");
+        let contentChanges = update.changedRanges;
+        let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));
+        let prevHeight = this.heightMap.height;
+        let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);
+        clearHeightChangeFlag();
+        this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
+        if (this.heightMap.height != prevHeight || heightChangeFlag)
+            update.flags |= 2 /* UpdateFlag.Height */;
+        if (scrollAnchor) {
+            this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);
+            this.scrollAnchorHeight = scrollAnchor.top;
+        }
+        else {
+            this.scrollAnchorPos = -1;
+            this.scrollAnchorHeight = this.heightMap.height;
+        }
+        let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
+        if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
+            !this.viewportIsAppropriate(viewport))
+            viewport = this.getViewport(0, scrollTarget);
+        let viewportChange = viewport.from != this.viewport.from || viewport.to != this.viewport.to;
+        this.viewport = viewport;
+        update.flags |= this.updateForViewport();
+        if (viewportChange || !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */))
+            this.updateViewportLines();
+        if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))
+            this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
+        update.flags |= this.computeVisibleRanges(update.changes);
+        if (scrollTarget)
+            this.scrollTarget = scrollTarget;
+        if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
+            update.state.selection.main.empty && update.state.selection.main.assoc &&
+            !update.state.facet(nativeSelectionHidden))
+            this.mustEnforceCursorAssoc = true;
+    }
+    measure(view) {
+        let dom = view.contentDOM, style = window.getComputedStyle(dom);
+        let oracle = this.heightOracle;
+        let whiteSpace = style.whiteSpace;
+        this.defaultTextDirection = style.direction == "rtl" ? Direction.RTL : Direction.LTR;
+        let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
+        let domRect = dom.getBoundingClientRect();
+        let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != domRect.height;
+        this.contentDOMHeight = domRect.height;
+        this.mustMeasureContent = false;
+        let result = 0, bias = 0;
+        if (domRect.width && domRect.height) {
+            let { scaleX, scaleY } = getScale(dom, domRect);
+            if (scaleX > .005 && Math.abs(this.scaleX - scaleX) > .005 ||
+                scaleY > .005 && Math.abs(this.scaleY - scaleY) > .005) {
+                this.scaleX = scaleX;
+                this.scaleY = scaleY;
+                result |= 16 /* UpdateFlag.Geometry */;
+                refresh = measureContent = true;
+            }
+        }
+        // Vertical padding
+        let paddingTop = (parseInt(style.paddingTop) || 0) * this.scaleY;
+        let paddingBottom = (parseInt(style.paddingBottom) || 0) * this.scaleY;
+        if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
+            this.paddingTop = paddingTop;
+            this.paddingBottom = paddingBottom;
+            result |= 16 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
+        }
+        if (this.editorWidth != view.scrollDOM.clientWidth) {
+            if (oracle.lineWrapping)
+                measureContent = true;
+            this.editorWidth = view.scrollDOM.clientWidth;
+            result |= 16 /* UpdateFlag.Geometry */;
+        }
+        let scrollTop = view.scrollDOM.scrollTop * this.scaleY;
+        if (this.scrollTop != scrollTop) {
+            this.scrollAnchorHeight = -1;
+            this.scrollTop = scrollTop;
+        }
+        this.scrolledToBottom = isScrolledToBottom(view.scrollDOM);
+        // Pixel viewport
+        let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
+        let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
+        this.pixelViewport = pixelViewport;
+        let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
+        if (inView != this.inView) {
+            this.inView = inView;
+            if (inView)
+                measureContent = true;
+        }
+        if (!this.inView && !this.scrollTarget)
+            return 0;
+        let contentWidth = domRect.width;
+        if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
+            this.contentDOMWidth = domRect.width;
+            this.editorHeight = view.scrollDOM.clientHeight;
+            result |= 16 /* UpdateFlag.Geometry */;
+        }
+        if (measureContent) {
+            let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
+            if (oracle.mustRefreshForHeights(lineHeights))
+                refresh = true;
+            if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
+                let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();
+                refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);
+                if (refresh) {
+                    view.docView.minWidth = 0;
+                    result |= 16 /* UpdateFlag.Geometry */;
+                }
+            }
+            if (dTop > 0 && dBottom > 0)
+                bias = Math.max(dTop, dBottom);
+            else if (dTop < 0 && dBottom < 0)
+                bias = Math.min(dTop, dBottom);
+            clearHeightChangeFlag();
+            for (let vp of this.viewports) {
+                let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
+                this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
+            }
+            if (heightChangeFlag)
+                result |= 2 /* UpdateFlag.Height */;
+        }
+        let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
+            this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||
+                this.scrollTarget.range.head > this.viewport.to);
+        if (viewportChange) {
+            if (result & 2 /* UpdateFlag.Height */)
+                result |= this.updateScaler();
+            this.viewport = this.getViewport(bias, this.scrollTarget);
+            result |= this.updateForViewport();
+        }
+        if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
+            this.updateViewportLines();
+        if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))
+            this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));
+        result |= this.computeVisibleRanges();
+        if (this.mustEnforceCursorAssoc) {
+            this.mustEnforceCursorAssoc = false;
+            // This is done in the read stage, because moving the selection
+            // to a line end is going to trigger a layout anyway, so it
+            // can't be a pure write. It should be rare that it does any
+            // writing.
+            view.docView.enforceCursorAssoc();
+        }
+        return result;
+    }
+    get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
+    get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
+    getViewport(bias, scrollTarget) {
+        // This will divide VP.Margin between the top and the
+        // bottom, depending on the bias (the change in viewport position
+        // since the last update). It'll hold a number between 0 and 1
+        let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
+        let map = this.heightMap, oracle = this.heightOracle;
+        let { visibleTop, visibleBottom } = this;
+        let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType$1.ByHeight, oracle, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType$1.ByHeight, oracle, 0, 0).to);
+        // If scrollTarget is given, make sure the viewport includes that position
+        if (scrollTarget) {
+            let { head } = scrollTarget.range;
+            if (head < viewport.from || head > viewport.to) {
+                let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
+                let block = map.lineAt(head, QueryType$1.ByPos, oracle, 0, 0), topPos;
+                if (scrollTarget.y == "center")
+                    topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
+                else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
+                    topPos = block.top;
+                else
+                    topPos = block.bottom - viewHeight;
+                viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType$1.ByHeight, oracle, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType$1.ByHeight, oracle, 0, 0).to);
+            }
+        }
+        return viewport;
+    }
+    mapViewport(viewport, changes) {
+        let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
+        return new Viewport(this.heightMap.lineAt(from, QueryType$1.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(to, QueryType$1.ByPos, this.heightOracle, 0, 0).to);
+    }
+    // Checks if a given viewport covers the visible part of the
+    // document and not too much beyond that.
+    viewportIsAppropriate({ from, to }, bias = 0) {
+        if (!this.inView)
+            return true;
+        let { top } = this.heightMap.lineAt(from, QueryType$1.ByPos, this.heightOracle, 0, 0);
+        let { bottom } = this.heightMap.lineAt(to, QueryType$1.ByPos, this.heightOracle, 0, 0);
+        let { visibleTop, visibleBottom } = this;
+        return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
+            (to == this.state.doc.length ||
+                bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
+            (top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
+    }
+    mapLineGaps(gaps, changes) {
+        if (!gaps.length || changes.empty)
+            return gaps;
+        let mapped = [];
+        for (let gap of gaps)
+            if (!changes.touchesRange(gap.from, gap.to))
+                mapped.push(new LineGap(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size, gap.displaySize));
+        return mapped;
+    }
+    // Computes positions in the viewport where the start or end of a
+    // line should be hidden, trying to reuse existing line gaps when
+    // appropriate to avoid unneccesary redraws.
+    // Uses crude character-counting for the positioning and sizing,
+    // since actual DOM coordinates aren't always available and
+    // predictable. Relies on generous margins (see LG.Margin) to hide
+    // the artifacts this might produce from the user.
+    ensureLineGaps(current, mayMeasure) {
+        let wrapping = this.heightOracle.lineWrapping;
+        let margin = wrapping ? 10000 /* LG.MarginWrap */ : 2000 /* LG.Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;
+        // The non-wrapping logic won't work at all in predominantly right-to-left text.
+        if (this.defaultTextDirection != Direction.LTR && !wrapping)
+            return [];
+        let gaps = [];
+        let addGap = (from, to, line, structure) => {
+            if (to - from < halfMargin)
+                return;
+            let sel = this.state.selection.main, avoid = [sel.from];
+            if (!sel.empty)
+                avoid.push(sel.to);
+            for (let pos of avoid) {
+                if (pos > from && pos < to) {
+                    addGap(from, pos - 10 /* LG.SelectionMargin */, line, structure);
+                    addGap(pos + 10 /* LG.SelectionMargin */, to, line, structure);
+                    return;
+                }
+            }
+            let gap = find(current, gap => gap.from >= line.from && gap.to <= line.to &&
+                Math.abs(gap.from - from) < halfMargin && Math.abs(gap.to - to) < halfMargin &&
+                !avoid.some(pos => gap.from < pos && gap.to > pos));
+            if (!gap) {
+                // When scrolling down, snap gap ends to line starts to avoid shifts in wrapping
+                if (to < line.to && mayMeasure && wrapping &&
+                    mayMeasure.visibleRanges.some(r => r.from <= to && r.to >= to)) {
+                    let lineStart = mayMeasure.moveToLineBoundary(EditorSelection.cursor(to), false, true).head;
+                    if (lineStart > from)
+                        to = lineStart;
+                }
+                let size = this.gapSize(line, from, to, structure);
+                let displaySize = wrapping || size < 2000000 /* VP.MaxHorizGap */ ? size : 2000000 /* VP.MaxHorizGap */;
+                gap = new LineGap(from, to, size, displaySize);
+            }
+            gaps.push(gap);
+        };
+        let checkLine = (line) => {
+            if (line.length < doubleMargin || line.type != BlockType.Text)
+                return;
+            let structure = lineStructure(line.from, line.to, this.stateDeco);
+            if (structure.total < doubleMargin)
+                return;
+            let target = this.scrollTarget ? this.scrollTarget.range.head : null;
+            let viewFrom, viewTo;
+            if (wrapping) {
+                let marginHeight = (margin / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
+                let top, bot;
+                if (target != null) {
+                    let targetFrac = findFraction(structure, target);
+                    let spaceFrac = ((this.visibleBottom - this.visibleTop) / 2 + marginHeight) / line.height;
+                    top = targetFrac - spaceFrac;
+                    bot = targetFrac + spaceFrac;
+                }
+                else {
+                    top = (this.visibleTop - line.top - marginHeight) / line.height;
+                    bot = (this.visibleBottom - line.top + marginHeight) / line.height;
+                }
+                viewFrom = findPosition(structure, top);
+                viewTo = findPosition(structure, bot);
+            }
+            else {
+                let totalWidth = structure.total * this.heightOracle.charWidth;
+                let marginWidth = margin * this.heightOracle.charWidth;
+                let horizOffset = 0;
+                if (totalWidth > 2000000 /* VP.MaxHorizGap */)
+                    for (let old of current) {
+                        if (old.from >= line.from && old.from < line.to && old.size != old.displaySize &&
+                            old.from * this.heightOracle.charWidth + horizOffset < this.pixelViewport.left)
+                            horizOffset = old.size - old.displaySize;
+                    }
+                let pxLeft = this.pixelViewport.left + horizOffset, pxRight = this.pixelViewport.right + horizOffset;
+                let left, right;
+                if (target != null) {
+                    let targetFrac = findFraction(structure, target);
+                    let spaceFrac = ((pxRight - pxLeft) / 2 + marginWidth) / totalWidth;
+                    left = targetFrac - spaceFrac;
+                    right = targetFrac + spaceFrac;
+                }
+                else {
+                    left = (pxLeft - marginWidth) / totalWidth;
+                    right = (pxRight + marginWidth) / totalWidth;
+                }
+                viewFrom = findPosition(structure, left);
+                viewTo = findPosition(structure, right);
+            }
+            if (viewFrom > line.from)
+                addGap(line.from, viewFrom, line, structure);
+            if (viewTo < line.to)
+                addGap(viewTo, line.to, line, structure);
+        };
+        for (let line of this.viewportLines) {
+            if (Array.isArray(line.type))
+                line.type.forEach(checkLine);
+            else
+                checkLine(line);
+        }
+        return gaps;
+    }
+    gapSize(line, from, to, structure) {
+        let fraction = findFraction(structure, to) - findFraction(structure, from);
+        if (this.heightOracle.lineWrapping) {
+            return line.height * fraction;
+        }
+        else {
+            return structure.total * this.heightOracle.charWidth * fraction;
+        }
+    }
+    updateLineGaps(gaps) {
+        if (!LineGap.same(gaps, this.lineGaps)) {
+            this.lineGaps = gaps;
+            this.lineGapDeco = Decoration.set(gaps.map(gap => gap.draw(this, this.heightOracle.lineWrapping)));
+        }
+    }
+    computeVisibleRanges(changes) {
+        let deco = this.stateDeco;
+        if (this.lineGaps.length)
+            deco = deco.concat(this.lineGapDeco);
+        let ranges = [];
+        RangeSet.spans(deco, this.viewport.from, this.viewport.to, {
+            span(from, to) { ranges.push({ from, to }); },
+            point() { }
+        }, 20);
+        let changed = 0;
+        if (ranges.length != this.visibleRanges.length) {
+            changed = 8 /* UpdateFlag.ViewportMoved */ | 4 /* UpdateFlag.Viewport */;
+        }
+        else {
+            for (let i = 0; i < ranges.length && !(changed & 8 /* UpdateFlag.ViewportMoved */); i++) {
+                let old = this.visibleRanges[i], nw = ranges[i];
+                if (old.from != nw.from || old.to != nw.to) {
+                    changed |= 4 /* UpdateFlag.Viewport */;
+                    if (!(changes && changes.mapPos(old.from, -1) == nw.from && changes.mapPos(old.to, 1) == nw.to))
+                        changed |= 8 /* UpdateFlag.ViewportMoved */;
+                }
+            }
+        }
+        this.visibleRanges = ranges;
+        return changed;
+    }
+    lineBlockAt(pos) {
+        return (pos >= this.viewport.from && pos <= this.viewport.to &&
+            this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
+            scaleBlock(this.heightMap.lineAt(pos, QueryType$1.ByPos, this.heightOracle, 0, 0), this.scaler);
+    }
+    lineBlockAtHeight(height) {
+        return (height >= this.viewportLines[0].top && height <= this.viewportLines[this.viewportLines.length - 1].bottom &&
+            this.viewportLines.find(l => l.top <= height && l.bottom >= height)) ||
+            scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$1.ByHeight, this.heightOracle, 0, 0), this.scaler);
+    }
+    scrollAnchorAt(scrollTop) {
+        let block = this.lineBlockAtHeight(scrollTop + 8);
+        return block.from >= this.viewport.from || this.viewportLines[0].top - scrollTop > 200 ? block : this.viewportLines[0];
+    }
+    elementAtHeight(height) {
+        return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.heightOracle, 0, 0), this.scaler);
+    }
+    get docHeight() {
+        return this.scaler.toDOM(this.heightMap.height);
+    }
+    get contentHeight() {
+        return this.docHeight + this.paddingTop + this.paddingBottom;
+    }
+}
+class Viewport {
+    constructor(from, to) {
+        this.from = from;
+        this.to = to;
+    }
+}
+function lineStructure(from, to, stateDeco) {
+    let ranges = [], pos = from, total = 0;
+    RangeSet.spans(stateDeco, from, to, {
+        span() { },
+        point(from, to) {
+            if (from > pos) {
+                ranges.push({ from: pos, to: from });
+                total += from - pos;
+            }
+            pos = to;
+        }
+    }, 20); // We're only interested in collapsed ranges of a significant size
+    if (pos < to) {
+        ranges.push({ from: pos, to });
+        total += to - pos;
+    }
+    return { total, ranges };
+}
+function findPosition({ total, ranges }, ratio) {
+    if (ratio <= 0)
+        return ranges[0].from;
+    if (ratio >= 1)
+        return ranges[ranges.length - 1].to;
+    let dist = Math.floor(total * ratio);
+    for (let i = 0;; i++) {
+        let { from, to } = ranges[i], size = to - from;
+        if (dist <= size)
+            return from + dist;
+        dist -= size;
+    }
+}
+function findFraction(structure, pos) {
+    let counted = 0;
+    for (let { from, to } of structure.ranges) {
+        if (pos <= to) {
+            counted += pos - from;
+            break;
+        }
+        counted += to - from;
+    }
+    return counted / structure.total;
+}
+function find(array, f) {
+    for (let val of array)
+        if (f(val))
+            return val;
+    return undefined;
+}
+// Don't scale when the document height is within the range of what
+// the DOM can handle.
+const IdScaler = {
+    toDOM(n) { return n; },
+    fromDOM(n) { return n; },
+    scale: 1,
+    eq(other) { return other == this; }
+};
+// When the height is too big (> VP.MaxDOMHeight), scale down the
+// regions outside the viewports so that the total height is
+// VP.MaxDOMHeight.
+class BigScaler {
+    constructor(oracle, heightMap, viewports) {
+        let vpHeight = 0, base = 0, domBase = 0;
+        this.viewports = viewports.map(({ from, to }) => {
+            let top = heightMap.lineAt(from, QueryType$1.ByPos, oracle, 0, 0).top;
+            let bottom = heightMap.lineAt(to, QueryType$1.ByPos, oracle, 0, 0).bottom;
+            vpHeight += bottom - top;
+            return { from, to, top, bottom, domTop: 0, domBottom: 0 };
+        });
+        this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
+        for (let obj of this.viewports) {
+            obj.domTop = domBase + (obj.top - base) * this.scale;
+            domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
+            base = obj.bottom;
+        }
+    }
+    toDOM(n) {
+        for (let i = 0, base = 0, domBase = 0;; i++) {
+            let vp = i < this.viewports.length ? this.viewports[i] : null;
+            if (!vp || n < vp.top)
+                return domBase + (n - base) * this.scale;
+            if (n <= vp.bottom)
+                return vp.domTop + (n - vp.top);
+            base = vp.bottom;
+            domBase = vp.domBottom;
+        }
+    }
+    fromDOM(n) {
+        for (let i = 0, base = 0, domBase = 0;; i++) {
+            let vp = i < this.viewports.length ? this.viewports[i] : null;
+            if (!vp || n < vp.domTop)
+                return base + (n - domBase) / this.scale;
+            if (n <= vp.domBottom)
+                return vp.top + (n - vp.domTop);
+            base = vp.bottom;
+            domBase = vp.domBottom;
+        }
+    }
+    eq(other) {
+        if (!(other instanceof BigScaler))
+            return false;
+        return this.scale == other.scale && this.viewports.length == other.viewports.length &&
+            this.viewports.every((vp, i) => vp.from == other.viewports[i].from && vp.to == other.viewports[i].to);
+    }
+}
+function scaleBlock(block, scaler) {
+    if (scaler.scale == 1)
+        return block;
+    let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
+    return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);
+}
+
+const theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(" ") });
+const darkTheme = /*@__PURE__*/Facet.define({ combine: values => values.indexOf(true) > -1 });
+const baseThemeID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();
+const lightDarkIDs = { "&light": "." + baseLightID, "&dark": "." + baseDarkID };
+function buildTheme(main, spec, scopes) {
+    return new StyleModule(spec, {
+        finish(sel) {
+            return /&/.test(sel) ? sel.replace(/&\w*/, m => {
+                if (m == "&")
+                    return main;
+                if (!scopes || !scopes[m])
+                    throw new RangeError(`Unsupported selector: ${m}`);
+                return scopes[m];
+            }) : main + " " + sel;
+        }
+    });
+}
+const baseTheme$1$3 = /*@__PURE__*/buildTheme("." + baseThemeID, {
+    "&": {
+        position: "relative !important",
+        boxSizing: "border-box",
+        "&.cm-focused": {
+            // Provide a simple default outline to make sure a focused
+            // editor is visually distinct. Can't leave the default behavior
+            // because that will apply to the content element, which is
+            // inside the scrollable container and doesn't include the
+            // gutters. We also can't use an 'auto' outline, since those
+            // are, for some reason, drawn behind the element content, which
+            // will cause things like the active line background to cover
+            // the outline (#297).
+            outline: "1px dotted #212121"
+        },
+        display: "flex !important",
+        flexDirection: "column"
+    },
+    ".cm-scroller": {
+        display: "flex !important",
+        alignItems: "flex-start !important",
+        fontFamily: "monospace",
+        lineHeight: 1.4,
+        height: "100%",
+        overflowX: "auto",
+        position: "relative",
+        zIndex: 0,
+        overflowAnchor: "none",
+    },
+    ".cm-content": {
+        margin: 0,
+        flexGrow: 2,
+        flexShrink: 0,
+        display: "block",
+        whiteSpace: "pre",
+        wordWrap: "normal", // https://github.com/codemirror/dev/issues/456
+        boxSizing: "border-box",
+        minHeight: "100%",
+        padding: "4px 0",
+        outline: "none",
+        "&[contenteditable=true]": {
+            WebkitUserModify: "read-write-plaintext-only",
+        }
+    },
+    ".cm-lineWrapping": {
+        whiteSpace_fallback: "pre-wrap", // For IE
+        whiteSpace: "break-spaces",
+        wordBreak: "break-word", // For Safari, which doesn't support overflow-wrap: anywhere
+        overflowWrap: "anywhere",
+        flexShrink: 1
+    },
+    "&light .cm-content": { caretColor: "black" },
+    "&dark .cm-content": { caretColor: "white" },
+    ".cm-line": {
+        display: "block",
+        padding: "0 2px 0 6px"
+    },
+    ".cm-layer": {
+        position: "absolute",
+        left: 0,
+        top: 0,
+        contain: "size style",
+        "& > *": {
+            position: "absolute"
+        }
+    },
+    "&light .cm-selectionBackground": {
+        background: "#d9d9d9"
+    },
+    "&dark .cm-selectionBackground": {
+        background: "#222"
+    },
+    "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
+        background: "#d7d4f0"
+    },
+    "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
+        background: "#233"
+    },
+    ".cm-cursorLayer": {
+        pointerEvents: "none"
+    },
+    "&.cm-focused > .cm-scroller > .cm-cursorLayer": {
+        animation: "steps(1) cm-blink 1.2s infinite"
+    },
+    // Two animations defined so that we can switch between them to
+    // restart the animation without forcing another style
+    // recomputation.
+    "@keyframes cm-blink": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
+    "@keyframes cm-blink2": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
+    ".cm-cursor, .cm-dropCursor": {
+        borderLeft: "1.2px solid black",
+        marginLeft: "-0.6px",
+        pointerEvents: "none",
+    },
+    ".cm-cursor": {
+        display: "none"
+    },
+    "&dark .cm-cursor": {
+        borderLeftColor: "#ddd"
+    },
+    ".cm-dropCursor": {
+        position: "absolute"
+    },
+    "&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
+        display: "block"
+    },
+    ".cm-iso": {
+        unicodeBidi: "isolate"
+    },
+    ".cm-announced": {
+        position: "fixed",
+        top: "-10000px"
+    },
+    "@media print": {
+        ".cm-announced": { display: "none" }
+    },
+    "&light .cm-activeLine": { backgroundColor: "#cceeff44" },
+    "&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
+    "&light .cm-specialChar": { color: "red" },
+    "&dark .cm-specialChar": { color: "#f78" },
+    ".cm-gutters": {
+        flexShrink: 0,
+        display: "flex",
+        height: "100%",
+        boxSizing: "border-box",
+        insetInlineStart: 0,
+        zIndex: 200
+    },
+    "&light .cm-gutters": {
+        backgroundColor: "#f5f5f5",
+        color: "#6c6c6c",
+        borderRight: "1px solid #ddd"
+    },
+    "&dark .cm-gutters": {
+        backgroundColor: "#333338",
+        color: "#ccc"
+    },
+    ".cm-gutter": {
+        display: "flex !important", // Necessary -- prevents margin collapsing
+        flexDirection: "column",
+        flexShrink: 0,
+        boxSizing: "border-box",
+        minHeight: "100%",
+        overflow: "hidden"
+    },
+    ".cm-gutterElement": {
+        boxSizing: "border-box"
+    },
+    ".cm-lineNumbers .cm-gutterElement": {
+        padding: "0 3px 0 5px",
+        minWidth: "20px",
+        textAlign: "right",
+        whiteSpace: "nowrap"
+    },
+    "&light .cm-activeLineGutter": {
+        backgroundColor: "#e2f2ff"
+    },
+    "&dark .cm-activeLineGutter": {
+        backgroundColor: "#222227"
+    },
+    ".cm-panels": {
+        boxSizing: "border-box",
+        position: "sticky",
+        left: 0,
+        right: 0,
+        zIndex: 300
+    },
+    "&light .cm-panels": {
+        backgroundColor: "#f5f5f5",
+        color: "black"
+    },
+    "&light .cm-panels-top": {
+        borderBottom: "1px solid #ddd"
+    },
+    "&light .cm-panels-bottom": {
+        borderTop: "1px solid #ddd"
+    },
+    "&dark .cm-panels": {
+        backgroundColor: "#333338",
+        color: "white"
+    },
+    ".cm-tab": {
+        display: "inline-block",
+        overflow: "hidden",
+        verticalAlign: "bottom"
+    },
+    ".cm-widgetBuffer": {
+        verticalAlign: "text-top",
+        height: "1em",
+        width: 0,
+        display: "inline"
+    },
+    ".cm-placeholder": {
+        color: "#888",
+        display: "inline-block",
+        verticalAlign: "top",
+    },
+    ".cm-highlightSpace": {
+        backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
+        backgroundPosition: "center",
+    },
+    ".cm-highlightTab": {
+        backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
+        backgroundSize: "auto 100%",
+        backgroundPosition: "right 90%",
+        backgroundRepeat: "no-repeat"
+    },
+    ".cm-trailingSpace": {
+        backgroundColor: "#ff332255"
+    },
+    ".cm-button": {
+        verticalAlign: "middle",
+        color: "inherit",
+        fontSize: "70%",
+        padding: ".2em 1em",
+        borderRadius: "1px"
+    },
+    "&light .cm-button": {
+        backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
+        border: "1px solid #888",
+        "&:active": {
+            backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
+        }
+    },
+    "&dark .cm-button": {
+        backgroundImage: "linear-gradient(#393939, #111)",
+        border: "1px solid #888",
+        "&:active": {
+            backgroundImage: "linear-gradient(#111, #333)"
+        }
+    },
+    ".cm-textfield": {
+        verticalAlign: "middle",
+        color: "inherit",
+        fontSize: "70%",
+        border: "1px solid silver",
+        padding: ".2em .5em"
+    },
+    "&light .cm-textfield": {
+        backgroundColor: "white"
+    },
+    "&dark .cm-textfield": {
+        border: "1px solid #555",
+        backgroundColor: "inherit"
+    }
+}, lightDarkIDs);
+
+const observeOptions = {
+    childList: true,
+    characterData: true,
+    subtree: true,
+    attributes: true,
+    characterDataOldValue: true
+};
+// IE11 has very broken mutation observers, so we also listen to
+// DOMCharacterDataModified there
+const useCharData = browser.ie && browser.ie_version <= 11;
+class DOMObserver {
+    constructor(view) {
+        this.view = view;
+        this.active = false;
+        this.editContext = null;
+        // The known selection. Kept in our own object, as opposed to just
+        // directly accessing the selection because:
+        //  - Safari doesn't report the right selection in shadow DOM
+        //  - Reading from the selection forces a DOM layout
+        //  - This way, we can ignore selectionchange events if we have
+        //    already seen the 'new' selection
+        this.selectionRange = new DOMSelectionState;
+        // Set when a selection change is detected, cleared on flush
+        this.selectionChanged = false;
+        this.delayedFlush = -1;
+        this.resizeTimeout = -1;
+        this.queue = [];
+        this.delayedAndroidKey = null;
+        this.flushingAndroidKey = -1;
+        this.lastChange = 0;
+        this.scrollTargets = [];
+        this.intersection = null;
+        this.resizeScroll = null;
+        this.intersecting = false;
+        this.gapIntersection = null;
+        this.gaps = [];
+        this.printQuery = null;
+        // Timeout for scheduling check of the parents that need scroll handlers
+        this.parentCheck = -1;
+        this.dom = view.contentDOM;
+        this.observer = new MutationObserver(mutations => {
+            for (let mut of mutations)
+                this.queue.push(mut);
+            // IE11 will sometimes (on typing over a selection or
+            // backspacing out a single character text node) call the
+            // observer callback before actually updating the DOM.
+            //
+            // Unrelatedly, iOS Safari will, when ending a composition,
+            // sometimes first clear it, deliver the mutations, and then
+            // reinsert the finished text. CodeMirror's handling of the
+            // deletion will prevent the reinsertion from happening,
+            // breaking composition.
+            if ((browser.ie && browser.ie_version <= 11 || browser.ios && view.composing) &&
+                mutations.some(m => m.type == "childList" && m.removedNodes.length ||
+                    m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
+                this.flushSoon();
+            else
+                this.flush();
+        });
+        if (window.EditContext && view.constructor.EDIT_CONTEXT !== false &&
+            // Chrome <126 doesn't support inverted selections in edit context (#1392)
+            !(browser.chrome && browser.chrome_version < 126)) {
+            this.editContext = new EditContextManager(view);
+            if (view.state.facet(editable))
+                view.contentDOM.editContext = this.editContext.editContext;
+        }
+        if (useCharData)
+            this.onCharData = (event) => {
+                this.queue.push({ target: event.target,
+                    type: "characterData",
+                    oldValue: event.prevValue });
+                this.flushSoon();
+            };
+        this.onSelectionChange = this.onSelectionChange.bind(this);
+        this.onResize = this.onResize.bind(this);
+        this.onPrint = this.onPrint.bind(this);
+        this.onScroll = this.onScroll.bind(this);
+        if (window.matchMedia)
+            this.printQuery = window.matchMedia("print");
+        if (typeof ResizeObserver == "function") {
+            this.resizeScroll = new ResizeObserver(() => {
+                var _a;
+                if (((_a = this.view.docView) === null || _a === void 0 ? void 0 : _a.lastUpdate) < Date.now() - 75)
+                    this.onResize();
+            });
+            this.resizeScroll.observe(view.scrollDOM);
+        }
+        this.addWindowListeners(this.win = view.win);
+        this.start();
+        if (typeof IntersectionObserver == "function") {
+            this.intersection = new IntersectionObserver(entries => {
+                if (this.parentCheck < 0)
+                    this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
+                if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
+                    this.intersecting = !this.intersecting;
+                    if (this.intersecting != this.view.inView)
+                        this.onScrollChanged(document.createEvent("Event"));
+                }
+            }, { threshold: [0, .001] });
+            this.intersection.observe(this.dom);
+            this.gapIntersection = new IntersectionObserver(entries => {
+                if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
+                    this.onScrollChanged(document.createEvent("Event"));
+            }, {});
+        }
+        this.listenForScroll();
+        this.readSelectionRange();
+    }
+    onScrollChanged(e) {
+        this.view.inputState.runHandlers("scroll", e);
+        if (this.intersecting)
+            this.view.measure();
+    }
+    onScroll(e) {
+        if (this.intersecting)
+            this.flush(false);
+        if (this.editContext)
+            this.view.requestMeasure(this.editContext.measureReq);
+        this.onScrollChanged(e);
+    }
+    onResize() {
+        if (this.resizeTimeout < 0)
+            this.resizeTimeout = setTimeout(() => {
+                this.resizeTimeout = -1;
+                this.view.requestMeasure();
+            }, 50);
+    }
+    onPrint(event) {
+        if ((event.type == "change" || !event.type) && !event.matches)
+            return;
+        this.view.viewState.printing = true;
+        this.view.measure();
+        setTimeout(() => {
+            this.view.viewState.printing = false;
+            this.view.requestMeasure();
+        }, 500);
+    }
+    updateGaps(gaps) {
+        if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
+            this.gapIntersection.disconnect();
+            for (let gap of gaps)
+                this.gapIntersection.observe(gap);
+            this.gaps = gaps;
+        }
+    }
+    onSelectionChange(event) {
+        let wasChanged = this.selectionChanged;
+        if (!this.readSelectionRange() || this.delayedAndroidKey)
+            return;
+        let { view } = this, sel = this.selectionRange;
+        if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(this.dom, sel))
+            return;
+        let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
+        if (context && context.ignoreEvent(event)) {
+            if (!wasChanged)
+                this.selectionChanged = false;
+            return;
+        }
+        // Deletions on IE11 fire their events in the wrong order, giving
+        // us a selection change event before the DOM changes are
+        // reported.
+        // Chrome Android has a similar issue when backspacing out a
+        // selection (#645).
+        if ((browser.ie && browser.ie_version <= 11 || browser.android && browser.chrome) && !view.state.selection.main.empty &&
+            // (Selection.isCollapsed isn't reliable on IE)
+            sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
+            this.flushSoon();
+        else
+            this.flush(false);
+    }
+    readSelectionRange() {
+        let { view } = this;
+        // The Selection object is broken in shadow roots in Safari. See
+        // https://github.com/codemirror/dev/issues/414
+        let selection = getSelection(view.root);
+        if (!selection)
+            return false;
+        let range = browser.safari && view.root.nodeType == 11 &&
+            view.root.activeElement == this.dom &&
+            safariSelectionRangeHack(this.view, selection) || selection;
+        if (!range || this.selectionRange.eq(range))
+            return false;
+        let local = hasSelection(this.dom, range);
+        // Detect the situation where the browser has, on focus, moved the
+        // selection to the start of the content element. Reset it to the
+        // position from the editor state.
+        if (local && !this.selectionChanged &&
+            view.inputState.lastFocusTime > Date.now() - 200 &&
+            view.inputState.lastTouchTime < Date.now() - 300 &&
+            atElementStart(this.dom, range)) {
+            this.view.inputState.lastFocusTime = 0;
+            view.docView.updateSelection();
+            return false;
+        }
+        this.selectionRange.setRange(range);
+        if (local)
+            this.selectionChanged = true;
+        return true;
+    }
+    setSelectionRange(anchor, head) {
+        this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
+        this.selectionChanged = false;
+    }
+    clearSelectionRange() {
+        this.selectionRange.set(null, 0, null, 0);
+    }
+    listenForScroll() {
+        this.parentCheck = -1;
+        let i = 0, changed = null;
+        for (let dom = this.dom; dom;) {
+            if (dom.nodeType == 1) {
+                if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
+                    i++;
+                else if (!changed)
+                    changed = this.scrollTargets.slice(0, i);
+                if (changed)
+                    changed.push(dom);
+                dom = dom.assignedSlot || dom.parentNode;
+            }
+            else if (dom.nodeType == 11) { // Shadow root
+                dom = dom.host;
+            }
+            else {
+                break;
+            }
+        }
+        if (i < this.scrollTargets.length && !changed)
+            changed = this.scrollTargets.slice(0, i);
+        if (changed) {
+            for (let dom of this.scrollTargets)
+                dom.removeEventListener("scroll", this.onScroll);
+            for (let dom of this.scrollTargets = changed)
+                dom.addEventListener("scroll", this.onScroll);
+        }
+    }
+    ignore(f) {
+        if (!this.active)
+            return f();
+        try {
+            this.stop();
+            return f();
+        }
+        finally {
+            this.start();
+            this.clear();
+        }
+    }
+    start() {
+        if (this.active)
+            return;
+        this.observer.observe(this.dom, observeOptions);
+        if (useCharData)
+            this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
+        this.active = true;
+    }
+    stop() {
+        if (!this.active)
+            return;
+        this.active = false;
+        this.observer.disconnect();
+        if (useCharData)
+            this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
+    }
+    // Throw away any pending changes
+    clear() {
+        this.processRecords();
+        this.queue.length = 0;
+        this.selectionChanged = false;
+    }
+    // Chrome Android, especially in combination with GBoard, not only
+    // doesn't reliably fire regular key events, but also often
+    // surrounds the effect of enter or backspace with a bunch of
+    // composition events that, when interrupted, cause text duplication
+    // or other kinds of corruption. This hack makes the editor back off
+    // from handling DOM changes for a moment when such a key is
+    // detected (via beforeinput or keydown), and then tries to flush
+    // them or, if that has no effect, dispatches the given key.
+    delayAndroidKey(key, keyCode) {
+        var _a;
+        if (!this.delayedAndroidKey) {
+            let flush = () => {
+                let key = this.delayedAndroidKey;
+                if (key) {
+                    this.clearDelayedAndroidKey();
+                    this.view.inputState.lastKeyCode = key.keyCode;
+                    this.view.inputState.lastKeyTime = Date.now();
+                    let flushed = this.flush();
+                    if (!flushed && key.force)
+                        dispatchKey(this.dom, key.key, key.keyCode);
+                }
+            };
+            this.flushingAndroidKey = this.view.win.requestAnimationFrame(flush);
+        }
+        // Since backspace beforeinput is sometimes signalled spuriously,
+        // Enter always takes precedence.
+        if (!this.delayedAndroidKey || key == "Enter")
+            this.delayedAndroidKey = {
+                key, keyCode,
+                // Only run the key handler when no changes are detected if
+                // this isn't coming right after another change, in which case
+                // it is probably part of a weird chain of updates, and should
+                // be ignored if it returns the DOM to its previous state.
+                force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
+            };
+    }
+    clearDelayedAndroidKey() {
+        this.win.cancelAnimationFrame(this.flushingAndroidKey);
+        this.delayedAndroidKey = null;
+        this.flushingAndroidKey = -1;
+    }
+    flushSoon() {
+        if (this.delayedFlush < 0)
+            this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
+    }
+    forceFlush() {
+        if (this.delayedFlush >= 0) {
+            this.view.win.cancelAnimationFrame(this.delayedFlush);
+            this.delayedFlush = -1;
+        }
+        this.flush();
+    }
+    pendingRecords() {
+        for (let mut of this.observer.takeRecords())
+            this.queue.push(mut);
+        return this.queue;
+    }
+    processRecords() {
+        let records = this.pendingRecords();
+        if (records.length)
+            this.queue = [];
+        let from = -1, to = -1, typeOver = false;
+        for (let record of records) {
+            let range = this.readMutation(record);
+            if (!range)
+                continue;
+            if (range.typeOver)
+                typeOver = true;
+            if (from == -1) {
+                ({ from, to } = range);
+            }
+            else {
+                from = Math.min(range.from, from);
+                to = Math.max(range.to, to);
+            }
+        }
+        return { from, to, typeOver };
+    }
+    readChange() {
+        let { from, to, typeOver } = this.processRecords();
+        let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
+        if (from < 0 && !newSel)
+            return null;
+        if (from > -1)
+            this.lastChange = Date.now();
+        this.view.inputState.lastFocusTime = 0;
+        this.selectionChanged = false;
+        let change = new DOMChange(this.view, from, to, typeOver);
+        this.view.docView.domChanged = { newSel: change.newSel ? change.newSel.main : null };
+        return change;
+    }
+    // Apply pending changes, if any
+    flush(readSelection = true) {
+        // Completely hold off flushing when pending keys are set—the code
+        // managing those will make sure processRecords is called and the
+        // view is resynchronized after
+        if (this.delayedFlush >= 0 || this.delayedAndroidKey)
+            return false;
+        if (readSelection)
+            this.readSelectionRange();
+        let domChange = this.readChange();
+        if (!domChange) {
+            this.view.requestMeasure();
+            return false;
+        }
+        let startState = this.view.state;
+        let handled = applyDOMChange(this.view, domChange);
+        // The view wasn't updated but DOM/selection changes were seen. Reset the view.
+        if (this.view.state == startState &&
+            (domChange.domChanged || domChange.newSel && !domChange.newSel.main.eq(this.view.state.selection.main)))
+            this.view.update([]);
+        return handled;
+    }
+    readMutation(rec) {
+        let cView = this.view.docView.nearest(rec.target);
+        if (!cView || cView.ignoreMutation(rec))
+            return null;
+        cView.markDirty(rec.type == "attributes");
+        if (rec.type == "attributes")
+            cView.flags |= 4 /* ViewFlag.AttrsDirty */;
+        if (rec.type == "childList") {
+            let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
+            let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
+            return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
+                to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
+        }
+        else if (rec.type == "characterData") {
+            return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
+        }
+        else {
+            return null;
+        }
+    }
+    setWindow(win) {
+        if (win != this.win) {
+            this.removeWindowListeners(this.win);
+            this.win = win;
+            this.addWindowListeners(this.win);
+        }
+    }
+    addWindowListeners(win) {
+        win.addEventListener("resize", this.onResize);
+        if (this.printQuery) {
+            if (this.printQuery.addEventListener)
+                this.printQuery.addEventListener("change", this.onPrint);
+            else
+                this.printQuery.addListener(this.onPrint);
+        }
+        else
+            win.addEventListener("beforeprint", this.onPrint);
+        win.addEventListener("scroll", this.onScroll);
+        win.document.addEventListener("selectionchange", this.onSelectionChange);
+    }
+    removeWindowListeners(win) {
+        win.removeEventListener("scroll", this.onScroll);
+        win.removeEventListener("resize", this.onResize);
+        if (this.printQuery) {
+            if (this.printQuery.removeEventListener)
+                this.printQuery.removeEventListener("change", this.onPrint);
+            else
+                this.printQuery.removeListener(this.onPrint);
+        }
+        else
+            win.removeEventListener("beforeprint", this.onPrint);
+        win.document.removeEventListener("selectionchange", this.onSelectionChange);
+    }
+    update(update) {
+        if (this.editContext) {
+            this.editContext.update(update);
+            if (update.startState.facet(editable) != update.state.facet(editable))
+                update.view.contentDOM.editContext = update.state.facet(editable) ? this.editContext.editContext : null;
+        }
+    }
+    destroy() {
+        var _a, _b, _c;
+        this.stop();
+        (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
+        (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
+        (_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();
+        for (let dom of this.scrollTargets)
+            dom.removeEventListener("scroll", this.onScroll);
+        this.removeWindowListeners(this.win);
+        clearTimeout(this.parentCheck);
+        clearTimeout(this.resizeTimeout);
+        this.win.cancelAnimationFrame(this.delayedFlush);
+        this.win.cancelAnimationFrame(this.flushingAndroidKey);
+        if (this.editContext) {
+            this.view.contentDOM.editContext = null;
+            this.editContext.destroy();
+        }
+    }
+}
+function findChild(cView, dom, dir) {
+    while (dom) {
+        let curView = ContentView.get(dom);
+        if (curView && curView.parent == cView)
+            return curView;
+        let parent = dom.parentNode;
+        dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
+    }
+    return null;
+}
+function buildSelectionRangeFromRange(view, range) {
+    let anchorNode = range.startContainer, anchorOffset = range.startOffset;
+    let focusNode = range.endContainer, focusOffset = range.endOffset;
+    let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
+    // Since such a range doesn't distinguish between anchor and head,
+    // use a heuristic that flips it around if its end matches the
+    // current anchor.
+    if (isEquivalentPosition(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
+        [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
+    return { anchorNode, anchorOffset, focusNode, focusOffset };
+}
+// Used to work around a Safari Selection/shadow DOM bug (#414)
+function safariSelectionRangeHack(view, selection) {
+    if (selection.getComposedRanges) {
+        let range = selection.getComposedRanges(view.root)[0];
+        if (range)
+            return buildSelectionRangeFromRange(view, range);
+    }
+    let found = null;
+    // Because Safari (at least in 2018-2021) doesn't provide regular
+    // access to the selection inside a shadowroot, we have to perform a
+    // ridiculous hack to get at it—using `execCommand` to trigger a
+    // `beforeInput` event so that we can read the target range from the
+    // event.
+    function read(event) {
+        event.preventDefault();
+        event.stopImmediatePropagation();
+        found = event.getTargetRanges()[0];
+    }
+    view.contentDOM.addEventListener("beforeinput", read, true);
+    view.dom.ownerDocument.execCommand("indent");
+    view.contentDOM.removeEventListener("beforeinput", read, true);
+    return found ? buildSelectionRangeFromRange(view, found) : null;
+}
+class EditContextManager {
+    constructor(view) {
+        // The document window for which the text in the context is
+        // maintained. For large documents, this may be smaller than the
+        // editor document. This window always includes the selection head.
+        this.from = 0;
+        this.to = 0;
+        // When applying a transaction, this is used to compare the change
+        // made to the context content to the change in the transaction in
+        // order to make the minimal changes to the context (since touching
+        // that sometimes breaks series of multiple edits made for a single
+        // user action on some Android keyboards)
+        this.pendingContextChange = null;
+        this.handlers = Object.create(null);
+        // Kludge to work around the fact that EditContext does not respond
+        // well to having its content updated during a composition (see #1472)
+        this.composing = null;
+        this.resetRange(view.state);
+        let context = this.editContext = new window.EditContext({
+            text: view.state.doc.sliceString(this.from, this.to),
+            selectionStart: this.toContextPos(Math.max(this.from, Math.min(this.to, view.state.selection.main.anchor))),
+            selectionEnd: this.toContextPos(view.state.selection.main.head)
+        });
+        this.handlers.textupdate = e => {
+            let { anchor } = view.state.selection.main;
+            let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
+            if (view.inputState.composing >= 0 && !this.composing)
+                this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
+            let change = { from, to, insert: Text.of(e.text.split("\n")) };
+            // If the window doesn't include the anchor, assume changes
+            // adjacent to a side go up to the anchor.
+            if (change.from == this.from && anchor < this.from)
+                change.from = anchor;
+            else if (change.to == this.to && anchor > this.to)
+                change.to = anchor;
+            // Edit contexts sometimes fire empty changes
+            if (change.from == change.to && !change.insert.length)
+                return;
+            this.pendingContextChange = change;
+            if (!view.state.readOnly) {
+                let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
+                applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart, newLen), this.toEditorPos(e.selectionEnd, newLen)));
+            }
+            // If the transaction didn't flush our change, revert it so
+            // that the context is in sync with the editor state again.
+            if (this.pendingContextChange) {
+                this.revertPending(view.state);
+                this.setSelection(view.state);
+            }
+        };
+        this.handlers.characterboundsupdate = e => {
+            let rects = [], prev = null;
+            for (let i = this.toEditorPos(e.rangeStart), end = this.toEditorPos(e.rangeEnd); i < end; i++) {
+                let rect = view.coordsForChar(i);
+                prev = (rect && new DOMRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top))
+                    || prev || new DOMRect;
+                rects.push(prev);
+            }
+            context.updateCharacterBounds(e.rangeStart, rects);
+        };
+        this.handlers.textformatupdate = e => {
+            let deco = [];
+            for (let format of e.getTextFormats()) {
+                let lineStyle = format.underlineStyle, thickness = format.underlineThickness;
+                if (lineStyle != "None" && thickness != "None") {
+                    let from = this.toEditorPos(format.rangeStart), to = this.toEditorPos(format.rangeEnd);
+                    if (from < to) {
+                        let style = `text-decoration: underline ${lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${thickness == "Thin" ? 1 : 2}px`;
+                        deco.push(Decoration.mark({ attributes: { style } }).range(from, to));
+                    }
+                }
+            }
+            view.dispatch({ effects: setEditContextFormatting.of(Decoration.set(deco)) });
+        };
+        this.handlers.compositionstart = () => {
+            if (view.inputState.composing < 0) {
+                view.inputState.composing = 0;
+                view.inputState.compositionFirstChange = true;
+            }
+        };
+        this.handlers.compositionend = () => {
+            view.inputState.composing = -1;
+            view.inputState.compositionFirstChange = null;
+            if (this.composing) {
+                let { drifted } = this.composing;
+                this.composing = null;
+                if (drifted)
+                    this.reset(view.state);
+            }
+        };
+        for (let event in this.handlers)
+            context.addEventListener(event, this.handlers[event]);
+        this.measureReq = { read: view => {
+                this.editContext.updateControlBounds(view.contentDOM.getBoundingClientRect());
+                let sel = getSelection(view.root);
+                if (sel && sel.rangeCount)
+                    this.editContext.updateSelectionBounds(sel.getRangeAt(0).getBoundingClientRect());
+            } };
+    }
+    applyEdits(update) {
+        let off = 0, abort = false, pending = this.pendingContextChange;
+        update.changes.iterChanges((fromA, toA, _fromB, _toB, insert) => {
+            if (abort)
+                return;
+            let dLen = insert.length - (toA - fromA);
+            if (pending && toA >= pending.to) {
+                if (pending.from == fromA && pending.to == toA && pending.insert.eq(insert)) {
+                    pending = this.pendingContextChange = null; // Match
+                    off += dLen;
+                    this.to += dLen;
+                    return;
+                }
+                else { // Mismatch, revert
+                    pending = null;
+                    this.revertPending(update.state);
+                }
+            }
+            fromA += off;
+            toA += off;
+            if (toA <= this.from) { // Before the window
+                this.from += dLen;
+                this.to += dLen;
+            }
+            else if (fromA < this.to) { // Overlaps with window
+                if (fromA < this.from || toA > this.to || (this.to - this.from) + insert.length > 30000 /* CxVp.MaxSize */) {
+                    abort = true;
+                    return;
+                }
+                this.editContext.updateText(this.toContextPos(fromA), this.toContextPos(toA), insert.toString());
+                this.to += dLen;
+            }
+            off += dLen;
+        });
+        if (pending && !abort)
+            this.revertPending(update.state);
+        return !abort;
+    }
+    update(update) {
+        let reverted = this.pendingContextChange;
+        if (this.composing && (this.composing.drifted || update.transactions.some(tr => !tr.isUserEvent("input.type") && tr.changes.touchesRange(this.from, this.to)))) {
+            this.composing.drifted = true;
+            this.composing.editorBase = update.changes.mapPos(this.composing.editorBase);
+        }
+        else if (!this.applyEdits(update) || !this.rangeIsValid(update.state)) {
+            this.pendingContextChange = null;
+            this.reset(update.state);
+        }
+        else if (update.docChanged || update.selectionSet || reverted) {
+            this.setSelection(update.state);
+        }
+        if (update.geometryChanged || update.docChanged || update.selectionSet)
+            update.view.requestMeasure(this.measureReq);
+    }
+    resetRange(state) {
+        let { head } = state.selection.main;
+        this.from = Math.max(0, head - 10000 /* CxVp.Margin */);
+        this.to = Math.min(state.doc.length, head + 10000 /* CxVp.Margin */);
+    }
+    reset(state) {
+        this.resetRange(state);
+        this.editContext.updateText(0, this.editContext.text.length, state.doc.sliceString(this.from, this.to));
+        this.setSelection(state);
+    }
+    revertPending(state) {
+        let pending = this.pendingContextChange;
+        this.pendingContextChange = null;
+        this.editContext.updateText(this.toContextPos(pending.from), this.toContextPos(pending.from + pending.insert.length), state.doc.sliceString(pending.from, pending.to));
+    }
+    setSelection(state) {
+        let { main } = state.selection;
+        let start = this.toContextPos(Math.max(this.from, Math.min(this.to, main.anchor)));
+        let end = this.toContextPos(main.head);
+        if (this.editContext.selectionStart != start || this.editContext.selectionEnd != end)
+            this.editContext.updateSelection(start, end);
+    }
+    rangeIsValid(state) {
+        let { head } = state.selection.main;
+        return !(this.from > 0 && head - this.from < 500 /* CxVp.MinMargin */ ||
+            this.to < state.doc.length && this.to - head < 500 /* CxVp.MinMargin */ ||
+            this.to - this.from > 10000 /* CxVp.Margin */ * 3);
+    }
+    toEditorPos(contextPos, clipLen = this.to - this.from) {
+        contextPos = Math.min(contextPos, clipLen);
+        let c = this.composing;
+        return c && c.drifted ? c.editorBase + (contextPos - c.contextBase) : contextPos + this.from;
+    }
+    toContextPos(editorPos) {
+        let c = this.composing;
+        return c && c.drifted ? c.contextBase + (editorPos - c.editorBase) : editorPos - this.from;
+    }
+    destroy() {
+        for (let event in this.handlers)
+            this.editContext.removeEventListener(event, this.handlers[event]);
+    }
+}
+
+// The editor's update state machine looks something like this:
+//
+//     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
+//                                         ↑      ↓
+//                                         Updating (measure)
+//
+// The difference between 'Idle' and 'Idle (unchecked)' lies in
+// whether a layout check has been scheduled. A regular update through
+// the `update` method updates the DOM in a write-only fashion, and
+// relies on a check (scheduled with `requestAnimationFrame`) to make
+// sure everything is where it should be and the viewport covers the
+// visible code. That check continues to measure and then optionally
+// update until it reaches a coherent state.
+/**
+An editor view represents the editor's user interface. It holds
+the editable DOM surface, and possibly other elements such as the
+line number gutter. It handles events and dispatches state
+transactions for editing actions.
+*/
+class EditorView {
+    /**
+    The current editor state.
+    */
+    get state() { return this.viewState.state; }
+    /**
+    To be able to display large documents without consuming too much
+    memory or overloading the browser, CodeMirror only draws the
+    code that is visible (plus a margin around it) to the DOM. This
+    property tells you the extent of the current drawn viewport, in
+    document positions.
+    */
+    get viewport() { return this.viewState.viewport; }
+    /**
+    When there are, for example, large collapsed ranges in the
+    viewport, its size can be a lot bigger than the actual visible
+    content. Thus, if you are doing something like styling the
+    content in the viewport, it is preferable to only do so for
+    these ranges, which are the subset of the viewport that is
+    actually drawn.
+    */
+    get visibleRanges() { return this.viewState.visibleRanges; }
+    /**
+    Returns false when the editor is entirely scrolled out of view
+    or otherwise hidden.
+    */
+    get inView() { return this.viewState.inView; }
+    /**
+    Indicates whether the user is currently composing text via
+    [IME](https://en.wikipedia.org/wiki/Input_method), and at least
+    one change has been made in the current composition.
+    */
+    get composing() { return this.inputState.composing > 0; }
+    /**
+    Indicates whether the user is currently in composing state. Note
+    that on some platforms, like Android, this will be the case a
+    lot, since just putting the cursor on a word starts a
+    composition there.
+    */
+    get compositionStarted() { return this.inputState.composing >= 0; }
+    /**
+    The document or shadow root that the view lives in.
+    */
+    get root() { return this._root; }
+    /**
+    @internal
+    */
+    get win() { return this.dom.ownerDocument.defaultView || window; }
+    /**
+    Construct a new view. You'll want to either provide a `parent`
+    option, or put `view.dom` into your document after creating a
+    view, so that the user can see the editor.
+    */
+    constructor(config = {}) {
+        var _a;
+        this.plugins = [];
+        this.pluginMap = new Map;
+        this.editorAttrs = {};
+        this.contentAttrs = {};
+        this.bidiCache = [];
+        this.destroyed = false;
+        /**
+        @internal
+        */
+        this.updateState = 2 /* UpdateState.Updating */;
+        /**
+        @internal
+        */
+        this.measureScheduled = -1;
+        /**
+        @internal
+        */
+        this.measureRequests = [];
+        this.contentDOM = document.createElement("div");
+        this.scrollDOM = document.createElement("div");
+        this.scrollDOM.tabIndex = -1;
+        this.scrollDOM.className = "cm-scroller";
+        this.scrollDOM.appendChild(this.contentDOM);
+        this.announceDOM = document.createElement("div");
+        this.announceDOM.className = "cm-announced";
+        this.announceDOM.setAttribute("aria-live", "polite");
+        this.dom = document.createElement("div");
+        this.dom.appendChild(this.announceDOM);
+        this.dom.appendChild(this.scrollDOM);
+        if (config.parent)
+            config.parent.appendChild(this.dom);
+        let { dispatch } = config;
+        this.dispatchTransactions = config.dispatchTransactions ||
+            (dispatch && ((trs) => trs.forEach(tr => dispatch(tr, this)))) ||
+            ((trs) => this.update(trs));
+        this.dispatch = this.dispatch.bind(this);
+        this._root = (config.root || getRoot(config.parent) || document);
+        this.viewState = new ViewState(config.state || EditorState.create(config));
+        if (config.scrollTo && config.scrollTo.is(scrollIntoView$1))
+            this.viewState.scrollTarget = config.scrollTo.value.clip(this.viewState.state);
+        this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
+        for (let plugin of this.plugins)
+            plugin.update(this);
+        this.observer = new DOMObserver(this);
+        this.inputState = new InputState(this);
+        this.inputState.ensureHandlers(this.plugins);
+        this.docView = new DocView(this);
+        this.mountStyles();
+        this.updateAttrs();
+        this.updateState = 0 /* UpdateState.Idle */;
+        this.requestMeasure();
+        if ((_a = document.fonts) === null || _a === void 0 ? void 0 : _a.ready)
+            document.fonts.ready.then(() => this.requestMeasure());
+    }
+    dispatch(...input) {
+        let trs = input.length == 1 && input[0] instanceof Transaction ? input
+            : input.length == 1 && Array.isArray(input[0]) ? input[0]
+                : [this.state.update(...input)];
+        this.dispatchTransactions(trs, this);
+    }
+    /**
+    Update the view for the given array of transactions. This will
+    update the visible document and selection to match the state
+    produced by the transactions, and notify view plugins of the
+    change. You should usually call
+    [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
+    as a primitive.
+    */
+    update(transactions) {
+        if (this.updateState != 0 /* UpdateState.Idle */)
+            throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
+        let redrawn = false, attrsChanged = false, update;
+        let state = this.state;
+        for (let tr of transactions) {
+            if (tr.startState != state)
+                throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
+            state = tr.state;
+        }
+        if (this.destroyed) {
+            this.viewState.state = state;
+            return;
+        }
+        let focus = this.hasFocus, focusFlag = 0, dispatchFocus = null;
+        if (transactions.some(tr => tr.annotation(isFocusChange))) {
+            this.inputState.notifiedFocused = focus;
+            // If a focus-change transaction is being dispatched, set this update flag.
+            focusFlag = 1 /* UpdateFlag.Focus */;
+        }
+        else if (focus != this.inputState.notifiedFocused) {
+            this.inputState.notifiedFocused = focus;
+            // Schedule a separate focus transaction if necessary, otherwise
+            // add a flag to this update
+            dispatchFocus = focusChangeTransaction(state, focus);
+            if (!dispatchFocus)
+                focusFlag = 1 /* UpdateFlag.Focus */;
+        }
+        // If there was a pending DOM change, eagerly read it and try to
+        // apply it after the given transactions.
+        let pendingKey = this.observer.delayedAndroidKey, domChange = null;
+        if (pendingKey) {
+            this.observer.clearDelayedAndroidKey();
+            domChange = this.observer.readChange();
+            // Only try to apply DOM changes if the transactions didn't
+            // change the doc or selection.
+            if (domChange && !this.state.doc.eq(state.doc) || !this.state.selection.eq(state.selection))
+                domChange = null;
+        }
+        else {
+            this.observer.clear();
+        }
+        // When the phrases change, redraw the editor
+        if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases))
+            return this.setState(state);
+        update = ViewUpdate.create(this, state, transactions);
+        update.flags |= focusFlag;
+        let scrollTarget = this.viewState.scrollTarget;
+        try {
+            this.updateState = 2 /* UpdateState.Updating */;
+            for (let tr of transactions) {
+                if (scrollTarget)
+                    scrollTarget = scrollTarget.map(tr.changes);
+                if (tr.scrollIntoView) {
+                    let { main } = tr.state.selection;
+                    scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1));
+                }
+                for (let e of tr.effects)
+                    if (e.is(scrollIntoView$1))
+                        scrollTarget = e.value.clip(this.state);
+            }
+            this.viewState.update(update, scrollTarget);
+            this.bidiCache = CachedOrder.update(this.bidiCache, update.changes);
+            if (!update.empty) {
+                this.updatePlugins(update);
+                this.inputState.update(update);
+            }
+            redrawn = this.docView.update(update);
+            if (this.state.facet(styleModule) != this.styleModules)
+                this.mountStyles();
+            attrsChanged = this.updateAttrs();
+            this.showAnnouncements(transactions);
+            this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
+        }
+        finally {
+            this.updateState = 0 /* UpdateState.Idle */;
+        }
+        if (update.startState.facet(theme) != update.state.facet(theme))
+            this.viewState.mustMeasureContent = true;
+        if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
+            this.requestMeasure();
+        if (redrawn)
+            this.docViewUpdate();
+        if (!update.empty)
+            for (let listener of this.state.facet(updateListener)) {
+                try {
+                    listener(update);
+                }
+                catch (e) {
+                    logException(this.state, e, "update listener");
+                }
+            }
+        if (dispatchFocus || domChange)
+            Promise.resolve().then(() => {
+                if (dispatchFocus && this.state == dispatchFocus.startState)
+                    this.dispatch(dispatchFocus);
+                if (domChange) {
+                    if (!applyDOMChange(this, domChange) && pendingKey.force)
+                        dispatchKey(this.contentDOM, pendingKey.key, pendingKey.keyCode);
+                }
+            });
+    }
+    /**
+    Reset the view to the given state. (This will cause the entire
+    document to be redrawn and all view plugins to be reinitialized,
+    so you should probably only use it when the new state isn't
+    derived from the old state. Otherwise, use
+    [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
+    */
+    setState(newState) {
+        if (this.updateState != 0 /* UpdateState.Idle */)
+            throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
+        if (this.destroyed) {
+            this.viewState.state = newState;
+            return;
+        }
+        this.updateState = 2 /* UpdateState.Updating */;
+        let hadFocus = this.hasFocus;
+        try {
+            for (let plugin of this.plugins)
+                plugin.destroy(this);
+            this.viewState = new ViewState(newState);
+            this.plugins = newState.facet(viewPlugin).map(spec => new PluginInstance(spec));
+            this.pluginMap.clear();
+            for (let plugin of this.plugins)
+                plugin.update(this);
+            this.docView.destroy();
+            this.docView = new DocView(this);
+            this.inputState.ensureHandlers(this.plugins);
+            this.mountStyles();
+            this.updateAttrs();
+            this.bidiCache = [];
+        }
+        finally {
+            this.updateState = 0 /* UpdateState.Idle */;
+        }
+        if (hadFocus)
+            this.focus();
+        this.requestMeasure();
+    }
+    updatePlugins(update) {
+        let prevSpecs = update.startState.facet(viewPlugin), specs = update.state.facet(viewPlugin);
+        if (prevSpecs != specs) {
+            let newPlugins = [];
+            for (let spec of specs) {
+                let found = prevSpecs.indexOf(spec);
+                if (found < 0) {
+                    newPlugins.push(new PluginInstance(spec));
+                }
+                else {
+                    let plugin = this.plugins[found];
+                    plugin.mustUpdate = update;
+                    newPlugins.push(plugin);
+                }
+            }
+            for (let plugin of this.plugins)
+                if (plugin.mustUpdate != update)
+                    plugin.destroy(this);
+            this.plugins = newPlugins;
+            this.pluginMap.clear();
+        }
+        else {
+            for (let p of this.plugins)
+                p.mustUpdate = update;
+        }
+        for (let i = 0; i < this.plugins.length; i++)
+            this.plugins[i].update(this);
+        if (prevSpecs != specs)
+            this.inputState.ensureHandlers(this.plugins);
+    }
+    docViewUpdate() {
+        for (let plugin of this.plugins) {
+            let val = plugin.value;
+            if (val && val.docViewUpdate) {
+                try {
+                    val.docViewUpdate(this);
+                }
+                catch (e) {
+                    logException(this.state, e, "doc view update listener");
+                }
+            }
+        }
+    }
+    /**
+    @internal
+    */
+    measure(flush = true) {
+        if (this.destroyed)
+            return;
+        if (this.measureScheduled > -1)
+            this.win.cancelAnimationFrame(this.measureScheduled);
+        if (this.observer.delayedAndroidKey) {
+            this.measureScheduled = -1;
+            this.requestMeasure();
+            return;
+        }
+        this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
+        if (flush)
+            this.observer.forceFlush();
+        let updated = null;
+        let sDOM = this.scrollDOM, scrollTop = sDOM.scrollTop * this.scaleY;
+        let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
+        if (Math.abs(scrollTop - this.viewState.scrollTop) > 1)
+            scrollAnchorHeight = -1;
+        this.viewState.scrollAnchorHeight = -1;
+        try {
+            for (let i = 0;; i++) {
+                if (scrollAnchorHeight < 0) {
+                    if (isScrolledToBottom(sDOM)) {
+                        scrollAnchorPos = -1;
+                        scrollAnchorHeight = this.viewState.heightMap.height;
+                    }
+                    else {
+                        let block = this.viewState.scrollAnchorAt(scrollTop);
+                        scrollAnchorPos = block.from;
+                        scrollAnchorHeight = block.top;
+                    }
+                }
+                this.updateState = 1 /* UpdateState.Measuring */;
+                let changed = this.viewState.measure(this);
+                if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
+                    break;
+                if (i > 5) {
+                    console.warn(this.measureRequests.length
+                        ? "Measure loop restarted more than 5 times"
+                        : "Viewport failed to stabilize");
+                    break;
+                }
+                let measuring = [];
+                // Only run measure requests in this cycle when the viewport didn't change
+                if (!(changed & 4 /* UpdateFlag.Viewport */))
+                    [this.measureRequests, measuring] = [measuring, this.measureRequests];
+                let measured = measuring.map(m => {
+                    try {
+                        return m.read(this);
+                    }
+                    catch (e) {
+                        logException(this.state, e);
+                        return BadMeasure;
+                    }
+                });
+                let update = ViewUpdate.create(this, this.state, []), redrawn = false;
+                update.flags |= changed;
+                if (!updated)
+                    updated = update;
+                else
+                    updated.flags |= changed;
+                this.updateState = 2 /* UpdateState.Updating */;
+                if (!update.empty) {
+                    this.updatePlugins(update);
+                    this.inputState.update(update);
+                    this.updateAttrs();
+                    redrawn = this.docView.update(update);
+                    if (redrawn)
+                        this.docViewUpdate();
+                }
+                for (let i = 0; i < measuring.length; i++)
+                    if (measured[i] != BadMeasure) {
+                        try {
+                            let m = measuring[i];
+                            if (m.write)
+                                m.write(measured[i], this);
+                        }
+                        catch (e) {
+                            logException(this.state, e);
+                        }
+                    }
+                if (redrawn)
+                    this.docView.updateSelection(true);
+                if (!update.viewportChanged && this.measureRequests.length == 0) {
+                    if (this.viewState.editorHeight) {
+                        if (this.viewState.scrollTarget) {
+                            this.docView.scrollIntoView(this.viewState.scrollTarget);
+                            this.viewState.scrollTarget = null;
+                            scrollAnchorHeight = -1;
+                            continue;
+                        }
+                        else {
+                            let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :
+                                this.viewState.lineBlockAt(scrollAnchorPos).top;
+                            let diff = newAnchorHeight - scrollAnchorHeight;
+                            if (diff > 1 || diff < -1) {
+                                scrollTop = scrollTop + diff;
+                                sDOM.scrollTop = scrollTop / this.scaleY;
+                                scrollAnchorHeight = -1;
+                                continue;
+                            }
+                        }
+                    }
+                    break;
+                }
+            }
+        }
+        finally {
+            this.updateState = 0 /* UpdateState.Idle */;
+            this.measureScheduled = -1;
+        }
+        if (updated && !updated.empty)
+            for (let listener of this.state.facet(updateListener))
+                listener(updated);
+    }
+    /**
+    Get the CSS classes for the currently active editor themes.
+    */
+    get themeClasses() {
+        return baseThemeID + " " +
+            (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + " " +
+            this.state.facet(theme);
+    }
+    updateAttrs() {
+        let editorAttrs = attrsFromFacet(this, editorAttributes, {
+            class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
+        });
+        let contentAttrs = {
+            spellcheck: "false",
+            autocorrect: "off",
+            autocapitalize: "off",
+            writingsuggestions: "false",
+            translate: "no",
+            contenteditable: !this.state.facet(editable) ? "false" : "true",
+            class: "cm-content",
+            style: `${browser.tabSize}: ${this.state.tabSize}`,
+            role: "textbox",
+            "aria-multiline": "true"
+        };
+        if (this.state.readOnly)
+            contentAttrs["aria-readonly"] = "true";
+        attrsFromFacet(this, contentAttributes, contentAttrs);
+        let changed = this.observer.ignore(() => {
+            let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
+            let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);
+            return changedContent || changedEditor;
+        });
+        this.editorAttrs = editorAttrs;
+        this.contentAttrs = contentAttrs;
+        return changed;
+    }
+    showAnnouncements(trs) {
+        let first = true;
+        for (let tr of trs)
+            for (let effect of tr.effects)
+                if (effect.is(EditorView.announce)) {
+                    if (first)
+                        this.announceDOM.textContent = "";
+                    first = false;
+                    let div = this.announceDOM.appendChild(document.createElement("div"));
+                    div.textContent = effect.value;
+                }
+    }
+    mountStyles() {
+        this.styleModules = this.state.facet(styleModule);
+        let nonce = this.state.facet(EditorView.cspNonce);
+        StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$3).reverse(), nonce ? { nonce } : undefined);
+    }
+    readMeasured() {
+        if (this.updateState == 2 /* UpdateState.Updating */)
+            throw new Error("Reading the editor layout isn't allowed during an update");
+        if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
+            this.measure(false);
+    }
+    /**
+    Schedule a layout measurement, optionally providing callbacks to
+    do custom DOM measuring followed by a DOM write phase. Using
+    this is preferable reading DOM layout directly from, for
+    example, an event handler, because it'll make sure measuring and
+    drawing done by other components is synchronized, avoiding
+    unnecessary DOM layout computations.
+    */
+    requestMeasure(request) {
+        if (this.measureScheduled < 0)
+            this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
+        if (request) {
+            if (this.measureRequests.indexOf(request) > -1)
+                return;
+            if (request.key != null)
+                for (let i = 0; i < this.measureRequests.length; i++) {
+                    if (this.measureRequests[i].key === request.key) {
+                        this.measureRequests[i] = request;
+                        return;
+                    }
+                }
+            this.measureRequests.push(request);
+        }
+    }
+    /**
+    Get the value of a specific plugin, if present. Note that
+    plugins that crash can be dropped from a view, so even when you
+    know you registered a given plugin, it is recommended to check
+    the return value of this method.
+    */
+    plugin(plugin) {
+        let known = this.pluginMap.get(plugin);
+        if (known === undefined || known && known.spec != plugin)
+            this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
+        return known && known.update(this).value;
+    }
+    /**
+    The top position of the document, in screen coordinates. This
+    may be negative when the editor is scrolled down. Points
+    directly to the top of the first line, not above the padding.
+    */
+    get documentTop() {
+        return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
+    }
+    /**
+    Reports the padding above and below the document.
+    */
+    get documentPadding() {
+        return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
+    }
+    /**
+    If the editor is transformed with CSS, this provides the scale
+    along the X axis. Otherwise, it will just be 1. Note that
+    transforms other than translation and scaling are not supported.
+    */
+    get scaleX() { return this.viewState.scaleX; }
+    /**
+    Provide the CSS transformed scale along the Y axis.
+    */
+    get scaleY() { return this.viewState.scaleY; }
+    /**
+    Find the text line or block widget at the given vertical
+    position (which is interpreted as relative to the [top of the
+    document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).
+    */
+    elementAtHeight(height) {
+        this.readMeasured();
+        return this.viewState.elementAtHeight(height);
+    }
+    /**
+    Find the line block (see
+    [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
+    height, again interpreted relative to the [top of the
+    document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
+    */
+    lineBlockAtHeight(height) {
+        this.readMeasured();
+        return this.viewState.lineBlockAtHeight(height);
+    }
+    /**
+    Get the extent and vertical position of all [line
+    blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
+    are relative to the [top of the
+    document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
+    */
+    get viewportLineBlocks() {
+        return this.viewState.viewportLines;
+    }
+    /**
+    Find the line block around the given document position. A line
+    block is a range delimited on both sides by either a
+    non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line break, or the
+    start/end of the document. It will usually just hold a line of
+    text, but may be broken into multiple textblocks by block
+    widgets.
+    */
+    lineBlockAt(pos) {
+        return this.viewState.lineBlockAt(pos);
+    }
+    /**
+    The editor's total content height.
+    */
+    get contentHeight() {
+        return this.viewState.contentHeight;
+    }
+    /**
+    Move a cursor position by [grapheme
+    cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
+    the motion is away from the line start, or towards it. In
+    bidirectional text, the line is traversed in visual order, using
+    the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+    When the start position was the last one on the line, the
+    returned position will be across the line break. If there is no
+    further line, the original position is returned.
+    
+    By default, this method moves over a single cluster. The
+    optional `by` argument can be used to move across more. It will
+    be called with the first cluster as argument, and should return
+    a predicate that determines, for each subsequent cluster,
+    whether it should also be moved over.
+    */
+    moveByChar(start, forward, by) {
+        return skipAtoms(this, start, moveByChar(this, start, forward, by));
+    }
+    /**
+    Move a cursor position across the next group of either
+    [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
+    non-whitespace characters.
+    */
+    moveByGroup(start, forward) {
+        return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));
+    }
+    /**
+    Get the cursor position visually at the start or end of a line.
+    Note that this may differ from the _logical_ position at its
+    start or end (which is simply at `line.from`/`line.to`) if text
+    at the start or end goes against the line's base text direction.
+    */
+    visualLineSide(line, end) {
+        let order = this.bidiSpans(line), dir = this.textDirectionAt(line.from);
+        let span = order[end ? order.length - 1 : 0];
+        return EditorSelection.cursor(span.side(end, dir) + line.from, span.forward(!end, dir) ? 1 : -1);
+    }
+    /**
+    Move to the next line boundary in the given direction. If
+    `includeWrap` is true, line wrapping is on, and there is a
+    further wrap point on the current line, the wrap point will be
+    returned. Otherwise this function will return the start or end
+    of the line.
+    */
+    moveToLineBoundary(start, forward, includeWrap = true) {
+        return moveToLineBoundary(this, start, forward, includeWrap);
+    }
+    /**
+    Move a cursor position vertically. When `distance` isn't given,
+    it defaults to moving to the next line (including wrapped
+    lines). Otherwise, `distance` should provide a positive distance
+    in pixels.
+    
+    When `start` has a
+    [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
+    motion will use that as a target horizontal position. Otherwise,
+    the cursor's own horizontal position is used. The returned
+    cursor will have its goal column set to whichever column was
+    used.
+    */
+    moveVertically(start, forward, distance) {
+        return skipAtoms(this, start, moveVertically(this, start, forward, distance));
+    }
+    /**
+    Find the DOM parent node and offset (child offset if `node` is
+    an element, character offset when it is a text node) at the
+    given document position.
+    
+    Note that for positions that aren't currently in
+    `visibleRanges`, the resulting DOM position isn't necessarily
+    meaningful (it may just point before or after a placeholder
+    element).
+    */
+    domAtPos(pos) {
+        return this.docView.domAtPos(pos);
+    }
+    /**
+    Find the document position at the given DOM node. Can be useful
+    for associating positions with DOM events. Will raise an error
+    when `node` isn't part of the editor content.
+    */
+    posAtDOM(node, offset = 0) {
+        return this.docView.posFromDOM(node, offset);
+    }
+    posAtCoords(coords, precise = true) {
+        this.readMeasured();
+        return posAtCoords(this, coords, precise);
+    }
+    /**
+    Get the screen coordinates at the given document position.
+    `side` determines whether the coordinates are based on the
+    element before (-1) or after (1) the position (if no element is
+    available on the given side, the method will transparently use
+    another strategy to get reasonable coordinates).
+    */
+    coordsAtPos(pos, side = 1) {
+        this.readMeasured();
+        let rect = this.docView.coordsAt(pos, side);
+        if (!rect || rect.left == rect.right)
+            return rect;
+        let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
+        let span = order[BidiSpan.find(order, pos - line.from, -1, side)];
+        return flattenRect(rect, (span.dir == Direction.LTR) == (side > 0));
+    }
+    /**
+    Return the rectangle around a given character. If `pos` does not
+    point in front of a character that is in the viewport and
+    rendered (i.e. not replaced, not a line break), this will return
+    null. For space characters that are a line wrap point, this will
+    return the position before the line break.
+    */
+    coordsForChar(pos) {
+        this.readMeasured();
+        return this.docView.coordsForChar(pos);
+    }
+    /**
+    The default width of a character in the editor. May not
+    accurately reflect the width of all characters (given variable
+    width fonts or styling of invididual ranges).
+    */
+    get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
+    /**
+    The default height of a line in the editor. May not be accurate
+    for all lines.
+    */
+    get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
+    /**
+    The text direction
+    ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
+    CSS property) of the editor's content element.
+    */
+    get textDirection() { return this.viewState.defaultTextDirection; }
+    /**
+    Find the text direction of the block at the given position, as
+    assigned by CSS. If
+    [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
+    isn't enabled, or the given position is outside of the viewport,
+    this will always return the same as
+    [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
+    this may trigger a DOM layout.
+    */
+    textDirectionAt(pos) {
+        let perLine = this.state.facet(perLineTextDirection);
+        if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
+            return this.textDirection;
+        this.readMeasured();
+        return this.docView.textDirectionAt(pos);
+    }
+    /**
+    Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
+    (as determined by the
+    [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
+    CSS property of its content element).
+    */
+    get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
+    /**
+    Returns the bidirectional text structure of the given line
+    (which should be in the current document) as an array of span
+    objects. The order of these spans matches the [text
+    direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
+    left-to-right, the leftmost spans come first, otherwise the
+    rightmost spans come first.
+    */
+    bidiSpans(line) {
+        if (line.length > MaxBidiLine)
+            return trivialOrder(line.length);
+        let dir = this.textDirectionAt(line.from), isolates;
+        for (let entry of this.bidiCache) {
+            if (entry.from == line.from && entry.dir == dir &&
+                (entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line))))
+                return entry.order;
+        }
+        if (!isolates)
+            isolates = getIsolatedRanges(this, line);
+        let order = computeOrder(line.text, dir, isolates);
+        this.bidiCache.push(new CachedOrder(line.from, line.to, dir, isolates, true, order));
+        return order;
+    }
+    /**
+    Check whether the editor has focus.
+    */
+    get hasFocus() {
+        var _a;
+        // Safari return false for hasFocus when the context menu is open
+        // or closing, which leads us to ignore selection changes from the
+        // context menu because it looks like the editor isn't focused.
+        // This kludges around that.
+        return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
+            this.root.activeElement == this.contentDOM;
+    }
+    /**
+    Put focus on the editor.
+    */
+    focus() {
+        this.observer.ignore(() => {
+            focusPreventScroll(this.contentDOM);
+            this.docView.updateSelection();
+        });
+    }
+    /**
+    Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only
+    necessary when moving the editor's existing DOM to a new window or shadow root.
+    */
+    setRoot(root) {
+        if (this._root != root) {
+            this._root = root;
+            this.observer.setWindow((root.nodeType == 9 ? root : root.ownerDocument).defaultView || window);
+            this.mountStyles();
+        }
+    }
+    /**
+    Clean up this editor view, removing its element from the
+    document, unregistering event handlers, and notifying
+    plugins. The view instance can no longer be used after
+    calling this.
+    */
+    destroy() {
+        if (this.root.activeElement == this.contentDOM)
+            this.contentDOM.blur();
+        for (let plugin of this.plugins)
+            plugin.destroy(this);
+        this.plugins = [];
+        this.inputState.destroy();
+        this.docView.destroy();
+        this.dom.remove();
+        this.observer.destroy();
+        if (this.measureScheduled > -1)
+            this.win.cancelAnimationFrame(this.measureScheduled);
+        this.destroyed = true;
+    }
+    /**
+    Returns an effect that can be
+    [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
+    cause it to scroll the given position or range into view.
+    */
+    static scrollIntoView(pos, options = {}) {
+        return scrollIntoView$1.of(new ScrollTarget(typeof pos == "number" ? EditorSelection.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
+    }
+    /**
+    Return an effect that resets the editor to its current (at the
+    time this method was called) scroll position. Note that this
+    only affects the editor's own scrollable element, not parents.
+    See also
+    [`EditorViewConfig.scrollTo`](https://codemirror.net/6/docs/ref/#view.EditorViewConfig.scrollTo).
+    
+    The effect should be used with a document identical to the one
+    it was created for. Failing to do so is not an error, but may
+    not scroll to the expected position. You can
+    [map](https://codemirror.net/6/docs/ref/#state.StateEffect.map) the effect to account for changes.
+    */
+    scrollSnapshot() {
+        let { scrollTop, scrollLeft } = this.scrollDOM;
+        let ref = this.viewState.scrollAnchorAt(scrollTop);
+        return scrollIntoView$1.of(new ScrollTarget(EditorSelection.cursor(ref.from), "start", "start", ref.top - scrollTop, scrollLeft, true));
+    }
+    /**
+    Enable or disable tab-focus mode, which disables key bindings
+    for Tab and Shift-Tab, letting the browser's default
+    focus-changing behavior go through instead. This is useful to
+    prevent trapping keyboard users in your editor.
+    
+    Without argument, this toggles the mode. With a boolean, it
+    enables (true) or disables it (false). Given a number, it
+    temporarily enables the mode until that number of milliseconds
+    have passed or another non-Tab key is pressed.
+    */
+    setTabFocusMode(to) {
+        if (to == null)
+            this.inputState.tabFocusMode = this.inputState.tabFocusMode < 0 ? 0 : -1;
+        else if (typeof to == "boolean")
+            this.inputState.tabFocusMode = to ? 0 : -1;
+        else if (this.inputState.tabFocusMode != 0)
+            this.inputState.tabFocusMode = Date.now() + to;
+    }
+    /**
+    Returns an extension that can be used to add DOM event handlers.
+    The value should be an object mapping event names to handler
+    functions. For any given event, such functions are ordered by
+    extension precedence, and the first handler to return true will
+    be assumed to have handled that event, and no other handlers or
+    built-in behavior will be activated for it. These are registered
+    on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
+    for `scroll` handlers, which will be called any time the
+    editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
+    its parent nodes is scrolled.
+    */
+    static domEventHandlers(handlers) {
+        return ViewPlugin.define(() => ({}), { eventHandlers: handlers });
+    }
+    /**
+    Create an extension that registers DOM event observers. Contrary
+    to event [handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers),
+    observers can't be prevented from running by a higher-precedence
+    handler returning true. They also don't prevent other handlers
+    and observers from running when they return true, and should not
+    call `preventDefault`.
+    */
+    static domEventObservers(observers) {
+        return ViewPlugin.define(() => ({}), { eventObservers: observers });
+    }
+    /**
+    Create a theme extension. The first argument can be a
+    [`style-mod`](https://github.com/marijnh/style-mod#documentation)
+    style spec providing the styles for the theme. These will be
+    prefixed with a generated class for the style.
+    
+    Because the selectors will be prefixed with a scope class, rule
+    that directly match the editor's [wrapper
+    element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
+    added—need to be explicitly differentiated by adding an `&` to
+    the selector for that element—for example
+    `&.cm-focused`.
+    
+    When `dark` is set to true, the theme will be marked as dark,
+    which will cause the `&dark` rules from [base
+    themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
+    `&light` when a light theme is active).
+    */
+    static theme(spec, options) {
+        let prefix = StyleModule.newName();
+        let result = [theme.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];
+        if (options && options.dark)
+            result.push(darkTheme.of(true));
+        return result;
+    }
+    /**
+    Create an extension that adds styles to the base theme. Like
+    with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
+    place of the editor wrapper element when directly targeting
+    that. You can also use `&dark` or `&light` instead to only
+    target editors with a dark or light theme.
+    */
+    static baseTheme(spec) {
+        return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
+    }
+    /**
+    Retrieve an editor view instance from the view's DOM
+    representation.
+    */
+    static findFromDOM(dom) {
+        var _a;
+        let content = dom.querySelector(".cm-content");
+        let cView = content && ContentView.get(content) || ContentView.get(dom);
+        return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
+    }
+}
+/**
+Facet to add a [style
+module](https://github.com/marijnh/style-mod#documentation) to
+an editor view. The view will ensure that the module is
+mounted in its [document
+root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
+*/
+EditorView.styleModule = styleModule;
+/**
+An input handler can override the way changes to the editable
+DOM content are handled. Handlers are passed the document
+positions between which the change was found, and the new
+content. When one returns true, no further input handlers are
+called and the default behavior is prevented.
+
+The `insert` argument can be used to get the default transaction
+that would be applied for this input. This can be useful when
+dispatching the custom behavior as a separate transaction.
+*/
+EditorView.inputHandler = inputHandler$1;
+/**
+Functions provided in this facet will be used to transform text
+pasted or dropped into the editor.
+*/
+EditorView.clipboardInputFilter = clipboardInputFilter;
+/**
+Transform text copied or dragged from the editor.
+*/
+EditorView.clipboardOutputFilter = clipboardOutputFilter;
+/**
+Scroll handlers can override how things are scrolled into view.
+If they return `true`, no further handling happens for the
+scrolling. If they return false, the default scroll behavior is
+applied. Scroll handlers should never initiate editor updates.
+*/
+EditorView.scrollHandler = scrollHandler;
+/**
+This facet can be used to provide functions that create effects
+to be dispatched when the editor's focus state changes.
+*/
+EditorView.focusChangeEffect = focusChangeEffect;
+/**
+By default, the editor assumes all its content has the same
+[text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
+value to make it read the text direction of every (rendered)
+line separately.
+*/
+EditorView.perLineTextDirection = perLineTextDirection;
+/**
+Allows you to provide a function that should be called when the
+library catches an exception from an extension (mostly from view
+plugins, but may be used by other extensions to route exceptions
+from user-code-provided callbacks). This is mostly useful for
+debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
+*/
+EditorView.exceptionSink = exceptionSink;
+/**
+A facet that can be used to register a function to be called
+every time the view updates.
+*/
+EditorView.updateListener = updateListener;
+/**
+Facet that controls whether the editor content DOM is editable.
+When its highest-precedence value is `false`, the element will
+not have its `contenteditable` attribute set. (Note that this
+doesn't affect API calls that change the editor content, even
+when those are bound to keys or buttons. See the
+[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
+*/
+EditorView.editable = editable;
+/**
+Allows you to influence the way mouse selection happens. The
+functions in this facet will be called for a `mousedown` event
+on the editor, and can return an object that overrides the way a
+selection is computed from that mouse click or drag.
+*/
+EditorView.mouseSelectionStyle = mouseSelectionStyle;
+/**
+Facet used to configure whether a given selection drag event
+should move or copy the selection. The given predicate will be
+called with the `mousedown` event, and can return `true` when
+the drag should move the content.
+*/
+EditorView.dragMovesSelection = dragMovesSelection$1;
+/**
+Facet used to configure whether a given selecting click adds a
+new range to the existing selection or replaces it entirely. The
+default behavior is to check `event.metaKey` on macOS, and
+`event.ctrlKey` elsewhere.
+*/
+EditorView.clickAddsSelectionRange = clickAddsSelectionRange;
+/**
+A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
+are shown in the view. Decorations can be provided in two
+ways—directly, or via a function that takes an editor view.
+
+Only decoration sets provided directly are allowed to influence
+the editor's vertical layout structure. The ones provided as
+functions are called _after_ the new viewport has been computed,
+and thus **must not** introduce block widgets or replacing
+decorations that cover line breaks.
+
+If you want decorated ranges to behave like atomic units for
+cursor motion and deletion purposes, also provide the range set
+containing the decorations to
+[`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
+*/
+EditorView.decorations = decorations;
+/**
+Facet that works much like
+[`decorations`](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), but puts its
+inputs at the very bottom of the precedence stack, meaning mark
+decorations provided here will only be split by other, partially
+overlapping \`outerDecorations\` ranges, and wrap around all
+regular decorations. Use this for mark elements that should, as
+much as possible, remain in one piece.
+*/
+EditorView.outerDecorations = outerDecorations;
+/**
+Used to provide ranges that should be treated as atoms as far as
+cursor motion is concerned. This causes methods like
+[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
+[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
+commands built on top of them) to skip across such regions when
+a selection endpoint would enter them. This does _not_ prevent
+direct programmatic [selection
+updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
+regions.
+*/
+EditorView.atomicRanges = atomicRanges;
+/**
+When range decorations add a `unicode-bidi: isolate` style, they
+should also include a
+[`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property
+in their decoration spec, and be exposed through this facet, so
+that the editor can compute the proper text order. (Other values
+for `unicode-bidi`, except of course `normal`, are not
+supported.)
+*/
+EditorView.bidiIsolatedRanges = bidiIsolatedRanges;
+/**
+Facet that allows extensions to provide additional scroll
+margins (space around the sides of the scrolling element that
+should be considered invisible). This can be useful when the
+plugin introduces elements that cover part of that element (for
+example a horizontally fixed gutter).
+*/
+EditorView.scrollMargins = scrollMargins;
+/**
+This facet records whether a dark theme is active. The extension
+returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
+includes an instance of this when the `dark` option is set to
+true.
+*/
+EditorView.darkTheme = darkTheme;
+/**
+Provides a Content Security Policy nonce to use when creating
+the style sheets for the editor. Holds the empty string when no
+nonce has been provided.
+*/
+EditorView.cspNonce = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : "" });
+/**
+Facet that provides additional DOM attributes for the editor's
+editable DOM element.
+*/
+EditorView.contentAttributes = contentAttributes;
+/**
+Facet that provides DOM attributes for the editor's outer
+element.
+*/
+EditorView.editorAttributes = editorAttributes;
+/**
+An extension that enables line wrapping in the editor (by
+setting CSS `white-space` to `pre-wrap` in the content).
+*/
+EditorView.lineWrapping = /*@__PURE__*/EditorView.contentAttributes.of({ "class": "cm-lineWrapping" });
+/**
+State effect used to include screen reader announcements in a
+transaction. These will be added to the DOM in a visually hidden
+element with `aria-live="polite"` set, and should be used to
+describe effects that are visually obvious but may not be
+noticed by screen reader users (such as moving to the next
+search match).
+*/
+EditorView.announce = /*@__PURE__*/StateEffect.define();
+// Maximum line length for which we compute accurate bidi info
+const MaxBidiLine = 4096;
+const BadMeasure = {};
+class CachedOrder {
+    constructor(from, to, dir, isolates, fresh, order) {
+        this.from = from;
+        this.to = to;
+        this.dir = dir;
+        this.isolates = isolates;
+        this.fresh = fresh;
+        this.order = order;
+    }
+    static update(cache, changes) {
+        if (changes.empty && !cache.some(c => c.fresh))
+            return cache;
+        let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction.LTR;
+        for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
+            let entry = cache[i];
+            if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
+                result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.isolates, false, entry.order));
+        }
+        return result;
+    }
+}
+function attrsFromFacet(view, facet, base) {
+    for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
+        let source = sources[i], value = typeof source == "function" ? source(view) : source;
+        if (value)
+            combineAttrs(value, base);
+    }
+    return base;
+}
+
+const currentPlatform = browser.mac ? "mac" : browser.windows ? "win" : browser.linux ? "linux" : "key";
+function normalizeKeyName(name, platform) {
+    const parts = name.split(/-(?!$)/);
+    let result = parts[parts.length - 1];
+    if (result == "Space")
+        result = " ";
+    let alt, ctrl, shift, meta;
+    for (let i = 0; i < parts.length - 1; ++i) {
+        const mod = parts[i];
+        if (/^(cmd|meta|m)$/i.test(mod))
+            meta = true;
+        else if (/^a(lt)?$/i.test(mod))
+            alt = true;
+        else if (/^(c|ctrl|control)$/i.test(mod))
+            ctrl = true;
+        else if (/^s(hift)?$/i.test(mod))
+            shift = true;
+        else if (/^mod$/i.test(mod)) {
+            if (platform == "mac")
+                meta = true;
+            else
+                ctrl = true;
+        }
+        else
+            throw new Error("Unrecognized modifier name: " + mod);
+    }
+    if (alt)
+        result = "Alt-" + result;
+    if (ctrl)
+        result = "Ctrl-" + result;
+    if (meta)
+        result = "Meta-" + result;
+    if (shift)
+        result = "Shift-" + result;
+    return result;
+}
+function modifiers(name, event, shift) {
+    if (event.altKey)
+        name = "Alt-" + name;
+    if (event.ctrlKey)
+        name = "Ctrl-" + name;
+    if (event.metaKey)
+        name = "Meta-" + name;
+    if (shift !== false && event.shiftKey)
+        name = "Shift-" + name;
+    return name;
+}
+const handleKeyEvents = /*@__PURE__*/Prec.default(/*@__PURE__*/EditorView.domEventHandlers({
+    keydown(event, view) {
+        return runHandlers(getKeymap(view.state), event, view, "editor");
+    }
+}));
+/**
+Facet used for registering keymaps.
+
+You can add multiple keymaps to an editor. Their priorities
+determine their precedence (the ones specified early or with high
+priority get checked first). When a handler has returned `true`
+for a given key, no further handlers are called.
+*/
+const keymap = /*@__PURE__*/Facet.define({ enables: handleKeyEvents });
+const Keymaps = /*@__PURE__*/new WeakMap();
+// This is hidden behind an indirection, rather than directly computed
+// by the facet, to keep internal types out of the facet's type.
+function getKeymap(state) {
+    let bindings = state.facet(keymap);
+    let map = Keymaps.get(bindings);
+    if (!map)
+        Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));
+    return map;
+}
+/**
+Run the key handlers registered for a given scope. The event
+object should be a `"keydown"` event. Returns true if any of the
+handlers handled it.
+*/
+function runScopeHandlers(view, event, scope) {
+    return runHandlers(getKeymap(view.state), event, view, scope);
+}
+let storedPrefix = null;
+const PrefixTimeout = 4000;
+function buildKeymap(bindings, platform = currentPlatform) {
+    let bound = Object.create(null);
+    let isPrefix = Object.create(null);
+    let checkPrefix = (name, is) => {
+        let current = isPrefix[name];
+        if (current == null)
+            isPrefix[name] = is;
+        else if (current != is)
+            throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
+    };
+    let add = (scope, key, command, preventDefault, stopPropagation) => {
+        var _a, _b;
+        let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
+        let parts = key.split(/ (?!$)/).map(k => normalizeKeyName(k, platform));
+        for (let i = 1; i < parts.length; i++) {
+            let prefix = parts.slice(0, i).join(" ");
+            checkPrefix(prefix, true);
+            if (!scopeObj[prefix])
+                scopeObj[prefix] = {
+                    preventDefault: true,
+                    stopPropagation: false,
+                    run: [(view) => {
+                            let ourObj = storedPrefix = { view, prefix, scope };
+                            setTimeout(() => { if (storedPrefix == ourObj)
+                                storedPrefix = null; }, PrefixTimeout);
+                            return true;
+                        }]
+                };
+        }
+        let full = parts.join(" ");
+        checkPrefix(full, false);
+        let binding = scopeObj[full] || (scopeObj[full] = {
+            preventDefault: false,
+            stopPropagation: false,
+            run: ((_b = (_a = scopeObj._any) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.slice()) || []
+        });
+        if (command)
+            binding.run.push(command);
+        if (preventDefault)
+            binding.preventDefault = true;
+        if (stopPropagation)
+            binding.stopPropagation = true;
+    };
+    for (let b of bindings) {
+        let scopes = b.scope ? b.scope.split(" ") : ["editor"];
+        if (b.any)
+            for (let scope of scopes) {
+                let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
+                if (!scopeObj._any)
+                    scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };
+                let { any } = b;
+                for (let key in scopeObj)
+                    scopeObj[key].run.push(view => any(view, currentKeyEvent));
+            }
+        let name = b[platform] || b.key;
+        if (!name)
+            continue;
+        for (let scope of scopes) {
+            add(scope, name, b.run, b.preventDefault, b.stopPropagation);
+            if (b.shift)
+                add(scope, "Shift-" + name, b.shift, b.preventDefault, b.stopPropagation);
+        }
+    }
+    return bound;
+}
+let currentKeyEvent = null;
+function runHandlers(map, event, view, scope) {
+    currentKeyEvent = event;
+    let name = keyName(event);
+    let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != " ";
+    let prefix = "", handled = false, prevented = false, stopPropagation = false;
+    if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
+        prefix = storedPrefix.prefix + " ";
+        if (modifierCodes.indexOf(event.keyCode) < 0) {
+            prevented = true;
+            storedPrefix = null;
+        }
+    }
+    let ran = new Set;
+    let runFor = (binding) => {
+        if (binding) {
+            for (let cmd of binding.run)
+                if (!ran.has(cmd)) {
+                    ran.add(cmd);
+                    if (cmd(view)) {
+                        if (binding.stopPropagation)
+                            stopPropagation = true;
+                        return true;
+                    }
+                }
+            if (binding.preventDefault) {
+                if (binding.stopPropagation)
+                    stopPropagation = true;
+                prevented = true;
+            }
+        }
+        return false;
+    };
+    let scopeObj = map[scope], baseName, shiftName;
+    if (scopeObj) {
+        if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {
+            handled = true;
+        }
+        else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
+            // Ctrl-Alt may be used for AltGr on Windows
+            !(browser.windows && event.ctrlKey && event.altKey) &&
+            (baseName = base[event.keyCode]) && baseName != name) {
+            if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
+                handled = true;
+            }
+            else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName &&
+                runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) {
+                handled = true;
+            }
+        }
+        else if (isChar && event.shiftKey &&
+            runFor(scopeObj[prefix + modifiers(name, event, true)])) {
+            handled = true;
+        }
+        if (!handled && runFor(scopeObj._any))
+            handled = true;
+    }
+    if (prevented)
+        handled = true;
+    if (handled && stopPropagation)
+        event.stopPropagation();
+    currentKeyEvent = null;
+    return handled;
+}
+
+/**
+Implementation of [`LayerMarker`](https://codemirror.net/6/docs/ref/#view.LayerMarker) that creates
+a rectangle at a given set of coordinates.
+*/
+class RectangleMarker {
+    /**
+    Create a marker with the given class and dimensions. If `width`
+    is null, the DOM element will get no width style.
+    */
+    constructor(className, 
+    /**
+    The left position of the marker (in pixels, document-relative).
+    */
+    left, 
+    /**
+    The top position of the marker.
+    */
+    top, 
+    /**
+    The width of the marker, or null if it shouldn't get a width assigned.
+    */
+    width, 
+    /**
+    The height of the marker.
+    */
+    height) {
+        this.className = className;
+        this.left = left;
+        this.top = top;
+        this.width = width;
+        this.height = height;
+    }
+    draw() {
+        let elt = document.createElement("div");
+        elt.className = this.className;
+        this.adjust(elt);
+        return elt;
+    }
+    update(elt, prev) {
+        if (prev.className != this.className)
+            return false;
+        this.adjust(elt);
+        return true;
+    }
+    adjust(elt) {
+        elt.style.left = this.left + "px";
+        elt.style.top = this.top + "px";
+        if (this.width != null)
+            elt.style.width = this.width + "px";
+        elt.style.height = this.height + "px";
+    }
+    eq(p) {
+        return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&
+            this.className == p.className;
+    }
+    /**
+    Create a set of rectangles for the given selection range,
+    assigning them theclass`className`. Will create a single
+    rectangle for empty ranges, and a set of selection-style
+    rectangles covering the range's content (in a bidi-aware
+    way) for non-empty ones.
+    */
+    static forRange(view, className, range) {
+        if (range.empty) {
+            let pos = view.coordsAtPos(range.head, range.assoc || 1);
+            if (!pos)
+                return [];
+            let base = getBase(view);
+            return [new RectangleMarker(className, pos.left - base.left, pos.top - base.top, null, pos.bottom - pos.top)];
+        }
+        else {
+            return rectanglesForRange(view, className, range);
+        }
+    }
+}
+function getBase(view) {
+    let rect = view.scrollDOM.getBoundingClientRect();
+    let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth * view.scaleX;
+    return { left: left - view.scrollDOM.scrollLeft * view.scaleX, top: rect.top - view.scrollDOM.scrollTop * view.scaleY };
+}
+function wrappedLine(view, pos, side, inside) {
+    let coords = view.coordsAtPos(pos, side * 2);
+    if (!coords)
+        return inside;
+    let editorRect = view.dom.getBoundingClientRect();
+    let y = (coords.top + coords.bottom) / 2;
+    let left = view.posAtCoords({ x: editorRect.left + 1, y });
+    let right = view.posAtCoords({ x: editorRect.right - 1, y });
+    if (left == null || right == null)
+        return inside;
+    return { from: Math.max(inside.from, Math.min(left, right)), to: Math.min(inside.to, Math.max(left, right)) };
+}
+function rectanglesForRange(view, className, range) {
+    if (range.to <= view.viewport.from || range.from >= view.viewport.to)
+        return [];
+    let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);
+    let ltr = view.textDirection == Direction.LTR;
+    let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);
+    let lineElt = content.querySelector(".cm-line"), lineStyle = lineElt && window.getComputedStyle(lineElt);
+    let leftSide = contentRect.left +
+        (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
+    let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
+    let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
+    let visualStart = startBlock.type == BlockType.Text ? startBlock : null;
+    let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;
+    if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
+        visualStart = wrappedLine(view, from, 1, visualStart);
+    if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))
+        visualEnd = wrappedLine(view, to, -1, visualEnd);
+    if (visualStart && visualEnd && visualStart.from == visualEnd.from && visualStart.to == visualEnd.to) {
+        return pieces(drawForLine(range.from, range.to, visualStart));
+    }
+    else {
+        let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
+        let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
+        let between = [];
+        if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||
+            startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)
+            between.push(piece(leftSide, top.bottom, rightSide, bottom.top));
+        else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text)
+            top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
+        return pieces(top).concat(between).concat(pieces(bottom));
+    }
+    function piece(left, top, right, bottom) {
+        return new RectangleMarker(className, left - base.left, top - base.top, right - left, bottom - top);
+    }
+    function pieces({ top, bottom, horizontal }) {
+        let pieces = [];
+        for (let i = 0; i < horizontal.length; i += 2)
+            pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));
+        return pieces;
+    }
+    // Gets passed from/to in line-local positions
+    function drawForLine(from, to, line) {
+        let top = 1e9, bottom = -1e9, horizontal = [];
+        function addSpan(from, fromOpen, to, toOpen, dir) {
+            // Passing 2/-2 is a kludge to force the view to return
+            // coordinates on the proper side of block widgets, since
+            // normalizing the side there, though appropriate for most
+            // coordsAtPos queries, would break selection drawing.
+            let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));
+            let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));
+            if (!fromCoords || !toCoords)
+                return;
+            top = Math.min(fromCoords.top, toCoords.top, top);
+            bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);
+            if (dir == Direction.LTR)
+                horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);
+            else
+                horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);
+        }
+        let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;
+        // Split the range by visible range and document line
+        for (let r of view.visibleRanges)
+            if (r.to > start && r.from < end) {
+                for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {
+                    let docLine = view.state.doc.lineAt(pos);
+                    for (let span of view.bidiSpans(docLine)) {
+                        let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;
+                        if (spanFrom >= endPos)
+                            break;
+                        if (spanTo > pos)
+                            addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);
+                    }
+                    pos = docLine.to + 1;
+                    if (pos >= endPos)
+                        break;
+                }
+            }
+        if (horizontal.length == 0)
+            addSpan(start, from == null, end, to == null, view.textDirection);
+        return { top, bottom, horizontal };
+    }
+    function drawForWidget(block, top) {
+        let y = contentRect.top + (top ? block.top : block.bottom);
+        return { top: y, bottom: y, horizontal: [] };
+    }
+}
+function sameMarker(a, b) {
+    return a.constructor == b.constructor && a.eq(b);
+}
+class LayerView {
+    constructor(view, layer) {
+        this.view = view;
+        this.layer = layer;
+        this.drawn = [];
+        this.scaleX = 1;
+        this.scaleY = 1;
+        this.measureReq = { read: this.measure.bind(this), write: this.draw.bind(this) };
+        this.dom = view.scrollDOM.appendChild(document.createElement("div"));
+        this.dom.classList.add("cm-layer");
+        if (layer.above)
+            this.dom.classList.add("cm-layer-above");
+        if (layer.class)
+            this.dom.classList.add(layer.class);
+        this.scale();
+        this.dom.setAttribute("aria-hidden", "true");
+        this.setOrder(view.state);
+        view.requestMeasure(this.measureReq);
+        if (layer.mount)
+            layer.mount(this.dom, view);
+    }
+    update(update) {
+        if (update.startState.facet(layerOrder) != update.state.facet(layerOrder))
+            this.setOrder(update.state);
+        if (this.layer.update(update, this.dom) || update.geometryChanged) {
+            this.scale();
+            update.view.requestMeasure(this.measureReq);
+        }
+    }
+    docViewUpdate(view) {
+        if (this.layer.updateOnDocViewUpdate !== false)
+            view.requestMeasure(this.measureReq);
+    }
+    setOrder(state) {
+        let pos = 0, order = state.facet(layerOrder);
+        while (pos < order.length && order[pos] != this.layer)
+            pos++;
+        this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - pos);
+    }
+    measure() {
+        return this.layer.markers(this.view);
+    }
+    scale() {
+        let { scaleX, scaleY } = this.view;
+        if (scaleX != this.scaleX || scaleY != this.scaleY) {
+            this.scaleX = scaleX;
+            this.scaleY = scaleY;
+            this.dom.style.transform = `scale(${1 / scaleX}, ${1 / scaleY})`;
+        }
+    }
+    draw(markers) {
+        if (markers.length != this.drawn.length || markers.some((p, i) => !sameMarker(p, this.drawn[i]))) {
+            let old = this.dom.firstChild, oldI = 0;
+            for (let marker of markers) {
+                if (marker.update && old && marker.constructor && this.drawn[oldI].constructor &&
+                    marker.update(old, this.drawn[oldI])) {
+                    old = old.nextSibling;
+                    oldI++;
+                }
+                else {
+                    this.dom.insertBefore(marker.draw(), old);
+                }
+            }
+            while (old) {
+                let next = old.nextSibling;
+                old.remove();
+                old = next;
+            }
+            this.drawn = markers;
+        }
+    }
+    destroy() {
+        if (this.layer.destroy)
+            this.layer.destroy(this.dom, this.view);
+        this.dom.remove();
+    }
+}
+const layerOrder = /*@__PURE__*/Facet.define();
+/**
+Define a layer.
+*/
+function layer(config) {
+    return [
+        ViewPlugin.define(v => new LayerView(v, config)),
+        layerOrder.of(config)
+    ];
+}
+
+const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
+const selectionConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        return combineConfig(configs, {
+            cursorBlinkRate: 1200,
+            drawRangeCursor: true
+        }, {
+            cursorBlinkRate: (a, b) => Math.min(a, b),
+            drawRangeCursor: (a, b) => a || b
+        });
+    }
+});
+/**
+Returns an extension that hides the browser's native selection and
+cursor, replacing the selection with a background behind the text
+(with the `cm-selectionBackground` class), and the
+cursors with elements overlaid over the code (using
+`cm-cursor-primary` and `cm-cursor-secondary`).
+
+This allows the editor to display secondary selection ranges, and
+tends to produce a type of selection more in line with that users
+expect in a text editor (the native selection styling will often
+leave gaps between lines and won't fill the horizontal space after
+a line when the selection continues past it).
+
+It does have a performance cost, in that it requires an extra DOM
+layout cycle for many updates (the selection is drawn based on DOM
+layout information that's only available after laying out the
+content).
+*/
+function drawSelection(config = {}) {
+    return [
+        selectionConfig.of(config),
+        cursorLayer,
+        selectionLayer,
+        hideNativeSelection,
+        nativeSelectionHidden.of(true)
+    ];
+}
+function configChanged(update) {
+    return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
+}
+const cursorLayer = /*@__PURE__*/layer({
+    above: true,
+    markers(view) {
+        let { state } = view, conf = state.facet(selectionConfig);
+        let cursors = [];
+        for (let r of state.selection.ranges) {
+            let prim = r == state.selection.main;
+            if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
+                let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
+                let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
+                for (let piece of RectangleMarker.forRange(view, className, cursor))
+                    cursors.push(piece);
+            }
+        }
+        return cursors;
+    },
+    update(update, dom) {
+        if (update.transactions.some(tr => tr.selection))
+            dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
+        let confChange = configChanged(update);
+        if (confChange)
+            setBlinkRate(update.state, dom);
+        return update.docChanged || update.selectionSet || confChange;
+    },
+    mount(dom, view) {
+        setBlinkRate(view.state, dom);
+    },
+    class: "cm-cursorLayer"
+});
+function setBlinkRate(state, dom) {
+    dom.style.animationDuration = state.facet(selectionConfig).cursorBlinkRate + "ms";
+}
+const selectionLayer = /*@__PURE__*/layer({
+    above: false,
+    markers(view) {
+        return view.state.selection.ranges.map(r => r.empty ? [] : RectangleMarker.forRange(view, "cm-selectionBackground", r))
+            .reduce((a, b) => a.concat(b));
+    },
+    update(update, dom) {
+        return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);
+    },
+    class: "cm-selectionLayer"
+});
+const themeSpec = {
+    ".cm-line": {
+        "& ::selection, &::selection": { backgroundColor: "transparent !important" },
+    },
+    ".cm-content": {
+        "& :focus": {
+            caretColor: "initial !important",
+            "&::selection, & ::selection": {
+                backgroundColor: "Highlight !important"
+            }
+        }
+    }
+};
+if (CanHidePrimary)
+    themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
+const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));
+
+const setDropCursorPos = /*@__PURE__*/StateEffect.define({
+    map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
+});
+const dropCursorPos = /*@__PURE__*/StateField.define({
+    create() { return null; },
+    update(pos, tr) {
+        if (pos != null)
+            pos = tr.changes.mapPos(pos);
+        return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);
+    }
+});
+const drawDropCursor = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.view = view;
+        this.cursor = null;
+        this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };
+    }
+    update(update) {
+        var _a;
+        let cursorPos = update.state.field(dropCursorPos);
+        if (cursorPos == null) {
+            if (this.cursor != null) {
+                (_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();
+                this.cursor = null;
+            }
+        }
+        else {
+            if (!this.cursor) {
+                this.cursor = this.view.scrollDOM.appendChild(document.createElement("div"));
+                this.cursor.className = "cm-dropCursor";
+            }
+            if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)
+                this.view.requestMeasure(this.measureReq);
+        }
+    }
+    readPos() {
+        let { view } = this;
+        let pos = view.state.field(dropCursorPos);
+        let rect = pos != null && view.coordsAtPos(pos);
+        if (!rect)
+            return null;
+        let outer = view.scrollDOM.getBoundingClientRect();
+        return {
+            left: rect.left - outer.left + view.scrollDOM.scrollLeft * view.scaleX,
+            top: rect.top - outer.top + view.scrollDOM.scrollTop * view.scaleY,
+            height: rect.bottom - rect.top
+        };
+    }
+    drawCursor(pos) {
+        if (this.cursor) {
+            let { scaleX, scaleY } = this.view;
+            if (pos) {
+                this.cursor.style.left = pos.left / scaleX + "px";
+                this.cursor.style.top = pos.top / scaleY + "px";
+                this.cursor.style.height = pos.height / scaleY + "px";
+            }
+            else {
+                this.cursor.style.left = "-100000px";
+            }
+        }
+    }
+    destroy() {
+        if (this.cursor)
+            this.cursor.remove();
+    }
+    setDropPos(pos) {
+        if (this.view.state.field(dropCursorPos) != pos)
+            this.view.dispatch({ effects: setDropCursorPos.of(pos) });
+    }
+}, {
+    eventObservers: {
+        dragover(event) {
+            this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));
+        },
+        dragleave(event) {
+            if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))
+                this.setDropPos(null);
+        },
+        dragend() {
+            this.setDropPos(null);
+        },
+        drop() {
+            this.setDropPos(null);
+        }
+    }
+});
+/**
+Draws a cursor at the current drop position when something is
+dragged over the editor.
+*/
+function dropCursor() {
+    return [dropCursorPos, drawDropCursor];
+}
+
+function iterMatches(doc, re, from, to, f) {
+    re.lastIndex = 0;
+    for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {
+        if (!cursor.lineBreak)
+            while (m = re.exec(cursor.value))
+                f(pos + m.index, m);
+    }
+}
+function matchRanges(view, maxLength) {
+    let visible = view.visibleRanges;
+    if (visible.length == 1 && visible[0].from == view.viewport.from &&
+        visible[0].to == view.viewport.to)
+        return visible;
+    let result = [];
+    for (let { from, to } of visible) {
+        from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);
+        to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);
+        if (result.length && result[result.length - 1].to >= from)
+            result[result.length - 1].to = to;
+        else
+            result.push({ from, to });
+    }
+    return result;
+}
+/**
+Helper class used to make it easier to maintain decorations on
+visible code that matches a given regular expression. To be used
+in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
+represent a matching configuration.
+*/
+class MatchDecorator {
+    /**
+    Create a decorator.
+    */
+    constructor(config) {
+        const { regexp, decoration, decorate, boundary, maxLength = 1000 } = config;
+        if (!regexp.global)
+            throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
+        this.regexp = regexp;
+        if (decorate) {
+            this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);
+        }
+        else if (typeof decoration == "function") {
+            this.addMatch = (match, view, from, add) => {
+                let deco = decoration(match, view, from);
+                if (deco)
+                    add(from, from + match[0].length, deco);
+            };
+        }
+        else if (decoration) {
+            this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);
+        }
+        else {
+            throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
+        }
+        this.boundary = boundary;
+        this.maxLength = maxLength;
+    }
+    /**
+    Compute the full set of decorations for matches in the given
+    view's viewport. You'll want to call this when initializing your
+    plugin.
+    */
+    createDeco(view) {
+        let build = new RangeSetBuilder(), add = build.add.bind(build);
+        for (let { from, to } of matchRanges(view, this.maxLength))
+            iterMatches(view.state.doc, this.regexp, from, to, (from, m) => this.addMatch(m, view, from, add));
+        return build.finish();
+    }
+    /**
+    Update a set of decorations for a view update. `deco` _must_ be
+    the set of decorations produced by _this_ `MatchDecorator` for
+    the view state before the update.
+    */
+    updateDeco(update, deco) {
+        let changeFrom = 1e9, changeTo = -1;
+        if (update.docChanged)
+            update.changes.iterChanges((_f, _t, from, to) => {
+                if (to > update.view.viewport.from && from < update.view.viewport.to) {
+                    changeFrom = Math.min(from, changeFrom);
+                    changeTo = Math.max(to, changeTo);
+                }
+            });
+        if (update.viewportMoved || changeTo - changeFrom > 1000)
+            return this.createDeco(update.view);
+        if (changeTo > -1)
+            return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);
+        return deco;
+    }
+    updateRange(view, deco, updateFrom, updateTo) {
+        for (let r of view.visibleRanges) {
+            let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);
+            if (to > from) {
+                let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;
+                let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);
+                if (this.boundary) {
+                    for (; from > fromLine.from; from--)
+                        if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {
+                            start = from;
+                            break;
+                        }
+                    for (; to < toLine.to; to++)
+                        if (this.boundary.test(toLine.text[to - toLine.from])) {
+                            end = to;
+                            break;
+                        }
+                }
+                let ranges = [], m;
+                let add = (from, to, deco) => ranges.push(deco.range(from, to));
+                if (fromLine == toLine) {
+                    this.regexp.lastIndex = start - fromLine.from;
+                    while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from)
+                        this.addMatch(m, view, m.index + fromLine.from, add);
+                }
+                else {
+                    iterMatches(view.state.doc, this.regexp, start, end, (from, m) => this.addMatch(m, view, from, add));
+                }
+                deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });
+            }
+        }
+        return deco;
+    }
+}
+
+const UnicodeRegexpSupport = /x/.unicode != null ? "gu" : "g";
+const Specials = /*@__PURE__*/new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]", UnicodeRegexpSupport);
+const Names = {
+    0: "null",
+    7: "bell",
+    8: "backspace",
+    10: "newline",
+    11: "vertical tab",
+    13: "carriage return",
+    27: "escape",
+    8203: "zero width space",
+    8204: "zero width non-joiner",
+    8205: "zero width joiner",
+    8206: "left-to-right mark",
+    8207: "right-to-left mark",
+    8232: "line separator",
+    8237: "left-to-right override",
+    8238: "right-to-left override",
+    8294: "left-to-right isolate",
+    8295: "right-to-left isolate",
+    8297: "pop directional isolate",
+    8233: "paragraph separator",
+    65279: "zero width no-break space",
+    65532: "object replacement"
+};
+let _supportsTabSize = null;
+function supportsTabSize() {
+    var _a;
+    if (_supportsTabSize == null && typeof document != "undefined" && document.body) {
+        let styles = document.body.style;
+        _supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;
+    }
+    return _supportsTabSize || false;
+}
+const specialCharConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        let config = combineConfig(configs, {
+            render: null,
+            specialChars: Specials,
+            addSpecialChars: null
+        });
+        if (config.replaceTabs = !supportsTabSize())
+            config.specialChars = new RegExp("\t|" + config.specialChars.source, UnicodeRegexpSupport);
+        if (config.addSpecialChars)
+            config.specialChars = new RegExp(config.specialChars.source + "|" + config.addSpecialChars.source, UnicodeRegexpSupport);
+        return config;
+    }
+});
+/**
+Returns an extension that installs highlighting of special
+characters.
+*/
+function highlightSpecialChars(
+/**
+Configuration options.
+*/
+config = {}) {
+    return [specialCharConfig.of(config), specialCharPlugin()];
+}
+let _plugin = null;
+function specialCharPlugin() {
+    return _plugin || (_plugin = ViewPlugin.fromClass(class {
+        constructor(view) {
+            this.view = view;
+            this.decorations = Decoration.none;
+            this.decorationCache = Object.create(null);
+            this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));
+            this.decorations = this.decorator.createDeco(view);
+        }
+        makeDecorator(conf) {
+            return new MatchDecorator({
+                regexp: conf.specialChars,
+                decoration: (m, view, pos) => {
+                    let { doc } = view.state;
+                    let code = codePointAt(m[0], 0);
+                    if (code == 9) {
+                        let line = doc.lineAt(pos);
+                        let size = view.state.tabSize, col = countColumn(line.text, size, pos - line.from);
+                        return Decoration.replace({
+                            widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth / this.view.scaleX)
+                        });
+                    }
+                    return this.decorationCache[code] ||
+                        (this.decorationCache[code] = Decoration.replace({ widget: new SpecialCharWidget(conf, code) }));
+                },
+                boundary: conf.replaceTabs ? undefined : /[^]/
+            });
+        }
+        update(update) {
+            let conf = update.state.facet(specialCharConfig);
+            if (update.startState.facet(specialCharConfig) != conf) {
+                this.decorator = this.makeDecorator(conf);
+                this.decorations = this.decorator.createDeco(update.view);
+            }
+            else {
+                this.decorations = this.decorator.updateDeco(update, this.decorations);
+            }
+        }
+    }, {
+        decorations: v => v.decorations
+    }));
+}
+const DefaultPlaceholder = "\u2022";
+// Assigns placeholder characters from the Control Pictures block to
+// ASCII control characters
+function placeholder$1(code) {
+    if (code >= 32)
+        return DefaultPlaceholder;
+    if (code == 10)
+        return "\u2424";
+    return String.fromCharCode(9216 + code);
+}
+class SpecialCharWidget extends WidgetType {
+    constructor(options, code) {
+        super();
+        this.options = options;
+        this.code = code;
+    }
+    eq(other) { return other.code == this.code; }
+    toDOM(view) {
+        let ph = placeholder$1(this.code);
+        let desc = view.state.phrase("Control character") + " " + (Names[this.code] || "0x" + this.code.toString(16));
+        let custom = this.options.render && this.options.render(this.code, desc, ph);
+        if (custom)
+            return custom;
+        let span = document.createElement("span");
+        span.textContent = ph;
+        span.title = desc;
+        span.setAttribute("aria-label", desc);
+        span.className = "cm-specialChar";
+        return span;
+    }
+    ignoreEvent() { return false; }
+}
+class TabWidget extends WidgetType {
+    constructor(width) {
+        super();
+        this.width = width;
+    }
+    eq(other) { return other.width == this.width; }
+    toDOM() {
+        let span = document.createElement("span");
+        span.textContent = "\t";
+        span.className = "cm-tab";
+        span.style.width = this.width + "px";
+        return span;
+    }
+    ignoreEvent() { return false; }
+}
+
+/**
+Mark lines that have a cursor on them with the `"cm-activeLine"`
+DOM class.
+*/
+function highlightActiveLine() {
+    return activeLineHighlighter;
+}
+const lineDeco = /*@__PURE__*/Decoration.line({ class: "cm-activeLine" });
+const activeLineHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.decorations = this.getDeco(view);
+    }
+    update(update) {
+        if (update.docChanged || update.selectionSet)
+            this.decorations = this.getDeco(update.view);
+    }
+    getDeco(view) {
+        let lastLineStart = -1, deco = [];
+        for (let r of view.state.selection.ranges) {
+            let line = view.lineBlockAt(r.head);
+            if (line.from > lastLineStart) {
+                deco.push(lineDeco.range(line.from));
+                lastLineStart = line.from;
+            }
+        }
+        return Decoration.set(deco);
+    }
+}, {
+    decorations: v => v.decorations
+});
+
+// Don't compute precise column positions for line offsets above this
+// (since it could get expensive). Assume offset==column for them.
+const MaxOff = 2000;
+function rectangleFor(state, a, b) {
+    let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);
+    let ranges = [];
+    if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {
+        let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);
+        for (let i = startLine; i <= endLine; i++) {
+            let line = state.doc.line(i);
+            if (line.length <= endOff)
+                ranges.push(EditorSelection.range(line.from + startOff, line.to + endOff));
+        }
+    }
+    else {
+        let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);
+        for (let i = startLine; i <= endLine; i++) {
+            let line = state.doc.line(i);
+            let start = findColumn(line.text, startCol, state.tabSize, true);
+            if (start < 0) {
+                ranges.push(EditorSelection.cursor(line.to));
+            }
+            else {
+                let end = findColumn(line.text, endCol, state.tabSize);
+                ranges.push(EditorSelection.range(line.from + start, line.from + end));
+            }
+        }
+    }
+    return ranges;
+}
+function absoluteColumn(view, x) {
+    let ref = view.coordsAtPos(view.viewport.from);
+    return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;
+}
+function getPos(view, event) {
+    let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+    let line = view.state.doc.lineAt(offset), off = offset - line.from;
+    let col = off > MaxOff ? -1
+        : off == line.length ? absoluteColumn(view, event.clientX)
+            : countColumn(line.text, view.state.tabSize, offset - line.from);
+    return { line: line.number, col, off };
+}
+function rectangleSelectionStyle(view, event) {
+    let start = getPos(view, event), startSel = view.state.selection;
+    if (!start)
+        return null;
+    return {
+        update(update) {
+            if (update.docChanged) {
+                let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);
+                let newLine = update.state.doc.lineAt(newStart);
+                start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };
+                startSel = startSel.map(update.changes);
+            }
+        },
+        get(event, _extend, multiple) {
+            let cur = getPos(view, event);
+            if (!cur)
+                return startSel;
+            let ranges = rectangleFor(view.state, start, cur);
+            if (!ranges.length)
+                return startSel;
+            if (multiple)
+                return EditorSelection.create(ranges.concat(startSel.ranges));
+            else
+                return EditorSelection.create(ranges);
+        }
+    };
+}
+/**
+Create an extension that enables rectangular selections. By
+default, it will react to left mouse drag with the Alt key held
+down. When such a selection occurs, the text within the rectangle
+that was dragged over will be selected, as one selection
+[range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.
+*/
+function rectangularSelection(options) {
+    let filter = (e => e.altKey && e.button == 0);
+    return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
+}
+const keys = {
+    Alt: [18, e => !!e.altKey],
+    Control: [17, e => !!e.ctrlKey],
+    Shift: [16, e => !!e.shiftKey],
+    Meta: [91, e => !!e.metaKey]
+};
+const showCrosshair = { style: "cursor: crosshair" };
+/**
+Returns an extension that turns the pointer cursor into a
+crosshair when a given modifier key, defaulting to Alt, is held
+down. Can serve as a visual hint that rectangular selection is
+going to happen when paired with
+[`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).
+*/
+function crosshairCursor(options = {}) {
+    let [code, getter] = keys[options.key || "Alt"];
+    let plugin = ViewPlugin.fromClass(class {
+        constructor(view) {
+            this.view = view;
+            this.isDown = false;
+        }
+        set(isDown) {
+            if (this.isDown != isDown) {
+                this.isDown = isDown;
+                this.view.update([]);
+            }
+        }
+    }, {
+        eventObservers: {
+            keydown(e) {
+                this.set(e.keyCode == code || getter(e));
+            },
+            keyup(e) {
+                if (e.keyCode == code || !getter(e))
+                    this.set(false);
+            },
+            mousemove(e) {
+                this.set(getter(e));
+            }
+        }
+    });
+    return [
+        plugin,
+        EditorView.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })
+    ];
+}
+
+const Outside = "-10000px";
+class TooltipViewManager {
+    constructor(view, facet, createTooltipView, removeTooltipView) {
+        this.facet = facet;
+        this.createTooltipView = createTooltipView;
+        this.removeTooltipView = removeTooltipView;
+        this.input = view.state.facet(facet);
+        this.tooltips = this.input.filter(t => t);
+        let prev = null;
+        this.tooltipViews = this.tooltips.map(t => prev = createTooltipView(t, prev));
+    }
+    update(update, above) {
+        var _a;
+        let input = update.state.facet(this.facet);
+        let tooltips = input.filter(x => x);
+        if (input === this.input) {
+            for (let t of this.tooltipViews)
+                if (t.update)
+                    t.update(update);
+            return false;
+        }
+        let tooltipViews = [], newAbove = above ? [] : null;
+        for (let i = 0; i < tooltips.length; i++) {
+            let tip = tooltips[i], known = -1;
+            if (!tip)
+                continue;
+            for (let i = 0; i < this.tooltips.length; i++) {
+                let other = this.tooltips[i];
+                if (other && other.create == tip.create)
+                    known = i;
+            }
+            if (known < 0) {
+                tooltipViews[i] = this.createTooltipView(tip, i ? tooltipViews[i - 1] : null);
+                if (newAbove)
+                    newAbove[i] = !!tip.above;
+            }
+            else {
+                let tooltipView = tooltipViews[i] = this.tooltipViews[known];
+                if (newAbove)
+                    newAbove[i] = above[known];
+                if (tooltipView.update)
+                    tooltipView.update(update);
+            }
+        }
+        for (let t of this.tooltipViews)
+            if (tooltipViews.indexOf(t) < 0) {
+                this.removeTooltipView(t);
+                (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
+            }
+        if (above) {
+            newAbove.forEach((val, i) => above[i] = val);
+            above.length = newAbove.length;
+        }
+        this.input = input;
+        this.tooltips = tooltips;
+        this.tooltipViews = tooltipViews;
+        return true;
+    }
+}
+function windowSpace(view) {
+    let { win } = view;
+    return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
+}
+const tooltipConfig = /*@__PURE__*/Facet.define({
+    combine: values => {
+        var _a, _b, _c;
+        return ({
+            position: browser.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
+            parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
+            tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,
+        });
+    }
+});
+const knownHeight = /*@__PURE__*/new WeakMap();
+const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.view = view;
+        this.above = [];
+        this.inView = true;
+        this.madeAbsolute = false;
+        this.lastTransaction = 0;
+        this.measureTimeout = -1;
+        let config = view.state.facet(tooltipConfig);
+        this.position = config.position;
+        this.parent = config.parent;
+        this.classes = view.themeClasses;
+        this.createContainer();
+        this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
+        this.resizeObserver = typeof ResizeObserver == "function" ? new ResizeObserver(() => this.measureSoon()) : null;
+        this.manager = new TooltipViewManager(view, showTooltip, (t, p) => this.createTooltip(t, p), t => {
+            if (this.resizeObserver)
+                this.resizeObserver.unobserve(t.dom);
+            t.dom.remove();
+        });
+        this.above = this.manager.tooltips.map(t => !!t.above);
+        this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
+            if (Date.now() > this.lastTransaction - 50 &&
+                entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
+                this.measureSoon();
+        }, { threshold: [1] }) : null;
+        this.observeIntersection();
+        view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
+        this.maybeMeasure();
+    }
+    createContainer() {
+        if (this.parent) {
+            this.container = document.createElement("div");
+            this.container.style.position = "relative";
+            this.container.className = this.view.themeClasses;
+            this.parent.appendChild(this.container);
+        }
+        else {
+            this.container = this.view.dom;
+        }
+    }
+    observeIntersection() {
+        if (this.intersectionObserver) {
+            this.intersectionObserver.disconnect();
+            for (let tooltip of this.manager.tooltipViews)
+                this.intersectionObserver.observe(tooltip.dom);
+        }
+    }
+    measureSoon() {
+        if (this.measureTimeout < 0)
+            this.measureTimeout = setTimeout(() => {
+                this.measureTimeout = -1;
+                this.maybeMeasure();
+            }, 50);
+    }
+    update(update) {
+        if (update.transactions.length)
+            this.lastTransaction = Date.now();
+        let updated = this.manager.update(update, this.above);
+        if (updated)
+            this.observeIntersection();
+        let shouldMeasure = updated || update.geometryChanged;
+        let newConfig = update.state.facet(tooltipConfig);
+        if (newConfig.position != this.position && !this.madeAbsolute) {
+            this.position = newConfig.position;
+            for (let t of this.manager.tooltipViews)
+                t.dom.style.position = this.position;
+            shouldMeasure = true;
+        }
+        if (newConfig.parent != this.parent) {
+            if (this.parent)
+                this.container.remove();
+            this.parent = newConfig.parent;
+            this.createContainer();
+            for (let t of this.manager.tooltipViews)
+                this.container.appendChild(t.dom);
+            shouldMeasure = true;
+        }
+        else if (this.parent && this.view.themeClasses != this.classes) {
+            this.classes = this.container.className = this.view.themeClasses;
+        }
+        if (shouldMeasure)
+            this.maybeMeasure();
+    }
+    createTooltip(tooltip, prev) {
+        let tooltipView = tooltip.create(this.view);
+        let before = prev ? prev.dom : null;
+        tooltipView.dom.classList.add("cm-tooltip");
+        if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
+            let arrow = document.createElement("div");
+            arrow.className = "cm-tooltip-arrow";
+            tooltipView.dom.appendChild(arrow);
+        }
+        tooltipView.dom.style.position = this.position;
+        tooltipView.dom.style.top = Outside;
+        tooltipView.dom.style.left = "0px";
+        this.container.insertBefore(tooltipView.dom, before);
+        if (tooltipView.mount)
+            tooltipView.mount(this.view);
+        if (this.resizeObserver)
+            this.resizeObserver.observe(tooltipView.dom);
+        return tooltipView;
+    }
+    destroy() {
+        var _a, _b, _c;
+        this.view.win.removeEventListener("resize", this.measureSoon);
+        for (let tooltipView of this.manager.tooltipViews) {
+            tooltipView.dom.remove();
+            (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);
+        }
+        if (this.parent)
+            this.container.remove();
+        (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
+        (_c = this.intersectionObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
+        clearTimeout(this.measureTimeout);
+    }
+    readMeasure() {
+        let scaleX = 1, scaleY = 1, makeAbsolute = false;
+        if (this.position == "fixed" && this.manager.tooltipViews.length) {
+            let { dom } = this.manager.tooltipViews[0];
+            if (browser.gecko) {
+                // Firefox sets the element's `offsetParent` to the
+                // transformed element when a transform interferes with fixed
+                // positioning.
+                makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
+            }
+            else if (dom.style.top == Outside && dom.style.left == "0px") {
+                // On other browsers, we have to awkwardly try and use other
+                // information to detect a transform.
+                let rect = dom.getBoundingClientRect();
+                makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
+            }
+        }
+        if (makeAbsolute || this.position == "absolute") {
+            if (this.parent) {
+                let rect = this.parent.getBoundingClientRect();
+                if (rect.width && rect.height) {
+                    scaleX = rect.width / this.parent.offsetWidth;
+                    scaleY = rect.height / this.parent.offsetHeight;
+                }
+            }
+            else {
+                ({ scaleX, scaleY } = this.view.viewState);
+            }
+        }
+        let visible = this.view.scrollDOM.getBoundingClientRect(), margins = getScrollMargins(this.view);
+        return {
+            visible: {
+                left: visible.left + margins.left, top: visible.top + margins.top,
+                right: visible.right - margins.right, bottom: visible.bottom - margins.bottom
+            },
+            parent: this.parent ? this.container.getBoundingClientRect() : this.view.dom.getBoundingClientRect(),
+            pos: this.manager.tooltips.map((t, i) => {
+                let tv = this.manager.tooltipViews[i];
+                return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
+            }),
+            size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
+            space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
+            scaleX, scaleY, makeAbsolute
+        };
+    }
+    writeMeasure(measured) {
+        var _a;
+        if (measured.makeAbsolute) {
+            this.madeAbsolute = true;
+            this.position = "absolute";
+            for (let t of this.manager.tooltipViews)
+                t.dom.style.position = "absolute";
+        }
+        let { visible, space, scaleX, scaleY } = measured;
+        let others = [];
+        for (let i = 0; i < this.manager.tooltips.length; i++) {
+            let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
+            let pos = measured.pos[i], size = measured.size[i];
+            // Hide tooltips that are outside of the editor.
+            if (!pos || tooltip.clip !== false && (pos.bottom <= Math.max(visible.top, space.top) ||
+                pos.top >= Math.min(visible.bottom, space.bottom) ||
+                pos.right < Math.max(visible.left, space.left) - .1 ||
+                pos.left > Math.min(visible.right, space.right) + .1)) {
+                dom.style.top = Outside;
+                continue;
+            }
+            let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
+            let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
+            let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
+            let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
+            let left = size.width > space.right - space.left
+                ? (ltr ? space.left : space.right - size.width)
+                : ltr ? Math.max(space.left, Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width))
+                    : Math.min(Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x), space.right - width);
+            let above = this.above[i];
+            if (!tooltip.strictSide && (above
+                ? pos.top - height - arrowHeight - offset.y < space.top
+                : pos.bottom + height + arrowHeight + offset.y > space.bottom) &&
+                above == (space.bottom - pos.bottom > pos.top - space.top))
+                above = this.above[i] = !above;
+            let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
+            if (spaceVert < height && tView.resize !== false) {
+                if (spaceVert < this.view.defaultLineHeight) {
+                    dom.style.top = Outside;
+                    continue;
+                }
+                knownHeight.set(tView, height);
+                dom.style.height = (height = spaceVert) / scaleY + "px";
+            }
+            else if (dom.style.height) {
+                dom.style.height = "";
+            }
+            let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
+            let right = left + width;
+            if (tView.overlap !== true)
+                for (let r of others)
+                    if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
+                        top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
+            if (this.position == "absolute") {
+                dom.style.top = (top - measured.parent.top) / scaleY + "px";
+                setLeftStyle(dom, (left - measured.parent.left) / scaleX);
+            }
+            else {
+                dom.style.top = top / scaleY + "px";
+                setLeftStyle(dom, left / scaleX);
+            }
+            if (arrow) {
+                let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);
+                arrow.style.left = arrowLeft / scaleX + "px";
+            }
+            if (tView.overlap !== true)
+                others.push({ left, top, right, bottom: top + height });
+            dom.classList.toggle("cm-tooltip-above", above);
+            dom.classList.toggle("cm-tooltip-below", !above);
+            if (tView.positioned)
+                tView.positioned(measured.space);
+        }
+    }
+    maybeMeasure() {
+        if (this.manager.tooltips.length) {
+            if (this.view.inView)
+                this.view.requestMeasure(this.measureReq);
+            if (this.inView != this.view.inView) {
+                this.inView = this.view.inView;
+                if (!this.inView)
+                    for (let tv of this.manager.tooltipViews)
+                        tv.dom.style.top = Outside;
+            }
+        }
+    }
+}, {
+    eventObservers: {
+        scroll() { this.maybeMeasure(); }
+    }
+});
+function setLeftStyle(elt, value) {
+    let current = parseInt(elt.style.left, 10);
+    if (isNaN(current) || Math.abs(value - current) > 1)
+        elt.style.left = value + "px";
+}
+const baseTheme$4 = /*@__PURE__*/EditorView.baseTheme({
+    ".cm-tooltip": {
+        zIndex: 500,
+        boxSizing: "border-box"
+    },
+    "&light .cm-tooltip": {
+        border: "1px solid #bbb",
+        backgroundColor: "#f5f5f5"
+    },
+    "&light .cm-tooltip-section:not(:first-child)": {
+        borderTop: "1px solid #bbb",
+    },
+    "&dark .cm-tooltip": {
+        backgroundColor: "#333338",
+        color: "white"
+    },
+    ".cm-tooltip-arrow": {
+        height: `${7 /* Arrow.Size */}px`,
+        width: `${7 /* Arrow.Size */ * 2}px`,
+        position: "absolute",
+        zIndex: -1,
+        overflow: "hidden",
+        "&:before, &:after": {
+            content: "''",
+            position: "absolute",
+            width: 0,
+            height: 0,
+            borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
+            borderRight: `${7 /* Arrow.Size */}px solid transparent`,
+        },
+        ".cm-tooltip-above &": {
+            bottom: `-${7 /* Arrow.Size */}px`,
+            "&:before": {
+                borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
+            },
+            "&:after": {
+                borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
+                bottom: "1px"
+            }
+        },
+        ".cm-tooltip-below &": {
+            top: `-${7 /* Arrow.Size */}px`,
+            "&:before": {
+                borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
+            },
+            "&:after": {
+                borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
+                top: "1px"
+            }
+        },
+    },
+    "&dark .cm-tooltip .cm-tooltip-arrow": {
+        "&:before": {
+            borderTopColor: "#333338",
+            borderBottomColor: "#333338"
+        },
+        "&:after": {
+            borderTopColor: "transparent",
+            borderBottomColor: "transparent"
+        }
+    }
+});
+const noOffset = { x: 0, y: 0 };
+/**
+Facet to which an extension can add a value to show a tooltip.
+*/
+const showTooltip = /*@__PURE__*/Facet.define({
+    enables: [tooltipPlugin, baseTheme$4]
+});
+const showHoverTooltip = /*@__PURE__*/Facet.define({
+    combine: inputs => inputs.reduce((a, i) => a.concat(i), [])
+});
+class HoverTooltipHost {
+    // Needs to be static so that host tooltip instances always match
+    static create(view) {
+        return new HoverTooltipHost(view);
+    }
+    constructor(view) {
+        this.view = view;
+        this.mounted = false;
+        this.dom = document.createElement("div");
+        this.dom.classList.add("cm-tooltip-hover");
+        this.manager = new TooltipViewManager(view, showHoverTooltip, (t, p) => this.createHostedView(t, p), t => t.dom.remove());
+    }
+    createHostedView(tooltip, prev) {
+        let hostedView = tooltip.create(this.view);
+        hostedView.dom.classList.add("cm-tooltip-section");
+        this.dom.insertBefore(hostedView.dom, prev ? prev.dom.nextSibling : this.dom.firstChild);
+        if (this.mounted && hostedView.mount)
+            hostedView.mount(this.view);
+        return hostedView;
+    }
+    mount(view) {
+        for (let hostedView of this.manager.tooltipViews) {
+            if (hostedView.mount)
+                hostedView.mount(view);
+        }
+        this.mounted = true;
+    }
+    positioned(space) {
+        for (let hostedView of this.manager.tooltipViews) {
+            if (hostedView.positioned)
+                hostedView.positioned(space);
+        }
+    }
+    update(update) {
+        this.manager.update(update);
+    }
+    destroy() {
+        var _a;
+        for (let t of this.manager.tooltipViews)
+            (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
+    }
+    passProp(name) {
+        let value = undefined;
+        for (let view of this.manager.tooltipViews) {
+            let given = view[name];
+            if (given !== undefined) {
+                if (value === undefined)
+                    value = given;
+                else if (value !== given)
+                    return undefined;
+            }
+        }
+        return value;
+    }
+    get offset() { return this.passProp("offset"); }
+    get getCoords() { return this.passProp("getCoords"); }
+    get overlap() { return this.passProp("overlap"); }
+    get resize() { return this.passProp("resize"); }
+}
+const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
+    let tooltips = state.facet(showHoverTooltip);
+    if (tooltips.length === 0)
+        return null;
+    return {
+        pos: Math.min(...tooltips.map(t => t.pos)),
+        end: Math.max(...tooltips.map(t => { var _a; return (_a = t.end) !== null && _a !== void 0 ? _a : t.pos; })),
+        create: HoverTooltipHost.create,
+        above: tooltips[0].above,
+        arrow: tooltips.some(t => t.arrow),
+    };
+});
+class HoverPlugin {
+    constructor(view, source, field, setHover, hoverTime) {
+        this.view = view;
+        this.source = source;
+        this.field = field;
+        this.setHover = setHover;
+        this.hoverTime = hoverTime;
+        this.hoverTimeout = -1;
+        this.restartTimeout = -1;
+        this.pending = null;
+        this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };
+        this.checkHover = this.checkHover.bind(this);
+        view.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this));
+        view.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
+    }
+    update() {
+        if (this.pending) {
+            this.pending = null;
+            clearTimeout(this.restartTimeout);
+            this.restartTimeout = setTimeout(() => this.startHover(), 20);
+        }
+    }
+    get active() {
+        return this.view.state.field(this.field);
+    }
+    checkHover() {
+        this.hoverTimeout = -1;
+        if (this.active.length)
+            return;
+        let hovered = Date.now() - this.lastMove.time;
+        if (hovered < this.hoverTime)
+            this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);
+        else
+            this.startHover();
+    }
+    startHover() {
+        clearTimeout(this.restartTimeout);
+        let { view, lastMove } = this;
+        let desc = view.docView.nearest(lastMove.target);
+        if (!desc)
+            return;
+        let pos, side = 1;
+        if (desc instanceof WidgetView) {
+            pos = desc.posAtStart;
+        }
+        else {
+            pos = view.posAtCoords(lastMove);
+            if (pos == null)
+                return;
+            let posCoords = view.coordsAtPos(pos);
+            if (!posCoords ||
+                lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||
+                lastMove.x < posCoords.left - view.defaultCharacterWidth ||
+                lastMove.x > posCoords.right + view.defaultCharacterWidth)
+                return;
+            let bidi = view.bidiSpans(view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);
+            let rtl = bidi && bidi.dir == Direction.RTL ? -1 : 1;
+            side = (lastMove.x < posCoords.left ? -rtl : rtl);
+        }
+        let open = this.source(view, pos, side);
+        if (open === null || open === void 0 ? void 0 : open.then) {
+            let pending = this.pending = { pos };
+            open.then(result => {
+                if (this.pending == pending) {
+                    this.pending = null;
+                    if (result && !(Array.isArray(result) && !result.length))
+                        view.dispatch({ effects: this.setHover.of(Array.isArray(result) ? result : [result]) });
+                }
+            }, e => logException(view.state, e, "hover tooltip"));
+        }
+        else if (open && !(Array.isArray(open) && !open.length)) {
+            view.dispatch({ effects: this.setHover.of(Array.isArray(open) ? open : [open]) });
+        }
+    }
+    get tooltip() {
+        let plugin = this.view.plugin(tooltipPlugin);
+        let index = plugin ? plugin.manager.tooltips.findIndex(t => t.create == HoverTooltipHost.create) : -1;
+        return index > -1 ? plugin.manager.tooltipViews[index] : null;
+    }
+    mousemove(event) {
+        var _a, _b;
+        this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };
+        if (this.hoverTimeout < 0)
+            this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
+        let { active, tooltip } = this;
+        if (active.length && tooltip && !isInTooltip(tooltip.dom, event) || this.pending) {
+            let { pos } = active[0] || this.pending, end = (_b = (_a = active[0]) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : pos;
+            if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
+                : !isOverRange(this.view, pos, end, event.clientX, event.clientY))) {
+                this.view.dispatch({ effects: this.setHover.of([]) });
+                this.pending = null;
+            }
+        }
+    }
+    mouseleave(event) {
+        clearTimeout(this.hoverTimeout);
+        this.hoverTimeout = -1;
+        let { active } = this;
+        if (active.length) {
+            let { tooltip } = this;
+            let inTooltip = tooltip && tooltip.dom.contains(event.relatedTarget);
+            if (!inTooltip)
+                this.view.dispatch({ effects: this.setHover.of([]) });
+            else
+                this.watchTooltipLeave(tooltip.dom);
+        }
+    }
+    watchTooltipLeave(tooltip) {
+        let watch = (event) => {
+            tooltip.removeEventListener("mouseleave", watch);
+            if (this.active.length && !this.view.dom.contains(event.relatedTarget))
+                this.view.dispatch({ effects: this.setHover.of([]) });
+        };
+        tooltip.addEventListener("mouseleave", watch);
+    }
+    destroy() {
+        clearTimeout(this.hoverTimeout);
+        this.view.dom.removeEventListener("mouseleave", this.mouseleave);
+        this.view.dom.removeEventListener("mousemove", this.mousemove);
+    }
+}
+const tooltipMargin = 4;
+function isInTooltip(tooltip, event) {
+    let { left, right, top, bottom } = tooltip.getBoundingClientRect(), arrow;
+    if (arrow = tooltip.querySelector(".cm-tooltip-arrow")) {
+        let arrowRect = arrow.getBoundingClientRect();
+        top = Math.min(arrowRect.top, top);
+        bottom = Math.max(arrowRect.bottom, bottom);
+    }
+    return event.clientX >= left - tooltipMargin && event.clientX <= right + tooltipMargin &&
+        event.clientY >= top - tooltipMargin && event.clientY <= bottom + tooltipMargin;
+}
+function isOverRange(view, from, to, x, y, margin) {
+    let rect = view.scrollDOM.getBoundingClientRect();
+    let docBottom = view.documentTop + view.documentPadding.top + view.contentHeight;
+    if (rect.left > x || rect.right < x || rect.top > y || Math.min(rect.bottom, docBottom) < y)
+        return false;
+    let pos = view.posAtCoords({ x, y }, false);
+    return pos >= from && pos <= to;
+}
+/**
+Set up a hover tooltip, which shows up when the pointer hovers
+over ranges of text. The callback is called when the mouse hovers
+over the document text. It should, if there is a tooltip
+associated with position `pos`, return the tooltip description
+(either directly or in a promise). The `side` argument indicates
+on which side of the position the pointer is—it will be -1 if the
+pointer is before the position, 1 if after the position.
+
+Note that all hover tooltips are hosted within a single tooltip
+container element. This allows multiple tooltips over the same
+range to be "merged" together without overlapping.
+
+The return value is a valid [editor extension](https://codemirror.net/6/docs/ref/#state.Extension)
+but also provides an `active` property holding a state field that
+can be used to read the currently active tooltips produced by this
+extension.
+*/
+function hoverTooltip(source, options = {}) {
+    let setHover = StateEffect.define();
+    let hoverState = StateField.define({
+        create() { return []; },
+        update(value, tr) {
+            if (value.length) {
+                if (options.hideOnChange && (tr.docChanged || tr.selection))
+                    value = [];
+                else if (options.hideOn)
+                    value = value.filter(v => !options.hideOn(tr, v));
+                if (tr.docChanged) {
+                    let mapped = [];
+                    for (let tooltip of value) {
+                        let newPos = tr.changes.mapPos(tooltip.pos, -1, MapMode.TrackDel);
+                        if (newPos != null) {
+                            let copy = Object.assign(Object.create(null), tooltip);
+                            copy.pos = newPos;
+                            if (copy.end != null)
+                                copy.end = tr.changes.mapPos(copy.end);
+                            mapped.push(copy);
+                        }
+                    }
+                    value = mapped;
+                }
+            }
+            for (let effect of tr.effects) {
+                if (effect.is(setHover))
+                    value = effect.value;
+                if (effect.is(closeHoverTooltipEffect))
+                    value = [];
+            }
+            return value;
+        },
+        provide: f => showHoverTooltip.from(f)
+    });
+    return {
+        active: hoverState,
+        extension: [
+            hoverState,
+            ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
+            showHoverTooltipHost
+        ]
+    };
+}
+/**
+Get the active tooltip view for a given tooltip, if available.
+*/
+function getTooltip(view, tooltip) {
+    let plugin = view.plugin(tooltipPlugin);
+    if (!plugin)
+        return null;
+    let found = plugin.manager.tooltips.indexOf(tooltip);
+    return found < 0 ? null : plugin.manager.tooltipViews[found];
+}
+const closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();
+
+const panelConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        let topContainer, bottomContainer;
+        for (let c of configs) {
+            topContainer = topContainer || c.topContainer;
+            bottomContainer = bottomContainer || c.bottomContainer;
+        }
+        return { topContainer, bottomContainer };
+    }
+});
+/**
+Get the active panel created by the given constructor, if any.
+This can be useful when you need access to your panels' DOM
+structure.
+*/
+function getPanel(view, panel) {
+    let plugin = view.plugin(panelPlugin);
+    let index = plugin ? plugin.specs.indexOf(panel) : -1;
+    return index > -1 ? plugin.panels[index] : null;
+}
+const panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.input = view.state.facet(showPanel);
+        this.specs = this.input.filter(s => s);
+        this.panels = this.specs.map(spec => spec(view));
+        let conf = view.state.facet(panelConfig);
+        this.top = new PanelGroup(view, true, conf.topContainer);
+        this.bottom = new PanelGroup(view, false, conf.bottomContainer);
+        this.top.sync(this.panels.filter(p => p.top));
+        this.bottom.sync(this.panels.filter(p => !p.top));
+        for (let p of this.panels) {
+            p.dom.classList.add("cm-panel");
+            if (p.mount)
+                p.mount();
+        }
+    }
+    update(update) {
+        let conf = update.state.facet(panelConfig);
+        if (this.top.container != conf.topContainer) {
+            this.top.sync([]);
+            this.top = new PanelGroup(update.view, true, conf.topContainer);
+        }
+        if (this.bottom.container != conf.bottomContainer) {
+            this.bottom.sync([]);
+            this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);
+        }
+        this.top.syncClasses();
+        this.bottom.syncClasses();
+        let input = update.state.facet(showPanel);
+        if (input != this.input) {
+            let specs = input.filter(x => x);
+            let panels = [], top = [], bottom = [], mount = [];
+            for (let spec of specs) {
+                let known = this.specs.indexOf(spec), panel;
+                if (known < 0) {
+                    panel = spec(update.view);
+                    mount.push(panel);
+                }
+                else {
+                    panel = this.panels[known];
+                    if (panel.update)
+                        panel.update(update);
+                }
+                panels.push(panel);
+                (panel.top ? top : bottom).push(panel);
+            }
+            this.specs = specs;
+            this.panels = panels;
+            this.top.sync(top);
+            this.bottom.sync(bottom);
+            for (let p of mount) {
+                p.dom.classList.add("cm-panel");
+                if (p.mount)
+                    p.mount();
+            }
+        }
+        else {
+            for (let p of this.panels)
+                if (p.update)
+                    p.update(update);
+        }
+    }
+    destroy() {
+        this.top.sync([]);
+        this.bottom.sync([]);
+    }
+}, {
+    provide: plugin => EditorView.scrollMargins.of(view => {
+        let value = view.plugin(plugin);
+        return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
+    })
+});
+class PanelGroup {
+    constructor(view, top, container) {
+        this.view = view;
+        this.top = top;
+        this.container = container;
+        this.dom = undefined;
+        this.classes = "";
+        this.panels = [];
+        this.syncClasses();
+    }
+    sync(panels) {
+        for (let p of this.panels)
+            if (p.destroy && panels.indexOf(p) < 0)
+                p.destroy();
+        this.panels = panels;
+        this.syncDOM();
+    }
+    syncDOM() {
+        if (this.panels.length == 0) {
+            if (this.dom) {
+                this.dom.remove();
+                this.dom = undefined;
+            }
+            return;
+        }
+        if (!this.dom) {
+            this.dom = document.createElement("div");
+            this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
+            this.dom.style[this.top ? "top" : "bottom"] = "0";
+            let parent = this.container || this.view.dom;
+            parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
+        }
+        let curDOM = this.dom.firstChild;
+        for (let panel of this.panels) {
+            if (panel.dom.parentNode == this.dom) {
+                while (curDOM != panel.dom)
+                    curDOM = rm(curDOM);
+                curDOM = curDOM.nextSibling;
+            }
+            else {
+                this.dom.insertBefore(panel.dom, curDOM);
+            }
+        }
+        while (curDOM)
+            curDOM = rm(curDOM);
+    }
+    scrollMargin() {
+        return !this.dom || this.container ? 0
+            : Math.max(0, this.top ?
+                this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
+                Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
+    }
+    syncClasses() {
+        if (!this.container || this.classes == this.view.themeClasses)
+            return;
+        for (let cls of this.classes.split(" "))
+            if (cls)
+                this.container.classList.remove(cls);
+        for (let cls of (this.classes = this.view.themeClasses).split(" "))
+            if (cls)
+                this.container.classList.add(cls);
+    }
+}
+function rm(node) {
+    let next = node.nextSibling;
+    node.remove();
+    return next;
+}
+/**
+Opening a panel is done by providing a constructor function for
+the panel through this facet. (The panel is closed again when its
+constructor is no longer provided.) Values of `null` are ignored.
+*/
+const showPanel = /*@__PURE__*/Facet.define({
+    enables: panelPlugin
+});
+
+/**
+A gutter marker represents a bit of information attached to a line
+in a specific gutter. Your own custom markers have to extend this
+class.
+*/
+class GutterMarker extends RangeValue {
+    /**
+    @internal
+    */
+    compare(other) {
+        return this == other || this.constructor == other.constructor && this.eq(other);
+    }
+    /**
+    Compare this marker to another marker of the same type.
+    */
+    eq(other) { return false; }
+    /**
+    Called if the marker has a `toDOM` method and its representation
+    was removed from a gutter.
+    */
+    destroy(dom) { }
+}
+GutterMarker.prototype.elementClass = "";
+GutterMarker.prototype.toDOM = undefined;
+GutterMarker.prototype.mapMode = MapMode.TrackBefore;
+GutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;
+GutterMarker.prototype.point = true;
+/**
+Facet used to add a class to all gutter elements for a given line.
+Markers given to this facet should _only_ define an
+[`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a
+[`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear
+in all gutters for the line).
+*/
+const gutterLineClass = /*@__PURE__*/Facet.define();
+/**
+Facet used to add a class to all gutter elements next to a widget.
+Should not provide widgets with a `toDOM` method.
+*/
+const gutterWidgetClass = /*@__PURE__*/Facet.define();
+const defaults$1 = {
+    class: "",
+    renderEmptyElements: false,
+    elementStyle: "",
+    markers: () => RangeSet.empty,
+    lineMarker: () => null,
+    widgetMarker: () => null,
+    lineMarkerChange: null,
+    initialSpacer: null,
+    updateSpacer: null,
+    domEventHandlers: {}
+};
+const activeGutters = /*@__PURE__*/Facet.define();
+/**
+Define an editor gutter. The order in which the gutters appear is
+determined by their extension priority.
+*/
+function gutter(config) {
+    return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults$1), config))];
+}
+const unfixGutters = /*@__PURE__*/Facet.define({
+    combine: values => values.some(x => x)
+});
+/**
+The gutter-drawing plugin is automatically enabled when you add a
+gutter, but you can use this function to explicitly configure it.
+
+Unless `fixed` is explicitly set to `false`, the gutters are
+fixed, meaning they don't scroll along with the content
+horizontally (except on Internet Explorer, which doesn't support
+CSS [`position:
+sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
+*/
+function gutters(config) {
+    let result = [
+        gutterView,
+    ];
+    return result;
+}
+const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.view = view;
+        this.prevViewport = view.viewport;
+        this.dom = document.createElement("div");
+        this.dom.className = "cm-gutters";
+        this.dom.setAttribute("aria-hidden", "true");
+        this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
+        this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));
+        for (let gutter of this.gutters)
+            this.dom.appendChild(gutter.dom);
+        this.fixed = !view.state.facet(unfixGutters);
+        if (this.fixed) {
+            // FIXME IE11 fallback, which doesn't support position: sticky,
+            // by using position: relative + event handlers that realign the
+            // gutter (or just force fixed=false on IE11?)
+            this.dom.style.position = "sticky";
+        }
+        this.syncGutters(false);
+        view.scrollDOM.insertBefore(this.dom, view.contentDOM);
+    }
+    update(update) {
+        if (this.updateGutters(update)) {
+            // Detach during sync when the viewport changed significantly
+            // (such as during scrolling), since for large updates that is
+            // faster.
+            let vpA = this.prevViewport, vpB = update.view.viewport;
+            let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);
+            this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);
+        }
+        if (update.geometryChanged) {
+            this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
+        }
+        if (this.view.state.facet(unfixGutters) != !this.fixed) {
+            this.fixed = !this.fixed;
+            this.dom.style.position = this.fixed ? "sticky" : "";
+        }
+        this.prevViewport = update.view.viewport;
+    }
+    syncGutters(detach) {
+        let after = this.dom.nextSibling;
+        if (detach)
+            this.dom.remove();
+        let lineClasses = RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);
+        let classSet = [];
+        let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
+        for (let line of this.view.viewportLineBlocks) {
+            if (classSet.length)
+                classSet = [];
+            if (Array.isArray(line.type)) {
+                let first = true;
+                for (let b of line.type) {
+                    if (b.type == BlockType.Text && first) {
+                        advanceCursor(lineClasses, classSet, b.from);
+                        for (let cx of contexts)
+                            cx.line(this.view, b, classSet);
+                        first = false;
+                    }
+                    else if (b.widget) {
+                        for (let cx of contexts)
+                            cx.widget(this.view, b);
+                    }
+                }
+            }
+            else if (line.type == BlockType.Text) {
+                advanceCursor(lineClasses, classSet, line.from);
+                for (let cx of contexts)
+                    cx.line(this.view, line, classSet);
+            }
+            else if (line.widget) {
+                for (let cx of contexts)
+                    cx.widget(this.view, line);
+            }
+        }
+        for (let cx of contexts)
+            cx.finish();
+        if (detach)
+            this.view.scrollDOM.insertBefore(this.dom, after);
+    }
+    updateGutters(update) {
+        let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);
+        let change = update.docChanged || update.heightChanged || update.viewportChanged ||
+            !RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);
+        if (prev == cur) {
+            for (let gutter of this.gutters)
+                if (gutter.update(update))
+                    change = true;
+        }
+        else {
+            change = true;
+            let gutters = [];
+            for (let conf of cur) {
+                let known = prev.indexOf(conf);
+                if (known < 0) {
+                    gutters.push(new SingleGutterView(this.view, conf));
+                }
+                else {
+                    this.gutters[known].update(update);
+                    gutters.push(this.gutters[known]);
+                }
+            }
+            for (let g of this.gutters) {
+                g.dom.remove();
+                if (gutters.indexOf(g) < 0)
+                    g.destroy();
+            }
+            for (let g of gutters)
+                this.dom.appendChild(g.dom);
+            this.gutters = gutters;
+        }
+        return change;
+    }
+    destroy() {
+        for (let view of this.gutters)
+            view.destroy();
+        this.dom.remove();
+    }
+}, {
+    provide: plugin => EditorView.scrollMargins.of(view => {
+        let value = view.plugin(plugin);
+        if (!value || value.gutters.length == 0 || !value.fixed)
+            return null;
+        return view.textDirection == Direction.LTR
+            ? { left: value.dom.offsetWidth * view.scaleX }
+            : { right: value.dom.offsetWidth * view.scaleX };
+    })
+});
+function asArray(val) { return (Array.isArray(val) ? val : [val]); }
+function advanceCursor(cursor, collect, pos) {
+    while (cursor.value && cursor.from <= pos) {
+        if (cursor.from == pos)
+            collect.push(cursor.value);
+        cursor.next();
+    }
+}
+class UpdateContext {
+    constructor(gutter, viewport, height) {
+        this.gutter = gutter;
+        this.height = height;
+        this.i = 0;
+        this.cursor = RangeSet.iter(gutter.markers, viewport.from);
+    }
+    addElement(view, block, markers) {
+        let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;
+        if (this.i == gutter.elements.length) {
+            let newElt = new GutterElement(view, height, above, markers);
+            gutter.elements.push(newElt);
+            gutter.dom.appendChild(newElt.dom);
+        }
+        else {
+            gutter.elements[this.i].update(view, height, above, markers);
+        }
+        this.height = block.bottom;
+        this.i++;
+    }
+    line(view, line, extraMarkers) {
+        let localMarkers = [];
+        advanceCursor(this.cursor, localMarkers, line.from);
+        if (extraMarkers.length)
+            localMarkers = localMarkers.concat(extraMarkers);
+        let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
+        if (forLine)
+            localMarkers.unshift(forLine);
+        let gutter = this.gutter;
+        if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
+            return;
+        this.addElement(view, line, localMarkers);
+    }
+    widget(view, block) {
+        let marker = this.gutter.config.widgetMarker(view, block.widget, block), markers = marker ? [marker] : null;
+        for (let cls of view.state.facet(gutterWidgetClass)) {
+            let marker = cls(view, block.widget, block);
+            if (marker)
+                (markers || (markers = [])).push(marker);
+        }
+        if (markers)
+            this.addElement(view, block, markers);
+    }
+    finish() {
+        let gutter = this.gutter;
+        while (gutter.elements.length > this.i) {
+            let last = gutter.elements.pop();
+            gutter.dom.removeChild(last.dom);
+            last.destroy();
+        }
+    }
+}
+class SingleGutterView {
+    constructor(view, config) {
+        this.view = view;
+        this.config = config;
+        this.elements = [];
+        this.spacer = null;
+        this.dom = document.createElement("div");
+        this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
+        for (let prop in config.domEventHandlers) {
+            this.dom.addEventListener(prop, (event) => {
+                let target = event.target, y;
+                if (target != this.dom && this.dom.contains(target)) {
+                    while (target.parentNode != this.dom)
+                        target = target.parentNode;
+                    let rect = target.getBoundingClientRect();
+                    y = (rect.top + rect.bottom) / 2;
+                }
+                else {
+                    y = event.clientY;
+                }
+                let line = view.lineBlockAtHeight(y - view.documentTop);
+                if (config.domEventHandlers[prop](view, line, event))
+                    event.preventDefault();
+            });
+        }
+        this.markers = asArray(config.markers(view));
+        if (config.initialSpacer) {
+            this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);
+            this.dom.appendChild(this.spacer.dom);
+            this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none";
+        }
+    }
+    update(update) {
+        let prevMarkers = this.markers;
+        this.markers = asArray(this.config.markers(update.view));
+        if (this.spacer && this.config.updateSpacer) {
+            let updated = this.config.updateSpacer(this.spacer.markers[0], update);
+            if (updated != this.spacer.markers[0])
+                this.spacer.update(update.view, 0, 0, [updated]);
+        }
+        let vp = update.view.viewport;
+        return !RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||
+            (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);
+    }
+    destroy() {
+        for (let elt of this.elements)
+            elt.destroy();
+    }
+}
+class GutterElement {
+    constructor(view, height, above, markers) {
+        this.height = -1;
+        this.above = 0;
+        this.markers = [];
+        this.dom = document.createElement("div");
+        this.dom.className = "cm-gutterElement";
+        this.update(view, height, above, markers);
+    }
+    update(view, height, above, markers) {
+        if (this.height != height) {
+            this.height = height;
+            this.dom.style.height = height + "px";
+        }
+        if (this.above != above)
+            this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
+        if (!sameMarkers(this.markers, markers))
+            this.setMarkers(view, markers);
+    }
+    setMarkers(view, markers) {
+        let cls = "cm-gutterElement", domPos = this.dom.firstChild;
+        for (let iNew = 0, iOld = 0;;) {
+            let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;
+            if (marker) {
+                let c = marker.elementClass;
+                if (c)
+                    cls += " " + c;
+                for (let i = iOld; i < this.markers.length; i++)
+                    if (this.markers[i].compare(marker)) {
+                        skipTo = i;
+                        matched = true;
+                        break;
+                    }
+            }
+            else {
+                skipTo = this.markers.length;
+            }
+            while (iOld < skipTo) {
+                let next = this.markers[iOld++];
+                if (next.toDOM) {
+                    next.destroy(domPos);
+                    let after = domPos.nextSibling;
+                    domPos.remove();
+                    domPos = after;
+                }
+            }
+            if (!marker)
+                break;
+            if (marker.toDOM) {
+                if (matched)
+                    domPos = domPos.nextSibling;
+                else
+                    this.dom.insertBefore(marker.toDOM(view), domPos);
+            }
+            if (matched)
+                iOld++;
+        }
+        this.dom.className = cls;
+        this.markers = markers;
+    }
+    destroy() {
+        this.setMarkers(null, []); // First argument not used unless creating markers
+    }
+}
+function sameMarkers(a, b) {
+    if (a.length != b.length)
+        return false;
+    for (let i = 0; i < a.length; i++)
+        if (!a[i].compare(b[i]))
+            return false;
+    return true;
+}
+/**
+Facet used to provide markers to the line number gutter.
+*/
+const lineNumberMarkers = /*@__PURE__*/Facet.define();
+/**
+Facet used to create markers in the line number gutter next to widgets.
+*/
+const lineNumberWidgetMarker = /*@__PURE__*/Facet.define();
+const lineNumberConfig = /*@__PURE__*/Facet.define({
+    combine(values) {
+        return combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {
+            domEventHandlers(a, b) {
+                let result = Object.assign({}, a);
+                for (let event in b) {
+                    let exists = result[event], add = b[event];
+                    result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;
+                }
+                return result;
+            }
+        });
+    }
+});
+class NumberMarker extends GutterMarker {
+    constructor(number) {
+        super();
+        this.number = number;
+    }
+    eq(other) { return this.number == other.number; }
+    toDOM() { return document.createTextNode(this.number); }
+}
+function formatNumber(view, number) {
+    return view.state.facet(lineNumberConfig).formatNumber(number, view.state);
+}
+const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({
+    class: "cm-lineNumbers",
+    renderEmptyElements: false,
+    markers(view) { return view.state.facet(lineNumberMarkers); },
+    lineMarker(view, line, others) {
+        if (others.some(m => m.toDOM))
+            return null;
+        return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
+    },
+    widgetMarker: (view, widget, block) => {
+        for (let m of view.state.facet(lineNumberWidgetMarker)) {
+            let result = m(view, widget, block);
+            if (result)
+                return result;
+        }
+        return null;
+    },
+    lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
+    initialSpacer(view) {
+        return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
+    },
+    updateSpacer(spacer, update) {
+        let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
+        return max == spacer.number ? spacer : new NumberMarker(max);
+    },
+    domEventHandlers: state.facet(lineNumberConfig).domEventHandlers
+}));
+/**
+Create a line number gutter extension.
+*/
+function lineNumbers(config = {}) {
+    return [
+        lineNumberConfig.of(config),
+        gutters(),
+        lineNumberGutter
+    ];
+}
+function maxLineNumber(lines) {
+    let last = 9;
+    while (last < lines)
+        last = last * 10 + 9;
+    return last;
+}
+const activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker {
+    constructor() {
+        super(...arguments);
+        this.elementClass = "cm-activeLineGutter";
+    }
+};
+const activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass.compute(["selection"], state => {
+    let marks = [], last = -1;
+    for (let range of state.selection.ranges) {
+        let linePos = state.doc.lineAt(range.head).from;
+        if (linePos > last) {
+            last = linePos;
+            marks.push(activeLineGutterMarker.range(linePos));
+        }
+    }
+    return RangeSet.of(marks);
+});
+/**
+Returns an extension that adds a `cm-activeLineGutter` class to
+all gutter elements on the [active
+line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
+*/
+function highlightActiveLineGutter() {
+    return activeLineGutterHighlighter;
+}
+
+/**
+The default maximum length of a `TreeBuffer` node.
+*/
+const DefaultBufferLength = 1024;
+let nextPropID$1 = 0;
+class Range {
+    constructor(from, to) {
+        this.from = from;
+        this.to = to;
+    }
+}
+/**
+Each [node type](#common.NodeType) or [individual tree](#common.Tree)
+can have metadata associated with it in props. Instances of this
+class represent prop names.
+*/
+let NodeProp$1 = class NodeProp {
+    /**
+    Create a new node prop type.
+    */
+    constructor(config = {}) {
+        this.id = nextPropID$1++;
+        this.perNode = !!config.perNode;
+        this.deserialize = config.deserialize || (() => {
+            throw new Error("This node type doesn't define a deserialize function");
+        });
+    }
+    /**
+    This is meant to be used with
+    [`NodeSet.extend`](#common.NodeSet.extend) or
+    [`LRParser.configure`](#lr.ParserConfig.props) to compute
+    prop values for each node type in the set. Takes a [match
+    object](#common.NodeType^match) or function that returns undefined
+    if the node type doesn't get this prop, and the prop's value if
+    it does.
+    */
+    add(match) {
+        if (this.perNode)
+            throw new RangeError("Can't add per-node props to node types");
+        if (typeof match != "function")
+            match = NodeType$1.match(match);
+        return (type) => {
+            let result = match(type);
+            return result === undefined ? null : [this, result];
+        };
+    }
+};
+/**
+Prop that is used to describe matching delimiters. For opening
+delimiters, this holds an array of node names (written as a
+space-separated string when declaring this prop in a grammar)
+for the node types of closing delimiters that match it.
+*/
+NodeProp$1.closedBy = new NodeProp$1({ deserialize: str => str.split(" ") });
+/**
+The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
+attached to closing delimiters, holding an array of node names
+of types of matching opening delimiters.
+*/
+NodeProp$1.openedBy = new NodeProp$1({ deserialize: str => str.split(" ") });
+/**
+Used to assign node types to groups (for example, all node
+types that represent an expression could be tagged with an
+`"Expression"` group).
+*/
+NodeProp$1.group = new NodeProp$1({ deserialize: str => str.split(" ") });
+/**
+Attached to nodes to indicate these should be
+[displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
+in a bidirectional text isolate, so that direction-neutral
+characters on their sides don't incorrectly get associated with
+surrounding text. You'll generally want to set this for nodes
+that contain arbitrary text, like strings and comments, and for
+nodes that appear _inside_ arbitrary text, like HTML tags. When
+not given a value, in a grammar declaration, defaults to
+`"auto"`.
+*/
+NodeProp$1.isolate = new NodeProp$1({ deserialize: value => {
+        if (value && value != "rtl" && value != "ltr" && value != "auto")
+            throw new RangeError("Invalid value for isolate: " + value);
+        return value || "auto";
+    } });
+/**
+The hash of the [context](#lr.ContextTracker.constructor)
+that the node was parsed in, if any. Used to limit reuse of
+contextual nodes.
+*/
+NodeProp$1.contextHash = new NodeProp$1({ perNode: true });
+/**
+The distance beyond the end of the node that the tokenizer
+looked ahead for any of the tokens inside the node. (The LR
+parser only stores this when it is larger than 25, for
+efficiency reasons.)
+*/
+NodeProp$1.lookAhead = new NodeProp$1({ perNode: true });
+/**
+This per-node prop is used to replace a given node, or part of a
+node, with another tree. This is useful to include trees from
+different languages in mixed-language parsers.
+*/
+NodeProp$1.mounted = new NodeProp$1({ perNode: true });
+/**
+A mounted tree, which can be [stored](#common.NodeProp^mounted) on
+a tree node to indicate that parts of its content are
+represented by another tree.
+*/
+class MountedTree {
+    constructor(
+    /**
+    The inner tree.
+    */
+    tree, 
+    /**
+    If this is null, this tree replaces the entire node (it will
+    be included in the regular iteration instead of its host
+    node). If not, only the given ranges are considered to be
+    covered by this tree. This is used for trees that are mixed in
+    a way that isn't strictly hierarchical. Such mounted trees are
+    only entered by [`resolveInner`](#common.Tree.resolveInner)
+    and [`enter`](#common.SyntaxNode.enter).
+    */
+    overlay, 
+    /**
+    The parser used to create this subtree.
+    */
+    parser) {
+        this.tree = tree;
+        this.overlay = overlay;
+        this.parser = parser;
+    }
+    /**
+    @internal
+    */
+    static get(tree) {
+        return tree && tree.props && tree.props[NodeProp$1.mounted.id];
+    }
+}
+const noProps$1 = Object.create(null);
+/**
+Each node in a syntax tree has a node type associated with it.
+*/
+let NodeType$1 = class NodeType {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    The name of the node type. Not necessarily unique, but if the
+    grammar was written properly, different node types with the
+    same name within a node set should play the same semantic
+    role.
+    */
+    name, 
+    /**
+    @internal
+    */
+    props, 
+    /**
+    The id of this node in its set. Corresponds to the term ids
+    used in the parser.
+    */
+    id, 
+    /**
+    @internal
+    */
+    flags = 0) {
+        this.name = name;
+        this.props = props;
+        this.id = id;
+        this.flags = flags;
+    }
+    /**
+    Define a node type.
+    */
+    static define(spec) {
+        let props = spec.props && spec.props.length ? Object.create(null) : noProps$1;
+        let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |
+            (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);
+        let type = new NodeType(spec.name || "", props, spec.id, flags);
+        if (spec.props)
+            for (let src of spec.props) {
+                if (!Array.isArray(src))
+                    src = src(type);
+                if (src) {
+                    if (src[0].perNode)
+                        throw new RangeError("Can't store a per-node prop on a node type");
+                    props[src[0].id] = src[1];
+                }
+            }
+        return type;
+    }
+    /**
+    Retrieves a node prop for this type. Will return `undefined` if
+    the prop isn't present on this node.
+    */
+    prop(prop) { return this.props[prop.id]; }
+    /**
+    True when this is the top node of a grammar.
+    */
+    get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }
+    /**
+    True when this node is produced by a skip rule.
+    */
+    get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }
+    /**
+    Indicates whether this is an error node.
+    */
+    get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }
+    /**
+    When true, this node type doesn't correspond to a user-declared
+    named node, for example because it is used to cache repetition.
+    */
+    get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }
+    /**
+    Returns true when this node's name or one of its
+    [groups](#common.NodeProp^group) matches the given string.
+    */
+    is(name) {
+        if (typeof name == 'string') {
+            if (this.name == name)
+                return true;
+            let group = this.prop(NodeProp$1.group);
+            return group ? group.indexOf(name) > -1 : false;
+        }
+        return this.id == name;
+    }
+    /**
+    Create a function from node types to arbitrary values by
+    specifying an object whose property names are node or
+    [group](#common.NodeProp^group) names. Often useful with
+    [`NodeProp.add`](#common.NodeProp.add). You can put multiple
+    names, separated by spaces, in a single property name to map
+    multiple node names to a single value.
+    */
+    static match(map) {
+        let direct = Object.create(null);
+        for (let prop in map)
+            for (let name of prop.split(" "))
+                direct[name] = map[prop];
+        return (node) => {
+            for (let groups = node.prop(NodeProp$1.group), i = -1; i < (groups ? groups.length : 0); i++) {
+                let found = direct[i < 0 ? node.name : groups[i]];
+                if (found)
+                    return found;
+            }
+        };
+    }
+};
+/**
+An empty dummy node type to use when no actual type is available.
+*/
+NodeType$1.none = new NodeType$1("", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);
+/**
+A node set holds a collection of node types. It is used to
+compactly represent trees by storing their type ids, rather than a
+full pointer to the type object, in a numeric array. Each parser
+[has](#lr.LRParser.nodeSet) a node set, and [tree
+buffers](#common.TreeBuffer) can only store collections of nodes
+from the same set. A set can have a maximum of 2**16 (65536) node
+types in it, so that the ids fit into 16-bit typed array slots.
+*/
+class NodeSet {
+    /**
+    Create a set with the given types. The `id` property of each
+    type should correspond to its position within the array.
+    */
+    constructor(
+    /**
+    The node types in this set, by id.
+    */
+    types) {
+        this.types = types;
+        for (let i = 0; i < types.length; i++)
+            if (types[i].id != i)
+                throw new RangeError("Node type ids should correspond to array positions when creating a node set");
+    }
+    /**
+    Create a copy of this set with some node properties added. The
+    arguments to this method can be created with
+    [`NodeProp.add`](#common.NodeProp.add).
+    */
+    extend(...props) {
+        let newTypes = [];
+        for (let type of this.types) {
+            let newProps = null;
+            for (let source of props) {
+                let add = source(type);
+                if (add) {
+                    if (!newProps)
+                        newProps = Object.assign({}, type.props);
+                    newProps[add[0].id] = add[1];
+                }
+            }
+            newTypes.push(newProps ? new NodeType$1(type.name, newProps, type.id, type.flags) : type);
+        }
+        return new NodeSet(newTypes);
+    }
+}
+const CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();
+/**
+Options that control iteration. Can be combined with the `|`
+operator to enable multiple ones.
+*/
+var IterMode$1;
+(function (IterMode) {
+    /**
+    When enabled, iteration will only visit [`Tree`](#common.Tree)
+    objects, not nodes packed into
+    [`TreeBuffer`](#common.TreeBuffer)s.
+    */
+    IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
+    /**
+    Enable this to make iteration include anonymous nodes (such as
+    the nodes that wrap repeated grammar constructs into a balanced
+    tree).
+    */
+    IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
+    /**
+    By default, regular [mounted](#common.NodeProp^mounted) nodes
+    replace their base node in iteration. Enable this to ignore them
+    instead.
+    */
+    IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
+    /**
+    This option only applies in
+    [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
+    library to not enter mounted overlays if one covers the given
+    position.
+    */
+    IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
+})(IterMode$1 || (IterMode$1 = {}));
+/**
+A piece of syntax tree. There are two ways to approach these
+trees: the way they are actually stored in memory, and the
+convenient way.
+
+Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
+objects. By packing detail information into `TreeBuffer` leaf
+nodes, the representation is made a lot more memory-efficient.
+
+However, when you want to actually work with tree nodes, this
+representation is very awkward, so most client code will want to
+use the [`TreeCursor`](#common.TreeCursor) or
+[`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
+a view on some part of this data structure, and can be used to
+move around to adjacent nodes.
+*/
+class Tree {
+    /**
+    Construct a new tree. See also [`Tree.build`](#common.Tree^build).
+    */
+    constructor(
+    /**
+    The type of the top node.
+    */
+    type, 
+    /**
+    This node's child nodes.
+    */
+    children, 
+    /**
+    The positions (offsets relative to the start of this tree) of
+    the children.
+    */
+    positions, 
+    /**
+    The total length of this tree
+    */
+    length, 
+    /**
+    Per-node [node props](#common.NodeProp) to associate with this node.
+    */
+    props) {
+        this.type = type;
+        this.children = children;
+        this.positions = positions;
+        this.length = length;
+        /**
+        @internal
+        */
+        this.props = null;
+        if (props && props.length) {
+            this.props = Object.create(null);
+            for (let [prop, value] of props)
+                this.props[typeof prop == "number" ? prop : prop.id] = value;
+        }
+    }
+    /**
+    @internal
+    */
+    toString() {
+        let mounted = MountedTree.get(this);
+        if (mounted && !mounted.overlay)
+            return mounted.tree.toString();
+        let children = "";
+        for (let ch of this.children) {
+            let str = ch.toString();
+            if (str) {
+                if (children)
+                    children += ",";
+                children += str;
+            }
+        }
+        return !this.type.name ? children :
+            (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
+                (children.length ? "(" + children + ")" : "");
+    }
+    /**
+    Get a [tree cursor](#common.TreeCursor) positioned at the top of
+    the tree. Mode can be used to [control](#common.IterMode) which
+    nodes the cursor visits.
+    */
+    cursor(mode = 0) {
+        return new TreeCursor(this.topNode, mode);
+    }
+    /**
+    Get a [tree cursor](#common.TreeCursor) pointing into this tree
+    at the given position and side (see
+    [`moveTo`](#common.TreeCursor.moveTo).
+    */
+    cursorAt(pos, side = 0, mode = 0) {
+        let scope = CachedNode.get(this) || this.topNode;
+        let cursor = new TreeCursor(scope);
+        cursor.moveTo(pos, side);
+        CachedNode.set(this, cursor._tree);
+        return cursor;
+    }
+    /**
+    Get a [syntax node](#common.SyntaxNode) object for the top of the
+    tree.
+    */
+    get topNode() {
+        return new TreeNode(this, 0, 0, null);
+    }
+    /**
+    Get the [syntax node](#common.SyntaxNode) at the given position.
+    If `side` is -1, this will move into nodes that end at the
+    position. If 1, it'll move into nodes that start at the
+    position. With 0, it'll only enter nodes that cover the position
+    from both sides.
+    
+    Note that this will not enter
+    [overlays](#common.MountedTree.overlay), and you often want
+    [`resolveInner`](#common.Tree.resolveInner) instead.
+    */
+    resolve(pos, side = 0) {
+        let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
+        CachedNode.set(this, node);
+        return node;
+    }
+    /**
+    Like [`resolve`](#common.Tree.resolve), but will enter
+    [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
+    pointing into the innermost overlaid tree at the given position
+    (with parent links going through all parent structure, including
+    the host trees).
+    */
+    resolveInner(pos, side = 0) {
+        let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
+        CachedInnerNode.set(this, node);
+        return node;
+    }
+    /**
+    In some situations, it can be useful to iterate through all
+    nodes around a position, including those in overlays that don't
+    directly cover the position. This method gives you an iterator
+    that will produce all nodes, from small to big, around the given
+    position.
+    */
+    resolveStack(pos, side = 0) {
+        return stackIterator(this, pos, side);
+    }
+    /**
+    Iterate over the tree and its children, calling `enter` for any
+    node that touches the `from`/`to` region (if given) before
+    running over such a node's children, and `leave` (if given) when
+    leaving the node. When `enter` returns `false`, that node will
+    not have its children iterated over (or `leave` called).
+    */
+    iterate(spec) {
+        let { enter, leave, from = 0, to = this.length } = spec;
+        let mode = spec.mode || 0, anon = (mode & IterMode$1.IncludeAnonymous) > 0;
+        for (let c = this.cursor(mode | IterMode$1.IncludeAnonymous);;) {
+            let entered = false;
+            if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
+                if (c.firstChild())
+                    continue;
+                entered = true;
+            }
+            for (;;) {
+                if (entered && leave && (anon || !c.type.isAnonymous))
+                    leave(c);
+                if (c.nextSibling())
+                    break;
+                if (!c.parent())
+                    return;
+                entered = true;
+            }
+        }
+    }
+    /**
+    Get the value of the given [node prop](#common.NodeProp) for this
+    node. Works with both per-node and per-type props.
+    */
+    prop(prop) {
+        return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
+    }
+    /**
+    Returns the node's [per-node props](#common.NodeProp.perNode) in a
+    format that can be passed to the [`Tree`](#common.Tree)
+    constructor.
+    */
+    get propValues() {
+        let result = [];
+        if (this.props)
+            for (let id in this.props)
+                result.push([+id, this.props[id]]);
+        return result;
+    }
+    /**
+    Balance the direct children of this tree, producing a copy of
+    which may have children grouped into subtrees with type
+    [`NodeType.none`](#common.NodeType^none).
+    */
+    balance(config = {}) {
+        return this.children.length <= 8 /* Balance.BranchFactor */ ? this :
+            balanceRange(NodeType$1.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType$1.none, children, positions, length)));
+    }
+    /**
+    Build a tree from a postfix-ordered buffer of node information,
+    or a cursor over such a buffer.
+    */
+    static build(data) { return buildTree(data); }
+}
+/**
+The empty tree
+*/
+Tree.empty = new Tree(NodeType$1.none, [], [], 0);
+class FlatBufferCursor {
+    constructor(buffer, index) {
+        this.buffer = buffer;
+        this.index = index;
+    }
+    get id() { return this.buffer[this.index - 4]; }
+    get start() { return this.buffer[this.index - 3]; }
+    get end() { return this.buffer[this.index - 2]; }
+    get size() { return this.buffer[this.index - 1]; }
+    get pos() { return this.index; }
+    next() { this.index -= 4; }
+    fork() { return new FlatBufferCursor(this.buffer, this.index); }
+}
+/**
+Tree buffers contain (type, start, end, endIndex) quads for each
+node. In such a buffer, nodes are stored in prefix order (parents
+before children, with the endIndex of the parent indicating which
+children belong to it).
+*/
+class TreeBuffer {
+    /**
+    Create a tree buffer.
+    */
+    constructor(
+    /**
+    The buffer's content.
+    */
+    buffer, 
+    /**
+    The total length of the group of nodes in the buffer.
+    */
+    length, 
+    /**
+    The node set used in this buffer.
+    */
+    set) {
+        this.buffer = buffer;
+        this.length = length;
+        this.set = set;
+    }
+    /**
+    @internal
+    */
+    get type() { return NodeType$1.none; }
+    /**
+    @internal
+    */
+    toString() {
+        let result = [];
+        for (let index = 0; index < this.buffer.length;) {
+            result.push(this.childString(index));
+            index = this.buffer[index + 3];
+        }
+        return result.join(",");
+    }
+    /**
+    @internal
+    */
+    childString(index) {
+        let id = this.buffer[index], endIndex = this.buffer[index + 3];
+        let type = this.set.types[id], result = type.name;
+        if (/\W/.test(result) && !type.isError)
+            result = JSON.stringify(result);
+        index += 4;
+        if (endIndex == index)
+            return result;
+        let children = [];
+        while (index < endIndex) {
+            children.push(this.childString(index));
+            index = this.buffer[index + 3];
+        }
+        return result + "(" + children.join(",") + ")";
+    }
+    /**
+    @internal
+    */
+    findChild(startIndex, endIndex, dir, pos, side) {
+        let { buffer } = this, pick = -1;
+        for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
+            if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
+                pick = i;
+                if (dir > 0)
+                    break;
+            }
+        }
+        return pick;
+    }
+    /**
+    @internal
+    */
+    slice(startI, endI, from) {
+        let b = this.buffer;
+        let copy = new Uint16Array(endI - startI), len = 0;
+        for (let i = startI, j = 0; i < endI;) {
+            copy[j++] = b[i++];
+            copy[j++] = b[i++] - from;
+            let to = copy[j++] = b[i++] - from;
+            copy[j++] = b[i++] - startI;
+            len = Math.max(len, to);
+        }
+        return new TreeBuffer(copy, len, this.set);
+    }
+}
+function checkSide(side, pos, from, to) {
+    switch (side) {
+        case -2 /* Side.Before */: return from < pos;
+        case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;
+        case 0 /* Side.Around */: return from < pos && to > pos;
+        case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;
+        case 2 /* Side.After */: return to > pos;
+        case 4 /* Side.DontCare */: return true;
+    }
+}
+function resolveNode(node, pos, side, overlays) {
+    var _a;
+    // Move up to a node that actually holds the position, if possible
+    while (node.from == node.to ||
+        (side < 1 ? node.from >= pos : node.from > pos) ||
+        (side > -1 ? node.to <= pos : node.to < pos)) {
+        let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
+        if (!parent)
+            return node;
+        node = parent;
+    }
+    let mode = overlays ? 0 : IterMode$1.IgnoreOverlays;
+    // Must go up out of overlays when those do not overlap with pos
+    if (overlays)
+        for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
+            if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
+                node = parent;
+        }
+    for (;;) {
+        let inner = node.enter(pos, side, mode);
+        if (!inner)
+            return node;
+        node = inner;
+    }
+}
+class BaseNode {
+    cursor(mode = 0) { return new TreeCursor(this, mode); }
+    getChild(type, before = null, after = null) {
+        let r = getChildren(this, type, before, after);
+        return r.length ? r[0] : null;
+    }
+    getChildren(type, before = null, after = null) {
+        return getChildren(this, type, before, after);
+    }
+    resolve(pos, side = 0) {
+        return resolveNode(this, pos, side, false);
+    }
+    resolveInner(pos, side = 0) {
+        return resolveNode(this, pos, side, true);
+    }
+    matchContext(context) {
+        return matchNodeContext(this.parent, context);
+    }
+    enterUnfinishedNodesBefore(pos) {
+        let scan = this.childBefore(pos), node = this;
+        while (scan) {
+            let last = scan.lastChild;
+            if (!last || last.to != scan.to)
+                break;
+            if (last.type.isError && last.from == last.to) {
+                node = scan;
+                scan = last.prevSibling;
+            }
+            else {
+                scan = last;
+            }
+        }
+        return node;
+    }
+    get node() { return this; }
+    get next() { return this.parent; }
+}
+class TreeNode extends BaseNode {
+    constructor(_tree, from, 
+    // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
+    index, _parent) {
+        super();
+        this._tree = _tree;
+        this.from = from;
+        this.index = index;
+        this._parent = _parent;
+    }
+    get type() { return this._tree.type; }
+    get name() { return this._tree.type.name; }
+    get to() { return this.from + this._tree.length; }
+    nextChild(i, dir, pos, side, mode = 0) {
+        for (let parent = this;;) {
+            for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
+                let next = children[i], start = positions[i] + parent.from;
+                if (!checkSide(side, pos, start, start + next.length))
+                    continue;
+                if (next instanceof TreeBuffer) {
+                    if (mode & IterMode$1.ExcludeBuffers)
+                        continue;
+                    let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
+                    if (index > -1)
+                        return new BufferNode(new BufferContext(parent, next, i, start), null, index);
+                }
+                else if ((mode & IterMode$1.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {
+                    let mounted;
+                    if (!(mode & IterMode$1.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
+                        return new TreeNode(mounted.tree, start, i, parent);
+                    let inner = new TreeNode(next, start, i, parent);
+                    return (mode & IterMode$1.IncludeAnonymous) || !inner.type.isAnonymous ? inner
+                        : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
+                }
+            }
+            if ((mode & IterMode$1.IncludeAnonymous) || !parent.type.isAnonymous)
+                return null;
+            if (parent.index >= 0)
+                i = parent.index + dir;
+            else
+                i = dir < 0 ? -1 : parent._parent._tree.children.length;
+            parent = parent._parent;
+            if (!parent)
+                return null;
+        }
+    }
+    get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); }
+    get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }
+    childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }
+    childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }
+    enter(pos, side, mode = 0) {
+        let mounted;
+        if (!(mode & IterMode$1.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
+            let rPos = pos - this.from;
+            for (let { from, to } of mounted.overlay) {
+                if ((side > 0 ? from <= rPos : from < rPos) &&
+                    (side < 0 ? to >= rPos : to > rPos))
+                    return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
+            }
+        }
+        return this.nextChild(0, 1, pos, side, mode);
+    }
+    nextSignificantParent() {
+        let val = this;
+        while (val.type.isAnonymous && val._parent)
+            val = val._parent;
+        return val;
+    }
+    get parent() {
+        return this._parent ? this._parent.nextSignificantParent() : null;
+    }
+    get nextSibling() {
+        return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null;
+    }
+    get prevSibling() {
+        return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null;
+    }
+    get tree() { return this._tree; }
+    toTree() { return this._tree; }
+    /**
+    @internal
+    */
+    toString() { return this._tree.toString(); }
+}
+function getChildren(node, type, before, after) {
+    let cur = node.cursor(), result = [];
+    if (!cur.firstChild())
+        return result;
+    if (before != null)
+        for (let found = false; !found;) {
+            found = cur.type.is(before);
+            if (!cur.nextSibling())
+                return result;
+        }
+    for (;;) {
+        if (after != null && cur.type.is(after))
+            return result;
+        if (cur.type.is(type))
+            result.push(cur.node);
+        if (!cur.nextSibling())
+            return after == null ? result : [];
+    }
+}
+function matchNodeContext(node, context, i = context.length - 1) {
+    for (let p = node; i >= 0; p = p.parent) {
+        if (!p)
+            return false;
+        if (!p.type.isAnonymous) {
+            if (context[i] && context[i] != p.name)
+                return false;
+            i--;
+        }
+    }
+    return true;
+}
+class BufferContext {
+    constructor(parent, buffer, index, start) {
+        this.parent = parent;
+        this.buffer = buffer;
+        this.index = index;
+        this.start = start;
+    }
+}
+class BufferNode extends BaseNode {
+    get name() { return this.type.name; }
+    get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
+    get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
+    constructor(context, _parent, index) {
+        super();
+        this.context = context;
+        this._parent = _parent;
+        this.index = index;
+        this.type = context.buffer.set.types[context.buffer.buffer[index]];
+    }
+    child(dir, pos, side) {
+        let { buffer } = this.context;
+        let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
+        return index < 0 ? null : new BufferNode(this.context, this, index);
+    }
+    get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }
+    get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }
+    childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }
+    childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }
+    enter(pos, side, mode = 0) {
+        if (mode & IterMode$1.ExcludeBuffers)
+            return null;
+        let { buffer } = this.context;
+        let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
+        return index < 0 ? null : new BufferNode(this.context, this, index);
+    }
+    get parent() {
+        return this._parent || this.context.parent.nextSignificantParent();
+    }
+    externalSibling(dir) {
+        return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */);
+    }
+    get nextSibling() {
+        let { buffer } = this.context;
+        let after = buffer.buffer[this.index + 3];
+        if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
+            return new BufferNode(this.context, this._parent, after);
+        return this.externalSibling(1);
+    }
+    get prevSibling() {
+        let { buffer } = this.context;
+        let parentStart = this._parent ? this._parent.index + 4 : 0;
+        if (this.index == parentStart)
+            return this.externalSibling(-1);
+        return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
+    }
+    get tree() { return null; }
+    toTree() {
+        let children = [], positions = [];
+        let { buffer } = this.context;
+        let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
+        if (endI > startI) {
+            let from = buffer.buffer[this.index + 1];
+            children.push(buffer.slice(startI, endI, from));
+            positions.push(0);
+        }
+        return new Tree(this.type, children, positions, this.to - this.from);
+    }
+    /**
+    @internal
+    */
+    toString() { return this.context.buffer.childString(this.index); }
+}
+function iterStack(heads) {
+    if (!heads.length)
+        return null;
+    let pick = 0, picked = heads[0];
+    for (let i = 1; i < heads.length; i++) {
+        let node = heads[i];
+        if (node.from > picked.from || node.to < picked.to) {
+            picked = node;
+            pick = i;
+        }
+    }
+    let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
+    let newHeads = heads.slice();
+    if (next)
+        newHeads[pick] = next;
+    else
+        newHeads.splice(pick, 1);
+    return new StackIterator(newHeads, picked);
+}
+class StackIterator {
+    constructor(heads, node) {
+        this.heads = heads;
+        this.node = node;
+    }
+    get next() { return iterStack(this.heads); }
+}
+function stackIterator(tree, pos, side) {
+    let inner = tree.resolveInner(pos, side), layers = null;
+    for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {
+        if (scan.index < 0) { // This is an overlay root
+            let parent = scan.parent;
+            (layers || (layers = [inner])).push(parent.resolve(pos, side));
+            scan = parent;
+        }
+        else {
+            let mount = MountedTree.get(scan.tree);
+            // Relevant overlay branching off
+            if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
+                let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
+                (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
+            }
+        }
+    }
+    return layers ? iterStack(layers) : inner;
+}
+/**
+A tree cursor object focuses on a given node in a syntax tree, and
+allows you to move to adjacent nodes.
+*/
+class TreeCursor {
+    /**
+    Shorthand for `.type.name`.
+    */
+    get name() { return this.type.name; }
+    /**
+    @internal
+    */
+    constructor(node, 
+    /**
+    @internal
+    */
+    mode = 0) {
+        this.mode = mode;
+        /**
+        @internal
+        */
+        this.buffer = null;
+        this.stack = [];
+        /**
+        @internal
+        */
+        this.index = 0;
+        this.bufferNode = null;
+        if (node instanceof TreeNode) {
+            this.yieldNode(node);
+        }
+        else {
+            this._tree = node.context.parent;
+            this.buffer = node.context;
+            for (let n = node._parent; n; n = n._parent)
+                this.stack.unshift(n.index);
+            this.bufferNode = node;
+            this.yieldBuf(node.index);
+        }
+    }
+    yieldNode(node) {
+        if (!node)
+            return false;
+        this._tree = node;
+        this.type = node.type;
+        this.from = node.from;
+        this.to = node.to;
+        return true;
+    }
+    yieldBuf(index, type) {
+        this.index = index;
+        let { start, buffer } = this.buffer;
+        this.type = type || buffer.set.types[buffer.buffer[index]];
+        this.from = start + buffer.buffer[index + 1];
+        this.to = start + buffer.buffer[index + 2];
+        return true;
+    }
+    /**
+    @internal
+    */
+    yield(node) {
+        if (!node)
+            return false;
+        if (node instanceof TreeNode) {
+            this.buffer = null;
+            return this.yieldNode(node);
+        }
+        this.buffer = node.context;
+        return this.yieldBuf(node.index, node.type);
+    }
+    /**
+    @internal
+    */
+    toString() {
+        return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
+    }
+    /**
+    @internal
+    */
+    enterChild(dir, pos, side) {
+        if (!this.buffer)
+            return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
+        let { buffer } = this.buffer;
+        let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
+        if (index < 0)
+            return false;
+        this.stack.push(this.index);
+        return this.yieldBuf(index);
+    }
+    /**
+    Move the cursor to this node's first child. When this returns
+    false, the node has no child, and the cursor has not been moved.
+    */
+    firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); }
+    /**
+    Move the cursor to this node's last child.
+    */
+    lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); }
+    /**
+    Move the cursor to the first child that ends after `pos`.
+    */
+    childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); }
+    /**
+    Move to the last child that starts before `pos`.
+    */
+    childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); }
+    /**
+    Move the cursor to the child around `pos`. If side is -1 the
+    child may end at that position, when 1 it may start there. This
+    will also enter [overlaid](#common.MountedTree.overlay)
+    [mounted](#common.NodeProp^mounted) trees unless `overlays` is
+    set to false.
+    */
+    enter(pos, side, mode = this.mode) {
+        if (!this.buffer)
+            return this.yield(this._tree.enter(pos, side, mode));
+        return mode & IterMode$1.ExcludeBuffers ? false : this.enterChild(1, pos, side);
+    }
+    /**
+    Move to the node's parent node, if this isn't the top node.
+    */
+    parent() {
+        if (!this.buffer)
+            return this.yieldNode((this.mode & IterMode$1.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
+        if (this.stack.length)
+            return this.yieldBuf(this.stack.pop());
+        let parent = (this.mode & IterMode$1.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
+        this.buffer = null;
+        return this.yieldNode(parent);
+    }
+    /**
+    @internal
+    */
+    sibling(dir) {
+        if (!this.buffer)
+            return !this._tree._parent ? false
+                : this.yield(this._tree.index < 0 ? null
+                    : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode));
+        let { buffer } = this.buffer, d = this.stack.length - 1;
+        if (dir < 0) {
+            let parentStart = d < 0 ? 0 : this.stack[d] + 4;
+            if (this.index != parentStart)
+                return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
+        }
+        else {
+            let after = buffer.buffer[this.index + 3];
+            if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
+                return this.yieldBuf(after);
+        }
+        return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false;
+    }
+    /**
+    Move to this node's next sibling, if any.
+    */
+    nextSibling() { return this.sibling(1); }
+    /**
+    Move to this node's previous sibling, if any.
+    */
+    prevSibling() { return this.sibling(-1); }
+    atLastNode(dir) {
+        let index, parent, { buffer } = this;
+        if (buffer) {
+            if (dir > 0) {
+                if (this.index < buffer.buffer.buffer.length)
+                    return false;
+            }
+            else {
+                for (let i = 0; i < this.index; i++)
+                    if (buffer.buffer.buffer[i + 3] < this.index)
+                        return false;
+            }
+            ({ index, parent } = buffer);
+        }
+        else {
+            ({ index, _parent: parent } = this._tree);
+        }
+        for (; parent; { index, _parent: parent } = parent) {
+            if (index > -1)
+                for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
+                    let child = parent._tree.children[i];
+                    if ((this.mode & IterMode$1.IncludeAnonymous) ||
+                        child instanceof TreeBuffer ||
+                        !child.type.isAnonymous ||
+                        hasChild(child))
+                        return false;
+                }
+        }
+        return true;
+    }
+    move(dir, enter) {
+        if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */))
+            return true;
+        for (;;) {
+            if (this.sibling(dir))
+                return true;
+            if (this.atLastNode(dir) || !this.parent())
+                return false;
+        }
+    }
+    /**
+    Move to the next node in a
+    [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
+    traversal, going from a node to its first child or, if the
+    current node is empty or `enter` is false, its next sibling or
+    the next sibling of the first parent node that has one.
+    */
+    next(enter = true) { return this.move(1, enter); }
+    /**
+    Move to the next node in a last-to-first pre-order traversal. A
+    node is followed by its last child or, if it has none, its
+    previous sibling or the previous sibling of the first parent
+    node that has one.
+    */
+    prev(enter = true) { return this.move(-1, enter); }
+    /**
+    Move the cursor to the innermost node that covers `pos`. If
+    `side` is -1, it will enter nodes that end at `pos`. If it is 1,
+    it will enter nodes that start at `pos`.
+    */
+    moveTo(pos, side = 0) {
+        // Move up to a node that actually holds the position, if possible
+        while (this.from == this.to ||
+            (side < 1 ? this.from >= pos : this.from > pos) ||
+            (side > -1 ? this.to <= pos : this.to < pos))
+            if (!this.parent())
+                break;
+        // Then scan down into child nodes as far as possible
+        while (this.enterChild(1, pos, side)) { }
+        return this;
+    }
+    /**
+    Get a [syntax node](#common.SyntaxNode) at the cursor's current
+    position.
+    */
+    get node() {
+        if (!this.buffer)
+            return this._tree;
+        let cache = this.bufferNode, result = null, depth = 0;
+        if (cache && cache.context == this.buffer) {
+            scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
+                for (let c = cache; c; c = c._parent)
+                    if (c.index == index) {
+                        if (index == this.index)
+                            return c;
+                        result = c;
+                        depth = d + 1;
+                        break scan;
+                    }
+                index = this.stack[--d];
+            }
+        }
+        for (let i = depth; i < this.stack.length; i++)
+            result = new BufferNode(this.buffer, result, this.stack[i]);
+        return this.bufferNode = new BufferNode(this.buffer, result, this.index);
+    }
+    /**
+    Get the [tree](#common.Tree) that represents the current node, if
+    any. Will return null when the node is in a [tree
+    buffer](#common.TreeBuffer).
+    */
+    get tree() {
+        return this.buffer ? null : this._tree._tree;
+    }
+    /**
+    Iterate over the current node and all its descendants, calling
+    `enter` when entering a node and `leave`, if given, when leaving
+    one. When `enter` returns `false`, any children of that node are
+    skipped, and `leave` isn't called for it.
+    */
+    iterate(enter, leave) {
+        for (let depth = 0;;) {
+            let mustLeave = false;
+            if (this.type.isAnonymous || enter(this) !== false) {
+                if (this.firstChild()) {
+                    depth++;
+                    continue;
+                }
+                if (!this.type.isAnonymous)
+                    mustLeave = true;
+            }
+            for (;;) {
+                if (mustLeave && leave)
+                    leave(this);
+                mustLeave = this.type.isAnonymous;
+                if (!depth)
+                    return;
+                if (this.nextSibling())
+                    break;
+                this.parent();
+                depth--;
+                mustLeave = true;
+            }
+        }
+    }
+    /**
+    Test whether the current node matches a given context—a sequence
+    of direct parent node names. Empty strings in the context array
+    are treated as wildcards.
+    */
+    matchContext(context) {
+        if (!this.buffer)
+            return matchNodeContext(this.node.parent, context);
+        let { buffer } = this.buffer, { types } = buffer.set;
+        for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
+            if (d < 0)
+                return matchNodeContext(this._tree, context, i);
+            let type = types[buffer.buffer[this.stack[d]]];
+            if (!type.isAnonymous) {
+                if (context[i] && context[i] != type.name)
+                    return false;
+                i--;
+            }
+        }
+        return true;
+    }
+}
+function hasChild(tree) {
+    return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
+}
+function buildTree(data) {
+    var _a;
+    let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
+    let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
+    let types = nodeSet.types;
+    let contextHash = 0, lookAhead = 0;
+    function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
+        let { id, start, end, size } = cursor;
+        let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
+        while (size < 0) {
+            cursor.next();
+            if (size == -1 /* SpecialRecord.Reuse */) {
+                let node = reused[id];
+                children.push(node);
+                positions.push(start - parentStart);
+                return;
+            }
+            else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change
+                contextHash = id;
+                return;
+            }
+            else if (size == -4 /* SpecialRecord.LookAhead */) {
+                lookAhead = id;
+                return;
+            }
+            else {
+                throw new RangeError(`Unrecognized record size: ${size}`);
+            }
+        }
+        let type = types[id], node, buffer;
+        let startPos = start - parentStart;
+        if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
+            // Small enough for a buffer, and no reused nodes inside
+            let data = new Uint16Array(buffer.size - buffer.skip);
+            let endPos = cursor.pos - buffer.size, index = data.length;
+            while (cursor.pos > endPos)
+                index = copyToBuffer(buffer.start, data, index);
+            node = new TreeBuffer(data, end - buffer.start, nodeSet);
+            startPos = buffer.start - parentStart;
+        }
+        else { // Make it a node
+            let endPos = cursor.pos - size;
+            cursor.next();
+            let localChildren = [], localPositions = [];
+            let localInRepeat = id >= minRepeatType ? id : -1;
+            let lastGroup = 0, lastEnd = end;
+            while (cursor.pos > endPos) {
+                if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
+                    if (cursor.end <= lastEnd - maxBufferLength) {
+                        makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
+                        lastGroup = localChildren.length;
+                        lastEnd = cursor.end;
+                    }
+                    cursor.next();
+                }
+                else if (depth > 2500 /* CutOff.Depth */) {
+                    takeFlatNode(start, endPos, localChildren, localPositions);
+                }
+                else {
+                    takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
+                }
+            }
+            if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
+                makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
+            localChildren.reverse();
+            localPositions.reverse();
+            if (localInRepeat > -1 && lastGroup > 0) {
+                let make = makeBalanced(type, contextAtStart);
+                node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
+            }
+            else {
+                node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
+            }
+        }
+        children.push(node);
+        positions.push(startPos);
+    }
+    function takeFlatNode(parentStart, minPos, children, positions) {
+        let nodes = []; // Temporary, inverted array of leaf nodes found, with absolute positions
+        let nodeCount = 0, stopAt = -1;
+        while (cursor.pos > minPos) {
+            let { id, start, end, size } = cursor;
+            if (size > 4) { // Not a leaf
+                cursor.next();
+            }
+            else if (stopAt > -1 && start < stopAt) {
+                break;
+            }
+            else {
+                if (stopAt < 0)
+                    stopAt = end - maxBufferLength;
+                nodes.push(id, start, end);
+                nodeCount++;
+                cursor.next();
+            }
+        }
+        if (nodeCount) {
+            let buffer = new Uint16Array(nodeCount * 4);
+            let start = nodes[nodes.length - 2];
+            for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
+                buffer[j++] = nodes[i];
+                buffer[j++] = nodes[i + 1] - start;
+                buffer[j++] = nodes[i + 2] - start;
+                buffer[j++] = j;
+            }
+            children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));
+            positions.push(start - parentStart);
+        }
+    }
+    function makeBalanced(type, contextHash) {
+        return (children, positions, length) => {
+            let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
+            if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
+                if (!lastI && last.type == type && last.length == length)
+                    return last;
+                if (lookAheadProp = last.prop(NodeProp$1.lookAhead))
+                    lookAhead = positions[lastI] + last.length + lookAheadProp;
+            }
+            return makeTree(type, children, positions, length, lookAhead, contextHash);
+        };
+    }
+    function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead, contextHash) {
+        let localChildren = [], localPositions = [];
+        while (children.length > i) {
+            localChildren.push(children.pop());
+            localPositions.push(positions.pop() + base - from);
+        }
+        children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to, contextHash));
+        positions.push(from - base);
+    }
+    function makeTree(type, children, positions, length, lookAhead, contextHash, props) {
+        if (contextHash) {
+            let pair = [NodeProp$1.contextHash, contextHash];
+            props = props ? [pair].concat(props) : [pair];
+        }
+        if (lookAhead > 25) {
+            let pair = [NodeProp$1.lookAhead, lookAhead];
+            props = props ? [pair].concat(props) : [pair];
+        }
+        return new Tree(type, children, positions, length, props);
+    }
+    function findBufferSize(maxSize, inRepeat) {
+        // Scan through the buffer to find previous siblings that fit
+        // together in a TreeBuffer, and don't contain any reused nodes
+        // (which can't be stored in a buffer).
+        // If `inRepeat` is > -1, ignore node boundaries of that type for
+        // nesting, but make sure the end falls either at the start
+        // (`maxSize`) or before such a node.
+        let fork = cursor.fork();
+        let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
+        let result = { size: 0, start: 0, skip: 0 };
+        scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
+            let nodeSize = fork.size;
+            // Pretend nested repeat nodes of the same type don't exist
+            if (fork.id == inRepeat && nodeSize >= 0) {
+                // Except that we store the current state as a valid return
+                // value.
+                result.size = size;
+                result.start = start;
+                result.skip = skip;
+                skip += 4;
+                size += 4;
+                fork.next();
+                continue;
+            }
+            let startPos = fork.pos - nodeSize;
+            if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
+                break;
+            let localSkipped = fork.id >= minRepeatType ? 4 : 0;
+            let nodeStart = fork.start;
+            fork.next();
+            while (fork.pos > startPos) {
+                if (fork.size < 0) {
+                    if (fork.size == -3 /* SpecialRecord.ContextChange */)
+                        localSkipped += 4;
+                    else
+                        break scan;
+                }
+                else if (fork.id >= minRepeatType) {
+                    localSkipped += 4;
+                }
+                fork.next();
+            }
+            start = nodeStart;
+            size += nodeSize;
+            skip += localSkipped;
+        }
+        if (inRepeat < 0 || size == maxSize) {
+            result.size = size;
+            result.start = start;
+            result.skip = skip;
+        }
+        return result.size > 4 ? result : undefined;
+    }
+    function copyToBuffer(bufferStart, buffer, index) {
+        let { id, start, end, size } = cursor;
+        cursor.next();
+        if (size >= 0 && id < minRepeatType) {
+            let startIndex = index;
+            if (size > 4) {
+                let endPos = cursor.pos - (size - 4);
+                while (cursor.pos > endPos)
+                    index = copyToBuffer(bufferStart, buffer, index);
+            }
+            buffer[--index] = startIndex;
+            buffer[--index] = end - bufferStart;
+            buffer[--index] = start - bufferStart;
+            buffer[--index] = id;
+        }
+        else if (size == -3 /* SpecialRecord.ContextChange */) {
+            contextHash = id;
+        }
+        else if (size == -4 /* SpecialRecord.LookAhead */) {
+            lookAhead = id;
+        }
+        return index;
+    }
+    let children = [], positions = [];
+    while (cursor.pos > 0)
+        takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
+    let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
+    return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
+}
+const nodeSizeCache = new WeakMap;
+function nodeSize(balanceType, node) {
+    if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
+        return 1;
+    let size = nodeSizeCache.get(node);
+    if (size == null) {
+        size = 1;
+        for (let child of node.children) {
+            if (child.type != balanceType || !(child instanceof Tree)) {
+                size = 1;
+                break;
+            }
+            size += nodeSize(balanceType, child);
+        }
+        nodeSizeCache.set(node, size);
+    }
+    return size;
+}
+function balanceRange(
+// The type the balanced tree's inner nodes.
+balanceType, 
+// The direct children and their positions
+children, positions, 
+// The index range in children/positions to use
+from, to, 
+// The start position of the nodes, relative to their parent.
+start, 
+// Length of the outer node
+length, 
+// Function to build the top node of the balanced tree
+mkTop, 
+// Function to build internal nodes for the balanced tree
+mkTree) {
+    let total = 0;
+    for (let i = from; i < to; i++)
+        total += nodeSize(balanceType, children[i]);
+    let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);
+    let localChildren = [], localPositions = [];
+    function divide(children, positions, from, to, offset) {
+        for (let i = from; i < to;) {
+            let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
+            i++;
+            for (; i < to; i++) {
+                let nextSize = nodeSize(balanceType, children[i]);
+                if (groupSize + nextSize >= maxChild)
+                    break;
+                groupSize += nextSize;
+            }
+            if (i == groupFrom + 1) {
+                if (groupSize > maxChild) {
+                    let only = children[groupFrom]; // Only trees can have a size > 1
+                    divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
+                    continue;
+                }
+                localChildren.push(children[groupFrom]);
+            }
+            else {
+                let length = positions[i - 1] + children[i - 1].length - groupStart;
+                localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
+            }
+            localPositions.push(groupStart + offset - start);
+        }
+    }
+    divide(children, positions, from, to, 0);
+    return (mkTop || mkTree)(localChildren, localPositions, length);
+}
+/**
+Provides a way to associate values with pieces of trees. As long
+as that part of the tree is reused, the associated values can be
+retrieved from an updated tree.
+*/
+class NodeWeakMap {
+    constructor() {
+        this.map = new WeakMap();
+    }
+    setBuffer(buffer, index, value) {
+        let inner = this.map.get(buffer);
+        if (!inner)
+            this.map.set(buffer, inner = new Map);
+        inner.set(index, value);
+    }
+    getBuffer(buffer, index) {
+        let inner = this.map.get(buffer);
+        return inner && inner.get(index);
+    }
+    /**
+    Set the value for this syntax node.
+    */
+    set(node, value) {
+        if (node instanceof BufferNode)
+            this.setBuffer(node.context.buffer, node.index, value);
+        else if (node instanceof TreeNode)
+            this.map.set(node.tree, value);
+    }
+    /**
+    Retrieve value for this syntax node, if it exists in the map.
+    */
+    get(node) {
+        return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index)
+            : node instanceof TreeNode ? this.map.get(node.tree) : undefined;
+    }
+    /**
+    Set the value for the node that a cursor currently points to.
+    */
+    cursorSet(cursor, value) {
+        if (cursor.buffer)
+            this.setBuffer(cursor.buffer.buffer, cursor.index, value);
+        else
+            this.map.set(cursor.tree, value);
+    }
+    /**
+    Retrieve the value for the node that a cursor currently points
+    to.
+    */
+    cursorGet(cursor) {
+        return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
+    }
+}
+
+/**
+Tree fragments are used during [incremental
+parsing](#common.Parser.startParse) to track parts of old trees
+that can be reused in a new parse. An array of fragments is used
+to track regions of an old tree whose nodes might be reused in new
+parses. Use the static
+[`applyChanges`](#common.TreeFragment^applyChanges) method to
+update fragments for document changes.
+*/
+class TreeFragment {
+    /**
+    Construct a tree fragment. You'll usually want to use
+    [`addTree`](#common.TreeFragment^addTree) and
+    [`applyChanges`](#common.TreeFragment^applyChanges) instead of
+    calling this directly.
+    */
+    constructor(
+    /**
+    The start of the unchanged range pointed to by this fragment.
+    This refers to an offset in the _updated_ document (as opposed
+    to the original tree).
+    */
+    from, 
+    /**
+    The end of the unchanged range.
+    */
+    to, 
+    /**
+    The tree that this fragment is based on.
+    */
+    tree, 
+    /**
+    The offset between the fragment's tree and the document that
+    this fragment can be used against. Add this when going from
+    document to tree positions, subtract it to go from tree to
+    document positions.
+    */
+    offset, openStart = false, openEnd = false) {
+        this.from = from;
+        this.to = to;
+        this.tree = tree;
+        this.offset = offset;
+        this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0);
+    }
+    /**
+    Whether the start of the fragment represents the start of a
+    parse, or the end of a change. (In the second case, it may not
+    be safe to reuse some nodes at the start, depending on the
+    parsing algorithm.)
+    */
+    get openStart() { return (this.open & 1 /* Open.Start */) > 0; }
+    /**
+    Whether the end of the fragment represents the end of a
+    full-document parse, or the start of a change.
+    */
+    get openEnd() { return (this.open & 2 /* Open.End */) > 0; }
+    /**
+    Create a set of fragments from a freshly parsed tree, or update
+    an existing set of fragments by replacing the ones that overlap
+    with a tree with content from the new tree. When `partial` is
+    true, the parse is treated as incomplete, and the resulting
+    fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
+    true.
+    */
+    static addTree(tree, fragments = [], partial = false) {
+        let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
+        for (let f of fragments)
+            if (f.to > tree.length)
+                result.push(f);
+        return result;
+    }
+    /**
+    Apply a set of edits to an array of fragments, removing or
+    splitting fragments as necessary to remove edited ranges, and
+    adjusting offsets for fragments that moved.
+    */
+    static applyChanges(fragments, changes, minGap = 128) {
+        if (!changes.length)
+            return fragments;
+        let result = [];
+        let fI = 1, nextF = fragments.length ? fragments[0] : null;
+        for (let cI = 0, pos = 0, off = 0;; cI++) {
+            let nextC = cI < changes.length ? changes[cI] : null;
+            let nextPos = nextC ? nextC.fromA : 1e9;
+            if (nextPos - pos >= minGap)
+                while (nextF && nextF.from < nextPos) {
+                    let cut = nextF;
+                    if (pos >= cut.from || nextPos <= cut.to || off) {
+                        let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
+                        cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
+                    }
+                    if (cut)
+                        result.push(cut);
+                    if (nextF.to > nextPos)
+                        break;
+                    nextF = fI < fragments.length ? fragments[fI++] : null;
+                }
+            if (!nextC)
+                break;
+            pos = nextC.toA;
+            off = nextC.toA - nextC.toB;
+        }
+        return result;
+    }
+}
+/**
+A superclass that parsers should extend.
+*/
+class Parser {
+    /**
+    Start a parse, returning a [partial parse](#common.PartialParse)
+    object. [`fragments`](#common.TreeFragment) can be passed in to
+    make the parse incremental.
+    
+    By default, the entire input is parsed. You can pass `ranges`,
+    which should be a sorted array of non-empty, non-overlapping
+    ranges, to parse only those ranges. The tree returned in that
+    case will start at `ranges[0].from`.
+    */
+    startParse(input, fragments, ranges) {
+        if (typeof input == "string")
+            input = new StringInput(input);
+        ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map(r => new Range(r.from, r.to)) : [new Range(0, 0)];
+        return this.createParse(input, fragments || [], ranges);
+    }
+    /**
+    Run a full parse, returning the resulting tree.
+    */
+    parse(input, fragments, ranges) {
+        let parse = this.startParse(input, fragments, ranges);
+        for (;;) {
+            let done = parse.advance();
+            if (done)
+                return done;
+        }
+    }
+}
+class StringInput {
+    constructor(string) {
+        this.string = string;
+    }
+    get length() { return this.string.length; }
+    chunk(from) { return this.string.slice(from); }
+    get lineChunks() { return false; }
+    read(from, to) { return this.string.slice(from, to); }
+}
+new NodeProp$1({ perNode: true });
+
+let nextTagID = 0;
+/**
+Highlighting tags are markers that denote a highlighting category.
+They are [associated](#highlight.styleTags) with parts of a syntax
+tree by a language mode, and then mapped to an actual CSS style by
+a [highlighter](#highlight.Highlighter).
+
+Because syntax tree node types and highlight styles have to be
+able to talk the same language, CodeMirror uses a mostly _closed_
+[vocabulary](#highlight.tags) of syntax tags (as opposed to
+traditional open string-based systems, which make it hard for
+highlighting themes to cover all the tokens produced by the
+various languages).
+
+It _is_ possible to [define](#highlight.Tag^define) your own
+highlighting tags for system-internal use (where you control both
+the language package and the highlighter), but such tags will not
+be picked up by regular highlighters (though you can derive them
+from standard tags to allow highlighters to fall back to those).
+*/
+class Tag {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    The optional name of the base tag @internal
+    */
+    name, 
+    /**
+    The set of this tag and all its parent tags, starting with
+    this one itself and sorted in order of decreasing specificity.
+    */
+    set, 
+    /**
+    The base unmodified tag that this one is based on, if it's
+    modified @internal
+    */
+    base, 
+    /**
+    The modifiers applied to this.base @internal
+    */
+    modified) {
+        this.name = name;
+        this.set = set;
+        this.base = base;
+        this.modified = modified;
+        /**
+        @internal
+        */
+        this.id = nextTagID++;
+    }
+    toString() {
+        let { name } = this;
+        for (let mod of this.modified)
+            if (mod.name)
+                name = `${mod.name}(${name})`;
+        return name;
+    }
+    static define(nameOrParent, parent) {
+        let name = typeof nameOrParent == "string" ? nameOrParent : "?";
+        if (nameOrParent instanceof Tag)
+            parent = nameOrParent;
+        if (parent === null || parent === void 0 ? void 0 : parent.base)
+            throw new Error("Can not derive from a modified tag");
+        let tag = new Tag(name, [], null, []);
+        tag.set.push(tag);
+        if (parent)
+            for (let t of parent.set)
+                tag.set.push(t);
+        return tag;
+    }
+    /**
+    Define a tag _modifier_, which is a function that, given a tag,
+    will return a tag that is a subtag of the original. Applying the
+    same modifier to a twice tag will return the same value (`m1(t1)
+    == m1(t1)`) and applying multiple modifiers will, regardless or
+    order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
+    
+    When multiple modifiers are applied to a given base tag, each
+    smaller set of modifiers is registered as a parent, so that for
+    example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
+    `m1(m3(t1)`, and so on.
+    */
+    static defineModifier(name) {
+        let mod = new Modifier(name);
+        return (tag) => {
+            if (tag.modified.indexOf(mod) > -1)
+                return tag;
+            return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
+        };
+    }
+}
+let nextModifierID = 0;
+class Modifier {
+    constructor(name) {
+        this.name = name;
+        this.instances = [];
+        this.id = nextModifierID++;
+    }
+    static get(base, mods) {
+        if (!mods.length)
+            return base;
+        let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));
+        if (exists)
+            return exists;
+        let set = [], tag = new Tag(base.name, set, base, mods);
+        for (let m of mods)
+            m.instances.push(tag);
+        let configs = powerSet(mods);
+        for (let parent of base.set)
+            if (!parent.modified.length)
+                for (let config of configs)
+                    set.push(Modifier.get(parent, config));
+        return tag;
+    }
+}
+function sameArray(a, b) {
+    return a.length == b.length && a.every((x, i) => x == b[i]);
+}
+function powerSet(array) {
+    let sets = [[]];
+    for (let i = 0; i < array.length; i++) {
+        for (let j = 0, e = sets.length; j < e; j++) {
+            sets.push(sets[j].concat(array[i]));
+        }
+    }
+    return sets.sort((a, b) => b.length - a.length);
+}
+/**
+This function is used to add a set of tags to a language syntax
+via [`NodeSet.extend`](#common.NodeSet.extend) or
+[`LRParser.configure`](#lr.LRParser.configure).
+
+The argument object maps node selectors to [highlighting
+tags](#highlight.Tag) or arrays of tags.
+
+Node selectors may hold one or more (space-separated) node paths.
+Such a path can be a [node name](#common.NodeType.name), or
+multiple node names (or `*` wildcards) separated by slash
+characters, as in `"Block/Declaration/VariableName"`. Such a path
+matches the final node but only if its direct parent nodes are the
+other nodes mentioned. A `*` in such a path matches any parent,
+but only a single level—wildcards that match multiple parents
+aren't supported, both for efficiency reasons and because Lezer
+trees make it rather hard to reason about what they would match.)
+
+A path can be ended with `/...` to indicate that the tag assigned
+to the node should also apply to all child nodes, even if they
+match their own style (by default, only the innermost style is
+used).
+
+When a path ends in `!`, as in `Attribute!`, no further matching
+happens for the node's child nodes, and the entire node gets the
+given style.
+
+In this notation, node names that contain `/`, `!`, `*`, or `...`
+must be quoted as JSON strings.
+
+For example:
+
+```javascript
+parser.withProps(
+  styleTags({
+    // Style Number and BigNumber nodes
+    "Number BigNumber": tags.number,
+    // Style Escape nodes whose parent is String
+    "String/Escape": tags.escape,
+    // Style anything inside Attributes nodes
+    "Attributes!": tags.meta,
+    // Add a style to all content inside Italic nodes
+    "Italic/...": tags.emphasis,
+    // Style InvalidString nodes as both `string` and `invalid`
+    "InvalidString": [tags.string, tags.invalid],
+    // Style the node named "/" as punctuation
+    '"/"': tags.punctuation
+  })
+)
+```
+*/
+function styleTags(spec) {
+    let byName = Object.create(null);
+    for (let prop in spec) {
+        let tags = spec[prop];
+        if (!Array.isArray(tags))
+            tags = [tags];
+        for (let part of prop.split(" "))
+            if (part) {
+                let pieces = [], mode = 2 /* Mode.Normal */, rest = part;
+                for (let pos = 0;;) {
+                    if (rest == "..." && pos > 0 && pos + 3 == part.length) {
+                        mode = 1 /* Mode.Inherit */;
+                        break;
+                    }
+                    let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
+                    if (!m)
+                        throw new RangeError("Invalid path: " + part);
+                    pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
+                    pos += m[0].length;
+                    if (pos == part.length)
+                        break;
+                    let next = part[pos++];
+                    if (pos == part.length && next == "!") {
+                        mode = 0 /* Mode.Opaque */;
+                        break;
+                    }
+                    if (next != "/")
+                        throw new RangeError("Invalid path: " + part);
+                    rest = part.slice(pos);
+                }
+                let last = pieces.length - 1, inner = pieces[last];
+                if (!inner)
+                    throw new RangeError("Invalid path: " + part);
+                let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);
+                byName[inner] = rule.sort(byName[inner]);
+            }
+    }
+    return ruleNodeProp.add(byName);
+}
+const ruleNodeProp = new NodeProp$1();
+class Rule {
+    constructor(tags, mode, context, next) {
+        this.tags = tags;
+        this.mode = mode;
+        this.context = context;
+        this.next = next;
+    }
+    get opaque() { return this.mode == 0 /* Mode.Opaque */; }
+    get inherit() { return this.mode == 1 /* Mode.Inherit */; }
+    sort(other) {
+        if (!other || other.depth < this.depth) {
+            this.next = other;
+            return this;
+        }
+        other.next = this.sort(other.next);
+        return other;
+    }
+    get depth() { return this.context ? this.context.length : 0; }
+}
+Rule.empty = new Rule([], 2 /* Mode.Normal */, null);
+/**
+Define a [highlighter](#highlight.Highlighter) from an array of
+tag/class pairs. Classes associated with more specific tags will
+take precedence.
+*/
+function tagHighlighter(tags, options) {
+    let map = Object.create(null);
+    for (let style of tags) {
+        if (!Array.isArray(style.tag))
+            map[style.tag.id] = style.class;
+        else
+            for (let tag of style.tag)
+                map[tag.id] = style.class;
+    }
+    let { scope, all = null } = options || {};
+    return {
+        style: (tags) => {
+            let cls = all;
+            for (let tag of tags) {
+                for (let sub of tag.set) {
+                    let tagClass = map[sub.id];
+                    if (tagClass) {
+                        cls = cls ? cls + " " + tagClass : tagClass;
+                        break;
+                    }
+                }
+            }
+            return cls;
+        },
+        scope
+    };
+}
+function highlightTags(highlighters, tags) {
+    let result = null;
+    for (let highlighter of highlighters) {
+        let value = highlighter.style(tags);
+        if (value)
+            result = result ? result + " " + value : value;
+    }
+    return result;
+}
+/**
+Highlight the given [tree](#common.Tree) with the given
+[highlighter](#highlight.Highlighter). Often, the higher-level
+[`highlightCode`](#highlight.highlightCode) function is easier to
+use.
+*/
+function highlightTree(tree, highlighter, 
+/**
+Assign styling to a region of the text. Will be called, in order
+of position, for any ranges where more than zero classes apply.
+`classes` is a space separated string of CSS classes.
+*/
+putStyle, 
+/**
+The start of the range to highlight.
+*/
+from = 0, 
+/**
+The end of the range.
+*/
+to = tree.length) {
+    let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
+    builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
+    builder.flush(to);
+}
+class HighlightBuilder {
+    constructor(at, highlighters, span) {
+        this.at = at;
+        this.highlighters = highlighters;
+        this.span = span;
+        this.class = "";
+    }
+    startSpan(at, cls) {
+        if (cls != this.class) {
+            this.flush(at);
+            if (at > this.at)
+                this.at = at;
+            this.class = cls;
+        }
+    }
+    flush(to) {
+        if (to > this.at && this.class)
+            this.span(this.at, to, this.class);
+    }
+    highlightRange(cursor, from, to, inheritedClass, highlighters) {
+        let { type, from: start, to: end } = cursor;
+        if (start >= to || end <= from)
+            return;
+        if (type.isTop)
+            highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
+        let cls = inheritedClass;
+        let rule = getStyleTags(cursor) || Rule.empty;
+        let tagCls = highlightTags(highlighters, rule.tags);
+        if (tagCls) {
+            if (cls)
+                cls += " ";
+            cls += tagCls;
+            if (rule.mode == 1 /* Mode.Inherit */)
+                inheritedClass += (inheritedClass ? " " : "") + tagCls;
+        }
+        this.startSpan(Math.max(from, start), cls);
+        if (rule.opaque)
+            return;
+        let mounted = cursor.tree && cursor.tree.prop(NodeProp$1.mounted);
+        if (mounted && mounted.overlay) {
+            let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
+            let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
+            let hasChild = cursor.firstChild();
+            for (let i = 0, pos = start;; i++) {
+                let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
+                let nextPos = next ? next.from + start : end;
+                let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
+                if (rangeFrom < rangeTo && hasChild) {
+                    while (cursor.from < rangeTo) {
+                        this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
+                        this.startSpan(Math.min(rangeTo, cursor.to), cls);
+                        if (cursor.to >= nextPos || !cursor.nextSibling())
+                            break;
+                    }
+                }
+                if (!next || nextPos > to)
+                    break;
+                pos = next.to + start;
+                if (pos > from) {
+                    this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters);
+                    this.startSpan(Math.min(to, pos), cls);
+                }
+            }
+            if (hasChild)
+                cursor.parent();
+        }
+        else if (cursor.firstChild()) {
+            if (mounted)
+                inheritedClass = "";
+            do {
+                if (cursor.to <= from)
+                    continue;
+                if (cursor.from >= to)
+                    break;
+                this.highlightRange(cursor, from, to, inheritedClass, highlighters);
+                this.startSpan(Math.min(to, cursor.to), cls);
+            } while (cursor.nextSibling());
+            cursor.parent();
+        }
+    }
+}
+/**
+Match a syntax node's [highlight rules](#highlight.styleTags). If
+there's a match, return its set of tags, and whether it is
+opaque (uses a `!`) or applies to all child nodes (`/...`).
+*/
+function getStyleTags(node) {
+    let rule = node.type.prop(ruleNodeProp);
+    while (rule && rule.context && !node.matchContext(rule.context))
+        rule = rule.next;
+    return rule || null;
+}
+const t = Tag.define;
+const comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();
+/**
+The default set of highlighting [tags](#highlight.Tag).
+
+This collection is heavily biased towards programming languages,
+and necessarily incomplete. A full ontology of syntactic
+constructs would fill a stack of books, and be impractical to
+write themes for. So try to make do with this set. If all else
+fails, [open an
+issue](https://github.com/codemirror/codemirror.next) to propose a
+new tag, or [define](#highlight.Tag^define) a local custom tag for
+your use case.
+
+Note that it is not obligatory to always attach the most specific
+tag possible to an element—if your grammar can't easily
+distinguish a certain type of element (such as a local variable),
+it is okay to style it as its more general variant (a variable).
+
+For tags that extend some parent tag, the documentation links to
+the parent.
+*/
+const tags = {
+    /**
+    A comment.
+    */
+    comment,
+    /**
+    A line [comment](#highlight.tags.comment).
+    */
+    lineComment: t(comment),
+    /**
+    A block [comment](#highlight.tags.comment).
+    */
+    blockComment: t(comment),
+    /**
+    A documentation [comment](#highlight.tags.comment).
+    */
+    docComment: t(comment),
+    /**
+    Any kind of identifier.
+    */
+    name,
+    /**
+    The [name](#highlight.tags.name) of a variable.
+    */
+    variableName: t(name),
+    /**
+    A type [name](#highlight.tags.name).
+    */
+    typeName: typeName,
+    /**
+    A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
+    */
+    tagName: t(typeName),
+    /**
+    A property or field [name](#highlight.tags.name).
+    */
+    propertyName: propertyName,
+    /**
+    An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
+    */
+    attributeName: t(propertyName),
+    /**
+    The [name](#highlight.tags.name) of a class.
+    */
+    className: t(name),
+    /**
+    A label [name](#highlight.tags.name).
+    */
+    labelName: t(name),
+    /**
+    A namespace [name](#highlight.tags.name).
+    */
+    namespace: t(name),
+    /**
+    The [name](#highlight.tags.name) of a macro.
+    */
+    macroName: t(name),
+    /**
+    A literal value.
+    */
+    literal,
+    /**
+    A string [literal](#highlight.tags.literal).
+    */
+    string,
+    /**
+    A documentation [string](#highlight.tags.string).
+    */
+    docString: t(string),
+    /**
+    A character literal (subtag of [string](#highlight.tags.string)).
+    */
+    character: t(string),
+    /**
+    An attribute value (subtag of [string](#highlight.tags.string)).
+    */
+    attributeValue: t(string),
+    /**
+    A number [literal](#highlight.tags.literal).
+    */
+    number,
+    /**
+    An integer [number](#highlight.tags.number) literal.
+    */
+    integer: t(number),
+    /**
+    A floating-point [number](#highlight.tags.number) literal.
+    */
+    float: t(number),
+    /**
+    A boolean [literal](#highlight.tags.literal).
+    */
+    bool: t(literal),
+    /**
+    Regular expression [literal](#highlight.tags.literal).
+    */
+    regexp: t(literal),
+    /**
+    An escape [literal](#highlight.tags.literal), for example a
+    backslash escape in a string.
+    */
+    escape: t(literal),
+    /**
+    A color [literal](#highlight.tags.literal).
+    */
+    color: t(literal),
+    /**
+    A URL [literal](#highlight.tags.literal).
+    */
+    url: t(literal),
+    /**
+    A language keyword.
+    */
+    keyword,
+    /**
+    The [keyword](#highlight.tags.keyword) for the self or this
+    object.
+    */
+    self: t(keyword),
+    /**
+    The [keyword](#highlight.tags.keyword) for null.
+    */
+    null: t(keyword),
+    /**
+    A [keyword](#highlight.tags.keyword) denoting some atomic value.
+    */
+    atom: t(keyword),
+    /**
+    A [keyword](#highlight.tags.keyword) that represents a unit.
+    */
+    unit: t(keyword),
+    /**
+    A modifier [keyword](#highlight.tags.keyword).
+    */
+    modifier: t(keyword),
+    /**
+    A [keyword](#highlight.tags.keyword) that acts as an operator.
+    */
+    operatorKeyword: t(keyword),
+    /**
+    A control-flow related [keyword](#highlight.tags.keyword).
+    */
+    controlKeyword: t(keyword),
+    /**
+    A [keyword](#highlight.tags.keyword) that defines something.
+    */
+    definitionKeyword: t(keyword),
+    /**
+    A [keyword](#highlight.tags.keyword) related to defining or
+    interfacing with modules.
+    */
+    moduleKeyword: t(keyword),
+    /**
+    An operator.
+    */
+    operator,
+    /**
+    An [operator](#highlight.tags.operator) that dereferences something.
+    */
+    derefOperator: t(operator),
+    /**
+    Arithmetic-related [operator](#highlight.tags.operator).
+    */
+    arithmeticOperator: t(operator),
+    /**
+    Logical [operator](#highlight.tags.operator).
+    */
+    logicOperator: t(operator),
+    /**
+    Bit [operator](#highlight.tags.operator).
+    */
+    bitwiseOperator: t(operator),
+    /**
+    Comparison [operator](#highlight.tags.operator).
+    */
+    compareOperator: t(operator),
+    /**
+    [Operator](#highlight.tags.operator) that updates its operand.
+    */
+    updateOperator: t(operator),
+    /**
+    [Operator](#highlight.tags.operator) that defines something.
+    */
+    definitionOperator: t(operator),
+    /**
+    Type-related [operator](#highlight.tags.operator).
+    */
+    typeOperator: t(operator),
+    /**
+    Control-flow [operator](#highlight.tags.operator).
+    */
+    controlOperator: t(operator),
+    /**
+    Program or markup punctuation.
+    */
+    punctuation,
+    /**
+    [Punctuation](#highlight.tags.punctuation) that separates
+    things.
+    */
+    separator: t(punctuation),
+    /**
+    Bracket-style [punctuation](#highlight.tags.punctuation).
+    */
+    bracket,
+    /**
+    Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
+    tokens).
+    */
+    angleBracket: t(bracket),
+    /**
+    Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
+    tokens).
+    */
+    squareBracket: t(bracket),
+    /**
+    Parentheses (usually `(` and `)` tokens). Subtag of
+    [bracket](#highlight.tags.bracket).
+    */
+    paren: t(bracket),
+    /**
+    Braces (usually `{` and `}` tokens). Subtag of
+    [bracket](#highlight.tags.bracket).
+    */
+    brace: t(bracket),
+    /**
+    Content, for example plain text in XML or markup documents.
+    */
+    content,
+    /**
+    [Content](#highlight.tags.content) that represents a heading.
+    */
+    heading,
+    /**
+    A level 1 [heading](#highlight.tags.heading).
+    */
+    heading1: t(heading),
+    /**
+    A level 2 [heading](#highlight.tags.heading).
+    */
+    heading2: t(heading),
+    /**
+    A level 3 [heading](#highlight.tags.heading).
+    */
+    heading3: t(heading),
+    /**
+    A level 4 [heading](#highlight.tags.heading).
+    */
+    heading4: t(heading),
+    /**
+    A level 5 [heading](#highlight.tags.heading).
+    */
+    heading5: t(heading),
+    /**
+    A level 6 [heading](#highlight.tags.heading).
+    */
+    heading6: t(heading),
+    /**
+    A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
+    */
+    contentSeparator: t(content),
+    /**
+    [Content](#highlight.tags.content) that represents a list.
+    */
+    list: t(content),
+    /**
+    [Content](#highlight.tags.content) that represents a quote.
+    */
+    quote: t(content),
+    /**
+    [Content](#highlight.tags.content) that is emphasized.
+    */
+    emphasis: t(content),
+    /**
+    [Content](#highlight.tags.content) that is styled strong.
+    */
+    strong: t(content),
+    /**
+    [Content](#highlight.tags.content) that is part of a link.
+    */
+    link: t(content),
+    /**
+    [Content](#highlight.tags.content) that is styled as code or
+    monospace.
+    */
+    monospace: t(content),
+    /**
+    [Content](#highlight.tags.content) that has a strike-through
+    style.
+    */
+    strikethrough: t(content),
+    /**
+    Inserted text in a change-tracking format.
+    */
+    inserted: t(),
+    /**
+    Deleted text.
+    */
+    deleted: t(),
+    /**
+    Changed text.
+    */
+    changed: t(),
+    /**
+    An invalid or unsyntactic element.
+    */
+    invalid: t(),
+    /**
+    Metadata or meta-instruction.
+    */
+    meta,
+    /**
+    [Metadata](#highlight.tags.meta) that applies to the entire
+    document.
+    */
+    documentMeta: t(meta),
+    /**
+    [Metadata](#highlight.tags.meta) that annotates or adds
+    attributes to a given syntactic element.
+    */
+    annotation: t(meta),
+    /**
+    Processing instruction or preprocessor directive. Subtag of
+    [meta](#highlight.tags.meta).
+    */
+    processingInstruction: t(meta),
+    /**
+    [Modifier](#highlight.Tag^defineModifier) that indicates that a
+    given element is being defined. Expected to be used with the
+    various [name](#highlight.tags.name) tags.
+    */
+    definition: Tag.defineModifier("definition"),
+    /**
+    [Modifier](#highlight.Tag^defineModifier) that indicates that
+    something is constant. Mostly expected to be used with
+    [variable names](#highlight.tags.variableName).
+    */
+    constant: Tag.defineModifier("constant"),
+    /**
+    [Modifier](#highlight.Tag^defineModifier) used to indicate that
+    a [variable](#highlight.tags.variableName) or [property
+    name](#highlight.tags.propertyName) is being called or defined
+    as a function.
+    */
+    function: Tag.defineModifier("function"),
+    /**
+    [Modifier](#highlight.Tag^defineModifier) that can be applied to
+    [names](#highlight.tags.name) to indicate that they belong to
+    the language's standard environment.
+    */
+    standard: Tag.defineModifier("standard"),
+    /**
+    [Modifier](#highlight.Tag^defineModifier) that indicates a given
+    [names](#highlight.tags.name) is local to some scope.
+    */
+    local: Tag.defineModifier("local"),
+    /**
+    A generic variant [modifier](#highlight.Tag^defineModifier) that
+    can be used to tag language-specific alternative variants of
+    some common tag. It is recommended for themes to define special
+    forms of at least the [string](#highlight.tags.string) and
+    [variable name](#highlight.tags.variableName) tags, since those
+    come up a lot.
+    */
+    special: Tag.defineModifier("special")
+};
+for (let name in tags) {
+    let val = tags[name];
+    if (val instanceof Tag)
+        val.name = name;
+}
+/**
+This is a highlighter that adds stable, predictable classes to
+tokens, for styling with external CSS.
+
+The following tags are mapped to their name prefixed with `"tok-"`
+(for example `"tok-comment"`):
+
+* [`link`](#highlight.tags.link)
+* [`heading`](#highlight.tags.heading)
+* [`emphasis`](#highlight.tags.emphasis)
+* [`strong`](#highlight.tags.strong)
+* [`keyword`](#highlight.tags.keyword)
+* [`atom`](#highlight.tags.atom)
+* [`bool`](#highlight.tags.bool)
+* [`url`](#highlight.tags.url)
+* [`labelName`](#highlight.tags.labelName)
+* [`inserted`](#highlight.tags.inserted)
+* [`deleted`](#highlight.tags.deleted)
+* [`literal`](#highlight.tags.literal)
+* [`string`](#highlight.tags.string)
+* [`number`](#highlight.tags.number)
+* [`variableName`](#highlight.tags.variableName)
+* [`typeName`](#highlight.tags.typeName)
+* [`namespace`](#highlight.tags.namespace)
+* [`className`](#highlight.tags.className)
+* [`macroName`](#highlight.tags.macroName)
+* [`propertyName`](#highlight.tags.propertyName)
+* [`operator`](#highlight.tags.operator)
+* [`comment`](#highlight.tags.comment)
+* [`meta`](#highlight.tags.meta)
+* [`punctuation`](#highlight.tags.punctuation)
+* [`invalid`](#highlight.tags.invalid)
+
+In addition, these mappings are provided:
+
+* [`regexp`](#highlight.tags.regexp),
+  [`escape`](#highlight.tags.escape), and
+  [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
+  are mapped to `"tok-string2"`
+* [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
+  to `"tok-variableName2"`
+* [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
+  to `"tok-variableName tok-local"`
+* [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
+  to `"tok-variableName tok-definition"`
+* [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
+  to `"tok-propertyName tok-definition"`
+*/
+tagHighlighter([
+    { tag: tags.link, class: "tok-link" },
+    { tag: tags.heading, class: "tok-heading" },
+    { tag: tags.emphasis, class: "tok-emphasis" },
+    { tag: tags.strong, class: "tok-strong" },
+    { tag: tags.keyword, class: "tok-keyword" },
+    { tag: tags.atom, class: "tok-atom" },
+    { tag: tags.bool, class: "tok-bool" },
+    { tag: tags.url, class: "tok-url" },
+    { tag: tags.labelName, class: "tok-labelName" },
+    { tag: tags.inserted, class: "tok-inserted" },
+    { tag: tags.deleted, class: "tok-deleted" },
+    { tag: tags.literal, class: "tok-literal" },
+    { tag: tags.string, class: "tok-string" },
+    { tag: tags.number, class: "tok-number" },
+    { tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" },
+    { tag: tags.variableName, class: "tok-variableName" },
+    { tag: tags.local(tags.variableName), class: "tok-variableName tok-local" },
+    { tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" },
+    { tag: tags.special(tags.variableName), class: "tok-variableName2" },
+    { tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" },
+    { tag: tags.typeName, class: "tok-typeName" },
+    { tag: tags.namespace, class: "tok-namespace" },
+    { tag: tags.className, class: "tok-className" },
+    { tag: tags.macroName, class: "tok-macroName" },
+    { tag: tags.propertyName, class: "tok-propertyName" },
+    { tag: tags.operator, class: "tok-operator" },
+    { tag: tags.comment, class: "tok-comment" },
+    { tag: tags.meta, class: "tok-meta" },
+    { tag: tags.invalid, class: "tok-invalid" },
+    { tag: tags.punctuation, class: "tok-punctuation" }
+]);
+
+var _a;
+/**
+Node prop stored in a parser's top syntax node to provide the
+facet that stores language-specific data for that language.
+*/
+const languageDataProp = /*@__PURE__*/new NodeProp$1();
+/**
+Helper function to define a facet (to be added to the top syntax
+node(s) for a language via
+[`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be
+used to associate language data with the language. You
+probably only need this when subclassing
+[`Language`](https://codemirror.net/6/docs/ref/#language.Language).
+*/
+function defineLanguageFacet(baseData) {
+    return Facet.define({
+        combine: baseData ? values => values.concat(baseData) : undefined
+    });
+}
+/**
+Syntax node prop used to register sublanguages. Should be added to
+the top level node type for the language.
+*/
+const sublanguageProp = /*@__PURE__*/new NodeProp$1();
+/**
+A language object manages parsing and per-language
+[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
+managed as a [Lezer](https://lezer.codemirror.net) tree. The class
+can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
+subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
+via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
+for stream parsers.
+*/
+class Language {
+    /**
+    Construct a language object. If you need to invoke this
+    directly, first define a data facet with
+    [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
+    configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
+    to the language's outer syntax node.
+    */
+    constructor(
+    /**
+    The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
+    used for this language.
+    */
+    data, parser, extraExtensions = [], 
+    /**
+    A language name.
+    */
+    name = "") {
+        this.data = data;
+        this.name = name;
+        // Kludge to define EditorState.tree as a debugging helper,
+        // without the EditorState package actually knowing about
+        // languages and lezer trees.
+        if (!EditorState.prototype.hasOwnProperty("tree"))
+            Object.defineProperty(EditorState.prototype, "tree", { get() { return syntaxTree(this); } });
+        this.parser = parser;
+        this.extension = [
+            language.of(this),
+            EditorState.languageData.of((state, pos, side) => {
+                let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);
+                if (!data)
+                    return [];
+                let base = state.facet(data), sub = top.type.prop(sublanguageProp);
+                if (sub) {
+                    let innerNode = top.resolve(pos - top.from, side);
+                    for (let sublang of sub)
+                        if (sublang.test(innerNode, state)) {
+                            let data = state.facet(sublang.facet);
+                            return sublang.type == "replace" ? data : data.concat(base);
+                        }
+                }
+                return base;
+            })
+        ].concat(extraExtensions);
+    }
+    /**
+    Query whether this language is active at the given position.
+    */
+    isActiveAt(state, pos, side = -1) {
+        return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;
+    }
+    /**
+    Find the document regions that were parsed using this language.
+    The returned regions will _include_ any nested languages rooted
+    in this language, when those exist.
+    */
+    findRegions(state) {
+        let lang = state.facet(language);
+        if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
+            return [{ from: 0, to: state.doc.length }];
+        if (!lang || !lang.allowsNesting)
+            return [];
+        let result = [];
+        let explore = (tree, from) => {
+            if (tree.prop(languageDataProp) == this.data) {
+                result.push({ from, to: from + tree.length });
+                return;
+            }
+            let mount = tree.prop(NodeProp$1.mounted);
+            if (mount) {
+                if (mount.tree.prop(languageDataProp) == this.data) {
+                    if (mount.overlay)
+                        for (let r of mount.overlay)
+                            result.push({ from: r.from + from, to: r.to + from });
+                    else
+                        result.push({ from: from, to: from + tree.length });
+                    return;
+                }
+                else if (mount.overlay) {
+                    let size = result.length;
+                    explore(mount.tree, mount.overlay[0].from + from);
+                    if (result.length > size)
+                        return;
+                }
+            }
+            for (let i = 0; i < tree.children.length; i++) {
+                let ch = tree.children[i];
+                if (ch instanceof Tree)
+                    explore(ch, tree.positions[i] + from);
+            }
+        };
+        explore(syntaxTree(state), 0);
+        return result;
+    }
+    /**
+    Indicates whether this language allows nested languages. The
+    default implementation returns true.
+    */
+    get allowsNesting() { return true; }
+}
+/**
+@internal
+*/
+Language.setState = /*@__PURE__*/StateEffect.define();
+function topNodeAt(state, pos, side) {
+    let topLang = state.facet(language), tree = syntaxTree(state).topNode;
+    if (!topLang || topLang.allowsNesting) {
+        for (let node = tree; node; node = node.enter(pos, side, IterMode$1.ExcludeBuffers))
+            if (node.type.isTop)
+                tree = node;
+    }
+    return tree;
+}
+/**
+A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
+[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
+parsers.
+*/
+class LRLanguage extends Language {
+    constructor(data, parser, name) {
+        super(data, parser, [], name);
+        this.parser = parser;
+    }
+    /**
+    Define a language from a parser.
+    */
+    static define(spec) {
+        let data = defineLanguageFacet(spec.languageData);
+        return new LRLanguage(data, spec.parser.configure({
+            props: [languageDataProp.add(type => type.isTop ? data : undefined)]
+        }), spec.name);
+    }
+    /**
+    Create a new instance of this language with a reconfigured
+    version of its parser and optionally a new name.
+    */
+    configure(options, name) {
+        return new LRLanguage(this.data, this.parser.configure(options), name || this.name);
+    }
+    get allowsNesting() { return this.parser.hasWrappers(); }
+}
+/**
+Get the syntax tree for a state, which is the current (possibly
+incomplete) parse tree of the active
+[language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
+language available.
+*/
+function syntaxTree(state) {
+    let field = state.field(Language.state, false);
+    return field ? field.tree : Tree.empty;
+}
+/**
+Lezer-style
+[`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
+object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
+*/
+class DocInput {
+    /**
+    Create an input object for the given document.
+    */
+    constructor(doc) {
+        this.doc = doc;
+        this.cursorPos = 0;
+        this.string = "";
+        this.cursor = doc.iter();
+    }
+    get length() { return this.doc.length; }
+    syncTo(pos) {
+        this.string = this.cursor.next(pos - this.cursorPos).value;
+        this.cursorPos = pos + this.string.length;
+        return this.cursorPos - this.string.length;
+    }
+    chunk(pos) {
+        this.syncTo(pos);
+        return this.string;
+    }
+    get lineChunks() { return true; }
+    read(from, to) {
+        let stringStart = this.cursorPos - this.string.length;
+        if (from < stringStart || to >= this.cursorPos)
+            return this.doc.sliceString(from, to);
+        else
+            return this.string.slice(from - stringStart, to - stringStart);
+    }
+}
+let currentContext = null;
+/**
+A parse context provided to parsers working on the editor content.
+*/
+class ParseContext {
+    constructor(parser, 
+    /**
+    The current editor state.
+    */
+    state, 
+    /**
+    Tree fragments that can be reused by incremental re-parses.
+    */
+    fragments = [], 
+    /**
+    @internal
+    */
+    tree, 
+    /**
+    @internal
+    */
+    treeLen, 
+    /**
+    The current editor viewport (or some overapproximation
+    thereof). Intended to be used for opportunistically avoiding
+    work (in which case
+    [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
+    should be called to make sure the parser is restarted when the
+    skipped region becomes visible).
+    */
+    viewport, 
+    /**
+    @internal
+    */
+    skipped, 
+    /**
+    This is where skipping parsers can register a promise that,
+    when resolved, will schedule a new parse. It is cleared when
+    the parse worker picks up the promise. @internal
+    */
+    scheduleOn) {
+        this.parser = parser;
+        this.state = state;
+        this.fragments = fragments;
+        this.tree = tree;
+        this.treeLen = treeLen;
+        this.viewport = viewport;
+        this.skipped = skipped;
+        this.scheduleOn = scheduleOn;
+        this.parse = null;
+        /**
+        @internal
+        */
+        this.tempSkipped = [];
+    }
+    /**
+    @internal
+    */
+    static create(parser, state, viewport) {
+        return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
+    }
+    startParse() {
+        return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
+    }
+    /**
+    @internal
+    */
+    work(until, upto) {
+        if (upto != null && upto >= this.state.doc.length)
+            upto = undefined;
+        if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
+            this.takeTree();
+            return true;
+        }
+        return this.withContext(() => {
+            var _a;
+            if (typeof until == "number") {
+                let endTime = Date.now() + until;
+                until = () => Date.now() > endTime;
+            }
+            if (!this.parse)
+                this.parse = this.startParse();
+            if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
+                upto < this.state.doc.length)
+                this.parse.stopAt(upto);
+            for (;;) {
+                let done = this.parse.advance();
+                if (done) {
+                    this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));
+                    this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
+                    this.tree = done;
+                    this.parse = null;
+                    if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
+                        this.parse = this.startParse();
+                    else
+                        return true;
+                }
+                if (until())
+                    return false;
+            }
+        });
+    }
+    /**
+    @internal
+    */
+    takeTree() {
+        let pos, tree;
+        if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
+            if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
+                this.parse.stopAt(pos);
+            this.withContext(() => { while (!(tree = this.parse.advance())) { } });
+            this.treeLen = pos;
+            this.tree = tree;
+            this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));
+            this.parse = null;
+        }
+    }
+    withContext(f) {
+        let prev = currentContext;
+        currentContext = this;
+        try {
+            return f();
+        }
+        finally {
+            currentContext = prev;
+        }
+    }
+    withoutTempSkipped(fragments) {
+        for (let r; r = this.tempSkipped.pop();)
+            fragments = cutFragments(fragments, r.from, r.to);
+        return fragments;
+    }
+    /**
+    @internal
+    */
+    changes(changes, newState) {
+        let { fragments, tree, treeLen, viewport, skipped } = this;
+        this.takeTree();
+        if (!changes.empty) {
+            let ranges = [];
+            changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
+            fragments = TreeFragment.applyChanges(fragments, ranges);
+            tree = Tree.empty;
+            treeLen = 0;
+            viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
+            if (this.skipped.length) {
+                skipped = [];
+                for (let r of this.skipped) {
+                    let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
+                    if (from < to)
+                        skipped.push({ from, to });
+                }
+            }
+        }
+        return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
+    }
+    /**
+    @internal
+    */
+    updateViewport(viewport) {
+        if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
+            return false;
+        this.viewport = viewport;
+        let startLen = this.skipped.length;
+        for (let i = 0; i < this.skipped.length; i++) {
+            let { from, to } = this.skipped[i];
+            if (from < viewport.to && to > viewport.from) {
+                this.fragments = cutFragments(this.fragments, from, to);
+                this.skipped.splice(i--, 1);
+            }
+        }
+        if (this.skipped.length >= startLen)
+            return false;
+        this.reset();
+        return true;
+    }
+    /**
+    @internal
+    */
+    reset() {
+        if (this.parse) {
+            this.takeTree();
+            this.parse = null;
+        }
+    }
+    /**
+    Notify the parse scheduler that the given region was skipped
+    because it wasn't in view, and the parse should be restarted
+    when it comes into view.
+    */
+    skipUntilInView(from, to) {
+        this.skipped.push({ from, to });
+    }
+    /**
+    Returns a parser intended to be used as placeholder when
+    asynchronously loading a nested parser. It'll skip its input and
+    mark it as not-really-parsed, so that the next update will parse
+    it again.
+    
+    When `until` is given, a reparse will be scheduled when that
+    promise resolves.
+    */
+    static getSkippingParser(until) {
+        return new class extends Parser {
+            createParse(input, fragments, ranges) {
+                let from = ranges[0].from, to = ranges[ranges.length - 1].to;
+                let parser = {
+                    parsedPos: from,
+                    advance() {
+                        let cx = currentContext;
+                        if (cx) {
+                            for (let r of ranges)
+                                cx.tempSkipped.push(r);
+                            if (until)
+                                cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
+                        }
+                        this.parsedPos = to;
+                        return new Tree(NodeType$1.none, [], [], to - from);
+                    },
+                    stoppedAt: null,
+                    stopAt() { }
+                };
+                return parser;
+            }
+        };
+    }
+    /**
+    @internal
+    */
+    isDone(upto) {
+        upto = Math.min(upto, this.state.doc.length);
+        let frags = this.fragments;
+        return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
+    }
+    /**
+    Get the context for the current parse, or `null` if no editor
+    parse is in progress.
+    */
+    static get() { return currentContext; }
+}
+function cutFragments(fragments, from, to) {
+    return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
+}
+class LanguageState {
+    constructor(
+    // A mutable parse state that is used to preserve work done during
+    // the lifetime of a state when moving to the next state.
+    context) {
+        this.context = context;
+        this.tree = context.tree;
+    }
+    apply(tr) {
+        if (!tr.docChanged && this.tree == this.context.tree)
+            return this;
+        let newCx = this.context.changes(tr.changes, tr.state);
+        // If the previous parse wasn't done, go forward only up to its
+        // end position or the end of the viewport, to avoid slowing down
+        // state updates with parse work beyond the viewport.
+        let upto = this.context.treeLen == tr.startState.doc.length ? undefined
+            : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
+        if (!newCx.work(20 /* Work.Apply */, upto))
+            newCx.takeTree();
+        return new LanguageState(newCx);
+    }
+    static init(state) {
+        let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);
+        let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
+        if (!parseState.work(20 /* Work.Apply */, vpTo))
+            parseState.takeTree();
+        return new LanguageState(parseState);
+    }
+}
+Language.state = /*@__PURE__*/StateField.define({
+    create: LanguageState.init,
+    update(value, tr) {
+        for (let e of tr.effects)
+            if (e.is(Language.setState))
+                return e.value;
+        if (tr.startState.facet(language) != tr.state.facet(language))
+            return LanguageState.init(tr.state);
+        return value.apply(tr);
+    }
+});
+let requestIdle = (callback) => {
+    let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);
+    return () => clearTimeout(timeout);
+};
+if (typeof requestIdleCallback != "undefined")
+    requestIdle = (callback) => {
+        let idle = -1, timeout = setTimeout(() => {
+            idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });
+        }, 100 /* Work.MinPause */);
+        return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
+    };
+const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
+    ? () => navigator.scheduling.isInputPending() : null;
+const parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {
+    constructor(view) {
+        this.view = view;
+        this.working = null;
+        this.workScheduled = 0;
+        // End of the current time chunk
+        this.chunkEnd = -1;
+        // Milliseconds of budget left for this chunk
+        this.chunkBudget = -1;
+        this.work = this.work.bind(this);
+        this.scheduleWork();
+    }
+    update(update) {
+        let cx = this.view.state.field(Language.state).context;
+        if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
+            this.scheduleWork();
+        if (update.docChanged || update.selectionSet) {
+            if (this.view.hasFocus)
+                this.chunkBudget += 50 /* Work.ChangeBonus */;
+            this.scheduleWork();
+        }
+        this.checkAsyncSchedule(cx);
+    }
+    scheduleWork() {
+        if (this.working)
+            return;
+        let { state } = this.view, field = state.field(Language.state);
+        if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
+            this.working = requestIdle(this.work);
+    }
+    work(deadline) {
+        this.working = null;
+        let now = Date.now();
+        if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
+            this.chunkEnd = now + 30000 /* Work.ChunkTime */;
+            this.chunkBudget = 3000 /* Work.ChunkBudget */;
+        }
+        if (this.chunkBudget <= 0)
+            return; // No more budget
+        let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
+        if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))
+            return;
+        let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);
+        let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
+        let done = field.context.work(() => {
+            return isInputPending && isInputPending() || Date.now() > endTime;
+        }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));
+        this.chunkBudget -= Date.now() - now;
+        if (done || this.chunkBudget <= 0) {
+            field.context.takeTree();
+            this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });
+        }
+        if (this.chunkBudget > 0 && !(done && !viewportFirst))
+            this.scheduleWork();
+        this.checkAsyncSchedule(field.context);
+    }
+    checkAsyncSchedule(cx) {
+        if (cx.scheduleOn) {
+            this.workScheduled++;
+            cx.scheduleOn
+                .then(() => this.scheduleWork())
+                .catch(err => logException(this.view.state, err))
+                .then(() => this.workScheduled--);
+            cx.scheduleOn = null;
+        }
+    }
+    destroy() {
+        if (this.working)
+            this.working();
+    }
+    isWorking() {
+        return !!(this.working || this.workScheduled > 0);
+    }
+}, {
+    eventHandlers: { focus() { this.scheduleWork(); } }
+});
+/**
+The facet used to associate a language with an editor state. Used
+by `Language` object's `extension` property (so you don't need to
+manually wrap your languages in this). Can be used to access the
+current language on a state.
+*/
+const language = /*@__PURE__*/Facet.define({
+    combine(languages) { return languages.length ? languages[0] : null; },
+    enables: language => [
+        Language.state,
+        parseWorker,
+        EditorView.contentAttributes.compute([language], state => {
+            let lang = state.facet(language);
+            return lang && lang.name ? { "data-language": lang.name } : {};
+        })
+    ]
+});
+/**
+This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
+optional set of supporting extensions. Language packages are
+encouraged to export a function that optionally takes a
+configuration object and returns a `LanguageSupport` instance, as
+the main way for client code to use the package.
+*/
+class LanguageSupport {
+    /**
+    Create a language support object.
+    */
+    constructor(
+    /**
+    The language object.
+    */
+    language, 
+    /**
+    An optional set of supporting extensions. When nesting a
+    language in another language, the outer language is encouraged
+    to include the supporting extensions for its inner languages
+    in its own set of support extensions.
+    */
+    support = []) {
+        this.language = language;
+        this.support = support;
+        this.extension = [language, support];
+    }
+}
+
+/**
+Facet that defines a way to provide a function that computes the
+appropriate indentation depth, as a column number (see
+[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given
+line. A return value of `null` indicates no indentation can be
+determined, and the line should inherit the indentation of the one
+above it. A return value of `undefined` defers to the next indent
+service.
+*/
+const indentService = /*@__PURE__*/Facet.define();
+/**
+Facet for overriding the unit by which indentation happens. Should
+be a string consisting either entirely of the same whitespace
+character. When not set, this defaults to 2 spaces.
+*/
+const indentUnit = /*@__PURE__*/Facet.define({
+    combine: values => {
+        if (!values.length)
+            return "  ";
+        let unit = values[0];
+        if (!unit || /\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))
+            throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
+        return unit;
+    }
+});
+/**
+Return the _column width_ of an indent unit in the state.
+Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
+facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
+contains tabs.
+*/
+function getIndentUnit(state) {
+    let unit = state.facet(indentUnit);
+    return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
+}
+/**
+Create an indentation string that covers columns 0 to `cols`.
+Will use tabs for as much of the columns as possible when the
+[`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
+tabs.
+*/
+function indentString(state, cols) {
+    let result = "", ts = state.tabSize, ch = state.facet(indentUnit)[0];
+    if (ch == "\t") {
+        while (cols >= ts) {
+            result += "\t";
+            cols -= ts;
+        }
+        ch = " ";
+    }
+    for (let i = 0; i < cols; i++)
+        result += ch;
+    return result;
+}
+/**
+Get the indentation, as a column number, at the given position.
+Will first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)
+that are registered, and if none of those return an indentation,
+this will check the syntax tree for the [indent node
+prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a
+number when an indentation could be determined, and null
+otherwise.
+*/
+function getIndentation(context, pos) {
+    if (context instanceof EditorState)
+        context = new IndentContext(context);
+    for (let service of context.state.facet(indentService)) {
+        let result = service(context, pos);
+        if (result !== undefined)
+            return result;
+    }
+    let tree = syntaxTree(context.state);
+    return tree.length >= pos ? syntaxIndentation(context, tree, pos) : null;
+}
+/**
+Indentation contexts are used when calling [indentation
+services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
+useful in indentation logic, and can selectively override the
+indentation reported for some lines.
+*/
+class IndentContext {
+    /**
+    Create an indent context.
+    */
+    constructor(
+    /**
+    The editor state.
+    */
+    state, 
+    /**
+    @internal
+    */
+    options = {}) {
+        this.state = state;
+        this.options = options;
+        this.unit = getIndentUnit(state);
+    }
+    /**
+    Get a description of the line at the given position, taking
+    [simulated line
+    breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
+    into account. If there is such a break at `pos`, the `bias`
+    argument determines whether the part of the line line before or
+    after the break is used.
+    */
+    lineAt(pos, bias = 1) {
+        let line = this.state.doc.lineAt(pos);
+        let { simulateBreak, simulateDoubleBreak } = this.options;
+        if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
+            if (simulateDoubleBreak && simulateBreak == pos)
+                return { text: "", from: pos };
+            else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
+                return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
+            else
+                return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
+        }
+        return line;
+    }
+    /**
+    Get the text directly after `pos`, either the entire line
+    or the next 100 characters, whichever is shorter.
+    */
+    textAfterPos(pos, bias = 1) {
+        if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
+            return "";
+        let { text, from } = this.lineAt(pos, bias);
+        return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
+    }
+    /**
+    Find the column for the given position.
+    */
+    column(pos, bias = 1) {
+        let { text, from } = this.lineAt(pos, bias);
+        let result = this.countColumn(text, pos - from);
+        let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
+        if (override > -1)
+            result += override - this.countColumn(text, text.search(/\S|$/));
+        return result;
+    }
+    /**
+    Find the column position (taking tabs into account) of the given
+    position in the given string.
+    */
+    countColumn(line, pos = line.length) {
+        return countColumn(line, this.state.tabSize, pos);
+    }
+    /**
+    Find the indentation column of the line at the given point.
+    */
+    lineIndent(pos, bias = 1) {
+        let { text, from } = this.lineAt(pos, bias);
+        let override = this.options.overrideIndentation;
+        if (override) {
+            let overriden = override(from);
+            if (overriden > -1)
+                return overriden;
+        }
+        return this.countColumn(text, text.search(/\S|$/));
+    }
+    /**
+    Returns the [simulated line
+    break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
+    for this context, if any.
+    */
+    get simulatedBreak() {
+        return this.options.simulateBreak || null;
+    }
+}
+/**
+A syntax tree node prop used to associate indentation strategies
+with node types. Such a strategy is a function from an indentation
+context to a column number (see also
+[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null
+indicates that no definitive indentation can be determined.
+*/
+const indentNodeProp = /*@__PURE__*/new NodeProp$1();
+// Compute the indentation for a given position from the syntax tree.
+function syntaxIndentation(cx, ast, pos) {
+    let stack = ast.resolveStack(pos);
+    let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
+    if (inner != stack.node) {
+        let add = [];
+        for (let cur = inner; cur != stack.node; cur = cur.parent)
+            add.push(cur);
+        for (let i = add.length - 1; i >= 0; i--)
+            stack = { node: add[i], next: stack };
+    }
+    return indentFor(stack, cx, pos);
+}
+function indentFor(stack, cx, pos) {
+    for (let cur = stack; cur; cur = cur.next) {
+        let strategy = indentStrategy(cur.node);
+        if (strategy)
+            return strategy(TreeIndentContext.create(cx, pos, cur));
+    }
+    return 0;
+}
+function ignoreClosed(cx) {
+    return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
+}
+function indentStrategy(tree) {
+    let strategy = tree.type.prop(indentNodeProp);
+    if (strategy)
+        return strategy;
+    let first = tree.firstChild, close;
+    if (first && (close = first.type.prop(NodeProp$1.closedBy))) {
+        let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
+        return cx => delimitedStrategy(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);
+    }
+    return tree.parent == null ? topIndent : null;
+}
+function topIndent() { return 0; }
+/**
+Objects of this type provide context information and helper
+methods to indentation functions registered on syntax nodes.
+*/
+class TreeIndentContext extends IndentContext {
+    constructor(base, 
+    /**
+    The position at which indentation is being computed.
+    */
+    pos, 
+    /**
+    @internal
+    */
+    context) {
+        super(base.state, base.options);
+        this.base = base;
+        this.pos = pos;
+        this.context = context;
+    }
+    /**
+    The syntax tree node to which the indentation strategy
+    applies.
+    */
+    get node() { return this.context.node; }
+    /**
+    @internal
+    */
+    static create(base, pos, context) {
+        return new TreeIndentContext(base, pos, context);
+    }
+    /**
+    Get the text directly after `this.pos`, either the entire line
+    or the next 100 characters, whichever is shorter.
+    */
+    get textAfter() {
+        return this.textAfterPos(this.pos);
+    }
+    /**
+    Get the indentation at the reference line for `this.node`, which
+    is the line on which it starts, unless there is a node that is
+    _not_ a parent of this node covering the start of that line. If
+    so, the line at the start of that node is tried, again skipping
+    on if it is covered by another such node.
+    */
+    get baseIndent() {
+        return this.baseIndentFor(this.node);
+    }
+    /**
+    Get the indentation for the reference line of the given node
+    (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).
+    */
+    baseIndentFor(node) {
+        let line = this.state.doc.lineAt(node.from);
+        // Skip line starts that are covered by a sibling (or cousin, etc)
+        for (;;) {
+            let atBreak = node.resolve(line.from);
+            while (atBreak.parent && atBreak.parent.from == atBreak.from)
+                atBreak = atBreak.parent;
+            if (isParent(atBreak, node))
+                break;
+            line = this.state.doc.lineAt(atBreak.from);
+        }
+        return this.lineIndent(line.from);
+    }
+    /**
+    Continue looking for indentations in the node's parent nodes,
+    and return the result of that.
+    */
+    continue() {
+        return indentFor(this.context.next, this.base, this.pos);
+    }
+}
+function isParent(parent, of) {
+    for (let cur = of; cur; cur = cur.parent)
+        if (parent == cur)
+            return true;
+    return false;
+}
+// Check whether a delimited node is aligned (meaning there are
+// non-skipped nodes on the same line as the opening delimiter). And
+// if so, return the opening token.
+function bracketedAligned(context) {
+    let tree = context.node;
+    let openToken = tree.childAfter(tree.from), last = tree.lastChild;
+    if (!openToken)
+        return null;
+    let sim = context.options.simulateBreak;
+    let openLine = context.state.doc.lineAt(openToken.from);
+    let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
+    for (let pos = openToken.to;;) {
+        let next = tree.childAfter(pos);
+        if (!next || next == last)
+            return null;
+        if (!next.type.isSkipped) {
+            if (next.from >= lineEnd)
+                return null;
+            let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
+            return { from: openToken.from, to: openToken.to + space };
+        }
+        pos = next.to;
+    }
+}
+/**
+An indentation strategy for delimited (usually bracketed) nodes.
+Will, by default, indent one unit more than the parent's base
+indent unless the line starts with a closing token. When `align`
+is true and there are non-skipped nodes on the node's opening
+line, the content of the node will be aligned with the end of the
+opening node, like this:
+
+    foo(bar,
+        baz)
+*/
+function delimitedIndent({ closing, align = true, units = 1 }) {
+    return (context) => delimitedStrategy(context, align, units, closing);
+}
+function delimitedStrategy(context, align, units, closing, closedAt) {
+    let after = context.textAfter, space = after.match(/^\s*/)[0].length;
+    let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
+    let aligned = align ? bracketedAligned(context) : null;
+    if (aligned)
+        return closed ? context.column(aligned.from) : context.column(aligned.to);
+    return context.baseIndent + (closed ? 0 : context.unit * units);
+}
+/**
+An indentation strategy that aligns a node's content to its base
+indentation.
+*/
+const flatIndent = (context) => context.baseIndent;
+/**
+Creates an indentation strategy that, by default, indents
+continued lines one unit more than the node's base indentation.
+You can provide `except` to prevent indentation of lines that
+match a pattern (for example `/^else\b/` in `if`/`else`
+constructs), and you can change the amount of units used with the
+`units` option.
+*/
+function continuedIndent({ except, units = 1 } = {}) {
+    return (context) => {
+        let matchExcept = except && except.test(context.textAfter);
+        return context.baseIndent + (matchExcept ? 0 : units * context.unit);
+    };
+}
+const DontIndentBeyond = 200;
+/**
+Enables reindentation on input. When a language defines an
+`indentOnInput` field in its [language
+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
+expression, the line at the cursor will be reindented whenever new
+text is typed and the input from the start of the line up to the
+cursor matches that regexp.
+
+To avoid unneccesary reindents, it is recommended to start the
+regexp with `^` (usually followed by `\s*`), and end it with `$`.
+For example, `/^\s*\}$/` will reindent when a closing brace is
+added at the start of a line.
+*/
+function indentOnInput() {
+    return EditorState.transactionFilter.of(tr => {
+        if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
+            return tr;
+        let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
+        if (!rules.length)
+            return tr;
+        let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);
+        if (head > line.from + DontIndentBeyond)
+            return tr;
+        let lineStart = doc.sliceString(line.from, head);
+        if (!rules.some(r => r.test(lineStart)))
+            return tr;
+        let { state } = tr, last = -1, changes = [];
+        for (let { head } of state.selection.ranges) {
+            let line = state.doc.lineAt(head);
+            if (line.from == last)
+                continue;
+            last = line.from;
+            let indent = getIndentation(state, line.from);
+            if (indent == null)
+                continue;
+            let cur = /^\s*/.exec(line.text)[0];
+            let norm = indentString(state, indent);
+            if (cur != norm)
+                changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
+        }
+        return changes.length ? [tr, { changes, sequential: true }] : tr;
+    });
+}
+
+/**
+A facet that registers a code folding service. When called with
+the extent of a line, such a function should return a foldable
+range that starts on that line (but continues beyond it), if one
+can be found.
+*/
+const foldService = /*@__PURE__*/Facet.define();
+/**
+This node prop is used to associate folding information with
+syntax node types. Given a syntax node, it should check whether
+that tree is foldable and return the range that can be collapsed
+when it is.
+*/
+const foldNodeProp = /*@__PURE__*/new NodeProp$1();
+/**
+[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
+the first and the last child of a syntax node. Useful for nodes
+that start and end with delimiters.
+*/
+function foldInside(node) {
+    let first = node.firstChild, last = node.lastChild;
+    return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;
+}
+function syntaxFolding(state, start, end) {
+    let tree = syntaxTree(state);
+    if (tree.length < end)
+        return null;
+    let stack = tree.resolveStack(end, 1);
+    let found = null;
+    for (let iter = stack; iter; iter = iter.next) {
+        let cur = iter.node;
+        if (cur.to <= end || cur.from > end)
+            continue;
+        if (found && cur.from < start)
+            break;
+        let prop = cur.type.prop(foldNodeProp);
+        if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {
+            let value = prop(cur, state);
+            if (value && value.from <= end && value.from >= start && value.to > end)
+                found = value;
+        }
+    }
+    return found;
+}
+function isUnfinished(node) {
+    let ch = node.lastChild;
+    return ch && ch.to == node.to && ch.type.isError;
+}
+/**
+Check whether the given line is foldable. First asks any fold
+services registered through
+[`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return
+a result, tries to query the [fold node
+prop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end
+of the line.
+*/
+function foldable(state, lineStart, lineEnd) {
+    for (let service of state.facet(foldService)) {
+        let result = service(state, lineStart, lineEnd);
+        if (result)
+            return result;
+    }
+    return syntaxFolding(state, lineStart, lineEnd);
+}
+function mapRange(range, mapping) {
+    let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);
+    return from >= to ? undefined : { from, to };
+}
+/**
+State effect that can be attached to a transaction to fold the
+given range. (You probably only need this in exceptional
+circumstances—usually you'll just want to let
+[`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold
+gutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)
+*/
+const foldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });
+/**
+State effect that unfolds the given range (if it was folded).
+*/
+const unfoldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });
+function selectedLines(view) {
+    let lines = [];
+    for (let { head } of view.state.selection.ranges) {
+        if (lines.some(l => l.from <= head && l.to >= head))
+            continue;
+        lines.push(view.lineBlockAt(head));
+    }
+    return lines;
+}
+/**
+The state field that stores the folded ranges (as a [decoration
+set](https://codemirror.net/6/docs/ref/#view.DecorationSet)). Can be passed to
+[`EditorState.toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) and
+[`fromJSON`](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) to serialize the fold
+state.
+*/
+const foldState = /*@__PURE__*/StateField.define({
+    create() {
+        return Decoration.none;
+    },
+    update(folded, tr) {
+        folded = folded.map(tr.changes);
+        for (let e of tr.effects) {
+            if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {
+                let { preparePlaceholder } = tr.state.facet(foldConfig);
+                let widget = !preparePlaceholder ? foldWidget :
+                    Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });
+                folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });
+            }
+            else if (e.is(unfoldEffect)) {
+                folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,
+                    filterFrom: e.value.from, filterTo: e.value.to });
+            }
+        }
+        // Clear folded ranges that cover the selection head
+        if (tr.selection) {
+            let onSelection = false, { head } = tr.selection.main;
+            folded.between(head, head, (a, b) => { if (a < head && b > head)
+                onSelection = true; });
+            if (onSelection)
+                folded = folded.update({
+                    filterFrom: head,
+                    filterTo: head,
+                    filter: (a, b) => b <= head || a >= head
+                });
+        }
+        return folded;
+    },
+    provide: f => EditorView.decorations.from(f),
+    toJSON(folded, state) {
+        let ranges = [];
+        folded.between(0, state.doc.length, (from, to) => { ranges.push(from, to); });
+        return ranges;
+    },
+    fromJSON(value) {
+        if (!Array.isArray(value) || value.length % 2)
+            throw new RangeError("Invalid JSON for fold state");
+        let ranges = [];
+        for (let i = 0; i < value.length;) {
+            let from = value[i++], to = value[i++];
+            if (typeof from != "number" || typeof to != "number")
+                throw new RangeError("Invalid JSON for fold state");
+            ranges.push(foldWidget.range(from, to));
+        }
+        return Decoration.set(ranges, true);
+    }
+});
+function findFold(state, from, to) {
+    var _a;
+    let found = null;
+    (_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {
+        if (!found || found.from > from)
+            found = { from, to };
+    });
+    return found;
+}
+function foldExists(folded, from, to) {
+    let found = false;
+    folded.between(from, from, (a, b) => { if (a == from && b == to)
+        found = true; });
+    return found;
+}
+function maybeEnable(state, other) {
+    return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));
+}
+/**
+Fold the lines that are selected, if possible.
+*/
+const foldCode = view => {
+    for (let line of selectedLines(view)) {
+        let range = foldable(view.state, line.from, line.to);
+        if (range) {
+            view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });
+            return true;
+        }
+    }
+    return false;
+};
+/**
+Unfold folded ranges on selected lines.
+*/
+const unfoldCode = view => {
+    if (!view.state.field(foldState, false))
+        return false;
+    let effects = [];
+    for (let line of selectedLines(view)) {
+        let folded = findFold(view.state, line.from, line.to);
+        if (folded)
+            effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));
+    }
+    if (effects.length)
+        view.dispatch({ effects });
+    return effects.length > 0;
+};
+function announceFold(view, range, fold = true) {
+    let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;
+    return EditorView.announce.of(`${view.state.phrase(fold ? "Folded lines" : "Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);
+}
+/**
+Fold all top-level foldable ranges. Note that, in most cases,
+folding information will depend on the [syntax
+tree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work
+reliably when the document hasn't been fully parsed (either
+because the editor state was only just initialized, or because the
+document is so big that the parser decided not to parse it
+entirely).
+*/
+const foldAll = view => {
+    let { state } = view, effects = [];
+    for (let pos = 0; pos < state.doc.length;) {
+        let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);
+        if (range)
+            effects.push(foldEffect.of(range));
+        pos = (range ? view.lineBlockAt(range.to) : line).to + 1;
+    }
+    if (effects.length)
+        view.dispatch({ effects: maybeEnable(view.state, effects) });
+    return !!effects.length;
+};
+/**
+Unfold all folded code.
+*/
+const unfoldAll = view => {
+    let field = view.state.field(foldState, false);
+    if (!field || !field.size)
+        return false;
+    let effects = [];
+    field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });
+    view.dispatch({ effects });
+    return true;
+};
+/**
+Default fold-related key bindings.
+
+ - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).
+ - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).
+ - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).
+ - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).
+*/
+const foldKeymap = [
+    { key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: foldCode },
+    { key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: unfoldCode },
+    { key: "Ctrl-Alt-[", run: foldAll },
+    { key: "Ctrl-Alt-]", run: unfoldAll }
+];
+const defaultConfig = {
+    placeholderDOM: null,
+    preparePlaceholder: null,
+    placeholderText: "…"
+};
+const foldConfig = /*@__PURE__*/Facet.define({
+    combine(values) { return combineConfig(values, defaultConfig); }
+});
+/**
+Create an extension that configures code folding.
+*/
+function codeFolding(config) {
+    let result = [foldState, baseTheme$1$2];
+    return result;
+}
+function widgetToDOM(view, prepared) {
+    let { state } = view, conf = state.facet(foldConfig);
+    let onclick = (event) => {
+        let line = view.lineBlockAt(view.posAtDOM(event.target));
+        let folded = findFold(view.state, line.from, line.to);
+        if (folded)
+            view.dispatch({ effects: unfoldEffect.of(folded) });
+        event.preventDefault();
+    };
+    if (conf.placeholderDOM)
+        return conf.placeholderDOM(view, onclick, prepared);
+    let element = document.createElement("span");
+    element.textContent = conf.placeholderText;
+    element.setAttribute("aria-label", state.phrase("folded code"));
+    element.title = state.phrase("unfold");
+    element.className = "cm-foldPlaceholder";
+    element.onclick = onclick;
+    return element;
+}
+const foldWidget = /*@__PURE__*/Decoration.replace({ widget: /*@__PURE__*/new class extends WidgetType {
+        toDOM(view) { return widgetToDOM(view, null); }
+    } });
+class PreparedFoldWidget extends WidgetType {
+    constructor(value) {
+        super();
+        this.value = value;
+    }
+    eq(other) { return this.value == other.value; }
+    toDOM(view) { return widgetToDOM(view, this.value); }
+}
+const foldGutterDefaults = {
+    openText: "⌄",
+    closedText: "›",
+    markerDOM: null,
+    domEventHandlers: {},
+    foldingChanged: () => false
+};
+class FoldMarker extends GutterMarker {
+    constructor(config, open) {
+        super();
+        this.config = config;
+        this.open = open;
+    }
+    eq(other) { return this.config == other.config && this.open == other.open; }
+    toDOM(view) {
+        if (this.config.markerDOM)
+            return this.config.markerDOM(this.open);
+        let span = document.createElement("span");
+        span.textContent = this.open ? this.config.openText : this.config.closedText;
+        span.title = view.state.phrase(this.open ? "Fold line" : "Unfold line");
+        return span;
+    }
+}
+/**
+Create an extension that registers a fold gutter, which shows a
+fold status indicator before foldable lines (which can be clicked
+to fold or unfold the line).
+*/
+function foldGutter(config = {}) {
+    let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
+    let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
+    let markers = ViewPlugin.fromClass(class {
+        constructor(view) {
+            this.from = view.viewport.from;
+            this.markers = this.buildMarkers(view);
+        }
+        update(update) {
+            if (update.docChanged || update.viewportChanged ||
+                update.startState.facet(language) != update.state.facet(language) ||
+                update.startState.field(foldState, false) != update.state.field(foldState, false) ||
+                syntaxTree(update.startState) != syntaxTree(update.state) ||
+                fullConfig.foldingChanged(update))
+                this.markers = this.buildMarkers(update.view);
+        }
+        buildMarkers(view) {
+            let builder = new RangeSetBuilder();
+            for (let line of view.viewportLineBlocks) {
+                let mark = findFold(view.state, line.from, line.to) ? canUnfold
+                    : foldable(view.state, line.from, line.to) ? canFold : null;
+                if (mark)
+                    builder.add(line.from, line.from, mark);
+            }
+            return builder.finish();
+        }
+    });
+    let { domEventHandlers } = fullConfig;
+    return [
+        markers,
+        gutter({
+            class: "cm-foldGutter",
+            markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet.empty; },
+            initialSpacer() {
+                return new FoldMarker(fullConfig, false);
+            },
+            domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
+                    if (domEventHandlers.click && domEventHandlers.click(view, line, event))
+                        return true;
+                    let folded = findFold(view.state, line.from, line.to);
+                    if (folded) {
+                        view.dispatch({ effects: unfoldEffect.of(folded) });
+                        return true;
+                    }
+                    let range = foldable(view.state, line.from, line.to);
+                    if (range) {
+                        view.dispatch({ effects: foldEffect.of(range) });
+                        return true;
+                    }
+                    return false;
+                } })
+        }),
+        codeFolding()
+    ];
+}
+const baseTheme$1$2 = /*@__PURE__*/EditorView.baseTheme({
+    ".cm-foldPlaceholder": {
+        backgroundColor: "#eee",
+        border: "1px solid #ddd",
+        color: "#888",
+        borderRadius: ".2em",
+        margin: "0 1px",
+        padding: "0 1px",
+        cursor: "pointer"
+    },
+    ".cm-foldGutter span": {
+        padding: "0 1px",
+        cursor: "pointer"
+    }
+});
+
+/**
+A highlight style associates CSS styles with higlighting
+[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
+*/
+class HighlightStyle {
+    constructor(
+    /**
+    The tag styles used to create this highlight style.
+    */
+    specs, options) {
+        this.specs = specs;
+        let modSpec;
+        function def(spec) {
+            let cls = StyleModule.newName();
+            (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
+            return cls;
+        }
+        const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
+        const scopeOpt = options.scope;
+        this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
+            : scopeOpt ? (type) => type == scopeOpt : undefined;
+        this.style = tagHighlighter(specs.map(style => ({
+            tag: style.tag,
+            class: style.class || def(Object.assign({}, style, { tag: null }))
+        })), {
+            all,
+        }).style;
+        this.module = modSpec ? new StyleModule(modSpec) : null;
+        this.themeType = options.themeType;
+    }
+    /**
+    Create a highlighter style that associates the given styles to
+    the given tags. The specs must be objects that hold a style tag
+    or array of tags in their `tag` property, and either a single
+    `class` property providing a static CSS class (for highlighter
+    that rely on external styling), or a
+    [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
+    set of CSS properties (which define the styling for those tags).
+    
+    The CSS rules created for a highlighter will be emitted in the
+    order of the spec's properties. That means that for elements that
+    have multiple tags associated with them, styles defined further
+    down in the list will have a higher CSS precedence than styles
+    defined earlier.
+    */
+    static define(specs, options) {
+        return new HighlightStyle(specs, options || {});
+    }
+}
+const highlighterFacet = /*@__PURE__*/Facet.define();
+const fallbackHighlighter = /*@__PURE__*/Facet.define({
+    combine(values) { return values.length ? [values[0]] : null; }
+});
+function getHighlighters(state) {
+    let main = state.facet(highlighterFacet);
+    return main.length ? main : state.facet(fallbackHighlighter);
+}
+/**
+Wrap a highlighter in an editor extension that uses it to apply
+syntax highlighting to the editor content.
+
+When multiple (non-fallback) styles are provided, the styling
+applied is the union of the classes they emit.
+*/
+function syntaxHighlighting(highlighter, options) {
+    let ext = [treeHighlighter], themeType;
+    if (highlighter instanceof HighlightStyle) {
+        if (highlighter.module)
+            ext.push(EditorView.styleModule.of(highlighter.module));
+        themeType = highlighter.themeType;
+    }
+    if (options === null || options === void 0 ? void 0 : options.fallback)
+        ext.push(fallbackHighlighter.of(highlighter));
+    else if (themeType)
+        ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {
+            return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
+        }));
+    else
+        ext.push(highlighterFacet.of(highlighter));
+    return ext;
+}
+class TreeHighlighter {
+    constructor(view) {
+        this.markCache = Object.create(null);
+        this.tree = syntaxTree(view.state);
+        this.decorations = this.buildDeco(view, getHighlighters(view.state));
+        this.decoratedTo = view.viewport.to;
+    }
+    update(update) {
+        let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);
+        let styleChange = highlighters != getHighlighters(update.startState);
+        let { viewport } = update.view, decoratedToMapped = update.changes.mapPos(this.decoratedTo, 1);
+        if (tree.length < viewport.to && !styleChange && tree.type == this.tree.type && decoratedToMapped >= viewport.to) {
+            this.decorations = this.decorations.map(update.changes);
+            this.decoratedTo = decoratedToMapped;
+        }
+        else if (tree != this.tree || update.viewportChanged || styleChange) {
+            this.tree = tree;
+            this.decorations = this.buildDeco(update.view, highlighters);
+            this.decoratedTo = viewport.to;
+        }
+    }
+    buildDeco(view, highlighters) {
+        if (!highlighters || !this.tree.length)
+            return Decoration.none;
+        let builder = new RangeSetBuilder();
+        for (let { from, to } of view.visibleRanges) {
+            highlightTree(this.tree, highlighters, (from, to, style) => {
+                builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));
+            }, from, to);
+        }
+        return builder.finish();
+    }
+}
+const treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {
+    decorations: v => v.decorations
+}));
+/**
+A default highlight style (works well with light themes).
+*/
+const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
+    { tag: tags.meta,
+        color: "#404740" },
+    { tag: tags.link,
+        textDecoration: "underline" },
+    { tag: tags.heading,
+        textDecoration: "underline",
+        fontWeight: "bold" },
+    { tag: tags.emphasis,
+        fontStyle: "italic" },
+    { tag: tags.strong,
+        fontWeight: "bold" },
+    { tag: tags.strikethrough,
+        textDecoration: "line-through" },
+    { tag: tags.keyword,
+        color: "#708" },
+    { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
+        color: "#219" },
+    { tag: [tags.literal, tags.inserted],
+        color: "#164" },
+    { tag: [tags.string, tags.deleted],
+        color: "#a11" },
+    { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],
+        color: "#e40" },
+    { tag: /*@__PURE__*/tags.definition(tags.variableName),
+        color: "#00f" },
+    { tag: /*@__PURE__*/tags.local(tags.variableName),
+        color: "#30a" },
+    { tag: [tags.typeName, tags.namespace],
+        color: "#085" },
+    { tag: tags.className,
+        color: "#167" },
+    { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],
+        color: "#256" },
+    { tag: /*@__PURE__*/tags.definition(tags.propertyName),
+        color: "#00c" },
+    { tag: tags.comment,
+        color: "#940" },
+    { tag: tags.invalid,
+        color: "#f00" }
+]);
+
+const baseTheme$3 = /*@__PURE__*/EditorView.baseTheme({
+    "&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
+    "&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
+});
+const DefaultScanDist = 10000, DefaultBrackets = "()[]{}";
+const bracketMatchingConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        return combineConfig(configs, {
+            afterCursor: true,
+            brackets: DefaultBrackets,
+            maxScanDistance: DefaultScanDist,
+            renderMatch: defaultRenderMatch
+        });
+    }
+});
+const matchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-matchingBracket" }), nonmatchingMark = /*@__PURE__*/Decoration.mark({ class: "cm-nonmatchingBracket" });
+function defaultRenderMatch(match) {
+    let decorations = [];
+    let mark = match.matched ? matchingMark : nonmatchingMark;
+    decorations.push(mark.range(match.start.from, match.start.to));
+    if (match.end)
+        decorations.push(mark.range(match.end.from, match.end.to));
+    return decorations;
+}
+const bracketMatchingState = /*@__PURE__*/StateField.define({
+    create() { return Decoration.none; },
+    update(deco, tr) {
+        if (!tr.docChanged && !tr.selection)
+            return deco;
+        let decorations = [];
+        let config = tr.state.facet(bracketMatchingConfig);
+        for (let range of tr.state.selection.ranges) {
+            if (!range.empty)
+                continue;
+            let match = matchBrackets(tr.state, range.head, -1, config)
+                || (range.head > 0 && matchBrackets(tr.state, range.head - 1, 1, config))
+                || (config.afterCursor &&
+                    (matchBrackets(tr.state, range.head, 1, config) ||
+                        (range.head < tr.state.doc.length && matchBrackets(tr.state, range.head + 1, -1, config))));
+            if (match)
+                decorations = decorations.concat(config.renderMatch(match, tr.state));
+        }
+        return Decoration.set(decorations, true);
+    },
+    provide: f => EditorView.decorations.from(f)
+});
+const bracketMatchingUnique = [
+    bracketMatchingState,
+    baseTheme$3
+];
+/**
+Create an extension that enables bracket matching. Whenever the
+cursor is next to a bracket, that bracket and the one it matches
+are highlighted. Or, when no matching bracket is found, another
+highlighting style is used to indicate this.
+*/
+function bracketMatching(config = {}) {
+    return [bracketMatchingConfig.of(config), bracketMatchingUnique];
+}
+/**
+When larger syntax nodes, such as HTML tags, are marked as
+opening/closing, it can be a bit messy to treat the whole node as
+a matchable bracket. This node prop allows you to define, for such
+a node, a ‘handle’—the part of the node that is highlighted, and
+that the cursor must be on to activate highlighting in the first
+place.
+*/
+const bracketMatchingHandle = /*@__PURE__*/new NodeProp$1();
+function matchingNodes(node, dir, brackets) {
+    let byProp = node.prop(dir < 0 ? NodeProp$1.openedBy : NodeProp$1.closedBy);
+    if (byProp)
+        return byProp;
+    if (node.name.length == 1) {
+        let index = brackets.indexOf(node.name);
+        if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
+            return [brackets[index + dir]];
+    }
+    return null;
+}
+function findHandle(node) {
+    let hasHandle = node.type.prop(bracketMatchingHandle);
+    return hasHandle ? hasHandle(node.node) : node;
+}
+/**
+Find the matching bracket for the token at `pos`, scanning
+direction `dir`. Only the `brackets` and `maxScanDistance`
+properties are used from `config`, if given. Returns null if no
+bracket was found at `pos`, or a match result otherwise.
+*/
+function matchBrackets(state, pos, dir, config = {}) {
+    let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;
+    let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);
+    for (let cur = node; cur; cur = cur.parent) {
+        let matches = matchingNodes(cur.type, dir, brackets);
+        if (matches && cur.from < cur.to) {
+            let handle = findHandle(cur);
+            if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))
+                return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);
+        }
+    }
+    return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
+}
+function matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {
+    let parent = token.parent, firstToken = { from: handle.from, to: handle.to };
+    let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
+    if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
+        do {
+            if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
+                if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
+                    let endHandle = findHandle(cursor);
+                    return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : undefined, matched: true };
+                }
+                else if (matchingNodes(cursor.type, dir, brackets)) {
+                    depth++;
+                }
+                else if (matchingNodes(cursor.type, -dir, brackets)) {
+                    if (depth == 0) {
+                        let endHandle = findHandle(cursor);
+                        return {
+                            start: firstToken,
+                            end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : undefined,
+                            matched: false
+                        };
+                    }
+                    depth--;
+                }
+            }
+        } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
+    return { start: firstToken, matched: false };
+}
+function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
+    let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
+    let bracket = brackets.indexOf(startCh);
+    if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
+        return null;
+    let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
+    let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
+    for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
+        let text = iter.value;
+        if (dir < 0)
+            distance += text.length;
+        let basePos = pos + distance * dir;
+        for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
+            let found = brackets.indexOf(text[pos]);
+            if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType)
+                continue;
+            if ((found % 2 == 0) == (dir > 0)) {
+                depth++;
+            }
+            else if (depth == 1) { // Closing
+                return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
+            }
+            else {
+                depth--;
+            }
+        }
+        if (dir > 0)
+            distance += text.length;
+    }
+    return iter.done ? { start: startToken, matched: false } : null;
+}
+const noTokens = /*@__PURE__*/Object.create(null);
+const typeArray = [NodeType$1.none];
+const warned = [];
+// Cache of node types by name and tags
+const byTag = /*@__PURE__*/Object.create(null);
+const defaultTable = /*@__PURE__*/Object.create(null);
+for (let [legacyName, name] of [
+    ["variable", "variableName"],
+    ["variable-2", "variableName.special"],
+    ["string-2", "string.special"],
+    ["def", "variableName.definition"],
+    ["tag", "tagName"],
+    ["attribute", "attributeName"],
+    ["type", "typeName"],
+    ["builtin", "variableName.standard"],
+    ["qualifier", "modifier"],
+    ["error", "invalid"],
+    ["header", "heading"],
+    ["property", "propertyName"]
+])
+    defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);
+function warnForPart(part, msg) {
+    if (warned.indexOf(part) > -1)
+        return;
+    warned.push(part);
+    console.warn(msg);
+}
+function createTokenType(extra, tagStr) {
+    let tags$1 = [];
+    for (let name of tagStr.split(" ")) {
+        let found = [];
+        for (let part of name.split(".")) {
+            let value = (extra[part] || tags[part]);
+            if (!value) {
+                warnForPart(part, `Unknown highlighting tag ${part}`);
+            }
+            else if (typeof value == "function") {
+                if (!found.length)
+                    warnForPart(part, `Modifier ${part} used at start of tag`);
+                else
+                    found = found.map(value);
+            }
+            else {
+                if (found.length)
+                    warnForPart(part, `Tag ${part} used as modifier`);
+                else
+                    found = Array.isArray(value) ? value : [value];
+            }
+        }
+        for (let tag of found)
+            tags$1.push(tag);
+    }
+    if (!tags$1.length)
+        return 0;
+    let name = tagStr.replace(/ /g, "_"), key = name + " " + tags$1.map(t => t.id);
+    let known = byTag[key];
+    if (known)
+        return known.id;
+    let type = byTag[key] = NodeType$1.define({
+        id: typeArray.length,
+        name,
+        props: [styleTags({ [name]: tags$1 })]
+    });
+    typeArray.push(type);
+    return type.id;
+}
+({
+    rtl: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "rtl" }, bidiIsolate: Direction.RTL }),
+    ltr: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "ltr" }, bidiIsolate: Direction.LTR }),
+    auto: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "auto" }, bidiIsolate: null })
+});
+
+// FIXME profile adding a per-Tree TreeNode cache, validating it by
+// parent pointer
+/// The default maximum length of a `TreeBuffer` node (1024).
+let nextPropID = 0;
+/// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
+/// can have metadata associated with it in props. Instances of this
+/// class represent prop names.
+class NodeProp {
+    /// Create a new node prop type.
+    constructor(config = {}) {
+        this.id = nextPropID++;
+        this.perNode = !!config.perNode;
+        this.deserialize = config.deserialize || (() => {
+            throw new Error("This node type doesn't define a deserialize function");
+        });
+    }
+    /// This is meant to be used with
+    /// [`NodeSet.extend`](#common.NodeSet.extend) or
+    /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
+    /// prop values for each node type in the set. Takes a [match
+    /// object](#common.NodeType^match) or function that returns undefined
+    /// if the node type doesn't get this prop, and the prop's value if
+    /// it does.
+    add(match) {
+        if (this.perNode)
+            throw new RangeError("Can't add per-node props to node types");
+        if (typeof match != "function")
+            match = NodeType.match(match);
+        return (type) => {
+            let result = match(type);
+            return result === undefined ? null : [this, result];
+        };
+    }
+}
+/// Prop that is used to describe matching delimiters. For opening
+/// delimiters, this holds an array of node names (written as a
+/// space-separated string when declaring this prop in a grammar)
+/// for the node types of closing delimiters that match it.
+NodeProp.closedBy = new NodeProp({ deserialize: str => str.split(" ") });
+/// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
+/// attached to closing delimiters, holding an array of node names
+/// of types of matching opening delimiters.
+NodeProp.openedBy = new NodeProp({ deserialize: str => str.split(" ") });
+/// Used to assign node types to groups (for example, all node
+/// types that represent an expression could be tagged with an
+/// `"Expression"` group).
+NodeProp.group = new NodeProp({ deserialize: str => str.split(" ") });
+/// The hash of the [context](#lr.ContextTracker.constructor)
+/// that the node was parsed in, if any. Used to limit reuse of
+/// contextual nodes.
+NodeProp.contextHash = new NodeProp({ perNode: true });
+/// The distance beyond the end of the node that the tokenizer
+/// looked ahead for any of the tokens inside the node. (The LR
+/// parser only stores this when it is larger than 25, for
+/// efficiency reasons.)
+NodeProp.lookAhead = new NodeProp({ perNode: true });
+/// This per-node prop is used to replace a given node, or part of a
+/// node, with another tree. This is useful to include trees from
+/// different languages.
+NodeProp.mounted = new NodeProp({ perNode: true });
+const noProps = Object.create(null);
+/// Each node in a syntax tree has a node type associated with it.
+class NodeType {
+    /// @internal
+    constructor(
+    /// The name of the node type. Not necessarily unique, but if the
+    /// grammar was written properly, different node types with the
+    /// same name within a node set should play the same semantic
+    /// role.
+    name, 
+    /// @internal
+    props, 
+    /// The id of this node in its set. Corresponds to the term ids
+    /// used in the parser.
+    id, 
+    /// @internal
+    flags = 0) {
+        this.name = name;
+        this.props = props;
+        this.id = id;
+        this.flags = flags;
+    }
+    static define(spec) {
+        let props = spec.props && spec.props.length ? Object.create(null) : noProps;
+        let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
+            (spec.error ? 4 /* Error */ : 0) | (spec.name == null ? 8 /* Anonymous */ : 0);
+        let type = new NodeType(spec.name || "", props, spec.id, flags);
+        if (spec.props)
+            for (let src of spec.props) {
+                if (!Array.isArray(src))
+                    src = src(type);
+                if (src) {
+                    if (src[0].perNode)
+                        throw new RangeError("Can't store a per-node prop on a node type");
+                    props[src[0].id] = src[1];
+                }
+            }
+        return type;
+    }
+    /// Retrieves a node prop for this type. Will return `undefined` if
+    /// the prop isn't present on this node.
+    prop(prop) { return this.props[prop.id]; }
+    /// True when this is the top node of a grammar.
+    get isTop() { return (this.flags & 1 /* Top */) > 0; }
+    /// True when this node is produced by a skip rule.
+    get isSkipped() { return (this.flags & 2 /* Skipped */) > 0; }
+    /// Indicates whether this is an error node.
+    get isError() { return (this.flags & 4 /* Error */) > 0; }
+    /// When true, this node type doesn't correspond to a user-declared
+    /// named node, for example because it is used to cache repetition.
+    get isAnonymous() { return (this.flags & 8 /* Anonymous */) > 0; }
+    /// Returns true when this node's name or one of its
+    /// [groups](#common.NodeProp^group) matches the given string.
+    is(name) {
+        if (typeof name == 'string') {
+            if (this.name == name)
+                return true;
+            let group = this.prop(NodeProp.group);
+            return group ? group.indexOf(name) > -1 : false;
+        }
+        return this.id == name;
+    }
+    /// Create a function from node types to arbitrary values by
+    /// specifying an object whose property names are node or
+    /// [group](#common.NodeProp^group) names. Often useful with
+    /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
+    /// names, separated by spaces, in a single property name to map
+    /// multiple node names to a single value.
+    static match(map) {
+        let direct = Object.create(null);
+        for (let prop in map)
+            for (let name of prop.split(" "))
+                direct[name] = map[prop];
+        return (node) => {
+            for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
+                let found = direct[i < 0 ? node.name : groups[i]];
+                if (found)
+                    return found;
+            }
+        };
+    }
+}
+/// An empty dummy node type to use when no actual type is available.
+NodeType.none = new NodeType("", Object.create(null), 0, 8 /* Anonymous */);
+/// Options that control iteration. Can be combined with the `|`
+/// operator to enable multiple ones.
+var IterMode;
+(function (IterMode) {
+    /// When enabled, iteration will only visit [`Tree`](#common.Tree)
+    /// objects, not nodes packed into
+    /// [`TreeBuffer`](#common.TreeBuffer)s.
+    IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
+    /// Enable this to make iteration include anonymous nodes (such as
+    /// the nodes that wrap repeated grammar constructs into a balanced
+    /// tree).
+    IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
+    /// By default, regular [mounted](#common.NodeProp^mounted) nodes
+    /// replace their base node in iteration. Enable this to ignore them
+    /// instead.
+    IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
+    /// This option only applies in
+    /// [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
+    /// library to not enter mounted overlays if one covers the given
+    /// position.
+    IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
+})(IterMode || (IterMode = {}));
+new NodeProp({ perNode: true });
+
+/**
+Comment or uncomment the current selection. Will use line comments
+if available, otherwise falling back to block comments.
+*/
+const toggleComment = target => {
+    let config = getConfig(target.state);
+    return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
+};
+function command(f, option) {
+    return ({ state, dispatch }) => {
+        if (state.readOnly)
+            return false;
+        let tr = f(option, state);
+        if (!tr)
+            return false;
+        dispatch(state.update(tr));
+        return true;
+    };
+}
+/**
+Comment or uncomment the current selection using line comments.
+The line comment syntax is taken from the
+[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
+*/
+const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* Toggle */);
+/**
+Comment or uncomment the current selection using block comments.
+The block comment syntax is taken from the
+[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
+*/
+const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* Toggle */);
+/**
+Comment or uncomment the lines around the current selection using
+block comments.
+*/
+const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
+function getConfig(state, pos = state.selection.main.head) {
+    let data = state.languageDataAt("commentTokens", pos);
+    return data.length ? data[0] : {};
+}
+const SearchMargin = 50;
+/**
+Determines if the given range is block-commented in the given
+state.
+*/
+function findBlockComment(state, { open, close }, from, to) {
+    let textBefore = state.sliceDoc(from - SearchMargin, from);
+    let textAfter = state.sliceDoc(to, to + SearchMargin);
+    let spaceBefore = /\s*$/.exec(textBefore)[0].length, spaceAfter = /^\s*/.exec(textAfter)[0].length;
+    let beforeOff = textBefore.length - spaceBefore;
+    if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&
+        textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {
+        return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },
+            close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };
+    }
+    let startText, endText;
+    if (to - from <= 2 * SearchMargin) {
+        startText = endText = state.sliceDoc(from, to);
+    }
+    else {
+        startText = state.sliceDoc(from, from + SearchMargin);
+        endText = state.sliceDoc(to - SearchMargin, to);
+    }
+    let startSpace = /^\s*/.exec(startText)[0].length, endSpace = /\s*$/.exec(endText)[0].length;
+    let endOff = endText.length - endSpace - close.length;
+    if (startText.slice(startSpace, startSpace + open.length) == open &&
+        endText.slice(endOff, endOff + close.length) == close) {
+        return { open: { pos: from + startSpace + open.length,
+                margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },
+            close: { pos: to - endSpace - close.length,
+                margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };
+    }
+    return null;
+}
+function selectedLineRanges(state) {
+    let ranges = [];
+    for (let r of state.selection.ranges) {
+        let fromLine = state.doc.lineAt(r.from);
+        let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
+        let last = ranges.length - 1;
+        if (last >= 0 && ranges[last].to > fromLine.from)
+            ranges[last].to = toLine.to;
+        else
+            ranges.push({ from: fromLine.from, to: toLine.to });
+    }
+    return ranges;
+}
+// Performs toggle, comment and uncomment of block comments in
+// languages that support them.
+function changeBlockComment(option, state, ranges = state.selection.ranges) {
+    let tokens = ranges.map(r => getConfig(state, r.from).block);
+    if (!tokens.every(c => c))
+        return null;
+    let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
+    if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
+        return { changes: state.changes(ranges.map((range, i) => {
+                if (comments[i])
+                    return [];
+                return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
+            })) };
+    }
+    else if (option != 1 /* Comment */ && comments.some(c => c)) {
+        let changes = [];
+        for (let i = 0, comment; i < comments.length; i++)
+            if (comment = comments[i]) {
+                let token = tokens[i], { open, close } = comment;
+                changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });
+            }
+        return { changes };
+    }
+    return null;
+}
+// Performs toggle, comment and uncomment of line comments.
+function changeLineComment(option, state, ranges = state.selection.ranges) {
+    let lines = [];
+    let prevLine = -1;
+    for (let { from, to } of ranges) {
+        let startI = lines.length, minIndent = 1e9;
+        for (let pos = from; pos <= to;) {
+            let line = state.doc.lineAt(pos);
+            if (line.from > prevLine && (from == to || to > line.from)) {
+                prevLine = line.from;
+                let token = getConfig(state, pos).line;
+                if (!token)
+                    continue;
+                let indent = /^\s*/.exec(line.text)[0].length;
+                let empty = indent == line.length;
+                let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
+                if (indent < line.text.length && indent < minIndent)
+                    minIndent = indent;
+                lines.push({ line, comment, token, indent, empty, single: false });
+            }
+            pos = line.to + 1;
+        }
+        if (minIndent < 1e9)
+            for (let i = startI; i < lines.length; i++)
+                if (lines[i].indent < lines[i].line.text.length)
+                    lines[i].indent = minIndent;
+        if (lines.length == startI + 1)
+            lines[startI].single = true;
+    }
+    if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
+        let changes = [];
+        for (let { line, token, indent, empty, single } of lines)
+            if (single || !empty)
+                changes.push({ from: line.from + indent, insert: token + " " });
+        let changeSet = state.changes(changes);
+        return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
+    }
+    else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
+        let changes = [];
+        for (let { line, comment, token } of lines)
+            if (comment >= 0) {
+                let from = line.from + comment, to = from + token.length;
+                if (line.text[to - line.from] == " ")
+                    to++;
+                changes.push({ from, to });
+            }
+        return { changes };
+    }
+    return null;
+}
+
+const fromHistory = /*@__PURE__*/Annotation.define();
+/**
+Transaction annotation that will prevent that transaction from
+being combined with other transactions in the undo history. Given
+`"before"`, it'll prevent merging with previous transactions. With
+`"after"`, subsequent transactions won't be combined with this
+one. With `"full"`, the transaction is isolated on both sides.
+*/
+const isolateHistory = /*@__PURE__*/Annotation.define();
+/**
+This facet provides a way to register functions that, given a
+transaction, provide a set of effects that the history should
+store when inverting the transaction. This can be used to
+integrate some kinds of effects in the history, so that they can
+be undone (and redone again).
+*/
+const invertedEffects = /*@__PURE__*/Facet.define();
+const historyConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        return combineConfig(configs, {
+            minDepth: 100,
+            newGroupDelay: 500
+        }, { minDepth: Math.max, newGroupDelay: Math.min });
+    }
+});
+function changeEnd(changes) {
+    let end = 0;
+    changes.iterChangedRanges((_, to) => end = to);
+    return end;
+}
+const historyField_ = /*@__PURE__*/StateField.define({
+    create() {
+        return HistoryState.empty;
+    },
+    update(state, tr) {
+        let config = tr.state.facet(historyConfig);
+        let fromHist = tr.annotation(fromHistory);
+        if (fromHist) {
+            let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;
+            let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
+            let other = from == 0 /* Done */ ? state.undone : state.done;
+            if (item)
+                other = updateBranch(other, other.length, config.minDepth, item);
+            else
+                other = addSelection(other, tr.startState.selection);
+            return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
+        }
+        let isolate = tr.annotation(isolateHistory);
+        if (isolate == "full" || isolate == "before")
+            state = state.isolate();
+        if (tr.annotation(Transaction.addToHistory) === false)
+            return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;
+        let event = HistEvent.fromTransaction(tr);
+        let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent);
+        if (event)
+            state = state.addChanges(event, time, userEvent, config.newGroupDelay, config.minDepth);
+        else if (tr.selection)
+            state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
+        if (isolate == "full" || isolate == "after")
+            state = state.isolate();
+        return state;
+    },
+    toJSON(value) {
+        return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };
+    },
+    fromJSON(json) {
+        return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));
+    }
+});
+/**
+Create a history extension with the given configuration.
+*/
+function history(config = {}) {
+    return [
+        historyField_,
+        historyConfig.of(config),
+        EditorView.domEventHandlers({
+            beforeinput(e, view) {
+                let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null;
+                if (!command)
+                    return false;
+                e.preventDefault();
+                return command(view);
+            }
+        })
+    ];
+}
+function cmd(side, selection) {
+    return function ({ state, dispatch }) {
+        if (!selection && state.readOnly)
+            return false;
+        let historyState = state.field(historyField_, false);
+        if (!historyState)
+            return false;
+        let tr = historyState.pop(side, state, selection);
+        if (!tr)
+            return false;
+        dispatch(tr);
+        return true;
+    };
+}
+/**
+Undo a single group of history events. Returns false if no group
+was available.
+*/
+const undo = /*@__PURE__*/cmd(0 /* Done */, false);
+/**
+Redo a group of history events. Returns false if no group was
+available.
+*/
+const redo = /*@__PURE__*/cmd(1 /* Undone */, false);
+/**
+Undo a change or selection change.
+*/
+const undoSelection = /*@__PURE__*/cmd(0 /* Done */, true);
+/**
+Redo a change or selection change.
+*/
+const redoSelection = /*@__PURE__*/cmd(1 /* Undone */, true);
+// History events store groups of changes or effects that need to be
+// undone/redone together.
+class HistEvent {
+    constructor(
+    // The changes in this event. Normal events hold at least one
+    // change or effect. But it may be necessary to store selection
+    // events before the first change, in which case a special type of
+    // instance is created which doesn't hold any changes, with
+    // changes == startSelection == undefined
+    changes, 
+    // The effects associated with this event
+    effects, mapped, 
+    // The selection before this event
+    startSelection, 
+    // Stores selection changes after this event, to be used for
+    // selection undo/redo.
+    selectionsAfter) {
+        this.changes = changes;
+        this.effects = effects;
+        this.mapped = mapped;
+        this.startSelection = startSelection;
+        this.selectionsAfter = selectionsAfter;
+    }
+    setSelAfter(after) {
+        return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);
+    }
+    toJSON() {
+        var _a, _b, _c;
+        return {
+            changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),
+            mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),
+            startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),
+            selectionsAfter: this.selectionsAfter.map(s => s.toJSON())
+        };
+    }
+    static fromJSON(json) {
+        return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.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(tr, selection) {
+        let effects = none$1;
+        for (let invert of tr.startState.facet(invertedEffects)) {
+            let result = invert(tr);
+            if (result.length)
+                effects = effects.concat(result);
+        }
+        if (!effects.length && tr.changes.empty)
+            return null;
+        return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none$1);
+    }
+    static selection(selections) {
+        return new HistEvent(undefined, none$1, undefined, undefined, selections);
+    }
+}
+function updateBranch(branch, to, maxLen, newEvent) {
+    let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;
+    let newBranch = branch.slice(start, to);
+    newBranch.push(newEvent);
+    return newBranch;
+}
+function isAdjacent(a, b) {
+    let ranges = [], isAdjacent = false;
+    a.iterChangedRanges((f, t) => ranges.push(f, t));
+    b.iterChangedRanges((_f, _t, f, t) => {
+        for (let i = 0; i < ranges.length;) {
+            let from = ranges[i++], to = ranges[i++];
+            if (t >= from && f <= to)
+                isAdjacent = true;
+        }
+    });
+    return isAdjacent;
+}
+function eqSelectionShape(a, b) {
+    return a.ranges.length == b.ranges.length &&
+        a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;
+}
+function conc(a, b) {
+    return !a.length ? b : !b.length ? a : a.concat(b);
+}
+const none$1 = [];
+const MaxSelectionsPerEvent = 200;
+function addSelection(branch, selection) {
+    if (!branch.length) {
+        return [HistEvent.selection([selection])];
+    }
+    else {
+        let lastEvent = branch[branch.length - 1];
+        let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));
+        if (sels.length && sels[sels.length - 1].eq(selection))
+            return branch;
+        sels.push(selection);
+        return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));
+    }
+}
+// Assumes the top item has one or more selectionAfter values
+function popSelection(branch) {
+    let last = branch[branch.length - 1];
+    let newBranch = branch.slice();
+    newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));
+    return newBranch;
+}
+// Add a mapping to the top event in the given branch. If this maps
+// away all the changes and effects in that item, drop it and
+// propagate the mapping to the next item.
+function addMappingToBranch(branch, mapping) {
+    if (!branch.length)
+        return branch;
+    let length = branch.length, selections = none$1;
+    while (length) {
+        let event = mapEvent(branch[length - 1], mapping, selections);
+        if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping
+            let result = branch.slice(0, length);
+            result[length - 1] = event;
+            return result;
+        }
+        else { // Drop this event, since there's no changes or effects left
+            mapping = event.mapped;
+            length--;
+            selections = event.selectionsAfter;
+        }
+    }
+    return selections.length ? [HistEvent.selection(selections)] : none$1;
+}
+function mapEvent(event, mapping, extraSelections) {
+    let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none$1, extraSelections);
+    // Change-less events don't store mappings (they are always the last event in a branch)
+    if (!event.changes)
+        return HistEvent.selection(selections);
+    let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);
+    let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;
+    return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);
+}
+const joinableUserEvent = /^(input\.type|delete)($|\.)/;
+class HistoryState {
+    constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {
+        this.done = done;
+        this.undone = undone;
+        this.prevTime = prevTime;
+        this.prevUserEvent = prevUserEvent;
+    }
+    isolate() {
+        return this.prevTime ? new HistoryState(this.done, this.undone) : this;
+    }
+    addChanges(event, time, userEvent, newGroupDelay, maxLen) {
+        let done = this.done, lastEvent = done[done.length - 1];
+        if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&
+            (!userEvent || joinableUserEvent.test(userEvent)) &&
+            ((!lastEvent.selectionsAfter.length &&
+                time - this.prevTime < newGroupDelay &&
+                isAdjacent(lastEvent.changes, event.changes)) ||
+                // For compose (but not compose.start) events, always join with previous event
+                userEvent == "input.type.compose")) {
+            done = updateBranch(done, done.length - 1, maxLen, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none$1));
+        }
+        else {
+            done = updateBranch(done, done.length, maxLen, event);
+        }
+        return new HistoryState(done, none$1, time, userEvent);
+    }
+    addSelection(selection, time, userEvent, newGroupDelay) {
+        let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none$1;
+        if (last.length > 0 &&
+            time - this.prevTime < newGroupDelay &&
+            userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) &&
+            eqSelectionShape(last[last.length - 1], selection))
+            return this;
+        return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);
+    }
+    addMapping(mapping) {
+        return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
+    }
+    pop(side, state, selection) {
+        let branch = side == 0 /* Done */ ? this.done : this.undone;
+        if (branch.length == 0)
+            return null;
+        let event = branch[branch.length - 1];
+        if (selection && event.selectionsAfter.length) {
+            return state.update({
+                selection: event.selectionsAfter[event.selectionsAfter.length - 1],
+                annotations: fromHistory.of({ side, rest: popSelection(branch) }),
+                userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
+                scrollIntoView: true
+            });
+        }
+        else if (!event.changes) {
+            return null;
+        }
+        else {
+            let rest = branch.length == 1 ? none$1 : branch.slice(0, branch.length - 1);
+            if (event.mapped)
+                rest = addMappingToBranch(rest, event.mapped);
+            return state.update({
+                changes: event.changes,
+                selection: event.startSelection,
+                effects: event.effects,
+                annotations: fromHistory.of({ side, rest }),
+                filter: false,
+                userEvent: side == 0 /* Done */ ? "undo" : "redo",
+                scrollIntoView: true
+            });
+        }
+    }
+}
+HistoryState.empty = /*@__PURE__*/new HistoryState(none$1, none$1);
+/**
+Default key bindings for the undo history.
+
+- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
+- Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
+- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
+- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
+*/
+const historyKeymap = [
+    { key: "Mod-z", run: undo, preventDefault: true },
+    { key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true },
+    { key: "Mod-u", run: undoSelection, preventDefault: true },
+    { key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true }
+];
+
+function updateSel(sel, by) {
+    return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);
+}
+function setSel(state, selection) {
+    return state.update({ selection, scrollIntoView: true, userEvent: "select" });
+}
+function moveSel({ state, dispatch }, how) {
+    let selection = updateSel(state.selection, how);
+    if (selection.eq(state.selection))
+        return false;
+    dispatch(setSel(state, selection));
+    return true;
+}
+function rangeEnd(range, forward) {
+    return EditorSelection.cursor(forward ? range.to : range.from);
+}
+function cursorByChar(view, forward) {
+    return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
+}
+function ltrAtCursor(view) {
+    return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;
+}
+/**
+Move the selection one character to the left (which is backward in
+left-to-right text, forward in right-to-left text).
+*/
+const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
+/**
+Move the selection one character to the right.
+*/
+const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));
+function cursorByGroup(view, forward) {
+    return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
+}
+/**
+Move the selection to the left across one group of word or
+non-word (but also non-space) characters.
+*/
+const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
+/**
+Move the selection one group to the right.
+*/
+const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));
+function interestingNode(state, node, bracketProp) {
+    if (node.type.prop(bracketProp))
+        return true;
+    let len = node.to - node.from;
+    return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;
+}
+function moveBySyntax(state, start, forward) {
+    let pos = syntaxTree(state).resolveInner(start.head);
+    let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy;
+    // Scan forward through child nodes to see if there's an interesting
+    // node ahead.
+    for (let at = start.head;;) {
+        let next = forward ? pos.childAfter(at) : pos.childBefore(at);
+        if (!next)
+            break;
+        if (interestingNode(state, next, bracketProp))
+            pos = next;
+        else
+            at = forward ? next.to : next.from;
+    }
+    let bracket = pos.type.prop(bracketProp), match, newPos;
+    if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched)
+        newPos = forward ? match.end.to : match.end.from;
+    else
+        newPos = forward ? pos.to : pos.from;
+    return EditorSelection.cursor(newPos, forward ? -1 : 1);
+}
+/**
+Move the cursor over the next syntactic element to the left.
+*/
+const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
+/**
+Move the cursor over the next syntactic element to the right.
+*/
+const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
+function cursorByLine(view, forward) {
+    return moveSel(view, range => {
+        if (!range.empty)
+            return rangeEnd(range, forward);
+        let moved = view.moveVertically(range, forward);
+        return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);
+    });
+}
+/**
+Move the selection one line up.
+*/
+const cursorLineUp = view => cursorByLine(view, false);
+/**
+Move the selection one line down.
+*/
+const cursorLineDown = view => cursorByLine(view, true);
+function cursorByPage(view, forward) {
+    let { state } = view, selection = updateSel(state.selection, range => {
+        return range.empty ? view.moveVertically(range, forward, Math.min(view.dom.clientHeight, innerHeight))
+            : rangeEnd(range, forward);
+    });
+    if (selection.eq(state.selection))
+        return false;
+    let startPos = view.coordsAtPos(state.selection.main.head);
+    let scrollRect = view.scrollDOM.getBoundingClientRect();
+    let effect;
+    if (startPos && startPos.top > scrollRect.top && startPos.bottom < scrollRect.bottom &&
+        startPos.top - scrollRect.top <= view.scrollDOM.scrollHeight - view.scrollDOM.scrollTop - view.scrollDOM.clientHeight)
+        effect = EditorView.scrollIntoView(selection.main.head, { y: "start", yMargin: startPos.top - scrollRect.top });
+    view.dispatch(setSel(state, selection), { effects: effect });
+    return true;
+}
+/**
+Move the selection one page up.
+*/
+const cursorPageUp = view => cursorByPage(view, false);
+/**
+Move the selection one page down.
+*/
+const cursorPageDown = view => cursorByPage(view, true);
+function moveByLineBoundary(view, start, forward) {
+    let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward);
+    if (moved.head == start.head && moved.head != (forward ? line.to : line.from))
+        moved = view.moveToLineBoundary(start, forward, false);
+    if (!forward && moved.head == line.from && line.length) {
+        let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;
+        if (space && start.head != line.from + space)
+            moved = EditorSelection.cursor(line.from + space);
+    }
+    return moved;
+}
+/**
+Move the selection to the next line wrap point, or to the end of
+the line if there isn't one left on this line.
+*/
+const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));
+/**
+Move the selection to previous line wrap point, or failing that to
+the start of the line. If the line is indented, and the cursor
+isn't already at the end of the indentation, this will move to the
+end of the indentation instead of the start of the line.
+*/
+const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
+/**
+Move the selection to the start of the line.
+*/
+const cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));
+/**
+Move the selection to the end of the line.
+*/
+const cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1));
+function toMatchingBracket(state, dispatch, extend) {
+    let found = false, selection = updateSel(state.selection, range => {
+        let matching = matchBrackets(state, range.head, -1)
+            || matchBrackets(state, range.head, 1)
+            || (range.head > 0 && matchBrackets(state, range.head - 1, 1))
+            || (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1));
+        if (!matching || !matching.end)
+            return range;
+        found = true;
+        let head = matching.start.from == range.head ? matching.end.to : matching.end.from;
+        return EditorSelection.cursor(head);
+    });
+    if (!found)
+        return false;
+    dispatch(setSel(state, selection));
+    return true;
+}
+/**
+Move the selection to the bracket matching the one it is currently
+on, if any.
+*/
+const cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch);
+function extendSel(view, how) {
+    let selection = updateSel(view.state.selection, range => {
+        let head = how(range);
+        return EditorSelection.range(range.anchor, head.head, head.goalColumn);
+    });
+    if (selection.eq(view.state.selection))
+        return false;
+    view.dispatch(setSel(view.state, selection));
+    return true;
+}
+function selectByChar(view, forward) {
+    return extendSel(view, range => view.moveByChar(range, forward));
+}
+/**
+Move the selection head one character to the left, while leaving
+the anchor in place.
+*/
+const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));
+/**
+Move the selection head one character to the right.
+*/
+const selectCharRight = view => selectByChar(view, ltrAtCursor(view));
+function selectByGroup(view, forward) {
+    return extendSel(view, range => view.moveByGroup(range, forward));
+}
+/**
+Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
+the left.
+*/
+const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));
+/**
+Move the selection head one group to the right.
+*/
+const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));
+/**
+Move the selection head over the next syntactic element to the left.
+*/
+const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
+/**
+Move the selection head over the next syntactic element to the right.
+*/
+const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
+function selectByLine(view, forward) {
+    return extendSel(view, range => view.moveVertically(range, forward));
+}
+/**
+Move the selection head one line up.
+*/
+const selectLineUp = view => selectByLine(view, false);
+/**
+Move the selection head one line down.
+*/
+const selectLineDown = view => selectByLine(view, true);
+function selectByPage(view, forward) {
+    return extendSel(view, range => view.moveVertically(range, forward, Math.min(view.dom.clientHeight, innerHeight)));
+}
+/**
+Move the selection head one page up.
+*/
+const selectPageUp = view => selectByPage(view, false);
+/**
+Move the selection head one page down.
+*/
+const selectPageDown = view => selectByPage(view, true);
+/**
+Move the selection head to the next line boundary.
+*/
+const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));
+/**
+Move the selection head to the previous line boundary.
+*/
+const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
+/**
+Move the selection head to the start of the line.
+*/
+const selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));
+/**
+Move the selection head to the end of the line.
+*/
+const selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to));
+/**
+Move the selection to the start of the document.
+*/
+const cursorDocStart = ({ state, dispatch }) => {
+    dispatch(setSel(state, { anchor: 0 }));
+    return true;
+};
+/**
+Move the selection to the end of the document.
+*/
+const cursorDocEnd = ({ state, dispatch }) => {
+    dispatch(setSel(state, { anchor: state.doc.length }));
+    return true;
+};
+/**
+Move the selection head to the start of the document.
+*/
+const selectDocStart = ({ state, dispatch }) => {
+    dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 }));
+    return true;
+};
+/**
+Move the selection head to the end of the document.
+*/
+const selectDocEnd = ({ state, dispatch }) => {
+    dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length }));
+    return true;
+};
+/**
+Select the entire document.
+*/
+const selectAll = ({ state, dispatch }) => {
+    dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: "select" }));
+    return true;
+};
+/**
+Expand the selection to cover entire lines.
+*/
+const selectLine = ({ state, dispatch }) => {
+    let ranges = selectedLineBlocks(state).map(({ from, to }) => EditorSelection.range(from, Math.min(to + 1, state.doc.length)));
+    dispatch(state.update({ selection: EditorSelection.create(ranges), userEvent: "select" }));
+    return true;
+};
+/**
+Select the next syntactic construct that is larger than the
+selection. Note that this will only work insofar as the language
+[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
+syntax tree.
+*/
+const selectParentSyntax = ({ state, dispatch }) => {
+    let selection = updateSel(state.selection, range => {
+        var _a;
+        let context = syntaxTree(state).resolveInner(range.head, 1);
+        while (!((context.from < range.from && context.to >= range.to) ||
+            (context.to > range.to && context.from <= range.from) ||
+            !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent)))
+            context = context.parent;
+        return EditorSelection.range(context.to, context.from);
+    });
+    dispatch(setSel(state, selection));
+    return true;
+};
+/**
+Simplify the current selection. When multiple ranges are selected,
+reduce it to its main range. Otherwise, if the selection is
+non-empty, convert it to a cursor selection.
+*/
+const simplifySelection = ({ state, dispatch }) => {
+    let cur = state.selection, selection = null;
+    if (cur.ranges.length > 1)
+        selection = EditorSelection.create([cur.main]);
+    else if (!cur.main.empty)
+        selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]);
+    if (!selection)
+        return false;
+    dispatch(setSel(state, selection));
+    return true;
+};
+function deleteBy({ state, dispatch }, by) {
+    if (state.readOnly)
+        return false;
+    let event = "delete.selection";
+    let changes = state.changeByRange(range => {
+        let { from, to } = range;
+        if (from == to) {
+            let towards = by(from);
+            if (towards < from)
+                event = "delete.backward";
+            else if (towards > from)
+                event = "delete.forward";
+            from = Math.min(from, towards);
+            to = Math.max(to, towards);
+        }
+        return from == to ? { range } : { changes: { from, to }, range: EditorSelection.cursor(from) };
+    });
+    if (changes.changes.empty)
+        return false;
+    dispatch(state.update(changes, { scrollIntoView: true, userEvent: event }));
+    return true;
+}
+function skipAtomic(target, pos, forward) {
+    if (target instanceof EditorView)
+        for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target)))
+            ranges.between(pos, pos, (from, to) => {
+                if (from < pos && to > pos)
+                    pos = forward ? to : from;
+            });
+    return pos;
+}
+const deleteByChar = (target, forward) => deleteBy(target, pos => {
+    let { state } = target, line = state.doc.lineAt(pos), before, targetPos;
+    if (!forward && pos > line.from && pos < line.from + 200 &&
+        !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) {
+        if (before[before.length - 1] == "\t")
+            return pos - 1;
+        let col = countColumn(before, state.tabSize), drop = col % getIndentUnit(state) || getIndentUnit(state);
+        for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++)
+            pos--;
+        targetPos = pos;
+    }
+    else {
+        targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from;
+        if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))
+            targetPos += forward ? 1 : -1;
+    }
+    return skipAtomic(target, targetPos, forward);
+});
+/**
+Delete the selection, or, for cursor selections, the character
+before the cursor.
+*/
+const deleteCharBackward = view => deleteByChar(view, false);
+/**
+Delete the selection or the character after the cursor.
+*/
+const deleteCharForward = view => deleteByChar(view, true);
+const deleteByGroup = (target, forward) => deleteBy(target, start => {
+    let pos = start, { state } = target, line = state.doc.lineAt(pos);
+    let categorize = state.charCategorizer(pos);
+    for (let cat = null;;) {
+        if (pos == (forward ? line.to : line.from)) {
+            if (pos == start && line.number != (forward ? state.doc.lines : 1))
+                pos += forward ? 1 : -1;
+            break;
+        }
+        let next = findClusterBreak(line.text, pos - line.from, forward) + line.from;
+        let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);
+        let nextCat = categorize(nextChar);
+        if (cat != null && nextCat != cat)
+            break;
+        if (nextChar != " " || pos != start)
+            cat = nextCat;
+        pos = next;
+    }
+    return skipAtomic(target, pos, forward);
+});
+/**
+Delete the selection or backward until the end of the next
+[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
+whitespace when they consist of a single space.
+*/
+const deleteGroupBackward = target => deleteByGroup(target, false);
+/**
+Delete the selection or forward until the end of the next group.
+*/
+const deleteGroupForward = target => deleteByGroup(target, true);
+/**
+Delete the selection, or, if it is a cursor selection, delete to
+the end of the line. If the cursor is directly at the end of the
+line, delete the line break after it.
+*/
+const deleteToLineEnd = view => deleteBy(view, pos => {
+    let lineEnd = view.lineBlockAt(pos).to;
+    return skipAtomic(view, pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1), true);
+});
+/**
+Delete the selection, or, if it is a cursor selection, delete to
+the start of the line. If the cursor is directly at the start of the
+line, delete the line break before it.
+*/
+const deleteToLineStart = view => deleteBy(view, pos => {
+    let lineStart = view.lineBlockAt(pos).from;
+    return skipAtomic(view, pos > lineStart ? lineStart : Math.max(0, pos - 1), false);
+});
+/**
+Replace each selection range with a line break, leaving the cursor
+on the line before the break.
+*/
+const splitLine = ({ state, dispatch }) => {
+    if (state.readOnly)
+        return false;
+    let changes = state.changeByRange(range => {
+        return { changes: { from: range.from, to: range.to, insert: Text.of(["", ""]) },
+            range: EditorSelection.cursor(range.from) };
+    });
+    dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
+    return true;
+};
+/**
+Flip the characters before and after the cursor(s).
+*/
+const transposeChars = ({ state, dispatch }) => {
+    if (state.readOnly)
+        return false;
+    let changes = state.changeByRange(range => {
+        if (!range.empty || range.from == 0 || range.from == state.doc.length)
+            return { range };
+        let pos = range.from, line = state.doc.lineAt(pos);
+        let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from;
+        let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from;
+        return { changes: { from, to, insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos)) },
+            range: EditorSelection.cursor(to) };
+    });
+    if (changes.changes.empty)
+        return false;
+    dispatch(state.update(changes, { scrollIntoView: true, userEvent: "move.character" }));
+    return true;
+};
+function selectedLineBlocks(state) {
+    let blocks = [], upto = -1;
+    for (let range of state.selection.ranges) {
+        let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to);
+        if (!range.empty && range.to == endLine.from)
+            endLine = state.doc.lineAt(range.to - 1);
+        if (upto >= startLine.number) {
+            let prev = blocks[blocks.length - 1];
+            prev.to = endLine.to;
+            prev.ranges.push(range);
+        }
+        else {
+            blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] });
+        }
+        upto = endLine.number + 1;
+    }
+    return blocks;
+}
+function moveLine(state, dispatch, forward) {
+    if (state.readOnly)
+        return false;
+    let changes = [], ranges = [];
+    for (let block of selectedLineBlocks(state)) {
+        if (forward ? block.to == state.doc.length : block.from == 0)
+            continue;
+        let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);
+        let size = nextLine.length + 1;
+        if (forward) {
+            changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state.lineBreak });
+            for (let r of block.ranges)
+                ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
+        }
+        else {
+            changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text });
+            for (let r of block.ranges)
+                ranges.push(EditorSelection.range(r.anchor - size, r.head - size));
+        }
+    }
+    if (!changes.length)
+        return false;
+    dispatch(state.update({
+        changes,
+        scrollIntoView: true,
+        selection: EditorSelection.create(ranges, state.selection.mainIndex),
+        userEvent: "move.line"
+    }));
+    return true;
+}
+/**
+Move the selected lines up one line.
+*/
+const moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false);
+/**
+Move the selected lines down one line.
+*/
+const moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true);
+function copyLine(state, dispatch, forward) {
+    if (state.readOnly)
+        return false;
+    let changes = [];
+    for (let block of selectedLineBlocks(state)) {
+        if (forward)
+            changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak });
+        else
+            changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) });
+    }
+    dispatch(state.update({ changes, scrollIntoView: true, userEvent: "input.copyline" }));
+    return true;
+}
+/**
+Create a copy of the selected lines. Keep the selection in the top copy.
+*/
+const copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false);
+/**
+Create a copy of the selected lines. Keep the selection in the bottom copy.
+*/
+const copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true);
+/**
+Delete selected lines.
+*/
+const deleteLine = view => {
+    if (view.state.readOnly)
+        return false;
+    let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => {
+        if (from > 0)
+            from--;
+        else if (to < state.doc.length)
+            to++;
+        return { from, to };
+    }));
+    let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);
+    view.dispatch({ changes, selection, scrollIntoView: true, userEvent: "delete.line" });
+    return true;
+};
+function isBetweenBrackets(state, pos) {
+    if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1)))
+        return { from: pos, to: pos };
+    let context = syntaxTree(state).resolveInner(pos);
+    let before = context.childBefore(pos), after = context.childAfter(pos), closedBy;
+    if (before && after && before.to <= pos && after.from >= pos &&
+        (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 &&
+        state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from)
+        return { from: before.to, to: after.from };
+    return null;
+}
+/**
+Replace the selection with a newline and indent the newly created
+line(s). If the current line consists only of whitespace, this
+will also delete that whitespace. When the cursor is between
+matching brackets, an additional newline will be inserted after
+the cursor.
+*/
+const insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);
+/**
+Create a blank, indented line below the current line.
+*/
+const insertBlankLine = /*@__PURE__*/newlineAndIndent(true);
+function newlineAndIndent(atEof) {
+    return ({ state, dispatch }) => {
+        if (state.readOnly)
+            return false;
+        let changes = state.changeByRange(range => {
+            let { from, to } = range, line = state.doc.lineAt(from);
+            let explode = !atEof && from == to && isBetweenBrackets(state, from);
+            if (atEof)
+                from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;
+            let cx = new IndentContext(state, { simulateBreak: from, simulateDoubleBreak: !!explode });
+            let indent = getIndentation(cx, from);
+            if (indent == null)
+                indent = /^\s*/.exec(state.doc.lineAt(from).text)[0].length;
+            while (to < line.to && /\s/.test(line.text[to - line.from]))
+                to++;
+            if (explode)
+                ({ from, to } = explode);
+            else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from)))
+                from = line.from;
+            let insert = ["", indentString(state, indent)];
+            if (explode)
+                insert.push(indentString(state, cx.lineIndent(line.from, -1)));
+            return { changes: { from, to, insert: Text.of(insert) },
+                range: EditorSelection.cursor(from + 1 + insert[1].length) };
+        });
+        dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
+        return true;
+    };
+}
+function changeBySelectedLine(state, f) {
+    let atLine = -1;
+    return state.changeByRange(range => {
+        let changes = [];
+        for (let pos = range.from; pos <= range.to;) {
+            let line = state.doc.lineAt(pos);
+            if (line.number > atLine && (range.empty || range.to > line.from)) {
+                f(line, changes, range);
+                atLine = line.number;
+            }
+            pos = line.to + 1;
+        }
+        let changeSet = state.changes(changes);
+        return { changes,
+            range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) };
+    });
+}
+/**
+Auto-indent the selected lines. This uses the [indentation service
+facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
+information.
+*/
+const indentSelection = ({ state, dispatch }) => {
+    if (state.readOnly)
+        return false;
+    let updated = Object.create(null);
+    let context = new IndentContext(state, { overrideIndentation: start => {
+            let found = updated[start];
+            return found == null ? -1 : found;
+        } });
+    let changes = changeBySelectedLine(state, (line, changes, range) => {
+        let indent = getIndentation(context, line.from);
+        if (indent == null)
+            return;
+        if (!/\S/.test(line.text))
+            indent = 0;
+        let cur = /^\s*/.exec(line.text)[0];
+        let norm = indentString(state, indent);
+        if (cur != norm || range.from < line.from + cur.length) {
+            updated[line.from] = indent;
+            changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
+        }
+    });
+    if (!changes.changes.empty)
+        dispatch(state.update(changes, { userEvent: "indent" }));
+    return true;
+};
+/**
+Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
+lines.
+*/
+const indentMore = ({ state, dispatch }) => {
+    if (state.readOnly)
+        return false;
+    dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
+        changes.push({ from: line.from, insert: state.facet(indentUnit) });
+    }), { userEvent: "input.indent" }));
+    return true;
+};
+/**
+Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
+selected lines.
+*/
+const indentLess = ({ state, dispatch }) => {
+    if (state.readOnly)
+        return false;
+    dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
+        let space = /^\s*/.exec(line.text)[0];
+        if (!space)
+            return;
+        let col = countColumn(space, state.tabSize), keep = 0;
+        let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));
+        while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep))
+            keep++;
+        changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) });
+    }), { userEvent: "delete.dedent" }));
+    return true;
+};
+/**
+Array of key bindings containing the Emacs-style bindings that are
+available on macOS by default.
+
+ - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
+ - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
+ - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
+ - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
+ - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
+ - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
+ - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
+ - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
+ - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
+ - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
+ - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
+ - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
+ - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
+ - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
+*/
+const emacsStyleKeymap = [
+    { key: "Ctrl-b", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
+    { key: "Ctrl-f", run: cursorCharRight, shift: selectCharRight },
+    { key: "Ctrl-p", run: cursorLineUp, shift: selectLineUp },
+    { key: "Ctrl-n", run: cursorLineDown, shift: selectLineDown },
+    { key: "Ctrl-a", run: cursorLineStart, shift: selectLineStart },
+    { key: "Ctrl-e", run: cursorLineEnd, shift: selectLineEnd },
+    { key: "Ctrl-d", run: deleteCharForward },
+    { key: "Ctrl-h", run: deleteCharBackward },
+    { key: "Ctrl-k", run: deleteToLineEnd },
+    { key: "Ctrl-Alt-h", run: deleteGroupBackward },
+    { key: "Ctrl-o", run: splitLine },
+    { key: "Ctrl-t", run: transposeChars },
+    { key: "Ctrl-v", run: cursorPageDown },
+];
+/**
+An array of key bindings closely sticking to platform-standard or
+widely used bindings. (This includes the bindings from
+[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
+property changed to `mac`.)
+
+ - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
+ - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
+ - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
+ - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
+ - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
+ - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
+ - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
+ - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
+ - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
+ - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
+ - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
+ - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
+ - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
+ - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
+ - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
+ - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
+ - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
+ - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
+ - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
+ - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
+ - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
+ - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
+ - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
+ - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
+ - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
+ - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
+*/
+const standardKeymap = /*@__PURE__*/[
+    { key: "ArrowLeft", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
+    { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft },
+    { mac: "Cmd-ArrowLeft", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward },
+    { key: "ArrowRight", run: cursorCharRight, shift: selectCharRight, preventDefault: true },
+    { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight },
+    { mac: "Cmd-ArrowRight", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward },
+    { key: "ArrowUp", run: cursorLineUp, shift: selectLineUp, preventDefault: true },
+    { mac: "Cmd-ArrowUp", run: cursorDocStart, shift: selectDocStart },
+    { mac: "Ctrl-ArrowUp", run: cursorPageUp, shift: selectPageUp },
+    { key: "ArrowDown", run: cursorLineDown, shift: selectLineDown, preventDefault: true },
+    { mac: "Cmd-ArrowDown", run: cursorDocEnd, shift: selectDocEnd },
+    { mac: "Ctrl-ArrowDown", run: cursorPageDown, shift: selectPageDown },
+    { key: "PageUp", run: cursorPageUp, shift: selectPageUp },
+    { key: "PageDown", run: cursorPageDown, shift: selectPageDown },
+    { key: "Home", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true },
+    { key: "Mod-Home", run: cursorDocStart, shift: selectDocStart },
+    { key: "End", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true },
+    { key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd },
+    { key: "Enter", run: insertNewlineAndIndent },
+    { key: "Mod-a", run: selectAll },
+    { key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward },
+    { key: "Delete", run: deleteCharForward },
+    { key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward },
+    { key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward },
+    { mac: "Mod-Backspace", run: deleteToLineStart },
+    { mac: "Mod-Delete", run: deleteToLineEnd }
+].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));
+/**
+The default keymap. Includes all bindings from
+[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
+
+- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
+- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
+- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
+- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
+- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
+- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
+- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
+- Ctrl-Enter (Comd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
+- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
+- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
+- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
+- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
+- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
+- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
+- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
+- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
+- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
+*/
+const defaultKeymap = /*@__PURE__*/[
+    { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: cursorSyntaxLeft, shift: selectSyntaxLeft },
+    { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: cursorSyntaxRight, shift: selectSyntaxRight },
+    { key: "Alt-ArrowUp", run: moveLineUp },
+    { key: "Shift-Alt-ArrowUp", run: copyLineUp },
+    { key: "Alt-ArrowDown", run: moveLineDown },
+    { key: "Shift-Alt-ArrowDown", run: copyLineDown },
+    { key: "Escape", run: simplifySelection },
+    { key: "Mod-Enter", run: insertBlankLine },
+    { key: "Alt-l", mac: "Ctrl-l", run: selectLine },
+    { key: "Mod-i", run: selectParentSyntax, preventDefault: true },
+    { key: "Mod-[", run: indentLess },
+    { key: "Mod-]", run: indentMore },
+    { key: "Mod-Alt-\\", run: indentSelection },
+    { key: "Shift-Mod-k", run: deleteLine },
+    { key: "Shift-Mod-\\", run: cursorMatchingBracket },
+    { key: "Mod-/", run: toggleComment },
+    { key: "Alt-A", run: toggleBlockComment }
+].concat(standardKeymap);
+
+function crelt() {
+  var elt = arguments[0];
+  if (typeof elt == "string") elt = document.createElement(elt);
+  var i = 1, next = arguments[1];
+  if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
+    for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
+      var value = next[name];
+      if (typeof value == "string") elt.setAttribute(name, value);
+      else if (value != null) elt[name] = value;
+    }
+    i++;
+  }
+  for (; i < arguments.length; i++) add(elt, arguments[i]);
+  return elt
+}
+
+function add(elt, child) {
+  if (typeof child == "string") {
+    elt.appendChild(document.createTextNode(child));
+  } else if (child == null) ; else if (child.nodeType != null) {
+    elt.appendChild(child);
+  } else if (Array.isArray(child)) {
+    for (var i = 0; i < child.length; i++) add(elt, child[i]);
+  } else {
+    throw new RangeError("Unsupported child node: " + child)
+  }
+}
+
+const basicNormalize = typeof String.prototype.normalize == "function"
+    ? x => x.normalize("NFKD") : x => x;
+/**
+A search cursor provides an iterator over text matches in a
+document.
+*/
+class SearchCursor {
+    /**
+    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(text, query, from = 0, to = text.length, normalize) {
+        /**
+        The current match (only holds a meaningful value after
+        [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
+        `done` is false).
+        */
+        this.value = { from: 0, to: 0 };
+        /**
+        Whether the end of the iterated region has been reached.
+        */
+        this.done = false;
+        this.matches = [];
+        this.buffer = "";
+        this.bufferPos = 0;
+        this.iter = text.iterRange(from, to);
+        this.bufferStart = from;
+        this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;
+        this.query = this.normalize(query);
+    }
+    peek() {
+        if (this.bufferPos == this.buffer.length) {
+            this.bufferStart += this.buffer.length;
+            this.iter.next();
+            if (this.iter.done)
+                return -1;
+            this.bufferPos = 0;
+            this.buffer = this.iter.value;
+        }
+        return codePointAt(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() {
+        while (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 next = this.peek();
+            if (next < 0) {
+                this.done = true;
+                return this;
+            }
+            let str = fromCodePoint(next), start = this.bufferStart + this.bufferPos;
+            this.bufferPos += codePointSize(next);
+            let norm = this.normalize(str);
+            for (let i = 0, pos = start;; i++) {
+                let code = norm.charCodeAt(i);
+                let match = this.match(code, pos);
+                if (match) {
+                    this.value = match;
+                    return this;
+                }
+                if (i == norm.length - 1)
+                    break;
+                if (pos == start && i < str.length && str.charCodeAt(i) == code)
+                    pos++;
+            }
+        }
+    }
+    match(code, pos) {
+        let match = null;
+        for (let i = 0; i < this.matches.length; i += 2) {
+            let index = this.matches[i], keep = false;
+            if (this.query.charCodeAt(index) == code) {
+                if (index == this.query.length - 1) {
+                    match = { from: this.matches[i + 1], to: pos + 1 };
+                }
+                else {
+                    this.matches[i]++;
+                    keep = true;
+                }
+            }
+            if (!keep) {
+                this.matches.splice(i, 2);
+                i -= 2;
+            }
+        }
+        if (this.query.charCodeAt(0) == code) {
+            if (this.query.length == 1)
+                match = { from: pos, to: pos + 1 };
+            else
+                this.matches.push(1, pos);
+        }
+        return match;
+    }
+}
+if (typeof Symbol != "undefined")
+    SearchCursor.prototype[Symbol.iterator] = function () { return this; };
+
+const empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec("") };
+const baseFlags = "gm" + (/x/.unicode == null ? "" : "u");
+/**
+This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
+but searches for a regular expression pattern instead of a plain
+string.
+*/
+class RegExpCursor {
+    /**
+    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(text, query, options, from = 0, to = text.length) {
+        this.to = to;
+        this.curLine = "";
+        /**
+        Set to `true` when the cursor has reached the end of the search
+        range.
+        */
+        this.done = false;
+        /**
+        Will contain an object with the extent of the match and the
+        match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
+        sucessfully finds a match.
+        */
+        this.value = empty;
+        if (/\\[sWDnr]|\n|\r|\[\^/.test(query))
+            return new MultilineRegExpCursor(text, query, options, from, to);
+        this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
+        this.iter = text.iter();
+        let startLine = text.lineAt(from);
+        this.curLineStart = startLine.from;
+        this.matchPos = from;
+        this.getLine(this.curLineStart);
+    }
+    getLine(skip) {
+        this.iter.next(skip);
+        if (this.iter.lineBreak) {
+            this.curLine = "";
+        }
+        else {
+            this.curLine = this.iter.value;
+            if (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;
+        if (this.curLineStart > this.to)
+            this.curLine = "";
+        else
+            this.getLine(0);
+    }
+    /**
+    Move to the next match, if there is one.
+    */
+    next() {
+        for (let off = this.matchPos - this.curLineStart;;) {
+            this.re.lastIndex = off;
+            let match = this.matchPos <= this.to && this.re.exec(this.curLine);
+            if (match) {
+                let from = this.curLineStart + match.index, to = from + match[0].length;
+                this.matchPos = to + (from == to ? 1 : 0);
+                if (from == this.curLine.length)
+                    this.nextLine();
+                if (from < to || from > this.value.to) {
+                    this.value = { from, to, match };
+                    return this;
+                }
+                off = this.matchPos - this.curLineStart;
+            }
+            else if (this.curLineStart + this.curLine.length < this.to) {
+                this.nextLine();
+                off = 0;
+            }
+            else {
+                this.done = true;
+                return this;
+            }
+        }
+    }
+}
+const flattened = /*@__PURE__*/new WeakMap();
+// Reusable (partially) flattened document strings
+class FlattenedDoc {
+    constructor(from, text) {
+        this.from = from;
+        this.text = text;
+    }
+    get to() { return this.from + this.text.length; }
+    static get(doc, from, to) {
+        let cached = flattened.get(doc);
+        if (!cached || cached.from >= to || cached.to <= from) {
+            let flat = new FlattenedDoc(from, doc.sliceString(from, to));
+            flattened.set(doc, flat);
+            return flat;
+        }
+        if (cached.from == from && cached.to == to)
+            return cached;
+        let { text, from: cachedFrom } = cached;
+        if (cachedFrom > from) {
+            text = doc.sliceString(from, cachedFrom) + text;
+            cachedFrom = from;
+        }
+        if (cached.to < to)
+            text += doc.sliceString(cached.to, to);
+        flattened.set(doc, new FlattenedDoc(cachedFrom, text));
+        return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));
+    }
+}
+class MultilineRegExpCursor {
+    constructor(text, query, options, from, to) {
+        this.text = text;
+        this.to = to;
+        this.done = false;
+        this.value = empty;
+        this.matchPos = from;
+        this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
+        this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Base */));
+    }
+    chunkEnd(pos) {
+        return pos >= this.to ? this.to : this.text.lineAt(pos).to;
+    }
+    next() {
+        for (;;) {
+            let off = this.re.lastIndex = this.matchPos - this.flat.from;
+            let match = this.re.exec(this.flat.text);
+            // Skip empty matches directly after the last match
+            if (match && !match[0] && match.index == off) {
+                this.re.lastIndex = off + 1;
+                match = this.re.exec(this.flat.text);
+            }
+            // If a match goes almost to the end of a noncomplete chunk, try
+            // again, since it'll likely be able to match more
+            if (match && this.flat.to < this.to && match.index + match[0].length > this.flat.text.length - 10)
+                match = null;
+            if (match) {
+                let from = this.flat.from + match.index, to = from + match[0].length;
+                this.value = { from, to, match };
+                this.matchPos = to + (from == to ? 1 : 0);
+                return this;
+            }
+            else {
+                if (this.flat.to == this.to) {
+                    this.done = true;
+                    return this;
+                }
+                // Grow the flattened doc
+                this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
+            }
+        }
+    }
+}
+if (typeof Symbol != "undefined") {
+    RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] =
+        function () { return this; };
+}
+function validRegExp(source) {
+    try {
+        new RegExp(source, baseFlags);
+        return true;
+    }
+    catch (_a) {
+        return false;
+    }
+}
+
+function createLineDialog(view) {
+    let input = crelt("input", { class: "cm-textfield", name: "line" });
+    let dom = crelt("form", {
+        class: "cm-gotoLine",
+        onkeydown: (event) => {
+            if (event.keyCode == 27) { // Escape
+                event.preventDefault();
+                view.dispatch({ effects: dialogEffect.of(false) });
+                view.focus();
+            }
+            else if (event.keyCode == 13) { // Enter
+                event.preventDefault();
+                go();
+            }
+        },
+        onsubmit: (event) => {
+            event.preventDefault();
+            go();
+        }
+    }, crelt("label", view.state.phrase("Go to line"), ": ", input), " ", crelt("button", { class: "cm-button", type: "submit" }, view.state.phrase("go")));
+    function go() {
+        let match = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);
+        if (!match)
+            return;
+        let { state } = view, startLine = state.doc.lineAt(state.selection.main.head);
+        let [, sign, ln, cl, percent] = match;
+        let col = cl ? +cl.slice(1) : 0;
+        let line = ln ? +ln : startLine.number;
+        if (ln && percent) {
+            let pc = line / 100;
+            if (sign)
+                pc = pc * (sign == "-" ? -1 : 1) + (startLine.number / state.doc.lines);
+            line = Math.round(state.doc.lines * pc);
+        }
+        else if (ln && sign) {
+            line = line * (sign == "-" ? -1 : 1) + startLine.number;
+        }
+        let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));
+        view.dispatch({
+            effects: dialogEffect.of(false),
+            selection: EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length))),
+            scrollIntoView: true
+        });
+        view.focus();
+    }
+    return { dom };
+}
+const dialogEffect = /*@__PURE__*/StateEffect.define();
+const dialogField = /*@__PURE__*/StateField.define({
+    create() { return true; },
+    update(value, tr) {
+        for (let e of tr.effects)
+            if (e.is(dialogEffect))
+                value = e.value;
+        return value;
+    },
+    provide: f => showPanel.from(f, val => val ? createLineDialog : null)
+});
+/**
+Command that shows a dialog asking the user for a line number, and
+when a valid position is provided, moves the cursor to that line.
+
+Supports line numbers, relative line offsets prefixed with `+` or
+`-`, document percentages suffixed with `%`, and an optional
+column position by adding `:` and a second number after the line
+number.
+
+The dialog can be styled with the `panel.gotoLine` theme
+selector.
+*/
+const gotoLine = view => {
+    let panel = getPanel(view, createLineDialog);
+    if (!panel) {
+        let effects = [dialogEffect.of(true)];
+        if (view.state.field(dialogField, false) == null)
+            effects.push(StateEffect.appendConfig.of([dialogField, baseTheme$1$1]));
+        view.dispatch({ effects });
+        panel = getPanel(view, createLineDialog);
+    }
+    if (panel)
+        panel.dom.querySelector("input").focus();
+    return true;
+};
+const baseTheme$1$1 = /*@__PURE__*/EditorView.baseTheme({
+    ".cm-panel.cm-gotoLine": {
+        padding: "2px 6px 4px",
+        "& label": { fontSize: "80%" }
+    }
+});
+
+const defaultHighlightOptions = {
+    highlightWordAroundCursor: false,
+    minSelectionLength: 1,
+    maxMatches: 100,
+    wholeWords: false
+};
+const highlightConfig = /*@__PURE__*/Facet.define({
+    combine(options) {
+        return combineConfig(options, defaultHighlightOptions, {
+            highlightWordAroundCursor: (a, b) => a || b,
+            minSelectionLength: Math.min,
+            maxMatches: Math.min
+        });
+    }
+});
+/**
+This extension highlights text that matches the selection. It uses
+the `"cm-selectionMatch"` class for the highlighting. When
+`highlightWordAroundCursor` is enabled, the word at the cursor
+itself will be highlighted with `"cm-selectionMatch-main"`.
+*/
+function highlightSelectionMatches(options) {
+    let ext = [defaultTheme, matchHighlighter];
+    return ext;
+}
+const matchDeco = /*@__PURE__*/Decoration.mark({ class: "cm-selectionMatch" });
+const mainMatchDeco = /*@__PURE__*/Decoration.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
+// Whether the characters directly outside the given positions are non-word characters
+function insideWordBoundaries(check, state, from, to) {
+    return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory.Word) &&
+        (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory.Word);
+}
+// Whether the characters directly at the given positions are word characters
+function insideWord(check, state, from, to) {
+    return check(state.sliceDoc(from, from + 1)) == CharCategory.Word
+        && check(state.sliceDoc(to - 1, to)) == CharCategory.Word;
+}
+const matchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.decorations = this.getDeco(view);
+    }
+    update(update) {
+        if (update.selectionSet || update.docChanged || update.viewportChanged)
+            this.decorations = this.getDeco(update.view);
+    }
+    getDeco(view) {
+        let conf = view.state.facet(highlightConfig);
+        let { state } = view, sel = state.selection;
+        if (sel.ranges.length > 1)
+            return Decoration.none;
+        let range = sel.main, query, check = null;
+        if (range.empty) {
+            if (!conf.highlightWordAroundCursor)
+                return Decoration.none;
+            let word = state.wordAt(range.head);
+            if (!word)
+                return Decoration.none;
+            check = state.charCategorizer(range.head);
+            query = state.sliceDoc(word.from, word.to);
+        }
+        else {
+            let len = range.to - range.from;
+            if (len < conf.minSelectionLength || len > 200)
+                return Decoration.none;
+            if (conf.wholeWords) {
+                query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?
+                check = state.charCategorizer(range.head);
+                if (!(insideWordBoundaries(check, state, range.from, range.to)
+                    && insideWord(check, state, range.from, range.to)))
+                    return Decoration.none;
+            }
+            else {
+                query = state.sliceDoc(range.from, range.to).trim();
+                if (!query)
+                    return Decoration.none;
+            }
+        }
+        let deco = [];
+        for (let part of view.visibleRanges) {
+            let cursor = new SearchCursor(state.doc, query, part.from, part.to);
+            while (!cursor.next().done) {
+                let { from, to } = cursor.value;
+                if (!check || insideWordBoundaries(check, state, from, to)) {
+                    if (range.empty && from <= range.from && to >= range.to)
+                        deco.push(mainMatchDeco.range(from, to));
+                    else if (from >= range.to || to <= range.from)
+                        deco.push(matchDeco.range(from, to));
+                    if (deco.length > conf.maxMatches)
+                        return Decoration.none;
+                }
+            }
+        }
+        return Decoration.set(deco);
+    }
+}, {
+    decorations: v => v.decorations
+});
+const defaultTheme = /*@__PURE__*/EditorView.baseTheme({
+    ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
+    ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
+});
+// Select the words around the cursors.
+const selectWord = ({ state, dispatch }) => {
+    let { selection } = state;
+    let newSel = EditorSelection.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection.cursor(range.head)), selection.mainIndex);
+    if (newSel.eq(selection))
+        return false;
+    dispatch(state.update({ selection: newSel }));
+    return true;
+};
+// Find next occurrence of query relative to last cursor. Wrap around
+// the document if there are no more matches.
+function findNextOccurrence(state, query) {
+    let { main, ranges } = state.selection;
+    let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;
+    for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {
+        cursor.next();
+        if (cursor.done) {
+            if (cycled)
+                return null;
+            cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
+            cycled = true;
+        }
+        else {
+            if (cycled && ranges.some(r => r.from == cursor.value.from))
+                continue;
+            if (fullWord) {
+                let word = state.wordAt(cursor.value.from);
+                if (!word || word.from != cursor.value.from || word.to != cursor.value.to)
+                    continue;
+            }
+            return cursor.value;
+        }
+    }
+}
+/**
+Select next occurrence of the current selection. Expand selection
+to the surrounding word when the selection is empty.
+*/
+const selectNextOccurrence = ({ state, dispatch }) => {
+    let { ranges } = state.selection;
+    if (ranges.some(sel => sel.from === sel.to))
+        return selectWord({ state, dispatch });
+    let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);
+    if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText))
+        return false;
+    let range = findNextOccurrence(state, searchedText);
+    if (!range)
+        return false;
+    dispatch(state.update({
+        selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),
+        effects: EditorView.scrollIntoView(range.to)
+    }));
+    return true;
+};
+
+const searchConfigFacet = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        var _a;
+        return {
+            top: configs.reduce((val, conf) => val !== null && val !== void 0 ? val : conf.top, undefined) || false,
+            caseSensitive: configs.reduce((val, conf) => val !== null && val !== void 0 ? val : conf.caseSensitive, undefined) || false,
+            createPanel: ((_a = configs.find(c => c.createPanel)) === null || _a === void 0 ? void 0 : _a.createPanel) || (view => new SearchPanel(view))
+        };
+    }
+});
+/**
+A search query. Part of the editor's search state.
+*/
+class SearchQuery {
+    /**
+    Create a query object.
+    */
+    constructor(config) {
+        this.search = config.search;
+        this.caseSensitive = !!config.caseSensitive;
+        this.regexp = !!config.regexp;
+        this.replace = config.replace || "";
+        this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
+        this.unquoted = config.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
+    }
+    /**
+    Compare this query to another query.
+    */
+    eq(other) {
+        return this.search == other.search && this.replace == other.replace &&
+            this.caseSensitive == other.caseSensitive && this.regexp == other.regexp;
+    }
+    /**
+    @internal
+    */
+    create() {
+        return this.regexp ? new RegExpQuery(this) : new StringQuery(this);
+    }
+    /**
+    Get a search cursor for this query, searching through the given
+    range in the given document.
+    */
+    getCursor(doc, from = 0, to = doc.length) {
+        return this.regexp ? regexpCursor(this, doc, from, to) : stringCursor(this, doc, from, to);
+    }
+}
+class QueryType {
+    constructor(spec) {
+        this.spec = spec;
+    }
+}
+function stringCursor(spec, doc, from, to) {
+    return new SearchCursor(doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase());
+}
+class StringQuery extends QueryType {
+    constructor(spec) {
+        super(spec);
+    }
+    nextMatch(doc, curFrom, curTo) {
+        let cursor = stringCursor(this.spec, doc, curTo, doc.length).nextOverlapping();
+        if (cursor.done)
+            cursor = stringCursor(this.spec, doc, 0, curFrom).nextOverlapping();
+        return cursor.done ? null : cursor.value;
+    }
+    // Searching in reverse is, rather than implementing inverted search
+    // cursor, done by scanning chunk after chunk forward.
+    prevMatchInRange(doc, from, to) {
+        for (let pos = to;;) {
+            let start = Math.max(from, pos - 10000 /* ChunkSize */ - this.spec.unquoted.length);
+            let cursor = stringCursor(this.spec, doc, start, pos), range = null;
+            while (!cursor.nextOverlapping().done)
+                range = cursor.value;
+            if (range)
+                return range;
+            if (start == from)
+                return null;
+            pos -= 10000 /* ChunkSize */;
+        }
+    }
+    prevMatch(doc, curFrom, curTo) {
+        return this.prevMatchInRange(doc, 0, curFrom) ||
+            this.prevMatchInRange(doc, curTo, doc.length);
+    }
+    getReplacement(_result) { return this.spec.replace; }
+    matchAll(doc, limit) {
+        let cursor = stringCursor(this.spec, doc, 0, doc.length), ranges = [];
+        while (!cursor.next().done) {
+            if (ranges.length >= limit)
+                return null;
+            ranges.push(cursor.value);
+        }
+        return ranges;
+    }
+    highlight(doc, from, to, add) {
+        let cursor = stringCursor(this.spec, doc, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, doc.length));
+        while (!cursor.next().done)
+            add(cursor.value.from, cursor.value.to);
+    }
+}
+function regexpCursor(spec, doc, from, to) {
+    return new RegExpCursor(doc, spec.search, spec.caseSensitive ? undefined : { ignoreCase: true }, from, to);
+}
+class RegExpQuery extends QueryType {
+    nextMatch(doc, curFrom, curTo) {
+        let cursor = regexpCursor(this.spec, doc, curTo, doc.length).next();
+        if (cursor.done)
+            cursor = regexpCursor(this.spec, doc, 0, curFrom).next();
+        return cursor.done ? null : cursor.value;
+    }
+    prevMatchInRange(doc, from, to) {
+        for (let size = 1;; size++) {
+            let start = Math.max(from, to - size * 10000 /* ChunkSize */);
+            let cursor = regexpCursor(this.spec, doc, start, to), range = null;
+            while (!cursor.next().done)
+                range = cursor.value;
+            if (range && (start == from || range.from > start + 10))
+                return range;
+            if (start == from)
+                return null;
+        }
+    }
+    prevMatch(doc, curFrom, curTo) {
+        return this.prevMatchInRange(doc, 0, curFrom) ||
+            this.prevMatchInRange(doc, curTo, doc.length);
+    }
+    getReplacement(result) {
+        return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
+            : i == "&" ? result.match[0]
+                : i != "0" && +i < result.match.length ? result.match[i]
+                    : m);
+    }
+    matchAll(doc, limit) {
+        let cursor = regexpCursor(this.spec, doc, 0, doc.length), ranges = [];
+        while (!cursor.next().done) {
+            if (ranges.length >= limit)
+                return null;
+            ranges.push(cursor.value);
+        }
+        return ranges;
+    }
+    highlight(doc, from, to, add) {
+        let cursor = regexpCursor(this.spec, doc, Math.max(0, from - 250 /* HighlightMargin */), Math.min(to + 250 /* HighlightMargin */, doc.length));
+        while (!cursor.next().done)
+            add(cursor.value.from, cursor.value.to);
+    }
+}
+/**
+A state effect that updates the current search query. Note that
+this only has an effect if the search state has been initialized
+(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
+by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
+once).
+*/
+const setSearchQuery = /*@__PURE__*/StateEffect.define();
+const togglePanel$1 = /*@__PURE__*/StateEffect.define();
+const searchState = /*@__PURE__*/StateField.define({
+    create(state) {
+        return new SearchState(defaultQuery(state).create(), null);
+    },
+    update(value, tr) {
+        for (let effect of tr.effects) {
+            if (effect.is(setSearchQuery))
+                value = new SearchState(effect.value.create(), value.panel);
+            else if (effect.is(togglePanel$1))
+                value = new SearchState(value.query, effect.value ? createSearchPanel : null);
+        }
+        return value;
+    },
+    provide: f => showPanel.from(f, val => val.panel)
+});
+class SearchState {
+    constructor(query, panel) {
+        this.query = query;
+        this.panel = panel;
+    }
+}
+const matchMark = /*@__PURE__*/Decoration.mark({ class: "cm-searchMatch" }), selectedMatchMark = /*@__PURE__*/Decoration.mark({ class: "cm-searchMatch cm-searchMatch-selected" });
+const searchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.view = view;
+        this.decorations = this.highlight(view.state.field(searchState));
+    }
+    update(update) {
+        let state = update.state.field(searchState);
+        if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged)
+            this.decorations = this.highlight(state);
+    }
+    highlight({ query, panel }) {
+        if (!panel || !query.spec.valid)
+            return Decoration.none;
+        let { view } = this;
+        let builder = new RangeSetBuilder();
+        for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {
+            let { from, to } = ranges[i];
+            while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* HighlightMargin */)
+                to = ranges[++i].to;
+            query.highlight(view.state.doc, from, to, (from, to) => {
+                let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);
+                builder.add(from, to, selected ? selectedMatchMark : matchMark);
+            });
+        }
+        return builder.finish();
+    }
+}, {
+    decorations: v => v.decorations
+});
+function searchCommand(f) {
+    return view => {
+        let state = view.state.field(searchState, false);
+        return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);
+    };
+}
+/**
+Open the search panel if it isn't already open, and move the
+selection to the first match after the current main selection.
+Will wrap around to the start of the document when it reaches the
+end.
+*/
+const findNext = /*@__PURE__*/searchCommand((view, { query }) => {
+    let { from, to } = view.state.selection.main;
+    let next = query.nextMatch(view.state.doc, from, to);
+    if (!next || next.from == from && next.to == to)
+        return false;
+    view.dispatch({
+        selection: { anchor: next.from, head: next.to },
+        scrollIntoView: true,
+        effects: announceMatch(view, next),
+        userEvent: "select.search"
+    });
+    return true;
+});
+/**
+Move the selection to the previous instance of the search query,
+before the current main selection. Will wrap past the start
+of the document to start searching at the end again.
+*/
+const findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {
+    let { state } = view, { from, to } = state.selection.main;
+    let range = query.prevMatch(state.doc, from, to);
+    if (!range)
+        return false;
+    view.dispatch({
+        selection: { anchor: range.from, head: range.to },
+        scrollIntoView: true,
+        effects: announceMatch(view, range),
+        userEvent: "select.search"
+    });
+    return true;
+});
+/**
+Select all instances of the search query.
+*/
+const selectMatches = /*@__PURE__*/searchCommand((view, { query }) => {
+    let ranges = query.matchAll(view.state.doc, 1000);
+    if (!ranges || !ranges.length)
+        return false;
+    view.dispatch({
+        selection: EditorSelection.create(ranges.map(r => EditorSelection.range(r.from, r.to))),
+        userEvent: "select.search.matches"
+    });
+    return true;
+});
+/**
+Select all instances of the currently selected text.
+*/
+const selectSelectionMatches = ({ state, dispatch }) => {
+    let sel = state.selection;
+    if (sel.ranges.length > 1 || sel.main.empty)
+        return false;
+    let { from, to } = sel.main;
+    let ranges = [], main = 0;
+    for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {
+        if (ranges.length > 1000)
+            return false;
+        if (cur.value.from == from)
+            main = ranges.length;
+        ranges.push(EditorSelection.range(cur.value.from, cur.value.to));
+    }
+    dispatch(state.update({
+        selection: EditorSelection.create(ranges, main),
+        userEvent: "select.search.matches"
+    }));
+    return true;
+};
+/**
+Replace the current match of the search query.
+*/
+const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
+    let { state } = view, { from, to } = state.selection.main;
+    if (state.readOnly)
+        return false;
+    let next = query.nextMatch(state.doc, from, from);
+    if (!next)
+        return false;
+    let changes = [], selection, replacement;
+    if (next.from == from && next.to == to) {
+        replacement = state.toText(query.getReplacement(next));
+        changes.push({ from: next.from, to: next.to, insert: replacement });
+        next = query.nextMatch(state.doc, next.from, next.to);
+    }
+    if (next) {
+        let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;
+        selection = { anchor: next.from - off, head: next.to - off };
+    }
+    view.dispatch({
+        changes, selection,
+        scrollIntoView: !!selection,
+        effects: next ? announceMatch(view, next) : undefined,
+        userEvent: "input.replace"
+    });
+    return true;
+});
+/**
+Replace all instances of the search query with the given
+replacement.
+*/
+const replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {
+    if (view.state.readOnly)
+        return false;
+    let changes = query.matchAll(view.state.doc, 1e9).map(match => {
+        let { from, to } = match;
+        return { from, to, insert: query.getReplacement(match) };
+    });
+    if (!changes.length)
+        return false;
+    view.dispatch({
+        changes,
+        userEvent: "input.replace.all"
+    });
+    return true;
+});
+function createSearchPanel(view) {
+    return view.state.facet(searchConfigFacet).createPanel(view);
+}
+function defaultQuery(state, fallback) {
+    var _a;
+    let sel = state.selection.main;
+    let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to);
+    let caseSensitive = (_a = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _a !== void 0 ? _a : state.facet(searchConfigFacet).caseSensitive;
+    return fallback && !selText ? fallback : new SearchQuery({ search: selText.replace(/\n/g, "\\n"), caseSensitive });
+}
+/**
+Make sure the search panel is open and focused.
+*/
+const openSearchPanel = view => {
+    let state = view.state.field(searchState, false);
+    if (state && state.panel) {
+        let panel = getPanel(view, createSearchPanel);
+        if (!panel)
+            return false;
+        let searchInput = panel.dom.querySelector("[name=search]");
+        if (searchInput != view.root.activeElement) {
+            let query = defaultQuery(view.state, state.query.spec);
+            if (query.valid)
+                view.dispatch({ effects: setSearchQuery.of(query) });
+            searchInput.focus();
+            searchInput.select();
+        }
+    }
+    else {
+        view.dispatch({ effects: [
+                togglePanel$1.of(true),
+                state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect.appendConfig.of(searchExtensions)
+            ] });
+    }
+    return true;
+};
+/**
+Close the search panel.
+*/
+const closeSearchPanel = view => {
+    let state = view.state.field(searchState, false);
+    if (!state || !state.panel)
+        return false;
+    let panel = getPanel(view, createSearchPanel);
+    if (panel && panel.dom.contains(view.root.activeElement))
+        view.focus();
+    view.dispatch({ effects: togglePanel$1.of(false) });
+    return true;
+};
+/**
+Default search-related key bindings.
+
+ - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
+ - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
+ - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
+ - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
+ - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
+*/
+const searchKeymap = [
+    { key: "Mod-f", run: openSearchPanel, scope: "editor search-panel" },
+    { key: "F3", run: findNext, shift: findPrevious, scope: "editor search-panel", preventDefault: true },
+    { key: "Mod-g", run: findNext, shift: findPrevious, scope: "editor search-panel", preventDefault: true },
+    { key: "Escape", run: closeSearchPanel, scope: "editor search-panel" },
+    { key: "Mod-Shift-l", run: selectSelectionMatches },
+    { key: "Alt-g", run: gotoLine },
+    { key: "Mod-d", run: selectNextOccurrence, preventDefault: true },
+];
+class SearchPanel {
+    constructor(view) {
+        this.view = view;
+        let query = this.query = view.state.field(searchState).query.spec;
+        this.commit = this.commit.bind(this);
+        this.searchField = crelt("input", {
+            value: query.search,
+            placeholder: phrase(view, "Find"),
+            "aria-label": phrase(view, "Find"),
+            class: "cm-textfield",
+            name: "search",
+            onchange: this.commit,
+            onkeyup: this.commit
+        });
+        this.replaceField = crelt("input", {
+            value: query.replace,
+            placeholder: phrase(view, "Replace"),
+            "aria-label": phrase(view, "Replace"),
+            class: "cm-textfield",
+            name: "replace",
+            onchange: this.commit,
+            onkeyup: this.commit
+        });
+        this.caseField = crelt("input", {
+            type: "checkbox",
+            name: "case",
+            checked: query.caseSensitive,
+            onchange: this.commit
+        });
+        this.reField = crelt("input", {
+            type: "checkbox",
+            name: "re",
+            checked: query.regexp,
+            onchange: this.commit
+        });
+        function button(name, onclick, content) {
+            return crelt("button", { class: "cm-button", name, onclick, type: "button" }, content);
+        }
+        this.dom = crelt("div", { onkeydown: (e) => this.keydown(e), class: "cm-search" }, [
+            this.searchField,
+            button("next", () => findNext(view), [phrase(view, "next")]),
+            button("prev", () => findPrevious(view), [phrase(view, "previous")]),
+            button("select", () => selectMatches(view), [phrase(view, "all")]),
+            crelt("label", null, [this.caseField, phrase(view, "match case")]),
+            crelt("label", null, [this.reField, phrase(view, "regexp")]),
+            ...view.state.readOnly ? [] : [
+                crelt("br"),
+                this.replaceField,
+                button("replace", () => replaceNext(view), [phrase(view, "replace")]),
+                button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")]),
+                crelt("button", {
+                    name: "close",
+                    onclick: () => closeSearchPanel(view),
+                    "aria-label": phrase(view, "close"),
+                    type: "button"
+                }, ["×"])
+            ]
+        ]);
+    }
+    commit() {
+        let query = new SearchQuery({
+            search: this.searchField.value,
+            caseSensitive: this.caseField.checked,
+            regexp: this.reField.checked,
+            replace: this.replaceField.value
+        });
+        if (!query.eq(this.query)) {
+            this.query = query;
+            this.view.dispatch({ effects: setSearchQuery.of(query) });
+        }
+    }
+    keydown(e) {
+        if (runScopeHandlers(this.view, e, "search-panel")) {
+            e.preventDefault();
+        }
+        else if (e.keyCode == 13 && e.target == this.searchField) {
+            e.preventDefault();
+            (e.shiftKey ? findPrevious : findNext)(this.view);
+        }
+        else if (e.keyCode == 13 && e.target == this.replaceField) {
+            e.preventDefault();
+            replaceNext(this.view);
+        }
+    }
+    update(update) {
+        for (let tr of update.transactions)
+            for (let effect of tr.effects) {
+                if (effect.is(setSearchQuery) && !effect.value.eq(this.query))
+                    this.setQuery(effect.value);
+            }
+    }
+    setQuery(query) {
+        this.query = query;
+        this.searchField.value = query.search;
+        this.replaceField.value = query.replace;
+        this.caseField.checked = query.caseSensitive;
+        this.reField.checked = query.regexp;
+    }
+    mount() {
+        this.searchField.select();
+    }
+    get pos() { return 80; }
+    get top() { return this.view.state.facet(searchConfigFacet).top; }
+}
+function phrase(view, phrase) { return view.state.phrase(phrase); }
+const AnnounceMargin = 30;
+const Break = /[\s\.,:;?!]/;
+function announceMatch(view, { from, to }) {
+    let lineStart = view.state.doc.lineAt(from).from, lineEnd = view.state.doc.lineAt(to).to;
+    let start = Math.max(lineStart, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);
+    let text = view.state.sliceDoc(start, end);
+    if (start != lineStart) {
+        for (let i = 0; i < AnnounceMargin; i++)
+            if (!Break.test(text[i + 1]) && Break.test(text[i])) {
+                text = text.slice(i);
+                break;
+            }
+    }
+    if (end != lineEnd) {
+        for (let i = text.length - 1; i > text.length - AnnounceMargin; i--)
+            if (!Break.test(text[i - 1]) && Break.test(text[i])) {
+                text = text.slice(0, i);
+                break;
+            }
+    }
+    return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${view.state.doc.lineAt(from).number}`);
+}
+const baseTheme$2 = /*@__PURE__*/EditorView.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" }
+});
+const searchExtensions = [
+    searchState,
+    /*@__PURE__*/Prec.lowest(searchHighlighter),
+    baseTheme$2
+];
+
+/**
+An instance of this is passed to completion source functions.
+*/
+class CompletionContext {
+    /**
+    Create a new completion context. (Mostly useful for testing
+    completion sources—in the editor, the extension will create
+    these for you.)
+    */
+    constructor(
+    /**
+    The editor state that the completion happens in.
+    */
+    state, 
+    /**
+    The position at which the completion is happening.
+    */
+    pos, 
+    /**
+    Indicates whether completion was activated explicitly, or
+    implicitly by typing. The usual way to respond to this is to
+    only return completions when either there is part of a
+    completable entity before the cursor, or `explicit` is true.
+    */
+    explicit, 
+    /**
+    The editor view. May be undefined if the context was created
+    in a situation where there is no such view available, such as
+    in synchronous updates via
+    [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
+    or when called by test code.
+    */
+    view) {
+        this.state = state;
+        this.pos = pos;
+        this.explicit = explicit;
+        this.view = view;
+        /**
+        @internal
+        */
+        this.abortListeners = [];
+        /**
+        @internal
+        */
+        this.abortOnDocChange = false;
+    }
+    /**
+    Get the extent, content, and (if there is a token) type of the
+    token before `this.pos`.
+    */
+    tokenBefore(types) {
+        let token = syntaxTree(this.state).resolveInner(this.pos, -1);
+        while (token && types.indexOf(token.name) < 0)
+            token = token.parent;
+        return token ? { from: token.from, to: this.pos,
+            text: this.state.sliceDoc(token.from, this.pos),
+            type: token.type } : null;
+    }
+    /**
+    Get the match of the given expression directly before the
+    cursor.
+    */
+    matchBefore(expr) {
+        let line = this.state.doc.lineAt(this.pos);
+        let start = Math.max(line.from, this.pos - 250);
+        let str = line.text.slice(start - line.from, this.pos - line.from);
+        let found = str.search(ensureAnchor(expr, false));
+        return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) };
+    }
+    /**
+    Yields true when the query has been aborted. Can be useful in
+    asynchronous queries to avoid doing work that will be ignored.
+    */
+    get aborted() { return this.abortListeners == null; }
+    /**
+    Allows you to register abort handlers, which will be called when
+    the query is
+    [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
+    
+    By default, running queries will not be aborted for regular
+    typing or backspacing, on the assumption that they are likely to
+    return a result with a
+    [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
+    allows the result to be used after all. Passing `onDocChange:
+    true` will cause this query to be aborted for any document
+    change.
+    */
+    addEventListener(type, listener, options) {
+        if (type == "abort" && this.abortListeners) {
+            this.abortListeners.push(listener);
+            if (options && options.onDocChange)
+                this.abortOnDocChange = true;
+        }
+    }
+}
+function toSet(chars) {
+    let flat = Object.keys(chars).join("");
+    let words = /\w/.test(flat);
+    if (words)
+        flat = flat.replace(/\w/g, "");
+    return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
+}
+function prefixMatch(options) {
+    let first = Object.create(null), rest = Object.create(null);
+    for (let { label } of options) {
+        first[label[0]] = true;
+        for (let i = 1; i < label.length; i++)
+            rest[label[i]] = true;
+    }
+    let source = toSet(first) + toSet(rest) + "*$";
+    return [new RegExp("^" + source), new RegExp(source)];
+}
+/**
+Given a a fixed array of options, return an autocompleter that
+completes them.
+*/
+function completeFromList(list) {
+    let options = list.map(o => typeof o == "string" ? { label: o } : o);
+    let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options);
+    return (context) => {
+        let token = context.matchBefore(match);
+        return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null;
+    };
+}
+/**
+Wrap the given completion source so that it will not fire when the
+cursor is in a syntax node with one of the given names.
+*/
+function ifNotIn(nodes, source) {
+    return (context) => {
+        for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) {
+            if (nodes.indexOf(pos.name) > -1)
+                return null;
+            if (pos.type.isTop)
+                break;
+        }
+        return source(context);
+    };
+}
+class Option {
+    constructor(completion, source, match, score) {
+        this.completion = completion;
+        this.source = source;
+        this.match = match;
+        this.score = score;
+    }
+}
+function cur(state) { return state.selection.main.from; }
+// Make sure the given regexp has a $ at its end and, if `start` is
+// true, a ^ at its start.
+function ensureAnchor(expr, start) {
+    var _a;
+    let { source } = expr;
+    let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$";
+    if (!addStart && !addEnd)
+        return expr;
+    return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : ""));
+}
+/**
+This annotation is added to transactions that are produced by
+picking a completion.
+*/
+const pickedCompletion = /*@__PURE__*/Annotation.define();
+/**
+Helper function that returns a transaction spec which inserts a
+completion's text in the main selection range, and any other
+selection range that has the same text in front of it.
+*/
+function insertCompletionText(state, text, from, to) {
+    let { main } = state.selection, fromOff = from - main.from, toOff = to - main.from;
+    return Object.assign(Object.assign({}, state.changeByRange(range => {
+        if (range != main && from != to &&
+            state.sliceDoc(range.from + fromOff, range.from + toOff) != state.sliceDoc(from, to))
+            return { range };
+        let lines = state.toText(text);
+        return {
+            changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: lines },
+            range: EditorSelection.cursor(range.from + fromOff + lines.length)
+        };
+    })), { scrollIntoView: true, userEvent: "input.complete" });
+}
+const SourceCache = /*@__PURE__*/new WeakMap();
+function asSource(source) {
+    if (!Array.isArray(source))
+        return source;
+    let known = SourceCache.get(source);
+    if (!known)
+        SourceCache.set(source, known = completeFromList(source));
+    return known;
+}
+const startCompletionEffect = /*@__PURE__*/StateEffect.define();
+const closeCompletionEffect = /*@__PURE__*/StateEffect.define();
+
+// A pattern matcher for fuzzy completion matching. Create an instance
+// once for a pattern, and then use that to match any number of
+// completions.
+class FuzzyMatcher {
+    constructor(pattern) {
+        this.pattern = pattern;
+        this.chars = [];
+        this.folded = [];
+        // Buffers reused by calls to `match` to track matched character
+        // positions.
+        this.any = [];
+        this.precise = [];
+        this.byWord = [];
+        this.score = 0;
+        this.matched = [];
+        for (let p = 0; p < pattern.length;) {
+            let char = codePointAt(pattern, p), size = codePointSize(char);
+            this.chars.push(char);
+            let part = pattern.slice(p, p + size), upper = part.toUpperCase();
+            this.folded.push(codePointAt(upper == part ? part.toLowerCase() : upper, 0));
+            p += size;
+        }
+        this.astral = pattern.length != this.chars.length;
+    }
+    ret(score, matched) {
+        this.score = score;
+        this.matched = matched;
+        return this;
+    }
+    // Matches a given word (completion) against the pattern (input).
+    // Will return a boolean indicating whether there was a match and,
+    // on success, set `this.score` to the score, `this.matched` to an
+    // array of `from, to` pairs indicating the matched parts of `word`.
+    //
+    // The score is a number that is more negative the worse the match
+    // is. See `Penalty` above.
+    match(word) {
+        if (this.pattern.length == 0)
+            return this.ret(-100 /* Penalty.NotFull */, []);
+        if (word.length < this.pattern.length)
+            return null;
+        let { chars, folded, any, precise, byWord } = this;
+        // For single-character queries, only match when they occur right
+        // at the start
+        if (chars.length == 1) {
+            let first = codePointAt(word, 0), firstSize = codePointSize(first);
+            let score = firstSize == word.length ? 0 : -100 /* Penalty.NotFull */;
+            if (first == chars[0]) ;
+            else if (first == folded[0])
+                score += -200 /* Penalty.CaseFold */;
+            else
+                return null;
+            return this.ret(score, [0, firstSize]);
+        }
+        let direct = word.indexOf(this.pattern);
+        if (direct == 0)
+            return this.ret(word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */, [0, this.pattern.length]);
+        let len = chars.length, anyTo = 0;
+        if (direct < 0) {
+            for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) {
+                let next = codePointAt(word, i);
+                if (next == chars[anyTo] || next == folded[anyTo])
+                    any[anyTo++] = i;
+                i += codePointSize(next);
+            }
+            // No match, exit immediately
+            if (anyTo < len)
+                return null;
+        }
+        // This tracks the extent of the precise (non-folded, not
+        // necessarily adjacent) match
+        let preciseTo = 0;
+        // Tracks whether there is a match that hits only characters that
+        // appear to be starting words. `byWordFolded` is set to true when
+        // a case folded character is encountered in such a match
+        let byWordTo = 0, byWordFolded = false;
+        // If we've found a partial adjacent match, these track its state
+        let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
+        let hasLower = /[a-z]/.test(word), wordAdjacent = true;
+        // Go over the option's text, scanning for the various kinds of matches
+        for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) {
+            let next = codePointAt(word, i);
+            if (direct < 0) {
+                if (preciseTo < len && next == chars[preciseTo])
+                    precise[preciseTo++] = i;
+                if (adjacentTo < len) {
+                    if (next == chars[adjacentTo] || next == folded[adjacentTo]) {
+                        if (adjacentTo == 0)
+                            adjacentStart = i;
+                        adjacentEnd = i + 1;
+                        adjacentTo++;
+                    }
+                    else {
+                        adjacentTo = 0;
+                    }
+                }
+            }
+            let ch, type = next < 0xff
+                ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */)
+                : ((ch = fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */);
+            if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) {
+                if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
+                    byWord[byWordTo++] = i;
+                else if (byWord.length)
+                    wordAdjacent = false;
+            }
+            prevType = type;
+            i += codePointSize(next);
+        }
+        if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
+            return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word);
+        if (adjacentTo == len && adjacentStart == 0)
+            return this.ret(-200 /* Penalty.CaseFold */ - word.length + (adjacentEnd == word.length ? 0 : -100 /* Penalty.NotFull */), [0, adjacentEnd]);
+        if (direct > -1)
+            return this.ret(-700 /* Penalty.NotStart */ - word.length, [direct, direct + this.pattern.length]);
+        if (adjacentTo == len)
+            return this.ret(-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, [adjacentStart, adjacentEnd]);
+        if (byWordTo == len)
+            return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ +
+                (wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word);
+        return chars.length == 2 ? null
+            : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word);
+    }
+    result(score, positions, word) {
+        let result = [], i = 0;
+        for (let pos of positions) {
+            let to = pos + (this.astral ? codePointSize(codePointAt(word, pos)) : 1);
+            if (i && result[i - 1] == pos)
+                result[i - 1] = to;
+            else {
+                result[i++] = pos;
+                result[i++] = to;
+            }
+        }
+        return this.ret(score - word.length, result);
+    }
+}
+class StrictMatcher {
+    constructor(pattern) {
+        this.pattern = pattern;
+        this.matched = [];
+        this.score = 0;
+        this.folded = pattern.toLowerCase();
+    }
+    match(word) {
+        if (word.length < this.pattern.length)
+            return null;
+        let start = word.slice(0, this.pattern.length);
+        let match = start == this.pattern ? 0 : start.toLowerCase() == this.folded ? -200 /* Penalty.CaseFold */ : null;
+        if (match == null)
+            return null;
+        this.matched = [0, start.length];
+        this.score = match + (word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */);
+        return this;
+    }
+}
+
+const completionConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        return combineConfig(configs, {
+            activateOnTyping: true,
+            activateOnCompletion: () => false,
+            activateOnTypingDelay: 100,
+            selectOnOpen: true,
+            override: null,
+            closeOnBlur: true,
+            maxRenderedOptions: 100,
+            defaultKeymap: true,
+            tooltipClass: () => "",
+            optionClass: () => "",
+            aboveCursor: false,
+            icons: true,
+            addToOptions: [],
+            positionInfo: defaultPositionInfo,
+            filterStrict: false,
+            compareCompletions: (a, b) => a.label.localeCompare(b.label),
+            interactionDelay: 75,
+            updateSyncTime: 100
+        }, {
+            defaultKeymap: (a, b) => a && b,
+            closeOnBlur: (a, b) => a && b,
+            icons: (a, b) => a && b,
+            tooltipClass: (a, b) => c => joinClass(a(c), b(c)),
+            optionClass: (a, b) => c => joinClass(a(c), b(c)),
+            addToOptions: (a, b) => a.concat(b),
+            filterStrict: (a, b) => a || b,
+        });
+    }
+});
+function joinClass(a, b) {
+    return a ? b ? a + " " + b : a : b;
+}
+function defaultPositionInfo(view, list, option, info, space, tooltip) {
+    let rtl = view.textDirection == Direction.RTL, left = rtl, narrow = false;
+    let side = "top", offset, maxWidth;
+    let spaceLeft = list.left - space.left, spaceRight = space.right - list.right;
+    let infoWidth = info.right - info.left, infoHeight = info.bottom - info.top;
+    if (left && spaceLeft < Math.min(infoWidth, spaceRight))
+        left = false;
+    else if (!left && spaceRight < Math.min(infoWidth, spaceLeft))
+        left = true;
+    if (infoWidth <= (left ? spaceLeft : spaceRight)) {
+        offset = Math.max(space.top, Math.min(option.top, space.bottom - infoHeight)) - list.top;
+        maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight);
+    }
+    else {
+        narrow = true;
+        maxWidth = Math.min(400 /* Info.Width */, (rtl ? list.right : space.right - list.left) - 30 /* Info.Margin */);
+        let spaceBelow = space.bottom - list.bottom;
+        if (spaceBelow >= infoHeight || spaceBelow > list.top) { // Below the completion
+            offset = option.bottom - list.top;
+        }
+        else { // Above it
+            side = "bottom";
+            offset = list.bottom - option.top;
+        }
+    }
+    let scaleY = (list.bottom - list.top) / tooltip.offsetHeight;
+    let scaleX = (list.right - list.left) / tooltip.offsetWidth;
+    return {
+        style: `${side}: ${offset / scaleY}px; max-width: ${maxWidth / scaleX}px`,
+        class: "cm-completionInfo-" + (narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right")
+    };
+}
+
+function optionContent(config) {
+    let content = config.addToOptions.slice();
+    if (config.icons)
+        content.push({
+            render(completion) {
+                let icon = document.createElement("div");
+                icon.classList.add("cm-completionIcon");
+                if (completion.type)
+                    icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls));
+                icon.setAttribute("aria-hidden", "true");
+                return icon;
+            },
+            position: 20
+        });
+    content.push({
+        render(completion, _s, _v, match) {
+            let labelElt = document.createElement("span");
+            labelElt.className = "cm-completionLabel";
+            let label = completion.displayLabel || completion.label, off = 0;
+            for (let j = 0; j < match.length;) {
+                let from = match[j++], to = match[j++];
+                if (from > off)
+                    labelElt.appendChild(document.createTextNode(label.slice(off, from)));
+                let span = labelElt.appendChild(document.createElement("span"));
+                span.appendChild(document.createTextNode(label.slice(from, to)));
+                span.className = "cm-completionMatchedText";
+                off = to;
+            }
+            if (off < label.length)
+                labelElt.appendChild(document.createTextNode(label.slice(off)));
+            return labelElt;
+        },
+        position: 50
+    }, {
+        render(completion) {
+            if (!completion.detail)
+                return null;
+            let detailElt = document.createElement("span");
+            detailElt.className = "cm-completionDetail";
+            detailElt.textContent = completion.detail;
+            return detailElt;
+        },
+        position: 80
+    });
+    return content.sort((a, b) => a.position - b.position).map(a => a.render);
+}
+function rangeAroundSelected(total, selected, max) {
+    if (total <= max)
+        return { from: 0, to: total };
+    if (selected < 0)
+        selected = 0;
+    if (selected <= (total >> 1)) {
+        let off = Math.floor(selected / max);
+        return { from: off * max, to: (off + 1) * max };
+    }
+    let off = Math.floor((total - selected) / max);
+    return { from: total - (off + 1) * max, to: total - off * max };
+}
+class CompletionTooltip {
+    constructor(view, stateField, applyCompletion) {
+        this.view = view;
+        this.stateField = stateField;
+        this.applyCompletion = applyCompletion;
+        this.info = null;
+        this.infoDestroy = null;
+        this.placeInfoReq = {
+            read: () => this.measureInfo(),
+            write: (pos) => this.placeInfo(pos),
+            key: this
+        };
+        this.space = null;
+        this.currentClass = "";
+        let cState = view.state.field(stateField);
+        let { options, selected } = cState.open;
+        let config = view.state.facet(completionConfig);
+        this.optionContent = optionContent(config);
+        this.optionClass = config.optionClass;
+        this.tooltipClass = config.tooltipClass;
+        this.range = rangeAroundSelected(options.length, selected, config.maxRenderedOptions);
+        this.dom = document.createElement("div");
+        this.dom.className = "cm-tooltip-autocomplete";
+        this.updateTooltipClass(view.state);
+        this.dom.addEventListener("mousedown", (e) => {
+            let { options } = view.state.field(stateField).open;
+            for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) {
+                if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) {
+                    this.applyCompletion(view, options[+match[1]]);
+                    e.preventDefault();
+                    return;
+                }
+            }
+        });
+        this.dom.addEventListener("focusout", (e) => {
+            let state = view.state.field(this.stateField, false);
+            if (state && state.tooltip && view.state.facet(completionConfig).closeOnBlur &&
+                e.relatedTarget != view.contentDOM)
+                view.dispatch({ effects: closeCompletionEffect.of(null) });
+        });
+        this.showOptions(options, cState.id);
+    }
+    mount() { this.updateSel(); }
+    showOptions(options, id) {
+        if (this.list)
+            this.list.remove();
+        this.list = this.dom.appendChild(this.createListBox(options, id, this.range));
+        this.list.addEventListener("scroll", () => {
+            if (this.info)
+                this.view.requestMeasure(this.placeInfoReq);
+        });
+    }
+    update(update) {
+        var _a;
+        let cState = update.state.field(this.stateField);
+        let prevState = update.startState.field(this.stateField);
+        this.updateTooltipClass(update.state);
+        if (cState != prevState) {
+            let { options, selected, disabled } = cState.open;
+            if (!prevState.open || prevState.open.options != options) {
+                this.range = rangeAroundSelected(options.length, selected, update.state.facet(completionConfig).maxRenderedOptions);
+                this.showOptions(options, cState.id);
+            }
+            this.updateSel();
+            if (disabled != ((_a = prevState.open) === null || _a === void 0 ? void 0 : _a.disabled))
+                this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!disabled);
+        }
+    }
+    updateTooltipClass(state) {
+        let cls = this.tooltipClass(state);
+        if (cls != this.currentClass) {
+            for (let c of this.currentClass.split(" "))
+                if (c)
+                    this.dom.classList.remove(c);
+            for (let c of cls.split(" "))
+                if (c)
+                    this.dom.classList.add(c);
+            this.currentClass = cls;
+        }
+    }
+    positioned(space) {
+        this.space = space;
+        if (this.info)
+            this.view.requestMeasure(this.placeInfoReq);
+    }
+    updateSel() {
+        let cState = this.view.state.field(this.stateField), open = cState.open;
+        if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
+            this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
+            this.showOptions(open.options, cState.id);
+        }
+        if (this.updateSelectedOption(open.selected)) {
+            this.destroyInfo();
+            let { completion } = open.options[open.selected];
+            let { info } = completion;
+            if (!info)
+                return;
+            let infoResult = typeof info === "string" ? document.createTextNode(info) : info(completion);
+            if (!infoResult)
+                return;
+            if ("then" in infoResult) {
+                infoResult.then(obj => {
+                    if (obj && this.view.state.field(this.stateField, false) == cState)
+                        this.addInfoPane(obj, completion);
+                }).catch(e => logException(this.view.state, e, "completion info"));
+            }
+            else {
+                this.addInfoPane(infoResult, completion);
+            }
+        }
+    }
+    addInfoPane(content, completion) {
+        this.destroyInfo();
+        let wrap = this.info = document.createElement("div");
+        wrap.className = "cm-tooltip cm-completionInfo";
+        if (content.nodeType != null) {
+            wrap.appendChild(content);
+            this.infoDestroy = null;
+        }
+        else {
+            let { dom, destroy } = content;
+            wrap.appendChild(dom);
+            this.infoDestroy = destroy || null;
+        }
+        this.dom.appendChild(wrap);
+        this.view.requestMeasure(this.placeInfoReq);
+    }
+    updateSelectedOption(selected) {
+        let set = null;
+        for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) {
+            if (opt.nodeName != "LI" || !opt.id) {
+                i--; // A section header
+            }
+            else if (i == selected) {
+                if (!opt.hasAttribute("aria-selected")) {
+                    opt.setAttribute("aria-selected", "true");
+                    set = opt;
+                }
+            }
+            else {
+                if (opt.hasAttribute("aria-selected"))
+                    opt.removeAttribute("aria-selected");
+            }
+        }
+        if (set)
+            scrollIntoView(this.list, set);
+        return set;
+    }
+    measureInfo() {
+        let sel = this.dom.querySelector("[aria-selected]");
+        if (!sel || !this.info)
+            return null;
+        let listRect = this.dom.getBoundingClientRect();
+        let infoRect = this.info.getBoundingClientRect();
+        let selRect = sel.getBoundingClientRect();
+        let space = this.space;
+        if (!space) {
+            let win = this.dom.ownerDocument.defaultView || window;
+            space = { left: 0, top: 0, right: win.innerWidth, bottom: win.innerHeight };
+        }
+        if (selRect.top > Math.min(space.bottom, listRect.bottom) - 10 ||
+            selRect.bottom < Math.max(space.top, listRect.top) + 10)
+            return null;
+        return this.view.state.facet(completionConfig).positionInfo(this.view, listRect, selRect, infoRect, space, this.dom);
+    }
+    placeInfo(pos) {
+        if (this.info) {
+            if (pos) {
+                if (pos.style)
+                    this.info.style.cssText = pos.style;
+                this.info.className = "cm-tooltip cm-completionInfo " + (pos.class || "");
+            }
+            else {
+                this.info.style.cssText = "top: -1e6px";
+            }
+        }
+    }
+    createListBox(options, id, range) {
+        const ul = document.createElement("ul");
+        ul.id = id;
+        ul.setAttribute("role", "listbox");
+        ul.setAttribute("aria-expanded", "true");
+        ul.setAttribute("aria-label", this.view.state.phrase("Completions"));
+        let curSection = null;
+        for (let i = range.from; i < range.to; i++) {
+            let { completion, match } = options[i], { section } = completion;
+            if (section) {
+                let name = typeof section == "string" ? section : section.name;
+                if (name != curSection && (i > range.from || range.from == 0)) {
+                    curSection = name;
+                    if (typeof section != "string" && section.header) {
+                        ul.appendChild(section.header(section));
+                    }
+                    else {
+                        let header = ul.appendChild(document.createElement("completion-section"));
+                        header.textContent = name;
+                    }
+                }
+            }
+            const li = ul.appendChild(document.createElement("li"));
+            li.id = id + "-" + i;
+            li.setAttribute("role", "option");
+            let cls = this.optionClass(completion);
+            if (cls)
+                li.className = cls;
+            for (let source of this.optionContent) {
+                let node = source(completion, this.view.state, this.view, match);
+                if (node)
+                    li.appendChild(node);
+            }
+        }
+        if (range.from)
+            ul.classList.add("cm-completionListIncompleteTop");
+        if (range.to < options.length)
+            ul.classList.add("cm-completionListIncompleteBottom");
+        return ul;
+    }
+    destroyInfo() {
+        if (this.info) {
+            if (this.infoDestroy)
+                this.infoDestroy();
+            this.info.remove();
+            this.info = null;
+        }
+    }
+    destroy() {
+        this.destroyInfo();
+    }
+}
+function completionTooltip(stateField, applyCompletion) {
+    return (view) => new CompletionTooltip(view, stateField, applyCompletion);
+}
+function scrollIntoView(container, element) {
+    let parent = container.getBoundingClientRect();
+    let self = element.getBoundingClientRect();
+    let scaleY = parent.height / container.offsetHeight;
+    if (self.top < parent.top)
+        container.scrollTop -= (parent.top - self.top) / scaleY;
+    else if (self.bottom > parent.bottom)
+        container.scrollTop += (self.bottom - parent.bottom) / scaleY;
+}
+
+// Used to pick a preferred option when two options with the same
+// label occur in the result.
+function score(option) {
+    return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) +
+        (option.type ? 1 : 0);
+}
+function sortOptions(active, state) {
+    let options = [];
+    let sections = null;
+    let addOption = (option) => {
+        options.push(option);
+        let { section } = option.completion;
+        if (section) {
+            if (!sections)
+                sections = [];
+            let name = typeof section == "string" ? section : section.name;
+            if (!sections.some(s => s.name == name))
+                sections.push(typeof section == "string" ? { name } : section);
+        }
+    };
+    let conf = state.facet(completionConfig);
+    for (let a of active)
+        if (a.hasResult()) {
+            let getMatch = a.result.getMatch;
+            if (a.result.filter === false) {
+                for (let option of a.result.options) {
+                    addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length));
+                }
+            }
+            else {
+                let pattern = state.sliceDoc(a.from, a.to), match;
+                let matcher = conf.filterStrict ? new StrictMatcher(pattern) : new FuzzyMatcher(pattern);
+                for (let option of a.result.options)
+                    if (match = matcher.match(option.label)) {
+                        let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : [];
+                        addOption(new Option(option, a.source, matched, match.score + (option.boost || 0)));
+                    }
+            }
+        }
+    if (sections) {
+        let sectionOrder = Object.create(null), pos = 0;
+        let cmp = (a, b) => { var _a, _b; return ((_a = a.rank) !== null && _a !== void 0 ? _a : 1e9) - ((_b = b.rank) !== null && _b !== void 0 ? _b : 1e9) || (a.name < b.name ? -1 : 1); };
+        for (let s of sections.sort(cmp)) {
+            pos -= 1e5;
+            sectionOrder[s.name] = pos;
+        }
+        for (let option of options) {
+            let { section } = option.completion;
+            if (section)
+                option.score += sectionOrder[typeof section == "string" ? section : section.name];
+        }
+    }
+    let result = [], prev = null;
+    let compare = conf.compareCompletions;
+    for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) {
+        let cur = opt.completion;
+        if (!prev || prev.label != cur.label || prev.detail != cur.detail ||
+            (prev.type != null && cur.type != null && prev.type != cur.type) ||
+            prev.apply != cur.apply || prev.boost != cur.boost)
+            result.push(opt);
+        else if (score(opt.completion) > score(prev))
+            result[result.length - 1] = opt;
+        prev = opt.completion;
+    }
+    return result;
+}
+class CompletionDialog {
+    constructor(options, attrs, tooltip, timestamp, selected, disabled) {
+        this.options = options;
+        this.attrs = attrs;
+        this.tooltip = tooltip;
+        this.timestamp = timestamp;
+        this.selected = selected;
+        this.disabled = disabled;
+    }
+    setSelected(selected, id) {
+        return selected == this.selected || selected >= this.options.length ? this
+            : new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
+    }
+    static build(active, state, id, prev, conf, didSetActive) {
+        if (prev && !didSetActive && active.some(s => s.isPending))
+            return prev.setDisabled();
+        let options = sortOptions(active, state);
+        if (!options.length)
+            return prev && active.some(a => a.isPending) ? prev.setDisabled() : null;
+        let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;
+        if (prev && prev.selected != selected && prev.selected != -1) {
+            let selectedValue = prev.options[prev.selected].completion;
+            for (let i = 0; i < options.length; i++)
+                if (options[i].completion == selectedValue) {
+                    selected = i;
+                    break;
+                }
+        }
+        return new CompletionDialog(options, makeAttrs(id, selected), {
+            pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
+            create: createTooltip,
+            above: conf.aboveCursor,
+        }, prev ? prev.timestamp : Date.now(), selected, false);
+    }
+    map(changes) {
+        return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected, this.disabled);
+    }
+    setDisabled() {
+        return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true);
+    }
+}
+class CompletionState {
+    constructor(active, id, open) {
+        this.active = active;
+        this.id = id;
+        this.open = open;
+    }
+    static start() {
+        return new CompletionState(none, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
+    }
+    update(tr) {
+        let { state } = tr, conf = state.facet(completionConfig);
+        let sources = conf.override ||
+            state.languageDataAt("autocomplete", cur(state)).map(asSource);
+        let active = sources.map(source => {
+            let value = this.active.find(s => s.source == source) ||
+                new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */);
+            return value.update(tr, conf);
+        });
+        if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
+            active = this.active;
+        let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect));
+        if (open && tr.docChanged)
+            open = open.map(tr.changes);
+        if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
+            !sameResults(active, this.active) || didSet)
+            open = CompletionDialog.build(active, state, this.id, open, conf, didSet);
+        else if (open && open.disabled && !active.some(a => a.isPending))
+            open = null;
+        if (!open && active.every(a => !a.isPending) && active.some(a => a.hasResult()))
+            active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
+        for (let effect of tr.effects)
+            if (effect.is(setSelectedEffect))
+                open = open && open.setSelected(effect.value, this.id);
+        return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
+    }
+    get tooltip() { return this.open ? this.open.tooltip : null; }
+    get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; }
+}
+function sameResults(a, b) {
+    if (a == b)
+        return true;
+    for (let iA = 0, iB = 0;;) {
+        while (iA < a.length && !a[iA].hasResult())
+            iA++;
+        while (iB < b.length && !b[iB].hasResult())
+            iB++;
+        let endA = iA == a.length, endB = iB == b.length;
+        if (endA || endB)
+            return endA == endB;
+        if (a[iA++].result != b[iB++].result)
+            return false;
+    }
+}
+const baseAttrs = {
+    "aria-autocomplete": "list"
+};
+const noAttrs = {};
+function makeAttrs(id, selected) {
+    let result = {
+        "aria-autocomplete": "list",
+        "aria-haspopup": "listbox",
+        "aria-controls": id
+    };
+    if (selected > -1)
+        result["aria-activedescendant"] = id + "-" + selected;
+    return result;
+}
+const none = [];
+function getUpdateType(tr, conf) {
+    if (tr.isUserEvent("input.complete")) {
+        let completion = tr.annotation(pickedCompletion);
+        if (completion && conf.activateOnCompletion(completion))
+            return 4 /* UpdateType.Activate */ | 8 /* UpdateType.Reset */;
+    }
+    let typing = tr.isUserEvent("input.type");
+    return typing && conf.activateOnTyping ? 4 /* UpdateType.Activate */ | 1 /* UpdateType.Typing */
+        : typing ? 1 /* UpdateType.Typing */
+            : tr.isUserEvent("delete.backward") ? 2 /* UpdateType.Backspacing */
+                : tr.selection ? 8 /* UpdateType.Reset */
+                    : tr.docChanged ? 16 /* UpdateType.ResetIfTouching */ : 0 /* UpdateType.None */;
+}
+class ActiveSource {
+    constructor(source, state, explicit = false) {
+        this.source = source;
+        this.state = state;
+        this.explicit = explicit;
+    }
+    hasResult() { return false; }
+    get isPending() { return this.state == 1 /* State.Pending */; }
+    update(tr, conf) {
+        let type = getUpdateType(tr, conf), value = this;
+        if ((type & 8 /* UpdateType.Reset */) || (type & 16 /* UpdateType.ResetIfTouching */) && this.touches(tr))
+            value = new ActiveSource(value.source, 0 /* State.Inactive */);
+        if ((type & 4 /* UpdateType.Activate */) && value.state == 0 /* State.Inactive */)
+            value = new ActiveSource(this.source, 1 /* State.Pending */);
+        value = value.updateFor(tr, type);
+        for (let effect of tr.effects) {
+            if (effect.is(startCompletionEffect))
+                value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value);
+            else if (effect.is(closeCompletionEffect))
+                value = new ActiveSource(value.source, 0 /* State.Inactive */);
+            else if (effect.is(setActiveEffect))
+                for (let active of effect.value)
+                    if (active.source == value.source)
+                        value = active;
+        }
+        return value;
+    }
+    updateFor(tr, type) { return this.map(tr.changes); }
+    map(changes) { return this; }
+    touches(tr) {
+        return tr.changes.touchesRange(cur(tr.state));
+    }
+}
+class ActiveResult extends ActiveSource {
+    constructor(source, explicit, limit, result, from, to) {
+        super(source, 3 /* State.Result */, explicit);
+        this.limit = limit;
+        this.result = result;
+        this.from = from;
+        this.to = to;
+    }
+    hasResult() { return true; }
+    updateFor(tr, type) {
+        var _a;
+        if (!(type & 3 /* UpdateType.SimpleInteraction */))
+            return this.map(tr.changes);
+        let result = this.result;
+        if (result.map && !tr.changes.empty)
+            result = result.map(result, tr.changes);
+        let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1);
+        let pos = cur(tr.state);
+        if (pos > to || !result ||
+            (type & 2 /* UpdateType.Backspacing */) && (cur(tr.startState) == this.from || pos < this.limit))
+            return new ActiveSource(this.source, type & 4 /* UpdateType.Activate */ ? 1 /* State.Pending */ : 0 /* State.Inactive */);
+        let limit = tr.changes.mapPos(this.limit);
+        if (checkValid(result.validFor, tr.state, from, to))
+            return new ActiveResult(this.source, this.explicit, limit, result, from, to);
+        if (result.update &&
+            (result = result.update(result, from, to, new CompletionContext(tr.state, pos, false))))
+            return new ActiveResult(this.source, this.explicit, limit, result, result.from, (_a = result.to) !== null && _a !== void 0 ? _a : cur(tr.state));
+        return new ActiveSource(this.source, 1 /* State.Pending */, this.explicit);
+    }
+    map(mapping) {
+        if (mapping.empty)
+            return this;
+        let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
+        if (!result)
+            return new ActiveSource(this.source, 0 /* State.Inactive */);
+        return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
+    }
+    touches(tr) {
+        return tr.changes.touchesRange(this.from, this.to);
+    }
+}
+function checkValid(validFor, state, from, to) {
+    if (!validFor)
+        return false;
+    let text = state.sliceDoc(from, to);
+    return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text);
+}
+const setActiveEffect = /*@__PURE__*/StateEffect.define({
+    map(sources, mapping) { return sources.map(s => s.map(mapping)); }
+});
+const setSelectedEffect = /*@__PURE__*/StateEffect.define();
+const completionState = /*@__PURE__*/StateField.define({
+    create() { return CompletionState.start(); },
+    update(value, tr) { return value.update(tr); },
+    provide: f => [
+        showTooltip.from(f, val => val.tooltip),
+        EditorView.contentAttributes.from(f, state => state.attrs)
+    ]
+});
+function applyCompletion(view, option) {
+    const apply = option.completion.apply || option.completion.label;
+    let result = view.state.field(completionState).active.find(a => a.source == option.source);
+    if (!(result instanceof ActiveResult))
+        return false;
+    if (typeof apply == "string")
+        view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to)), { annotations: pickedCompletion.of(option.completion) }));
+    else
+        apply(view, option.completion, result.from, result.to);
+    return true;
+}
+const createTooltip = /*@__PURE__*/completionTooltip(completionState, applyCompletion);
+
+/**
+Returns a command that moves the completion selection forward or
+backward by the given amount.
+*/
+function moveCompletionSelection(forward, by = "option") {
+    return (view) => {
+        let cState = view.state.field(completionState, false);
+        if (!cState || !cState.open || cState.open.disabled ||
+            Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
+            return false;
+        let step = 1, tooltip;
+        if (by == "page" && (tooltip = getTooltip(view, cState.open.tooltip)))
+            step = Math.max(2, Math.floor(tooltip.dom.offsetHeight /
+                tooltip.dom.querySelector("li").offsetHeight) - 1);
+        let { length } = cState.open.options;
+        let selected = cState.open.selected > -1 ? cState.open.selected + step * (forward ? 1 : -1) : forward ? 0 : length - 1;
+        if (selected < 0)
+            selected = by == "page" ? 0 : length - 1;
+        else if (selected >= length)
+            selected = by == "page" ? length - 1 : 0;
+        view.dispatch({ effects: setSelectedEffect.of(selected) });
+        return true;
+    };
+}
+/**
+Accept the current completion.
+*/
+const acceptCompletion = (view) => {
+    let cState = view.state.field(completionState, false);
+    if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || cState.open.disabled ||
+        Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
+        return false;
+    return applyCompletion(view, cState.open.options[cState.open.selected]);
+};
+/**
+Explicitly start autocompletion.
+*/
+const startCompletion = (view) => {
+    let cState = view.state.field(completionState, false);
+    if (!cState)
+        return false;
+    view.dispatch({ effects: startCompletionEffect.of(true) });
+    return true;
+};
+/**
+Close the currently active completion.
+*/
+const closeCompletion = (view) => {
+    let cState = view.state.field(completionState, false);
+    if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */))
+        return false;
+    view.dispatch({ effects: closeCompletionEffect.of(null) });
+    return true;
+};
+class RunningQuery {
+    constructor(active, context) {
+        this.active = active;
+        this.context = context;
+        this.time = Date.now();
+        this.updates = [];
+        // Note that 'undefined' means 'not done yet', whereas 'null' means
+        // 'query returned null'.
+        this.done = undefined;
+    }
+}
+const MaxUpdateCount = 50, MinAbortTime = 1000;
+const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.view = view;
+        this.debounceUpdate = -1;
+        this.running = [];
+        this.debounceAccept = -1;
+        this.pendingStart = false;
+        this.composing = 0 /* CompositionState.None */;
+        for (let active of view.state.field(completionState).active)
+            if (active.isPending)
+                this.startQuery(active);
+    }
+    update(update) {
+        let cState = update.state.field(completionState);
+        let conf = update.state.facet(completionConfig);
+        if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState)
+            return;
+        let doesReset = update.transactions.some(tr => {
+            let type = getUpdateType(tr, conf);
+            return (type & 8 /* UpdateType.Reset */) || (tr.selection || tr.docChanged) && !(type & 3 /* UpdateType.SimpleInteraction */);
+        });
+        for (let i = 0; i < this.running.length; i++) {
+            let query = this.running[i];
+            if (doesReset ||
+                query.context.abortOnDocChange && update.docChanged ||
+                query.updates.length + update.transactions.length > MaxUpdateCount && Date.now() - query.time > MinAbortTime) {
+                for (let handler of query.context.abortListeners) {
+                    try {
+                        handler();
+                    }
+                    catch (e) {
+                        logException(this.view.state, e);
+                    }
+                }
+                query.context.abortListeners = null;
+                this.running.splice(i--, 1);
+            }
+            else {
+                query.updates.push(...update.transactions);
+            }
+        }
+        if (this.debounceUpdate > -1)
+            clearTimeout(this.debounceUpdate);
+        if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect))))
+            this.pendingStart = true;
+        let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay;
+        this.debounceUpdate = cState.active.some(a => a.isPending && !this.running.some(q => q.active.source == a.source))
+            ? setTimeout(() => this.startUpdate(), delay) : -1;
+        if (this.composing != 0 /* CompositionState.None */)
+            for (let tr of update.transactions) {
+                if (tr.isUserEvent("input.type"))
+                    this.composing = 2 /* CompositionState.Changed */;
+                else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
+                    this.composing = 3 /* CompositionState.ChangedAndMoved */;
+            }
+    }
+    startUpdate() {
+        this.debounceUpdate = -1;
+        this.pendingStart = false;
+        let { state } = this.view, cState = state.field(completionState);
+        for (let active of cState.active) {
+            if (active.isPending && !this.running.some(r => r.active.source == active.source))
+                this.startQuery(active);
+        }
+        if (this.running.length && cState.open && cState.open.disabled)
+            this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
+    }
+    startQuery(active) {
+        let { state } = this.view, pos = cur(state);
+        let context = new CompletionContext(state, pos, active.explicit, this.view);
+        let pending = new RunningQuery(active, context);
+        this.running.push(pending);
+        Promise.resolve(active.source(context)).then(result => {
+            if (!pending.context.aborted) {
+                pending.done = result || null;
+                this.scheduleAccept();
+            }
+        }, err => {
+            this.view.dispatch({ effects: closeCompletionEffect.of(null) });
+            logException(this.view.state, err);
+        });
+    }
+    scheduleAccept() {
+        if (this.running.every(q => q.done !== undefined))
+            this.accept();
+        else if (this.debounceAccept < 0)
+            this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
+    }
+    // For each finished query in this.running, try to create a result
+    // or, if appropriate, restart the query.
+    accept() {
+        var _a;
+        if (this.debounceAccept > -1)
+            clearTimeout(this.debounceAccept);
+        this.debounceAccept = -1;
+        let updated = [];
+        let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState);
+        for (let i = 0; i < this.running.length; i++) {
+            let query = this.running[i];
+            if (query.done === undefined)
+                continue;
+            this.running.splice(i--, 1);
+            if (query.done) {
+                let pos = cur(query.updates.length ? query.updates[0].startState : this.view.state);
+                let limit = Math.min(pos, query.done.from + (query.active.explicit ? 0 : 1));
+                let active = new ActiveResult(query.active.source, query.active.explicit, limit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : pos);
+                // Replay the transactions that happened since the start of
+                // the request and see if that preserves the result
+                for (let tr of query.updates)
+                    active = active.update(tr, conf);
+                if (active.hasResult()) {
+                    updated.push(active);
+                    continue;
+                }
+            }
+            let current = cState.active.find(a => a.source == query.active.source);
+            if (current && current.isPending) {
+                if (query.done == null) {
+                    // Explicitly failed. Should clear the pending status if it
+                    // hasn't been re-set in the meantime.
+                    let active = new ActiveSource(query.active.source, 0 /* State.Inactive */);
+                    for (let tr of query.updates)
+                        active = active.update(tr, conf);
+                    if (!active.isPending)
+                        updated.push(active);
+                }
+                else {
+                    // Cleared by subsequent transactions. Restart.
+                    this.startQuery(current);
+                }
+            }
+        }
+        if (updated.length || cState.open && cState.open.disabled)
+            this.view.dispatch({ effects: setActiveEffect.of(updated) });
+    }
+}, {
+    eventHandlers: {
+        blur(event) {
+            let state = this.view.state.field(completionState, false);
+            if (state && state.tooltip && this.view.state.facet(completionConfig).closeOnBlur) {
+                let dialog = state.open && getTooltip(this.view, state.open.tooltip);
+                if (!dialog || !dialog.dom.contains(event.relatedTarget))
+                    setTimeout(() => this.view.dispatch({ effects: closeCompletionEffect.of(null) }), 10);
+            }
+        },
+        compositionstart() {
+            this.composing = 1 /* CompositionState.Started */;
+        },
+        compositionend() {
+            if (this.composing == 3 /* CompositionState.ChangedAndMoved */) {
+                // Safari fires compositionend events synchronously, possibly
+                // from inside an update, so dispatch asynchronously to avoid reentrancy
+                setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20);
+            }
+            this.composing = 0 /* CompositionState.None */;
+        }
+    }
+});
+const windows = typeof navigator == "object" && /*@__PURE__*//Win/.test(navigator.platform);
+const commitCharacters = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.domEventHandlers({
+    keydown(event, view) {
+        let field = view.state.field(completionState, false);
+        if (!field || !field.open || field.open.disabled || field.open.selected < 0 ||
+            event.key.length > 1 || event.ctrlKey && !(windows && event.altKey) || event.metaKey)
+            return false;
+        let option = field.open.options[field.open.selected];
+        let result = field.active.find(a => a.source == option.source);
+        let commitChars = option.completion.commitCharacters || result.result.commitCharacters;
+        if (commitChars && commitChars.indexOf(event.key) > -1)
+            applyCompletion(view, option);
+        return false;
+    }
+}));
+
+const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
+    ".cm-tooltip.cm-tooltip-autocomplete": {
+        "& > ul": {
+            fontFamily: "monospace",
+            whiteSpace: "nowrap",
+            overflow: "hidden auto",
+            maxWidth_fallback: "700px",
+            maxWidth: "min(700px, 95vw)",
+            minWidth: "250px",
+            maxHeight: "10em",
+            height: "100%",
+            listStyle: "none",
+            margin: 0,
+            padding: 0,
+            "& > li, & > completion-section": {
+                padding: "1px 3px",
+                lineHeight: 1.2
+            },
+            "& > li": {
+                overflowX: "hidden",
+                textOverflow: "ellipsis",
+                cursor: "pointer"
+            },
+            "& > completion-section": {
+                display: "list-item",
+                borderBottom: "1px solid silver",
+                paddingLeft: "0.5em",
+                opacity: 0.7
+            }
+        }
+    },
+    "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
+        background: "#17c",
+        color: "white",
+    },
+    "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
+        background: "#777",
+    },
+    "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
+        background: "#347",
+        color: "white",
+    },
+    "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
+        background: "#444",
+    },
+    ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
+        content: '"···"',
+        opacity: 0.5,
+        display: "block",
+        textAlign: "center"
+    },
+    ".cm-tooltip.cm-completionInfo": {
+        position: "absolute",
+        padding: "3px 9px",
+        width: "max-content",
+        maxWidth: `${400 /* Info.Width */}px`,
+        boxSizing: "border-box",
+        whiteSpace: "pre-line"
+    },
+    ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
+    ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
+    ".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` },
+    ".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` },
+    "&light .cm-snippetField": { backgroundColor: "#00000022" },
+    "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
+    ".cm-snippetFieldPosition": {
+        verticalAlign: "text-top",
+        width: 0,
+        height: "1.15em",
+        display: "inline-block",
+        margin: "0 -0.7px -.7em",
+        borderLeft: "1.4px dotted #888"
+    },
+    ".cm-completionMatchedText": {
+        textDecoration: "underline"
+    },
+    ".cm-completionDetail": {
+        marginLeft: "0.5em",
+        fontStyle: "italic"
+    },
+    ".cm-completionIcon": {
+        fontSize: "90%",
+        width: ".8em",
+        display: "inline-block",
+        textAlign: "center",
+        paddingRight: ".6em",
+        opacity: "0.6",
+        boxSizing: "content-box"
+    },
+    ".cm-completionIcon-function, .cm-completionIcon-method": {
+        "&:after": { content: "'ƒ'" }
+    },
+    ".cm-completionIcon-class": {
+        "&:after": { content: "'○'" }
+    },
+    ".cm-completionIcon-interface": {
+        "&:after": { content: "'◌'" }
+    },
+    ".cm-completionIcon-variable": {
+        "&:after": { content: "'𝑥'" }
+    },
+    ".cm-completionIcon-constant": {
+        "&:after": { content: "'𝐶'" }
+    },
+    ".cm-completionIcon-type": {
+        "&:after": { content: "'𝑡'" }
+    },
+    ".cm-completionIcon-enum": {
+        "&:after": { content: "'∪'" }
+    },
+    ".cm-completionIcon-property": {
+        "&:after": { content: "'□'" }
+    },
+    ".cm-completionIcon-keyword": {
+        "&:after": { content: "'🔑\uFE0E'" } // Disable emoji rendering
+    },
+    ".cm-completionIcon-namespace": {
+        "&:after": { content: "'▢'" }
+    },
+    ".cm-completionIcon-text": {
+        "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
+    }
+});
+
+class FieldPos {
+    constructor(field, line, from, to) {
+        this.field = field;
+        this.line = line;
+        this.from = from;
+        this.to = to;
+    }
+}
+class FieldRange {
+    constructor(field, from, to) {
+        this.field = field;
+        this.from = from;
+        this.to = to;
+    }
+    map(changes) {
+        let from = changes.mapPos(this.from, -1, MapMode.TrackDel);
+        let to = changes.mapPos(this.to, 1, MapMode.TrackDel);
+        return from == null || to == null ? null : new FieldRange(this.field, from, to);
+    }
+}
+class Snippet {
+    constructor(lines, fieldPositions) {
+        this.lines = lines;
+        this.fieldPositions = fieldPositions;
+    }
+    instantiate(state, pos) {
+        let text = [], lineStart = [pos];
+        let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0];
+        for (let line of this.lines) {
+            if (text.length) {
+                let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length;
+                for (let i = 0; i < tabs; i++)
+                    indent += state.facet(indentUnit);
+                lineStart.push(pos + indent.length - tabs);
+                line = indent + line.slice(tabs);
+            }
+            text.push(line);
+            pos += line.length + 1;
+        }
+        let ranges = this.fieldPositions.map(pos => new FieldRange(pos.field, lineStart[pos.line] + pos.from, lineStart[pos.line] + pos.to));
+        return { text, ranges };
+    }
+    static parse(template) {
+        let fields = [];
+        let lines = [], positions = [], m;
+        for (let line of template.split(/\r\n?|\n/)) {
+            while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
+                let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
+                let name = rawName.replace(/\\[{}]/g, m => m[1]);
+                for (let i = 0; i < fields.length; i++) {
+                    if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
+                        found = i;
+                }
+                if (found < 0) {
+                    let i = 0;
+                    while (i < fields.length && (seq == null || (fields[i].seq != null && fields[i].seq < seq)))
+                        i++;
+                    fields.splice(i, 0, { seq, name });
+                    found = i;
+                    for (let pos of positions)
+                        if (pos.field >= found)
+                            pos.field++;
+                }
+                positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
+                line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
+            }
+            line = line.replace(/\\([{}])/g, (_, brace, index) => {
+                for (let pos of positions)
+                    if (pos.line == lines.length && pos.from > index) {
+                        pos.from--;
+                        pos.to--;
+                    }
+                return brace;
+            });
+            lines.push(line);
+        }
+        return new Snippet(lines, positions);
+    }
+}
+let fieldMarker = /*@__PURE__*/Decoration.widget({ widget: /*@__PURE__*/new class extends WidgetType {
+        toDOM() {
+            let span = document.createElement("span");
+            span.className = "cm-snippetFieldPosition";
+            return span;
+        }
+        ignoreEvent() { return false; }
+    } });
+let fieldRange = /*@__PURE__*/Decoration.mark({ class: "cm-snippetField" });
+class ActiveSnippet {
+    constructor(ranges, active) {
+        this.ranges = ranges;
+        this.active = active;
+        this.deco = Decoration.set(ranges.map(r => (r.from == r.to ? fieldMarker : fieldRange).range(r.from, r.to)));
+    }
+    map(changes) {
+        let ranges = [];
+        for (let r of this.ranges) {
+            let mapped = r.map(changes);
+            if (!mapped)
+                return null;
+            ranges.push(mapped);
+        }
+        return new ActiveSnippet(ranges, this.active);
+    }
+    selectionInsideField(sel) {
+        return sel.ranges.every(range => this.ranges.some(r => r.field == this.active && r.from <= range.from && r.to >= range.to));
+    }
+}
+const setActive = /*@__PURE__*/StateEffect.define({
+    map(value, changes) { return value && value.map(changes); }
+});
+const moveToField = /*@__PURE__*/StateEffect.define();
+const snippetState = /*@__PURE__*/StateField.define({
+    create() { return null; },
+    update(value, tr) {
+        for (let effect of tr.effects) {
+            if (effect.is(setActive))
+                return effect.value;
+            if (effect.is(moveToField) && value)
+                return new ActiveSnippet(value.ranges, effect.value);
+        }
+        if (value && tr.docChanged)
+            value = value.map(tr.changes);
+        if (value && tr.selection && !value.selectionInsideField(tr.selection))
+            value = null;
+        return value;
+    },
+    provide: f => EditorView.decorations.from(f, val => val ? val.deco : Decoration.none)
+});
+function fieldSelection(ranges, field) {
+    return EditorSelection.create(ranges.filter(r => r.field == field).map(r => EditorSelection.range(r.from, r.to)));
+}
+/**
+Convert a snippet template to a function that can
+[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
+using syntax like this:
+
+    "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
+
+Each `${}` placeholder (you may also use `#{}`) indicates a field
+that the user can fill in. Its name, if any, will be the default
+content for the field.
+
+When the snippet is activated by calling the returned function,
+the code is inserted at the given position. Newlines in the
+template are indented by the indentation of the start line, plus
+one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
+the newline.
+
+On activation, (all instances of) the first field are selected.
+The user can move between fields with Tab and Shift-Tab as long as
+the fields are active. Moving to the last field or moving the
+cursor out of the current field deactivates the fields.
+
+The order of fields defaults to textual order, but you can add
+numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
+a custom order.
+
+To include a literal `{` or `}` in your template, put a backslash
+in front of it. This will be removed and the brace will not be
+interpreted as indicating a placeholder.
+*/
+function snippet(template) {
+    let snippet = Snippet.parse(template);
+    return (editor, completion, from, to) => {
+        let { text, ranges } = snippet.instantiate(editor.state, from);
+        let { main } = editor.state.selection;
+        let spec = {
+            changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) },
+            scrollIntoView: true,
+            annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
+        };
+        if (ranges.length)
+            spec.selection = fieldSelection(ranges, 0);
+        if (ranges.some(r => r.field > 0)) {
+            let active = new ActiveSnippet(ranges, 0);
+            let effects = spec.effects = [setActive.of(active)];
+            if (editor.state.field(snippetState, false) === undefined)
+                effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme$1]));
+        }
+        editor.dispatch(editor.state.update(spec));
+    };
+}
+function moveField(dir) {
+    return ({ state, dispatch }) => {
+        let active = state.field(snippetState, false);
+        if (!active || dir < 0 && active.active == 0)
+            return false;
+        let next = active.active + dir, last = dir > 0 && !active.ranges.some(r => r.field == next + dir);
+        dispatch(state.update({
+            selection: fieldSelection(active.ranges, next),
+            effects: setActive.of(last ? null : new ActiveSnippet(active.ranges, next)),
+            scrollIntoView: true
+        }));
+        return true;
+    };
+}
+/**
+A command that clears the active snippet, if any.
+*/
+const clearSnippet = ({ state, dispatch }) => {
+    let active = state.field(snippetState, false);
+    if (!active)
+        return false;
+    dispatch(state.update({ effects: setActive.of(null) }));
+    return true;
+};
+/**
+Move to the next snippet field, if available.
+*/
+const nextSnippetField = /*@__PURE__*/moveField(1);
+/**
+Move to the previous snippet field, if available.
+*/
+const prevSnippetField = /*@__PURE__*/moveField(-1);
+const defaultSnippetKeymap = [
+    { key: "Tab", run: nextSnippetField, shift: prevSnippetField },
+    { key: "Escape", run: clearSnippet }
+];
+/**
+A facet that can be used to configure the key bindings used by
+snippets. The default binds Tab to
+[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
+[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
+to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
+*/
+const snippetKeymap = /*@__PURE__*/Facet.define({
+    combine(maps) { return maps.length ? maps[0] : defaultSnippetKeymap; }
+});
+const addSnippetKeymap = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.compute([snippetKeymap], state => state.facet(snippetKeymap)));
+/**
+Create a completion from a snippet. Returns an object with the
+properties from `completion`, plus an `apply` function that
+applies the snippet.
+*/
+function snippetCompletion(template, completion) {
+    return Object.assign(Object.assign({}, completion), { apply: snippet(template) });
+}
+const snippetPointerHandler = /*@__PURE__*/EditorView.domEventHandlers({
+    mousedown(event, view) {
+        let active = view.state.field(snippetState, false), pos;
+        if (!active || (pos = view.posAtCoords({ x: event.clientX, y: event.clientY })) == null)
+            return false;
+        let match = active.ranges.find(r => r.from <= pos && r.to >= pos);
+        if (!match || match.field == active.active)
+            return false;
+        view.dispatch({
+            selection: fieldSelection(active.ranges, match.field),
+            effects: setActive.of(active.ranges.some(r => r.field > match.field)
+                ? new ActiveSnippet(active.ranges, match.field) : null),
+            scrollIntoView: true
+        });
+        return true;
+    }
+});
+
+const defaults = {
+    brackets: ["(", "[", "{", "'", '"'],
+    before: ")]}:;>",
+    stringPrefixes: []
+};
+const closeBracketEffect = /*@__PURE__*/StateEffect.define({
+    map(value, mapping) {
+        let mapped = mapping.mapPos(value, -1, MapMode.TrackAfter);
+        return mapped == null ? undefined : mapped;
+    }
+});
+const closedBracket = /*@__PURE__*/new class extends RangeValue {
+};
+closedBracket.startSide = 1;
+closedBracket.endSide = -1;
+const bracketState = /*@__PURE__*/StateField.define({
+    create() { return RangeSet.empty; },
+    update(value, tr) {
+        value = value.map(tr.changes);
+        if (tr.selection) {
+            let line = tr.state.doc.lineAt(tr.selection.main.head);
+            value = value.update({ filter: from => from >= line.from && from <= line.to });
+        }
+        for (let effect of tr.effects)
+            if (effect.is(closeBracketEffect))
+                value = value.update({ add: [closedBracket.range(effect.value, effect.value + 1)] });
+        return value;
+    }
+});
+/**
+Extension to enable bracket-closing behavior. When a closeable
+bracket is typed, its closing bracket is immediately inserted
+after the cursor. When closing a bracket directly in front of a
+closing bracket inserted by the extension, the cursor moves over
+that bracket.
+*/
+function closeBrackets() {
+    return [inputHandler, bracketState];
+}
+const definedClosing = "()[]{}<>";
+function closing(ch) {
+    for (let i = 0; i < definedClosing.length; i += 2)
+        if (definedClosing.charCodeAt(i) == ch)
+            return definedClosing.charAt(i + 1);
+    return fromCodePoint(ch < 128 ? ch : ch + 1);
+}
+function config(state, pos) {
+    return state.languageDataAt("closeBrackets", pos)[0] || defaults;
+}
+const android$1 = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
+const inputHandler = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, insert) => {
+    if ((android$1 ? view.composing : view.compositionStarted) || view.state.readOnly)
+        return false;
+    let sel = view.state.selection.main;
+    if (insert.length > 2 || insert.length == 2 && codePointSize(codePointAt(insert, 0)) == 1 ||
+        from != sel.from || to != sel.to)
+        return false;
+    let tr = insertBracket(view.state, insert);
+    if (!tr)
+        return false;
+    view.dispatch(tr);
+    return true;
+});
+/**
+Command that implements deleting a pair of matching brackets when
+the cursor is between them.
+*/
+const deleteBracketPair = ({ state, dispatch }) => {
+    if (state.readOnly)
+        return false;
+    let conf = config(state, state.selection.main.head);
+    let tokens = conf.brackets || defaults.brackets;
+    let dont = null, changes = state.changeByRange(range => {
+        if (range.empty) {
+            let before = prevChar(state.doc, range.head);
+            for (let token of tokens) {
+                if (token == before && nextChar(state.doc, range.head) == closing(codePointAt(token, 0)))
+                    return { changes: { from: range.head - token.length, to: range.head + token.length },
+                        range: EditorSelection.cursor(range.head - token.length) };
+            }
+        }
+        return { range: dont = range };
+    });
+    if (!dont)
+        dispatch(state.update(changes, { scrollIntoView: true, userEvent: "delete.backward" }));
+    return !dont;
+};
+/**
+Close-brackets related key bindings. Binds Backspace to
+[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
+*/
+const closeBracketsKeymap = [
+    { key: "Backspace", run: deleteBracketPair }
+];
+/**
+Implements the extension's behavior on text insertion. If the
+given string counts as a bracket in the language around the
+selection, and replacing the selection with it requires custom
+behavior (inserting a closing version or skipping past a
+previously-closed bracket), this function returns a transaction
+representing that custom behavior. (You only need this if you want
+to programmatically insert brackets—the
+[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
+take care of running this for user input.)
+*/
+function insertBracket(state, bracket) {
+    let conf = config(state, state.selection.main.head);
+    let tokens = conf.brackets || defaults.brackets;
+    for (let tok of tokens) {
+        let closed = closing(codePointAt(tok, 0));
+        if (bracket == tok)
+            return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1, conf)
+                : handleOpen(state, tok, closed, conf.before || defaults.before);
+        if (bracket == closed && closedBracketAt(state, state.selection.main.from))
+            return handleClose(state, tok, closed);
+    }
+    return null;
+}
+function closedBracketAt(state, pos) {
+    let found = false;
+    state.field(bracketState).between(0, state.doc.length, from => {
+        if (from == pos)
+            found = true;
+    });
+    return found;
+}
+function nextChar(doc, pos) {
+    let next = doc.sliceString(pos, pos + 2);
+    return next.slice(0, codePointSize(codePointAt(next, 0)));
+}
+function prevChar(doc, pos) {
+    let prev = doc.sliceString(pos - 2, pos);
+    return codePointSize(codePointAt(prev, 0)) == prev.length ? prev : prev.slice(1);
+}
+function handleOpen(state, open, close, closeBefore) {
+    let dont = null, changes = state.changeByRange(range => {
+        if (!range.empty)
+            return { changes: [{ insert: open, from: range.from }, { insert: close, from: range.to }],
+                effects: closeBracketEffect.of(range.to + open.length),
+                range: EditorSelection.range(range.anchor + open.length, range.head + open.length) };
+        let next = nextChar(state.doc, range.head);
+        if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1)
+            return { changes: { insert: open + close, from: range.head },
+                effects: closeBracketEffect.of(range.head + open.length),
+                range: EditorSelection.cursor(range.head + open.length) };
+        return { range: dont = range };
+    });
+    return dont ? null : state.update(changes, {
+        scrollIntoView: true,
+        userEvent: "input.type"
+    });
+}
+function handleClose(state, _open, close) {
+    let dont = null, changes = state.changeByRange(range => {
+        if (range.empty && nextChar(state.doc, range.head) == close)
+            return { changes: { from: range.head, to: range.head + close.length, insert: close },
+                range: EditorSelection.cursor(range.head + close.length) };
+        return dont = { range };
+    });
+    return dont ? null : state.update(changes, {
+        scrollIntoView: true,
+        userEvent: "input.type"
+    });
+}
+// Handles cases where the open and close token are the same, and
+// possibly triple quotes (as in `"""abc"""`-style quoting).
+function handleSame(state, token, allowTriple, config) {
+    let stringPrefixes = config.stringPrefixes || defaults.stringPrefixes;
+    let dont = null, changes = state.changeByRange(range => {
+        if (!range.empty)
+            return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }],
+                effects: closeBracketEffect.of(range.to + token.length),
+                range: EditorSelection.range(range.anchor + token.length, range.head + token.length) };
+        let pos = range.head, next = nextChar(state.doc, pos), start;
+        if (next == token) {
+            if (nodeStart(state, pos)) {
+                return { changes: { insert: token + token, from: pos },
+                    effects: closeBracketEffect.of(pos + token.length),
+                    range: EditorSelection.cursor(pos + token.length) };
+            }
+            else if (closedBracketAt(state, pos)) {
+                let isTriple = allowTriple && state.sliceDoc(pos, pos + token.length * 3) == token + token + token;
+                let content = isTriple ? token + token + token : token;
+                return { changes: { from: pos, to: pos + content.length, insert: content },
+                    range: EditorSelection.cursor(pos + content.length) };
+            }
+        }
+        else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token &&
+            (start = canStartStringAt(state, pos - 2 * token.length, stringPrefixes)) > -1 &&
+            nodeStart(state, start)) {
+            return { changes: { insert: token + token + token + token, from: pos },
+                effects: closeBracketEffect.of(pos + token.length),
+                range: EditorSelection.cursor(pos + token.length) };
+        }
+        else if (state.charCategorizer(pos)(next) != CharCategory.Word) {
+            if (canStartStringAt(state, pos, stringPrefixes) > -1 && !probablyInString(state, pos, token, stringPrefixes))
+                return { changes: { insert: token + token, from: pos },
+                    effects: closeBracketEffect.of(pos + token.length),
+                    range: EditorSelection.cursor(pos + token.length) };
+        }
+        return { range: dont = range };
+    });
+    return dont ? null : state.update(changes, {
+        scrollIntoView: true,
+        userEvent: "input.type"
+    });
+}
+function nodeStart(state, pos) {
+    let tree = syntaxTree(state).resolveInner(pos + 1);
+    return tree.parent && tree.from == pos;
+}
+function probablyInString(state, pos, quoteToken, prefixes) {
+    let node = syntaxTree(state).resolveInner(pos, -1);
+    let maxPrefix = prefixes.reduce((m, p) => Math.max(m, p.length), 0);
+    for (let i = 0; i < 5; i++) {
+        let start = state.sliceDoc(node.from, Math.min(node.to, node.from + quoteToken.length + maxPrefix));
+        let quotePos = start.indexOf(quoteToken);
+        if (!quotePos || quotePos > -1 && prefixes.indexOf(start.slice(0, quotePos)) > -1) {
+            let first = node.firstChild;
+            while (first && first.from == node.from && first.to - first.from > quoteToken.length + quotePos) {
+                if (state.sliceDoc(first.to - quoteToken.length, first.to) == quoteToken)
+                    return false;
+                first = first.firstChild;
+            }
+            return true;
+        }
+        let parent = node.to == pos && node.parent;
+        if (!parent)
+            break;
+        node = parent;
+    }
+    return false;
+}
+function canStartStringAt(state, pos, prefixes) {
+    let charCat = state.charCategorizer(pos);
+    if (charCat(state.sliceDoc(pos - 1, pos)) != CharCategory.Word)
+        return pos;
+    for (let prefix of prefixes) {
+        let start = pos - prefix.length;
+        if (state.sliceDoc(start, pos) == prefix && charCat(state.sliceDoc(start - 1, start)) != CharCategory.Word)
+            return start;
+    }
+    return -1;
+}
+
+/**
+Returns an extension that enables autocompletion.
+*/
+function autocompletion(config = {}) {
+    return [
+        commitCharacters,
+        completionState,
+        completionConfig.of(config),
+        completionPlugin,
+        completionKeymapExt,
+        baseTheme$1
+    ];
+}
+/**
+Basic keybindings for autocompletion.
+
+ - Ctrl-Space (and Alt-\` on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
+ - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
+ - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
+ - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
+ - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
+ - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
+ - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
+*/
+const completionKeymap = [
+    { key: "Ctrl-Space", run: startCompletion },
+    { mac: "Alt-`", run: startCompletion },
+    { key: "Escape", run: closeCompletion },
+    { key: "ArrowDown", run: /*@__PURE__*/moveCompletionSelection(true) },
+    { key: "ArrowUp", run: /*@__PURE__*/moveCompletionSelection(false) },
+    { key: "PageDown", run: /*@__PURE__*/moveCompletionSelection(true, "page") },
+    { key: "PageUp", run: /*@__PURE__*/moveCompletionSelection(false, "page") },
+    { key: "Enter", run: acceptCompletion }
+];
+const completionKeymapExt = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
+
+class SelectedDiagnostic {
+    constructor(from, to, diagnostic) {
+        this.from = from;
+        this.to = to;
+        this.diagnostic = diagnostic;
+    }
+}
+class LintState {
+    constructor(diagnostics, panel, selected) {
+        this.diagnostics = diagnostics;
+        this.panel = panel;
+        this.selected = selected;
+    }
+    static init(diagnostics, panel, state) {
+        // Filter the list of diagnostics for which to create markers
+        let markedDiagnostics = diagnostics;
+        let diagnosticFilter = state.facet(lintConfig).markerFilter;
+        if (diagnosticFilter)
+            markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
+        let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
+        let deco = new RangeSetBuilder(), active = [], pos = 0;
+        for (let i = 0;;) {
+            let next = i == sorted.length ? null : sorted[i];
+            if (!next && !active.length)
+                break;
+            let from, to;
+            if (active.length) {
+                from = pos;
+                to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8);
+            }
+            else {
+                from = next.from;
+                to = next.to;
+                active.push(next);
+                i++;
+            }
+            while (i < sorted.length) {
+                let next = sorted[i];
+                if (next.from == from && (next.to > next.from || next.to == from)) {
+                    active.push(next);
+                    i++;
+                    to = Math.min(next.to, to);
+                }
+                else {
+                    to = Math.min(next.from, to);
+                    break;
+                }
+            }
+            let sev = maxSeverity(active);
+            if (active.some(d => d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from))) {
+                deco.add(from, from, Decoration.widget({
+                    widget: new DiagnosticWidget(sev),
+                    diagnostics: active.slice()
+                }));
+            }
+            else {
+                let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, "");
+                deco.add(from, to, Decoration.mark({
+                    class: "cm-lintRange cm-lintRange-" + sev + markClass,
+                    diagnostics: active.slice(),
+                    inclusiveEnd: active.some(a => a.to > to)
+                }));
+            }
+            pos = to;
+            for (let i = 0; i < active.length; i++)
+                if (active[i].to <= pos)
+                    active.splice(i--, 1);
+        }
+        let set = deco.finish();
+        return new LintState(set, panel, findDiagnostic(set));
+    }
+}
+function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
+    let found = null;
+    diagnostics.between(after, 1e9, (from, to, { spec }) => {
+        if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0)
+            return;
+        if (!found)
+            found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]);
+        else if (spec.diagnostics.indexOf(found.diagnostic) < 0)
+            return false;
+        else
+            found = new SelectedDiagnostic(found.from, to, found.diagnostic);
+    });
+    return found;
+}
+function hideTooltip(tr, tooltip) {
+    let from = tooltip.pos, to = tooltip.end || from;
+    let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
+    if (result != null)
+        return result;
+    let line = tr.startState.doc.lineAt(tooltip.pos);
+    return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
+}
+function maybeEnableLint(state, effects) {
+    return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
+}
+/**
+The state effect that updates the set of active diagnostics. Can
+be useful when writing an extension that needs to track these.
+*/
+const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
+const togglePanel = /*@__PURE__*/StateEffect.define();
+const movePanelSelection = /*@__PURE__*/StateEffect.define();
+const lintState = /*@__PURE__*/StateField.define({
+    create() {
+        return new LintState(Decoration.none, null, null);
+    },
+    update(value, tr) {
+        if (tr.docChanged && value.diagnostics.size) {
+            let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
+            if (value.selected) {
+                let selPos = tr.changes.mapPos(value.selected.from, 1);
+                selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
+            }
+            if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel)
+                panel = null;
+            value = new LintState(mapped, panel, selected);
+        }
+        for (let effect of tr.effects) {
+            if (effect.is(setDiagnosticsEffect)) {
+                let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
+                value = LintState.init(effect.value, panel, tr.state);
+            }
+            else if (effect.is(togglePanel)) {
+                value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
+            }
+            else if (effect.is(movePanelSelection)) {
+                value = new LintState(value.diagnostics, value.panel, effect.value);
+            }
+        }
+        return value;
+    },
+    provide: f => [showPanel.from(f, val => val.panel),
+        EditorView.decorations.from(f, s => s.diagnostics)]
+});
+const activeMark = /*@__PURE__*/Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
+function lintTooltip(view, pos, side) {
+    let { diagnostics } = view.state.field(lintState);
+    let found, start = -1, end = -1;
+    diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
+        if (pos >= from && pos <= to &&
+            (from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
+            found = spec.diagnostics;
+            start = from;
+            end = to;
+            return false;
+        }
+    });
+    let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
+    if (found && diagnosticFilter)
+        found = diagnosticFilter(found, view.state);
+    if (!found)
+        return null;
+    return {
+        pos: start,
+        end: end,
+        above: view.state.doc.lineAt(start).to < end,
+        create() {
+            return { dom: diagnosticsTooltip(view, found) };
+        }
+    };
+}
+function diagnosticsTooltip(view, diagnostics) {
+    return crelt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
+}
+/**
+Command to open and focus the lint panel.
+*/
+const openLintPanel = (view) => {
+    let field = view.state.field(lintState, false);
+    if (!field || !field.panel)
+        view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) });
+    let panel = getPanel(view, LintPanel.open);
+    if (panel)
+        panel.dom.querySelector(".cm-panel-lint ul").focus();
+    return true;
+};
+/**
+Command to close the lint panel, when open.
+*/
+const closeLintPanel = (view) => {
+    let field = view.state.field(lintState, false);
+    if (!field || !field.panel)
+        return false;
+    view.dispatch({ effects: togglePanel.of(false) });
+    return true;
+};
+/**
+Move the selection to the next diagnostic.
+*/
+const nextDiagnostic = (view) => {
+    let field = view.state.field(lintState, false);
+    if (!field)
+        return false;
+    let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1);
+    if (!next.value) {
+        next = field.diagnostics.iter(0);
+        if (!next.value || next.from == sel.from && next.to == sel.to)
+            return false;
+    }
+    view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true });
+    return true;
+};
+/**
+A set of default key bindings for the lint functionality.
+
+- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
+- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
+*/
+const lintKeymap = [
+    { key: "Mod-Shift-m", run: openLintPanel, preventDefault: true },
+    { key: "F8", run: nextDiagnostic }
+];
+const lintConfig = /*@__PURE__*/Facet.define({
+    combine(input) {
+        return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
+            delay: 750,
+            markerFilter: null,
+            tooltipFilter: null,
+            needsRefresh: null,
+            hideOn: () => null,
+        }, {
+            needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
+        }));
+    }
+});
+function assignKeys(actions) {
+    let assigned = [];
+    if (actions)
+        actions: for (let { name } of actions) {
+            for (let i = 0; i < name.length; i++) {
+                let ch = name[i];
+                if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
+                    assigned.push(ch);
+                    continue actions;
+                }
+            }
+            assigned.push("");
+        }
+    return assigned;
+}
+function renderDiagnostic(view, diagnostic, inPanel) {
+    var _a;
+    let keys = inPanel ? assignKeys(diagnostic.actions) : [];
+    return crelt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, crelt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
+        let fired = false, click = (e) => {
+            e.preventDefault();
+            if (fired)
+                return;
+            fired = true;
+            let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
+            if (found)
+                action.apply(view, found.from, found.to);
+        };
+        let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
+        let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
+            crelt("u", name.slice(keyIndex, keyIndex + 1)),
+            name.slice(keyIndex + 1)];
+        return crelt("button", {
+            type: "button",
+            class: "cm-diagnosticAction",
+            onclick: click,
+            onmousedown: click,
+            "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
+        }, nameElt);
+    }), diagnostic.source && crelt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
+}
+class DiagnosticWidget extends WidgetType {
+    constructor(sev) {
+        super();
+        this.sev = sev;
+    }
+    eq(other) { return other.sev == this.sev; }
+    toDOM() {
+        return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
+    }
+}
+class PanelItem {
+    constructor(view, diagnostic) {
+        this.diagnostic = diagnostic;
+        this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
+        this.dom = renderDiagnostic(view, diagnostic, true);
+        this.dom.id = this.id;
+        this.dom.setAttribute("role", "option");
+    }
+}
+class LintPanel {
+    constructor(view) {
+        this.view = view;
+        this.items = [];
+        let onkeydown = (event) => {
+            if (event.keyCode == 27) { // Escape
+                closeLintPanel(this.view);
+                this.view.focus();
+            }
+            else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
+                this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
+            }
+            else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
+                this.moveSelection((this.selectedIndex + 1) % this.items.length);
+            }
+            else if (event.keyCode == 36) { // Home
+                this.moveSelection(0);
+            }
+            else if (event.keyCode == 35) { // End
+                this.moveSelection(this.items.length - 1);
+            }
+            else if (event.keyCode == 13) { // Enter
+                this.view.focus();
+            }
+            else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
+                let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions);
+                for (let i = 0; i < keys.length; i++)
+                    if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
+                        let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
+                        if (found)
+                            diagnostic.actions[i].apply(view, found.from, found.to);
+                    }
+            }
+            else {
+                return;
+            }
+            event.preventDefault();
+        };
+        let onclick = (event) => {
+            for (let i = 0; i < this.items.length; i++) {
+                if (this.items[i].dom.contains(event.target))
+                    this.moveSelection(i);
+            }
+        };
+        this.list = crelt("ul", {
+            tabIndex: 0,
+            role: "listbox",
+            "aria-label": this.view.state.phrase("Diagnostics"),
+            onkeydown,
+            onclick
+        });
+        this.dom = crelt("div", { class: "cm-panel-lint" }, this.list, crelt("button", {
+            type: "button",
+            name: "close",
+            "aria-label": this.view.state.phrase("close"),
+            onclick: () => closeLintPanel(this.view)
+        }, "×"));
+        this.update();
+    }
+    get selectedIndex() {
+        let selected = this.view.state.field(lintState).selected;
+        if (!selected)
+            return -1;
+        for (let i = 0; i < this.items.length; i++)
+            if (this.items[i].diagnostic == selected.diagnostic)
+                return i;
+        return -1;
+    }
+    update() {
+        let { diagnostics, selected } = this.view.state.field(lintState);
+        let i = 0, needsSync = false, newSelectedItem = null;
+        let seen = new Set();
+        diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
+            for (let diagnostic of spec.diagnostics) {
+                if (seen.has(diagnostic))
+                    continue;
+                seen.add(diagnostic);
+                let found = -1, item;
+                for (let j = i; j < this.items.length; j++)
+                    if (this.items[j].diagnostic == diagnostic) {
+                        found = j;
+                        break;
+                    }
+                if (found < 0) {
+                    item = new PanelItem(this.view, diagnostic);
+                    this.items.splice(i, 0, item);
+                    needsSync = true;
+                }
+                else {
+                    item = this.items[found];
+                    if (found > i) {
+                        this.items.splice(i, found - i);
+                        needsSync = true;
+                    }
+                }
+                if (selected && item.diagnostic == selected.diagnostic) {
+                    if (!item.dom.hasAttribute("aria-selected")) {
+                        item.dom.setAttribute("aria-selected", "true");
+                        newSelectedItem = item;
+                    }
+                }
+                else if (item.dom.hasAttribute("aria-selected")) {
+                    item.dom.removeAttribute("aria-selected");
+                }
+                i++;
+            }
+        });
+        while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
+            needsSync = true;
+            this.items.pop();
+        }
+        if (this.items.length == 0) {
+            this.items.push(new PanelItem(this.view, {
+                from: -1, to: -1,
+                severity: "info",
+                message: this.view.state.phrase("No diagnostics")
+            }));
+            needsSync = true;
+        }
+        if (newSelectedItem) {
+            this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
+            this.view.requestMeasure({
+                key: this,
+                read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
+                write: ({ sel, panel }) => {
+                    let scaleY = panel.height / this.list.offsetHeight;
+                    if (sel.top < panel.top)
+                        this.list.scrollTop -= (panel.top - sel.top) / scaleY;
+                    else if (sel.bottom > panel.bottom)
+                        this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY;
+                }
+            });
+        }
+        else if (this.selectedIndex < 0) {
+            this.list.removeAttribute("aria-activedescendant");
+        }
+        if (needsSync)
+            this.sync();
+    }
+    sync() {
+        let domPos = this.list.firstChild;
+        function rm() {
+            let prev = domPos;
+            domPos = prev.nextSibling;
+            prev.remove();
+        }
+        for (let item of this.items) {
+            if (item.dom.parentNode == this.list) {
+                while (domPos != item.dom)
+                    rm();
+                domPos = item.dom.nextSibling;
+            }
+            else {
+                this.list.insertBefore(item.dom, domPos);
+            }
+        }
+        while (domPos)
+            rm();
+    }
+    moveSelection(selectedIndex) {
+        if (this.selectedIndex < 0)
+            return;
+        let field = this.view.state.field(lintState);
+        let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
+        if (!selection)
+            return;
+        this.view.dispatch({
+            selection: { anchor: selection.from, head: selection.to },
+            scrollIntoView: true,
+            effects: movePanelSelection.of(selection)
+        });
+    }
+    static open(view) { return new LintPanel(view); }
+}
+function svg(content, attrs = `viewBox="0 0 40 40"`) {
+    return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
+}
+function underline(color) {
+    return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
+}
+const baseTheme = /*@__PURE__*/EditorView.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: .7
+    },
+    ".cm-lintRange": {
+        backgroundPosition: "left bottom",
+        backgroundRepeat: "repeat-x",
+        paddingBottom: "0.7px",
+    },
+    ".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") },
+    ".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") },
+    ".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") },
+    ".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/underline("#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
+        }
+    }
+});
+function severityWeight(sev) {
+    return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
+}
+function maxSeverity(diagnostics) {
+    let sev = "hint", weight = 1;
+    for (let d of diagnostics) {
+        let w = severityWeight(d.severity);
+        if (w > weight) {
+            weight = w;
+            sev = d.severity;
+        }
+    }
+    return sev;
+}
+class LintGutterMarker extends GutterMarker {
+    constructor(diagnostics) {
+        super();
+        this.diagnostics = diagnostics;
+        this.severity = maxSeverity(diagnostics);
+    }
+    toDOM(view) {
+        let elt = document.createElement("div");
+        elt.className = "cm-lint-marker cm-lint-marker-" + this.severity;
+        let diagnostics = this.diagnostics;
+        let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter;
+        if (diagnosticsFilter)
+            diagnostics = diagnosticsFilter(diagnostics, view.state);
+        if (diagnostics.length)
+            elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics);
+        return elt;
+    }
+}
+function trackHoverOn(view, marker) {
+    let mousemove = (event) => {
+        let rect = marker.getBoundingClientRect();
+        if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
+            event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
+            return;
+        for (let target = event.target; target; target = target.parentNode) {
+            if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
+                return;
+        }
+        window.removeEventListener("mousemove", mousemove);
+        if (view.state.field(lintGutterTooltip))
+            view.dispatch({ effects: setLintGutterTooltip.of(null) });
+    };
+    window.addEventListener("mousemove", mousemove);
+}
+function gutterMarkerMouseOver(view, marker, diagnostics) {
+    function hovered() {
+        let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
+        const linePos = view.coordsAtPos(line.from);
+        if (linePos) {
+            view.dispatch({ effects: setLintGutterTooltip.of({
+                    pos: line.from,
+                    above: false,
+                    clip: false,
+                    create() {
+                        return {
+                            dom: diagnosticsTooltip(view, diagnostics),
+                            getCoords: () => marker.getBoundingClientRect()
+                        };
+                    }
+                }) });
+        }
+        marker.onmouseout = marker.onmousemove = null;
+        trackHoverOn(view, marker);
+    }
+    let { hoverTime } = view.state.facet(lintGutterConfig);
+    let hoverTimeout = setTimeout(hovered, hoverTime);
+    marker.onmouseout = () => {
+        clearTimeout(hoverTimeout);
+        marker.onmouseout = marker.onmousemove = null;
+    };
+    marker.onmousemove = () => {
+        clearTimeout(hoverTimeout);
+        hoverTimeout = setTimeout(hovered, hoverTime);
+    };
+}
+function markersForDiagnostics(doc, diagnostics) {
+    let byLine = Object.create(null);
+    for (let diagnostic of diagnostics) {
+        let line = doc.lineAt(diagnostic.from);
+        (byLine[line.from] || (byLine[line.from] = [])).push(diagnostic);
+    }
+    let markers = [];
+    for (let line in byLine) {
+        markers.push(new LintGutterMarker(byLine[line]).range(+line));
+    }
+    return RangeSet.of(markers, true);
+}
+const lintGutterExtension = /*@__PURE__*/gutter({
+    class: "cm-gutter-lint",
+    markers: view => view.state.field(lintGutterMarkers),
+    widgetMarker: (view, widget, block) => {
+        let diagnostics = [];
+        view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
+            if (from > block.from && from < block.to)
+                diagnostics.push(...value.diagnostics);
+        });
+        return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
+    }
+});
+const lintGutterMarkers = /*@__PURE__*/StateField.define({
+    create() {
+        return RangeSet.empty;
+    },
+    update(markers, tr) {
+        markers = markers.map(tr.changes);
+        let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter;
+        for (let effect of tr.effects) {
+            if (effect.is(setDiagnosticsEffect)) {
+                let diagnostics = effect.value;
+                if (diagnosticFilter)
+                    diagnostics = diagnosticFilter(diagnostics || [], tr.state);
+                markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0));
+            }
+        }
+        return markers;
+    }
+});
+const setLintGutterTooltip = /*@__PURE__*/StateEffect.define();
+const lintGutterTooltip = /*@__PURE__*/StateField.define({
+    create() { return null; },
+    update(tooltip, tr) {
+        if (tooltip && tr.docChanged)
+            tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
+        return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
+    },
+    provide: field => showTooltip.from(field)
+});
+const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
+    ".cm-gutter-lint": {
+        width: "1.4em",
+        "& .cm-gutterElement": {
+            padding: ".2em"
+        }
+    },
+    ".cm-lint-marker": {
+        width: "1em",
+        height: "1em"
+    },
+    ".cm-lint-marker-info": {
+        content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
+    },
+    ".cm-lint-marker-warning": {
+        content: /*@__PURE__*/svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
+    },
+    ".cm-lint-marker-error": {
+        content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
+    },
+});
+const lintExtensions = [
+    lintState,
+    /*@__PURE__*/EditorView.decorations.compute([lintState], state => {
+        let { selected, panel } = state.field(lintState);
+        return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([
+            activeMark.range(selected.from, selected.to)
+        ]);
+    }),
+    /*@__PURE__*/hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
+    baseTheme
+];
+const lintGutterConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        return combineConfig(configs, {
+            hoverTime: 300 /* Hover.Time */,
+            markerFilter: null,
+            tooltipFilter: null
+        });
+    }
+});
+/**
+Returns an extension that installs a gutter showing markers for
+each line that has diagnostics, which can be hovered over to see
+the diagnostics.
+*/
+function lintGutter(config = {}) {
+    return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
+}
+
+/**
+This is an extension value that just pulls together a number of
+extensions that you might want in a basic editor. It is meant as a
+convenient helper to quickly set up CodeMirror without installing
+and importing a lot of separate packages.
+
+Specifically, it includes...
+
+ - [the default command bindings](https://codemirror.net/6/docs/ref/#commands.defaultKeymap)
+ - [line numbers](https://codemirror.net/6/docs/ref/#view.lineNumbers)
+ - [special character highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars)
+ - [the undo history](https://codemirror.net/6/docs/ref/#commands.history)
+ - [a fold gutter](https://codemirror.net/6/docs/ref/#language.foldGutter)
+ - [custom selection drawing](https://codemirror.net/6/docs/ref/#view.drawSelection)
+ - [drop cursor](https://codemirror.net/6/docs/ref/#view.dropCursor)
+ - [multiple selections](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
+ - [reindentation on input](https://codemirror.net/6/docs/ref/#language.indentOnInput)
+ - [the default highlight style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle) (as fallback)
+ - [bracket matching](https://codemirror.net/6/docs/ref/#language.bracketMatching)
+ - [bracket closing](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets)
+ - [autocompletion](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion)
+ - [rectangular selection](https://codemirror.net/6/docs/ref/#view.rectangularSelection) and [crosshair cursor](https://codemirror.net/6/docs/ref/#view.crosshairCursor)
+ - [active line highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLine)
+ - [active line gutter highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLineGutter)
+ - [selection match highlighting](https://codemirror.net/6/docs/ref/#search.highlightSelectionMatches)
+ - [search](https://codemirror.net/6/docs/ref/#search.searchKeymap)
+ - [linting](https://codemirror.net/6/docs/ref/#lint.lintKeymap)
+
+(You'll probably want to add some language package to your setup
+too.)
+
+This package does not allow customization. The idea is that, once
+you decide you want to configure your editor more precisely, you
+take this package's source (which is just a bunch of imports and
+an array literal), copy it into your own code, and adjust it as
+desired.
+*/
+const basicSetup = [
+    /*@__PURE__*/lineNumbers(),
+    /*@__PURE__*/highlightActiveLineGutter(),
+    /*@__PURE__*/highlightSpecialChars(),
+    /*@__PURE__*/history(),
+    /*@__PURE__*/foldGutter(),
+    /*@__PURE__*/drawSelection(),
+    /*@__PURE__*/dropCursor(),
+    /*@__PURE__*/EditorState.allowMultipleSelections.of(true),
+    /*@__PURE__*/indentOnInput(),
+    /*@__PURE__*/syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
+    /*@__PURE__*/bracketMatching(),
+    /*@__PURE__*/closeBrackets(),
+    /*@__PURE__*/autocompletion(),
+    /*@__PURE__*/rectangularSelection(),
+    /*@__PURE__*/crosshairCursor(),
+    /*@__PURE__*/highlightActiveLine(),
+    /*@__PURE__*/highlightSelectionMatches(),
+    /*@__PURE__*/keymap.of([
+        ...closeBracketsKeymap,
+        ...defaultKeymap,
+        ...searchKeymap,
+        ...historyKeymap,
+        ...foldKeymap,
+        ...completionKeymap,
+        ...lintKeymap
+    ])
+];
+
+/**
+A parse stack. These are used internally by the parser to track
+parsing progress. They also provide some properties and methods
+that external code such as a tokenizer can use to get information
+about the parse state.
+*/
+class Stack {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    The parse that this stack is part of @internal
+    */
+    p, 
+    /**
+    Holds state, input pos, buffer index triplets for all but the
+    top state @internal
+    */
+    stack, 
+    /**
+    The current parse state @internal
+    */
+    state, 
+    // The position at which the next reduce should take place. This
+    // can be less than `this.pos` when skipped expressions have been
+    // added to the stack (which should be moved outside of the next
+    // reduction)
+    /**
+    @internal
+    */
+    reducePos, 
+    /**
+    The input position up to which this stack has parsed.
+    */
+    pos, 
+    /**
+    The dynamic score of the stack, including dynamic precedence
+    and error-recovery penalties
+    @internal
+    */
+    score, 
+    // The output buffer. Holds (type, start, end, size) quads
+    // representing nodes created by the parser, where `size` is
+    // amount of buffer array entries covered by this node.
+    /**
+    @internal
+    */
+    buffer, 
+    // The base offset of the buffer. When stacks are split, the split
+    // instance shared the buffer history with its parent up to
+    // `bufferBase`, which is the absolute offset (including the
+    // offset of previous splits) into the buffer at which this stack
+    // starts writing.
+    /**
+    @internal
+    */
+    bufferBase, 
+    /**
+    @internal
+    */
+    curContext, 
+    /**
+    @internal
+    */
+    lookAhead = 0, 
+    // A parent stack from which this was split off, if any. This is
+    // set up so that it always points to a stack that has some
+    // additional buffer content, never to a stack with an equal
+    // `bufferBase`.
+    /**
+    @internal
+    */
+    parent) {
+        this.p = p;
+        this.stack = stack;
+        this.state = state;
+        this.reducePos = reducePos;
+        this.pos = pos;
+        this.score = score;
+        this.buffer = buffer;
+        this.bufferBase = bufferBase;
+        this.curContext = curContext;
+        this.lookAhead = lookAhead;
+        this.parent = parent;
+    }
+    /**
+    @internal
+    */
+    toString() {
+        return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
+    }
+    // Start an empty stack
+    /**
+    @internal
+    */
+    static start(p, state, pos = 0) {
+        let cx = p.parser.context;
+        return new Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
+    }
+    /**
+    The stack's current [context](#lr.ContextTracker) value, if
+    any. Its type will depend on the context tracker's type
+    parameter, or it will be `null` if there is no context
+    tracker.
+    */
+    get context() { return this.curContext ? this.curContext.context : null; }
+    // Push a state onto the stack, tracking its start position as well
+    // as the buffer base at that point.
+    /**
+    @internal
+    */
+    pushState(state, start) {
+        this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
+        this.state = state;
+    }
+    // Apply a reduce action
+    /**
+    @internal
+    */
+    reduce(action) {
+        var _a;
+        let depth = action >> 19 /* Action.ReduceDepthShift */, type = action & 65535 /* Action.ValueMask */;
+        let { parser } = this.p;
+        let lookaheadRecord = this.reducePos < this.pos - 25 /* Lookahead.Margin */;
+        if (lookaheadRecord)
+            this.setLookAhead(this.pos);
+        let dPrec = parser.dynamicPrecedence(type);
+        if (dPrec)
+            this.score += dPrec;
+        if (depth == 0) {
+            this.pushState(parser.getGoto(this.state, type, true), this.reducePos);
+            // Zero-depth reductions are a special case—they add stuff to
+            // the stack without popping anything off.
+            if (type < parser.minRepeatTerm)
+                this.storeNode(type, this.reducePos, this.reducePos, lookaheadRecord ? 8 : 4, true);
+            this.reduceContext(type, this.reducePos);
+            return;
+        }
+        // Find the base index into `this.stack`, content after which will
+        // be dropped. Note that with `StayFlag` reductions we need to
+        // consume two extra frames (the dummy parent node for the skipped
+        // expression and the state that we'll be staying in, which should
+        // be moved to `this.state`).
+        let base = this.stack.length - ((depth - 1) * 3) - (action & 262144 /* Action.StayFlag */ ? 6 : 0);
+        let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start;
+        // This is a kludge to try and detect overly deep left-associative
+        // trees, which will not increase the parse stack depth and thus
+        // won't be caught by the regular stack-depth limit check.
+        if (size >= 2000 /* Recover.MinBigReduction */ && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) {
+            if (start == this.p.lastBigReductionStart) {
+                this.p.bigReductionCount++;
+                this.p.lastBigReductionSize = size;
+            }
+            else if (this.p.lastBigReductionSize < size) {
+                this.p.bigReductionCount = 1;
+                this.p.lastBigReductionStart = start;
+                this.p.lastBigReductionSize = size;
+            }
+        }
+        let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
+        // Store normal terms or `R -> R R` repeat reductions
+        if (type < parser.minRepeatTerm || (action & 131072 /* Action.RepeatFlag */)) {
+            let pos = parser.stateFlag(this.state, 1 /* StateFlag.Skipped */) ? this.pos : this.reducePos;
+            this.storeNode(type, start, pos, count + 4, true);
+        }
+        if (action & 262144 /* Action.StayFlag */) {
+            this.state = this.stack[base];
+        }
+        else {
+            let baseStateID = this.stack[base - 3];
+            this.state = parser.getGoto(baseStateID, type, true);
+        }
+        while (this.stack.length > base)
+            this.stack.pop();
+        this.reduceContext(type, start);
+    }
+    // Shift a value into the buffer
+    /**
+    @internal
+    */
+    storeNode(term, start, end, size = 4, mustSink = false) {
+        if (term == 0 /* Term.Err */ &&
+            (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
+            // Try to omit/merge adjacent error nodes
+            let cur = this, top = this.buffer.length;
+            if (top == 0 && cur.parent) {
+                top = cur.bufferBase - cur.parent.bufferBase;
+                cur = cur.parent;
+            }
+            if (top > 0 && cur.buffer[top - 4] == 0 /* Term.Err */ && cur.buffer[top - 1] > -1) {
+                if (start == end)
+                    return;
+                if (cur.buffer[top - 2] >= start) {
+                    cur.buffer[top - 2] = end;
+                    return;
+                }
+            }
+        }
+        if (!mustSink || this.pos == end) { // Simple case, just append
+            this.buffer.push(term, start, end, size);
+        }
+        else { // There may be skipped nodes that have to be moved forward
+            let index = this.buffer.length;
+            if (index > 0 && this.buffer[index - 4] != 0 /* Term.Err */) {
+                let mustMove = false;
+                for (let scan = index; scan > 0 && this.buffer[scan - 2] > end; scan -= 4) {
+                    if (this.buffer[scan - 1] >= 0) {
+                        mustMove = true;
+                        break;
+                    }
+                }
+                if (mustMove)
+                    while (index > 0 && this.buffer[index - 2] > end) {
+                        // Move this record forward
+                        this.buffer[index] = this.buffer[index - 4];
+                        this.buffer[index + 1] = this.buffer[index - 3];
+                        this.buffer[index + 2] = this.buffer[index - 2];
+                        this.buffer[index + 3] = this.buffer[index - 1];
+                        index -= 4;
+                        if (size > 4)
+                            size -= 4;
+                    }
+            }
+            this.buffer[index] = term;
+            this.buffer[index + 1] = start;
+            this.buffer[index + 2] = end;
+            this.buffer[index + 3] = size;
+        }
+    }
+    // Apply a shift action
+    /**
+    @internal
+    */
+    shift(action, type, start, end) {
+        if (action & 131072 /* Action.GotoFlag */) {
+            this.pushState(action & 65535 /* Action.ValueMask */, this.pos);
+        }
+        else if ((action & 262144 /* Action.StayFlag */) == 0) { // Regular shift
+            let nextState = action, { parser } = this.p;
+            if (end > this.pos || type <= parser.maxNode) {
+                this.pos = end;
+                if (!parser.stateFlag(nextState, 1 /* StateFlag.Skipped */))
+                    this.reducePos = end;
+            }
+            this.pushState(nextState, start);
+            this.shiftContext(type, start);
+            if (type <= parser.maxNode)
+                this.buffer.push(type, start, end, 4);
+        }
+        else { // Shift-and-stay, which means this is a skipped token
+            this.pos = end;
+            this.shiftContext(type, start);
+            if (type <= this.p.parser.maxNode)
+                this.buffer.push(type, start, end, 4);
+        }
+    }
+    // Apply an action
+    /**
+    @internal
+    */
+    apply(action, next, nextStart, nextEnd) {
+        if (action & 65536 /* Action.ReduceFlag */)
+            this.reduce(action);
+        else
+            this.shift(action, next, nextStart, nextEnd);
+    }
+    // Add a prebuilt (reused) node into the buffer.
+    /**
+    @internal
+    */
+    useNode(value, next) {
+        let index = this.p.reused.length - 1;
+        if (index < 0 || this.p.reused[index] != value) {
+            this.p.reused.push(value);
+            index++;
+        }
+        let start = this.pos;
+        this.reducePos = this.pos = start + value.length;
+        this.pushState(next, start);
+        this.buffer.push(index, start, this.reducePos, -1 /* size == -1 means this is a reused value */);
+        if (this.curContext)
+            this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
+    }
+    // Split the stack. Due to the buffer sharing and the fact
+    // that `this.stack` tends to stay quite shallow, this isn't very
+    // expensive.
+    /**
+    @internal
+    */
+    split() {
+        let parent = this;
+        let off = parent.buffer.length;
+        // Because the top of the buffer (after this.pos) may be mutated
+        // to reorder reductions and skipped tokens, and shared buffers
+        // should be immutable, this copies any outstanding skipped tokens
+        // to the new buffer, and puts the base pointer before them.
+        while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
+            off -= 4;
+        let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
+        // Make sure parent points to an actual parent with content, if there is such a parent.
+        while (parent && base == parent.bufferBase)
+            parent = parent.parent;
+        return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
+    }
+    // Try to recover from an error by 'deleting' (ignoring) one token.
+    /**
+    @internal
+    */
+    recoverByDelete(next, nextEnd) {
+        let isNode = next <= this.p.parser.maxNode;
+        if (isNode)
+            this.storeNode(next, this.pos, nextEnd, 4);
+        this.storeNode(0 /* Term.Err */, this.pos, nextEnd, isNode ? 8 : 4);
+        this.pos = this.reducePos = nextEnd;
+        this.score -= 190 /* Recover.Delete */;
+    }
+    /**
+    Check if the given term would be able to be shifted (optionally
+    after some reductions) on this stack. This can be useful for
+    external tokenizers that want to make sure they only provide a
+    given token when it applies.
+    */
+    canShift(term) {
+        for (let sim = new SimulatedStack(this);;) {
+            let action = this.p.parser.stateSlot(sim.state, 4 /* ParseState.DefaultReduce */) || this.p.parser.hasAction(sim.state, term);
+            if (action == 0)
+                return false;
+            if ((action & 65536 /* Action.ReduceFlag */) == 0)
+                return true;
+            sim.reduce(action);
+        }
+    }
+    // Apply up to Recover.MaxNext recovery actions that conceptually
+    // inserts some missing token or rule.
+    /**
+    @internal
+    */
+    recoverByInsert(next) {
+        if (this.stack.length >= 300 /* Recover.MaxInsertStackDepth */)
+            return [];
+        let nextStates = this.p.parser.nextStates(this.state);
+        if (nextStates.length > 4 /* Recover.MaxNext */ << 1 || this.stack.length >= 120 /* Recover.DampenInsertStackDepth */) {
+            let best = [];
+            for (let i = 0, s; i < nextStates.length; i += 2) {
+                if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
+                    best.push(nextStates[i], s);
+            }
+            if (this.stack.length < 120 /* Recover.DampenInsertStackDepth */)
+                for (let i = 0; best.length < 4 /* Recover.MaxNext */ << 1 && i < nextStates.length; i += 2) {
+                    let s = nextStates[i + 1];
+                    if (!best.some((v, i) => (i & 1) && v == s))
+                        best.push(nextStates[i], s);
+                }
+            nextStates = best;
+        }
+        let result = [];
+        for (let i = 0; i < nextStates.length && result.length < 4 /* Recover.MaxNext */; i += 2) {
+            let s = nextStates[i + 1];
+            if (s == this.state)
+                continue;
+            let stack = this.split();
+            stack.pushState(s, this.pos);
+            stack.storeNode(0 /* Term.Err */, stack.pos, stack.pos, 4, true);
+            stack.shiftContext(nextStates[i], this.pos);
+            stack.reducePos = this.pos;
+            stack.score -= 200 /* Recover.Insert */;
+            result.push(stack);
+        }
+        return result;
+    }
+    // Force a reduce, if possible. Return false if that can't
+    // be done.
+    /**
+    @internal
+    */
+    forceReduce() {
+        let { parser } = this.p;
+        let reduce = parser.stateSlot(this.state, 5 /* ParseState.ForcedReduce */);
+        if ((reduce & 65536 /* Action.ReduceFlag */) == 0)
+            return false;
+        if (!parser.validAction(this.state, reduce)) {
+            let depth = reduce >> 19 /* Action.ReduceDepthShift */, term = reduce & 65535 /* Action.ValueMask */;
+            let target = this.stack.length - depth * 3;
+            if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) {
+                let backup = this.findForcedReduction();
+                if (backup == null)
+                    return false;
+                reduce = backup;
+            }
+            this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
+            this.score -= 100 /* Recover.Reduce */;
+        }
+        this.reducePos = this.pos;
+        this.reduce(reduce);
+        return true;
+    }
+    /**
+    Try to scan through the automaton to find some kind of reduction
+    that can be applied. Used when the regular ForcedReduce field
+    isn't a valid action. @internal
+    */
+    findForcedReduction() {
+        let { parser } = this.p, seen = [];
+        let explore = (state, depth) => {
+            if (seen.includes(state))
+                return;
+            seen.push(state);
+            return parser.allActions(state, (action) => {
+                if (action & (262144 /* Action.StayFlag */ | 131072 /* Action.GotoFlag */)) ;
+                else if (action & 65536 /* Action.ReduceFlag */) {
+                    let rDepth = (action >> 19 /* Action.ReduceDepthShift */) - depth;
+                    if (rDepth > 1) {
+                        let term = action & 65535 /* Action.ValueMask */, target = this.stack.length - rDepth * 3;
+                        if (target >= 0 && parser.getGoto(this.stack[target], term, false) >= 0)
+                            return (rDepth << 19 /* Action.ReduceDepthShift */) | 65536 /* Action.ReduceFlag */ | term;
+                    }
+                }
+                else {
+                    let found = explore(action, depth + 1);
+                    if (found != null)
+                        return found;
+                }
+            });
+        };
+        return explore(this.state, 0);
+    }
+    /**
+    @internal
+    */
+    forceAll() {
+        while (!this.p.parser.stateFlag(this.state, 2 /* StateFlag.Accepting */)) {
+            if (!this.forceReduce()) {
+                this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
+                break;
+            }
+        }
+        return this;
+    }
+    /**
+    Check whether this state has no further actions (assumed to be a direct descendant of the
+    top state, since any other states must be able to continue
+    somehow). @internal
+    */
+    get deadEnd() {
+        if (this.stack.length != 3)
+            return false;
+        let { parser } = this.p;
+        return parser.data[parser.stateSlot(this.state, 1 /* ParseState.Actions */)] == 65535 /* Seq.End */ &&
+            !parser.stateSlot(this.state, 4 /* ParseState.DefaultReduce */);
+    }
+    /**
+    Restart the stack (put it back in its start state). Only safe
+    when this.stack.length == 3 (state is directly below the top
+    state). @internal
+    */
+    restart() {
+        this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
+        this.state = this.stack[0];
+        this.stack.length = 0;
+    }
+    /**
+    @internal
+    */
+    sameState(other) {
+        if (this.state != other.state || this.stack.length != other.stack.length)
+            return false;
+        for (let i = 0; i < this.stack.length; i += 3)
+            if (this.stack[i] != other.stack[i])
+                return false;
+        return true;
+    }
+    /**
+    Get the parser used by this stack.
+    */
+    get parser() { return this.p.parser; }
+    /**
+    Test whether a given dialect (by numeric ID, as exported from
+    the terms file) is enabled.
+    */
+    dialectEnabled(dialectID) { return this.p.parser.dialect.flags[dialectID]; }
+    shiftContext(term, start) {
+        if (this.curContext)
+            this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
+    }
+    reduceContext(term, start) {
+        if (this.curContext)
+            this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
+    }
+    /**
+    @internal
+    */
+    emitContext() {
+        let last = this.buffer.length - 1;
+        if (last < 0 || this.buffer[last] != -3)
+            this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
+    }
+    /**
+    @internal
+    */
+    emitLookAhead() {
+        let last = this.buffer.length - 1;
+        if (last < 0 || this.buffer[last] != -4)
+            this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
+    }
+    updateContext(context) {
+        if (context != this.curContext.context) {
+            let newCx = new StackContext(this.curContext.tracker, context);
+            if (newCx.hash != this.curContext.hash)
+                this.emitContext();
+            this.curContext = newCx;
+        }
+    }
+    /**
+    @internal
+    */
+    setLookAhead(lookAhead) {
+        if (lookAhead > this.lookAhead) {
+            this.emitLookAhead();
+            this.lookAhead = lookAhead;
+        }
+    }
+    /**
+    @internal
+    */
+    close() {
+        if (this.curContext && this.curContext.tracker.strict)
+            this.emitContext();
+        if (this.lookAhead > 0)
+            this.emitLookAhead();
+    }
+}
+class StackContext {
+    constructor(tracker, context) {
+        this.tracker = tracker;
+        this.context = context;
+        this.hash = tracker.strict ? tracker.hash(context) : 0;
+    }
+}
+// Used to cheaply run some reductions to scan ahead without mutating
+// an entire stack
+class SimulatedStack {
+    constructor(start) {
+        this.start = start;
+        this.state = start.state;
+        this.stack = start.stack;
+        this.base = this.stack.length;
+    }
+    reduce(action) {
+        let term = action & 65535 /* Action.ValueMask */, depth = action >> 19 /* Action.ReduceDepthShift */;
+        if (depth == 0) {
+            if (this.stack == this.start.stack)
+                this.stack = this.stack.slice();
+            this.stack.push(this.state, 0, 0);
+            this.base += 3;
+        }
+        else {
+            this.base -= (depth - 1) * 3;
+        }
+        let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
+        this.state = goto;
+    }
+}
+// This is given to `Tree.build` to build a buffer, and encapsulates
+// the parent-stack-walking necessary to read the nodes.
+class StackBufferCursor {
+    constructor(stack, pos, index) {
+        this.stack = stack;
+        this.pos = pos;
+        this.index = index;
+        this.buffer = stack.buffer;
+        if (this.index == 0)
+            this.maybeNext();
+    }
+    static create(stack, pos = stack.bufferBase + stack.buffer.length) {
+        return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
+    }
+    maybeNext() {
+        let next = this.stack.parent;
+        if (next != null) {
+            this.index = this.stack.bufferBase - next.bufferBase;
+            this.stack = next;
+            this.buffer = next.buffer;
+        }
+    }
+    get id() { return this.buffer[this.index - 4]; }
+    get start() { return this.buffer[this.index - 3]; }
+    get end() { return this.buffer[this.index - 2]; }
+    get size() { return this.buffer[this.index - 1]; }
+    next() {
+        this.index -= 4;
+        this.pos -= 4;
+        if (this.index == 0)
+            this.maybeNext();
+    }
+    fork() {
+        return new StackBufferCursor(this.stack, this.pos, this.index);
+    }
+}
+
+// See lezer-generator/src/encode.ts for comments about the encoding
+// used here
+function decodeArray(input, Type = Uint16Array) {
+    if (typeof input != "string")
+        return input;
+    let array = null;
+    for (let pos = 0, out = 0; pos < input.length;) {
+        let value = 0;
+        for (;;) {
+            let next = input.charCodeAt(pos++), stop = false;
+            if (next == 126 /* Encode.BigValCode */) {
+                value = 65535 /* Encode.BigVal */;
+                break;
+            }
+            if (next >= 92 /* Encode.Gap2 */)
+                next--;
+            if (next >= 34 /* Encode.Gap1 */)
+                next--;
+            let digit = next - 32 /* Encode.Start */;
+            if (digit >= 46 /* Encode.Base */) {
+                digit -= 46 /* Encode.Base */;
+                stop = true;
+            }
+            value += digit;
+            if (stop)
+                break;
+            value *= 46 /* Encode.Base */;
+        }
+        if (array)
+            array[out++] = value;
+        else
+            array = new Type(value);
+    }
+    return array;
+}
+
+class CachedToken {
+    constructor() {
+        this.start = -1;
+        this.value = -1;
+        this.end = -1;
+        this.extended = -1;
+        this.lookAhead = 0;
+        this.mask = 0;
+        this.context = 0;
+    }
+}
+const nullToken = new CachedToken;
+/**
+[Tokenizers](#lr.ExternalTokenizer) interact with the input
+through this interface. It presents the input as a stream of
+characters, tracking lookahead and hiding the complexity of
+[ranges](#common.Parser.parse^ranges) from tokenizer code.
+*/
+class InputStream {
+    /**
+    @internal
+    */
+    constructor(
+    /**
+    @internal
+    */
+    input, 
+    /**
+    @internal
+    */
+    ranges) {
+        this.input = input;
+        this.ranges = ranges;
+        /**
+        @internal
+        */
+        this.chunk = "";
+        /**
+        @internal
+        */
+        this.chunkOff = 0;
+        /**
+        Backup chunk
+        */
+        this.chunk2 = "";
+        this.chunk2Pos = 0;
+        /**
+        The character code of the next code unit in the input, or -1
+        when the stream is at the end of the input.
+        */
+        this.next = -1;
+        /**
+        @internal
+        */
+        this.token = nullToken;
+        this.rangeIndex = 0;
+        this.pos = this.chunkPos = ranges[0].from;
+        this.range = ranges[0];
+        this.end = ranges[ranges.length - 1].to;
+        this.readNext();
+    }
+    /**
+    @internal
+    */
+    resolveOffset(offset, assoc) {
+        let range = this.range, index = this.rangeIndex;
+        let pos = this.pos + offset;
+        while (pos < range.from) {
+            if (!index)
+                return null;
+            let next = this.ranges[--index];
+            pos -= range.from - next.to;
+            range = next;
+        }
+        while (assoc < 0 ? pos > range.to : pos >= range.to) {
+            if (index == this.ranges.length - 1)
+                return null;
+            let next = this.ranges[++index];
+            pos += next.from - range.to;
+            range = next;
+        }
+        return pos;
+    }
+    /**
+    @internal
+    */
+    clipPos(pos) {
+        if (pos >= this.range.from && pos < this.range.to)
+            return pos;
+        for (let range of this.ranges)
+            if (range.to > pos)
+                return Math.max(pos, range.from);
+        return this.end;
+    }
+    /**
+    Look at a code unit near the stream position. `.peek(0)` equals
+    `.next`, `.peek(-1)` gives you the previous character, and so
+    on.
+    
+    Note that looking around during tokenizing creates dependencies
+    on potentially far-away content, which may reduce the
+    effectiveness incremental parsing—when looking forward—or even
+    cause invalid reparses when looking backward more than 25 code
+    units, since the library does not track lookbehind.
+    */
+    peek(offset) {
+        let idx = this.chunkOff + offset, pos, result;
+        if (idx >= 0 && idx < this.chunk.length) {
+            pos = this.pos + offset;
+            result = this.chunk.charCodeAt(idx);
+        }
+        else {
+            let resolved = this.resolveOffset(offset, 1);
+            if (resolved == null)
+                return -1;
+            pos = resolved;
+            if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
+                result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
+            }
+            else {
+                let i = this.rangeIndex, range = this.range;
+                while (range.to <= pos)
+                    range = this.ranges[++i];
+                this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
+                if (pos + this.chunk2.length > range.to)
+                    this.chunk2 = this.chunk2.slice(0, range.to - pos);
+                result = this.chunk2.charCodeAt(0);
+            }
+        }
+        if (pos >= this.token.lookAhead)
+            this.token.lookAhead = pos + 1;
+        return result;
+    }
+    /**
+    Accept a token. By default, the end of the token is set to the
+    current stream position, but you can pass an offset (relative to
+    the stream position) to change that.
+    */
+    acceptToken(token, endOffset = 0) {
+        let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
+        if (end == null || end < this.token.start)
+            throw new RangeError("Token end out of bounds");
+        this.token.value = token;
+        this.token.end = end;
+    }
+    /**
+    Accept a token ending at a specific given position.
+    */
+    acceptTokenTo(token, endPos) {
+        this.token.value = token;
+        this.token.end = endPos;
+    }
+    getChunk() {
+        if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
+            let { chunk, chunkPos } = this;
+            this.chunk = this.chunk2;
+            this.chunkPos = this.chunk2Pos;
+            this.chunk2 = chunk;
+            this.chunk2Pos = chunkPos;
+            this.chunkOff = this.pos - this.chunkPos;
+        }
+        else {
+            this.chunk2 = this.chunk;
+            this.chunk2Pos = this.chunkPos;
+            let nextChunk = this.input.chunk(this.pos);
+            let end = this.pos + nextChunk.length;
+            this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
+            this.chunkPos = this.pos;
+            this.chunkOff = 0;
+        }
+    }
+    readNext() {
+        if (this.chunkOff >= this.chunk.length) {
+            this.getChunk();
+            if (this.chunkOff == this.chunk.length)
+                return this.next = -1;
+        }
+        return this.next = this.chunk.charCodeAt(this.chunkOff);
+    }
+    /**
+    Move the stream forward N (defaults to 1) code units. Returns
+    the new value of [`next`](#lr.InputStream.next).
+    */
+    advance(n = 1) {
+        this.chunkOff += n;
+        while (this.pos + n >= this.range.to) {
+            if (this.rangeIndex == this.ranges.length - 1)
+                return this.setDone();
+            n -= this.range.to - this.pos;
+            this.range = this.ranges[++this.rangeIndex];
+            this.pos = this.range.from;
+        }
+        this.pos += n;
+        if (this.pos >= this.token.lookAhead)
+            this.token.lookAhead = this.pos + 1;
+        return this.readNext();
+    }
+    setDone() {
+        this.pos = this.chunkPos = this.end;
+        this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
+        this.chunk = "";
+        return this.next = -1;
+    }
+    /**
+    @internal
+    */
+    reset(pos, token) {
+        if (token) {
+            this.token = token;
+            token.start = pos;
+            token.lookAhead = pos + 1;
+            token.value = token.extended = -1;
+        }
+        else {
+            this.token = nullToken;
+        }
+        if (this.pos != pos) {
+            this.pos = pos;
+            if (pos == this.end) {
+                this.setDone();
+                return this;
+            }
+            while (pos < this.range.from)
+                this.range = this.ranges[--this.rangeIndex];
+            while (pos >= this.range.to)
+                this.range = this.ranges[++this.rangeIndex];
+            if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
+                this.chunkOff = pos - this.chunkPos;
+            }
+            else {
+                this.chunk = "";
+                this.chunkOff = 0;
+            }
+            this.readNext();
+        }
+        return this;
+    }
+    /**
+    @internal
+    */
+    read(from, to) {
+        if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
+            return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
+        if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
+            return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
+        if (from >= this.range.from && to <= this.range.to)
+            return this.input.read(from, to);
+        let result = "";
+        for (let r of this.ranges) {
+            if (r.from >= to)
+                break;
+            if (r.to > from)
+                result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
+        }
+        return result;
+    }
+}
+/**
+@internal
+*/
+class TokenGroup {
+    constructor(data, id) {
+        this.data = data;
+        this.id = id;
+    }
+    token(input, stack) {
+        let { parser } = stack.p;
+        readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable);
+    }
+}
+TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
+/**
+@hide
+*/
+class LocalTokenGroup {
+    constructor(data, precTable, elseToken) {
+        this.precTable = precTable;
+        this.elseToken = elseToken;
+        this.data = typeof data == "string" ? decodeArray(data) : data;
+    }
+    token(input, stack) {
+        let start = input.pos, skipped = 0;
+        for (;;) {
+            let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
+            readToken(this.data, input, stack, 0, this.data, this.precTable);
+            if (input.token.value > -1)
+                break;
+            if (this.elseToken == null)
+                return;
+            if (!atEof)
+                skipped++;
+            if (nextPos == null)
+                break;
+            input.reset(nextPos, input.token);
+        }
+        if (skipped) {
+            input.reset(start, input.token);
+            input.acceptToken(this.elseToken, skipped);
+        }
+    }
+}
+LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
+/**
+`@external tokens` declarations in the grammar should resolve to
+an instance of this class.
+*/
+class ExternalTokenizer {
+    /**
+    Create a tokenizer. The first argument is the function that,
+    given an input stream, scans for the types of tokens it
+    recognizes at the stream's position, and calls
+    [`acceptToken`](#lr.InputStream.acceptToken) when it finds
+    one.
+    */
+    constructor(
+    /**
+    @internal
+    */
+    token, options = {}) {
+        this.token = token;
+        this.contextual = !!options.contextual;
+        this.fallback = !!options.fallback;
+        this.extend = !!options.extend;
+    }
+}
+// Tokenizer data is stored a big uint16 array containing, for each
+// state:
+//
+//  - A group bitmask, indicating what token groups are reachable from
+//    this state, so that paths that can only lead to tokens not in
+//    any of the current groups can be cut off early.
+//
+//  - The position of the end of the state's sequence of accepting
+//    tokens
+//
+//  - The number of outgoing edges for the state
+//
+//  - The accepting tokens, as (token id, group mask) pairs
+//
+//  - The outgoing edges, as (start character, end character, state
+//    index) triples, with end character being exclusive
+//
+// This function interprets that data, running through a stream as
+// long as new states with the a matching group mask can be reached,
+// and updating `input.token` when it matches a token.
+function readToken(data, input, stack, group, precTable, precOffset) {
+    let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
+    scan: for (;;) {
+        if ((groupMask & data[state]) == 0)
+            break;
+        let accEnd = data[state + 1];
+        // Check whether this state can lead to a token in the current group
+        // Accept tokens in this state, possibly overwriting
+        // lower-precedence / shorter tokens
+        for (let i = state + 3; i < accEnd; i += 2)
+            if ((data[i + 1] & groupMask) > 0) {
+                let term = data[i];
+                if (dialect.allows(term) &&
+                    (input.token.value == -1 || input.token.value == term ||
+                        overrides(term, input.token.value, precTable, precOffset))) {
+                    input.acceptToken(term);
+                    break;
+                }
+            }
+        let next = input.next, low = 0, high = data[state + 2];
+        // Special case for EOF
+        if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 /* Seq.End */) {
+            state = data[accEnd + high * 3 - 1];
+            continue scan;
+        }
+        // Do a binary search on the state's edges
+        for (; low < high;) {
+            let mid = (low + high) >> 1;
+            let index = accEnd + mid + (mid << 1);
+            let from = data[index], to = data[index + 1] || 0x10000;
+            if (next < from)
+                high = mid;
+            else if (next >= to)
+                low = mid + 1;
+            else {
+                state = data[index + 2];
+                input.advance();
+                continue scan;
+            }
+        }
+        break;
+    }
+}
+function findOffset(data, start, term) {
+    for (let i = start, next; (next = data[i]) != 65535 /* Seq.End */; i++)
+        if (next == term)
+            return i - start;
+    return -1;
+}
+function overrides(token, prev, tableData, tableOffset) {
+    let iPrev = findOffset(tableData, tableOffset, prev);
+    return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
+}
+
+// Environment variable used to control console output
+const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
+let stackIDs = null;
+function cutAt(tree, pos, side) {
+    let cursor = tree.cursor(IterMode$1.IncludeAnonymous);
+    cursor.moveTo(pos);
+    for (;;) {
+        if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
+            for (;;) {
+                if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
+                    return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25 /* Lookahead.Margin */))
+                        : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25 /* Lookahead.Margin */));
+                if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
+                    break;
+                if (!cursor.parent())
+                    return side < 0 ? 0 : tree.length;
+            }
+    }
+}
+class FragmentCursor {
+    constructor(fragments, nodeSet) {
+        this.fragments = fragments;
+        this.nodeSet = nodeSet;
+        this.i = 0;
+        this.fragment = null;
+        this.safeFrom = -1;
+        this.safeTo = -1;
+        this.trees = [];
+        this.start = [];
+        this.index = [];
+        this.nextFragment();
+    }
+    nextFragment() {
+        let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
+        if (fr) {
+            this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
+            this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
+            while (this.trees.length) {
+                this.trees.pop();
+                this.start.pop();
+                this.index.pop();
+            }
+            this.trees.push(fr.tree);
+            this.start.push(-fr.offset);
+            this.index.push(0);
+            this.nextStart = this.safeFrom;
+        }
+        else {
+            this.nextStart = 1e9;
+        }
+    }
+    // `pos` must be >= any previously given `pos` for this cursor
+    nodeAt(pos) {
+        if (pos < this.nextStart)
+            return null;
+        while (this.fragment && this.safeTo <= pos)
+            this.nextFragment();
+        if (!this.fragment)
+            return null;
+        for (;;) {
+            let last = this.trees.length - 1;
+            if (last < 0) { // End of tree
+                this.nextFragment();
+                return null;
+            }
+            let top = this.trees[last], index = this.index[last];
+            if (index == top.children.length) {
+                this.trees.pop();
+                this.start.pop();
+                this.index.pop();
+                continue;
+            }
+            let next = top.children[index];
+            let start = this.start[last] + top.positions[index];
+            if (start > pos) {
+                this.nextStart = start;
+                return null;
+            }
+            if (next instanceof Tree) {
+                if (start == pos) {
+                    if (start < this.safeFrom)
+                        return null;
+                    let end = start + next.length;
+                    if (end <= this.safeTo) {
+                        let lookAhead = next.prop(NodeProp$1.lookAhead);
+                        if (!lookAhead || end + lookAhead < this.fragment.to)
+                            return next;
+                    }
+                }
+                this.index[last]++;
+                if (start + next.length >= Math.max(this.safeFrom, pos)) { // Enter this node
+                    this.trees.push(next);
+                    this.start.push(start);
+                    this.index.push(0);
+                }
+            }
+            else {
+                this.index[last]++;
+                this.nextStart = start + next.length;
+            }
+        }
+    }
+}
+class TokenCache {
+    constructor(parser, stream) {
+        this.stream = stream;
+        this.tokens = [];
+        this.mainToken = null;
+        this.actions = [];
+        this.tokens = parser.tokenizers.map(_ => new CachedToken);
+    }
+    getActions(stack) {
+        let actionIndex = 0;
+        let main = null;
+        let { parser } = stack.p, { tokenizers } = parser;
+        let mask = parser.stateSlot(stack.state, 3 /* ParseState.TokenizerMask */);
+        let context = stack.curContext ? stack.curContext.hash : 0;
+        let lookAhead = 0;
+        for (let i = 0; i < tokenizers.length; i++) {
+            if (((1 << i) & mask) == 0)
+                continue;
+            let tokenizer = tokenizers[i], token = this.tokens[i];
+            if (main && !tokenizer.fallback)
+                continue;
+            if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
+                this.updateCachedToken(token, tokenizer, stack);
+                token.mask = mask;
+                token.context = context;
+            }
+            if (token.lookAhead > token.end + 25 /* Lookahead.Margin */)
+                lookAhead = Math.max(token.lookAhead, lookAhead);
+            if (token.value != 0 /* Term.Err */) {
+                let startIndex = actionIndex;
+                if (token.extended > -1)
+                    actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
+                actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
+                if (!tokenizer.extend) {
+                    main = token;
+                    if (actionIndex > startIndex)
+                        break;
+                }
+            }
+        }
+        while (this.actions.length > actionIndex)
+            this.actions.pop();
+        if (lookAhead)
+            stack.setLookAhead(lookAhead);
+        if (!main && stack.pos == this.stream.end) {
+            main = new CachedToken;
+            main.value = stack.p.parser.eofTerm;
+            main.start = main.end = stack.pos;
+            actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
+        }
+        this.mainToken = main;
+        return this.actions;
+    }
+    getMainToken(stack) {
+        if (this.mainToken)
+            return this.mainToken;
+        let main = new CachedToken, { pos, p } = stack;
+        main.start = pos;
+        main.end = Math.min(pos + 1, p.stream.end);
+        main.value = pos == p.stream.end ? p.parser.eofTerm : 0 /* Term.Err */;
+        return main;
+    }
+    updateCachedToken(token, tokenizer, stack) {
+        let start = this.stream.clipPos(stack.pos);
+        tokenizer.token(this.stream.reset(start, token), stack);
+        if (token.value > -1) {
+            let { parser } = stack.p;
+            for (let i = 0; i < parser.specialized.length; i++)
+                if (parser.specialized[i] == token.value) {
+                    let result = parser.specializers[i](this.stream.read(token.start, token.end), stack);
+                    if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
+                        if ((result & 1) == 0 /* Specialize.Specialize */)
+                            token.value = result >> 1;
+                        else
+                            token.extended = result >> 1;
+                        break;
+                    }
+                }
+        }
+        else {
+            token.value = 0 /* Term.Err */;
+            token.end = this.stream.clipPos(start + 1);
+        }
+    }
+    putAction(action, token, end, index) {
+        // Don't add duplicate actions
+        for (let i = 0; i < index; i += 3)
+            if (this.actions[i] == action)
+                return index;
+        this.actions[index++] = action;
+        this.actions[index++] = token;
+        this.actions[index++] = end;
+        return index;
+    }
+    addActions(stack, token, end, index) {
+        let { state } = stack, { parser } = stack.p, { data } = parser;
+        for (let set = 0; set < 2; set++) {
+            for (let i = parser.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */);; i += 3) {
+                if (data[i] == 65535 /* Seq.End */) {
+                    if (data[i + 1] == 1 /* Seq.Next */) {
+                        i = pair(data, i + 2);
+                    }
+                    else {
+                        if (index == 0 && data[i + 1] == 2 /* Seq.Other */)
+                            index = this.putAction(pair(data, i + 2), token, end, index);
+                        break;
+                    }
+                }
+                if (data[i] == token)
+                    index = this.putAction(pair(data, i + 1), token, end, index);
+            }
+        }
+        return index;
+    }
+}
+class Parse {
+    constructor(parser, input, fragments, ranges) {
+        this.parser = parser;
+        this.input = input;
+        this.ranges = ranges;
+        this.recovering = 0;
+        this.nextStackID = 0x2654; // ♔, ♕, ♖, ♗, ♘, ♙, ♠, ♡, ♢, ♣, ♤, ♥, ♦, ♧
+        this.minStackPos = 0;
+        this.reused = [];
+        this.stoppedAt = null;
+        this.lastBigReductionStart = -1;
+        this.lastBigReductionSize = 0;
+        this.bigReductionCount = 0;
+        this.stream = new InputStream(input, ranges);
+        this.tokens = new TokenCache(parser, this.stream);
+        this.topTerm = parser.top[1];
+        let { from } = ranges[0];
+        this.stacks = [Stack.start(this, parser.top[0], from)];
+        this.fragments = fragments.length && this.stream.end - from > parser.bufferLength * 4
+            ? new FragmentCursor(fragments, parser.nodeSet) : null;
+    }
+    get parsedPos() {
+        return this.minStackPos;
+    }
+    // Move the parser forward. This will process all parse stacks at
+    // `this.pos` and try to advance them to a further position. If no
+    // stack for such a position is found, it'll start error-recovery.
+    //
+    // When the parse is finished, this will return a syntax tree. When
+    // not, it returns `null`.
+    advance() {
+        let stacks = this.stacks, pos = this.minStackPos;
+        // This will hold stacks beyond `pos`.
+        let newStacks = this.stacks = [];
+        let stopped, stoppedTokens;
+        // If a large amount of reductions happened with the same start
+        // position, force the stack out of that production in order to
+        // avoid creating a tree too deep to recurse through.
+        // (This is an ugly kludge, because unfortunately there is no
+        // straightforward, cheap way to check for this happening, due to
+        // the history of reductions only being available in an
+        // expensive-to-access format in the stack buffers.)
+        if (this.bigReductionCount > 300 /* Rec.MaxLeftAssociativeReductionCount */ && stacks.length == 1) {
+            let [s] = stacks;
+            while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) { }
+            this.bigReductionCount = this.lastBigReductionSize = 0;
+        }
+        // Keep advancing any stacks at `pos` until they either move
+        // forward or can't be advanced. Gather stacks that can't be
+        // advanced further in `stopped`.
+        for (let i = 0; i < stacks.length; i++) {
+            let stack = stacks[i];
+            for (;;) {
+                this.tokens.mainToken = null;
+                if (stack.pos > pos) {
+                    newStacks.push(stack);
+                }
+                else if (this.advanceStack(stack, newStacks, stacks)) {
+                    continue;
+                }
+                else {
+                    if (!stopped) {
+                        stopped = [];
+                        stoppedTokens = [];
+                    }
+                    stopped.push(stack);
+                    let tok = this.tokens.getMainToken(stack);
+                    stoppedTokens.push(tok.value, tok.end);
+                }
+                break;
+            }
+        }
+        if (!newStacks.length) {
+            let finished = stopped && findFinished(stopped);
+            if (finished) {
+                if (verbose)
+                    console.log("Finish with " + this.stackID(finished));
+                return this.stackToTree(finished);
+            }
+            if (this.parser.strict) {
+                if (verbose && stopped)
+                    console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
+                throw new SyntaxError("No parse at " + pos);
+            }
+            if (!this.recovering)
+                this.recovering = 5 /* Rec.Distance */;
+        }
+        if (this.recovering && stopped) {
+            let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0]
+                : this.runRecovery(stopped, stoppedTokens, newStacks);
+            if (finished) {
+                if (verbose)
+                    console.log("Force-finish " + this.stackID(finished));
+                return this.stackToTree(finished.forceAll());
+            }
+        }
+        if (this.recovering) {
+            let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3 /* Rec.MaxRemainingPerStep */;
+            if (newStacks.length > maxRemaining) {
+                newStacks.sort((a, b) => b.score - a.score);
+                while (newStacks.length > maxRemaining)
+                    newStacks.pop();
+            }
+            if (newStacks.some(s => s.reducePos > pos))
+                this.recovering--;
+        }
+        else if (newStacks.length > 1) {
+            // Prune stacks that are in the same state, or that have been
+            // running without splitting for a while, to avoid getting stuck
+            // with multiple successful stacks running endlessly on.
+            outer: for (let i = 0; i < newStacks.length - 1; i++) {
+                let stack = newStacks[i];
+                for (let j = i + 1; j < newStacks.length; j++) {
+                    let other = newStacks[j];
+                    if (stack.sameState(other) ||
+                        stack.buffer.length > 500 /* Rec.MinBufferLengthPrune */ && other.buffer.length > 500 /* Rec.MinBufferLengthPrune */) {
+                        if (((stack.score - other.score) || (stack.buffer.length - other.buffer.length)) > 0) {
+                            newStacks.splice(j--, 1);
+                        }
+                        else {
+                            newStacks.splice(i--, 1);
+                            continue outer;
+                        }
+                    }
+                }
+            }
+            if (newStacks.length > 12 /* Rec.MaxStackCount */)
+                newStacks.splice(12 /* Rec.MaxStackCount */, newStacks.length - 12 /* Rec.MaxStackCount */);
+        }
+        this.minStackPos = newStacks[0].pos;
+        for (let i = 1; i < newStacks.length; i++)
+            if (newStacks[i].pos < this.minStackPos)
+                this.minStackPos = newStacks[i].pos;
+        return null;
+    }
+    stopAt(pos) {
+        if (this.stoppedAt != null && this.stoppedAt < pos)
+            throw new RangeError("Can't move stoppedAt forward");
+        this.stoppedAt = pos;
+    }
+    // Returns an updated version of the given stack, or null if the
+    // stack can't advance normally. When `split` and `stacks` are
+    // given, stacks split off by ambiguous operations will be pushed to
+    // `split`, or added to `stacks` if they move `pos` forward.
+    advanceStack(stack, stacks, split) {
+        let start = stack.pos, { parser } = this;
+        let base = verbose ? this.stackID(stack) + " -> " : "";
+        if (this.stoppedAt != null && start > this.stoppedAt)
+            return stack.forceReduce() ? stack : null;
+        if (this.fragments) {
+            let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
+            for (let cached = this.fragments.nodeAt(start); cached;) {
+                let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser.getGoto(stack.state, cached.type.id) : -1;
+                if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp$1.contextHash) || 0) == cxHash)) {
+                    stack.useNode(cached, match);
+                    if (verbose)
+                        console.log(base + this.stackID(stack) + ` (via reuse of ${parser.getName(cached.type.id)})`);
+                    return true;
+                }
+                if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
+                    break;
+                let inner = cached.children[0];
+                if (inner instanceof Tree && cached.positions[0] == 0)
+                    cached = inner;
+                else
+                    break;
+            }
+        }
+        let defaultReduce = parser.stateSlot(stack.state, 4 /* ParseState.DefaultReduce */);
+        if (defaultReduce > 0) {
+            stack.reduce(defaultReduce);
+            if (verbose)
+                console.log(base + this.stackID(stack) + ` (via always-reduce ${parser.getName(defaultReduce & 65535 /* Action.ValueMask */)})`);
+            return true;
+        }
+        if (stack.stack.length >= 8400 /* Rec.CutDepth */) {
+            while (stack.stack.length > 6000 /* Rec.CutTo */ && stack.forceReduce()) { }
+        }
+        let actions = this.tokens.getActions(stack);
+        for (let i = 0; i < actions.length;) {
+            let action = actions[i++], term = actions[i++], end = actions[i++];
+            let last = i == actions.length || !split;
+            let localStack = last ? stack : stack.split();
+            let main = this.tokens.mainToken;
+            localStack.apply(action, term, main ? main.start : localStack.pos, end);
+            if (verbose)
+                console.log(base + this.stackID(localStack) + ` (via ${(action & 65536 /* Action.ReduceFlag */) == 0 ? "shift"
+                    : `reduce of ${parser.getName(action & 65535 /* Action.ValueMask */)}`} for ${parser.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
+            if (last)
+                return true;
+            else if (localStack.pos > start)
+                stacks.push(localStack);
+            else
+                split.push(localStack);
+        }
+        return false;
+    }
+    // Advance a given stack forward as far as it will go. Returns the
+    // (possibly updated) stack if it got stuck, or null if it moved
+    // forward and was given to `pushStackDedup`.
+    advanceFully(stack, newStacks) {
+        let pos = stack.pos;
+        for (;;) {
+            if (!this.advanceStack(stack, null, null))
+                return false;
+            if (stack.pos > pos) {
+                pushStackDedup(stack, newStacks);
+                return true;
+            }
+        }
+    }
+    runRecovery(stacks, tokens, newStacks) {
+        let finished = null, restarted = false;
+        for (let i = 0; i < stacks.length; i++) {
+            let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
+            let base = verbose ? this.stackID(stack) + " -> " : "";
+            if (stack.deadEnd) {
+                if (restarted)
+                    continue;
+                restarted = true;
+                stack.restart();
+                if (verbose)
+                    console.log(base + this.stackID(stack) + " (restarted)");
+                let done = this.advanceFully(stack, newStacks);
+                if (done)
+                    continue;
+            }
+            let force = stack.split(), forceBase = base;
+            for (let j = 0; force.forceReduce() && j < 10 /* Rec.ForceReduceLimit */; j++) {
+                if (verbose)
+                    console.log(forceBase + this.stackID(force) + " (via force-reduce)");
+                let done = this.advanceFully(force, newStacks);
+                if (done)
+                    break;
+                if (verbose)
+                    forceBase = this.stackID(force) + " -> ";
+            }
+            for (let insert of stack.recoverByInsert(token)) {
+                if (verbose)
+                    console.log(base + this.stackID(insert) + " (via recover-insert)");
+                this.advanceFully(insert, newStacks);
+            }
+            if (this.stream.end > stack.pos) {
+                if (tokenEnd == stack.pos) {
+                    tokenEnd++;
+                    token = 0 /* Term.Err */;
+                }
+                stack.recoverByDelete(token, tokenEnd);
+                if (verbose)
+                    console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
+                pushStackDedup(stack, newStacks);
+            }
+            else if (!finished || finished.score < stack.score) {
+                finished = stack;
+            }
+        }
+        return finished;
+    }
+    // Convert the stack's buffer to a syntax tree.
+    stackToTree(stack) {
+        stack.close();
+        return Tree.build({ buffer: StackBufferCursor.create(stack),
+            nodeSet: this.parser.nodeSet,
+            topID: this.topTerm,
+            maxBufferLength: this.parser.bufferLength,
+            reused: this.reused,
+            start: this.ranges[0].from,
+            length: stack.pos - this.ranges[0].from,
+            minRepeatType: this.parser.minRepeatTerm });
+    }
+    stackID(stack) {
+        let id = (stackIDs || (stackIDs = new WeakMap)).get(stack);
+        if (!id)
+            stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
+        return id + stack;
+    }
+}
+function pushStackDedup(stack, newStacks) {
+    for (let i = 0; i < newStacks.length; i++) {
+        let other = newStacks[i];
+        if (other.pos == stack.pos && other.sameState(stack)) {
+            if (newStacks[i].score < stack.score)
+                newStacks[i] = stack;
+            return;
+        }
+    }
+    newStacks.push(stack);
+}
+class Dialect {
+    constructor(source, flags, disabled) {
+        this.source = source;
+        this.flags = flags;
+        this.disabled = disabled;
+    }
+    allows(term) { return !this.disabled || this.disabled[term] == 0; }
+}
+const id = x => x;
+/**
+Context trackers are used to track stateful context (such as
+indentation in the Python grammar, or parent elements in the XML
+grammar) needed by external tokenizers. You declare them in a
+grammar file as `@context exportName from "module"`.
+
+Context values should be immutable, and can be updated (replaced)
+on shift or reduce actions.
+
+The export used in a `@context` declaration should be of this
+type.
+*/
+class ContextTracker {
+    /**
+    Define a context tracker.
+    */
+    constructor(spec) {
+        this.start = spec.start;
+        this.shift = spec.shift || id;
+        this.reduce = spec.reduce || id;
+        this.reuse = spec.reuse || id;
+        this.hash = spec.hash || (() => 0);
+        this.strict = spec.strict !== false;
+    }
+}
+/**
+Holds the parse tables for a given grammar, as generated by
+`lezer-generator`, and provides [methods](#common.Parser) to parse
+content with.
+*/
+class LRParser extends Parser {
+    /**
+    @internal
+    */
+    constructor(spec) {
+        super();
+        /**
+        @internal
+        */
+        this.wrappers = [];
+        if (spec.version != 14 /* File.Version */)
+            throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14 /* File.Version */})`);
+        let nodeNames = spec.nodeNames.split(" ");
+        this.minRepeatTerm = nodeNames.length;
+        for (let i = 0; i < spec.repeatNodeCount; i++)
+            nodeNames.push("");
+        let topTerms = Object.keys(spec.topRules).map(r => spec.topRules[r][1]);
+        let nodeProps = [];
+        for (let i = 0; i < nodeNames.length; i++)
+            nodeProps.push([]);
+        function setProp(nodeID, prop, value) {
+            nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
+        }
+        if (spec.nodeProps)
+            for (let propSpec of spec.nodeProps) {
+                let prop = propSpec[0];
+                if (typeof prop == "string")
+                    prop = NodeProp$1[prop];
+                for (let i = 1; i < propSpec.length;) {
+                    let next = propSpec[i++];
+                    if (next >= 0) {
+                        setProp(next, prop, propSpec[i++]);
+                    }
+                    else {
+                        let value = propSpec[i + -next];
+                        for (let j = -next; j > 0; j--)
+                            setProp(propSpec[i++], prop, value);
+                        i++;
+                    }
+                }
+            }
+        this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType$1.define({
+            name: i >= this.minRepeatTerm ? undefined : name,
+            id: i,
+            props: nodeProps[i],
+            top: topTerms.indexOf(i) > -1,
+            error: i == 0,
+            skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
+        })));
+        if (spec.propSources)
+            this.nodeSet = this.nodeSet.extend(...spec.propSources);
+        this.strict = false;
+        this.bufferLength = DefaultBufferLength;
+        let tokenArray = decodeArray(spec.tokenData);
+        this.context = spec.context;
+        this.specializerSpecs = spec.specialized || [];
+        this.specialized = new Uint16Array(this.specializerSpecs.length);
+        for (let i = 0; i < this.specializerSpecs.length; i++)
+            this.specialized[i] = this.specializerSpecs[i].term;
+        this.specializers = this.specializerSpecs.map(getSpecializer);
+        this.states = decodeArray(spec.states, Uint32Array);
+        this.data = decodeArray(spec.stateData);
+        this.goto = decodeArray(spec.goto);
+        this.maxTerm = spec.maxTerm;
+        this.tokenizers = spec.tokenizers.map(value => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
+        this.topRules = spec.topRules;
+        this.dialects = spec.dialects || {};
+        this.dynamicPrecedences = spec.dynamicPrecedences || null;
+        this.tokenPrecTable = spec.tokenPrec;
+        this.termNames = spec.termNames || null;
+        this.maxNode = this.nodeSet.types.length - 1;
+        this.dialect = this.parseDialect();
+        this.top = this.topRules[Object.keys(this.topRules)[0]];
+    }
+    createParse(input, fragments, ranges) {
+        let parse = new Parse(this, input, fragments, ranges);
+        for (let w of this.wrappers)
+            parse = w(parse, input, fragments, ranges);
+        return parse;
+    }
+    /**
+    Get a goto table entry @internal
+    */
+    getGoto(state, term, loose = false) {
+        let table = this.goto;
+        if (term >= table[0])
+            return -1;
+        for (let pos = table[term + 1];;) {
+            let groupTag = table[pos++], last = groupTag & 1;
+            let target = table[pos++];
+            if (last && loose)
+                return target;
+            for (let end = pos + (groupTag >> 1); pos < end; pos++)
+                if (table[pos] == state)
+                    return target;
+            if (last)
+                return -1;
+        }
+    }
+    /**
+    Check if this state has an action for a given terminal @internal
+    */
+    hasAction(state, terminal) {
+        let data = this.data;
+        for (let set = 0; set < 2; set++) {
+            for (let i = this.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */), next;; i += 3) {
+                if ((next = data[i]) == 65535 /* Seq.End */) {
+                    if (data[i + 1] == 1 /* Seq.Next */)
+                        next = data[i = pair(data, i + 2)];
+                    else if (data[i + 1] == 2 /* Seq.Other */)
+                        return pair(data, i + 2);
+                    else
+                        break;
+                }
+                if (next == terminal || next == 0 /* Term.Err */)
+                    return pair(data, i + 1);
+            }
+        }
+        return 0;
+    }
+    /**
+    @internal
+    */
+    stateSlot(state, slot) {
+        return this.states[(state * 6 /* ParseState.Size */) + slot];
+    }
+    /**
+    @internal
+    */
+    stateFlag(state, flag) {
+        return (this.stateSlot(state, 0 /* ParseState.Flags */) & flag) > 0;
+    }
+    /**
+    @internal
+    */
+    validAction(state, action) {
+        return !!this.allActions(state, a => a == action ? true : null);
+    }
+    /**
+    @internal
+    */
+    allActions(state, action) {
+        let deflt = this.stateSlot(state, 4 /* ParseState.DefaultReduce */);
+        let result = deflt ? action(deflt) : undefined;
+        for (let i = this.stateSlot(state, 1 /* ParseState.Actions */); result == null; i += 3) {
+            if (this.data[i] == 65535 /* Seq.End */) {
+                if (this.data[i + 1] == 1 /* Seq.Next */)
+                    i = pair(this.data, i + 2);
+                else
+                    break;
+            }
+            result = action(pair(this.data, i + 1));
+        }
+        return result;
+    }
+    /**
+    Get the states that can follow this one through shift actions or
+    goto jumps. @internal
+    */
+    nextStates(state) {
+        let result = [];
+        for (let i = this.stateSlot(state, 1 /* ParseState.Actions */);; i += 3) {
+            if (this.data[i] == 65535 /* Seq.End */) {
+                if (this.data[i + 1] == 1 /* Seq.Next */)
+                    i = pair(this.data, i + 2);
+                else
+                    break;
+            }
+            if ((this.data[i + 2] & (65536 /* Action.ReduceFlag */ >> 16)) == 0) {
+                let value = this.data[i + 1];
+                if (!result.some((v, i) => (i & 1) && v == value))
+                    result.push(this.data[i], value);
+            }
+        }
+        return result;
+    }
+    /**
+    Configure the parser. Returns a new parser instance that has the
+    given settings modified. Settings not provided in `config` are
+    kept from the original parser.
+    */
+    configure(config) {
+        // Hideous reflection-based kludge to make it easy to create a
+        // slightly modified copy of a parser.
+        let copy = Object.assign(Object.create(LRParser.prototype), this);
+        if (config.props)
+            copy.nodeSet = this.nodeSet.extend(...config.props);
+        if (config.top) {
+            let info = this.topRules[config.top];
+            if (!info)
+                throw new RangeError(`Invalid top rule name ${config.top}`);
+            copy.top = info;
+        }
+        if (config.tokenizers)
+            copy.tokenizers = this.tokenizers.map(t => {
+                let found = config.tokenizers.find(r => r.from == t);
+                return found ? found.to : t;
+            });
+        if (config.specializers) {
+            copy.specializers = this.specializers.slice();
+            copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
+                let found = config.specializers.find(r => r.from == s.external);
+                if (!found)
+                    return s;
+                let spec = Object.assign(Object.assign({}, s), { external: found.to });
+                copy.specializers[i] = getSpecializer(spec);
+                return spec;
+            });
+        }
+        if (config.contextTracker)
+            copy.context = config.contextTracker;
+        if (config.dialect)
+            copy.dialect = this.parseDialect(config.dialect);
+        if (config.strict != null)
+            copy.strict = config.strict;
+        if (config.wrap)
+            copy.wrappers = copy.wrappers.concat(config.wrap);
+        if (config.bufferLength != null)
+            copy.bufferLength = config.bufferLength;
+        return copy;
+    }
+    /**
+    Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
+    are registered for this parser.
+    */
+    hasWrappers() {
+        return this.wrappers.length > 0;
+    }
+    /**
+    Returns the name associated with a given term. This will only
+    work for all terms when the parser was generated with the
+    `--names` option. By default, only the names of tagged terms are
+    stored.
+    */
+    getName(term) {
+        return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
+    }
+    /**
+    The eof term id is always allocated directly after the node
+    types. @internal
+    */
+    get eofTerm() { return this.maxNode + 1; }
+    /**
+    The type of top node produced by the parser.
+    */
+    get topNode() { return this.nodeSet.types[this.top[1]]; }
+    /**
+    @internal
+    */
+    dynamicPrecedence(term) {
+        let prec = this.dynamicPrecedences;
+        return prec == null ? 0 : prec[term] || 0;
+    }
+    /**
+    @internal
+    */
+    parseDialect(dialect) {
+        let values = Object.keys(this.dialects), flags = values.map(() => false);
+        if (dialect)
+            for (let part of dialect.split(" ")) {
+                let id = values.indexOf(part);
+                if (id >= 0)
+                    flags[id] = true;
+            }
+        let disabled = null;
+        for (let i = 0; i < values.length; i++)
+            if (!flags[i]) {
+                for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535 /* Seq.End */;)
+                    (disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
+            }
+        return new Dialect(dialect, flags, disabled);
+    }
+    /**
+    Used by the output of the parser generator. Not available to
+    user code. @hide
+    */
+    static deserialize(spec) {
+        return new LRParser(spec);
+    }
+}
+function pair(data, off) { return data[off] | (data[off + 1] << 16); }
+function findFinished(stacks) {
+    let best = null;
+    for (let stack of stacks) {
+        let stopped = stack.p.stoppedAt;
+        if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) &&
+            stack.p.parser.stateFlag(stack.state, 2 /* StateFlag.Accepting */) &&
+            (!best || best.score < stack.score))
+            best = stack;
+    }
+    return best;
+}
+function getSpecializer(spec) {
+    if (spec.external) {
+        let mask = spec.extend ? 1 /* Specialize.Extend */ : 0 /* Specialize.Specialize */;
+        return (value, stack) => (spec.external(value, stack) << 1) | mask;
+    }
+    return spec.get;
+}
+
+// This file was generated by lezer-generator. You probably shouldn't edit it.
+const noSemi = 314,
+  noSemiType = 315,
+  incdec = 1,
+  incdecPrefix = 2,
+  questionDot = 3,
+  JSXStartTag = 4,
+  insertSemi = 316,
+  spaces = 318,
+  newline = 319,
+  LineComment = 5,
+  BlockComment = 6,
+  Dialect_jsx = 0;
+
+/* Hand-written tokenizers for JavaScript tokens that can't be
+   expressed by lezer's built-in tokenizer. */
+
+const space = [9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200,
+               8201, 8202, 8232, 8233, 8239, 8287, 12288];
+
+const braceR = 125, semicolon = 59, slash = 47, star = 42, plus = 43, minus = 45, lt = 60, comma = 44,
+      question = 63, dot = 46, bracketL = 91;
+
+const trackNewline = new ContextTracker({
+  start: false,
+  shift(context, term) {
+    return term == LineComment || term == BlockComment || term == spaces ? context : term == newline
+  },
+  strict: false
+});
+
+const insertSemicolon = new ExternalTokenizer((input, stack) => {
+  let {next} = input;
+  if (next == braceR || next == -1 || stack.context)
+    input.acceptToken(insertSemi);
+}, {contextual: true, fallback: true});
+
+const noSemicolon = new ExternalTokenizer((input, stack) => {
+  let {next} = input, after;
+  if (space.indexOf(next) > -1) return
+  if (next == slash && ((after = input.peek(1)) == slash || after == star)) return
+  if (next != braceR && next != semicolon && next != -1 && !stack.context)
+    input.acceptToken(noSemi);
+}, {contextual: true});
+
+const noSemicolonType = new ExternalTokenizer((input, stack) => {
+  if (input.next == bracketL && !stack.context) input.acceptToken(noSemiType);
+}, {contextual: true});
+
+const operatorToken = new ExternalTokenizer((input, stack) => {
+  let {next} = input;
+  if (next == plus || next == minus) {
+    input.advance();
+    if (next == input.next) {
+      input.advance();
+      let mayPostfix = !stack.context && stack.canShift(incdec);
+      input.acceptToken(mayPostfix ? incdec : incdecPrefix);
+    }
+  } else if (next == question && input.peek(1) == dot) {
+    input.advance(); input.advance();
+    if (input.next < 48 || input.next > 57) // No digit after
+      input.acceptToken(questionDot);
+  }
+}, {contextual: true});
+
+function identifierChar(ch, start) {
+  return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch == 95 || ch >= 192 ||
+    !start && ch >= 48 && ch <= 57
+}
+
+const jsx = new ExternalTokenizer((input, stack) => {
+  if (input.next != lt || !stack.dialectEnabled(Dialect_jsx)) return
+  input.advance();
+  if (input.next == slash) return
+  // Scan for an identifier followed by a comma or 'extends', don't
+  // treat this as a start tag if present.
+  let back = 0;
+  while (space.indexOf(input.next) > -1) { input.advance(); back++; }
+  if (identifierChar(input.next, true)) {
+    input.advance();
+    back++;
+    while (identifierChar(input.next, false)) { input.advance(); back++; }
+    while (space.indexOf(input.next) > -1) { input.advance(); back++; }
+    if (input.next == comma) return
+    for (let i = 0;; i++) {
+      if (i == 7) {
+        if (!identifierChar(input.next, true)) return
+        break
+      }
+      if (input.next != "extends".charCodeAt(i)) break
+      input.advance();
+      back++;
+    }
+  }
+  input.acceptToken(JSXStartTag, -back);
+});
+
+const jsHighlight = styleTags({
+  "get set async static": tags.modifier,
+  "for while do if else switch try catch finally return throw break continue default case": tags.controlKeyword,
+  "in of await yield void typeof delete instanceof": tags.operatorKeyword,
+  "let var const using function class extends": tags.definitionKeyword,
+  "import export from": tags.moduleKeyword,
+  "with debugger as new": tags.keyword,
+  TemplateString: tags.special(tags.string),
+  super: tags.atom,
+  BooleanLiteral: tags.bool,
+  this: tags.self,
+  null: tags.null,
+  Star: tags.modifier,
+  VariableName: tags.variableName,
+  "CallExpression/VariableName TaggedTemplateExpression/VariableName": tags.function(tags.variableName),
+  VariableDefinition: tags.definition(tags.variableName),
+  Label: tags.labelName,
+  PropertyName: tags.propertyName,
+  PrivatePropertyName: tags.special(tags.propertyName),
+  "CallExpression/MemberExpression/PropertyName": tags.function(tags.propertyName),
+  "FunctionDeclaration/VariableDefinition": tags.function(tags.definition(tags.variableName)),
+  "ClassDeclaration/VariableDefinition": tags.definition(tags.className),
+  "NewExpression/VariableName": tags.className,
+  PropertyDefinition: tags.definition(tags.propertyName),
+  PrivatePropertyDefinition: tags.definition(tags.special(tags.propertyName)),
+  UpdateOp: tags.updateOperator,
+  "LineComment Hashbang": tags.lineComment,
+  BlockComment: tags.blockComment,
+  Number: tags.number,
+  String: tags.string,
+  Escape: tags.escape,
+  ArithOp: tags.arithmeticOperator,
+  LogicOp: tags.logicOperator,
+  BitOp: tags.bitwiseOperator,
+  CompareOp: tags.compareOperator,
+  RegExp: tags.regexp,
+  Equals: tags.definitionOperator,
+  Arrow: tags.function(tags.punctuation),
+  ": Spread": tags.punctuation,
+  "( )": tags.paren,
+  "[ ]": tags.squareBracket,
+  "{ }": tags.brace,
+  "InterpolationStart InterpolationEnd": tags.special(tags.brace),
+  ".": tags.derefOperator,
+  ", ;": tags.separator,
+  "@": tags.meta,
+
+  TypeName: tags.typeName,
+  TypeDefinition: tags.definition(tags.typeName),
+  "type enum interface implements namespace module declare": tags.definitionKeyword,
+  "abstract global Privacy readonly override": tags.modifier,
+  "is keyof unique infer asserts": tags.operatorKeyword,
+
+  JSXAttributeValue: tags.attributeValue,
+  JSXText: tags.content,
+  "JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": tags.angleBracket,
+  "JSXIdentifier JSXNameSpacedName": tags.tagName,
+  "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName,
+  "JSXBuiltin/JSXIdentifier": tags.standard(tags.tagName)
+});
+
+// This file was generated by lezer-generator. You probably shouldn't edit it.
+const spec_identifier = {__proto__:null,export:20, as:25, from:33, default:36, async:41, function:42, const:52, extends:56, this:60, true:68, false:68, null:80, void:84, typeof:88, super:104, new:138, delete:150, yield:159, await:163, class:168, public:231, private:231, protected:231, readonly:233, instanceof:252, satisfies:255, in:256, import:290, keyof:347, unique:351, infer:357, asserts:393, is:395, abstract:415, implements:417, type:419, let:422, var:424, using:427, interface:433, enum:437, namespace:443, module:445, declare:449, global:453, for:472, of:481, while:484, with:488, do:492, if:496, else:498, switch:502, case:508, try:514, catch:518, finally:522, return:526, throw:530, break:534, continue:538, debugger:542};
+const spec_word = {__proto__:null,async:125, get:127, set:129, declare:191, public:193, private:193, protected:193, static:195, abstract:197, override:199, readonly:205, accessor:207, new:399};
+const spec_LessThan = {__proto__:null,"<":189};
+const parser = LRParser.deserialize({
+  version: 14,
+  states: "$EOQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#D_O.QQlO'#DeO.bQlO'#DpO%[QlO'#DxO0fQlO'#EQOOQ!0Lf'#EY'#EYO1PQ`O'#EVOOQO'#En'#EnOOQO'#Ij'#IjO1XQ`O'#GrO1dQ`O'#EmO1iQ`O'#EmO3hQ!0MxO'#JpO6[Q!0MxO'#JqO6uQ`O'#F[O6zQ,UO'#FsOOQ!0Lf'#Fe'#FeO7VO7dO'#FeO7eQMhO'#F{O9UQ`O'#FzOOQ!0Lf'#Jq'#JqOOQ!0Lb'#Jp'#JpO9ZQ`O'#GvOOQ['#K]'#K]O9fQ`O'#IWO9kQ!0LrO'#IXOOQ['#J^'#J^OOQ['#I]'#I]Q`QlOOQ`QlOOO9sQ!L^O'#DtO9zQlO'#D|O:RQlO'#EOO9aQ`O'#GrO:YQMhO'#CoO:hQ`O'#ElO:sQ`O'#EwO:xQMhO'#FdO;gQ`O'#GrOOQO'#K^'#K^O;lQ`O'#K^O;zQ`O'#GzO;zQ`O'#G{O;zQ`O'#G}O9aQ`O'#HQO<qQ`O'#HTO>YQ`O'#CeO>jQ`O'#HaO>rQ`O'#HgO>rQ`O'#HiO`QlO'#HkO>rQ`O'#HmO>rQ`O'#HpO>wQ`O'#HvO>|Q!0LsO'#H|O%[QlO'#IOO?XQ!0LsO'#IQO?dQ!0LsO'#ISO9kQ!0LrO'#IUO?oQ!0MxO'#CiO@qQpO'#DjQOQ`OOO%[QlO'#EOOAXQ`O'#ERO:YQMhO'#ElOAdQ`O'#ElOAoQ!bO'#FdOOQ['#Cg'#CgOOQ!0Lb'#Do'#DoOOQ!0Lb'#Jt'#JtO%[QlO'#JtOOQO'#Jw'#JwOOQO'#If'#IfOBoQpO'#EeOOQ!0Lb'#Ed'#EdOOQ!0Lb'#J{'#J{OCkQ!0MSO'#EeOCuQpO'#EUOOQO'#Jv'#JvODZQpO'#JwOEhQpO'#EUOCuQpO'#EePEuO&2DjO'#CbPOOO)CD{)CD{OOOO'#I^'#I^OFQO#tO,59UOOQ!0Lh,59U,59UOOOO'#I_'#I_OF`O&jO,59UOFnQ!L^O'#DaOOOO'#Ia'#IaOFuO#@ItO,59yOOQ!0Lf,59y,59yOGTQlO'#IbOGhQ`O'#JrOIgQ!fO'#JrO+}QlO'#JrOInQ`O,5:POJUQ`O'#EnOJcQ`O'#KROJnQ`O'#KQOJnQ`O'#KQOJvQ`O,5;[OJ{Q`O'#KPOOQ!0Ln,5:[,5:[OKSQlO,5:[OMQQ!0MxO,5:dOMqQ`O,5:lON[Q!0LrO'#KOONcQ`O'#J}O9ZQ`O'#J}ONwQ`O'#J}O! PQ`O,5;ZO! UQ`O'#J}O!#ZQ!fO'#JqOOQ!0Lh'#Ci'#CiO%[QlO'#EQO!#yQ!fO,5:qOOQS'#Jx'#JxOOQO-E<h-E<hO9aQ`O,5=^O!$aQ`O,5=^O!$fQlO,5;XO!&iQMhO'#EiO!(SQ`O,5;XO!(XQlO'#DwO!(cQpO,5;bO!(kQpO,5;bO%[QlO,5;bOOQ['#FS'#FSOOQ['#FU'#FUO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cOOQ['#FY'#FYO!(yQlO,5;sOOQ!0Lf,5;x,5;xOOQ!0Lf,5;y,5;yOOQ!0Lf,5;{,5;{O%[QlO'#InO!*|Q!0LrO,5<hO%[QlO,5;cO!&iQMhO,5;cO!+kQMhO,5;cO!-]QMhO'#E[O%[QlO,5;vOOQ!0Lf,5;z,5;zO!-dQ,UO'#FiO!.aQ,UO'#KVO!-{Q,UO'#KVO!.hQ,UO'#KVOOQO'#KV'#KVO!.|Q,UO,5<ROOOW,5<_,5<_O!/_QlO'#FuOOOW'#Im'#ImO7VO7dO,5<PO!/fQ,UO'#FwOOQ!0Lf,5<P,5<PO!0VQ$IUO'#CwOOQ!0Lh'#C{'#C{O!0jO#@ItO'#DPO!1WQMjO,5<dO!1_Q`O,5<gO!2zQ(CWO'#GWO!3XQ`O'#GXO!3^Q`O'#GXO!4|Q(CWO'#G]O!6RQpO'#GaOOQO'#Gm'#GmO!+rQMhO'#GlOOQO'#Go'#GoO!+rQMhO'#GnO!6tQ$IUO'#JjOOQ!0Lh'#Jj'#JjO!7OQ`O'#JiO!7^Q`O'#JhO!7fQ`O'#CuOOQ!0Lh'#Cy'#CyO!7qQ`O'#C{OOQ!0Lh'#DT'#DTOOQ!0Lh'#DV'#DVO1SQ`O'#DXO!+rQMhO'#GOO!+rQMhO'#GQO!7vQ`O'#GSO!7{Q`O'#GTO!3^Q`O'#GZO!+rQMhO'#G`O;zQ`O'#JiO!8QQ`O'#EoO!8oQ`O,5<fOOQ!0Lb'#Cr'#CrO!8wQ`O'#EpO!9qQpO'#EqOOQ!0Lb'#KP'#KPO!9xQ!0LrO'#K_O9kQ!0LrO,5=bO`QlO,5>rOOQ['#Jf'#JfOOQ[,5>s,5>sOOQ[-E<Z-E<ZO!;wQ!0MxO,5:`O!9lQpO,5:^O!>bQ!0MxO,5:hO%[QlO,5:hO!@xQ!0MxO,5:jOOQO,5@x,5@xO!AiQMhO,5=^O!AwQ!0LrO'#JgO9UQ`O'#JgO!BYQ!0LrO,59ZO!BeQpO,59ZO!BmQMhO,59ZO:YQMhO,59ZO!BxQ`O,5;XO!CQQ`O'#H`O!CfQ`O'#KbO%[QlO,5;|O!9lQpO,5<OO!CnQ`O,5=yO!CsQ`O,5=yO!CxQ`O,5=yO9kQ!0LrO,5=yO;zQ`O,5=iOOQO'#Cw'#CwO!DWQpO,5=fO!D`QMhO,5=gO!DkQ`O,5=iO!DpQ!bO,5=lO!DxQ`O'#K^O>wQ`O'#HVO9aQ`O'#HXO!D}Q`O'#HXO:YQMhO'#HZO!ESQ`O'#HZOOQ[,5=o,5=oO!EXQ`O'#H[O!EjQ`O'#CoO!EoQ`O,59PO!EyQ`O,59PO!HOQlO,59POOQ[,59P,59PO!H`Q!0LrO,59PO%[QlO,59PO!JkQlO'#HcOOQ['#Hd'#HdOOQ['#He'#HeO`QlO,5={O!KRQ`O,5={O`QlO,5>RO`QlO,5>TO!KWQ`O,5>VO`QlO,5>XO!K]Q`O,5>[O!KbQlO,5>bOOQ[,5>h,5>hO%[QlO,5>hO9kQ!0LrO,5>jOOQ[,5>l,5>lO# lQ`O,5>lOOQ[,5>n,5>nO# lQ`O,5>nOOQ[,5>p,5>pO#!YQpO'#D]O%[QlO'#JtO#!{QpO'#JtO##VQpO'#DkO##hQpO'#DkO#%yQlO'#DkO#&QQ`O'#JsO#&YQ`O,5:UO#&_Q`O'#ErO#&mQ`O'#KSO#&uQ`O,5;]O#&zQpO'#DkO#'XQpO'#ETOOQ!0Lf,5:m,5:mO%[QlO,5:mO#'`Q`O,5:mO>wQ`O,5;WO!BeQpO,5;WO!BmQMhO,5;WO:YQMhO,5;WO#'hQ`O,5@`O#'mQ07dO,5:qOOQO-E<d-E<dO#(sQ!0MSO,5;POCuQpO,5:pO#(}QpO,5:pOCuQpO,5;PO!BYQ!0LrO,5:pOOQ!0Lb'#Eh'#EhOOQO,5;P,5;PO%[QlO,5;PO#)[Q!0LrO,5;PO#)gQ!0LrO,5;PO!BeQpO,5:pOOQO,5;V,5;VO#)uQ!0LrO,5;PPOOO'#I['#I[P#*ZO&2DjO,58|POOO,58|,58|OOOO-E<[-E<[OOQ!0Lh1G.p1G.pOOOO-E<]-E<]OOOO,59{,59{O#*fQ!bO,59{OOOO-E<_-E<_OOQ!0Lf1G/e1G/eO#*kQ!fO,5>|O+}QlO,5>|OOQO,5?S,5?SO#*uQlO'#IbOOQO-E<`-E<`O#+SQ`O,5@^O#+[Q!fO,5@^O#+cQ`O,5@lOOQ!0Lf1G/k1G/kO%[QlO,5@mO#+kQ`O'#IhOOQO-E<f-E<fO#+cQ`O,5@lOOQ!0Lb1G0v1G0vOOQ!0Ln1G/v1G/vOOQ!0Ln1G0W1G0WO%[QlO,5@jO#,PQ!0LrO,5@jO#,bQ!0LrO,5@jO#,iQ`O,5@iO9ZQ`O,5@iO#,qQ`O,5@iO#-PQ`O'#IkO#,iQ`O,5@iOOQ!0Lb1G0u1G0uO!(cQpO,5:sO!(nQpO,5:sOOQS,5:u,5:uO#-qQdO,5:uO#-yQMhO1G2xO9aQ`O1G2xOOQ!0Lf1G0s1G0sO#.XQ!0MxO1G0sO#/^Q!0MvO,5;TOOQ!0Lh'#GV'#GVO#/zQ!0MzO'#JjO!$fQlO1G0sO#2VQ!fO'#JuO%[QlO'#JuO#2aQ`O,5:cOOQ!0Lh'#D]'#D]OOQ!0Lf1G0|1G0|O%[QlO1G0|OOQ!0Lf1G1e1G1eO#2fQ`O1G0|O#4zQ!0MxO1G0}O#5RQ!0MxO1G0}O#7iQ!0MxO1G0}O#7pQ!0MxO1G0}O#:WQ!0MxO1G0}O#<nQ!0MxO1G0}O#<uQ!0MxO1G0}O#<|Q!0MxO1G0}O#?dQ!0MxO1G0}O#?kQ!0MxO1G0}O#AxQ?MtO'#CiO#CsQ?MtO1G1_O#CzQ?MtO'#JqO#D_Q!0MxO,5?YOOQ!0Lb-E<l-E<lO#FlQ!0MxO1G0}O#GiQ!0MzO1G0}OOQ!0Lf1G0}1G0}O#HlQMjO'#JzO#HvQ`O,5:vO#H{Q!0MxO1G1bO#IoQ,UO,5<VO#IwQ,UO,5<WO#JPQ,UO'#FnO#JhQ`O'#FmOOQO'#KW'#KWOOQO'#Il'#IlO#JmQ,UO1G1mOOQ!0Lf1G1m1G1mOOOW1G1x1G1xO#KOQ?MtO'#JpO#KYQ`O,5<aO!(yQlO,5<aOOOW-E<k-E<kOOQ!0Lf1G1k1G1kO#K_QpO'#KVOOQ!0Lf,5<c,5<cO#KgQpO,5<cO#KlQMhO'#DROOOO'#I`'#I`O#KsO#@ItO,59kOOQ!0Lh,59k,59kO%[QlO1G2OO!7{Q`O'#IpO#LOQ`O,5<yOOQ!0Lh,5<v,5<vO!+rQMhO'#IsO#LlQMjO,5=WO!+rQMhO'#IuO#M_QMjO,5=YO!&iQMhO,5=[OOQO1G2R1G2RO#MiQ!dO'#CrO#M|Q(CWO'#EpO$ RQpO'#GaO$ iQ!dO,5<rO$ pQ`O'#KYO9ZQ`O'#KYO$!OQ`O,5<tO!+rQMhO,5<sO$!TQ`O'#GYO$!fQ`O,5<sO$!kQ!dO'#GVO$!xQ!dO'#KZO$#SQ`O'#KZO!&iQMhO'#KZO$#XQ`O,5<wO$#^QlO'#JtO$#hQpO'#GbO##hQpO'#GbO$#yQ`O'#GfO!3^Q`O'#GjO$$OQ!0LrO'#IrO$$ZQpO,5<{OOQ!0Lp,5<{,5<{O$$bQpO'#GbO$$oQpO'#GcO$%QQpO'#GcO$%VQMjO,5=WO$%gQMjO,5=YOOQ!0Lh,5=],5=]O!+rQMhO,5@TO!+rQMhO,5@TO$%wQ`O'#IwO$&VQ`O,5@SO$&_Q`O,59aOOQ!0Lh,59g,59gO$'UQ$IYO,59sOOQ!0Lh'#Jn'#JnO$'wQMjO,5<jO$(jQMjO,5<lO@iQ`O,5<nOOQ!0Lh,5<o,5<oO$(tQ`O,5<uO$(yQMjO,5<zO$)ZQ`O,5@TO$)iQ`O'#J}O!$fQlO1G2QO$)nQ`O1G2QO9ZQ`O'#KQO9ZQ`O'#ErO%[QlO'#ErO9ZQ`O'#IyO$)sQ!0LrO,5@yOOQ[1G2|1G2|OOQ[1G4^1G4^OOQ!0Lf1G/z1G/zOOQ!0Lf1G/x1G/xO$+uQ!0MxO1G0SOOQ[1G2x1G2xO!&iQMhO1G2xO%[QlO1G2xO#-|Q`O1G2xO$-yQMhO'#EiOOQ!0Lb,5@R,5@RO$.WQ!0LrO,5@ROOQ[1G.u1G.uO!BYQ!0LrO1G.uO!BeQpO1G.uO!BmQMhO1G.uO$.iQ`O1G0sO$.nQ`O'#CiO$.yQ`O'#KcO$/RQ`O,5=zO$/WQ`O'#KcO$/]Q`O'#KcO$/kQ`O'#JPO$/yQ`O,5@|O$0RQ!fO1G1hOOQ!0Lf1G1j1G1jO9aQ`O1G3eO@iQ`O1G3eO$0YQ`O1G3eO$0_Q`O1G3eOOQ[1G3e1G3eO!DkQ`O1G3TO!&iQMhO1G3QO$0dQ`O1G3QOOQ[1G3R1G3RO!&iQMhO1G3RO$0iQ`O1G3RO$0qQpO'#HPOOQ[1G3T1G3TO!5|QpO'#I{O!DpQ!bO1G3WOOQ[1G3W1G3WOOQ[,5=q,5=qO$0yQMhO,5=sO9aQ`O,5=sO$#yQ`O,5=uO9UQ`O,5=uO!BeQpO,5=uO!BmQMhO,5=uO:YQMhO,5=uO$1XQ`O'#KaO$1dQ`O,5=vOOQ[1G.k1G.kO$1iQ!0LrO1G.kO@iQ`O1G.kO$1tQ`O1G.kO9kQ!0LrO1G.kO$3|Q!fO,5AOO$4ZQ`O,5AOO9ZQ`O,5AOO$4fQlO,5=}O$4mQ`O,5=}OOQ[1G3g1G3gO`QlO1G3gOOQ[1G3m1G3mOOQ[1G3o1G3oO>rQ`O1G3qO$4rQlO1G3sO$8vQlO'#HrOOQ[1G3v1G3vO$9TQ`O'#HxO>wQ`O'#HzOOQ[1G3|1G3|O$9]QlO1G3|O9kQ!0LrO1G4SOOQ[1G4U1G4UOOQ!0Lb'#G^'#G^O9kQ!0LrO1G4WO9kQ!0LrO1G4YO$=dQ`O,5@`O!(yQlO,5;^O9ZQ`O,5;^O>wQ`O,5:VO!(yQlO,5:VO!BeQpO,5:VO$=iQ?MtO,5:VOOQO,5;^,5;^O$=sQpO'#IcO$>ZQ`O,5@_OOQ!0Lf1G/p1G/pO$>cQpO'#IiO$>mQ`O,5@nOOQ!0Lb1G0w1G0wO##hQpO,5:VOOQO'#Ie'#IeO$>uQpO,5:oOOQ!0Ln,5:o,5:oO#'cQ`O1G0XOOQ!0Lf1G0X1G0XO%[QlO1G0XOOQ!0Lf1G0r1G0rO>wQ`O1G0rO!BeQpO1G0rO!BmQMhO1G0rOOQ!0Lb1G5z1G5zO!BYQ!0LrO1G0[OOQO1G0k1G0kO%[QlO1G0kO$>|Q!0LrO1G0kO$?XQ!0LrO1G0kO!BeQpO1G0[OCuQpO1G0[O$?gQ!0LrO1G0kOOQO1G0[1G0[O$?{Q!0MxO1G0kPOOO-E<Y-E<YPOOO1G.h1G.hOOOO1G/g1G/gO$@VQ!bO,5<hO$@_Q!fO1G4hOOQO1G4n1G4nO%[QlO,5>|O$@iQ`O1G5xO$@qQ`O1G6WO$@yQ!fO1G6XO9ZQ`O,5?SO$ATQ!0MxO1G6UO%[QlO1G6UO$AeQ!0LrO1G6UO$AvQ`O1G6TO$AvQ`O1G6TO9ZQ`O1G6TO$BOQ`O,5?VO9ZQ`O,5?VOOQO,5?V,5?VO$BdQ`O,5?VO$)iQ`O,5?VOOQO-E<i-E<iOOQS1G0_1G0_OOQS1G0a1G0aO#-tQ`O1G0aOOQ[7+(d7+(dO!&iQMhO7+(dO%[QlO7+(dO$BrQ`O7+(dO$B}QMhO7+(dO$C]Q!0MzO,5=WO$EhQ!0MzO,5=YO$GsQ!0MzO,5=WO$JUQ!0MzO,5=YO$LgQ!0MzO,59sO$NlQ!0MzO,5<jO%!wQ!0MzO,5<lO%%SQ!0MzO,5<zOOQ!0Lf7+&_7+&_O%'eQ!0MxO7+&_O%(XQlO'#IdO%(fQ`O,5@aO%(nQ!fO,5@aOOQ!0Lf1G/}1G/}O%(xQ`O7+&hOOQ!0Lf7+&h7+&hO%(}Q?MtO,5:dO%[QlO7+&yO%)XQ?MtO,5:`O%)fQ?MtO,5:hO%)pQ?MtO,5:jO%)zQMhO'#IgO%*UQ`O,5@fOOQ!0Lh1G0b1G0bOOQO1G1q1G1qOOQO1G1r1G1rO%*^Q!jO,5<YO!(yQlO,5<XOOQO-E<j-E<jOOQ!0Lf7+'X7+'XOOOW7+'d7+'dOOOW1G1{1G1{O%*iQ`O1G1{OOQ!0Lf1G1}1G1}OOOO,59m,59mO%*nQ!dO,59mOOOO-E<^-E<^OOQ!0Lh1G/V1G/VO%*uQ!0MxO7+'jOOQ!0Lh,5?[,5?[O%+iQMhO1G2eP%+pQ`O'#IpPOQ!0Lh-E<n-E<nO%,^QMjO,5?_OOQ!0Lh-E<q-E<qO%-PQMjO,5?aOOQ!0Lh-E<s-E<sO%-ZQ!dO1G2vO%-bQ!dO'#CrO%-xQMhO'#KQO$#^QlO'#JtOOQ!0Lh1G2^1G2^O%.PQ`O'#IoO%.eQ`O,5@tO%.eQ`O,5@tO%.mQ`O,5@tO%.xQ`O,5@tOOQO1G2`1G2`O%/WQMjO1G2_O!+rQMhO1G2_O%/hQ(CWO'#IqO%/uQ`O,5@uO!&iQMhO,5@uO%/}Q!dO,5@uOOQ!0Lh1G2c1G2cO%2_Q!fO'#CiO%2iQ`O,5=OOOQ!0Lb,5<|,5<|O%2qQpO,5<|OOQ!0Lb,5<},5<}OCfQ`O,5<|O%2|QpO,5<|OOQ!0Lb,5=Q,5=QO$)iQ`O,5=UOOQO,5?^,5?^OOQO-E<p-E<pOOQ!0Lp1G2g1G2gO##hQpO,5<|O$#^QlO,5=OO%3[Q`O,5<}O%3gQpO,5<}O!+rQMhO'#IsO%4aQMjO1G2rO!+rQMhO'#IuO%5SQMjO1G2tO%5^QMjO1G5oO%5hQMjO1G5oOOQO,5?c,5?cOOQO-E<u-E<uOOQO1G.{1G.{O!9lQpO,59uO%[QlO,59uOOQ!0Lh,5<i,5<iO%5uQ`O1G2YO!+rQMhO1G2aO!+rQMhO1G5oO!+rQMhO1G5oO%5zQ!0MxO7+'lOOQ!0Lf7+'l7+'lO!$fQlO7+'lO%6nQ`O,5;^OOQ!0Lb,5?e,5?eOOQ!0Lb-E<w-E<wO%6sQ!dO'#K[O#'cQ`O7+(dO4UQ!fO7+(dO$BuQ`O7+(dO%6}Q!0MvO'#CiO%7nQ!0LrO,5=RO%8PQ!0MvO,5=RO%8dQ`O,5=ROOQ!0Lb1G5m1G5mOOQ[7+$a7+$aO!BYQ!0LrO7+$aO!BeQpO7+$aO!$fQlO7+&_O%8lQ`O'#JOO%9TQ`O,5@}OOQO1G3f1G3fO9aQ`O,5@}O%9TQ`O,5@}O%9]Q`O,5@}OOQO,5?k,5?kOOQO-E<}-E<}OOQ!0Lf7+'S7+'SO%9bQ`O7+)PO9kQ!0LrO7+)PO9aQ`O7+)PO@iQ`O7+)POOQ[7+(o7+(oO%9gQ!0MvO7+(lO!&iQMhO7+(lO!DfQ`O7+(mOOQ[7+(m7+(mO!&iQMhO7+(mO%9qQ`O'#K`O%9|Q`O,5=kOOQO,5?g,5?gOOQO-E<y-E<yOOQ[7+(r7+(rO%;`QpO'#HYOOQ[1G3_1G3_O!&iQMhO1G3_O%[QlO1G3_O%;gQ`O1G3_O%;rQMhO1G3_O9kQ!0LrO1G3aO$#yQ`O1G3aO9UQ`O1G3aO!BeQpO1G3aO!BmQMhO1G3aO%<QQ`O'#I}O%<fQ`O,5@{O%<nQpO,5@{OOQ!0Lb1G3b1G3bOOQ[7+$V7+$VO@iQ`O7+$VO9kQ!0LrO7+$VO%<yQ`O7+$VO%[QlO1G6jO%[QlO1G6kO%=OQ!0LrO1G6jO%=YQlO1G3iO%=aQ`O1G3iO%=fQlO1G3iOOQ[7+)R7+)RO9kQ!0LrO7+)]O`QlO7+)_OOQ['#Kf'#KfOOQ['#JQ'#JQO%=mQlO,5>^OOQ[,5>^,5>^O%[QlO'#HsO%=zQ`O'#HuOOQ[,5>d,5>dO9ZQ`O,5>dOOQ[,5>f,5>fOOQ[7+)h7+)hOOQ[7+)n7+)nOOQ[7+)r7+)rOOQ[7+)t7+)tO%>PQpO1G5zO%>kQ?MtO1G0xO%>uQ`O1G0xOOQO1G/q1G/qO%?QQ?MtO1G/qO>wQ`O1G/qO!(yQlO'#DkOOQO,5>},5>}OOQO-E<a-E<aOOQO,5?T,5?TOOQO-E<g-E<gO!BeQpO1G/qOOQO-E<c-E<cOOQ!0Ln1G0Z1G0ZOOQ!0Lf7+%s7+%sO#'cQ`O7+%sOOQ!0Lf7+&^7+&^O>wQ`O7+&^O!BeQpO7+&^OOQO7+%v7+%vO$?{Q!0MxO7+&VOOQO7+&V7+&VO%[QlO7+&VO%?[Q!0LrO7+&VO!BYQ!0LrO7+%vO!BeQpO7+%vO%?gQ!0LrO7+&VO%?uQ!0MxO7++pO%[QlO7++pO%@VQ`O7++oO%@VQ`O7++oOOQO1G4q1G4qO9ZQ`O1G4qO%@_Q`O1G4qOOQS7+%{7+%{O#'cQ`O<<LOO4UQ!fO<<LOO%@mQ`O<<LOOOQ[<<LO<<LOO!&iQMhO<<LOO%[QlO<<LOO%@uQ`O<<LOO%AQQ!0MzO,5?_O%C]Q!0MzO,5?aO%EhQ!0MzO1G2_O%GyQ!0MzO1G2rO%JUQ!0MzO1G2tO%LaQ!fO,5?OO%[QlO,5?OOOQO-E<b-E<bO%LkQ`O1G5{OOQ!0Lf<<JS<<JSO%LsQ?MtO1G0sO%NzQ?MtO1G0}O& RQ?MtO1G0}O&#SQ?MtO1G0}O&#ZQ?MtO1G0}O&%[Q?MtO1G0}O&']Q?MtO1G0}O&'dQ?MtO1G0}O&'kQ?MtO1G0}O&)lQ?MtO1G0}O&)sQ?MtO1G0}O&)zQ!0MxO<<JeO&+rQ?MtO1G0}O&,oQ?MvO1G0}O&-rQ?MvO'#JjO&/xQ?MtO1G1bO&0VQ?MtO1G0SO&0aQMjO,5?ROOQO-E<e-E<eO!(yQlO'#FpOOQO'#KX'#KXOOQO1G1t1G1tO&0kQ`O1G1sO&0pQ?MtO,5?YOOOW7+'g7+'gOOOO1G/X1G/XO&0zQ!dO1G4vOOQ!0Lh7+(P7+(PP!&iQMhO,5?[O!+rQMhO7+(bO&1RQ`O,5?ZO9ZQ`O,5?ZOOQO-E<m-E<mO&1aQ`O1G6`O&1aQ`O1G6`O&1iQ`O1G6`O&1tQMjO7+'yO&2UQ!dO,5?]O&2`Q`O,5?]O!&iQMhO,5?]OOQO-E<o-E<oO&2eQ!dO1G6aO&2oQ`O1G6aO&2wQ`O1G2jO!&iQMhO1G2jOOQ!0Lb1G2h1G2hOOQ!0Lb1G2i1G2iO%2qQpO1G2hO!BeQpO1G2hOCfQ`O1G2hOOQ!0Lb1G2p1G2pO&2|QpO1G2hO&3[Q`O1G2jO$)iQ`O1G2iOCfQ`O1G2iO$#^QlO1G2jO&3dQ`O1G2iO&4WQMjO,5?_OOQ!0Lh-E<r-E<rO&4yQMjO,5?aOOQ!0Lh-E<t-E<tO!+rQMhO7++ZOOQ!0Lh1G/a1G/aO&5TQ`O1G/aOOQ!0Lh7+'t7+'tO&5YQMjO7+'{O&5jQMjO7++ZO&5tQMjO7++ZO&6RQ!0MxO<<KWOOQ!0Lf<<KW<<KWO&6uQ`O1G0xO!&iQMhO'#IxO&6zQ`O,5@vO&8|Q!fO<<LOO!&iQMhO1G2mO&9TQ!0LrO1G2mOOQ[<<G{<<G{O!BYQ!0LrO<<G{O&9fQ!0MxO<<IyOOQ!0Lf<<Iy<<IyOOQO,5?j,5?jO&:YQ`O,5?jO&:_Q`O,5?jOOQO-E<|-E<|O&:mQ`O1G6iO&:mQ`O1G6iO9aQ`O1G6iO@iQ`O<<LkOOQ[<<Lk<<LkO&:uQ`O<<LkO9kQ!0LrO<<LkOOQ[<<LW<<LWO%9gQ!0MvO<<LWOOQ[<<LX<<LXO!DfQ`O<<LXO&:zQpO'#IzO&;VQ`O,5@zO!(yQlO,5@zOOQ[1G3V1G3VOOQO'#I|'#I|O9kQ!0LrO'#I|O&;_QpO,5=tOOQ[,5=t,5=tO&;fQpO'#EeO&;mQpO'#GdO&;rQ`O7+(yO&;wQ`O7+(yOOQ[7+(y7+(yO!&iQMhO7+(yO%[QlO7+(yO&<PQ`O7+(yOOQ[7+({7+({O9kQ!0LrO7+({O$#yQ`O7+({O9UQ`O7+({O!BeQpO7+({O&<[Q`O,5?iOOQO-E<{-E<{OOQO'#H]'#H]O&<gQ`O1G6gO9kQ!0LrO<<GqOOQ[<<Gq<<GqO@iQ`O<<GqO&<oQ`O7+,UO&<tQ`O7+,VO%[QlO7+,UO%[QlO7+,VOOQ[7+)T7+)TO&<yQ`O7+)TO&=OQlO7+)TO&=VQ`O7+)TOOQ[<<Lw<<LwOOQ[<<Ly<<LyOOQ[-E=O-E=OOOQ[1G3x1G3xO&=[Q`O,5>_OOQ[,5>a,5>aO&=aQ`O1G4OO9ZQ`O7+&dO!(yQlO7+&dOOQO7+%]7+%]O&=fQ?MtO1G6XO>wQ`O7+%]OOQ!0Lf<<I_<<I_OOQ!0Lf<<Ix<<IxO>wQ`O<<IxOOQO<<Iq<<IqO$?{Q!0MxO<<IqO%[QlO<<IqOOQO<<Ib<<IbO!BYQ!0LrO<<IbO&=pQ!0LrO<<IqO&={Q!0MxO<= [O&>]Q`O<= ZOOQO7+*]7+*]O9ZQ`O7+*]OOQ[ANAjANAjO&>eQ!fOANAjO!&iQMhOANAjO#'cQ`OANAjO4UQ!fOANAjO&>lQ`OANAjO%[QlOANAjO&>tQ!0MzO7+'yO&AVQ!0MzO,5?_O&CbQ!0MzO,5?aO&EmQ!0MzO7+'{O&HOQ!fO1G4jO&HYQ?MtO7+&_O&J^Q?MvO,5=WO&LeQ?MvO,5=YO&LuQ?MvO,5=WO&MVQ?MvO,5=YO&MgQ?MvO,59sO' mQ?MvO,5<jO'#pQ?MvO,5<lO'&UQ?MvO,5<zO''zQ?MtO7+'jO'(XQ?MtO7+'lO'(fQ`O,5<[OOQO7+'_7+'_OOQ!0Lh7+*b7+*bO'(kQMjO<<K|OOQO1G4u1G4uO'(rQ`O1G4uO'(}Q`O1G4uO')]Q`O7++zO')]Q`O7++zO!&iQMhO1G4wO')eQ!dO1G4wO')oQ`O7++{O')wQ`O7+(UO'*SQ!dO7+(UOOQ!0Lb7+(S7+(SOOQ!0Lb7+(T7+(TO!BeQpO7+(SOCfQ`O7+(SO'*^Q`O7+(UO!&iQMhO7+(UO$)iQ`O7+(TO'*cQ`O7+(UOCfQ`O7+(TO'*kQMjO<<NuOOQ!0Lh7+${7+${O!+rQMhO<<NuO'*uQ!dO,5?dOOQO-E<v-E<vO'+PQ!0MvO7+(XO!&iQMhO7+(XOOQ[AN=gAN=gO9aQ`O1G5UOOQO1G5U1G5UO'+aQ`O1G5UO'+fQ`O7+,TO'+fQ`O7+,TO9kQ!0LrOANBVO@iQ`OANBVOOQ[ANBVANBVOOQ[ANArANArOOQ[ANAsANAsO'+nQ`O,5?fOOQO-E<x-E<xO'+yQ?MtO1G6fOOQO,5?h,5?hOOQO-E<z-E<zOOQ[1G3`1G3`O',TQ`O,5=OOOQ[<<Le<<LeO!&iQMhO<<LeO&;rQ`O<<LeO',YQ`O<<LeO%[QlO<<LeOOQ[<<Lg<<LgO9kQ!0LrO<<LgO$#yQ`O<<LgO9UQ`O<<LgO',bQpO1G5TO',mQ`O7+,ROOQ[AN=]AN=]O9kQ!0LrOAN=]OOQ[<= p<= pOOQ[<= q<= qO',uQ`O<= pO',zQ`O<= qOOQ[<<Lo<<LoO'-PQ`O<<LoO'-UQlO<<LoOOQ[1G3y1G3yO>wQ`O7+)jO'-]Q`O<<JOO'-hQ?MtO<<JOOOQO<<Hw<<HwOOQ!0LfAN?dAN?dOOQOAN?]AN?]O$?{Q!0MxOAN?]OOQOAN>|AN>|O%[QlOAN?]OOQO<<Mw<<MwOOQ[G27UG27UO!&iQMhOG27UO#'cQ`OG27UO'-rQ!fOG27UO4UQ!fOG27UO'-yQ`OG27UO'.RQ?MtO<<JeO'.`Q?MvO1G2_O'0UQ?MvO,5?_O'2XQ?MvO,5?aO'4[Q?MvO1G2rO'6_Q?MvO1G2tO'8bQ?MtO<<KWO'8oQ?MtO<<IyOOQO1G1v1G1vO!+rQMhOANAhOOQO7+*a7+*aO'8|Q`O7+*aO'9XQ`O<= fO'9aQ!dO7+*cOOQ!0Lb<<Kp<<KpO$)iQ`O<<KpOCfQ`O<<KpO'9kQ`O<<KpO!&iQMhO<<KpOOQ!0Lb<<Kn<<KnO!BeQpO<<KnO'9vQ!dO<<KpOOQ!0Lb<<Ko<<KoO':QQ`O<<KpO!&iQMhO<<KpO$)iQ`O<<KoO':VQMjOANDaO':aQ!0MvO<<KsOOQO7+*p7+*pO9aQ`O7+*pO':qQ`O<= oOOQ[G27qG27qO9kQ!0LrOG27qO!(yQlO1G5QO':yQ`O7+,QO';RQ`O1G2jO&;rQ`OANBPOOQ[ANBPANBPO!&iQMhOANBPO';WQ`OANBPOOQ[ANBRANBRO9kQ!0LrOANBRO$#yQ`OANBROOQO'#H^'#H^OOQO7+*o7+*oOOQ[G22wG22wOOQ[ANE[ANE[OOQ[ANE]ANE]OOQ[ANBZANBZO';`Q`OANBZOOQ[<<MU<<MUO!(yQlOAN?jOOQOG24wG24wO$?{Q!0MxOG24wO#'cQ`OLD,pOOQ[LD,pLD,pO!&iQMhOLD,pO';eQ!fOLD,pO';lQ?MvO7+'yO'=bQ?MvO,5?_O'?eQ?MvO,5?aO'AhQ?MvO7+'{O'C^QMjOG27SOOQO<<M{<<M{OOQ!0LbANA[ANA[O$)iQ`OANA[OCfQ`OANA[O'CnQ!dOANA[OOQ!0LbANAYANAYO'CuQ`OANA[O!&iQMhOANA[O'DQQ!dOANA[OOQ!0LbANAZANAZOOQO<<N[<<N[OOQ[LD-]LD-]O'D[Q?MtO7+*lOOQO'#Ge'#GeOOQ[G27kG27kO&;rQ`OG27kO!&iQMhOG27kOOQ[G27mG27mO9kQ!0LrOG27mOOQ[G27uG27uO'DfQ?MtOG25UOOQOLD*cLD*cOOQ[!$(![!$(![O#'cQ`O!$(![O!&iQMhO!$(![O'DpQ!0MzOG27SOOQ!0LbG26vG26vO$)iQ`OG26vO'GRQ`OG26vOCfQ`OG26vO'G^Q!dOG26vO!&iQMhOG26vOOQ[LD-VLD-VO&;rQ`OLD-VOOQ[LD-XLD-XOOQ[!)9Ev!)9EvO#'cQ`O!)9EvOOQ!0LbLD,bLD,bO$)iQ`OLD,bOCfQ`OLD,bO'GeQ`OLD,bO'GpQ!dOLD,bOOQ[!$(!q!$(!qOOQ[!.K;b!.K;bO'GwQ?MvOG27SOOQ!0Lb!$( |!$( |O$)iQ`O!$( |OCfQ`O!$( |O'ImQ`O!$( |OOQ!0Lb!)9Eh!)9EhO$)iQ`O!)9EhOCfQ`O!)9EhOOQ!0Lb!.K;S!.K;SO$)iQ`O!.K;SOOQ!0Lb!4/0n!4/0nO!(yQlO'#DxO1PQ`O'#EVO'IxQ!fO'#JpO'JPQ!L^O'#DtO'JWQlO'#D|O'J_Q!fO'#CiO'LuQ!fO'#CiO!(yQlO'#EOO'MVQlO,5;XO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO'#InO( YQ`O,5<hO!(yQlO,5;cO( bQMhO,5;cO(!{QMhO,5;cO!(yQlO,5;vO!&iQMhO'#GlO( bQMhO'#GlO!&iQMhO'#GnO( bQMhO'#GnO1SQ`O'#DXO1SQ`O'#DXO!&iQMhO'#GOO( bQMhO'#GOO!&iQMhO'#GQO( bQMhO'#GQO!&iQMhO'#G`O( bQMhO'#G`O!(yQlO,5:hO(#SQpO'#D]O(#^QpO'#JtO!(yQlO,5@mO'MVQlO1G0sO(#hQ?MtO'#CiO!(yQlO1G2OO!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO(#rQ!dO'#CrO!&iQMhO,5<sO( bQMhO,5<sO'MVQlO1G2QO!(yQlO7+&yO!&iQMhO1G2_O( bQMhO1G2_O!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO!&iQMhO1G2aO( bQMhO1G2aO'MVQlO7+'lO'MVQlO7+&_O!&iQMhOANAhO( bQMhOANAhO($VQ`O'#EmO($[Q`O'#EmO($dQ`O'#F[O($iQ`O'#EwO($nQ`O'#KRO($yQ`O'#KPO(%UQ`O,5;XO(%ZQMjO,5<dO(%bQ`O'#GXO(%gQ`O'#GXO(%lQ`O,5<fO(%tQ`O,5;XO(%|Q?MtO1G1_O(&TQ`O,5<sO(&YQ`O,5<sO(&_Q`O,5<uO(&dQ`O,5<uO(&iQ`O1G2QO(&nQ`O1G0sO(&sQMjO<<K|O(&zQMjO<<K|O7eQMhO'#F{O9UQ`O'#FzOAdQ`O'#ElO!(yQlO,5;sO!3^Q`O'#GXO!3^Q`O'#GXO!3^Q`O'#GZO!3^Q`O'#GZO!+rQMhO7+(bO!+rQMhO7+(bO%-ZQ!dO1G2vO%-ZQ!dO1G2vO!&iQMhO,5=[O!&iQMhO,5=[",
+  stateData: "((P~O'zOS'{OSTOS'|RQ~OPYOQYOSfOY!VOaqOdzOeyOj!POnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!swO!vxO!z]O$V|O$miO%g}O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO&U!WO&[!XO&^!YO&`!ZO&b![O&e!]O&k!^O&q!_O&s!`O&u!aO&w!bO&y!cO(RSO(TTO(WUO(_VO(m[O~OWtO~P`OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa!wOq!nO!Q!oO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!xO#U!pO#V!pO#Y!zO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O'|!{O~OP]XR]X[]Xa]Xp]X!O]X!Q]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X'x]X(_]X(p]X(w]X(x]X~O!e%QX~P(qO_!}O(T#PO(U!}O(V#PO~O_#QO(V#PO(W#PO(X#QO~Ov#SO!S#TO(`#TO(a#VO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R;{O(TTO(WUO(_VO(m[O~O!Y#ZO!Z#WO!W(fP!W(tP~P+}O![#cO~P`OPYOQYOSfOd!jOe!iOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(TTO(WUO(_VO(m[O~On#mO!Y#iO!z]O#g#lO#h#iO(R;|O!i(qP~P.iO!j#oO(R#nO~O!v#sO!z]O%g#tO~O#i#uO~O!e#vO#i#uO~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z$_O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa(dX'x(dX'u(dX!i(dX!W(dX!](dX%h(dX!e(dX~P1qO#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX!](eX%h(eX~Oa(eX'x(eX'u(eX!W(eX!i(eXt(eX!e(eX~P4UO#^$eO~O$[$hO$^$gO$e$mO~OSfO!]$nO$h$oO$j$qO~Oh%VOj%cOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R$sO(TTO(WUO(_$uO(w$}O(x%POg([P~O!j%dO~O!Q%gO!]%hO(R%fO~O!e%lO~Oa%mO'x%mO~O!O%qO~P%[O(S!lO~P%[O%m%uO~P%[Oh%VO!j%dO(R%fO(S!lO~Oe%|O!j%dO(R%fO~O#t$RO~O!O&RO!]&OO!j&QO%i&UO(R%fO(S!lO(TTO(WUO`)UP~O!v#sO~O%r&WO!Q)QX!])QX(R)QX~O(R&XO~Oj!PO!s&^O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO~Od&cOe&bO!v&`O%g&aO%z&_O~P<POd&fOeyOj!PO!]&eO!s&^O!vxO!z]O%g}O%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO~Ob&iO#^&lO%i&gO(S!lO~P=UO!j&mO!s&qO~O!j#oO~O!]XO~Oa%mO'v&yO'x%mO~Oa%mO'v&|O'x%mO~Oa%mO'v'OO'x%mO~O'u]X!W]Xt]X!i]X&Y]X!]]X%h]X!e]X~P(qO!`']O!a'UO!b'UO(S!lO(TTO(WUO~Oq'SO!Q'RO!Y'VO(c'QO![(gP![(vP~P@]Ol'`O!]'^O(R%fO~Oe'eO!j%dO(R%fO~O!O&RO!j&QO~Oq!nO!Q!oO!z;wO#R!pO#S!pO#U!pO#V!pO(S!lO(TTO(WUO(c!mO(m!sO~O!`'kO!a'jO!b'jO#T!pO#Y'lO#Z'lO~PAwOa%mOh%VO!e#vO!j%dO'x%mO(p'nO~O!n'rO#^'pO~PCVOq!nO!Q!oO(TTO(WUO(c!mO(m!sO~O!]XOq(kX!Q(kX!`(kX!a(kX!b(kX!z(kX#R(kX#S(kX#T(kX#U(kX#V(kX#Y(kX#Z(kX(S(kX(T(kX(W(kX(c(kX(m(kX~O!a'jO!b'jO(S!lO~PCuO'}'vO(O'vO(P'xO~O_!}O(T'zO(U!}O(V'zO~O_#QO(V'zO(W'zO(X#QO~Ot'|O~P%[Ov#SO!S#TO(`#TO(a(PO~O!Y(RO!W'UX!W'[X!Z'UX!Z'[X~P+}O!Z(TO!W(fX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z(TO!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~O!W(fX~PGpO!W(YO~O!W(sX!Z(sX!e(sX!i(sX(p(sX~O#^(sX#i#bX![(sX~PIsO#^(ZO!W(uX!Z(uX~O!Z([O!W(tX~O!W(_O~O#^$eO~PIsO![(`O~P`OR#zO!O#yO!Q#{O!j#xO(_VOP!la[!lap!la!Z!la!n!la#P!la#l!la#m!la#n!la#o!la#p!la#q!la#r!la#s!la#t!la#u!la#w!la#y!la#z!la(p!la(w!la(x!la~Oa!la'x!la'u!la!W!la!i!lat!la!]!la%h!la!e!la~PKZO!i(aO~O!e#vO#^(bO(p'nO!Z(rXa(rX'x(rX~O!i(rX~PMvO!Q%gO!]%hO!z]O#g(gO#h(fO(R%fO~O!Z(hO!i(qX~O!i(jO~O!Q%gO!]%hO#h(fO(R%fO~OP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O!e#vO!i(eX~P! dOR(lO!O(kO!j#xO#Q$dO!z!ya!Q!ya~O!v!ya%g!ya!]!ya#g!ya#h!ya(R!ya~P!#eO!v(pO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~O#i(vO~O!Y(xO!i(iP~P%[O(c(zO(m[O~O!Q(|O!j#xO(c(zO(m[O~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z$_Oa$pa'x$pa'u$pa!i$pa!W$pa!]$pa%h$pa!e$pa~Oj)bO~P!&iOh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Og(nP~P!+rO!O)gO!e)fO!]$]X$Y$]X$[$]X$^$]X$e$]X~O!e)fO!](yX$Y(yX$[(yX$^(yX$e(yX~O!O)gO~P!-{O!O)gO!](yX$Y(yX$[(yX$^(yX$e(yX~O!])iO$Y)mO$[)hO$^)hO$e)nO~O!Y)qO~P!(yO$[$hO$^$gO$e)uO~Ol$yX!O$yX#Q$yX'w$yX(w$yX(x$yX~OgkXg$yXlkX!ZkX#^kX~P!/qOv)wO(`)xO(a)zO~Ol*TO!O)|O'w)}O(w$}O(x%PO~Og){O~P!0uOg*UO~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q*WO!]*XO!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~O!Y*[O(R*VO!i(|P~P!1dO#i*^O~O!j*_O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R*aO(TTO(WUO(_$uO(w$}O(x%PO~O!Y*dO!W(}P~P!3cOp*pOq!nO!Q*fO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO(c!mO~O![*mO~P!5WO#Q$dOl(^X!O(^X'w(^X(w(^X(x(^X!Z(^X#^(^X~Og(^X#}(^X~P!6YOl*uO#^*tOg(]X!Z(]X~O!Z*vOg([X~Oj%cO(R&XOg([P~Oq*yO~O!j+OO~O(R(tO~On+TO!Q%gO!Y#iO!]%hO!z]O#g#lO#h#iO(R%fO!i(qP~O!e#vO#i+UO~O!Q%gO!Y+WO!Z([O!]%hO(R%fO!W(tP~Oq'YO!Q+YO!Y+XO(TTO(WUO(c(zO~O![(vP~P!9]O!Z+ZOa)RX'x)RX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa!ha!Z!ha'x!ha'u!ha!W!ha!i!hat!ha!]!ha%h!ha!e!ha~P!:TOR#zO!O#yO!Q#{O!j#xO(_VOP!pa[!pap!pa!Z!pa!n!pa#P!pa#l!pa#m!pa#n!pa#o!pa#p!pa#q!pa#r!pa#s!pa#t!pa#u!pa#w!pa#y!pa#z!pa(p!pa(w!pa(x!pa~Oa!pa'x!pa'u!pa!W!pa!i!pat!pa!]!pa%h!pa!e!pa~P!<kOR#zO!O#yO!Q#{O!j#xO(_VOP!ra[!rap!ra!Z!ra!n!ra#P!ra#l!ra#m!ra#n!ra#o!ra#p!ra#q!ra#r!ra#s!ra#t!ra#u!ra#w!ra#y!ra#z!ra(p!ra(w!ra(x!ra~Oa!ra'x!ra'u!ra!W!ra!i!rat!ra!]!ra%h!ra!e!ra~P!?ROh%VOl+dO!]'^O%h+cO~O!e+fOa(ZX!](ZX'x(ZX!Z(ZX~Oa%mO!]XO'x%mO~Oh%VO!j%dO~Oh%VO!j%dO(R%fO~O!e#vO#i(vO~Ob+qO%i+rO(R+nO(TTO(WUO![)VP~O!Z+sO`)UX~O[+wO~O`+xO~O!]&OO(R%fO(S!lO`)UP~Oh%VO#^+}O~Oh%VOl,QO!]$|O~O!],SO~O!O,UO!]XO~O%m%uO~O!v,ZO~Oe,`O~Ob,aO(R#nO(TTO(WUO![)TP~Oe%|O~O%i!QO(R&XO~P=UO[,fO`,eO~OPYOQYOSfOdzOeyOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!guO!jZO!mYO!nYO!oYO!qvO!vxO!z]O$miO%g}O(TTO(WUO(_VO(m[O~O!]!eO!s!gO$V!kO(R!dO~P!FRO`,eOa%mO'x%mO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa,kOj!OO!swO%k!OO%l!OO%m!OO~P!HkO!j&mO~O&[,qO~O!],sO~O&m,uO&o,vOP&jaQ&jaS&jaY&jaa&jad&jae&jaj&jan&jap&jaq&jar&jax&jaz&ja|&ja!Q&ja!U&ja!V&ja!]&ja!g&ja!j&ja!m&ja!n&ja!o&ja!q&ja!s&ja!v&ja!z&ja$V&ja$m&ja%g&ja%i&ja%k&ja%l&ja%m&ja%p&ja%r&ja%u&ja%v&ja%x&ja&U&ja&[&ja&^&ja&`&ja&b&ja&e&ja&k&ja&q&ja&s&ja&u&ja&w&ja&y&ja'u&ja(R&ja(T&ja(W&ja(_&ja(m&ja![&ja&c&jab&ja&h&ja~O(R,{O~Oh!cX!Z!PX![!PX!e!PX!e!cX!j!cX#^!PX~O!Z!cX![!cX~P# qO!e-QO#^-POh(hX!Z#fX![#fX!e(hX!j(hX~O!Z(hX![(hX~P#!dOh%VO!e-SO!j%dO!Z!_X![!_X~Oq!nO!Q!oO(TTO(WUO(c!mO~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(TTO(WUO(_VO(m[O~O(R<rO~P##yO!Z-WO![(gX~O![-YO~O!e-QO#^-PO!Z#fX![#fX~O!Z-ZO![(vX~O![-]O~O!a-^O!b-^O(S!lO~P##hO![-aO~P'_Ol-dO!]'^O~O!W-iO~Oq!ya!`!ya!a!ya!b!ya#R!ya#S!ya#T!ya#U!ya#V!ya#Y!ya#Z!ya(S!ya(T!ya(W!ya(c!ya(m!ya~P!#eO!n-nO#^-lO~PCVO!a-pO!b-pO(S!lO~PCuOa%mO#^-lO'x%mO~Oa%mO!e#vO#^-lO'x%mO~Oa%mO!e#vO!n-nO#^-lO'x%mO(p'nO~O'}'vO(O'vO(P-uO~Ot-vO~O!W'Ua!Z'Ua~P!:TO!Y-zO!W'UX!Z'UX~P%[O!Z(TO!W(fa~O!W(fa~PGpO!Z([O!W(ta~O!Q%gO!Y.OO!]%hO(R%fO!W'[X!Z'[X~O#^.QO!Z(ra!i(raa(ra'x(ra~O!e#vO~P#,PO!Z(hO!i(qa~O!Q%gO!]%hO#h.UO(R%fO~On.ZO!Q%gO!Y.WO!]%hO!z]O#g.YO#h.WO(R%fO!Z'_X!i'_X~OR._O!j#xO~Oh%VOl.bO!]'^O%h.aO~Oa#ai!Z#ai'x#ai'u#ai!W#ai!i#ait#ai!]#ai%h#ai!e#ai~P!:TOl=|O!O)|O'w)}O(w$}O(x%PO~O#i#]aa#]a#^#]a'x#]a!Z#]a!i#]a!]#]a!W#]a~P#.{O#i(^XP(^XR(^X[(^Xa(^Xp(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X'x(^X(_(^X(p(^X!i(^X!W(^X'u(^Xt(^X!](^X%h(^X!e(^X~P!6YO!Z.oO!i(iX~P!:TO!i.rO~O!W.tO~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kia#kip#ki!Z#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#l#ki~P#2kO#l$OO~P#2kOP$[OR#zOp$aO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO[#kia#ki!Z#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#p#ki~P#5YO#p$QO~P#5YOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO(_VOa#ki!Z#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#u#ki~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO(_VO(x#}Oa#ki!Z#ki#y#ki#z#ki'x#ki(p#ki(w#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#w$UO~P#:_O#w#ki~P#:_O#u$SO~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO(_VO(w#|O(x#}Oa#ki!Z#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#y#ki~P#=TO#y$WO~P#=TOP]XR]X[]Xp]X!O]X!Q]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X!Z]X![]X~O#}]X~P#?rOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO#y<XO#z<YO(_VO(p$YO(w#|O(x#}O~O#}.vO~P#BPO#Q$dO#^<`O$P<`O#}(eX![(eX~P! dOa'ba!Z'ba'x'ba'u'ba!i'ba!W'bat'ba!]'ba%h'ba!e'ba~P!:TO[#kia#kip#ki!Z#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO(w#ki(x#ki~P#EROl=|O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P#ERO!Z.zOg(nX~P!0uOg.|O~Oa$Oi!Z$Oi'x$Oi'u$Oi!W$Oi!i$Oit$Oi!]$Oi%h$Oi!e$Oi~P!:TO$[.}O$^.}O~O$[/OO$^/OO~O!e)fO#^/PO!]$bX$Y$bX$[$bX$^$bX$e$bX~O!Y/QO~O!])iO$Y/SO$[)hO$^)hO$e/TO~O!Z<ZO![(dX~P#BPO![/UO~O!e)fO$e(yX~O$e/WO~Ot/XO~P!&iOv)wO(`)xO(a/[O~O!Q/_O~O(w$}Ol%`a!O%`a'w%`a(x%`a!Z%`a#^%`a~Og%`a#}%`a~P#LTO(x%POl%ba!O%ba'w%ba(w%ba!Z%ba#^%ba~Og%ba#}%ba~P#LvO!ZfX!efX!ifX!i$yX(pfX~P!/qO!Y/hO!Z([O(R/gO!W(tP!W(}P~P!1dOp*pO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO~Oq<oO!Q/iO!Y+XO![*mO(c<nO![(vP~P#NaO!i/jO~P#.{O!Z/kO!e#vO(p'nO!i(|X~O!i/pO~O!Q%gO!Y*[O!]%hO(R%fO!i(|P~O#i/rO~O!W$yX!Z$yX!e%QX~P!/qO!Z/sO!W(}X~P#.{O!e/uO~O!W/wO~OnkO(R/xO~P.iOh%VOp/}O!e#vO!j%dO(p'nO~O!e+fO~Oa%mO!Z0RO'x%mO~O![0TO~P!5WO!a0UO!b0UO(S!lO~P##hOq!nO!Q0VO(TTO(WUO(c!mO~O#Y0XO~Og%`a!Z%`a#^%`a#}%`a~P!0uOg%ba!Z%ba#^%ba#}%ba~P!0uOj%cO(R&XOg'kX!Z'kX~O!Z*vOg([a~Og0bO~OR0cO!O0cO!Q0dO#Q$dOl{a'w{a(w{a(x{a!Z{a#^{a~Og{a#}{a~P$&dO!O)|O'w)}Ol$ra(w$ra(x$ra!Z$ra#^$ra~Og$ra#}$ra~P$'`O!O)|O'w)}Ol$ta(w$ta(x$ta!Z$ta#^$ta~Og$ta#}$ta~P$(RO#i0gO~Og%Sa!Z%Sa#^%Sa#}%Sa~P!0uOl0iO#^0hOg(]a!Z(]a~O!e#vO~O#i0lO~O!Z+ZOa)Ra'x)Ra~OR#zO!O#yO!Q#{O!j#xO(_VOP!pi[!pip!pi!Z!pi!n!pi#P!pi#l!pi#m!pi#n!pi#o!pi#p!pi#q!pi#r!pi#s!pi#t!pi#u!pi#w!pi#y!pi#z!pi(p!pi(w!pi(x!pi~Oa!pi'x!pi'u!pi!W!pi!i!pit!pi!]!pi%h!pi!e!pi~P$*OOh%VOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~On0vO%[0wO(R0tO~P$,fO!e+fOa(Za!](Za'x(Za!Z(Za~O#i0|O~O[]X!ZfX![fX~O!Z0}O![)VX~O![1PO~O[1QO~Ob1SO(R+nO(TTO(WUO~O!]&OO(R%fO`'sX!Z'sX~O!Z+sO`)Ua~O!i1VO~P!:TO[1YO~O`1ZO~O#^1^O~Ol1aO!]$|O~O(c(zO![)SP~Oh%VOl1jO!]1gO%h1iO~O[1tO!Z1rO![)TX~O![1uO~O`1wOa%mO'x%mO~O(R#nO(TTO(WUO~O#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O#t1zO&Y1{Oa(eX~P$2PO#^$eO#t1zO&Y1{O~Oa1}O~P%[Oa2PO~O&c2SOP&aiQ&aiS&aiY&aia&aid&aie&aij&ain&aip&aiq&air&aix&aiz&ai|&ai!Q&ai!U&ai!V&ai!]&ai!g&ai!j&ai!m&ai!n&ai!o&ai!q&ai!s&ai!v&ai!z&ai$V&ai$m&ai%g&ai%i&ai%k&ai%l&ai%m&ai%p&ai%r&ai%u&ai%v&ai%x&ai&U&ai&[&ai&^&ai&`&ai&b&ai&e&ai&k&ai&q&ai&s&ai&u&ai&w&ai&y&ai'u&ai(R&ai(T&ai(W&ai(_&ai(m&ai![&aib&ai&h&ai~Ob2YO![2WO&h2XO~P`O!]XO!j2[O~O&o,vOP&jiQ&jiS&jiY&jia&jid&jie&jij&jin&jip&jiq&jir&jix&jiz&ji|&ji!Q&ji!U&ji!V&ji!]&ji!g&ji!j&ji!m&ji!n&ji!o&ji!q&ji!s&ji!v&ji!z&ji$V&ji$m&ji%g&ji%i&ji%k&ji%l&ji%m&ji%p&ji%r&ji%u&ji%v&ji%x&ji&U&ji&[&ji&^&ji&`&ji&b&ji&e&ji&k&ji&q&ji&s&ji&u&ji&w&ji&y&ji'u&ji(R&ji(T&ji(W&ji(_&ji(m&ji![&ji&c&jib&ji&h&ji~O!W2bO~O!Z!_a![!_a~P#BPOq!nO!Q!oO!Y2hO(c!mO!Z'VX!['VX~P@]O!Z-WO![(ga~O!Z']X![']X~P!9]O!Z-ZO![(va~O![2oO~P'_Oa%mO#^2xO'x%mO~Oa%mO!e#vO#^2xO'x%mO~Oa%mO!e#vO!n2|O#^2xO'x%mO(p'nO~Oa%mO'x%mO~P!:TO!Z$_Ot$pa~O!W'Ui!Z'Ui~P!:TO!Z(TO!W(fi~O!Z([O!W(ti~O!W(ui!Z(ui~P!:TO!Z(ri!i(ria(ri'x(ri~P!:TO#^3OO!Z(ri!i(ria(ri'x(ri~O!Z(hO!i(qi~O!Q%gO!]%hO!z]O#g3TO#h3SO(R%fO~O!Q%gO!]%hO#h3SO(R%fO~Ol3[O!]'^O%h3ZO~Oh%VOl3[O!]'^O%h3ZO~O#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`at%`a!]%`a%h%`a!e%`a~P#LTO#i%baP%baR%ba[%baa%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%bat%ba!]%ba%h%ba!e%ba~P#LvO#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!Z%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`a#^%`at%`a!]%`a%h%`a!e%`a~P#.{O#i%baP%baR%ba[%baa%bap%ba!Q%ba!Z%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%ba#^%bat%ba!]%ba%h%ba!e%ba~P#.{O#i{aP{a[{aa{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a'x{a(_{a(p{a!i{a!W{a'u{at{a!]{a%h{a!e{a~P$&dO#i$raP$raR$ra[$raa$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra'x$ra(_$ra(p$ra!i$ra!W$ra'u$rat$ra!]$ra%h$ra!e$ra~P$'`O#i$taP$taR$ta[$taa$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta'x$ta(_$ta(p$ta!i$ta!W$ta'u$tat$ta!]$ta%h$ta!e$ta~P$(RO#i%SaP%SaR%Sa[%Saa%Sap%Sa!Q%Sa!Z%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa'x%Sa(_%Sa(p%Sa!i%Sa!W%Sa'u%Sa#^%Sat%Sa!]%Sa%h%Sa!e%Sa~P#.{Oa#aq!Z#aq'x#aq'u#aq!W#aq!i#aqt#aq!]#aq%h#aq!e#aq~P!:TO!Y3dO!Z'WX!i'WX~P%[O!Z.oO!i(ia~O!Z.oO!i(ia~P!:TO!W3gO~O#}!la![!la~PKZO#}!ha!Z!ha![!ha~P#BPO#}!pa![!pa~P!<kO#}!ra![!ra~P!?ROg'ZX!Z'ZX~P!+rO!Z.zOg(na~OSfO!]3{O$c3|O~O![4QO~Ot4RO~P#.{Oa$lq!Z$lq'x$lq'u$lq!W$lq!i$lqt$lq!]$lq%h$lq!e$lq~P!:TO!W4TO~P!&iO!Q4UO~O!O)|O'w)}O(x%POl'ga(w'ga!Z'ga#^'ga~Og'ga#}'ga~P%+uO!O)|O'w)}Ol'ia(w'ia(x'ia!Z'ia#^'ia~Og'ia#}'ia~P%,hO(p$YO~P#.{O!WfX!W$yX!ZfX!Z$yX!e%QX#^fX~P!/qO(R<xO~P!1dO!Q%gO!Y4XO!]%hO(R%fO!Z'cX!i'cX~O!Z/kO!i(|a~O!Z/kO!e#vO!i(|a~O!Z/kO!e#vO(p'nO!i(|a~Og${i!Z${i#^${i#}${i~P!0uO!Y4aO!W'eX!Z'eX~P!3cO!Z/sO!W(}a~O!Z/sO!W(}a~P#.{OP]XR]X[]Xp]X!O]X!Q]X!W]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!e%XX#t%XX~P%0XO!e#vO#t4fO~Oh%VO!e#vO!j%dO~Oh%VOp4kO!j%dO(p'nO~Op4pO!e#vO(p'nO~Oq!nO!Q4qO(TTO(WUO(c!mO~O(w$}Ol%`i!O%`i'w%`i(x%`i!Z%`i#^%`i~Og%`i#}%`i~P%3xO(x%POl%bi!O%bi'w%bi(w%bi!Z%bi#^%bi~Og%bi#}%bi~P%4kOg(]i!Z(]i~P!0uO#^4wOg(]i!Z(]i~P!0uO!i4zO~Oa$nq!Z$nq'x$nq'u$nq!W$nq!i$nqt$nq!]$nq%h$nq!e$nq~P!:TO!W5QO~O!Z5RO!])OX~P#.{Oa]Xa$yX!]]X!]$yX%]]X'x]X'x$yX!Z]X!Z$yX~P!/qO%]5UOa%Za!]%Za'x%Za!Z%Za~OlmX!OmX'wmX(wmX(xmX~P%7nOn5VO(R#nO~Ob5]O%i5^O(R+nO(TTO(WUO!Z'rX!['rX~O!Z0}O![)Va~O[5bO~O`5cO~Oa%mO'x%mO~P#.{O!Z5kO#^5mO![)SX~O![5nO~Op5tOq!nO!Q*fO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!pO#U!pO#V!pO#Y5sO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O![5rO~P%:ROl5yO!]1gO%h5xO~Oh%VOl5yO!]1gO%h5xO~Ob6QO(R#nO(TTO(WUO!Z'qX!['qX~O!Z1rO![)Ta~O(TTO(WUO(c6SO~O`6WO~O#t6ZO&Y6[O~PMvO!i6]O~P%[Oa6_O~Oa6_O~P%[Ob2YO![6dO&h2XO~P`O!e6fO~O!e6hOh(hi!Z(hi![(hi!e(hi!j(hip(hi(p(hi~O!Z#fi![#fi~P#BPO#^6iO!Z#fi![#fi~O!Z!_i![!_i~P#BPOa%mO#^6rO'x%mO~Oa%mO!e#vO#^6rO'x%mO~O!Z(rq!i(rqa(rq'x(rq~P!:TO!Z(hO!i(qq~O!Q%gO!]%hO#h6yO(R%fO~O!]'^O%h6|O~Ol7QO!]'^O%h6|O~O#i'gaP'gaR'ga['gaa'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga'x'ga(_'ga(p'ga!i'ga!W'ga'u'gat'ga!]'ga%h'ga!e'ga~P%+uO#i'iaP'iaR'ia['iaa'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia'x'ia(_'ia(p'ia!i'ia!W'ia'u'iat'ia!]'ia%h'ia!e'ia~P%,hO#i${iP${iR${i[${ia${ip${i!Q${i!Z${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i'x${i(_${i(p${i!i${i!W${i'u${i#^${it${i!]${i%h${i!e${i~P#.{O#i%`iP%`iR%`i[%`ia%`ip%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i'x%`i(_%`i(p%`i!i%`i!W%`i'u%`it%`i!]%`i%h%`i!e%`i~P%3xO#i%biP%biR%bi[%bia%bip%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi'x%bi(_%bi(p%bi!i%bi!W%bi'u%bit%bi!]%bi%h%bi!e%bi~P%4kO!Z'Wa!i'Wa~P!:TO!Z.oO!i(ii~O#}#ai!Z#ai![#ai~P#BPOP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kip#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#l#ki~P%MQO#l<PO~P%MQOP$[OR#zOp<]O!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO[#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#p#ki~P& YO#p<RO~P& YOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO(_VO#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#u#ki~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO(_VO(x#}O#y#ki#z#ki#}#ki(p#ki(w#ki!Z#ki![#ki~O#w<VO~P&%cO#w#ki~P&%cO#u<TO~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO(_VO(w#|O(x#}O#z#ki#}#ki(p#ki!Z#ki![#ki~O#y#ki~P&'rO#y<XO~P&'rOa#{y!Z#{y'x#{y'u#{y!W#{y!i#{yt#{y!]#{y%h#{y!e#{y~P!:TO[#kip#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki!Z#ki![#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO(w#ki(x#ki~P&*nOl=}O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P&*nO#Q$dOP(^XR(^X[(^Xl(^Xp(^X!O(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X#}(^X'w(^X(_(^X(p(^X(w(^X(x(^X!Z(^X![(^X~O#}$Oi!Z$Oi![$Oi~P#BPO#}!pi![!pi~P$*OOg'Za!Z'Za~P!0uO![7dO~O!Z'ba!['ba~P#BPO!W7eO~P#.{O!e#vO(p'nO!Z'ca!i'ca~O!Z/kO!i(|i~O!Z/kO!e#vO!i(|i~Og${q!Z${q#^${q#}${q~P!0uO!W'ea!Z'ea~P#.{O!e7lO~O!Z/sO!W(}i~P#.{O!Z/sO!W(}i~O!W7oO~Oh%VOp7tO!j%dO(p'nO~O!e#vO#t7vO~Op7yO!e#vO(p'nO~O!O)|O'w)}O(x%POl'ha(w'ha!Z'ha#^'ha~Og'ha#}'ha~P&3oO!O)|O'w)}Ol'ja(w'ja(x'ja!Z'ja#^'ja~Og'ja#}'ja~P&4bO!W7{O~Og$}q!Z$}q#^$}q#}$}q~P!0uOg(]q!Z(]q~P!0uO#^7|Og(]q!Z(]q~P!0uOa$ny!Z$ny'x$ny'u$ny!W$ny!i$nyt$ny!]$ny%h$ny!e$ny~P!:TO!e6hO~O!Z5RO!])Oa~O!]'^OP$SaR$Sa[$Sap$Sa!O$Sa!Q$Sa!Z$Sa!j$Sa!n$Sa#P$Sa#l$Sa#m$Sa#n$Sa#o$Sa#p$Sa#q$Sa#r$Sa#s$Sa#t$Sa#u$Sa#w$Sa#y$Sa#z$Sa(_$Sa(p$Sa(w$Sa(x$Sa~O%h6|O~P&7SO%]8QOa%Zi!]%Zi'x%Zi!Z%Zi~Oa#ay!Z#ay'x#ay'u#ay!W#ay!i#ayt#ay!]#ay%h#ay!e#ay~P!:TO[8SO~Ob8UO(R+nO(TTO(WUO~O!Z0}O![)Vi~O`8YO~O(c(zO!Z'nX!['nX~O!Z5kO![)Sa~O![8cO~P%:RO(m!sO~P$$oO#Y8dO~O!]1gO~O!]1gO%h8fO~Ol8iO!]1gO%h8fO~O[8nO!Z'qa!['qa~O!Z1rO![)Ti~O!i8rO~O!i8sO~O!i8vO~O!i8vO~P%[Oa8xO~O!e8yO~O!i8zO~O!Z(ui![(ui~P#BPOa%mO#^9SO'x%mO~O!Z(ry!i(rya(ry'x(ry~P!:TO!Z(hO!i(qy~O%h9VO~P&7SO!]'^O%h9VO~O#i${qP${qR${q[${qa${qp${q!Q${q!Z${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q'x${q(_${q(p${q!i${q!W${q'u${q#^${qt${q!]${q%h${q!e${q~P#.{O#i'haP'haR'ha['haa'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha'x'ha(_'ha(p'ha!i'ha!W'ha'u'hat'ha!]'ha%h'ha!e'ha~P&3oO#i'jaP'jaR'ja['jaa'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja'x'ja(_'ja(p'ja!i'ja!W'ja'u'jat'ja!]'ja%h'ja!e'ja~P&4bO#i$}qP$}qR$}q[$}qa$}qp$}q!Q$}q!Z$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q'x$}q(_$}q(p$}q!i$}q!W$}q'u$}q#^$}qt$}q!]$}q%h$}q!e$}q~P#.{O!Z'Wi!i'Wi~P!:TO#}#aq!Z#aq![#aq~P#BPO(w$}OP%`aR%`a[%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a#}%`a(_%`a(p%`a!Z%`a![%`a~Ol%`a!O%`a'w%`a(x%`a~P&HgO(x%POP%baR%ba[%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba#}%ba(_%ba(p%ba!Z%ba![%ba~Ol%ba!O%ba'w%ba(w%ba~P&JnOl=}O!O)|O'w)}O(x%PO~P&HgOl=}O!O)|O'w)}O(w$}O~P&JnOR0cO!O0cO!Q0dO#Q$dOP{a[{al{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a#}{a'w{a(_{a(p{a(w{a(x{a!Z{a![{a~O!O)|O'w)}OP$raR$ra[$ral$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra#}$ra(_$ra(p$ra(w$ra(x$ra!Z$ra![$ra~O!O)|O'w)}OP$taR$ta[$tal$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta#}$ta(_$ta(p$ta(w$ta(x$ta!Z$ta![$ta~Ol=}O!O)|O'w)}O(w$}O(x%PO~OP%SaR%Sa[%Sap%Sa!Q%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa#}%Sa(_%Sa(p%Sa!Z%Sa![%Sa~P'%sO#}$lq!Z$lq![$lq~P#BPO#}$nq!Z$nq![$nq~P#BPO![9dO~O#}9eO~P!0uO!e#vO!Z'ci!i'ci~O!e#vO(p'nO!Z'ci!i'ci~O!Z/kO!i(|q~O!W'ei!Z'ei~P#.{O!Z/sO!W(}q~Op9lO!e#vO(p'nO~O[9nO!W9mO~P#.{O!W9mO~O!e#vO#t9tO~Og(]y!Z(]y~P!0uO!Z'la!]'la~P#.{Oa%Zq!]%Zq'x%Zq!Z%Zq~P#.{O[9yO~O!Z0}O![)Vq~O#^9}O!Z'na!['na~O!Z5kO![)Si~P#BPO!Q:PO~O!]1gO%h:SO~O(TTO(WUO(c:XO~O!Z1rO![)Tq~O!i:[O~O!i:]O~O!i:^O~O!i:^O~P%[O#^:aO!Z#fy![#fy~O!Z#fy![#fy~P#BPO%h:fO~P&7SO!]'^O%h:fO~O#}#{y!Z#{y![#{y~P#BPOP${iR${i[${ip${i!Q${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i#}${i(_${i(p${i!Z${i![${i~P'%sO!O)|O'w)}O(x%POP'gaR'ga['gal'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga#}'ga(_'ga(p'ga(w'ga!Z'ga!['ga~O!O)|O'w)}OP'iaR'ia['ial'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia#}'ia(_'ia(p'ia(w'ia(x'ia!Z'ia!['ia~O(w$}OP%`iR%`i[%`il%`ip%`i!O%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i#}%`i'w%`i(_%`i(p%`i(x%`i!Z%`i![%`i~O(x%POP%biR%bi[%bil%bip%bi!O%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi#}%bi'w%bi(_%bi(p%bi(w%bi!Z%bi![%bi~O#}$ny!Z$ny![$ny~P#BPO#}#ay!Z#ay![#ay~P#BPO!e#vO!Z'cq!i'cq~O!Z/kO!i(|y~O!W'eq!Z'eq~P#.{Op:pO!e#vO(p'nO~O[:tO!W:sO~P#.{O!W:sO~Og(]!R!Z(]!R~P!0uOa%Zy!]%Zy'x%Zy!Z%Zy~P#.{O!Z0}O![)Vy~O!Z5kO![)Sq~O(R:zO~O!]1gO%h:}O~O!i;QO~O%h;VO~P&7SOP${qR${q[${qp${q!Q${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q#}${q(_${q(p${q!Z${q![${q~P'%sO!O)|O'w)}O(x%POP'haR'ha['hal'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha#}'ha(_'ha(p'ha(w'ha!Z'ha!['ha~O!O)|O'w)}OP'jaR'ja['jal'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja#}'ja(_'ja(p'ja(w'ja(x'ja!Z'ja!['ja~OP$}qR$}q[$}qp$}q!Q$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q#}$}q(_$}q(p$}q!Z$}q![$}q~P'%sOg%d!Z!Z%d!Z#^%d!Z#}%d!Z~P!0uO!W;ZO~P#.{Op;[O!e#vO(p'nO~O[;^O!W;ZO~P#.{O!Z'nq!['nq~P#BPO!Z#f!Z![#f!Z~P#BPO#i%d!ZP%d!ZR%d!Z[%d!Za%d!Zp%d!Z!Q%d!Z!Z%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z'x%d!Z(_%d!Z(p%d!Z!i%d!Z!W%d!Z'u%d!Z#^%d!Zt%d!Z!]%d!Z%h%d!Z!e%d!Z~P#.{Op;fO!e#vO(p'nO~O!W;gO~P#.{Op;nO!e#vO(p'nO~O!W;oO~P#.{OP%d!ZR%d!Z[%d!Zp%d!Z!Q%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z#}%d!Z(_%d!Z(p%d!Z!Z%d!Z![%d!Z~P'%sOp;rO!e#vO(p'nO~Ot(dX~P1qO!O%qO~P!(yO(S!lO~P!(yO!WfX!ZfX#^fX~P%0XOP]XR]X[]Xp]X!O]X!Q]X!Z]X!ZfX!j]X!n]X#P]X#Q]X#^]X#^fX#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!efX!i]X!ifX(pfX~P'JlOP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]XO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z<ZO![$pa~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<fO!Q${O!]$|O!g=wO!j$xO#h<lO$V%_O$s<hO$u<jO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Oj)bO~P( bOp!cX(p!cX~P# qOp(hX(p(hX~P#!dO![]X![fX~P'JlO!WfX!W$yX!ZfX!Z$yX#^fX~P!/qO#i<OO~O!e#vO#i<OO~O#^<`O~O#t<SO~O#^<pO!Z(uX![(uX~O#^<`O!Z(sX![(sX~O#i<qO~Og<sO~P!0uO#i<yO~O#i<zO~O!e#vO#i<{O~O!e#vO#i<qO~O#}<|O~P#BPO#i<}O~O#i=OO~O#i=TO~O#i=UO~O#i=VO~O#i=WO~O#}=XO~P!0uO#}=YO~P!0uO#Q#R#S#U#V#Y#g#h#s$m$s$u$x%[%]%g%h%i%p%r%u%v%x%z~'|T#m!V'z(S#nq#l#op!O'{$['{(R$^(c~",
+  goto: "$8f)ZPPPPPP)[PP)_P)pP+Q/VPPPP6aPP6wPP<oP@cP@yP@yPPP@yPCRP@yP@yP@yPCVPC[PCyPHsPPPHwPPPPHwKzPPPLQLrPHwPHwPP! QHwPPPHwPHwP!#XHwP!&o!'t!'}P!(q!(u!(q!,SPPPPPPP!,s!'tPP!-T!.uP!2RHwHw!2W!5d!:Q!:Q!>PPPP!>XHwPPPPPPPPPP!AhP!BuPPHw!DWPHwPHwHwHwHwHwPHw!EjP!HtP!KzP!LO!LY!L^!L^P!HqP!Lb!LbP# hP# lHwPHw# r#$wCV@yP@yP@y@yP#&U@y@y#(h@y#+`@y#-l@y@y#.[#0p#0p#0u#1O#0p#1ZPP#0pP@y#1s@y#5r@y@y6aPPP#9wPPP#:b#:bP#:bP#:x#:bPP#;OP#:uP#:u#;c#:u#;}#<T#<W)_#<Z)_P#<b#<b#<bP)_P)_P)_P)_PP)_P#<h#<kP#<k)_P#<oP#<rP)_P)_P)_P)_P)_P)_)_PP#<x#=O#=Z#=a#=g#=m#=s#>R#>X#>c#>i#>s#>y#?Z#?a#@R#@e#@k#@q#AP#Af#CZ#Ci#Cp#E[#Ej#G[#Gj#Gp#Gv#G|#HW#H^#Hd#Hn#IQ#IWPPPPPPPPPPP#I^PPPPPPP#JR#MY#Nr#Ny$ RPPP$&mP$&v$)o$0Y$0]$0`$1_$1b$1i$1qP$1w$1zP$2h$2l$3d$4r$4w$5_PP$5d$5j$5n$5q$5u$5y$6u$7^$7u$7y$7|$8P$8V$8Y$8^$8bR!|RoqOXst!Z#d%l&p&r&s&u,n,s2S2VY!vQ'^-`1g5qQ%svQ%{yQ&S|Q&h!VS'U!e-WQ'd!iS'j!r!yU*h$|*X*lQ+l%|Q+y&UQ,_&bQ-^']Q-h'eQ-p'kQ0U*nQ1q,`R<m;z%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y,k,n,s-d-l-z.Q.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3d4q5y6Z6[6_6r8i8x9SS#q];w!r)]$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sU*{%[<e<fQ+q&OQ,a&eQ,h&mQ0r+dQ0u+fQ1S+rQ1y,fQ3W.bQ5V0wQ5]0}Q6Q1rQ7O3[Q8U5^R9Y7Q'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s!S!nQ!r!v!y!z$|'U']'^'j'k'l*h*l*n*o-W-^-`-p0U0X1g5q5s%[$ti#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}Q&V|Q'S!eS'Y%h-ZQ+q&OQ,a&eQ0f+OQ1S+rQ1X+xQ1x,eQ1y,fQ5]0}Q5f1ZQ6Q1rQ6T1tQ6U1wQ8U5^Q8X5cQ8q6WQ9|8YQ:Y8nR<o*XrnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VR,c&i&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=r=s[#]WZ#W#Z'V(R!b%im#h#i#l$x%d%g([(f(g(h*W*[*_+W+X+Z,j-Q.O.U.V.W.Y/h/k2[3S3T4X6h6yQ%vxQ%zyS&P|&UQ&]!TQ'a!hQ'c!iQ(o#sS+k%{%|Q+o&OQ,Y&`Q,^&bS-g'd'eQ.d(pQ0{+lQ1R+rQ1T+sQ1W+wQ1l,ZS1p,_,`Q2t-hQ5[0}Q5`1QQ5e1YQ6P1qQ8T5^Q8W5bQ9x8SR:w9y!U$zi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y!^%xy!i!u%z%{%|'T'c'd'e'i's*g+k+l-T-g-h-o/{0O0{2m2t2{4i4j4m7s9pQ+e%vQ,O&YQ,R&ZQ,]&bQ.c(oQ1k,YU1o,^,_,`Q3].dQ5z1lS6O1p1qQ8m6P#f=t#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}o=u<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YW%Ti%V*v=pS&Y!Q&gQ&Z!RQ&[!SQ+S%cR+|&W%]%Si#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}T)x$u)yV*{%[<e<fW'Y!e%h*X-ZS({#y#zQ+`%qQ+v&RS.](k(lQ1b,SQ4x0cR8^5k'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s$i$^c#Y#e%p%r%t(Q(W(r(w)P)Q)R)S)T)U)V)W)X)Y)[)^)`)e)o+a+u-U-s-x-}.P.n.q.u.w.x.y/]0j2c2f2v2}3c3h3i3j3k3l3m3n3o3p3q3r3s3t3w3x4P5O5Y6k6q6v7V7W7a7b8`8|9Q9[9b9c:c:y;R;x=gT#TV#U'RkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ'W!eR2i-W!W!nQ!e!r!v!y!z$|'U']'^'j'k'l*X*h*l*n*o-W-^-`-p0U0X1g5q5sR1d,UnqOXst!Z#d%l&p&r&s&u,n,s2S2VQ&w!^Q't!xS(q#u<OQ+i%yQ,W&]Q,X&_Q-e'bQ-r'mS.m(v<qS0k+U<{Q0y+jQ1f,VQ2Z,uQ2],vQ2e-RQ2r-fQ2u-jS5P0l=VQ5W0zS5Z0|=WQ6j2gQ6n2sQ6s2zQ8R5XQ8}6lQ9O6oQ9R6tR:`8z$d$]c#Y#e%r%t(Q(W(r(w)P)Q)R)S)T)U)V)W)X)Y)[)^)`)e)o+a+u-U-s-x-}.P.n.q.u.x.y/]0j2c2f2v2}3c3h3i3j3k3l3m3n3o3p3q3r3s3t3w3x4P5O5Y6k6q6v7V7W7a7b8`8|9Q9[9b9c:c:y;R;x=gS(m#p'gQ(}#zS+_%p.wS.^(l(nR3U._'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sS#q];wQ&r!XQ&s!YQ&u![Q&v!]R2R,qQ'_!hQ+b%vQ-c'aS.`(o+eQ2p-bW3Y.c.d0q0sQ6m2qW6z3V3X3]5TU9U6{6}7PU:e9W9X9ZS;T:d:gQ;b;UR;j;cU!wQ'^-`T5o1g5q!Q_OXZ`st!V!Z#d#h%d%l&g&i&p&r&s&u(h,n,s.V2S2V]!pQ!r'^-`1g5qT#q];w%^{OPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SS({#y#zS.](k(l!s=^$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sU$fd)],hS(n#p'gU*s%R(u3vU0e*z.i7]Q5T0rQ6{3WQ9X7OR:g9Ym!tQ!r!v!y!z'^'j'k'l-`-p1g5q5sQ'r!uS(d#g1|S-n'i'uQ/n*ZQ/{*gQ2|-qQ4]/oQ4i/}Q4j0OQ4o0WQ7h4WS7s4k4mS7w4p4rQ9g7iQ9k7oQ9p7tQ9u7yS:o9l9mS;Y:p:sS;e;Z;[S;m;f;gS;q;n;oR;t;rQ#wbQ'q!uS(c#g1|S(e#m+TQ+V%eQ+g%wQ+m%}U-m'i'r'uQ.R(dQ/m*ZQ/|*gQ0P*iQ0x+hQ1m,[S2y-n-qQ3R.ZS4[/n/oQ4e/yS4h/{0WQ4l0QQ5|1nQ6u2|Q7g4WQ7k4]U7r4i4o4rQ7u4nQ8k5}S9f7h7iQ9j7oQ9r7wQ9s7xQ:V8lQ:m9gS:n9k9mQ:v9uQ;P:WS;X:o:sS;d;Y;ZS;l;e;gS;p;m;oQ;s;qQ;u;tQ=a=[Q=l=eR=m=fV!wQ'^-`%^aOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SS#wz!j!r=Z$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sR=a=r%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SQ%ej!^%wy!i!u%z%{%|'T'c'd'e'i's*g+k+l-T-g-h-o/{0O0{2m2t2{4i4j4m7s9pS%}z!jQ+h%xQ,[&bW1n,],^,_,`U5}1o1p1qS8l6O6PQ:W8m!r=[$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ=e=qR=f=r%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SY#bWZ#W#Z(R!b%im#h#i#l$x%d%g([(f(g(h*W*[*_+W+X+Z,j-Q.O.U.V.W.Y/h/k2[3S3T4X6h6yQ,i&m!p=]$Z$n)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sR=`'VU'Z!e%h*XR2k-Z%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y,k,n,s-d-l-z.Q.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3d4q5y6Z6[6_6r8i8x9S!r)]$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ,h&mQ0r+dQ3W.bQ7O3[R9Y7Q!b$Tc#Y%p(Q(W(r(w)X)Y)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;x!P<U)[)o-U.w2c2f3h3q3r3w4P6k7W7a7b8`8|9[9b9c:y;R=g!f$Vc#Y%p(Q(W(r(w)U)V)X)Y)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;x!T<W)[)o-U.w2c2f3h3n3o3q3r3w4P6k7W7a7b8`8|9[9b9c:y;R=g!^$Zc#Y%p(Q(W(r(w)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;xQ4V/fz=s)[)o-U.w2c2f3h3w4P6k7W7a7b8`8|9[9b9c:y;R=gQ=x=zR=y={'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sS$oh$pR3|/P'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/P/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sT$kf$qQ$ifS)h$l)lR)t$qT$jf$qT)j$l)l'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/P/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sT$oh$pQ$rhR)s$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9S!s=q$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s#glOPXZst!Z!`!o#S#d#o#{$n%l&i&l&m&p&r&s&u&y'R'`(|)q*f+Y+d,k,n,s-d.b/Q/i0V0d1j1z1{1}2P2S2V2X3[3{4q5y6Z6[6_7Q8i8x!U%Ri$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y#f(u#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}Q+P%`Q/^)|o3v<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!U$yi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=yQ*`$zU*i$|*X*lQ+Q%aQ0Q*j#f=c#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n=d<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YQ=h=tQ=i=uQ=j=vR=k=w!U%Ri$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y#f(u#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}o3v<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YnoOXst!Z#d%l&p&r&s&u,n,s2S2VS*c${*WQ,|&|Q,}'OR4`/s%[%Si#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}Q,P&ZQ1`,RQ5i1_R8]5jV*k$|*X*lU*k$|*X*lT5p1g5qS/y*f/iQ4n0VT7x4q:PQ+g%wQ0P*iQ0x+hQ1m,[Q5|1nQ8k5}Q:V8lR;P:W!U%Oi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=yx*P$v)c*Q*r+R/q0^0_3y4^4{4|4}7f7z9v:l=b=n=oS0Y*q0Z#f<a#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n<b<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!d<t(s)a*Y*b.e.h.l/Y/f/v0p1]3`4S4_4c5h7R7U7m7p7}8P9i9q9w:q:u;W;];h=z={`<u3u7X7[7`9]:h:k;kS=P.g3aT=Q7Z9`!U%Qi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y|*R$v)c*S*q+R/b/q0^0_3y4^4s4{4|4}7f7z9v:l=b=n=oS0[*r0]#f<c#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n<d<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!h<v(s)a*Y*b.f.g.l/Y/f/v0p1]3^3`4S4_4c5h7R7S7U7m7p7}8P9i9q9w:q:u;W;];h=z={d<w3u7Y7Z7`9]9^:h:i:k;kS=R.h3bT=S7[9arnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VQ&d!UR,k&mrnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VR&d!UQ,T&[R1[+|snOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VQ1h,YS5w1k1lU8e5u5v5zS:R8g8hS:{:Q:TQ;_:|R;i;`Q&k!VR,d&gR6T1tR:Y8nS&P|&UR1T+sQ&p!WR,n&qR,t&vT2T,s2VR,x&wQ,w&wR2^,xQ'w!{R-t'wSsOtQ#dXT%os#dQ#OTR'y#OQ#RUR'{#RQ)y$uR/Z)yQ#UVR(O#UQ#XWU(U#X(V-{Q(V#YR-{(WQ-X'WR2j-XQ.p(wS3e.p3fR3f.qQ-`'^R2n-`Y!rQ'^-`1g5qR'h!rQ.{)cR3z.{U#_W%g*WU(]#_(^-|Q(^#`R-|(XQ-['ZR2l-[t`OXst!V!Z#d%l&g&i&p&r&s&u,n,s2S2VS#hZ%dU#r`#h.VR.V(hQ(i#jQ.S(eW.[(i.S3P6wQ3P.TR6w3QQ)l$lR/R)lQ$phR)r$pQ$`cU)_$`-w<[Q-w;xR<[)oQ/l*ZW4Y/l4Z7j9hU4Z/m/n/oS7j4[4]R9h7k$e*O$v(s)a)c*Y*b*q*r*|*}+R.g.h.j.k.l/Y/b/d/f/q/v0^0_0p1]3^3_3`3u3y4S4^4_4c4s4u4{4|4}5h7R7S7T7U7Z7[7^7_7`7f7m7p7z7}8P9]9^9_9i9q9v9w:h:i:j:k:l:q:u;W;];h;k=b=n=o=z={Q/t*bU4b/t4d7nQ4d/vR7n4cS*l$|*XR0S*lx*Q$v)c*q*r+R/q0^0_3y4^4{4|4}7f7z9v:l=b=n=o!d.e(s)a*Y*b.g.h.l/Y/f/v0p1]3`4S4_4c5h7R7U7m7p7}8P9i9q9w:q:u;W;];h=z={U/c*Q.e7Xa7X3u7Z7[7`9]:h:k;kQ0Z*qQ3a.gU4t0Z3a9`R9`7Z|*S$v)c*q*r+R/b/q0^0_3y4^4s4{4|4}7f7z9v:l=b=n=o!h.f(s)a*Y*b.g.h.l/Y/f/v0p1]3^3`4S4_4c5h7R7S7U7m7p7}8P9i9q9w:q:u;W;];h=z={U/e*S.f7Ye7Y3u7Z7[7`9]9^:h:i:k;kQ0]*rQ3b.hU4v0]3b9aR9a7[Q*w%UR0a*wQ5S0pR8O5SQ+[%jR0o+[Q5l1bS8_5l:OR:O8`Q,V&]R1e,VQ5q1gR8b5qQ1s,aS6R1s8oR8o6TQ1O+oW5_1O5a8V9zQ5a1RQ8V5`R9z8WQ+t&PR1U+tQ2V,sR6c2VYrOXst#dQ&t!ZQ+^%lQ,m&pQ,o&rQ,p&sQ,r&uQ2Q,nS2T,s2VR6b2SQ%npQ&x!_Q&{!aQ&}!bQ'P!cQ'o!uQ+]%kQ+i%yQ+{&VQ,c&kQ,z&zW-k'i'q'r'uQ-r'mQ0R*kQ0y+jS1v,d,gQ2_,yQ2`,|Q2a,}Q2u-jW2w-m-n-q-sQ5W0zQ5d1XQ5g1]Q5{1mQ6V1xQ6a2RU6p2v2y2|Q6s2zQ8R5XQ8Z5fQ8[5hQ8a5pQ8j5|Q8p6US9P6q6uQ9R6tQ9{8XQ:U8kQ:Z8qQ:b9QQ:x9|Q;O:VQ;S:cR;a;PQ%yyQ'b!iQ'm!uU+j%z%{%|Q-R'TU-f'c'd'eS-j'i'sQ/z*gS0z+k+lQ2g-TS2s-g-hQ2z-oS4g/{0OQ5X0{Q6l2mQ6o2tQ6t2{U7q4i4j4mQ9o7sR:r9pS$wi=pR*x%VU%Ui%V=pR0`*vQ$viS(s#v+fS)a$b$cQ)c$dQ*Y$xS*b${*WQ*q%OQ*r%QQ*|%]Q*}%^Q+R%bQ.g<aQ.h<cQ.j<gQ.k<iQ.l<kQ/Y)wQ/b*PQ/d*RQ/f*TQ/q*^S/v*d/hQ0^*tQ0_*ul0p+c,Q.a1a1i3Z5x6|8f9V:S:f:};VQ1]+}Q3^<tQ3_<vQ3`<yS3u<^<_Q3y.zS4S/_4UQ4^/rQ4_/sQ4c/uQ4s0YQ4u0[Q4{0gQ4|0hQ4}0iQ5h1^Q7R<}Q7S=PQ7T=RQ7U=TQ7Z<bQ7[<dQ7^<hQ7_<jQ7`<lQ7f4VQ7m4aQ7p4fQ7z4wQ7}5RQ8P5UQ9]<zQ9^<uQ9_<wQ9i7lQ9q7vQ9v7|Q9w8QQ:h=OQ:i=QQ:j=SQ:k=UQ:l9eQ:q9nQ:u9tQ;W=XQ;]:tQ;h;^Q;k=YQ=b=pQ=n=xQ=o=yQ=z=|R={=}Q*z%[Q.i<eR7]<fnpOXst!Z#d%l&p&r&s&u,n,s2S2VQ!fPS#fZ#oQ&z!`W'f!o*f0V4qQ'}#SQ)O#{Q)p$nS,g&i&lQ,l&mQ,y&yS-O'R/iQ-b'`Q.s(|Q/V)qQ0m+YQ0s+dQ2O,kQ2q-dQ3X.bQ4O/QQ4y0dQ5v1jQ6X1zQ6Y1{Q6^1}Q6`2PQ6e2XQ7P3[Q7c3{Q8h5yQ8t6ZQ8u6[Q8w6_Q9Z7QQ:T8iR:_8x#[cOPXZst!Z!`!o#d#o#{%l&i&l&m&p&r&s&u&y'R'`(|*f+Y+d,k,n,s-d.b/i0V0d1j1z1{1}2P2S2V2X3[4q5y6Z6[6_7Q8i8xQ#YWQ#eYQ%puQ%rvS%tw!gS(Q#W(TQ(W#ZQ(r#uQ(w#xQ)P$OQ)Q$PQ)R$QQ)S$RQ)T$SQ)U$TQ)V$UQ)W$VQ)X$WQ)Y$XQ)[$ZQ)^$_Q)`$aQ)e$eW)o$n)q/Q3{Q+a%sQ+u&QS-U'V2hQ-s'pS-x(R-zQ-}(ZQ.P(bQ.n(vQ.q(xQ.u;vQ.w;yQ.x;zQ.y;}Q/]){Q0j+UQ2c-PQ2f-SQ2v-lQ2}.QQ3c.oQ3h<OQ3i<PQ3j<QQ3k<RQ3l<SQ3m<TQ3n<UQ3o<VQ3p<WQ3q<XQ3r<YQ3s.vQ3t<]Q3w<`Q3x<mQ4P<ZQ5O0lQ5Y0|Q6k<pQ6q2xQ6v3OQ7V3dQ7W<qQ7a<sQ7b<{Q8`5mQ8|6iQ9Q6rQ9[<|Q9b=VQ9c=WQ:c9SQ:y9}Q;R:aQ;x#SR=g=sR#[WR'X!el!tQ!r!v!y!z'^'j'k'l-`-p1g5q5sS'T!e-WU*g$|*X*lS-T'U']S0O*h*nQ0W*oQ2m-^Q4m0UR4r0XR(y#xQ!fQT-_'^-`]!qQ!r'^-`1g5qQ#p]R'g;wR)d$dY!uQ'^-`1g5qQ'i!rS's!v!yS'u!z5sS-o'j'kQ-q'lR2{-pT#kZ%dS#jZ%dS%jm,jU(e#h#i#lS.T(f(gQ.X(hQ0n+ZQ3Q.UU3R.V.W.YS6x3S3TR9T6yd#^W#W#Z%g(R([*W+W.O/hr#gZm#h#i#l%d(f(g(h+Z.U.V.W.Y3S3T6yS*Z$x*_Q/o*[Q1|,jQ2d-QQ4W/kQ6g2[Q7i4XQ8{6hT=_'V+XV#aW%g*WU#`W%g*WS(S#W([U(X#Z+W/hS-V'V+XT-y(R.OV'[!e%h*XQ$lfR)v$qT)k$l)lR3}/PT*]$x*_T*e${*WQ0q+cQ1_,QQ3V.aQ5j1aQ5u1iQ6}3ZQ8g5xQ9W6|Q:Q8fQ:d9VQ:|:SQ;U:fQ;`:}R;c;VnqOXst!Z#d%l&p&r&s&u,n,s2S2VQ&j!VR,c&gtmOXst!U!V!Z#d%l&g&p&r&s&u,n,s2S2VR,j&mT%km,jR1c,SR,b&eQ&T|R+z&UR+p&OT&n!W&qT&o!W&qT2U,s2V",
+  nodeNames: "⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",
+  maxTerm: 378,
+  context: trackNewline,
+  nodeProps: [
+    ["isolate", -8,5,6,14,35,37,49,51,53,""],
+    ["group", -26,9,17,19,66,206,210,214,215,217,220,223,233,235,241,243,245,247,250,256,262,264,266,268,270,272,273,"Statement",-34,13,14,30,33,34,40,49,52,53,55,60,68,70,74,78,80,82,83,108,109,118,119,135,138,140,141,142,143,144,146,147,166,168,170,"Expression",-23,29,31,35,39,41,43,172,174,176,177,179,180,181,183,184,185,187,188,189,200,202,204,205,"Type",-3,86,101,107,"ClassItem"],
+    ["openedBy", 23,"<",36,"InterpolationStart",54,"[",58,"{",71,"(",159,"JSXStartCloseTag"],
+    ["closedBy", -2,24,167,">",38,"InterpolationEnd",48,"]",59,"}",72,")",164,"JSXEndTag"]
+  ],
+  propSources: [jsHighlight],
+  skippedNodes: [0,5,6,276],
+  repeatNodeCount: 37,
+  tokenData: "$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$<r#p#q$=h#q#r$>x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(UpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(UpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$h&j(Up(X!b'z0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(V#S$h&j'{0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Up(X!b'{0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$h&j!n),Q(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(T':f$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$h&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$c`$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$c``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$c`$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(X!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Up(X!bOY%ZYZ&cZq%Zqr<Srs&}st%ZtuCruw%Zwx(rx!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr(r<__WS$h&j(Up(X!bOY<SYZ&cZr<Srs=^sw<Swx@nx!^<S!^!_Bm!_#O<S#O#P>`#P#o<S#o#pBm#p;'S<S;'S;=`Cl<%lO<S(Q=g]WS$h&j(X!bOY=^YZ&cZw=^wx>`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$h&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(X!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$h&j(UpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(UpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Up(X!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l<S%9[C}i$h&j(m%1l(Up(X!bOY%ZYZ&cZr%Zrs&}st%ZtuCruw%Zwx(rx!Q%Z!Q![Cr![!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr%9[EoP;=`<%lCr07[FRk$h&j(Up(X!b$[#t(R,2j(c$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr+dHRk$h&j(Up(X!b$[#tOY%ZYZ&cZr%Zrs&}st%ZtuGvuw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Gv![!^%Z!^!_*g!_!c%Z!c!}Gv!}#O%Z#O#P&c#P#R%Z#R#SGv#S#T%Z#T#oGv#o#p*g#p$g%Z$g;'SGv;'S;=`Iv<%lOGv+dIyP;=`<%lGv07[JPP;=`<%lEr(KWJ_`$h&j(Up(X!b#n(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWKl_$h&j$P(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,#xLva(x+JY$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sv%ZvwM{wx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWNW`$h&j#y(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At! c_(W';W$h&j(UpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b'l!!i_$h&j(UpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b&z!#mX$h&jOw!#hwx6cx!^!#h!^!_!$Y!_#o!#h#o#p!$Y#p;'S!#h;'S;=`!$r<%lO!#h`!$]TOw!$Ywx7]x;'S!$Y;'S;=`!$l<%lO!$Y`!$oP;=`<%l!$Y&z!$uP;=`<%l!#h'l!%R]$c`$h&j(UpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r!Q!&PZ(UpOY!%zYZ!$YZr!%zrs!$Ysw!%zwx!&rx#O!%z#O#P!$Y#P;'S!%z;'S;=`!']<%lO!%z!Q!&yU$c`(UpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)r!Q!'`P;=`<%l!%z'l!'fP;=`<%l!!b/5|!'t_!j/.^$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#&U!)O_!i!Lf$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z-!n!*[b$h&j(Up(X!b(S%&f#o(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rxz%Zz{!+d{!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW!+o`$h&j(Up(X!b#l(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;x!,|`$h&j(Up(X!bp+4YOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,$U!.Z_!Z+Jf$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!/ec$h&j(Up(X!b!O.2^OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!0p!P!Q%Z!Q![!3Y![!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!0ya$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!2O!P!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!2Z_!Y!L^$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!3eg$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!3Y![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S!3Y#S#X%Z#X#Y!4|#Y#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!5Vg$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx{%Z{|!6n|}%Z}!O!6n!O!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!6wc$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!8_c$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!9uf$h&j(Up(X!b#m(ChOY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcxz!;Zz{#-}{!P!;Z!P!Q#/d!Q!^!;Z!^!_#(i!_!`#7S!`!a#8i!a!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z?O!;fb$h&j(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z>^!<w`$h&j(X!b!V7`OY!<nYZ&cZw!<nwx!=yx!P!<n!P!Q!Eq!Q!^!<n!^!_!Gr!_!}!<n!}#O!KS#O#P!Dy#P#o!<n#o#p!Gr#p;'S!<n;'S;=`!L]<%lO!<n<z!>Q^$h&j!V7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!?Td$h&j!V7`O!^&c!_#W&c#W#X!>|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!V7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!V7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c<z!C][$h&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#O!CW#O#P!DR#P#Q!=y#Q#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DWX$h&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DvP;=`<%l!CW<z!EOX$h&jOY!=yYZ&cZ!^!=y!^!_!@c!_#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!EnP;=`<%l!=y>^!Ezl$h&j(X!b!V7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(X!b!V7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(X!b!V7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(X!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$h&j(X!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!<n#Q#o!KS#o#p!JU#p;'S!KS;'S;=`!LV<%lO!KS>^!LYP;=`<%l!KS>^!L`P;=`<%l!<n=l!Ll`$h&j(Up!V7`OY!LcYZ&cZr!Lcrs!=ys!P!Lc!P!Q!Mn!Q!^!Lc!^!_# o!_!}!Lc!}#O#%P#O#P!Dy#P#o!Lc#o#p# o#p;'S!Lc;'S;=`#&Y<%lO!Lc=l!Mwl$h&j(Up!V7`OY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#W(r#W#X!Mn#X#Z(r#Z#[!Mn#[#](r#]#^!Mn#^#a(r#a#b!Mn#b#g(r#g#h!Mn#h#i(r#i#j!Mn#j#k!Mn#k#m(r#m#n!Mn#n#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r8Q# vZ(Up!V7`OY# oZr# ors!@cs!P# o!P!Q#!i!Q!}# o!}#O#$R#O#P!Bq#P;'S# o;'S;=`#$y<%lO# o8Q#!pe(Up!V7`OY)rZr)rs#O)r#P#W)r#W#X#!i#X#Z)r#Z#[#!i#[#])r#]#^#!i#^#a)r#a#b#!i#b#g)r#g#h#!i#h#i)r#i#j#!i#j#k#!i#k#m)r#m#n#!i#n;'S)r;'S;=`*Z<%lO)r8Q#$WX(UpOY#$RZr#$Rrs!Ars#O#$R#O#P!B[#P#Q# o#Q;'S#$R;'S;=`#$s<%lO#$R8Q#$vP;=`<%l#$R8Q#$|P;=`<%l# o=l#%W^$h&j(UpOY#%PYZ&cZr#%Prs!CWs!^#%P!^!_#$R!_#O#%P#O#P!DR#P#Q!Lc#Q#o#%P#o#p#$R#p;'S#%P;'S;=`#&S<%lO#%P=l#&VP;=`<%l#%P=l#&]P;=`<%l!Lc?O#&kn$h&j(Up(X!b!V7`OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#W%Z#W#X#&`#X#Z%Z#Z#[#&`#[#]%Z#]#^#&`#^#a%Z#a#b#&`#b#g%Z#g#h#&`#h#i%Z#i#j#&`#j#k#&`#k#m%Z#m#n#&`#n#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z9d#(r](Up(X!b!V7`OY#(iZr#(irs!Grsw#(iwx# ox!P#(i!P!Q#)k!Q!}#(i!}#O#+`#O#P!Bq#P;'S#(i;'S;=`#,`<%lO#(i9d#)th(Up(X!b!V7`OY*gZr*grs'}sw*gwx)rx#O*g#P#W*g#W#X#)k#X#Z*g#Z#[#)k#[#]*g#]#^#)k#^#a*g#a#b#)k#b#g*g#g#h#)k#h#i*g#i#j#)k#j#k#)k#k#m*g#m#n#)k#n;'S*g;'S;=`+Z<%lO*g9d#+gZ(Up(X!bOY#+`Zr#+`rs!JUsw#+`wx#$Rx#O#+`#O#P!B[#P#Q#(i#Q;'S#+`;'S;=`#,Y<%lO#+`9d#,]P;=`<%l#+`9d#,cP;=`<%l#(i?O#,o`$h&j(Up(X!bOY#,fYZ&cZr#,frs!KSsw#,fwx#%Px!^#,f!^!_#+`!_#O#,f#O#P!DR#P#Q!;Z#Q#o#,f#o#p#+`#p;'S#,f;'S;=`#-q<%lO#,f?O#-tP;=`<%l#,f?O#-zP;=`<%l!;Z07[#.[b$h&j(Up(X!b'|0/l!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z07[#/o_$h&j(Up(X!bT0/lOY#/dYZ&cZr#/drs#0nsw#/dwx#4Ox!^#/d!^!_#5}!_#O#/d#O#P#1p#P#o#/d#o#p#5}#p;'S#/d;'S;=`#6|<%lO#/d06j#0w]$h&j(X!bT0/lOY#0nYZ&cZw#0nwx#1px!^#0n!^!_#3R!_#O#0n#O#P#1p#P#o#0n#o#p#3R#p;'S#0n;'S;=`#3x<%lO#0n05W#1wX$h&jT0/lOY#1pYZ&cZ!^#1p!^!_#2d!_#o#1p#o#p#2d#p;'S#1p;'S;=`#2{<%lO#1p0/l#2iST0/lOY#2dZ;'S#2d;'S;=`#2u<%lO#2d0/l#2xP;=`<%l#2d05W#3OP;=`<%l#1p01O#3YW(X!bT0/lOY#3RZw#3Rwx#2dx#O#3R#O#P#2d#P;'S#3R;'S;=`#3r<%lO#3R01O#3uP;=`<%l#3R06j#3{P;=`<%l#0n05x#4X]$h&j(UpT0/lOY#4OYZ&cZr#4Ors#1ps!^#4O!^!_#5Q!_#O#4O#O#P#1p#P#o#4O#o#p#5Q#p;'S#4O;'S;=`#5w<%lO#4O00^#5XW(UpT0/lOY#5QZr#5Qrs#2ds#O#5Q#O#P#2d#P;'S#5Q;'S;=`#5q<%lO#5Q00^#5tP;=`<%l#5Q05x#5zP;=`<%l#4O01p#6WY(Up(X!bT0/lOY#5}Zr#5}rs#3Rsw#5}wx#5Qx#O#5}#O#P#2d#P;'S#5};'S;=`#6v<%lO#5}01p#6yP;=`<%l#5}07[#7PP;=`<%l#/d)3h#7ab$h&j$P(Ch(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;ZAt#8vb$Y#t$h&j(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z'Ad#:Zp$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#U%Z#U#V#?i#V#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#<jk$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!e$b$h&j#})Lv(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#P-<U(Up(X!b$m7`OY*gZr*grs'}sw*gwx)rx!P*g!P!Q#MO!Q!^*g!^!_#Mt!_!`$ f!`#O*g#P;'S*g;'S;=`+Z<%lO*g(n#MXX$j&j(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El#M}Z#p(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx!_*g!_!`#Np!`#O*g#P;'S*g;'S;=`+Z<%lO*g(El#NyX$P(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El$ oX#q(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g*)x$!ga#^*!Y$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`!a$#l!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(K[$#w_#i(Cl$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x$%Vag!*r#q(Ch$e#|$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`$&[!`!a$'f!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$&g_#q(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$'qa#p(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`!a$(v!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$)R`#p(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(Kd$*`a(p(Ct$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!a%Z!a!b$+e!b#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$+p`$h&j#z(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%#`$,}_!z$Ip$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f$.X_!Q0,v$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(n$/]Z$h&jO!^$0O!^!_$0f!_#i$0O#i#j$0k#j#l$0O#l#m$2^#m#o$0O#o#p$0f#p;'S$0O;'S;=`$4i<%lO$0O(n$0VT_#S$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c#S$0kO_#S(n$0p[$h&jO!Q&c!Q![$1f![!^&c!_!c&c!c!i$1f!i#T&c#T#Z$1f#Z#o&c#o#p$3|#p;'S&c;'S;=`&w<%lO&c(n$1kZ$h&jO!Q&c!Q![$2^![!^&c!_!c&c!c!i$2^!i#T&c#T#Z$2^#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$2cZ$h&jO!Q&c!Q![$3U![!^&c!_!c&c!c!i$3U!i#T&c#T#Z$3U#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$3ZZ$h&jO!Q&c!Q![$0O![!^&c!_!c&c!c!i$0O!i#T&c#T#Z$0O#Z#o&c#p;'S&c;'S;=`&w<%lO&c#S$4PR!Q![$4Y!c!i$4Y#T#Z$4Y#S$4]S!Q![$4Y!c!i$4Y#T#Z$4Y#q#r$0f(n$4lP;=`<%l$0O#1[$4z_!W#)l$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$6U`#w(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;p$7c_$h&j(Up(X!b(_+4QOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$8qk$h&j(Up(X!b(R,2j$^#t(c$I[OY%ZYZ&cZr%Zrs&}st%Ztu$8buw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$8b![!^%Z!^!_*g!_!c%Z!c!}$8b!}#O%Z#O#P&c#P#R%Z#R#S$8b#S#T%Z#T#o$8b#o#p*g#p$g%Z$g;'S$8b;'S;=`$<l<%lO$8b+d$:qk$h&j(Up(X!b$^#tOY%ZYZ&cZr%Zrs&}st%Ztu$:fuw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$:f![!^%Z!^!_*g!_!c%Z!c!}$:f!}#O%Z#O#P&c#P#R%Z#R#S$:f#S#T%Z#T#o$:f#o#p*g#p$g%Z$g;'S$:f;'S;=`$<f<%lO$:f+d$<iP;=`<%l$:f07[$<oP;=`<%l$8b#Jf$<{X!]#Hb(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g,#x$=sa(w+JY$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p#q$+e#q;'S%Z;'S;=`+a<%lO%Z)>v$?V_![(CdtBr$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!o7`$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$h&j(Up(X!b'z0/l$[#t(R,2j(c$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$h&j(Up(X!b'{0/l$[#t(R,2j(c$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",
+  tokenizers: [noSemicolon, noSemicolonType, operatorToken, jsx, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, insertSemicolon, new LocalTokenGroup("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOv~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!S~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(a~~", 141, 338), new LocalTokenGroup("j~RQYZXz{^~^O(O~~aP!P!Qd~iO(P~~", 25, 321)],
+  topRules: {"Script":[0,7],"SingleExpression":[1,274],"SingleClassItem":[2,275]},
+  dialects: {jsx: 0, ts: 15091},
+  dynamicPrecedences: {"78":1,"80":1,"92":1,"168":1,"198":1},
+  specialized: [{term: 325, get: (value) => spec_identifier[value] || -1},{term: 341, get: (value) => spec_word[value] || -1},{term: 93, get: (value) => spec_LessThan[value] || -1}],
+  tokenPrec: 15116
+});
+
+/**
+A collection of JavaScript-related
+[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
+*/
+const snippets = [
+    /*@__PURE__*/snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
+        label: "function",
+        detail: "definition",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
+        label: "for",
+        detail: "loop",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
+        label: "for",
+        detail: "of loop",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("do {\n\t${}\n} while (${})", {
+        label: "do",
+        detail: "loop",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("while (${}) {\n\t${}\n}", {
+        label: "while",
+        detail: "loop",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
+        label: "try",
+        detail: "/ catch block",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n}", {
+        label: "if",
+        detail: "block",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", {
+        label: "if",
+        detail: "/ else block",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
+        label: "class",
+        detail: "definition",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("import {${names}} from \"${module}\"\n${}", {
+        label: "import",
+        detail: "named",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("import ${name} from \"${module}\"\n${}", {
+        label: "import",
+        detail: "default",
+        type: "keyword"
+    })
+];
+/**
+A collection of snippet completions for TypeScript. Includes the
+JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
+*/
+const typescriptSnippets = /*@__PURE__*/snippets.concat([
+    /*@__PURE__*/snippetCompletion("interface ${name} {\n\t${}\n}", {
+        label: "interface",
+        detail: "definition",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("type ${name} = ${type}", {
+        label: "type",
+        detail: "definition",
+        type: "keyword"
+    }),
+    /*@__PURE__*/snippetCompletion("enum ${name} {\n\t${}\n}", {
+        label: "enum",
+        detail: "definition",
+        type: "keyword"
+    })
+]);
+
+const cache = /*@__PURE__*/new NodeWeakMap();
+const ScopeNodes = /*@__PURE__*/new Set([
+    "Script", "Block",
+    "FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration",
+    "ForStatement"
+]);
+function defID(type) {
+    return (node, def) => {
+        let id = node.node.getChild("VariableDefinition");
+        if (id)
+            def(id, type);
+        return true;
+    };
+}
+const functionContext = ["FunctionDeclaration"];
+const gatherCompletions = {
+    FunctionDeclaration: /*@__PURE__*/defID("function"),
+    ClassDeclaration: /*@__PURE__*/defID("class"),
+    ClassExpression: () => true,
+    EnumDeclaration: /*@__PURE__*/defID("constant"),
+    TypeAliasDeclaration: /*@__PURE__*/defID("type"),
+    NamespaceDeclaration: /*@__PURE__*/defID("namespace"),
+    VariableDefinition(node, def) { if (!node.matchContext(functionContext))
+        def(node, "variable"); },
+    TypeDefinition(node, def) { def(node, "type"); },
+    __proto__: null
+};
+function getScope(doc, node) {
+    let cached = cache.get(node);
+    if (cached)
+        return cached;
+    let completions = [], top = true;
+    function def(node, type) {
+        let name = doc.sliceString(node.from, node.to);
+        completions.push({ label: name, type });
+    }
+    node.cursor(IterMode$1.IncludeAnonymous).iterate(node => {
+        if (top) {
+            top = false;
+        }
+        else if (node.name) {
+            let gather = gatherCompletions[node.name];
+            if (gather && gather(node, def) || ScopeNodes.has(node.name))
+                return false;
+        }
+        else if (node.to - node.from > 8192) {
+            // Allow caching for bigger internal nodes
+            for (let c of getScope(doc, node.node))
+                completions.push(c);
+            return false;
+        }
+    });
+    cache.set(node, completions);
+    return completions;
+}
+const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
+const dontComplete = [
+    "TemplateString", "String", "RegExp",
+    "LineComment", "BlockComment",
+    "VariableDefinition", "TypeDefinition", "Label",
+    "PropertyDefinition", "PropertyName",
+    "PrivatePropertyDefinition", "PrivatePropertyName",
+    ".", "?."
+];
+/**
+Completion source that looks up locally defined names in
+JavaScript code.
+*/
+function localCompletionSource(context) {
+    let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
+    if (dontComplete.indexOf(inner.name) > -1)
+        return null;
+    let isWord = inner.name == "VariableName" ||
+        inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
+    if (!isWord && !context.explicit)
+        return null;
+    let options = [];
+    for (let pos = inner; pos; pos = pos.parent) {
+        if (ScopeNodes.has(pos.name))
+            options = options.concat(getScope(context.state.doc, pos));
+    }
+    return {
+        options,
+        from: isWord ? inner.from : context.pos,
+        validFor: Identifier
+    };
+}
+
+/**
+A language provider based on the [Lezer JavaScript
+parser](https://github.com/lezer-parser/javascript), extended with
+highlighting and indentation information.
+*/
+const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
+    name: "javascript",
+    parser: /*@__PURE__*/parser.configure({
+        props: [
+            /*@__PURE__*/indentNodeProp.add({
+                IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
+                TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
+                LabeledStatement: flatIndent,
+                SwitchBody: context => {
+                    let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
+                    return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
+                },
+                Block: /*@__PURE__*/delimitedIndent({ closing: "}" }),
+                ArrowFunction: cx => cx.baseIndent + cx.unit,
+                "TemplateString BlockComment": () => null,
+                "Statement Property": /*@__PURE__*/continuedIndent({ except: /^{/ }),
+                JSXElement(context) {
+                    let closed = /^\s*<\//.test(context.textAfter);
+                    return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
+                },
+                JSXEscape(context) {
+                    let closed = /\s*\}/.test(context.textAfter);
+                    return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
+                },
+                "JSXOpenTag JSXSelfClosingTag"(context) {
+                    return context.column(context.node.from) + context.unit;
+                }
+            }),
+            /*@__PURE__*/foldNodeProp.add({
+                "Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": foldInside,
+                BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
+            })
+        ]
+    }),
+    languageData: {
+        closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
+        commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
+        indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
+        wordChars: "$"
+    }
+});
+const jsxSublanguage = {
+    test: node => /^JSX/.test(node.name),
+    facet: /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } })
+};
+/**
+A language provider for TypeScript.
+*/
+const typescriptLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "ts" }, "typescript");
+/**
+Language provider for JSX.
+*/
+const jsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
+    dialect: "jsx",
+    props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
+});
+/**
+Language provider for JSX + TypeScript.
+*/
+const tsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
+    dialect: "jsx ts",
+    props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
+}, "typescript");
+let kwCompletion = (name) => ({ label: name, type: "keyword" });
+const keywords = /*@__PURE__*/"break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);
+const typescriptKeywords = /*@__PURE__*/keywords.concat(/*@__PURE__*/["declare", "implements", "private", "protected", "public"].map(kwCompletion));
+/**
+JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
+and local variable completion.
+*/
+function javascript(config = {}) {
+    let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage)
+        : config.typescript ? typescriptLanguage : javascriptLanguage;
+    let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords);
+    return new LanguageSupport(lang, [
+        javascriptLanguage.data.of({
+            autocomplete: ifNotIn(dontComplete, completeFromList(completions))
+        }),
+        javascriptLanguage.data.of({
+            autocomplete: localCompletionSource
+        }),
+        config.jsx ? autoCloseTags : [],
+    ]);
+}
+function findOpenTag(node) {
+    for (;;) {
+        if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag")
+            return node;
+        if (node.name == "JSXEscape" || !node.parent)
+            return null;
+        node = node.parent;
+    }
+}
+function elementName(doc, tree, max = doc.length) {
+    for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
+        if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
+            ch.name == "JSXMemberExpression")
+            return doc.sliceString(ch.from, Math.min(ch.to, max));
+    }
+    return "";
+}
+const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
+/**
+Extension that will automatically insert JSX close tags when a `>` or
+`/` is typed.
+*/
+const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
+    if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
+        from != to || (text != ">" && text != "/") ||
+        !javascriptLanguage.isActiveAt(view.state, from, -1))
+        return false;
+    let base = defaultInsert(), { state } = base;
+    let closeTags = state.changeByRange(range => {
+        var _a;
+        let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name;
+        if (around.name == "JSXStartTag")
+            around = around.parent;
+        if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
+        else if (text == ">" && around.name == "JSXFragmentTag") {
+            return { range, changes: { from: head, insert: `</>` } };
+        }
+        else if (text == "/" && around.name == "JSXStartCloseTag") {
+            let empty = around.parent, base = empty.parent;
+            if (base && empty.from == head - 2 &&
+                ((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
+                let insert = `${name}>`;
+                return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
+            }
+        }
+        else if (text == ">") {
+            let openTag = findOpenTag(around);
+            if (openTag && openTag.name == "JSXOpenTag" &&
+                !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
+                (name = elementName(state.doc, openTag, head)))
+                return { range, changes: { from: head, insert: `</${name}>` } };
+        }
+        return { range };
+    });
+    if (closeTags.changes.empty)
+        return false;
+    view.dispatch([
+        base,
+        state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
+    ]);
+    return true;
+});
+
+// Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
+const chalky = "#e5c07b", coral = "#e06c75", cyan = "#56b6c2", invalid = "#ffffff", ivory = "#abb2bf", stone = "#7d8799", // Brightened compared to original to increase contrast
+malibu = "#61afef", sage = "#98c379", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#2c313a", background = "#282c34", tooltipBackground = "#353a42", selection = "#3E4451", cursor = "#528bff";
+/**
+The editor theme styles for One Dark.
+*/
+const oneDarkTheme = /*@__PURE__*/EditorView.theme({
+    "&": {
+        color: ivory,
+        backgroundColor: background
+    },
+    ".cm-content": {
+        caretColor: cursor
+    },
+    ".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
+    "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
+    ".cm-panels": { backgroundColor: darkBackground, color: ivory },
+    ".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: background,
+        color: stone,
+        border: "none"
+    },
+    ".cm-activeLineGutter": {
+        backgroundColor: highlightBackground
+    },
+    ".cm-foldPlaceholder": {
+        backgroundColor: "transparent",
+        border: "none",
+        color: "#ddd"
+    },
+    ".cm-tooltip": {
+        border: "none",
+        backgroundColor: tooltipBackground
+    },
+    ".cm-tooltip .cm-tooltip-arrow:before": {
+        borderTopColor: "transparent",
+        borderBottomColor: "transparent"
+    },
+    ".cm-tooltip .cm-tooltip-arrow:after": {
+        borderTopColor: tooltipBackground,
+        borderBottomColor: tooltipBackground
+    },
+    ".cm-tooltip-autocomplete": {
+        "& > ul > li[aria-selected]": {
+            backgroundColor: highlightBackground,
+            color: ivory
+        }
+    }
+}, { dark: true });
+/**
+The highlighting style for code in the One Dark theme.
+*/
+const oneDarkHighlightStyle = /*@__PURE__*/HighlightStyle.define([
+    { tag: tags.keyword,
+        color: violet },
+    { tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
+        color: coral },
+    { tag: [/*@__PURE__*/tags.function(tags.variableName), tags.labelName],
+        color: malibu },
+    { tag: [tags.color, /*@__PURE__*/tags.constant(tags.name), /*@__PURE__*/tags.standard(tags.name)],
+        color: whiskey },
+    { tag: [/*@__PURE__*/tags.definition(tags.name), tags.separator],
+        color: ivory },
+    { tag: [tags.typeName, tags.className, tags.number, tags.changed, tags.annotation, tags.modifier, tags.self, tags.namespace],
+        color: chalky },
+    { tag: [tags.operator, tags.operatorKeyword, tags.url, tags.escape, tags.regexp, tags.link, /*@__PURE__*/tags.special(tags.string)],
+        color: cyan },
+    { tag: [tags.meta, tags.comment],
+        color: stone },
+    { tag: tags.strong,
+        fontWeight: "bold" },
+    { tag: tags.emphasis,
+        fontStyle: "italic" },
+    { tag: tags.strikethrough,
+        textDecoration: "line-through" },
+    { tag: tags.link,
+        color: stone,
+        textDecoration: "underline" },
+    { tag: tags.heading,
+        fontWeight: "bold",
+        color: coral },
+    { tag: [tags.atom, tags.bool, /*@__PURE__*/tags.special(tags.variableName)],
+        color: whiskey },
+    { tag: [tags.processingInstruction, tags.string, tags.inserted],
+        color: sage },
+    { tag: tags.invalid,
+        color: invalid },
+]);
+/**
+Extension to enable the One Dark theme (both the editor theme and
+the highlight style).
+*/
+const oneDark = [oneDarkTheme, /*@__PURE__*/syntaxHighlighting(oneDarkHighlightStyle)];
+
+export { EditorState, EditorView, autocompletion, basicSetup, javascript, language, lineNumbers, lintGutter, oneDark };
diff --git a/core/src/main/resources/static/codemirror-bundle.js b/core/src/main/resources/static/codemirror-bundle.js
new file mode 100644
index 000000000..53c90a02e
--- /dev/null
+++ b/core/src/main/resources/static/codemirror-bundle.js
@@ -0,0 +1,67545 @@
+(function () {
+   'use strict';
+
+   /**
+   The data structure for documents. @nonabstract
+   */
+   let Text$3 = class Text {
+       /**
+       @internal
+       */
+       constructor() {}
+       /**
+       Get the line description around the given position.
+       */
+       lineAt(pos) {
+           if (pos < 0 || pos > this.length)
+               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
+           return this.lineInner(pos, false, 1, 0);
+       }
+       /**
+       Get the description for the given (1-based) line number.
+       */
+       line(n) {
+           if (n < 1 || n > this.lines)
+               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
+           return this.lineInner(n, true, 1, 0);
+       }
+       /**
+       Replace a range of the text with the given content.
+       */
+       replace(from, to, text) {
+           let parts = [];
+           this.decompose(0, from, parts, 2 /* To */);
+           if (text.length)
+               text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
+           this.decompose(to, this.length, parts, 1 /* From */);
+           return TextNode$3.from(parts, this.length - (to - from) + text.length);
+       }
+       /**
+       Append another document to this one.
+       */
+       append(other) {
+           return this.replace(this.length, this.length, other);
+       }
+       /**
+       Retrieve the text between the given points.
+       */
+       slice(from, to = this.length) {
+           let parts = [];
+           this.decompose(from, to, parts, 0);
+           return TextNode$3.from(parts, to - from);
+       }
+       /**
+       Test whether this text is equal to another instance.
+       */
+       eq(other) {
+           if (other == this)
+               return true;
+           if (other.length != this.length || other.lines != this.lines)
+               return false;
+           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
+           let a = new RawTextCursor$3(this), b = new RawTextCursor$3(other);
+           for (let skip = start, pos = start;;) {
+               a.next(skip);
+               b.next(skip);
+               skip = 0;
+               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
+                   return false;
+               pos += a.value.length;
+               if (a.done || pos >= end)
+                   return true;
+           }
+       }
+       /**
+       Iterate over the text. When `dir` is `-1`, iteration happens
+       from end to start. This will return lines and the breaks between
+       them as separate strings.
+       */
+       iter(dir = 1) { return new RawTextCursor$3(this, dir); }
+       /**
+       Iterate over a range of the text. When `from` > `to`, the
+       iterator will run in reverse.
+       */
+       iterRange(from, to = this.length) { return new PartialTextCursor$3(this, from, to); }
+       /**
+       Return a cursor that iterates over the given range of lines,
+       _without_ returning the line breaks between, and yielding empty
+       strings for empty lines.
+       
+       When `from` and `to` are given, they should be 1-based line numbers.
+       */
+       iterLines(from, to) {
+           let inner;
+           if (from == null) {
+               inner = this.iter();
+           }
+           else {
+               if (to == null)
+                   to = this.lines + 1;
+               let start = this.line(from).from;
+               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
+           }
+           return new LineCursor$3(inner);
+       }
+       /**
+       @internal
+       */
+       toString() { return this.sliceString(0); }
+       /**
+       Convert the document to an array of lines (which can be
+       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
+       */
+       toJSON() {
+           let lines = [];
+           this.flatten(lines);
+           return lines;
+       }
+       /**
+       Create a `Text` instance for the given array of lines.
+       */
+       static of(text) {
+           if (text.length == 0)
+               throw new RangeError("A document must have at least one line");
+           if (text.length == 1 && !text[0])
+               return Text.empty;
+           return text.length <= 32 /* Branch */ ? new TextLeaf$3(text) : TextNode$3.from(TextLeaf$3.split(text, []));
+       }
+   };
+   // Leaves store an array of line strings. There are always line breaks
+   // between these strings. Leaves are limited in size and have to be
+   // contained in TextNode instances for bigger documents.
+   let TextLeaf$3 = class TextLeaf extends Text$3 {
+       constructor(text, length = textLength$3(text)) {
+           super();
+           this.text = text;
+           this.length = length;
+       }
+       get lines() { return this.text.length; }
+       get children() { return null; }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let string = this.text[i], end = offset + string.length;
+               if ((isLine ? line : end) >= target)
+                   return new Line$3(offset, end, line, string);
+               offset = end + 1;
+               line++;
+           }
+       }
+       decompose(from, to, target, open) {
+           let text = from <= 0 && to >= this.length ? this
+               : new TextLeaf(sliceText$3(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
+           if (open & 1 /* From */) {
+               let prev = target.pop();
+               let joined = appendText$3(text.text, prev.text.slice(), 0, text.length);
+               if (joined.length <= 32 /* Branch */) {
+                   target.push(new TextLeaf(joined, prev.length + text.length));
+               }
+               else {
+                   let mid = joined.length >> 1;
+                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
+               }
+           }
+           else {
+               target.push(text);
+           }
+       }
+       replace(from, to, text) {
+           if (!(text instanceof TextLeaf))
+               return super.replace(from, to, text);
+           let lines = appendText$3(this.text, appendText$3(text.text, sliceText$3(this.text, 0, from)), to);
+           let newLen = this.length + text.length - (to - from);
+           if (lines.length <= 32 /* Branch */)
+               return new TextLeaf(lines, newLen);
+           return TextNode$3.from(TextLeaf.split(lines, []), newLen);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           let result = "";
+           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
+               let line = this.text[i], end = pos + line.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += line.slice(Math.max(0, from - pos), to - pos);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let line of this.text)
+               target.push(line);
+       }
+       scanIdentical() { return 0; }
+       static split(text, target) {
+           let part = [], len = -1;
+           for (let line of text) {
+               part.push(line);
+               len += line.length + 1;
+               if (part.length == 32 /* Branch */) {
+                   target.push(new TextLeaf(part, len));
+                   part = [];
+                   len = -1;
+               }
+           }
+           if (len > -1)
+               target.push(new TextLeaf(part, len));
+           return target;
+       }
+   };
+   // Nodes provide the tree structure of the `Text` type. They store a
+   // number of other nodes or leaves, taking care to balance themselves
+   // on changes. There are implied line breaks _between_ the children of
+   // a node (but not before the first or after the last child).
+   let TextNode$3 = class TextNode extends Text$3 {
+       constructor(children, length) {
+           super();
+           this.children = children;
+           this.length = length;
+           this.lines = 0;
+           for (let child of children)
+               this.lines += child.lines;
+       }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
+               if ((isLine ? endLine : end) >= target)
+                   return child.lineInner(target, isLine, line, offset);
+               offset = end + 1;
+               line = endLine + 1;
+           }
+       }
+       decompose(from, to, target, open) {
+           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (from <= end && to >= pos) {
+                   let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
+                   if (pos >= from && end <= to && !childOpen)
+                       target.push(child);
+                   else
+                       child.decompose(from - pos, to - pos, target, childOpen);
+               }
+               pos = end + 1;
+           }
+       }
+       replace(from, to, text) {
+           if (text.lines < this.lines)
+               for (let i = 0, pos = 0; i < this.children.length; i++) {
+                   let child = this.children[i], end = pos + child.length;
+                   // Fast path: if the change only affects one child and the
+                   // child's size remains in the acceptable range, only update
+                   // that child
+                   if (from >= pos && to <= end) {
+                       let updated = child.replace(from - pos, to - pos, text);
+                       let totalLines = this.lines - child.lines + updated.lines;
+                       if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
+                           updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
+                           let copy = this.children.slice();
+                           copy[i] = updated;
+                           return new TextNode(copy, this.length - (to - from) + text.length);
+                       }
+                       return super.replace(pos, end, updated);
+                   }
+                   pos = end + 1;
+               }
+           return super.replace(from, to, text);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           let result = "";
+           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += child.sliceString(from - pos, to - pos, lineSep);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let child of this.children)
+               child.flatten(target);
+       }
+       scanIdentical(other, dir) {
+           if (!(other instanceof TextNode))
+               return 0;
+           let length = 0;
+           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
+               : [this.children.length - 1, other.children.length - 1, -1, -1];
+           for (;; iA += dir, iB += dir) {
+               if (iA == eA || iB == eB)
+                   return length;
+               let chA = this.children[iA], chB = other.children[iB];
+               if (chA != chB)
+                   return length + chA.scanIdentical(chB, dir);
+               length += chA.length + 1;
+           }
+       }
+       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
+           let lines = 0;
+           for (let ch of children)
+               lines += ch.lines;
+           if (lines < 32 /* Branch */) {
+               let flat = [];
+               for (let ch of children)
+                   ch.flatten(flat);
+               return new TextLeaf$3(flat, length);
+           }
+           let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
+           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
+           function add(child) {
+               let last;
+               if (child.lines > maxChunk && child instanceof TextNode) {
+                   for (let node of child.children)
+                       add(node);
+               }
+               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
+                   flush();
+                   chunked.push(child);
+               }
+               else if (child instanceof TextLeaf$3 && currentLines &&
+                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf$3 &&
+                   child.lines + last.lines <= 32 /* Branch */) {
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk[currentChunk.length - 1] = new TextLeaf$3(last.text.concat(child.text), last.length + 1 + child.length);
+               }
+               else {
+                   if (currentLines + child.lines > chunk)
+                       flush();
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk.push(child);
+               }
+           }
+           function flush() {
+               if (currentLines == 0)
+                   return;
+               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
+               currentLen = -1;
+               currentLines = currentChunk.length = 0;
+           }
+           for (let child of children)
+               add(child);
+           flush();
+           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
+       }
+   };
+   Text$3.empty = /*@__PURE__*/new TextLeaf$3([""], 0);
+   function textLength$3(text) {
+       let length = -1;
+       for (let line of text)
+           length += line.length + 1;
+       return length;
+   }
+   function appendText$3(text, target, from = 0, to = 1e9) {
+       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
+           let line = text[i], end = pos + line.length;
+           if (end >= from) {
+               if (end > to)
+                   line = line.slice(0, to - pos);
+               if (pos < from)
+                   line = line.slice(from - pos);
+               if (first) {
+                   target[target.length - 1] += line;
+                   first = false;
+               }
+               else
+                   target.push(line);
+           }
+           pos = end + 1;
+       }
+       return target;
+   }
+   function sliceText$3(text, from, to) {
+       return appendText$3(text, [""], from, to);
+   }
+   let RawTextCursor$3 = class RawTextCursor {
+       constructor(text, dir = 1) {
+           this.dir = dir;
+           this.done = false;
+           this.lineBreak = false;
+           this.value = "";
+           this.nodes = [text];
+           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf$3 ? text.text.length : text.children.length) << 1];
+       }
+       nextInner(skip, dir) {
+           this.done = this.lineBreak = false;
+           for (;;) {
+               let last = this.nodes.length - 1;
+               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
+               let size = top instanceof TextLeaf$3 ? top.text.length : top.children.length;
+               if (offset == (dir > 0 ? size : 0)) {
+                   if (last == 0) {
+                       this.done = true;
+                       this.value = "";
+                       return this;
+                   }
+                   if (dir > 0)
+                       this.offsets[last - 1]++;
+                   this.nodes.pop();
+                   this.offsets.pop();
+               }
+               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
+                   this.offsets[last] += dir;
+                   if (skip == 0) {
+                       this.lineBreak = true;
+                       this.value = "\n";
+                       return this;
+                   }
+                   skip--;
+               }
+               else if (top instanceof TextLeaf$3) {
+                   // Move to the next string
+                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
+                   this.offsets[last] += dir;
+                   if (next.length > Math.max(0, skip)) {
+                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
+                       return this;
+                   }
+                   skip -= next.length;
+               }
+               else {
+                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
+                   if (skip > next.length) {
+                       skip -= next.length;
+                       this.offsets[last] += dir;
+                   }
+                   else {
+                       if (dir < 0)
+                           this.offsets[last]--;
+                       this.nodes.push(next);
+                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf$3 ? next.text.length : next.children.length) << 1);
+                   }
+               }
+           }
+       }
+       next(skip = 0) {
+           if (skip < 0) {
+               this.nextInner(-skip, (-this.dir));
+               skip = this.value.length;
+           }
+           return this.nextInner(skip, this.dir);
+       }
+   };
+   let PartialTextCursor$3 = class PartialTextCursor {
+       constructor(text, start, end) {
+           this.value = "";
+           this.done = false;
+           this.cursor = new RawTextCursor$3(text, start > end ? -1 : 1);
+           this.pos = start > end ? text.length : 0;
+           this.from = Math.min(start, end);
+           this.to = Math.max(start, end);
+       }
+       nextInner(skip, dir) {
+           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
+               this.value = "";
+               this.done = true;
+               return this;
+           }
+           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
+           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
+           if (skip > limit)
+               skip = limit;
+           limit -= skip;
+           let { value } = this.cursor.next(skip);
+           this.pos += (value.length + skip) * dir;
+           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
+           this.done = !this.value;
+           return this;
+       }
+       next(skip = 0) {
+           if (skip < 0)
+               skip = Math.max(skip, this.from - this.pos);
+           else if (skip > 0)
+               skip = Math.min(skip, this.to - this.pos);
+           return this.nextInner(skip, this.cursor.dir);
+       }
+       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
+   };
+   let LineCursor$3 = class LineCursor {
+       constructor(inner) {
+           this.inner = inner;
+           this.afterBreak = true;
+           this.value = "";
+           this.done = false;
+       }
+       next(skip = 0) {
+           let { done, lineBreak, value } = this.inner.next(skip);
+           if (done) {
+               this.done = true;
+               this.value = "";
+           }
+           else if (lineBreak) {
+               if (this.afterBreak) {
+                   this.value = "";
+               }
+               else {
+                   this.afterBreak = true;
+                   this.next();
+               }
+           }
+           else {
+               this.value = value;
+               this.afterBreak = false;
+           }
+           return this;
+       }
+       get lineBreak() { return false; }
+   };
+   if (typeof Symbol != "undefined") {
+       Text$3.prototype[Symbol.iterator] = function () { return this.iter(); };
+       RawTextCursor$3.prototype[Symbol.iterator] = PartialTextCursor$3.prototype[Symbol.iterator] =
+           LineCursor$3.prototype[Symbol.iterator] = function () { return this; };
+   }
+   /**
+   This type describes a line in the document. It is created
+   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
+   */
+   let Line$3 = class Line {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The position of the start of the line.
+       */
+       from, 
+       /**
+       The position at the end of the line (_before_ the line break,
+       or at the end of document for the last line).
+       */
+       to, 
+       /**
+       This line's line number (1-based).
+       */
+       number, 
+       /**
+       The line's content.
+       */
+       text) {
+           this.from = from;
+           this.to = to;
+           this.number = number;
+           this.text = text;
+       }
+       /**
+       The length of the line (not including any line break after it).
+       */
+       get length() { return this.to - this.from; }
+   };
+
+   // Compressed representation of the Grapheme_Cluster_Break=Extend
+   // information from
+   // http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
+   // Each pair of elements represents a range, as an offet from the
+   // previous range and a length. Numbers are in base-36, with the empty
+   // string being a shorthand for 1.
+   let extend$2 = /*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
+   // Convert offsets into absolute values
+   for (let i = 1; i < extend$2.length; i++)
+       extend$2[i] += extend$2[i - 1];
+   function isExtendingChar$3(code) {
+       for (let i = 1; i < extend$2.length; i += 2)
+           if (extend$2[i] > code)
+               return extend$2[i - 1] <= code;
+       return false;
+   }
+   function isRegionalIndicator$3(code) {
+       return code >= 0x1F1E6 && code <= 0x1F1FF;
+   }
+   const ZWJ$3 = 0x200d;
+   /**
+   Returns a next grapheme cluster break _after_ (not equal to)
+   `pos`, if `forward` is true, or before otherwise. Returns `pos`
+   itself if no further cluster break is available in the string.
+   Moves across surrogate pairs, extending characters (when
+   `includeExtending` is true), characters joined with zero-width
+   joiners, and flag emoji.
+   */
+   function findClusterBreak$4(str, pos, forward = true, includeExtending = true) {
+       return (forward ? nextClusterBreak$3 : prevClusterBreak$3)(str, pos, includeExtending);
+   }
+   function nextClusterBreak$3(str, pos, includeExtending) {
+       if (pos == str.length)
+           return pos;
+       // If pos is in the middle of a surrogate pair, move to its start
+       if (pos && surrogateLow$4(str.charCodeAt(pos)) && surrogateHigh$4(str.charCodeAt(pos - 1)))
+           pos--;
+       let prev = codePointAt$4(str, pos);
+       pos += codePointSize$4(prev);
+       while (pos < str.length) {
+           let next = codePointAt$4(str, pos);
+           if (prev == ZWJ$3 || next == ZWJ$3 || includeExtending && isExtendingChar$3(next)) {
+               pos += codePointSize$4(next);
+               prev = next;
+           }
+           else if (isRegionalIndicator$3(next)) {
+               let countBefore = 0, i = pos - 2;
+               while (i >= 0 && isRegionalIndicator$3(codePointAt$4(str, i))) {
+                   countBefore++;
+                   i -= 2;
+               }
+               if (countBefore % 2 == 0)
+                   break;
+               else
+                   pos += 2;
+           }
+           else {
+               break;
+           }
+       }
+       return pos;
+   }
+   function prevClusterBreak$3(str, pos, includeExtending) {
+       while (pos > 0) {
+           let found = nextClusterBreak$3(str, pos - 2, includeExtending);
+           if (found < pos)
+               return found;
+           pos--;
+       }
+       return 0;
+   }
+   function surrogateLow$4(ch) { return ch >= 0xDC00 && ch < 0xE000; }
+   function surrogateHigh$4(ch) { return ch >= 0xD800 && ch < 0xDC00; }
+   /**
+   Find the code point at the given position in a string (like the
+   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
+   string method).
+   */
+   function codePointAt$4(str, pos) {
+       let code0 = str.charCodeAt(pos);
+       if (!surrogateHigh$4(code0) || pos + 1 == str.length)
+           return code0;
+       let code1 = str.charCodeAt(pos + 1);
+       if (!surrogateLow$4(code1))
+           return code0;
+       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
+   }
+   /**
+   Given a Unicode codepoint, return the JavaScript string that
+   respresents it (like
+   [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
+   */
+   function fromCodePoint$2(code) {
+       if (code <= 0xffff)
+           return String.fromCharCode(code);
+       code -= 0x10000;
+       return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
+   }
+   /**
+   The first character that takes up two positions in a JavaScript
+   string. It is often useful to compare with this after calling
+   `codePointAt`, to figure out whether your character takes up 1 or
+   2 index positions.
+   */
+   function codePointSize$4(code) { return code < 0x10000 ? 1 : 2; }
+
+   const DefaultSplit$3 = /\r\n?|\n/;
+   /**
+   Distinguishes different ways in which positions can be mapped.
+   */
+   var MapMode$3 = /*@__PURE__*/(function (MapMode) {
+       /**
+       Map a position to a valid new position, even when its context
+       was deleted.
+       */
+       MapMode[MapMode["Simple"] = 0] = "Simple";
+       /**
+       Return null if deletion happens across the position.
+       */
+       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
+       /**
+       Return null if the character _before_ the position is deleted.
+       */
+       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
+       /**
+       Return null if the character _after_ the position is deleted.
+       */
+       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
+   return MapMode})(MapMode$3 || (MapMode$3 = {}));
+   /**
+   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
+   that doesn't store the inserted text. As such, it can't be
+   applied, but is cheaper to store and manipulate.
+   */
+   let ChangeDesc$3 = class ChangeDesc {
+       // Sections are encoded as pairs of integers. The first is the
+       // length in the current document, and the second is -1 for
+       // unaffected sections, and the length of the replacement content
+       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
+       // 0), and a replacement two positive numbers.
+       constructor(
+       /**
+       @internal
+       */
+       sections) {
+           this.sections = sections;
+       }
+       /**
+       The length of the document before the change.
+       */
+       get length() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2)
+               result += this.sections[i];
+           return result;
+       }
+       /**
+       The length of the document after the change.
+       */
+       get newLength() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let ins = this.sections[i + 1];
+               result += ins < 0 ? this.sections[i] : ins;
+           }
+           return result;
+       }
+       /**
+       False when there are actual changes in this set.
+       */
+       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
+       /**
+       Iterate over the unchanged parts left by these changes. `posA`
+       provides the position of the range in the old document, `posB`
+       the new position in the changed document.
+       */
+       iterGaps(f) {
+           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0) {
+                   f(posA, posB, len);
+                   posB += len;
+               }
+               else {
+                   posB += ins;
+               }
+               posA += len;
+           }
+       }
+       /**
+       Iterate over the ranges changed by these changes. (See
+       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
+       variant that also provides you with the inserted text.)
+       `fromA`/`toA` provides the extent of the change in the starting
+       document, `fromB`/`toB` the extent of the replacement in the
+       changed document.
+       
+       When `individual` is true, adjacent changes (which are kept
+       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
+       reported separately.
+       */
+       iterChangedRanges(f, individual = false) {
+           iterChanges$3(this, f, individual);
+       }
+       /**
+       Get a description of the inverted form of these changes.
+       */
+       get invertedDesc() {
+           let sections = [];
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0)
+                   sections.push(len, ins);
+               else
+                   sections.push(ins, len);
+           }
+           return new ChangeDesc(sections);
+       }
+       /**
+       Compute the combined effect of applying another set of changes
+       after this one. The length of the document after this set should
+       match the length before `other`.
+       */
+       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets$3(this, other); }
+       /**
+       Map this description, which should start with the same document
+       as `other`, over another set of changes, so that it can be
+       applied after it. When `before` is true, map as if the changes
+       in `other` happened before the ones in `this`.
+       */
+       mapDesc(other, before = false) { return other.empty ? this : mapSet$3(this, other, before); }
+       mapPos(pos, assoc = -1, mode = MapMode$3.Simple) {
+           let posA = 0, posB = 0;
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
+               if (ins < 0) {
+                   if (endA > pos)
+                       return posB + (pos - posA);
+                   posB += len;
+               }
+               else {
+                   if (mode != MapMode$3.Simple && endA >= pos &&
+                       (mode == MapMode$3.TrackDel && posA < pos && endA > pos ||
+                           mode == MapMode$3.TrackBefore && posA < pos ||
+                           mode == MapMode$3.TrackAfter && endA > pos))
+                       return null;
+                   if (endA > pos || endA == pos && assoc < 0 && !len)
+                       return pos == posA || assoc < 0 ? posB : posB + ins;
+                   posB += ins;
+               }
+               posA = endA;
+           }
+           if (pos > posA)
+               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
+           return posB;
+       }
+       /**
+       Check whether these changes touch a given range. When one of the
+       changes entirely covers the range, the string `"cover"` is
+       returned.
+       */
+       touchesRange(from, to = from) {
+           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
+               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
+               if (ins >= 0 && pos <= to && end >= from)
+                   return pos < from && end > to ? "cover" : true;
+               pos = end;
+           }
+           return false;
+       }
+       /**
+       @internal
+       */
+       toString() {
+           let result = "";
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
+           }
+           return result;
+       }
+       /**
+       Serialize this change desc to a JSON-representable value.
+       */
+       toJSON() { return this.sections; }
+       /**
+       Create a change desc from its JSON representation (as produced
+       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
+               throw new RangeError("Invalid JSON representation of ChangeDesc");
+           return new ChangeDesc(json);
+       }
+       /**
+       @internal
+       */
+       static create(sections) { return new ChangeDesc(sections); }
+   };
+   /**
+   A change set represents a group of modifications to a document. It
+   stores the document length, and can only be applied to documents
+   with exactly that length.
+   */
+   let ChangeSet$3 = class ChangeSet extends ChangeDesc$3 {
+       constructor(sections, 
+       /**
+       @internal
+       */
+       inserted) {
+           super(sections);
+           this.inserted = inserted;
+       }
+       /**
+       Apply the changes to a document, returning the modified
+       document.
+       */
+       apply(doc) {
+           if (this.length != doc.length)
+               throw new RangeError("Applying change set to a document with the wrong length");
+           iterChanges$3(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
+           return doc;
+       }
+       mapDesc(other, before = false) { return mapSet$3(this, other, before, true); }
+       /**
+       Given the document as it existed _before_ the changes, return a
+       change set that represents the inverse of this set, which could
+       be used to go from the document created by the changes back to
+       the document as it existed before the changes.
+       */
+       invert(doc) {
+           let sections = this.sections.slice(), inserted = [];
+           for (let i = 0, pos = 0; i < sections.length; i += 2) {
+               let len = sections[i], ins = sections[i + 1];
+               if (ins >= 0) {
+                   sections[i] = ins;
+                   sections[i + 1] = len;
+                   let index = i >> 1;
+                   while (inserted.length < index)
+                       inserted.push(Text$3.empty);
+                   inserted.push(len ? doc.slice(pos, pos + len) : Text$3.empty);
+               }
+               pos += len;
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       Combine two subsequent change sets into a single set. `other`
+       must start in the document produced by `this`. If `this` goes
+       `docA` → `docB` and `other` represents `docB` → `docC`, the
+       returned value will represent the change `docA` → `docC`.
+       */
+       compose(other) { return this.empty ? other : other.empty ? this : composeSets$3(this, other, true); }
+       /**
+       Given another change set starting in the same document, maps this
+       change set over the other, producing a new change set that can be
+       applied to the document produced by applying `other`. When
+       `before` is `true`, order changes as if `this` comes before
+       `other`, otherwise (the default) treat `other` as coming first.
+       
+       Given two changes `A` and `B`, `A.compose(B.map(A))` and
+       `B.compose(A.map(B, true))` will produce the same document. This
+       provides a basic form of [operational
+       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
+       and can be used for collaborative editing.
+       */
+       map(other, before = false) { return other.empty ? this : mapSet$3(this, other, before, true); }
+       /**
+       Iterate over the changed ranges in the document, calling `f` for
+       each, with the range in the original document (`fromA`-`toA`)
+       and the range that replaces it in the new document
+       (`fromB`-`toB`).
+       
+       When `individual` is true, adjacent changes are reported
+       separately.
+       */
+       iterChanges(f, individual = false) {
+           iterChanges$3(this, f, individual);
+       }
+       /**
+       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
+       set.
+       */
+       get desc() { return ChangeDesc$3.create(this.sections); }
+       /**
+       @internal
+       */
+       filter(ranges) {
+           let resultSections = [], resultInserted = [], filteredSections = [];
+           let iter = new SectionIter$3(this);
+           done: for (let i = 0, pos = 0;;) {
+               let next = i == ranges.length ? 1e9 : ranges[i++];
+               while (pos < next || pos == next && iter.len == 0) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, next - pos);
+                   addSection$3(filteredSections, len, -1);
+                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
+                   addSection$3(resultSections, len, ins);
+                   if (ins > 0)
+                       addInsert$3(resultInserted, resultSections, iter.text);
+                   iter.forward(len);
+                   pos += len;
+               }
+               let end = ranges[i++];
+               while (pos < end) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, end - pos);
+                   addSection$3(resultSections, len, -1);
+                   addSection$3(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
+                   iter.forward(len);
+                   pos += len;
+               }
+           }
+           return { changes: new ChangeSet(resultSections, resultInserted),
+               filtered: ChangeDesc$3.create(filteredSections) };
+       }
+       /**
+       Serialize this change set to a JSON-representable value.
+       */
+       toJSON() {
+           let parts = [];
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let len = this.sections[i], ins = this.sections[i + 1];
+               if (ins < 0)
+                   parts.push(len);
+               else if (ins == 0)
+                   parts.push([len]);
+               else
+                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
+           }
+           return parts;
+       }
+       /**
+       Create a change set for the given changes, for a document of the
+       given length, using `lineSep` as line separator.
+       */
+       static of(changes, length, lineSep) {
+           let sections = [], inserted = [], pos = 0;
+           let total = null;
+           function flush(force = false) {
+               if (!force && !sections.length)
+                   return;
+               if (pos < length)
+                   addSection$3(sections, length - pos, -1);
+               let set = new ChangeSet(sections, inserted);
+               total = total ? total.compose(set.map(total)) : set;
+               sections = [];
+               inserted = [];
+               pos = 0;
+           }
+           function process(spec) {
+               if (Array.isArray(spec)) {
+                   for (let sub of spec)
+                       process(sub);
+               }
+               else if (spec instanceof ChangeSet) {
+                   if (spec.length != length)
+                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
+                   flush();
+                   total = total ? total.compose(spec.map(total)) : spec;
+               }
+               else {
+                   let { from, to = from, insert } = spec;
+                   if (from > to || from < 0 || to > length)
+                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
+                   let insText = !insert ? Text$3.empty : typeof insert == "string" ? Text$3.of(insert.split(lineSep || DefaultSplit$3)) : insert;
+                   let insLen = insText.length;
+                   if (from == to && insLen == 0)
+                       return;
+                   if (from < pos)
+                       flush();
+                   if (from > pos)
+                       addSection$3(sections, from - pos, -1);
+                   addSection$3(sections, to - from, insLen);
+                   addInsert$3(inserted, sections, insText);
+                   pos = to;
+               }
+           }
+           process(changes);
+           flush(!total);
+           return total;
+       }
+       /**
+       Create an empty changeset of the given length.
+       */
+       static empty(length) {
+           return new ChangeSet(length ? [length, -1] : [], []);
+       }
+       /**
+       Create a changeset from its JSON representation (as produced by
+       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json))
+               throw new RangeError("Invalid JSON representation of ChangeSet");
+           let sections = [], inserted = [];
+           for (let i = 0; i < json.length; i++) {
+               let part = json[i];
+               if (typeof part == "number") {
+                   sections.push(part, -1);
+               }
+               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
+                   throw new RangeError("Invalid JSON representation of ChangeSet");
+               }
+               else if (part.length == 1) {
+                   sections.push(part[0], 0);
+               }
+               else {
+                   while (inserted.length < i)
+                       inserted.push(Text$3.empty);
+                   inserted[i] = Text$3.of(part.slice(1));
+                   sections.push(part[0], inserted[i].length);
+               }
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       @internal
+       */
+       static createSet(sections, inserted) {
+           return new ChangeSet(sections, inserted);
+       }
+   };
+   function addSection$3(sections, len, ins, forceJoin = false) {
+       if (len == 0 && ins <= 0)
+           return;
+       let last = sections.length - 2;
+       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
+           sections[last] += len;
+       else if (len == 0 && sections[last] == 0)
+           sections[last + 1] += ins;
+       else if (forceJoin) {
+           sections[last] += len;
+           sections[last + 1] += ins;
+       }
+       else
+           sections.push(len, ins);
+   }
+   function addInsert$3(values, sections, value) {
+       if (value.length == 0)
+           return;
+       let index = (sections.length - 2) >> 1;
+       if (index < values.length) {
+           values[values.length - 1] = values[values.length - 1].append(value);
+       }
+       else {
+           while (values.length < index)
+               values.push(Text$3.empty);
+           values.push(value);
+       }
+   }
+   function iterChanges$3(desc, f, individual) {
+       let inserted = desc.inserted;
+       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
+           let len = desc.sections[i++], ins = desc.sections[i++];
+           if (ins < 0) {
+               posA += len;
+               posB += len;
+           }
+           else {
+               let endA = posA, endB = posB, text = Text$3.empty;
+               for (;;) {
+                   endA += len;
+                   endB += ins;
+                   if (ins && inserted)
+                       text = text.append(inserted[(i - 2) >> 1]);
+                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
+                       break;
+                   len = desc.sections[i++];
+                   ins = desc.sections[i++];
+               }
+               f(posA, endA, posB, endB, text);
+               posA = endA;
+               posB = endB;
+           }
+       }
+   }
+   function mapSet$3(setA, setB, before, mkSet = false) {
+       let sections = [], insert = mkSet ? [] : null;
+       let a = new SectionIter$3(setA), b = new SectionIter$3(setB);
+       for (let posA = 0, posB = 0;;) {
+           if (a.ins == -1) {
+               posA += a.len;
+               a.next();
+           }
+           else if (b.ins == -1 && posB < posA) {
+               let skip = Math.min(b.len, posA - posB);
+               b.forward(skip);
+               addSection$3(sections, skip, -1);
+               posB += skip;
+           }
+           else if (b.ins >= 0 && (a.done || posB < posA || posB == posA && (b.len < a.len || b.len == a.len && !before))) {
+               addSection$3(sections, b.ins, -1);
+               while (posA > posB && !a.done && posA + a.len < posB + b.len) {
+                   posA += a.len;
+                   a.next();
+               }
+               posB += b.len;
+               b.next();
+           }
+           else if (a.ins >= 0) {
+               let len = 0, end = posA + a.len;
+               for (;;) {
+                   if (b.ins >= 0 && posB > posA && posB + b.len < end) {
+                       len += b.ins;
+                       posB += b.len;
+                       b.next();
+                   }
+                   else if (b.ins == -1 && posB < end) {
+                       let skip = Math.min(b.len, end - posB);
+                       len += skip;
+                       b.forward(skip);
+                       posB += skip;
+                   }
+                   else {
+                       break;
+                   }
+               }
+               addSection$3(sections, len, a.ins);
+               if (insert)
+                   addInsert$3(insert, sections, a.text);
+               posA = end;
+               a.next();
+           }
+           else if (a.done && b.done) {
+               return insert ? ChangeSet$3.createSet(sections, insert) : ChangeDesc$3.create(sections);
+           }
+           else {
+               throw new Error("Mismatched change set lengths");
+           }
+       }
+   }
+   function composeSets$3(setA, setB, mkSet = false) {
+       let sections = [];
+       let insert = mkSet ? [] : null;
+       let a = new SectionIter$3(setA), b = new SectionIter$3(setB);
+       for (let open = false;;) {
+           if (a.done && b.done) {
+               return insert ? ChangeSet$3.createSet(sections, insert) : ChangeDesc$3.create(sections);
+           }
+           else if (a.ins == 0) { // Deletion in A
+               addSection$3(sections, a.len, 0, open);
+               a.next();
+           }
+           else if (b.len == 0 && !b.done) { // Insertion in B
+               addSection$3(sections, 0, b.ins, open);
+               if (insert)
+                   addInsert$3(insert, sections, b.text);
+               b.next();
+           }
+           else if (a.done || b.done) {
+               throw new Error("Mismatched change set lengths");
+           }
+           else {
+               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
+               if (a.ins == -1) {
+                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
+                   addSection$3(sections, len, insB, open);
+                   if (insert && insB)
+                       addInsert$3(insert, sections, b.text);
+               }
+               else if (b.ins == -1) {
+                   addSection$3(sections, a.off ? 0 : a.len, len, open);
+                   if (insert)
+                       addInsert$3(insert, sections, a.textBit(len));
+               }
+               else {
+                   addSection$3(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
+                   if (insert && !b.off)
+                       addInsert$3(insert, sections, b.text);
+               }
+               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
+               a.forward2(len);
+               b.forward(len);
+           }
+       }
+   }
+   let SectionIter$3 = class SectionIter {
+       constructor(set) {
+           this.set = set;
+           this.i = 0;
+           this.next();
+       }
+       next() {
+           let { sections } = this.set;
+           if (this.i < sections.length) {
+               this.len = sections[this.i++];
+               this.ins = sections[this.i++];
+           }
+           else {
+               this.len = 0;
+               this.ins = -2;
+           }
+           this.off = 0;
+       }
+       get done() { return this.ins == -2; }
+       get len2() { return this.ins < 0 ? this.len : this.ins; }
+       get text() {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length ? Text$3.empty : inserted[index];
+       }
+       textBit(len) {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length && !len ? Text$3.empty
+               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
+       }
+       forward(len) {
+           if (len == this.len)
+               this.next();
+           else {
+               this.len -= len;
+               this.off += len;
+           }
+       }
+       forward2(len) {
+           if (this.ins == -1)
+               this.forward(len);
+           else if (len == this.ins)
+               this.next();
+           else {
+               this.ins -= len;
+               this.off += len;
+           }
+       }
+   };
+
+   /**
+   A single selection range. When
+   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
+   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
+   multiple ranges. By default, selections hold exactly one range.
+   */
+   let SelectionRange$3 = class SelectionRange {
+       constructor(
+       /**
+       The lower boundary of the range.
+       */
+       from, 
+       /**
+       The upper boundary of the range.
+       */
+       to, flags) {
+           this.from = from;
+           this.to = to;
+           this.flags = flags;
+       }
+       /**
+       The anchor of the range—the side that doesn't move when you
+       extend it.
+       */
+       get anchor() { return this.flags & 16 /* Inverted */ ? 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 & 16 /* Inverted */ ? 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 & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
+       /**
+       The bidirectional text level associated with this cursor, if
+       any.
+       */
+       get bidiLevel() {
+           let level = this.flags & 3 /* BidiLevelMask */;
+           return level == 3 ? null : level;
+       }
+       /**
+       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 value = this.flags >> 5 /* GoalColumnOffset */;
+           return value == 33554431 /* NoGoalColumn */ ? undefined : value;
+       }
+       /**
+       Map this range through a change, producing a valid range in the
+       updated document.
+       */
+       map(change, assoc = -1) {
+           let from, to;
+           if (this.empty) {
+               from = to = change.mapPos(this.from, assoc);
+           }
+           else {
+               from = change.mapPos(this.from, 1);
+               to = change.mapPos(this.to, -1);
+           }
+           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
+       }
+       /**
+       Extend this range to cover at least `from` to `to`.
+       */
+       extend(from, to = from) {
+           if (from <= this.anchor && to >= this.anchor)
+               return EditorSelection$3.range(from, to);
+           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
+           return EditorSelection$3.range(this.anchor, head);
+       }
+       /**
+       Compare this range to another range.
+       */
+       eq(other) {
+           return this.anchor == other.anchor && this.head == other.head;
+       }
+       /**
+       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(json) {
+           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
+               throw new RangeError("Invalid JSON representation for SelectionRange");
+           return EditorSelection$3.range(json.anchor, json.head);
+       }
+       /**
+       @internal
+       */
+       static create(from, to, flags) {
+           return new SelectionRange(from, to, flags);
+       }
+   };
+   /**
+   An editor selection holds one or more selection ranges.
+   */
+   let EditorSelection$3 = class EditorSelection {
+       constructor(
+       /**
+       The ranges in the selection, sorted by position. Ranges cannot
+       overlap (but they may touch, if they aren't empty).
+       */
+       ranges, 
+       /**
+       The index of the _main_ range in the selection (which is
+       usually the range that was added last).
+       */
+       mainIndex) {
+           this.ranges = ranges;
+           this.mainIndex = mainIndex;
+       }
+       /**
+       Map a selection through a change. Used to adjust the selection
+       position for changes.
+       */
+       map(change, assoc = -1) {
+           if (change.empty)
+               return this;
+           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
+       }
+       /**
+       Compare this selection to another selection.
+       */
+       eq(other) {
+           if (this.ranges.length != other.ranges.length ||
+               this.mainIndex != other.mainIndex)
+               return false;
+           for (let i = 0; i < this.ranges.length; i++)
+               if (!this.ranges[i].eq(other.ranges[i]))
+                   return false;
+           return true;
+       }
+       /**
+       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 EditorSelection([this.main], 0);
+       }
+       /**
+       Extend this selection with an extra range.
+       */
+       addRange(range, main = true) {
+           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
+       }
+       /**
+       Replace a given range with another range, and then normalize the
+       selection to merge and sort ranges if necessary.
+       */
+       replaceRange(range, which = this.mainIndex) {
+           let ranges = this.ranges.slice();
+           ranges[which] = range;
+           return EditorSelection.create(ranges, this.mainIndex);
+       }
+       /**
+       Convert this selection to an object that can be serialized to
+       JSON.
+       */
+       toJSON() {
+           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
+       }
+       /**
+       Create a selection from a JSON representation.
+       */
+       static fromJSON(json) {
+           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
+               throw new RangeError("Invalid JSON representation for EditorSelection");
+           return new EditorSelection(json.ranges.map((r) => SelectionRange$3.fromJSON(r)), json.main);
+       }
+       /**
+       Create a selection holding a single range.
+       */
+       static single(anchor, head = anchor) {
+           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
+       }
+       /**
+       Sort and merge the given set of ranges, creating a valid
+       selection.
+       */
+       static create(ranges, mainIndex = 0) {
+           if (ranges.length == 0)
+               throw new RangeError("A selection needs at least one range");
+           for (let pos = 0, i = 0; i < ranges.length; i++) {
+               let range = ranges[i];
+               if (range.empty ? range.from <= pos : range.from < pos)
+                   return EditorSelection.normalized(ranges.slice(), mainIndex);
+               pos = range.to;
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+       /**
+       Create a cursor selection range at the given position. You can
+       safely ignore the optional arguments in most situations.
+       */
+       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
+           return SelectionRange$3.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
+               (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
+               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
+       }
+       /**
+       Create a selection range.
+       */
+       static range(anchor, head, goalColumn) {
+           let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
+           return head < anchor ? SelectionRange$3.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
+               : SelectionRange$3.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
+       }
+       /**
+       @internal
+       */
+       static normalized(ranges, mainIndex = 0) {
+           let main = ranges[mainIndex];
+           ranges.sort((a, b) => a.from - b.from);
+           mainIndex = ranges.indexOf(main);
+           for (let i = 1; i < ranges.length; i++) {
+               let range = ranges[i], prev = ranges[i - 1];
+               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
+                   let from = prev.from, to = Math.max(range.to, prev.to);
+                   if (i <= mainIndex)
+                       mainIndex--;
+                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
+               }
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+   };
+   function checkSelection$3(selection, docLength) {
+       for (let range of selection.ranges)
+           if (range.to > docLength)
+               throw new RangeError("Selection points outside of document");
+   }
+
+   let nextID$3 = 0;
+   /**
+   A facet is a labeled value that is associated with an editor
+   state. It takes inputs from any number of extensions, and combines
+   those into a single output value.
+
+   Examples of uses of facets are the [tab
+   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
+   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
+   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
+   */
+   let Facet$3 = class Facet {
+       constructor(
+       /**
+       @internal
+       */
+       combine, 
+       /**
+       @internal
+       */
+       compareInput, 
+       /**
+       @internal
+       */
+       compare, isStatic, 
+       /**
+       @internal
+       */
+       extensions) {
+           this.combine = combine;
+           this.compareInput = compareInput;
+           this.compare = compare;
+           this.isStatic = isStatic;
+           this.extensions = extensions;
+           /**
+           @internal
+           */
+           this.id = nextID$3++;
+           this.default = combine([]);
+       }
+       /**
+       Define a new facet.
+       */
+       static define(config = {}) {
+           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$6 : (a, b) => a === b), !!config.static, config.enables);
+       }
+       /**
+       Returns an extension that adds the given value to this facet.
+       */
+       of(value) {
+           return new FacetProvider$3([], this, 0 /* Static */, value);
+       }
+       /**
+       Create an extension that computes a value for the facet from a
+       state. You must take care to declare the parts of the state that
+       this value depends on, since your function is only called again
+       for a new state when one of those parts changed.
+       
+       In cases where your value depends only on a single field, you'll
+       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
+       */
+       compute(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider$3(deps, this, 1 /* Single */, get);
+       }
+       /**
+       Create an extension that computes zero or more values for this
+       facet from a state.
+       */
+       computeN(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider$3(deps, this, 2 /* Multi */, get);
+       }
+       from(field, get) {
+           if (!get)
+               get = x => x;
+           return this.compute([field], state => get(state.field(field)));
+       }
+   };
+   function sameArray$6(a, b) {
+       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
+   }
+   let FacetProvider$3 = class FacetProvider {
+       constructor(dependencies, facet, type, value) {
+           this.dependencies = dependencies;
+           this.facet = facet;
+           this.type = type;
+           this.value = value;
+           this.id = nextID$3++;
+       }
+       dynamicSlot(addresses) {
+           var _a;
+           let getter = this.value;
+           let compare = this.facet.compareInput;
+           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
+           let depDoc = false, depSel = false, depAddrs = [];
+           for (let dep of this.dependencies) {
+               if (dep == "doc")
+                   depDoc = true;
+               else if (dep == "selection")
+                   depSel = true;
+               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
+                   depAddrs.push(addresses[dep.id]);
+           }
+           return {
+               create(state) {
+                   state.values[idx] = getter(state);
+                   return 1 /* Changed */;
+               },
+               update(state, tr) {
+                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll$3(state, depAddrs)) {
+                       let newVal = getter(state);
+                       if (multi ? !compareArray$3(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
+                           state.values[idx] = newVal;
+                           return 1 /* Changed */;
+                       }
+                   }
+                   return 0;
+               },
+               reconfigure: (state, oldState) => {
+                   let newVal = getter(state);
+                   let oldAddr = oldState.config.address[id];
+                   if (oldAddr != null) {
+                       let oldVal = getAddr$3(oldState, oldAddr);
+                       if (this.dependencies.every(dep => {
+                           return dep instanceof Facet$3 ? oldState.facet(dep) === state.facet(dep) :
+                               dep instanceof StateField$3 ? oldState.field(dep, false) == state.field(dep, false) : true;
+                       }) || (multi ? compareArray$3(newVal, oldVal, compare) : compare(newVal, oldVal))) {
+                           state.values[idx] = oldVal;
+                           return 0;
+                       }
+                   }
+                   state.values[idx] = newVal;
+                   return 1 /* Changed */;
+               }
+           };
+       }
+   };
+   function compareArray$3(a, b, compare) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (!compare(a[i], b[i]))
+               return false;
+       return true;
+   }
+   function ensureAll$3(state, addrs) {
+       let changed = false;
+       for (let addr of addrs)
+           if (ensureAddr$3(state, addr) & 1 /* Changed */)
+               changed = true;
+       return changed;
+   }
+   function dynamicFacetSlot$3(addresses, facet, providers) {
+       let providerAddrs = providers.map(p => addresses[p.id]);
+       let providerTypes = providers.map(p => p.type);
+       let dynamic = providerAddrs.filter(p => !(p & 1));
+       let idx = addresses[facet.id] >> 1;
+       function get(state) {
+           let values = [];
+           for (let i = 0; i < providerAddrs.length; i++) {
+               let value = getAddr$3(state, providerAddrs[i]);
+               if (providerTypes[i] == 2 /* Multi */)
+                   for (let val of value)
+                       values.push(val);
+               else
+                   values.push(value);
+           }
+           return facet.combine(values);
+       }
+       return {
+           create(state) {
+               for (let addr of providerAddrs)
+                   ensureAddr$3(state, addr);
+               state.values[idx] = get(state);
+               return 1 /* Changed */;
+           },
+           update(state, tr) {
+               if (!ensureAll$3(state, dynamic))
+                   return 0;
+               let value = get(state);
+               if (facet.compare(value, state.values[idx]))
+                   return 0;
+               state.values[idx] = value;
+               return 1 /* Changed */;
+           },
+           reconfigure(state, oldState) {
+               let depChanged = ensureAll$3(state, providerAddrs);
+               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
+               if (oldProviders && !depChanged && sameArray$6(providers, oldProviders)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               let value = get(state);
+               if (facet.compare(value, oldValue)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               state.values[idx] = value;
+               return 1 /* Changed */;
+           }
+       };
+   }
+   const initField$3 = /*@__PURE__*/Facet$3.define({ static: true });
+   /**
+   Fields can store additional information in an editor state, and
+   keep it in sync with the rest of the state.
+   */
+   let StateField$3 = class StateField {
+       constructor(
+       /**
+       @internal
+       */
+       id, createF, updateF, compareF, 
+       /**
+       @internal
+       */
+       spec) {
+           this.id = id;
+           this.createF = createF;
+           this.updateF = updateF;
+           this.compareF = compareF;
+           this.spec = spec;
+           /**
+           @internal
+           */
+           this.provides = undefined;
+       }
+       /**
+       Define a state field.
+       */
+       static define(config) {
+           let field = new StateField(nextID$3++, config.create, config.update, config.compare || ((a, b) => a === b), config);
+           if (config.provide)
+               field.provides = config.provide(field);
+           return field;
+       }
+       create(state) {
+           let init = state.facet(initField$3).find(i => i.field == this);
+           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
+       }
+       /**
+       @internal
+       */
+       slot(addresses) {
+           let idx = addresses[this.id] >> 1;
+           return {
+               create: (state) => {
+                   state.values[idx] = this.create(state);
+                   return 1 /* Changed */;
+               },
+               update: (state, tr) => {
+                   let oldVal = state.values[idx];
+                   let value = this.updateF(oldVal, tr);
+                   if (this.compareF(oldVal, value))
+                       return 0;
+                   state.values[idx] = value;
+                   return 1 /* Changed */;
+               },
+               reconfigure: (state, oldState) => {
+                   if (oldState.config.address[this.id] != null) {
+                       state.values[idx] = oldState.field(this);
+                       return 0;
+                   }
+                   state.values[idx] = this.create(state);
+                   return 1 /* Changed */;
+               }
+           };
+       }
+       /**
+       Returns an extension that enables this field and overrides the
+       way it is initialized. Can be useful when you need to provide a
+       non-default starting value for the field.
+       */
+       init(create) {
+           return [this, initField$3.of({ field: this, create })];
+       }
+       /**
+       State field instances can be used as
+       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
+       given state.
+       */
+       get extension() { return this; }
+   };
+   const Prec_$3 = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
+   function prec$3(value) {
+       return (ext) => new PrecExtension$3(ext, value);
+   }
+   /**
+   By default extensions are registered in the order they are found
+   in the flattened form of nested array that was provided.
+   Individual extension values can be assigned a precedence to
+   override this. Extensions that do not have a precedence set get
+   the precedence of the nearest parent with a precedence, or
+   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
+   final ordering of extensions is determined by first sorting by
+   precedence and then by order within each precedence.
+   */
+   const Prec$3 = {
+       /**
+       The highest precedence level, for extensions that should end up
+       near the start of the precedence ordering.
+       */
+       highest: /*@__PURE__*/prec$3(Prec_$3.highest),
+       /**
+       A higher-than-default precedence, for extensions that should
+       come before those with default precedence.
+       */
+       high: /*@__PURE__*/prec$3(Prec_$3.high),
+       /**
+       The default precedence, which is also used for extensions
+       without an explicit precedence.
+       */
+       default: /*@__PURE__*/prec$3(Prec_$3.default),
+       /**
+       A lower-than-default precedence.
+       */
+       low: /*@__PURE__*/prec$3(Prec_$3.low),
+       /**
+       The lowest precedence level. Meant for things that should end up
+       near the end of the extension order.
+       */
+       lowest: /*@__PURE__*/prec$3(Prec_$3.lowest)
+   };
+   let PrecExtension$3 = class PrecExtension {
+       constructor(inner, prec) {
+           this.inner = inner;
+           this.prec = prec;
+       }
+   };
+   /**
+   Extension compartments can be used to make a configuration
+   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
+   configuration in a compartment, you can later
+   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
+   transaction.
+   */
+   let Compartment$3 = class Compartment {
+       /**
+       Create an instance of this compartment to add to your [state
+       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
+       */
+       of(ext) { return new CompartmentInstance$3(this, ext); }
+       /**
+       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
+       reconfigures this compartment.
+       */
+       reconfigure(content) {
+           return Compartment.reconfigure.of({ compartment: this, extension: content });
+       }
+       /**
+       Get the current content of the compartment in the state, or
+       `undefined` if it isn't present.
+       */
+       get(state) {
+           return state.config.compartments.get(this);
+       }
+   };
+   let CompartmentInstance$3 = class CompartmentInstance {
+       constructor(compartment, inner) {
+           this.compartment = compartment;
+           this.inner = inner;
+       }
+   };
+   let Configuration$3 = class Configuration {
+       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
+           this.base = base;
+           this.compartments = compartments;
+           this.dynamicSlots = dynamicSlots;
+           this.address = address;
+           this.staticValues = staticValues;
+           this.facets = facets;
+           this.statusTemplate = [];
+           while (this.statusTemplate.length < dynamicSlots.length)
+               this.statusTemplate.push(0 /* Unresolved */);
+       }
+       staticFacet(facet) {
+           let addr = this.address[facet.id];
+           return addr == null ? facet.default : this.staticValues[addr >> 1];
+       }
+       static resolve(base, compartments, oldState) {
+           let fields = [];
+           let facets = Object.create(null);
+           let newCompartments = new Map();
+           for (let ext of flatten$3(base, compartments, newCompartments)) {
+               if (ext instanceof StateField$3)
+                   fields.push(ext);
+               else
+                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
+           }
+           let address = Object.create(null);
+           let staticValues = [];
+           let dynamicSlots = [];
+           for (let field of fields) {
+               address[field.id] = dynamicSlots.length << 1;
+               dynamicSlots.push(a => field.slot(a));
+           }
+           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
+           for (let id in facets) {
+               let providers = facets[id], facet = providers[0].facet;
+               let oldProviders = oldFacets && oldFacets[id] || [];
+               if (providers.every(p => p.type == 0 /* Static */)) {
+                   address[facet.id] = (staticValues.length << 1) | 1;
+                   if (sameArray$6(oldProviders, providers)) {
+                       staticValues.push(oldState.facet(facet));
+                   }
+                   else {
+                       let value = facet.combine(providers.map(p => p.value));
+                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
+                   }
+               }
+               else {
+                   for (let p of providers) {
+                       if (p.type == 0 /* Static */) {
+                           address[p.id] = (staticValues.length << 1) | 1;
+                           staticValues.push(p.value);
+                       }
+                       else {
+                           address[p.id] = dynamicSlots.length << 1;
+                           dynamicSlots.push(a => p.dynamicSlot(a));
+                       }
+                   }
+                   address[facet.id] = dynamicSlots.length << 1;
+                   dynamicSlots.push(a => dynamicFacetSlot$3(a, facet, providers));
+               }
+           }
+           let dynamic = dynamicSlots.map(f => f(address));
+           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
+       }
+   };
+   function flatten$3(extension, compartments, newCompartments) {
+       let result = [[], [], [], [], []];
+       let seen = new Map();
+       function inner(ext, prec) {
+           let known = seen.get(ext);
+           if (known != null) {
+               if (known <= prec)
+                   return;
+               let found = result[known].indexOf(ext);
+               if (found > -1)
+                   result[known].splice(found, 1);
+               if (ext instanceof CompartmentInstance$3)
+                   newCompartments.delete(ext.compartment);
+           }
+           seen.set(ext, prec);
+           if (Array.isArray(ext)) {
+               for (let e of ext)
+                   inner(e, prec);
+           }
+           else if (ext instanceof CompartmentInstance$3) {
+               if (newCompartments.has(ext.compartment))
+                   throw new RangeError(`Duplicate use of compartment in extensions`);
+               let content = compartments.get(ext.compartment) || ext.inner;
+               newCompartments.set(ext.compartment, content);
+               inner(content, prec);
+           }
+           else if (ext instanceof PrecExtension$3) {
+               inner(ext.inner, ext.prec);
+           }
+           else if (ext instanceof StateField$3) {
+               result[prec].push(ext);
+               if (ext.provides)
+                   inner(ext.provides, prec);
+           }
+           else if (ext instanceof FacetProvider$3) {
+               result[prec].push(ext);
+               if (ext.facet.extensions)
+                   inner(ext.facet.extensions, prec);
+           }
+           else {
+               let content = ext.extension;
+               if (!content)
+                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
+               inner(content, prec);
+           }
+       }
+       inner(extension, Prec_$3.default);
+       return result.reduce((a, b) => a.concat(b));
+   }
+   function ensureAddr$3(state, addr) {
+       if (addr & 1)
+           return 2 /* Computed */;
+       let idx = addr >> 1;
+       let status = state.status[idx];
+       if (status == 4 /* Computing */)
+           throw new Error("Cyclic dependency between fields and/or facets");
+       if (status & 2 /* Computed */)
+           return status;
+       state.status[idx] = 4 /* Computing */;
+       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
+       return state.status[idx] = 2 /* Computed */ | changed;
+   }
+   function getAddr$3(state, addr) {
+       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
+   }
+
+   const languageData$3 = /*@__PURE__*/Facet$3.define();
+   const allowMultipleSelections$3 = /*@__PURE__*/Facet$3.define({
+       combine: values => values.some(v => v),
+       static: true
+   });
+   const lineSeparator$3 = /*@__PURE__*/Facet$3.define({
+       combine: values => values.length ? values[0] : undefined,
+       static: true
+   });
+   const changeFilter$3 = /*@__PURE__*/Facet$3.define();
+   const transactionFilter$3 = /*@__PURE__*/Facet$3.define();
+   const transactionExtender$3 = /*@__PURE__*/Facet$3.define();
+   const readOnly$3 = /*@__PURE__*/Facet$3.define({
+       combine: values => values.length ? values[0] : false
+   });
+
+   /**
+   Annotations are tagged values that are used to add metadata to
+   transactions in an extensible way. They should be used to model
+   things that effect the entire transaction (such as its [time
+   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
+   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
+   _alongside_ the other changes made by the transaction, [state
+   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
+   */
+   let Annotation$3 = class Annotation {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The annotation type.
+       */
+       type, 
+       /**
+       The value of this annotation.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Define a new type of annotation.
+       */
+       static define() { return new AnnotationType$3(); }
+   };
+   /**
+   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
+   */
+   let AnnotationType$3 = class AnnotationType {
+       /**
+       Create an instance of this annotation.
+       */
+       of(value) { return new Annotation$3(this, value); }
+   };
+   /**
+   Representation of a type of state effect. Defined with
+   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
+   */
+   let StateEffectType$3 = class StateEffectType {
+       /**
+       @internal
+       */
+       constructor(
+       // The `any` types in these function types are there to work
+       // around TypeScript issue #37631, where the type guard on
+       // `StateEffect.is` mysteriously stops working when these properly
+       // have type `Value`.
+       /**
+       @internal
+       */
+       map) {
+           this.map = map;
+       }
+       /**
+       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
+       type.
+       */
+       of(value) { return new StateEffect$3(this, value); }
+   };
+   /**
+   State effects can be used to represent additional effects
+   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
+   are often useful to model changes to custom [state
+   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
+   document or selection changes.
+   */
+   let StateEffect$3 = class StateEffect {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       @internal
+       */
+       type, 
+       /**
+       The value of this effect.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Map this effect through a position mapping. Will return
+       `undefined` when that ends up deleting the effect.
+       */
+       map(mapping) {
+           let mapped = this.type.map(this.value, mapping);
+           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
+       }
+       /**
+       Tells you whether this effect object is of a given
+       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
+       */
+       is(type) { return this.type == type; }
+       /**
+       Define a new effect type. The type parameter indicates the type
+       of values that his effect holds.
+       */
+       static define(spec = {}) {
+           return new StateEffectType$3(spec.map || (v => v));
+       }
+       /**
+       Map an array of effects through a change set.
+       */
+       static mapEffects(effects, mapping) {
+           if (!effects.length)
+               return effects;
+           let result = [];
+           for (let effect of effects) {
+               let mapped = effect.map(mapping);
+               if (mapped)
+                   result.push(mapped);
+           }
+           return result;
+       }
+   };
+   /**
+   This effect can be used to reconfigure the root extensions of
+   the editor. Doing this will discard any extensions
+   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
+   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
+   compartments.
+   */
+   StateEffect$3.reconfigure = /*@__PURE__*/StateEffect$3.define();
+   /**
+   Append extensions to the top-level configuration of the editor.
+   */
+   StateEffect$3.appendConfig = /*@__PURE__*/StateEffect$3.define();
+   /**
+   Changes to the editor state are grouped into transactions.
+   Typically, a user action creates a single transaction, which may
+   contain any number of document changes, may change the selection,
+   or have other effects. Create a transaction by calling
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
+   dispatch one by calling
+   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
+   */
+   let Transaction$3 = class Transaction {
+       constructor(
+       /**
+       The state from which the transaction starts.
+       */
+       startState, 
+       /**
+       The document changes made by this transaction.
+       */
+       changes, 
+       /**
+       The selection set by this transaction, or undefined if it
+       doesn't explicitly set a selection.
+       */
+       selection, 
+       /**
+       The effects added to the transaction.
+       */
+       effects, 
+       /**
+       @internal
+       */
+       annotations, 
+       /**
+       Whether the selection should be scrolled into view after this
+       transaction is dispatched.
+       */
+       scrollIntoView) {
+           this.startState = startState;
+           this.changes = changes;
+           this.selection = selection;
+           this.effects = effects;
+           this.annotations = annotations;
+           this.scrollIntoView = scrollIntoView;
+           /**
+           @internal
+           */
+           this._doc = null;
+           /**
+           @internal
+           */
+           this._state = null;
+           if (selection)
+               checkSelection$3(selection, changes.newLength);
+           if (!annotations.some((a) => a.type == Transaction.time))
+               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
+       }
+       /**
+       @internal
+       */
+       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
+           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
+       }
+       /**
+       The new document produced by the transaction. Contrary to
+       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
+       force the entire new state to be computed right away, so it is
+       recommended that [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
+       when they need to look at the new document.
+       */
+       get newDoc() {
+           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
+       }
+       /**
+       The new selection produced by the transaction. If
+       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
+       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
+       current selection through the changes made by the transaction.
+       */
+       get newSelection() {
+           return this.selection || this.startState.selection.map(this.changes);
+       }
+       /**
+       The new state created by the transaction. Computed on demand
+       (but retained for subsequent access), so it is recommended not to
+       access it in [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
+       */
+       get state() {
+           if (!this._state)
+               this.startState.applyTransaction(this);
+           return this._state;
+       }
+       /**
+       Get the value of the given annotation type, if any.
+       */
+       annotation(type) {
+           for (let ann of this.annotations)
+               if (ann.type == type)
+                   return ann.value;
+           return undefined;
+       }
+       /**
+       Indicates whether the transaction changed the document.
+       */
+       get docChanged() { return !this.changes.empty; }
+       /**
+       Indicates whether this transaction reconfigures the state
+       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
+       with a top-level configuration
+       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
+       */
+       get reconfigured() { return this.startState.config != this.state.config; }
+       /**
+       Returns true if the transaction has a [user
+       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
+       or more specific than `event`. For example, if the transaction
+       has `"select.pointer"` as user event, `"select"` and
+       `"select.pointer"` will match it.
+       */
+       isUserEvent(event) {
+           let e = this.annotation(Transaction.userEvent);
+           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
+       }
+   };
+   /**
+   Annotation used to store transaction timestamps. Automatically
+   added to every transaction, holding `Date.now()`.
+   */
+   Transaction$3.time = /*@__PURE__*/Annotation$3.define();
+   /**
+   Annotation used to associate a transaction with a user interface
+   event. Holds a string identifying the event, using a
+   dot-separated format to support attaching more specific
+   information. The events used by the core libraries are:
+
+    - `"input"` when content is entered
+      - `"input.type"` for typed input
+        - `"input.type.compose"` for composition
+      - `"input.paste"` for pasted input
+      - `"input.drop"` when adding content with drag-and-drop
+      - `"input.complete"` when autocompleting
+    - `"delete"` when the user deletes content
+      - `"delete.selection"` when deleting the selection
+      - `"delete.forward"` when deleting forward from the selection
+      - `"delete.backward"` when deleting backward from the selection
+      - `"delete.cut"` when cutting to the clipboard
+    - `"move"` when content is moved
+      - `"move.drop"` when content is moved within the editor through drag-and-drop
+    - `"select"` when explicitly changing the selection
+      - `"select.pointer"` when selecting with a mouse or other pointing device
+    - `"undo"` and `"redo"` for history actions
+
+   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
+   whether the annotation matches a given event.
+   */
+   Transaction$3.userEvent = /*@__PURE__*/Annotation$3.define();
+   /**
+   Annotation indicating whether a transaction should be added to
+   the undo history or not.
+   */
+   Transaction$3.addToHistory = /*@__PURE__*/Annotation$3.define();
+   /**
+   Annotation indicating (when present and true) that a transaction
+   represents a change made by some other actor, not the user. This
+   is used, for example, to tag other people's changes in
+   collaborative editing.
+   */
+   Transaction$3.remote = /*@__PURE__*/Annotation$3.define();
+   function joinRanges$3(a, b) {
+       let result = [];
+       for (let iA = 0, iB = 0;;) {
+           let from, to;
+           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
+               from = a[iA++];
+               to = a[iA++];
+           }
+           else if (iB < b.length) {
+               from = b[iB++];
+               to = b[iB++];
+           }
+           else
+               return result;
+           if (!result.length || result[result.length - 1] < from)
+               result.push(from, to);
+           else if (result[result.length - 1] < to)
+               result[result.length - 1] = to;
+       }
+   }
+   function mergeTransaction$3(a, b, sequential) {
+       var _a;
+       let mapForA, mapForB, changes;
+       if (sequential) {
+           mapForA = b.changes;
+           mapForB = ChangeSet$3.empty(b.changes.length);
+           changes = a.changes.compose(b.changes);
+       }
+       else {
+           mapForA = b.changes.map(a.changes);
+           mapForB = a.changes.mapDesc(b.changes, true);
+           changes = a.changes.compose(mapForA);
+       }
+       return {
+           changes,
+           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
+           effects: StateEffect$3.mapEffects(a.effects, mapForA).concat(StateEffect$3.mapEffects(b.effects, mapForB)),
+           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
+           scrollIntoView: a.scrollIntoView || b.scrollIntoView
+       };
+   }
+   function resolveTransactionInner$3(state, spec, docSize) {
+       let sel = spec.selection, annotations = asArray$5(spec.annotations);
+       if (spec.userEvent)
+           annotations = annotations.concat(Transaction$3.userEvent.of(spec.userEvent));
+       return {
+           changes: spec.changes instanceof ChangeSet$3 ? spec.changes
+               : ChangeSet$3.of(spec.changes || [], docSize, state.facet(lineSeparator$3)),
+           selection: sel && (sel instanceof EditorSelection$3 ? sel : EditorSelection$3.single(sel.anchor, sel.head)),
+           effects: asArray$5(spec.effects),
+           annotations,
+           scrollIntoView: !!spec.scrollIntoView
+       };
+   }
+   function resolveTransaction$3(state, specs, filter) {
+       let s = resolveTransactionInner$3(state, specs.length ? specs[0] : {}, state.doc.length);
+       if (specs.length && specs[0].filter === false)
+           filter = false;
+       for (let i = 1; i < specs.length; i++) {
+           if (specs[i].filter === false)
+               filter = false;
+           let seq = !!specs[i].sequential;
+           s = mergeTransaction$3(s, resolveTransactionInner$3(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
+       }
+       let tr = Transaction$3.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
+       return extendTransaction$3(filter ? filterTransaction$3(tr) : tr);
+   }
+   // Finish a transaction by applying filters if necessary.
+   function filterTransaction$3(tr) {
+       let state = tr.startState;
+       // Change filters
+       let result = true;
+       for (let filter of state.facet(changeFilter$3)) {
+           let value = filter(tr);
+           if (value === false) {
+               result = false;
+               break;
+           }
+           if (Array.isArray(value))
+               result = result === true ? value : joinRanges$3(result, value);
+       }
+       if (result !== true) {
+           let changes, back;
+           if (result === false) {
+               back = tr.changes.invertedDesc;
+               changes = ChangeSet$3.empty(state.doc.length);
+           }
+           else {
+               let filtered = tr.changes.filter(result);
+               changes = filtered.changes;
+               back = filtered.filtered.invertedDesc;
+           }
+           tr = Transaction$3.create(state, changes, tr.selection && tr.selection.map(back), StateEffect$3.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
+       }
+       // Transaction filters
+       let filters = state.facet(transactionFilter$3);
+       for (let i = filters.length - 1; i >= 0; i--) {
+           let filtered = filters[i](tr);
+           if (filtered instanceof Transaction$3)
+               tr = filtered;
+           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction$3)
+               tr = filtered[0];
+           else
+               tr = resolveTransaction$3(state, asArray$5(filtered), false);
+       }
+       return tr;
+   }
+   function extendTransaction$3(tr) {
+       let state = tr.startState, extenders = state.facet(transactionExtender$3), spec = tr;
+       for (let i = extenders.length - 1; i >= 0; i--) {
+           let extension = extenders[i](tr);
+           if (extension && Object.keys(extension).length)
+               spec = mergeTransaction$3(tr, resolveTransactionInner$3(state, extension, tr.changes.newLength), true);
+       }
+       return spec == tr ? tr : Transaction$3.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
+   }
+   const none$6 = [];
+   function asArray$5(value) {
+       return value == null ? none$6 : Array.isArray(value) ? value : [value];
+   }
+
+   /**
+   The categories produced by a [character
+   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
+   do things like selecting by word.
+   */
+   var CharCategory$3 = /*@__PURE__*/(function (CharCategory) {
+       /**
+       Word characters.
+       */
+       CharCategory[CharCategory["Word"] = 0] = "Word";
+       /**
+       Whitespace.
+       */
+       CharCategory[CharCategory["Space"] = 1] = "Space";
+       /**
+       Anything else.
+       */
+       CharCategory[CharCategory["Other"] = 2] = "Other";
+   return CharCategory})(CharCategory$3 || (CharCategory$3 = {}));
+   const nonASCIISingleCaseWordChar$3 = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
+   let wordChar$3;
+   try {
+       wordChar$3 = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
+   }
+   catch (_) { }
+   function hasWordChar$3(str) {
+       if (wordChar$3)
+           return wordChar$3.test(str);
+       for (let i = 0; i < str.length; i++) {
+           let ch = str[i];
+           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar$3.test(ch)))
+               return true;
+       }
+       return false;
+   }
+   function makeCategorizer$3(wordChars) {
+       return (char) => {
+           if (!/\S/.test(char))
+               return CharCategory$3.Space;
+           if (hasWordChar$3(char))
+               return CharCategory$3.Word;
+           for (let i = 0; i < wordChars.length; i++)
+               if (char.indexOf(wordChars[i]) > -1)
+                   return CharCategory$3.Word;
+           return CharCategory$3.Other;
+       };
+   }
+
+   /**
+   The editor state class is a persistent (immutable) data structure.
+   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
+   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
+   instance, without modifying the original object.
+
+   As such, _never_ mutate properties of a state directly. That'll
+   just break things.
+   */
+   let EditorState$3 = class EditorState {
+       constructor(
+       /**
+       @internal
+       */
+       config, 
+       /**
+       The current document.
+       */
+       doc, 
+       /**
+       The current selection.
+       */
+       selection, 
+       /**
+       @internal
+       */
+       values, computeSlot, tr) {
+           this.config = config;
+           this.doc = doc;
+           this.selection = selection;
+           this.values = values;
+           this.status = config.statusTemplate.slice();
+           this.computeSlot = computeSlot;
+           // Fill in the computed state immediately, so that further queries
+           // for it made during the update return this state
+           if (tr)
+               tr._state = this;
+           for (let i = 0; i < this.config.dynamicSlots.length; i++)
+               ensureAddr$3(this, i << 1);
+           this.computeSlot = null;
+       }
+       field(field, require = true) {
+           let addr = this.config.address[field.id];
+           if (addr == null) {
+               if (require)
+                   throw new RangeError("Field is not present in this state");
+               return undefined;
+           }
+           ensureAddr$3(this, addr);
+           return getAddr$3(this, addr);
+       }
+       /**
+       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
+       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
+       can be passed. Unless
+       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
+       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
+       are assumed to start in the _current_ document (not the document
+       produced by previous specs), and its
+       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
+       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
+       to the document created by its _own_ changes. The resulting
+       transaction contains the combined effect of all the different
+       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
+       specs take precedence over earlier ones.
+       */
+       update(...specs) {
+           return resolveTransaction$3(this, specs, true);
+       }
+       /**
+       @internal
+       */
+       applyTransaction(tr) {
+           let conf = this.config, { base, compartments } = conf;
+           for (let effect of tr.effects) {
+               if (effect.is(Compartment$3.reconfigure)) {
+                   if (conf) {
+                       compartments = new Map;
+                       conf.compartments.forEach((val, key) => compartments.set(key, val));
+                       conf = null;
+                   }
+                   compartments.set(effect.value.compartment, effect.value.extension);
+               }
+               else if (effect.is(StateEffect$3.reconfigure)) {
+                   conf = null;
+                   base = effect.value;
+               }
+               else if (effect.is(StateEffect$3.appendConfig)) {
+                   conf = null;
+                   base = asArray$5(base).concat(effect.value);
+               }
+           }
+           let startValues;
+           if (!conf) {
+               conf = Configuration$3.resolve(base, compartments, this);
+               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
+               startValues = intermediateState.values;
+           }
+           else {
+               startValues = tr.startState.values.slice();
+           }
+           new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
+       }
+       /**
+       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
+       replaces every selection range with the given content.
+       */
+       replaceSelection(text) {
+           if (typeof text == "string")
+               text = this.toText(text);
+           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
+               range: EditorSelection$3.cursor(range.from + text.length) }));
+       }
+       /**
+       Create a set of changes and a new selection by running the given
+       function for each range in the active selection. The function
+       can return an optional set of changes (in the coordinate space
+       of the start document), plus an updated range (in the coordinate
+       space of the document produced by the call's own changes). This
+       method will merge all the changes and ranges into a single
+       changeset and selection, and return it as a [transaction
+       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
+       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
+       */
+       changeByRange(f) {
+           let sel = this.selection;
+           let result1 = f(sel.ranges[0]);
+           let changes = this.changes(result1.changes), ranges = [result1.range];
+           let effects = asArray$5(result1.effects);
+           for (let i = 1; i < sel.ranges.length; i++) {
+               let result = f(sel.ranges[i]);
+               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
+               for (let j = 0; j < i; j++)
+                   ranges[j] = ranges[j].map(newMapped);
+               let mapBy = changes.mapDesc(newChanges, true);
+               ranges.push(result.range.map(mapBy));
+               changes = changes.compose(newMapped);
+               effects = StateEffect$3.mapEffects(effects, newMapped).concat(StateEffect$3.mapEffects(asArray$5(result.effects), mapBy));
+           }
+           return {
+               changes,
+               selection: EditorSelection$3.create(ranges, sel.mainIndex),
+               effects
+           };
+       }
+       /**
+       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
+       description, taking the state's document length and line
+       separator into account.
+       */
+       changes(spec = []) {
+           if (spec instanceof ChangeSet$3)
+               return spec;
+           return ChangeSet$3.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
+       }
+       /**
+       Using the state's [line
+       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
+       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
+       */
+       toText(string) {
+           return Text$3.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit$3));
+       }
+       /**
+       Return the given range of the document as a string.
+       */
+       sliceDoc(from = 0, to = this.doc.length) {
+           return this.doc.sliceString(from, to, this.lineBreak);
+       }
+       /**
+       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
+       */
+       facet(facet) {
+           let addr = this.config.address[facet.id];
+           if (addr == null)
+               return facet.default;
+           ensureAddr$3(this, addr);
+           return getAddr$3(this, addr);
+       }
+       /**
+       Convert this state to a JSON-serializable object. When custom
+       fields should be serialized, you can pass them in as an object
+       mapping property names (in the resulting object, which should
+       not use `doc` or `selection`) to fields.
+       */
+       toJSON(fields) {
+           let result = {
+               doc: this.sliceDoc(),
+               selection: this.selection.toJSON()
+           };
+           if (fields)
+               for (let prop in fields) {
+                   let value = fields[prop];
+                   if (value instanceof StateField$3)
+                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
+               }
+           return result;
+       }
+       /**
+       Deserialize a state from its JSON representation. When custom
+       fields should be deserialized, pass the same object you passed
+       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
+       third argument.
+       */
+       static fromJSON(json, config = {}, fields) {
+           if (!json || typeof json.doc != "string")
+               throw new RangeError("Invalid JSON representation for EditorState");
+           let fieldInit = [];
+           if (fields)
+               for (let prop in fields) {
+                   let field = fields[prop], value = json[prop];
+                   fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
+               }
+           return EditorState.create({
+               doc: json.doc,
+               selection: EditorSelection$3.fromJSON(json.selection),
+               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
+           });
+       }
+       /**
+       Create a new state. You'll usually only need this when
+       initializing an editor—updated states are created by applying
+       transactions.
+       */
+       static create(config = {}) {
+           let configuration = Configuration$3.resolve(config.extensions || [], new Map);
+           let doc = config.doc instanceof Text$3 ? config.doc
+               : Text$3.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit$3));
+           let selection = !config.selection ? EditorSelection$3.single(0)
+               : config.selection instanceof EditorSelection$3 ? config.selection
+                   : EditorSelection$3.single(config.selection.anchor, config.selection.head);
+           checkSelection$3(selection, doc.length);
+           if (!configuration.staticFacet(allowMultipleSelections$3))
+               selection = selection.asSingle();
+           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
+       }
+       /**
+       The size (in columns) of a tab in the document, determined by
+       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
+       */
+       get tabSize() { return this.facet(EditorState.tabSize); }
+       /**
+       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
+       string for this state.
+       */
+       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
+       /**
+       Returns true when the editor is
+       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
+       */
+       get readOnly() { return this.facet(readOnly$3); }
+       /**
+       Look up a translation for the given phrase (via the
+       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
+       original string if no translation is found.
+       
+       If additional arguments are passed, they will be inserted in
+       place of markers like `$1` (for the first value) and `$2`, etc.
+       A single `$` is equivalent to `$1`, and `$$` will produce a
+       literal dollar sign.
+       */
+       phrase(phrase, ...insert) {
+           for (let map of this.facet(EditorState.phrases))
+               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
+                   phrase = map[phrase];
+                   break;
+               }
+           if (insert.length)
+               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
+                   if (i == "$")
+                       return "$";
+                   let n = +(i || 1);
+                   return n > insert.length ? m : insert[n - 1];
+               });
+           return phrase;
+       }
+       /**
+       Find the values for a given language data field, provided by the
+       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
+       */
+       languageDataAt(name, pos, side = -1) {
+           let values = [];
+           for (let provider of this.facet(languageData$3)) {
+               for (let result of provider(this, pos, side)) {
+                   if (Object.prototype.hasOwnProperty.call(result, name))
+                       values.push(result[name]);
+               }
+           }
+           return values;
+       }
+       /**
+       Return a function that can categorize strings (expected to
+       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
+       into one of:
+       
+        - Word (contains an alphanumeric character or a character
+          explicitly listed in the local language's `"wordChars"`
+          language data, which should be a string)
+        - Space (contains only whitespace)
+        - Other (anything else)
+       */
+       charCategorizer(at) {
+           return makeCategorizer$3(this.languageDataAt("wordChars", at).join(""));
+       }
+       /**
+       Find the word at the given position, meaning the range
+       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
+       around it. If no word characters are adjacent to the position,
+       this returns null.
+       */
+       wordAt(pos) {
+           let { text, from, length } = this.doc.lineAt(pos);
+           let cat = this.charCategorizer(pos);
+           let start = pos - from, end = pos - from;
+           while (start > 0) {
+               let prev = findClusterBreak$4(text, start, false);
+               if (cat(text.slice(prev, start)) != CharCategory$3.Word)
+                   break;
+               start = prev;
+           }
+           while (end < length) {
+               let next = findClusterBreak$4(text, end);
+               if (cat(text.slice(end, next)) != CharCategory$3.Word)
+                   break;
+               end = next;
+           }
+           return start == end ? null : EditorSelection$3.range(start + from, end + from);
+       }
+   };
+   /**
+   A facet that, when enabled, causes the editor to allow multiple
+   ranges to be selected. Be careful though, because by default the
+   editor relies on the native DOM selection, which cannot handle
+   multiple selections. An extension like
+   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
+   secondary selections visible to the user.
+   */
+   EditorState$3.allowMultipleSelections = allowMultipleSelections$3;
+   /**
+   Configures the tab size to use in this state. The first
+   (highest-precedence) value of the facet is used. If no value is
+   given, this defaults to 4.
+   */
+   EditorState$3.tabSize = /*@__PURE__*/Facet$3.define({
+       combine: values => values.length ? values[0] : 4
+   });
+   /**
+   The line separator to use. By default, any of `"\n"`, `"\r\n"`
+   and `"\r"` is treated as a separator when splitting lines, and
+   lines are joined with `"\n"`.
+
+   When you configure a value here, only that precise separator
+   will be used, allowing you to round-trip documents through the
+   editor without normalizing line separators.
+   */
+   EditorState$3.lineSeparator = lineSeparator$3;
+   /**
+   This facet controls the value of the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
+   consulted by commands and extensions that implement editing
+   functionality to determine whether they should apply. It
+   defaults to false, but when its highest-precedence value is
+   `true`, such functionality disables itself.
+
+   Not to be confused with
+   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
+   controls whether the editor's DOM is set to be editable (and
+   thus focusable).
+   */
+   EditorState$3.readOnly = readOnly$3;
+   /**
+   Registers translation phrases. The
+   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
+   all objects registered with this facet to find translations for
+   its argument.
+   */
+   EditorState$3.phrases = /*@__PURE__*/Facet$3.define({
+       compare(a, b) {
+           let kA = Object.keys(a), kB = Object.keys(b);
+           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
+       }
+   });
+   /**
+   A facet used to register [language
+   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
+   */
+   EditorState$3.languageData = languageData$3;
+   /**
+   Facet used to register change filters, which are called for each
+   transaction (unless explicitly
+   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
+   part of the transaction's changes.
+
+   Such a function can return `true` to indicate that it doesn't
+   want to do anything, `false` to completely stop the changes in
+   the transaction, or a set of ranges in which changes should be
+   suppressed. Such ranges are represented as an array of numbers,
+   with each pair of two numbers indicating the start and end of a
+   range. So for example `[10, 20, 100, 110]` suppresses changes
+   between 10 and 20, and between 100 and 110.
+   */
+   EditorState$3.changeFilter = changeFilter$3;
+   /**
+   Facet used to register a hook that gets a chance to update or
+   replace transaction specs before they are applied. This will
+   only be applied for transactions that don't have
+   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
+   can either return a single transaction spec (possibly the input
+   transaction), or an array of specs (which will be combined in
+   the same way as the arguments to
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
+
+   When possible, it is recommended to avoid accessing
+   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
+   since it will force creation of a state that will then be
+   discarded again, if the transaction is actually filtered.
+
+   (This functionality should be used with care. Indiscriminately
+   modifying transaction is likely to break something or degrade
+   the user experience.)
+   */
+   EditorState$3.transactionFilter = transactionFilter$3;
+   /**
+   This is a more limited form of
+   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
+   which can only add
+   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
+   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
+   of filter runs even if the transaction has disabled regular
+   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
+   for effects that don't need to touch the changes or selection,
+   but do want to process every transaction.
+
+   Extenders run _after_ filters, when both are present.
+   */
+   EditorState$3.transactionExtender = transactionExtender$3;
+   Compartment$3.reconfigure = /*@__PURE__*/StateEffect$3.define();
+
+   /**
+   Utility function for combining behaviors to fill in a config
+   object from an array of provided configs. `defaults` should hold
+   default values for all optional fields in `Config`.
+
+   The function will, by default, error
+   when a field gets two values that aren't `===`-equal, but you can
+   provide combine functions per field to do something else.
+   */
+   function combineConfig$3(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
+   combine = {}) {
+       let result = {};
+       for (let config of configs)
+           for (let key of Object.keys(config)) {
+               let value = config[key], current = result[key];
+               if (current === undefined)
+                   result[key] = value;
+               else if (current === value || value === undefined) ; // No conflict
+               else if (Object.hasOwnProperty.call(combine, key))
+                   result[key] = combine[key](current, value);
+               else
+                   throw new Error("Config merge conflict for field " + key);
+           }
+       for (let key in defaults)
+           if (result[key] === undefined)
+               result[key] = defaults[key];
+       return result;
+   }
+
+   /**
+   Each range is associated with a value, which must inherit from
+   this class.
+   */
+   let RangeValue$3 = class RangeValue {
+       /**
+       Compare this value with another value. Used when comparing
+       rangesets. The default implementation compares by identity.
+       Unless you are only creating a fixed number of unique instances
+       of your value type, it is a good idea to implement this
+       properly.
+       */
+       eq(other) { return this == other; }
+       /**
+       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
+       */
+       range(from, to = from) { return Range$6.create(from, to, this); }
+   };
+   RangeValue$3.prototype.startSide = RangeValue$3.prototype.endSide = 0;
+   RangeValue$3.prototype.point = false;
+   RangeValue$3.prototype.mapMode = MapMode$3.TrackDel;
+   /**
+   A range associates a value with a range of positions.
+   */
+   let Range$6 = class Range {
+       constructor(
+       /**
+       The range's start position.
+       */
+       from, 
+       /**
+       Its end position.
+       */
+       to, 
+       /**
+       The value associated with this range.
+       */
+       value) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+       }
+       /**
+       @internal
+       */
+       static create(from, to, value) {
+           return new Range(from, to, value);
+       }
+   };
+   function cmpRange$3(a, b) {
+       return a.from - b.from || a.value.startSide - b.value.startSide;
+   }
+   let Chunk$3 = class Chunk {
+       constructor(from, to, value, 
+       // Chunks are marked with the largest point that occurs
+       // in them (or -1 for no points), so that scans that are
+       // only interested in points (such as the
+       // heightmap-related logic) can skip range-only chunks.
+       maxPoint) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+           this.maxPoint = maxPoint;
+       }
+       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(pos, side, end, startAt = 0) {
+           let arr = end ? this.to : this.from;
+           for (let lo = startAt, hi = arr.length;;) {
+               if (lo == hi)
+                   return lo;
+               let mid = (lo + hi) >> 1;
+               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
+               if (mid == lo)
+                   return diff >= 0 ? lo : hi;
+               if (diff >= 0)
+                   hi = mid;
+               else
+                   lo = mid + 1;
+           }
+       }
+       between(offset, from, to, f) {
+           for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
+               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
+                   return false;
+       }
+       map(offset, changes) {
+           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
+           for (let i = 0; i < this.value.length; i++) {
+               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
+               if (curFrom == curTo) {
+                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
+                   if (mapped == null)
+                       continue;
+                   newFrom = newTo = mapped;
+                   if (val.startSide != val.endSide) {
+                       newTo = changes.mapPos(curFrom, val.endSide);
+                       if (newTo < newFrom)
+                           continue;
+                   }
+               }
+               else {
+                   newFrom = changes.mapPos(curFrom, val.startSide);
+                   newTo = changes.mapPos(curTo, val.endSide);
+                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
+                       continue;
+               }
+               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
+                   continue;
+               if (newPos < 0)
+                   newPos = newFrom;
+               if (val.point)
+                   maxPoint = Math.max(maxPoint, newTo - newFrom);
+               value.push(val);
+               from.push(newFrom - newPos);
+               to.push(newTo - newPos);
+           }
+           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
+       }
+   };
+   /**
+   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
+   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
+   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
+   structure.
+   */
+   let RangeSet$3 = class RangeSet {
+       constructor(
+       /**
+       @internal
+       */
+       chunkPos, 
+       /**
+       @internal
+       */
+       chunk, 
+       /**
+       @internal
+       */
+       nextLayer, 
+       /**
+       @internal
+       */
+       maxPoint) {
+           this.chunkPos = chunkPos;
+           this.chunk = chunk;
+           this.nextLayer = nextLayer;
+           this.maxPoint = maxPoint;
+       }
+       /**
+       @internal
+       */
+       static create(chunkPos, chunk, nextLayer, maxPoint) {
+           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
+       }
+       /**
+       @internal
+       */
+       get length() {
+           let last = this.chunk.length - 1;
+           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
+       }
+       /**
+       The number of ranges in the set.
+       */
+       get size() {
+           if (this.isEmpty)
+               return 0;
+           let size = this.nextLayer.size;
+           for (let chunk of this.chunk)
+               size += chunk.value.length;
+           return size;
+       }
+       /**
+       @internal
+       */
+       chunkEnd(index) {
+           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
+           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
+           let filter = updateSpec.filter;
+           if (add.length == 0 && !filter)
+               return this;
+           if (sort)
+               add = add.slice().sort(cmpRange$3);
+           if (this.isEmpty)
+               return add.length ? RangeSet.of(add) : this;
+           let cur = new LayerCursor$3(this, null, -1).goto(0), i = 0, spill = [];
+           let builder = new RangeSetBuilder$3();
+           while (cur.value || i < add.length) {
+               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
+                   let range = add[i++];
+                   if (!builder.addInner(range.from, range.to, range.value))
+                       spill.push(range);
+               }
+               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
+                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
+                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
+                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
+                   cur.nextChunk();
+               }
+               else {
+                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
+                       if (!builder.addInner(cur.from, cur.to, cur.value))
+                           spill.push(Range$6.create(cur.from, cur.to, cur.value));
+                   }
+                   cur.next();
+               }
+           }
+           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
+               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
+       }
+       /**
+       Map this range set through a set of changes, return the new set.
+       */
+       map(changes) {
+           if (changes.empty || this.isEmpty)
+               return this;
+           let chunks = [], chunkPos = [], maxPoint = -1;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               let touch = changes.touchesRange(start, start + chunk.length);
+               if (touch === false) {
+                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
+                   chunks.push(chunk);
+                   chunkPos.push(changes.mapPos(start));
+               }
+               else if (touch === true) {
+                   let { mapped, pos } = chunk.map(start, changes);
+                   if (mapped) {
+                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
+                       chunks.push(mapped);
+                       chunkPos.push(pos);
+                   }
+               }
+           }
+           let next = this.nextLayer.map(changes);
+           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
+       }
+       /**
+       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(from, to, f) {
+           if (this.isEmpty)
+               return;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               if (to >= start && from <= start + chunk.length &&
+                   chunk.between(start, from - start, to - start, f) === false)
+                   return;
+           }
+           this.nextLayer.between(from, to, f);
+       }
+       /**
+       Iterate over the ranges in this set, in order, including all
+       ranges that end at or after `from`.
+       */
+       iter(from = 0) {
+           return HeapCursor$3.from([this]).goto(from);
+       }
+       /**
+       @internal
+       */
+       get isEmpty() { return this.nextLayer == this; }
+       /**
+       Iterate over the ranges in a collection of sets, in order,
+       starting from `from`.
+       */
+       static iter(sets, from = 0) {
+           return HeapCursor$3.from(sets).goto(from);
+       }
+       /**
+       Iterate over two groups of sets, calling methods on `comparator`
+       to notify it of possible differences.
+       */
+       static compare(oldSets, newSets, 
+       /**
+       This indicates how the underlying data changed between these
+       ranges, and is needed to synchronize the iteration. `from` and
+       `to` are coordinates in the _new_ space, after these changes.
+       */
+       textDiff, comparator, 
+       /**
+       Can be used to ignore all non-point ranges, and points below
+       the given size. When -1, all ranges are compared.
+       */
+       minPointSize = -1) {
+           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let sharedChunks = findSharedChunks$3(a, b, textDiff);
+           let sideA = new SpanCursor$3(a, sharedChunks, minPointSize);
+           let sideB = new SpanCursor$3(b, sharedChunks, minPointSize);
+           textDiff.iterGaps((fromA, fromB, length) => compare$3(sideA, fromA, sideB, fromB, length, comparator));
+           if (textDiff.empty && textDiff.length == 0)
+               compare$3(sideA, 0, sideB, 0, 0, comparator);
+       }
+       /**
+       Compare the contents of two groups of range sets, returning true
+       if they are equivalent in the given range.
+       */
+       static eq(oldSets, newSets, from = 0, to) {
+           if (to == null)
+               to = 1000000000 /* Far */;
+           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
+           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
+           if (a.length != b.length)
+               return false;
+           if (!a.length)
+               return true;
+           let sharedChunks = findSharedChunks$3(a, b);
+           let sideA = new SpanCursor$3(a, sharedChunks, 0).goto(from), sideB = new SpanCursor$3(b, sharedChunks, 0).goto(from);
+           for (;;) {
+               if (sideA.to != sideB.to ||
+                   !sameValues$3(sideA.active, sideB.active) ||
+                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
+                   return false;
+               if (sideA.to > to)
+                   return true;
+               sideA.next();
+               sideB.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(sets, from, to, iterator, 
+       /**
+       When given and greater than -1, only points of at least this
+       size are taken into account.
+       */
+       minPointSize = -1) {
+           let cursor = new SpanCursor$3(sets, null, minPointSize).goto(from), pos = from;
+           let open = cursor.openStart;
+           for (;;) {
+               let curTo = Math.min(cursor.to, to);
+               if (cursor.point) {
+                   iterator.point(pos, curTo, cursor.point, cursor.activeForPoint(cursor.to), open, cursor.pointRank);
+                   open = cursor.openEnd(curTo) + (cursor.to > curTo ? 1 : 0);
+               }
+               else if (curTo > pos) {
+                   iterator.span(pos, curTo, cursor.active, open);
+                   open = cursor.openEnd(curTo);
+               }
+               if (cursor.to > to)
+                   break;
+               pos = cursor.to;
+               cursor.next();
+           }
+           return open;
+       }
+       /**
+       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(ranges, sort = false) {
+           let build = new RangeSetBuilder$3();
+           for (let range of ranges instanceof Range$6 ? [ranges] : sort ? lazySort$3(ranges) : ranges)
+               build.add(range.from, range.to, range.value);
+           return build.finish();
+       }
+   };
+   /**
+   The empty set of ranges.
+   */
+   RangeSet$3.empty = /*@__PURE__*/new RangeSet$3([], [], null, -1);
+   function lazySort$3(ranges) {
+       if (ranges.length > 1)
+           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
+               let cur = ranges[i];
+               if (cmpRange$3(prev, cur) > 0)
+                   return ranges.slice().sort(cmpRange$3);
+               prev = cur;
+           }
+       return ranges;
+   }
+   RangeSet$3.empty.nextLayer = RangeSet$3.empty;
+   /**
+   A range set builder is a data structure that helps build up a
+   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
+   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
+   */
+   let RangeSetBuilder$3 = class RangeSetBuilder {
+       /**
+       Create an empty builder.
+       */
+       constructor() {
+           this.chunks = [];
+           this.chunkPos = [];
+           this.chunkStart = -1;
+           this.last = null;
+           this.lastFrom = -1000000000 /* Far */;
+           this.lastTo = -1000000000 /* Far */;
+           this.from = [];
+           this.to = [];
+           this.value = [];
+           this.maxPoint = -1;
+           this.setMaxPoint = -1;
+           this.nextLayer = null;
+       }
+       finishChunk(newArrays) {
+           this.chunks.push(new Chunk$3(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;
+           if (newArrays) {
+               this.from = [];
+               this.to = [];
+               this.value = [];
+           }
+       }
+       /**
+       Add a range. Ranges should be added in sorted (by `from` and
+       `value.startSide`) order.
+       */
+       add(from, to, value) {
+           if (!this.addInner(from, to, value))
+               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
+       }
+       /**
+       @internal
+       */
+       addInner(from, to, value) {
+           let diff = from - this.lastTo || value.startSide - this.last.endSide;
+           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
+               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
+           if (diff < 0)
+               return false;
+           if (this.from.length == 250 /* ChunkSize */)
+               this.finishChunk(true);
+           if (this.chunkStart < 0)
+               this.chunkStart = from;
+           this.from.push(from - this.chunkStart);
+           this.to.push(to - this.chunkStart);
+           this.last = value;
+           this.lastFrom = from;
+           this.lastTo = to;
+           this.value.push(value);
+           if (value.point)
+               this.maxPoint = Math.max(this.maxPoint, to - from);
+           return true;
+       }
+       /**
+       @internal
+       */
+       addChunk(from, chunk) {
+           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
+               return false;
+           if (this.from.length)
+               this.finishChunk(true);
+           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
+           this.chunks.push(chunk);
+           this.chunkPos.push(from);
+           let last = chunk.value.length - 1;
+           this.last = chunk.value[last];
+           this.lastFrom = chunk.from[last] + from;
+           this.lastTo = chunk.to[last] + from;
+           return true;
+       }
+       /**
+       Finish the range set. Returns the new set. The builder can't be
+       used anymore after this has been called.
+       */
+       finish() { return this.finishInner(RangeSet$3.empty); }
+       /**
+       @internal
+       */
+       finishInner(next) {
+           if (this.from.length)
+               this.finishChunk(false);
+           if (this.chunks.length == 0)
+               return next;
+           let result = RangeSet$3.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
+           this.from = null; // Make sure further `add` calls produce errors
+           return result;
+       }
+   };
+   function findSharedChunks$3(a, b, textDiff) {
+       let inA = new Map();
+       for (let set of a)
+           for (let i = 0; i < set.chunk.length; i++)
+               if (set.chunk[i].maxPoint <= 0)
+                   inA.set(set.chunk[i], set.chunkPos[i]);
+       let shared = new Set();
+       for (let set of b)
+           for (let i = 0; i < set.chunk.length; i++) {
+               let known = inA.get(set.chunk[i]);
+               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
+                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
+                   shared.add(set.chunk[i]);
+           }
+       return shared;
+   }
+   let LayerCursor$3 = class LayerCursor {
+       constructor(layer, skip, minPoint, rank = 0) {
+           this.layer = layer;
+           this.skip = skip;
+           this.minPoint = minPoint;
+           this.rank = rank;
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       get endSide() { return this.value ? this.value.endSide : 0; }
+       goto(pos, side = -1000000000 /* Far */) {
+           this.chunkIndex = this.rangeIndex = 0;
+           this.gotoInner(pos, side, false);
+           return this;
+       }
+       gotoInner(pos, side, forward) {
+           while (this.chunkIndex < this.layer.chunk.length) {
+               let next = this.layer.chunk[this.chunkIndex];
+               if (!(this.skip && this.skip.has(next) ||
+                   this.layer.chunkEnd(this.chunkIndex) < pos ||
+                   next.maxPoint < this.minPoint))
+                   break;
+               this.chunkIndex++;
+               forward = false;
+           }
+           if (this.chunkIndex < this.layer.chunk.length) {
+               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
+               if (!forward || this.rangeIndex < rangeIndex)
+                   this.setRangeIndex(rangeIndex);
+           }
+           this.next();
+       }
+       forward(pos, side) {
+           if ((this.to - pos || this.endSide - side) < 0)
+               this.gotoInner(pos, side, true);
+       }
+       next() {
+           for (;;) {
+               if (this.chunkIndex == this.layer.chunk.length) {
+                   this.from = this.to = 1000000000 /* Far */;
+                   this.value = null;
+                   break;
+               }
+               else {
+                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
+                   let from = chunkPos + chunk.from[this.rangeIndex];
+                   this.from = from;
+                   this.to = chunkPos + chunk.to[this.rangeIndex];
+                   this.value = chunk.value[this.rangeIndex];
+                   this.setRangeIndex(this.rangeIndex + 1);
+                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
+                       break;
+               }
+           }
+       }
+       setRangeIndex(index) {
+           if (index == this.layer.chunk[this.chunkIndex].value.length) {
+               this.chunkIndex++;
+               if (this.skip) {
+                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
+                       this.chunkIndex++;
+               }
+               this.rangeIndex = 0;
+           }
+           else {
+               this.rangeIndex = index;
+           }
+       }
+       nextChunk() {
+           this.chunkIndex++;
+           this.rangeIndex = 0;
+           this.next();
+       }
+       compare(other) {
+           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
+               this.to - other.to || this.endSide - other.endSide;
+       }
+   };
+   let HeapCursor$3 = class HeapCursor {
+       constructor(heap) {
+           this.heap = heap;
+       }
+       static from(sets, skip = null, minPoint = -1) {
+           let heap = [];
+           for (let i = 0; i < sets.length; i++) {
+               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
+                   if (cur.maxPoint >= minPoint)
+                       heap.push(new LayerCursor$3(cur, skip, minPoint, i));
+               }
+           }
+           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       goto(pos, side = -1000000000 /* Far */) {
+           for (let cur of this.heap)
+               cur.goto(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble$3(this.heap, i);
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           for (let cur of this.heap)
+               cur.forward(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble$3(this.heap, i);
+           if ((this.to - pos || this.value.endSide - side) < 0)
+               this.next();
+       }
+       next() {
+           if (this.heap.length == 0) {
+               this.from = this.to = 1000000000 /* Far */;
+               this.value = null;
+               this.rank = -1;
+           }
+           else {
+               let top = this.heap[0];
+               this.from = top.from;
+               this.to = top.to;
+               this.value = top.value;
+               this.rank = top.rank;
+               if (top.value)
+                   top.next();
+               heapBubble$3(this.heap, 0);
+           }
+       }
+   };
+   function heapBubble$3(heap, index) {
+       for (let cur = heap[index];;) {
+           let childIndex = (index << 1) + 1;
+           if (childIndex >= heap.length)
+               break;
+           let child = heap[childIndex];
+           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
+               child = heap[childIndex + 1];
+               childIndex++;
+           }
+           if (cur.compare(child) < 0)
+               break;
+           heap[childIndex] = cur;
+           heap[index] = child;
+           index = childIndex;
+       }
+   }
+   let SpanCursor$3 = class SpanCursor {
+       constructor(sets, skip, minPoint) {
+           this.minPoint = minPoint;
+           this.active = [];
+           this.activeTo = [];
+           this.activeRank = [];
+           this.minActive = -1;
+           // A currently active point range, if any
+           this.point = null;
+           this.pointFrom = 0;
+           this.pointRank = 0;
+           this.to = -1000000000 /* Far */;
+           this.endSide = 0;
+           this.openStart = -1;
+           this.cursor = HeapCursor$3.from(sets, skip, minPoint);
+       }
+       goto(pos, side = -1000000000 /* Far */) {
+           this.cursor.goto(pos, side);
+           this.active.length = this.activeTo.length = this.activeRank.length = 0;
+           this.minActive = -1;
+           this.to = pos;
+           this.endSide = side;
+           this.openStart = -1;
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
+               this.removeActive(this.minActive);
+           this.cursor.forward(pos, side);
+       }
+       removeActive(index) {
+           remove$3(this.active, index);
+           remove$3(this.activeTo, index);
+           remove$3(this.activeRank, index);
+           this.minActive = findMinIndex$3(this.active, this.activeTo);
+       }
+       addActive(trackOpen) {
+           let i = 0, { value, to, rank } = this.cursor;
+           while (i < this.activeRank.length && this.activeRank[i] <= rank)
+               i++;
+           insert$3(this.active, i, value);
+           insert$3(this.activeTo, i, to);
+           insert$3(this.activeRank, i, rank);
+           if (trackOpen)
+               insert$3(trackOpen, i, this.cursor.from);
+           this.minActive = findMinIndex$3(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 from = this.to, wasPoint = this.point;
+           this.point = null;
+           let trackOpen = this.openStart < 0 ? [] : null, trackExtra = 0;
+           for (;;) {
+               let a = this.minActive;
+               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
+                   if (this.activeTo[a] > from) {
+                       this.to = this.activeTo[a];
+                       this.endSide = this.active[a].endSide;
+                       break;
+                   }
+                   this.removeActive(a);
+                   if (trackOpen)
+                       remove$3(trackOpen, a);
+               }
+               else if (!this.cursor.value) {
+                   this.to = this.endSide = 1000000000 /* Far */;
+                   break;
+               }
+               else if (this.cursor.from > from) {
+                   this.to = this.cursor.from;
+                   this.endSide = this.cursor.startSide;
+                   break;
+               }
+               else {
+                   let nextVal = this.cursor.value;
+                   if (!nextVal.point) { // Opening a range
+                       this.addActive(trackOpen);
+                       this.cursor.next();
+                   }
+                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
+                       // Ignore any non-empty points that end precisely at the end of the prev point
+                       this.cursor.next();
+                   }
+                   else { // New point
+                       this.point = nextVal;
+                       this.pointFrom = this.cursor.from;
+                       this.pointRank = this.cursor.rank;
+                       this.to = this.cursor.to;
+                       this.endSide = nextVal.endSide;
+                       if (this.cursor.from < from)
+                           trackExtra = 1;
+                       this.cursor.next();
+                       this.forward(this.to, this.endSide);
+                       break;
+                   }
+               }
+           }
+           if (trackOpen) {
+               let openStart = 0;
+               while (openStart < trackOpen.length && trackOpen[openStart] < from)
+                   openStart++;
+               this.openStart = openStart + trackExtra;
+           }
+       }
+       activeForPoint(to) {
+           if (!this.active.length)
+               return this.active;
+           let active = [];
+           for (let i = this.active.length - 1; i >= 0; i--) {
+               if (this.activeRank[i] < this.pointRank)
+                   break;
+               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
+                   active.push(this.active[i]);
+           }
+           return active.reverse();
+       }
+       openEnd(to) {
+           let open = 0;
+           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
+               open++;
+           return open;
+       }
+   };
+   function compare$3(a, startA, b, startB, length, comparator) {
+       a.goto(startA);
+       b.goto(startB);
+       let endB = startB + length;
+       let pos = startB, dPos = startB - startA;
+       for (;;) {
+           let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;
+           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
+           if (a.point || b.point) {
+               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
+                   sameValues$3(a.activeForPoint(a.to + dPos), b.activeForPoint(b.to))))
+                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
+           }
+           else {
+               if (clipEnd > pos && !sameValues$3(a.active, b.active))
+                   comparator.compareRange(pos, clipEnd, a.active, b.active);
+           }
+           if (end > endB)
+               break;
+           pos = end;
+           if (diff <= 0)
+               a.next();
+           if (diff >= 0)
+               b.next();
+       }
+   }
+   function sameValues$3(a, b) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (a[i] != b[i] && !a[i].eq(b[i]))
+               return false;
+       return true;
+   }
+   function remove$3(array, index) {
+       for (let i = index, e = array.length - 1; i < e; i++)
+           array[i] = array[i + 1];
+       array.pop();
+   }
+   function insert$3(array, index, value) {
+       for (let i = array.length - 1; i >= index; i--)
+           array[i + 1] = array[i];
+       array[index] = value;
+   }
+   function findMinIndex$3(value, array) {
+       let found = -1, foundPos = 1000000000 /* Far */;
+       for (let i = 0; i < array.length; i++)
+           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
+               found = i;
+               foundPos = array[i];
+           }
+       return found;
+   }
+
+   /**
+   Count the column position at the given offset into the string,
+   taking extending characters and tab size into account.
+   */
+   function countColumn$1(string, tabSize, to = string.length) {
+       let n = 0;
+       for (let i = 0; i < to;) {
+           if (string.charCodeAt(i) == 9) {
+               n += tabSize - (n % tabSize);
+               i++;
+           }
+           else {
+               n++;
+               i = findClusterBreak$4(string, i);
+           }
+       }
+       return n;
+   }
+   /**
+   Find the offset that corresponds to the given column position in a
+   string, taking extending characters and tab size into account. By
+   default, the string length is returned when it is too short to
+   reach the column. Pass `strict` true to make it return -1 in that
+   situation.
+   */
+   function findColumn$3(string, col, tabSize, strict) {
+       for (let i = 0, n = 0;;) {
+           if (n >= col)
+               return i;
+           if (i == string.length)
+               break;
+           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
+           i = findClusterBreak$4(string, i);
+       }
+       return strict === true ? -1 : string.length;
+   }
+
+   const C = "\u037c";
+   const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C);
+   const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
+   const top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
+
+   // :: - Style modules encapsulate a set of CSS rules defined from
+   // JavaScript. Their definitions are only available in a given DOM
+   // root after it has been _mounted_ there with `StyleModule.mount`.
+   //
+   // Style modules should be created once and stored somewhere, as
+   // opposed to re-creating them every time you need them. The amount of
+   // CSS rules generated for a given DOM root is bounded by the amount
+   // of style modules that were used. So to avoid leaking rules, don't
+   // create these dynamically, but treat them as one-time allocations.
+   class StyleModule {
+     // :: (Object<Style>, ?{finish: ?(string) → string})
+     // Create a style module from the given spec.
+     //
+     // When `finish` is given, it is called on regular (non-`@`)
+     // selectors (after `&` expansion) to compute the final selector.
+     constructor(spec, options) {
+       this.rules = [];
+       let {finish} = options || {};
+
+       function splitSelector(selector) {
+         return /^@/.test(selector) ? [selector] : selector.split(/,\s*/)
+       }
+
+       function render(selectors, spec, target, isKeyframes) {
+         let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
+         if (isAt && spec == null) return target.push(selectors[0] + ";")
+         for (let prop in spec) {
+           let value = spec[prop];
+           if (/&/.test(prop)) {
+             render(prop.split(/,\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),
+                    value, target);
+           } else if (value && typeof value == "object") {
+             if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.")
+             render(splitSelector(prop), value, local, keyframes);
+           } else if (value != null) {
+             local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, l => "-" + l.toLowerCase()) + ": " + value + ";");
+           }
+         }
+         if (local.length || keyframes) {
+           target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") +
+                       " {" + local.join(" ") + "}");
+         }
+       }
+
+       for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
+     }
+
+     // :: () → string
+     // Returns a string containing the module's CSS rules.
+     getRules() { return this.rules.join("\n") }
+
+     // :: () → string
+     // Generate a new unique CSS class name.
+     static newName() {
+       let id = top[COUNT] || 1;
+       top[COUNT] = id + 1;
+       return C + id.toString(36)
+     }
+
+     // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
+     //
+     // Mount the given set of modules in the given DOM root, which ensures
+     // that the CSS rules defined by the module are available in that
+     // context.
+     //
+     // Rules are only added to the document once per root.
+     //
+     // Rule order will follow the order of the modules, so that rules from
+     // modules later in the array take precedence of those from earlier
+     // modules. If you call this function multiple times for the same root
+     // in a way that changes the order of already mounted modules, the old
+     // order will be changed.
+     //
+     // If a Content Security Policy nonce is provided, it is added to
+     // the `<style>` tag generated by the library.
+     static mount(root, modules, options) {
+       let set = root[SET], nonce = options && options.nonce;
+       if (!set) set = new StyleSet(root, nonce);
+       else if (nonce) set.setNonce(nonce);
+       set.mount(Array.isArray(modules) ? modules : [modules], root);
+     }
+   }
+
+   let adoptedSet = new Map; //<Document, StyleSet>
+
+   class StyleSet {
+     constructor(root, nonce) {
+       let doc = root.ownerDocument || root, win = doc.defaultView;
+       if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
+         let adopted = adoptedSet.get(doc);
+         if (adopted) return root[SET] = adopted
+         this.sheet = new win.CSSStyleSheet;
+         adoptedSet.set(doc, this);
+       } else {
+         this.styleTag = doc.createElement("style");
+         if (nonce) this.styleTag.setAttribute("nonce", nonce);
+       }
+       this.modules = [];
+       root[SET] = this;
+     }
+
+     mount(modules, root) {
+       let sheet = this.sheet;
+       let pos = 0 /* Current rule offset */, j = 0; /* Index into this.modules */
+       for (let i = 0; i < modules.length; i++) {
+         let mod = modules[i], index = this.modules.indexOf(mod);
+         if (index < j && index > -1) { // Ordering conflict
+           this.modules.splice(index, 1);
+           j--;
+           index = -1;
+         }
+         if (index == -1) {
+           this.modules.splice(j++, 0, mod);
+           if (sheet) for (let k = 0; k < mod.rules.length; k++)
+             sheet.insertRule(mod.rules[k], pos++);
+         } else {
+           while (j < index) pos += this.modules[j++].rules.length;
+           pos += mod.rules.length;
+           j++;
+         }
+       }
+
+       if (sheet) {
+         if (root.adoptedStyleSheets.indexOf(this.sheet) < 0)
+           root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
+       } else {
+         let text = "";
+         for (let i = 0; i < this.modules.length; i++)
+           text += this.modules[i].getRules() + "\n";
+         this.styleTag.textContent = text;
+         let target = root.head || root;
+         if (this.styleTag.parentNode != target)
+           target.insertBefore(this.styleTag, target.firstChild);
+       }
+     }
+
+     setNonce(nonce) {
+       if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce)
+         this.styleTag.setAttribute("nonce", nonce);
+     }
+   }
+
+   // Style::Object<union<Style,string>>
+   //
+   // A style is an object that, in the simple case, maps CSS property
+   // names to strings holding their values, as in `{color: "red",
+   // fontWeight: "bold"}`. The property names can be given in
+   // camel-case—the library will insert a dash before capital letters
+   // when converting them to CSS.
+   //
+   // If you include an underscore in a property name, it and everything
+   // after it will be removed from the output, which can be useful when
+   // providing a property multiple times, for browser compatibility
+   // reasons.
+   //
+   // A property in a style object can also be a sub-selector, which
+   // extends the current context to add a pseudo-selector or a child
+   // selector. Such a property should contain a `&` character, which
+   // will be replaced by the current selector. For example `{"&:before":
+   // {content: '"hi"'}}`. Sub-selectors and regular properties can
+   // freely be mixed in a given object. Any property containing a `&` is
+   // assumed to be a sub-selector.
+   //
+   // Finally, a property can specify an @-block to be wrapped around the
+   // styles defined inside the object that's the property's value. For
+   // example to create a media query you can do `{"@media screen and
+   // (min-width: 400px)": {...}}`.
+
+   var base = {
+     8: "Backspace",
+     9: "Tab",
+     10: "Enter",
+     12: "NumLock",
+     13: "Enter",
+     16: "Shift",
+     17: "Control",
+     18: "Alt",
+     20: "CapsLock",
+     27: "Escape",
+     32: " ",
+     33: "PageUp",
+     34: "PageDown",
+     35: "End",
+     36: "Home",
+     37: "ArrowLeft",
+     38: "ArrowUp",
+     39: "ArrowRight",
+     40: "ArrowDown",
+     44: "PrintScreen",
+     45: "Insert",
+     46: "Delete",
+     59: ";",
+     61: "=",
+     91: "Meta",
+     92: "Meta",
+     106: "*",
+     107: "+",
+     108: ",",
+     109: "-",
+     110: ".",
+     111: "/",
+     144: "NumLock",
+     145: "ScrollLock",
+     160: "Shift",
+     161: "Shift",
+     162: "Control",
+     163: "Control",
+     164: "Alt",
+     165: "Alt",
+     173: "-",
+     186: ";",
+     187: "=",
+     188: ",",
+     189: "-",
+     190: ".",
+     191: "/",
+     192: "`",
+     219: "[",
+     220: "\\",
+     221: "]",
+     222: "'"
+   };
+
+   var shift = {
+     48: ")",
+     49: "!",
+     50: "@",
+     51: "#",
+     52: "$",
+     53: "%",
+     54: "^",
+     55: "&",
+     56: "*",
+     57: "(",
+     59: ":",
+     61: "+",
+     173: "_",
+     186: ":",
+     187: "+",
+     188: "<",
+     189: "_",
+     190: ">",
+     191: "?",
+     192: "~",
+     219: "{",
+     220: "|",
+     221: "}",
+     222: "\""
+   };
+
+   var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
+   var ie$4 = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
+
+   // Fill in the digit keys
+   for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);
+
+   // The function keys
+   for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i;
+
+   // And the alphabetic keys
+   for (var i = 65; i <= 90; i++) {
+     base[i] = String.fromCharCode(i + 32);
+     shift[i] = String.fromCharCode(i);
+   }
+
+   // For each code that doesn't have a shift-equivalent, copy the base name
+   for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];
+
+   function keyName(event) {
+     // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.
+     // On IE, shift effect is never included in `.key`.
+     var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||
+         ie$4 && event.shiftKey && event.key && event.key.length == 1 ||
+         event.key == "Unidentified";
+     var name = (!ignoreKey && event.key) ||
+       (event.shiftKey ? shift : base)[event.keyCode] ||
+       event.key || "Unidentified";
+     // Edge sometimes produces wrong names (Issue #3)
+     if (name == "Esc") name = "Escape";
+     if (name == "Del") name = "Delete";
+     // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
+     if (name == "Left") name = "ArrowLeft";
+     if (name == "Up") name = "ArrowUp";
+     if (name == "Right") name = "ArrowRight";
+     if (name == "Down") name = "ArrowDown";
+     return name
+   }
+
+   function getSelection$3(root) {
+       let target;
+       // Browsers differ on whether shadow roots have a getSelection
+       // method. If it exists, use that, otherwise, call it on the
+       // document.
+       if (root.nodeType == 11) { // Shadow root
+           target = root.getSelection ? root : root.ownerDocument;
+       }
+       else {
+           target = root;
+       }
+       return target.getSelection();
+   }
+   function contains$3(dom, node) {
+       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
+   }
+   function deepActiveElement$2() {
+       let elt = document.activeElement;
+       while (elt && elt.shadowRoot)
+           elt = elt.shadowRoot.activeElement;
+       return elt;
+   }
+   function hasSelection$3(dom, selection) {
+       if (!selection.anchorNode)
+           return false;
+       try {
+           // Firefox will raise 'permission denied' errors when accessing
+           // properties of `sel.anchorNode` when it's in a generated CSS
+           // element.
+           return contains$3(dom, selection.anchorNode);
+       }
+       catch (_) {
+           return false;
+       }
+   }
+   function clientRectsFor$3(dom) {
+       if (dom.nodeType == 3)
+           return textRange$3(dom, 0, dom.nodeValue.length).getClientRects();
+       else if (dom.nodeType == 1)
+           return dom.getClientRects();
+       else
+           return [];
+   }
+   // Scans forward and backward through DOM positions equivalent to the
+   // given one to see if the two are in the same place (i.e. after a
+   // text node vs at the end of that text node)
+   function isEquivalentPosition$3(node, off, targetNode, targetOff) {
+       return targetNode ? (scanFor$3(node, off, targetNode, targetOff, -1) ||
+           scanFor$3(node, off, targetNode, targetOff, 1)) : false;
+   }
+   function domIndex$3(node) {
+       for (var index = 0;; index++) {
+           node = node.previousSibling;
+           if (!node)
+               return index;
+       }
+   }
+   function scanFor$3(node, off, targetNode, targetOff, dir) {
+       for (;;) {
+           if (node == targetNode && off == targetOff)
+               return true;
+           if (off == (dir < 0 ? 0 : maxOffset$3(node))) {
+               if (node.nodeName == "DIV")
+                   return false;
+               let parent = node.parentNode;
+               if (!parent || parent.nodeType != 1)
+                   return false;
+               off = domIndex$3(node) + (dir < 0 ? 0 : 1);
+               node = parent;
+           }
+           else if (node.nodeType == 1) {
+               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
+               if (node.nodeType == 1 && node.contentEditable == "false")
+                   return false;
+               off = dir < 0 ? maxOffset$3(node) : 0;
+           }
+           else {
+               return false;
+           }
+       }
+   }
+   function maxOffset$3(node) {
+       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
+   }
+   const Rect0$2 = { left: 0, right: 0, top: 0, bottom: 0 };
+   function flattenRect$3(rect, left) {
+       let x = left ? rect.left : rect.right;
+       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
+   }
+   function windowRect$3(win) {
+       return { left: 0, right: win.innerWidth,
+           top: 0, bottom: win.innerHeight };
+   }
+   function scrollRectIntoView$3(dom, rect, side, x, y, xMargin, yMargin, ltr) {
+       let doc = dom.ownerDocument, win = doc.defaultView;
+       for (let cur = dom; cur;) {
+           if (cur.nodeType == 1) { // Element
+               let bounding, top = cur == doc.body;
+               if (top) {
+                   bounding = windowRect$3(win);
+               }
+               else {
+                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
+                       cur = cur.parentNode;
+                       continue;
+                   }
+                   let rect = cur.getBoundingClientRect();
+                   // Make sure scrollbar width isn't included in the rectangle
+                   bounding = { left: rect.left, right: rect.left + cur.clientWidth,
+                       top: rect.top, bottom: rect.top + cur.clientHeight };
+               }
+               let moveX = 0, moveY = 0;
+               if (y == "nearest") {
+                   if (rect.top < bounding.top) {
+                       moveY = -(bounding.top - rect.top + yMargin);
+                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
+                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
+                   }
+                   else if (rect.bottom > bounding.bottom) {
+                       moveY = rect.bottom - bounding.bottom + yMargin;
+                       if (side < 0 && (rect.top - moveY) < bounding.top)
+                           moveY = -(bounding.top + moveY - rect.top + yMargin);
+                   }
+               }
+               else {
+                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
+                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
+                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
+                           rect.bottom - boundingHeight + yMargin;
+                   moveY = targetTop - bounding.top;
+               }
+               if (x == "nearest") {
+                   if (rect.left < bounding.left) {
+                       moveX = -(bounding.left - rect.left + xMargin);
+                       if (side > 0 && rect.right > bounding.right + moveX)
+                           moveX = rect.right - bounding.right + moveX + xMargin;
+                   }
+                   else if (rect.right > bounding.right) {
+                       moveX = rect.right - bounding.right + xMargin;
+                       if (side < 0 && rect.left < bounding.left + moveX)
+                           moveX = -(bounding.left + moveX - rect.left + xMargin);
+                   }
+               }
+               else {
+                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
+                       (x == "start") == ltr ? rect.left - xMargin :
+                           rect.right - (bounding.right - bounding.left) + xMargin;
+                   moveX = targetLeft - bounding.left;
+               }
+               if (moveX || moveY) {
+                   if (top) {
+                       win.scrollBy(moveX, moveY);
+                   }
+                   else {
+                       if (moveY) {
+                           let start = cur.scrollTop;
+                           cur.scrollTop += moveY;
+                           moveY = cur.scrollTop - start;
+                       }
+                       if (moveX) {
+                           let start = cur.scrollLeft;
+                           cur.scrollLeft += moveX;
+                           moveX = cur.scrollLeft - start;
+                       }
+                       rect = { left: rect.left - moveX, top: rect.top - moveY,
+                           right: rect.right - moveX, bottom: rect.bottom - moveY };
+                   }
+               }
+               if (top)
+                   break;
+               cur = cur.assignedSlot || cur.parentNode;
+               x = y = "nearest";
+           }
+           else if (cur.nodeType == 11) { // A shadow root
+               cur = cur.host;
+           }
+           else {
+               break;
+           }
+       }
+   }
+   let DOMSelectionState$3 = class DOMSelectionState {
+       constructor() {
+           this.anchorNode = null;
+           this.anchorOffset = 0;
+           this.focusNode = null;
+           this.focusOffset = 0;
+       }
+       eq(domSel) {
+           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
+               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
+       }
+       setRange(range) {
+           this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
+       }
+       set(anchorNode, anchorOffset, focusNode, focusOffset) {
+           this.anchorNode = anchorNode;
+           this.anchorOffset = anchorOffset;
+           this.focusNode = focusNode;
+           this.focusOffset = focusOffset;
+       }
+   };
+   let preventScrollSupported$3 = null;
+   // Feature-detects support for .focus({preventScroll: true}), and uses
+   // a fallback kludge when not supported.
+   function focusPreventScroll$3(dom) {
+       if (dom.setActive)
+           return dom.setActive(); // in IE
+       if (preventScrollSupported$3)
+           return dom.focus(preventScrollSupported$3);
+       let stack = [];
+       for (let cur = dom; cur; cur = cur.parentNode) {
+           stack.push(cur, cur.scrollTop, cur.scrollLeft);
+           if (cur == cur.ownerDocument)
+               break;
+       }
+       dom.focus(preventScrollSupported$3 == null ? {
+           get preventScroll() {
+               preventScrollSupported$3 = { preventScroll: true };
+               return true;
+           }
+       } : undefined);
+       if (!preventScrollSupported$3) {
+           preventScrollSupported$3 = false;
+           for (let i = 0; i < stack.length;) {
+               let elt = stack[i++], top = stack[i++], left = stack[i++];
+               if (elt.scrollTop != top)
+                   elt.scrollTop = top;
+               if (elt.scrollLeft != left)
+                   elt.scrollLeft = left;
+           }
+       }
+   }
+   let scratchRange$3;
+   function textRange$3(node, from, to = from) {
+       let range = scratchRange$3 || (scratchRange$3 = document.createRange());
+       range.setEnd(node, to);
+       range.setStart(node, from);
+       return range;
+   }
+   function dispatchKey$3(elt, name, code) {
+       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
+       let down = new KeyboardEvent("keydown", options);
+       down.synthetic = true;
+       elt.dispatchEvent(down);
+       let up = new KeyboardEvent("keyup", options);
+       up.synthetic = true;
+       elt.dispatchEvent(up);
+       return down.defaultPrevented || up.defaultPrevented;
+   }
+   function getRoot$3(node) {
+       while (node) {
+           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
+               return node;
+           node = node.assignedSlot || node.parentNode;
+       }
+       return null;
+   }
+   function clearAttributes$3(node) {
+       while (node.attributes.length)
+           node.removeAttributeNode(node.attributes[0]);
+   }
+
+   let DOMPos$3 = class DOMPos {
+       constructor(node, offset, precise = true) {
+           this.node = node;
+           this.offset = offset;
+           this.precise = precise;
+       }
+       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex$3(dom), precise); }
+       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex$3(dom) + 1, precise); }
+   };
+   const noChildren$3 = [];
+   let ContentView$3 = class ContentView {
+       constructor() {
+           this.parent = null;
+           this.dom = null;
+           this.dirty = 2 /* Node */;
+       }
+       get editorView() {
+           if (!this.parent)
+               throw new Error("Accessing view in orphan content view");
+           return this.parent.editorView;
+       }
+       get overrideDOMText() { return null; }
+       get posAtStart() {
+           return this.parent ? this.parent.posBefore(this) : 0;
+       }
+       get posAtEnd() {
+           return this.posAtStart + this.length;
+       }
+       posBefore(view) {
+           let pos = this.posAtStart;
+           for (let child of this.children) {
+               if (child == view)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+           throw new RangeError("Invalid child in posBefore");
+       }
+       posAfter(view) {
+           return this.posBefore(view) + view.length;
+       }
+       // Will return a rectangle directly before (when side < 0), after
+       // (side > 0) or directly on (when the browser supports it) the
+       // given position.
+       coordsAt(_pos, _side) { return null; }
+       sync(track) {
+           if (this.dirty & 2 /* Node */) {
+               let parent = this.dom;
+               let prev = null, next;
+               for (let child of this.children) {
+                   if (child.dirty) {
+                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
+                           let contentView = ContentView.get(next);
+                           if (!contentView || !contentView.parent && contentView.constructor == child.constructor)
+                               child.reuseDOM(next);
+                       }
+                       child.sync(track);
+                       child.dirty = 0 /* Not */;
+                   }
+                   next = prev ? prev.nextSibling : parent.firstChild;
+                   if (track && !track.written && track.node == parent && next != child.dom)
+                       track.written = true;
+                   if (child.dom.parentNode == parent) {
+                       while (next && next != child.dom)
+                           next = rm$1$3(next);
+                   }
+                   else {
+                       parent.insertBefore(child.dom, next);
+                   }
+                   prev = child.dom;
+               }
+               next = prev ? prev.nextSibling : parent.firstChild;
+               if (next && track && track.node == parent)
+                   track.written = true;
+               while (next)
+                   next = rm$1$3(next);
+           }
+           else if (this.dirty & 1 /* Child */) {
+               for (let child of this.children)
+                   if (child.dirty) {
+                       child.sync(track);
+                       child.dirty = 0 /* Not */;
+                   }
+           }
+       }
+       reuseDOM(_dom) { }
+       localPosFromDOM(node, offset) {
+           let after;
+           if (node == this.dom) {
+               after = this.dom.childNodes[offset];
+           }
+           else {
+               let bias = maxOffset$3(node) == 0 ? 0 : offset == 0 ? -1 : 1;
+               for (;;) {
+                   let parent = node.parentNode;
+                   if (parent == this.dom)
+                       break;
+                   if (bias == 0 && parent.firstChild != parent.lastChild) {
+                       if (node == parent.firstChild)
+                           bias = -1;
+                       else
+                           bias = 1;
+                   }
+                   node = parent;
+               }
+               if (bias < 0)
+                   after = node;
+               else
+                   after = node.nextSibling;
+           }
+           if (after == this.dom.firstChild)
+               return 0;
+           while (after && !ContentView.get(after))
+               after = after.nextSibling;
+           if (!after)
+               return this.length;
+           for (let i = 0, pos = 0;; i++) {
+               let child = this.children[i];
+               if (child.dom == after)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+       }
+       domBoundsAround(from, to, offset = 0) {
+           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
+           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos < from && end > to)
+                   return child.domBoundsAround(from, to, pos);
+               if (end >= from && fromI == -1) {
+                   fromI = i;
+                   fromStart = pos;
+               }
+               if (pos > to && child.dom.parentNode == this.dom) {
+                   toI = i;
+                   toEnd = prevEnd;
+                   break;
+               }
+               prevEnd = end;
+               pos = end + child.breakAfter;
+           }
+           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
+               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
+               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
+       }
+       markDirty(andParent = false) {
+           this.dirty |= 2 /* Node */;
+           this.markParentsDirty(andParent);
+       }
+       markParentsDirty(childList) {
+           for (let parent = this.parent; parent; parent = parent.parent) {
+               if (childList)
+                   parent.dirty |= 2 /* Node */;
+               if (parent.dirty & 1 /* Child */)
+                   return;
+               parent.dirty |= 1 /* Child */;
+               childList = false;
+           }
+       }
+       setParent(parent) {
+           if (this.parent != parent) {
+               this.parent = parent;
+               if (this.dirty)
+                   this.markParentsDirty(true);
+           }
+       }
+       setDOM(dom) {
+           if (this.dom)
+               this.dom.cmView = null;
+           this.dom = dom;
+           dom.cmView = this;
+       }
+       get rootView() {
+           for (let v = this;;) {
+               let parent = v.parent;
+               if (!parent)
+                   return v;
+               v = parent;
+           }
+       }
+       replaceChildren(from, to, children = noChildren$3) {
+           this.markDirty();
+           for (let i = from; i < to; i++) {
+               let child = this.children[i];
+               if (child.parent == this)
+                   child.destroy();
+           }
+           this.children.splice(from, to - from, ...children);
+           for (let i = 0; i < children.length; i++)
+               children[i].setParent(this);
+       }
+       ignoreMutation(_rec) { return false; }
+       ignoreEvent(_event) { return false; }
+       childCursor(pos = this.length) {
+           return new ChildCursor$3(this.children, pos, this.children.length);
+       }
+       childPos(pos, bias = 1) {
+           return this.childCursor().findPos(pos, bias);
+       }
+       toString() {
+           let name = this.constructor.name.replace("View", "");
+           return name + (this.children.length ? "(" + this.children.join() + ")" :
+               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
+               (this.breakAfter ? "#" : "");
+       }
+       static get(node) { return node.cmView; }
+       get isEditable() { return true; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           return false;
+       }
+       become(other) { return false; }
+       // When this is a zero-length view with a side, this should return a
+       // number <= 0 to indicate it is before its position, or a
+       // number > 0 when after its position.
+       getSide() { return 0; }
+       destroy() {
+           this.parent = null;
+       }
+   };
+   ContentView$3.prototype.breakAfter = 0;
+   // Remove a DOM node and return its next sibling.
+   function rm$1$3(dom) {
+       let next = dom.nextSibling;
+       dom.parentNode.removeChild(dom);
+       return next;
+   }
+   let ChildCursor$3 = class ChildCursor {
+       constructor(children, pos, i) {
+           this.children = children;
+           this.pos = pos;
+           this.i = i;
+           this.off = 0;
+       }
+       findPos(pos, bias = 1) {
+           for (;;) {
+               if (pos > this.pos || pos == this.pos &&
+                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
+                   this.off = pos - this.pos;
+                   return this;
+               }
+               let next = this.children[--this.i];
+               this.pos -= next.length + next.breakAfter;
+           }
+       }
+   };
+   function replaceRange$3(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
+       let { children } = parent;
+       let before = children.length ? children[fromI] : null;
+       let last = insert.length ? insert[insert.length - 1] : null;
+       let breakAtEnd = last ? last.breakAfter : breakAtStart;
+       // Change within a single child
+       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
+           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
+           return;
+       if (toI < children.length) {
+           let after = children[toI];
+           // Make sure the end of the child after the update is preserved in `after`
+           if (after && toOff < after.length) {
+               // If we're splitting a child, separate part of it to avoid that
+               // being mangled when updating the child before the update.
+               if (fromI == toI) {
+                   after = after.split(toOff);
+                   toOff = 0;
+               }
+               // If the element after the replacement should be merged with
+               // the last replacing element, update `content`
+               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
+                   insert[insert.length - 1] = after;
+               }
+               else {
+                   // Remove the start of the after element, if necessary, and
+                   // add it to `content`.
+                   if (toOff)
+                       after.merge(0, toOff, null, false, 0, openEnd);
+                   insert.push(after);
+               }
+           }
+           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
+               // The element at `toI` is entirely covered by this range.
+               // Preserve its line break, if any.
+               if (last)
+                   last.breakAfter = 1;
+               else
+                   breakAtStart = 1;
+           }
+           // Since we've handled the next element from the current elements
+           // now, make sure `toI` points after that.
+           toI++;
+       }
+       if (before) {
+           before.breakAfter = breakAtStart;
+           if (fromOff > 0) {
+               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
+                   before.breakAfter = insert.shift().breakAfter;
+               }
+               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
+                   before.merge(fromOff, before.length, null, false, openStart, 0);
+               }
+               fromI++;
+           }
+       }
+       // Try to merge widgets on the boundaries of the replacement
+       while (fromI < toI && insert.length) {
+           if (children[toI - 1].become(insert[insert.length - 1])) {
+               toI--;
+               insert.pop();
+               openEnd = insert.length ? 0 : openStart;
+           }
+           else if (children[fromI].become(insert[0])) {
+               fromI++;
+               insert.shift();
+               openStart = insert.length ? 0 : openEnd;
+           }
+           else {
+               break;
+           }
+       }
+       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
+           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
+           fromI--;
+       if (fromI < toI || insert.length)
+           parent.replaceChildren(fromI, toI, insert);
+   }
+   function mergeChildrenInto$3(parent, from, to, insert, openStart, openEnd) {
+       let cur = parent.childCursor();
+       let { i: toI, off: toOff } = cur.findPos(to, 1);
+       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
+       let dLen = from - to;
+       for (let view of insert)
+           dLen += view.length;
+       parent.length += dLen;
+       replaceRange$3(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
+   }
+
+   let nav$3 = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
+   let doc$3 = typeof document != "undefined" ? document : { documentElement: { style: {} } };
+   const ie_edge$3 = /*@__PURE__*//Edge\/(\d+)/.exec(nav$3.userAgent);
+   const ie_upto10$3 = /*@__PURE__*//MSIE \d/.test(nav$3.userAgent);
+   const ie_11up$3 = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav$3.userAgent);
+   const ie$3 = !!(ie_upto10$3 || ie_11up$3 || ie_edge$3);
+   const gecko$3 = !ie$3 && /*@__PURE__*//gecko\/(\d+)/i.test(nav$3.userAgent);
+   const chrome$3 = !ie$3 && /*@__PURE__*//Chrome\/(\d+)/.exec(nav$3.userAgent);
+   const webkit$3 = "webkitFontSmoothing" in doc$3.documentElement.style;
+   const safari$3 = !ie$3 && /*@__PURE__*//Apple Computer/.test(nav$3.vendor);
+   const ios$3 = safari$3 && (/*@__PURE__*//Mobile\/\w+/.test(nav$3.userAgent) || nav$3.maxTouchPoints > 2);
+   var browser$3 = {
+       mac: ios$3 || /*@__PURE__*//Mac/.test(nav$3.platform),
+       windows: /*@__PURE__*//Win/.test(nav$3.platform),
+       linux: /*@__PURE__*//Linux|X11/.test(nav$3.platform),
+       ie: ie$3,
+       ie_version: ie_upto10$3 ? doc$3.documentMode || 6 : ie_11up$3 ? +ie_11up$3[1] : ie_edge$3 ? +ie_edge$3[1] : 0,
+       gecko: gecko$3,
+       gecko_version: gecko$3 ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav$3.userAgent) || [0, 0])[1] : 0,
+       chrome: !!chrome$3,
+       chrome_version: chrome$3 ? +chrome$3[1] : 0,
+       ios: ios$3,
+       android: /*@__PURE__*//Android\b/.test(nav$3.userAgent),
+       webkit: webkit$3,
+       safari: safari$3,
+       webkit_version: webkit$3 ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
+       tabSize: doc$3.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
+   };
+
+   const MaxJoinLen$3 = 256;
+   let TextView$3 = class TextView extends ContentView$3 {
+       constructor(text) {
+           super();
+           this.text = text;
+       }
+       get length() { return this.text.length; }
+       createDOM(textDOM) {
+           this.setDOM(textDOM || document.createTextNode(this.text));
+       }
+       sync(track) {
+           if (!this.dom)
+               this.createDOM();
+           if (this.dom.nodeValue != this.text) {
+               if (track && track.node == this.dom)
+                   track.written = true;
+               this.dom.nodeValue = this.text;
+           }
+       }
+       reuseDOM(dom) {
+           if (dom.nodeType == 3)
+               this.createDOM(dom);
+       }
+       merge(from, to, source) {
+           if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen$3))
+               return false;
+           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = new TextView(this.text.slice(from));
+           this.text = this.text.slice(0, from);
+           this.markDirty();
+           return result;
+       }
+       localPosFromDOM(node, offset) {
+           return node == this.dom ? offset : offset ? this.text.length : 0;
+       }
+       domAtPos(pos) { return new DOMPos$3(this.dom, pos); }
+       domBoundsAround(_from, _to, offset) {
+           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
+       }
+       coordsAt(pos, side) {
+           return textCoords$3(this.dom, pos, side);
+       }
+   };
+   let MarkView$3 = class MarkView extends ContentView$3 {
+       constructor(mark, children = [], length = 0) {
+           super();
+           this.mark = mark;
+           this.children = children;
+           this.length = length;
+           for (let ch of children)
+               ch.setParent(this);
+       }
+       setAttrs(dom) {
+           clearAttributes$3(dom);
+           if (this.mark.class)
+               dom.className = this.mark.class;
+           if (this.mark.attrs)
+               for (let name in this.mark.attrs)
+                   dom.setAttribute(name, this.mark.attrs[name]);
+           return dom;
+       }
+       reuseDOM(node) {
+           if (node.nodeName == this.mark.tagName.toUpperCase()) {
+               this.setDOM(node);
+               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
+           }
+       }
+       sync(track) {
+           if (!this.dom)
+               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
+           else if (this.dirty & 4 /* Attrs */)
+               this.setAttrs(this.dom);
+           super.sync(track);
+       }
+       merge(from, to, source, _hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
+               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
+               return false;
+           mergeChildrenInto$3(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = [], off = 0, detachFrom = -1, i = 0;
+           for (let elt of this.children) {
+               let end = off + elt.length;
+               if (end > from)
+                   result.push(off < from ? elt.split(from - off) : elt);
+               if (detachFrom < 0 && off >= from)
+                   detachFrom = i;
+               off = end;
+               i++;
+           }
+           let length = this.length - from;
+           this.length = from;
+           if (detachFrom > -1) {
+               this.children.length = detachFrom;
+               this.markDirty();
+           }
+           return new MarkView(this.mark, result, length);
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos$3(this.dom, this.children, pos);
+       }
+       coordsAt(pos, side) {
+           return coordsInChildren$3(this, pos, side);
+       }
+   };
+   function textCoords$3(text, pos, side) {
+       let length = text.nodeValue.length;
+       if (pos > length)
+           pos = length;
+       let from = pos, to = pos, flatten = 0;
+       if (pos == 0 && side < 0 || pos == length && side >= 0) {
+           if (!(browser$3.chrome || browser$3.gecko)) { // These browsers reliably return valid rectangles for empty ranges
+               if (pos) {
+                   from--;
+                   flatten = 1;
+               } // FIXME this is wrong in RTL text
+               else if (to < length) {
+                   to++;
+                   flatten = -1;
+               }
+           }
+       }
+       else {
+           if (side < 0)
+               from--;
+           else if (to < length)
+               to++;
+       }
+       let rects = textRange$3(text, from, to).getClientRects();
+       if (!rects.length)
+           return Rect0$2;
+       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
+       if (browser$3.safari && !flatten && rect.width == 0)
+           rect = Array.prototype.find.call(rects, r => r.width) || rect;
+       return flatten ? flattenRect$3(rect, flatten < 0) : rect || null;
+   }
+   // Also used for collapsed ranges that don't have a placeholder widget!
+   let WidgetView$3 = class WidgetView extends ContentView$3 {
+       constructor(widget, length, side) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.side = side;
+           this.prevWidget = null;
+       }
+       static create(widget, length, side) {
+           return new (widget.customView || WidgetView)(widget, length, side);
+       }
+       split(from) {
+           let result = WidgetView.create(this.widget, this.length - from, this.side);
+           this.length -= from;
+           return result;
+       }
+       sync() {
+           if (!this.dom || !this.widget.updateDOM(this.dom)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(this.editorView));
+               this.dom.contentEditable = "false";
+           }
+       }
+       getSide() { return this.side; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       become(other) {
+           if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
+               if (this.widget.constructor == other.widget.constructor) {
+                   if (!this.widget.eq(other.widget))
+                       this.markDirty(true);
+                   if (this.dom && !this.prevWidget)
+                       this.prevWidget = this.widget;
+                   this.widget = other.widget;
+                   return true;
+               }
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       get overrideDOMText() {
+           if (this.length == 0)
+               return Text$3.empty;
+           let top = this;
+           while (top.parent)
+               top = top.parent;
+           let view = top.editorView, text = view && view.state.doc, start = this.posAtStart;
+           return text ? text.slice(start, start + this.length) : Text$3.empty;
+       }
+       domAtPos(pos) {
+           return pos == 0 ? DOMPos$3.before(this.dom) : DOMPos$3.after(this.dom, pos == this.length);
+       }
+       domBoundsAround() { return null; }
+       coordsAt(pos, side) {
+           let rects = this.dom.getClientRects(), rect = null;
+           if (!rects.length)
+               return Rect0$2;
+           for (let i = pos > 0 ? rects.length - 1 : 0;; i += (pos > 0 ? -1 : 1)) {
+               rect = rects[i];
+               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
+                   break;
+           }
+           return (pos == 0 && side > 0 || pos == this.length && side <= 0) ? rect : flattenRect$3(rect, pos == 0);
+       }
+       get isEditable() { return false; }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+   };
+   let CompositionView$2 = class CompositionView extends WidgetView$3 {
+       domAtPos(pos) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return new DOMPos$3(text, Math.min(pos, text.nodeValue.length));
+           return scanCompositionTree$2(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos$3(text, Math.min(p, text.nodeValue.length)));
+       }
+       sync() { this.setDOM(this.widget.toDOM()); }
+       localPosFromDOM(node, offset) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return Math.min(offset, this.length);
+           return posFromDOMInCompositionTree$2(node, offset, topView, text);
+       }
+       ignoreMutation() { return false; }
+       get overrideDOMText() { return null; }
+       coordsAt(pos, side) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return textCoords$3(text, pos, side);
+           return scanCompositionTree$2(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords$3(text, pos, side));
+       }
+       destroy() {
+           var _a;
+           super.destroy();
+           (_a = this.widget.topView) === null || _a === void 0 ? void 0 : _a.destroy();
+       }
+       get isEditable() { return true; }
+   };
+   // Uses the old structure of a chunk of content view frozen for
+   // composition to try and find a reasonable DOM location for the given
+   // offset.
+   function scanCompositionTree$2(pos, side, view, text, enterView, fromText) {
+       if (view instanceof MarkView$3) {
+           for (let child of view.children) {
+               let hasComp = contains$3(child.dom, text);
+               let len = hasComp ? text.nodeValue.length : child.length;
+               if (pos < len || pos == len && child.getSide() <= 0)
+                   return hasComp ? scanCompositionTree$2(pos, side, child, text, enterView, fromText) : enterView(child, pos, side);
+               pos -= len;
+           }
+           return enterView(view, view.length, -1);
+       }
+       else if (view.dom == text) {
+           return fromText(pos, side);
+       }
+       else {
+           return enterView(view, pos, side);
+       }
+   }
+   function posFromDOMInCompositionTree$2(node, offset, view, text) {
+       if (view instanceof MarkView$3) {
+           for (let child of view.children) {
+               let pos = 0, hasComp = contains$3(child.dom, text);
+               if (contains$3(child.dom, node))
+                   return pos + (hasComp ? posFromDOMInCompositionTree$2(node, offset, child, text) : child.localPosFromDOM(node, offset));
+               pos += hasComp ? text.nodeValue.length : child.length;
+           }
+       }
+       else if (view.dom == text) {
+           return Math.min(offset, text.nodeValue.length);
+       }
+       return view.localPosFromDOM(node, offset);
+   }
+   // These are drawn around uneditable widgets to avoid a number of
+   // browser bugs that show up when the cursor is directly next to
+   // uneditable inline content.
+   let WidgetBufferView$3 = class WidgetBufferView extends ContentView$3 {
+       constructor(side) {
+           super();
+           this.side = side;
+       }
+       get length() { return 0; }
+       merge() { return false; }
+       become(other) {
+           return other instanceof WidgetBufferView && other.side == this.side;
+       }
+       split() { return new WidgetBufferView(this.side); }
+       sync() {
+           if (!this.dom) {
+               let dom = document.createElement("img");
+               dom.className = "cm-widgetBuffer";
+               dom.setAttribute("aria-hidden", "true");
+               this.setDOM(dom);
+           }
+       }
+       getSide() { return this.side; }
+       domAtPos(pos) { return DOMPos$3.before(this.dom); }
+       localPosFromDOM() { return 0; }
+       domBoundsAround() { return null; }
+       coordsAt(pos) {
+           let imgRect = this.dom.getBoundingClientRect();
+           // Since the <img> height doesn't correspond to text height, try
+           // to borrow the height from some sibling node.
+           let siblingRect = inlineSiblingRect$2(this, this.side > 0 ? -1 : 1);
+           return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top
+               ? { left: imgRect.left, right: imgRect.right, top: siblingRect.top, bottom: siblingRect.bottom } : imgRect;
+       }
+       get overrideDOMText() {
+           return Text$3.empty;
+       }
+   };
+   TextView$3.prototype.children = WidgetView$3.prototype.children = WidgetBufferView$3.prototype.children = noChildren$3;
+   function inlineSiblingRect$2(view, side) {
+       let parent = view.parent, index = parent ? parent.children.indexOf(view) : -1;
+       while (parent && index >= 0) {
+           if (side < 0 ? index > 0 : index < parent.children.length) {
+               let next = parent.children[index + side];
+               if (next instanceof TextView$3) {
+                   let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
+                   if (nextRect)
+                       return nextRect;
+               }
+               index += side;
+           }
+           else if (parent instanceof MarkView$3 && parent.parent) {
+               index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
+               parent = parent.parent;
+           }
+           else {
+               let last = parent.dom.lastChild;
+               if (last && last.nodeName == "BR")
+                   return last.getClientRects()[0];
+               break;
+           }
+       }
+       return undefined;
+   }
+   function inlineDOMAtPos$3(dom, children, pos) {
+       let i = 0;
+       for (let off = 0; i < children.length; i++) {
+           let child = children[i], end = off + child.length;
+           if (end == off && child.getSide() <= 0)
+               continue;
+           if (pos > off && pos < end && child.dom.parentNode == dom)
+               return child.domAtPos(pos - off);
+           if (pos <= off)
+               break;
+           off = end;
+       }
+       for (; i > 0; i--) {
+           let before = children[i - 1].dom;
+           if (before.parentNode == dom)
+               return DOMPos$3.after(before);
+       }
+       return new DOMPos$3(dom, 0);
+   }
+   // Assumes `view`, if a mark view, has precisely 1 child.
+   function joinInlineInto$3(parent, view, open) {
+       let last, { children } = parent;
+       if (open > 0 && view instanceof MarkView$3 && children.length &&
+           (last = children[children.length - 1]) instanceof MarkView$3 && last.mark.eq(view.mark)) {
+           joinInlineInto$3(last, view.children[0], open - 1);
+       }
+       else {
+           children.push(view);
+           view.setParent(parent);
+       }
+       parent.length += view.length;
+   }
+   function coordsInChildren$3(view, pos, side) {
+       for (let off = 0, i = 0; i < view.children.length; i++) {
+           let child = view.children[i], end = off + child.length, next;
+           if ((side <= 0 || end == view.length || child.getSide() > 0 ? end >= pos : end > pos) &&
+               (pos < end || i + 1 == view.children.length || (next = view.children[i + 1]).length || next.getSide() > 0)) {
+               let flatten = 0;
+               if (end == off) {
+                   if (child.getSide() <= 0)
+                       continue;
+                   flatten = side = -child.getSide();
+               }
+               let rect = child.coordsAt(Math.max(0, pos - off), side);
+               return flatten && rect ? flattenRect$3(rect, side < 0) : rect;
+           }
+           off = end;
+       }
+       let last = view.dom.lastChild;
+       if (!last)
+           return view.dom.getBoundingClientRect();
+       let rects = clientRectsFor$3(last);
+       return rects[rects.length - 1] || null;
+   }
+
+   function combineAttrs$3(source, target) {
+       for (let name in source) {
+           if (name == "class" && target.class)
+               target.class += " " + source.class;
+           else if (name == "style" && target.style)
+               target.style += ";" + source.style;
+           else
+               target[name] = source[name];
+       }
+       return target;
+   }
+   function attrsEq$3(a, b) {
+       if (a == b)
+           return true;
+       if (!a || !b)
+           return false;
+       let keysA = Object.keys(a), keysB = Object.keys(b);
+       if (keysA.length != keysB.length)
+           return false;
+       for (let key of keysA) {
+           if (keysB.indexOf(key) == -1 || a[key] !== b[key])
+               return false;
+       }
+       return true;
+   }
+   function updateAttrs$3(dom, prev, attrs) {
+       let changed = null;
+       if (prev)
+           for (let name in prev)
+               if (!(attrs && name in attrs))
+                   dom.removeAttribute(changed = name);
+       if (attrs)
+           for (let name in attrs)
+               if (!(prev && prev[name] == attrs[name]))
+                   dom.setAttribute(changed = name, attrs[name]);
+       return !!changed;
+   }
+
+   /**
+   Widgets added to the content are described by subclasses of this
+   class. Using a description object like that makes it possible to
+   delay creating of the DOM structure for a widget until it is
+   needed, and to avoid redrawing widgets even if the decorations
+   that define them are recreated.
+   */
+   let WidgetType$3 = class WidgetType {
+       /**
+       Compare this instance to another instance of the same type.
+       (TypeScript can't express this, but only instances of the same
+       specific class will be passed to this method.) This is used to
+       avoid redrawing widgets when they are replaced by a new
+       decoration of the same type. The default implementation just
+       returns `false`, which will cause new instances of the widget to
+       always be redrawn.
+       */
+       eq(widget) { return false; }
+       /**
+       Update a DOM element created by a widget of the same type (but
+       different, non-`eq` content) to reflect this widget. May return
+       true to indicate that it could update, false to indicate it
+       couldn't (in which case the widget will be redrawn). The default
+       implementation just returns false.
+       */
+       updateDOM(dom) { return false; }
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       The estimated height this widget will have, to be used when
+       estimating the height of content that hasn't been drawn. May
+       return -1 to indicate you don't know. The default implementation
+       returns -1.
+       */
+       get estimatedHeight() { return -1; }
+       /**
+       Can be used to configure which kinds of events inside the widget
+       should be ignored by the editor. The default is to ignore all
+       events.
+       */
+       ignoreEvent(event) { return true; }
+       /**
+       @internal
+       */
+       get customView() { return null; }
+       /**
+       This is called when the an instance of the widget is removed
+       from the editor view.
+       */
+       destroy(dom) { }
+   };
+   /**
+   The different types of blocks that can occur in an editor view.
+   */
+   var BlockType$3 = /*@__PURE__*/(function (BlockType) {
+       /**
+       A line of text.
+       */
+       BlockType[BlockType["Text"] = 0] = "Text";
+       /**
+       A block widget associated with the position after it.
+       */
+       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
+       /**
+       A block widget associated with the position before it.
+       */
+       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
+       /**
+       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
+       */
+       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
+   return BlockType})(BlockType$3 || (BlockType$3 = {}));
+   /**
+   A decoration provides information on how to draw or style a piece
+   of content. You'll usually use it wrapped in a
+   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
+   @nonabstract
+   */
+   let Decoration$3 = class Decoration extends RangeValue$3 {
+       constructor(
+       /**
+       @internal
+       */
+       startSide, 
+       /**
+       @internal
+       */
+       endSide, 
+       /**
+       @internal
+       */
+       widget, 
+       /**
+       The config object used to create this decoration. You can
+       include additional properties in there to store metadata about
+       your decoration.
+       */
+       spec) {
+           super();
+           this.startSide = startSide;
+           this.endSide = endSide;
+           this.widget = widget;
+           this.spec = spec;
+       }
+       /**
+       @internal
+       */
+       get heightRelevant() { return false; }
+       /**
+       Create a mark decoration, which influences the styling of the
+       content in its range. Nested mark decorations will cause nested
+       DOM elements to be created. Nesting order is determined by
+       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
+       the higher-precedence decorations creating the inner DOM nodes.
+       Such elements are split on line boundaries and on the boundaries
+       of lower-precedence decorations.
+       */
+       static mark(spec) {
+           return new MarkDecoration$3(spec);
+       }
+       /**
+       Create a widget decoration, which displays a DOM element at the
+       given position.
+       */
+       static widget(spec) {
+           let side = spec.side || 0, block = !!spec.block;
+           side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
+           return new PointDecoration$3(spec, side, side, block, spec.widget || null, false);
+       }
+       /**
+       Create a replace decoration which replaces the given range with
+       a widget, or simply hides it.
+       */
+       static replace(spec) {
+           let block = !!spec.block, startSide, endSide;
+           if (spec.isBlockGap) {
+               startSide = -500000000 /* GapStart */;
+               endSide = 400000000 /* GapEnd */;
+           }
+           else {
+               let { start, end } = getInclusive$3(spec, block);
+               startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
+               endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
+           }
+           return new PointDecoration$3(spec, startSide, endSide, block, spec.widget || null, true);
+       }
+       /**
+       Create a line decoration, which can add DOM attributes to the
+       line starting at the given position.
+       */
+       static line(spec) {
+           return new LineDecoration$3(spec);
+       }
+       /**
+       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
+       decorated range or ranges. If the ranges aren't already sorted,
+       pass `true` for `sort` to make the library sort them for you.
+       */
+       static set(of, sort = false) {
+           return RangeSet$3.of(of, sort);
+       }
+       /**
+       @internal
+       */
+       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
+   };
+   /**
+   The empty set of decorations.
+   */
+   Decoration$3.none = RangeSet$3.empty;
+   let MarkDecoration$3 = class MarkDecoration extends Decoration$3 {
+       constructor(spec) {
+           let { start, end } = getInclusive$3(spec);
+           super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
+           this.tagName = spec.tagName || "span";
+           this.class = spec.class || "";
+           this.attrs = spec.attributes || null;
+       }
+       eq(other) {
+           return this == other ||
+               other instanceof MarkDecoration &&
+                   this.tagName == other.tagName &&
+                   this.class == other.class &&
+                   attrsEq$3(this.attrs, other.attrs);
+       }
+       range(from, to = from) {
+           if (from >= to)
+               throw new RangeError("Mark decorations may not be empty");
+           return super.range(from, to);
+       }
+   };
+   MarkDecoration$3.prototype.point = false;
+   let LineDecoration$3 = class LineDecoration extends Decoration$3 {
+       constructor(spec) {
+           super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
+       }
+       eq(other) {
+           return other instanceof LineDecoration && attrsEq$3(this.spec.attributes, other.spec.attributes);
+       }
+       range(from, to = from) {
+           if (to != from)
+               throw new RangeError("Line decoration ranges must be zero-length");
+           return super.range(from, to);
+       }
+   };
+   LineDecoration$3.prototype.mapMode = MapMode$3.TrackBefore;
+   LineDecoration$3.prototype.point = true;
+   let PointDecoration$3 = class PointDecoration extends Decoration$3 {
+       constructor(spec, startSide, endSide, block, widget, isReplace) {
+           super(startSide, endSide, widget, spec);
+           this.block = block;
+           this.isReplace = isReplace;
+           this.mapMode = !block ? MapMode$3.TrackDel : startSide <= 0 ? MapMode$3.TrackBefore : MapMode$3.TrackAfter;
+       }
+       // Only relevant when this.block == true
+       get type() {
+           return this.startSide < this.endSide ? BlockType$3.WidgetRange
+               : this.startSide <= 0 ? BlockType$3.WidgetBefore : BlockType$3.WidgetAfter;
+       }
+       get heightRelevant() { return this.block || !!this.widget && this.widget.estimatedHeight >= 5; }
+       eq(other) {
+           return other instanceof PointDecoration &&
+               widgetsEq$3(this.widget, other.widget) &&
+               this.block == other.block &&
+               this.startSide == other.startSide && this.endSide == other.endSide;
+       }
+       range(from, to = from) {
+           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
+               throw new RangeError("Invalid range for replacement decoration");
+           if (!this.isReplace && to != from)
+               throw new RangeError("Widget decorations can only have zero-length ranges");
+           return super.range(from, to);
+       }
+   };
+   PointDecoration$3.prototype.point = true;
+   function getInclusive$3(spec, block = false) {
+       let { inclusiveStart: start, inclusiveEnd: end } = spec;
+       if (start == null)
+           start = spec.inclusive;
+       if (end == null)
+           end = spec.inclusive;
+       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
+   }
+   function widgetsEq$3(a, b) {
+       return a == b || !!(a && b && a.compare(b));
+   }
+   function addRange$3(from, to, ranges, margin = 0) {
+       let last = ranges.length - 1;
+       if (last >= 0 && ranges[last] + margin >= from)
+           ranges[last] = Math.max(ranges[last], to);
+       else
+           ranges.push(from, to);
+   }
+
+   let LineView$3 = class LineView extends ContentView$3 {
+       constructor() {
+           super(...arguments);
+           this.children = [];
+           this.length = 0;
+           this.prevAttrs = undefined;
+           this.attrs = null;
+           this.breakAfter = 0;
+       }
+       // Consumes source
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source) {
+               if (!(source instanceof LineView))
+                   return false;
+               if (!this.dom)
+                   source.transferDOM(this); // Reuse source.dom when appropriate
+           }
+           if (hasStart)
+               this.setDeco(source ? source.attrs : null);
+           mergeChildrenInto$3(this, from, to, source ? source.children : [], openStart, openEnd);
+           return true;
+       }
+       split(at) {
+           let end = new LineView;
+           end.breakAfter = this.breakAfter;
+           if (this.length == 0)
+               return end;
+           let { i, off } = this.childPos(at);
+           if (off) {
+               end.append(this.children[i].split(off), 0);
+               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
+               i++;
+           }
+           for (let j = i; j < this.children.length; j++)
+               end.append(this.children[j], 0);
+           while (i > 0 && this.children[i - 1].length == 0)
+               this.children[--i].destroy();
+           this.children.length = i;
+           this.markDirty();
+           this.length = at;
+           return end;
+       }
+       transferDOM(other) {
+           if (!this.dom)
+               return;
+           this.markDirty();
+           other.setDOM(this.dom);
+           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
+           this.prevAttrs = undefined;
+           this.dom = null;
+       }
+       setDeco(attrs) {
+           if (!attrsEq$3(this.attrs, attrs)) {
+               if (this.dom) {
+                   this.prevAttrs = this.attrs;
+                   this.markDirty();
+               }
+               this.attrs = attrs;
+           }
+       }
+       append(child, openStart) {
+           joinInlineInto$3(this, child, openStart);
+       }
+       // Only called when building a line view in ContentBuilder
+       addLineDeco(deco) {
+           let attrs = deco.spec.attributes, cls = deco.spec.class;
+           if (attrs)
+               this.attrs = combineAttrs$3(attrs, this.attrs || {});
+           if (cls)
+               this.attrs = combineAttrs$3({ class: cls }, this.attrs || {});
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos$3(this.dom, this.children, pos);
+       }
+       reuseDOM(node) {
+           if (node.nodeName == "DIV") {
+               this.setDOM(node);
+               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
+           }
+       }
+       sync(track) {
+           var _a;
+           if (!this.dom) {
+               this.setDOM(document.createElement("div"));
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           else if (this.dirty & 4 /* Attrs */) {
+               clearAttributes$3(this.dom);
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           if (this.prevAttrs !== undefined) {
+               updateAttrs$3(this.dom, this.prevAttrs, this.attrs);
+               this.dom.classList.add("cm-line");
+               this.prevAttrs = undefined;
+           }
+           super.sync(track);
+           let last = this.dom.lastChild;
+           while (last && ContentView$3.get(last) instanceof MarkView$3)
+               last = last.lastChild;
+           if (!last || !this.length ||
+               last.nodeName != "BR" && ((_a = ContentView$3.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
+                   (!browser$3.ios || !this.children.some(ch => ch instanceof TextView$3))) {
+               let hack = document.createElement("BR");
+               hack.cmIgnore = true;
+               this.dom.appendChild(hack);
+           }
+       }
+       measureTextSize() {
+           if (this.children.length == 0 || this.length > 20)
+               return null;
+           let totalWidth = 0;
+           for (let child of this.children) {
+               if (!(child instanceof TextView$3))
+                   return null;
+               let rects = clientRectsFor$3(child.dom);
+               if (rects.length != 1)
+                   return null;
+               totalWidth += rects[0].width;
+           }
+           return { lineHeight: this.dom.getBoundingClientRect().height,
+               charWidth: totalWidth / this.length };
+       }
+       coordsAt(pos, side) {
+           return coordsInChildren$3(this, pos, side);
+       }
+       become(_other) { return false; }
+       get type() { return BlockType$3.Text; }
+       static find(docView, pos) {
+           for (let i = 0, off = 0; i < docView.children.length; i++) {
+               let block = docView.children[i], end = off + block.length;
+               if (end >= pos) {
+                   if (block instanceof LineView)
+                       return block;
+                   if (end > pos)
+                       break;
+               }
+               off = end + block.breakAfter;
+           }
+           return null;
+       }
+   };
+   let BlockWidgetView$3 = class BlockWidgetView extends ContentView$3 {
+       constructor(widget, length, type) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.type = type;
+           this.breakAfter = 0;
+           this.prevWidget = null;
+       }
+       merge(from, to, source, _takeDeco, openStart, openEnd) {
+           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       domAtPos(pos) {
+           return pos == 0 ? DOMPos$3.before(this.dom) : DOMPos$3.after(this.dom, pos == this.length);
+       }
+       split(at) {
+           let len = this.length - at;
+           this.length = at;
+           let end = new BlockWidgetView(this.widget, len, this.type);
+           end.breakAfter = this.breakAfter;
+           return end;
+       }
+       get children() { return noChildren$3; }
+       sync() {
+           if (!this.dom || !this.widget.updateDOM(this.dom)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(this.editorView));
+               this.dom.contentEditable = "false";
+           }
+       }
+       get overrideDOMText() {
+           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$3.empty;
+       }
+       domBoundsAround() { return null; }
+       become(other) {
+           if (other instanceof BlockWidgetView && other.type == this.type &&
+               other.widget.constructor == this.widget.constructor) {
+               if (!other.widget.eq(this.widget))
+                   this.markDirty(true);
+               if (this.dom && !this.prevWidget)
+                   this.prevWidget = this.widget;
+               this.widget = other.widget;
+               this.length = other.length;
+               this.breakAfter = other.breakAfter;
+               return true;
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+   };
+
+   let ContentBuilder$3 = class ContentBuilder {
+       constructor(doc, pos, end, disallowBlockEffectsFor) {
+           this.doc = doc;
+           this.pos = pos;
+           this.end = end;
+           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
+           this.content = [];
+           this.curLine = null;
+           this.breakAtStart = 0;
+           this.pendingBuffer = 0 /* No */;
+           // Set to false directly after a widget that covers the position after it
+           this.atCursorPos = true;
+           this.openStart = -1;
+           this.openEnd = -1;
+           this.text = "";
+           this.textOff = 0;
+           this.cursor = doc.iter();
+           this.skip = pos;
+       }
+       posCovered() {
+           if (this.content.length == 0)
+               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
+           let last = this.content[this.content.length - 1];
+           return !last.breakAfter && !(last instanceof BlockWidgetView$3 && last.type == BlockType$3.WidgetBefore);
+       }
+       getLine() {
+           if (!this.curLine) {
+               this.content.push(this.curLine = new LineView$3);
+               this.atCursorPos = true;
+           }
+           return this.curLine;
+       }
+       flushBuffer(active) {
+           if (this.pendingBuffer) {
+               this.curLine.append(wrapMarks$3(new WidgetBufferView$3(-1), active), active.length);
+               this.pendingBuffer = 0 /* No */;
+           }
+       }
+       addBlockWidget(view) {
+           this.flushBuffer([]);
+           this.curLine = null;
+           this.content.push(view);
+       }
+       finish(openEnd) {
+           if (!openEnd)
+               this.flushBuffer([]);
+           else
+               this.pendingBuffer = 0 /* No */;
+           if (!this.posCovered())
+               this.getLine();
+       }
+       buildText(length, active, openStart) {
+           while (length > 0) {
+               if (this.textOff == this.text.length) {
+                   let { value, lineBreak, done } = this.cursor.next(this.skip);
+                   this.skip = 0;
+                   if (done)
+                       throw new Error("Ran out of text content when drawing inline views");
+                   if (lineBreak) {
+                       if (!this.posCovered())
+                           this.getLine();
+                       if (this.content.length)
+                           this.content[this.content.length - 1].breakAfter = 1;
+                       else
+                           this.breakAtStart = 1;
+                       this.flushBuffer([]);
+                       this.curLine = null;
+                       length--;
+                       continue;
+                   }
+                   else {
+                       this.text = value;
+                       this.textOff = 0;
+                   }
+               }
+               let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
+               this.flushBuffer(active.slice(0, openStart));
+               this.getLine().append(wrapMarks$3(new TextView$3(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
+               this.atCursorPos = true;
+               this.textOff += take;
+               length -= take;
+               openStart = 0;
+           }
+       }
+       span(from, to, active, openStart) {
+           this.buildText(to - from, active, openStart);
+           this.pos = to;
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       point(from, to, deco, active, openStart, index) {
+           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration$3) {
+               if (deco.block)
+                   throw new RangeError("Block decorations may not be specified via plugins");
+               if (to > this.doc.lineAt(this.pos).to)
+                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
+           }
+           let len = to - from;
+           if (deco instanceof PointDecoration$3) {
+               if (deco.block) {
+                   let { type } = deco;
+                   if (type == BlockType$3.WidgetAfter && !this.posCovered())
+                       this.getLine();
+                   this.addBlockWidget(new BlockWidgetView$3(deco.widget || new NullWidget$3("div"), len, type));
+               }
+               else {
+                   let view = WidgetView$3.create(deco.widget || new NullWidget$3("span"), len, deco.startSide);
+                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
+                   let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
+                   let line = this.getLine();
+                   if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
+                       this.pendingBuffer = 0 /* No */;
+                   this.flushBuffer(active);
+                   if (cursorBefore) {
+                       line.append(wrapMarks$3(new WidgetBufferView$3(1), active), openStart);
+                       openStart = active.length + Math.max(0, openStart - active.length);
+                   }
+                   line.append(wrapMarks$3(view, active), openStart);
+                   this.atCursorPos = cursorAfter;
+                   this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
+               }
+           }
+           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
+               this.getLine().addLineDeco(deco);
+           }
+           if (len) {
+               // Advance the iterator past the replaced content
+               if (this.textOff + len <= this.text.length) {
+                   this.textOff += len;
+               }
+               else {
+                   this.skip += len - (this.text.length - this.textOff);
+                   this.text = "";
+                   this.textOff = 0;
+               }
+               this.pos = to;
+           }
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       static build(text, from, to, decorations, dynamicDecorationMap) {
+           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
+           builder.openEnd = RangeSet$3.spans(decorations, from, to, builder);
+           if (builder.openStart < 0)
+               builder.openStart = builder.openEnd;
+           builder.finish(builder.openEnd);
+           return builder;
+       }
+   };
+   function wrapMarks$3(view, active) {
+       for (let mark of active)
+           view = new MarkView$3(mark, [view], view.length);
+       return view;
+   }
+   let NullWidget$3 = class NullWidget extends WidgetType$3 {
+       constructor(tag) {
+           super();
+           this.tag = tag;
+       }
+       eq(other) { return other.tag == this.tag; }
+       toDOM() { return document.createElement(this.tag); }
+       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
+   };
+
+   const clickAddsSelectionRange$3 = /*@__PURE__*/Facet$3.define();
+   const dragMovesSelection$1$3 = /*@__PURE__*/Facet$3.define();
+   const mouseSelectionStyle$3 = /*@__PURE__*/Facet$3.define();
+   const exceptionSink$3 = /*@__PURE__*/Facet$3.define();
+   const updateListener$3 = /*@__PURE__*/Facet$3.define();
+   const inputHandler$4 = /*@__PURE__*/Facet$3.define();
+   const perLineTextDirection$3 = /*@__PURE__*/Facet$3.define({
+       combine: values => values.some(x => x)
+   });
+   let ScrollTarget$3 = class ScrollTarget {
+       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5) {
+           this.range = range;
+           this.y = y;
+           this.x = x;
+           this.yMargin = yMargin;
+           this.xMargin = xMargin;
+       }
+       map(changes) {
+           return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);
+       }
+   };
+   const scrollIntoView$5 = /*@__PURE__*/StateEffect$3.define({ map: (t, ch) => t.map(ch) });
+   /**
+   Log or report an unhandled exception in client code. Should
+   probably only be used by extension code that allows client code to
+   provide functions, and calls those functions in a context where an
+   exception can't be propagated to calling code in a reasonable way
+   (for example when in an event handler).
+
+   Either calls a handler registered with
+   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
+   `window.onerror`, if defined, or `console.error` (in which case
+   it'll pass `context`, when given, as first argument).
+   */
+   function logException$3(state, exception, context) {
+       let handler = state.facet(exceptionSink$3);
+       if (handler.length)
+           handler[0](exception);
+       else if (window.onerror)
+           window.onerror(String(exception), context, undefined, undefined, exception);
+       else if (context)
+           console.error(context + ":", exception);
+       else
+           console.error(exception);
+   }
+   const editable$3 = /*@__PURE__*/Facet$3.define({ combine: values => values.length ? values[0] : true });
+   let nextPluginID$3 = 0;
+   const viewPlugin$3 = /*@__PURE__*/Facet$3.define();
+   /**
+   View plugins associate stateful values with a view. They can
+   influence the way the content is drawn, and are notified of things
+   that happen in the view.
+   */
+   let ViewPlugin$3 = class ViewPlugin {
+       constructor(
+       /**
+       @internal
+       */
+       id, 
+       /**
+       @internal
+       */
+       create, 
+       /**
+       @internal
+       */
+       domEventHandlers, buildExtensions) {
+           this.id = id;
+           this.create = create;
+           this.domEventHandlers = domEventHandlers;
+           this.extension = buildExtensions(this);
+       }
+       /**
+       Define a plugin from a constructor function that creates the
+       plugin's value, given an editor view.
+       */
+       static define(create, spec) {
+           const { eventHandlers, provide, decorations: deco } = spec || {};
+           return new ViewPlugin(nextPluginID$3++, create, eventHandlers, plugin => {
+               let ext = [viewPlugin$3.of(plugin)];
+               if (deco)
+                   ext.push(decorations$3.of(view => {
+                       let pluginInst = view.plugin(plugin);
+                       return pluginInst ? deco(pluginInst) : Decoration$3.none;
+                   }));
+               if (provide)
+                   ext.push(provide(plugin));
+               return ext;
+           });
+       }
+       /**
+       Create a plugin for a class whose constructor takes a single
+       editor view as argument.
+       */
+       static fromClass(cls, spec) {
+           return ViewPlugin.define(view => new cls(view), spec);
+       }
+   };
+   let PluginInstance$3 = class PluginInstance {
+       constructor(spec) {
+           this.spec = spec;
+           // When starting an update, all plugins have this field set to the
+           // update object, indicating they need to be updated. When finished
+           // updating, it is set to `false`. Retrieving a plugin that needs to
+           // be updated with `view.plugin` forces an eager update.
+           this.mustUpdate = null;
+           // This is null when the plugin is initially created, but
+           // initialized on the first update.
+           this.value = null;
+       }
+       update(view) {
+           if (!this.value) {
+               if (this.spec) {
+                   try {
+                       this.value = this.spec.create(view);
+                   }
+                   catch (e) {
+                       logException$3(view.state, e, "CodeMirror plugin crashed");
+                       this.deactivate();
+                   }
+               }
+           }
+           else if (this.mustUpdate) {
+               let update = this.mustUpdate;
+               this.mustUpdate = null;
+               if (this.value.update) {
+                   try {
+                       this.value.update(update);
+                   }
+                   catch (e) {
+                       logException$3(update.state, e, "CodeMirror plugin crashed");
+                       if (this.value.destroy)
+                           try {
+                               this.value.destroy();
+                           }
+                           catch (_) { }
+                       this.deactivate();
+                   }
+               }
+           }
+           return this;
+       }
+       destroy(view) {
+           var _a;
+           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
+               try {
+                   this.value.destroy();
+               }
+               catch (e) {
+                   logException$3(view.state, e, "CodeMirror plugin crashed");
+               }
+           }
+       }
+       deactivate() {
+           this.spec = this.value = null;
+       }
+   };
+   const editorAttributes$3 = /*@__PURE__*/Facet$3.define();
+   const contentAttributes$3 = /*@__PURE__*/Facet$3.define();
+   // Provide decorations
+   const decorations$3 = /*@__PURE__*/Facet$3.define();
+   const atomicRanges$3 = /*@__PURE__*/Facet$3.define();
+   const scrollMargins$3 = /*@__PURE__*/Facet$3.define();
+   const styleModule$3 = /*@__PURE__*/Facet$3.define();
+   let ChangedRange$3 = class ChangedRange {
+       constructor(fromA, toA, fromB, toB) {
+           this.fromA = fromA;
+           this.toA = toA;
+           this.fromB = fromB;
+           this.toB = toB;
+       }
+       join(other) {
+           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
+       }
+       addToSet(set) {
+           let i = set.length, me = this;
+           for (; i > 0; i--) {
+               let range = set[i - 1];
+               if (range.fromA > me.toA)
+                   continue;
+               if (range.toA < me.fromA)
+                   break;
+               me = me.join(range);
+               set.splice(i - 1, 1);
+           }
+           set.splice(i, 0, me);
+           return set;
+       }
+       static extendWithRanges(diff, ranges) {
+           if (ranges.length == 0)
+               return diff;
+           let result = [];
+           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
+               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
+               let end = next ? next.fromB : 1e9;
+               while (rI < ranges.length && ranges[rI] < end) {
+                   let from = ranges[rI], to = ranges[rI + 1];
+                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
+                   if (fromB <= toB)
+                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
+                   if (to > end)
+                       break;
+                   else
+                       rI += 2;
+               }
+               if (!next)
+                   return result;
+               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
+               posA = next.toA;
+               posB = next.toB;
+           }
+       }
+   };
+   /**
+   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
+   class, which describe what happened, whenever the view is updated.
+   */
+   let ViewUpdate$3 = class ViewUpdate {
+       constructor(
+       /**
+       The editor view that the update is associated with.
+       */
+       view, 
+       /**
+       The new editor state.
+       */
+       state, 
+       /**
+       The transactions involved in the update. May be empty.
+       */
+       transactions) {
+           this.view = view;
+           this.state = state;
+           this.transactions = transactions;
+           /**
+           @internal
+           */
+           this.flags = 0;
+           this.startState = view.state;
+           this.changes = ChangeSet$3.empty(this.startState.doc.length);
+           for (let tr of transactions)
+               this.changes = this.changes.compose(tr.changes);
+           let changedRanges = [];
+           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange$3(fromA, toA, fromB, toB)));
+           this.changedRanges = changedRanges;
+           let focus = view.hasFocus;
+           if (focus != view.inputState.notifiedFocused) {
+               view.inputState.notifiedFocused = focus;
+               this.flags |= 1 /* Focus */;
+           }
+       }
+       /**
+       @internal
+       */
+       static create(view, state, transactions) {
+           return new ViewUpdate(view, state, transactions);
+       }
+       /**
+       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
+       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
+       update.
+       */
+       get viewportChanged() {
+           return (this.flags & 4 /* Viewport */) > 0;
+       }
+       /**
+       Indicates whether the height of a block element in the editor
+       changed in this update.
+       */
+       get heightChanged() {
+           return (this.flags & 2 /* Height */) > 0;
+       }
+       /**
+       Returns true when the document was modified or the size of the
+       editor, or elements within the editor, changed.
+       */
+       get geometryChanged() {
+           return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
+       }
+       /**
+       True when this update indicates a focus change.
+       */
+       get focusChanged() {
+           return (this.flags & 1 /* Focus */) > 0;
+       }
+       /**
+       Whether the document changed in this update.
+       */
+       get docChanged() {
+           return !this.changes.empty;
+       }
+       /**
+       Whether the selection was explicitly set in this update.
+       */
+       get selectionSet() {
+           return this.transactions.some(tr => tr.selection);
+       }
+       /**
+       @internal
+       */
+       get empty() { return this.flags == 0 && this.transactions.length == 0; }
+   };
+
+   /**
+   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+   */
+   var Direction$3 = /*@__PURE__*/(function (Direction) {
+       // (These are chosen to match the base levels, in bidi algorithm
+       // terms, of spans in that direction.)
+       /**
+       Left-to-right.
+       */
+       Direction[Direction["LTR"] = 0] = "LTR";
+       /**
+       Right-to-left.
+       */
+       Direction[Direction["RTL"] = 1] = "RTL";
+   return Direction})(Direction$3 || (Direction$3 = {}));
+   const LTR$3 = Direction$3.LTR, RTL$3 = Direction$3.RTL;
+   // Decode a string with each type encoded as log2(type)
+   function dec$3(str) {
+       let result = [];
+       for (let i = 0; i < str.length; i++)
+           result.push(1 << +str[i]);
+       return result;
+   }
+   // Character types for codepoints 0 to 0xf8
+   const LowTypes$3 = /*@__PURE__*/dec$3("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
+   // Character types for codepoints 0x600 to 0x6f9
+   const ArabicTypes$3 = /*@__PURE__*/dec$3("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
+   const Brackets$3 = /*@__PURE__*/Object.create(null), BracketStack$3 = [];
+   // There's a lot more in
+   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
+   // which are left out to keep code size down.
+   for (let p of ["()", "[]", "{}"]) {
+       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
+       Brackets$3[l] = r;
+       Brackets$3[r] = -l;
+   }
+   function charType$3(ch) {
+       return ch <= 0xf7 ? LowTypes$3[ch] :
+           0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
+               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes$3[ch - 0x600] :
+                   0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
+                       0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
+                           ch == 0x200c ? 256 /* NI */ : 1 /* L */;
+   }
+   const BidiRE$3 = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
+   /**
+   Represents a contiguous range of text that has a single direction
+   (as in left-to-right or right-to-left).
+   */
+   let BidiSpan$3 = class BidiSpan {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the span (relative to the start of the line).
+       */
+       from, 
+       /**
+       The end of the span.
+       */
+       to, 
+       /**
+       The ["bidi
+       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
+       of the span (in this context, 0 means
+       left-to-right, 1 means right-to-left, 2 means left-to-right
+       number inside right-to-left text).
+       */
+       level) {
+           this.from = from;
+           this.to = to;
+           this.level = level;
+       }
+       /**
+       The direction of this span.
+       */
+       get dir() { return this.level % 2 ? RTL$3 : LTR$3; }
+       /**
+       @internal
+       */
+       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
+       /**
+       @internal
+       */
+       static find(order, index, level, assoc) {
+           let maybe = -1;
+           for (let i = 0; i < order.length; i++) {
+               let span = order[i];
+               if (span.from <= index && span.to >= index) {
+                   if (span.level == level)
+                       return i;
+                   // When multiple spans match, if assoc != 0, take the one that
+                   // covers that side, otherwise take the one with the minimum
+                   // level.
+                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
+                       maybe = i;
+               }
+           }
+           if (maybe < 0)
+               throw new RangeError("Index out of range");
+           return maybe;
+       }
+   };
+   // Reused array of character types
+   const types$3 = [];
+   function computeOrder$3(line, direction) {
+       let len = line.length, outerType = direction == LTR$3 ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR$3 ? 2 /* R */ : 1 /* L */;
+       if (!line || outerType == 1 /* L */ && !BidiRE$3.test(line))
+           return trivialOrder$3(len);
+       // W1. Examine each non-spacing mark (NSM) in the level run, and
+       // change the type of the NSM to the type of the previous
+       // character. If the NSM is at the start of the level run, it will
+       // get the type of sor.
+       // W2. Search backwards from each instance of a European number
+       // until the first strong type (R, L, AL, or sor) is found. If an
+       // AL is found, change the type of the European number to Arabic
+       // number.
+       // W3. Change all ALs to R.
+       // (Left after this: L, R, EN, AN, ET, CS, NI)
+       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
+           let type = charType$3(line.charCodeAt(i));
+           if (type == 512 /* NSM */)
+               type = prev;
+           else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
+               type = 16 /* AN */;
+           types$3[i] = type == 4 /* AL */ ? 2 /* R */ : type;
+           if (type & 7 /* Strong */)
+               prevStrong = type;
+           prev = type;
+       }
+       // W5. A sequence of European terminators adjacent to European
+       // numbers changes to all European numbers.
+       // W6. Otherwise, separators and terminators change to Other
+       // Neutral.
+       // W7. Search backwards from each instance of a European number
+       // until the first strong type (R, L, or sor) is found. If an L is
+       // found, then change the type of the European number to L.
+       // (Left after this: L, R, EN+AN, NI)
+       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
+           let type = types$3[i];
+           if (type == 128 /* CS */) {
+               if (i < len - 1 && prev == types$3[i + 1] && (prev & 24 /* Num */))
+                   type = types$3[i] = prev;
+               else
+                   types$3[i] = 256 /* NI */;
+           }
+           else if (type == 64 /* ET */) {
+               let end = i + 1;
+               while (end < len && types$3[end] == 64 /* ET */)
+                   end++;
+               let replace = (i && prev == 8 /* EN */) || (end < len && types$3[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
+               for (let j = i; j < end; j++)
+                   types$3[j] = replace;
+               i = end - 1;
+           }
+           else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
+               types$3[i] = 1 /* L */;
+           }
+           prev = type;
+           if (type & 7 /* Strong */)
+               prevStrong = type;
+       }
+       // N0. Process bracket pairs in an isolating run sequence
+       // sequentially in the logical order of the text positions of the
+       // opening paired brackets using the logic given below. Within this
+       // scope, bidirectional types EN and AN are treated as R.
+       for (let i = 0, sI = 0, context = 0, ch, br, type; i < len; i++) {
+           // Keeps [startIndex, type, strongSeen] triples for each open
+           // bracket on BracketStack.
+           if (br = Brackets$3[ch = line.charCodeAt(i)]) {
+               if (br < 0) { // Closing bracket
+                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                       if (BracketStack$3[sJ + 1] == -br) {
+                           let flags = BracketStack$3[sJ + 2];
+                           let type = (flags & 2 /* EmbedInside */) ? outerType :
+                               !(flags & 4 /* OppositeInside */) ? 0 :
+                                   (flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
+                           if (type)
+                               types$3[i] = types$3[BracketStack$3[sJ]] = type;
+                           sI = sJ;
+                           break;
+                       }
+                   }
+               }
+               else if (BracketStack$3.length == 189 /* MaxDepth */) {
+                   break;
+               }
+               else {
+                   BracketStack$3[sI++] = i;
+                   BracketStack$3[sI++] = ch;
+                   BracketStack$3[sI++] = context;
+               }
+           }
+           else if ((type = types$3[i]) == 2 /* R */ || type == 1 /* L */) {
+               let embed = type == outerType;
+               context = embed ? 0 : 1 /* OppositeBefore */;
+               for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                   let cur = BracketStack$3[sJ + 2];
+                   if (cur & 2 /* EmbedInside */)
+                       break;
+                   if (embed) {
+                       BracketStack$3[sJ + 2] |= 2 /* EmbedInside */;
+                   }
+                   else {
+                       if (cur & 4 /* OppositeInside */)
+                           break;
+                       BracketStack$3[sJ + 2] |= 4 /* OppositeInside */;
+                   }
+               }
+           }
+       }
+       // N1. A sequence of neutrals takes the direction of the
+       // surrounding strong text if the text on both sides has the same
+       // direction. European and Arabic numbers act as if they were R in
+       // terms of their influence on neutrals. Start-of-level-run (sor)
+       // and end-of-level-run (eor) are used at level run boundaries.
+       // N2. Any remaining neutrals take the embedding direction.
+       // (Left after this: L, R, EN+AN)
+       for (let i = 0; i < len; i++) {
+           if (types$3[i] == 256 /* NI */) {
+               let end = i + 1;
+               while (end < len && types$3[end] == 256 /* NI */)
+                   end++;
+               let beforeL = (i ? types$3[i - 1] : outerType) == 1 /* L */;
+               let afterL = (end < len ? types$3[end] : outerType) == 1 /* L */;
+               let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
+               for (let j = i; j < end; j++)
+                   types$3[j] = replace;
+               i = end - 1;
+           }
+       }
+       // Here we depart from the documented algorithm, in order to avoid
+       // building up an actual levels array. Since there are only three
+       // levels (0, 1, 2) in an implementation that doesn't take
+       // explicit embedding into account, we can build up the order on
+       // the fly, without following the level-based algorithm.
+       let order = [];
+       if (outerType == 1 /* L */) {
+           for (let i = 0; i < len;) {
+               let start = i, rtl = types$3[i++] != 1 /* L */;
+               while (i < len && rtl == (types$3[i] != 1 /* L */))
+                   i++;
+               if (rtl) {
+                   for (let j = i; j > start;) {
+                       let end = j, l = types$3[--j] != 2 /* R */;
+                       while (j > start && l == (types$3[j - 1] != 2 /* R */))
+                           j--;
+                       order.push(new BidiSpan$3(j, end, l ? 2 : 1));
+                   }
+               }
+               else {
+                   order.push(new BidiSpan$3(start, i, 0));
+               }
+           }
+       }
+       else {
+           for (let i = 0; i < len;) {
+               let start = i, rtl = types$3[i++] == 2 /* R */;
+               while (i < len && rtl == (types$3[i] == 2 /* R */))
+                   i++;
+               order.push(new BidiSpan$3(start, i, rtl ? 1 : 2));
+           }
+       }
+       return order;
+   }
+   function trivialOrder$3(length) {
+       return [new BidiSpan$3(0, length, 0)];
+   }
+   let movedOver$3 = "";
+   function moveVisually$3(line, order, dir, start, forward) {
+       var _a;
+       let startIndex = start.head - line.from, spanI = -1;
+       if (startIndex == 0) {
+           if (!forward || !line.length)
+               return null;
+           if (order[0].level != dir) {
+               startIndex = order[0].side(false, dir);
+               spanI = 0;
+           }
+       }
+       else if (startIndex == line.length) {
+           if (forward)
+               return null;
+           let last = order[order.length - 1];
+           if (last.level != dir) {
+               startIndex = last.side(true, dir);
+               spanI = order.length - 1;
+           }
+       }
+       if (spanI < 0)
+           spanI = BidiSpan$3.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
+       let span = order[spanI];
+       // End of span. (But not end of line--that was checked for above.)
+       if (startIndex == span.side(forward, dir)) {
+           span = order[spanI += forward ? 1 : -1];
+           startIndex = span.side(!forward, dir);
+       }
+       let indexForward = forward == (span.dir == dir);
+       let nextIndex = findClusterBreak$4(line.text, startIndex, indexForward);
+       movedOver$3 = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
+       if (nextIndex != span.side(forward, dir))
+           return EditorSelection$3.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);
+       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
+       if (!nextSpan && span.level != dir)
+           return EditorSelection$3.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);
+       if (nextSpan && nextSpan.level < span.level)
+           return EditorSelection$3.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
+       return EditorSelection$3.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
+   }
+
+   const LineBreakPlaceholder$3 = "\uffff";
+   let DOMReader$3 = class DOMReader {
+       constructor(points, state) {
+           this.points = points;
+           this.text = "";
+           this.lineSeparator = state.facet(EditorState$3.lineSeparator);
+       }
+       append(text) {
+           this.text += text;
+       }
+       lineBreak() {
+           this.text += LineBreakPlaceholder$3;
+       }
+       readRange(start, end) {
+           if (!start)
+               return this;
+           let parent = start.parentNode;
+           for (let cur = start;;) {
+               this.findPointBefore(parent, cur);
+               this.readNode(cur);
+               let next = cur.nextSibling;
+               if (next == end)
+                   break;
+               let view = ContentView$3.get(cur), nextView = ContentView$3.get(next);
+               if (view && nextView ? view.breakAfter :
+                   (view ? view.breakAfter : isBlockElement$3(cur)) ||
+                       (isBlockElement$3(next) && (cur.nodeName != "BR" || cur.cmIgnore)))
+                   this.lineBreak();
+               cur = next;
+           }
+           this.findPointBefore(parent, end);
+           return this;
+       }
+       readTextNode(node) {
+           let text = node.nodeValue;
+           for (let point of this.points)
+               if (point.node == node)
+                   point.pos = this.text.length + Math.min(point.offset, text.length);
+           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
+               let nextBreak = -1, breakSize = 1, m;
+               if (this.lineSeparator) {
+                   nextBreak = text.indexOf(this.lineSeparator, off);
+                   breakSize = this.lineSeparator.length;
+               }
+               else if (m = re.exec(text)) {
+                   nextBreak = m.index;
+                   breakSize = m[0].length;
+               }
+               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
+               if (nextBreak < 0)
+                   break;
+               this.lineBreak();
+               if (breakSize > 1)
+                   for (let point of this.points)
+                       if (point.node == node && point.pos > this.text.length)
+                           point.pos -= breakSize - 1;
+               off = nextBreak + breakSize;
+           }
+       }
+       readNode(node) {
+           if (node.cmIgnore)
+               return;
+           let view = ContentView$3.get(node);
+           let fromView = view && view.overrideDOMText;
+           if (fromView != null) {
+               this.findPointInside(node, fromView.length);
+               for (let i = fromView.iter(); !i.next().done;) {
+                   if (i.lineBreak)
+                       this.lineBreak();
+                   else
+                       this.append(i.value);
+               }
+           }
+           else if (node.nodeType == 3) {
+               this.readTextNode(node);
+           }
+           else if (node.nodeName == "BR") {
+               if (node.nextSibling)
+                   this.lineBreak();
+           }
+           else if (node.nodeType == 1) {
+               this.readRange(node.firstChild, null);
+           }
+       }
+       findPointBefore(node, next) {
+           for (let point of this.points)
+               if (point.node == node && node.childNodes[point.offset] == next)
+                   point.pos = this.text.length;
+       }
+       findPointInside(node, maxLen) {
+           for (let point of this.points)
+               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
+                   point.pos = this.text.length + Math.min(maxLen, point.offset);
+       }
+   };
+   function isBlockElement$3(node) {
+       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
+   }
+   let DOMPoint$3 = class DOMPoint {
+       constructor(node, offset) {
+           this.node = node;
+           this.offset = offset;
+           this.pos = -1;
+       }
+   };
+
+   let DocView$3 = class DocView extends ContentView$3 {
+       constructor(view) {
+           super();
+           this.view = view;
+           this.compositionDeco = Decoration$3.none;
+           this.decorations = [];
+           this.dynamicDecorationMap = [];
+           // Track a minimum width for the editor. When measuring sizes in
+           // measureVisibleLineHeights, this is updated to point at the width
+           // of a given element and its extent in the document. When a change
+           // happens in that range, these are reset. That way, once we've seen
+           // a line/element of a given length, we keep the editor wide enough
+           // to fit at least that element, until it is changed, at which point
+           // we forget it again.
+           this.minWidth = 0;
+           this.minWidthFrom = 0;
+           this.minWidthTo = 0;
+           // Track whether the DOM selection was set in a lossy way, so that
+           // we don't mess it up when reading it back it
+           this.impreciseAnchor = null;
+           this.impreciseHead = null;
+           this.forceSelection = false;
+           // Used by the resize observer to ignore resizes that we caused
+           // ourselves
+           this.lastUpdate = Date.now();
+           this.setDOM(view.contentDOM);
+           this.children = [new LineView$3];
+           this.children[0].setParent(this);
+           this.updateDeco();
+           this.updateInner([new ChangedRange$3(0, 0, 0, view.state.doc.length)], 0);
+       }
+       get root() { return this.view.root; }
+       get editorView() { return this.view; }
+       get length() { return this.view.state.doc.length; }
+       // Update the document view to a given state. scrollIntoView can be
+       // used as a hint to compute a new viewport that includes that
+       // position, if we know the editor is going to scroll that position
+       // into view.
+       update(update) {
+           let changedRanges = update.changedRanges;
+           if (this.minWidth > 0 && changedRanges.length) {
+               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
+                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
+               }
+               else {
+                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
+                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
+               }
+           }
+           if (this.view.inputState.composing < 0)
+               this.compositionDeco = Decoration$3.none;
+           else if (update.transactions.length || this.dirty)
+               this.compositionDeco = computeCompositionDeco$2(this.view, update.changes);
+           // When the DOM nodes around the selection are moved to another
+           // parent, Chrome sometimes reports a different selection through
+           // getSelection than the one that it actually shows to the user.
+           // This forces a selection update when lines are joined to work
+           // around that. Issue #54
+           if ((browser$3.ie || browser$3.chrome) && !this.compositionDeco.size && update &&
+               update.state.doc.lines != update.startState.doc.lines)
+               this.forceSelection = true;
+           let prevDeco = this.decorations, deco = this.updateDeco();
+           let decoDiff = findChangedDeco$3(prevDeco, deco, update.changes);
+           changedRanges = ChangedRange$3.extendWithRanges(changedRanges, decoDiff);
+           if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
+               return false;
+           }
+           else {
+               this.updateInner(changedRanges, update.startState.doc.length);
+               if (update.transactions.length)
+                   this.lastUpdate = Date.now();
+               return true;
+           }
+       }
+       // Used by update and the constructor do perform the actual DOM
+       // update
+       updateInner(changes, oldLength) {
+           this.view.viewState.mustMeasureContent = true;
+           this.updateChildren(changes, oldLength);
+           let { observer } = this.view;
+           observer.ignore(() => {
+               // Lock the height during redrawing, since Chrome sometimes
+               // messes with the scroll position during DOM mutation (though
+               // no relayout is triggered and I cannot imagine how it can
+               // recompute the scroll position without a layout)
+               this.dom.style.height = this.view.viewState.contentHeight + "px";
+               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
+               // Chrome will sometimes, when DOM mutations occur directly
+               // around the selection, get confused and report a different
+               // selection from the one it displays (issue #218). This tries
+               // to detect that situation.
+               let track = browser$3.chrome || browser$3.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
+               this.sync(track);
+               this.dirty = 0 /* Not */;
+               if (track && (track.written || observer.selectionRange.focusNode != track.node))
+                   this.forceSelection = true;
+               this.dom.style.height = "";
+           });
+           let gaps = [];
+           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
+               for (let child of this.children)
+                   if (child instanceof BlockWidgetView$3 && child.widget instanceof BlockGapWidget$3)
+                       gaps.push(child.dom);
+           observer.updateGaps(gaps);
+       }
+       updateChildren(changes, oldLength) {
+           let cursor = this.childCursor(oldLength);
+           for (let i = changes.length - 1;; i--) {
+               let next = i >= 0 ? changes[i] : null;
+               if (!next)
+                   break;
+               let { fromA, toA, fromB, toB } = next;
+               let { content, breakAtStart, openStart, openEnd } = ContentBuilder$3.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap);
+               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
+               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
+               replaceRange$3(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
+           }
+       }
+       // Sync the DOM selection to this.state.selection
+       updateSelection(mustRead = false, fromPointer = false) {
+           if (mustRead)
+               this.view.observer.readSelectionRange();
+           if (!(fromPointer || this.mayControlSelection()) ||
+               browser$3.ios && this.view.inputState.rapidCompositionStart)
+               return;
+           let force = this.forceSelection;
+           this.forceSelection = false;
+           let main = this.view.state.selection.main;
+           // FIXME need to handle the case where the selection falls inside a block range
+           let anchor = this.domAtPos(main.anchor);
+           let head = main.empty ? anchor : this.domAtPos(main.head);
+           // Always reset on Firefox when next to an uneditable node to
+           // avoid invisible cursor bugs (#111)
+           if (browser$3.gecko && main.empty && betweenUneditable$3(anchor)) {
+               let dummy = document.createTextNode("");
+               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
+               anchor = head = new DOMPos$3(dummy, 0);
+               force = true;
+           }
+           let domSel = this.view.observer.selectionRange;
+           // If the selection is already here, or in an equivalent position, don't touch it
+           if (force || !domSel.focusNode ||
+               !isEquivalentPosition$3(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
+               !isEquivalentPosition$3(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
+               this.view.observer.ignore(() => {
+                   // Chrome Android will hide the virtual keyboard when tapping
+                   // inside an uneditable node, and not bring it back when we
+                   // move the cursor to its proper position. This tries to
+                   // restore the keyboard by cycling focus.
+                   if (browser$3.android && browser$3.chrome && this.dom.contains(domSel.focusNode) &&
+                       inUneditable$3(domSel.focusNode, this.dom)) {
+                       this.dom.blur();
+                       this.dom.focus({ preventScroll: true });
+                   }
+                   let rawSel = getSelection$3(this.root);
+                   if (main.empty) {
+                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
+                       if (browser$3.gecko) {
+                           let nextTo = nextToUneditable$3(anchor.node, anchor.offset);
+                           if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
+                               let text = nearbyTextNode$2(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
+                               if (text)
+                                   anchor = new DOMPos$3(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
+                           }
+                       }
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       if (main.bidiLevel != null && domSel.cursorBidiLevel != null)
+                           domSel.cursorBidiLevel = main.bidiLevel;
+                   }
+                   else if (rawSel.extend) {
+                       // Selection.extend can be used to create an 'inverted' selection
+                       // (one where the focus is before the anchor), but not all
+                       // browsers support it yet.
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       rawSel.extend(head.node, head.offset);
+                   }
+                   else {
+                       // Primitive (IE) way
+                       let range = document.createRange();
+                       if (main.anchor > main.head)
+                           [anchor, head] = [head, anchor];
+                       range.setEnd(head.node, head.offset);
+                       range.setStart(anchor.node, anchor.offset);
+                       rawSel.removeAllRanges();
+                       rawSel.addRange(range);
+                   }
+               });
+               this.view.observer.setSelectionRange(anchor, head);
+           }
+           this.impreciseAnchor = anchor.precise ? null : new DOMPos$3(domSel.anchorNode, domSel.anchorOffset);
+           this.impreciseHead = head.precise ? null : new DOMPos$3(domSel.focusNode, domSel.focusOffset);
+       }
+       enforceCursorAssoc() {
+           if (this.compositionDeco.size)
+               return;
+           let cursor = this.view.state.selection.main;
+           let sel = getSelection$3(this.root);
+           if (!cursor.empty || !cursor.assoc || !sel.modify)
+               return;
+           let line = LineView$3.find(this, cursor.head);
+           if (!line)
+               return;
+           let lineStart = line.posAtStart;
+           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
+               return;
+           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
+           if (!before || !after || before.bottom > after.top)
+               return;
+           let dom = this.domAtPos(cursor.head + cursor.assoc);
+           sel.collapse(dom.node, dom.offset);
+           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
+       }
+       mayControlSelection() {
+           return this.view.state.facet(editable$3) ? this.root.activeElement == this.dom
+               : hasSelection$3(this.dom, this.view.observer.selectionRange);
+       }
+       nearest(dom) {
+           for (let cur = dom; cur;) {
+               let domView = ContentView$3.get(cur);
+               if (domView && domView.rootView == this)
+                   return domView;
+               cur = cur.parentNode;
+           }
+           return null;
+       }
+       posFromDOM(node, offset) {
+           let view = this.nearest(node);
+           if (!view)
+               throw new RangeError("Trying to find position for a DOM position outside of the document");
+           return view.localPosFromDOM(node, offset) + view.posAtStart;
+       }
+       domAtPos(pos) {
+           let { i, off } = this.childCursor().findPos(pos, -1);
+           for (; i < this.children.length - 1;) {
+               let child = this.children[i];
+               if (off < child.length || child instanceof LineView$3)
+                   break;
+               i++;
+               off = 0;
+           }
+           return this.children[i].domAtPos(off);
+       }
+       coordsAt(pos, side) {
+           for (let off = this.length, i = this.children.length - 1;; i--) {
+               let child = this.children[i], start = off - child.breakAfter - child.length;
+               if (pos > start ||
+                   (pos == start && child.type != BlockType$3.WidgetBefore && child.type != BlockType$3.WidgetAfter &&
+                       (!i || side == 2 || this.children[i - 1].breakAfter ||
+                           (this.children[i - 1].type == BlockType$3.WidgetBefore && side > -2))))
+                   return child.coordsAt(pos - start, side);
+               off = start;
+           }
+       }
+       measureVisibleLineHeights(viewport) {
+           let result = [], { from, to } = viewport;
+           let contentWidth = this.view.contentDOM.clientWidth;
+           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
+           let widest = -1, ltr = this.view.textDirection == Direction$3.LTR;
+           for (let pos = 0, i = 0; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (end > to)
+                   break;
+               if (pos >= from) {
+                   let childRect = child.dom.getBoundingClientRect();
+                   result.push(childRect.height);
+                   if (isWider) {
+                       let last = child.dom.lastChild;
+                       let rects = last ? clientRectsFor$3(last) : [];
+                       if (rects.length) {
+                           let rect = rects[rects.length - 1];
+                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
+                           if (width > widest) {
+                               widest = width;
+                               this.minWidth = contentWidth;
+                               this.minWidthFrom = pos;
+                               this.minWidthTo = end;
+                           }
+                       }
+                   }
+               }
+               pos = end + child.breakAfter;
+           }
+           return result;
+       }
+       textDirectionAt(pos) {
+           let { i } = this.childPos(pos, 1);
+           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction$3.RTL : Direction$3.LTR;
+       }
+       measureTextSize() {
+           for (let child of this.children) {
+               if (child instanceof LineView$3) {
+                   let measure = child.measureTextSize();
+                   if (measure)
+                       return measure;
+               }
+           }
+           // If no workable line exists, force a layout of a measurable element
+           let dummy = document.createElement("div"), lineHeight, charWidth;
+           dummy.className = "cm-line";
+           dummy.textContent = "abc def ghi jkl mno pqr stu";
+           this.view.observer.ignore(() => {
+               this.dom.appendChild(dummy);
+               let rect = clientRectsFor$3(dummy.firstChild)[0];
+               lineHeight = dummy.getBoundingClientRect().height;
+               charWidth = rect ? rect.width / 27 : 7;
+               dummy.remove();
+           });
+           return { lineHeight, charWidth };
+       }
+       childCursor(pos = this.length) {
+           // Move back to start of last element when possible, so that
+           // `ChildCursor.findPos` doesn't have to deal with the edge case
+           // of being after the last element.
+           let i = this.children.length;
+           if (i)
+               pos -= this.children[--i].length;
+           return new ChildCursor$3(this.children, pos, i);
+       }
+       computeBlockGapDeco() {
+           let deco = [], vs = this.view.viewState;
+           for (let pos = 0, i = 0;; i++) {
+               let next = i == vs.viewports.length ? null : vs.viewports[i];
+               let end = next ? next.from - 1 : this.length;
+               if (end > pos) {
+                   let height = vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top;
+                   deco.push(Decoration$3.replace({
+                       widget: new BlockGapWidget$3(height),
+                       block: true,
+                       inclusive: true,
+                       isBlockGap: true,
+                   }).range(pos, end));
+               }
+               if (!next)
+                   break;
+               pos = next.to + 1;
+           }
+           return Decoration$3.set(deco);
+       }
+       updateDeco() {
+           let allDeco = this.view.state.facet(decorations$3).map((d, i) => {
+               let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
+               return dynamic ? d(this.view) : d;
+           });
+           for (let i = allDeco.length; i < allDeco.length + 3; i++)
+               this.dynamicDecorationMap[i] = false;
+           return this.decorations = [
+               ...allDeco,
+               this.compositionDeco,
+               this.computeBlockGapDeco(),
+               this.view.viewState.lineGapDeco
+           ];
+       }
+       scrollIntoView(target) {
+           let { range } = target;
+           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
+           if (!rect)
+               return;
+           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
+               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
+                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
+           let mLeft = 0, mRight = 0, mTop = 0, mBottom = 0;
+           for (let margins of this.view.state.facet(scrollMargins$3).map(f => f(this.view)))
+               if (margins) {
+                   let { left, right, top, bottom } = margins;
+                   if (left != null)
+                       mLeft = Math.max(mLeft, left);
+                   if (right != null)
+                       mRight = Math.max(mRight, right);
+                   if (top != null)
+                       mTop = Math.max(mTop, top);
+                   if (bottom != null)
+                       mBottom = Math.max(mBottom, bottom);
+               }
+           let targetRect = {
+               left: rect.left - mLeft, top: rect.top - mTop,
+               right: rect.right + mRight, bottom: rect.bottom + mBottom
+           };
+           scrollRectIntoView$3(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction$3.LTR);
+       }
+   };
+   function betweenUneditable$3(pos) {
+       return pos.node.nodeType == 1 && pos.node.firstChild &&
+           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
+           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
+   }
+   let BlockGapWidget$3 = class BlockGapWidget extends WidgetType$3 {
+       constructor(height) {
+           super();
+           this.height = height;
+       }
+       toDOM() {
+           let elt = document.createElement("div");
+           this.updateDOM(elt);
+           return elt;
+       }
+       eq(other) { return other.height == this.height; }
+       updateDOM(elt) {
+           elt.style.height = this.height + "px";
+           return true;
+       }
+       get estimatedHeight() { return this.height; }
+   };
+   function compositionSurroundingNode$2(view) {
+       let sel = view.observer.selectionRange;
+       let textNode = sel.focusNode && nearbyTextNode$2(sel.focusNode, sel.focusOffset, 0);
+       if (!textNode)
+           return null;
+       let cView = view.docView.nearest(textNode);
+       if (!cView)
+           return null;
+       if (cView instanceof LineView$3) {
+           let topNode = textNode;
+           while (topNode.parentNode != cView.dom)
+               topNode = topNode.parentNode;
+           let prev = topNode.previousSibling;
+           while (prev && !ContentView$3.get(prev))
+               prev = prev.previousSibling;
+           let pos = prev ? ContentView$3.get(prev).posAtEnd : cView.posAtStart;
+           return { from: pos, to: pos, node: topNode, text: textNode };
+       }
+       else {
+           for (;;) {
+               let { parent } = cView;
+               if (!parent)
+                   return null;
+               if (parent instanceof LineView$3)
+                   break;
+               cView = parent;
+           }
+           let from = cView.posAtStart;
+           return { from, to: from + cView.length, node: cView.dom, text: textNode };
+       }
+   }
+   function computeCompositionDeco$2(view, changes) {
+       let surrounding = compositionSurroundingNode$2(view);
+       if (!surrounding)
+           return Decoration$3.none;
+       let { from, to, node, text: textNode } = surrounding;
+       let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
+       let { state } = view, text = node.nodeType == 3 ? node.nodeValue :
+           new DOMReader$3([], state).readRange(node.firstChild, null).text;
+       if (newTo - newFrom < text.length) {
+           if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder$3) == text)
+               newTo = newFrom + text.length;
+           else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder$3) == text)
+               newFrom = newTo - text.length;
+           else
+               return Decoration$3.none;
+       }
+       else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder$3) != text) {
+           return Decoration$3.none;
+       }
+       let topView = ContentView$3.get(node);
+       if (topView instanceof CompositionView$2)
+           topView = topView.widget.topView;
+       else if (topView)
+           topView.parent = null;
+       return Decoration$3.set(Decoration$3.replace({ widget: new CompositionWidget$2(node, textNode, topView), inclusive: true })
+           .range(newFrom, newTo));
+   }
+   let CompositionWidget$2 = class CompositionWidget extends WidgetType$3 {
+       constructor(top, text, topView) {
+           super();
+           this.top = top;
+           this.text = text;
+           this.topView = topView;
+       }
+       eq(other) { return this.top == other.top && this.text == other.text; }
+       toDOM() { return this.top; }
+       ignoreEvent() { return false; }
+       get customView() { return CompositionView$2; }
+   };
+   function nearbyTextNode$2(node, offset, side) {
+       for (;;) {
+           if (node.nodeType == 3)
+               return node;
+           if (node.nodeType == 1 && offset > 0 && side <= 0) {
+               node = node.childNodes[offset - 1];
+               offset = maxOffset$3(node);
+           }
+           else if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {
+               node = node.childNodes[offset];
+               offset = 0;
+           }
+           else {
+               return null;
+           }
+       }
+   }
+   function nextToUneditable$3(node, offset) {
+       if (node.nodeType != 1)
+           return 0;
+       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
+           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
+   }
+   let DecorationComparator$1$3 = class DecorationComparator$1 {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange(from, to) { addRange$3(from, to, this.changes); }
+       comparePoint(from, to) { addRange$3(from, to, this.changes); }
+   };
+   function findChangedDeco$3(a, b, diff) {
+       let comp = new DecorationComparator$1$3;
+       RangeSet$3.compare(a, b, diff, comp);
+       return comp.changes;
+   }
+   function inUneditable$3(node, inside) {
+       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
+           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
+               return true;
+           }
+       }
+       return false;
+   }
+
+   function groupAt$3(state, pos, bias = 1) {
+       let categorize = state.charCategorizer(pos);
+       let line = state.doc.lineAt(pos), linePos = pos - line.from;
+       if (line.length == 0)
+           return EditorSelection$3.cursor(pos);
+       if (linePos == 0)
+           bias = 1;
+       else if (linePos == line.length)
+           bias = -1;
+       let from = linePos, to = linePos;
+       if (bias < 0)
+           from = findClusterBreak$4(line.text, linePos, false);
+       else
+           to = findClusterBreak$4(line.text, linePos);
+       let cat = categorize(line.text.slice(from, to));
+       while (from > 0) {
+           let prev = findClusterBreak$4(line.text, from, false);
+           if (categorize(line.text.slice(prev, from)) != cat)
+               break;
+           from = prev;
+       }
+       while (to < line.length) {
+           let next = findClusterBreak$4(line.text, to);
+           if (categorize(line.text.slice(to, next)) != cat)
+               break;
+           to = next;
+       }
+       return EditorSelection$3.range(from + line.from, to + line.from);
+   }
+   // Search the DOM for the {node, offset} position closest to the given
+   // coordinates. Very inefficient and crude, but can usually be avoided
+   // by calling caret(Position|Range)FromPoint instead.
+   function getdx$3(x, rect) {
+       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
+   }
+   function getdy$3(y, rect) {
+       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
+   }
+   function yOverlap$3(a, b) {
+       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
+   }
+   function upTop$3(rect, top) {
+       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
+   }
+   function upBot$3(rect, bottom) {
+       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
+   }
+   function domPosAtCoords$3(parent, x, y) {
+       let closest, closestRect, closestX, closestY;
+       let above, below, aboveRect, belowRect;
+       for (let child = parent.firstChild; child; child = child.nextSibling) {
+           let rects = clientRectsFor$3(child);
+           for (let i = 0; i < rects.length; i++) {
+               let rect = rects[i];
+               if (closestRect && yOverlap$3(closestRect, rect))
+                   rect = upTop$3(upBot$3(rect, closestRect.bottom), closestRect.top);
+               let dx = getdx$3(x, rect), dy = getdy$3(y, rect);
+               if (dx == 0 && dy == 0)
+                   return child.nodeType == 3 ? domPosInText$3(child, x, y) : domPosAtCoords$3(child, x, y);
+               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
+                   closest = child;
+                   closestRect = rect;
+                   closestX = dx;
+                   closestY = dy;
+               }
+               if (dx == 0) {
+                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
+                       above = child;
+                       aboveRect = rect;
+                   }
+                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
+                       below = child;
+                       belowRect = rect;
+                   }
+               }
+               else if (aboveRect && yOverlap$3(aboveRect, rect)) {
+                   aboveRect = upBot$3(aboveRect, rect.bottom);
+               }
+               else if (belowRect && yOverlap$3(belowRect, rect)) {
+                   belowRect = upTop$3(belowRect, rect.top);
+               }
+           }
+       }
+       if (aboveRect && aboveRect.bottom >= y) {
+           closest = above;
+           closestRect = aboveRect;
+       }
+       else if (belowRect && belowRect.top <= y) {
+           closest = below;
+           closestRect = belowRect;
+       }
+       if (!closest)
+           return { node: parent, offset: 0 };
+       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
+       if (closest.nodeType == 3)
+           return domPosInText$3(closest, clipX, y);
+       if (!closestX && closest.contentEditable == "true")
+           return domPosAtCoords$3(closest, clipX, y);
+       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
+           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
+       return { node: parent, offset };
+   }
+   function domPosInText$3(node, x, y) {
+       let len = node.nodeValue.length;
+       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
+       for (let i = 0; i < len; i++) {
+           let rects = textRange$3(node, i, i + 1).getClientRects();
+           for (let j = 0; j < rects.length; j++) {
+               let rect = rects[j];
+               if (rect.top == rect.bottom)
+                   continue;
+               if (!generalSide)
+                   generalSide = x - rect.left;
+               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
+               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
+                   let right = x >= (rect.left + rect.right) / 2, after = right;
+                   if (browser$3.chrome || browser$3.gecko) {
+                       // Check for RTL on browsers that support getting client
+                       // rects for empty ranges.
+                       let rectBefore = textRange$3(node, i).getBoundingClientRect();
+                       if (rectBefore.left == rect.right)
+                           after = !right;
+                   }
+                   if (dy <= 0)
+                       return { node, offset: i + (after ? 1 : 0) };
+                   closestOffset = i + (after ? 1 : 0);
+                   closestDY = dy;
+               }
+           }
+       }
+       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
+   }
+   function posAtCoords$3(view, { x, y }, precise, bias = -1) {
+       var _a;
+       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
+       let block, { docHeight } = view.viewState;
+       let yOffset = y - docTop;
+       if (yOffset < 0)
+           return 0;
+       if (yOffset > docHeight)
+           return view.state.doc.length;
+       // Scan for a text block near the queried y position
+       for (let halfLine = view.defaultLineHeight / 2, bounced = false;;) {
+           block = view.elementAtHeight(yOffset);
+           if (block.type == BlockType$3.Text)
+               break;
+           for (;;) {
+               // Move the y position out of this block
+               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
+               if (yOffset >= 0 && yOffset <= docHeight)
+                   break;
+               // If the document consists entirely of replaced widgets, we
+               // won't find a text block, so return 0
+               if (bounced)
+                   return precise ? null : 0;
+               bounced = true;
+               bias = -bias;
+           }
+       }
+       y = docTop + yOffset;
+       let lineStart = block.from;
+       // If this is outside of the rendered viewport, we can't determine a position
+       if (lineStart < view.viewport.from)
+           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise$3(view, content, block, x, y);
+       if (lineStart > view.viewport.to)
+           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
+               precise ? null : posAtCoordsImprecise$3(view, content, block, x, y);
+       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
+       let doc = view.dom.ownerDocument;
+       let root = view.root.elementFromPoint ? view.root : doc;
+       let element = root.elementFromPoint(x, y);
+       if (element && !view.contentDOM.contains(element))
+           element = null;
+       // If the element is unexpected, clip x at the sides of the content area and try again
+       if (!element) {
+           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
+           element = root.elementFromPoint(x, y);
+           if (element && !view.contentDOM.contains(element))
+               element = null;
+       }
+       // There's visible editor content under the point, so we can try
+       // using caret(Position|Range)FromPoint as a shortcut
+       let node, offset = -1;
+       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
+           if (doc.caretPositionFromPoint) {
+               let pos = doc.caretPositionFromPoint(x, y);
+               if (pos)
+                   ({ offsetNode: node, offset } = pos);
+           }
+           else if (doc.caretRangeFromPoint) {
+               let range = doc.caretRangeFromPoint(x, y);
+               if (range) {
+                   ({ startContainer: node, startOffset: offset } = range);
+                   if (browser$3.safari && isSuspiciousCaretResult$2(node, offset, x))
+                       node = undefined;
+               }
+           }
+       }
+       // No luck, do our own (potentially expensive) search
+       if (!node || !view.docView.dom.contains(node)) {
+           let line = LineView$3.find(view.docView, lineStart);
+           if (!line)
+               return yOffset > block.top + block.height / 2 ? block.to : block.from;
+           ({ node, offset } = domPosAtCoords$3(line.dom, x, y));
+       }
+       return view.docView.posFromDOM(node, offset);
+   }
+   function posAtCoordsImprecise$3(view, contentRect, block, x, y) {
+       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
+       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
+           let line = Math.floor((y - block.top) / view.defaultLineHeight);
+           into += line * view.viewState.heightOracle.lineLength;
+       }
+       let content = view.state.sliceDoc(block.from, block.to);
+       return block.from + findColumn$3(content, into, view.state.tabSize);
+   }
+   // In case of a high line height, Safari's caretRangeFromPoint treats
+   // the space between lines as belonging to the last character of the
+   // line before. This is used to detect such a result so that it can be
+   // ignored (issue #401).
+   function isSuspiciousCaretResult$2(node, offset, x) {
+       let len;
+       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
+           return false;
+       for (let next = node.nextSibling; next; next = next.nextSibling)
+           if (next.nodeType != 1 || next.nodeName != "BR")
+               return false;
+       return textRange$3(node, len - 1, len).getBoundingClientRect().left > x;
+   }
+   function moveToLineBoundary$3(view, start, forward, includeWrap) {
+       let line = view.state.doc.lineAt(start.head);
+       let coords = !includeWrap || !view.lineWrapping ? null
+           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
+       if (coords) {
+           let editorRect = view.dom.getBoundingClientRect();
+           let direction = view.textDirectionAt(line.from);
+           let pos = view.posAtCoords({ x: forward == (direction == Direction$3.LTR) ? editorRect.right - 1 : editorRect.left + 1,
+               y: (coords.top + coords.bottom) / 2 });
+           if (pos != null)
+               return EditorSelection$3.cursor(pos, forward ? -1 : 1);
+       }
+       let lineView = LineView$3.find(view.docView, start.head);
+       let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
+       return EditorSelection$3.cursor(end, forward ? -1 : 1);
+   }
+   function moveByChar$3(view, start, forward, by) {
+       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
+       let direction = view.textDirectionAt(line.from);
+       for (let cur = start, check = null;;) {
+           let next = moveVisually$3(line, spans, direction, cur, forward), char = movedOver$3;
+           if (!next) {
+               if (line.number == (forward ? view.state.doc.lines : 1))
+                   return cur;
+               char = "\n";
+               line = view.state.doc.line(line.number + (forward ? 1 : -1));
+               spans = view.bidiSpans(line);
+               next = EditorSelection$3.cursor(forward ? line.from : line.to);
+           }
+           if (!check) {
+               if (!by)
+                   return next;
+               check = by(char);
+           }
+           else if (!check(char)) {
+               return cur;
+           }
+           cur = next;
+       }
+   }
+   function byGroup$3(view, pos, start) {
+       let categorize = view.state.charCategorizer(pos);
+       let cat = categorize(start);
+       return (next) => {
+           let nextCat = categorize(next);
+           if (cat == CharCategory$3.Space)
+               cat = nextCat;
+           return cat == nextCat;
+       };
+   }
+   function moveVertically$3(view, start, forward, distance) {
+       let startPos = start.head, dir = forward ? 1 : -1;
+       if (startPos == (forward ? view.state.doc.length : 0))
+           return EditorSelection$3.cursor(startPos, start.assoc);
+       let goal = start.goalColumn, startY;
+       let rect = view.contentDOM.getBoundingClientRect();
+       let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;
+       if (startCoords) {
+           if (goal == null)
+               goal = startCoords.left - rect.left;
+           startY = dir < 0 ? startCoords.top : startCoords.bottom;
+       }
+       else {
+           let line = view.viewState.lineBlockAt(startPos);
+           if (goal == null)
+               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
+           startY = (dir < 0 ? line.top : line.bottom) + docTop;
+       }
+       let resolvedGoal = rect.left + goal;
+       let dist = distance !== null && distance !== void 0 ? distance : (view.defaultLineHeight >> 1);
+       for (let extra = 0;; extra += 10) {
+           let curY = startY + (dist + extra) * dir;
+           let pos = posAtCoords$3(view, { x: resolvedGoal, y: curY }, false, dir);
+           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))
+               return EditorSelection$3.cursor(pos, start.assoc, undefined, goal);
+       }
+   }
+   function skipAtoms$3(view, oldPos, pos) {
+       let atoms = view.state.facet(atomicRanges$3).map(f => f(view));
+       for (;;) {
+           let moved = false;
+           for (let set of atoms) {
+               set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
+                   if (pos.from > from && pos.from < to) {
+                       pos = oldPos.from > pos.from ? EditorSelection$3.cursor(from, 1) : EditorSelection$3.cursor(to, -1);
+                       moved = true;
+                   }
+               });
+           }
+           if (!moved)
+               return pos;
+       }
+   }
+
+   // This will also be where dragging info and such goes
+   let InputState$3 = class InputState {
+       constructor(view) {
+           this.lastKeyCode = 0;
+           this.lastKeyTime = 0;
+           this.chromeScrollHack = -1;
+           // On iOS, some keys need to have their default behavior happen
+           // (after which we retroactively handle them and reset the DOM) to
+           // avoid messing up the virtual keyboard state.
+           this.pendingIOSKey = undefined;
+           this.lastSelectionOrigin = null;
+           this.lastSelectionTime = 0;
+           this.lastEscPress = 0;
+           this.lastContextMenu = 0;
+           this.scrollHandlers = [];
+           this.registeredEvents = [];
+           this.customHandlers = [];
+           // -1 means not in a composition. Otherwise, this counts the number
+           // of changes made during the composition. The count is used to
+           // avoid treating the start state of the composition, before any
+           // changes have been made, as part of the composition.
+           this.composing = -1;
+           // Tracks whether the next change should be marked as starting the
+           // composition (null means no composition, true means next is the
+           // first, false means first has already been marked for this
+           // composition)
+           this.compositionFirstChange = null;
+           this.compositionEndedAt = 0;
+           this.rapidCompositionStart = false;
+           this.mouseSelection = null;
+           for (let type in handlers$3) {
+               let handler = handlers$3[type];
+               view.contentDOM.addEventListener(type, (event) => {
+                   if (!eventBelongsToEditor$3(view, event) || this.ignoreDuringComposition(event))
+                       return;
+                   if (type == "keydown" && this.keydown(view, event))
+                       return;
+                   if (this.mustFlushObserver(event))
+                       view.observer.forceFlush();
+                   if (this.runCustomHandlers(type, view, event))
+                       event.preventDefault();
+                   else
+                       handler(view, event);
+               });
+               this.registeredEvents.push(type);
+           }
+           if (browser$3.chrome && browser$3.chrome_version >= 102) {
+               // On Chrome 102, viewport updates somehow stop wheel-based
+               // scrolling. Turning off pointer events during the scroll seems
+               // to avoid the issue.
+               view.scrollDOM.addEventListener("wheel", () => {
+                   if (this.chromeScrollHack < 0)
+                       view.contentDOM.style.pointerEvents = "none";
+                   else
+                       window.clearTimeout(this.chromeScrollHack);
+                   this.chromeScrollHack = setTimeout(() => {
+                       this.chromeScrollHack = -1;
+                       view.contentDOM.style.pointerEvents = "";
+                   }, 100);
+               }, { passive: true });
+           }
+           this.notifiedFocused = view.hasFocus;
+           // On Safari adding an input event handler somehow prevents an
+           // issue where the composition vanishes when you press enter.
+           if (browser$3.safari)
+               view.contentDOM.addEventListener("input", () => null);
+       }
+       setSelectionOrigin(origin) {
+           this.lastSelectionOrigin = origin;
+           this.lastSelectionTime = Date.now();
+       }
+       ensureHandlers(view, plugins) {
+           var _a;
+           let handlers;
+           this.customHandlers = [];
+           for (let plugin of plugins)
+               if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {
+                   this.customHandlers.push({ plugin: plugin.value, handlers });
+                   for (let type in handlers)
+                       if (this.registeredEvents.indexOf(type) < 0 && type != "scroll") {
+                           this.registeredEvents.push(type);
+                           view.contentDOM.addEventListener(type, (event) => {
+                               if (!eventBelongsToEditor$3(view, event))
+                                   return;
+                               if (this.runCustomHandlers(type, view, event))
+                                   event.preventDefault();
+                           });
+                       }
+               }
+       }
+       runCustomHandlers(type, view, event) {
+           for (let set of this.customHandlers) {
+               let handler = set.handlers[type];
+               if (handler) {
+                   try {
+                       if (handler.call(set.plugin, event, view) || event.defaultPrevented)
+                           return true;
+                   }
+                   catch (e) {
+                       logException$3(view.state, e);
+                   }
+               }
+           }
+           return false;
+       }
+       runScrollHandlers(view, event) {
+           for (let set of this.customHandlers) {
+               let handler = set.handlers.scroll;
+               if (handler) {
+                   try {
+                       handler.call(set.plugin, event, view);
+                   }
+                   catch (e) {
+                       logException$3(view.state, e);
+                   }
+               }
+           }
+       }
+       keydown(view, event) {
+           // Must always run, even if a custom handler handled the event
+           this.lastKeyCode = event.keyCode;
+           this.lastKeyTime = Date.now();
+           if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
+               return true;
+           // Chrome for Android usually doesn't fire proper key events, but
+           // occasionally does, usually surrounded by a bunch of complicated
+           // composition changes. When an enter or backspace key event is
+           // seen, hold off on handling DOM events for a bit, and then
+           // dispatch it.
+           if (browser$3.android && browser$3.chrome && !event.synthetic &&
+               (event.keyCode == 13 || event.keyCode == 8)) {
+               view.observer.delayAndroidKey(event.key, event.keyCode);
+               return true;
+           }
+           // Prevent the default behavior of Enter on iOS makes the
+           // virtual keyboard get stuck in the wrong (lowercase)
+           // state. So we let it go through, and then, in
+           // applyDOMChange, notify key handlers of it and reset to
+           // the state they produce.
+           let pending;
+           if (browser$3.ios && (pending = PendingKeys$3.find(key => key.keyCode == event.keyCode)) &&
+               !(event.ctrlKey || event.altKey || event.metaKey) && !event.synthetic) {
+               this.pendingIOSKey = pending;
+               setTimeout(() => this.flushIOSKey(view), 250);
+               return true;
+           }
+           return false;
+       }
+       flushIOSKey(view) {
+           let key = this.pendingIOSKey;
+           if (!key)
+               return false;
+           this.pendingIOSKey = undefined;
+           return dispatchKey$3(view.contentDOM, key.key, key.keyCode);
+       }
+       ignoreDuringComposition(event) {
+           if (!/^key/.test(event.type))
+               return false;
+           if (this.composing > 0)
+               return true;
+           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
+           // On some input method editors (IMEs), the Enter key is used to
+           // confirm character selection. On Safari, when Enter is pressed,
+           // compositionend and keydown events are sometimes emitted in the
+           // wrong order. The key event should still be ignored, even when
+           // it happens after the compositionend event.
+           if (browser$3.safari && Date.now() - this.compositionEndedAt < 100) {
+               this.compositionEndedAt = 0;
+               return true;
+           }
+           return false;
+       }
+       mustFlushObserver(event) {
+           return (event.type == "keydown" && event.keyCode != 229) ||
+               event.type == "compositionend" && !browser$3.ios;
+       }
+       startMouseSelection(mouseSelection) {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+           this.mouseSelection = mouseSelection;
+       }
+       update(update) {
+           if (this.mouseSelection)
+               this.mouseSelection.update(update);
+           if (update.transactions.length)
+               this.lastKeyCode = this.lastSelectionTime = 0;
+       }
+       destroy() {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+       }
+   };
+   const PendingKeys$3 = [
+       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
+       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
+       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
+   ];
+   // Key codes for modifier keys
+   const modifierCodes$3 = [16, 17, 18, 20, 91, 92, 224, 225];
+   let MouseSelection$3 = class MouseSelection {
+       constructor(view, startEvent, style, mustSelect) {
+           this.view = view;
+           this.style = style;
+           this.mustSelect = mustSelect;
+           this.lastEvent = startEvent;
+           let doc = view.contentDOM.ownerDocument;
+           doc.addEventListener("mousemove", this.move = this.move.bind(this));
+           doc.addEventListener("mouseup", this.up = this.up.bind(this));
+           this.extend = startEvent.shiftKey;
+           this.multiple = view.state.facet(EditorState$3.allowMultipleSelections) && addsSelectionRange$3(view, startEvent);
+           this.dragMove = dragMovesSelection$4(view, startEvent);
+           this.dragging = isInPrimarySelection$3(view, startEvent) && getClickType$3(startEvent) == 1 ? null : false;
+           // When clicking outside of the selection, immediately apply the
+           // effect of starting the selection
+           if (this.dragging === false) {
+               startEvent.preventDefault();
+               this.select(startEvent);
+           }
+       }
+       move(event) {
+           if (event.buttons == 0)
+               return this.destroy();
+           if (this.dragging !== false)
+               return;
+           this.select(this.lastEvent = event);
+       }
+       up(event) {
+           if (this.dragging == null)
+               this.select(this.lastEvent);
+           if (!this.dragging)
+               event.preventDefault();
+           this.destroy();
+       }
+       destroy() {
+           let doc = this.view.contentDOM.ownerDocument;
+           doc.removeEventListener("mousemove", this.move);
+           doc.removeEventListener("mouseup", this.up);
+           this.view.inputState.mouseSelection = null;
+       }
+       select(event) {
+           let selection = this.style.get(event, this.extend, this.multiple);
+           if (this.mustSelect || !selection.eq(this.view.state.selection) ||
+               selection.main.assoc != this.view.state.selection.main.assoc)
+               this.view.dispatch({
+                   selection,
+                   userEvent: "select.pointer",
+                   scrollIntoView: true
+               });
+           this.mustSelect = false;
+       }
+       update(update) {
+           if (update.docChanged && this.dragging)
+               this.dragging = this.dragging.map(update.changes);
+           if (this.style.update(update))
+               setTimeout(() => this.select(this.lastEvent), 20);
+       }
+   };
+   function addsSelectionRange$3(view, event) {
+       let facet = view.state.facet(clickAddsSelectionRange$3);
+       return facet.length ? facet[0](event) : browser$3.mac ? event.metaKey : event.ctrlKey;
+   }
+   function dragMovesSelection$4(view, event) {
+       let facet = view.state.facet(dragMovesSelection$1$3);
+       return facet.length ? facet[0](event) : browser$3.mac ? !event.altKey : !event.ctrlKey;
+   }
+   function isInPrimarySelection$3(view, event) {
+       let { main } = view.state.selection;
+       if (main.empty)
+           return false;
+       // On boundary clicks, check whether the coordinates are inside the
+       // selection's client rectangles
+       let sel = getSelection$3(view.root);
+       if (sel.rangeCount == 0)
+           return true;
+       let rects = sel.getRangeAt(0).getClientRects();
+       for (let i = 0; i < rects.length; i++) {
+           let rect = rects[i];
+           if (rect.left <= event.clientX && rect.right >= event.clientX &&
+               rect.top <= event.clientY && rect.bottom >= event.clientY)
+               return true;
+       }
+       return false;
+   }
+   function eventBelongsToEditor$3(view, event) {
+       if (!event.bubbles)
+           return true;
+       if (event.defaultPrevented)
+           return false;
+       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
+           if (!node || node.nodeType == 11 || ((cView = ContentView$3.get(node)) && cView.ignoreEvent(event)))
+               return false;
+       return true;
+   }
+   const handlers$3 = /*@__PURE__*/Object.create(null);
+   // This is very crude, but unfortunately both these browsers _pretend_
+   // that they have a clipboard API—all the objects and methods are
+   // there, they just don't work, and they are hard to test.
+   const brokenClipboardAPI$3 = (browser$3.ie && browser$3.ie_version < 15) ||
+       (browser$3.ios && browser$3.webkit_version < 604);
+   function capturePaste$3(view) {
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.focus();
+       setTimeout(() => {
+           view.focus();
+           target.remove();
+           doPaste$3(view, target.value);
+       }, 50);
+   }
+   function doPaste$3(view, input) {
+       let { state } = view, changes, i = 1, text = state.toText(input);
+       let byLine = text.lines == state.selection.ranges.length;
+       let linewise = lastLinewiseCopy$3 != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy$3 == text.toString();
+       if (linewise) {
+           let lastLine = -1;
+           changes = state.changeByRange(range => {
+               let line = state.doc.lineAt(range.from);
+               if (line.from == lastLine)
+                   return { range };
+               lastLine = line.from;
+               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
+               return { changes: { from: line.from, insert },
+                   range: EditorSelection$3.cursor(range.from + insert.length) };
+           });
+       }
+       else if (byLine) {
+           changes = state.changeByRange(range => {
+               let line = text.line(i++);
+               return { changes: { from: range.from, to: range.to, insert: line.text },
+                   range: EditorSelection$3.cursor(range.from + line.length) };
+           });
+       }
+       else {
+           changes = state.replaceSelection(text);
+       }
+       view.dispatch(changes, {
+           userEvent: "input.paste",
+           scrollIntoView: true
+       });
+   }
+   handlers$3.keydown = (view, event) => {
+       view.inputState.setSelectionOrigin("select");
+       if (event.keyCode == 27)
+           view.inputState.lastEscPress = Date.now();
+       else if (modifierCodes$3.indexOf(event.keyCode) < 0)
+           view.inputState.lastEscPress = 0;
+   };
+   let lastTouch$2 = 0;
+   handlers$3.touchstart = (view, e) => {
+       lastTouch$2 = Date.now();
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   handlers$3.touchmove = view => {
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   handlers$3.mousedown = (view, event) => {
+       view.observer.flush();
+       if (lastTouch$2 > Date.now() - 2000 && getClickType$3(event) == 1)
+           return; // Ignore touch interaction
+       let style = null;
+       for (let makeStyle of view.state.facet(mouseSelectionStyle$3)) {
+           style = makeStyle(view, event);
+           if (style)
+               break;
+       }
+       if (!style && event.button == 0)
+           style = basicMouseSelection$3(view, event);
+       if (style) {
+           let mustFocus = view.root.activeElement != view.contentDOM;
+           if (mustFocus)
+               view.observer.ignore(() => focusPreventScroll$3(view.contentDOM));
+           view.inputState.startMouseSelection(new MouseSelection$3(view, event, style, mustFocus));
+       }
+   };
+   function rangeForClick$3(view, pos, bias, type) {
+       if (type == 1) { // Single click
+           return EditorSelection$3.cursor(pos, bias);
+       }
+       else if (type == 2) { // Double click
+           return groupAt$3(view.state, pos, bias);
+       }
+       else { // Triple click
+           let visual = LineView$3.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
+           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
+           if (to < view.state.doc.length && to == line.to)
+               to++;
+           return EditorSelection$3.range(from, to);
+       }
+   }
+   let insideY$2 = (y, rect) => y >= rect.top && y <= rect.bottom;
+   let inside$3 = (x, y, rect) => insideY$2(y, rect) && x >= rect.left && x <= rect.right;
+   // Try to determine, for the given coordinates, associated with the
+   // given position, whether they are related to the element before or
+   // the element after the position.
+   function findPositionSide$3(view, pos, x, y) {
+       let line = LineView$3.find(view.docView, pos);
+       if (!line)
+           return 1;
+       let off = pos - line.posAtStart;
+       // Line boundaries point into the line
+       if (off == 0)
+           return 1;
+       if (off == line.length)
+           return -1;
+       // Positions on top of an element point at that element
+       let before = line.coordsAt(off, -1);
+       if (before && inside$3(x, y, before))
+           return -1;
+       let after = line.coordsAt(off, 1);
+       if (after && inside$3(x, y, after))
+           return 1;
+       // This is probably a line wrap point. Pick before if the point is
+       // beside it.
+       return before && insideY$2(y, before) ? -1 : 1;
+   }
+   function queryPos$3(view, event) {
+       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       return { pos, bias: findPositionSide$3(view, pos, event.clientX, event.clientY) };
+   }
+   const BadMouseDetail$3 = browser$3.ie && browser$3.ie_version <= 11;
+   let lastMouseDown$3 = null, lastMouseDownCount$3 = 0, lastMouseDownTime$3 = 0;
+   function getClickType$3(event) {
+       if (!BadMouseDetail$3)
+           return event.detail;
+       let last = lastMouseDown$3, lastTime = lastMouseDownTime$3;
+       lastMouseDown$3 = event;
+       lastMouseDownTime$3 = Date.now();
+       return lastMouseDownCount$3 = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
+           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount$3 + 1) % 3 : 1;
+   }
+   function basicMouseSelection$3(view, event) {
+       let start = queryPos$3(view, event), type = getClickType$3(event);
+       let startSel = view.state.selection;
+       let last = start, lastEvent = event;
+       return {
+           update(update) {
+               if (update.docChanged) {
+                   if (start)
+                       start.pos = update.changes.mapPos(start.pos);
+                   startSel = startSel.map(update.changes);
+                   lastEvent = null;
+               }
+           },
+           get(event, extend, multiple) {
+               let cur;
+               if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
+                   cur = last;
+               else {
+                   cur = last = queryPos$3(view, event);
+                   lastEvent = event;
+               }
+               if (!cur || !start)
+                   return startSel;
+               let range = rangeForClick$3(view, cur.pos, cur.bias, type);
+               if (start.pos != cur.pos && !extend) {
+                   let startRange = rangeForClick$3(view, start.pos, start.bias, type);
+                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
+                   range = from < range.from ? EditorSelection$3.range(from, to) : EditorSelection$3.range(to, from);
+               }
+               if (extend)
+                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
+               else if (multiple)
+                   return startSel.addRange(range);
+               else
+                   return EditorSelection$3.create([range]);
+           }
+       };
+   }
+   handlers$3.dragstart = (view, event) => {
+       let { selection: { main } } = view.state;
+       let { mouseSelection } = view.inputState;
+       if (mouseSelection)
+           mouseSelection.dragging = main;
+       if (event.dataTransfer) {
+           event.dataTransfer.setData("Text", view.state.sliceDoc(main.from, main.to));
+           event.dataTransfer.effectAllowed = "copyMove";
+       }
+   };
+   function dropText$3(view, event, text, direct) {
+       if (!text)
+           return;
+       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       event.preventDefault();
+       let { mouseSelection } = view.inputState;
+       let del = direct && mouseSelection && mouseSelection.dragging && mouseSelection.dragMove ?
+           { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;
+       let ins = { from: dropPos, insert: text };
+       let changes = view.state.changes(del ? [del, ins] : ins);
+       view.focus();
+       view.dispatch({
+           changes,
+           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
+           userEvent: del ? "move.drop" : "input.drop"
+       });
+   }
+   handlers$3.drop = (view, event) => {
+       if (!event.dataTransfer)
+           return;
+       if (view.state.readOnly)
+           return event.preventDefault();
+       let files = event.dataTransfer.files;
+       if (files && files.length) { // For a file drop, read the file's text.
+           event.preventDefault();
+           let text = Array(files.length), read = 0;
+           let finishFile = () => {
+               if (++read == files.length)
+                   dropText$3(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
+           };
+           for (let i = 0; i < files.length; i++) {
+               let reader = new FileReader;
+               reader.onerror = finishFile;
+               reader.onload = () => {
+                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
+                       text[i] = reader.result;
+                   finishFile();
+               };
+               reader.readAsText(files[i]);
+           }
+       }
+       else {
+           dropText$3(view, event, event.dataTransfer.getData("Text"), true);
+       }
+   };
+   handlers$3.paste = (view, event) => {
+       if (view.state.readOnly)
+           return event.preventDefault();
+       view.observer.flush();
+       let data = brokenClipboardAPI$3 ? null : event.clipboardData;
+       if (data) {
+           doPaste$3(view, data.getData("text/plain"));
+           event.preventDefault();
+       }
+       else {
+           capturePaste$3(view);
+       }
+   };
+   function captureCopy$3(view, text) {
+       // The extra wrapper is somehow necessary on IE/Edge to prevent the
+       // content from being mangled when it is put onto the clipboard
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.value = text;
+       target.focus();
+       target.selectionEnd = text.length;
+       target.selectionStart = 0;
+       setTimeout(() => {
+           target.remove();
+           view.focus();
+       }, 50);
+   }
+   function copiedRange$3(state) {
+       let content = [], ranges = [], linewise = false;
+       for (let range of state.selection.ranges)
+           if (!range.empty) {
+               content.push(state.sliceDoc(range.from, range.to));
+               ranges.push(range);
+           }
+       if (!content.length) {
+           // Nothing selected, do a line-wise copy
+           let upto = -1;
+           for (let { from } of state.selection.ranges) {
+               let line = state.doc.lineAt(from);
+               if (line.number > upto) {
+                   content.push(line.text);
+                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
+               }
+               upto = line.number;
+           }
+           linewise = true;
+       }
+       return { text: content.join(state.lineBreak), ranges, linewise };
+   }
+   let lastLinewiseCopy$3 = null;
+   handlers$3.copy = handlers$3.cut = (view, event) => {
+       let { text, ranges, linewise } = copiedRange$3(view.state);
+       if (!text && !linewise)
+           return;
+       lastLinewiseCopy$3 = linewise ? text : null;
+       let data = brokenClipboardAPI$3 ? null : event.clipboardData;
+       if (data) {
+           event.preventDefault();
+           data.clearData();
+           data.setData("text/plain", text);
+       }
+       else {
+           captureCopy$3(view, text);
+       }
+       if (event.type == "cut" && !view.state.readOnly)
+           view.dispatch({
+               changes: ranges,
+               scrollIntoView: true,
+               userEvent: "delete.cut"
+           });
+   };
+   function updateForFocusChange$3(view) {
+       setTimeout(() => {
+           if (view.hasFocus != view.inputState.notifiedFocused)
+               view.update([]);
+       }, 10);
+   }
+   handlers$3.focus = updateForFocusChange$3;
+   handlers$3.blur = view => {
+       view.observer.clearSelectionRange();
+       updateForFocusChange$3(view);
+   };
+   function forceClearComposition$2(view, rapid) {
+       if (view.docView.compositionDeco.size) {
+           view.inputState.rapidCompositionStart = rapid;
+           try {
+               view.update([]);
+           }
+           finally {
+               view.inputState.rapidCompositionStart = false;
+           }
+       }
+   }
+   handlers$3.compositionstart = handlers$3.compositionupdate = view => {
+       if (view.inputState.compositionFirstChange == null)
+           view.inputState.compositionFirstChange = true;
+       if (view.inputState.composing < 0) {
+           // FIXME possibly set a timeout to clear it again on Android
+           view.inputState.composing = 0;
+           if (view.docView.compositionDeco.size) {
+               view.observer.flush();
+               forceClearComposition$2(view, true);
+           }
+       }
+   };
+   handlers$3.compositionend = view => {
+       view.inputState.composing = -1;
+       view.inputState.compositionEndedAt = Date.now();
+       view.inputState.compositionFirstChange = null;
+       setTimeout(() => {
+           if (view.inputState.composing < 0)
+               forceClearComposition$2(view, false);
+       }, 50);
+   };
+   handlers$3.contextmenu = view => {
+       view.inputState.lastContextMenu = Date.now();
+   };
+   handlers$3.beforeinput = (view, event) => {
+       var _a;
+       // Because Chrome Android doesn't fire useful key events, use
+       // beforeinput to detect backspace (and possibly enter and delete,
+       // but those usually don't even seem to fire beforeinput events at
+       // the moment) and fake a key event for it.
+       //
+       // (preventDefault on beforeinput, though supported in the spec,
+       // seems to do nothing at all on Chrome).
+       let pending;
+       if (browser$3.chrome && browser$3.android && (pending = PendingKeys$3.find(key => key.inputType == event.inputType))) {
+           view.observer.delayAndroidKey(pending.key, pending.keyCode);
+           if (pending.key == "Backspace" || pending.key == "Delete") {
+               let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
+               setTimeout(() => {
+                   var _a;
+                   // Backspacing near uneditable nodes on Chrome Android sometimes
+                   // closes the virtual keyboard. This tries to crudely detect
+                   // that and refocus to get it back.
+                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
+                       view.contentDOM.blur();
+                       view.focus();
+                   }
+               }, 100);
+           }
+       }
+   };
+
+   const wrappingWhiteSpace$3 = ["pre-wrap", "normal", "pre-line", "break-spaces"];
+   let HeightOracle$3 = class HeightOracle {
+       constructor() {
+           this.doc = Text$3.empty;
+           this.lineWrapping = false;
+           this.heightSamples = {};
+           this.lineHeight = 14;
+           this.charWidth = 7;
+           this.lineLength = 30;
+           // Used to track, during updateHeight, if any actual heights changed
+           this.heightChanged = false;
+       }
+       heightForGap(from, to) {
+           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
+           if (this.lineWrapping)
+               lines += Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength);
+           return this.lineHeight * lines;
+       }
+       heightForLine(length) {
+           if (!this.lineWrapping)
+               return this.lineHeight;
+           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
+           return lines * this.lineHeight;
+       }
+       setDoc(doc) { this.doc = doc; return this; }
+       mustRefreshForWrapping(whiteSpace) {
+           return (wrappingWhiteSpace$3.indexOf(whiteSpace) > -1) != this.lineWrapping;
+       }
+       mustRefreshForHeights(lineHeights) {
+           let newHeight = false;
+           for (let i = 0; i < lineHeights.length; i++) {
+               let h = lineHeights[i];
+               if (h < 0) {
+                   i++;
+               }
+               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
+                   newHeight = true;
+                   this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return newHeight;
+       }
+       refresh(whiteSpace, lineHeight, charWidth, lineLength, knownHeights) {
+           let lineWrapping = wrappingWhiteSpace$3.indexOf(whiteSpace) > -1;
+           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
+           this.lineWrapping = lineWrapping;
+           this.lineHeight = lineHeight;
+           this.charWidth = charWidth;
+           this.lineLength = lineLength;
+           if (changed) {
+               this.heightSamples = {};
+               for (let i = 0; i < knownHeights.length; i++) {
+                   let h = knownHeights[i];
+                   if (h < 0)
+                       i++;
+                   else
+                       this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return changed;
+       }
+   };
+   // This object is used by `updateHeight` to make DOM measurements
+   // arrive at the right nides. The `heights` array is a sequence of
+   // block heights, starting from position `from`.
+   let MeasuredHeights$3 = class MeasuredHeights {
+       constructor(from, heights) {
+           this.from = from;
+           this.heights = heights;
+           this.index = 0;
+       }
+       get more() { return this.index < this.heights.length; }
+   };
+   /**
+   Record used to represent information about a block-level element
+   in the editor view.
+   */
+   let BlockInfo$3 = class BlockInfo {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the element in the document.
+       */
+       from, 
+       /**
+       The length of the element.
+       */
+       length, 
+       /**
+       The top position of the element (relative to the top of the
+       document).
+       */
+       top, 
+       /**
+       Its height.
+       */
+       height, 
+       /**
+       The type of element this is. When querying lines, this may be
+       an array of all the blocks that make up the line.
+       */
+       type) {
+           this.from = from;
+           this.length = length;
+           this.top = top;
+           this.height = height;
+           this.type = type;
+       }
+       /**
+       The end of the element as a document position.
+       */
+       get to() { return this.from + this.length; }
+       /**
+       The bottom position of the element.
+       */
+       get bottom() { return this.top + this.height; }
+       /**
+       @internal
+       */
+       join(other) {
+           let detail = (Array.isArray(this.type) ? this.type : [this])
+               .concat(Array.isArray(other.type) ? other.type : [other]);
+           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
+       }
+   };
+   var QueryType$4 = /*@__PURE__*/(function (QueryType) {
+       QueryType[QueryType["ByPos"] = 0] = "ByPos";
+       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
+       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
+   return QueryType})(QueryType$4 || (QueryType$4 = {}));
+   const Epsilon$3 = 1e-3;
+   let HeightMap$3 = class HeightMap {
+       constructor(length, // The number of characters covered
+       height, // Height of this part of the document
+       flags = 2 /* Outdated */) {
+           this.length = length;
+           this.height = height;
+           this.flags = flags;
+       }
+       get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
+       set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
+       setHeight(oracle, height) {
+           if (this.height != height) {
+               if (Math.abs(this.height - height) > Epsilon$3)
+                   oracle.heightChanged = true;
+               this.height = height;
+           }
+       }
+       // Base case is to replace a leaf node, which simply builds a tree
+       // from the new nodes and returns that (HeightMapBranch and
+       // HeightMapGap override this to actually use from/to)
+       replace(_from, _to, nodes) {
+           return HeightMap.of(nodes);
+       }
+       // Again, these are base cases, and are overridden for branch and gap nodes.
+       decomposeLeft(_to, result) { result.push(this); }
+       decomposeRight(_from, result) { result.push(this); }
+       applyChanges(decorations, oldDoc, oracle, changes) {
+           let me = this;
+           for (let i = changes.length - 1; i >= 0; i--) {
+               let { fromA, toA, fromB, toB } = changes[i];
+               let start = me.lineAt(fromA, QueryType$4.ByPosNoHeight, oldDoc, 0, 0);
+               let end = start.to >= toA ? start : me.lineAt(toA, QueryType$4.ByPosNoHeight, oldDoc, 0, 0);
+               toB += end.to - toA;
+               toA = end.to;
+               while (i > 0 && start.from <= changes[i - 1].toA) {
+                   fromA = changes[i - 1].fromA;
+                   fromB = changes[i - 1].fromB;
+                   i--;
+                   if (fromA < start.from)
+                       start = me.lineAt(fromA, QueryType$4.ByPosNoHeight, oldDoc, 0, 0);
+               }
+               fromB += start.from - fromA;
+               fromA = start.from;
+               let nodes = NodeBuilder$3.build(oracle, decorations, fromB, toB);
+               me = me.replace(fromA, toA, nodes);
+           }
+           return me.updateHeight(oracle, 0);
+       }
+       static empty() { return new HeightMapText$3(0, 0); }
+       // nodes uses null values to indicate the position of line breaks.
+       // There are never line breaks at the start or end of the array, or
+       // two line breaks next to each other, and the array isn't allowed
+       // to be empty (same restrictions as return value from the builder).
+       static of(nodes) {
+           if (nodes.length == 1)
+               return nodes[0];
+           let i = 0, j = nodes.length, before = 0, after = 0;
+           for (;;) {
+               if (i == j) {
+                   if (before > after * 2) {
+                       let split = nodes[i - 1];
+                       if (split.break)
+                           nodes.splice(--i, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(--i, 1, split.left, split.right);
+                       j += 1 + split.break;
+                       before -= split.size;
+                   }
+                   else if (after > before * 2) {
+                       let split = nodes[j];
+                       if (split.break)
+                           nodes.splice(j, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(j, 1, split.left, split.right);
+                       j += 2 + split.break;
+                       after -= split.size;
+                   }
+                   else {
+                       break;
+                   }
+               }
+               else if (before < after) {
+                   let next = nodes[i++];
+                   if (next)
+                       before += next.size;
+               }
+               else {
+                   let next = nodes[--j];
+                   if (next)
+                       after += next.size;
+               }
+           }
+           let brk = 0;
+           if (nodes[i - 1] == null) {
+               brk = 1;
+               i--;
+           }
+           else if (nodes[i] == null) {
+               brk = 1;
+               j++;
+           }
+           return new HeightMapBranch$3(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
+       }
+   };
+   HeightMap$3.prototype.size = 1;
+   let HeightMapBlock$3 = class HeightMapBlock extends HeightMap$3 {
+       constructor(length, height, type) {
+           super(length, height);
+           this.type = type;
+       }
+       blockAt(_height, _doc, top, offset) {
+           return new BlockInfo$3(offset, this.length, top, this.height, this.type);
+       }
+       lineAt(_value, _type, doc, top, offset) {
+           return this.blockAt(0, doc, top, offset);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           if (from <= offset + this.length && to >= offset)
+               f(this.blockAt(0, doc, top, offset));
+       }
+       updateHeight(oracle, offset = 0, _force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(oracle, measured.heights[measured.index++]);
+           this.outdated = false;
+           return this;
+       }
+       toString() { return `block(${this.length})`; }
+   };
+   let HeightMapText$3 = class HeightMapText extends HeightMapBlock$3 {
+       constructor(length, height) {
+           super(length, height, BlockType$3.Text);
+           this.collapsed = 0; // Amount of collapsed content in the line
+           this.widgetHeight = 0; // Maximum inline widget height
+       }
+       replace(_from, _to, nodes) {
+           let node = nodes[0];
+           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap$3 && (node.flags & 4 /* SingleLine */)) &&
+               Math.abs(this.length - node.length) < 10) {
+               if (node instanceof HeightMapGap$3)
+                   node = new HeightMapText(node.length, this.height);
+               else
+                   node.height = this.height;
+               if (!this.outdated)
+                   node.outdated = false;
+               return node;
+           }
+           else {
+               return HeightMap$3.of(nodes);
+           }
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(oracle, measured.heights[measured.index++]);
+           else if (force || this.outdated)
+               this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)));
+           this.outdated = false;
+           return this;
+       }
+       toString() {
+           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
+       }
+   };
+   let HeightMapGap$3 = class HeightMapGap extends HeightMap$3 {
+       constructor(length) { super(length, 0); }
+       lines(doc, offset) {
+           let firstLine = doc.lineAt(offset).number, lastLine = doc.lineAt(offset + this.length).number;
+           return { firstLine, lastLine, lineHeight: this.height / (lastLine - firstLine + 1) };
+       }
+       blockAt(height, doc, top, offset) {
+           let { firstLine, lastLine, lineHeight } = this.lines(doc, offset);
+           let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / lineHeight)));
+           let { from, length } = doc.line(firstLine + line);
+           return new BlockInfo$3(from, length, top + lineHeight * line, lineHeight, BlockType$3.Text);
+       }
+       lineAt(value, type, doc, top, offset) {
+           if (type == QueryType$4.ByHeight)
+               return this.blockAt(value, doc, top, offset);
+           if (type == QueryType$4.ByPosNoHeight) {
+               let { from, to } = doc.lineAt(value);
+               return new BlockInfo$3(from, to - from, 0, 0, BlockType$3.Text);
+           }
+           let { firstLine, lineHeight } = this.lines(doc, offset);
+           let { from, length, number } = doc.lineAt(value);
+           return new BlockInfo$3(from, length, top + lineHeight * (number - firstLine), lineHeight, BlockType$3.Text);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           let { firstLine, lineHeight } = this.lines(doc, offset);
+           for (let pos = Math.max(from, offset), end = Math.min(offset + this.length, to); pos <= end;) {
+               let line = doc.lineAt(pos);
+               if (pos == from)
+                   top += lineHeight * (line.number - firstLine);
+               f(new BlockInfo$3(line.from, line.length, top, lineHeight, BlockType$3.Text));
+               top += lineHeight;
+               pos = line.to + 1;
+           }
+       }
+       replace(from, to, nodes) {
+           let after = this.length - to;
+           if (after > 0) {
+               let last = nodes[nodes.length - 1];
+               if (last instanceof HeightMapGap)
+                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
+               else
+                   nodes.push(null, new HeightMapGap(after - 1));
+           }
+           if (from > 0) {
+               let first = nodes[0];
+               if (first instanceof HeightMapGap)
+                   nodes[0] = new HeightMapGap(from + first.length);
+               else
+                   nodes.unshift(new HeightMapGap(from - 1), null);
+           }
+           return HeightMap$3.of(nodes);
+       }
+       decomposeLeft(to, result) {
+           result.push(new HeightMapGap(to - 1), null);
+       }
+       decomposeRight(from, result) {
+           result.push(null, new HeightMapGap(this.length - from - 1));
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let end = offset + this.length;
+           if (measured && measured.from <= offset + this.length && measured.more) {
+               // Fill in part of this gap with measured lines. We know there
+               // can't be widgets or collapsed ranges in those lines, because
+               // they would already have been added to the heightmap (gaps
+               // only contain plain text).
+               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
+               let wasChanged = oracle.heightChanged;
+               if (measured.from > offset)
+                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
+               while (pos <= end && measured.more) {
+                   let len = oracle.doc.lineAt(pos).length;
+                   if (nodes.length)
+                       nodes.push(null);
+                   let height = measured.heights[measured.index++];
+                   if (singleHeight == -1)
+                       singleHeight = height;
+                   else if (Math.abs(height - singleHeight) >= Epsilon$3)
+                       singleHeight = -2;
+                   let line = new HeightMapText$3(len, height);
+                   line.outdated = false;
+                   nodes.push(line);
+                   pos += len + 1;
+               }
+               if (pos <= end)
+                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
+               let result = HeightMap$3.of(nodes);
+               oracle.heightChanged = wasChanged || singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon$3 ||
+                   Math.abs(singleHeight - this.lines(oracle.doc, offset).lineHeight) >= Epsilon$3;
+               return result;
+           }
+           else if (force || this.outdated) {
+               this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));
+               this.outdated = false;
+           }
+           return this;
+       }
+       toString() { return `gap(${this.length})`; }
+   };
+   let HeightMapBranch$3 = class HeightMapBranch extends HeightMap$3 {
+       constructor(left, brk, right) {
+           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
+           this.left = left;
+           this.right = right;
+           this.size = left.size + right.size;
+       }
+       get break() { return this.flags & 1 /* Break */; }
+       blockAt(height, doc, top, offset) {
+           let mid = top + this.left.height;
+           return height < mid ? this.left.blockAt(height, doc, top, offset)
+               : this.right.blockAt(height, doc, mid, offset + this.left.length + this.break);
+       }
+       lineAt(value, type, doc, top, offset) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           let left = type == QueryType$4.ByHeight ? value < rightTop : value < rightOffset;
+           let base = left ? this.left.lineAt(value, type, doc, top, offset)
+               : this.right.lineAt(value, type, doc, rightTop, rightOffset);
+           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
+               return base;
+           let subQuery = type == QueryType$4.ByPosNoHeight ? QueryType$4.ByPosNoHeight : QueryType$4.ByPos;
+           if (left)
+               return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));
+           else
+               return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           if (this.break) {
+               if (from < rightOffset)
+                   this.left.forEachLine(from, to, doc, top, offset, f);
+               if (to >= rightOffset)
+                   this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
+           }
+           else {
+               let mid = this.lineAt(rightOffset, QueryType$4.ByPos, doc, top, offset);
+               if (from < mid.from)
+                   this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
+               if (mid.to >= from && mid.from <= to)
+                   f(mid);
+               if (to > mid.to)
+                   this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
+           }
+       }
+       replace(from, to, nodes) {
+           let rightStart = this.left.length + this.break;
+           if (to < rightStart)
+               return this.balanced(this.left.replace(from, to, nodes), this.right);
+           if (from > this.left.length)
+               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
+           let result = [];
+           if (from > 0)
+               this.decomposeLeft(from, result);
+           let left = result.length;
+           for (let node of nodes)
+               result.push(node);
+           if (from > 0)
+               mergeGaps$3(result, left - 1);
+           if (to < this.length) {
+               let right = result.length;
+               this.decomposeRight(to, result);
+               mergeGaps$3(result, right);
+           }
+           return HeightMap$3.of(result);
+       }
+       decomposeLeft(to, result) {
+           let left = this.left.length;
+           if (to <= left)
+               return this.left.decomposeLeft(to, result);
+           result.push(this.left);
+           if (this.break) {
+               left++;
+               if (to >= left)
+                   result.push(null);
+           }
+           if (to > left)
+               this.right.decomposeLeft(to - left, result);
+       }
+       decomposeRight(from, result) {
+           let left = this.left.length, right = left + this.break;
+           if (from >= right)
+               return this.right.decomposeRight(from - right, result);
+           if (from < left)
+               this.left.decomposeRight(from, result);
+           if (this.break && from < right)
+               result.push(null);
+           result.push(this.right);
+       }
+       balanced(left, right) {
+           if (left.size > 2 * right.size || right.size > 2 * left.size)
+               return HeightMap$3.of(this.break ? [left, null, right] : [left, right]);
+           this.left = left;
+           this.right = right;
+           this.height = left.height + right.height;
+           this.outdated = left.outdated || right.outdated;
+           this.size = left.size + right.size;
+           this.length = left.length + this.break + right.length;
+           return this;
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
+           if (measured && measured.from <= offset + left.length && measured.more)
+               rebalance = left = left.updateHeight(oracle, offset, force, measured);
+           else
+               left.updateHeight(oracle, offset, force);
+           if (measured && measured.from <= rightStart + right.length && measured.more)
+               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
+           else
+               right.updateHeight(oracle, rightStart, force);
+           if (rebalance)
+               return this.balanced(left, right);
+           this.height = this.left.height + this.right.height;
+           this.outdated = false;
+           return this;
+       }
+       toString() { return this.left + (this.break ? " " : "-") + this.right; }
+   };
+   function mergeGaps$3(nodes, around) {
+       let before, after;
+       if (nodes[around] == null &&
+           (before = nodes[around - 1]) instanceof HeightMapGap$3 &&
+           (after = nodes[around + 1]) instanceof HeightMapGap$3)
+           nodes.splice(around - 1, 3, new HeightMapGap$3(before.length + 1 + after.length));
+   }
+   const relevantWidgetHeight$3 = 5;
+   let NodeBuilder$3 = class NodeBuilder {
+       constructor(pos, oracle) {
+           this.pos = pos;
+           this.oracle = oracle;
+           this.nodes = [];
+           this.lineStart = -1;
+           this.lineEnd = -1;
+           this.covering = null;
+           this.writtenTo = pos;
+       }
+       get isCovered() {
+           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
+       }
+       span(_from, to) {
+           if (this.lineStart > -1) {
+               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
+               if (last instanceof HeightMapText$3)
+                   last.length += end - this.pos;
+               else if (end > this.pos || !this.isCovered)
+                   this.nodes.push(new HeightMapText$3(end - this.pos, -1));
+               this.writtenTo = end;
+               if (to > end) {
+                   this.nodes.push(null);
+                   this.writtenTo++;
+                   this.lineStart = -1;
+               }
+           }
+           this.pos = to;
+       }
+       point(from, to, deco) {
+           if (from < to || deco.heightRelevant) {
+               let height = deco.widget ? deco.widget.estimatedHeight : 0;
+               if (height < 0)
+                   height = this.oracle.lineHeight;
+               let len = to - from;
+               if (deco.block) {
+                   this.addBlock(new HeightMapBlock$3(len, height, deco.type));
+               }
+               else if (len || height >= relevantWidgetHeight$3) {
+                   this.addLineDeco(height, len);
+               }
+           }
+           else if (to > from) {
+               this.span(from, to);
+           }
+           if (this.lineEnd > -1 && this.lineEnd < this.pos)
+               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
+       }
+       enterLine() {
+           if (this.lineStart > -1)
+               return;
+           let { from, to } = this.oracle.doc.lineAt(this.pos);
+           this.lineStart = from;
+           this.lineEnd = to;
+           if (this.writtenTo < from) {
+               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
+                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
+               this.nodes.push(null);
+           }
+           if (this.pos > from)
+               this.nodes.push(new HeightMapText$3(this.pos - from, -1));
+           this.writtenTo = this.pos;
+       }
+       blankContent(from, to) {
+           let gap = new HeightMapGap$3(to - from);
+           if (this.oracle.doc.lineAt(from).to == to)
+               gap.flags |= 4 /* SingleLine */;
+           return gap;
+       }
+       ensureLine() {
+           this.enterLine();
+           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
+           if (last instanceof HeightMapText$3)
+               return last;
+           let line = new HeightMapText$3(0, -1);
+           this.nodes.push(line);
+           return line;
+       }
+       addBlock(block) {
+           this.enterLine();
+           if (block.type == BlockType$3.WidgetAfter && !this.isCovered)
+               this.ensureLine();
+           this.nodes.push(block);
+           this.writtenTo = this.pos = this.pos + block.length;
+           if (block.type != BlockType$3.WidgetBefore)
+               this.covering = block;
+       }
+       addLineDeco(height, length) {
+           let line = this.ensureLine();
+           line.length += length;
+           line.collapsed += length;
+           line.widgetHeight = Math.max(line.widgetHeight, height);
+           this.writtenTo = this.pos = this.pos + length;
+       }
+       finish(from) {
+           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
+           if (this.lineStart > -1 && !(last instanceof HeightMapText$3) && !this.isCovered)
+               this.nodes.push(new HeightMapText$3(0, -1));
+           else if (this.writtenTo < this.pos || last == null)
+               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
+           let pos = from;
+           for (let node of this.nodes) {
+               if (node instanceof HeightMapText$3)
+                   node.updateHeight(this.oracle, pos);
+               pos += node ? node.length : 1;
+           }
+           return this.nodes;
+       }
+       // Always called with a region that on both sides either stretches
+       // to a line break or the end of the document.
+       // The returned array uses null to indicate line breaks, but never
+       // starts or ends in a line break, or has multiple line breaks next
+       // to each other.
+       static build(oracle, decorations, from, to) {
+           let builder = new NodeBuilder(from, oracle);
+           RangeSet$3.spans(decorations, from, to, builder, 0);
+           return builder.finish(from);
+       }
+   };
+   function heightRelevantDecoChanges$3(a, b, diff) {
+       let comp = new DecorationComparator$4;
+       RangeSet$3.compare(a, b, diff, comp, 0);
+       return comp.changes;
+   }
+   let DecorationComparator$4 = class DecorationComparator {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange() { }
+       comparePoint(from, to, a, b) {
+           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
+               addRange$3(from, to, this.changes, 5);
+       }
+   };
+
+   function visiblePixelRange$3(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       let left = Math.max(0, rect.left), right = Math.min(innerWidth, rect.right);
+       let top = Math.max(0, rect.top), bottom = Math.min(innerHeight, rect.bottom);
+       let body = dom.ownerDocument.body;
+       for (let parent = dom.parentNode; parent && parent != body;) {
+           if (parent.nodeType == 1) {
+               let elt = parent;
+               let style = window.getComputedStyle(elt);
+               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
+                   style.overflow != "visible") {
+                   let parentRect = elt.getBoundingClientRect();
+                   left = Math.max(left, parentRect.left);
+                   right = Math.min(right, parentRect.right);
+                   top = Math.max(top, parentRect.top);
+                   bottom = Math.min(bottom, parentRect.bottom);
+               }
+               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
+           }
+           else if (parent.nodeType == 11) { // Shadow root
+               parent = parent.host;
+           }
+           else {
+               break;
+           }
+       }
+       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
+           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
+   }
+   function fullPixelRange$3(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       return { left: 0, right: rect.right - rect.left,
+           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
+   }
+   // Line gaps are placeholder widgets used to hide pieces of overlong
+   // lines within the viewport, as a kludge to keep the editor
+   // responsive when a ridiculously long line is loaded into it.
+   let LineGap$3 = class LineGap {
+       constructor(from, to, size) {
+           this.from = from;
+           this.to = to;
+           this.size = size;
+       }
+       static same(a, b) {
+           if (a.length != b.length)
+               return false;
+           for (let i = 0; i < a.length; i++) {
+               let gA = a[i], gB = b[i];
+               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
+                   return false;
+           }
+           return true;
+       }
+       draw(wrapping) {
+           return Decoration$3.replace({ widget: new LineGapWidget$3(this.size, wrapping) }).range(this.from, this.to);
+       }
+   };
+   let LineGapWidget$3 = class LineGapWidget extends WidgetType$3 {
+       constructor(size, vertical) {
+           super();
+           this.size = size;
+           this.vertical = vertical;
+       }
+       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
+       toDOM() {
+           let elt = document.createElement("div");
+           if (this.vertical) {
+               elt.style.height = this.size + "px";
+           }
+           else {
+               elt.style.width = this.size + "px";
+               elt.style.height = "2px";
+               elt.style.display = "inline-block";
+           }
+           return elt;
+       }
+       get estimatedHeight() { return this.vertical ? this.size : -1; }
+   };
+   let ViewState$3 = class ViewState {
+       constructor(state) {
+           this.state = state;
+           // These are contentDOM-local coordinates
+           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
+           this.inView = true;
+           this.paddingTop = 0;
+           this.paddingBottom = 0;
+           this.contentDOMWidth = 0;
+           this.contentDOMHeight = 0;
+           this.editorHeight = 0;
+           this.editorWidth = 0;
+           this.heightOracle = new HeightOracle$3;
+           // See VP.MaxDOMHeight
+           this.scaler = IdScaler$3;
+           this.scrollTarget = null;
+           // Briefly set to true when printing, to disable viewport limiting
+           this.printing = false;
+           // Flag set when editor content was redrawn, so that the next
+           // measure stage knows it must read DOM layout
+           this.mustMeasureContent = true;
+           this.defaultTextDirection = Direction$3.RTL;
+           this.visibleRanges = [];
+           // Cursor 'assoc' is only significant when the cursor is on a line
+           // wrap point, where it must stick to the character that it is
+           // associated with. Since browsers don't provide a reasonable
+           // interface to set or query this, when a selection is set that
+           // might cause this to be significant, this flag is set. The next
+           // measure phase will check whether the cursor is on a line-wrapping
+           // boundary and, if so, reset it to make sure it is positioned in
+           // the right place.
+           this.mustEnforceCursorAssoc = false;
+           this.stateDeco = state.facet(decorations$3).filter(d => typeof d != "function");
+           this.heightMap = HeightMap$3.empty().applyChanges(this.stateDeco, Text$3.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange$3(0, 0, 0, state.doc.length)]);
+           this.viewport = this.getViewport(0, null);
+           this.updateViewportLines();
+           this.updateForViewport();
+           this.lineGaps = this.ensureLineGaps([]);
+           this.lineGapDeco = Decoration$3.set(this.lineGaps.map(gap => gap.draw(false)));
+           this.computeVisibleRanges();
+       }
+       updateForViewport() {
+           let viewports = [this.viewport], { main } = this.state.selection;
+           for (let i = 0; i <= 1; i++) {
+               let pos = i ? main.head : main.anchor;
+               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
+                   let { from, to } = this.lineBlockAt(pos);
+                   viewports.push(new Viewport$3(from, to));
+               }
+           }
+           this.viewports = viewports.sort((a, b) => a.from - b.from);
+           this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler$3 :
+               new BigScaler$3(this.heightOracle.doc, this.heightMap, this.viewports);
+       }
+       updateViewportLines() {
+           this.viewportLines = [];
+           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, block => {
+               this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock$3(block, this.scaler));
+           });
+       }
+       update(update, scrollTarget = null) {
+           this.state = update.state;
+           let prevDeco = this.stateDeco;
+           this.stateDeco = this.state.facet(decorations$3).filter(d => typeof d != "function");
+           let contentChanges = update.changedRanges;
+           let heightChanges = ChangedRange$3.extendWithRanges(contentChanges, heightRelevantDecoChanges$3(prevDeco, this.stateDeco, update ? update.changes : ChangeSet$3.empty(this.state.doc.length)));
+           let prevHeight = this.heightMap.height;
+           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
+           if (this.heightMap.height != prevHeight)
+               update.flags |= 2 /* Height */;
+           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
+           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
+               !this.viewportIsAppropriate(viewport))
+               viewport = this.getViewport(0, scrollTarget);
+           let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
+               viewport.from != this.viewport.from || viewport.to != this.viewport.to;
+           this.viewport = viewport;
+           this.updateForViewport();
+           if (updateLines)
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
+               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
+           update.flags |= this.computeVisibleRanges();
+           if (scrollTarget)
+               this.scrollTarget = scrollTarget;
+           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
+               update.state.selection.main.empty && update.state.selection.main.assoc)
+               this.mustEnforceCursorAssoc = true;
+       }
+       measure(view) {
+           let dom = view.contentDOM, style = window.getComputedStyle(dom);
+           let oracle = this.heightOracle;
+           let whiteSpace = style.whiteSpace;
+           this.defaultTextDirection = style.direction == "rtl" ? Direction$3.RTL : Direction$3.LTR;
+           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
+           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
+           this.contentDOMHeight = dom.clientHeight;
+           this.mustMeasureContent = false;
+           let result = 0, bias = 0;
+           // Vertical padding
+           let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
+           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
+               this.paddingTop = paddingTop;
+               this.paddingBottom = paddingBottom;
+               result |= 8 /* Geometry */ | 2 /* Height */;
+           }
+           if (this.editorWidth != view.scrollDOM.clientWidth) {
+               if (oracle.lineWrapping)
+                   measureContent = true;
+               this.editorWidth = view.scrollDOM.clientWidth;
+               result |= 8 /* Geometry */;
+           }
+           // Pixel viewport
+           let pixelViewport = (this.printing ? fullPixelRange$3 : visiblePixelRange$3)(dom, this.paddingTop);
+           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
+           this.pixelViewport = pixelViewport;
+           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
+           if (inView != this.inView) {
+               this.inView = inView;
+               if (inView)
+                   measureContent = true;
+           }
+           if (!this.inView)
+               return 0;
+           let contentWidth = dom.clientWidth;
+           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
+               this.contentDOMWidth = contentWidth;
+               this.editorHeight = view.scrollDOM.clientHeight;
+               result |= 8 /* Geometry */;
+           }
+           if (measureContent) {
+               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
+               if (oracle.mustRefreshForHeights(lineHeights))
+                   refresh = true;
+               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
+                   let { lineHeight, charWidth } = view.docView.measureTextSize();
+                   refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
+                   if (refresh) {
+                       view.docView.minWidth = 0;
+                       result |= 8 /* Geometry */;
+                   }
+               }
+               if (dTop > 0 && dBottom > 0)
+                   bias = Math.max(dTop, dBottom);
+               else if (dTop < 0 && dBottom < 0)
+                   bias = Math.min(dTop, dBottom);
+               oracle.heightChanged = false;
+               for (let vp of this.viewports) {
+                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
+                   this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights$3(vp.from, heights));
+               }
+               if (oracle.heightChanged)
+                   result |= 2 /* Height */;
+           }
+           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
+               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
+           if (viewportChange)
+               this.viewport = this.getViewport(bias, this.scrollTarget);
+           this.updateForViewport();
+           if ((result & 2 /* Height */) || viewportChange)
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
+               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
+           result |= this.computeVisibleRanges();
+           if (this.mustEnforceCursorAssoc) {
+               this.mustEnforceCursorAssoc = false;
+               // This is done in the read stage, because moving the selection
+               // to a line end is going to trigger a layout anyway, so it
+               // can't be a pure write. It should be rare that it does any
+               // writing.
+               view.docView.enforceCursorAssoc();
+           }
+           return result;
+       }
+       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
+       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
+       getViewport(bias, scrollTarget) {
+           // This will divide VP.Margin between the top and the
+           // bottom, depending on the bias (the change in viewport position
+           // since the last update). It'll hold a number between 0 and 1
+           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
+           let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
+           let viewport = new Viewport$3(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType$4.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType$4.ByHeight, doc, 0, 0).to);
+           // If scrollTarget is given, make sure the viewport includes that position
+           if (scrollTarget) {
+               let { head } = scrollTarget.range;
+               if (head < viewport.from || head > viewport.to) {
+                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
+                   let block = map.lineAt(head, QueryType$4.ByPos, doc, 0, 0), topPos;
+                   if (scrollTarget.y == "center")
+                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
+                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
+                       topPos = block.top;
+                   else
+                       topPos = block.bottom - viewHeight;
+                   viewport = new Viewport$3(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType$4.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType$4.ByHeight, doc, 0, 0).to);
+               }
+           }
+           return viewport;
+       }
+       mapViewport(viewport, changes) {
+           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
+           return new Viewport$3(this.heightMap.lineAt(from, QueryType$4.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType$4.ByPos, this.state.doc, 0, 0).to);
+       }
+       // Checks if a given viewport covers the visible part of the
+       // document and not too much beyond that.
+       viewportIsAppropriate({ from, to }, bias = 0) {
+           if (!this.inView)
+               return true;
+           let { top } = this.heightMap.lineAt(from, QueryType$4.ByPos, this.state.doc, 0, 0);
+           let { bottom } = this.heightMap.lineAt(to, QueryType$4.ByPos, this.state.doc, 0, 0);
+           let { visibleTop, visibleBottom } = this;
+           return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
+               (to == this.state.doc.length ||
+                   bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
+               (top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
+       }
+       mapLineGaps(gaps, changes) {
+           if (!gaps.length || changes.empty)
+               return gaps;
+           let mapped = [];
+           for (let gap of gaps)
+               if (!changes.touchesRange(gap.from, gap.to))
+                   mapped.push(new LineGap$3(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));
+           return mapped;
+       }
+       // Computes positions in the viewport where the start or end of a
+       // line should be hidden, trying to reuse existing line gaps when
+       // appropriate to avoid unneccesary redraws.
+       // Uses crude character-counting for the positioning and sizing,
+       // since actual DOM coordinates aren't always available and
+       // predictable. Relies on generous margins (see LG.Margin) to hide
+       // the artifacts this might produce from the user.
+       ensureLineGaps(current) {
+           let gaps = [];
+           // This won't work at all in predominantly right-to-left text.
+           if (this.defaultTextDirection != Direction$3.LTR)
+               return gaps;
+           for (let line of this.viewportLines) {
+               if (line.length < 4000 /* DoubleMargin */)
+                   continue;
+               let structure = lineStructure$3(line.from, line.to, this.stateDeco);
+               if (structure.total < 4000 /* DoubleMargin */)
+                   continue;
+               let viewFrom, viewTo;
+               if (this.heightOracle.lineWrapping) {
+                   let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
+                   viewFrom = findPosition$3(structure, (this.visibleTop - line.top - marginHeight) / line.height);
+                   viewTo = findPosition$3(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
+               }
+               else {
+                   let totalWidth = structure.total * this.heightOracle.charWidth;
+                   let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
+                   viewFrom = findPosition$3(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
+                   viewTo = findPosition$3(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
+               }
+               let outside = [];
+               if (viewFrom > line.from)
+                   outside.push({ from: line.from, to: viewFrom });
+               if (viewTo < line.to)
+                   outside.push({ from: viewTo, to: line.to });
+               let sel = this.state.selection.main;
+               // Make sure the gaps don't cover a selection end
+               if (sel.from >= line.from && sel.from <= line.to)
+                   cutRange$2(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
+               if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
+                   cutRange$2(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
+               for (let { from, to } of outside)
+                   if (to - from > 1000 /* HalfMargin */) {
+                       gaps.push(find$3(current, gap => gap.from >= line.from && gap.to <= line.to &&
+                           Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
+                           new LineGap$3(from, to, this.gapSize(line, from, to, structure)));
+                   }
+           }
+           return gaps;
+       }
+       gapSize(line, from, to, structure) {
+           let fraction = findFraction$3(structure, to) - findFraction$3(structure, from);
+           if (this.heightOracle.lineWrapping) {
+               return line.height * fraction;
+           }
+           else {
+               return structure.total * this.heightOracle.charWidth * fraction;
+           }
+       }
+       updateLineGaps(gaps) {
+           if (!LineGap$3.same(gaps, this.lineGaps)) {
+               this.lineGaps = gaps;
+               this.lineGapDeco = Decoration$3.set(gaps.map(gap => gap.draw(this.heightOracle.lineWrapping)));
+           }
+       }
+       computeVisibleRanges() {
+           let deco = this.stateDeco;
+           if (this.lineGaps.length)
+               deco = deco.concat(this.lineGapDeco);
+           let ranges = [];
+           RangeSet$3.spans(deco, this.viewport.from, this.viewport.to, {
+               span(from, to) { ranges.push({ from, to }); },
+               point() { }
+           }, 20);
+           let changed = ranges.length != this.visibleRanges.length ||
+               this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
+           this.visibleRanges = ranges;
+           return changed ? 4 /* Viewport */ : 0;
+       }
+       lineBlockAt(pos) {
+           return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
+               scaleBlock$3(this.heightMap.lineAt(pos, QueryType$4.ByPos, this.state.doc, 0, 0), this.scaler);
+       }
+       lineBlockAtHeight(height) {
+           return scaleBlock$3(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$4.ByHeight, this.state.doc, 0, 0), this.scaler);
+       }
+       elementAtHeight(height) {
+           return scaleBlock$3(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
+       }
+       get docHeight() {
+           return this.scaler.toDOM(this.heightMap.height);
+       }
+       get contentHeight() {
+           return this.docHeight + this.paddingTop + this.paddingBottom;
+       }
+   };
+   let Viewport$3 = class Viewport {
+       constructor(from, to) {
+           this.from = from;
+           this.to = to;
+       }
+   };
+   function lineStructure$3(from, to, stateDeco) {
+       let ranges = [], pos = from, total = 0;
+       RangeSet$3.spans(stateDeco, from, to, {
+           span() { },
+           point(from, to) {
+               if (from > pos) {
+                   ranges.push({ from: pos, to: from });
+                   total += from - pos;
+               }
+               pos = to;
+           }
+       }, 20); // We're only interested in collapsed ranges of a significant size
+       if (pos < to) {
+           ranges.push({ from: pos, to });
+           total += to - pos;
+       }
+       return { total, ranges };
+   }
+   function findPosition$3({ total, ranges }, ratio) {
+       if (ratio <= 0)
+           return ranges[0].from;
+       if (ratio >= 1)
+           return ranges[ranges.length - 1].to;
+       let dist = Math.floor(total * ratio);
+       for (let i = 0;; i++) {
+           let { from, to } = ranges[i], size = to - from;
+           if (dist <= size)
+               return from + dist;
+           dist -= size;
+       }
+   }
+   function findFraction$3(structure, pos) {
+       let counted = 0;
+       for (let { from, to } of structure.ranges) {
+           if (pos <= to) {
+               counted += pos - from;
+               break;
+           }
+           counted += to - from;
+       }
+       return counted / structure.total;
+   }
+   function cutRange$2(ranges, from, to) {
+       for (let i = 0; i < ranges.length; i++) {
+           let r = ranges[i];
+           if (r.from < to && r.to > from) {
+               let pieces = [];
+               if (r.from < from)
+                   pieces.push({ from: r.from, to: from });
+               if (r.to > to)
+                   pieces.push({ from: to, to: r.to });
+               ranges.splice(i, 1, ...pieces);
+               i += pieces.length - 1;
+           }
+       }
+   }
+   function find$3(array, f) {
+       for (let val of array)
+           if (f(val))
+               return val;
+       return undefined;
+   }
+   // Don't scale when the document height is within the range of what
+   // the DOM can handle.
+   const IdScaler$3 = {
+       toDOM(n) { return n; },
+       fromDOM(n) { return n; },
+       scale: 1
+   };
+   // When the height is too big (> VP.MaxDOMHeight), scale down the
+   // regions outside the viewports so that the total height is
+   // VP.MaxDOMHeight.
+   let BigScaler$3 = class BigScaler {
+       constructor(doc, heightMap, viewports) {
+           let vpHeight = 0, base = 0, domBase = 0;
+           this.viewports = viewports.map(({ from, to }) => {
+               let top = heightMap.lineAt(from, QueryType$4.ByPos, doc, 0, 0).top;
+               let bottom = heightMap.lineAt(to, QueryType$4.ByPos, doc, 0, 0).bottom;
+               vpHeight += bottom - top;
+               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
+           });
+           this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
+           for (let obj of this.viewports) {
+               obj.domTop = domBase + (obj.top - base) * this.scale;
+               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
+               base = obj.bottom;
+           }
+       }
+       toDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.top)
+                   return domBase + (n - base) * this.scale;
+               if (n <= vp.bottom)
+                   return vp.domTop + (n - vp.top);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+       fromDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.domTop)
+                   return base + (n - domBase) / this.scale;
+               if (n <= vp.domBottom)
+                   return vp.top + (n - vp.domTop);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+   };
+   function scaleBlock$3(block, scaler) {
+       if (scaler.scale == 1)
+           return block;
+       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
+       return new BlockInfo$3(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock$3(b, scaler)) : block.type);
+   }
+
+   const theme$3 = /*@__PURE__*/Facet$3.define({ combine: strs => strs.join(" ") });
+   const darkTheme$3 = /*@__PURE__*/Facet$3.define({ combine: values => values.indexOf(true) > -1 });
+   const baseThemeID$3 = /*@__PURE__*/StyleModule.newName(), baseLightID$3 = /*@__PURE__*/StyleModule.newName(), baseDarkID$3 = /*@__PURE__*/StyleModule.newName();
+   const lightDarkIDs$3 = { "&light": "." + baseLightID$3, "&dark": "." + baseDarkID$3 };
+   function buildTheme$3(main, spec, scopes) {
+       return new StyleModule(spec, {
+           finish(sel) {
+               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
+                   if (m == "&")
+                       return main;
+                   if (!scopes || !scopes[m])
+                       throw new RangeError(`Unsupported selector: ${m}`);
+                   return scopes[m];
+               }) : main + " " + sel;
+           }
+       });
+   }
+   const baseTheme$1$5 = /*@__PURE__*/buildTheme$3("." + baseThemeID$3, {
+       "&.cm-editor": {
+           position: "relative !important",
+           boxSizing: "border-box",
+           "&.cm-focused": {
+               // Provide a simple default outline to make sure a focused
+               // editor is visually distinct. Can't leave the default behavior
+               // because that will apply to the content element, which is
+               // inside the scrollable container and doesn't include the
+               // gutters. We also can't use an 'auto' outline, since those
+               // are, for some reason, drawn behind the element content, which
+               // will cause things like the active line background to cover
+               // the outline (#297).
+               outline: "1px dotted #212121"
+           },
+           display: "flex !important",
+           flexDirection: "column"
+       },
+       ".cm-scroller": {
+           display: "flex !important",
+           alignItems: "flex-start !important",
+           fontFamily: "monospace",
+           lineHeight: 1.4,
+           height: "100%",
+           overflowX: "auto",
+           position: "relative",
+           zIndex: 0
+       },
+       ".cm-content": {
+           margin: 0,
+           flexGrow: 2,
+           minHeight: "100%",
+           display: "block",
+           whiteSpace: "pre",
+           wordWrap: "normal",
+           boxSizing: "border-box",
+           padding: "4px 0",
+           outline: "none",
+           "&[contenteditable=true]": {
+               WebkitUserModify: "read-write-plaintext-only",
+           }
+       },
+       ".cm-lineWrapping": {
+           whiteSpace_fallback: "pre-wrap",
+           whiteSpace: "break-spaces",
+           wordBreak: "break-word",
+           overflowWrap: "anywhere"
+       },
+       "&light .cm-content": { caretColor: "black" },
+       "&dark .cm-content": { caretColor: "white" },
+       ".cm-line": {
+           display: "block",
+           padding: "0 2px 0 4px"
+       },
+       ".cm-selectionLayer": {
+           zIndex: -1,
+           contain: "size style"
+       },
+       ".cm-selectionBackground": {
+           position: "absolute",
+       },
+       "&light .cm-selectionBackground": {
+           background: "#d9d9d9"
+       },
+       "&dark .cm-selectionBackground": {
+           background: "#222"
+       },
+       "&light.cm-focused .cm-selectionBackground": {
+           background: "#d7d4f0"
+       },
+       "&dark.cm-focused .cm-selectionBackground": {
+           background: "#233"
+       },
+       ".cm-cursorLayer": {
+           zIndex: 100,
+           contain: "size style",
+           pointerEvents: "none"
+       },
+       "&.cm-focused .cm-cursorLayer": {
+           animation: "steps(1) cm-blink 1.2s infinite"
+       },
+       // Two animations defined so that we can switch between them to
+       // restart the animation without forcing another style
+       // recomputation.
+       "@keyframes cm-blink": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
+       "@keyframes cm-blink2": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
+       ".cm-cursor, .cm-dropCursor": {
+           position: "absolute",
+           borderLeft: "1.2px solid black",
+           marginLeft: "-0.6px",
+           pointerEvents: "none",
+       },
+       ".cm-cursor": {
+           display: "none"
+       },
+       "&dark .cm-cursor": {
+           borderLeftColor: "#444"
+       },
+       "&.cm-focused .cm-cursor": {
+           display: "block"
+       },
+       "&light .cm-activeLine": { backgroundColor: "#f3f9ff" },
+       "&dark .cm-activeLine": { backgroundColor: "#223039" },
+       "&light .cm-specialChar": { color: "red" },
+       "&dark .cm-specialChar": { color: "#f78" },
+       ".cm-gutters": {
+           display: "flex",
+           height: "100%",
+           boxSizing: "border-box",
+           left: 0,
+           zIndex: 200
+       },
+       "&light .cm-gutters": {
+           backgroundColor: "#f5f5f5",
+           color: "#6c6c6c",
+           borderRight: "1px solid #ddd"
+       },
+       "&dark .cm-gutters": {
+           backgroundColor: "#333338",
+           color: "#ccc"
+       },
+       ".cm-gutter": {
+           display: "flex !important",
+           flexDirection: "column",
+           flexShrink: 0,
+           boxSizing: "border-box",
+           minHeight: "100%",
+           overflow: "hidden"
+       },
+       ".cm-gutterElement": {
+           boxSizing: "border-box"
+       },
+       ".cm-lineNumbers .cm-gutterElement": {
+           padding: "0 3px 0 5px",
+           minWidth: "20px",
+           textAlign: "right",
+           whiteSpace: "nowrap"
+       },
+       "&light .cm-activeLineGutter": {
+           backgroundColor: "#e2f2ff"
+       },
+       "&dark .cm-activeLineGutter": {
+           backgroundColor: "#222227"
+       },
+       ".cm-panels": {
+           boxSizing: "border-box",
+           position: "sticky",
+           left: 0,
+           right: 0
+       },
+       "&light .cm-panels": {
+           backgroundColor: "#f5f5f5",
+           color: "black"
+       },
+       "&light .cm-panels-top": {
+           borderBottom: "1px solid #ddd"
+       },
+       "&light .cm-panels-bottom": {
+           borderTop: "1px solid #ddd"
+       },
+       "&dark .cm-panels": {
+           backgroundColor: "#333338",
+           color: "white"
+       },
+       ".cm-tab": {
+           display: "inline-block",
+           overflow: "hidden",
+           verticalAlign: "bottom"
+       },
+       ".cm-widgetBuffer": {
+           verticalAlign: "text-top",
+           height: "1em",
+           display: "inline"
+       },
+       ".cm-placeholder": {
+           color: "#888",
+           display: "inline-block",
+           verticalAlign: "top",
+       },
+       ".cm-button": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           padding: ".2em 1em",
+           borderRadius: "1px"
+       },
+       "&light .cm-button": {
+           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
+           }
+       },
+       "&dark .cm-button": {
+           backgroundImage: "linear-gradient(#393939, #111)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#111, #333)"
+           }
+       },
+       ".cm-textfield": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           border: "1px solid silver",
+           padding: ".2em .5em"
+       },
+       "&light .cm-textfield": {
+           backgroundColor: "white"
+       },
+       "&dark .cm-textfield": {
+           border: "1px solid #555",
+           backgroundColor: "inherit"
+       }
+   }, lightDarkIDs$3);
+
+   const observeOptions$3 = {
+       childList: true,
+       characterData: true,
+       subtree: true,
+       attributes: true,
+       characterDataOldValue: true
+   };
+   // IE11 has very broken mutation observers, so we also listen to
+   // DOMCharacterDataModified there
+   const useCharData$3 = browser$3.ie && browser$3.ie_version <= 11;
+   let DOMObserver$3 = class DOMObserver {
+       constructor(view, onChange, onScrollChanged) {
+           this.view = view;
+           this.onChange = onChange;
+           this.onScrollChanged = onScrollChanged;
+           this.active = false;
+           // The known selection. Kept in our own object, as opposed to just
+           // directly accessing the selection because:
+           //  - Safari doesn't report the right selection in shadow DOM
+           //  - Reading from the selection forces a DOM layout
+           //  - This way, we can ignore selectionchange events if we have
+           //    already seen the 'new' selection
+           this.selectionRange = new DOMSelectionState$3;
+           // Set when a selection change is detected, cleared on flush
+           this.selectionChanged = false;
+           this.delayedFlush = -1;
+           this.resizeTimeout = -1;
+           this.queue = [];
+           this.delayedAndroidKey = null;
+           this.scrollTargets = [];
+           this.intersection = null;
+           this.resize = null;
+           this.intersecting = false;
+           this.gapIntersection = null;
+           this.gaps = [];
+           // Timeout for scheduling check of the parents that need scroll handlers
+           this.parentCheck = -1;
+           this.dom = view.contentDOM;
+           this.observer = new MutationObserver(mutations => {
+               for (let mut of mutations)
+                   this.queue.push(mut);
+               // IE11 will sometimes (on typing over a selection or
+               // backspacing out a single character text node) call the
+               // observer callback before actually updating the DOM.
+               //
+               // Unrelatedly, iOS Safari will, when ending a composition,
+               // sometimes first clear it, deliver the mutations, and then
+               // reinsert the finished text. CodeMirror's handling of the
+               // deletion will prevent the reinsertion from happening,
+               // breaking composition.
+               if ((browser$3.ie && browser$3.ie_version <= 11 || browser$3.ios && view.composing) &&
+                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
+                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
+                   this.flushSoon();
+               else
+                   this.flush();
+           });
+           if (useCharData$3)
+               this.onCharData = (event) => {
+                   this.queue.push({ target: event.target,
+                       type: "characterData",
+                       oldValue: event.prevValue });
+                   this.flushSoon();
+               };
+           this.onSelectionChange = this.onSelectionChange.bind(this);
+           window.addEventListener("resize", this.onResize = this.onResize.bind(this));
+           if (typeof ResizeObserver == "function") {
+               this.resize = new ResizeObserver(() => {
+                   if (this.view.docView.lastUpdate < Date.now() - 75)
+                       this.onResize();
+               });
+               this.resize.observe(view.scrollDOM);
+           }
+           window.addEventListener("beforeprint", this.onPrint = this.onPrint.bind(this));
+           this.start();
+           window.addEventListener("scroll", this.onScroll = this.onScroll.bind(this));
+           if (typeof IntersectionObserver == "function") {
+               this.intersection = new IntersectionObserver(entries => {
+                   if (this.parentCheck < 0)
+                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
+                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
+                       this.intersecting = !this.intersecting;
+                       if (this.intersecting != this.view.inView)
+                           this.onScrollChanged(document.createEvent("Event"));
+                   }
+               }, {});
+               this.intersection.observe(this.dom);
+               this.gapIntersection = new IntersectionObserver(entries => {
+                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
+                       this.onScrollChanged(document.createEvent("Event"));
+               }, {});
+           }
+           this.listenForScroll();
+           this.readSelectionRange();
+           this.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
+       }
+       onScroll(e) {
+           if (this.intersecting)
+               this.flush(false);
+           this.onScrollChanged(e);
+       }
+       onResize() {
+           if (this.resizeTimeout < 0)
+               this.resizeTimeout = setTimeout(() => {
+                   this.resizeTimeout = -1;
+                   this.view.requestMeasure();
+               }, 50);
+       }
+       onPrint() {
+           this.view.viewState.printing = true;
+           this.view.measure();
+           setTimeout(() => {
+               this.view.viewState.printing = false;
+               this.view.requestMeasure();
+           }, 500);
+       }
+       updateGaps(gaps) {
+           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
+               this.gapIntersection.disconnect();
+               for (let gap of gaps)
+                   this.gapIntersection.observe(gap);
+               this.gaps = gaps;
+           }
+       }
+       onSelectionChange(event) {
+           if (!this.readSelectionRange() || this.delayedAndroidKey)
+               return;
+           let { view } = this, sel = this.selectionRange;
+           if (view.state.facet(editable$3) ? view.root.activeElement != this.dom : !hasSelection$3(view.dom, sel))
+               return;
+           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
+           if (context && context.ignoreEvent(event))
+               return;
+           // Deletions on IE11 fire their events in the wrong order, giving
+           // us a selection change event before the DOM changes are
+           // reported.
+           // Chrome Android has a similar issue when backspacing out a
+           // selection (#645).
+           if ((browser$3.ie && browser$3.ie_version <= 11 || browser$3.android && browser$3.chrome) && !view.state.selection.main.empty &&
+               // (Selection.isCollapsed isn't reliable on IE)
+               sel.focusNode && isEquivalentPosition$3(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
+               this.flushSoon();
+           else
+               this.flush(false);
+       }
+       readSelectionRange() {
+           let { root } = this.view, domSel = getSelection$3(root);
+           // The Selection object is broken in shadow roots in Safari. See
+           // https://github.com/codemirror/codemirror.next/issues/414
+           let range = browser$3.safari && root.nodeType == 11 && deepActiveElement$2() == this.view.contentDOM &&
+               safariSelectionRangeHack$3(this.view) || domSel;
+           if (this.selectionRange.eq(range))
+               return false;
+           this.selectionRange.setRange(range);
+           return this.selectionChanged = true;
+       }
+       setSelectionRange(anchor, head) {
+           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
+           this.selectionChanged = false;
+       }
+       clearSelectionRange() {
+           this.selectionRange.set(null, 0, null, 0);
+       }
+       listenForScroll() {
+           this.parentCheck = -1;
+           let i = 0, changed = null;
+           for (let dom = this.dom; dom;) {
+               if (dom.nodeType == 1) {
+                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
+                       i++;
+                   else if (!changed)
+                       changed = this.scrollTargets.slice(0, i);
+                   if (changed)
+                       changed.push(dom);
+                   dom = dom.assignedSlot || dom.parentNode;
+               }
+               else if (dom.nodeType == 11) { // Shadow root
+                   dom = dom.host;
+               }
+               else {
+                   break;
+               }
+           }
+           if (i < this.scrollTargets.length && !changed)
+               changed = this.scrollTargets.slice(0, i);
+           if (changed) {
+               for (let dom of this.scrollTargets)
+                   dom.removeEventListener("scroll", this.onScroll);
+               for (let dom of this.scrollTargets = changed)
+                   dom.addEventListener("scroll", this.onScroll);
+           }
+       }
+       ignore(f) {
+           if (!this.active)
+               return f();
+           try {
+               this.stop();
+               return f();
+           }
+           finally {
+               this.start();
+               this.clear();
+           }
+       }
+       start() {
+           if (this.active)
+               return;
+           this.observer.observe(this.dom, observeOptions$3);
+           if (useCharData$3)
+               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
+           this.active = true;
+       }
+       stop() {
+           if (!this.active)
+               return;
+           this.active = false;
+           this.observer.disconnect();
+           if (useCharData$3)
+               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
+       }
+       // Throw away any pending changes
+       clear() {
+           this.processRecords();
+           this.queue.length = 0;
+           this.selectionChanged = false;
+       }
+       // Chrome Android, especially in combination with GBoard, not only
+       // doesn't reliably fire regular key events, but also often
+       // surrounds the effect of enter or backspace with a bunch of
+       // composition events that, when interrupted, cause text duplication
+       // or other kinds of corruption. This hack makes the editor back off
+       // from handling DOM changes for a moment when such a key is
+       // detected (via beforeinput or keydown), and then tries to flush
+       // them or, if that has no effect, dispatches the given key.
+       delayAndroidKey(key, keyCode) {
+           if (!this.delayedAndroidKey)
+               requestAnimationFrame(() => {
+                   let key = this.delayedAndroidKey;
+                   this.delayedAndroidKey = null;
+                   this.delayedFlush = -1;
+                   if (!this.flush())
+                       dispatchKey$3(this.view.contentDOM, key.key, key.keyCode);
+               });
+           // Since backspace beforeinput is sometimes signalled spuriously,
+           // Enter always takes precedence.
+           if (!this.delayedAndroidKey || key == "Enter")
+               this.delayedAndroidKey = { key, keyCode };
+       }
+       flushSoon() {
+           if (this.delayedFlush < 0)
+               this.delayedFlush = window.setTimeout(() => { this.delayedFlush = -1; this.flush(); }, 20);
+       }
+       forceFlush() {
+           if (this.delayedFlush >= 0) {
+               window.clearTimeout(this.delayedFlush);
+               this.delayedFlush = -1;
+               this.flush();
+           }
+       }
+       processRecords() {
+           let records = this.queue;
+           for (let mut of this.observer.takeRecords())
+               records.push(mut);
+           if (records.length)
+               this.queue = [];
+           let from = -1, to = -1, typeOver = false;
+           for (let record of records) {
+               let range = this.readMutation(record);
+               if (!range)
+                   continue;
+               if (range.typeOver)
+                   typeOver = true;
+               if (from == -1) {
+                   ({ from, to } = range);
+               }
+               else {
+                   from = Math.min(range.from, from);
+                   to = Math.max(range.to, to);
+               }
+           }
+           return { from, to, typeOver };
+       }
+       // Apply pending changes, if any
+       flush(readSelection = true) {
+           // Completely hold off flushing when pending keys are set—the code
+           // managing those will make sure processRecords is called and the
+           // view is resynchronized after
+           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
+               return;
+           if (readSelection)
+               this.readSelectionRange();
+           let { from, to, typeOver } = this.processRecords();
+           let newSel = this.selectionChanged && hasSelection$3(this.dom, this.selectionRange);
+           if (from < 0 && !newSel)
+               return;
+           this.selectionChanged = false;
+           let startState = this.view.state;
+           let handled = this.onChange(from, to, typeOver);
+           // The view wasn't updated
+           if (this.view.state == startState)
+               this.view.update([]);
+           return handled;
+       }
+       readMutation(rec) {
+           let cView = this.view.docView.nearest(rec.target);
+           if (!cView || cView.ignoreMutation(rec))
+               return null;
+           cView.markDirty(rec.type == "attributes");
+           if (rec.type == "attributes")
+               cView.dirty |= 4 /* Attrs */;
+           if (rec.type == "childList") {
+               let childBefore = findChild$3(cView, rec.previousSibling || rec.target.previousSibling, -1);
+               let childAfter = findChild$3(cView, rec.nextSibling || rec.target.nextSibling, 1);
+               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
+                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
+           }
+           else if (rec.type == "characterData") {
+               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
+           }
+           else {
+               return null;
+           }
+       }
+       destroy() {
+           var _a, _b, _c;
+           this.stop();
+           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
+           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
+           (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
+           for (let dom of this.scrollTargets)
+               dom.removeEventListener("scroll", this.onScroll);
+           window.removeEventListener("scroll", this.onScroll);
+           window.removeEventListener("resize", this.onResize);
+           window.removeEventListener("beforeprint", this.onPrint);
+           this.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
+           clearTimeout(this.parentCheck);
+           clearTimeout(this.resizeTimeout);
+       }
+   };
+   function findChild$3(cView, dom, dir) {
+       while (dom) {
+           let curView = ContentView$3.get(dom);
+           if (curView && curView.parent == cView)
+               return curView;
+           let parent = dom.parentNode;
+           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
+       }
+       return null;
+   }
+   // Used to work around a Safari Selection/shadow DOM bug (#414)
+   function safariSelectionRangeHack$3(view) {
+       let found = null;
+       // Because Safari (at least in 2018-2021) doesn't provide regular
+       // access to the selection inside a shadowroot, we have to perform a
+       // ridiculous hack to get at it—using `execCommand` to trigger a
+       // `beforeInput` event so that we can read the target range from the
+       // event.
+       function read(event) {
+           event.preventDefault();
+           event.stopImmediatePropagation();
+           found = event.getTargetRanges()[0];
+       }
+       view.contentDOM.addEventListener("beforeinput", read, true);
+       document.execCommand("indent");
+       view.contentDOM.removeEventListener("beforeinput", read, true);
+       if (!found)
+           return null;
+       let anchorNode = found.startContainer, anchorOffset = found.startOffset;
+       let focusNode = found.endContainer, focusOffset = found.endOffset;
+       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
+       // Since such a range doesn't distinguish between anchor and head,
+       // use a heuristic that flips it around if its end matches the
+       // current anchor.
+       if (isEquivalentPosition$3(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
+           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
+       return { anchorNode, anchorOffset, focusNode, focusOffset };
+   }
+
+   function applyDOMChange$3(view, start, end, typeOver) {
+       let change, newSel;
+       let sel = view.state.selection.main;
+       if (start > -1) {
+           let bounds = view.docView.domBoundsAround(start, end, 0);
+           if (!bounds || view.state.readOnly)
+               return false;
+           let { from, to } = bounds;
+           let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints$3(view);
+           let reader = new DOMReader$3(selPoints, view.state);
+           reader.readRange(bounds.startDOM, bounds.endDOM);
+           let preferredPos = sel.from, preferredSide = null;
+           // Prefer anchoring to end when Backspace is pressed (or, on
+           // Android, when something was deleted)
+           if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 ||
+               browser$3.android && reader.text.length < to - from) {
+               preferredPos = sel.to;
+               preferredSide = "end";
+           }
+           let diff = findDiff$3(view.state.doc.sliceString(from, to, LineBreakPlaceholder$3), reader.text, preferredPos - from, preferredSide);
+           if (diff) {
+               // Chrome inserts two newlines when pressing shift-enter at the
+               // end of a line. This drops one of those.
+               if (browser$3.chrome && view.inputState.lastKeyCode == 13 &&
+                   diff.toB == diff.from + 2 && reader.text.slice(diff.from, diff.toB) == LineBreakPlaceholder$3 + LineBreakPlaceholder$3)
+                   diff.toB--;
+               change = { from: from + diff.from, to: from + diff.toA,
+                   insert: Text$3.of(reader.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder$3)) };
+           }
+           newSel = selectionFromPoints$3(selPoints, from);
+       }
+       else if (view.hasFocus || !view.state.facet(editable$3)) {
+           let domSel = view.observer.selectionRange;
+           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
+           let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
+               !contains$3(view.contentDOM, domSel.focusNode)
+               ? view.state.selection.main.head
+               : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
+           let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
+               !contains$3(view.contentDOM, domSel.anchorNode)
+               ? view.state.selection.main.anchor
+               : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
+           if (head != sel.head || anchor != sel.anchor)
+               newSel = EditorSelection$3.single(anchor, head);
+       }
+       if (!change && !newSel)
+           return false;
+       // Heuristic to notice typing over a selected character
+       if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
+           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
+       // If the change is inside the selection and covers most of it,
+       // assume it is a selection replace (with identical characters at
+       // the start/end not included in the diff)
+       else if (change && change.from >= sel.from && change.to <= sel.to &&
+           (change.from != sel.from || change.to != sel.to) &&
+           (sel.to - sel.from) - (change.to - change.from) <= 4)
+           change = {
+               from: sel.from, to: sel.to,
+               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
+           };
+       // Detect insert-period-on-double-space Mac behavior, and transform
+       // it into a regular space insert.
+       else if ((browser$3.mac || browser$3.android) && change && change.from == change.to && change.from == sel.head - 1 &&
+           change.insert.toString() == ".")
+           change = { from: sel.from, to: sel.to, insert: Text$3.of([" "]) };
+       if (change) {
+           let startState = view.state;
+           if (browser$3.ios && view.inputState.flushIOSKey(view))
+               return true;
+           // Android browsers don't fire reasonable key events for enter,
+           // backspace, or delete. So this detects changes that look like
+           // they're caused by those keys, and reinterprets them as key
+           // events. (Some of these keys are also handled by beforeinput
+           // events and the pendingAndroidKey mechanism, but that's not
+           // reliable in all situations.)
+           if (browser$3.android &&
+               ((change.from == sel.from && change.to == sel.to &&
+                   change.insert.length == 1 && change.insert.lines == 2 &&
+                   dispatchKey$3(view.contentDOM, "Enter", 13)) ||
+                   (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 &&
+                       dispatchKey$3(view.contentDOM, "Backspace", 8)) ||
+                   (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
+                       dispatchKey$3(view.contentDOM, "Delete", 46))))
+               return true;
+           let text = change.insert.toString();
+           if (view.state.facet(inputHandler$4).some(h => h(view, change.from, change.to, text)))
+               return true;
+           if (view.inputState.composing >= 0)
+               view.inputState.composing++;
+           let tr;
+           if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
+               (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
+               view.inputState.composing < 0) {
+               let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
+               let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
+               tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
+           }
+           else {
+               let changes = startState.changes(change);
+               let mainSel = newSel && !startState.selection.main.eq(newSel.main) && newSel.main.to <= changes.newLength
+                   ? newSel.main : undefined;
+               // Try to apply a composition change to all cursors
+               if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
+                   change.to <= sel.to && change.to >= sel.to - 10) {
+                   let replaced = view.state.sliceDoc(change.from, change.to);
+                   let compositionRange = compositionSurroundingNode$2(view) || view.state.doc.lineAt(sel.head);
+                   let offset = sel.to - change.to, size = sel.to - sel.from;
+                   tr = startState.changeByRange(range => {
+                       if (range.from == sel.from && range.to == sel.to)
+                           return { changes, range: mainSel || range.map(changes) };
+                       let to = range.to - offset, from = to - replaced.length;
+                       if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
+                           // Unfortunately, there's no way to make multiple
+                           // changes in the same node work without aborting
+                           // composition, so cursors in the composition range are
+                           // ignored.
+                           compositionRange && range.to >= compositionRange.from && range.from <= compositionRange.to)
+                           return { range };
+                       let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
+                       return {
+                           changes: rangeChanges,
+                           range: !mainSel ? range.map(rangeChanges) :
+                               EditorSelection$3.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
+                       };
+                   });
+               }
+               else {
+                   tr = {
+                       changes,
+                       selection: mainSel && startState.selection.replaceRange(mainSel)
+                   };
+               }
+           }
+           let userEvent = "input.type";
+           if (view.composing) {
+               userEvent += ".compose";
+               if (view.inputState.compositionFirstChange) {
+                   userEvent += ".start";
+                   view.inputState.compositionFirstChange = false;
+               }
+           }
+           view.dispatch(tr, { scrollIntoView: true, userEvent });
+           return true;
+       }
+       else if (newSel && !newSel.main.eq(sel)) {
+           let scrollIntoView = false, userEvent = "select";
+           if (view.inputState.lastSelectionTime > Date.now() - 50) {
+               if (view.inputState.lastSelectionOrigin == "select")
+                   scrollIntoView = true;
+               userEvent = view.inputState.lastSelectionOrigin;
+           }
+           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
+           return true;
+       }
+       else {
+           return false;
+       }
+   }
+   function findDiff$3(a, b, preferredPos, preferredSide) {
+       let minLen = Math.min(a.length, b.length);
+       let from = 0;
+       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
+           from++;
+       if (from == minLen && a.length == b.length)
+           return null;
+       let toA = a.length, toB = b.length;
+       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
+           toA--;
+           toB--;
+       }
+       if (preferredSide == "end") {
+           let adjust = Math.max(0, from - Math.min(toA, toB));
+           preferredPos -= toA + adjust - from;
+       }
+       if (toA < from && a.length < b.length) {
+           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
+           from -= move;
+           toB = from + (toB - toA);
+           toA = from;
+       }
+       else if (toB < from) {
+           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
+           from -= move;
+           toA = from + (toA - toB);
+           toB = from;
+       }
+       return { from, toA, toB };
+   }
+   function selectionPoints$3(view) {
+       let result = [];
+       if (view.root.activeElement != view.contentDOM)
+           return result;
+       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
+       if (anchorNode) {
+           result.push(new DOMPoint$3(anchorNode, anchorOffset));
+           if (focusNode != anchorNode || focusOffset != anchorOffset)
+               result.push(new DOMPoint$3(focusNode, focusOffset));
+       }
+       return result;
+   }
+   function selectionFromPoints$3(points, base) {
+       if (points.length == 0)
+           return null;
+       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
+       return anchor > -1 && head > -1 ? EditorSelection$3.single(anchor + base, head + base) : null;
+   }
+
+   // The editor's update state machine looks something like this:
+   //
+   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
+   //                                         ↑      ↓
+   //                                         Updating (measure)
+   //
+   // The difference between 'Idle' and 'Idle (unchecked)' lies in
+   // whether a layout check has been scheduled. A regular update through
+   // the `update` method updates the DOM in a write-only fashion, and
+   // relies on a check (scheduled with `requestAnimationFrame`) to make
+   // sure everything is where it should be and the viewport covers the
+   // visible code. That check continues to measure and then optionally
+   // update until it reaches a coherent state.
+   /**
+   An editor view represents the editor's user interface. It holds
+   the editable DOM surface, and possibly other elements such as the
+   line number gutter. It handles events and dispatches state
+   transactions for editing actions.
+   */
+   let EditorView$3 = class EditorView {
+       /**
+       Construct a new view. You'll want to either provide a `parent`
+       option, or put `view.dom` into your document after creating a
+       view, so that the user can see the editor.
+       */
+       constructor(
+       /**
+       Initialization options.
+       */
+       config = {}) {
+           this.plugins = [];
+           this.pluginMap = new Map;
+           this.editorAttrs = {};
+           this.contentAttrs = {};
+           this.bidiCache = [];
+           this.destroyed = false;
+           /**
+           @internal
+           */
+           this.updateState = 2 /* Updating */;
+           /**
+           @internal
+           */
+           this.measureScheduled = -1;
+           /**
+           @internal
+           */
+           this.measureRequests = [];
+           this.contentDOM = document.createElement("div");
+           this.scrollDOM = document.createElement("div");
+           this.scrollDOM.tabIndex = -1;
+           this.scrollDOM.className = "cm-scroller";
+           this.scrollDOM.appendChild(this.contentDOM);
+           this.announceDOM = document.createElement("div");
+           this.announceDOM.style.cssText = "position: absolute; top: -10000px";
+           this.announceDOM.setAttribute("aria-live", "polite");
+           this.dom = document.createElement("div");
+           this.dom.appendChild(this.announceDOM);
+           this.dom.appendChild(this.scrollDOM);
+           this._dispatch = config.dispatch || ((tr) => this.update([tr]));
+           this.dispatch = this.dispatch.bind(this);
+           this.root = (config.root || getRoot$3(config.parent) || document);
+           this.viewState = new ViewState$3(config.state || EditorState$3.create());
+           this.plugins = this.state.facet(viewPlugin$3).map(spec => new PluginInstance$3(spec));
+           for (let plugin of this.plugins)
+               plugin.update(this);
+           this.observer = new DOMObserver$3(this, (from, to, typeOver) => {
+               return applyDOMChange$3(this, from, to, typeOver);
+           }, event => {
+               this.inputState.runScrollHandlers(this, event);
+               if (this.observer.intersecting)
+                   this.measure();
+           });
+           this.inputState = new InputState$3(this);
+           this.inputState.ensureHandlers(this, this.plugins);
+           this.docView = new DocView$3(this);
+           this.mountStyles();
+           this.updateAttrs();
+           this.updateState = 0 /* Idle */;
+           this.requestMeasure();
+           if (config.parent)
+               config.parent.appendChild(this.dom);
+       }
+       /**
+       The current editor state.
+       */
+       get state() { return this.viewState.state; }
+       /**
+       To be able to display large documents without consuming too much
+       memory or overloading the browser, CodeMirror only draws the
+       code that is visible (plus a margin around it) to the DOM. This
+       property tells you the extent of the current drawn viewport, in
+       document positions.
+       */
+       get viewport() { return this.viewState.viewport; }
+       /**
+       When there are, for example, large collapsed ranges in the
+       viewport, its size can be a lot bigger than the actual visible
+       content. Thus, if you are doing something like styling the
+       content in the viewport, it is preferable to only do so for
+       these ranges, which are the subset of the viewport that is
+       actually drawn.
+       */
+       get visibleRanges() { return this.viewState.visibleRanges; }
+       /**
+       Returns false when the editor is entirely scrolled out of view
+       or otherwise hidden.
+       */
+       get inView() { return this.viewState.inView; }
+       /**
+       Indicates whether the user is currently composing text via
+       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
+       one change has been made in the current composition.
+       */
+       get composing() { return this.inputState.composing > 0; }
+       /**
+       Indicates whether the user is currently in composing state. Note
+       that on some platforms, like Android, this will be the case a
+       lot, since just putting the cursor on a word starts a
+       composition there.
+       */
+       get compositionStarted() { return this.inputState.composing >= 0; }
+       dispatch(...input) {
+           this._dispatch(input.length == 1 && input[0] instanceof Transaction$3 ? input[0]
+               : this.state.update(...input));
+       }
+       /**
+       Update the view for the given array of transactions. This will
+       update the visible document and selection to match the state
+       produced by the transactions, and notify view plugins of the
+       change. You should usually call
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
+       as a primitive.
+       */
+       update(transactions) {
+           if (this.updateState != 0 /* Idle */)
+               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
+           let redrawn = false, attrsChanged = false, update;
+           let state = this.state;
+           for (let tr of transactions) {
+               if (tr.startState != state)
+                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
+               state = tr.state;
+           }
+           if (this.destroyed) {
+               this.viewState.state = state;
+               return;
+           }
+           this.observer.clear();
+           // When the phrases change, redraw the editor
+           if (state.facet(EditorState$3.phrases) != this.state.facet(EditorState$3.phrases))
+               return this.setState(state);
+           update = ViewUpdate$3.create(this, state, transactions);
+           let scrollTarget = this.viewState.scrollTarget;
+           try {
+               this.updateState = 2 /* Updating */;
+               for (let tr of transactions) {
+                   if (scrollTarget)
+                       scrollTarget = scrollTarget.map(tr.changes);
+                   if (tr.scrollIntoView) {
+                       let { main } = tr.state.selection;
+                       scrollTarget = new ScrollTarget$3(main.empty ? main : EditorSelection$3.cursor(main.head, main.head > main.anchor ? -1 : 1));
+                   }
+                   for (let e of tr.effects)
+                       if (e.is(scrollIntoView$5))
+                           scrollTarget = e.value;
+               }
+               this.viewState.update(update, scrollTarget);
+               this.bidiCache = CachedOrder$3.update(this.bidiCache, update.changes);
+               if (!update.empty) {
+                   this.updatePlugins(update);
+                   this.inputState.update(update);
+               }
+               redrawn = this.docView.update(update);
+               if (this.state.facet(styleModule$3) != this.styleModules)
+                   this.mountStyles();
+               attrsChanged = this.updateAttrs();
+               this.showAnnouncements(transactions);
+               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+           }
+           if (update.startState.facet(theme$3) != update.state.facet(theme$3))
+               this.viewState.mustMeasureContent = true;
+           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
+               this.requestMeasure();
+           if (!update.empty)
+               for (let listener of this.state.facet(updateListener$3))
+                   listener(update);
+       }
+       /**
+       Reset the view to the given state. (This will cause the entire
+       document to be redrawn and all view plugins to be reinitialized,
+       so you should probably only use it when the new state isn't
+       derived from the old state. Otherwise, use
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
+       */
+       setState(newState) {
+           if (this.updateState != 0 /* Idle */)
+               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
+           if (this.destroyed) {
+               this.viewState.state = newState;
+               return;
+           }
+           this.updateState = 2 /* Updating */;
+           let hadFocus = this.hasFocus;
+           try {
+               for (let plugin of this.plugins)
+                   plugin.destroy(this);
+               this.viewState = new ViewState$3(newState);
+               this.plugins = newState.facet(viewPlugin$3).map(spec => new PluginInstance$3(spec));
+               this.pluginMap.clear();
+               for (let plugin of this.plugins)
+                   plugin.update(this);
+               this.docView = new DocView$3(this);
+               this.inputState.ensureHandlers(this, this.plugins);
+               this.mountStyles();
+               this.updateAttrs();
+               this.bidiCache = [];
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+           }
+           if (hadFocus)
+               this.focus();
+           this.requestMeasure();
+       }
+       updatePlugins(update) {
+           let prevSpecs = update.startState.facet(viewPlugin$3), specs = update.state.facet(viewPlugin$3);
+           if (prevSpecs != specs) {
+               let newPlugins = [];
+               for (let spec of specs) {
+                   let found = prevSpecs.indexOf(spec);
+                   if (found < 0) {
+                       newPlugins.push(new PluginInstance$3(spec));
+                   }
+                   else {
+                       let plugin = this.plugins[found];
+                       plugin.mustUpdate = update;
+                       newPlugins.push(plugin);
+                   }
+               }
+               for (let plugin of this.plugins)
+                   if (plugin.mustUpdate != update)
+                       plugin.destroy(this);
+               this.plugins = newPlugins;
+               this.pluginMap.clear();
+               this.inputState.ensureHandlers(this, this.plugins);
+           }
+           else {
+               for (let p of this.plugins)
+                   p.mustUpdate = update;
+           }
+           for (let i = 0; i < this.plugins.length; i++)
+               this.plugins[i].update(this);
+       }
+       /**
+       @internal
+       */
+       measure(flush = true) {
+           if (this.destroyed)
+               return;
+           if (this.measureScheduled > -1)
+               cancelAnimationFrame(this.measureScheduled);
+           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
+           if (flush)
+               this.observer.flush();
+           let updated = null;
+           try {
+               for (let i = 0;; i++) {
+                   this.updateState = 1 /* Measuring */;
+                   let oldViewport = this.viewport;
+                   let changed = this.viewState.measure(this);
+                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
+                       break;
+                   if (i > 5) {
+                       console.warn(this.measureRequests.length
+                           ? "Measure loop restarted more than 5 times"
+                           : "Viewport failed to stabilize");
+                       break;
+                   }
+                   let measuring = [];
+                   // Only run measure requests in this cycle when the viewport didn't change
+                   if (!(changed & 4 /* Viewport */))
+                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
+                   let measured = measuring.map(m => {
+                       try {
+                           return m.read(this);
+                       }
+                       catch (e) {
+                           logException$3(this.state, e);
+                           return BadMeasure$3;
+                       }
+                   });
+                   let update = ViewUpdate$3.create(this, this.state, []), redrawn = false, scrolled = false;
+                   update.flags |= changed;
+                   if (!updated)
+                       updated = update;
+                   else
+                       updated.flags |= changed;
+                   this.updateState = 2 /* Updating */;
+                   if (!update.empty) {
+                       this.updatePlugins(update);
+                       this.inputState.update(update);
+                       this.updateAttrs();
+                       redrawn = this.docView.update(update);
+                   }
+                   for (let i = 0; i < measuring.length; i++)
+                       if (measured[i] != BadMeasure$3) {
+                           try {
+                               let m = measuring[i];
+                               if (m.write)
+                                   m.write(measured[i], this);
+                           }
+                           catch (e) {
+                               logException$3(this.state, e);
+                           }
+                       }
+                   if (this.viewState.scrollTarget) {
+                       this.docView.scrollIntoView(this.viewState.scrollTarget);
+                       this.viewState.scrollTarget = null;
+                       scrolled = true;
+                   }
+                   if (redrawn)
+                       this.docView.updateSelection(true);
+                   if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
+                       !scrolled && this.measureRequests.length == 0)
+                       break;
+               }
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+               this.measureScheduled = -1;
+           }
+           if (updated && !updated.empty)
+               for (let listener of this.state.facet(updateListener$3))
+                   listener(updated);
+       }
+       /**
+       Get the CSS classes for the currently active editor themes.
+       */
+       get themeClasses() {
+           return baseThemeID$3 + " " +
+               (this.state.facet(darkTheme$3) ? baseDarkID$3 : baseLightID$3) + " " +
+               this.state.facet(theme$3);
+       }
+       updateAttrs() {
+           let editorAttrs = attrsFromFacet$3(this, editorAttributes$3, {
+               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
+           });
+           let contentAttrs = {
+               spellcheck: "false",
+               autocorrect: "off",
+               autocapitalize: "off",
+               translate: "no",
+               contenteditable: !this.state.facet(editable$3) ? "false" : "true",
+               class: "cm-content",
+               style: `${browser$3.tabSize}: ${this.state.tabSize}`,
+               role: "textbox",
+               "aria-multiline": "true"
+           };
+           if (this.state.readOnly)
+               contentAttrs["aria-readonly"] = "true";
+           attrsFromFacet$3(this, contentAttributes$3, contentAttrs);
+           let changed = this.observer.ignore(() => {
+               let changedContent = updateAttrs$3(this.contentDOM, this.contentAttrs, contentAttrs);
+               let changedEditor = updateAttrs$3(this.dom, this.editorAttrs, editorAttrs);
+               return changedContent || changedEditor;
+           });
+           this.editorAttrs = editorAttrs;
+           this.contentAttrs = contentAttrs;
+           return changed;
+       }
+       showAnnouncements(trs) {
+           let first = true;
+           for (let tr of trs)
+               for (let effect of tr.effects)
+                   if (effect.is(EditorView.announce)) {
+                       if (first)
+                           this.announceDOM.textContent = "";
+                       first = false;
+                       let div = this.announceDOM.appendChild(document.createElement("div"));
+                       div.textContent = effect.value;
+                   }
+       }
+       mountStyles() {
+           this.styleModules = this.state.facet(styleModule$3);
+           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$5).reverse());
+       }
+       readMeasured() {
+           if (this.updateState == 2 /* Updating */)
+               throw new Error("Reading the editor layout isn't allowed during an update");
+           if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
+               this.measure(false);
+       }
+       /**
+       Schedule a layout measurement, optionally providing callbacks to
+       do custom DOM measuring followed by a DOM write phase. Using
+       this is preferable reading DOM layout directly from, for
+       example, an event handler, because it'll make sure measuring and
+       drawing done by other components is synchronized, avoiding
+       unnecessary DOM layout computations.
+       */
+       requestMeasure(request) {
+           if (this.measureScheduled < 0)
+               this.measureScheduled = requestAnimationFrame(() => this.measure());
+           if (request) {
+               if (request.key != null)
+                   for (let i = 0; i < this.measureRequests.length; i++) {
+                       if (this.measureRequests[i].key === request.key) {
+                           this.measureRequests[i] = request;
+                           return;
+                       }
+                   }
+               this.measureRequests.push(request);
+           }
+       }
+       /**
+       Get the value of a specific plugin, if present. Note that
+       plugins that crash can be dropped from a view, so even when you
+       know you registered a given plugin, it is recommended to check
+       the return value of this method.
+       */
+       plugin(plugin) {
+           let known = this.pluginMap.get(plugin);
+           if (known === undefined || known && known.spec != plugin)
+               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
+           return known && known.update(this).value;
+       }
+       /**
+       The top position of the document, in screen coordinates. This
+       may be negative when the editor is scrolled down. Points
+       directly to the top of the first line, not above the padding.
+       */
+       get documentTop() {
+           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
+       }
+       /**
+       Reports the padding above and below the document.
+       */
+       get documentPadding() {
+           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
+       }
+       /**
+       Find the text line or block widget at the given vertical
+       position (which is interpreted as relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
+       */
+       elementAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.elementAtHeight(height);
+       }
+       /**
+       Find the line block (see
+       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
+       height.
+       */
+       lineBlockAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.lineBlockAtHeight(height);
+       }
+       /**
+       Get the extent and vertical position of all [line
+       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
+       are relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
+       */
+       get viewportLineBlocks() {
+           return this.viewState.viewportLines;
+       }
+       /**
+       Find the line block around the given document position. A line
+       block is a range delimited on both sides by either a
+       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
+       start/end of the document. It will usually just hold a line of
+       text, but may be broken into multiple textblocks by block
+       widgets.
+       */
+       lineBlockAt(pos) {
+           return this.viewState.lineBlockAt(pos);
+       }
+       /**
+       The editor's total content height.
+       */
+       get contentHeight() {
+           return this.viewState.contentHeight;
+       }
+       /**
+       Move a cursor position by [grapheme
+       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
+       the motion is away from the line start, or towards it. In
+       bidirectional text, the line is traversed in visual order, using
+       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+       When the start position was the last one on the line, the
+       returned position will be across the line break. If there is no
+       further line, the original position is returned.
+       
+       By default, this method moves over a single cluster. The
+       optional `by` argument can be used to move across more. It will
+       be called with the first cluster as argument, and should return
+       a predicate that determines, for each subsequent cluster,
+       whether it should also be moved over.
+       */
+       moveByChar(start, forward, by) {
+           return skipAtoms$3(this, start, moveByChar$3(this, start, forward, by));
+       }
+       /**
+       Move a cursor position across the next group of either
+       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
+       non-whitespace characters.
+       */
+       moveByGroup(start, forward) {
+           return skipAtoms$3(this, start, moveByChar$3(this, start, forward, initial => byGroup$3(this, start.head, initial)));
+       }
+       /**
+       Move to the next line boundary in the given direction. If
+       `includeWrap` is true, line wrapping is on, and there is a
+       further wrap point on the current line, the wrap point will be
+       returned. Otherwise this function will return the start or end
+       of the line.
+       */
+       moveToLineBoundary(start, forward, includeWrap = true) {
+           return moveToLineBoundary$3(this, start, forward, includeWrap);
+       }
+       /**
+       Move a cursor position vertically. When `distance` isn't given,
+       it defaults to moving to the next line (including wrapped
+       lines). Otherwise, `distance` should provide a positive distance
+       in pixels.
+       
+       When `start` has a
+       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
+       motion will use that as a target horizontal position. Otherwise,
+       the cursor's own horizontal position is used. The returned
+       cursor will have its goal column set to whichever column was
+       used.
+       */
+       moveVertically(start, forward, distance) {
+           return skipAtoms$3(this, start, moveVertically$3(this, start, forward, distance));
+       }
+       /**
+       Find the DOM parent node and offset (child offset if `node` is
+       an element, character offset when it is a text node) at the
+       given document position.
+       
+       Note that for positions that aren't currently in
+       `visibleRanges`, the resulting DOM position isn't necessarily
+       meaningful (it may just point before or after a placeholder
+       element).
+       */
+       domAtPos(pos) {
+           return this.docView.domAtPos(pos);
+       }
+       /**
+       Find the document position at the given DOM node. Can be useful
+       for associating positions with DOM events. Will raise an error
+       when `node` isn't part of the editor content.
+       */
+       posAtDOM(node, offset = 0) {
+           return this.docView.posFromDOM(node, offset);
+       }
+       posAtCoords(coords, precise = true) {
+           this.readMeasured();
+           return posAtCoords$3(this, coords, precise);
+       }
+       /**
+       Get the screen coordinates at the given document position.
+       `side` determines whether the coordinates are based on the
+       element before (-1) or after (1) the position (if no element is
+       available on the given side, the method will transparently use
+       another strategy to get reasonable coordinates).
+       */
+       coordsAtPos(pos, side = 1) {
+           this.readMeasured();
+           let rect = this.docView.coordsAt(pos, side);
+           if (!rect || rect.left == rect.right)
+               return rect;
+           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
+           let span = order[BidiSpan$3.find(order, pos - line.from, -1, side)];
+           return flattenRect$3(rect, (span.dir == Direction$3.LTR) == (side > 0));
+       }
+       /**
+       The default width of a character in the editor. May not
+       accurately reflect the width of all characters (given variable
+       width fonts or styling of invididual ranges).
+       */
+       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
+       /**
+       The default height of a line in the editor. May not be accurate
+       for all lines.
+       */
+       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
+       /**
+       The text direction
+       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
+       CSS property) of the editor's content element.
+       */
+       get textDirection() { return this.viewState.defaultTextDirection; }
+       /**
+       Find the text direction of the block at the given position, as
+       assigned by CSS. If
+       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
+       isn't enabled, or the given position is outside of the viewport,
+       this will always return the same as
+       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
+       this may trigger a DOM layout.
+       */
+       textDirectionAt(pos) {
+           let perLine = this.state.facet(perLineTextDirection$3);
+           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
+               return this.textDirection;
+           this.readMeasured();
+           return this.docView.textDirectionAt(pos);
+       }
+       /**
+       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
+       (as determined by the
+       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
+       CSS property of its content element).
+       */
+       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
+       /**
+       Returns the bidirectional text structure of the given line
+       (which should be in the current document) as an array of span
+       objects. The order of these spans matches the [text
+       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
+       left-to-right, the leftmost spans come first, otherwise the
+       rightmost spans come first.
+       */
+       bidiSpans(line) {
+           if (line.length > MaxBidiLine$3)
+               return trivialOrder$3(line.length);
+           let dir = this.textDirectionAt(line.from);
+           for (let entry of this.bidiCache)
+               if (entry.from == line.from && entry.dir == dir)
+                   return entry.order;
+           let order = computeOrder$3(line.text, dir);
+           this.bidiCache.push(new CachedOrder$3(line.from, line.to, dir, order));
+           return order;
+       }
+       /**
+       Check whether the editor has focus.
+       */
+       get hasFocus() {
+           var _a;
+           // Safari return false for hasFocus when the context menu is open
+           // or closing, which leads us to ignore selection changes from the
+           // context menu because it looks like the editor isn't focused.
+           // This kludges around that.
+           return (document.hasFocus() || browser$3.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
+               this.root.activeElement == this.contentDOM;
+       }
+       /**
+       Put focus on the editor.
+       */
+       focus() {
+           this.observer.ignore(() => {
+               focusPreventScroll$3(this.contentDOM);
+               this.docView.updateSelection();
+           });
+       }
+       /**
+       Clean up this editor view, removing its element from the
+       document, unregistering event handlers, and notifying
+       plugins. The view instance can no longer be used after
+       calling this.
+       */
+       destroy() {
+           for (let plugin of this.plugins)
+               plugin.destroy(this);
+           this.plugins = [];
+           this.inputState.destroy();
+           this.dom.remove();
+           this.observer.destroy();
+           if (this.measureScheduled > -1)
+               cancelAnimationFrame(this.measureScheduled);
+           this.destroyed = true;
+       }
+       /**
+       Returns an effect that can be
+       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
+       cause it to scroll the given position or range into view.
+       */
+       static scrollIntoView(pos, options = {}) {
+           return scrollIntoView$5.of(new ScrollTarget$3(typeof pos == "number" ? EditorSelection$3.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
+       }
+       /**
+       Returns an extension that can be used to add DOM event handlers.
+       The value should be an object mapping event names to handler
+       functions. For any given event, such functions are ordered by
+       extension precedence, and the first handler to return true will
+       be assumed to have handled that event, and no other handlers or
+       built-in behavior will be activated for it. These are registered
+       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
+       for `scroll` handlers, which will be called any time the
+       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
+       its parent nodes is scrolled.
+       */
+       static domEventHandlers(handlers) {
+           return ViewPlugin$3.define(() => ({}), { eventHandlers: handlers });
+       }
+       /**
+       Create a theme extension. The first argument can be a
+       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
+       style spec providing the styles for the theme. These will be
+       prefixed with a generated class for the style.
+       
+       Because the selectors will be prefixed with a scope class, rule
+       that directly match the editor's [wrapper
+       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
+       added—need to be explicitly differentiated by adding an `&` to
+       the selector for that element—for example
+       `&.cm-focused`.
+       
+       When `dark` is set to true, the theme will be marked as dark,
+       which will cause the `&dark` rules from [base
+       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
+       `&light` when a light theme is active).
+       */
+       static theme(spec, options) {
+           let prefix = StyleModule.newName();
+           let result = [theme$3.of(prefix), styleModule$3.of(buildTheme$3(`.${prefix}`, spec))];
+           if (options && options.dark)
+               result.push(darkTheme$3.of(true));
+           return result;
+       }
+       /**
+       Create an extension that adds styles to the base theme. Like
+       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
+       place of the editor wrapper element when directly targeting
+       that. You can also use `&dark` or `&light` instead to only
+       target editors with a dark or light theme.
+       */
+       static baseTheme(spec) {
+           return Prec$3.lowest(styleModule$3.of(buildTheme$3("." + baseThemeID$3, spec, lightDarkIDs$3)));
+       }
+   };
+   /**
+   Facet to add a [style
+   module](https://github.com/marijnh/style-mod#documentation) to
+   an editor view. The view will ensure that the module is
+   mounted in its [document
+   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
+   */
+   EditorView$3.styleModule = styleModule$3;
+   /**
+   An input handler can override the way changes to the editable
+   DOM content are handled. Handlers are passed the document
+   positions between which the change was found, and the new
+   content. When one returns true, no further input handlers are
+   called and the default behavior is prevented.
+   */
+   EditorView$3.inputHandler = inputHandler$4;
+   /**
+   By default, the editor assumes all its content has the same
+   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
+   value to make it read the text direction of every (rendered)
+   line separately.
+   */
+   EditorView$3.perLineTextDirection = perLineTextDirection$3;
+   /**
+   Allows you to provide a function that should be called when the
+   library catches an exception from an extension (mostly from view
+   plugins, but may be used by other extensions to route exceptions
+   from user-code-provided callbacks). This is mostly useful for
+   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
+   */
+   EditorView$3.exceptionSink = exceptionSink$3;
+   /**
+   A facet that can be used to register a function to be called
+   every time the view updates.
+   */
+   EditorView$3.updateListener = updateListener$3;
+   /**
+   Facet that controls whether the editor content DOM is editable.
+   When its highest-precedence value is `false`, the element will
+   not have its `contenteditable` attribute set. (Note that this
+   doesn't affect API calls that change the editor content, even
+   when those are bound to keys or buttons. See the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
+   */
+   EditorView$3.editable = editable$3;
+   /**
+   Allows you to influence the way mouse selection happens. The
+   functions in this facet will be called for a `mousedown` event
+   on the editor, and can return an object that overrides the way a
+   selection is computed from that mouse click or drag.
+   */
+   EditorView$3.mouseSelectionStyle = mouseSelectionStyle$3;
+   /**
+   Facet used to configure whether a given selection drag event
+   should move or copy the selection. The given predicate will be
+   called with the `mousedown` event, and can return `true` when
+   the drag should move the content.
+   */
+   EditorView$3.dragMovesSelection = dragMovesSelection$1$3;
+   /**
+   Facet used to configure whether a given selecting click adds a
+   new range to the existing selection or replaces it entirely. The
+   default behavior is to check `event.metaKey` on macOS, and
+   `event.ctrlKey` elsewhere.
+   */
+   EditorView$3.clickAddsSelectionRange = clickAddsSelectionRange$3;
+   /**
+   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
+   are shown in the view. Decorations can be provided in two
+   ways—directly, or via a function that takes an editor view.
+
+   Only decoration sets provided directly are allowed to influence
+   the editor's vertical layout structure. The ones provided as
+   functions are called _after_ the new viewport has been computed,
+   and thus **must not** introduce block widgets or replacing
+   decorations that cover line breaks.
+   */
+   EditorView$3.decorations = decorations$3;
+   /**
+   Used to provide ranges that should be treated as atoms as far as
+   cursor motion is concerned. This causes methods like
+   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
+   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
+   commands built on top of them) to skip across such regions when
+   a selection endpoint would enter them. This does _not_ prevent
+   direct programmatic [selection
+   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
+   regions.
+   */
+   EditorView$3.atomicRanges = atomicRanges$3;
+   /**
+   Facet that allows extensions to provide additional scroll
+   margins (space around the sides of the scrolling element that
+   should be considered invisible). This can be useful when the
+   plugin introduces elements that cover part of that element (for
+   example a horizontally fixed gutter).
+   */
+   EditorView$3.scrollMargins = scrollMargins$3;
+   /**
+   This facet records whether a dark theme is active. The extension
+   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
+   includes an instance of this when the `dark` option is set to
+   true.
+   */
+   EditorView$3.darkTheme = darkTheme$3;
+   /**
+   Facet that provides additional DOM attributes for the editor's
+   editable DOM element.
+   */
+   EditorView$3.contentAttributes = contentAttributes$3;
+   /**
+   Facet that provides DOM attributes for the editor's outer
+   element.
+   */
+   EditorView$3.editorAttributes = editorAttributes$3;
+   /**
+   An extension that enables line wrapping in the editor (by
+   setting CSS `white-space` to `pre-wrap` in the content).
+   */
+   EditorView$3.lineWrapping = /*@__PURE__*/EditorView$3.contentAttributes.of({ "class": "cm-lineWrapping" });
+   /**
+   State effect used to include screen reader announcements in a
+   transaction. These will be added to the DOM in a visually hidden
+   element with `aria-live="polite"` set, and should be used to
+   describe effects that are visually obvious but may not be
+   noticed by screen reader users (such as moving to the next
+   search match).
+   */
+   EditorView$3.announce = /*@__PURE__*/StateEffect$3.define();
+   // Maximum line length for which we compute accurate bidi info
+   const MaxBidiLine$3 = 4096;
+   const BadMeasure$3 = {};
+   let CachedOrder$3 = class CachedOrder {
+       constructor(from, to, dir, order) {
+           this.from = from;
+           this.to = to;
+           this.dir = dir;
+           this.order = order;
+       }
+       static update(cache, changes) {
+           if (changes.empty)
+               return cache;
+           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction$3.LTR;
+           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
+               let entry = cache[i];
+               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
+                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.order));
+           }
+           return result;
+       }
+   };
+   function attrsFromFacet$3(view, facet, base) {
+       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
+           let source = sources[i], value = typeof source == "function" ? source(view) : source;
+           if (value)
+               combineAttrs$3(value, base);
+       }
+       return base;
+   }
+
+   const currentPlatform$2 = browser$3.mac ? "mac" : browser$3.windows ? "win" : browser$3.linux ? "linux" : "key";
+   function normalizeKeyName$2(name, platform) {
+       const parts = name.split(/-(?!$)/);
+       let result = parts[parts.length - 1];
+       if (result == "Space")
+           result = " ";
+       let alt, ctrl, shift, meta;
+       for (let i = 0; i < parts.length - 1; ++i) {
+           const mod = parts[i];
+           if (/^(cmd|meta|m)$/i.test(mod))
+               meta = true;
+           else if (/^a(lt)?$/i.test(mod))
+               alt = true;
+           else if (/^(c|ctrl|control)$/i.test(mod))
+               ctrl = true;
+           else if (/^s(hift)?$/i.test(mod))
+               shift = true;
+           else if (/^mod$/i.test(mod)) {
+               if (platform == "mac")
+                   meta = true;
+               else
+                   ctrl = true;
+           }
+           else
+               throw new Error("Unrecognized modifier name: " + mod);
+       }
+       if (alt)
+           result = "Alt-" + result;
+       if (ctrl)
+           result = "Ctrl-" + result;
+       if (meta)
+           result = "Meta-" + result;
+       if (shift)
+           result = "Shift-" + result;
+       return result;
+   }
+   function modifiers$2(name, event, shift) {
+       if (event.altKey)
+           name = "Alt-" + name;
+       if (event.ctrlKey)
+           name = "Ctrl-" + name;
+       if (event.metaKey)
+           name = "Meta-" + name;
+       if (shift !== false && event.shiftKey)
+           name = "Shift-" + name;
+       return name;
+   }
+   const handleKeyEvents$2 = /*@__PURE__*/EditorView$3.domEventHandlers({
+       keydown(event, view) {
+           return runHandlers$2(getKeymap$2(view.state), event, view, "editor");
+       }
+   });
+   /**
+   Facet used for registering keymaps.
+
+   You can add multiple keymaps to an editor. Their priorities
+   determine their precedence (the ones specified early or with high
+   priority get checked first). When a handler has returned `true`
+   for a given key, no further handlers are called.
+   */
+   const keymap$2 = /*@__PURE__*/Facet$3.define({ enables: handleKeyEvents$2 });
+   const Keymaps$2 = /*@__PURE__*/new WeakMap();
+   // This is hidden behind an indirection, rather than directly computed
+   // by the facet, to keep internal types out of the facet's type.
+   function getKeymap$2(state) {
+       let bindings = state.facet(keymap$2);
+       let map = Keymaps$2.get(bindings);
+       if (!map)
+           Keymaps$2.set(bindings, map = buildKeymap$2(bindings.reduce((a, b) => a.concat(b), [])));
+       return map;
+   }
+   let storedPrefix$2 = null;
+   const PrefixTimeout$2 = 4000;
+   function buildKeymap$2(bindings, platform = currentPlatform$2) {
+       let bound = Object.create(null);
+       let isPrefix = Object.create(null);
+       let checkPrefix = (name, is) => {
+           let current = isPrefix[name];
+           if (current == null)
+               isPrefix[name] = is;
+           else if (current != is)
+               throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
+       };
+       let add = (scope, key, command, preventDefault) => {
+           let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
+           let parts = key.split(/ (?!$)/).map(k => normalizeKeyName$2(k, platform));
+           for (let i = 1; i < parts.length; i++) {
+               let prefix = parts.slice(0, i).join(" ");
+               checkPrefix(prefix, true);
+               if (!scopeObj[prefix])
+                   scopeObj[prefix] = {
+                       preventDefault: true,
+                       commands: [(view) => {
+                               let ourObj = storedPrefix$2 = { view, prefix, scope };
+                               setTimeout(() => { if (storedPrefix$2 == ourObj)
+                                   storedPrefix$2 = null; }, PrefixTimeout$2);
+                               return true;
+                           }]
+                   };
+           }
+           let full = parts.join(" ");
+           checkPrefix(full, false);
+           let binding = scopeObj[full] || (scopeObj[full] = { preventDefault: false, commands: [] });
+           binding.commands.push(command);
+           if (preventDefault)
+               binding.preventDefault = true;
+       };
+       for (let b of bindings) {
+           let name = b[platform] || b.key;
+           if (!name)
+               continue;
+           for (let scope of b.scope ? b.scope.split(" ") : ["editor"]) {
+               add(scope, name, b.run, b.preventDefault);
+               if (b.shift)
+                   add(scope, "Shift-" + name, b.shift, b.preventDefault);
+           }
+       }
+       return bound;
+   }
+   function runHandlers$2(map, event, view, scope) {
+       let name = keyName(event), isChar = name.length == 1 && name != " ";
+       let prefix = "", fallthrough = false;
+       if (storedPrefix$2 && storedPrefix$2.view == view && storedPrefix$2.scope == scope) {
+           prefix = storedPrefix$2.prefix + " ";
+           if (fallthrough = modifierCodes$3.indexOf(event.keyCode) < 0)
+               storedPrefix$2 = null;
+       }
+       let runFor = (binding) => {
+           if (binding) {
+               for (let cmd of binding.commands)
+                   if (cmd(view))
+                       return true;
+               if (binding.preventDefault)
+                   fallthrough = true;
+           }
+           return false;
+       };
+       let scopeObj = map[scope], baseName;
+       if (scopeObj) {
+           if (runFor(scopeObj[prefix + modifiers$2(name, event, !isChar)]))
+               return true;
+           if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
+               (baseName = base[event.keyCode]) && baseName != name) {
+               if (runFor(scopeObj[prefix + modifiers$2(baseName, event, true)]))
+                   return true;
+           }
+           else if (isChar && event.shiftKey) {
+               if (runFor(scopeObj[prefix + modifiers$2(name, event, true)]))
+                   return true;
+           }
+       }
+       return fallthrough;
+   }
+
+   const CanHidePrimary$3 = !browser$3.ios; // FIXME test IE
+   const selectionConfig = /*@__PURE__*/Facet$3.define({
+       combine(configs) {
+           return combineConfig$3(configs, {
+               cursorBlinkRate: 1200,
+               drawRangeCursor: true
+           }, {
+               cursorBlinkRate: (a, b) => Math.min(a, b),
+               drawRangeCursor: (a, b) => a || b
+           });
+       }
+   });
+   /**
+   Returns an extension that hides the browser's native selection and
+   cursor, replacing the selection with a background behind the text
+   (with the `cm-selectionBackground` class), and the
+   cursors with elements overlaid over the code (using
+   `cm-cursor-primary` and `cm-cursor-secondary`).
+
+   This allows the editor to display secondary selection ranges, and
+   tends to produce a type of selection more in line with that users
+   expect in a text editor (the native selection styling will often
+   leave gaps between lines and won't fill the horizontal space after
+   a line when the selection continues past it).
+
+   It does have a performance cost, in that it requires an extra DOM
+   layout cycle for many updates (the selection is drawn based on DOM
+   layout information that's only available after laying out the
+   content).
+   */
+   function drawSelection(config = {}) {
+       return [
+           selectionConfig.of(config),
+           drawSelectionPlugin,
+           hideNativeSelection
+       ];
+   }
+   class Piece {
+       constructor(left, top, width, height, className) {
+           this.left = left;
+           this.top = top;
+           this.width = width;
+           this.height = height;
+           this.className = className;
+       }
+       draw() {
+           let elt = document.createElement("div");
+           elt.className = this.className;
+           this.adjust(elt);
+           return elt;
+       }
+       adjust(elt) {
+           elt.style.left = this.left + "px";
+           elt.style.top = this.top + "px";
+           if (this.width >= 0)
+               elt.style.width = this.width + "px";
+           elt.style.height = this.height + "px";
+       }
+       eq(p) {
+           return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&
+               this.className == p.className;
+       }
+   }
+   const drawSelectionPlugin = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.rangePieces = [];
+           this.cursors = [];
+           this.measureReq = { read: this.readPos.bind(this), write: this.drawSel.bind(this) };
+           this.selectionLayer = view.scrollDOM.appendChild(document.createElement("div"));
+           this.selectionLayer.className = "cm-selectionLayer";
+           this.selectionLayer.setAttribute("aria-hidden", "true");
+           this.cursorLayer = view.scrollDOM.appendChild(document.createElement("div"));
+           this.cursorLayer.className = "cm-cursorLayer";
+           this.cursorLayer.setAttribute("aria-hidden", "true");
+           view.requestMeasure(this.measureReq);
+           this.setBlinkRate();
+       }
+       setBlinkRate() {
+           this.cursorLayer.style.animationDuration = this.view.state.facet(selectionConfig).cursorBlinkRate + "ms";
+       }
+       update(update) {
+           let confChanged = update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
+           if (confChanged || update.selectionSet || update.geometryChanged || update.viewportChanged)
+               this.view.requestMeasure(this.measureReq);
+           if (update.transactions.some(tr => tr.scrollIntoView))
+               this.cursorLayer.style.animationName = this.cursorLayer.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
+           if (confChanged)
+               this.setBlinkRate();
+       }
+       readPos() {
+           let { state } = this.view, conf = state.facet(selectionConfig);
+           let rangePieces = state.selection.ranges.map(r => r.empty ? [] : measureRange(this.view, r)).reduce((a, b) => a.concat(b));
+           let cursors = [];
+           for (let r of state.selection.ranges) {
+               let prim = r == state.selection.main;
+               if (r.empty ? !prim || CanHidePrimary$3 : conf.drawRangeCursor) {
+                   let piece = measureCursor(this.view, r, prim);
+                   if (piece)
+                       cursors.push(piece);
+               }
+           }
+           return { rangePieces, cursors };
+       }
+       drawSel({ rangePieces, cursors }) {
+           if (rangePieces.length != this.rangePieces.length || rangePieces.some((p, i) => !p.eq(this.rangePieces[i]))) {
+               this.selectionLayer.textContent = "";
+               for (let p of rangePieces)
+                   this.selectionLayer.appendChild(p.draw());
+               this.rangePieces = rangePieces;
+           }
+           if (cursors.length != this.cursors.length || cursors.some((c, i) => !c.eq(this.cursors[i]))) {
+               let oldCursors = this.cursorLayer.children;
+               if (oldCursors.length !== cursors.length) {
+                   this.cursorLayer.textContent = "";
+                   for (const c of cursors)
+                       this.cursorLayer.appendChild(c.draw());
+               }
+               else {
+                   cursors.forEach((c, idx) => c.adjust(oldCursors[idx]));
+               }
+               this.cursors = cursors;
+           }
+       }
+       destroy() {
+           this.selectionLayer.remove();
+           this.cursorLayer.remove();
+       }
+   });
+   const themeSpec$3 = {
+       ".cm-line": {
+           "& ::selection": { backgroundColor: "transparent !important" },
+           "&::selection": { backgroundColor: "transparent !important" }
+       }
+   };
+   if (CanHidePrimary$3)
+       themeSpec$3[".cm-line"].caretColor = "transparent !important";
+   const hideNativeSelection = /*@__PURE__*/Prec$3.highest(/*@__PURE__*/EditorView$3.theme(themeSpec$3));
+   function getBase(view) {
+       let rect = view.scrollDOM.getBoundingClientRect();
+       let left = view.textDirection == Direction$3.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth;
+       return { left: left - view.scrollDOM.scrollLeft, top: rect.top - view.scrollDOM.scrollTop };
+   }
+   function wrappedLine(view, pos, inside) {
+       let range = EditorSelection$3.cursor(pos);
+       return { from: Math.max(inside.from, view.moveToLineBoundary(range, false, true).from),
+           to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),
+           type: BlockType$3.Text };
+   }
+   function blockAt$1(view, pos) {
+       let line = view.lineBlockAt(pos);
+       if (Array.isArray(line.type))
+           for (let l of line.type) {
+               if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType$3.Text))
+                   return l;
+           }
+       return line;
+   }
+   function measureRange(view, range) {
+       if (range.to <= view.viewport.from || range.from >= view.viewport.to)
+           return [];
+       let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);
+       let ltr = view.textDirection == Direction$3.LTR;
+       let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);
+       let lineStyle = window.getComputedStyle(content.firstChild);
+       let leftSide = contentRect.left + parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent));
+       let rightSide = contentRect.right - parseInt(lineStyle.paddingRight);
+       let startBlock = blockAt$1(view, from), endBlock = blockAt$1(view, to);
+       let visualStart = startBlock.type == BlockType$3.Text ? startBlock : null;
+       let visualEnd = endBlock.type == BlockType$3.Text ? endBlock : null;
+       if (view.lineWrapping) {
+           if (visualStart)
+               visualStart = wrappedLine(view, from, visualStart);
+           if (visualEnd)
+               visualEnd = wrappedLine(view, to, visualEnd);
+       }
+       if (visualStart && visualEnd && visualStart.from == visualEnd.from) {
+           return pieces(drawForLine(range.from, range.to, visualStart));
+       }
+       else {
+           let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
+           let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
+           let between = [];
+           if ((visualStart || startBlock).to < (visualEnd || endBlock).from - 1)
+               between.push(piece(leftSide, top.bottom, rightSide, bottom.top));
+           else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType$3.Text)
+               top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
+           return pieces(top).concat(between).concat(pieces(bottom));
+       }
+       function piece(left, top, right, bottom) {
+           return new Piece(left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */, "cm-selectionBackground");
+       }
+       function pieces({ top, bottom, horizontal }) {
+           let pieces = [];
+           for (let i = 0; i < horizontal.length; i += 2)
+               pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));
+           return pieces;
+       }
+       // Gets passed from/to in line-local positions
+       function drawForLine(from, to, line) {
+           let top = 1e9, bottom = -1e9, horizontal = [];
+           function addSpan(from, fromOpen, to, toOpen, dir) {
+               // Passing 2/-2 is a kludge to force the view to return
+               // coordinates on the proper side of block widgets, since
+               // normalizing the side there, though appropriate for most
+               // coordsAtPos queries, would break selection drawing.
+               let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));
+               let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));
+               top = Math.min(fromCoords.top, toCoords.top, top);
+               bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);
+               if (dir == Direction$3.LTR)
+                   horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);
+               else
+                   horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);
+           }
+           let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;
+           // Split the range by visible range and document line
+           for (let r of view.visibleRanges)
+               if (r.to > start && r.from < end) {
+                   for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {
+                       let docLine = view.state.doc.lineAt(pos);
+                       for (let span of view.bidiSpans(docLine)) {
+                           let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;
+                           if (spanFrom >= endPos)
+                               break;
+                           if (spanTo > pos)
+                               addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);
+                       }
+                       pos = docLine.to + 1;
+                       if (pos >= endPos)
+                           break;
+                   }
+               }
+           if (horizontal.length == 0)
+               addSpan(start, from == null, end, to == null, view.textDirection);
+           return { top, bottom, horizontal };
+       }
+       function drawForWidget(block, top) {
+           let y = contentRect.top + (top ? block.top : block.bottom);
+           return { top: y, bottom: y, horizontal: [] };
+       }
+   }
+   function measureCursor(view, cursor, primary) {
+       let pos = view.coordsAtPos(cursor.head, cursor.assoc || 1);
+       if (!pos)
+           return null;
+       let base = getBase(view);
+       return new Piece(pos.left - base.left, pos.top - base.top, -1, pos.bottom - pos.top, primary ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary");
+   }
+
+   const setDropCursorPos = /*@__PURE__*/StateEffect$3.define({
+       map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
+   });
+   const dropCursorPos = /*@__PURE__*/StateField$3.define({
+       create() { return null; },
+       update(pos, tr) {
+           if (pos != null)
+               pos = tr.changes.mapPos(pos);
+           return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);
+       }
+   });
+   const drawDropCursor = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.cursor = null;
+           this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };
+       }
+       update(update) {
+           var _a;
+           let cursorPos = update.state.field(dropCursorPos);
+           if (cursorPos == null) {
+               if (this.cursor != null) {
+                   (_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();
+                   this.cursor = null;
+               }
+           }
+           else {
+               if (!this.cursor) {
+                   this.cursor = this.view.scrollDOM.appendChild(document.createElement("div"));
+                   this.cursor.className = "cm-dropCursor";
+               }
+               if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)
+                   this.view.requestMeasure(this.measureReq);
+           }
+       }
+       readPos() {
+           let pos = this.view.state.field(dropCursorPos);
+           let rect = pos != null && this.view.coordsAtPos(pos);
+           if (!rect)
+               return null;
+           let outer = this.view.scrollDOM.getBoundingClientRect();
+           return {
+               left: rect.left - outer.left + this.view.scrollDOM.scrollLeft,
+               top: rect.top - outer.top + this.view.scrollDOM.scrollTop,
+               height: rect.bottom - rect.top
+           };
+       }
+       drawCursor(pos) {
+           if (this.cursor) {
+               if (pos) {
+                   this.cursor.style.left = pos.left + "px";
+                   this.cursor.style.top = pos.top + "px";
+                   this.cursor.style.height = pos.height + "px";
+               }
+               else {
+                   this.cursor.style.left = "-100000px";
+               }
+           }
+       }
+       destroy() {
+           if (this.cursor)
+               this.cursor.remove();
+       }
+       setDropPos(pos) {
+           if (this.view.state.field(dropCursorPos) != pos)
+               this.view.dispatch({ effects: setDropCursorPos.of(pos) });
+       }
+   }, {
+       eventHandlers: {
+           dragover(event) {
+               this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));
+           },
+           dragleave(event) {
+               if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))
+                   this.setDropPos(null);
+           },
+           dragend() {
+               this.setDropPos(null);
+           },
+           drop() {
+               this.setDropPos(null);
+           }
+       }
+   });
+   /**
+   Draws a cursor at the current drop position when something is
+   dragged over the editor.
+   */
+   function dropCursor() {
+       return [dropCursorPos, drawDropCursor];
+   }
+
+   function iterMatches(doc, re, from, to, f) {
+       re.lastIndex = 0;
+       for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {
+           if (!cursor.lineBreak)
+               while (m = re.exec(cursor.value))
+                   f(pos + m.index, pos + m.index + m[0].length, m);
+       }
+   }
+   function matchRanges(view, maxLength) {
+       let visible = view.visibleRanges;
+       if (visible.length == 1 && visible[0].from == view.viewport.from &&
+           visible[0].to == view.viewport.to)
+           return visible;
+       let result = [];
+       for (let { from, to } of visible) {
+           from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);
+           to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);
+           if (result.length && result[result.length - 1].to >= from)
+               result[result.length - 1].to = to;
+           else
+               result.push({ from, to });
+       }
+       return result;
+   }
+   /**
+   Helper class used to make it easier to maintain decorations on
+   visible code that matches a given regular expression. To be used
+   in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
+   represent a matching configuration.
+   */
+   class MatchDecorator {
+       /**
+       Create a decorator.
+       */
+       constructor(config) {
+           let { regexp, decoration, boundary, maxLength = 1000 } = config;
+           if (!regexp.global)
+               throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
+           this.regexp = regexp;
+           this.getDeco = typeof decoration == "function" ? decoration : () => decoration;
+           this.boundary = boundary;
+           this.maxLength = maxLength;
+       }
+       /**
+       Compute the full set of decorations for matches in the given
+       view's viewport. You'll want to call this when initializing your
+       plugin.
+       */
+       createDeco(view) {
+           let build = new RangeSetBuilder$3();
+           for (let { from, to } of matchRanges(view, this.maxLength))
+               iterMatches(view.state.doc, this.regexp, from, to, (a, b, m) => build.add(a, b, this.getDeco(m, view, a)));
+           return build.finish();
+       }
+       /**
+       Update a set of decorations for a view update. `deco` _must_ be
+       the set of decorations produced by _this_ `MatchDecorator` for
+       the view state before the update.
+       */
+       updateDeco(update, deco) {
+           let changeFrom = 1e9, changeTo = -1;
+           if (update.docChanged)
+               update.changes.iterChanges((_f, _t, from, to) => {
+                   if (to > update.view.viewport.from && from < update.view.viewport.to) {
+                       changeFrom = Math.min(from, changeFrom);
+                       changeTo = Math.max(to, changeTo);
+                   }
+               });
+           if (update.viewportChanged || changeTo - changeFrom > 1000)
+               return this.createDeco(update.view);
+           if (changeTo > -1)
+               return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);
+           return deco;
+       }
+       updateRange(view, deco, updateFrom, updateTo) {
+           for (let r of view.visibleRanges) {
+               let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);
+               if (to > from) {
+                   let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;
+                   let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);
+                   if (this.boundary) {
+                       for (; from > fromLine.from; from--)
+                           if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {
+                               start = from;
+                               break;
+                           }
+                       for (; to < toLine.to; to++)
+                           if (this.boundary.test(toLine.text[to - toLine.from])) {
+                               end = to;
+                               break;
+                           }
+                   }
+                   let ranges = [], m;
+                   if (fromLine == toLine) {
+                       this.regexp.lastIndex = start - fromLine.from;
+                       while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from) {
+                           let pos = m.index + fromLine.from;
+                           ranges.push(this.getDeco(m, view, pos).range(pos, pos + m[0].length));
+                       }
+                   }
+                   else {
+                       iterMatches(view.state.doc, this.regexp, start, end, (from, to, m) => ranges.push(this.getDeco(m, view, from).range(from, to)));
+                   }
+                   deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });
+               }
+           }
+           return deco;
+       }
+   }
+
+   const UnicodeRegexpSupport = /x/.unicode != null ? "gu" : "g";
+   const Specials = /*@__PURE__*/new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\ufeff\ufff9-\ufffc]", UnicodeRegexpSupport);
+   const Names = {
+       0: "null",
+       7: "bell",
+       8: "backspace",
+       10: "newline",
+       11: "vertical tab",
+       13: "carriage return",
+       27: "escape",
+       8203: "zero width space",
+       8204: "zero width non-joiner",
+       8205: "zero width joiner",
+       8206: "left-to-right mark",
+       8207: "right-to-left mark",
+       8232: "line separator",
+       8237: "left-to-right override",
+       8238: "right-to-left override",
+       8233: "paragraph separator",
+       65279: "zero width no-break space",
+       65532: "object replacement"
+   };
+   let _supportsTabSize = null;
+   function supportsTabSize() {
+       var _a;
+       if (_supportsTabSize == null && typeof document != "undefined" && document.body) {
+           let styles = document.body.style;
+           _supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;
+       }
+       return _supportsTabSize || false;
+   }
+   const specialCharConfig = /*@__PURE__*/Facet$3.define({
+       combine(configs) {
+           let config = combineConfig$3(configs, {
+               render: null,
+               specialChars: Specials,
+               addSpecialChars: null
+           });
+           if (config.replaceTabs = !supportsTabSize())
+               config.specialChars = new RegExp("\t|" + config.specialChars.source, UnicodeRegexpSupport);
+           if (config.addSpecialChars)
+               config.specialChars = new RegExp(config.specialChars.source + "|" + config.addSpecialChars.source, UnicodeRegexpSupport);
+           return config;
+       }
+   });
+   /**
+   Returns an extension that installs highlighting of special
+   characters.
+   */
+   function highlightSpecialChars(
+   /**
+   Configuration options.
+   */
+   config = {}) {
+       return [specialCharConfig.of(config), specialCharPlugin()];
+   }
+   let _plugin = null;
+   function specialCharPlugin() {
+       return _plugin || (_plugin = ViewPlugin$3.fromClass(class {
+           constructor(view) {
+               this.view = view;
+               this.decorations = Decoration$3.none;
+               this.decorationCache = Object.create(null);
+               this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));
+               this.decorations = this.decorator.createDeco(view);
+           }
+           makeDecorator(conf) {
+               return new MatchDecorator({
+                   regexp: conf.specialChars,
+                   decoration: (m, view, pos) => {
+                       let { doc } = view.state;
+                       let code = codePointAt$4(m[0], 0);
+                       if (code == 9) {
+                           let line = doc.lineAt(pos);
+                           let size = view.state.tabSize, col = countColumn$1(line.text, size, pos - line.from);
+                           return Decoration$3.replace({ widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth) });
+                       }
+                       return this.decorationCache[code] ||
+                           (this.decorationCache[code] = Decoration$3.replace({ widget: new SpecialCharWidget(conf, code) }));
+                   },
+                   boundary: conf.replaceTabs ? undefined : /[^]/
+               });
+           }
+           update(update) {
+               let conf = update.state.facet(specialCharConfig);
+               if (update.startState.facet(specialCharConfig) != conf) {
+                   this.decorator = this.makeDecorator(conf);
+                   this.decorations = this.decorator.createDeco(update.view);
+               }
+               else {
+                   this.decorations = this.decorator.updateDeco(update, this.decorations);
+               }
+           }
+       }, {
+           decorations: v => v.decorations
+       }));
+   }
+   const DefaultPlaceholder = "\u2022";
+   // Assigns placeholder characters from the Control Pictures block to
+   // ASCII control characters
+   function placeholder$1(code) {
+       if (code >= 32)
+           return DefaultPlaceholder;
+       if (code == 10)
+           return "\u2424";
+       return String.fromCharCode(9216 + code);
+   }
+   class SpecialCharWidget extends WidgetType$3 {
+       constructor(options, code) {
+           super();
+           this.options = options;
+           this.code = code;
+       }
+       eq(other) { return other.code == this.code; }
+       toDOM(view) {
+           let ph = placeholder$1(this.code);
+           let desc = view.state.phrase("Control character") + " " + (Names[this.code] || "0x" + this.code.toString(16));
+           let custom = this.options.render && this.options.render(this.code, desc, ph);
+           if (custom)
+               return custom;
+           let span = document.createElement("span");
+           span.textContent = ph;
+           span.title = desc;
+           span.setAttribute("aria-label", desc);
+           span.className = "cm-specialChar";
+           return span;
+       }
+       ignoreEvent() { return false; }
+   }
+   class TabWidget extends WidgetType$3 {
+       constructor(width) {
+           super();
+           this.width = width;
+       }
+       eq(other) { return other.width == this.width; }
+       toDOM() {
+           let span = document.createElement("span");
+           span.textContent = "\t";
+           span.className = "cm-tab";
+           span.style.width = this.width + "px";
+           return span;
+       }
+       ignoreEvent() { return false; }
+   }
+
+   /**
+   Mark lines that have a cursor on them with the `"cm-activeLine"`
+   DOM class.
+   */
+   function highlightActiveLine() {
+       return activeLineHighlighter;
+   }
+   const lineDeco = /*@__PURE__*/Decoration$3.line({ class: "cm-activeLine" });
+   const activeLineHighlighter = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           this.decorations = this.getDeco(view);
+       }
+       update(update) {
+           if (update.docChanged || update.selectionSet)
+               this.decorations = this.getDeco(update.view);
+       }
+       getDeco(view) {
+           let lastLineStart = -1, deco = [];
+           for (let r of view.state.selection.ranges) {
+               if (!r.empty)
+                   return Decoration$3.none;
+               let line = view.lineBlockAt(r.head);
+               if (line.from > lastLineStart) {
+                   deco.push(lineDeco.range(line.from));
+                   lastLineStart = line.from;
+               }
+           }
+           return Decoration$3.set(deco);
+       }
+   }, {
+       decorations: v => v.decorations
+   });
+
+   // Don't compute precise column positions for line offsets above this
+   // (since it could get expensive). Assume offset==column for them.
+   const MaxOff = 2000;
+   function rectangleFor(state, a, b) {
+       let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);
+       let ranges = [];
+       if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {
+           let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);
+           for (let i = startLine; i <= endLine; i++) {
+               let line = state.doc.line(i);
+               if (line.length <= endOff)
+                   ranges.push(EditorSelection$3.range(line.from + startOff, line.to + endOff));
+           }
+       }
+       else {
+           let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);
+           for (let i = startLine; i <= endLine; i++) {
+               let line = state.doc.line(i);
+               let start = findColumn$3(line.text, startCol, state.tabSize, true);
+               if (start > -1) {
+                   let end = findColumn$3(line.text, endCol, state.tabSize);
+                   ranges.push(EditorSelection$3.range(line.from + start, line.from + end));
+               }
+           }
+       }
+       return ranges;
+   }
+   function absoluteColumn(view, x) {
+       let ref = view.coordsAtPos(view.viewport.from);
+       return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;
+   }
+   function getPos(view, event) {
+       let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       let line = view.state.doc.lineAt(offset), off = offset - line.from;
+       let col = off > MaxOff ? -1
+           : off == line.length ? absoluteColumn(view, event.clientX)
+               : countColumn$1(line.text, view.state.tabSize, offset - line.from);
+       return { line: line.number, col, off };
+   }
+   function rectangleSelectionStyle(view, event) {
+       let start = getPos(view, event), startSel = view.state.selection;
+       if (!start)
+           return null;
+       return {
+           update(update) {
+               if (update.docChanged) {
+                   let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);
+                   let newLine = update.state.doc.lineAt(newStart);
+                   start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };
+                   startSel = startSel.map(update.changes);
+               }
+           },
+           get(event, _extend, multiple) {
+               let cur = getPos(view, event);
+               if (!cur)
+                   return startSel;
+               let ranges = rectangleFor(view.state, start, cur);
+               if (!ranges.length)
+                   return startSel;
+               if (multiple)
+                   return EditorSelection$3.create(ranges.concat(startSel.ranges));
+               else
+                   return EditorSelection$3.create(ranges);
+           }
+       };
+   }
+   /**
+   Create an extension that enables rectangular selections. By
+   default, it will react to left mouse drag with the Alt key held
+   down. When such a selection occurs, the text within the rectangle
+   that was dragged over will be selected, as one selection
+   [range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.
+   */
+   function rectangularSelection(options) {
+       let filter = (e => e.altKey && e.button == 0);
+       return EditorView$3.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
+   }
+   const keys = {
+       Alt: [18, e => e.altKey],
+       Control: [17, e => e.ctrlKey],
+       Shift: [16, e => e.shiftKey],
+       Meta: [91, e => e.metaKey]
+   };
+   const showCrosshair = { style: "cursor: crosshair" };
+   /**
+   Returns an extension that turns the pointer cursor into a
+   crosshair when a given modifier key, defaulting to Alt, is held
+   down. Can serve as a visual hint that rectangular selection is
+   going to happen when paired with
+   [`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).
+   */
+   function crosshairCursor(options = {}) {
+       let [code, getter] = keys[options.key || "Alt"];
+       let plugin = ViewPlugin$3.fromClass(class {
+           constructor(view) {
+               this.view = view;
+               this.isDown = false;
+           }
+           set(isDown) {
+               if (this.isDown != isDown) {
+                   this.isDown = isDown;
+                   this.view.update([]);
+               }
+           }
+       }, {
+           eventHandlers: {
+               keydown(e) {
+                   this.set(e.keyCode == code || getter(e));
+               },
+               keyup(e) {
+                   if (e.keyCode == code || !getter(e))
+                       this.set(false);
+               }
+           }
+       });
+       return [
+           plugin,
+           EditorView$3.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })
+       ];
+   }
+
+   const Outside$1 = "-10000px";
+   let TooltipViewManager$1 = class TooltipViewManager {
+       constructor(view, facet, createTooltipView) {
+           this.facet = facet;
+           this.createTooltipView = createTooltipView;
+           this.input = view.state.facet(facet);
+           this.tooltips = this.input.filter(t => t);
+           this.tooltipViews = this.tooltips.map(createTooltipView);
+       }
+       update(update) {
+           let input = update.state.facet(this.facet);
+           let tooltips = input.filter(x => x);
+           if (input === this.input) {
+               for (let t of this.tooltipViews)
+                   if (t.update)
+                       t.update(update);
+               return false;
+           }
+           let tooltipViews = [];
+           for (let i = 0; i < tooltips.length; i++) {
+               let tip = tooltips[i], known = -1;
+               if (!tip)
+                   continue;
+               for (let i = 0; i < this.tooltips.length; i++) {
+                   let other = this.tooltips[i];
+                   if (other && other.create == tip.create)
+                       known = i;
+               }
+               if (known < 0) {
+                   tooltipViews[i] = this.createTooltipView(tip);
+               }
+               else {
+                   let tooltipView = tooltipViews[i] = this.tooltipViews[known];
+                   if (tooltipView.update)
+                       tooltipView.update(update);
+               }
+           }
+           for (let t of this.tooltipViews)
+               if (tooltipViews.indexOf(t) < 0)
+                   t.dom.remove();
+           this.input = input;
+           this.tooltips = tooltips;
+           this.tooltipViews = tooltipViews;
+           return true;
+       }
+   };
+   function windowSpace$1() {
+       return { top: 0, left: 0, bottom: innerHeight, right: innerWidth };
+   }
+   const tooltipConfig$1 = /*@__PURE__*/Facet$3.define({
+       combine: values => {
+           var _a, _b, _c;
+           return ({
+               position: browser$3.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
+               parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
+               tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace$1,
+           });
+       }
+   });
+   const tooltipPlugin$1 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           var _a;
+           this.view = view;
+           this.inView = true;
+           this.lastTransaction = 0;
+           this.measureTimeout = -1;
+           let config = view.state.facet(tooltipConfig$1);
+           this.position = config.position;
+           this.parent = config.parent;
+           this.classes = view.themeClasses;
+           this.createContainer();
+           this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
+           this.manager = new TooltipViewManager$1(view, showTooltip$1, t => this.createTooltip(t));
+           this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
+               if (Date.now() > this.lastTransaction - 50 &&
+                   entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
+                   this.measureSoon();
+           }, { threshold: [1] }) : null;
+           this.observeIntersection();
+           (_a = view.dom.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
+           this.maybeMeasure();
+       }
+       createContainer() {
+           if (this.parent) {
+               this.container = document.createElement("div");
+               this.container.style.position = "relative";
+               this.container.className = this.view.themeClasses;
+               this.parent.appendChild(this.container);
+           }
+           else {
+               this.container = this.view.dom;
+           }
+       }
+       observeIntersection() {
+           if (this.intersectionObserver) {
+               this.intersectionObserver.disconnect();
+               for (let tooltip of this.manager.tooltipViews)
+                   this.intersectionObserver.observe(tooltip.dom);
+           }
+       }
+       measureSoon() {
+           if (this.measureTimeout < 0)
+               this.measureTimeout = setTimeout(() => {
+                   this.measureTimeout = -1;
+                   this.maybeMeasure();
+               }, 50);
+       }
+       update(update) {
+           if (update.transactions.length)
+               this.lastTransaction = Date.now();
+           let updated = this.manager.update(update);
+           if (updated)
+               this.observeIntersection();
+           let shouldMeasure = updated || update.geometryChanged;
+           let newConfig = update.state.facet(tooltipConfig$1);
+           if (newConfig.position != this.position) {
+               this.position = newConfig.position;
+               for (let t of this.manager.tooltipViews)
+                   t.dom.style.position = this.position;
+               shouldMeasure = true;
+           }
+           if (newConfig.parent != this.parent) {
+               if (this.parent)
+                   this.container.remove();
+               this.parent = newConfig.parent;
+               this.createContainer();
+               for (let t of this.manager.tooltipViews)
+                   this.container.appendChild(t.dom);
+               shouldMeasure = true;
+           }
+           else if (this.parent && this.view.themeClasses != this.classes) {
+               this.classes = this.container.className = this.view.themeClasses;
+           }
+           if (shouldMeasure)
+               this.maybeMeasure();
+       }
+       createTooltip(tooltip) {
+           let tooltipView = tooltip.create(this.view);
+           tooltipView.dom.classList.add("cm-tooltip");
+           if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
+               let arrow = document.createElement("div");
+               arrow.className = "cm-tooltip-arrow";
+               tooltipView.dom.appendChild(arrow);
+           }
+           tooltipView.dom.style.position = this.position;
+           tooltipView.dom.style.top = Outside$1;
+           this.container.appendChild(tooltipView.dom);
+           if (tooltipView.mount)
+               tooltipView.mount(this.view);
+           return tooltipView;
+       }
+       destroy() {
+           var _a, _b;
+           (_a = this.view.dom.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.removeEventListener("resize", this.measureSoon);
+           for (let { dom } of this.manager.tooltipViews)
+               dom.remove();
+           (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
+           clearTimeout(this.measureTimeout);
+       }
+       readMeasure() {
+           let editor = this.view.dom.getBoundingClientRect();
+           return {
+               editor,
+               parent: this.parent ? this.container.getBoundingClientRect() : editor,
+               pos: this.manager.tooltips.map((t, i) => {
+                   let tv = this.manager.tooltipViews[i];
+                   return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
+               }),
+               size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
+               space: this.view.state.facet(tooltipConfig$1).tooltipSpace(this.view),
+           };
+       }
+       writeMeasure(measured) {
+           let { editor, space } = measured;
+           let others = [];
+           for (let i = 0; i < this.manager.tooltips.length; i++) {
+               let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
+               let pos = measured.pos[i], size = measured.size[i];
+               // Hide tooltips that are outside of the editor.
+               if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||
+                   pos.top >= Math.min(editor.bottom, space.bottom) ||
+                   pos.right < Math.max(editor.left, space.left) - .1 ||
+                   pos.left > Math.min(editor.right, space.right) + .1) {
+                   dom.style.top = Outside$1;
+                   continue;
+               }
+               let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
+               let arrowHeight = arrow ? 7 /* Size */ : 0;
+               let width = size.right - size.left, height = size.bottom - size.top;
+               let offset = tView.offset || noOffset$1, ltr = this.view.textDirection == Direction$3.LTR;
+               let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
+                   : ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
+                       : Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
+               let above = !!tooltip.above;
+               if (!tooltip.strictSide && (above
+                   ? pos.top - (size.bottom - size.top) - offset.y < space.top
+                   : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
+                   above == (space.bottom - pos.bottom > pos.top - space.top))
+                   above = !above;
+               let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
+               let right = left + width;
+               if (tView.overlap !== true)
+                   for (let r of others)
+                       if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
+                           top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
+               if (this.position == "absolute") {
+                   dom.style.top = (top - measured.parent.top) + "px";
+                   dom.style.left = (left - measured.parent.left) + "px";
+               }
+               else {
+                   dom.style.top = top + "px";
+                   dom.style.left = left + "px";
+               }
+               if (arrow)
+                   arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
+               if (tView.overlap !== true)
+                   others.push({ left, top, right, bottom: top + height });
+               dom.classList.toggle("cm-tooltip-above", above);
+               dom.classList.toggle("cm-tooltip-below", !above);
+               if (tView.positioned)
+                   tView.positioned();
+           }
+       }
+       maybeMeasure() {
+           if (this.manager.tooltips.length) {
+               if (this.view.inView)
+                   this.view.requestMeasure(this.measureReq);
+               if (this.inView != this.view.inView) {
+                   this.inView = this.view.inView;
+                   if (!this.inView)
+                       for (let tv of this.manager.tooltipViews)
+                           tv.dom.style.top = Outside$1;
+               }
+           }
+       }
+   }, {
+       eventHandlers: {
+           scroll() { this.maybeMeasure(); }
+       }
+   });
+   const baseTheme$7 = /*@__PURE__*/EditorView$3.baseTheme({
+       ".cm-tooltip": {
+           zIndex: 100
+       },
+       "&light .cm-tooltip": {
+           border: "1px solid #bbb",
+           backgroundColor: "#f5f5f5"
+       },
+       "&light .cm-tooltip-section:not(:first-child)": {
+           borderTop: "1px solid #bbb",
+       },
+       "&dark .cm-tooltip": {
+           backgroundColor: "#333338",
+           color: "white"
+       },
+       ".cm-tooltip-arrow": {
+           height: `${7 /* Size */}px`,
+           width: `${7 /* Size */ * 2}px`,
+           position: "absolute",
+           zIndex: -1,
+           overflow: "hidden",
+           "&:before, &:after": {
+               content: "''",
+               position: "absolute",
+               width: 0,
+               height: 0,
+               borderLeft: `${7 /* Size */}px solid transparent`,
+               borderRight: `${7 /* Size */}px solid transparent`,
+           },
+           ".cm-tooltip-above &": {
+               bottom: `-${7 /* Size */}px`,
+               "&:before": {
+                   borderTop: `${7 /* Size */}px solid #bbb`,
+               },
+               "&:after": {
+                   borderTop: `${7 /* Size */}px solid #f5f5f5`,
+                   bottom: "1px"
+               }
+           },
+           ".cm-tooltip-below &": {
+               top: `-${7 /* Size */}px`,
+               "&:before": {
+                   borderBottom: `${7 /* Size */}px solid #bbb`,
+               },
+               "&:after": {
+                   borderBottom: `${7 /* Size */}px solid #f5f5f5`,
+                   top: "1px"
+               }
+           },
+       },
+       "&dark .cm-tooltip .cm-tooltip-arrow": {
+           "&:before": {
+               borderTopColor: "#333338",
+               borderBottomColor: "#333338"
+           },
+           "&:after": {
+               borderTopColor: "transparent",
+               borderBottomColor: "transparent"
+           }
+       }
+   });
+   const noOffset$1 = { x: 0, y: 0 };
+   /**
+   Facet to which an extension can add a value to show a tooltip.
+   */
+   const showTooltip$1 = /*@__PURE__*/Facet$3.define({
+       enables: [tooltipPlugin$1, baseTheme$7]
+   });
+   const showHoverTooltip = /*@__PURE__*/Facet$3.define();
+   class HoverTooltipHost {
+       constructor(view) {
+           this.view = view;
+           this.mounted = false;
+           this.dom = document.createElement("div");
+           this.dom.classList.add("cm-tooltip-hover");
+           this.manager = new TooltipViewManager$1(view, showHoverTooltip, t => this.createHostedView(t));
+       }
+       // Needs to be static so that host tooltip instances always match
+       static create(view) {
+           return new HoverTooltipHost(view);
+       }
+       createHostedView(tooltip) {
+           let hostedView = tooltip.create(this.view);
+           hostedView.dom.classList.add("cm-tooltip-section");
+           this.dom.appendChild(hostedView.dom);
+           if (this.mounted && hostedView.mount)
+               hostedView.mount(this.view);
+           return hostedView;
+       }
+       mount(view) {
+           for (let hostedView of this.manager.tooltipViews) {
+               if (hostedView.mount)
+                   hostedView.mount(view);
+           }
+           this.mounted = true;
+       }
+       positioned() {
+           for (let hostedView of this.manager.tooltipViews) {
+               if (hostedView.positioned)
+                   hostedView.positioned();
+           }
+       }
+       update(update) {
+           this.manager.update(update);
+       }
+   }
+   const showHoverTooltipHost = /*@__PURE__*/showTooltip$1.compute([showHoverTooltip], state => {
+       let tooltips = state.facet(showHoverTooltip).filter(t => t);
+       if (tooltips.length === 0)
+           return null;
+       return {
+           pos: Math.min(...tooltips.map(t => t.pos)),
+           end: Math.max(...tooltips.filter(t => t.end != null).map(t => t.end)),
+           create: HoverTooltipHost.create,
+           above: tooltips[0].above,
+           arrow: tooltips.some(t => t.arrow),
+       };
+   });
+   class HoverPlugin {
+       constructor(view, source, field, setHover, hoverTime) {
+           this.view = view;
+           this.source = source;
+           this.field = field;
+           this.setHover = setHover;
+           this.hoverTime = hoverTime;
+           this.hoverTimeout = -1;
+           this.restartTimeout = -1;
+           this.pending = null;
+           this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };
+           this.checkHover = this.checkHover.bind(this);
+           view.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this));
+           view.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
+       }
+       update() {
+           if (this.pending) {
+               this.pending = null;
+               clearTimeout(this.restartTimeout);
+               this.restartTimeout = setTimeout(() => this.startHover(), 20);
+           }
+       }
+       get active() {
+           return this.view.state.field(this.field);
+       }
+       checkHover() {
+           this.hoverTimeout = -1;
+           if (this.active)
+               return;
+           let hovered = Date.now() - this.lastMove.time;
+           if (hovered < this.hoverTime)
+               this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);
+           else
+               this.startHover();
+       }
+       startHover() {
+           clearTimeout(this.restartTimeout);
+           let { lastMove } = this;
+           let pos = this.view.contentDOM.contains(lastMove.target) ? this.view.posAtCoords(lastMove) : null;
+           if (pos == null)
+               return;
+           let posCoords = this.view.coordsAtPos(pos);
+           if (posCoords == null || lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||
+               lastMove.x < posCoords.left - this.view.defaultCharacterWidth ||
+               lastMove.x > posCoords.right + this.view.defaultCharacterWidth)
+               return;
+           let bidi = this.view.bidiSpans(this.view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);
+           let rtl = bidi && bidi.dir == Direction$3.RTL ? -1 : 1;
+           let open = this.source(this.view, pos, (lastMove.x < posCoords.left ? -rtl : rtl));
+           if (open === null || open === void 0 ? void 0 : open.then) {
+               let pending = this.pending = { pos };
+               open.then(result => {
+                   if (this.pending == pending) {
+                       this.pending = null;
+                       if (result)
+                           this.view.dispatch({ effects: this.setHover.of(result) });
+                   }
+               }, e => logException$3(this.view.state, e, "hover tooltip"));
+           }
+           else if (open) {
+               this.view.dispatch({ effects: this.setHover.of(open) });
+           }
+       }
+       mousemove(event) {
+           var _a;
+           this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };
+           if (this.hoverTimeout < 0)
+               this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
+           let tooltip = this.active;
+           if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
+               let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
+               if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
+                   : !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
+                   this.view.dispatch({ effects: this.setHover.of(null) });
+                   this.pending = null;
+               }
+           }
+       }
+       mouseleave() {
+           clearTimeout(this.hoverTimeout);
+           this.hoverTimeout = -1;
+           if (this.active)
+               this.view.dispatch({ effects: this.setHover.of(null) });
+       }
+       destroy() {
+           clearTimeout(this.hoverTimeout);
+           this.view.dom.removeEventListener("mouseleave", this.mouseleave);
+           this.view.dom.removeEventListener("mousemove", this.mousemove);
+       }
+   }
+   function isInTooltip(elt) {
+       for (let cur = elt; cur; cur = cur.parentNode)
+           if (cur.nodeType == 1 && cur.classList.contains("cm-tooltip"))
+               return true;
+       return false;
+   }
+   function isOverRange(view, from, to, x, y, margin) {
+       let range = document.createRange();
+       let fromDOM = view.domAtPos(from), toDOM = view.domAtPos(to);
+       range.setEnd(toDOM.node, toDOM.offset);
+       range.setStart(fromDOM.node, fromDOM.offset);
+       let rects = range.getClientRects();
+       range.detach();
+       for (let i = 0; i < rects.length; i++) {
+           let rect = rects[i];
+           let dist = Math.max(rect.top - y, y - rect.bottom, rect.left - x, x - rect.right);
+           if (dist <= margin)
+               return true;
+       }
+       return false;
+   }
+   /**
+   Set up a hover tooltip, which shows up when the pointer hovers
+   over ranges of text. The callback is called when the mouse hovers
+   over the document text. It should, if there is a tooltip
+   associated with position `pos`, return the tooltip description
+   (either directly or in a promise). The `side` argument indicates
+   on which side of the position the pointer is—it will be -1 if the
+   pointer is before the position, 1 if after the position.
+
+   Note that all hover tooltips are hosted within a single tooltip
+   container element. This allows multiple tooltips over the same
+   range to be "merged" together without overlapping.
+   */
+   function hoverTooltip(source, options = {}) {
+       let setHover = StateEffect$3.define();
+       let hoverState = StateField$3.define({
+           create() { return null; },
+           update(value, tr) {
+               if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
+                   options.hideOn && options.hideOn(tr, value)))
+                   return null;
+               if (value && tr.docChanged) {
+                   let newPos = tr.changes.mapPos(value.pos, -1, MapMode$3.TrackDel);
+                   if (newPos == null)
+                       return null;
+                   let copy = Object.assign(Object.create(null), value);
+                   copy.pos = newPos;
+                   if (value.end != null)
+                       copy.end = tr.changes.mapPos(value.end);
+                   value = copy;
+               }
+               for (let effect of tr.effects) {
+                   if (effect.is(setHover))
+                       value = effect.value;
+                   if (effect.is(closeHoverTooltipEffect))
+                       value = null;
+               }
+               return value;
+           },
+           provide: f => showHoverTooltip.from(f)
+       });
+       return [
+           hoverState,
+           ViewPlugin$3.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
+           showHoverTooltipHost
+       ];
+   }
+   /**
+   Get the active tooltip view for a given tooltip, if available.
+   */
+   function getTooltip$1(view, tooltip) {
+       let plugin = view.plugin(tooltipPlugin$1);
+       if (!plugin)
+           return null;
+       let found = plugin.manager.tooltips.indexOf(tooltip);
+       return found < 0 ? null : plugin.manager.tooltipViews[found];
+   }
+   const closeHoverTooltipEffect = /*@__PURE__*/StateEffect$3.define();
+
+   const panelConfig$2 = /*@__PURE__*/Facet$3.define({
+       combine(configs) {
+           let topContainer, bottomContainer;
+           for (let c of configs) {
+               topContainer = topContainer || c.topContainer;
+               bottomContainer = bottomContainer || c.bottomContainer;
+           }
+           return { topContainer, bottomContainer };
+       }
+   });
+   /**
+   Get the active panel created by the given constructor, if any.
+   This can be useful when you need access to your panels' DOM
+   structure.
+   */
+   function getPanel$1(view, panel) {
+       let plugin = view.plugin(panelPlugin$2);
+       let index = plugin ? plugin.specs.indexOf(panel) : -1;
+       return index > -1 ? plugin.panels[index] : null;
+   }
+   const panelPlugin$2 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           this.input = view.state.facet(showPanel$2);
+           this.specs = this.input.filter(s => s);
+           this.panels = this.specs.map(spec => spec(view));
+           let conf = view.state.facet(panelConfig$2);
+           this.top = new PanelGroup$2(view, true, conf.topContainer);
+           this.bottom = new PanelGroup$2(view, false, conf.bottomContainer);
+           this.top.sync(this.panels.filter(p => p.top));
+           this.bottom.sync(this.panels.filter(p => !p.top));
+           for (let p of this.panels) {
+               p.dom.classList.add("cm-panel");
+               if (p.mount)
+                   p.mount();
+           }
+       }
+       update(update) {
+           let conf = update.state.facet(panelConfig$2);
+           if (this.top.container != conf.topContainer) {
+               this.top.sync([]);
+               this.top = new PanelGroup$2(update.view, true, conf.topContainer);
+           }
+           if (this.bottom.container != conf.bottomContainer) {
+               this.bottom.sync([]);
+               this.bottom = new PanelGroup$2(update.view, false, conf.bottomContainer);
+           }
+           this.top.syncClasses();
+           this.bottom.syncClasses();
+           let input = update.state.facet(showPanel$2);
+           if (input != this.input) {
+               let specs = input.filter(x => x);
+               let panels = [], top = [], bottom = [], mount = [];
+               for (let spec of specs) {
+                   let known = this.specs.indexOf(spec), panel;
+                   if (known < 0) {
+                       panel = spec(update.view);
+                       mount.push(panel);
+                   }
+                   else {
+                       panel = this.panels[known];
+                       if (panel.update)
+                           panel.update(update);
+                   }
+                   panels.push(panel);
+                   (panel.top ? top : bottom).push(panel);
+               }
+               this.specs = specs;
+               this.panels = panels;
+               this.top.sync(top);
+               this.bottom.sync(bottom);
+               for (let p of mount) {
+                   p.dom.classList.add("cm-panel");
+                   if (p.mount)
+                       p.mount();
+               }
+           }
+           else {
+               for (let p of this.panels)
+                   if (p.update)
+                       p.update(update);
+           }
+       }
+       destroy() {
+           this.top.sync([]);
+           this.bottom.sync([]);
+       }
+   }, {
+       provide: plugin => EditorView$3.scrollMargins.of(view => {
+           let value = view.plugin(plugin);
+           return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
+       })
+   });
+   let PanelGroup$2 = class PanelGroup {
+       constructor(view, top, container) {
+           this.view = view;
+           this.top = top;
+           this.container = container;
+           this.dom = undefined;
+           this.classes = "";
+           this.panels = [];
+           this.syncClasses();
+       }
+       sync(panels) {
+           for (let p of this.panels)
+               if (p.destroy && panels.indexOf(p) < 0)
+                   p.destroy();
+           this.panels = panels;
+           this.syncDOM();
+       }
+       syncDOM() {
+           if (this.panels.length == 0) {
+               if (this.dom) {
+                   this.dom.remove();
+                   this.dom = undefined;
+               }
+               return;
+           }
+           if (!this.dom) {
+               this.dom = document.createElement("div");
+               this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
+               this.dom.style[this.top ? "top" : "bottom"] = "0";
+               let parent = this.container || this.view.dom;
+               parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
+           }
+           let curDOM = this.dom.firstChild;
+           for (let panel of this.panels) {
+               if (panel.dom.parentNode == this.dom) {
+                   while (curDOM != panel.dom)
+                       curDOM = rm$3(curDOM);
+                   curDOM = curDOM.nextSibling;
+               }
+               else {
+                   this.dom.insertBefore(panel.dom, curDOM);
+               }
+           }
+           while (curDOM)
+               curDOM = rm$3(curDOM);
+       }
+       scrollMargin() {
+           return !this.dom || this.container ? 0
+               : Math.max(0, this.top ?
+                   this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
+                   Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
+       }
+       syncClasses() {
+           if (!this.container || this.classes == this.view.themeClasses)
+               return;
+           for (let cls of this.classes.split(" "))
+               if (cls)
+                   this.container.classList.remove(cls);
+           for (let cls of (this.classes = this.view.themeClasses).split(" "))
+               if (cls)
+                   this.container.classList.add(cls);
+       }
+   };
+   function rm$3(node) {
+       let next = node.nextSibling;
+       node.remove();
+       return next;
+   }
+   /**
+   Opening a panel is done by providing a constructor function for
+   the panel through this facet. (The panel is closed again when its
+   constructor is no longer provided.) Values of `null` are ignored.
+   */
+   const showPanel$2 = /*@__PURE__*/Facet$3.define({
+       enables: panelPlugin$2
+   });
+
+   /**
+   A gutter marker represents a bit of information attached to a line
+   in a specific gutter. Your own custom markers have to extend this
+   class.
+   */
+   let GutterMarker$3 = class GutterMarker extends RangeValue$3 {
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       Compare this marker to another marker of the same type.
+       */
+       eq(other) { return false; }
+       /**
+       Called if the marker has a `toDOM` method and its representation
+       was removed from a gutter.
+       */
+       destroy(dom) { }
+   };
+   GutterMarker$3.prototype.elementClass = "";
+   GutterMarker$3.prototype.toDOM = undefined;
+   GutterMarker$3.prototype.mapMode = MapMode$3.TrackBefore;
+   GutterMarker$3.prototype.startSide = GutterMarker$3.prototype.endSide = -1;
+   GutterMarker$3.prototype.point = true;
+   /**
+   Facet used to add a class to all gutter elements for a given line.
+   Markers given to this facet should _only_ define an
+   [`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a
+   [`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear
+   in all gutters for the line).
+   */
+   const gutterLineClass$1 = /*@__PURE__*/Facet$3.define();
+   const defaults$2 = {
+       class: "",
+       renderEmptyElements: false,
+       elementStyle: "",
+       markers: () => RangeSet$3.empty,
+       lineMarker: () => null,
+       lineMarkerChange: null,
+       initialSpacer: null,
+       updateSpacer: null,
+       domEventHandlers: {}
+   };
+   const activeGutters$1 = /*@__PURE__*/Facet$3.define();
+   /**
+   Define an editor gutter. The order in which the gutters appear is
+   determined by their extension priority.
+   */
+   function gutter$1(config) {
+       return [gutters$1(), activeGutters$1.of(Object.assign(Object.assign({}, defaults$2), config))];
+   }
+   const unfixGutters$1 = /*@__PURE__*/Facet$3.define({
+       combine: values => values.some(x => x)
+   });
+   /**
+   The gutter-drawing plugin is automatically enabled when you add a
+   gutter, but you can use this function to explicitly configure it.
+
+   Unless `fixed` is explicitly set to `false`, the gutters are
+   fixed, meaning they don't scroll along with the content
+   horizontally (except on Internet Explorer, which doesn't support
+   CSS [`position:
+   sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
+   */
+   function gutters$1(config) {
+       let result = [
+           gutterView$1,
+       ];
+       return result;
+   }
+   const gutterView$1 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.prevViewport = view.viewport;
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-gutters";
+           this.dom.setAttribute("aria-hidden", "true");
+           this.dom.style.minHeight = this.view.contentHeight + "px";
+           this.gutters = view.state.facet(activeGutters$1).map(conf => new SingleGutterView$1(view, conf));
+           for (let gutter of this.gutters)
+               this.dom.appendChild(gutter.dom);
+           this.fixed = !view.state.facet(unfixGutters$1);
+           if (this.fixed) {
+               // FIXME IE11 fallback, which doesn't support position: sticky,
+               // by using position: relative + event handlers that realign the
+               // gutter (or just force fixed=false on IE11?)
+               this.dom.style.position = "sticky";
+           }
+           this.syncGutters(false);
+           view.scrollDOM.insertBefore(this.dom, view.contentDOM);
+       }
+       update(update) {
+           if (this.updateGutters(update)) {
+               // Detach during sync when the viewport changed significantly
+               // (such as during scrolling), since for large updates that is
+               // faster.
+               let vpA = this.prevViewport, vpB = update.view.viewport;
+               let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);
+               this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);
+           }
+           if (update.geometryChanged)
+               this.dom.style.minHeight = this.view.contentHeight + "px";
+           if (this.view.state.facet(unfixGutters$1) != !this.fixed) {
+               this.fixed = !this.fixed;
+               this.dom.style.position = this.fixed ? "sticky" : "";
+           }
+           this.prevViewport = update.view.viewport;
+       }
+       syncGutters(detach) {
+           let after = this.dom.nextSibling;
+           if (detach)
+               this.dom.remove();
+           let lineClasses = RangeSet$3.iter(this.view.state.facet(gutterLineClass$1), this.view.viewport.from);
+           let classSet = [];
+           let contexts = this.gutters.map(gutter => new UpdateContext$1(gutter, this.view.viewport, -this.view.documentPadding.top));
+           for (let line of this.view.viewportLineBlocks) {
+               let text;
+               if (Array.isArray(line.type)) {
+                   for (let b of line.type)
+                       if (b.type == BlockType$3.Text) {
+                           text = b;
+                           break;
+                       }
+               }
+               else {
+                   text = line.type == BlockType$3.Text ? line : undefined;
+               }
+               if (!text)
+                   continue;
+               if (classSet.length)
+                   classSet = [];
+               advanceCursor$1(lineClasses, classSet, line.from);
+               for (let cx of contexts)
+                   cx.line(this.view, text, classSet);
+           }
+           for (let cx of contexts)
+               cx.finish();
+           if (detach)
+               this.view.scrollDOM.insertBefore(this.dom, after);
+       }
+       updateGutters(update) {
+           let prev = update.startState.facet(activeGutters$1), cur = update.state.facet(activeGutters$1);
+           let change = update.docChanged || update.heightChanged || update.viewportChanged ||
+               !RangeSet$3.eq(update.startState.facet(gutterLineClass$1), update.state.facet(gutterLineClass$1), update.view.viewport.from, update.view.viewport.to);
+           if (prev == cur) {
+               for (let gutter of this.gutters)
+                   if (gutter.update(update))
+                       change = true;
+           }
+           else {
+               change = true;
+               let gutters = [];
+               for (let conf of cur) {
+                   let known = prev.indexOf(conf);
+                   if (known < 0) {
+                       gutters.push(new SingleGutterView$1(this.view, conf));
+                   }
+                   else {
+                       this.gutters[known].update(update);
+                       gutters.push(this.gutters[known]);
+                   }
+               }
+               for (let g of this.gutters) {
+                   g.dom.remove();
+                   if (gutters.indexOf(g) < 0)
+                       g.destroy();
+               }
+               for (let g of gutters)
+                   this.dom.appendChild(g.dom);
+               this.gutters = gutters;
+           }
+           return change;
+       }
+       destroy() {
+           for (let view of this.gutters)
+               view.destroy();
+           this.dom.remove();
+       }
+   }, {
+       provide: plugin => EditorView$3.scrollMargins.of(view => {
+           let value = view.plugin(plugin);
+           if (!value || value.gutters.length == 0 || !value.fixed)
+               return null;
+           return view.textDirection == Direction$3.LTR ? { left: value.dom.offsetWidth } : { right: value.dom.offsetWidth };
+       })
+   });
+   function asArray$4(val) { return (Array.isArray(val) ? val : [val]); }
+   function advanceCursor$1(cursor, collect, pos) {
+       while (cursor.value && cursor.from <= pos) {
+           if (cursor.from == pos)
+               collect.push(cursor.value);
+           cursor.next();
+       }
+   }
+   let UpdateContext$1 = class UpdateContext {
+       constructor(gutter, viewport, height) {
+           this.gutter = gutter;
+           this.height = height;
+           this.localMarkers = [];
+           this.i = 0;
+           this.cursor = RangeSet$3.iter(gutter.markers, viewport.from);
+       }
+       line(view, line, extraMarkers) {
+           if (this.localMarkers.length)
+               this.localMarkers = [];
+           advanceCursor$1(this.cursor, this.localMarkers, line.from);
+           let localMarkers = extraMarkers.length ? this.localMarkers.concat(extraMarkers) : this.localMarkers;
+           let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
+           if (forLine)
+               localMarkers.unshift(forLine);
+           let gutter = this.gutter;
+           if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
+               return;
+           let above = line.top - this.height;
+           if (this.i == gutter.elements.length) {
+               let newElt = new GutterElement$1(view, line.height, above, localMarkers);
+               gutter.elements.push(newElt);
+               gutter.dom.appendChild(newElt.dom);
+           }
+           else {
+               gutter.elements[this.i].update(view, line.height, above, localMarkers);
+           }
+           this.height = line.bottom;
+           this.i++;
+       }
+       finish() {
+           let gutter = this.gutter;
+           while (gutter.elements.length > this.i) {
+               let last = gutter.elements.pop();
+               gutter.dom.removeChild(last.dom);
+               last.destroy();
+           }
+       }
+   };
+   let SingleGutterView$1 = class SingleGutterView {
+       constructor(view, config) {
+           this.view = view;
+           this.config = config;
+           this.elements = [];
+           this.spacer = null;
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
+           for (let prop in config.domEventHandlers) {
+               this.dom.addEventListener(prop, (event) => {
+                   let line = view.lineBlockAtHeight(event.clientY - view.documentTop);
+                   if (config.domEventHandlers[prop](view, line, event))
+                       event.preventDefault();
+               });
+           }
+           this.markers = asArray$4(config.markers(view));
+           if (config.initialSpacer) {
+               this.spacer = new GutterElement$1(view, 0, 0, [config.initialSpacer(view)]);
+               this.dom.appendChild(this.spacer.dom);
+               this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none";
+           }
+       }
+       update(update) {
+           let prevMarkers = this.markers;
+           this.markers = asArray$4(this.config.markers(update.view));
+           if (this.spacer && this.config.updateSpacer) {
+               let updated = this.config.updateSpacer(this.spacer.markers[0], update);
+               if (updated != this.spacer.markers[0])
+                   this.spacer.update(update.view, 0, 0, [updated]);
+           }
+           let vp = update.view.viewport;
+           return !RangeSet$3.eq(this.markers, prevMarkers, vp.from, vp.to) ||
+               (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);
+       }
+       destroy() {
+           for (let elt of this.elements)
+               elt.destroy();
+       }
+   };
+   let GutterElement$1 = class GutterElement {
+       constructor(view, height, above, markers) {
+           this.height = -1;
+           this.above = 0;
+           this.markers = [];
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-gutterElement";
+           this.update(view, height, above, markers);
+       }
+       update(view, height, above, markers) {
+           if (this.height != height)
+               this.dom.style.height = (this.height = height) + "px";
+           if (this.above != above)
+               this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
+           if (!sameMarkers$1(this.markers, markers))
+               this.setMarkers(view, markers);
+       }
+       setMarkers(view, markers) {
+           let cls = "cm-gutterElement", domPos = this.dom.firstChild;
+           for (let iNew = 0, iOld = 0;;) {
+               let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;
+               if (marker) {
+                   let c = marker.elementClass;
+                   if (c)
+                       cls += " " + c;
+                   for (let i = iOld; i < this.markers.length; i++)
+                       if (this.markers[i].compare(marker)) {
+                           skipTo = i;
+                           matched = true;
+                           break;
+                       }
+               }
+               else {
+                   skipTo = this.markers.length;
+               }
+               while (iOld < skipTo) {
+                   let next = this.markers[iOld++];
+                   if (next.toDOM) {
+                       next.destroy(domPos);
+                       let after = domPos.nextSibling;
+                       domPos.remove();
+                       domPos = after;
+                   }
+               }
+               if (!marker)
+                   break;
+               if (marker.toDOM) {
+                   if (matched)
+                       domPos = domPos.nextSibling;
+                   else
+                       this.dom.insertBefore(marker.toDOM(view), domPos);
+               }
+               if (matched)
+                   iOld++;
+           }
+           this.dom.className = cls;
+           this.markers = markers;
+       }
+       destroy() {
+           this.setMarkers(null, []); // First argument not used unless creating markers
+       }
+   };
+   function sameMarkers$1(a, b) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (!a[i].compare(b[i]))
+               return false;
+       return true;
+   }
+   /**
+   Facet used to provide markers to the line number gutter.
+   */
+   const lineNumberMarkers$1 = /*@__PURE__*/Facet$3.define();
+   const lineNumberConfig$1 = /*@__PURE__*/Facet$3.define({
+       combine(values) {
+           return combineConfig$3(values, { formatNumber: String, domEventHandlers: {} }, {
+               domEventHandlers(a, b) {
+                   let result = Object.assign({}, a);
+                   for (let event in b) {
+                       let exists = result[event], add = b[event];
+                       result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;
+                   }
+                   return result;
+               }
+           });
+       }
+   });
+   let NumberMarker$1 = class NumberMarker extends GutterMarker$3 {
+       constructor(number) {
+           super();
+           this.number = number;
+       }
+       eq(other) { return this.number == other.number; }
+       toDOM() { return document.createTextNode(this.number); }
+   };
+   function formatNumber$1(view, number) {
+       return view.state.facet(lineNumberConfig$1).formatNumber(number, view.state);
+   }
+   const lineNumberGutter$1 = /*@__PURE__*/activeGutters$1.compute([lineNumberConfig$1], state => ({
+       class: "cm-lineNumbers",
+       renderEmptyElements: false,
+       markers(view) { return view.state.facet(lineNumberMarkers$1); },
+       lineMarker(view, line, others) {
+           if (others.some(m => m.toDOM))
+               return null;
+           return new NumberMarker$1(formatNumber$1(view, view.state.doc.lineAt(line.from).number));
+       },
+       lineMarkerChange: update => update.startState.facet(lineNumberConfig$1) != update.state.facet(lineNumberConfig$1),
+       initialSpacer(view) {
+           return new NumberMarker$1(formatNumber$1(view, maxLineNumber$1(view.state.doc.lines)));
+       },
+       updateSpacer(spacer, update) {
+           let max = formatNumber$1(update.view, maxLineNumber$1(update.view.state.doc.lines));
+           return max == spacer.number ? spacer : new NumberMarker$1(max);
+       },
+       domEventHandlers: state.facet(lineNumberConfig$1).domEventHandlers
+   }));
+   /**
+   Create a line number gutter extension.
+   */
+   function lineNumbers$1(config = {}) {
+       return [
+           lineNumberConfig$1.of(config),
+           gutters$1(),
+           lineNumberGutter$1
+       ];
+   }
+   function maxLineNumber$1(lines) {
+       let last = 9;
+       while (last < lines)
+           last = last * 10 + 9;
+       return last;
+   }
+   const activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker$3 {
+       constructor() {
+           super(...arguments);
+           this.elementClass = "cm-activeLineGutter";
+       }
+   };
+   const activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass$1.compute(["selection"], state => {
+       let marks = [], last = -1;
+       for (let range of state.selection.ranges)
+           if (range.empty) {
+               let linePos = state.doc.lineAt(range.head).from;
+               if (linePos > last) {
+                   last = linePos;
+                   marks.push(activeLineGutterMarker.range(linePos));
+               }
+           }
+       return RangeSet$3.of(marks);
+   });
+   /**
+   Returns an extension that adds a `cm-activeLineGutter` class to
+   all gutter elements on the [active
+   line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
+   */
+   function highlightActiveLineGutter() {
+       return activeLineGutterHighlighter;
+   }
+
+   // FIXME profile adding a per-Tree TreeNode cache, validating it by
+   // parent pointer
+   /// The default maximum length of a `TreeBuffer` node (1024).
+   const DefaultBufferLength$2 = 1024;
+   let nextPropID$2 = 0;
+   let Range$5 = class Range {
+       constructor(from, to) {
+           this.from = from;
+           this.to = to;
+       }
+   };
+   /// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
+   /// can have metadata associated with it in props. Instances of this
+   /// class represent prop names.
+   let NodeProp$2 = class NodeProp {
+       /// Create a new node prop type.
+       constructor(config = {}) {
+           this.id = nextPropID$2++;
+           this.perNode = !!config.perNode;
+           this.deserialize = config.deserialize || (() => {
+               throw new Error("This node type doesn't define a deserialize function");
+           });
+       }
+       /// This is meant to be used with
+       /// [`NodeSet.extend`](#common.NodeSet.extend) or
+       /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
+       /// prop values for each node type in the set. Takes a [match
+       /// object](#common.NodeType^match) or function that returns undefined
+       /// if the node type doesn't get this prop, and the prop's value if
+       /// it does.
+       add(match) {
+           if (this.perNode)
+               throw new RangeError("Can't add per-node props to node types");
+           if (typeof match != "function")
+               match = NodeType$2.match(match);
+           return (type) => {
+               let result = match(type);
+               return result === undefined ? null : [this, result];
+           };
+       }
+   };
+   /// Prop that is used to describe matching delimiters. For opening
+   /// delimiters, this holds an array of node names (written as a
+   /// space-separated string when declaring this prop in a grammar)
+   /// for the node types of closing delimiters that match it.
+   NodeProp$2.closedBy = new NodeProp$2({ deserialize: str => str.split(" ") });
+   /// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
+   /// attached to closing delimiters, holding an array of node names
+   /// of types of matching opening delimiters.
+   NodeProp$2.openedBy = new NodeProp$2({ deserialize: str => str.split(" ") });
+   /// Used to assign node types to groups (for example, all node
+   /// types that represent an expression could be tagged with an
+   /// `"Expression"` group).
+   NodeProp$2.group = new NodeProp$2({ deserialize: str => str.split(" ") });
+   /// The hash of the [context](#lr.ContextTracker.constructor)
+   /// that the node was parsed in, if any. Used to limit reuse of
+   /// contextual nodes.
+   NodeProp$2.contextHash = new NodeProp$2({ perNode: true });
+   /// The distance beyond the end of the node that the tokenizer
+   /// looked ahead for any of the tokens inside the node. (The LR
+   /// parser only stores this when it is larger than 25, for
+   /// efficiency reasons.)
+   NodeProp$2.lookAhead = new NodeProp$2({ perNode: true });
+   /// This per-node prop is used to replace a given node, or part of a
+   /// node, with another tree. This is useful to include trees from
+   /// different languages.
+   NodeProp$2.mounted = new NodeProp$2({ perNode: true });
+   const noProps$2 = Object.create(null);
+   /// Each node in a syntax tree has a node type associated with it.
+   let NodeType$2 = class NodeType {
+       /// @internal
+       constructor(
+       /// The name of the node type. Not necessarily unique, but if the
+       /// grammar was written properly, different node types with the
+       /// same name within a node set should play the same semantic
+       /// role.
+       name, 
+       /// @internal
+       props, 
+       /// The id of this node in its set. Corresponds to the term ids
+       /// used in the parser.
+       id, 
+       /// @internal
+       flags = 0) {
+           this.name = name;
+           this.props = props;
+           this.id = id;
+           this.flags = flags;
+       }
+       static define(spec) {
+           let props = spec.props && spec.props.length ? Object.create(null) : noProps$2;
+           let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
+               (spec.error ? 4 /* Error */ : 0) | (spec.name == null ? 8 /* Anonymous */ : 0);
+           let type = new NodeType(spec.name || "", props, spec.id, flags);
+           if (spec.props)
+               for (let src of spec.props) {
+                   if (!Array.isArray(src))
+                       src = src(type);
+                   if (src) {
+                       if (src[0].perNode)
+                           throw new RangeError("Can't store a per-node prop on a node type");
+                       props[src[0].id] = src[1];
+                   }
+               }
+           return type;
+       }
+       /// Retrieves a node prop for this type. Will return `undefined` if
+       /// the prop isn't present on this node.
+       prop(prop) { return this.props[prop.id]; }
+       /// True when this is the top node of a grammar.
+       get isTop() { return (this.flags & 1 /* Top */) > 0; }
+       /// True when this node is produced by a skip rule.
+       get isSkipped() { return (this.flags & 2 /* Skipped */) > 0; }
+       /// Indicates whether this is an error node.
+       get isError() { return (this.flags & 4 /* Error */) > 0; }
+       /// When true, this node type doesn't correspond to a user-declared
+       /// named node, for example because it is used to cache repetition.
+       get isAnonymous() { return (this.flags & 8 /* Anonymous */) > 0; }
+       /// Returns true when this node's name or one of its
+       /// [groups](#common.NodeProp^group) matches the given string.
+       is(name) {
+           if (typeof name == 'string') {
+               if (this.name == name)
+                   return true;
+               let group = this.prop(NodeProp$2.group);
+               return group ? group.indexOf(name) > -1 : false;
+           }
+           return this.id == name;
+       }
+       /// Create a function from node types to arbitrary values by
+       /// specifying an object whose property names are node or
+       /// [group](#common.NodeProp^group) names. Often useful with
+       /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
+       /// names, separated by spaces, in a single property name to map
+       /// multiple node names to a single value.
+       static match(map) {
+           let direct = Object.create(null);
+           for (let prop in map)
+               for (let name of prop.split(" "))
+                   direct[name] = map[prop];
+           return (node) => {
+               for (let groups = node.prop(NodeProp$2.group), i = -1; i < (groups ? groups.length : 0); i++) {
+                   let found = direct[i < 0 ? node.name : groups[i]];
+                   if (found)
+                       return found;
+               }
+           };
+       }
+   };
+   /// An empty dummy node type to use when no actual type is available.
+   NodeType$2.none = new NodeType$2("", Object.create(null), 0, 8 /* Anonymous */);
+   const CachedNode$2 = new WeakMap(), CachedInnerNode$2 = new WeakMap();
+   /// Options that control iteration. Can be combined with the `|`
+   /// operator to enable multiple ones.
+   var IterMode$2;
+   (function (IterMode) {
+       /// When enabled, iteration will only visit [`Tree`](#common.Tree)
+       /// objects, not nodes packed into
+       /// [`TreeBuffer`](#common.TreeBuffer)s.
+       IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
+       /// Enable this to make iteration include anonymous nodes (such as
+       /// the nodes that wrap repeated grammar constructs into a balanced
+       /// tree).
+       IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
+       /// By default, regular [mounted](#common.NodeProp^mounted) nodes
+       /// replace their base node in iteration. Enable this to ignore them
+       /// instead.
+       IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
+       /// This option only applies in
+       /// [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
+       /// library to not enter mounted overlays if one covers the given
+       /// position.
+       IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
+   })(IterMode$2 || (IterMode$2 = {}));
+   /// A piece of syntax tree. There are two ways to approach these
+   /// trees: the way they are actually stored in memory, and the
+   /// convenient way.
+   ///
+   /// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
+   /// objects. By packing detail information into `TreeBuffer` leaf
+   /// nodes, the representation is made a lot more memory-efficient.
+   ///
+   /// However, when you want to actually work with tree nodes, this
+   /// representation is very awkward, so most client code will want to
+   /// use the [`TreeCursor`](#common.TreeCursor) or
+   /// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
+   /// a view on some part of this data structure, and can be used to
+   /// move around to adjacent nodes.
+   let Tree$2 = class Tree {
+       /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
+       constructor(
+       /// The type of the top node.
+       type, 
+       /// This node's child nodes.
+       children, 
+       /// The positions (offsets relative to the start of this tree) of
+       /// the children.
+       positions, 
+       /// The total length of this tree
+       length, 
+       /// Per-node [node props](#common.NodeProp) to associate with this node.
+       props) {
+           this.type = type;
+           this.children = children;
+           this.positions = positions;
+           this.length = length;
+           /// @internal
+           this.props = null;
+           if (props && props.length) {
+               this.props = Object.create(null);
+               for (let [prop, value] of props)
+                   this.props[typeof prop == "number" ? prop : prop.id] = value;
+           }
+       }
+       /// @internal
+       toString() {
+           let mounted = this.prop(NodeProp$2.mounted);
+           if (mounted && !mounted.overlay)
+               return mounted.tree.toString();
+           let children = "";
+           for (let ch of this.children) {
+               let str = ch.toString();
+               if (str) {
+                   if (children)
+                       children += ",";
+                   children += str;
+               }
+           }
+           return !this.type.name ? children :
+               (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
+                   (children.length ? "(" + children + ")" : "");
+       }
+       /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
+       /// the tree. Mode can be used to [control](#common.IterMode) which
+       /// nodes the cursor visits.
+       cursor(mode = 0) {
+           return new TreeCursor$2(this.topNode, mode);
+       }
+       /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
+       /// at the given position and side (see
+       /// [`moveTo`](#common.TreeCursor.moveTo).
+       cursorAt(pos, side = 0, mode = 0) {
+           let scope = CachedNode$2.get(this) || this.topNode;
+           let cursor = new TreeCursor$2(scope);
+           cursor.moveTo(pos, side);
+           CachedNode$2.set(this, cursor._tree);
+           return cursor;
+       }
+       /// Get a [syntax node](#common.SyntaxNode) object for the top of the
+       /// tree.
+       get topNode() {
+           return new TreeNode$2(this, 0, 0, null);
+       }
+       /// Get the [syntax node](#common.SyntaxNode) at the given position.
+       /// If `side` is -1, this will move into nodes that end at the
+       /// position. If 1, it'll move into nodes that start at the
+       /// position. With 0, it'll only enter nodes that cover the position
+       /// from both sides.
+       resolve(pos, side = 0) {
+           let node = resolveNode$2(CachedNode$2.get(this) || this.topNode, pos, side, false);
+           CachedNode$2.set(this, node);
+           return node;
+       }
+       /// Like [`resolve`](#common.Tree.resolve), but will enter
+       /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
+       /// pointing into the innermost overlaid tree at the given position
+       /// (with parent links going through all parent structure, including
+       /// the host trees).
+       resolveInner(pos, side = 0) {
+           let node = resolveNode$2(CachedInnerNode$2.get(this) || this.topNode, pos, side, true);
+           CachedInnerNode$2.set(this, node);
+           return node;
+       }
+       /// Iterate over the tree and its children, calling `enter` for any
+       /// node that touches the `from`/`to` region (if given) before
+       /// running over such a node's children, and `leave` (if given) when
+       /// leaving the node. When `enter` returns `false`, that node will
+       /// not have its children iterated over (or `leave` called).
+       iterate(spec) {
+           let { enter, leave, from = 0, to = this.length } = spec;
+           for (let c = this.cursor((spec.mode || 0) | IterMode$2.IncludeAnonymous);;) {
+               let entered = false;
+               if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
+                   if (c.firstChild())
+                       continue;
+                   entered = true;
+               }
+               for (;;) {
+                   if (entered && leave && !c.type.isAnonymous)
+                       leave(c);
+                   if (c.nextSibling())
+                       break;
+                   if (!c.parent())
+                       return;
+                   entered = true;
+               }
+           }
+       }
+       /// Get the value of the given [node prop](#common.NodeProp) for this
+       /// node. Works with both per-node and per-type props.
+       prop(prop) {
+           return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
+       }
+       /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
+       /// format that can be passed to the [`Tree`](#common.Tree)
+       /// constructor.
+       get propValues() {
+           let result = [];
+           if (this.props)
+               for (let id in this.props)
+                   result.push([+id, this.props[id]]);
+           return result;
+       }
+       /// Balance the direct children of this tree, producing a copy of
+       /// which may have children grouped into subtrees with type
+       /// [`NodeType.none`](#common.NodeType^none).
+       balance(config = {}) {
+           return this.children.length <= 8 /* BranchFactor */ ? this :
+               balanceRange$2(NodeType$2.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType$2.none, children, positions, length)));
+       }
+       /// Build a tree from a postfix-ordered buffer of node information,
+       /// or a cursor over such a buffer.
+       static build(data) { return buildTree$2(data); }
+   };
+   /// The empty tree
+   Tree$2.empty = new Tree$2(NodeType$2.none, [], [], 0);
+   let FlatBufferCursor$2 = class FlatBufferCursor {
+       constructor(buffer, index) {
+           this.buffer = buffer;
+           this.index = index;
+       }
+       get id() { return this.buffer[this.index - 4]; }
+       get start() { return this.buffer[this.index - 3]; }
+       get end() { return this.buffer[this.index - 2]; }
+       get size() { return this.buffer[this.index - 1]; }
+       get pos() { return this.index; }
+       next() { this.index -= 4; }
+       fork() { return new FlatBufferCursor(this.buffer, this.index); }
+   };
+   /// Tree buffers contain (type, start, end, endIndex) quads for each
+   /// node. In such a buffer, nodes are stored in prefix order (parents
+   /// before children, with the endIndex of the parent indicating which
+   /// children belong to it)
+   let TreeBuffer$2 = class TreeBuffer {
+       /// Create a tree buffer.
+       constructor(
+       /// The buffer's content.
+       buffer, 
+       /// The total length of the group of nodes in the buffer.
+       length, 
+       /// The node set used in this buffer.
+       set) {
+           this.buffer = buffer;
+           this.length = length;
+           this.set = set;
+       }
+       /// @internal
+       get type() { return NodeType$2.none; }
+       /// @internal
+       toString() {
+           let result = [];
+           for (let index = 0; index < this.buffer.length;) {
+               result.push(this.childString(index));
+               index = this.buffer[index + 3];
+           }
+           return result.join(",");
+       }
+       /// @internal
+       childString(index) {
+           let id = this.buffer[index], endIndex = this.buffer[index + 3];
+           let type = this.set.types[id], result = type.name;
+           if (/\W/.test(result) && !type.isError)
+               result = JSON.stringify(result);
+           index += 4;
+           if (endIndex == index)
+               return result;
+           let children = [];
+           while (index < endIndex) {
+               children.push(this.childString(index));
+               index = this.buffer[index + 3];
+           }
+           return result + "(" + children.join(",") + ")";
+       }
+       /// @internal
+       findChild(startIndex, endIndex, dir, pos, side) {
+           let { buffer } = this, pick = -1;
+           for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
+               if (checkSide$2(side, pos, buffer[i + 1], buffer[i + 2])) {
+                   pick = i;
+                   if (dir > 0)
+                       break;
+               }
+           }
+           return pick;
+       }
+       /// @internal
+       slice(startI, endI, from, to) {
+           let b = this.buffer;
+           let copy = new Uint16Array(endI - startI);
+           for (let i = startI, j = 0; i < endI;) {
+               copy[j++] = b[i++];
+               copy[j++] = b[i++] - from;
+               copy[j++] = b[i++] - from;
+               copy[j++] = b[i++] - startI;
+           }
+           return new TreeBuffer(copy, to - from, this.set);
+       }
+   };
+   function checkSide$2(side, pos, from, to) {
+       switch (side) {
+           case -2 /* Before */: return from < pos;
+           case -1 /* AtOrBefore */: return to >= pos && from < pos;
+           case 0 /* Around */: return from < pos && to > pos;
+           case 1 /* AtOrAfter */: return from <= pos && to > pos;
+           case 2 /* After */: return to > pos;
+           case 4 /* DontCare */: return true;
+       }
+   }
+   function enterUnfinishedNodesBefore$1(node, pos) {
+       let scan = node.childBefore(pos);
+       while (scan) {
+           let last = scan.lastChild;
+           if (!last || last.to != scan.to)
+               break;
+           if (last.type.isError && last.from == last.to) {
+               node = scan;
+               scan = last.prevSibling;
+           }
+           else {
+               scan = last;
+           }
+       }
+       return node;
+   }
+   function resolveNode$2(node, pos, side, overlays) {
+       var _a;
+       // Move up to a node that actually holds the position, if possible
+       while (node.from == node.to ||
+           (side < 1 ? node.from >= pos : node.from > pos) ||
+           (side > -1 ? node.to <= pos : node.to < pos)) {
+           let parent = !overlays && node instanceof TreeNode$2 && node.index < 0 ? null : node.parent;
+           if (!parent)
+               return node;
+           node = parent;
+       }
+       let mode = overlays ? 0 : IterMode$2.IgnoreOverlays;
+       // Must go up out of overlays when those do not overlap with pos
+       if (overlays)
+           for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
+               if (scan instanceof TreeNode$2 && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
+                   node = parent;
+           }
+       for (;;) {
+           let inner = node.enter(pos, side, mode);
+           if (!inner)
+               return node;
+           node = inner;
+       }
+   }
+   let TreeNode$2 = class TreeNode {
+       constructor(_tree, from, 
+       // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
+       index, _parent) {
+           this._tree = _tree;
+           this.from = from;
+           this.index = index;
+           this._parent = _parent;
+       }
+       get type() { return this._tree.type; }
+       get name() { return this._tree.type.name; }
+       get to() { return this.from + this._tree.length; }
+       nextChild(i, dir, pos, side, mode = 0) {
+           for (let parent = this;;) {
+               for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
+                   let next = children[i], start = positions[i] + parent.from;
+                   if (!checkSide$2(side, pos, start, start + next.length))
+                       continue;
+                   if (next instanceof TreeBuffer$2) {
+                       if (mode & IterMode$2.ExcludeBuffers)
+                           continue;
+                       let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
+                       if (index > -1)
+                           return new BufferNode$2(new BufferContext$2(parent, next, i, start), null, index);
+                   }
+                   else if ((mode & IterMode$2.IncludeAnonymous) || (!next.type.isAnonymous || hasChild$2(next))) {
+                       let mounted;
+                       if (!(mode & IterMode$2.IgnoreMounts) &&
+                           next.props && (mounted = next.prop(NodeProp$2.mounted)) && !mounted.overlay)
+                           return new TreeNode(mounted.tree, start, i, parent);
+                       let inner = new TreeNode(next, start, i, parent);
+                       return (mode & IterMode$2.IncludeAnonymous) || !inner.type.isAnonymous ? inner
+                           : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
+                   }
+               }
+               if ((mode & IterMode$2.IncludeAnonymous) || !parent.type.isAnonymous)
+                   return null;
+               if (parent.index >= 0)
+                   i = parent.index + dir;
+               else
+                   i = dir < 0 ? -1 : parent._parent._tree.children.length;
+               parent = parent._parent;
+               if (!parent)
+                   return null;
+           }
+       }
+       get firstChild() { return this.nextChild(0, 1, 0, 4 /* DontCare */); }
+       get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* DontCare */); }
+       childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* After */); }
+       childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Before */); }
+       enter(pos, side, mode = 0) {
+           let mounted;
+           if (!(mode & IterMode$2.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp$2.mounted)) && mounted.overlay) {
+               let rPos = pos - this.from;
+               for (let { from, to } of mounted.overlay) {
+                   if ((side > 0 ? from <= rPos : from < rPos) &&
+                       (side < 0 ? to >= rPos : to > rPos))
+                       return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
+               }
+           }
+           return this.nextChild(0, 1, pos, side, mode);
+       }
+       nextSignificantParent() {
+           let val = this;
+           while (val.type.isAnonymous && val._parent)
+               val = val._parent;
+           return val;
+       }
+       get parent() {
+           return this._parent ? this._parent.nextSignificantParent() : null;
+       }
+       get nextSibling() {
+           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* DontCare */) : null;
+       }
+       get prevSibling() {
+           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* DontCare */) : null;
+       }
+       cursor(mode = 0) { return new TreeCursor$2(this, mode); }
+       get tree() { return this._tree; }
+       toTree() { return this._tree; }
+       resolve(pos, side = 0) {
+           return resolveNode$2(this, pos, side, false);
+       }
+       resolveInner(pos, side = 0) {
+           return resolveNode$2(this, pos, side, true);
+       }
+       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore$1(this, pos); }
+       getChild(type, before = null, after = null) {
+           let r = getChildren$2(this, type, before, after);
+           return r.length ? r[0] : null;
+       }
+       getChildren(type, before = null, after = null) {
+           return getChildren$2(this, type, before, after);
+       }
+       /// @internal
+       toString() { return this._tree.toString(); }
+       get node() { return this; }
+       matchContext(context) { return matchNodeContext$2(this, context); }
+   };
+   function getChildren$2(node, type, before, after) {
+       let cur = node.cursor(), result = [];
+       if (!cur.firstChild())
+           return result;
+       if (before != null)
+           while (!cur.type.is(before))
+               if (!cur.nextSibling())
+                   return result;
+       for (;;) {
+           if (after != null && cur.type.is(after))
+               return result;
+           if (cur.type.is(type))
+               result.push(cur.node);
+           if (!cur.nextSibling())
+               return after == null ? result : [];
+       }
+   }
+   function matchNodeContext$2(node, context, i = context.length - 1) {
+       for (let p = node.parent; i >= 0; p = p.parent) {
+           if (!p)
+               return false;
+           if (!p.type.isAnonymous) {
+               if (context[i] && context[i] != p.name)
+                   return false;
+               i--;
+           }
+       }
+       return true;
+   }
+   let BufferContext$2 = class BufferContext {
+       constructor(parent, buffer, index, start) {
+           this.parent = parent;
+           this.buffer = buffer;
+           this.index = index;
+           this.start = start;
+       }
+   };
+   let BufferNode$2 = class BufferNode {
+       constructor(context, _parent, index) {
+           this.context = context;
+           this._parent = _parent;
+           this.index = index;
+           this.type = context.buffer.set.types[context.buffer.buffer[index]];
+       }
+       get name() { return this.type.name; }
+       get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
+       get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
+       child(dir, pos, side) {
+           let { buffer } = this.context;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
+           return index < 0 ? null : new BufferNode(this.context, this, index);
+       }
+       get firstChild() { return this.child(1, 0, 4 /* DontCare */); }
+       get lastChild() { return this.child(-1, 0, 4 /* DontCare */); }
+       childAfter(pos) { return this.child(1, pos, 2 /* After */); }
+       childBefore(pos) { return this.child(-1, pos, -2 /* Before */); }
+       enter(pos, side, mode = 0) {
+           if (mode & IterMode$2.ExcludeBuffers)
+               return null;
+           let { buffer } = this.context;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
+           return index < 0 ? null : new BufferNode(this.context, this, index);
+       }
+       get parent() {
+           return this._parent || this.context.parent.nextSignificantParent();
+       }
+       externalSibling(dir) {
+           return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* DontCare */);
+       }
+       get nextSibling() {
+           let { buffer } = this.context;
+           let after = buffer.buffer[this.index + 3];
+           if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
+               return new BufferNode(this.context, this._parent, after);
+           return this.externalSibling(1);
+       }
+       get prevSibling() {
+           let { buffer } = this.context;
+           let parentStart = this._parent ? this._parent.index + 4 : 0;
+           if (this.index == parentStart)
+               return this.externalSibling(-1);
+           return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
+       }
+       cursor(mode = 0) { return new TreeCursor$2(this, mode); }
+       get tree() { return null; }
+       toTree() {
+           let children = [], positions = [];
+           let { buffer } = this.context;
+           let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
+           if (endI > startI) {
+               let from = buffer.buffer[this.index + 1], to = buffer.buffer[this.index + 2];
+               children.push(buffer.slice(startI, endI, from, to));
+               positions.push(0);
+           }
+           return new Tree$2(this.type, children, positions, this.to - this.from);
+       }
+       resolve(pos, side = 0) {
+           return resolveNode$2(this, pos, side, false);
+       }
+       resolveInner(pos, side = 0) {
+           return resolveNode$2(this, pos, side, true);
+       }
+       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore$1(this, pos); }
+       /// @internal
+       toString() { return this.context.buffer.childString(this.index); }
+       getChild(type, before = null, after = null) {
+           let r = getChildren$2(this, type, before, after);
+           return r.length ? r[0] : null;
+       }
+       getChildren(type, before = null, after = null) {
+           return getChildren$2(this, type, before, after);
+       }
+       get node() { return this; }
+       matchContext(context) { return matchNodeContext$2(this, context); }
+   };
+   /// A tree cursor object focuses on a given node in a syntax tree, and
+   /// allows you to move to adjacent nodes.
+   let TreeCursor$2 = class TreeCursor {
+       /// @internal
+       constructor(node, 
+       /// @internal
+       mode = 0) {
+           this.mode = mode;
+           /// @internal
+           this.buffer = null;
+           this.stack = [];
+           /// @internal
+           this.index = 0;
+           this.bufferNode = null;
+           if (node instanceof TreeNode$2) {
+               this.yieldNode(node);
+           }
+           else {
+               this._tree = node.context.parent;
+               this.buffer = node.context;
+               for (let n = node._parent; n; n = n._parent)
+                   this.stack.unshift(n.index);
+               this.bufferNode = node;
+               this.yieldBuf(node.index);
+           }
+       }
+       /// Shorthand for `.type.name`.
+       get name() { return this.type.name; }
+       yieldNode(node) {
+           if (!node)
+               return false;
+           this._tree = node;
+           this.type = node.type;
+           this.from = node.from;
+           this.to = node.to;
+           return true;
+       }
+       yieldBuf(index, type) {
+           this.index = index;
+           let { start, buffer } = this.buffer;
+           this.type = type || buffer.set.types[buffer.buffer[index]];
+           this.from = start + buffer.buffer[index + 1];
+           this.to = start + buffer.buffer[index + 2];
+           return true;
+       }
+       yield(node) {
+           if (!node)
+               return false;
+           if (node instanceof TreeNode$2) {
+               this.buffer = null;
+               return this.yieldNode(node);
+           }
+           this.buffer = node.context;
+           return this.yieldBuf(node.index, node.type);
+       }
+       /// @internal
+       toString() {
+           return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
+       }
+       /// @internal
+       enterChild(dir, pos, side) {
+           if (!this.buffer)
+               return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
+           let { buffer } = this.buffer;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
+           if (index < 0)
+               return false;
+           this.stack.push(this.index);
+           return this.yieldBuf(index);
+       }
+       /// Move the cursor to this node's first child. When this returns
+       /// false, the node has no child, and the cursor has not been moved.
+       firstChild() { return this.enterChild(1, 0, 4 /* DontCare */); }
+       /// Move the cursor to this node's last child.
+       lastChild() { return this.enterChild(-1, 0, 4 /* DontCare */); }
+       /// Move the cursor to the first child that ends after `pos`.
+       childAfter(pos) { return this.enterChild(1, pos, 2 /* After */); }
+       /// Move to the last child that starts before `pos`.
+       childBefore(pos) { return this.enterChild(-1, pos, -2 /* Before */); }
+       /// Move the cursor to the child around `pos`. If side is -1 the
+       /// child may end at that position, when 1 it may start there. This
+       /// will also enter [overlaid](#common.MountedTree.overlay)
+       /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
+       /// set to false.
+       enter(pos, side, mode = this.mode) {
+           if (!this.buffer)
+               return this.yield(this._tree.enter(pos, side, mode));
+           return mode & IterMode$2.ExcludeBuffers ? false : this.enterChild(1, pos, side);
+       }
+       /// Move to the node's parent node, if this isn't the top node.
+       parent() {
+           if (!this.buffer)
+               return this.yieldNode((this.mode & IterMode$2.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
+           if (this.stack.length)
+               return this.yieldBuf(this.stack.pop());
+           let parent = (this.mode & IterMode$2.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
+           this.buffer = null;
+           return this.yieldNode(parent);
+       }
+       /// @internal
+       sibling(dir) {
+           if (!this.buffer)
+               return !this._tree._parent ? false
+                   : this.yield(this._tree.index < 0 ? null
+                       : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* DontCare */, this.mode));
+           let { buffer } = this.buffer, d = this.stack.length - 1;
+           if (dir < 0) {
+               let parentStart = d < 0 ? 0 : this.stack[d] + 4;
+               if (this.index != parentStart)
+                   return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
+           }
+           else {
+               let after = buffer.buffer[this.index + 3];
+               if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
+                   return this.yieldBuf(after);
+           }
+           return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* DontCare */, this.mode)) : false;
+       }
+       /// Move to this node's next sibling, if any.
+       nextSibling() { return this.sibling(1); }
+       /// Move to this node's previous sibling, if any.
+       prevSibling() { return this.sibling(-1); }
+       atLastNode(dir) {
+           let index, parent, { buffer } = this;
+           if (buffer) {
+               if (dir > 0) {
+                   if (this.index < buffer.buffer.buffer.length)
+                       return false;
+               }
+               else {
+                   for (let i = 0; i < this.index; i++)
+                       if (buffer.buffer.buffer[i + 3] < this.index)
+                           return false;
+               }
+               ({ index, parent } = buffer);
+           }
+           else {
+               ({ index, _parent: parent } = this._tree);
+           }
+           for (; parent; { index, _parent: parent } = parent) {
+               if (index > -1)
+                   for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
+                       let child = parent._tree.children[i];
+                       if ((this.mode & IterMode$2.IncludeAnonymous) ||
+                           child instanceof TreeBuffer$2 ||
+                           !child.type.isAnonymous ||
+                           hasChild$2(child))
+                           return false;
+                   }
+           }
+           return true;
+       }
+       move(dir, enter) {
+           if (enter && this.enterChild(dir, 0, 4 /* DontCare */))
+               return true;
+           for (;;) {
+               if (this.sibling(dir))
+                   return true;
+               if (this.atLastNode(dir) || !this.parent())
+                   return false;
+           }
+       }
+       /// Move to the next node in a
+       /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
+       /// traversal, going from a node to its first child or, if the
+       /// current node is empty or `enter` is false, its next sibling or
+       /// the next sibling of the first parent node that has one.
+       next(enter = true) { return this.move(1, enter); }
+       /// Move to the next node in a last-to-first pre-order traveral. A
+       /// node is followed by its last child or, if it has none, its
+       /// previous sibling or the previous sibling of the first parent
+       /// node that has one.
+       prev(enter = true) { return this.move(-1, enter); }
+       /// Move the cursor to the innermost node that covers `pos`. If
+       /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
+       /// it will enter nodes that start at `pos`.
+       moveTo(pos, side = 0) {
+           // Move up to a node that actually holds the position, if possible
+           while (this.from == this.to ||
+               (side < 1 ? this.from >= pos : this.from > pos) ||
+               (side > -1 ? this.to <= pos : this.to < pos))
+               if (!this.parent())
+                   break;
+           // Then scan down into child nodes as far as possible
+           while (this.enterChild(1, pos, side)) { }
+           return this;
+       }
+       /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
+       /// position.
+       get node() {
+           if (!this.buffer)
+               return this._tree;
+           let cache = this.bufferNode, result = null, depth = 0;
+           if (cache && cache.context == this.buffer) {
+               scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
+                   for (let c = cache; c; c = c._parent)
+                       if (c.index == index) {
+                           if (index == this.index)
+                               return c;
+                           result = c;
+                           depth = d + 1;
+                           break scan;
+                       }
+                   index = this.stack[--d];
+               }
+           }
+           for (let i = depth; i < this.stack.length; i++)
+               result = new BufferNode$2(this.buffer, result, this.stack[i]);
+           return this.bufferNode = new BufferNode$2(this.buffer, result, this.index);
+       }
+       /// Get the [tree](#common.Tree) that represents the current node, if
+       /// any. Will return null when the node is in a [tree
+       /// buffer](#common.TreeBuffer).
+       get tree() {
+           return this.buffer ? null : this._tree._tree;
+       }
+       /// Iterate over the current node and all its descendants, calling
+       /// `enter` when entering a node and `leave`, if given, when leaving
+       /// one. When `enter` returns `false`, any children of that node are
+       /// skipped, and `leave` isn't called for it.
+       iterate(enter, leave) {
+           for (let depth = 0;;) {
+               let mustLeave = false;
+               if (this.type.isAnonymous || enter(this) !== false) {
+                   if (this.firstChild()) {
+                       depth++;
+                       continue;
+                   }
+                   if (!this.type.isAnonymous)
+                       mustLeave = true;
+               }
+               for (;;) {
+                   if (mustLeave && leave)
+                       leave(this);
+                   mustLeave = this.type.isAnonymous;
+                   if (this.nextSibling())
+                       break;
+                   if (!depth)
+                       return;
+                   this.parent();
+                   depth--;
+                   mustLeave = true;
+               }
+           }
+       }
+       /// Test whether the current node matches a given context—a sequence
+       /// of direct parent node names. Empty strings in the context array
+       /// are treated as wildcards.
+       matchContext(context) {
+           if (!this.buffer)
+               return matchNodeContext$2(this.node, context);
+           let { buffer } = this.buffer, { types } = buffer.set;
+           for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
+               if (d < 0)
+                   return matchNodeContext$2(this.node, context, i);
+               let type = types[buffer.buffer[this.stack[d]]];
+               if (!type.isAnonymous) {
+                   if (context[i] && context[i] != type.name)
+                       return false;
+                   i--;
+               }
+           }
+           return true;
+       }
+   };
+   function hasChild$2(tree) {
+       return tree.children.some(ch => ch instanceof TreeBuffer$2 || !ch.type.isAnonymous || hasChild$2(ch));
+   }
+   function buildTree$2(data) {
+       var _a;
+       let { buffer, nodeSet, maxBufferLength = DefaultBufferLength$2, reused = [], minRepeatType = nodeSet.types.length } = data;
+       let cursor = Array.isArray(buffer) ? new FlatBufferCursor$2(buffer, buffer.length) : buffer;
+       let types = nodeSet.types;
+       let contextHash = 0, lookAhead = 0;
+       function takeNode(parentStart, minPos, children, positions, inRepeat) {
+           let { id, start, end, size } = cursor;
+           let lookAheadAtStart = lookAhead;
+           while (size < 0) {
+               cursor.next();
+               if (size == -1 /* Reuse */) {
+                   let node = reused[id];
+                   children.push(node);
+                   positions.push(start - parentStart);
+                   return;
+               }
+               else if (size == -3 /* ContextChange */) { // Context change
+                   contextHash = id;
+                   return;
+               }
+               else if (size == -4 /* LookAhead */) {
+                   lookAhead = id;
+                   return;
+               }
+               else {
+                   throw new RangeError(`Unrecognized record size: ${size}`);
+               }
+           }
+           let type = types[id], node, buffer;
+           let startPos = start - parentStart;
+           if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
+               // Small enough for a buffer, and no reused nodes inside
+               let data = new Uint16Array(buffer.size - buffer.skip);
+               let endPos = cursor.pos - buffer.size, index = data.length;
+               while (cursor.pos > endPos)
+                   index = copyToBuffer(buffer.start, data, index);
+               node = new TreeBuffer$2(data, end - buffer.start, nodeSet);
+               startPos = buffer.start - parentStart;
+           }
+           else { // Make it a node
+               let endPos = cursor.pos - size;
+               cursor.next();
+               let localChildren = [], localPositions = [];
+               let localInRepeat = id >= minRepeatType ? id : -1;
+               let lastGroup = 0, lastEnd = end;
+               while (cursor.pos > endPos) {
+                   if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
+                       if (cursor.end <= lastEnd - maxBufferLength) {
+                           makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
+                           lastGroup = localChildren.length;
+                           lastEnd = cursor.end;
+                       }
+                       cursor.next();
+                   }
+                   else {
+                       takeNode(start, endPos, localChildren, localPositions, localInRepeat);
+                   }
+               }
+               if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
+                   makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
+               localChildren.reverse();
+               localPositions.reverse();
+               if (localInRepeat > -1 && lastGroup > 0) {
+                   let make = makeBalanced(type);
+                   node = balanceRange$2(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
+               }
+               else {
+                   node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
+               }
+           }
+           children.push(node);
+           positions.push(startPos);
+       }
+       function makeBalanced(type) {
+           return (children, positions, length) => {
+               let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
+               if (lastI >= 0 && (last = children[lastI]) instanceof Tree$2) {
+                   if (!lastI && last.type == type && last.length == length)
+                       return last;
+                   if (lookAheadProp = last.prop(NodeProp$2.lookAhead))
+                       lookAhead = positions[lastI] + last.length + lookAheadProp;
+               }
+               return makeTree(type, children, positions, length, lookAhead);
+           };
+       }
+       function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {
+           let localChildren = [], localPositions = [];
+           while (children.length > i) {
+               localChildren.push(children.pop());
+               localPositions.push(positions.pop() + base - from);
+           }
+           children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));
+           positions.push(from - base);
+       }
+       function makeTree(type, children, positions, length, lookAhead = 0, props) {
+           if (contextHash) {
+               let pair = [NodeProp$2.contextHash, contextHash];
+               props = props ? [pair].concat(props) : [pair];
+           }
+           if (lookAhead > 25) {
+               let pair = [NodeProp$2.lookAhead, lookAhead];
+               props = props ? [pair].concat(props) : [pair];
+           }
+           return new Tree$2(type, children, positions, length, props);
+       }
+       function findBufferSize(maxSize, inRepeat) {
+           // Scan through the buffer to find previous siblings that fit
+           // together in a TreeBuffer, and don't contain any reused nodes
+           // (which can't be stored in a buffer).
+           // If `inRepeat` is > -1, ignore node boundaries of that type for
+           // nesting, but make sure the end falls either at the start
+           // (`maxSize`) or before such a node.
+           let fork = cursor.fork();
+           let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
+           let result = { size: 0, start: 0, skip: 0 };
+           scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
+               let nodeSize = fork.size;
+               // Pretend nested repeat nodes of the same type don't exist
+               if (fork.id == inRepeat && nodeSize >= 0) {
+                   // Except that we store the current state as a valid return
+                   // value.
+                   result.size = size;
+                   result.start = start;
+                   result.skip = skip;
+                   skip += 4;
+                   size += 4;
+                   fork.next();
+                   continue;
+               }
+               let startPos = fork.pos - nodeSize;
+               if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
+                   break;
+               let localSkipped = fork.id >= minRepeatType ? 4 : 0;
+               let nodeStart = fork.start;
+               fork.next();
+               while (fork.pos > startPos) {
+                   if (fork.size < 0) {
+                       if (fork.size == -3 /* ContextChange */)
+                           localSkipped += 4;
+                       else
+                           break scan;
+                   }
+                   else if (fork.id >= minRepeatType) {
+                       localSkipped += 4;
+                   }
+                   fork.next();
+               }
+               start = nodeStart;
+               size += nodeSize;
+               skip += localSkipped;
+           }
+           if (inRepeat < 0 || size == maxSize) {
+               result.size = size;
+               result.start = start;
+               result.skip = skip;
+           }
+           return result.size > 4 ? result : undefined;
+       }
+       function copyToBuffer(bufferStart, buffer, index) {
+           let { id, start, end, size } = cursor;
+           cursor.next();
+           if (size >= 0 && id < minRepeatType) {
+               let startIndex = index;
+               if (size > 4) {
+                   let endPos = cursor.pos - (size - 4);
+                   while (cursor.pos > endPos)
+                       index = copyToBuffer(bufferStart, buffer, index);
+               }
+               buffer[--index] = startIndex;
+               buffer[--index] = end - bufferStart;
+               buffer[--index] = start - bufferStart;
+               buffer[--index] = id;
+           }
+           else if (size == -3 /* ContextChange */) {
+               contextHash = id;
+           }
+           else if (size == -4 /* LookAhead */) {
+               lookAhead = id;
+           }
+           return index;
+       }
+       let children = [], positions = [];
+       while (cursor.pos > 0)
+           takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
+       let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
+       return new Tree$2(types[data.topID], children.reverse(), positions.reverse(), length);
+   }
+   const nodeSizeCache$2 = new WeakMap;
+   function nodeSize$2(balanceType, node) {
+       if (!balanceType.isAnonymous || node instanceof TreeBuffer$2 || node.type != balanceType)
+           return 1;
+       let size = nodeSizeCache$2.get(node);
+       if (size == null) {
+           size = 1;
+           for (let child of node.children) {
+               if (child.type != balanceType || !(child instanceof Tree$2)) {
+                   size = 1;
+                   break;
+               }
+               size += nodeSize$2(balanceType, child);
+           }
+           nodeSizeCache$2.set(node, size);
+       }
+       return size;
+   }
+   function balanceRange$2(
+   // The type the balanced tree's inner nodes.
+   balanceType, 
+   // The direct children and their positions
+   children, positions, 
+   // The index range in children/positions to use
+   from, to, 
+   // The start position of the nodes, relative to their parent.
+   start, 
+   // Length of the outer node
+   length, 
+   // Function to build the top node of the balanced tree
+   mkTop, 
+   // Function to build internal nodes for the balanced tree
+   mkTree) {
+       let total = 0;
+       for (let i = from; i < to; i++)
+           total += nodeSize$2(balanceType, children[i]);
+       let maxChild = Math.ceil((total * 1.5) / 8 /* BranchFactor */);
+       let localChildren = [], localPositions = [];
+       function divide(children, positions, from, to, offset) {
+           for (let i = from; i < to;) {
+               let groupFrom = i, groupStart = positions[i], groupSize = nodeSize$2(balanceType, children[i]);
+               i++;
+               for (; i < to; i++) {
+                   let nextSize = nodeSize$2(balanceType, children[i]);
+                   if (groupSize + nextSize >= maxChild)
+                       break;
+                   groupSize += nextSize;
+               }
+               if (i == groupFrom + 1) {
+                   if (groupSize > maxChild) {
+                       let only = children[groupFrom]; // Only trees can have a size > 1
+                       divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
+                       continue;
+                   }
+                   localChildren.push(children[groupFrom]);
+               }
+               else {
+                   let length = positions[i - 1] + children[i - 1].length - groupStart;
+                   localChildren.push(balanceRange$2(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
+               }
+               localPositions.push(groupStart + offset - start);
+           }
+       }
+       divide(children, positions, from, to, 0);
+       return (mkTop || mkTree)(localChildren, localPositions, length);
+   }
+
+   /// Tree fragments are used during [incremental
+   /// parsing](#common.Parser.startParse) to track parts of old trees
+   /// that can be reused in a new parse. An array of fragments is used
+   /// to track regions of an old tree whose nodes might be reused in new
+   /// parses. Use the static
+   /// [`applyChanges`](#common.TreeFragment^applyChanges) method to
+   /// update fragments for document changes.
+   let TreeFragment$2 = class TreeFragment {
+       /// Construct a tree fragment.
+       constructor(
+       /// The start of the unchanged range pointed to by this fragment.
+       /// This refers to an offset in the _updated_ document (as opposed
+       /// to the original tree).
+       from, 
+       /// The end of the unchanged range.
+       to, 
+       /// The tree that this fragment is based on.
+       tree, 
+       /// The offset between the fragment's tree and the document that
+       /// this fragment can be used against. Add this when going from
+       /// document to tree positions, subtract it to go from tree to
+       /// document positions.
+       offset, openStart = false, openEnd = false) {
+           this.from = from;
+           this.to = to;
+           this.tree = tree;
+           this.offset = offset;
+           this.open = (openStart ? 1 /* Start */ : 0) | (openEnd ? 2 /* End */ : 0);
+       }
+       /// Whether the start of the fragment represents the start of a
+       /// parse, or the end of a change. (In the second case, it may not
+       /// be safe to reuse some nodes at the start, depending on the
+       /// parsing algorithm.)
+       get openStart() { return (this.open & 1 /* Start */) > 0; }
+       /// Whether the end of the fragment represents the end of a
+       /// full-document parse, or the start of a change.
+       get openEnd() { return (this.open & 2 /* End */) > 0; }
+       /// Create a set of fragments from a freshly parsed tree, or update
+       /// an existing set of fragments by replacing the ones that overlap
+       /// with a tree with content from the new tree. When `partial` is
+       /// true, the parse is treated as incomplete, and the resulting
+       /// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
+       /// true.
+       static addTree(tree, fragments = [], partial = false) {
+           let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
+           for (let f of fragments)
+               if (f.to > tree.length)
+                   result.push(f);
+           return result;
+       }
+       /// Apply a set of edits to an array of fragments, removing or
+       /// splitting fragments as necessary to remove edited ranges, and
+       /// adjusting offsets for fragments that moved.
+       static applyChanges(fragments, changes, minGap = 128) {
+           if (!changes.length)
+               return fragments;
+           let result = [];
+           let fI = 1, nextF = fragments.length ? fragments[0] : null;
+           for (let cI = 0, pos = 0, off = 0;; cI++) {
+               let nextC = cI < changes.length ? changes[cI] : null;
+               let nextPos = nextC ? nextC.fromA : 1e9;
+               if (nextPos - pos >= minGap)
+                   while (nextF && nextF.from < nextPos) {
+                       let cut = nextF;
+                       if (pos >= cut.from || nextPos <= cut.to || off) {
+                           let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
+                           cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
+                       }
+                       if (cut)
+                           result.push(cut);
+                       if (nextF.to > nextPos)
+                           break;
+                       nextF = fI < fragments.length ? fragments[fI++] : null;
+                   }
+               if (!nextC)
+                   break;
+               pos = nextC.toA;
+               off = nextC.toA - nextC.toB;
+           }
+           return result;
+       }
+   };
+   /// A superclass that parsers should extend.
+   let Parser$2 = class Parser {
+       /// Start a parse, returning a [partial parse](#common.PartialParse)
+       /// object. [`fragments`](#common.TreeFragment) can be passed in to
+       /// make the parse incremental.
+       ///
+       /// By default, the entire input is parsed. You can pass `ranges`,
+       /// which should be a sorted array of non-empty, non-overlapping
+       /// ranges, to parse only those ranges. The tree returned in that
+       /// case will start at `ranges[0].from`.
+       startParse(input, fragments, ranges) {
+           if (typeof input == "string")
+               input = new StringInput$2(input);
+           ranges = !ranges ? [new Range$5(0, input.length)] : ranges.length ? ranges.map(r => new Range$5(r.from, r.to)) : [new Range$5(0, 0)];
+           return this.createParse(input, fragments || [], ranges);
+       }
+       /// Run a full parse, returning the resulting tree.
+       parse(input, fragments, ranges) {
+           let parse = this.startParse(input, fragments, ranges);
+           for (;;) {
+               let done = parse.advance();
+               if (done)
+                   return done;
+           }
+       }
+   };
+   let StringInput$2 = class StringInput {
+       constructor(string) {
+           this.string = string;
+       }
+       get length() { return this.string.length; }
+       chunk(from) { return this.string.slice(from); }
+       get lineChunks() { return false; }
+       read(from, to) { return this.string.slice(from, to); }
+   };
+   new NodeProp$2({ perNode: true });
+
+   let nextTagID$2 = 0;
+   /// Highlighting tags are markers that denote a highlighting category.
+   /// They are [associated](#highlight.styleTags) with parts of a syntax
+   /// tree by a language mode, and then mapped to an actual CSS style by
+   /// a [highlighter](#highlight.Highlighter).
+   ///
+   /// Because syntax tree node types and highlight styles have to be
+   /// able to talk the same language, CodeMirror uses a mostly _closed_
+   /// [vocabulary](#highlight.tags) of syntax tags (as opposed to
+   /// traditional open string-based systems, which make it hard for
+   /// highlighting themes to cover all the tokens produced by the
+   /// various languages).
+   ///
+   /// It _is_ possible to [define](#highlight.Tag^define) your own
+   /// highlighting tags for system-internal use (where you control both
+   /// the language package and the highlighter), but such tags will not
+   /// be picked up by regular highlighters (though you can derive them
+   /// from standard tags to allow highlighters to fall back to those).
+   let Tag$2 = class Tag {
+       /// @internal
+       constructor(
+       /// The set of this tag and all its parent tags, starting with
+       /// this one itself and sorted in order of decreasing specificity.
+       set, 
+       /// The base unmodified tag that this one is based on, if it's
+       /// modified @internal
+       base, 
+       /// The modifiers applied to this.base @internal
+       modified) {
+           this.set = set;
+           this.base = base;
+           this.modified = modified;
+           /// @internal
+           this.id = nextTagID$2++;
+       }
+       /// Define a new tag. If `parent` is given, the tag is treated as a
+       /// sub-tag of that parent, and
+       /// [highlighters](#highlight.tagHighlighter) that don't mention
+       /// this tag will try to fall back to the parent tag (or grandparent
+       /// tag, etc).
+       static define(parent) {
+           if (parent === null || parent === void 0 ? void 0 : parent.base)
+               throw new Error("Can not derive from a modified tag");
+           let tag = new Tag([], null, []);
+           tag.set.push(tag);
+           if (parent)
+               for (let t of parent.set)
+                   tag.set.push(t);
+           return tag;
+       }
+       /// Define a tag _modifier_, which is a function that, given a tag,
+       /// will return a tag that is a subtag of the original. Applying the
+       /// same modifier to a twice tag will return the same value (`m1(t1)
+       /// == m1(t1)`) and applying multiple modifiers will, regardless or
+       /// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
+       ///
+       /// When multiple modifiers are applied to a given base tag, each
+       /// smaller set of modifiers is registered as a parent, so that for
+       /// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
+       /// `m1(m3(t1)`, and so on.
+       static defineModifier() {
+           let mod = new Modifier$2;
+           return (tag) => {
+               if (tag.modified.indexOf(mod) > -1)
+                   return tag;
+               return Modifier$2.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
+           };
+       }
+   };
+   let nextModifierID$2 = 0;
+   let Modifier$2 = class Modifier {
+       constructor() {
+           this.instances = [];
+           this.id = nextModifierID$2++;
+       }
+       static get(base, mods) {
+           if (!mods.length)
+               return base;
+           let exists = mods[0].instances.find(t => t.base == base && sameArray$5(mods, t.modified));
+           if (exists)
+               return exists;
+           let set = [], tag = new Tag$2(set, base, mods);
+           for (let m of mods)
+               m.instances.push(tag);
+           let configs = permute$1(mods);
+           for (let parent of base.set)
+               for (let config of configs)
+                   set.push(Modifier.get(parent, config));
+           return tag;
+       }
+   };
+   function sameArray$5(a, b) {
+       return a.length == b.length && a.every((x, i) => x == b[i]);
+   }
+   function permute$1(array) {
+       let result = [array];
+       for (let i = 0; i < array.length; i++) {
+           for (let a of permute$1(array.slice(0, i).concat(array.slice(i + 1))))
+               result.push(a);
+       }
+       return result;
+   }
+   /// This function is used to add a set of tags to a language syntax
+   /// via [`NodeSet.extend`](#common.NodeSet.extend) or
+   /// [`LRParser.configure`](#lr.LRParser.configure).
+   ///
+   /// The argument object maps node selectors to [highlighting
+   /// tags](#highlight.Tag) or arrays of tags.
+   ///
+   /// Node selectors may hold one or more (space-separated) node paths.
+   /// Such a path can be a [node name](#common.NodeType.name), or
+   /// multiple node names (or `*` wildcards) separated by slash
+   /// characters, as in `"Block/Declaration/VariableName"`. Such a path
+   /// matches the final node but only if its direct parent nodes are the
+   /// other nodes mentioned. A `*` in such a path matches any parent,
+   /// but only a single level—wildcards that match multiple parents
+   /// aren't supported, both for efficiency reasons and because Lezer
+   /// trees make it rather hard to reason about what they would match.)
+   ///
+   /// A path can be ended with `/...` to indicate that the tag assigned
+   /// to the node should also apply to all child nodes, even if they
+   /// match their own style (by default, only the innermost style is
+   /// used).
+   ///
+   /// When a path ends in `!`, as in `Attribute!`, no further matching
+   /// happens for the node's child nodes, and the entire node gets the
+   /// given style.
+   ///
+   /// In this notation, node names that contain `/`, `!`, `*`, or `...`
+   /// must be quoted as JSON strings.
+   ///
+   /// For example:
+   ///
+   /// ```javascript
+   /// parser.withProps(
+   ///   styleTags({
+   ///     // Style Number and BigNumber nodes
+   ///     "Number BigNumber": tags.number,
+   ///     // Style Escape nodes whose parent is String
+   ///     "String/Escape": tags.escape,
+   ///     // Style anything inside Attributes nodes
+   ///     "Attributes!": tags.meta,
+   ///     // Add a style to all content inside Italic nodes
+   ///     "Italic/...": tags.emphasis,
+   ///     // Style InvalidString nodes as both `string` and `invalid`
+   ///     "InvalidString": [tags.string, tags.invalid],
+   ///     // Style the node named "/" as punctuation
+   ///     '"/"': tags.punctuation
+   ///   })
+   /// )
+   /// ```
+   function styleTags$2(spec) {
+       let byName = Object.create(null);
+       for (let prop in spec) {
+           let tags = spec[prop];
+           if (!Array.isArray(tags))
+               tags = [tags];
+           for (let part of prop.split(" "))
+               if (part) {
+                   let pieces = [], mode = 2 /* Normal */, rest = part;
+                   for (let pos = 0;;) {
+                       if (rest == "..." && pos > 0 && pos + 3 == part.length) {
+                           mode = 1 /* Inherit */;
+                           break;
+                       }
+                       let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
+                       if (!m)
+                           throw new RangeError("Invalid path: " + part);
+                       pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
+                       pos += m[0].length;
+                       if (pos == part.length)
+                           break;
+                       let next = part[pos++];
+                       if (pos == part.length && next == "!") {
+                           mode = 0 /* Opaque */;
+                           break;
+                       }
+                       if (next != "/")
+                           throw new RangeError("Invalid path: " + part);
+                       rest = part.slice(pos);
+                   }
+                   let last = pieces.length - 1, inner = pieces[last];
+                   if (!inner)
+                       throw new RangeError("Invalid path: " + part);
+                   let rule = new Rule$2(tags, mode, last > 0 ? pieces.slice(0, last) : null);
+                   byName[inner] = rule.sort(byName[inner]);
+               }
+       }
+       return ruleNodeProp$2.add(byName);
+   }
+   const ruleNodeProp$2 = new NodeProp$2();
+   let Rule$2 = class Rule {
+       constructor(tags, mode, context, next) {
+           this.tags = tags;
+           this.mode = mode;
+           this.context = context;
+           this.next = next;
+       }
+       sort(other) {
+           if (!other || other.depth < this.depth) {
+               this.next = other;
+               return this;
+           }
+           other.next = this.sort(other.next);
+           return other;
+       }
+       get depth() { return this.context ? this.context.length : 0; }
+   };
+   /// Define a [highlighter](#highlight.Highlighter) from an array of
+   /// tag/class pairs. Classes associated with more specific tags will
+   /// take precedence.
+   function tagHighlighter$2(tags, options) {
+       let map = Object.create(null);
+       for (let style of tags) {
+           if (!Array.isArray(style.tag))
+               map[style.tag.id] = style.class;
+           else
+               for (let tag of style.tag)
+                   map[tag.id] = style.class;
+       }
+       let { scope, all = null } = options || {};
+       return {
+           style: (tags) => {
+               let cls = all;
+               for (let tag of tags) {
+                   for (let sub of tag.set) {
+                       let tagClass = map[sub.id];
+                       if (tagClass) {
+                           cls = cls ? cls + " " + tagClass : tagClass;
+                           break;
+                       }
+                   }
+               }
+               return cls;
+           },
+           scope: scope
+       };
+   }
+   function highlightTags$1(highlighters, tags) {
+       let result = null;
+       for (let highlighter of highlighters) {
+           let value = highlighter.style(tags);
+           if (value)
+               result = result ? result + " " + value : value;
+       }
+       return result;
+   }
+   /// Highlight the given [tree](#common.Tree) with the given
+   /// [highlighter](#highlight.Highlighter).
+   function highlightTree$1(tree, highlighter, 
+   /// Assign styling to a region of the text. Will be called, in order
+   /// of position, for any ranges where more than zero classes apply.
+   /// `classes` is a space separated string of CSS classes.
+   putStyle, 
+   /// The start of the range to highlight.
+   from = 0, 
+   /// The end of the range.
+   to = tree.length) {
+       let builder = new HighlightBuilder$1(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
+       builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
+       builder.flush(to);
+   }
+   let HighlightBuilder$1 = class HighlightBuilder {
+       constructor(at, highlighters, span) {
+           this.at = at;
+           this.highlighters = highlighters;
+           this.span = span;
+           this.class = "";
+       }
+       startSpan(at, cls) {
+           if (cls != this.class) {
+               this.flush(at);
+               if (at > this.at)
+                   this.at = at;
+               this.class = cls;
+           }
+       }
+       flush(to) {
+           if (to > this.at && this.class)
+               this.span(this.at, to, this.class);
+       }
+       highlightRange(cursor, from, to, inheritedClass, highlighters) {
+           let { type, from: start, to: end } = cursor;
+           if (start >= to || end <= from)
+               return;
+           if (type.isTop)
+               highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
+           let cls = inheritedClass;
+           let rule = type.prop(ruleNodeProp$2), opaque = false;
+           while (rule) {
+               if (!rule.context || cursor.matchContext(rule.context)) {
+                   let tagCls = highlightTags$1(highlighters, rule.tags);
+                   if (tagCls) {
+                       if (cls)
+                           cls += " ";
+                       cls += tagCls;
+                       if (rule.mode == 1 /* Inherit */)
+                           inheritedClass += (inheritedClass ? " " : "") + tagCls;
+                       else if (rule.mode == 0 /* Opaque */)
+                           opaque = true;
+                   }
+                   break;
+               }
+               rule = rule.next;
+           }
+           this.startSpan(cursor.from, cls);
+           if (opaque)
+               return;
+           let mounted = cursor.tree && cursor.tree.prop(NodeProp$2.mounted);
+           if (mounted && mounted.overlay) {
+               let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
+               let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
+               let hasChild = cursor.firstChild();
+               for (let i = 0, pos = start;; i++) {
+                   let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
+                   let nextPos = next ? next.from + start : end;
+                   let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
+                   if (rangeFrom < rangeTo && hasChild) {
+                       while (cursor.from < rangeTo) {
+                           this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
+                           this.startSpan(Math.min(to, cursor.to), cls);
+                           if (cursor.to >= nextPos || !cursor.nextSibling())
+                               break;
+                       }
+                   }
+                   if (!next || nextPos > to)
+                       break;
+                   pos = next.to + start;
+                   if (pos > from) {
+                       this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), inheritedClass, innerHighlighters);
+                       this.startSpan(pos, cls);
+                   }
+               }
+               if (hasChild)
+                   cursor.parent();
+           }
+           else if (cursor.firstChild()) {
+               do {
+                   if (cursor.to <= from)
+                       continue;
+                   if (cursor.from >= to)
+                       break;
+                   this.highlightRange(cursor, from, to, inheritedClass, highlighters);
+                   this.startSpan(Math.min(to, cursor.to), cls);
+               } while (cursor.nextSibling());
+               cursor.parent();
+           }
+       }
+   };
+   const t$2 = Tag$2.define;
+   const comment$2 = t$2(), name$2 = t$2(), typeName$2 = t$2(name$2), propertyName$2 = t$2(name$2), literal$2 = t$2(), string$2 = t$2(literal$2), number$2 = t$2(literal$2), content$2 = t$2(), heading$2 = t$2(content$2), keyword$2 = t$2(), operator$2 = t$2(), punctuation$2 = t$2(), bracket$2 = t$2(punctuation$2), meta$2 = t$2();
+   /// The default set of highlighting [tags](#highlight.Tag).
+   ///
+   /// This collection is heavily biased towards programming languages,
+   /// and necessarily incomplete. A full ontology of syntactic
+   /// constructs would fill a stack of books, and be impractical to
+   /// write themes for. So try to make do with this set. If all else
+   /// fails, [open an
+   /// issue](https://github.com/codemirror/codemirror.next) to propose a
+   /// new tag, or [define](#highlight.Tag^define) a local custom tag for
+   /// your use case.
+   ///
+   /// Note that it is not obligatory to always attach the most specific
+   /// tag possible to an element—if your grammar can't easily
+   /// distinguish a certain type of element (such as a local variable),
+   /// it is okay to style it as its more general variant (a variable).
+   /// 
+   /// For tags that extend some parent tag, the documentation links to
+   /// the parent.
+   const tags$2 = {
+       /// A comment.
+       comment: comment$2,
+       /// A line [comment](#highlight.tags.comment).
+       lineComment: t$2(comment$2),
+       /// A block [comment](#highlight.tags.comment).
+       blockComment: t$2(comment$2),
+       /// A documentation [comment](#highlight.tags.comment).
+       docComment: t$2(comment$2),
+       /// Any kind of identifier.
+       name: name$2,
+       /// The [name](#highlight.tags.name) of a variable.
+       variableName: t$2(name$2),
+       /// A type [name](#highlight.tags.name).
+       typeName: typeName$2,
+       /// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
+       tagName: t$2(typeName$2),
+       /// A property or field [name](#highlight.tags.name).
+       propertyName: propertyName$2,
+       /// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
+       attributeName: t$2(propertyName$2),
+       /// The [name](#highlight.tags.name) of a class.
+       className: t$2(name$2),
+       /// A label [name](#highlight.tags.name).
+       labelName: t$2(name$2),
+       /// A namespace [name](#highlight.tags.name).
+       namespace: t$2(name$2),
+       /// The [name](#highlight.tags.name) of a macro.
+       macroName: t$2(name$2),
+       /// A literal value.
+       literal: literal$2,
+       /// A string [literal](#highlight.tags.literal).
+       string: string$2,
+       /// A documentation [string](#highlight.tags.string).
+       docString: t$2(string$2),
+       /// A character literal (subtag of [string](#highlight.tags.string)).
+       character: t$2(string$2),
+       /// An attribute value (subtag of [string](#highlight.tags.string)).
+       attributeValue: t$2(string$2),
+       /// A number [literal](#highlight.tags.literal).
+       number: number$2,
+       /// An integer [number](#highlight.tags.number) literal.
+       integer: t$2(number$2),
+       /// A floating-point [number](#highlight.tags.number) literal.
+       float: t$2(number$2),
+       /// A boolean [literal](#highlight.tags.literal).
+       bool: t$2(literal$2),
+       /// Regular expression [literal](#highlight.tags.literal).
+       regexp: t$2(literal$2),
+       /// An escape [literal](#highlight.tags.literal), for example a
+       /// backslash escape in a string.
+       escape: t$2(literal$2),
+       /// A color [literal](#highlight.tags.literal).
+       color: t$2(literal$2),
+       /// A URL [literal](#highlight.tags.literal).
+       url: t$2(literal$2),
+       /// A language keyword.
+       keyword: keyword$2,
+       /// The [keyword](#highlight.tags.keyword) for the self or this
+       /// object.
+       self: t$2(keyword$2),
+       /// The [keyword](#highlight.tags.keyword) for null.
+       null: t$2(keyword$2),
+       /// A [keyword](#highlight.tags.keyword) denoting some atomic value.
+       atom: t$2(keyword$2),
+       /// A [keyword](#highlight.tags.keyword) that represents a unit.
+       unit: t$2(keyword$2),
+       /// A modifier [keyword](#highlight.tags.keyword).
+       modifier: t$2(keyword$2),
+       /// A [keyword](#highlight.tags.keyword) that acts as an operator.
+       operatorKeyword: t$2(keyword$2),
+       /// A control-flow related [keyword](#highlight.tags.keyword).
+       controlKeyword: t$2(keyword$2),
+       /// A [keyword](#highlight.tags.keyword) that defines something.
+       definitionKeyword: t$2(keyword$2),
+       /// A [keyword](#highlight.tags.keyword) related to defining or
+       /// interfacing with modules.
+       moduleKeyword: t$2(keyword$2),
+       /// An operator.
+       operator: operator$2,
+       /// An [operator](#highlight.tags.operator) that defines something.
+       derefOperator: t$2(operator$2),
+       /// Arithmetic-related [operator](#highlight.tags.operator).
+       arithmeticOperator: t$2(operator$2),
+       /// Logical [operator](#highlight.tags.operator).
+       logicOperator: t$2(operator$2),
+       /// Bit [operator](#highlight.tags.operator).
+       bitwiseOperator: t$2(operator$2),
+       /// Comparison [operator](#highlight.tags.operator).
+       compareOperator: t$2(operator$2),
+       /// [Operator](#highlight.tags.operator) that updates its operand.
+       updateOperator: t$2(operator$2),
+       /// [Operator](#highlight.tags.operator) that defines something.
+       definitionOperator: t$2(operator$2),
+       /// Type-related [operator](#highlight.tags.operator).
+       typeOperator: t$2(operator$2),
+       /// Control-flow [operator](#highlight.tags.operator).
+       controlOperator: t$2(operator$2),
+       /// Program or markup punctuation.
+       punctuation: punctuation$2,
+       /// [Punctuation](#highlight.tags.punctuation) that separates
+       /// things.
+       separator: t$2(punctuation$2),
+       /// Bracket-style [punctuation](#highlight.tags.punctuation).
+       bracket: bracket$2,
+       /// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
+       /// tokens).
+       angleBracket: t$2(bracket$2),
+       /// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
+       /// tokens).
+       squareBracket: t$2(bracket$2),
+       /// Parentheses (usually `(` and `)` tokens). Subtag of
+       /// [bracket](#highlight.tags.bracket).
+       paren: t$2(bracket$2),
+       /// Braces (usually `{` and `}` tokens). Subtag of
+       /// [bracket](#highlight.tags.bracket).
+       brace: t$2(bracket$2),
+       /// Content, for example plain text in XML or markup documents.
+       content: content$2,
+       /// [Content](#highlight.tags.content) that represents a heading.
+       heading: heading$2,
+       /// A level 1 [heading](#highlight.tags.heading).
+       heading1: t$2(heading$2),
+       /// A level 2 [heading](#highlight.tags.heading).
+       heading2: t$2(heading$2),
+       /// A level 3 [heading](#highlight.tags.heading).
+       heading3: t$2(heading$2),
+       /// A level 4 [heading](#highlight.tags.heading).
+       heading4: t$2(heading$2),
+       /// A level 5 [heading](#highlight.tags.heading).
+       heading5: t$2(heading$2),
+       /// A level 6 [heading](#highlight.tags.heading).
+       heading6: t$2(heading$2),
+       /// A prose separator (such as a horizontal rule).
+       contentSeparator: t$2(content$2),
+       /// [Content](#highlight.tags.content) that represents a list.
+       list: t$2(content$2),
+       /// [Content](#highlight.tags.content) that represents a quote.
+       quote: t$2(content$2),
+       /// [Content](#highlight.tags.content) that is emphasized.
+       emphasis: t$2(content$2),
+       /// [Content](#highlight.tags.content) that is styled strong.
+       strong: t$2(content$2),
+       /// [Content](#highlight.tags.content) that is part of a link.
+       link: t$2(content$2),
+       /// [Content](#highlight.tags.content) that is styled as code or
+       /// monospace.
+       monospace: t$2(content$2),
+       /// [Content](#highlight.tags.content) that has a strike-through
+       /// style.
+       strikethrough: t$2(content$2),
+       /// Inserted text in a change-tracking format.
+       inserted: t$2(),
+       /// Deleted text.
+       deleted: t$2(),
+       /// Changed text.
+       changed: t$2(),
+       /// An invalid or unsyntactic element.
+       invalid: t$2(),
+       /// Metadata or meta-instruction.
+       meta: meta$2,
+       /// [Metadata](#highlight.tags.meta) that applies to the entire
+       /// document.
+       documentMeta: t$2(meta$2),
+       /// [Metadata](#highlight.tags.meta) that annotates or adds
+       /// attributes to a given syntactic element.
+       annotation: t$2(meta$2),
+       /// Processing instruction or preprocessor directive. Subtag of
+       /// [meta](#highlight.tags.meta).
+       processingInstruction: t$2(meta$2),
+       /// [Modifier](#highlight.Tag^defineModifier) that indicates that a
+       /// given element is being defined. Expected to be used with the
+       /// various [name](#highlight.tags.name) tags.
+       definition: Tag$2.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) that indicates that
+       /// something is constant. Mostly expected to be used with
+       /// [variable names](#highlight.tags.variableName).
+       constant: Tag$2.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) used to indicate that
+       /// a [variable](#highlight.tags.variableName) or [property
+       /// name](#highlight.tags.propertyName) is being called or defined
+       /// as a function.
+       function: Tag$2.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) that can be applied to
+       /// [names](#highlight.tags.name) to indicate that they belong to
+       /// the language's standard environment.
+       standard: Tag$2.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) that indicates a given
+       /// [names](#highlight.tags.name) is local to some scope.
+       local: Tag$2.defineModifier(),
+       /// A generic variant [modifier](#highlight.Tag^defineModifier) that
+       /// can be used to tag language-specific alternative variants of
+       /// some common tag. It is recommended for themes to define special
+       /// forms of at least the [string](#highlight.tags.string) and
+       /// [variable name](#highlight.tags.variableName) tags, since those
+       /// come up a lot.
+       special: Tag$2.defineModifier()
+   };
+   /// This is a highlighter that adds stable, predictable classes to
+   /// tokens, for styling with external CSS.
+   ///
+   /// The following tags are mapped to their name prefixed with `"tok-"`
+   /// (for example `"tok-comment"`):
+   ///
+   /// * [`link`](#highlight.tags.link)
+   /// * [`heading`](#highlight.tags.heading)
+   /// * [`emphasis`](#highlight.tags.emphasis)
+   /// * [`strong`](#highlight.tags.strong)
+   /// * [`keyword`](#highlight.tags.keyword)
+   /// * [`atom`](#highlight.tags.atom) [`bool`](#highlight.tags.bool)
+   /// * [`url`](#highlight.tags.url)
+   /// * [`labelName`](#highlight.tags.labelName)
+   /// * [`inserted`](#highlight.tags.inserted)
+   /// * [`deleted`](#highlight.tags.deleted)
+   /// * [`literal`](#highlight.tags.literal)
+   /// * [`string`](#highlight.tags.string)
+   /// * [`number`](#highlight.tags.number)
+   /// * [`variableName`](#highlight.tags.variableName)
+   /// * [`typeName`](#highlight.tags.typeName)
+   /// * [`namespace`](#highlight.tags.namespace)
+   /// * [`className`](#highlight.tags.className)
+   /// * [`macroName`](#highlight.tags.macroName)
+   /// * [`propertyName`](#highlight.tags.propertyName)
+   /// * [`operator`](#highlight.tags.operator)
+   /// * [`comment`](#highlight.tags.comment)
+   /// * [`meta`](#highlight.tags.meta)
+   /// * [`punctuation`](#highlight.tags.punctuation)
+   /// * [`invalid`](#highlight.tags.invalid)
+   ///
+   /// In addition, these mappings are provided:
+   ///
+   /// * [`regexp`](#highlight.tags.regexp),
+   ///   [`escape`](#highlight.tags.escape), and
+   ///   [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
+   ///   are mapped to `"tok-string2"`
+   /// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
+   ///   to `"tok-variableName2"`
+   /// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
+   ///   to `"tok-variableName tok-local"`
+   /// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
+   ///   to `"tok-variableName tok-definition"`
+   /// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
+   ///   to `"tok-propertyName tok-definition"`
+   tagHighlighter$2([
+       { tag: tags$2.link, class: "tok-link" },
+       { tag: tags$2.heading, class: "tok-heading" },
+       { tag: tags$2.emphasis, class: "tok-emphasis" },
+       { tag: tags$2.strong, class: "tok-strong" },
+       { tag: tags$2.keyword, class: "tok-keyword" },
+       { tag: tags$2.atom, class: "tok-atom" },
+       { tag: tags$2.bool, class: "tok-bool" },
+       { tag: tags$2.url, class: "tok-url" },
+       { tag: tags$2.labelName, class: "tok-labelName" },
+       { tag: tags$2.inserted, class: "tok-inserted" },
+       { tag: tags$2.deleted, class: "tok-deleted" },
+       { tag: tags$2.literal, class: "tok-literal" },
+       { tag: tags$2.string, class: "tok-string" },
+       { tag: tags$2.number, class: "tok-number" },
+       { tag: [tags$2.regexp, tags$2.escape, tags$2.special(tags$2.string)], class: "tok-string2" },
+       { tag: tags$2.variableName, class: "tok-variableName" },
+       { tag: tags$2.local(tags$2.variableName), class: "tok-variableName tok-local" },
+       { tag: tags$2.definition(tags$2.variableName), class: "tok-variableName tok-definition" },
+       { tag: tags$2.special(tags$2.variableName), class: "tok-variableName2" },
+       { tag: tags$2.definition(tags$2.propertyName), class: "tok-propertyName tok-definition" },
+       { tag: tags$2.typeName, class: "tok-typeName" },
+       { tag: tags$2.namespace, class: "tok-namespace" },
+       { tag: tags$2.className, class: "tok-className" },
+       { tag: tags$2.macroName, class: "tok-macroName" },
+       { tag: tags$2.propertyName, class: "tok-propertyName" },
+       { tag: tags$2.operator, class: "tok-operator" },
+       { tag: tags$2.comment, class: "tok-comment" },
+       { tag: tags$2.meta, class: "tok-meta" },
+       { tag: tags$2.invalid, class: "tok-invalid" },
+       { tag: tags$2.punctuation, class: "tok-punctuation" }
+   ]);
+
+   var _a$2;
+   /**
+   Node prop stored in a parser's top syntax node to provide the
+   facet that stores language-specific data for that language.
+   */
+   const languageDataProp$2 = /*@__PURE__*/new NodeProp$2();
+   /**
+   A language object manages parsing and per-language
+   [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
+   managed as a [Lezer](https://lezer.codemirror.net) tree. The class
+   can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
+   subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
+   via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
+   for stream parsers.
+   */
+   let Language$2 = class Language {
+       /**
+       Construct a language object. If you need to invoke this
+       directly, first define a data facet with
+       [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
+       configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
+       to the language's outer syntax node.
+       */
+       constructor(
+       /**
+       The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
+       used for this language.
+       */
+       data, parser, extraExtensions = []) {
+           this.data = data;
+           // Kludge to define EditorState.tree as a debugging helper,
+           // without the EditorState package actually knowing about
+           // languages and lezer trees.
+           if (!EditorState$3.prototype.hasOwnProperty("tree"))
+               Object.defineProperty(EditorState$3.prototype, "tree", { get() { return syntaxTree$2(this); } });
+           this.parser = parser;
+           this.extension = [
+               language$2.of(this),
+               EditorState$3.languageData.of((state, pos, side) => state.facet(languageDataFacetAt$1(state, pos, side)))
+           ].concat(extraExtensions);
+       }
+       /**
+       Query whether this language is active at the given position.
+       */
+       isActiveAt(state, pos, side = -1) {
+           return languageDataFacetAt$1(state, pos, side) == this.data;
+       }
+       /**
+       Find the document regions that were parsed using this language.
+       The returned regions will _include_ any nested languages rooted
+       in this language, when those exist.
+       */
+       findRegions(state) {
+           let lang = state.facet(language$2);
+           if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
+               return [{ from: 0, to: state.doc.length }];
+           if (!lang || !lang.allowsNesting)
+               return [];
+           let result = [];
+           let explore = (tree, from) => {
+               if (tree.prop(languageDataProp$2) == this.data) {
+                   result.push({ from, to: from + tree.length });
+                   return;
+               }
+               let mount = tree.prop(NodeProp$2.mounted);
+               if (mount) {
+                   if (mount.tree.prop(languageDataProp$2) == this.data) {
+                       if (mount.overlay)
+                           for (let r of mount.overlay)
+                               result.push({ from: r.from + from, to: r.to + from });
+                       else
+                           result.push({ from: from, to: from + tree.length });
+                       return;
+                   }
+                   else if (mount.overlay) {
+                       let size = result.length;
+                       explore(mount.tree, mount.overlay[0].from + from);
+                       if (result.length > size)
+                           return;
+                   }
+               }
+               for (let i = 0; i < tree.children.length; i++) {
+                   let ch = tree.children[i];
+                   if (ch instanceof Tree$2)
+                       explore(ch, tree.positions[i] + from);
+               }
+           };
+           explore(syntaxTree$2(state), 0);
+           return result;
+       }
+       /**
+       Indicates whether this language allows nested languages. The
+       default implementation returns true.
+       */
+       get allowsNesting() { return true; }
+   };
+   /**
+   @internal
+   */
+   Language$2.setState = /*@__PURE__*/StateEffect$3.define();
+   function languageDataFacetAt$1(state, pos, side) {
+       let topLang = state.facet(language$2);
+       if (!topLang)
+           return null;
+       let facet = topLang.data;
+       if (topLang.allowsNesting) {
+           for (let node = syntaxTree$2(state).topNode; node; node = node.enter(pos, side, IterMode$2.ExcludeBuffers))
+               facet = node.type.prop(languageDataProp$2) || facet;
+       }
+       return facet;
+   }
+   /**
+   Get the syntax tree for a state, which is the current (possibly
+   incomplete) parse tree of the active
+   [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
+   language available.
+   */
+   function syntaxTree$2(state) {
+       let field = state.field(Language$2.state, false);
+       return field ? field.tree : Tree$2.empty;
+   }
+   // Lezer-style Input object for a Text document.
+   let DocInput$2 = class DocInput {
+       constructor(doc, length = doc.length) {
+           this.doc = doc;
+           this.length = length;
+           this.cursorPos = 0;
+           this.string = "";
+           this.cursor = doc.iter();
+       }
+       syncTo(pos) {
+           this.string = this.cursor.next(pos - this.cursorPos).value;
+           this.cursorPos = pos + this.string.length;
+           return this.cursorPos - this.string.length;
+       }
+       chunk(pos) {
+           this.syncTo(pos);
+           return this.string;
+       }
+       get lineChunks() { return true; }
+       read(from, to) {
+           let stringStart = this.cursorPos - this.string.length;
+           if (from < stringStart || to >= this.cursorPos)
+               return this.doc.sliceString(from, to);
+           else
+               return this.string.slice(from - stringStart, to - stringStart);
+       }
+   };
+   let currentContext$2 = null;
+   /**
+   A parse context provided to parsers working on the editor content.
+   */
+   let ParseContext$2 = class ParseContext {
+       constructor(parser, 
+       /**
+       The current editor state.
+       */
+       state, 
+       /**
+       Tree fragments that can be reused by incremental re-parses.
+       */
+       fragments = [], 
+       /**
+       @internal
+       */
+       tree, 
+       /**
+       @internal
+       */
+       treeLen, 
+       /**
+       The current editor viewport (or some overapproximation
+       thereof). Intended to be used for opportunistically avoiding
+       work (in which case
+       [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
+       should be called to make sure the parser is restarted when the
+       skipped region becomes visible).
+       */
+       viewport, 
+       /**
+       @internal
+       */
+       skipped, 
+       /**
+       This is where skipping parsers can register a promise that,
+       when resolved, will schedule a new parse. It is cleared when
+       the parse worker picks up the promise. @internal
+       */
+       scheduleOn) {
+           this.parser = parser;
+           this.state = state;
+           this.fragments = fragments;
+           this.tree = tree;
+           this.treeLen = treeLen;
+           this.viewport = viewport;
+           this.skipped = skipped;
+           this.scheduleOn = scheduleOn;
+           this.parse = null;
+           /**
+           @internal
+           */
+           this.tempSkipped = [];
+       }
+       /**
+       @internal
+       */
+       static create(parser, state, viewport) {
+           return new ParseContext(parser, state, [], Tree$2.empty, 0, viewport, [], null);
+       }
+       startParse() {
+           return this.parser.startParse(new DocInput$2(this.state.doc), this.fragments);
+       }
+       /**
+       @internal
+       */
+       work(until, upto) {
+           if (upto != null && upto >= this.state.doc.length)
+               upto = undefined;
+           if (this.tree != Tree$2.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
+               this.takeTree();
+               return true;
+           }
+           return this.withContext(() => {
+               var _a;
+               if (typeof until == "number") {
+                   let endTime = Date.now() + until;
+                   until = () => Date.now() > endTime;
+               }
+               if (!this.parse)
+                   this.parse = this.startParse();
+               if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
+                   upto < this.state.doc.length)
+                   this.parse.stopAt(upto);
+               for (;;) {
+                   let done = this.parse.advance();
+                   if (done) {
+                       this.fragments = this.withoutTempSkipped(TreeFragment$2.addTree(done, this.fragments, this.parse.stoppedAt != null));
+                       this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
+                       this.tree = done;
+                       this.parse = null;
+                       if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
+                           this.parse = this.startParse();
+                       else
+                           return true;
+                   }
+                   if (until())
+                       return false;
+               }
+           });
+       }
+       /**
+       @internal
+       */
+       takeTree() {
+           let pos, tree;
+           if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
+               if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
+                   this.parse.stopAt(pos);
+               this.withContext(() => { while (!(tree = this.parse.advance())) { } });
+               this.treeLen = pos;
+               this.tree = tree;
+               this.fragments = this.withoutTempSkipped(TreeFragment$2.addTree(this.tree, this.fragments, true));
+               this.parse = null;
+           }
+       }
+       withContext(f) {
+           let prev = currentContext$2;
+           currentContext$2 = this;
+           try {
+               return f();
+           }
+           finally {
+               currentContext$2 = prev;
+           }
+       }
+       withoutTempSkipped(fragments) {
+           for (let r; r = this.tempSkipped.pop();)
+               fragments = cutFragments$2(fragments, r.from, r.to);
+           return fragments;
+       }
+       /**
+       @internal
+       */
+       changes(changes, newState) {
+           let { fragments, tree, treeLen, viewport, skipped } = this;
+           this.takeTree();
+           if (!changes.empty) {
+               let ranges = [];
+               changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
+               fragments = TreeFragment$2.applyChanges(fragments, ranges);
+               tree = Tree$2.empty;
+               treeLen = 0;
+               viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
+               if (this.skipped.length) {
+                   skipped = [];
+                   for (let r of this.skipped) {
+                       let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
+                       if (from < to)
+                           skipped.push({ from, to });
+                   }
+               }
+           }
+           return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
+       }
+       /**
+       @internal
+       */
+       updateViewport(viewport) {
+           if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
+               return false;
+           this.viewport = viewport;
+           let startLen = this.skipped.length;
+           for (let i = 0; i < this.skipped.length; i++) {
+               let { from, to } = this.skipped[i];
+               if (from < viewport.to && to > viewport.from) {
+                   this.fragments = cutFragments$2(this.fragments, from, to);
+                   this.skipped.splice(i--, 1);
+               }
+           }
+           if (this.skipped.length >= startLen)
+               return false;
+           this.reset();
+           return true;
+       }
+       /**
+       @internal
+       */
+       reset() {
+           if (this.parse) {
+               this.takeTree();
+               this.parse = null;
+           }
+       }
+       /**
+       Notify the parse scheduler that the given region was skipped
+       because it wasn't in view, and the parse should be restarted
+       when it comes into view.
+       */
+       skipUntilInView(from, to) {
+           this.skipped.push({ from, to });
+       }
+       /**
+       Returns a parser intended to be used as placeholder when
+       asynchronously loading a nested parser. It'll skip its input and
+       mark it as not-really-parsed, so that the next update will parse
+       it again.
+       
+       When `until` is given, a reparse will be scheduled when that
+       promise resolves.
+       */
+       static getSkippingParser(until) {
+           return new class extends Parser$2 {
+               createParse(input, fragments, ranges) {
+                   let from = ranges[0].from, to = ranges[ranges.length - 1].to;
+                   let parser = {
+                       parsedPos: from,
+                       advance() {
+                           let cx = currentContext$2;
+                           if (cx) {
+                               for (let r of ranges)
+                                   cx.tempSkipped.push(r);
+                               if (until)
+                                   cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
+                           }
+                           this.parsedPos = to;
+                           return new Tree$2(NodeType$2.none, [], [], to - from);
+                       },
+                       stoppedAt: null,
+                       stopAt() { }
+                   };
+                   return parser;
+               }
+           };
+       }
+       /**
+       @internal
+       */
+       isDone(upto) {
+           upto = Math.min(upto, this.state.doc.length);
+           let frags = this.fragments;
+           return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
+       }
+       /**
+       Get the context for the current parse, or `null` if no editor
+       parse is in progress.
+       */
+       static get() { return currentContext$2; }
+   };
+   function cutFragments$2(fragments, from, to) {
+       return TreeFragment$2.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
+   }
+   let LanguageState$2 = class LanguageState {
+       constructor(
+       // A mutable parse state that is used to preserve work done during
+       // the lifetime of a state when moving to the next state.
+       context) {
+           this.context = context;
+           this.tree = context.tree;
+       }
+       apply(tr) {
+           if (!tr.docChanged && this.tree == this.context.tree)
+               return this;
+           let newCx = this.context.changes(tr.changes, tr.state);
+           // If the previous parse wasn't done, go forward only up to its
+           // end position or the end of the viewport, to avoid slowing down
+           // state updates with parse work beyond the viewport.
+           let upto = this.context.treeLen == tr.startState.doc.length ? undefined
+               : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
+           if (!newCx.work(20 /* Apply */, upto))
+               newCx.takeTree();
+           return new LanguageState(newCx);
+       }
+       static init(state) {
+           let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
+           let parseState = ParseContext$2.create(state.facet(language$2).parser, state, { from: 0, to: vpTo });
+           if (!parseState.work(20 /* Apply */, vpTo))
+               parseState.takeTree();
+           return new LanguageState(parseState);
+       }
+   };
+   Language$2.state = /*@__PURE__*/StateField$3.define({
+       create: LanguageState$2.init,
+       update(value, tr) {
+           for (let e of tr.effects)
+               if (e.is(Language$2.setState))
+                   return e.value;
+           if (tr.startState.facet(language$2) != tr.state.facet(language$2))
+               return LanguageState$2.init(tr.state);
+           return value.apply(tr);
+       }
+   });
+   let requestIdle$2 = (callback) => {
+       let timeout = setTimeout(() => callback(), 500 /* MaxPause */);
+       return () => clearTimeout(timeout);
+   };
+   if (typeof requestIdleCallback != "undefined")
+       requestIdle$2 = (callback) => {
+           let idle = -1, timeout = setTimeout(() => {
+               idle = requestIdleCallback(callback, { timeout: 500 /* MaxPause */ - 100 /* MinPause */ });
+           }, 100 /* MinPause */);
+           return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
+       };
+   const isInputPending$2 = typeof navigator != "undefined" && ((_a$2 = navigator.scheduling) === null || _a$2 === void 0 ? void 0 : _a$2.isInputPending)
+       ? () => navigator.scheduling.isInputPending() : null;
+   const parseWorker$2 = /*@__PURE__*/ViewPlugin$3.fromClass(class ParseWorker {
+       constructor(view) {
+           this.view = view;
+           this.working = null;
+           this.workScheduled = 0;
+           // End of the current time chunk
+           this.chunkEnd = -1;
+           // Milliseconds of budget left for this chunk
+           this.chunkBudget = -1;
+           this.work = this.work.bind(this);
+           this.scheduleWork();
+       }
+       update(update) {
+           let cx = this.view.state.field(Language$2.state).context;
+           if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
+               this.scheduleWork();
+           if (update.docChanged) {
+               if (this.view.hasFocus)
+                   this.chunkBudget += 50 /* ChangeBonus */;
+               this.scheduleWork();
+           }
+           this.checkAsyncSchedule(cx);
+       }
+       scheduleWork() {
+           if (this.working)
+               return;
+           let { state } = this.view, field = state.field(Language$2.state);
+           if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
+               this.working = requestIdle$2(this.work);
+       }
+       work(deadline) {
+           this.working = null;
+           let now = Date.now();
+           if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
+               this.chunkEnd = now + 30000 /* ChunkTime */;
+               this.chunkBudget = 3000 /* ChunkBudget */;
+           }
+           if (this.chunkBudget <= 0)
+               return; // No more budget
+           let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language$2.state);
+           if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* MaxParseAhead */))
+               return;
+           let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Slice */, deadline && !isInputPending$2 ? Math.max(25 /* MinSlice */, deadline.timeRemaining() - 5) : 1e9);
+           let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
+           let done = field.context.work(() => {
+               return isInputPending$2 && isInputPending$2() || Date.now() > endTime;
+           }, vpTo + (viewportFirst ? 0 : 100000 /* MaxParseAhead */));
+           this.chunkBudget -= Date.now() - now;
+           if (done || this.chunkBudget <= 0) {
+               field.context.takeTree();
+               this.view.dispatch({ effects: Language$2.setState.of(new LanguageState$2(field.context)) });
+           }
+           if (this.chunkBudget > 0 && !(done && !viewportFirst))
+               this.scheduleWork();
+           this.checkAsyncSchedule(field.context);
+       }
+       checkAsyncSchedule(cx) {
+           if (cx.scheduleOn) {
+               this.workScheduled++;
+               cx.scheduleOn
+                   .then(() => this.scheduleWork())
+                   .catch(err => logException$3(this.view.state, err))
+                   .then(() => this.workScheduled--);
+               cx.scheduleOn = null;
+           }
+       }
+       destroy() {
+           if (this.working)
+               this.working();
+       }
+       isWorking() {
+           return !!(this.working || this.workScheduled > 0);
+       }
+   }, {
+       eventHandlers: { focus() { this.scheduleWork(); } }
+   });
+   /**
+   The facet used to associate a language with an editor state.
+   */
+   const language$2 = /*@__PURE__*/Facet$3.define({
+       combine(languages) { return languages.length ? languages[0] : null; },
+       enables: [Language$2.state, parseWorker$2]
+   });
+
+   /**
+   Facet that defines a way to provide a function that computes the
+   appropriate indentation depth at the start of a given line, or
+   `null` to indicate no appropriate indentation could be determined.
+   */
+   const indentService$1 = /*@__PURE__*/Facet$3.define();
+   /**
+   Facet for overriding the unit by which indentation happens.
+   Should be a string consisting either entirely of spaces or
+   entirely of tabs. When not set, this defaults to 2 spaces.
+   */
+   const indentUnit$2 = /*@__PURE__*/Facet$3.define({
+       combine: values => {
+           if (!values.length)
+               return "  ";
+           if (!/^(?: +|\t+)$/.test(values[0]))
+               throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
+           return values[0];
+       }
+   });
+   /**
+   Return the _column width_ of an indent unit in the state.
+   Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
+   facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
+   contains tabs.
+   */
+   function getIndentUnit$1(state) {
+       let unit = state.facet(indentUnit$2);
+       return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
+   }
+   /**
+   Create an indentation string that covers columns 0 to `cols`.
+   Will use tabs for as much of the columns as possible when the
+   [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
+   tabs.
+   */
+   function indentString$1(state, cols) {
+       let result = "", ts = state.tabSize;
+       if (state.facet(indentUnit$2).charCodeAt(0) == 9)
+           while (cols >= ts) {
+               result += "\t";
+               cols -= ts;
+           }
+       for (let i = 0; i < cols; i++)
+           result += " ";
+       return result;
+   }
+   /**
+   Get the indentation at the given position. Will first consult any
+   [indent services](https://codemirror.net/6/docs/ref/#language.indentService) that are registered,
+   and if none of those return an indentation, this will check the
+   syntax tree for the [indent node prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp)
+   and use that if found. Returns a number when an indentation could
+   be determined, and null otherwise.
+   */
+   function getIndentation$1(context, pos) {
+       if (context instanceof EditorState$3)
+           context = new IndentContext$1(context);
+       for (let service of context.state.facet(indentService$1)) {
+           let result = service(context, pos);
+           if (result != null)
+               return result;
+       }
+       let tree = syntaxTree$2(context.state);
+       return tree ? syntaxIndentation$1(context, tree, pos) : null;
+   }
+   /**
+   Indentation contexts are used when calling [indentation
+   services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
+   useful in indentation logic, and can selectively override the
+   indentation reported for some lines.
+   */
+   let IndentContext$1 = class IndentContext {
+       /**
+       Create an indent context.
+       */
+       constructor(
+       /**
+       The editor state.
+       */
+       state, 
+       /**
+       @internal
+       */
+       options = {}) {
+           this.state = state;
+           this.options = options;
+           this.unit = getIndentUnit$1(state);
+       }
+       /**
+       Get a description of the line at the given position, taking
+       [simulated line
+       breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
+       into account. If there is such a break at `pos`, the `bias`
+       argument determines whether the part of the line line before or
+       after the break is used.
+       */
+       lineAt(pos, bias = 1) {
+           let line = this.state.doc.lineAt(pos);
+           let { simulateBreak, simulateDoubleBreak } = this.options;
+           if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
+               if (simulateDoubleBreak && simulateBreak == pos)
+                   return { text: "", from: pos };
+               else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
+                   return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
+               else
+                   return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
+           }
+           return line;
+       }
+       /**
+       Get the text directly after `pos`, either the entire line
+       or the next 100 characters, whichever is shorter.
+       */
+       textAfterPos(pos, bias = 1) {
+           if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
+               return "";
+           let { text, from } = this.lineAt(pos, bias);
+           return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
+       }
+       /**
+       Find the column for the given position.
+       */
+       column(pos, bias = 1) {
+           let { text, from } = this.lineAt(pos, bias);
+           let result = this.countColumn(text, pos - from);
+           let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
+           if (override > -1)
+               result += override - this.countColumn(text, text.search(/\S|$/));
+           return result;
+       }
+       /**
+       Find the column position (taking tabs into account) of the given
+       position in the given string.
+       */
+       countColumn(line, pos = line.length) {
+           return countColumn$1(line, this.state.tabSize, pos);
+       }
+       /**
+       Find the indentation column of the line at the given point.
+       */
+       lineIndent(pos, bias = 1) {
+           let { text, from } = this.lineAt(pos, bias);
+           let override = this.options.overrideIndentation;
+           if (override) {
+               let overriden = override(from);
+               if (overriden > -1)
+                   return overriden;
+           }
+           return this.countColumn(text, text.search(/\S|$/));
+       }
+       /**
+       Returns the [simulated line
+       break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
+       for this context, if any.
+       */
+       get simulatedBreak() {
+           return this.options.simulateBreak || null;
+       }
+   };
+   /**
+   A syntax tree node prop used to associate indentation strategies
+   with node types. Such a strategy is a function from an indentation
+   context to a column number or null, where null indicates that no
+   definitive indentation can be determined.
+   */
+   const indentNodeProp$2 = /*@__PURE__*/new NodeProp$2();
+   // Compute the indentation for a given position from the syntax tree.
+   function syntaxIndentation$1(cx, ast, pos) {
+       return indentFrom$1(ast.resolveInner(pos).enterUnfinishedNodesBefore(pos), pos, cx);
+   }
+   function ignoreClosed$1(cx) {
+       return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
+   }
+   function indentStrategy$1(tree) {
+       let strategy = tree.type.prop(indentNodeProp$2);
+       if (strategy)
+           return strategy;
+       let first = tree.firstChild, close;
+       if (first && (close = first.type.prop(NodeProp$2.closedBy))) {
+           let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
+           return cx => delimitedStrategy$2(cx, true, 1, undefined, closed && !ignoreClosed$1(cx) ? last.from : undefined);
+       }
+       return tree.parent == null ? topIndent$1 : null;
+   }
+   function indentFrom$1(node, pos, base) {
+       for (; node; node = node.parent) {
+           let strategy = indentStrategy$1(node);
+           if (strategy)
+               return strategy(TreeIndentContext$1.create(base, pos, node));
+       }
+       return null;
+   }
+   function topIndent$1() { return 0; }
+   /**
+   Objects of this type provide context information and helper
+   methods to indentation functions registered on syntax nodes.
+   */
+   let TreeIndentContext$1 = class TreeIndentContext extends IndentContext$1 {
+       constructor(base, 
+       /**
+       The position at which indentation is being computed.
+       */
+       pos, 
+       /**
+       The syntax tree node to which the indentation strategy
+       applies.
+       */
+       node) {
+           super(base.state, base.options);
+           this.base = base;
+           this.pos = pos;
+           this.node = node;
+       }
+       /**
+       @internal
+       */
+       static create(base, pos, node) {
+           return new TreeIndentContext(base, pos, node);
+       }
+       /**
+       Get the text directly after `this.pos`, either the entire line
+       or the next 100 characters, whichever is shorter.
+       */
+       get textAfter() {
+           return this.textAfterPos(this.pos);
+       }
+       /**
+       Get the indentation at the reference line for `this.node`, which
+       is the line on which it starts, unless there is a node that is
+       _not_ a parent of this node covering the start of that line. If
+       so, the line at the start of that node is tried, again skipping
+       on if it is covered by another such node.
+       */
+       get baseIndent() {
+           let line = this.state.doc.lineAt(this.node.from);
+           // Skip line starts that are covered by a sibling (or cousin, etc)
+           for (;;) {
+               let atBreak = this.node.resolve(line.from);
+               while (atBreak.parent && atBreak.parent.from == atBreak.from)
+                   atBreak = atBreak.parent;
+               if (isParent$1(atBreak, this.node))
+                   break;
+               line = this.state.doc.lineAt(atBreak.from);
+           }
+           return this.lineIndent(line.from);
+       }
+       /**
+       Continue looking for indentations in the node's parent nodes,
+       and return the result of that.
+       */
+       continue() {
+           let parent = this.node.parent;
+           return parent ? indentFrom$1(parent, this.pos, this.base) : 0;
+       }
+   };
+   function isParent$1(parent, of) {
+       for (let cur = of; cur; cur = cur.parent)
+           if (parent == cur)
+               return true;
+       return false;
+   }
+   // Check whether a delimited node is aligned (meaning there are
+   // non-skipped nodes on the same line as the opening delimiter). And
+   // if so, return the opening token.
+   function bracketedAligned$2(context) {
+       let tree = context.node;
+       let openToken = tree.childAfter(tree.from), last = tree.lastChild;
+       if (!openToken)
+           return null;
+       let sim = context.options.simulateBreak;
+       let openLine = context.state.doc.lineAt(openToken.from);
+       let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
+       for (let pos = openToken.to;;) {
+           let next = tree.childAfter(pos);
+           if (!next || next == last)
+               return null;
+           if (!next.type.isSkipped)
+               return next.from < lineEnd ? openToken : null;
+           pos = next.to;
+       }
+   }
+   function delimitedStrategy$2(context, align, units, closing, closedAt) {
+       let after = context.textAfter, space = after.match(/^\s*/)[0].length;
+       let closed = closedAt == context.pos + space;
+       let aligned = bracketedAligned$2(context) ;
+       if (aligned)
+           return closed ? context.column(aligned.from) : context.column(aligned.to);
+       return context.baseIndent + (closed ? 0 : context.unit * units);
+   }
+   const DontIndentBeyond = 200;
+   /**
+   Enables reindentation on input. When a language defines an
+   `indentOnInput` field in its [language
+   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
+   expression, the line at the cursor will be reindented whenever new
+   text is typed and the input from the start of the line up to the
+   cursor matches that regexp.
+
+   To avoid unneccesary reindents, it is recommended to start the
+   regexp with `^` (usually followed by `\s*`), and end it with `$`.
+   For example, `/^\s*\}$/` will reindent when a closing brace is
+   added at the start of a line.
+   */
+   function indentOnInput() {
+       return EditorState$3.transactionFilter.of(tr => {
+           if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
+               return tr;
+           let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
+           if (!rules.length)
+               return tr;
+           let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);
+           if (head > line.from + DontIndentBeyond)
+               return tr;
+           let lineStart = doc.sliceString(line.from, head);
+           if (!rules.some(r => r.test(lineStart)))
+               return tr;
+           let { state } = tr, last = -1, changes = [];
+           for (let { head } of state.selection.ranges) {
+               let line = state.doc.lineAt(head);
+               if (line.from == last)
+                   continue;
+               last = line.from;
+               let indent = getIndentation$1(state, line.from);
+               if (indent == null)
+                   continue;
+               let cur = /^\s*/.exec(line.text)[0];
+               let norm = indentString$1(state, indent);
+               if (cur != norm)
+                   changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
+           }
+           return changes.length ? [tr, { changes, sequential: true }] : tr;
+       });
+   }
+
+   /**
+   A facet that registers a code folding service. When called with
+   the extent of a line, such a function should return a foldable
+   range that starts on that line (but continues beyond it), if one
+   can be found.
+   */
+   const foldService = /*@__PURE__*/Facet$3.define();
+   /**
+   This node prop is used to associate folding information with
+   syntax node types. Given a syntax node, it should check whether
+   that tree is foldable and return the range that can be collapsed
+   when it is.
+   */
+   const foldNodeProp$1 = /*@__PURE__*/new NodeProp$2();
+   function syntaxFolding(state, start, end) {
+       let tree = syntaxTree$2(state);
+       if (tree.length < end)
+           return null;
+       let inner = tree.resolveInner(end);
+       let found = null;
+       for (let cur = inner; cur; cur = cur.parent) {
+           if (cur.to <= end || cur.from > end)
+               continue;
+           if (found && cur.from < start)
+               break;
+           let prop = cur.type.prop(foldNodeProp$1);
+           if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {
+               let value = prop(cur, state);
+               if (value && value.from <= end && value.from >= start && value.to > end)
+                   found = value;
+           }
+       }
+       return found;
+   }
+   function isUnfinished(node) {
+       let ch = node.lastChild;
+       return ch && ch.to == node.to && ch.type.isError;
+   }
+   /**
+   Check whether the given line is foldable. First asks any fold
+   services registered through
+   [`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return
+   a result, tries to query the [fold node
+   prop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end
+   of the line.
+   */
+   function foldable(state, lineStart, lineEnd) {
+       for (let service of state.facet(foldService)) {
+           let result = service(state, lineStart, lineEnd);
+           if (result)
+               return result;
+       }
+       return syntaxFolding(state, lineStart, lineEnd);
+   }
+   function mapRange(range, mapping) {
+       let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);
+       return from >= to ? undefined : { from, to };
+   }
+   /**
+   State effect that can be attached to a transaction to fold the
+   given range. (You probably only need this in exceptional
+   circumstances—usually you'll just want to let
+   [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold
+   gutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)
+   */
+   const foldEffect = /*@__PURE__*/StateEffect$3.define({ map: mapRange });
+   /**
+   State effect that unfolds the given range (if it was folded).
+   */
+   const unfoldEffect = /*@__PURE__*/StateEffect$3.define({ map: mapRange });
+   function selectedLines(view) {
+       let lines = [];
+       for (let { head } of view.state.selection.ranges) {
+           if (lines.some(l => l.from <= head && l.to >= head))
+               continue;
+           lines.push(view.lineBlockAt(head));
+       }
+       return lines;
+   }
+   const foldState = /*@__PURE__*/StateField$3.define({
+       create() {
+           return Decoration$3.none;
+       },
+       update(folded, tr) {
+           folded = folded.map(tr.changes);
+           for (let e of tr.effects) {
+               if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to))
+                   folded = folded.update({ add: [foldWidget.range(e.value.from, e.value.to)] });
+               else if (e.is(unfoldEffect))
+                   folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,
+                       filterFrom: e.value.from, filterTo: e.value.to });
+           }
+           // Clear folded ranges that cover the selection head
+           if (tr.selection) {
+               let onSelection = false, { head } = tr.selection.main;
+               folded.between(head, head, (a, b) => { if (a < head && b > head)
+                   onSelection = true; });
+               if (onSelection)
+                   folded = folded.update({
+                       filterFrom: head,
+                       filterTo: head,
+                       filter: (a, b) => b <= head || a >= head
+                   });
+           }
+           return folded;
+       },
+       provide: f => EditorView$3.decorations.from(f)
+   });
+   function findFold(state, from, to) {
+       var _a;
+       let found = null;
+       (_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {
+           if (!found || found.from > from)
+               found = { from, to };
+       });
+       return found;
+   }
+   function foldExists(folded, from, to) {
+       let found = false;
+       folded.between(from, from, (a, b) => { if (a == from && b == to)
+           found = true; });
+       return found;
+   }
+   function maybeEnable(state, other) {
+       return state.field(foldState, false) ? other : other.concat(StateEffect$3.appendConfig.of(codeFolding()));
+   }
+   /**
+   Fold the lines that are selected, if possible.
+   */
+   const foldCode = view => {
+       for (let line of selectedLines(view)) {
+           let range = foldable(view.state, line.from, line.to);
+           if (range) {
+               view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });
+               return true;
+           }
+       }
+       return false;
+   };
+   /**
+   Unfold folded ranges on selected lines.
+   */
+   const unfoldCode = view => {
+       if (!view.state.field(foldState, false))
+           return false;
+       let effects = [];
+       for (let line of selectedLines(view)) {
+           let folded = findFold(view.state, line.from, line.to);
+           if (folded)
+               effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));
+       }
+       if (effects.length)
+           view.dispatch({ effects });
+       return effects.length > 0;
+   };
+   function announceFold(view, range, fold = true) {
+       let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;
+       return EditorView$3.announce.of(`${view.state.phrase(fold ? "Folded lines" : "Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);
+   }
+   /**
+   Fold all top-level foldable ranges. Note that, in most cases,
+   folding information will depend on the [syntax
+   tree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work
+   reliably when the document hasn't been fully parsed (either
+   because the editor state was only just initialized, or because the
+   document is so big that the parser decided not to parse it
+   entirely).
+   */
+   const foldAll = view => {
+       let { state } = view, effects = [];
+       for (let pos = 0; pos < state.doc.length;) {
+           let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);
+           if (range)
+               effects.push(foldEffect.of(range));
+           pos = (range ? view.lineBlockAt(range.to) : line).to + 1;
+       }
+       if (effects.length)
+           view.dispatch({ effects: maybeEnable(view.state, effects) });
+       return !!effects.length;
+   };
+   /**
+   Unfold all folded code.
+   */
+   const unfoldAll = view => {
+       let field = view.state.field(foldState, false);
+       if (!field || !field.size)
+           return false;
+       let effects = [];
+       field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });
+       view.dispatch({ effects });
+       return true;
+   };
+   /**
+   Default fold-related key bindings.
+
+    - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).
+    - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).
+    - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).
+    - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).
+   */
+   const foldKeymap = [
+       { key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: foldCode },
+       { key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: unfoldCode },
+       { key: "Ctrl-Alt-[", run: foldAll },
+       { key: "Ctrl-Alt-]", run: unfoldAll }
+   ];
+   const defaultConfig = {
+       placeholderDOM: null,
+       placeholderText: "…"
+   };
+   const foldConfig = /*@__PURE__*/Facet$3.define({
+       combine(values) { return combineConfig$3(values, defaultConfig); }
+   });
+   /**
+   Create an extension that configures code folding.
+   */
+   function codeFolding(config) {
+       let result = [foldState, baseTheme$1$4];
+       return result;
+   }
+   const foldWidget = /*@__PURE__*/Decoration$3.replace({ widget: /*@__PURE__*/new class extends WidgetType$3 {
+           toDOM(view) {
+               let { state } = view, conf = state.facet(foldConfig);
+               let onclick = (event) => {
+                   let line = view.lineBlockAt(view.posAtDOM(event.target));
+                   let folded = findFold(view.state, line.from, line.to);
+                   if (folded)
+                       view.dispatch({ effects: unfoldEffect.of(folded) });
+                   event.preventDefault();
+               };
+               if (conf.placeholderDOM)
+                   return conf.placeholderDOM(view, onclick);
+               let element = document.createElement("span");
+               element.textContent = conf.placeholderText;
+               element.setAttribute("aria-label", state.phrase("folded code"));
+               element.title = state.phrase("unfold");
+               element.className = "cm-foldPlaceholder";
+               element.onclick = onclick;
+               return element;
+           }
+       } });
+   const foldGutterDefaults = {
+       openText: "⌄",
+       closedText: "›",
+       markerDOM: null,
+       domEventHandlers: {},
+   };
+   class FoldMarker extends GutterMarker$3 {
+       constructor(config, open) {
+           super();
+           this.config = config;
+           this.open = open;
+       }
+       eq(other) { return this.config == other.config && this.open == other.open; }
+       toDOM(view) {
+           if (this.config.markerDOM)
+               return this.config.markerDOM(this.open);
+           let span = document.createElement("span");
+           span.textContent = this.open ? this.config.openText : this.config.closedText;
+           span.title = view.state.phrase(this.open ? "Fold line" : "Unfold line");
+           return span;
+       }
+   }
+   /**
+   Create an extension that registers a fold gutter, which shows a
+   fold status indicator before foldable lines (which can be clicked
+   to fold or unfold the line).
+   */
+   function foldGutter(config = {}) {
+       let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
+       let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
+       let markers = ViewPlugin$3.fromClass(class {
+           constructor(view) {
+               this.from = view.viewport.from;
+               this.markers = this.buildMarkers(view);
+           }
+           update(update) {
+               if (update.docChanged || update.viewportChanged ||
+                   update.startState.facet(language$2) != update.state.facet(language$2) ||
+                   update.startState.field(foldState, false) != update.state.field(foldState, false) ||
+                   syntaxTree$2(update.startState) != syntaxTree$2(update.state))
+                   this.markers = this.buildMarkers(update.view);
+           }
+           buildMarkers(view) {
+               let builder = new RangeSetBuilder$3();
+               for (let line of view.viewportLineBlocks) {
+                   let mark = findFold(view.state, line.from, line.to) ? canUnfold
+                       : foldable(view.state, line.from, line.to) ? canFold : null;
+                   if (mark)
+                       builder.add(line.from, line.from, mark);
+               }
+               return builder.finish();
+           }
+       });
+       let { domEventHandlers } = fullConfig;
+       return [
+           markers,
+           gutter$1({
+               class: "cm-foldGutter",
+               markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet$3.empty; },
+               initialSpacer() {
+                   return new FoldMarker(fullConfig, false);
+               },
+               domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
+                       if (domEventHandlers.click && domEventHandlers.click(view, line, event))
+                           return true;
+                       let folded = findFold(view.state, line.from, line.to);
+                       if (folded) {
+                           view.dispatch({ effects: unfoldEffect.of(folded) });
+                           return true;
+                       }
+                       let range = foldable(view.state, line.from, line.to);
+                       if (range) {
+                           view.dispatch({ effects: foldEffect.of(range) });
+                           return true;
+                       }
+                       return false;
+                   } })
+           }),
+           codeFolding()
+       ];
+   }
+   const baseTheme$1$4 = /*@__PURE__*/EditorView$3.baseTheme({
+       ".cm-foldPlaceholder": {
+           backgroundColor: "#eee",
+           border: "1px solid #ddd",
+           color: "#888",
+           borderRadius: ".2em",
+           margin: "0 1px",
+           padding: "0 1px",
+           cursor: "pointer"
+       },
+       ".cm-foldGutter span": {
+           padding: "0 1px",
+           cursor: "pointer"
+       }
+   });
+
+   /**
+   A highlight style associates CSS styles with higlighting
+   [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
+   */
+   let HighlightStyle$1 = class HighlightStyle {
+       constructor(spec, options) {
+           let modSpec;
+           function def(spec) {
+               let cls = StyleModule.newName();
+               (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
+               return cls;
+           }
+           const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
+           const scopeOpt = options.scope;
+           this.scope = scopeOpt instanceof Language$2 ? (type) => type.prop(languageDataProp$2) == scopeOpt.data
+               : scopeOpt ? (type) => type == scopeOpt : undefined;
+           this.style = tagHighlighter$2(spec.map(style => ({
+               tag: style.tag,
+               class: style.class || def(Object.assign({}, style, { tag: null }))
+           })), {
+               all,
+           }).style;
+           this.module = modSpec ? new StyleModule(modSpec) : null;
+           this.themeType = options.themeType;
+       }
+       /**
+       Create a highlighter style that associates the given styles to
+       the given tags. The specs must be objects that hold a style tag
+       or array of tags in their `tag` property, and either a single
+       `class` property providing a static CSS class (for highlighter
+       that rely on external styling), or a
+       [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
+       set of CSS properties (which define the styling for those tags).
+       
+       The CSS rules created for a highlighter will be emitted in the
+       order of the spec's properties. That means that for elements that
+       have multiple tags associated with them, styles defined further
+       down in the list will have a higher CSS precedence than styles
+       defined earlier.
+       */
+       static define(specs, options) {
+           return new HighlightStyle(specs, options || {});
+       }
+   };
+   const highlighterFacet$1 = /*@__PURE__*/Facet$3.define();
+   const fallbackHighlighter$1 = /*@__PURE__*/Facet$3.define({
+       combine(values) { return values.length ? [values[0]] : null; }
+   });
+   function getHighlighters$1(state) {
+       let main = state.facet(highlighterFacet$1);
+       return main.length ? main : state.facet(fallbackHighlighter$1);
+   }
+   /**
+   Wrap a highlighter in an editor extension that uses it to apply
+   syntax highlighting to the editor content.
+
+   When multiple (non-fallback) styles are provided, the styling
+   applied is the union of the classes they emit.
+   */
+   function syntaxHighlighting$1(highlighter, options) {
+       let ext = [treeHighlighter$1], themeType;
+       if (highlighter instanceof HighlightStyle$1) {
+           if (highlighter.module)
+               ext.push(EditorView$3.styleModule.of(highlighter.module));
+           themeType = highlighter.themeType;
+       }
+       if (options === null || options === void 0 ? void 0 : options.fallback)
+           ext.push(fallbackHighlighter$1.of(highlighter));
+       else if (themeType)
+           ext.push(highlighterFacet$1.computeN([EditorView$3.darkTheme], state => {
+               return state.facet(EditorView$3.darkTheme) == (themeType == "dark") ? [highlighter] : [];
+           }));
+       else
+           ext.push(highlighterFacet$1.of(highlighter));
+       return ext;
+   }
+   let TreeHighlighter$1 = class TreeHighlighter {
+       constructor(view) {
+           this.markCache = Object.create(null);
+           this.tree = syntaxTree$2(view.state);
+           this.decorations = this.buildDeco(view, getHighlighters$1(view.state));
+       }
+       update(update) {
+           let tree = syntaxTree$2(update.state), highlighters = getHighlighters$1(update.state);
+           let styleChange = highlighters != getHighlighters$1(update.startState);
+           if (tree.length < update.view.viewport.to && !styleChange && tree.type == this.tree.type) {
+               this.decorations = this.decorations.map(update.changes);
+           }
+           else if (tree != this.tree || update.viewportChanged || styleChange) {
+               this.tree = tree;
+               this.decorations = this.buildDeco(update.view, highlighters);
+           }
+       }
+       buildDeco(view, highlighters) {
+           if (!highlighters || !this.tree.length)
+               return Decoration$3.none;
+           let builder = new RangeSetBuilder$3();
+           for (let { from, to } of view.visibleRanges) {
+               highlightTree$1(this.tree, highlighters, (from, to, style) => {
+                   builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration$3.mark({ class: style })));
+               }, from, to);
+           }
+           return builder.finish();
+       }
+   };
+   const treeHighlighter$1 = /*@__PURE__*/Prec$3.high(/*@__PURE__*/ViewPlugin$3.fromClass(TreeHighlighter$1, {
+       decorations: v => v.decorations
+   }));
+   /**
+   A default highlight style (works well with light themes).
+   */
+   const defaultHighlightStyle = /*@__PURE__*/HighlightStyle$1.define([
+       { tag: tags$2.meta,
+           color: "#7a757a" },
+       { tag: tags$2.link,
+           textDecoration: "underline" },
+       { tag: tags$2.heading,
+           textDecoration: "underline",
+           fontWeight: "bold" },
+       { tag: tags$2.emphasis,
+           fontStyle: "italic" },
+       { tag: tags$2.strong,
+           fontWeight: "bold" },
+       { tag: tags$2.strikethrough,
+           textDecoration: "line-through" },
+       { tag: tags$2.keyword,
+           color: "#708" },
+       { tag: [tags$2.atom, tags$2.bool, tags$2.url, tags$2.contentSeparator, tags$2.labelName],
+           color: "#219" },
+       { tag: [tags$2.literal, tags$2.inserted],
+           color: "#164" },
+       { tag: [tags$2.string, tags$2.deleted],
+           color: "#a11" },
+       { tag: [tags$2.regexp, tags$2.escape, /*@__PURE__*/tags$2.special(tags$2.string)],
+           color: "#e40" },
+       { tag: /*@__PURE__*/tags$2.definition(tags$2.variableName),
+           color: "#00f" },
+       { tag: /*@__PURE__*/tags$2.local(tags$2.variableName),
+           color: "#30a" },
+       { tag: [tags$2.typeName, tags$2.namespace],
+           color: "#085" },
+       { tag: tags$2.className,
+           color: "#167" },
+       { tag: [/*@__PURE__*/tags$2.special(tags$2.variableName), tags$2.macroName],
+           color: "#256" },
+       { tag: /*@__PURE__*/tags$2.definition(tags$2.propertyName),
+           color: "#00c" },
+       { tag: tags$2.comment,
+           color: "#940" },
+       { tag: tags$2.invalid,
+           color: "#f00" }
+   ]);
+
+   const baseTheme$6 = /*@__PURE__*/EditorView$3.baseTheme({
+       "&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
+       "&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
+   });
+   const DefaultScanDist$1 = 10000, DefaultBrackets$1 = "()[]{}";
+   const bracketMatchingConfig = /*@__PURE__*/Facet$3.define({
+       combine(configs) {
+           return combineConfig$3(configs, {
+               afterCursor: true,
+               brackets: DefaultBrackets$1,
+               maxScanDistance: DefaultScanDist$1,
+               renderMatch: defaultRenderMatch
+           });
+       }
+   });
+   const matchingMark = /*@__PURE__*/Decoration$3.mark({ class: "cm-matchingBracket" }), nonmatchingMark = /*@__PURE__*/Decoration$3.mark({ class: "cm-nonmatchingBracket" });
+   function defaultRenderMatch(match) {
+       let decorations = [];
+       let mark = match.matched ? matchingMark : nonmatchingMark;
+       decorations.push(mark.range(match.start.from, match.start.to));
+       if (match.end)
+           decorations.push(mark.range(match.end.from, match.end.to));
+       return decorations;
+   }
+   const bracketMatchingState = /*@__PURE__*/StateField$3.define({
+       create() { return Decoration$3.none; },
+       update(deco, tr) {
+           if (!tr.docChanged && !tr.selection)
+               return deco;
+           let decorations = [];
+           let config = tr.state.facet(bracketMatchingConfig);
+           for (let range of tr.state.selection.ranges) {
+               if (!range.empty)
+                   continue;
+               let match = matchBrackets$1(tr.state, range.head, -1, config)
+                   || (range.head > 0 && matchBrackets$1(tr.state, range.head - 1, 1, config))
+                   || (config.afterCursor &&
+                       (matchBrackets$1(tr.state, range.head, 1, config) ||
+                           (range.head < tr.state.doc.length && matchBrackets$1(tr.state, range.head + 1, -1, config))));
+               if (match)
+                   decorations = decorations.concat(config.renderMatch(match, tr.state));
+           }
+           return Decoration$3.set(decorations, true);
+       },
+       provide: f => EditorView$3.decorations.from(f)
+   });
+   const bracketMatchingUnique = [
+       bracketMatchingState,
+       baseTheme$6
+   ];
+   /**
+   Create an extension that enables bracket matching. Whenever the
+   cursor is next to a bracket, that bracket and the one it matches
+   are highlighted. Or, when no matching bracket is found, another
+   highlighting style is used to indicate this.
+   */
+   function bracketMatching(config = {}) {
+       return [bracketMatchingConfig.of(config), bracketMatchingUnique];
+   }
+   function matchingNodes$1(node, dir, brackets) {
+       let byProp = node.prop(dir < 0 ? NodeProp$2.openedBy : NodeProp$2.closedBy);
+       if (byProp)
+           return byProp;
+       if (node.name.length == 1) {
+           let index = brackets.indexOf(node.name);
+           if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
+               return [brackets[index + dir]];
+       }
+       return null;
+   }
+   /**
+   Find the matching bracket for the token at `pos`, scanning
+   direction `dir`. Only the `brackets` and `maxScanDistance`
+   properties are used from `config`, if given. Returns null if no
+   bracket was found at `pos`, or a match result otherwise.
+   */
+   function matchBrackets$1(state, pos, dir, config = {}) {
+       let maxScanDistance = config.maxScanDistance || DefaultScanDist$1, brackets = config.brackets || DefaultBrackets$1;
+       let tree = syntaxTree$2(state), node = tree.resolveInner(pos, dir);
+       for (let cur = node; cur; cur = cur.parent) {
+           let matches = matchingNodes$1(cur.type, dir, brackets);
+           if (matches && cur.from < cur.to)
+               return matchMarkedBrackets$1(state, pos, dir, cur, matches, brackets);
+       }
+       return matchPlainBrackets$1(state, pos, dir, tree, node.type, maxScanDistance, brackets);
+   }
+   function matchMarkedBrackets$1(_state, _pos, dir, token, matching, brackets) {
+       let parent = token.parent, firstToken = { from: token.from, to: token.to };
+       let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
+       if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
+           do {
+               if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
+                   if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
+                       return { start: firstToken, end: { from: cursor.from, to: cursor.to }, matched: true };
+                   }
+                   else if (matchingNodes$1(cursor.type, dir, brackets)) {
+                       depth++;
+                   }
+                   else if (matchingNodes$1(cursor.type, -dir, brackets)) {
+                       depth--;
+                       if (depth == 0)
+                           return {
+                               start: firstToken,
+                               end: cursor.from == cursor.to ? undefined : { from: cursor.from, to: cursor.to },
+                               matched: false
+                           };
+                   }
+               }
+           } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
+       return { start: firstToken, matched: false };
+   }
+   function matchPlainBrackets$1(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
+       let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
+       let bracket = brackets.indexOf(startCh);
+       if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
+           return null;
+       let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
+       let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
+       for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
+           let text = iter.value;
+           if (dir < 0)
+               distance += text.length;
+           let basePos = pos + distance * dir;
+           for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
+               let found = brackets.indexOf(text[pos]);
+               if (found < 0 || tree.resolve(basePos + pos, 1).type != tokenType)
+                   continue;
+               if ((found % 2 == 0) == (dir > 0)) {
+                   depth++;
+               }
+               else if (depth == 1) { // Closing
+                   return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
+               }
+               else {
+                   depth--;
+               }
+           }
+           if (dir > 0)
+               distance += text.length;
+       }
+       return iter.done ? { start: startToken, matched: false } : null;
+   }
+   const noTokens$2 = /*@__PURE__*/Object.create(null);
+   const typeArray$2 = [NodeType$2.none];
+   const warned$2 = [];
+   const defaultTable$2 = /*@__PURE__*/Object.create(null);
+   for (let [legacyName, name] of [
+       ["variable", "variableName"],
+       ["variable-2", "variableName.special"],
+       ["string-2", "string.special"],
+       ["def", "variableName.definition"],
+       ["tag", "typeName"],
+       ["attribute", "propertyName"],
+       ["type", "typeName"],
+       ["builtin", "variableName.standard"],
+       ["qualifier", "modifier"],
+       ["error", "invalid"],
+       ["header", "heading"],
+       ["property", "propertyName"]
+   ])
+       defaultTable$2[legacyName] = /*@__PURE__*/createTokenType$2(noTokens$2, name);
+   function warnForPart$2(part, msg) {
+       if (warned$2.indexOf(part) > -1)
+           return;
+       warned$2.push(part);
+       console.warn(msg);
+   }
+   function createTokenType$2(extra, tagStr) {
+       let tag = null;
+       for (let part of tagStr.split(".")) {
+           let value = (extra[part] || tags$2[part]);
+           if (!value) {
+               warnForPart$2(part, `Unknown highlighting tag ${part}`);
+           }
+           else if (typeof value == "function") {
+               if (!tag)
+                   warnForPart$2(part, `Modifier ${part} used at start of tag`);
+               else
+                   tag = value(tag);
+           }
+           else {
+               if (tag)
+                   warnForPart$2(part, `Tag ${part} used as modifier`);
+               else
+                   tag = value;
+           }
+       }
+       if (!tag)
+           return 0;
+       let name = tagStr.replace(/ /g, "_"), type = NodeType$2.define({
+           id: typeArray$2.length,
+           name,
+           props: [styleTags$2({ [name]: tag })]
+       });
+       typeArray$2.push(type);
+       return type.id;
+   }
+
+   /**
+   The data structure for documents. @nonabstract
+   */
+   let Text$2 = class Text {
+       /**
+       @internal
+       */
+       constructor() { }
+       /**
+       Get the line description around the given position.
+       */
+       lineAt(pos) {
+           if (pos < 0 || pos > this.length)
+               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
+           return this.lineInner(pos, false, 1, 0);
+       }
+       /**
+       Get the description for the given (1-based) line number.
+       */
+       line(n) {
+           if (n < 1 || n > this.lines)
+               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
+           return this.lineInner(n, true, 1, 0);
+       }
+       /**
+       Replace a range of the text with the given content.
+       */
+       replace(from, to, text) {
+           let parts = [];
+           this.decompose(0, from, parts, 2 /* To */);
+           if (text.length)
+               text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
+           this.decompose(to, this.length, parts, 1 /* From */);
+           return TextNode$2.from(parts, this.length - (to - from) + text.length);
+       }
+       /**
+       Append another document to this one.
+       */
+       append(other) {
+           return this.replace(this.length, this.length, other);
+       }
+       /**
+       Retrieve the text between the given points.
+       */
+       slice(from, to = this.length) {
+           let parts = [];
+           this.decompose(from, to, parts, 0);
+           return TextNode$2.from(parts, to - from);
+       }
+       /**
+       Test whether this text is equal to another instance.
+       */
+       eq(other) {
+           if (other == this)
+               return true;
+           if (other.length != this.length || other.lines != this.lines)
+               return false;
+           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
+           let a = new RawTextCursor$2(this), b = new RawTextCursor$2(other);
+           for (let skip = start, pos = start;;) {
+               a.next(skip);
+               b.next(skip);
+               skip = 0;
+               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
+                   return false;
+               pos += a.value.length;
+               if (a.done || pos >= end)
+                   return true;
+           }
+       }
+       /**
+       Iterate over the text. When `dir` is `-1`, iteration happens
+       from end to start. This will return lines and the breaks between
+       them as separate strings.
+       */
+       iter(dir = 1) { return new RawTextCursor$2(this, dir); }
+       /**
+       Iterate over a range of the text. When `from` > `to`, the
+       iterator will run in reverse.
+       */
+       iterRange(from, to = this.length) { return new PartialTextCursor$2(this, from, to); }
+       /**
+       Return a cursor that iterates over the given range of lines,
+       _without_ returning the line breaks between, and yielding empty
+       strings for empty lines.
+       
+       When `from` and `to` are given, they should be 1-based line numbers.
+       */
+       iterLines(from, to) {
+           let inner;
+           if (from == null) {
+               inner = this.iter();
+           }
+           else {
+               if (to == null)
+                   to = this.lines + 1;
+               let start = this.line(from).from;
+               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
+           }
+           return new LineCursor$2(inner);
+       }
+       /**
+       @internal
+       */
+       toString() { return this.sliceString(0); }
+       /**
+       Convert the document to an array of lines (which can be
+       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
+       */
+       toJSON() {
+           let lines = [];
+           this.flatten(lines);
+           return lines;
+       }
+       /**
+       Create a `Text` instance for the given array of lines.
+       */
+       static of(text) {
+           if (text.length == 0)
+               throw new RangeError("A document must have at least one line");
+           if (text.length == 1 && !text[0])
+               return Text.empty;
+           return text.length <= 32 /* Branch */ ? new TextLeaf$2(text) : TextNode$2.from(TextLeaf$2.split(text, []));
+       }
+   };
+   // Leaves store an array of line strings. There are always line breaks
+   // between these strings. Leaves are limited in size and have to be
+   // contained in TextNode instances for bigger documents.
+   let TextLeaf$2 = class TextLeaf extends Text$2 {
+       constructor(text, length = textLength$2(text)) {
+           super();
+           this.text = text;
+           this.length = length;
+       }
+       get lines() { return this.text.length; }
+       get children() { return null; }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let string = this.text[i], end = offset + string.length;
+               if ((isLine ? line : end) >= target)
+                   return new Line$2(offset, end, line, string);
+               offset = end + 1;
+               line++;
+           }
+       }
+       decompose(from, to, target, open) {
+           let text = from <= 0 && to >= this.length ? this
+               : new TextLeaf(sliceText$2(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
+           if (open & 1 /* From */) {
+               let prev = target.pop();
+               let joined = appendText$2(text.text, prev.text.slice(), 0, text.length);
+               if (joined.length <= 32 /* Branch */) {
+                   target.push(new TextLeaf(joined, prev.length + text.length));
+               }
+               else {
+                   let mid = joined.length >> 1;
+                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
+               }
+           }
+           else {
+               target.push(text);
+           }
+       }
+       replace(from, to, text) {
+           if (!(text instanceof TextLeaf))
+               return super.replace(from, to, text);
+           let lines = appendText$2(this.text, appendText$2(text.text, sliceText$2(this.text, 0, from)), to);
+           let newLen = this.length + text.length - (to - from);
+           if (lines.length <= 32 /* Branch */)
+               return new TextLeaf(lines, newLen);
+           return TextNode$2.from(TextLeaf.split(lines, []), newLen);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           let result = "";
+           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
+               let line = this.text[i], end = pos + line.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += line.slice(Math.max(0, from - pos), to - pos);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let line of this.text)
+               target.push(line);
+       }
+       scanIdentical() { return 0; }
+       static split(text, target) {
+           let part = [], len = -1;
+           for (let line of text) {
+               part.push(line);
+               len += line.length + 1;
+               if (part.length == 32 /* Branch */) {
+                   target.push(new TextLeaf(part, len));
+                   part = [];
+                   len = -1;
+               }
+           }
+           if (len > -1)
+               target.push(new TextLeaf(part, len));
+           return target;
+       }
+   };
+   // Nodes provide the tree structure of the `Text` type. They store a
+   // number of other nodes or leaves, taking care to balance themselves
+   // on changes. There are implied line breaks _between_ the children of
+   // a node (but not before the first or after the last child).
+   let TextNode$2 = class TextNode extends Text$2 {
+       constructor(children, length) {
+           super();
+           this.children = children;
+           this.length = length;
+           this.lines = 0;
+           for (let child of children)
+               this.lines += child.lines;
+       }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
+               if ((isLine ? endLine : end) >= target)
+                   return child.lineInner(target, isLine, line, offset);
+               offset = end + 1;
+               line = endLine + 1;
+           }
+       }
+       decompose(from, to, target, open) {
+           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (from <= end && to >= pos) {
+                   let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
+                   if (pos >= from && end <= to && !childOpen)
+                       target.push(child);
+                   else
+                       child.decompose(from - pos, to - pos, target, childOpen);
+               }
+               pos = end + 1;
+           }
+       }
+       replace(from, to, text) {
+           if (text.lines < this.lines)
+               for (let i = 0, pos = 0; i < this.children.length; i++) {
+                   let child = this.children[i], end = pos + child.length;
+                   // Fast path: if the change only affects one child and the
+                   // child's size remains in the acceptable range, only update
+                   // that child
+                   if (from >= pos && to <= end) {
+                       let updated = child.replace(from - pos, to - pos, text);
+                       let totalLines = this.lines - child.lines + updated.lines;
+                       if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
+                           updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
+                           let copy = this.children.slice();
+                           copy[i] = updated;
+                           return new TextNode(copy, this.length - (to - from) + text.length);
+                       }
+                       return super.replace(pos, end, updated);
+                   }
+                   pos = end + 1;
+               }
+           return super.replace(from, to, text);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           let result = "";
+           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += child.sliceString(from - pos, to - pos, lineSep);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let child of this.children)
+               child.flatten(target);
+       }
+       scanIdentical(other, dir) {
+           if (!(other instanceof TextNode))
+               return 0;
+           let length = 0;
+           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
+               : [this.children.length - 1, other.children.length - 1, -1, -1];
+           for (;; iA += dir, iB += dir) {
+               if (iA == eA || iB == eB)
+                   return length;
+               let chA = this.children[iA], chB = other.children[iB];
+               if (chA != chB)
+                   return length + chA.scanIdentical(chB, dir);
+               length += chA.length + 1;
+           }
+       }
+       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
+           let lines = 0;
+           for (let ch of children)
+               lines += ch.lines;
+           if (lines < 32 /* Branch */) {
+               let flat = [];
+               for (let ch of children)
+                   ch.flatten(flat);
+               return new TextLeaf$2(flat, length);
+           }
+           let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
+           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
+           function add(child) {
+               let last;
+               if (child.lines > maxChunk && child instanceof TextNode) {
+                   for (let node of child.children)
+                       add(node);
+               }
+               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
+                   flush();
+                   chunked.push(child);
+               }
+               else if (child instanceof TextLeaf$2 && currentLines &&
+                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf$2 &&
+                   child.lines + last.lines <= 32 /* Branch */) {
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk[currentChunk.length - 1] = new TextLeaf$2(last.text.concat(child.text), last.length + 1 + child.length);
+               }
+               else {
+                   if (currentLines + child.lines > chunk)
+                       flush();
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk.push(child);
+               }
+           }
+           function flush() {
+               if (currentLines == 0)
+                   return;
+               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
+               currentLen = -1;
+               currentLines = currentChunk.length = 0;
+           }
+           for (let child of children)
+               add(child);
+           flush();
+           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
+       }
+   };
+   Text$2.empty = /*@__PURE__*/new TextLeaf$2([""], 0);
+   function textLength$2(text) {
+       let length = -1;
+       for (let line of text)
+           length += line.length + 1;
+       return length;
+   }
+   function appendText$2(text, target, from = 0, to = 1e9) {
+       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
+           let line = text[i], end = pos + line.length;
+           if (end >= from) {
+               if (end > to)
+                   line = line.slice(0, to - pos);
+               if (pos < from)
+                   line = line.slice(from - pos);
+               if (first) {
+                   target[target.length - 1] += line;
+                   first = false;
+               }
+               else
+                   target.push(line);
+           }
+           pos = end + 1;
+       }
+       return target;
+   }
+   function sliceText$2(text, from, to) {
+       return appendText$2(text, [""], from, to);
+   }
+   let RawTextCursor$2 = class RawTextCursor {
+       constructor(text, dir = 1) {
+           this.dir = dir;
+           this.done = false;
+           this.lineBreak = false;
+           this.value = "";
+           this.nodes = [text];
+           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf$2 ? text.text.length : text.children.length) << 1];
+       }
+       nextInner(skip, dir) {
+           this.done = this.lineBreak = false;
+           for (;;) {
+               let last = this.nodes.length - 1;
+               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
+               let size = top instanceof TextLeaf$2 ? top.text.length : top.children.length;
+               if (offset == (dir > 0 ? size : 0)) {
+                   if (last == 0) {
+                       this.done = true;
+                       this.value = "";
+                       return this;
+                   }
+                   if (dir > 0)
+                       this.offsets[last - 1]++;
+                   this.nodes.pop();
+                   this.offsets.pop();
+               }
+               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
+                   this.offsets[last] += dir;
+                   if (skip == 0) {
+                       this.lineBreak = true;
+                       this.value = "\n";
+                       return this;
+                   }
+                   skip--;
+               }
+               else if (top instanceof TextLeaf$2) {
+                   // Move to the next string
+                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
+                   this.offsets[last] += dir;
+                   if (next.length > Math.max(0, skip)) {
+                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
+                       return this;
+                   }
+                   skip -= next.length;
+               }
+               else {
+                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
+                   if (skip > next.length) {
+                       skip -= next.length;
+                       this.offsets[last] += dir;
+                   }
+                   else {
+                       if (dir < 0)
+                           this.offsets[last]--;
+                       this.nodes.push(next);
+                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf$2 ? next.text.length : next.children.length) << 1);
+                   }
+               }
+           }
+       }
+       next(skip = 0) {
+           if (skip < 0) {
+               this.nextInner(-skip, (-this.dir));
+               skip = this.value.length;
+           }
+           return this.nextInner(skip, this.dir);
+       }
+   };
+   let PartialTextCursor$2 = class PartialTextCursor {
+       constructor(text, start, end) {
+           this.value = "";
+           this.done = false;
+           this.cursor = new RawTextCursor$2(text, start > end ? -1 : 1);
+           this.pos = start > end ? text.length : 0;
+           this.from = Math.min(start, end);
+           this.to = Math.max(start, end);
+       }
+       nextInner(skip, dir) {
+           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
+               this.value = "";
+               this.done = true;
+               return this;
+           }
+           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
+           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
+           if (skip > limit)
+               skip = limit;
+           limit -= skip;
+           let { value } = this.cursor.next(skip);
+           this.pos += (value.length + skip) * dir;
+           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
+           this.done = !this.value;
+           return this;
+       }
+       next(skip = 0) {
+           if (skip < 0)
+               skip = Math.max(skip, this.from - this.pos);
+           else if (skip > 0)
+               skip = Math.min(skip, this.to - this.pos);
+           return this.nextInner(skip, this.cursor.dir);
+       }
+       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
+   };
+   let LineCursor$2 = class LineCursor {
+       constructor(inner) {
+           this.inner = inner;
+           this.afterBreak = true;
+           this.value = "";
+           this.done = false;
+       }
+       next(skip = 0) {
+           let { done, lineBreak, value } = this.inner.next(skip);
+           if (done) {
+               this.done = true;
+               this.value = "";
+           }
+           else if (lineBreak) {
+               if (this.afterBreak) {
+                   this.value = "";
+               }
+               else {
+                   this.afterBreak = true;
+                   this.next();
+               }
+           }
+           else {
+               this.value = value;
+               this.afterBreak = false;
+           }
+           return this;
+       }
+       get lineBreak() { return false; }
+   };
+   if (typeof Symbol != "undefined") {
+       Text$2.prototype[Symbol.iterator] = function () { return this.iter(); };
+       RawTextCursor$2.prototype[Symbol.iterator] = PartialTextCursor$2.prototype[Symbol.iterator] =
+           LineCursor$2.prototype[Symbol.iterator] = function () { return this; };
+   }
+   /**
+   This type describes a line in the document. It is created
+   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
+   */
+   let Line$2 = class Line {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The position of the start of the line.
+       */
+       from, 
+       /**
+       The position at the end of the line (_before_ the line break,
+       or at the end of document for the last line).
+       */
+       to, 
+       /**
+       This line's line number (1-based).
+       */
+       number, 
+       /**
+       The line's content.
+       */
+       text) {
+           this.from = from;
+           this.to = to;
+           this.number = number;
+           this.text = text;
+       }
+       /**
+       The length of the line (not including any line break after it).
+       */
+       get length() { return this.to - this.from; }
+   };
+
+   // Compressed representation of the Grapheme_Cluster_Break=Extend
+   // information from
+   // http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
+   // Each pair of elements represents a range, as an offet from the
+   // previous range and a length. Numbers are in base-36, with the empty
+   // string being a shorthand for 1.
+   let extend$1 = /*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
+   // Convert offsets into absolute values
+   for (let i = 1; i < extend$1.length; i++)
+       extend$1[i] += extend$1[i - 1];
+   function isExtendingChar$2(code) {
+       for (let i = 1; i < extend$1.length; i += 2)
+           if (extend$1[i] > code)
+               return extend$1[i - 1] <= code;
+       return false;
+   }
+   function isRegionalIndicator$2(code) {
+       return code >= 0x1F1E6 && code <= 0x1F1FF;
+   }
+   const ZWJ$2 = 0x200d;
+   /**
+   Returns a next grapheme cluster break _after_ (not equal to)
+   `pos`, if `forward` is true, or before otherwise. Returns `pos`
+   itself if no further cluster break is available in the string.
+   Moves across surrogate pairs, extending characters (when
+   `includeExtending` is true), characters joined with zero-width
+   joiners, and flag emoji.
+   */
+   function findClusterBreak$3(str, pos, forward = true, includeExtending = true) {
+       return (forward ? nextClusterBreak$2 : prevClusterBreak$2)(str, pos, includeExtending);
+   }
+   function nextClusterBreak$2(str, pos, includeExtending) {
+       if (pos == str.length)
+           return pos;
+       // If pos is in the middle of a surrogate pair, move to its start
+       if (pos && surrogateLow$3(str.charCodeAt(pos)) && surrogateHigh$3(str.charCodeAt(pos - 1)))
+           pos--;
+       let prev = codePointAt$3(str, pos);
+       pos += codePointSize$3(prev);
+       while (pos < str.length) {
+           let next = codePointAt$3(str, pos);
+           if (prev == ZWJ$2 || next == ZWJ$2 || includeExtending && isExtendingChar$2(next)) {
+               pos += codePointSize$3(next);
+               prev = next;
+           }
+           else if (isRegionalIndicator$2(next)) {
+               let countBefore = 0, i = pos - 2;
+               while (i >= 0 && isRegionalIndicator$2(codePointAt$3(str, i))) {
+                   countBefore++;
+                   i -= 2;
+               }
+               if (countBefore % 2 == 0)
+                   break;
+               else
+                   pos += 2;
+           }
+           else {
+               break;
+           }
+       }
+       return pos;
+   }
+   function prevClusterBreak$2(str, pos, includeExtending) {
+       while (pos > 0) {
+           let found = nextClusterBreak$2(str, pos - 2, includeExtending);
+           if (found < pos)
+               return found;
+           pos--;
+       }
+       return 0;
+   }
+   function surrogateLow$3(ch) { return ch >= 0xDC00 && ch < 0xE000; }
+   function surrogateHigh$3(ch) { return ch >= 0xD800 && ch < 0xDC00; }
+   /**
+   Find the code point at the given position in a string (like the
+   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
+   string method).
+   */
+   function codePointAt$3(str, pos) {
+       let code0 = str.charCodeAt(pos);
+       if (!surrogateHigh$3(code0) || pos + 1 == str.length)
+           return code0;
+       let code1 = str.charCodeAt(pos + 1);
+       if (!surrogateLow$3(code1))
+           return code0;
+       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
+   }
+   /**
+   The first character that takes up two positions in a JavaScript
+   string. It is often useful to compare with this after calling
+   `codePointAt`, to figure out whether your character takes up 1 or
+   2 index positions.
+   */
+   function codePointSize$3(code) { return code < 0x10000 ? 1 : 2; }
+
+   const DefaultSplit$2 = /\r\n?|\n/;
+   /**
+   Distinguishes different ways in which positions can be mapped.
+   */
+   var MapMode$2 = /*@__PURE__*/(function (MapMode) {
+       /**
+       Map a position to a valid new position, even when its context
+       was deleted.
+       */
+       MapMode[MapMode["Simple"] = 0] = "Simple";
+       /**
+       Return null if deletion happens across the position.
+       */
+       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
+       /**
+       Return null if the character _before_ the position is deleted.
+       */
+       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
+       /**
+       Return null if the character _after_ the position is deleted.
+       */
+       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
+   return MapMode})(MapMode$2 || (MapMode$2 = {}));
+   /**
+   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
+   that doesn't store the inserted text. As such, it can't be
+   applied, but is cheaper to store and manipulate.
+   */
+   let ChangeDesc$2 = class ChangeDesc {
+       // Sections are encoded as pairs of integers. The first is the
+       // length in the current document, and the second is -1 for
+       // unaffected sections, and the length of the replacement content
+       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
+       // 0), and a replacement two positive numbers.
+       constructor(
+       /**
+       @internal
+       */
+       sections) {
+           this.sections = sections;
+       }
+       /**
+       The length of the document before the change.
+       */
+       get length() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2)
+               result += this.sections[i];
+           return result;
+       }
+       /**
+       The length of the document after the change.
+       */
+       get newLength() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let ins = this.sections[i + 1];
+               result += ins < 0 ? this.sections[i] : ins;
+           }
+           return result;
+       }
+       /**
+       False when there are actual changes in this set.
+       */
+       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
+       /**
+       Iterate over the unchanged parts left by these changes. `posA`
+       provides the position of the range in the old document, `posB`
+       the new position in the changed document.
+       */
+       iterGaps(f) {
+           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0) {
+                   f(posA, posB, len);
+                   posB += len;
+               }
+               else {
+                   posB += ins;
+               }
+               posA += len;
+           }
+       }
+       /**
+       Iterate over the ranges changed by these changes. (See
+       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
+       variant that also provides you with the inserted text.)
+       `fromA`/`toA` provides the extent of the change in the starting
+       document, `fromB`/`toB` the extent of the replacement in the
+       changed document.
+       
+       When `individual` is true, adjacent changes (which are kept
+       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
+       reported separately.
+       */
+       iterChangedRanges(f, individual = false) {
+           iterChanges$2(this, f, individual);
+       }
+       /**
+       Get a description of the inverted form of these changes.
+       */
+       get invertedDesc() {
+           let sections = [];
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0)
+                   sections.push(len, ins);
+               else
+                   sections.push(ins, len);
+           }
+           return new ChangeDesc(sections);
+       }
+       /**
+       Compute the combined effect of applying another set of changes
+       after this one. The length of the document after this set should
+       match the length before `other`.
+       */
+       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets$2(this, other); }
+       /**
+       Map this description, which should start with the same document
+       as `other`, over another set of changes, so that it can be
+       applied after it. When `before` is true, map as if the changes
+       in `other` happened before the ones in `this`.
+       */
+       mapDesc(other, before = false) { return other.empty ? this : mapSet$2(this, other, before); }
+       mapPos(pos, assoc = -1, mode = MapMode$2.Simple) {
+           let posA = 0, posB = 0;
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
+               if (ins < 0) {
+                   if (endA > pos)
+                       return posB + (pos - posA);
+                   posB += len;
+               }
+               else {
+                   if (mode != MapMode$2.Simple && endA >= pos &&
+                       (mode == MapMode$2.TrackDel && posA < pos && endA > pos ||
+                           mode == MapMode$2.TrackBefore && posA < pos ||
+                           mode == MapMode$2.TrackAfter && endA > pos))
+                       return null;
+                   if (endA > pos || endA == pos && assoc < 0 && !len)
+                       return pos == posA || assoc < 0 ? posB : posB + ins;
+                   posB += ins;
+               }
+               posA = endA;
+           }
+           if (pos > posA)
+               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
+           return posB;
+       }
+       /**
+       Check whether these changes touch a given range. When one of the
+       changes entirely covers the range, the string `"cover"` is
+       returned.
+       */
+       touchesRange(from, to = from) {
+           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
+               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
+               if (ins >= 0 && pos <= to && end >= from)
+                   return pos < from && end > to ? "cover" : true;
+               pos = end;
+           }
+           return false;
+       }
+       /**
+       @internal
+       */
+       toString() {
+           let result = "";
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
+           }
+           return result;
+       }
+       /**
+       Serialize this change desc to a JSON-representable value.
+       */
+       toJSON() { return this.sections; }
+       /**
+       Create a change desc from its JSON representation (as produced
+       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
+               throw new RangeError("Invalid JSON representation of ChangeDesc");
+           return new ChangeDesc(json);
+       }
+       /**
+       @internal
+       */
+       static create(sections) { return new ChangeDesc(sections); }
+   };
+   /**
+   A change set represents a group of modifications to a document. It
+   stores the document length, and can only be applied to documents
+   with exactly that length.
+   */
+   let ChangeSet$2 = class ChangeSet extends ChangeDesc$2 {
+       constructor(sections, 
+       /**
+       @internal
+       */
+       inserted) {
+           super(sections);
+           this.inserted = inserted;
+       }
+       /**
+       Apply the changes to a document, returning the modified
+       document.
+       */
+       apply(doc) {
+           if (this.length != doc.length)
+               throw new RangeError("Applying change set to a document with the wrong length");
+           iterChanges$2(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
+           return doc;
+       }
+       mapDesc(other, before = false) { return mapSet$2(this, other, before, true); }
+       /**
+       Given the document as it existed _before_ the changes, return a
+       change set that represents the inverse of this set, which could
+       be used to go from the document created by the changes back to
+       the document as it existed before the changes.
+       */
+       invert(doc) {
+           let sections = this.sections.slice(), inserted = [];
+           for (let i = 0, pos = 0; i < sections.length; i += 2) {
+               let len = sections[i], ins = sections[i + 1];
+               if (ins >= 0) {
+                   sections[i] = ins;
+                   sections[i + 1] = len;
+                   let index = i >> 1;
+                   while (inserted.length < index)
+                       inserted.push(Text$2.empty);
+                   inserted.push(len ? doc.slice(pos, pos + len) : Text$2.empty);
+               }
+               pos += len;
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       Combine two subsequent change sets into a single set. `other`
+       must start in the document produced by `this`. If `this` goes
+       `docA` → `docB` and `other` represents `docB` → `docC`, the
+       returned value will represent the change `docA` → `docC`.
+       */
+       compose(other) { return this.empty ? other : other.empty ? this : composeSets$2(this, other, true); }
+       /**
+       Given another change set starting in the same document, maps this
+       change set over the other, producing a new change set that can be
+       applied to the document produced by applying `other`. When
+       `before` is `true`, order changes as if `this` comes before
+       `other`, otherwise (the default) treat `other` as coming first.
+       
+       Given two changes `A` and `B`, `A.compose(B.map(A))` and
+       `B.compose(A.map(B, true))` will produce the same document. This
+       provides a basic form of [operational
+       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
+       and can be used for collaborative editing.
+       */
+       map(other, before = false) { return other.empty ? this : mapSet$2(this, other, before, true); }
+       /**
+       Iterate over the changed ranges in the document, calling `f` for
+       each, with the range in the original document (`fromA`-`toA`)
+       and the range that replaces it in the new document
+       (`fromB`-`toB`).
+       
+       When `individual` is true, adjacent changes are reported
+       separately.
+       */
+       iterChanges(f, individual = false) {
+           iterChanges$2(this, f, individual);
+       }
+       /**
+       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
+       set.
+       */
+       get desc() { return ChangeDesc$2.create(this.sections); }
+       /**
+       @internal
+       */
+       filter(ranges) {
+           let resultSections = [], resultInserted = [], filteredSections = [];
+           let iter = new SectionIter$2(this);
+           done: for (let i = 0, pos = 0;;) {
+               let next = i == ranges.length ? 1e9 : ranges[i++];
+               while (pos < next || pos == next && iter.len == 0) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, next - pos);
+                   addSection$2(filteredSections, len, -1);
+                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
+                   addSection$2(resultSections, len, ins);
+                   if (ins > 0)
+                       addInsert$2(resultInserted, resultSections, iter.text);
+                   iter.forward(len);
+                   pos += len;
+               }
+               let end = ranges[i++];
+               while (pos < end) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, end - pos);
+                   addSection$2(resultSections, len, -1);
+                   addSection$2(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
+                   iter.forward(len);
+                   pos += len;
+               }
+           }
+           return { changes: new ChangeSet(resultSections, resultInserted),
+               filtered: ChangeDesc$2.create(filteredSections) };
+       }
+       /**
+       Serialize this change set to a JSON-representable value.
+       */
+       toJSON() {
+           let parts = [];
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let len = this.sections[i], ins = this.sections[i + 1];
+               if (ins < 0)
+                   parts.push(len);
+               else if (ins == 0)
+                   parts.push([len]);
+               else
+                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
+           }
+           return parts;
+       }
+       /**
+       Create a change set for the given changes, for a document of the
+       given length, using `lineSep` as line separator.
+       */
+       static of(changes, length, lineSep) {
+           let sections = [], inserted = [], pos = 0;
+           let total = null;
+           function flush(force = false) {
+               if (!force && !sections.length)
+                   return;
+               if (pos < length)
+                   addSection$2(sections, length - pos, -1);
+               let set = new ChangeSet(sections, inserted);
+               total = total ? total.compose(set.map(total)) : set;
+               sections = [];
+               inserted = [];
+               pos = 0;
+           }
+           function process(spec) {
+               if (Array.isArray(spec)) {
+                   for (let sub of spec)
+                       process(sub);
+               }
+               else if (spec instanceof ChangeSet) {
+                   if (spec.length != length)
+                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
+                   flush();
+                   total = total ? total.compose(spec.map(total)) : spec;
+               }
+               else {
+                   let { from, to = from, insert } = spec;
+                   if (from > to || from < 0 || to > length)
+                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
+                   let insText = !insert ? Text$2.empty : typeof insert == "string" ? Text$2.of(insert.split(lineSep || DefaultSplit$2)) : insert;
+                   let insLen = insText.length;
+                   if (from == to && insLen == 0)
+                       return;
+                   if (from < pos)
+                       flush();
+                   if (from > pos)
+                       addSection$2(sections, from - pos, -1);
+                   addSection$2(sections, to - from, insLen);
+                   addInsert$2(inserted, sections, insText);
+                   pos = to;
+               }
+           }
+           process(changes);
+           flush(!total);
+           return total;
+       }
+       /**
+       Create an empty changeset of the given length.
+       */
+       static empty(length) {
+           return new ChangeSet(length ? [length, -1] : [], []);
+       }
+       /**
+       Create a changeset from its JSON representation (as produced by
+       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json))
+               throw new RangeError("Invalid JSON representation of ChangeSet");
+           let sections = [], inserted = [];
+           for (let i = 0; i < json.length; i++) {
+               let part = json[i];
+               if (typeof part == "number") {
+                   sections.push(part, -1);
+               }
+               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
+                   throw new RangeError("Invalid JSON representation of ChangeSet");
+               }
+               else if (part.length == 1) {
+                   sections.push(part[0], 0);
+               }
+               else {
+                   while (inserted.length < i)
+                       inserted.push(Text$2.empty);
+                   inserted[i] = Text$2.of(part.slice(1));
+                   sections.push(part[0], inserted[i].length);
+               }
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       @internal
+       */
+       static createSet(sections, inserted) {
+           return new ChangeSet(sections, inserted);
+       }
+   };
+   function addSection$2(sections, len, ins, forceJoin = false) {
+       if (len == 0 && ins <= 0)
+           return;
+       let last = sections.length - 2;
+       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
+           sections[last] += len;
+       else if (len == 0 && sections[last] == 0)
+           sections[last + 1] += ins;
+       else if (forceJoin) {
+           sections[last] += len;
+           sections[last + 1] += ins;
+       }
+       else
+           sections.push(len, ins);
+   }
+   function addInsert$2(values, sections, value) {
+       if (value.length == 0)
+           return;
+       let index = (sections.length - 2) >> 1;
+       if (index < values.length) {
+           values[values.length - 1] = values[values.length - 1].append(value);
+       }
+       else {
+           while (values.length < index)
+               values.push(Text$2.empty);
+           values.push(value);
+       }
+   }
+   function iterChanges$2(desc, f, individual) {
+       let inserted = desc.inserted;
+       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
+           let len = desc.sections[i++], ins = desc.sections[i++];
+           if (ins < 0) {
+               posA += len;
+               posB += len;
+           }
+           else {
+               let endA = posA, endB = posB, text = Text$2.empty;
+               for (;;) {
+                   endA += len;
+                   endB += ins;
+                   if (ins && inserted)
+                       text = text.append(inserted[(i - 2) >> 1]);
+                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
+                       break;
+                   len = desc.sections[i++];
+                   ins = desc.sections[i++];
+               }
+               f(posA, endA, posB, endB, text);
+               posA = endA;
+               posB = endB;
+           }
+       }
+   }
+   function mapSet$2(setA, setB, before, mkSet = false) {
+       let sections = [], insert = mkSet ? [] : null;
+       let a = new SectionIter$2(setA), b = new SectionIter$2(setB);
+       for (let posA = 0, posB = 0;;) {
+           if (a.ins == -1) {
+               posA += a.len;
+               a.next();
+           }
+           else if (b.ins == -1 && posB < posA) {
+               let skip = Math.min(b.len, posA - posB);
+               b.forward(skip);
+               addSection$2(sections, skip, -1);
+               posB += skip;
+           }
+           else if (b.ins >= 0 && (a.done || posB < posA || posB == posA && (b.len < a.len || b.len == a.len && !before))) {
+               addSection$2(sections, b.ins, -1);
+               while (posA > posB && !a.done && posA + a.len < posB + b.len) {
+                   posA += a.len;
+                   a.next();
+               }
+               posB += b.len;
+               b.next();
+           }
+           else if (a.ins >= 0) {
+               let len = 0, end = posA + a.len;
+               for (;;) {
+                   if (b.ins >= 0 && posB > posA && posB + b.len < end) {
+                       len += b.ins;
+                       posB += b.len;
+                       b.next();
+                   }
+                   else if (b.ins == -1 && posB < end) {
+                       let skip = Math.min(b.len, end - posB);
+                       len += skip;
+                       b.forward(skip);
+                       posB += skip;
+                   }
+                   else {
+                       break;
+                   }
+               }
+               addSection$2(sections, len, a.ins);
+               if (insert)
+                   addInsert$2(insert, sections, a.text);
+               posA = end;
+               a.next();
+           }
+           else if (a.done && b.done) {
+               return insert ? ChangeSet$2.createSet(sections, insert) : ChangeDesc$2.create(sections);
+           }
+           else {
+               throw new Error("Mismatched change set lengths");
+           }
+       }
+   }
+   function composeSets$2(setA, setB, mkSet = false) {
+       let sections = [];
+       let insert = mkSet ? [] : null;
+       let a = new SectionIter$2(setA), b = new SectionIter$2(setB);
+       for (let open = false;;) {
+           if (a.done && b.done) {
+               return insert ? ChangeSet$2.createSet(sections, insert) : ChangeDesc$2.create(sections);
+           }
+           else if (a.ins == 0) { // Deletion in A
+               addSection$2(sections, a.len, 0, open);
+               a.next();
+           }
+           else if (b.len == 0 && !b.done) { // Insertion in B
+               addSection$2(sections, 0, b.ins, open);
+               if (insert)
+                   addInsert$2(insert, sections, b.text);
+               b.next();
+           }
+           else if (a.done || b.done) {
+               throw new Error("Mismatched change set lengths");
+           }
+           else {
+               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
+               if (a.ins == -1) {
+                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
+                   addSection$2(sections, len, insB, open);
+                   if (insert && insB)
+                       addInsert$2(insert, sections, b.text);
+               }
+               else if (b.ins == -1) {
+                   addSection$2(sections, a.off ? 0 : a.len, len, open);
+                   if (insert)
+                       addInsert$2(insert, sections, a.textBit(len));
+               }
+               else {
+                   addSection$2(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
+                   if (insert && !b.off)
+                       addInsert$2(insert, sections, b.text);
+               }
+               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
+               a.forward2(len);
+               b.forward(len);
+           }
+       }
+   }
+   let SectionIter$2 = class SectionIter {
+       constructor(set) {
+           this.set = set;
+           this.i = 0;
+           this.next();
+       }
+       next() {
+           let { sections } = this.set;
+           if (this.i < sections.length) {
+               this.len = sections[this.i++];
+               this.ins = sections[this.i++];
+           }
+           else {
+               this.len = 0;
+               this.ins = -2;
+           }
+           this.off = 0;
+       }
+       get done() { return this.ins == -2; }
+       get len2() { return this.ins < 0 ? this.len : this.ins; }
+       get text() {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length ? Text$2.empty : inserted[index];
+       }
+       textBit(len) {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length && !len ? Text$2.empty
+               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
+       }
+       forward(len) {
+           if (len == this.len)
+               this.next();
+           else {
+               this.len -= len;
+               this.off += len;
+           }
+       }
+       forward2(len) {
+           if (this.ins == -1)
+               this.forward(len);
+           else if (len == this.ins)
+               this.next();
+           else {
+               this.ins -= len;
+               this.off += len;
+           }
+       }
+   };
+
+   /**
+   A single selection range. When
+   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
+   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
+   multiple ranges. By default, selections hold exactly one range.
+   */
+   let SelectionRange$2 = class SelectionRange {
+       constructor(
+       /**
+       The lower boundary of the range.
+       */
+       from, 
+       /**
+       The upper boundary of the range.
+       */
+       to, flags) {
+           this.from = from;
+           this.to = to;
+           this.flags = flags;
+       }
+       /**
+       The anchor of the range—the side that doesn't move when you
+       extend it.
+       */
+       get anchor() { return this.flags & 16 /* Inverted */ ? 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 & 16 /* Inverted */ ? 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 & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
+       /**
+       The bidirectional text level associated with this cursor, if
+       any.
+       */
+       get bidiLevel() {
+           let level = this.flags & 3 /* BidiLevelMask */;
+           return level == 3 ? null : level;
+       }
+       /**
+       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 value = this.flags >> 5 /* GoalColumnOffset */;
+           return value == 33554431 /* NoGoalColumn */ ? undefined : value;
+       }
+       /**
+       Map this range through a change, producing a valid range in the
+       updated document.
+       */
+       map(change, assoc = -1) {
+           let from, to;
+           if (this.empty) {
+               from = to = change.mapPos(this.from, assoc);
+           }
+           else {
+               from = change.mapPos(this.from, 1);
+               to = change.mapPos(this.to, -1);
+           }
+           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
+       }
+       /**
+       Extend this range to cover at least `from` to `to`.
+       */
+       extend(from, to = from) {
+           if (from <= this.anchor && to >= this.anchor)
+               return EditorSelection$2.range(from, to);
+           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
+           return EditorSelection$2.range(this.anchor, head);
+       }
+       /**
+       Compare this range to another range.
+       */
+       eq(other) {
+           return this.anchor == other.anchor && this.head == other.head;
+       }
+       /**
+       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(json) {
+           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
+               throw new RangeError("Invalid JSON representation for SelectionRange");
+           return EditorSelection$2.range(json.anchor, json.head);
+       }
+       /**
+       @internal
+       */
+       static create(from, to, flags) {
+           return new SelectionRange(from, to, flags);
+       }
+   };
+   /**
+   An editor selection holds one or more selection ranges.
+   */
+   let EditorSelection$2 = class EditorSelection {
+       constructor(
+       /**
+       The ranges in the selection, sorted by position. Ranges cannot
+       overlap (but they may touch, if they aren't empty).
+       */
+       ranges, 
+       /**
+       The index of the _main_ range in the selection (which is
+       usually the range that was added last).
+       */
+       mainIndex) {
+           this.ranges = ranges;
+           this.mainIndex = mainIndex;
+       }
+       /**
+       Map a selection through a change. Used to adjust the selection
+       position for changes.
+       */
+       map(change, assoc = -1) {
+           if (change.empty)
+               return this;
+           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
+       }
+       /**
+       Compare this selection to another selection.
+       */
+       eq(other) {
+           if (this.ranges.length != other.ranges.length ||
+               this.mainIndex != other.mainIndex)
+               return false;
+           for (let i = 0; i < this.ranges.length; i++)
+               if (!this.ranges[i].eq(other.ranges[i]))
+                   return false;
+           return true;
+       }
+       /**
+       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 EditorSelection([this.main], 0);
+       }
+       /**
+       Extend this selection with an extra range.
+       */
+       addRange(range, main = true) {
+           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
+       }
+       /**
+       Replace a given range with another range, and then normalize the
+       selection to merge and sort ranges if necessary.
+       */
+       replaceRange(range, which = this.mainIndex) {
+           let ranges = this.ranges.slice();
+           ranges[which] = range;
+           return EditorSelection.create(ranges, this.mainIndex);
+       }
+       /**
+       Convert this selection to an object that can be serialized to
+       JSON.
+       */
+       toJSON() {
+           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
+       }
+       /**
+       Create a selection from a JSON representation.
+       */
+       static fromJSON(json) {
+           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
+               throw new RangeError("Invalid JSON representation for EditorSelection");
+           return new EditorSelection(json.ranges.map((r) => SelectionRange$2.fromJSON(r)), json.main);
+       }
+       /**
+       Create a selection holding a single range.
+       */
+       static single(anchor, head = anchor) {
+           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
+       }
+       /**
+       Sort and merge the given set of ranges, creating a valid
+       selection.
+       */
+       static create(ranges, mainIndex = 0) {
+           if (ranges.length == 0)
+               throw new RangeError("A selection needs at least one range");
+           for (let pos = 0, i = 0; i < ranges.length; i++) {
+               let range = ranges[i];
+               if (range.empty ? range.from <= pos : range.from < pos)
+                   return EditorSelection.normalized(ranges.slice(), mainIndex);
+               pos = range.to;
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+       /**
+       Create a cursor selection range at the given position. You can
+       safely ignore the optional arguments in most situations.
+       */
+       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
+           return SelectionRange$2.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
+               (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
+               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
+       }
+       /**
+       Create a selection range.
+       */
+       static range(anchor, head, goalColumn) {
+           let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
+           return head < anchor ? SelectionRange$2.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
+               : SelectionRange$2.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
+       }
+       /**
+       @internal
+       */
+       static normalized(ranges, mainIndex = 0) {
+           let main = ranges[mainIndex];
+           ranges.sort((a, b) => a.from - b.from);
+           mainIndex = ranges.indexOf(main);
+           for (let i = 1; i < ranges.length; i++) {
+               let range = ranges[i], prev = ranges[i - 1];
+               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
+                   let from = prev.from, to = Math.max(range.to, prev.to);
+                   if (i <= mainIndex)
+                       mainIndex--;
+                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
+               }
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+   };
+   function checkSelection$2(selection, docLength) {
+       for (let range of selection.ranges)
+           if (range.to > docLength)
+               throw new RangeError("Selection points outside of document");
+   }
+
+   let nextID$2 = 0;
+   /**
+   A facet is a labeled value that is associated with an editor
+   state. It takes inputs from any number of extensions, and combines
+   those into a single output value.
+
+   Examples of uses of facets are the [tab
+   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
+   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
+   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
+   */
+   let Facet$2 = class Facet {
+       constructor(
+       /**
+       @internal
+       */
+       combine, 
+       /**
+       @internal
+       */
+       compareInput, 
+       /**
+       @internal
+       */
+       compare, isStatic, 
+       /**
+       @internal
+       */
+       extensions) {
+           this.combine = combine;
+           this.compareInput = compareInput;
+           this.compare = compare;
+           this.isStatic = isStatic;
+           this.extensions = extensions;
+           /**
+           @internal
+           */
+           this.id = nextID$2++;
+           this.default = combine([]);
+       }
+       /**
+       Define a new facet.
+       */
+       static define(config = {}) {
+           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$4 : (a, b) => a === b), !!config.static, config.enables);
+       }
+       /**
+       Returns an extension that adds the given value to this facet.
+       */
+       of(value) {
+           return new FacetProvider$2([], this, 0 /* Static */, value);
+       }
+       /**
+       Create an extension that computes a value for the facet from a
+       state. You must take care to declare the parts of the state that
+       this value depends on, since your function is only called again
+       for a new state when one of those parts changed.
+       
+       In cases where your value depends only on a single field, you'll
+       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
+       */
+       compute(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider$2(deps, this, 1 /* Single */, get);
+       }
+       /**
+       Create an extension that computes zero or more values for this
+       facet from a state.
+       */
+       computeN(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider$2(deps, this, 2 /* Multi */, get);
+       }
+       from(field, get) {
+           if (!get)
+               get = x => x;
+           return this.compute([field], state => get(state.field(field)));
+       }
+   };
+   function sameArray$4(a, b) {
+       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
+   }
+   let FacetProvider$2 = class FacetProvider {
+       constructor(dependencies, facet, type, value) {
+           this.dependencies = dependencies;
+           this.facet = facet;
+           this.type = type;
+           this.value = value;
+           this.id = nextID$2++;
+       }
+       dynamicSlot(addresses) {
+           var _a;
+           let getter = this.value;
+           let compare = this.facet.compareInput;
+           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
+           let depDoc = false, depSel = false, depAddrs = [];
+           for (let dep of this.dependencies) {
+               if (dep == "doc")
+                   depDoc = true;
+               else if (dep == "selection")
+                   depSel = true;
+               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
+                   depAddrs.push(addresses[dep.id]);
+           }
+           return {
+               create(state) {
+                   state.values[idx] = getter(state);
+                   return 1 /* Changed */;
+               },
+               update(state, tr) {
+                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll$2(state, depAddrs)) {
+                       let newVal = getter(state);
+                       if (multi ? !compareArray$2(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
+                           state.values[idx] = newVal;
+                           return 1 /* Changed */;
+                       }
+                   }
+                   return 0;
+               },
+               reconfigure: (state, oldState) => {
+                   let newVal = getter(state);
+                   let oldAddr = oldState.config.address[id];
+                   if (oldAddr != null) {
+                       let oldVal = getAddr$2(oldState, oldAddr);
+                       if (this.dependencies.every(dep => {
+                           return dep instanceof Facet$2 ? oldState.facet(dep) === state.facet(dep) :
+                               dep instanceof StateField$2 ? oldState.field(dep, false) == state.field(dep, false) : true;
+                       }) || (multi ? compareArray$2(newVal, oldVal, compare) : compare(newVal, oldVal))) {
+                           state.values[idx] = oldVal;
+                           return 0;
+                       }
+                   }
+                   state.values[idx] = newVal;
+                   return 1 /* Changed */;
+               }
+           };
+       }
+   };
+   function compareArray$2(a, b, compare) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (!compare(a[i], b[i]))
+               return false;
+       return true;
+   }
+   function ensureAll$2(state, addrs) {
+       let changed = false;
+       for (let addr of addrs)
+           if (ensureAddr$2(state, addr) & 1 /* Changed */)
+               changed = true;
+       return changed;
+   }
+   function dynamicFacetSlot$2(addresses, facet, providers) {
+       let providerAddrs = providers.map(p => addresses[p.id]);
+       let providerTypes = providers.map(p => p.type);
+       let dynamic = providerAddrs.filter(p => !(p & 1));
+       let idx = addresses[facet.id] >> 1;
+       function get(state) {
+           let values = [];
+           for (let i = 0; i < providerAddrs.length; i++) {
+               let value = getAddr$2(state, providerAddrs[i]);
+               if (providerTypes[i] == 2 /* Multi */)
+                   for (let val of value)
+                       values.push(val);
+               else
+                   values.push(value);
+           }
+           return facet.combine(values);
+       }
+       return {
+           create(state) {
+               for (let addr of providerAddrs)
+                   ensureAddr$2(state, addr);
+               state.values[idx] = get(state);
+               return 1 /* Changed */;
+           },
+           update(state, tr) {
+               if (!ensureAll$2(state, dynamic))
+                   return 0;
+               let value = get(state);
+               if (facet.compare(value, state.values[idx]))
+                   return 0;
+               state.values[idx] = value;
+               return 1 /* Changed */;
+           },
+           reconfigure(state, oldState) {
+               let depChanged = ensureAll$2(state, providerAddrs);
+               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
+               if (oldProviders && !depChanged && sameArray$4(providers, oldProviders)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               let value = get(state);
+               if (facet.compare(value, oldValue)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               state.values[idx] = value;
+               return 1 /* Changed */;
+           }
+       };
+   }
+   const initField$2 = /*@__PURE__*/Facet$2.define({ static: true });
+   /**
+   Fields can store additional information in an editor state, and
+   keep it in sync with the rest of the state.
+   */
+   let StateField$2 = class StateField {
+       constructor(
+       /**
+       @internal
+       */
+       id, createF, updateF, compareF, 
+       /**
+       @internal
+       */
+       spec) {
+           this.id = id;
+           this.createF = createF;
+           this.updateF = updateF;
+           this.compareF = compareF;
+           this.spec = spec;
+           /**
+           @internal
+           */
+           this.provides = undefined;
+       }
+       /**
+       Define a state field.
+       */
+       static define(config) {
+           let field = new StateField(nextID$2++, config.create, config.update, config.compare || ((a, b) => a === b), config);
+           if (config.provide)
+               field.provides = config.provide(field);
+           return field;
+       }
+       create(state) {
+           let init = state.facet(initField$2).find(i => i.field == this);
+           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
+       }
+       /**
+       @internal
+       */
+       slot(addresses) {
+           let idx = addresses[this.id] >> 1;
+           return {
+               create: (state) => {
+                   state.values[idx] = this.create(state);
+                   return 1 /* Changed */;
+               },
+               update: (state, tr) => {
+                   let oldVal = state.values[idx];
+                   let value = this.updateF(oldVal, tr);
+                   if (this.compareF(oldVal, value))
+                       return 0;
+                   state.values[idx] = value;
+                   return 1 /* Changed */;
+               },
+               reconfigure: (state, oldState) => {
+                   if (oldState.config.address[this.id] != null) {
+                       state.values[idx] = oldState.field(this);
+                       return 0;
+                   }
+                   state.values[idx] = this.create(state);
+                   return 1 /* Changed */;
+               }
+           };
+       }
+       /**
+       Returns an extension that enables this field and overrides the
+       way it is initialized. Can be useful when you need to provide a
+       non-default starting value for the field.
+       */
+       init(create) {
+           return [this, initField$2.of({ field: this, create })];
+       }
+       /**
+       State field instances can be used as
+       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
+       given state.
+       */
+       get extension() { return this; }
+   };
+   const Prec_$2 = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
+   function prec$2(value) {
+       return (ext) => new PrecExtension$2(ext, value);
+   }
+   /**
+   By default extensions are registered in the order they are found
+   in the flattened form of nested array that was provided.
+   Individual extension values can be assigned a precedence to
+   override this. Extensions that do not have a precedence set get
+   the precedence of the nearest parent with a precedence, or
+   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
+   final ordering of extensions is determined by first sorting by
+   precedence and then by order within each precedence.
+   */
+   const Prec$2 = {
+       /**
+       The highest precedence level, for extensions that should end up
+       near the start of the precedence ordering.
+       */
+       highest: /*@__PURE__*/prec$2(Prec_$2.highest),
+       /**
+       A higher-than-default precedence, for extensions that should
+       come before those with default precedence.
+       */
+       high: /*@__PURE__*/prec$2(Prec_$2.high),
+       /**
+       The default precedence, which is also used for extensions
+       without an explicit precedence.
+       */
+       default: /*@__PURE__*/prec$2(Prec_$2.default),
+       /**
+       A lower-than-default precedence.
+       */
+       low: /*@__PURE__*/prec$2(Prec_$2.low),
+       /**
+       The lowest precedence level. Meant for things that should end up
+       near the end of the extension order.
+       */
+       lowest: /*@__PURE__*/prec$2(Prec_$2.lowest)
+   };
+   let PrecExtension$2 = class PrecExtension {
+       constructor(inner, prec) {
+           this.inner = inner;
+           this.prec = prec;
+       }
+   };
+   /**
+   Extension compartments can be used to make a configuration
+   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
+   configuration in a compartment, you can later
+   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
+   transaction.
+   */
+   let Compartment$2 = class Compartment {
+       /**
+       Create an instance of this compartment to add to your [state
+       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
+       */
+       of(ext) { return new CompartmentInstance$2(this, ext); }
+       /**
+       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
+       reconfigures this compartment.
+       */
+       reconfigure(content) {
+           return Compartment.reconfigure.of({ compartment: this, extension: content });
+       }
+       /**
+       Get the current content of the compartment in the state, or
+       `undefined` if it isn't present.
+       */
+       get(state) {
+           return state.config.compartments.get(this);
+       }
+   };
+   let CompartmentInstance$2 = class CompartmentInstance {
+       constructor(compartment, inner) {
+           this.compartment = compartment;
+           this.inner = inner;
+       }
+   };
+   let Configuration$2 = class Configuration {
+       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
+           this.base = base;
+           this.compartments = compartments;
+           this.dynamicSlots = dynamicSlots;
+           this.address = address;
+           this.staticValues = staticValues;
+           this.facets = facets;
+           this.statusTemplate = [];
+           while (this.statusTemplate.length < dynamicSlots.length)
+               this.statusTemplate.push(0 /* Unresolved */);
+       }
+       staticFacet(facet) {
+           let addr = this.address[facet.id];
+           return addr == null ? facet.default : this.staticValues[addr >> 1];
+       }
+       static resolve(base, compartments, oldState) {
+           let fields = [];
+           let facets = Object.create(null);
+           let newCompartments = new Map();
+           for (let ext of flatten$2(base, compartments, newCompartments)) {
+               if (ext instanceof StateField$2)
+                   fields.push(ext);
+               else
+                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
+           }
+           let address = Object.create(null);
+           let staticValues = [];
+           let dynamicSlots = [];
+           for (let field of fields) {
+               address[field.id] = dynamicSlots.length << 1;
+               dynamicSlots.push(a => field.slot(a));
+           }
+           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
+           for (let id in facets) {
+               let providers = facets[id], facet = providers[0].facet;
+               let oldProviders = oldFacets && oldFacets[id] || [];
+               if (providers.every(p => p.type == 0 /* Static */)) {
+                   address[facet.id] = (staticValues.length << 1) | 1;
+                   if (sameArray$4(oldProviders, providers)) {
+                       staticValues.push(oldState.facet(facet));
+                   }
+                   else {
+                       let value = facet.combine(providers.map(p => p.value));
+                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
+                   }
+               }
+               else {
+                   for (let p of providers) {
+                       if (p.type == 0 /* Static */) {
+                           address[p.id] = (staticValues.length << 1) | 1;
+                           staticValues.push(p.value);
+                       }
+                       else {
+                           address[p.id] = dynamicSlots.length << 1;
+                           dynamicSlots.push(a => p.dynamicSlot(a));
+                       }
+                   }
+                   address[facet.id] = dynamicSlots.length << 1;
+                   dynamicSlots.push(a => dynamicFacetSlot$2(a, facet, providers));
+               }
+           }
+           let dynamic = dynamicSlots.map(f => f(address));
+           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
+       }
+   };
+   function flatten$2(extension, compartments, newCompartments) {
+       let result = [[], [], [], [], []];
+       let seen = new Map();
+       function inner(ext, prec) {
+           let known = seen.get(ext);
+           if (known != null) {
+               if (known <= prec)
+                   return;
+               let found = result[known].indexOf(ext);
+               if (found > -1)
+                   result[known].splice(found, 1);
+               if (ext instanceof CompartmentInstance$2)
+                   newCompartments.delete(ext.compartment);
+           }
+           seen.set(ext, prec);
+           if (Array.isArray(ext)) {
+               for (let e of ext)
+                   inner(e, prec);
+           }
+           else if (ext instanceof CompartmentInstance$2) {
+               if (newCompartments.has(ext.compartment))
+                   throw new RangeError(`Duplicate use of compartment in extensions`);
+               let content = compartments.get(ext.compartment) || ext.inner;
+               newCompartments.set(ext.compartment, content);
+               inner(content, prec);
+           }
+           else if (ext instanceof PrecExtension$2) {
+               inner(ext.inner, ext.prec);
+           }
+           else if (ext instanceof StateField$2) {
+               result[prec].push(ext);
+               if (ext.provides)
+                   inner(ext.provides, prec);
+           }
+           else if (ext instanceof FacetProvider$2) {
+               result[prec].push(ext);
+               if (ext.facet.extensions)
+                   inner(ext.facet.extensions, prec);
+           }
+           else {
+               let content = ext.extension;
+               if (!content)
+                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
+               inner(content, prec);
+           }
+       }
+       inner(extension, Prec_$2.default);
+       return result.reduce((a, b) => a.concat(b));
+   }
+   function ensureAddr$2(state, addr) {
+       if (addr & 1)
+           return 2 /* Computed */;
+       let idx = addr >> 1;
+       let status = state.status[idx];
+       if (status == 4 /* Computing */)
+           throw new Error("Cyclic dependency between fields and/or facets");
+       if (status & 2 /* Computed */)
+           return status;
+       state.status[idx] = 4 /* Computing */;
+       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
+       return state.status[idx] = 2 /* Computed */ | changed;
+   }
+   function getAddr$2(state, addr) {
+       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
+   }
+
+   const languageData$2 = /*@__PURE__*/Facet$2.define();
+   const allowMultipleSelections$2 = /*@__PURE__*/Facet$2.define({
+       combine: values => values.some(v => v),
+       static: true
+   });
+   const lineSeparator$2 = /*@__PURE__*/Facet$2.define({
+       combine: values => values.length ? values[0] : undefined,
+       static: true
+   });
+   const changeFilter$2 = /*@__PURE__*/Facet$2.define();
+   const transactionFilter$2 = /*@__PURE__*/Facet$2.define();
+   const transactionExtender$2 = /*@__PURE__*/Facet$2.define();
+   const readOnly$2 = /*@__PURE__*/Facet$2.define({
+       combine: values => values.length ? values[0] : false
+   });
+
+   /**
+   Annotations are tagged values that are used to add metadata to
+   transactions in an extensible way. They should be used to model
+   things that effect the entire transaction (such as its [time
+   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
+   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
+   _alongside_ the other changes made by the transaction, [state
+   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
+   */
+   let Annotation$2 = class Annotation {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The annotation type.
+       */
+       type, 
+       /**
+       The value of this annotation.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Define a new type of annotation.
+       */
+       static define() { return new AnnotationType$2(); }
+   };
+   /**
+   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
+   */
+   let AnnotationType$2 = class AnnotationType {
+       /**
+       Create an instance of this annotation.
+       */
+       of(value) { return new Annotation$2(this, value); }
+   };
+   /**
+   Representation of a type of state effect. Defined with
+   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
+   */
+   let StateEffectType$2 = class StateEffectType {
+       /**
+       @internal
+       */
+       constructor(
+       // The `any` types in these function types are there to work
+       // around TypeScript issue #37631, where the type guard on
+       // `StateEffect.is` mysteriously stops working when these properly
+       // have type `Value`.
+       /**
+       @internal
+       */
+       map) {
+           this.map = map;
+       }
+       /**
+       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
+       type.
+       */
+       of(value) { return new StateEffect$2(this, value); }
+   };
+   /**
+   State effects can be used to represent additional effects
+   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
+   are often useful to model changes to custom [state
+   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
+   document or selection changes.
+   */
+   let StateEffect$2 = class StateEffect {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       @internal
+       */
+       type, 
+       /**
+       The value of this effect.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Map this effect through a position mapping. Will return
+       `undefined` when that ends up deleting the effect.
+       */
+       map(mapping) {
+           let mapped = this.type.map(this.value, mapping);
+           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
+       }
+       /**
+       Tells you whether this effect object is of a given
+       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
+       */
+       is(type) { return this.type == type; }
+       /**
+       Define a new effect type. The type parameter indicates the type
+       of values that his effect holds.
+       */
+       static define(spec = {}) {
+           return new StateEffectType$2(spec.map || (v => v));
+       }
+       /**
+       Map an array of effects through a change set.
+       */
+       static mapEffects(effects, mapping) {
+           if (!effects.length)
+               return effects;
+           let result = [];
+           for (let effect of effects) {
+               let mapped = effect.map(mapping);
+               if (mapped)
+                   result.push(mapped);
+           }
+           return result;
+       }
+   };
+   /**
+   This effect can be used to reconfigure the root extensions of
+   the editor. Doing this will discard any extensions
+   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
+   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
+   compartments.
+   */
+   StateEffect$2.reconfigure = /*@__PURE__*/StateEffect$2.define();
+   /**
+   Append extensions to the top-level configuration of the editor.
+   */
+   StateEffect$2.appendConfig = /*@__PURE__*/StateEffect$2.define();
+   /**
+   Changes to the editor state are grouped into transactions.
+   Typically, a user action creates a single transaction, which may
+   contain any number of document changes, may change the selection,
+   or have other effects. Create a transaction by calling
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
+   dispatch one by calling
+   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
+   */
+   let Transaction$2 = class Transaction {
+       constructor(
+       /**
+       The state from which the transaction starts.
+       */
+       startState, 
+       /**
+       The document changes made by this transaction.
+       */
+       changes, 
+       /**
+       The selection set by this transaction, or undefined if it
+       doesn't explicitly set a selection.
+       */
+       selection, 
+       /**
+       The effects added to the transaction.
+       */
+       effects, 
+       /**
+       @internal
+       */
+       annotations, 
+       /**
+       Whether the selection should be scrolled into view after this
+       transaction is dispatched.
+       */
+       scrollIntoView) {
+           this.startState = startState;
+           this.changes = changes;
+           this.selection = selection;
+           this.effects = effects;
+           this.annotations = annotations;
+           this.scrollIntoView = scrollIntoView;
+           /**
+           @internal
+           */
+           this._doc = null;
+           /**
+           @internal
+           */
+           this._state = null;
+           if (selection)
+               checkSelection$2(selection, changes.newLength);
+           if (!annotations.some((a) => a.type == Transaction.time))
+               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
+       }
+       /**
+       @internal
+       */
+       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
+           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
+       }
+       /**
+       The new document produced by the transaction. Contrary to
+       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
+       force the entire new state to be computed right away, so it is
+       recommended that [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
+       when they need to look at the new document.
+       */
+       get newDoc() {
+           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
+       }
+       /**
+       The new selection produced by the transaction. If
+       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
+       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
+       current selection through the changes made by the transaction.
+       */
+       get newSelection() {
+           return this.selection || this.startState.selection.map(this.changes);
+       }
+       /**
+       The new state created by the transaction. Computed on demand
+       (but retained for subsequent access), so it is recommended not to
+       access it in [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
+       */
+       get state() {
+           if (!this._state)
+               this.startState.applyTransaction(this);
+           return this._state;
+       }
+       /**
+       Get the value of the given annotation type, if any.
+       */
+       annotation(type) {
+           for (let ann of this.annotations)
+               if (ann.type == type)
+                   return ann.value;
+           return undefined;
+       }
+       /**
+       Indicates whether the transaction changed the document.
+       */
+       get docChanged() { return !this.changes.empty; }
+       /**
+       Indicates whether this transaction reconfigures the state
+       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
+       with a top-level configuration
+       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
+       */
+       get reconfigured() { return this.startState.config != this.state.config; }
+       /**
+       Returns true if the transaction has a [user
+       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
+       or more specific than `event`. For example, if the transaction
+       has `"select.pointer"` as user event, `"select"` and
+       `"select.pointer"` will match it.
+       */
+       isUserEvent(event) {
+           let e = this.annotation(Transaction.userEvent);
+           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
+       }
+   };
+   /**
+   Annotation used to store transaction timestamps. Automatically
+   added to every transaction, holding `Date.now()`.
+   */
+   Transaction$2.time = /*@__PURE__*/Annotation$2.define();
+   /**
+   Annotation used to associate a transaction with a user interface
+   event. Holds a string identifying the event, using a
+   dot-separated format to support attaching more specific
+   information. The events used by the core libraries are:
+
+    - `"input"` when content is entered
+      - `"input.type"` for typed input
+        - `"input.type.compose"` for composition
+      - `"input.paste"` for pasted input
+      - `"input.drop"` when adding content with drag-and-drop
+      - `"input.complete"` when autocompleting
+    - `"delete"` when the user deletes content
+      - `"delete.selection"` when deleting the selection
+      - `"delete.forward"` when deleting forward from the selection
+      - `"delete.backward"` when deleting backward from the selection
+      - `"delete.cut"` when cutting to the clipboard
+    - `"move"` when content is moved
+      - `"move.drop"` when content is moved within the editor through drag-and-drop
+    - `"select"` when explicitly changing the selection
+      - `"select.pointer"` when selecting with a mouse or other pointing device
+    - `"undo"` and `"redo"` for history actions
+
+   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
+   whether the annotation matches a given event.
+   */
+   Transaction$2.userEvent = /*@__PURE__*/Annotation$2.define();
+   /**
+   Annotation indicating whether a transaction should be added to
+   the undo history or not.
+   */
+   Transaction$2.addToHistory = /*@__PURE__*/Annotation$2.define();
+   /**
+   Annotation indicating (when present and true) that a transaction
+   represents a change made by some other actor, not the user. This
+   is used, for example, to tag other people's changes in
+   collaborative editing.
+   */
+   Transaction$2.remote = /*@__PURE__*/Annotation$2.define();
+   function joinRanges$2(a, b) {
+       let result = [];
+       for (let iA = 0, iB = 0;;) {
+           let from, to;
+           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
+               from = a[iA++];
+               to = a[iA++];
+           }
+           else if (iB < b.length) {
+               from = b[iB++];
+               to = b[iB++];
+           }
+           else
+               return result;
+           if (!result.length || result[result.length - 1] < from)
+               result.push(from, to);
+           else if (result[result.length - 1] < to)
+               result[result.length - 1] = to;
+       }
+   }
+   function mergeTransaction$2(a, b, sequential) {
+       var _a;
+       let mapForA, mapForB, changes;
+       if (sequential) {
+           mapForA = b.changes;
+           mapForB = ChangeSet$2.empty(b.changes.length);
+           changes = a.changes.compose(b.changes);
+       }
+       else {
+           mapForA = b.changes.map(a.changes);
+           mapForB = a.changes.mapDesc(b.changes, true);
+           changes = a.changes.compose(mapForA);
+       }
+       return {
+           changes,
+           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
+           effects: StateEffect$2.mapEffects(a.effects, mapForA).concat(StateEffect$2.mapEffects(b.effects, mapForB)),
+           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
+           scrollIntoView: a.scrollIntoView || b.scrollIntoView
+       };
+   }
+   function resolveTransactionInner$2(state, spec, docSize) {
+       let sel = spec.selection, annotations = asArray$3(spec.annotations);
+       if (spec.userEvent)
+           annotations = annotations.concat(Transaction$2.userEvent.of(spec.userEvent));
+       return {
+           changes: spec.changes instanceof ChangeSet$2 ? spec.changes
+               : ChangeSet$2.of(spec.changes || [], docSize, state.facet(lineSeparator$2)),
+           selection: sel && (sel instanceof EditorSelection$2 ? sel : EditorSelection$2.single(sel.anchor, sel.head)),
+           effects: asArray$3(spec.effects),
+           annotations,
+           scrollIntoView: !!spec.scrollIntoView
+       };
+   }
+   function resolveTransaction$2(state, specs, filter) {
+       let s = resolveTransactionInner$2(state, specs.length ? specs[0] : {}, state.doc.length);
+       if (specs.length && specs[0].filter === false)
+           filter = false;
+       for (let i = 1; i < specs.length; i++) {
+           if (specs[i].filter === false)
+               filter = false;
+           let seq = !!specs[i].sequential;
+           s = mergeTransaction$2(s, resolveTransactionInner$2(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
+       }
+       let tr = Transaction$2.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
+       return extendTransaction$2(filter ? filterTransaction$2(tr) : tr);
+   }
+   // Finish a transaction by applying filters if necessary.
+   function filterTransaction$2(tr) {
+       let state = tr.startState;
+       // Change filters
+       let result = true;
+       for (let filter of state.facet(changeFilter$2)) {
+           let value = filter(tr);
+           if (value === false) {
+               result = false;
+               break;
+           }
+           if (Array.isArray(value))
+               result = result === true ? value : joinRanges$2(result, value);
+       }
+       if (result !== true) {
+           let changes, back;
+           if (result === false) {
+               back = tr.changes.invertedDesc;
+               changes = ChangeSet$2.empty(state.doc.length);
+           }
+           else {
+               let filtered = tr.changes.filter(result);
+               changes = filtered.changes;
+               back = filtered.filtered.invertedDesc;
+           }
+           tr = Transaction$2.create(state, changes, tr.selection && tr.selection.map(back), StateEffect$2.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
+       }
+       // Transaction filters
+       let filters = state.facet(transactionFilter$2);
+       for (let i = filters.length - 1; i >= 0; i--) {
+           let filtered = filters[i](tr);
+           if (filtered instanceof Transaction$2)
+               tr = filtered;
+           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction$2)
+               tr = filtered[0];
+           else
+               tr = resolveTransaction$2(state, asArray$3(filtered), false);
+       }
+       return tr;
+   }
+   function extendTransaction$2(tr) {
+       let state = tr.startState, extenders = state.facet(transactionExtender$2), spec = tr;
+       for (let i = extenders.length - 1; i >= 0; i--) {
+           let extension = extenders[i](tr);
+           if (extension && Object.keys(extension).length)
+               spec = mergeTransaction$2(tr, resolveTransactionInner$2(state, extension, tr.changes.newLength), true);
+       }
+       return spec == tr ? tr : Transaction$2.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
+   }
+   const none$5 = [];
+   function asArray$3(value) {
+       return value == null ? none$5 : Array.isArray(value) ? value : [value];
+   }
+
+   /**
+   The categories produced by a [character
+   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
+   do things like selecting by word.
+   */
+   var CharCategory$2 = /*@__PURE__*/(function (CharCategory) {
+       /**
+       Word characters.
+       */
+       CharCategory[CharCategory["Word"] = 0] = "Word";
+       /**
+       Whitespace.
+       */
+       CharCategory[CharCategory["Space"] = 1] = "Space";
+       /**
+       Anything else.
+       */
+       CharCategory[CharCategory["Other"] = 2] = "Other";
+   return CharCategory})(CharCategory$2 || (CharCategory$2 = {}));
+   const nonASCIISingleCaseWordChar$2 = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
+   let wordChar$2;
+   try {
+       wordChar$2 = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
+   }
+   catch (_) { }
+   function hasWordChar$2(str) {
+       if (wordChar$2)
+           return wordChar$2.test(str);
+       for (let i = 0; i < str.length; i++) {
+           let ch = str[i];
+           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar$2.test(ch)))
+               return true;
+       }
+       return false;
+   }
+   function makeCategorizer$2(wordChars) {
+       return (char) => {
+           if (!/\S/.test(char))
+               return CharCategory$2.Space;
+           if (hasWordChar$2(char))
+               return CharCategory$2.Word;
+           for (let i = 0; i < wordChars.length; i++)
+               if (char.indexOf(wordChars[i]) > -1)
+                   return CharCategory$2.Word;
+           return CharCategory$2.Other;
+       };
+   }
+
+   /**
+   The editor state class is a persistent (immutable) data structure.
+   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
+   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
+   instance, without modifying the original object.
+
+   As such, _never_ mutate properties of a state directly. That'll
+   just break things.
+   */
+   let EditorState$2 = class EditorState {
+       constructor(
+       /**
+       @internal
+       */
+       config, 
+       /**
+       The current document.
+       */
+       doc, 
+       /**
+       The current selection.
+       */
+       selection, 
+       /**
+       @internal
+       */
+       values, computeSlot, tr) {
+           this.config = config;
+           this.doc = doc;
+           this.selection = selection;
+           this.values = values;
+           this.status = config.statusTemplate.slice();
+           this.computeSlot = computeSlot;
+           // Fill in the computed state immediately, so that further queries
+           // for it made during the update return this state
+           if (tr)
+               tr._state = this;
+           for (let i = 0; i < this.config.dynamicSlots.length; i++)
+               ensureAddr$2(this, i << 1);
+           this.computeSlot = null;
+       }
+       field(field, require = true) {
+           let addr = this.config.address[field.id];
+           if (addr == null) {
+               if (require)
+                   throw new RangeError("Field is not present in this state");
+               return undefined;
+           }
+           ensureAddr$2(this, addr);
+           return getAddr$2(this, addr);
+       }
+       /**
+       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
+       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
+       can be passed. Unless
+       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
+       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
+       are assumed to start in the _current_ document (not the document
+       produced by previous specs), and its
+       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
+       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
+       to the document created by its _own_ changes. The resulting
+       transaction contains the combined effect of all the different
+       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
+       specs take precedence over earlier ones.
+       */
+       update(...specs) {
+           return resolveTransaction$2(this, specs, true);
+       }
+       /**
+       @internal
+       */
+       applyTransaction(tr) {
+           let conf = this.config, { base, compartments } = conf;
+           for (let effect of tr.effects) {
+               if (effect.is(Compartment$2.reconfigure)) {
+                   if (conf) {
+                       compartments = new Map;
+                       conf.compartments.forEach((val, key) => compartments.set(key, val));
+                       conf = null;
+                   }
+                   compartments.set(effect.value.compartment, effect.value.extension);
+               }
+               else if (effect.is(StateEffect$2.reconfigure)) {
+                   conf = null;
+                   base = effect.value;
+               }
+               else if (effect.is(StateEffect$2.appendConfig)) {
+                   conf = null;
+                   base = asArray$3(base).concat(effect.value);
+               }
+           }
+           let startValues;
+           if (!conf) {
+               conf = Configuration$2.resolve(base, compartments, this);
+               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
+               startValues = intermediateState.values;
+           }
+           else {
+               startValues = tr.startState.values.slice();
+           }
+           new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
+       }
+       /**
+       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
+       replaces every selection range with the given content.
+       */
+       replaceSelection(text) {
+           if (typeof text == "string")
+               text = this.toText(text);
+           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
+               range: EditorSelection$2.cursor(range.from + text.length) }));
+       }
+       /**
+       Create a set of changes and a new selection by running the given
+       function for each range in the active selection. The function
+       can return an optional set of changes (in the coordinate space
+       of the start document), plus an updated range (in the coordinate
+       space of the document produced by the call's own changes). This
+       method will merge all the changes and ranges into a single
+       changeset and selection, and return it as a [transaction
+       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
+       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
+       */
+       changeByRange(f) {
+           let sel = this.selection;
+           let result1 = f(sel.ranges[0]);
+           let changes = this.changes(result1.changes), ranges = [result1.range];
+           let effects = asArray$3(result1.effects);
+           for (let i = 1; i < sel.ranges.length; i++) {
+               let result = f(sel.ranges[i]);
+               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
+               for (let j = 0; j < i; j++)
+                   ranges[j] = ranges[j].map(newMapped);
+               let mapBy = changes.mapDesc(newChanges, true);
+               ranges.push(result.range.map(mapBy));
+               changes = changes.compose(newMapped);
+               effects = StateEffect$2.mapEffects(effects, newMapped).concat(StateEffect$2.mapEffects(asArray$3(result.effects), mapBy));
+           }
+           return {
+               changes,
+               selection: EditorSelection$2.create(ranges, sel.mainIndex),
+               effects
+           };
+       }
+       /**
+       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
+       description, taking the state's document length and line
+       separator into account.
+       */
+       changes(spec = []) {
+           if (spec instanceof ChangeSet$2)
+               return spec;
+           return ChangeSet$2.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
+       }
+       /**
+       Using the state's [line
+       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
+       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
+       */
+       toText(string) {
+           return Text$2.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit$2));
+       }
+       /**
+       Return the given range of the document as a string.
+       */
+       sliceDoc(from = 0, to = this.doc.length) {
+           return this.doc.sliceString(from, to, this.lineBreak);
+       }
+       /**
+       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
+       */
+       facet(facet) {
+           let addr = this.config.address[facet.id];
+           if (addr == null)
+               return facet.default;
+           ensureAddr$2(this, addr);
+           return getAddr$2(this, addr);
+       }
+       /**
+       Convert this state to a JSON-serializable object. When custom
+       fields should be serialized, you can pass them in as an object
+       mapping property names (in the resulting object, which should
+       not use `doc` or `selection`) to fields.
+       */
+       toJSON(fields) {
+           let result = {
+               doc: this.sliceDoc(),
+               selection: this.selection.toJSON()
+           };
+           if (fields)
+               for (let prop in fields) {
+                   let value = fields[prop];
+                   if (value instanceof StateField$2)
+                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
+               }
+           return result;
+       }
+       /**
+       Deserialize a state from its JSON representation. When custom
+       fields should be deserialized, pass the same object you passed
+       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
+       third argument.
+       */
+       static fromJSON(json, config = {}, fields) {
+           if (!json || typeof json.doc != "string")
+               throw new RangeError("Invalid JSON representation for EditorState");
+           let fieldInit = [];
+           if (fields)
+               for (let prop in fields) {
+                   let field = fields[prop], value = json[prop];
+                   fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
+               }
+           return EditorState.create({
+               doc: json.doc,
+               selection: EditorSelection$2.fromJSON(json.selection),
+               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
+           });
+       }
+       /**
+       Create a new state. You'll usually only need this when
+       initializing an editor—updated states are created by applying
+       transactions.
+       */
+       static create(config = {}) {
+           let configuration = Configuration$2.resolve(config.extensions || [], new Map);
+           let doc = config.doc instanceof Text$2 ? config.doc
+               : Text$2.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit$2));
+           let selection = !config.selection ? EditorSelection$2.single(0)
+               : config.selection instanceof EditorSelection$2 ? config.selection
+                   : EditorSelection$2.single(config.selection.anchor, config.selection.head);
+           checkSelection$2(selection, doc.length);
+           if (!configuration.staticFacet(allowMultipleSelections$2))
+               selection = selection.asSingle();
+           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
+       }
+       /**
+       The size (in columns) of a tab in the document, determined by
+       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
+       */
+       get tabSize() { return this.facet(EditorState.tabSize); }
+       /**
+       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
+       string for this state.
+       */
+       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
+       /**
+       Returns true when the editor is
+       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
+       */
+       get readOnly() { return this.facet(readOnly$2); }
+       /**
+       Look up a translation for the given phrase (via the
+       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
+       original string if no translation is found.
+       
+       If additional arguments are passed, they will be inserted in
+       place of markers like `$1` (for the first value) and `$2`, etc.
+       A single `$` is equivalent to `$1`, and `$$` will produce a
+       literal dollar sign.
+       */
+       phrase(phrase, ...insert) {
+           for (let map of this.facet(EditorState.phrases))
+               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
+                   phrase = map[phrase];
+                   break;
+               }
+           if (insert.length)
+               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
+                   if (i == "$")
+                       return "$";
+                   let n = +(i || 1);
+                   return n > insert.length ? m : insert[n - 1];
+               });
+           return phrase;
+       }
+       /**
+       Find the values for a given language data field, provided by the
+       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
+       */
+       languageDataAt(name, pos, side = -1) {
+           let values = [];
+           for (let provider of this.facet(languageData$2)) {
+               for (let result of provider(this, pos, side)) {
+                   if (Object.prototype.hasOwnProperty.call(result, name))
+                       values.push(result[name]);
+               }
+           }
+           return values;
+       }
+       /**
+       Return a function that can categorize strings (expected to
+       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
+       into one of:
+       
+        - Word (contains an alphanumeric character or a character
+          explicitly listed in the local language's `"wordChars"`
+          language data, which should be a string)
+        - Space (contains only whitespace)
+        - Other (anything else)
+       */
+       charCategorizer(at) {
+           return makeCategorizer$2(this.languageDataAt("wordChars", at).join(""));
+       }
+       /**
+       Find the word at the given position, meaning the range
+       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
+       around it. If no word characters are adjacent to the position,
+       this returns null.
+       */
+       wordAt(pos) {
+           let { text, from, length } = this.doc.lineAt(pos);
+           let cat = this.charCategorizer(pos);
+           let start = pos - from, end = pos - from;
+           while (start > 0) {
+               let prev = findClusterBreak$3(text, start, false);
+               if (cat(text.slice(prev, start)) != CharCategory$2.Word)
+                   break;
+               start = prev;
+           }
+           while (end < length) {
+               let next = findClusterBreak$3(text, end);
+               if (cat(text.slice(end, next)) != CharCategory$2.Word)
+                   break;
+               end = next;
+           }
+           return start == end ? null : EditorSelection$2.range(start + from, end + from);
+       }
+   };
+   /**
+   A facet that, when enabled, causes the editor to allow multiple
+   ranges to be selected. Be careful though, because by default the
+   editor relies on the native DOM selection, which cannot handle
+   multiple selections. An extension like
+   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
+   secondary selections visible to the user.
+   */
+   EditorState$2.allowMultipleSelections = allowMultipleSelections$2;
+   /**
+   Configures the tab size to use in this state. The first
+   (highest-precedence) value of the facet is used. If no value is
+   given, this defaults to 4.
+   */
+   EditorState$2.tabSize = /*@__PURE__*/Facet$2.define({
+       combine: values => values.length ? values[0] : 4
+   });
+   /**
+   The line separator to use. By default, any of `"\n"`, `"\r\n"`
+   and `"\r"` is treated as a separator when splitting lines, and
+   lines are joined with `"\n"`.
+
+   When you configure a value here, only that precise separator
+   will be used, allowing you to round-trip documents through the
+   editor without normalizing line separators.
+   */
+   EditorState$2.lineSeparator = lineSeparator$2;
+   /**
+   This facet controls the value of the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
+   consulted by commands and extensions that implement editing
+   functionality to determine whether they should apply. It
+   defaults to false, but when its highest-precedence value is
+   `true`, such functionality disables itself.
+
+   Not to be confused with
+   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
+   controls whether the editor's DOM is set to be editable (and
+   thus focusable).
+   */
+   EditorState$2.readOnly = readOnly$2;
+   /**
+   Registers translation phrases. The
+   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
+   all objects registered with this facet to find translations for
+   its argument.
+   */
+   EditorState$2.phrases = /*@__PURE__*/Facet$2.define({
+       compare(a, b) {
+           let kA = Object.keys(a), kB = Object.keys(b);
+           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
+       }
+   });
+   /**
+   A facet used to register [language
+   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
+   */
+   EditorState$2.languageData = languageData$2;
+   /**
+   Facet used to register change filters, which are called for each
+   transaction (unless explicitly
+   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
+   part of the transaction's changes.
+
+   Such a function can return `true` to indicate that it doesn't
+   want to do anything, `false` to completely stop the changes in
+   the transaction, or a set of ranges in which changes should be
+   suppressed. Such ranges are represented as an array of numbers,
+   with each pair of two numbers indicating the start and end of a
+   range. So for example `[10, 20, 100, 110]` suppresses changes
+   between 10 and 20, and between 100 and 110.
+   */
+   EditorState$2.changeFilter = changeFilter$2;
+   /**
+   Facet used to register a hook that gets a chance to update or
+   replace transaction specs before they are applied. This will
+   only be applied for transactions that don't have
+   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
+   can either return a single transaction spec (possibly the input
+   transaction), or an array of specs (which will be combined in
+   the same way as the arguments to
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
+
+   When possible, it is recommended to avoid accessing
+   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
+   since it will force creation of a state that will then be
+   discarded again, if the transaction is actually filtered.
+
+   (This functionality should be used with care. Indiscriminately
+   modifying transaction is likely to break something or degrade
+   the user experience.)
+   */
+   EditorState$2.transactionFilter = transactionFilter$2;
+   /**
+   This is a more limited form of
+   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
+   which can only add
+   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
+   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
+   of filter runs even if the transaction has disabled regular
+   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
+   for effects that don't need to touch the changes or selection,
+   but do want to process every transaction.
+
+   Extenders run _after_ filters, when both are present.
+   */
+   EditorState$2.transactionExtender = transactionExtender$2;
+   Compartment$2.reconfigure = /*@__PURE__*/StateEffect$2.define();
+
+   /**
+   Utility function for combining behaviors to fill in a config
+   object from an array of provided configs. `defaults` should hold
+   default values for all optional fields in `Config`.
+
+   The function will, by default, error
+   when a field gets two values that aren't `===`-equal, but you can
+   provide combine functions per field to do something else.
+   */
+   function combineConfig$2(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
+   combine = {}) {
+       let result = {};
+       for (let config of configs)
+           for (let key of Object.keys(config)) {
+               let value = config[key], current = result[key];
+               if (current === undefined)
+                   result[key] = value;
+               else if (current === value || value === undefined) ; // No conflict
+               else if (Object.hasOwnProperty.call(combine, key))
+                   result[key] = combine[key](current, value);
+               else
+                   throw new Error("Config merge conflict for field " + key);
+           }
+       for (let key in defaults)
+           if (result[key] === undefined)
+               result[key] = defaults[key];
+       return result;
+   }
+
+   /**
+   Each range is associated with a value, which must inherit from
+   this class.
+   */
+   let RangeValue$2 = class RangeValue {
+       /**
+       Compare this value with another value. Used when comparing
+       rangesets. The default implementation compares by identity.
+       Unless you are only creating a fixed number of unique instances
+       of your value type, it is a good idea to implement this
+       properly.
+       */
+       eq(other) { return this == other; }
+       /**
+       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
+       */
+       range(from, to = from) { return Range$4.create(from, to, this); }
+   };
+   RangeValue$2.prototype.startSide = RangeValue$2.prototype.endSide = 0;
+   RangeValue$2.prototype.point = false;
+   RangeValue$2.prototype.mapMode = MapMode$2.TrackDel;
+   /**
+   A range associates a value with a range of positions.
+   */
+   let Range$4 = class Range {
+       constructor(
+       /**
+       The range's start position.
+       */
+       from, 
+       /**
+       Its end position.
+       */
+       to, 
+       /**
+       The value associated with this range.
+       */
+       value) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+       }
+       /**
+       @internal
+       */
+       static create(from, to, value) {
+           return new Range(from, to, value);
+       }
+   };
+   function cmpRange$2(a, b) {
+       return a.from - b.from || a.value.startSide - b.value.startSide;
+   }
+   let Chunk$2 = class Chunk {
+       constructor(from, to, value, 
+       // Chunks are marked with the largest point that occurs
+       // in them (or -1 for no points), so that scans that are
+       // only interested in points (such as the
+       // heightmap-related logic) can skip range-only chunks.
+       maxPoint) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+           this.maxPoint = maxPoint;
+       }
+       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(pos, side, end, startAt = 0) {
+           let arr = end ? this.to : this.from;
+           for (let lo = startAt, hi = arr.length;;) {
+               if (lo == hi)
+                   return lo;
+               let mid = (lo + hi) >> 1;
+               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
+               if (mid == lo)
+                   return diff >= 0 ? lo : hi;
+               if (diff >= 0)
+                   hi = mid;
+               else
+                   lo = mid + 1;
+           }
+       }
+       between(offset, from, to, f) {
+           for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
+               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
+                   return false;
+       }
+       map(offset, changes) {
+           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
+           for (let i = 0; i < this.value.length; i++) {
+               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
+               if (curFrom == curTo) {
+                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
+                   if (mapped == null)
+                       continue;
+                   newFrom = newTo = mapped;
+                   if (val.startSide != val.endSide) {
+                       newTo = changes.mapPos(curFrom, val.endSide);
+                       if (newTo < newFrom)
+                           continue;
+                   }
+               }
+               else {
+                   newFrom = changes.mapPos(curFrom, val.startSide);
+                   newTo = changes.mapPos(curTo, val.endSide);
+                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
+                       continue;
+               }
+               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
+                   continue;
+               if (newPos < 0)
+                   newPos = newFrom;
+               if (val.point)
+                   maxPoint = Math.max(maxPoint, newTo - newFrom);
+               value.push(val);
+               from.push(newFrom - newPos);
+               to.push(newTo - newPos);
+           }
+           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
+       }
+   };
+   /**
+   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
+   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
+   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
+   structure.
+   */
+   let RangeSet$2 = class RangeSet {
+       constructor(
+       /**
+       @internal
+       */
+       chunkPos, 
+       /**
+       @internal
+       */
+       chunk, 
+       /**
+       @internal
+       */
+       nextLayer, 
+       /**
+       @internal
+       */
+       maxPoint) {
+           this.chunkPos = chunkPos;
+           this.chunk = chunk;
+           this.nextLayer = nextLayer;
+           this.maxPoint = maxPoint;
+       }
+       /**
+       @internal
+       */
+       static create(chunkPos, chunk, nextLayer, maxPoint) {
+           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
+       }
+       /**
+       @internal
+       */
+       get length() {
+           let last = this.chunk.length - 1;
+           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
+       }
+       /**
+       The number of ranges in the set.
+       */
+       get size() {
+           if (this.isEmpty)
+               return 0;
+           let size = this.nextLayer.size;
+           for (let chunk of this.chunk)
+               size += chunk.value.length;
+           return size;
+       }
+       /**
+       @internal
+       */
+       chunkEnd(index) {
+           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
+           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
+           let filter = updateSpec.filter;
+           if (add.length == 0 && !filter)
+               return this;
+           if (sort)
+               add = add.slice().sort(cmpRange$2);
+           if (this.isEmpty)
+               return add.length ? RangeSet.of(add) : this;
+           let cur = new LayerCursor$2(this, null, -1).goto(0), i = 0, spill = [];
+           let builder = new RangeSetBuilder$2();
+           while (cur.value || i < add.length) {
+               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
+                   let range = add[i++];
+                   if (!builder.addInner(range.from, range.to, range.value))
+                       spill.push(range);
+               }
+               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
+                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
+                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
+                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
+                   cur.nextChunk();
+               }
+               else {
+                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
+                       if (!builder.addInner(cur.from, cur.to, cur.value))
+                           spill.push(Range$4.create(cur.from, cur.to, cur.value));
+                   }
+                   cur.next();
+               }
+           }
+           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
+               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
+       }
+       /**
+       Map this range set through a set of changes, return the new set.
+       */
+       map(changes) {
+           if (changes.empty || this.isEmpty)
+               return this;
+           let chunks = [], chunkPos = [], maxPoint = -1;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               let touch = changes.touchesRange(start, start + chunk.length);
+               if (touch === false) {
+                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
+                   chunks.push(chunk);
+                   chunkPos.push(changes.mapPos(start));
+               }
+               else if (touch === true) {
+                   let { mapped, pos } = chunk.map(start, changes);
+                   if (mapped) {
+                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
+                       chunks.push(mapped);
+                       chunkPos.push(pos);
+                   }
+               }
+           }
+           let next = this.nextLayer.map(changes);
+           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
+       }
+       /**
+       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(from, to, f) {
+           if (this.isEmpty)
+               return;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               if (to >= start && from <= start + chunk.length &&
+                   chunk.between(start, from - start, to - start, f) === false)
+                   return;
+           }
+           this.nextLayer.between(from, to, f);
+       }
+       /**
+       Iterate over the ranges in this set, in order, including all
+       ranges that end at or after `from`.
+       */
+       iter(from = 0) {
+           return HeapCursor$2.from([this]).goto(from);
+       }
+       /**
+       @internal
+       */
+       get isEmpty() { return this.nextLayer == this; }
+       /**
+       Iterate over the ranges in a collection of sets, in order,
+       starting from `from`.
+       */
+       static iter(sets, from = 0) {
+           return HeapCursor$2.from(sets).goto(from);
+       }
+       /**
+       Iterate over two groups of sets, calling methods on `comparator`
+       to notify it of possible differences.
+       */
+       static compare(oldSets, newSets, 
+       /**
+       This indicates how the underlying data changed between these
+       ranges, and is needed to synchronize the iteration. `from` and
+       `to` are coordinates in the _new_ space, after these changes.
+       */
+       textDiff, comparator, 
+       /**
+       Can be used to ignore all non-point ranges, and points below
+       the given size. When -1, all ranges are compared.
+       */
+       minPointSize = -1) {
+           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let sharedChunks = findSharedChunks$2(a, b, textDiff);
+           let sideA = new SpanCursor$2(a, sharedChunks, minPointSize);
+           let sideB = new SpanCursor$2(b, sharedChunks, minPointSize);
+           textDiff.iterGaps((fromA, fromB, length) => compare$2(sideA, fromA, sideB, fromB, length, comparator));
+           if (textDiff.empty && textDiff.length == 0)
+               compare$2(sideA, 0, sideB, 0, 0, comparator);
+       }
+       /**
+       Compare the contents of two groups of range sets, returning true
+       if they are equivalent in the given range.
+       */
+       static eq(oldSets, newSets, from = 0, to) {
+           if (to == null)
+               to = 1000000000 /* Far */;
+           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
+           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
+           if (a.length != b.length)
+               return false;
+           if (!a.length)
+               return true;
+           let sharedChunks = findSharedChunks$2(a, b);
+           let sideA = new SpanCursor$2(a, sharedChunks, 0).goto(from), sideB = new SpanCursor$2(b, sharedChunks, 0).goto(from);
+           for (;;) {
+               if (sideA.to != sideB.to ||
+                   !sameValues$2(sideA.active, sideB.active) ||
+                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
+                   return false;
+               if (sideA.to > to)
+                   return true;
+               sideA.next();
+               sideB.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(sets, from, to, iterator, 
+       /**
+       When given and greater than -1, only points of at least this
+       size are taken into account.
+       */
+       minPointSize = -1) {
+           let cursor = new SpanCursor$2(sets, null, minPointSize).goto(from), pos = from;
+           let open = cursor.openStart;
+           for (;;) {
+               let curTo = Math.min(cursor.to, to);
+               if (cursor.point) {
+                   iterator.point(pos, curTo, cursor.point, cursor.activeForPoint(cursor.to), open, cursor.pointRank);
+                   open = cursor.openEnd(curTo) + (cursor.to > curTo ? 1 : 0);
+               }
+               else if (curTo > pos) {
+                   iterator.span(pos, curTo, cursor.active, open);
+                   open = cursor.openEnd(curTo);
+               }
+               if (cursor.to > to)
+                   break;
+               pos = cursor.to;
+               cursor.next();
+           }
+           return open;
+       }
+       /**
+       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(ranges, sort = false) {
+           let build = new RangeSetBuilder$2();
+           for (let range of ranges instanceof Range$4 ? [ranges] : sort ? lazySort$2(ranges) : ranges)
+               build.add(range.from, range.to, range.value);
+           return build.finish();
+       }
+   };
+   /**
+   The empty set of ranges.
+   */
+   RangeSet$2.empty = /*@__PURE__*/new RangeSet$2([], [], null, -1);
+   function lazySort$2(ranges) {
+       if (ranges.length > 1)
+           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
+               let cur = ranges[i];
+               if (cmpRange$2(prev, cur) > 0)
+                   return ranges.slice().sort(cmpRange$2);
+               prev = cur;
+           }
+       return ranges;
+   }
+   RangeSet$2.empty.nextLayer = RangeSet$2.empty;
+   /**
+   A range set builder is a data structure that helps build up a
+   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
+   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
+   */
+   let RangeSetBuilder$2 = class RangeSetBuilder {
+       /**
+       Create an empty builder.
+       */
+       constructor() {
+           this.chunks = [];
+           this.chunkPos = [];
+           this.chunkStart = -1;
+           this.last = null;
+           this.lastFrom = -1000000000 /* Far */;
+           this.lastTo = -1000000000 /* Far */;
+           this.from = [];
+           this.to = [];
+           this.value = [];
+           this.maxPoint = -1;
+           this.setMaxPoint = -1;
+           this.nextLayer = null;
+       }
+       finishChunk(newArrays) {
+           this.chunks.push(new Chunk$2(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;
+           if (newArrays) {
+               this.from = [];
+               this.to = [];
+               this.value = [];
+           }
+       }
+       /**
+       Add a range. Ranges should be added in sorted (by `from` and
+       `value.startSide`) order.
+       */
+       add(from, to, value) {
+           if (!this.addInner(from, to, value))
+               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
+       }
+       /**
+       @internal
+       */
+       addInner(from, to, value) {
+           let diff = from - this.lastTo || value.startSide - this.last.endSide;
+           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
+               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
+           if (diff < 0)
+               return false;
+           if (this.from.length == 250 /* ChunkSize */)
+               this.finishChunk(true);
+           if (this.chunkStart < 0)
+               this.chunkStart = from;
+           this.from.push(from - this.chunkStart);
+           this.to.push(to - this.chunkStart);
+           this.last = value;
+           this.lastFrom = from;
+           this.lastTo = to;
+           this.value.push(value);
+           if (value.point)
+               this.maxPoint = Math.max(this.maxPoint, to - from);
+           return true;
+       }
+       /**
+       @internal
+       */
+       addChunk(from, chunk) {
+           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
+               return false;
+           if (this.from.length)
+               this.finishChunk(true);
+           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
+           this.chunks.push(chunk);
+           this.chunkPos.push(from);
+           let last = chunk.value.length - 1;
+           this.last = chunk.value[last];
+           this.lastFrom = chunk.from[last] + from;
+           this.lastTo = chunk.to[last] + from;
+           return true;
+       }
+       /**
+       Finish the range set. Returns the new set. The builder can't be
+       used anymore after this has been called.
+       */
+       finish() { return this.finishInner(RangeSet$2.empty); }
+       /**
+       @internal
+       */
+       finishInner(next) {
+           if (this.from.length)
+               this.finishChunk(false);
+           if (this.chunks.length == 0)
+               return next;
+           let result = RangeSet$2.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
+           this.from = null; // Make sure further `add` calls produce errors
+           return result;
+       }
+   };
+   function findSharedChunks$2(a, b, textDiff) {
+       let inA = new Map();
+       for (let set of a)
+           for (let i = 0; i < set.chunk.length; i++)
+               if (set.chunk[i].maxPoint <= 0)
+                   inA.set(set.chunk[i], set.chunkPos[i]);
+       let shared = new Set();
+       for (let set of b)
+           for (let i = 0; i < set.chunk.length; i++) {
+               let known = inA.get(set.chunk[i]);
+               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
+                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
+                   shared.add(set.chunk[i]);
+           }
+       return shared;
+   }
+   let LayerCursor$2 = class LayerCursor {
+       constructor(layer, skip, minPoint, rank = 0) {
+           this.layer = layer;
+           this.skip = skip;
+           this.minPoint = minPoint;
+           this.rank = rank;
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       get endSide() { return this.value ? this.value.endSide : 0; }
+       goto(pos, side = -1000000000 /* Far */) {
+           this.chunkIndex = this.rangeIndex = 0;
+           this.gotoInner(pos, side, false);
+           return this;
+       }
+       gotoInner(pos, side, forward) {
+           while (this.chunkIndex < this.layer.chunk.length) {
+               let next = this.layer.chunk[this.chunkIndex];
+               if (!(this.skip && this.skip.has(next) ||
+                   this.layer.chunkEnd(this.chunkIndex) < pos ||
+                   next.maxPoint < this.minPoint))
+                   break;
+               this.chunkIndex++;
+               forward = false;
+           }
+           if (this.chunkIndex < this.layer.chunk.length) {
+               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
+               if (!forward || this.rangeIndex < rangeIndex)
+                   this.setRangeIndex(rangeIndex);
+           }
+           this.next();
+       }
+       forward(pos, side) {
+           if ((this.to - pos || this.endSide - side) < 0)
+               this.gotoInner(pos, side, true);
+       }
+       next() {
+           for (;;) {
+               if (this.chunkIndex == this.layer.chunk.length) {
+                   this.from = this.to = 1000000000 /* Far */;
+                   this.value = null;
+                   break;
+               }
+               else {
+                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
+                   let from = chunkPos + chunk.from[this.rangeIndex];
+                   this.from = from;
+                   this.to = chunkPos + chunk.to[this.rangeIndex];
+                   this.value = chunk.value[this.rangeIndex];
+                   this.setRangeIndex(this.rangeIndex + 1);
+                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
+                       break;
+               }
+           }
+       }
+       setRangeIndex(index) {
+           if (index == this.layer.chunk[this.chunkIndex].value.length) {
+               this.chunkIndex++;
+               if (this.skip) {
+                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
+                       this.chunkIndex++;
+               }
+               this.rangeIndex = 0;
+           }
+           else {
+               this.rangeIndex = index;
+           }
+       }
+       nextChunk() {
+           this.chunkIndex++;
+           this.rangeIndex = 0;
+           this.next();
+       }
+       compare(other) {
+           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
+               this.to - other.to || this.endSide - other.endSide;
+       }
+   };
+   let HeapCursor$2 = class HeapCursor {
+       constructor(heap) {
+           this.heap = heap;
+       }
+       static from(sets, skip = null, minPoint = -1) {
+           let heap = [];
+           for (let i = 0; i < sets.length; i++) {
+               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
+                   if (cur.maxPoint >= minPoint)
+                       heap.push(new LayerCursor$2(cur, skip, minPoint, i));
+               }
+           }
+           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       goto(pos, side = -1000000000 /* Far */) {
+           for (let cur of this.heap)
+               cur.goto(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble$2(this.heap, i);
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           for (let cur of this.heap)
+               cur.forward(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble$2(this.heap, i);
+           if ((this.to - pos || this.value.endSide - side) < 0)
+               this.next();
+       }
+       next() {
+           if (this.heap.length == 0) {
+               this.from = this.to = 1000000000 /* Far */;
+               this.value = null;
+               this.rank = -1;
+           }
+           else {
+               let top = this.heap[0];
+               this.from = top.from;
+               this.to = top.to;
+               this.value = top.value;
+               this.rank = top.rank;
+               if (top.value)
+                   top.next();
+               heapBubble$2(this.heap, 0);
+           }
+       }
+   };
+   function heapBubble$2(heap, index) {
+       for (let cur = heap[index];;) {
+           let childIndex = (index << 1) + 1;
+           if (childIndex >= heap.length)
+               break;
+           let child = heap[childIndex];
+           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
+               child = heap[childIndex + 1];
+               childIndex++;
+           }
+           if (cur.compare(child) < 0)
+               break;
+           heap[childIndex] = cur;
+           heap[index] = child;
+           index = childIndex;
+       }
+   }
+   let SpanCursor$2 = class SpanCursor {
+       constructor(sets, skip, minPoint) {
+           this.minPoint = minPoint;
+           this.active = [];
+           this.activeTo = [];
+           this.activeRank = [];
+           this.minActive = -1;
+           // A currently active point range, if any
+           this.point = null;
+           this.pointFrom = 0;
+           this.pointRank = 0;
+           this.to = -1000000000 /* Far */;
+           this.endSide = 0;
+           this.openStart = -1;
+           this.cursor = HeapCursor$2.from(sets, skip, minPoint);
+       }
+       goto(pos, side = -1000000000 /* Far */) {
+           this.cursor.goto(pos, side);
+           this.active.length = this.activeTo.length = this.activeRank.length = 0;
+           this.minActive = -1;
+           this.to = pos;
+           this.endSide = side;
+           this.openStart = -1;
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
+               this.removeActive(this.minActive);
+           this.cursor.forward(pos, side);
+       }
+       removeActive(index) {
+           remove$2(this.active, index);
+           remove$2(this.activeTo, index);
+           remove$2(this.activeRank, index);
+           this.minActive = findMinIndex$2(this.active, this.activeTo);
+       }
+       addActive(trackOpen) {
+           let i = 0, { value, to, rank } = this.cursor;
+           while (i < this.activeRank.length && this.activeRank[i] <= rank)
+               i++;
+           insert$2(this.active, i, value);
+           insert$2(this.activeTo, i, to);
+           insert$2(this.activeRank, i, rank);
+           if (trackOpen)
+               insert$2(trackOpen, i, this.cursor.from);
+           this.minActive = findMinIndex$2(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 from = this.to, wasPoint = this.point;
+           this.point = null;
+           let trackOpen = this.openStart < 0 ? [] : null, trackExtra = 0;
+           for (;;) {
+               let a = this.minActive;
+               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
+                   if (this.activeTo[a] > from) {
+                       this.to = this.activeTo[a];
+                       this.endSide = this.active[a].endSide;
+                       break;
+                   }
+                   this.removeActive(a);
+                   if (trackOpen)
+                       remove$2(trackOpen, a);
+               }
+               else if (!this.cursor.value) {
+                   this.to = this.endSide = 1000000000 /* Far */;
+                   break;
+               }
+               else if (this.cursor.from > from) {
+                   this.to = this.cursor.from;
+                   this.endSide = this.cursor.startSide;
+                   break;
+               }
+               else {
+                   let nextVal = this.cursor.value;
+                   if (!nextVal.point) { // Opening a range
+                       this.addActive(trackOpen);
+                       this.cursor.next();
+                   }
+                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
+                       // Ignore any non-empty points that end precisely at the end of the prev point
+                       this.cursor.next();
+                   }
+                   else { // New point
+                       this.point = nextVal;
+                       this.pointFrom = this.cursor.from;
+                       this.pointRank = this.cursor.rank;
+                       this.to = this.cursor.to;
+                       this.endSide = nextVal.endSide;
+                       if (this.cursor.from < from)
+                           trackExtra = 1;
+                       this.cursor.next();
+                       this.forward(this.to, this.endSide);
+                       break;
+                   }
+               }
+           }
+           if (trackOpen) {
+               let openStart = 0;
+               while (openStart < trackOpen.length && trackOpen[openStart] < from)
+                   openStart++;
+               this.openStart = openStart + trackExtra;
+           }
+       }
+       activeForPoint(to) {
+           if (!this.active.length)
+               return this.active;
+           let active = [];
+           for (let i = this.active.length - 1; i >= 0; i--) {
+               if (this.activeRank[i] < this.pointRank)
+                   break;
+               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
+                   active.push(this.active[i]);
+           }
+           return active.reverse();
+       }
+       openEnd(to) {
+           let open = 0;
+           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
+               open++;
+           return open;
+       }
+   };
+   function compare$2(a, startA, b, startB, length, comparator) {
+       a.goto(startA);
+       b.goto(startB);
+       let endB = startB + length;
+       let pos = startB, dPos = startB - startA;
+       for (;;) {
+           let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;
+           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
+           if (a.point || b.point) {
+               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
+                   sameValues$2(a.activeForPoint(a.to + dPos), b.activeForPoint(b.to))))
+                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
+           }
+           else {
+               if (clipEnd > pos && !sameValues$2(a.active, b.active))
+                   comparator.compareRange(pos, clipEnd, a.active, b.active);
+           }
+           if (end > endB)
+               break;
+           pos = end;
+           if (diff <= 0)
+               a.next();
+           if (diff >= 0)
+               b.next();
+       }
+   }
+   function sameValues$2(a, b) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (a[i] != b[i] && !a[i].eq(b[i]))
+               return false;
+       return true;
+   }
+   function remove$2(array, index) {
+       for (let i = index, e = array.length - 1; i < e; i++)
+           array[i] = array[i + 1];
+       array.pop();
+   }
+   function insert$2(array, index, value) {
+       for (let i = array.length - 1; i >= index; i--)
+           array[i + 1] = array[i];
+       array[index] = value;
+   }
+   function findMinIndex$2(value, array) {
+       let found = -1, foundPos = 1000000000 /* Far */;
+       for (let i = 0; i < array.length; i++)
+           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
+               found = i;
+               foundPos = array[i];
+           }
+       return found;
+   }
+
+   /**
+   Count the column position at the given offset into the string,
+   taking extending characters and tab size into account.
+   */
+   function countColumn(string, tabSize, to = string.length) {
+       let n = 0;
+       for (let i = 0; i < to;) {
+           if (string.charCodeAt(i) == 9) {
+               n += tabSize - (n % tabSize);
+               i++;
+           }
+           else {
+               n++;
+               i = findClusterBreak$3(string, i);
+           }
+       }
+       return n;
+   }
+   /**
+   Find the offset that corresponds to the given column position in a
+   string, taking extending characters and tab size into account. By
+   default, the string length is returned when it is too short to
+   reach the column. Pass `strict` true to make it return -1 in that
+   situation.
+   */
+   function findColumn$2(string, col, tabSize, strict) {
+       for (let i = 0, n = 0;;) {
+           if (n >= col)
+               return i;
+           if (i == string.length)
+               break;
+           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
+           i = findClusterBreak$3(string, i);
+       }
+       return strict === true ? -1 : string.length;
+   }
+
+   function getSelection$2(root) {
+       let target;
+       // Browsers differ on whether shadow roots have a getSelection
+       // method. If it exists, use that, otherwise, call it on the
+       // document.
+       if (root.nodeType == 11) { // Shadow root
+           target = root.getSelection ? root : root.ownerDocument;
+       }
+       else {
+           target = root;
+       }
+       return target.getSelection();
+   }
+   function contains$2(dom, node) {
+       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
+   }
+   function deepActiveElement$1() {
+       let elt = document.activeElement;
+       while (elt && elt.shadowRoot)
+           elt = elt.shadowRoot.activeElement;
+       return elt;
+   }
+   function hasSelection$2(dom, selection) {
+       if (!selection.anchorNode)
+           return false;
+       try {
+           // Firefox will raise 'permission denied' errors when accessing
+           // properties of `sel.anchorNode` when it's in a generated CSS
+           // element.
+           return contains$2(dom, selection.anchorNode);
+       }
+       catch (_) {
+           return false;
+       }
+   }
+   function clientRectsFor$2(dom) {
+       if (dom.nodeType == 3)
+           return textRange$2(dom, 0, dom.nodeValue.length).getClientRects();
+       else if (dom.nodeType == 1)
+           return dom.getClientRects();
+       else
+           return [];
+   }
+   // Scans forward and backward through DOM positions equivalent to the
+   // given one to see if the two are in the same place (i.e. after a
+   // text node vs at the end of that text node)
+   function isEquivalentPosition$2(node, off, targetNode, targetOff) {
+       return targetNode ? (scanFor$2(node, off, targetNode, targetOff, -1) ||
+           scanFor$2(node, off, targetNode, targetOff, 1)) : false;
+   }
+   function domIndex$2(node) {
+       for (var index = 0;; index++) {
+           node = node.previousSibling;
+           if (!node)
+               return index;
+       }
+   }
+   function scanFor$2(node, off, targetNode, targetOff, dir) {
+       for (;;) {
+           if (node == targetNode && off == targetOff)
+               return true;
+           if (off == (dir < 0 ? 0 : maxOffset$2(node))) {
+               if (node.nodeName == "DIV")
+                   return false;
+               let parent = node.parentNode;
+               if (!parent || parent.nodeType != 1)
+                   return false;
+               off = domIndex$2(node) + (dir < 0 ? 0 : 1);
+               node = parent;
+           }
+           else if (node.nodeType == 1) {
+               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
+               if (node.nodeType == 1 && node.contentEditable == "false")
+                   return false;
+               off = dir < 0 ? maxOffset$2(node) : 0;
+           }
+           else {
+               return false;
+           }
+       }
+   }
+   function maxOffset$2(node) {
+       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
+   }
+   const Rect0$1 = { left: 0, right: 0, top: 0, bottom: 0 };
+   function flattenRect$2(rect, left) {
+       let x = left ? rect.left : rect.right;
+       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
+   }
+   function windowRect$2(win) {
+       return { left: 0, right: win.innerWidth,
+           top: 0, bottom: win.innerHeight };
+   }
+   function scrollRectIntoView$2(dom, rect, side, x, y, xMargin, yMargin, ltr) {
+       let doc = dom.ownerDocument, win = doc.defaultView;
+       for (let cur = dom; cur;) {
+           if (cur.nodeType == 1) { // Element
+               let bounding, top = cur == doc.body;
+               if (top) {
+                   bounding = windowRect$2(win);
+               }
+               else {
+                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
+                       cur = cur.parentNode;
+                       continue;
+                   }
+                   let rect = cur.getBoundingClientRect();
+                   // Make sure scrollbar width isn't included in the rectangle
+                   bounding = { left: rect.left, right: rect.left + cur.clientWidth,
+                       top: rect.top, bottom: rect.top + cur.clientHeight };
+               }
+               let moveX = 0, moveY = 0;
+               if (y == "nearest") {
+                   if (rect.top < bounding.top) {
+                       moveY = -(bounding.top - rect.top + yMargin);
+                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
+                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
+                   }
+                   else if (rect.bottom > bounding.bottom) {
+                       moveY = rect.bottom - bounding.bottom + yMargin;
+                       if (side < 0 && (rect.top - moveY) < bounding.top)
+                           moveY = -(bounding.top + moveY - rect.top + yMargin);
+                   }
+               }
+               else {
+                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
+                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
+                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
+                           rect.bottom - boundingHeight + yMargin;
+                   moveY = targetTop - bounding.top;
+               }
+               if (x == "nearest") {
+                   if (rect.left < bounding.left) {
+                       moveX = -(bounding.left - rect.left + xMargin);
+                       if (side > 0 && rect.right > bounding.right + moveX)
+                           moveX = rect.right - bounding.right + moveX + xMargin;
+                   }
+                   else if (rect.right > bounding.right) {
+                       moveX = rect.right - bounding.right + xMargin;
+                       if (side < 0 && rect.left < bounding.left + moveX)
+                           moveX = -(bounding.left + moveX - rect.left + xMargin);
+                   }
+               }
+               else {
+                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
+                       (x == "start") == ltr ? rect.left - xMargin :
+                           rect.right - (bounding.right - bounding.left) + xMargin;
+                   moveX = targetLeft - bounding.left;
+               }
+               if (moveX || moveY) {
+                   if (top) {
+                       win.scrollBy(moveX, moveY);
+                   }
+                   else {
+                       if (moveY) {
+                           let start = cur.scrollTop;
+                           cur.scrollTop += moveY;
+                           moveY = cur.scrollTop - start;
+                       }
+                       if (moveX) {
+                           let start = cur.scrollLeft;
+                           cur.scrollLeft += moveX;
+                           moveX = cur.scrollLeft - start;
+                       }
+                       rect = { left: rect.left - moveX, top: rect.top - moveY,
+                           right: rect.right - moveX, bottom: rect.bottom - moveY };
+                   }
+               }
+               if (top)
+                   break;
+               cur = cur.assignedSlot || cur.parentNode;
+               x = y = "nearest";
+           }
+           else if (cur.nodeType == 11) { // A shadow root
+               cur = cur.host;
+           }
+           else {
+               break;
+           }
+       }
+   }
+   let DOMSelectionState$2 = class DOMSelectionState {
+       constructor() {
+           this.anchorNode = null;
+           this.anchorOffset = 0;
+           this.focusNode = null;
+           this.focusOffset = 0;
+       }
+       eq(domSel) {
+           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
+               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
+       }
+       setRange(range) {
+           this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
+       }
+       set(anchorNode, anchorOffset, focusNode, focusOffset) {
+           this.anchorNode = anchorNode;
+           this.anchorOffset = anchorOffset;
+           this.focusNode = focusNode;
+           this.focusOffset = focusOffset;
+       }
+   };
+   let preventScrollSupported$2 = null;
+   // Feature-detects support for .focus({preventScroll: true}), and uses
+   // a fallback kludge when not supported.
+   function focusPreventScroll$2(dom) {
+       if (dom.setActive)
+           return dom.setActive(); // in IE
+       if (preventScrollSupported$2)
+           return dom.focus(preventScrollSupported$2);
+       let stack = [];
+       for (let cur = dom; cur; cur = cur.parentNode) {
+           stack.push(cur, cur.scrollTop, cur.scrollLeft);
+           if (cur == cur.ownerDocument)
+               break;
+       }
+       dom.focus(preventScrollSupported$2 == null ? {
+           get preventScroll() {
+               preventScrollSupported$2 = { preventScroll: true };
+               return true;
+           }
+       } : undefined);
+       if (!preventScrollSupported$2) {
+           preventScrollSupported$2 = false;
+           for (let i = 0; i < stack.length;) {
+               let elt = stack[i++], top = stack[i++], left = stack[i++];
+               if (elt.scrollTop != top)
+                   elt.scrollTop = top;
+               if (elt.scrollLeft != left)
+                   elt.scrollLeft = left;
+           }
+       }
+   }
+   let scratchRange$2;
+   function textRange$2(node, from, to = from) {
+       let range = scratchRange$2 || (scratchRange$2 = document.createRange());
+       range.setEnd(node, to);
+       range.setStart(node, from);
+       return range;
+   }
+   function dispatchKey$2(elt, name, code) {
+       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
+       let down = new KeyboardEvent("keydown", options);
+       down.synthetic = true;
+       elt.dispatchEvent(down);
+       let up = new KeyboardEvent("keyup", options);
+       up.synthetic = true;
+       elt.dispatchEvent(up);
+       return down.defaultPrevented || up.defaultPrevented;
+   }
+   function getRoot$2(node) {
+       while (node) {
+           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
+               return node;
+           node = node.assignedSlot || node.parentNode;
+       }
+       return null;
+   }
+   function clearAttributes$2(node) {
+       while (node.attributes.length)
+           node.removeAttributeNode(node.attributes[0]);
+   }
+
+   let DOMPos$2 = class DOMPos {
+       constructor(node, offset, precise = true) {
+           this.node = node;
+           this.offset = offset;
+           this.precise = precise;
+       }
+       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex$2(dom), precise); }
+       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex$2(dom) + 1, precise); }
+   };
+   const noChildren$2 = [];
+   let ContentView$2 = class ContentView {
+       constructor() {
+           this.parent = null;
+           this.dom = null;
+           this.dirty = 2 /* Node */;
+       }
+       get editorView() {
+           if (!this.parent)
+               throw new Error("Accessing view in orphan content view");
+           return this.parent.editorView;
+       }
+       get overrideDOMText() { return null; }
+       get posAtStart() {
+           return this.parent ? this.parent.posBefore(this) : 0;
+       }
+       get posAtEnd() {
+           return this.posAtStart + this.length;
+       }
+       posBefore(view) {
+           let pos = this.posAtStart;
+           for (let child of this.children) {
+               if (child == view)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+           throw new RangeError("Invalid child in posBefore");
+       }
+       posAfter(view) {
+           return this.posBefore(view) + view.length;
+       }
+       // Will return a rectangle directly before (when side < 0), after
+       // (side > 0) or directly on (when the browser supports it) the
+       // given position.
+       coordsAt(_pos, _side) { return null; }
+       sync(track) {
+           if (this.dirty & 2 /* Node */) {
+               let parent = this.dom;
+               let prev = null, next;
+               for (let child of this.children) {
+                   if (child.dirty) {
+                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
+                           let contentView = ContentView.get(next);
+                           if (!contentView || !contentView.parent && contentView.constructor == child.constructor)
+                               child.reuseDOM(next);
+                       }
+                       child.sync(track);
+                       child.dirty = 0 /* Not */;
+                   }
+                   next = prev ? prev.nextSibling : parent.firstChild;
+                   if (track && !track.written && track.node == parent && next != child.dom)
+                       track.written = true;
+                   if (child.dom.parentNode == parent) {
+                       while (next && next != child.dom)
+                           next = rm$1$2(next);
+                   }
+                   else {
+                       parent.insertBefore(child.dom, next);
+                   }
+                   prev = child.dom;
+               }
+               next = prev ? prev.nextSibling : parent.firstChild;
+               if (next && track && track.node == parent)
+                   track.written = true;
+               while (next)
+                   next = rm$1$2(next);
+           }
+           else if (this.dirty & 1 /* Child */) {
+               for (let child of this.children)
+                   if (child.dirty) {
+                       child.sync(track);
+                       child.dirty = 0 /* Not */;
+                   }
+           }
+       }
+       reuseDOM(_dom) { }
+       localPosFromDOM(node, offset) {
+           let after;
+           if (node == this.dom) {
+               after = this.dom.childNodes[offset];
+           }
+           else {
+               let bias = maxOffset$2(node) == 0 ? 0 : offset == 0 ? -1 : 1;
+               for (;;) {
+                   let parent = node.parentNode;
+                   if (parent == this.dom)
+                       break;
+                   if (bias == 0 && parent.firstChild != parent.lastChild) {
+                       if (node == parent.firstChild)
+                           bias = -1;
+                       else
+                           bias = 1;
+                   }
+                   node = parent;
+               }
+               if (bias < 0)
+                   after = node;
+               else
+                   after = node.nextSibling;
+           }
+           if (after == this.dom.firstChild)
+               return 0;
+           while (after && !ContentView.get(after))
+               after = after.nextSibling;
+           if (!after)
+               return this.length;
+           for (let i = 0, pos = 0;; i++) {
+               let child = this.children[i];
+               if (child.dom == after)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+       }
+       domBoundsAround(from, to, offset = 0) {
+           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
+           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos < from && end > to)
+                   return child.domBoundsAround(from, to, pos);
+               if (end >= from && fromI == -1) {
+                   fromI = i;
+                   fromStart = pos;
+               }
+               if (pos > to && child.dom.parentNode == this.dom) {
+                   toI = i;
+                   toEnd = prevEnd;
+                   break;
+               }
+               prevEnd = end;
+               pos = end + child.breakAfter;
+           }
+           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
+               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
+               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
+       }
+       markDirty(andParent = false) {
+           this.dirty |= 2 /* Node */;
+           this.markParentsDirty(andParent);
+       }
+       markParentsDirty(childList) {
+           for (let parent = this.parent; parent; parent = parent.parent) {
+               if (childList)
+                   parent.dirty |= 2 /* Node */;
+               if (parent.dirty & 1 /* Child */)
+                   return;
+               parent.dirty |= 1 /* Child */;
+               childList = false;
+           }
+       }
+       setParent(parent) {
+           if (this.parent != parent) {
+               this.parent = parent;
+               if (this.dirty)
+                   this.markParentsDirty(true);
+           }
+       }
+       setDOM(dom) {
+           if (this.dom)
+               this.dom.cmView = null;
+           this.dom = dom;
+           dom.cmView = this;
+       }
+       get rootView() {
+           for (let v = this;;) {
+               let parent = v.parent;
+               if (!parent)
+                   return v;
+               v = parent;
+           }
+       }
+       replaceChildren(from, to, children = noChildren$2) {
+           this.markDirty();
+           for (let i = from; i < to; i++) {
+               let child = this.children[i];
+               if (child.parent == this)
+                   child.destroy();
+           }
+           this.children.splice(from, to - from, ...children);
+           for (let i = 0; i < children.length; i++)
+               children[i].setParent(this);
+       }
+       ignoreMutation(_rec) { return false; }
+       ignoreEvent(_event) { return false; }
+       childCursor(pos = this.length) {
+           return new ChildCursor$2(this.children, pos, this.children.length);
+       }
+       childPos(pos, bias = 1) {
+           return this.childCursor().findPos(pos, bias);
+       }
+       toString() {
+           let name = this.constructor.name.replace("View", "");
+           return name + (this.children.length ? "(" + this.children.join() + ")" :
+               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
+               (this.breakAfter ? "#" : "");
+       }
+       static get(node) { return node.cmView; }
+       get isEditable() { return true; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           return false;
+       }
+       become(other) { return false; }
+       // When this is a zero-length view with a side, this should return a
+       // number <= 0 to indicate it is before its position, or a
+       // number > 0 when after its position.
+       getSide() { return 0; }
+       destroy() {
+           this.parent = null;
+       }
+   };
+   ContentView$2.prototype.breakAfter = 0;
+   // Remove a DOM node and return its next sibling.
+   function rm$1$2(dom) {
+       let next = dom.nextSibling;
+       dom.parentNode.removeChild(dom);
+       return next;
+   }
+   let ChildCursor$2 = class ChildCursor {
+       constructor(children, pos, i) {
+           this.children = children;
+           this.pos = pos;
+           this.i = i;
+           this.off = 0;
+       }
+       findPos(pos, bias = 1) {
+           for (;;) {
+               if (pos > this.pos || pos == this.pos &&
+                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
+                   this.off = pos - this.pos;
+                   return this;
+               }
+               let next = this.children[--this.i];
+               this.pos -= next.length + next.breakAfter;
+           }
+       }
+   };
+   function replaceRange$2(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
+       let { children } = parent;
+       let before = children.length ? children[fromI] : null;
+       let last = insert.length ? insert[insert.length - 1] : null;
+       let breakAtEnd = last ? last.breakAfter : breakAtStart;
+       // Change within a single child
+       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
+           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
+           return;
+       if (toI < children.length) {
+           let after = children[toI];
+           // Make sure the end of the child after the update is preserved in `after`
+           if (after && toOff < after.length) {
+               // If we're splitting a child, separate part of it to avoid that
+               // being mangled when updating the child before the update.
+               if (fromI == toI) {
+                   after = after.split(toOff);
+                   toOff = 0;
+               }
+               // If the element after the replacement should be merged with
+               // the last replacing element, update `content`
+               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
+                   insert[insert.length - 1] = after;
+               }
+               else {
+                   // Remove the start of the after element, if necessary, and
+                   // add it to `content`.
+                   if (toOff)
+                       after.merge(0, toOff, null, false, 0, openEnd);
+                   insert.push(after);
+               }
+           }
+           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
+               // The element at `toI` is entirely covered by this range.
+               // Preserve its line break, if any.
+               if (last)
+                   last.breakAfter = 1;
+               else
+                   breakAtStart = 1;
+           }
+           // Since we've handled the next element from the current elements
+           // now, make sure `toI` points after that.
+           toI++;
+       }
+       if (before) {
+           before.breakAfter = breakAtStart;
+           if (fromOff > 0) {
+               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
+                   before.breakAfter = insert.shift().breakAfter;
+               }
+               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
+                   before.merge(fromOff, before.length, null, false, openStart, 0);
+               }
+               fromI++;
+           }
+       }
+       // Try to merge widgets on the boundaries of the replacement
+       while (fromI < toI && insert.length) {
+           if (children[toI - 1].become(insert[insert.length - 1])) {
+               toI--;
+               insert.pop();
+               openEnd = insert.length ? 0 : openStart;
+           }
+           else if (children[fromI].become(insert[0])) {
+               fromI++;
+               insert.shift();
+               openStart = insert.length ? 0 : openEnd;
+           }
+           else {
+               break;
+           }
+       }
+       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
+           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
+           fromI--;
+       if (fromI < toI || insert.length)
+           parent.replaceChildren(fromI, toI, insert);
+   }
+   function mergeChildrenInto$2(parent, from, to, insert, openStart, openEnd) {
+       let cur = parent.childCursor();
+       let { i: toI, off: toOff } = cur.findPos(to, 1);
+       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
+       let dLen = from - to;
+       for (let view of insert)
+           dLen += view.length;
+       parent.length += dLen;
+       replaceRange$2(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
+   }
+
+   let nav$2 = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
+   let doc$2 = typeof document != "undefined" ? document : { documentElement: { style: {} } };
+   const ie_edge$2 = /*@__PURE__*//Edge\/(\d+)/.exec(nav$2.userAgent);
+   const ie_upto10$2 = /*@__PURE__*//MSIE \d/.test(nav$2.userAgent);
+   const ie_11up$2 = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav$2.userAgent);
+   const ie$2 = !!(ie_upto10$2 || ie_11up$2 || ie_edge$2);
+   const gecko$2 = !ie$2 && /*@__PURE__*//gecko\/(\d+)/i.test(nav$2.userAgent);
+   const chrome$2 = !ie$2 && /*@__PURE__*//Chrome\/(\d+)/.exec(nav$2.userAgent);
+   const webkit$2 = "webkitFontSmoothing" in doc$2.documentElement.style;
+   const safari$2 = !ie$2 && /*@__PURE__*//Apple Computer/.test(nav$2.vendor);
+   const ios$2 = safari$2 && (/*@__PURE__*//Mobile\/\w+/.test(nav$2.userAgent) || nav$2.maxTouchPoints > 2);
+   var browser$2 = {
+       mac: ios$2 || /*@__PURE__*//Mac/.test(nav$2.platform),
+       windows: /*@__PURE__*//Win/.test(nav$2.platform),
+       linux: /*@__PURE__*//Linux|X11/.test(nav$2.platform),
+       ie: ie$2,
+       ie_version: ie_upto10$2 ? doc$2.documentMode || 6 : ie_11up$2 ? +ie_11up$2[1] : ie_edge$2 ? +ie_edge$2[1] : 0,
+       gecko: gecko$2,
+       gecko_version: gecko$2 ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav$2.userAgent) || [0, 0])[1] : 0,
+       chrome: !!chrome$2,
+       chrome_version: chrome$2 ? +chrome$2[1] : 0,
+       ios: ios$2,
+       android: /*@__PURE__*//Android\b/.test(nav$2.userAgent),
+       webkit: webkit$2,
+       safari: safari$2,
+       webkit_version: webkit$2 ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
+       tabSize: doc$2.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
+   };
+
+   const MaxJoinLen$2 = 256;
+   let TextView$2 = class TextView extends ContentView$2 {
+       constructor(text) {
+           super();
+           this.text = text;
+       }
+       get length() { return this.text.length; }
+       createDOM(textDOM) {
+           this.setDOM(textDOM || document.createTextNode(this.text));
+       }
+       sync(track) {
+           if (!this.dom)
+               this.createDOM();
+           if (this.dom.nodeValue != this.text) {
+               if (track && track.node == this.dom)
+                   track.written = true;
+               this.dom.nodeValue = this.text;
+           }
+       }
+       reuseDOM(dom) {
+           if (dom.nodeType == 3)
+               this.createDOM(dom);
+       }
+       merge(from, to, source) {
+           if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen$2))
+               return false;
+           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = new TextView(this.text.slice(from));
+           this.text = this.text.slice(0, from);
+           this.markDirty();
+           return result;
+       }
+       localPosFromDOM(node, offset) {
+           return node == this.dom ? offset : offset ? this.text.length : 0;
+       }
+       domAtPos(pos) { return new DOMPos$2(this.dom, pos); }
+       domBoundsAround(_from, _to, offset) {
+           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
+       }
+       coordsAt(pos, side) {
+           return textCoords$2(this.dom, pos, side);
+       }
+   };
+   let MarkView$2 = class MarkView extends ContentView$2 {
+       constructor(mark, children = [], length = 0) {
+           super();
+           this.mark = mark;
+           this.children = children;
+           this.length = length;
+           for (let ch of children)
+               ch.setParent(this);
+       }
+       setAttrs(dom) {
+           clearAttributes$2(dom);
+           if (this.mark.class)
+               dom.className = this.mark.class;
+           if (this.mark.attrs)
+               for (let name in this.mark.attrs)
+                   dom.setAttribute(name, this.mark.attrs[name]);
+           return dom;
+       }
+       reuseDOM(node) {
+           if (node.nodeName == this.mark.tagName.toUpperCase()) {
+               this.setDOM(node);
+               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
+           }
+       }
+       sync(track) {
+           if (!this.dom)
+               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
+           else if (this.dirty & 4 /* Attrs */)
+               this.setAttrs(this.dom);
+           super.sync(track);
+       }
+       merge(from, to, source, _hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
+               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
+               return false;
+           mergeChildrenInto$2(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = [], off = 0, detachFrom = -1, i = 0;
+           for (let elt of this.children) {
+               let end = off + elt.length;
+               if (end > from)
+                   result.push(off < from ? elt.split(from - off) : elt);
+               if (detachFrom < 0 && off >= from)
+                   detachFrom = i;
+               off = end;
+               i++;
+           }
+           let length = this.length - from;
+           this.length = from;
+           if (detachFrom > -1) {
+               this.children.length = detachFrom;
+               this.markDirty();
+           }
+           return new MarkView(this.mark, result, length);
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos$2(this.dom, this.children, pos);
+       }
+       coordsAt(pos, side) {
+           return coordsInChildren$2(this, pos, side);
+       }
+   };
+   function textCoords$2(text, pos, side) {
+       let length = text.nodeValue.length;
+       if (pos > length)
+           pos = length;
+       let from = pos, to = pos, flatten = 0;
+       if (pos == 0 && side < 0 || pos == length && side >= 0) {
+           if (!(browser$2.chrome || browser$2.gecko)) { // These browsers reliably return valid rectangles for empty ranges
+               if (pos) {
+                   from--;
+                   flatten = 1;
+               } // FIXME this is wrong in RTL text
+               else if (to < length) {
+                   to++;
+                   flatten = -1;
+               }
+           }
+       }
+       else {
+           if (side < 0)
+               from--;
+           else if (to < length)
+               to++;
+       }
+       let rects = textRange$2(text, from, to).getClientRects();
+       if (!rects.length)
+           return Rect0$1;
+       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
+       if (browser$2.safari && !flatten && rect.width == 0)
+           rect = Array.prototype.find.call(rects, r => r.width) || rect;
+       return flatten ? flattenRect$2(rect, flatten < 0) : rect || null;
+   }
+   // Also used for collapsed ranges that don't have a placeholder widget!
+   let WidgetView$2 = class WidgetView extends ContentView$2 {
+       constructor(widget, length, side) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.side = side;
+           this.prevWidget = null;
+       }
+       static create(widget, length, side) {
+           return new (widget.customView || WidgetView)(widget, length, side);
+       }
+       split(from) {
+           let result = WidgetView.create(this.widget, this.length - from, this.side);
+           this.length -= from;
+           return result;
+       }
+       sync() {
+           if (!this.dom || !this.widget.updateDOM(this.dom)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(this.editorView));
+               this.dom.contentEditable = "false";
+           }
+       }
+       getSide() { return this.side; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       become(other) {
+           if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
+               if (this.widget.constructor == other.widget.constructor) {
+                   if (!this.widget.eq(other.widget))
+                       this.markDirty(true);
+                   if (this.dom && !this.prevWidget)
+                       this.prevWidget = this.widget;
+                   this.widget = other.widget;
+                   return true;
+               }
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       get overrideDOMText() {
+           if (this.length == 0)
+               return Text$2.empty;
+           let top = this;
+           while (top.parent)
+               top = top.parent;
+           let view = top.editorView, text = view && view.state.doc, start = this.posAtStart;
+           return text ? text.slice(start, start + this.length) : Text$2.empty;
+       }
+       domAtPos(pos) {
+           return pos == 0 ? DOMPos$2.before(this.dom) : DOMPos$2.after(this.dom, pos == this.length);
+       }
+       domBoundsAround() { return null; }
+       coordsAt(pos, side) {
+           let rects = this.dom.getClientRects(), rect = null;
+           if (!rects.length)
+               return Rect0$1;
+           for (let i = pos > 0 ? rects.length - 1 : 0;; i += (pos > 0 ? -1 : 1)) {
+               rect = rects[i];
+               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
+                   break;
+           }
+           return (pos == 0 && side > 0 || pos == this.length && side <= 0) ? rect : flattenRect$2(rect, pos == 0);
+       }
+       get isEditable() { return false; }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+   };
+   let CompositionView$1 = class CompositionView extends WidgetView$2 {
+       domAtPos(pos) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return new DOMPos$2(text, Math.min(pos, text.nodeValue.length));
+           return scanCompositionTree$1(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos$2(text, Math.min(p, text.nodeValue.length)));
+       }
+       sync() { this.setDOM(this.widget.toDOM()); }
+       localPosFromDOM(node, offset) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return Math.min(offset, this.length);
+           return posFromDOMInCompositionTree$1(node, offset, topView, text);
+       }
+       ignoreMutation() { return false; }
+       get overrideDOMText() { return null; }
+       coordsAt(pos, side) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return textCoords$2(text, pos, side);
+           return scanCompositionTree$1(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords$2(text, pos, side));
+       }
+       destroy() {
+           var _a;
+           super.destroy();
+           (_a = this.widget.topView) === null || _a === void 0 ? void 0 : _a.destroy();
+       }
+       get isEditable() { return true; }
+   };
+   // Uses the old structure of a chunk of content view frozen for
+   // composition to try and find a reasonable DOM location for the given
+   // offset.
+   function scanCompositionTree$1(pos, side, view, text, enterView, fromText) {
+       if (view instanceof MarkView$2) {
+           for (let child of view.children) {
+               let hasComp = contains$2(child.dom, text);
+               let len = hasComp ? text.nodeValue.length : child.length;
+               if (pos < len || pos == len && child.getSide() <= 0)
+                   return hasComp ? scanCompositionTree$1(pos, side, child, text, enterView, fromText) : enterView(child, pos, side);
+               pos -= len;
+           }
+           return enterView(view, view.length, -1);
+       }
+       else if (view.dom == text) {
+           return fromText(pos, side);
+       }
+       else {
+           return enterView(view, pos, side);
+       }
+   }
+   function posFromDOMInCompositionTree$1(node, offset, view, text) {
+       if (view instanceof MarkView$2) {
+           for (let child of view.children) {
+               let pos = 0, hasComp = contains$2(child.dom, text);
+               if (contains$2(child.dom, node))
+                   return pos + (hasComp ? posFromDOMInCompositionTree$1(node, offset, child, text) : child.localPosFromDOM(node, offset));
+               pos += hasComp ? text.nodeValue.length : child.length;
+           }
+       }
+       else if (view.dom == text) {
+           return Math.min(offset, text.nodeValue.length);
+       }
+       return view.localPosFromDOM(node, offset);
+   }
+   // These are drawn around uneditable widgets to avoid a number of
+   // browser bugs that show up when the cursor is directly next to
+   // uneditable inline content.
+   let WidgetBufferView$2 = class WidgetBufferView extends ContentView$2 {
+       constructor(side) {
+           super();
+           this.side = side;
+       }
+       get length() { return 0; }
+       merge() { return false; }
+       become(other) {
+           return other instanceof WidgetBufferView && other.side == this.side;
+       }
+       split() { return new WidgetBufferView(this.side); }
+       sync() {
+           if (!this.dom) {
+               let dom = document.createElement("img");
+               dom.className = "cm-widgetBuffer";
+               dom.setAttribute("aria-hidden", "true");
+               this.setDOM(dom);
+           }
+       }
+       getSide() { return this.side; }
+       domAtPos(pos) { return DOMPos$2.before(this.dom); }
+       localPosFromDOM() { return 0; }
+       domBoundsAround() { return null; }
+       coordsAt(pos) {
+           let imgRect = this.dom.getBoundingClientRect();
+           // Since the <img> height doesn't correspond to text height, try
+           // to borrow the height from some sibling node.
+           let siblingRect = inlineSiblingRect$1(this, this.side > 0 ? -1 : 1);
+           return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top
+               ? { left: imgRect.left, right: imgRect.right, top: siblingRect.top, bottom: siblingRect.bottom } : imgRect;
+       }
+       get overrideDOMText() {
+           return Text$2.empty;
+       }
+   };
+   TextView$2.prototype.children = WidgetView$2.prototype.children = WidgetBufferView$2.prototype.children = noChildren$2;
+   function inlineSiblingRect$1(view, side) {
+       let parent = view.parent, index = parent ? parent.children.indexOf(view) : -1;
+       while (parent && index >= 0) {
+           if (side < 0 ? index > 0 : index < parent.children.length) {
+               let next = parent.children[index + side];
+               if (next instanceof TextView$2) {
+                   let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
+                   if (nextRect)
+                       return nextRect;
+               }
+               index += side;
+           }
+           else if (parent instanceof MarkView$2 && parent.parent) {
+               index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
+               parent = parent.parent;
+           }
+           else {
+               let last = parent.dom.lastChild;
+               if (last && last.nodeName == "BR")
+                   return last.getClientRects()[0];
+               break;
+           }
+       }
+       return undefined;
+   }
+   function inlineDOMAtPos$2(dom, children, pos) {
+       let i = 0;
+       for (let off = 0; i < children.length; i++) {
+           let child = children[i], end = off + child.length;
+           if (end == off && child.getSide() <= 0)
+               continue;
+           if (pos > off && pos < end && child.dom.parentNode == dom)
+               return child.domAtPos(pos - off);
+           if (pos <= off)
+               break;
+           off = end;
+       }
+       for (; i > 0; i--) {
+           let before = children[i - 1].dom;
+           if (before.parentNode == dom)
+               return DOMPos$2.after(before);
+       }
+       return new DOMPos$2(dom, 0);
+   }
+   // Assumes `view`, if a mark view, has precisely 1 child.
+   function joinInlineInto$2(parent, view, open) {
+       let last, { children } = parent;
+       if (open > 0 && view instanceof MarkView$2 && children.length &&
+           (last = children[children.length - 1]) instanceof MarkView$2 && last.mark.eq(view.mark)) {
+           joinInlineInto$2(last, view.children[0], open - 1);
+       }
+       else {
+           children.push(view);
+           view.setParent(parent);
+       }
+       parent.length += view.length;
+   }
+   function coordsInChildren$2(view, pos, side) {
+       for (let off = 0, i = 0; i < view.children.length; i++) {
+           let child = view.children[i], end = off + child.length, next;
+           if ((side <= 0 || end == view.length || child.getSide() > 0 ? end >= pos : end > pos) &&
+               (pos < end || i + 1 == view.children.length || (next = view.children[i + 1]).length || next.getSide() > 0)) {
+               let flatten = 0;
+               if (end == off) {
+                   if (child.getSide() <= 0)
+                       continue;
+                   flatten = side = -child.getSide();
+               }
+               let rect = child.coordsAt(Math.max(0, pos - off), side);
+               return flatten && rect ? flattenRect$2(rect, side < 0) : rect;
+           }
+           off = end;
+       }
+       let last = view.dom.lastChild;
+       if (!last)
+           return view.dom.getBoundingClientRect();
+       let rects = clientRectsFor$2(last);
+       return rects[rects.length - 1] || null;
+   }
+
+   function combineAttrs$2(source, target) {
+       for (let name in source) {
+           if (name == "class" && target.class)
+               target.class += " " + source.class;
+           else if (name == "style" && target.style)
+               target.style += ";" + source.style;
+           else
+               target[name] = source[name];
+       }
+       return target;
+   }
+   function attrsEq$2(a, b) {
+       if (a == b)
+           return true;
+       if (!a || !b)
+           return false;
+       let keysA = Object.keys(a), keysB = Object.keys(b);
+       if (keysA.length != keysB.length)
+           return false;
+       for (let key of keysA) {
+           if (keysB.indexOf(key) == -1 || a[key] !== b[key])
+               return false;
+       }
+       return true;
+   }
+   function updateAttrs$2(dom, prev, attrs) {
+       let changed = null;
+       if (prev)
+           for (let name in prev)
+               if (!(attrs && name in attrs))
+                   dom.removeAttribute(changed = name);
+       if (attrs)
+           for (let name in attrs)
+               if (!(prev && prev[name] == attrs[name]))
+                   dom.setAttribute(changed = name, attrs[name]);
+       return !!changed;
+   }
+
+   /**
+   Widgets added to the content are described by subclasses of this
+   class. Using a description object like that makes it possible to
+   delay creating of the DOM structure for a widget until it is
+   needed, and to avoid redrawing widgets even if the decorations
+   that define them are recreated.
+   */
+   let WidgetType$2 = class WidgetType {
+       /**
+       Compare this instance to another instance of the same type.
+       (TypeScript can't express this, but only instances of the same
+       specific class will be passed to this method.) This is used to
+       avoid redrawing widgets when they are replaced by a new
+       decoration of the same type. The default implementation just
+       returns `false`, which will cause new instances of the widget to
+       always be redrawn.
+       */
+       eq(widget) { return false; }
+       /**
+       Update a DOM element created by a widget of the same type (but
+       different, non-`eq` content) to reflect this widget. May return
+       true to indicate that it could update, false to indicate it
+       couldn't (in which case the widget will be redrawn). The default
+       implementation just returns false.
+       */
+       updateDOM(dom) { return false; }
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       The estimated height this widget will have, to be used when
+       estimating the height of content that hasn't been drawn. May
+       return -1 to indicate you don't know. The default implementation
+       returns -1.
+       */
+       get estimatedHeight() { return -1; }
+       /**
+       Can be used to configure which kinds of events inside the widget
+       should be ignored by the editor. The default is to ignore all
+       events.
+       */
+       ignoreEvent(event) { return true; }
+       /**
+       @internal
+       */
+       get customView() { return null; }
+       /**
+       This is called when the an instance of the widget is removed
+       from the editor view.
+       */
+       destroy(dom) { }
+   };
+   /**
+   The different types of blocks that can occur in an editor view.
+   */
+   var BlockType$2 = /*@__PURE__*/(function (BlockType) {
+       /**
+       A line of text.
+       */
+       BlockType[BlockType["Text"] = 0] = "Text";
+       /**
+       A block widget associated with the position after it.
+       */
+       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
+       /**
+       A block widget associated with the position before it.
+       */
+       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
+       /**
+       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
+       */
+       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
+   return BlockType})(BlockType$2 || (BlockType$2 = {}));
+   /**
+   A decoration provides information on how to draw or style a piece
+   of content. You'll usually use it wrapped in a
+   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
+   @nonabstract
+   */
+   let Decoration$2 = class Decoration extends RangeValue$2 {
+       constructor(
+       /**
+       @internal
+       */
+       startSide, 
+       /**
+       @internal
+       */
+       endSide, 
+       /**
+       @internal
+       */
+       widget, 
+       /**
+       The config object used to create this decoration. You can
+       include additional properties in there to store metadata about
+       your decoration.
+       */
+       spec) {
+           super();
+           this.startSide = startSide;
+           this.endSide = endSide;
+           this.widget = widget;
+           this.spec = spec;
+       }
+       /**
+       @internal
+       */
+       get heightRelevant() { return false; }
+       /**
+       Create a mark decoration, which influences the styling of the
+       content in its range. Nested mark decorations will cause nested
+       DOM elements to be created. Nesting order is determined by
+       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
+       the higher-precedence decorations creating the inner DOM nodes.
+       Such elements are split on line boundaries and on the boundaries
+       of lower-precedence decorations.
+       */
+       static mark(spec) {
+           return new MarkDecoration$2(spec);
+       }
+       /**
+       Create a widget decoration, which displays a DOM element at the
+       given position.
+       */
+       static widget(spec) {
+           let side = spec.side || 0, block = !!spec.block;
+           side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
+           return new PointDecoration$2(spec, side, side, block, spec.widget || null, false);
+       }
+       /**
+       Create a replace decoration which replaces the given range with
+       a widget, or simply hides it.
+       */
+       static replace(spec) {
+           let block = !!spec.block, startSide, endSide;
+           if (spec.isBlockGap) {
+               startSide = -500000000 /* GapStart */;
+               endSide = 400000000 /* GapEnd */;
+           }
+           else {
+               let { start, end } = getInclusive$2(spec, block);
+               startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
+               endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
+           }
+           return new PointDecoration$2(spec, startSide, endSide, block, spec.widget || null, true);
+       }
+       /**
+       Create a line decoration, which can add DOM attributes to the
+       line starting at the given position.
+       */
+       static line(spec) {
+           return new LineDecoration$2(spec);
+       }
+       /**
+       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
+       decorated range or ranges. If the ranges aren't already sorted,
+       pass `true` for `sort` to make the library sort them for you.
+       */
+       static set(of, sort = false) {
+           return RangeSet$2.of(of, sort);
+       }
+       /**
+       @internal
+       */
+       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
+   };
+   /**
+   The empty set of decorations.
+   */
+   Decoration$2.none = RangeSet$2.empty;
+   let MarkDecoration$2 = class MarkDecoration extends Decoration$2 {
+       constructor(spec) {
+           let { start, end } = getInclusive$2(spec);
+           super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
+           this.tagName = spec.tagName || "span";
+           this.class = spec.class || "";
+           this.attrs = spec.attributes || null;
+       }
+       eq(other) {
+           return this == other ||
+               other instanceof MarkDecoration &&
+                   this.tagName == other.tagName &&
+                   this.class == other.class &&
+                   attrsEq$2(this.attrs, other.attrs);
+       }
+       range(from, to = from) {
+           if (from >= to)
+               throw new RangeError("Mark decorations may not be empty");
+           return super.range(from, to);
+       }
+   };
+   MarkDecoration$2.prototype.point = false;
+   let LineDecoration$2 = class LineDecoration extends Decoration$2 {
+       constructor(spec) {
+           super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
+       }
+       eq(other) {
+           return other instanceof LineDecoration && attrsEq$2(this.spec.attributes, other.spec.attributes);
+       }
+       range(from, to = from) {
+           if (to != from)
+               throw new RangeError("Line decoration ranges must be zero-length");
+           return super.range(from, to);
+       }
+   };
+   LineDecoration$2.prototype.mapMode = MapMode$2.TrackBefore;
+   LineDecoration$2.prototype.point = true;
+   let PointDecoration$2 = class PointDecoration extends Decoration$2 {
+       constructor(spec, startSide, endSide, block, widget, isReplace) {
+           super(startSide, endSide, widget, spec);
+           this.block = block;
+           this.isReplace = isReplace;
+           this.mapMode = !block ? MapMode$2.TrackDel : startSide <= 0 ? MapMode$2.TrackBefore : MapMode$2.TrackAfter;
+       }
+       // Only relevant when this.block == true
+       get type() {
+           return this.startSide < this.endSide ? BlockType$2.WidgetRange
+               : this.startSide <= 0 ? BlockType$2.WidgetBefore : BlockType$2.WidgetAfter;
+       }
+       get heightRelevant() { return this.block || !!this.widget && this.widget.estimatedHeight >= 5; }
+       eq(other) {
+           return other instanceof PointDecoration &&
+               widgetsEq$2(this.widget, other.widget) &&
+               this.block == other.block &&
+               this.startSide == other.startSide && this.endSide == other.endSide;
+       }
+       range(from, to = from) {
+           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
+               throw new RangeError("Invalid range for replacement decoration");
+           if (!this.isReplace && to != from)
+               throw new RangeError("Widget decorations can only have zero-length ranges");
+           return super.range(from, to);
+       }
+   };
+   PointDecoration$2.prototype.point = true;
+   function getInclusive$2(spec, block = false) {
+       let { inclusiveStart: start, inclusiveEnd: end } = spec;
+       if (start == null)
+           start = spec.inclusive;
+       if (end == null)
+           end = spec.inclusive;
+       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
+   }
+   function widgetsEq$2(a, b) {
+       return a == b || !!(a && b && a.compare(b));
+   }
+   function addRange$2(from, to, ranges, margin = 0) {
+       let last = ranges.length - 1;
+       if (last >= 0 && ranges[last] + margin >= from)
+           ranges[last] = Math.max(ranges[last], to);
+       else
+           ranges.push(from, to);
+   }
+
+   let LineView$2 = class LineView extends ContentView$2 {
+       constructor() {
+           super(...arguments);
+           this.children = [];
+           this.length = 0;
+           this.prevAttrs = undefined;
+           this.attrs = null;
+           this.breakAfter = 0;
+       }
+       // Consumes source
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source) {
+               if (!(source instanceof LineView))
+                   return false;
+               if (!this.dom)
+                   source.transferDOM(this); // Reuse source.dom when appropriate
+           }
+           if (hasStart)
+               this.setDeco(source ? source.attrs : null);
+           mergeChildrenInto$2(this, from, to, source ? source.children : [], openStart, openEnd);
+           return true;
+       }
+       split(at) {
+           let end = new LineView;
+           end.breakAfter = this.breakAfter;
+           if (this.length == 0)
+               return end;
+           let { i, off } = this.childPos(at);
+           if (off) {
+               end.append(this.children[i].split(off), 0);
+               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
+               i++;
+           }
+           for (let j = i; j < this.children.length; j++)
+               end.append(this.children[j], 0);
+           while (i > 0 && this.children[i - 1].length == 0)
+               this.children[--i].destroy();
+           this.children.length = i;
+           this.markDirty();
+           this.length = at;
+           return end;
+       }
+       transferDOM(other) {
+           if (!this.dom)
+               return;
+           this.markDirty();
+           other.setDOM(this.dom);
+           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
+           this.prevAttrs = undefined;
+           this.dom = null;
+       }
+       setDeco(attrs) {
+           if (!attrsEq$2(this.attrs, attrs)) {
+               if (this.dom) {
+                   this.prevAttrs = this.attrs;
+                   this.markDirty();
+               }
+               this.attrs = attrs;
+           }
+       }
+       append(child, openStart) {
+           joinInlineInto$2(this, child, openStart);
+       }
+       // Only called when building a line view in ContentBuilder
+       addLineDeco(deco) {
+           let attrs = deco.spec.attributes, cls = deco.spec.class;
+           if (attrs)
+               this.attrs = combineAttrs$2(attrs, this.attrs || {});
+           if (cls)
+               this.attrs = combineAttrs$2({ class: cls }, this.attrs || {});
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos$2(this.dom, this.children, pos);
+       }
+       reuseDOM(node) {
+           if (node.nodeName == "DIV") {
+               this.setDOM(node);
+               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
+           }
+       }
+       sync(track) {
+           var _a;
+           if (!this.dom) {
+               this.setDOM(document.createElement("div"));
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           else if (this.dirty & 4 /* Attrs */) {
+               clearAttributes$2(this.dom);
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           if (this.prevAttrs !== undefined) {
+               updateAttrs$2(this.dom, this.prevAttrs, this.attrs);
+               this.dom.classList.add("cm-line");
+               this.prevAttrs = undefined;
+           }
+           super.sync(track);
+           let last = this.dom.lastChild;
+           while (last && ContentView$2.get(last) instanceof MarkView$2)
+               last = last.lastChild;
+           if (!last || !this.length ||
+               last.nodeName != "BR" && ((_a = ContentView$2.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
+                   (!browser$2.ios || !this.children.some(ch => ch instanceof TextView$2))) {
+               let hack = document.createElement("BR");
+               hack.cmIgnore = true;
+               this.dom.appendChild(hack);
+           }
+       }
+       measureTextSize() {
+           if (this.children.length == 0 || this.length > 20)
+               return null;
+           let totalWidth = 0;
+           for (let child of this.children) {
+               if (!(child instanceof TextView$2))
+                   return null;
+               let rects = clientRectsFor$2(child.dom);
+               if (rects.length != 1)
+                   return null;
+               totalWidth += rects[0].width;
+           }
+           return { lineHeight: this.dom.getBoundingClientRect().height,
+               charWidth: totalWidth / this.length };
+       }
+       coordsAt(pos, side) {
+           return coordsInChildren$2(this, pos, side);
+       }
+       become(_other) { return false; }
+       get type() { return BlockType$2.Text; }
+       static find(docView, pos) {
+           for (let i = 0, off = 0; i < docView.children.length; i++) {
+               let block = docView.children[i], end = off + block.length;
+               if (end >= pos) {
+                   if (block instanceof LineView)
+                       return block;
+                   if (end > pos)
+                       break;
+               }
+               off = end + block.breakAfter;
+           }
+           return null;
+       }
+   };
+   let BlockWidgetView$2 = class BlockWidgetView extends ContentView$2 {
+       constructor(widget, length, type) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.type = type;
+           this.breakAfter = 0;
+           this.prevWidget = null;
+       }
+       merge(from, to, source, _takeDeco, openStart, openEnd) {
+           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       domAtPos(pos) {
+           return pos == 0 ? DOMPos$2.before(this.dom) : DOMPos$2.after(this.dom, pos == this.length);
+       }
+       split(at) {
+           let len = this.length - at;
+           this.length = at;
+           let end = new BlockWidgetView(this.widget, len, this.type);
+           end.breakAfter = this.breakAfter;
+           return end;
+       }
+       get children() { return noChildren$2; }
+       sync() {
+           if (!this.dom || !this.widget.updateDOM(this.dom)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(this.editorView));
+               this.dom.contentEditable = "false";
+           }
+       }
+       get overrideDOMText() {
+           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$2.empty;
+       }
+       domBoundsAround() { return null; }
+       become(other) {
+           if (other instanceof BlockWidgetView && other.type == this.type &&
+               other.widget.constructor == this.widget.constructor) {
+               if (!other.widget.eq(this.widget))
+                   this.markDirty(true);
+               if (this.dom && !this.prevWidget)
+                   this.prevWidget = this.widget;
+               this.widget = other.widget;
+               this.length = other.length;
+               this.breakAfter = other.breakAfter;
+               return true;
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+   };
+
+   let ContentBuilder$2 = class ContentBuilder {
+       constructor(doc, pos, end, disallowBlockEffectsFor) {
+           this.doc = doc;
+           this.pos = pos;
+           this.end = end;
+           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
+           this.content = [];
+           this.curLine = null;
+           this.breakAtStart = 0;
+           this.pendingBuffer = 0 /* No */;
+           // Set to false directly after a widget that covers the position after it
+           this.atCursorPos = true;
+           this.openStart = -1;
+           this.openEnd = -1;
+           this.text = "";
+           this.textOff = 0;
+           this.cursor = doc.iter();
+           this.skip = pos;
+       }
+       posCovered() {
+           if (this.content.length == 0)
+               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
+           let last = this.content[this.content.length - 1];
+           return !last.breakAfter && !(last instanceof BlockWidgetView$2 && last.type == BlockType$2.WidgetBefore);
+       }
+       getLine() {
+           if (!this.curLine) {
+               this.content.push(this.curLine = new LineView$2);
+               this.atCursorPos = true;
+           }
+           return this.curLine;
+       }
+       flushBuffer(active) {
+           if (this.pendingBuffer) {
+               this.curLine.append(wrapMarks$2(new WidgetBufferView$2(-1), active), active.length);
+               this.pendingBuffer = 0 /* No */;
+           }
+       }
+       addBlockWidget(view) {
+           this.flushBuffer([]);
+           this.curLine = null;
+           this.content.push(view);
+       }
+       finish(openEnd) {
+           if (!openEnd)
+               this.flushBuffer([]);
+           else
+               this.pendingBuffer = 0 /* No */;
+           if (!this.posCovered())
+               this.getLine();
+       }
+       buildText(length, active, openStart) {
+           while (length > 0) {
+               if (this.textOff == this.text.length) {
+                   let { value, lineBreak, done } = this.cursor.next(this.skip);
+                   this.skip = 0;
+                   if (done)
+                       throw new Error("Ran out of text content when drawing inline views");
+                   if (lineBreak) {
+                       if (!this.posCovered())
+                           this.getLine();
+                       if (this.content.length)
+                           this.content[this.content.length - 1].breakAfter = 1;
+                       else
+                           this.breakAtStart = 1;
+                       this.flushBuffer([]);
+                       this.curLine = null;
+                       length--;
+                       continue;
+                   }
+                   else {
+                       this.text = value;
+                       this.textOff = 0;
+                   }
+               }
+               let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
+               this.flushBuffer(active.slice(0, openStart));
+               this.getLine().append(wrapMarks$2(new TextView$2(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
+               this.atCursorPos = true;
+               this.textOff += take;
+               length -= take;
+               openStart = 0;
+           }
+       }
+       span(from, to, active, openStart) {
+           this.buildText(to - from, active, openStart);
+           this.pos = to;
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       point(from, to, deco, active, openStart, index) {
+           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration$2) {
+               if (deco.block)
+                   throw new RangeError("Block decorations may not be specified via plugins");
+               if (to > this.doc.lineAt(this.pos).to)
+                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
+           }
+           let len = to - from;
+           if (deco instanceof PointDecoration$2) {
+               if (deco.block) {
+                   let { type } = deco;
+                   if (type == BlockType$2.WidgetAfter && !this.posCovered())
+                       this.getLine();
+                   this.addBlockWidget(new BlockWidgetView$2(deco.widget || new NullWidget$2("div"), len, type));
+               }
+               else {
+                   let view = WidgetView$2.create(deco.widget || new NullWidget$2("span"), len, deco.startSide);
+                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
+                   let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
+                   let line = this.getLine();
+                   if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
+                       this.pendingBuffer = 0 /* No */;
+                   this.flushBuffer(active);
+                   if (cursorBefore) {
+                       line.append(wrapMarks$2(new WidgetBufferView$2(1), active), openStart);
+                       openStart = active.length + Math.max(0, openStart - active.length);
+                   }
+                   line.append(wrapMarks$2(view, active), openStart);
+                   this.atCursorPos = cursorAfter;
+                   this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
+               }
+           }
+           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
+               this.getLine().addLineDeco(deco);
+           }
+           if (len) {
+               // Advance the iterator past the replaced content
+               if (this.textOff + len <= this.text.length) {
+                   this.textOff += len;
+               }
+               else {
+                   this.skip += len - (this.text.length - this.textOff);
+                   this.text = "";
+                   this.textOff = 0;
+               }
+               this.pos = to;
+           }
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       static build(text, from, to, decorations, dynamicDecorationMap) {
+           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
+           builder.openEnd = RangeSet$2.spans(decorations, from, to, builder);
+           if (builder.openStart < 0)
+               builder.openStart = builder.openEnd;
+           builder.finish(builder.openEnd);
+           return builder;
+       }
+   };
+   function wrapMarks$2(view, active) {
+       for (let mark of active)
+           view = new MarkView$2(mark, [view], view.length);
+       return view;
+   }
+   let NullWidget$2 = class NullWidget extends WidgetType$2 {
+       constructor(tag) {
+           super();
+           this.tag = tag;
+       }
+       eq(other) { return other.tag == this.tag; }
+       toDOM() { return document.createElement(this.tag); }
+       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
+   };
+
+   const clickAddsSelectionRange$2 = /*@__PURE__*/Facet$2.define();
+   const dragMovesSelection$1$2 = /*@__PURE__*/Facet$2.define();
+   const mouseSelectionStyle$2 = /*@__PURE__*/Facet$2.define();
+   const exceptionSink$2 = /*@__PURE__*/Facet$2.define();
+   const updateListener$2 = /*@__PURE__*/Facet$2.define();
+   const inputHandler$3 = /*@__PURE__*/Facet$2.define();
+   const perLineTextDirection$2 = /*@__PURE__*/Facet$2.define({
+       combine: values => values.some(x => x)
+   });
+   let ScrollTarget$2 = class ScrollTarget {
+       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5) {
+           this.range = range;
+           this.y = y;
+           this.x = x;
+           this.yMargin = yMargin;
+           this.xMargin = xMargin;
+       }
+       map(changes) {
+           return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);
+       }
+   };
+   const scrollIntoView$4 = /*@__PURE__*/StateEffect$2.define({ map: (t, ch) => t.map(ch) });
+   /**
+   Log or report an unhandled exception in client code. Should
+   probably only be used by extension code that allows client code to
+   provide functions, and calls those functions in a context where an
+   exception can't be propagated to calling code in a reasonable way
+   (for example when in an event handler).
+
+   Either calls a handler registered with
+   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
+   `window.onerror`, if defined, or `console.error` (in which case
+   it'll pass `context`, when given, as first argument).
+   */
+   function logException$2(state, exception, context) {
+       let handler = state.facet(exceptionSink$2);
+       if (handler.length)
+           handler[0](exception);
+       else if (window.onerror)
+           window.onerror(String(exception), context, undefined, undefined, exception);
+       else if (context)
+           console.error(context + ":", exception);
+       else
+           console.error(exception);
+   }
+   const editable$2 = /*@__PURE__*/Facet$2.define({ combine: values => values.length ? values[0] : true });
+   let nextPluginID$2 = 0;
+   const viewPlugin$2 = /*@__PURE__*/Facet$2.define();
+   /**
+   View plugins associate stateful values with a view. They can
+   influence the way the content is drawn, and are notified of things
+   that happen in the view.
+   */
+   let ViewPlugin$2 = class ViewPlugin {
+       constructor(
+       /**
+       @internal
+       */
+       id, 
+       /**
+       @internal
+       */
+       create, 
+       /**
+       @internal
+       */
+       domEventHandlers, buildExtensions) {
+           this.id = id;
+           this.create = create;
+           this.domEventHandlers = domEventHandlers;
+           this.extension = buildExtensions(this);
+       }
+       /**
+       Define a plugin from a constructor function that creates the
+       plugin's value, given an editor view.
+       */
+       static define(create, spec) {
+           const { eventHandlers, provide, decorations: deco } = spec || {};
+           return new ViewPlugin(nextPluginID$2++, create, eventHandlers, plugin => {
+               let ext = [viewPlugin$2.of(plugin)];
+               if (deco)
+                   ext.push(decorations$2.of(view => {
+                       let pluginInst = view.plugin(plugin);
+                       return pluginInst ? deco(pluginInst) : Decoration$2.none;
+                   }));
+               if (provide)
+                   ext.push(provide(plugin));
+               return ext;
+           });
+       }
+       /**
+       Create a plugin for a class whose constructor takes a single
+       editor view as argument.
+       */
+       static fromClass(cls, spec) {
+           return ViewPlugin.define(view => new cls(view), spec);
+       }
+   };
+   let PluginInstance$2 = class PluginInstance {
+       constructor(spec) {
+           this.spec = spec;
+           // When starting an update, all plugins have this field set to the
+           // update object, indicating they need to be updated. When finished
+           // updating, it is set to `false`. Retrieving a plugin that needs to
+           // be updated with `view.plugin` forces an eager update.
+           this.mustUpdate = null;
+           // This is null when the plugin is initially created, but
+           // initialized on the first update.
+           this.value = null;
+       }
+       update(view) {
+           if (!this.value) {
+               if (this.spec) {
+                   try {
+                       this.value = this.spec.create(view);
+                   }
+                   catch (e) {
+                       logException$2(view.state, e, "CodeMirror plugin crashed");
+                       this.deactivate();
+                   }
+               }
+           }
+           else if (this.mustUpdate) {
+               let update = this.mustUpdate;
+               this.mustUpdate = null;
+               if (this.value.update) {
+                   try {
+                       this.value.update(update);
+                   }
+                   catch (e) {
+                       logException$2(update.state, e, "CodeMirror plugin crashed");
+                       if (this.value.destroy)
+                           try {
+                               this.value.destroy();
+                           }
+                           catch (_) { }
+                       this.deactivate();
+                   }
+               }
+           }
+           return this;
+       }
+       destroy(view) {
+           var _a;
+           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
+               try {
+                   this.value.destroy();
+               }
+               catch (e) {
+                   logException$2(view.state, e, "CodeMirror plugin crashed");
+               }
+           }
+       }
+       deactivate() {
+           this.spec = this.value = null;
+       }
+   };
+   const editorAttributes$2 = /*@__PURE__*/Facet$2.define();
+   const contentAttributes$2 = /*@__PURE__*/Facet$2.define();
+   // Provide decorations
+   const decorations$2 = /*@__PURE__*/Facet$2.define();
+   const atomicRanges$2 = /*@__PURE__*/Facet$2.define();
+   const scrollMargins$2 = /*@__PURE__*/Facet$2.define();
+   const styleModule$2 = /*@__PURE__*/Facet$2.define();
+   let ChangedRange$2 = class ChangedRange {
+       constructor(fromA, toA, fromB, toB) {
+           this.fromA = fromA;
+           this.toA = toA;
+           this.fromB = fromB;
+           this.toB = toB;
+       }
+       join(other) {
+           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
+       }
+       addToSet(set) {
+           let i = set.length, me = this;
+           for (; i > 0; i--) {
+               let range = set[i - 1];
+               if (range.fromA > me.toA)
+                   continue;
+               if (range.toA < me.fromA)
+                   break;
+               me = me.join(range);
+               set.splice(i - 1, 1);
+           }
+           set.splice(i, 0, me);
+           return set;
+       }
+       static extendWithRanges(diff, ranges) {
+           if (ranges.length == 0)
+               return diff;
+           let result = [];
+           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
+               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
+               let end = next ? next.fromB : 1e9;
+               while (rI < ranges.length && ranges[rI] < end) {
+                   let from = ranges[rI], to = ranges[rI + 1];
+                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
+                   if (fromB <= toB)
+                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
+                   if (to > end)
+                       break;
+                   else
+                       rI += 2;
+               }
+               if (!next)
+                   return result;
+               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
+               posA = next.toA;
+               posB = next.toB;
+           }
+       }
+   };
+   /**
+   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
+   class, which describe what happened, whenever the view is updated.
+   */
+   let ViewUpdate$2 = class ViewUpdate {
+       constructor(
+       /**
+       The editor view that the update is associated with.
+       */
+       view, 
+       /**
+       The new editor state.
+       */
+       state, 
+       /**
+       The transactions involved in the update. May be empty.
+       */
+       transactions) {
+           this.view = view;
+           this.state = state;
+           this.transactions = transactions;
+           /**
+           @internal
+           */
+           this.flags = 0;
+           this.startState = view.state;
+           this.changes = ChangeSet$2.empty(this.startState.doc.length);
+           for (let tr of transactions)
+               this.changes = this.changes.compose(tr.changes);
+           let changedRanges = [];
+           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange$2(fromA, toA, fromB, toB)));
+           this.changedRanges = changedRanges;
+           let focus = view.hasFocus;
+           if (focus != view.inputState.notifiedFocused) {
+               view.inputState.notifiedFocused = focus;
+               this.flags |= 1 /* Focus */;
+           }
+       }
+       /**
+       @internal
+       */
+       static create(view, state, transactions) {
+           return new ViewUpdate(view, state, transactions);
+       }
+       /**
+       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
+       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
+       update.
+       */
+       get viewportChanged() {
+           return (this.flags & 4 /* Viewport */) > 0;
+       }
+       /**
+       Indicates whether the height of a block element in the editor
+       changed in this update.
+       */
+       get heightChanged() {
+           return (this.flags & 2 /* Height */) > 0;
+       }
+       /**
+       Returns true when the document was modified or the size of the
+       editor, or elements within the editor, changed.
+       */
+       get geometryChanged() {
+           return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
+       }
+       /**
+       True when this update indicates a focus change.
+       */
+       get focusChanged() {
+           return (this.flags & 1 /* Focus */) > 0;
+       }
+       /**
+       Whether the document changed in this update.
+       */
+       get docChanged() {
+           return !this.changes.empty;
+       }
+       /**
+       Whether the selection was explicitly set in this update.
+       */
+       get selectionSet() {
+           return this.transactions.some(tr => tr.selection);
+       }
+       /**
+       @internal
+       */
+       get empty() { return this.flags == 0 && this.transactions.length == 0; }
+   };
+
+   /**
+   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+   */
+   var Direction$2 = /*@__PURE__*/(function (Direction) {
+       // (These are chosen to match the base levels, in bidi algorithm
+       // terms, of spans in that direction.)
+       /**
+       Left-to-right.
+       */
+       Direction[Direction["LTR"] = 0] = "LTR";
+       /**
+       Right-to-left.
+       */
+       Direction[Direction["RTL"] = 1] = "RTL";
+   return Direction})(Direction$2 || (Direction$2 = {}));
+   const LTR$2 = Direction$2.LTR, RTL$2 = Direction$2.RTL;
+   // Decode a string with each type encoded as log2(type)
+   function dec$2(str) {
+       let result = [];
+       for (let i = 0; i < str.length; i++)
+           result.push(1 << +str[i]);
+       return result;
+   }
+   // Character types for codepoints 0 to 0xf8
+   const LowTypes$2 = /*@__PURE__*/dec$2("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
+   // Character types for codepoints 0x600 to 0x6f9
+   const ArabicTypes$2 = /*@__PURE__*/dec$2("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
+   const Brackets$2 = /*@__PURE__*/Object.create(null), BracketStack$2 = [];
+   // There's a lot more in
+   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
+   // which are left out to keep code size down.
+   for (let p of ["()", "[]", "{}"]) {
+       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
+       Brackets$2[l] = r;
+       Brackets$2[r] = -l;
+   }
+   function charType$2(ch) {
+       return ch <= 0xf7 ? LowTypes$2[ch] :
+           0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
+               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes$2[ch - 0x600] :
+                   0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
+                       0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
+                           ch == 0x200c ? 256 /* NI */ : 1 /* L */;
+   }
+   const BidiRE$2 = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
+   /**
+   Represents a contiguous range of text that has a single direction
+   (as in left-to-right or right-to-left).
+   */
+   let BidiSpan$2 = class BidiSpan {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the span (relative to the start of the line).
+       */
+       from, 
+       /**
+       The end of the span.
+       */
+       to, 
+       /**
+       The ["bidi
+       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
+       of the span (in this context, 0 means
+       left-to-right, 1 means right-to-left, 2 means left-to-right
+       number inside right-to-left text).
+       */
+       level) {
+           this.from = from;
+           this.to = to;
+           this.level = level;
+       }
+       /**
+       The direction of this span.
+       */
+       get dir() { return this.level % 2 ? RTL$2 : LTR$2; }
+       /**
+       @internal
+       */
+       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
+       /**
+       @internal
+       */
+       static find(order, index, level, assoc) {
+           let maybe = -1;
+           for (let i = 0; i < order.length; i++) {
+               let span = order[i];
+               if (span.from <= index && span.to >= index) {
+                   if (span.level == level)
+                       return i;
+                   // When multiple spans match, if assoc != 0, take the one that
+                   // covers that side, otherwise take the one with the minimum
+                   // level.
+                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
+                       maybe = i;
+               }
+           }
+           if (maybe < 0)
+               throw new RangeError("Index out of range");
+           return maybe;
+       }
+   };
+   // Reused array of character types
+   const types$2 = [];
+   function computeOrder$2(line, direction) {
+       let len = line.length, outerType = direction == LTR$2 ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR$2 ? 2 /* R */ : 1 /* L */;
+       if (!line || outerType == 1 /* L */ && !BidiRE$2.test(line))
+           return trivialOrder$2(len);
+       // W1. Examine each non-spacing mark (NSM) in the level run, and
+       // change the type of the NSM to the type of the previous
+       // character. If the NSM is at the start of the level run, it will
+       // get the type of sor.
+       // W2. Search backwards from each instance of a European number
+       // until the first strong type (R, L, AL, or sor) is found. If an
+       // AL is found, change the type of the European number to Arabic
+       // number.
+       // W3. Change all ALs to R.
+       // (Left after this: L, R, EN, AN, ET, CS, NI)
+       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
+           let type = charType$2(line.charCodeAt(i));
+           if (type == 512 /* NSM */)
+               type = prev;
+           else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
+               type = 16 /* AN */;
+           types$2[i] = type == 4 /* AL */ ? 2 /* R */ : type;
+           if (type & 7 /* Strong */)
+               prevStrong = type;
+           prev = type;
+       }
+       // W5. A sequence of European terminators adjacent to European
+       // numbers changes to all European numbers.
+       // W6. Otherwise, separators and terminators change to Other
+       // Neutral.
+       // W7. Search backwards from each instance of a European number
+       // until the first strong type (R, L, or sor) is found. If an L is
+       // found, then change the type of the European number to L.
+       // (Left after this: L, R, EN+AN, NI)
+       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
+           let type = types$2[i];
+           if (type == 128 /* CS */) {
+               if (i < len - 1 && prev == types$2[i + 1] && (prev & 24 /* Num */))
+                   type = types$2[i] = prev;
+               else
+                   types$2[i] = 256 /* NI */;
+           }
+           else if (type == 64 /* ET */) {
+               let end = i + 1;
+               while (end < len && types$2[end] == 64 /* ET */)
+                   end++;
+               let replace = (i && prev == 8 /* EN */) || (end < len && types$2[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
+               for (let j = i; j < end; j++)
+                   types$2[j] = replace;
+               i = end - 1;
+           }
+           else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
+               types$2[i] = 1 /* L */;
+           }
+           prev = type;
+           if (type & 7 /* Strong */)
+               prevStrong = type;
+       }
+       // N0. Process bracket pairs in an isolating run sequence
+       // sequentially in the logical order of the text positions of the
+       // opening paired brackets using the logic given below. Within this
+       // scope, bidirectional types EN and AN are treated as R.
+       for (let i = 0, sI = 0, context = 0, ch, br, type; i < len; i++) {
+           // Keeps [startIndex, type, strongSeen] triples for each open
+           // bracket on BracketStack.
+           if (br = Brackets$2[ch = line.charCodeAt(i)]) {
+               if (br < 0) { // Closing bracket
+                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                       if (BracketStack$2[sJ + 1] == -br) {
+                           let flags = BracketStack$2[sJ + 2];
+                           let type = (flags & 2 /* EmbedInside */) ? outerType :
+                               !(flags & 4 /* OppositeInside */) ? 0 :
+                                   (flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
+                           if (type)
+                               types$2[i] = types$2[BracketStack$2[sJ]] = type;
+                           sI = sJ;
+                           break;
+                       }
+                   }
+               }
+               else if (BracketStack$2.length == 189 /* MaxDepth */) {
+                   break;
+               }
+               else {
+                   BracketStack$2[sI++] = i;
+                   BracketStack$2[sI++] = ch;
+                   BracketStack$2[sI++] = context;
+               }
+           }
+           else if ((type = types$2[i]) == 2 /* R */ || type == 1 /* L */) {
+               let embed = type == outerType;
+               context = embed ? 0 : 1 /* OppositeBefore */;
+               for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                   let cur = BracketStack$2[sJ + 2];
+                   if (cur & 2 /* EmbedInside */)
+                       break;
+                   if (embed) {
+                       BracketStack$2[sJ + 2] |= 2 /* EmbedInside */;
+                   }
+                   else {
+                       if (cur & 4 /* OppositeInside */)
+                           break;
+                       BracketStack$2[sJ + 2] |= 4 /* OppositeInside */;
+                   }
+               }
+           }
+       }
+       // N1. A sequence of neutrals takes the direction of the
+       // surrounding strong text if the text on both sides has the same
+       // direction. European and Arabic numbers act as if they were R in
+       // terms of their influence on neutrals. Start-of-level-run (sor)
+       // and end-of-level-run (eor) are used at level run boundaries.
+       // N2. Any remaining neutrals take the embedding direction.
+       // (Left after this: L, R, EN+AN)
+       for (let i = 0; i < len; i++) {
+           if (types$2[i] == 256 /* NI */) {
+               let end = i + 1;
+               while (end < len && types$2[end] == 256 /* NI */)
+                   end++;
+               let beforeL = (i ? types$2[i - 1] : outerType) == 1 /* L */;
+               let afterL = (end < len ? types$2[end] : outerType) == 1 /* L */;
+               let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
+               for (let j = i; j < end; j++)
+                   types$2[j] = replace;
+               i = end - 1;
+           }
+       }
+       // Here we depart from the documented algorithm, in order to avoid
+       // building up an actual levels array. Since there are only three
+       // levels (0, 1, 2) in an implementation that doesn't take
+       // explicit embedding into account, we can build up the order on
+       // the fly, without following the level-based algorithm.
+       let order = [];
+       if (outerType == 1 /* L */) {
+           for (let i = 0; i < len;) {
+               let start = i, rtl = types$2[i++] != 1 /* L */;
+               while (i < len && rtl == (types$2[i] != 1 /* L */))
+                   i++;
+               if (rtl) {
+                   for (let j = i; j > start;) {
+                       let end = j, l = types$2[--j] != 2 /* R */;
+                       while (j > start && l == (types$2[j - 1] != 2 /* R */))
+                           j--;
+                       order.push(new BidiSpan$2(j, end, l ? 2 : 1));
+                   }
+               }
+               else {
+                   order.push(new BidiSpan$2(start, i, 0));
+               }
+           }
+       }
+       else {
+           for (let i = 0; i < len;) {
+               let start = i, rtl = types$2[i++] == 2 /* R */;
+               while (i < len && rtl == (types$2[i] == 2 /* R */))
+                   i++;
+               order.push(new BidiSpan$2(start, i, rtl ? 1 : 2));
+           }
+       }
+       return order;
+   }
+   function trivialOrder$2(length) {
+       return [new BidiSpan$2(0, length, 0)];
+   }
+   let movedOver$2 = "";
+   function moveVisually$2(line, order, dir, start, forward) {
+       var _a;
+       let startIndex = start.head - line.from, spanI = -1;
+       if (startIndex == 0) {
+           if (!forward || !line.length)
+               return null;
+           if (order[0].level != dir) {
+               startIndex = order[0].side(false, dir);
+               spanI = 0;
+           }
+       }
+       else if (startIndex == line.length) {
+           if (forward)
+               return null;
+           let last = order[order.length - 1];
+           if (last.level != dir) {
+               startIndex = last.side(true, dir);
+               spanI = order.length - 1;
+           }
+       }
+       if (spanI < 0)
+           spanI = BidiSpan$2.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
+       let span = order[spanI];
+       // End of span. (But not end of line--that was checked for above.)
+       if (startIndex == span.side(forward, dir)) {
+           span = order[spanI += forward ? 1 : -1];
+           startIndex = span.side(!forward, dir);
+       }
+       let indexForward = forward == (span.dir == dir);
+       let nextIndex = findClusterBreak$3(line.text, startIndex, indexForward);
+       movedOver$2 = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
+       if (nextIndex != span.side(forward, dir))
+           return EditorSelection$2.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);
+       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
+       if (!nextSpan && span.level != dir)
+           return EditorSelection$2.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);
+       if (nextSpan && nextSpan.level < span.level)
+           return EditorSelection$2.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
+       return EditorSelection$2.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
+   }
+
+   const LineBreakPlaceholder$2 = "\uffff";
+   let DOMReader$2 = class DOMReader {
+       constructor(points, state) {
+           this.points = points;
+           this.text = "";
+           this.lineSeparator = state.facet(EditorState$2.lineSeparator);
+       }
+       append(text) {
+           this.text += text;
+       }
+       lineBreak() {
+           this.text += LineBreakPlaceholder$2;
+       }
+       readRange(start, end) {
+           if (!start)
+               return this;
+           let parent = start.parentNode;
+           for (let cur = start;;) {
+               this.findPointBefore(parent, cur);
+               this.readNode(cur);
+               let next = cur.nextSibling;
+               if (next == end)
+                   break;
+               let view = ContentView$2.get(cur), nextView = ContentView$2.get(next);
+               if (view && nextView ? view.breakAfter :
+                   (view ? view.breakAfter : isBlockElement$2(cur)) ||
+                       (isBlockElement$2(next) && (cur.nodeName != "BR" || cur.cmIgnore)))
+                   this.lineBreak();
+               cur = next;
+           }
+           this.findPointBefore(parent, end);
+           return this;
+       }
+       readTextNode(node) {
+           let text = node.nodeValue;
+           for (let point of this.points)
+               if (point.node == node)
+                   point.pos = this.text.length + Math.min(point.offset, text.length);
+           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
+               let nextBreak = -1, breakSize = 1, m;
+               if (this.lineSeparator) {
+                   nextBreak = text.indexOf(this.lineSeparator, off);
+                   breakSize = this.lineSeparator.length;
+               }
+               else if (m = re.exec(text)) {
+                   nextBreak = m.index;
+                   breakSize = m[0].length;
+               }
+               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
+               if (nextBreak < 0)
+                   break;
+               this.lineBreak();
+               if (breakSize > 1)
+                   for (let point of this.points)
+                       if (point.node == node && point.pos > this.text.length)
+                           point.pos -= breakSize - 1;
+               off = nextBreak + breakSize;
+           }
+       }
+       readNode(node) {
+           if (node.cmIgnore)
+               return;
+           let view = ContentView$2.get(node);
+           let fromView = view && view.overrideDOMText;
+           if (fromView != null) {
+               this.findPointInside(node, fromView.length);
+               for (let i = fromView.iter(); !i.next().done;) {
+                   if (i.lineBreak)
+                       this.lineBreak();
+                   else
+                       this.append(i.value);
+               }
+           }
+           else if (node.nodeType == 3) {
+               this.readTextNode(node);
+           }
+           else if (node.nodeName == "BR") {
+               if (node.nextSibling)
+                   this.lineBreak();
+           }
+           else if (node.nodeType == 1) {
+               this.readRange(node.firstChild, null);
+           }
+       }
+       findPointBefore(node, next) {
+           for (let point of this.points)
+               if (point.node == node && node.childNodes[point.offset] == next)
+                   point.pos = this.text.length;
+       }
+       findPointInside(node, maxLen) {
+           for (let point of this.points)
+               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
+                   point.pos = this.text.length + Math.min(maxLen, point.offset);
+       }
+   };
+   function isBlockElement$2(node) {
+       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
+   }
+   let DOMPoint$2 = class DOMPoint {
+       constructor(node, offset) {
+           this.node = node;
+           this.offset = offset;
+           this.pos = -1;
+       }
+   };
+
+   let DocView$2 = class DocView extends ContentView$2 {
+       constructor(view) {
+           super();
+           this.view = view;
+           this.compositionDeco = Decoration$2.none;
+           this.decorations = [];
+           this.dynamicDecorationMap = [];
+           // Track a minimum width for the editor. When measuring sizes in
+           // measureVisibleLineHeights, this is updated to point at the width
+           // of a given element and its extent in the document. When a change
+           // happens in that range, these are reset. That way, once we've seen
+           // a line/element of a given length, we keep the editor wide enough
+           // to fit at least that element, until it is changed, at which point
+           // we forget it again.
+           this.minWidth = 0;
+           this.minWidthFrom = 0;
+           this.minWidthTo = 0;
+           // Track whether the DOM selection was set in a lossy way, so that
+           // we don't mess it up when reading it back it
+           this.impreciseAnchor = null;
+           this.impreciseHead = null;
+           this.forceSelection = false;
+           // Used by the resize observer to ignore resizes that we caused
+           // ourselves
+           this.lastUpdate = Date.now();
+           this.setDOM(view.contentDOM);
+           this.children = [new LineView$2];
+           this.children[0].setParent(this);
+           this.updateDeco();
+           this.updateInner([new ChangedRange$2(0, 0, 0, view.state.doc.length)], 0);
+       }
+       get root() { return this.view.root; }
+       get editorView() { return this.view; }
+       get length() { return this.view.state.doc.length; }
+       // Update the document view to a given state. scrollIntoView can be
+       // used as a hint to compute a new viewport that includes that
+       // position, if we know the editor is going to scroll that position
+       // into view.
+       update(update) {
+           let changedRanges = update.changedRanges;
+           if (this.minWidth > 0 && changedRanges.length) {
+               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
+                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
+               }
+               else {
+                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
+                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
+               }
+           }
+           if (this.view.inputState.composing < 0)
+               this.compositionDeco = Decoration$2.none;
+           else if (update.transactions.length || this.dirty)
+               this.compositionDeco = computeCompositionDeco$1(this.view, update.changes);
+           // When the DOM nodes around the selection are moved to another
+           // parent, Chrome sometimes reports a different selection through
+           // getSelection than the one that it actually shows to the user.
+           // This forces a selection update when lines are joined to work
+           // around that. Issue #54
+           if ((browser$2.ie || browser$2.chrome) && !this.compositionDeco.size && update &&
+               update.state.doc.lines != update.startState.doc.lines)
+               this.forceSelection = true;
+           let prevDeco = this.decorations, deco = this.updateDeco();
+           let decoDiff = findChangedDeco$2(prevDeco, deco, update.changes);
+           changedRanges = ChangedRange$2.extendWithRanges(changedRanges, decoDiff);
+           if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
+               return false;
+           }
+           else {
+               this.updateInner(changedRanges, update.startState.doc.length);
+               if (update.transactions.length)
+                   this.lastUpdate = Date.now();
+               return true;
+           }
+       }
+       // Used by update and the constructor do perform the actual DOM
+       // update
+       updateInner(changes, oldLength) {
+           this.view.viewState.mustMeasureContent = true;
+           this.updateChildren(changes, oldLength);
+           let { observer } = this.view;
+           observer.ignore(() => {
+               // Lock the height during redrawing, since Chrome sometimes
+               // messes with the scroll position during DOM mutation (though
+               // no relayout is triggered and I cannot imagine how it can
+               // recompute the scroll position without a layout)
+               this.dom.style.height = this.view.viewState.contentHeight + "px";
+               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
+               // Chrome will sometimes, when DOM mutations occur directly
+               // around the selection, get confused and report a different
+               // selection from the one it displays (issue #218). This tries
+               // to detect that situation.
+               let track = browser$2.chrome || browser$2.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
+               this.sync(track);
+               this.dirty = 0 /* Not */;
+               if (track && (track.written || observer.selectionRange.focusNode != track.node))
+                   this.forceSelection = true;
+               this.dom.style.height = "";
+           });
+           let gaps = [];
+           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
+               for (let child of this.children)
+                   if (child instanceof BlockWidgetView$2 && child.widget instanceof BlockGapWidget$2)
+                       gaps.push(child.dom);
+           observer.updateGaps(gaps);
+       }
+       updateChildren(changes, oldLength) {
+           let cursor = this.childCursor(oldLength);
+           for (let i = changes.length - 1;; i--) {
+               let next = i >= 0 ? changes[i] : null;
+               if (!next)
+                   break;
+               let { fromA, toA, fromB, toB } = next;
+               let { content, breakAtStart, openStart, openEnd } = ContentBuilder$2.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap);
+               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
+               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
+               replaceRange$2(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
+           }
+       }
+       // Sync the DOM selection to this.state.selection
+       updateSelection(mustRead = false, fromPointer = false) {
+           if (mustRead)
+               this.view.observer.readSelectionRange();
+           if (!(fromPointer || this.mayControlSelection()) ||
+               browser$2.ios && this.view.inputState.rapidCompositionStart)
+               return;
+           let force = this.forceSelection;
+           this.forceSelection = false;
+           let main = this.view.state.selection.main;
+           // FIXME need to handle the case where the selection falls inside a block range
+           let anchor = this.domAtPos(main.anchor);
+           let head = main.empty ? anchor : this.domAtPos(main.head);
+           // Always reset on Firefox when next to an uneditable node to
+           // avoid invisible cursor bugs (#111)
+           if (browser$2.gecko && main.empty && betweenUneditable$2(anchor)) {
+               let dummy = document.createTextNode("");
+               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
+               anchor = head = new DOMPos$2(dummy, 0);
+               force = true;
+           }
+           let domSel = this.view.observer.selectionRange;
+           // If the selection is already here, or in an equivalent position, don't touch it
+           if (force || !domSel.focusNode ||
+               !isEquivalentPosition$2(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
+               !isEquivalentPosition$2(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
+               this.view.observer.ignore(() => {
+                   // Chrome Android will hide the virtual keyboard when tapping
+                   // inside an uneditable node, and not bring it back when we
+                   // move the cursor to its proper position. This tries to
+                   // restore the keyboard by cycling focus.
+                   if (browser$2.android && browser$2.chrome && this.dom.contains(domSel.focusNode) &&
+                       inUneditable$2(domSel.focusNode, this.dom)) {
+                       this.dom.blur();
+                       this.dom.focus({ preventScroll: true });
+                   }
+                   let rawSel = getSelection$2(this.root);
+                   if (main.empty) {
+                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
+                       if (browser$2.gecko) {
+                           let nextTo = nextToUneditable$2(anchor.node, anchor.offset);
+                           if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
+                               let text = nearbyTextNode$1(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
+                               if (text)
+                                   anchor = new DOMPos$2(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
+                           }
+                       }
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       if (main.bidiLevel != null && domSel.cursorBidiLevel != null)
+                           domSel.cursorBidiLevel = main.bidiLevel;
+                   }
+                   else if (rawSel.extend) {
+                       // Selection.extend can be used to create an 'inverted' selection
+                       // (one where the focus is before the anchor), but not all
+                       // browsers support it yet.
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       rawSel.extend(head.node, head.offset);
+                   }
+                   else {
+                       // Primitive (IE) way
+                       let range = document.createRange();
+                       if (main.anchor > main.head)
+                           [anchor, head] = [head, anchor];
+                       range.setEnd(head.node, head.offset);
+                       range.setStart(anchor.node, anchor.offset);
+                       rawSel.removeAllRanges();
+                       rawSel.addRange(range);
+                   }
+               });
+               this.view.observer.setSelectionRange(anchor, head);
+           }
+           this.impreciseAnchor = anchor.precise ? null : new DOMPos$2(domSel.anchorNode, domSel.anchorOffset);
+           this.impreciseHead = head.precise ? null : new DOMPos$2(domSel.focusNode, domSel.focusOffset);
+       }
+       enforceCursorAssoc() {
+           if (this.compositionDeco.size)
+               return;
+           let cursor = this.view.state.selection.main;
+           let sel = getSelection$2(this.root);
+           if (!cursor.empty || !cursor.assoc || !sel.modify)
+               return;
+           let line = LineView$2.find(this, cursor.head);
+           if (!line)
+               return;
+           let lineStart = line.posAtStart;
+           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
+               return;
+           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
+           if (!before || !after || before.bottom > after.top)
+               return;
+           let dom = this.domAtPos(cursor.head + cursor.assoc);
+           sel.collapse(dom.node, dom.offset);
+           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
+       }
+       mayControlSelection() {
+           return this.view.state.facet(editable$2) ? this.root.activeElement == this.dom
+               : hasSelection$2(this.dom, this.view.observer.selectionRange);
+       }
+       nearest(dom) {
+           for (let cur = dom; cur;) {
+               let domView = ContentView$2.get(cur);
+               if (domView && domView.rootView == this)
+                   return domView;
+               cur = cur.parentNode;
+           }
+           return null;
+       }
+       posFromDOM(node, offset) {
+           let view = this.nearest(node);
+           if (!view)
+               throw new RangeError("Trying to find position for a DOM position outside of the document");
+           return view.localPosFromDOM(node, offset) + view.posAtStart;
+       }
+       domAtPos(pos) {
+           let { i, off } = this.childCursor().findPos(pos, -1);
+           for (; i < this.children.length - 1;) {
+               let child = this.children[i];
+               if (off < child.length || child instanceof LineView$2)
+                   break;
+               i++;
+               off = 0;
+           }
+           return this.children[i].domAtPos(off);
+       }
+       coordsAt(pos, side) {
+           for (let off = this.length, i = this.children.length - 1;; i--) {
+               let child = this.children[i], start = off - child.breakAfter - child.length;
+               if (pos > start ||
+                   (pos == start && child.type != BlockType$2.WidgetBefore && child.type != BlockType$2.WidgetAfter &&
+                       (!i || side == 2 || this.children[i - 1].breakAfter ||
+                           (this.children[i - 1].type == BlockType$2.WidgetBefore && side > -2))))
+                   return child.coordsAt(pos - start, side);
+               off = start;
+           }
+       }
+       measureVisibleLineHeights(viewport) {
+           let result = [], { from, to } = viewport;
+           let contentWidth = this.view.contentDOM.clientWidth;
+           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
+           let widest = -1, ltr = this.view.textDirection == Direction$2.LTR;
+           for (let pos = 0, i = 0; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (end > to)
+                   break;
+               if (pos >= from) {
+                   let childRect = child.dom.getBoundingClientRect();
+                   result.push(childRect.height);
+                   if (isWider) {
+                       let last = child.dom.lastChild;
+                       let rects = last ? clientRectsFor$2(last) : [];
+                       if (rects.length) {
+                           let rect = rects[rects.length - 1];
+                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
+                           if (width > widest) {
+                               widest = width;
+                               this.minWidth = contentWidth;
+                               this.minWidthFrom = pos;
+                               this.minWidthTo = end;
+                           }
+                       }
+                   }
+               }
+               pos = end + child.breakAfter;
+           }
+           return result;
+       }
+       textDirectionAt(pos) {
+           let { i } = this.childPos(pos, 1);
+           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction$2.RTL : Direction$2.LTR;
+       }
+       measureTextSize() {
+           for (let child of this.children) {
+               if (child instanceof LineView$2) {
+                   let measure = child.measureTextSize();
+                   if (measure)
+                       return measure;
+               }
+           }
+           // If no workable line exists, force a layout of a measurable element
+           let dummy = document.createElement("div"), lineHeight, charWidth;
+           dummy.className = "cm-line";
+           dummy.textContent = "abc def ghi jkl mno pqr stu";
+           this.view.observer.ignore(() => {
+               this.dom.appendChild(dummy);
+               let rect = clientRectsFor$2(dummy.firstChild)[0];
+               lineHeight = dummy.getBoundingClientRect().height;
+               charWidth = rect ? rect.width / 27 : 7;
+               dummy.remove();
+           });
+           return { lineHeight, charWidth };
+       }
+       childCursor(pos = this.length) {
+           // Move back to start of last element when possible, so that
+           // `ChildCursor.findPos` doesn't have to deal with the edge case
+           // of being after the last element.
+           let i = this.children.length;
+           if (i)
+               pos -= this.children[--i].length;
+           return new ChildCursor$2(this.children, pos, i);
+       }
+       computeBlockGapDeco() {
+           let deco = [], vs = this.view.viewState;
+           for (let pos = 0, i = 0;; i++) {
+               let next = i == vs.viewports.length ? null : vs.viewports[i];
+               let end = next ? next.from - 1 : this.length;
+               if (end > pos) {
+                   let height = vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top;
+                   deco.push(Decoration$2.replace({
+                       widget: new BlockGapWidget$2(height),
+                       block: true,
+                       inclusive: true,
+                       isBlockGap: true,
+                   }).range(pos, end));
+               }
+               if (!next)
+                   break;
+               pos = next.to + 1;
+           }
+           return Decoration$2.set(deco);
+       }
+       updateDeco() {
+           let allDeco = this.view.state.facet(decorations$2).map((d, i) => {
+               let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
+               return dynamic ? d(this.view) : d;
+           });
+           for (let i = allDeco.length; i < allDeco.length + 3; i++)
+               this.dynamicDecorationMap[i] = false;
+           return this.decorations = [
+               ...allDeco,
+               this.compositionDeco,
+               this.computeBlockGapDeco(),
+               this.view.viewState.lineGapDeco
+           ];
+       }
+       scrollIntoView(target) {
+           let { range } = target;
+           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
+           if (!rect)
+               return;
+           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
+               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
+                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
+           let mLeft = 0, mRight = 0, mTop = 0, mBottom = 0;
+           for (let margins of this.view.state.facet(scrollMargins$2).map(f => f(this.view)))
+               if (margins) {
+                   let { left, right, top, bottom } = margins;
+                   if (left != null)
+                       mLeft = Math.max(mLeft, left);
+                   if (right != null)
+                       mRight = Math.max(mRight, right);
+                   if (top != null)
+                       mTop = Math.max(mTop, top);
+                   if (bottom != null)
+                       mBottom = Math.max(mBottom, bottom);
+               }
+           let targetRect = {
+               left: rect.left - mLeft, top: rect.top - mTop,
+               right: rect.right + mRight, bottom: rect.bottom + mBottom
+           };
+           scrollRectIntoView$2(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction$2.LTR);
+       }
+   };
+   function betweenUneditable$2(pos) {
+       return pos.node.nodeType == 1 && pos.node.firstChild &&
+           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
+           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
+   }
+   let BlockGapWidget$2 = class BlockGapWidget extends WidgetType$2 {
+       constructor(height) {
+           super();
+           this.height = height;
+       }
+       toDOM() {
+           let elt = document.createElement("div");
+           this.updateDOM(elt);
+           return elt;
+       }
+       eq(other) { return other.height == this.height; }
+       updateDOM(elt) {
+           elt.style.height = this.height + "px";
+           return true;
+       }
+       get estimatedHeight() { return this.height; }
+   };
+   function compositionSurroundingNode$1(view) {
+       let sel = view.observer.selectionRange;
+       let textNode = sel.focusNode && nearbyTextNode$1(sel.focusNode, sel.focusOffset, 0);
+       if (!textNode)
+           return null;
+       let cView = view.docView.nearest(textNode);
+       if (!cView)
+           return null;
+       if (cView instanceof LineView$2) {
+           let topNode = textNode;
+           while (topNode.parentNode != cView.dom)
+               topNode = topNode.parentNode;
+           let prev = topNode.previousSibling;
+           while (prev && !ContentView$2.get(prev))
+               prev = prev.previousSibling;
+           let pos = prev ? ContentView$2.get(prev).posAtEnd : cView.posAtStart;
+           return { from: pos, to: pos, node: topNode, text: textNode };
+       }
+       else {
+           for (;;) {
+               let { parent } = cView;
+               if (!parent)
+                   return null;
+               if (parent instanceof LineView$2)
+                   break;
+               cView = parent;
+           }
+           let from = cView.posAtStart;
+           return { from, to: from + cView.length, node: cView.dom, text: textNode };
+       }
+   }
+   function computeCompositionDeco$1(view, changes) {
+       let surrounding = compositionSurroundingNode$1(view);
+       if (!surrounding)
+           return Decoration$2.none;
+       let { from, to, node, text: textNode } = surrounding;
+       let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
+       let { state } = view, text = node.nodeType == 3 ? node.nodeValue :
+           new DOMReader$2([], state).readRange(node.firstChild, null).text;
+       if (newTo - newFrom < text.length) {
+           if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder$2) == text)
+               newTo = newFrom + text.length;
+           else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder$2) == text)
+               newFrom = newTo - text.length;
+           else
+               return Decoration$2.none;
+       }
+       else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder$2) != text) {
+           return Decoration$2.none;
+       }
+       let topView = ContentView$2.get(node);
+       if (topView instanceof CompositionView$1)
+           topView = topView.widget.topView;
+       else if (topView)
+           topView.parent = null;
+       return Decoration$2.set(Decoration$2.replace({ widget: new CompositionWidget$1(node, textNode, topView), inclusive: true })
+           .range(newFrom, newTo));
+   }
+   let CompositionWidget$1 = class CompositionWidget extends WidgetType$2 {
+       constructor(top, text, topView) {
+           super();
+           this.top = top;
+           this.text = text;
+           this.topView = topView;
+       }
+       eq(other) { return this.top == other.top && this.text == other.text; }
+       toDOM() { return this.top; }
+       ignoreEvent() { return false; }
+       get customView() { return CompositionView$1; }
+   };
+   function nearbyTextNode$1(node, offset, side) {
+       for (;;) {
+           if (node.nodeType == 3)
+               return node;
+           if (node.nodeType == 1 && offset > 0 && side <= 0) {
+               node = node.childNodes[offset - 1];
+               offset = maxOffset$2(node);
+           }
+           else if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {
+               node = node.childNodes[offset];
+               offset = 0;
+           }
+           else {
+               return null;
+           }
+       }
+   }
+   function nextToUneditable$2(node, offset) {
+       if (node.nodeType != 1)
+           return 0;
+       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
+           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
+   }
+   let DecorationComparator$1$2 = class DecorationComparator$1 {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange(from, to) { addRange$2(from, to, this.changes); }
+       comparePoint(from, to) { addRange$2(from, to, this.changes); }
+   };
+   function findChangedDeco$2(a, b, diff) {
+       let comp = new DecorationComparator$1$2;
+       RangeSet$2.compare(a, b, diff, comp);
+       return comp.changes;
+   }
+   function inUneditable$2(node, inside) {
+       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
+           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
+               return true;
+           }
+       }
+       return false;
+   }
+
+   function groupAt$2(state, pos, bias = 1) {
+       let categorize = state.charCategorizer(pos);
+       let line = state.doc.lineAt(pos), linePos = pos - line.from;
+       if (line.length == 0)
+           return EditorSelection$2.cursor(pos);
+       if (linePos == 0)
+           bias = 1;
+       else if (linePos == line.length)
+           bias = -1;
+       let from = linePos, to = linePos;
+       if (bias < 0)
+           from = findClusterBreak$3(line.text, linePos, false);
+       else
+           to = findClusterBreak$3(line.text, linePos);
+       let cat = categorize(line.text.slice(from, to));
+       while (from > 0) {
+           let prev = findClusterBreak$3(line.text, from, false);
+           if (categorize(line.text.slice(prev, from)) != cat)
+               break;
+           from = prev;
+       }
+       while (to < line.length) {
+           let next = findClusterBreak$3(line.text, to);
+           if (categorize(line.text.slice(to, next)) != cat)
+               break;
+           to = next;
+       }
+       return EditorSelection$2.range(from + line.from, to + line.from);
+   }
+   // Search the DOM for the {node, offset} position closest to the given
+   // coordinates. Very inefficient and crude, but can usually be avoided
+   // by calling caret(Position|Range)FromPoint instead.
+   function getdx$2(x, rect) {
+       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
+   }
+   function getdy$2(y, rect) {
+       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
+   }
+   function yOverlap$2(a, b) {
+       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
+   }
+   function upTop$2(rect, top) {
+       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
+   }
+   function upBot$2(rect, bottom) {
+       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
+   }
+   function domPosAtCoords$2(parent, x, y) {
+       let closest, closestRect, closestX, closestY;
+       let above, below, aboveRect, belowRect;
+       for (let child = parent.firstChild; child; child = child.nextSibling) {
+           let rects = clientRectsFor$2(child);
+           for (let i = 0; i < rects.length; i++) {
+               let rect = rects[i];
+               if (closestRect && yOverlap$2(closestRect, rect))
+                   rect = upTop$2(upBot$2(rect, closestRect.bottom), closestRect.top);
+               let dx = getdx$2(x, rect), dy = getdy$2(y, rect);
+               if (dx == 0 && dy == 0)
+                   return child.nodeType == 3 ? domPosInText$2(child, x, y) : domPosAtCoords$2(child, x, y);
+               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
+                   closest = child;
+                   closestRect = rect;
+                   closestX = dx;
+                   closestY = dy;
+               }
+               if (dx == 0) {
+                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
+                       above = child;
+                       aboveRect = rect;
+                   }
+                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
+                       below = child;
+                       belowRect = rect;
+                   }
+               }
+               else if (aboveRect && yOverlap$2(aboveRect, rect)) {
+                   aboveRect = upBot$2(aboveRect, rect.bottom);
+               }
+               else if (belowRect && yOverlap$2(belowRect, rect)) {
+                   belowRect = upTop$2(belowRect, rect.top);
+               }
+           }
+       }
+       if (aboveRect && aboveRect.bottom >= y) {
+           closest = above;
+           closestRect = aboveRect;
+       }
+       else if (belowRect && belowRect.top <= y) {
+           closest = below;
+           closestRect = belowRect;
+       }
+       if (!closest)
+           return { node: parent, offset: 0 };
+       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
+       if (closest.nodeType == 3)
+           return domPosInText$2(closest, clipX, y);
+       if (!closestX && closest.contentEditable == "true")
+           return domPosAtCoords$2(closest, clipX, y);
+       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
+           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
+       return { node: parent, offset };
+   }
+   function domPosInText$2(node, x, y) {
+       let len = node.nodeValue.length;
+       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
+       for (let i = 0; i < len; i++) {
+           let rects = textRange$2(node, i, i + 1).getClientRects();
+           for (let j = 0; j < rects.length; j++) {
+               let rect = rects[j];
+               if (rect.top == rect.bottom)
+                   continue;
+               if (!generalSide)
+                   generalSide = x - rect.left;
+               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
+               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
+                   let right = x >= (rect.left + rect.right) / 2, after = right;
+                   if (browser$2.chrome || browser$2.gecko) {
+                       // Check for RTL on browsers that support getting client
+                       // rects for empty ranges.
+                       let rectBefore = textRange$2(node, i).getBoundingClientRect();
+                       if (rectBefore.left == rect.right)
+                           after = !right;
+                   }
+                   if (dy <= 0)
+                       return { node, offset: i + (after ? 1 : 0) };
+                   closestOffset = i + (after ? 1 : 0);
+                   closestDY = dy;
+               }
+           }
+       }
+       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
+   }
+   function posAtCoords$2(view, { x, y }, precise, bias = -1) {
+       var _a;
+       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
+       let block, { docHeight } = view.viewState;
+       let yOffset = y - docTop;
+       if (yOffset < 0)
+           return 0;
+       if (yOffset > docHeight)
+           return view.state.doc.length;
+       // Scan for a text block near the queried y position
+       for (let halfLine = view.defaultLineHeight / 2, bounced = false;;) {
+           block = view.elementAtHeight(yOffset);
+           if (block.type == BlockType$2.Text)
+               break;
+           for (;;) {
+               // Move the y position out of this block
+               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
+               if (yOffset >= 0 && yOffset <= docHeight)
+                   break;
+               // If the document consists entirely of replaced widgets, we
+               // won't find a text block, so return 0
+               if (bounced)
+                   return precise ? null : 0;
+               bounced = true;
+               bias = -bias;
+           }
+       }
+       y = docTop + yOffset;
+       let lineStart = block.from;
+       // If this is outside of the rendered viewport, we can't determine a position
+       if (lineStart < view.viewport.from)
+           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise$2(view, content, block, x, y);
+       if (lineStart > view.viewport.to)
+           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
+               precise ? null : posAtCoordsImprecise$2(view, content, block, x, y);
+       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
+       let doc = view.dom.ownerDocument;
+       let root = view.root.elementFromPoint ? view.root : doc;
+       let element = root.elementFromPoint(x, y);
+       if (element && !view.contentDOM.contains(element))
+           element = null;
+       // If the element is unexpected, clip x at the sides of the content area and try again
+       if (!element) {
+           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
+           element = root.elementFromPoint(x, y);
+           if (element && !view.contentDOM.contains(element))
+               element = null;
+       }
+       // There's visible editor content under the point, so we can try
+       // using caret(Position|Range)FromPoint as a shortcut
+       let node, offset = -1;
+       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
+           if (doc.caretPositionFromPoint) {
+               let pos = doc.caretPositionFromPoint(x, y);
+               if (pos)
+                   ({ offsetNode: node, offset } = pos);
+           }
+           else if (doc.caretRangeFromPoint) {
+               let range = doc.caretRangeFromPoint(x, y);
+               if (range) {
+                   ({ startContainer: node, startOffset: offset } = range);
+                   if (browser$2.safari && isSuspiciousCaretResult$1(node, offset, x))
+                       node = undefined;
+               }
+           }
+       }
+       // No luck, do our own (potentially expensive) search
+       if (!node || !view.docView.dom.contains(node)) {
+           let line = LineView$2.find(view.docView, lineStart);
+           if (!line)
+               return yOffset > block.top + block.height / 2 ? block.to : block.from;
+           ({ node, offset } = domPosAtCoords$2(line.dom, x, y));
+       }
+       return view.docView.posFromDOM(node, offset);
+   }
+   function posAtCoordsImprecise$2(view, contentRect, block, x, y) {
+       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
+       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
+           let line = Math.floor((y - block.top) / view.defaultLineHeight);
+           into += line * view.viewState.heightOracle.lineLength;
+       }
+       let content = view.state.sliceDoc(block.from, block.to);
+       return block.from + findColumn$2(content, into, view.state.tabSize);
+   }
+   // In case of a high line height, Safari's caretRangeFromPoint treats
+   // the space between lines as belonging to the last character of the
+   // line before. This is used to detect such a result so that it can be
+   // ignored (issue #401).
+   function isSuspiciousCaretResult$1(node, offset, x) {
+       let len;
+       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
+           return false;
+       for (let next = node.nextSibling; next; next = next.nextSibling)
+           if (next.nodeType != 1 || next.nodeName != "BR")
+               return false;
+       return textRange$2(node, len - 1, len).getBoundingClientRect().left > x;
+   }
+   function moveToLineBoundary$2(view, start, forward, includeWrap) {
+       let line = view.state.doc.lineAt(start.head);
+       let coords = !includeWrap || !view.lineWrapping ? null
+           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
+       if (coords) {
+           let editorRect = view.dom.getBoundingClientRect();
+           let direction = view.textDirectionAt(line.from);
+           let pos = view.posAtCoords({ x: forward == (direction == Direction$2.LTR) ? editorRect.right - 1 : editorRect.left + 1,
+               y: (coords.top + coords.bottom) / 2 });
+           if (pos != null)
+               return EditorSelection$2.cursor(pos, forward ? -1 : 1);
+       }
+       let lineView = LineView$2.find(view.docView, start.head);
+       let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
+       return EditorSelection$2.cursor(end, forward ? -1 : 1);
+   }
+   function moveByChar$2(view, start, forward, by) {
+       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
+       let direction = view.textDirectionAt(line.from);
+       for (let cur = start, check = null;;) {
+           let next = moveVisually$2(line, spans, direction, cur, forward), char = movedOver$2;
+           if (!next) {
+               if (line.number == (forward ? view.state.doc.lines : 1))
+                   return cur;
+               char = "\n";
+               line = view.state.doc.line(line.number + (forward ? 1 : -1));
+               spans = view.bidiSpans(line);
+               next = EditorSelection$2.cursor(forward ? line.from : line.to);
+           }
+           if (!check) {
+               if (!by)
+                   return next;
+               check = by(char);
+           }
+           else if (!check(char)) {
+               return cur;
+           }
+           cur = next;
+       }
+   }
+   function byGroup$2(view, pos, start) {
+       let categorize = view.state.charCategorizer(pos);
+       let cat = categorize(start);
+       return (next) => {
+           let nextCat = categorize(next);
+           if (cat == CharCategory$2.Space)
+               cat = nextCat;
+           return cat == nextCat;
+       };
+   }
+   function moveVertically$2(view, start, forward, distance) {
+       let startPos = start.head, dir = forward ? 1 : -1;
+       if (startPos == (forward ? view.state.doc.length : 0))
+           return EditorSelection$2.cursor(startPos, start.assoc);
+       let goal = start.goalColumn, startY;
+       let rect = view.contentDOM.getBoundingClientRect();
+       let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;
+       if (startCoords) {
+           if (goal == null)
+               goal = startCoords.left - rect.left;
+           startY = dir < 0 ? startCoords.top : startCoords.bottom;
+       }
+       else {
+           let line = view.viewState.lineBlockAt(startPos);
+           if (goal == null)
+               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
+           startY = (dir < 0 ? line.top : line.bottom) + docTop;
+       }
+       let resolvedGoal = rect.left + goal;
+       let dist = distance !== null && distance !== void 0 ? distance : (view.defaultLineHeight >> 1);
+       for (let extra = 0;; extra += 10) {
+           let curY = startY + (dist + extra) * dir;
+           let pos = posAtCoords$2(view, { x: resolvedGoal, y: curY }, false, dir);
+           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))
+               return EditorSelection$2.cursor(pos, start.assoc, undefined, goal);
+       }
+   }
+   function skipAtoms$2(view, oldPos, pos) {
+       let atoms = view.state.facet(atomicRanges$2).map(f => f(view));
+       for (;;) {
+           let moved = false;
+           for (let set of atoms) {
+               set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
+                   if (pos.from > from && pos.from < to) {
+                       pos = oldPos.from > pos.from ? EditorSelection$2.cursor(from, 1) : EditorSelection$2.cursor(to, -1);
+                       moved = true;
+                   }
+               });
+           }
+           if (!moved)
+               return pos;
+       }
+   }
+
+   // This will also be where dragging info and such goes
+   let InputState$2 = class InputState {
+       constructor(view) {
+           this.lastKeyCode = 0;
+           this.lastKeyTime = 0;
+           this.chromeScrollHack = -1;
+           // On iOS, some keys need to have their default behavior happen
+           // (after which we retroactively handle them and reset the DOM) to
+           // avoid messing up the virtual keyboard state.
+           this.pendingIOSKey = undefined;
+           this.lastSelectionOrigin = null;
+           this.lastSelectionTime = 0;
+           this.lastEscPress = 0;
+           this.lastContextMenu = 0;
+           this.scrollHandlers = [];
+           this.registeredEvents = [];
+           this.customHandlers = [];
+           // -1 means not in a composition. Otherwise, this counts the number
+           // of changes made during the composition. The count is used to
+           // avoid treating the start state of the composition, before any
+           // changes have been made, as part of the composition.
+           this.composing = -1;
+           // Tracks whether the next change should be marked as starting the
+           // composition (null means no composition, true means next is the
+           // first, false means first has already been marked for this
+           // composition)
+           this.compositionFirstChange = null;
+           this.compositionEndedAt = 0;
+           this.rapidCompositionStart = false;
+           this.mouseSelection = null;
+           for (let type in handlers$2) {
+               let handler = handlers$2[type];
+               view.contentDOM.addEventListener(type, (event) => {
+                   if (!eventBelongsToEditor$2(view, event) || this.ignoreDuringComposition(event))
+                       return;
+                   if (type == "keydown" && this.keydown(view, event))
+                       return;
+                   if (this.mustFlushObserver(event))
+                       view.observer.forceFlush();
+                   if (this.runCustomHandlers(type, view, event))
+                       event.preventDefault();
+                   else
+                       handler(view, event);
+               });
+               this.registeredEvents.push(type);
+           }
+           if (browser$2.chrome && browser$2.chrome_version >= 102) {
+               // On Chrome 102, viewport updates somehow stop wheel-based
+               // scrolling. Turning off pointer events during the scroll seems
+               // to avoid the issue.
+               view.scrollDOM.addEventListener("wheel", () => {
+                   if (this.chromeScrollHack < 0)
+                       view.contentDOM.style.pointerEvents = "none";
+                   else
+                       window.clearTimeout(this.chromeScrollHack);
+                   this.chromeScrollHack = setTimeout(() => {
+                       this.chromeScrollHack = -1;
+                       view.contentDOM.style.pointerEvents = "";
+                   }, 100);
+               }, { passive: true });
+           }
+           this.notifiedFocused = view.hasFocus;
+           // On Safari adding an input event handler somehow prevents an
+           // issue where the composition vanishes when you press enter.
+           if (browser$2.safari)
+               view.contentDOM.addEventListener("input", () => null);
+       }
+       setSelectionOrigin(origin) {
+           this.lastSelectionOrigin = origin;
+           this.lastSelectionTime = Date.now();
+       }
+       ensureHandlers(view, plugins) {
+           var _a;
+           let handlers;
+           this.customHandlers = [];
+           for (let plugin of plugins)
+               if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {
+                   this.customHandlers.push({ plugin: plugin.value, handlers });
+                   for (let type in handlers)
+                       if (this.registeredEvents.indexOf(type) < 0 && type != "scroll") {
+                           this.registeredEvents.push(type);
+                           view.contentDOM.addEventListener(type, (event) => {
+                               if (!eventBelongsToEditor$2(view, event))
+                                   return;
+                               if (this.runCustomHandlers(type, view, event))
+                                   event.preventDefault();
+                           });
+                       }
+               }
+       }
+       runCustomHandlers(type, view, event) {
+           for (let set of this.customHandlers) {
+               let handler = set.handlers[type];
+               if (handler) {
+                   try {
+                       if (handler.call(set.plugin, event, view) || event.defaultPrevented)
+                           return true;
+                   }
+                   catch (e) {
+                       logException$2(view.state, e);
+                   }
+               }
+           }
+           return false;
+       }
+       runScrollHandlers(view, event) {
+           for (let set of this.customHandlers) {
+               let handler = set.handlers.scroll;
+               if (handler) {
+                   try {
+                       handler.call(set.plugin, event, view);
+                   }
+                   catch (e) {
+                       logException$2(view.state, e);
+                   }
+               }
+           }
+       }
+       keydown(view, event) {
+           // Must always run, even if a custom handler handled the event
+           this.lastKeyCode = event.keyCode;
+           this.lastKeyTime = Date.now();
+           if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
+               return true;
+           // Chrome for Android usually doesn't fire proper key events, but
+           // occasionally does, usually surrounded by a bunch of complicated
+           // composition changes. When an enter or backspace key event is
+           // seen, hold off on handling DOM events for a bit, and then
+           // dispatch it.
+           if (browser$2.android && browser$2.chrome && !event.synthetic &&
+               (event.keyCode == 13 || event.keyCode == 8)) {
+               view.observer.delayAndroidKey(event.key, event.keyCode);
+               return true;
+           }
+           // Prevent the default behavior of Enter on iOS makes the
+           // virtual keyboard get stuck in the wrong (lowercase)
+           // state. So we let it go through, and then, in
+           // applyDOMChange, notify key handlers of it and reset to
+           // the state they produce.
+           let pending;
+           if (browser$2.ios && (pending = PendingKeys$2.find(key => key.keyCode == event.keyCode)) &&
+               !(event.ctrlKey || event.altKey || event.metaKey) && !event.synthetic) {
+               this.pendingIOSKey = pending;
+               setTimeout(() => this.flushIOSKey(view), 250);
+               return true;
+           }
+           return false;
+       }
+       flushIOSKey(view) {
+           let key = this.pendingIOSKey;
+           if (!key)
+               return false;
+           this.pendingIOSKey = undefined;
+           return dispatchKey$2(view.contentDOM, key.key, key.keyCode);
+       }
+       ignoreDuringComposition(event) {
+           if (!/^key/.test(event.type))
+               return false;
+           if (this.composing > 0)
+               return true;
+           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
+           // On some input method editors (IMEs), the Enter key is used to
+           // confirm character selection. On Safari, when Enter is pressed,
+           // compositionend and keydown events are sometimes emitted in the
+           // wrong order. The key event should still be ignored, even when
+           // it happens after the compositionend event.
+           if (browser$2.safari && Date.now() - this.compositionEndedAt < 100) {
+               this.compositionEndedAt = 0;
+               return true;
+           }
+           return false;
+       }
+       mustFlushObserver(event) {
+           return (event.type == "keydown" && event.keyCode != 229) ||
+               event.type == "compositionend" && !browser$2.ios;
+       }
+       startMouseSelection(mouseSelection) {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+           this.mouseSelection = mouseSelection;
+       }
+       update(update) {
+           if (this.mouseSelection)
+               this.mouseSelection.update(update);
+           if (update.transactions.length)
+               this.lastKeyCode = this.lastSelectionTime = 0;
+       }
+       destroy() {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+       }
+   };
+   const PendingKeys$2 = [
+       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
+       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
+       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
+   ];
+   // Key codes for modifier keys
+   const modifierCodes$2 = [16, 17, 18, 20, 91, 92, 224, 225];
+   let MouseSelection$2 = class MouseSelection {
+       constructor(view, startEvent, style, mustSelect) {
+           this.view = view;
+           this.style = style;
+           this.mustSelect = mustSelect;
+           this.lastEvent = startEvent;
+           let doc = view.contentDOM.ownerDocument;
+           doc.addEventListener("mousemove", this.move = this.move.bind(this));
+           doc.addEventListener("mouseup", this.up = this.up.bind(this));
+           this.extend = startEvent.shiftKey;
+           this.multiple = view.state.facet(EditorState$2.allowMultipleSelections) && addsSelectionRange$2(view, startEvent);
+           this.dragMove = dragMovesSelection$3(view, startEvent);
+           this.dragging = isInPrimarySelection$2(view, startEvent) && getClickType$2(startEvent) == 1 ? null : false;
+           // When clicking outside of the selection, immediately apply the
+           // effect of starting the selection
+           if (this.dragging === false) {
+               startEvent.preventDefault();
+               this.select(startEvent);
+           }
+       }
+       move(event) {
+           if (event.buttons == 0)
+               return this.destroy();
+           if (this.dragging !== false)
+               return;
+           this.select(this.lastEvent = event);
+       }
+       up(event) {
+           if (this.dragging == null)
+               this.select(this.lastEvent);
+           if (!this.dragging)
+               event.preventDefault();
+           this.destroy();
+       }
+       destroy() {
+           let doc = this.view.contentDOM.ownerDocument;
+           doc.removeEventListener("mousemove", this.move);
+           doc.removeEventListener("mouseup", this.up);
+           this.view.inputState.mouseSelection = null;
+       }
+       select(event) {
+           let selection = this.style.get(event, this.extend, this.multiple);
+           if (this.mustSelect || !selection.eq(this.view.state.selection) ||
+               selection.main.assoc != this.view.state.selection.main.assoc)
+               this.view.dispatch({
+                   selection,
+                   userEvent: "select.pointer",
+                   scrollIntoView: true
+               });
+           this.mustSelect = false;
+       }
+       update(update) {
+           if (update.docChanged && this.dragging)
+               this.dragging = this.dragging.map(update.changes);
+           if (this.style.update(update))
+               setTimeout(() => this.select(this.lastEvent), 20);
+       }
+   };
+   function addsSelectionRange$2(view, event) {
+       let facet = view.state.facet(clickAddsSelectionRange$2);
+       return facet.length ? facet[0](event) : browser$2.mac ? event.metaKey : event.ctrlKey;
+   }
+   function dragMovesSelection$3(view, event) {
+       let facet = view.state.facet(dragMovesSelection$1$2);
+       return facet.length ? facet[0](event) : browser$2.mac ? !event.altKey : !event.ctrlKey;
+   }
+   function isInPrimarySelection$2(view, event) {
+       let { main } = view.state.selection;
+       if (main.empty)
+           return false;
+       // On boundary clicks, check whether the coordinates are inside the
+       // selection's client rectangles
+       let sel = getSelection$2(view.root);
+       if (sel.rangeCount == 0)
+           return true;
+       let rects = sel.getRangeAt(0).getClientRects();
+       for (let i = 0; i < rects.length; i++) {
+           let rect = rects[i];
+           if (rect.left <= event.clientX && rect.right >= event.clientX &&
+               rect.top <= event.clientY && rect.bottom >= event.clientY)
+               return true;
+       }
+       return false;
+   }
+   function eventBelongsToEditor$2(view, event) {
+       if (!event.bubbles)
+           return true;
+       if (event.defaultPrevented)
+           return false;
+       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
+           if (!node || node.nodeType == 11 || ((cView = ContentView$2.get(node)) && cView.ignoreEvent(event)))
+               return false;
+       return true;
+   }
+   const handlers$2 = /*@__PURE__*/Object.create(null);
+   // This is very crude, but unfortunately both these browsers _pretend_
+   // that they have a clipboard API—all the objects and methods are
+   // there, they just don't work, and they are hard to test.
+   const brokenClipboardAPI$2 = (browser$2.ie && browser$2.ie_version < 15) ||
+       (browser$2.ios && browser$2.webkit_version < 604);
+   function capturePaste$2(view) {
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.focus();
+       setTimeout(() => {
+           view.focus();
+           target.remove();
+           doPaste$2(view, target.value);
+       }, 50);
+   }
+   function doPaste$2(view, input) {
+       let { state } = view, changes, i = 1, text = state.toText(input);
+       let byLine = text.lines == state.selection.ranges.length;
+       let linewise = lastLinewiseCopy$2 != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy$2 == text.toString();
+       if (linewise) {
+           let lastLine = -1;
+           changes = state.changeByRange(range => {
+               let line = state.doc.lineAt(range.from);
+               if (line.from == lastLine)
+                   return { range };
+               lastLine = line.from;
+               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
+               return { changes: { from: line.from, insert },
+                   range: EditorSelection$2.cursor(range.from + insert.length) };
+           });
+       }
+       else if (byLine) {
+           changes = state.changeByRange(range => {
+               let line = text.line(i++);
+               return { changes: { from: range.from, to: range.to, insert: line.text },
+                   range: EditorSelection$2.cursor(range.from + line.length) };
+           });
+       }
+       else {
+           changes = state.replaceSelection(text);
+       }
+       view.dispatch(changes, {
+           userEvent: "input.paste",
+           scrollIntoView: true
+       });
+   }
+   handlers$2.keydown = (view, event) => {
+       view.inputState.setSelectionOrigin("select");
+       if (event.keyCode == 27)
+           view.inputState.lastEscPress = Date.now();
+       else if (modifierCodes$2.indexOf(event.keyCode) < 0)
+           view.inputState.lastEscPress = 0;
+   };
+   let lastTouch$1 = 0;
+   handlers$2.touchstart = (view, e) => {
+       lastTouch$1 = Date.now();
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   handlers$2.touchmove = view => {
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   handlers$2.mousedown = (view, event) => {
+       view.observer.flush();
+       if (lastTouch$1 > Date.now() - 2000 && getClickType$2(event) == 1)
+           return; // Ignore touch interaction
+       let style = null;
+       for (let makeStyle of view.state.facet(mouseSelectionStyle$2)) {
+           style = makeStyle(view, event);
+           if (style)
+               break;
+       }
+       if (!style && event.button == 0)
+           style = basicMouseSelection$2(view, event);
+       if (style) {
+           let mustFocus = view.root.activeElement != view.contentDOM;
+           if (mustFocus)
+               view.observer.ignore(() => focusPreventScroll$2(view.contentDOM));
+           view.inputState.startMouseSelection(new MouseSelection$2(view, event, style, mustFocus));
+       }
+   };
+   function rangeForClick$2(view, pos, bias, type) {
+       if (type == 1) { // Single click
+           return EditorSelection$2.cursor(pos, bias);
+       }
+       else if (type == 2) { // Double click
+           return groupAt$2(view.state, pos, bias);
+       }
+       else { // Triple click
+           let visual = LineView$2.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
+           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
+           if (to < view.state.doc.length && to == line.to)
+               to++;
+           return EditorSelection$2.range(from, to);
+       }
+   }
+   let insideY$1 = (y, rect) => y >= rect.top && y <= rect.bottom;
+   let inside$2 = (x, y, rect) => insideY$1(y, rect) && x >= rect.left && x <= rect.right;
+   // Try to determine, for the given coordinates, associated with the
+   // given position, whether they are related to the element before or
+   // the element after the position.
+   function findPositionSide$2(view, pos, x, y) {
+       let line = LineView$2.find(view.docView, pos);
+       if (!line)
+           return 1;
+       let off = pos - line.posAtStart;
+       // Line boundaries point into the line
+       if (off == 0)
+           return 1;
+       if (off == line.length)
+           return -1;
+       // Positions on top of an element point at that element
+       let before = line.coordsAt(off, -1);
+       if (before && inside$2(x, y, before))
+           return -1;
+       let after = line.coordsAt(off, 1);
+       if (after && inside$2(x, y, after))
+           return 1;
+       // This is probably a line wrap point. Pick before if the point is
+       // beside it.
+       return before && insideY$1(y, before) ? -1 : 1;
+   }
+   function queryPos$2(view, event) {
+       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       return { pos, bias: findPositionSide$2(view, pos, event.clientX, event.clientY) };
+   }
+   const BadMouseDetail$2 = browser$2.ie && browser$2.ie_version <= 11;
+   let lastMouseDown$2 = null, lastMouseDownCount$2 = 0, lastMouseDownTime$2 = 0;
+   function getClickType$2(event) {
+       if (!BadMouseDetail$2)
+           return event.detail;
+       let last = lastMouseDown$2, lastTime = lastMouseDownTime$2;
+       lastMouseDown$2 = event;
+       lastMouseDownTime$2 = Date.now();
+       return lastMouseDownCount$2 = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
+           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount$2 + 1) % 3 : 1;
+   }
+   function basicMouseSelection$2(view, event) {
+       let start = queryPos$2(view, event), type = getClickType$2(event);
+       let startSel = view.state.selection;
+       let last = start, lastEvent = event;
+       return {
+           update(update) {
+               if (update.docChanged) {
+                   if (start)
+                       start.pos = update.changes.mapPos(start.pos);
+                   startSel = startSel.map(update.changes);
+                   lastEvent = null;
+               }
+           },
+           get(event, extend, multiple) {
+               let cur;
+               if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
+                   cur = last;
+               else {
+                   cur = last = queryPos$2(view, event);
+                   lastEvent = event;
+               }
+               if (!cur || !start)
+                   return startSel;
+               let range = rangeForClick$2(view, cur.pos, cur.bias, type);
+               if (start.pos != cur.pos && !extend) {
+                   let startRange = rangeForClick$2(view, start.pos, start.bias, type);
+                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
+                   range = from < range.from ? EditorSelection$2.range(from, to) : EditorSelection$2.range(to, from);
+               }
+               if (extend)
+                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
+               else if (multiple)
+                   return startSel.addRange(range);
+               else
+                   return EditorSelection$2.create([range]);
+           }
+       };
+   }
+   handlers$2.dragstart = (view, event) => {
+       let { selection: { main } } = view.state;
+       let { mouseSelection } = view.inputState;
+       if (mouseSelection)
+           mouseSelection.dragging = main;
+       if (event.dataTransfer) {
+           event.dataTransfer.setData("Text", view.state.sliceDoc(main.from, main.to));
+           event.dataTransfer.effectAllowed = "copyMove";
+       }
+   };
+   function dropText$2(view, event, text, direct) {
+       if (!text)
+           return;
+       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       event.preventDefault();
+       let { mouseSelection } = view.inputState;
+       let del = direct && mouseSelection && mouseSelection.dragging && mouseSelection.dragMove ?
+           { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;
+       let ins = { from: dropPos, insert: text };
+       let changes = view.state.changes(del ? [del, ins] : ins);
+       view.focus();
+       view.dispatch({
+           changes,
+           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
+           userEvent: del ? "move.drop" : "input.drop"
+       });
+   }
+   handlers$2.drop = (view, event) => {
+       if (!event.dataTransfer)
+           return;
+       if (view.state.readOnly)
+           return event.preventDefault();
+       let files = event.dataTransfer.files;
+       if (files && files.length) { // For a file drop, read the file's text.
+           event.preventDefault();
+           let text = Array(files.length), read = 0;
+           let finishFile = () => {
+               if (++read == files.length)
+                   dropText$2(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
+           };
+           for (let i = 0; i < files.length; i++) {
+               let reader = new FileReader;
+               reader.onerror = finishFile;
+               reader.onload = () => {
+                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
+                       text[i] = reader.result;
+                   finishFile();
+               };
+               reader.readAsText(files[i]);
+           }
+       }
+       else {
+           dropText$2(view, event, event.dataTransfer.getData("Text"), true);
+       }
+   };
+   handlers$2.paste = (view, event) => {
+       if (view.state.readOnly)
+           return event.preventDefault();
+       view.observer.flush();
+       let data = brokenClipboardAPI$2 ? null : event.clipboardData;
+       if (data) {
+           doPaste$2(view, data.getData("text/plain"));
+           event.preventDefault();
+       }
+       else {
+           capturePaste$2(view);
+       }
+   };
+   function captureCopy$2(view, text) {
+       // The extra wrapper is somehow necessary on IE/Edge to prevent the
+       // content from being mangled when it is put onto the clipboard
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.value = text;
+       target.focus();
+       target.selectionEnd = text.length;
+       target.selectionStart = 0;
+       setTimeout(() => {
+           target.remove();
+           view.focus();
+       }, 50);
+   }
+   function copiedRange$2(state) {
+       let content = [], ranges = [], linewise = false;
+       for (let range of state.selection.ranges)
+           if (!range.empty) {
+               content.push(state.sliceDoc(range.from, range.to));
+               ranges.push(range);
+           }
+       if (!content.length) {
+           // Nothing selected, do a line-wise copy
+           let upto = -1;
+           for (let { from } of state.selection.ranges) {
+               let line = state.doc.lineAt(from);
+               if (line.number > upto) {
+                   content.push(line.text);
+                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
+               }
+               upto = line.number;
+           }
+           linewise = true;
+       }
+       return { text: content.join(state.lineBreak), ranges, linewise };
+   }
+   let lastLinewiseCopy$2 = null;
+   handlers$2.copy = handlers$2.cut = (view, event) => {
+       let { text, ranges, linewise } = copiedRange$2(view.state);
+       if (!text && !linewise)
+           return;
+       lastLinewiseCopy$2 = linewise ? text : null;
+       let data = brokenClipboardAPI$2 ? null : event.clipboardData;
+       if (data) {
+           event.preventDefault();
+           data.clearData();
+           data.setData("text/plain", text);
+       }
+       else {
+           captureCopy$2(view, text);
+       }
+       if (event.type == "cut" && !view.state.readOnly)
+           view.dispatch({
+               changes: ranges,
+               scrollIntoView: true,
+               userEvent: "delete.cut"
+           });
+   };
+   function updateForFocusChange$2(view) {
+       setTimeout(() => {
+           if (view.hasFocus != view.inputState.notifiedFocused)
+               view.update([]);
+       }, 10);
+   }
+   handlers$2.focus = updateForFocusChange$2;
+   handlers$2.blur = view => {
+       view.observer.clearSelectionRange();
+       updateForFocusChange$2(view);
+   };
+   function forceClearComposition$1(view, rapid) {
+       if (view.docView.compositionDeco.size) {
+           view.inputState.rapidCompositionStart = rapid;
+           try {
+               view.update([]);
+           }
+           finally {
+               view.inputState.rapidCompositionStart = false;
+           }
+       }
+   }
+   handlers$2.compositionstart = handlers$2.compositionupdate = view => {
+       if (view.inputState.compositionFirstChange == null)
+           view.inputState.compositionFirstChange = true;
+       if (view.inputState.composing < 0) {
+           // FIXME possibly set a timeout to clear it again on Android
+           view.inputState.composing = 0;
+           if (view.docView.compositionDeco.size) {
+               view.observer.flush();
+               forceClearComposition$1(view, true);
+           }
+       }
+   };
+   handlers$2.compositionend = view => {
+       view.inputState.composing = -1;
+       view.inputState.compositionEndedAt = Date.now();
+       view.inputState.compositionFirstChange = null;
+       setTimeout(() => {
+           if (view.inputState.composing < 0)
+               forceClearComposition$1(view, false);
+       }, 50);
+   };
+   handlers$2.contextmenu = view => {
+       view.inputState.lastContextMenu = Date.now();
+   };
+   handlers$2.beforeinput = (view, event) => {
+       var _a;
+       // Because Chrome Android doesn't fire useful key events, use
+       // beforeinput to detect backspace (and possibly enter and delete,
+       // but those usually don't even seem to fire beforeinput events at
+       // the moment) and fake a key event for it.
+       //
+       // (preventDefault on beforeinput, though supported in the spec,
+       // seems to do nothing at all on Chrome).
+       let pending;
+       if (browser$2.chrome && browser$2.android && (pending = PendingKeys$2.find(key => key.inputType == event.inputType))) {
+           view.observer.delayAndroidKey(pending.key, pending.keyCode);
+           if (pending.key == "Backspace" || pending.key == "Delete") {
+               let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
+               setTimeout(() => {
+                   var _a;
+                   // Backspacing near uneditable nodes on Chrome Android sometimes
+                   // closes the virtual keyboard. This tries to crudely detect
+                   // that and refocus to get it back.
+                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
+                       view.contentDOM.blur();
+                       view.focus();
+                   }
+               }, 100);
+           }
+       }
+   };
+
+   const wrappingWhiteSpace$2 = ["pre-wrap", "normal", "pre-line", "break-spaces"];
+   let HeightOracle$2 = class HeightOracle {
+       constructor() {
+           this.doc = Text$2.empty;
+           this.lineWrapping = false;
+           this.heightSamples = {};
+           this.lineHeight = 14;
+           this.charWidth = 7;
+           this.lineLength = 30;
+           // Used to track, during updateHeight, if any actual heights changed
+           this.heightChanged = false;
+       }
+       heightForGap(from, to) {
+           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
+           if (this.lineWrapping)
+               lines += Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength);
+           return this.lineHeight * lines;
+       }
+       heightForLine(length) {
+           if (!this.lineWrapping)
+               return this.lineHeight;
+           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
+           return lines * this.lineHeight;
+       }
+       setDoc(doc) { this.doc = doc; return this; }
+       mustRefreshForWrapping(whiteSpace) {
+           return (wrappingWhiteSpace$2.indexOf(whiteSpace) > -1) != this.lineWrapping;
+       }
+       mustRefreshForHeights(lineHeights) {
+           let newHeight = false;
+           for (let i = 0; i < lineHeights.length; i++) {
+               let h = lineHeights[i];
+               if (h < 0) {
+                   i++;
+               }
+               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
+                   newHeight = true;
+                   this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return newHeight;
+       }
+       refresh(whiteSpace, lineHeight, charWidth, lineLength, knownHeights) {
+           let lineWrapping = wrappingWhiteSpace$2.indexOf(whiteSpace) > -1;
+           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
+           this.lineWrapping = lineWrapping;
+           this.lineHeight = lineHeight;
+           this.charWidth = charWidth;
+           this.lineLength = lineLength;
+           if (changed) {
+               this.heightSamples = {};
+               for (let i = 0; i < knownHeights.length; i++) {
+                   let h = knownHeights[i];
+                   if (h < 0)
+                       i++;
+                   else
+                       this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return changed;
+       }
+   };
+   // This object is used by `updateHeight` to make DOM measurements
+   // arrive at the right nides. The `heights` array is a sequence of
+   // block heights, starting from position `from`.
+   let MeasuredHeights$2 = class MeasuredHeights {
+       constructor(from, heights) {
+           this.from = from;
+           this.heights = heights;
+           this.index = 0;
+       }
+       get more() { return this.index < this.heights.length; }
+   };
+   /**
+   Record used to represent information about a block-level element
+   in the editor view.
+   */
+   let BlockInfo$2 = class BlockInfo {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the element in the document.
+       */
+       from, 
+       /**
+       The length of the element.
+       */
+       length, 
+       /**
+       The top position of the element (relative to the top of the
+       document).
+       */
+       top, 
+       /**
+       Its height.
+       */
+       height, 
+       /**
+       The type of element this is. When querying lines, this may be
+       an array of all the blocks that make up the line.
+       */
+       type) {
+           this.from = from;
+           this.length = length;
+           this.top = top;
+           this.height = height;
+           this.type = type;
+       }
+       /**
+       The end of the element as a document position.
+       */
+       get to() { return this.from + this.length; }
+       /**
+       The bottom position of the element.
+       */
+       get bottom() { return this.top + this.height; }
+       /**
+       @internal
+       */
+       join(other) {
+           let detail = (Array.isArray(this.type) ? this.type : [this])
+               .concat(Array.isArray(other.type) ? other.type : [other]);
+           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
+       }
+   };
+   var QueryType$3 = /*@__PURE__*/(function (QueryType) {
+       QueryType[QueryType["ByPos"] = 0] = "ByPos";
+       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
+       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
+   return QueryType})(QueryType$3 || (QueryType$3 = {}));
+   const Epsilon$2 = 1e-3;
+   let HeightMap$2 = class HeightMap {
+       constructor(length, // The number of characters covered
+       height, // Height of this part of the document
+       flags = 2 /* Outdated */) {
+           this.length = length;
+           this.height = height;
+           this.flags = flags;
+       }
+       get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
+       set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
+       setHeight(oracle, height) {
+           if (this.height != height) {
+               if (Math.abs(this.height - height) > Epsilon$2)
+                   oracle.heightChanged = true;
+               this.height = height;
+           }
+       }
+       // Base case is to replace a leaf node, which simply builds a tree
+       // from the new nodes and returns that (HeightMapBranch and
+       // HeightMapGap override this to actually use from/to)
+       replace(_from, _to, nodes) {
+           return HeightMap.of(nodes);
+       }
+       // Again, these are base cases, and are overridden for branch and gap nodes.
+       decomposeLeft(_to, result) { result.push(this); }
+       decomposeRight(_from, result) { result.push(this); }
+       applyChanges(decorations, oldDoc, oracle, changes) {
+           let me = this;
+           for (let i = changes.length - 1; i >= 0; i--) {
+               let { fromA, toA, fromB, toB } = changes[i];
+               let start = me.lineAt(fromA, QueryType$3.ByPosNoHeight, oldDoc, 0, 0);
+               let end = start.to >= toA ? start : me.lineAt(toA, QueryType$3.ByPosNoHeight, oldDoc, 0, 0);
+               toB += end.to - toA;
+               toA = end.to;
+               while (i > 0 && start.from <= changes[i - 1].toA) {
+                   fromA = changes[i - 1].fromA;
+                   fromB = changes[i - 1].fromB;
+                   i--;
+                   if (fromA < start.from)
+                       start = me.lineAt(fromA, QueryType$3.ByPosNoHeight, oldDoc, 0, 0);
+               }
+               fromB += start.from - fromA;
+               fromA = start.from;
+               let nodes = NodeBuilder$2.build(oracle, decorations, fromB, toB);
+               me = me.replace(fromA, toA, nodes);
+           }
+           return me.updateHeight(oracle, 0);
+       }
+       static empty() { return new HeightMapText$2(0, 0); }
+       // nodes uses null values to indicate the position of line breaks.
+       // There are never line breaks at the start or end of the array, or
+       // two line breaks next to each other, and the array isn't allowed
+       // to be empty (same restrictions as return value from the builder).
+       static of(nodes) {
+           if (nodes.length == 1)
+               return nodes[0];
+           let i = 0, j = nodes.length, before = 0, after = 0;
+           for (;;) {
+               if (i == j) {
+                   if (before > after * 2) {
+                       let split = nodes[i - 1];
+                       if (split.break)
+                           nodes.splice(--i, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(--i, 1, split.left, split.right);
+                       j += 1 + split.break;
+                       before -= split.size;
+                   }
+                   else if (after > before * 2) {
+                       let split = nodes[j];
+                       if (split.break)
+                           nodes.splice(j, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(j, 1, split.left, split.right);
+                       j += 2 + split.break;
+                       after -= split.size;
+                   }
+                   else {
+                       break;
+                   }
+               }
+               else if (before < after) {
+                   let next = nodes[i++];
+                   if (next)
+                       before += next.size;
+               }
+               else {
+                   let next = nodes[--j];
+                   if (next)
+                       after += next.size;
+               }
+           }
+           let brk = 0;
+           if (nodes[i - 1] == null) {
+               brk = 1;
+               i--;
+           }
+           else if (nodes[i] == null) {
+               brk = 1;
+               j++;
+           }
+           return new HeightMapBranch$2(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
+       }
+   };
+   HeightMap$2.prototype.size = 1;
+   let HeightMapBlock$2 = class HeightMapBlock extends HeightMap$2 {
+       constructor(length, height, type) {
+           super(length, height);
+           this.type = type;
+       }
+       blockAt(_height, _doc, top, offset) {
+           return new BlockInfo$2(offset, this.length, top, this.height, this.type);
+       }
+       lineAt(_value, _type, doc, top, offset) {
+           return this.blockAt(0, doc, top, offset);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           if (from <= offset + this.length && to >= offset)
+               f(this.blockAt(0, doc, top, offset));
+       }
+       updateHeight(oracle, offset = 0, _force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(oracle, measured.heights[measured.index++]);
+           this.outdated = false;
+           return this;
+       }
+       toString() { return `block(${this.length})`; }
+   };
+   let HeightMapText$2 = class HeightMapText extends HeightMapBlock$2 {
+       constructor(length, height) {
+           super(length, height, BlockType$2.Text);
+           this.collapsed = 0; // Amount of collapsed content in the line
+           this.widgetHeight = 0; // Maximum inline widget height
+       }
+       replace(_from, _to, nodes) {
+           let node = nodes[0];
+           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap$2 && (node.flags & 4 /* SingleLine */)) &&
+               Math.abs(this.length - node.length) < 10) {
+               if (node instanceof HeightMapGap$2)
+                   node = new HeightMapText(node.length, this.height);
+               else
+                   node.height = this.height;
+               if (!this.outdated)
+                   node.outdated = false;
+               return node;
+           }
+           else {
+               return HeightMap$2.of(nodes);
+           }
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(oracle, measured.heights[measured.index++]);
+           else if (force || this.outdated)
+               this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)));
+           this.outdated = false;
+           return this;
+       }
+       toString() {
+           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
+       }
+   };
+   let HeightMapGap$2 = class HeightMapGap extends HeightMap$2 {
+       constructor(length) { super(length, 0); }
+       lines(doc, offset) {
+           let firstLine = doc.lineAt(offset).number, lastLine = doc.lineAt(offset + this.length).number;
+           return { firstLine, lastLine, lineHeight: this.height / (lastLine - firstLine + 1) };
+       }
+       blockAt(height, doc, top, offset) {
+           let { firstLine, lastLine, lineHeight } = this.lines(doc, offset);
+           let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / lineHeight)));
+           let { from, length } = doc.line(firstLine + line);
+           return new BlockInfo$2(from, length, top + lineHeight * line, lineHeight, BlockType$2.Text);
+       }
+       lineAt(value, type, doc, top, offset) {
+           if (type == QueryType$3.ByHeight)
+               return this.blockAt(value, doc, top, offset);
+           if (type == QueryType$3.ByPosNoHeight) {
+               let { from, to } = doc.lineAt(value);
+               return new BlockInfo$2(from, to - from, 0, 0, BlockType$2.Text);
+           }
+           let { firstLine, lineHeight } = this.lines(doc, offset);
+           let { from, length, number } = doc.lineAt(value);
+           return new BlockInfo$2(from, length, top + lineHeight * (number - firstLine), lineHeight, BlockType$2.Text);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           let { firstLine, lineHeight } = this.lines(doc, offset);
+           for (let pos = Math.max(from, offset), end = Math.min(offset + this.length, to); pos <= end;) {
+               let line = doc.lineAt(pos);
+               if (pos == from)
+                   top += lineHeight * (line.number - firstLine);
+               f(new BlockInfo$2(line.from, line.length, top, lineHeight, BlockType$2.Text));
+               top += lineHeight;
+               pos = line.to + 1;
+           }
+       }
+       replace(from, to, nodes) {
+           let after = this.length - to;
+           if (after > 0) {
+               let last = nodes[nodes.length - 1];
+               if (last instanceof HeightMapGap)
+                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
+               else
+                   nodes.push(null, new HeightMapGap(after - 1));
+           }
+           if (from > 0) {
+               let first = nodes[0];
+               if (first instanceof HeightMapGap)
+                   nodes[0] = new HeightMapGap(from + first.length);
+               else
+                   nodes.unshift(new HeightMapGap(from - 1), null);
+           }
+           return HeightMap$2.of(nodes);
+       }
+       decomposeLeft(to, result) {
+           result.push(new HeightMapGap(to - 1), null);
+       }
+       decomposeRight(from, result) {
+           result.push(null, new HeightMapGap(this.length - from - 1));
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let end = offset + this.length;
+           if (measured && measured.from <= offset + this.length && measured.more) {
+               // Fill in part of this gap with measured lines. We know there
+               // can't be widgets or collapsed ranges in those lines, because
+               // they would already have been added to the heightmap (gaps
+               // only contain plain text).
+               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
+               let wasChanged = oracle.heightChanged;
+               if (measured.from > offset)
+                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
+               while (pos <= end && measured.more) {
+                   let len = oracle.doc.lineAt(pos).length;
+                   if (nodes.length)
+                       nodes.push(null);
+                   let height = measured.heights[measured.index++];
+                   if (singleHeight == -1)
+                       singleHeight = height;
+                   else if (Math.abs(height - singleHeight) >= Epsilon$2)
+                       singleHeight = -2;
+                   let line = new HeightMapText$2(len, height);
+                   line.outdated = false;
+                   nodes.push(line);
+                   pos += len + 1;
+               }
+               if (pos <= end)
+                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
+               let result = HeightMap$2.of(nodes);
+               oracle.heightChanged = wasChanged || singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon$2 ||
+                   Math.abs(singleHeight - this.lines(oracle.doc, offset).lineHeight) >= Epsilon$2;
+               return result;
+           }
+           else if (force || this.outdated) {
+               this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));
+               this.outdated = false;
+           }
+           return this;
+       }
+       toString() { return `gap(${this.length})`; }
+   };
+   let HeightMapBranch$2 = class HeightMapBranch extends HeightMap$2 {
+       constructor(left, brk, right) {
+           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
+           this.left = left;
+           this.right = right;
+           this.size = left.size + right.size;
+       }
+       get break() { return this.flags & 1 /* Break */; }
+       blockAt(height, doc, top, offset) {
+           let mid = top + this.left.height;
+           return height < mid ? this.left.blockAt(height, doc, top, offset)
+               : this.right.blockAt(height, doc, mid, offset + this.left.length + this.break);
+       }
+       lineAt(value, type, doc, top, offset) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           let left = type == QueryType$3.ByHeight ? value < rightTop : value < rightOffset;
+           let base = left ? this.left.lineAt(value, type, doc, top, offset)
+               : this.right.lineAt(value, type, doc, rightTop, rightOffset);
+           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
+               return base;
+           let subQuery = type == QueryType$3.ByPosNoHeight ? QueryType$3.ByPosNoHeight : QueryType$3.ByPos;
+           if (left)
+               return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));
+           else
+               return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           if (this.break) {
+               if (from < rightOffset)
+                   this.left.forEachLine(from, to, doc, top, offset, f);
+               if (to >= rightOffset)
+                   this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
+           }
+           else {
+               let mid = this.lineAt(rightOffset, QueryType$3.ByPos, doc, top, offset);
+               if (from < mid.from)
+                   this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
+               if (mid.to >= from && mid.from <= to)
+                   f(mid);
+               if (to > mid.to)
+                   this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
+           }
+       }
+       replace(from, to, nodes) {
+           let rightStart = this.left.length + this.break;
+           if (to < rightStart)
+               return this.balanced(this.left.replace(from, to, nodes), this.right);
+           if (from > this.left.length)
+               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
+           let result = [];
+           if (from > 0)
+               this.decomposeLeft(from, result);
+           let left = result.length;
+           for (let node of nodes)
+               result.push(node);
+           if (from > 0)
+               mergeGaps$2(result, left - 1);
+           if (to < this.length) {
+               let right = result.length;
+               this.decomposeRight(to, result);
+               mergeGaps$2(result, right);
+           }
+           return HeightMap$2.of(result);
+       }
+       decomposeLeft(to, result) {
+           let left = this.left.length;
+           if (to <= left)
+               return this.left.decomposeLeft(to, result);
+           result.push(this.left);
+           if (this.break) {
+               left++;
+               if (to >= left)
+                   result.push(null);
+           }
+           if (to > left)
+               this.right.decomposeLeft(to - left, result);
+       }
+       decomposeRight(from, result) {
+           let left = this.left.length, right = left + this.break;
+           if (from >= right)
+               return this.right.decomposeRight(from - right, result);
+           if (from < left)
+               this.left.decomposeRight(from, result);
+           if (this.break && from < right)
+               result.push(null);
+           result.push(this.right);
+       }
+       balanced(left, right) {
+           if (left.size > 2 * right.size || right.size > 2 * left.size)
+               return HeightMap$2.of(this.break ? [left, null, right] : [left, right]);
+           this.left = left;
+           this.right = right;
+           this.height = left.height + right.height;
+           this.outdated = left.outdated || right.outdated;
+           this.size = left.size + right.size;
+           this.length = left.length + this.break + right.length;
+           return this;
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
+           if (measured && measured.from <= offset + left.length && measured.more)
+               rebalance = left = left.updateHeight(oracle, offset, force, measured);
+           else
+               left.updateHeight(oracle, offset, force);
+           if (measured && measured.from <= rightStart + right.length && measured.more)
+               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
+           else
+               right.updateHeight(oracle, rightStart, force);
+           if (rebalance)
+               return this.balanced(left, right);
+           this.height = this.left.height + this.right.height;
+           this.outdated = false;
+           return this;
+       }
+       toString() { return this.left + (this.break ? " " : "-") + this.right; }
+   };
+   function mergeGaps$2(nodes, around) {
+       let before, after;
+       if (nodes[around] == null &&
+           (before = nodes[around - 1]) instanceof HeightMapGap$2 &&
+           (after = nodes[around + 1]) instanceof HeightMapGap$2)
+           nodes.splice(around - 1, 3, new HeightMapGap$2(before.length + 1 + after.length));
+   }
+   const relevantWidgetHeight$2 = 5;
+   let NodeBuilder$2 = class NodeBuilder {
+       constructor(pos, oracle) {
+           this.pos = pos;
+           this.oracle = oracle;
+           this.nodes = [];
+           this.lineStart = -1;
+           this.lineEnd = -1;
+           this.covering = null;
+           this.writtenTo = pos;
+       }
+       get isCovered() {
+           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
+       }
+       span(_from, to) {
+           if (this.lineStart > -1) {
+               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
+               if (last instanceof HeightMapText$2)
+                   last.length += end - this.pos;
+               else if (end > this.pos || !this.isCovered)
+                   this.nodes.push(new HeightMapText$2(end - this.pos, -1));
+               this.writtenTo = end;
+               if (to > end) {
+                   this.nodes.push(null);
+                   this.writtenTo++;
+                   this.lineStart = -1;
+               }
+           }
+           this.pos = to;
+       }
+       point(from, to, deco) {
+           if (from < to || deco.heightRelevant) {
+               let height = deco.widget ? deco.widget.estimatedHeight : 0;
+               if (height < 0)
+                   height = this.oracle.lineHeight;
+               let len = to - from;
+               if (deco.block) {
+                   this.addBlock(new HeightMapBlock$2(len, height, deco.type));
+               }
+               else if (len || height >= relevantWidgetHeight$2) {
+                   this.addLineDeco(height, len);
+               }
+           }
+           else if (to > from) {
+               this.span(from, to);
+           }
+           if (this.lineEnd > -1 && this.lineEnd < this.pos)
+               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
+       }
+       enterLine() {
+           if (this.lineStart > -1)
+               return;
+           let { from, to } = this.oracle.doc.lineAt(this.pos);
+           this.lineStart = from;
+           this.lineEnd = to;
+           if (this.writtenTo < from) {
+               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
+                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
+               this.nodes.push(null);
+           }
+           if (this.pos > from)
+               this.nodes.push(new HeightMapText$2(this.pos - from, -1));
+           this.writtenTo = this.pos;
+       }
+       blankContent(from, to) {
+           let gap = new HeightMapGap$2(to - from);
+           if (this.oracle.doc.lineAt(from).to == to)
+               gap.flags |= 4 /* SingleLine */;
+           return gap;
+       }
+       ensureLine() {
+           this.enterLine();
+           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
+           if (last instanceof HeightMapText$2)
+               return last;
+           let line = new HeightMapText$2(0, -1);
+           this.nodes.push(line);
+           return line;
+       }
+       addBlock(block) {
+           this.enterLine();
+           if (block.type == BlockType$2.WidgetAfter && !this.isCovered)
+               this.ensureLine();
+           this.nodes.push(block);
+           this.writtenTo = this.pos = this.pos + block.length;
+           if (block.type != BlockType$2.WidgetBefore)
+               this.covering = block;
+       }
+       addLineDeco(height, length) {
+           let line = this.ensureLine();
+           line.length += length;
+           line.collapsed += length;
+           line.widgetHeight = Math.max(line.widgetHeight, height);
+           this.writtenTo = this.pos = this.pos + length;
+       }
+       finish(from) {
+           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
+           if (this.lineStart > -1 && !(last instanceof HeightMapText$2) && !this.isCovered)
+               this.nodes.push(new HeightMapText$2(0, -1));
+           else if (this.writtenTo < this.pos || last == null)
+               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
+           let pos = from;
+           for (let node of this.nodes) {
+               if (node instanceof HeightMapText$2)
+                   node.updateHeight(this.oracle, pos);
+               pos += node ? node.length : 1;
+           }
+           return this.nodes;
+       }
+       // Always called with a region that on both sides either stretches
+       // to a line break or the end of the document.
+       // The returned array uses null to indicate line breaks, but never
+       // starts or ends in a line break, or has multiple line breaks next
+       // to each other.
+       static build(oracle, decorations, from, to) {
+           let builder = new NodeBuilder(from, oracle);
+           RangeSet$2.spans(decorations, from, to, builder, 0);
+           return builder.finish(from);
+       }
+   };
+   function heightRelevantDecoChanges$2(a, b, diff) {
+       let comp = new DecorationComparator$3;
+       RangeSet$2.compare(a, b, diff, comp, 0);
+       return comp.changes;
+   }
+   let DecorationComparator$3 = class DecorationComparator {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange() { }
+       comparePoint(from, to, a, b) {
+           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
+               addRange$2(from, to, this.changes, 5);
+       }
+   };
+
+   function visiblePixelRange$2(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       let left = Math.max(0, rect.left), right = Math.min(innerWidth, rect.right);
+       let top = Math.max(0, rect.top), bottom = Math.min(innerHeight, rect.bottom);
+       let body = dom.ownerDocument.body;
+       for (let parent = dom.parentNode; parent && parent != body;) {
+           if (parent.nodeType == 1) {
+               let elt = parent;
+               let style = window.getComputedStyle(elt);
+               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
+                   style.overflow != "visible") {
+                   let parentRect = elt.getBoundingClientRect();
+                   left = Math.max(left, parentRect.left);
+                   right = Math.min(right, parentRect.right);
+                   top = Math.max(top, parentRect.top);
+                   bottom = Math.min(bottom, parentRect.bottom);
+               }
+               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
+           }
+           else if (parent.nodeType == 11) { // Shadow root
+               parent = parent.host;
+           }
+           else {
+               break;
+           }
+       }
+       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
+           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
+   }
+   function fullPixelRange$2(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       return { left: 0, right: rect.right - rect.left,
+           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
+   }
+   // Line gaps are placeholder widgets used to hide pieces of overlong
+   // lines within the viewport, as a kludge to keep the editor
+   // responsive when a ridiculously long line is loaded into it.
+   let LineGap$2 = class LineGap {
+       constructor(from, to, size) {
+           this.from = from;
+           this.to = to;
+           this.size = size;
+       }
+       static same(a, b) {
+           if (a.length != b.length)
+               return false;
+           for (let i = 0; i < a.length; i++) {
+               let gA = a[i], gB = b[i];
+               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
+                   return false;
+           }
+           return true;
+       }
+       draw(wrapping) {
+           return Decoration$2.replace({ widget: new LineGapWidget$2(this.size, wrapping) }).range(this.from, this.to);
+       }
+   };
+   let LineGapWidget$2 = class LineGapWidget extends WidgetType$2 {
+       constructor(size, vertical) {
+           super();
+           this.size = size;
+           this.vertical = vertical;
+       }
+       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
+       toDOM() {
+           let elt = document.createElement("div");
+           if (this.vertical) {
+               elt.style.height = this.size + "px";
+           }
+           else {
+               elt.style.width = this.size + "px";
+               elt.style.height = "2px";
+               elt.style.display = "inline-block";
+           }
+           return elt;
+       }
+       get estimatedHeight() { return this.vertical ? this.size : -1; }
+   };
+   let ViewState$2 = class ViewState {
+       constructor(state) {
+           this.state = state;
+           // These are contentDOM-local coordinates
+           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
+           this.inView = true;
+           this.paddingTop = 0;
+           this.paddingBottom = 0;
+           this.contentDOMWidth = 0;
+           this.contentDOMHeight = 0;
+           this.editorHeight = 0;
+           this.editorWidth = 0;
+           this.heightOracle = new HeightOracle$2;
+           // See VP.MaxDOMHeight
+           this.scaler = IdScaler$2;
+           this.scrollTarget = null;
+           // Briefly set to true when printing, to disable viewport limiting
+           this.printing = false;
+           // Flag set when editor content was redrawn, so that the next
+           // measure stage knows it must read DOM layout
+           this.mustMeasureContent = true;
+           this.defaultTextDirection = Direction$2.RTL;
+           this.visibleRanges = [];
+           // Cursor 'assoc' is only significant when the cursor is on a line
+           // wrap point, where it must stick to the character that it is
+           // associated with. Since browsers don't provide a reasonable
+           // interface to set or query this, when a selection is set that
+           // might cause this to be significant, this flag is set. The next
+           // measure phase will check whether the cursor is on a line-wrapping
+           // boundary and, if so, reset it to make sure it is positioned in
+           // the right place.
+           this.mustEnforceCursorAssoc = false;
+           this.stateDeco = state.facet(decorations$2).filter(d => typeof d != "function");
+           this.heightMap = HeightMap$2.empty().applyChanges(this.stateDeco, Text$2.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange$2(0, 0, 0, state.doc.length)]);
+           this.viewport = this.getViewport(0, null);
+           this.updateViewportLines();
+           this.updateForViewport();
+           this.lineGaps = this.ensureLineGaps([]);
+           this.lineGapDeco = Decoration$2.set(this.lineGaps.map(gap => gap.draw(false)));
+           this.computeVisibleRanges();
+       }
+       updateForViewport() {
+           let viewports = [this.viewport], { main } = this.state.selection;
+           for (let i = 0; i <= 1; i++) {
+               let pos = i ? main.head : main.anchor;
+               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
+                   let { from, to } = this.lineBlockAt(pos);
+                   viewports.push(new Viewport$2(from, to));
+               }
+           }
+           this.viewports = viewports.sort((a, b) => a.from - b.from);
+           this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler$2 :
+               new BigScaler$2(this.heightOracle.doc, this.heightMap, this.viewports);
+       }
+       updateViewportLines() {
+           this.viewportLines = [];
+           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, block => {
+               this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock$2(block, this.scaler));
+           });
+       }
+       update(update, scrollTarget = null) {
+           this.state = update.state;
+           let prevDeco = this.stateDeco;
+           this.stateDeco = this.state.facet(decorations$2).filter(d => typeof d != "function");
+           let contentChanges = update.changedRanges;
+           let heightChanges = ChangedRange$2.extendWithRanges(contentChanges, heightRelevantDecoChanges$2(prevDeco, this.stateDeco, update ? update.changes : ChangeSet$2.empty(this.state.doc.length)));
+           let prevHeight = this.heightMap.height;
+           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
+           if (this.heightMap.height != prevHeight)
+               update.flags |= 2 /* Height */;
+           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
+           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
+               !this.viewportIsAppropriate(viewport))
+               viewport = this.getViewport(0, scrollTarget);
+           let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
+               viewport.from != this.viewport.from || viewport.to != this.viewport.to;
+           this.viewport = viewport;
+           this.updateForViewport();
+           if (updateLines)
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
+               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
+           update.flags |= this.computeVisibleRanges();
+           if (scrollTarget)
+               this.scrollTarget = scrollTarget;
+           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
+               update.state.selection.main.empty && update.state.selection.main.assoc)
+               this.mustEnforceCursorAssoc = true;
+       }
+       measure(view) {
+           let dom = view.contentDOM, style = window.getComputedStyle(dom);
+           let oracle = this.heightOracle;
+           let whiteSpace = style.whiteSpace;
+           this.defaultTextDirection = style.direction == "rtl" ? Direction$2.RTL : Direction$2.LTR;
+           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
+           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
+           this.contentDOMHeight = dom.clientHeight;
+           this.mustMeasureContent = false;
+           let result = 0, bias = 0;
+           // Vertical padding
+           let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
+           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
+               this.paddingTop = paddingTop;
+               this.paddingBottom = paddingBottom;
+               result |= 8 /* Geometry */ | 2 /* Height */;
+           }
+           if (this.editorWidth != view.scrollDOM.clientWidth) {
+               if (oracle.lineWrapping)
+                   measureContent = true;
+               this.editorWidth = view.scrollDOM.clientWidth;
+               result |= 8 /* Geometry */;
+           }
+           // Pixel viewport
+           let pixelViewport = (this.printing ? fullPixelRange$2 : visiblePixelRange$2)(dom, this.paddingTop);
+           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
+           this.pixelViewport = pixelViewport;
+           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
+           if (inView != this.inView) {
+               this.inView = inView;
+               if (inView)
+                   measureContent = true;
+           }
+           if (!this.inView)
+               return 0;
+           let contentWidth = dom.clientWidth;
+           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
+               this.contentDOMWidth = contentWidth;
+               this.editorHeight = view.scrollDOM.clientHeight;
+               result |= 8 /* Geometry */;
+           }
+           if (measureContent) {
+               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
+               if (oracle.mustRefreshForHeights(lineHeights))
+                   refresh = true;
+               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
+                   let { lineHeight, charWidth } = view.docView.measureTextSize();
+                   refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
+                   if (refresh) {
+                       view.docView.minWidth = 0;
+                       result |= 8 /* Geometry */;
+                   }
+               }
+               if (dTop > 0 && dBottom > 0)
+                   bias = Math.max(dTop, dBottom);
+               else if (dTop < 0 && dBottom < 0)
+                   bias = Math.min(dTop, dBottom);
+               oracle.heightChanged = false;
+               for (let vp of this.viewports) {
+                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
+                   this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights$2(vp.from, heights));
+               }
+               if (oracle.heightChanged)
+                   result |= 2 /* Height */;
+           }
+           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
+               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
+           if (viewportChange)
+               this.viewport = this.getViewport(bias, this.scrollTarget);
+           this.updateForViewport();
+           if ((result & 2 /* Height */) || viewportChange)
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
+               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
+           result |= this.computeVisibleRanges();
+           if (this.mustEnforceCursorAssoc) {
+               this.mustEnforceCursorAssoc = false;
+               // This is done in the read stage, because moving the selection
+               // to a line end is going to trigger a layout anyway, so it
+               // can't be a pure write. It should be rare that it does any
+               // writing.
+               view.docView.enforceCursorAssoc();
+           }
+           return result;
+       }
+       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
+       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
+       getViewport(bias, scrollTarget) {
+           // This will divide VP.Margin between the top and the
+           // bottom, depending on the bias (the change in viewport position
+           // since the last update). It'll hold a number between 0 and 1
+           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
+           let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
+           let viewport = new Viewport$2(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType$3.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType$3.ByHeight, doc, 0, 0).to);
+           // If scrollTarget is given, make sure the viewport includes that position
+           if (scrollTarget) {
+               let { head } = scrollTarget.range;
+               if (head < viewport.from || head > viewport.to) {
+                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
+                   let block = map.lineAt(head, QueryType$3.ByPos, doc, 0, 0), topPos;
+                   if (scrollTarget.y == "center")
+                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
+                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
+                       topPos = block.top;
+                   else
+                       topPos = block.bottom - viewHeight;
+                   viewport = new Viewport$2(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType$3.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType$3.ByHeight, doc, 0, 0).to);
+               }
+           }
+           return viewport;
+       }
+       mapViewport(viewport, changes) {
+           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
+           return new Viewport$2(this.heightMap.lineAt(from, QueryType$3.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType$3.ByPos, this.state.doc, 0, 0).to);
+       }
+       // Checks if a given viewport covers the visible part of the
+       // document and not too much beyond that.
+       viewportIsAppropriate({ from, to }, bias = 0) {
+           if (!this.inView)
+               return true;
+           let { top } = this.heightMap.lineAt(from, QueryType$3.ByPos, this.state.doc, 0, 0);
+           let { bottom } = this.heightMap.lineAt(to, QueryType$3.ByPos, this.state.doc, 0, 0);
+           let { visibleTop, visibleBottom } = this;
+           return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
+               (to == this.state.doc.length ||
+                   bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
+               (top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
+       }
+       mapLineGaps(gaps, changes) {
+           if (!gaps.length || changes.empty)
+               return gaps;
+           let mapped = [];
+           for (let gap of gaps)
+               if (!changes.touchesRange(gap.from, gap.to))
+                   mapped.push(new LineGap$2(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));
+           return mapped;
+       }
+       // Computes positions in the viewport where the start or end of a
+       // line should be hidden, trying to reuse existing line gaps when
+       // appropriate to avoid unneccesary redraws.
+       // Uses crude character-counting for the positioning and sizing,
+       // since actual DOM coordinates aren't always available and
+       // predictable. Relies on generous margins (see LG.Margin) to hide
+       // the artifacts this might produce from the user.
+       ensureLineGaps(current) {
+           let gaps = [];
+           // This won't work at all in predominantly right-to-left text.
+           if (this.defaultTextDirection != Direction$2.LTR)
+               return gaps;
+           for (let line of this.viewportLines) {
+               if (line.length < 4000 /* DoubleMargin */)
+                   continue;
+               let structure = lineStructure$2(line.from, line.to, this.stateDeco);
+               if (structure.total < 4000 /* DoubleMargin */)
+                   continue;
+               let viewFrom, viewTo;
+               if (this.heightOracle.lineWrapping) {
+                   let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
+                   viewFrom = findPosition$2(structure, (this.visibleTop - line.top - marginHeight) / line.height);
+                   viewTo = findPosition$2(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
+               }
+               else {
+                   let totalWidth = structure.total * this.heightOracle.charWidth;
+                   let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
+                   viewFrom = findPosition$2(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
+                   viewTo = findPosition$2(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
+               }
+               let outside = [];
+               if (viewFrom > line.from)
+                   outside.push({ from: line.from, to: viewFrom });
+               if (viewTo < line.to)
+                   outside.push({ from: viewTo, to: line.to });
+               let sel = this.state.selection.main;
+               // Make sure the gaps don't cover a selection end
+               if (sel.from >= line.from && sel.from <= line.to)
+                   cutRange$1(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
+               if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
+                   cutRange$1(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
+               for (let { from, to } of outside)
+                   if (to - from > 1000 /* HalfMargin */) {
+                       gaps.push(find$2(current, gap => gap.from >= line.from && gap.to <= line.to &&
+                           Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
+                           new LineGap$2(from, to, this.gapSize(line, from, to, structure)));
+                   }
+           }
+           return gaps;
+       }
+       gapSize(line, from, to, structure) {
+           let fraction = findFraction$2(structure, to) - findFraction$2(structure, from);
+           if (this.heightOracle.lineWrapping) {
+               return line.height * fraction;
+           }
+           else {
+               return structure.total * this.heightOracle.charWidth * fraction;
+           }
+       }
+       updateLineGaps(gaps) {
+           if (!LineGap$2.same(gaps, this.lineGaps)) {
+               this.lineGaps = gaps;
+               this.lineGapDeco = Decoration$2.set(gaps.map(gap => gap.draw(this.heightOracle.lineWrapping)));
+           }
+       }
+       computeVisibleRanges() {
+           let deco = this.stateDeco;
+           if (this.lineGaps.length)
+               deco = deco.concat(this.lineGapDeco);
+           let ranges = [];
+           RangeSet$2.spans(deco, this.viewport.from, this.viewport.to, {
+               span(from, to) { ranges.push({ from, to }); },
+               point() { }
+           }, 20);
+           let changed = ranges.length != this.visibleRanges.length ||
+               this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
+           this.visibleRanges = ranges;
+           return changed ? 4 /* Viewport */ : 0;
+       }
+       lineBlockAt(pos) {
+           return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
+               scaleBlock$2(this.heightMap.lineAt(pos, QueryType$3.ByPos, this.state.doc, 0, 0), this.scaler);
+       }
+       lineBlockAtHeight(height) {
+           return scaleBlock$2(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$3.ByHeight, this.state.doc, 0, 0), this.scaler);
+       }
+       elementAtHeight(height) {
+           return scaleBlock$2(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
+       }
+       get docHeight() {
+           return this.scaler.toDOM(this.heightMap.height);
+       }
+       get contentHeight() {
+           return this.docHeight + this.paddingTop + this.paddingBottom;
+       }
+   };
+   let Viewport$2 = class Viewport {
+       constructor(from, to) {
+           this.from = from;
+           this.to = to;
+       }
+   };
+   function lineStructure$2(from, to, stateDeco) {
+       let ranges = [], pos = from, total = 0;
+       RangeSet$2.spans(stateDeco, from, to, {
+           span() { },
+           point(from, to) {
+               if (from > pos) {
+                   ranges.push({ from: pos, to: from });
+                   total += from - pos;
+               }
+               pos = to;
+           }
+       }, 20); // We're only interested in collapsed ranges of a significant size
+       if (pos < to) {
+           ranges.push({ from: pos, to });
+           total += to - pos;
+       }
+       return { total, ranges };
+   }
+   function findPosition$2({ total, ranges }, ratio) {
+       if (ratio <= 0)
+           return ranges[0].from;
+       if (ratio >= 1)
+           return ranges[ranges.length - 1].to;
+       let dist = Math.floor(total * ratio);
+       for (let i = 0;; i++) {
+           let { from, to } = ranges[i], size = to - from;
+           if (dist <= size)
+               return from + dist;
+           dist -= size;
+       }
+   }
+   function findFraction$2(structure, pos) {
+       let counted = 0;
+       for (let { from, to } of structure.ranges) {
+           if (pos <= to) {
+               counted += pos - from;
+               break;
+           }
+           counted += to - from;
+       }
+       return counted / structure.total;
+   }
+   function cutRange$1(ranges, from, to) {
+       for (let i = 0; i < ranges.length; i++) {
+           let r = ranges[i];
+           if (r.from < to && r.to > from) {
+               let pieces = [];
+               if (r.from < from)
+                   pieces.push({ from: r.from, to: from });
+               if (r.to > to)
+                   pieces.push({ from: to, to: r.to });
+               ranges.splice(i, 1, ...pieces);
+               i += pieces.length - 1;
+           }
+       }
+   }
+   function find$2(array, f) {
+       for (let val of array)
+           if (f(val))
+               return val;
+       return undefined;
+   }
+   // Don't scale when the document height is within the range of what
+   // the DOM can handle.
+   const IdScaler$2 = {
+       toDOM(n) { return n; },
+       fromDOM(n) { return n; },
+       scale: 1
+   };
+   // When the height is too big (> VP.MaxDOMHeight), scale down the
+   // regions outside the viewports so that the total height is
+   // VP.MaxDOMHeight.
+   let BigScaler$2 = class BigScaler {
+       constructor(doc, heightMap, viewports) {
+           let vpHeight = 0, base = 0, domBase = 0;
+           this.viewports = viewports.map(({ from, to }) => {
+               let top = heightMap.lineAt(from, QueryType$3.ByPos, doc, 0, 0).top;
+               let bottom = heightMap.lineAt(to, QueryType$3.ByPos, doc, 0, 0).bottom;
+               vpHeight += bottom - top;
+               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
+           });
+           this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
+           for (let obj of this.viewports) {
+               obj.domTop = domBase + (obj.top - base) * this.scale;
+               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
+               base = obj.bottom;
+           }
+       }
+       toDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.top)
+                   return domBase + (n - base) * this.scale;
+               if (n <= vp.bottom)
+                   return vp.domTop + (n - vp.top);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+       fromDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.domTop)
+                   return base + (n - domBase) / this.scale;
+               if (n <= vp.domBottom)
+                   return vp.top + (n - vp.domTop);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+   };
+   function scaleBlock$2(block, scaler) {
+       if (scaler.scale == 1)
+           return block;
+       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
+       return new BlockInfo$2(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock$2(b, scaler)) : block.type);
+   }
+
+   const theme$2 = /*@__PURE__*/Facet$2.define({ combine: strs => strs.join(" ") });
+   const darkTheme$2 = /*@__PURE__*/Facet$2.define({ combine: values => values.indexOf(true) > -1 });
+   const baseThemeID$2 = /*@__PURE__*/StyleModule.newName(), baseLightID$2 = /*@__PURE__*/StyleModule.newName(), baseDarkID$2 = /*@__PURE__*/StyleModule.newName();
+   const lightDarkIDs$2 = { "&light": "." + baseLightID$2, "&dark": "." + baseDarkID$2 };
+   function buildTheme$2(main, spec, scopes) {
+       return new StyleModule(spec, {
+           finish(sel) {
+               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
+                   if (m == "&")
+                       return main;
+                   if (!scopes || !scopes[m])
+                       throw new RangeError(`Unsupported selector: ${m}`);
+                   return scopes[m];
+               }) : main + " " + sel;
+           }
+       });
+   }
+   const baseTheme$1$3 = /*@__PURE__*/buildTheme$2("." + baseThemeID$2, {
+       "&.cm-editor": {
+           position: "relative !important",
+           boxSizing: "border-box",
+           "&.cm-focused": {
+               // Provide a simple default outline to make sure a focused
+               // editor is visually distinct. Can't leave the default behavior
+               // because that will apply to the content element, which is
+               // inside the scrollable container and doesn't include the
+               // gutters. We also can't use an 'auto' outline, since those
+               // are, for some reason, drawn behind the element content, which
+               // will cause things like the active line background to cover
+               // the outline (#297).
+               outline: "1px dotted #212121"
+           },
+           display: "flex !important",
+           flexDirection: "column"
+       },
+       ".cm-scroller": {
+           display: "flex !important",
+           alignItems: "flex-start !important",
+           fontFamily: "monospace",
+           lineHeight: 1.4,
+           height: "100%",
+           overflowX: "auto",
+           position: "relative",
+           zIndex: 0
+       },
+       ".cm-content": {
+           margin: 0,
+           flexGrow: 2,
+           minHeight: "100%",
+           display: "block",
+           whiteSpace: "pre",
+           wordWrap: "normal",
+           boxSizing: "border-box",
+           padding: "4px 0",
+           outline: "none",
+           "&[contenteditable=true]": {
+               WebkitUserModify: "read-write-plaintext-only",
+           }
+       },
+       ".cm-lineWrapping": {
+           whiteSpace_fallback: "pre-wrap",
+           whiteSpace: "break-spaces",
+           wordBreak: "break-word",
+           overflowWrap: "anywhere"
+       },
+       "&light .cm-content": { caretColor: "black" },
+       "&dark .cm-content": { caretColor: "white" },
+       ".cm-line": {
+           display: "block",
+           padding: "0 2px 0 4px"
+       },
+       ".cm-selectionLayer": {
+           zIndex: -1,
+           contain: "size style"
+       },
+       ".cm-selectionBackground": {
+           position: "absolute",
+       },
+       "&light .cm-selectionBackground": {
+           background: "#d9d9d9"
+       },
+       "&dark .cm-selectionBackground": {
+           background: "#222"
+       },
+       "&light.cm-focused .cm-selectionBackground": {
+           background: "#d7d4f0"
+       },
+       "&dark.cm-focused .cm-selectionBackground": {
+           background: "#233"
+       },
+       ".cm-cursorLayer": {
+           zIndex: 100,
+           contain: "size style",
+           pointerEvents: "none"
+       },
+       "&.cm-focused .cm-cursorLayer": {
+           animation: "steps(1) cm-blink 1.2s infinite"
+       },
+       // Two animations defined so that we can switch between them to
+       // restart the animation without forcing another style
+       // recomputation.
+       "@keyframes cm-blink": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
+       "@keyframes cm-blink2": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
+       ".cm-cursor, .cm-dropCursor": {
+           position: "absolute",
+           borderLeft: "1.2px solid black",
+           marginLeft: "-0.6px",
+           pointerEvents: "none",
+       },
+       ".cm-cursor": {
+           display: "none"
+       },
+       "&dark .cm-cursor": {
+           borderLeftColor: "#444"
+       },
+       "&.cm-focused .cm-cursor": {
+           display: "block"
+       },
+       "&light .cm-activeLine": { backgroundColor: "#f3f9ff" },
+       "&dark .cm-activeLine": { backgroundColor: "#223039" },
+       "&light .cm-specialChar": { color: "red" },
+       "&dark .cm-specialChar": { color: "#f78" },
+       ".cm-gutters": {
+           display: "flex",
+           height: "100%",
+           boxSizing: "border-box",
+           left: 0,
+           zIndex: 200
+       },
+       "&light .cm-gutters": {
+           backgroundColor: "#f5f5f5",
+           color: "#6c6c6c",
+           borderRight: "1px solid #ddd"
+       },
+       "&dark .cm-gutters": {
+           backgroundColor: "#333338",
+           color: "#ccc"
+       },
+       ".cm-gutter": {
+           display: "flex !important",
+           flexDirection: "column",
+           flexShrink: 0,
+           boxSizing: "border-box",
+           minHeight: "100%",
+           overflow: "hidden"
+       },
+       ".cm-gutterElement": {
+           boxSizing: "border-box"
+       },
+       ".cm-lineNumbers .cm-gutterElement": {
+           padding: "0 3px 0 5px",
+           minWidth: "20px",
+           textAlign: "right",
+           whiteSpace: "nowrap"
+       },
+       "&light .cm-activeLineGutter": {
+           backgroundColor: "#e2f2ff"
+       },
+       "&dark .cm-activeLineGutter": {
+           backgroundColor: "#222227"
+       },
+       ".cm-panels": {
+           boxSizing: "border-box",
+           position: "sticky",
+           left: 0,
+           right: 0
+       },
+       "&light .cm-panels": {
+           backgroundColor: "#f5f5f5",
+           color: "black"
+       },
+       "&light .cm-panels-top": {
+           borderBottom: "1px solid #ddd"
+       },
+       "&light .cm-panels-bottom": {
+           borderTop: "1px solid #ddd"
+       },
+       "&dark .cm-panels": {
+           backgroundColor: "#333338",
+           color: "white"
+       },
+       ".cm-tab": {
+           display: "inline-block",
+           overflow: "hidden",
+           verticalAlign: "bottom"
+       },
+       ".cm-widgetBuffer": {
+           verticalAlign: "text-top",
+           height: "1em",
+           display: "inline"
+       },
+       ".cm-placeholder": {
+           color: "#888",
+           display: "inline-block",
+           verticalAlign: "top",
+       },
+       ".cm-button": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           padding: ".2em 1em",
+           borderRadius: "1px"
+       },
+       "&light .cm-button": {
+           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
+           }
+       },
+       "&dark .cm-button": {
+           backgroundImage: "linear-gradient(#393939, #111)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#111, #333)"
+           }
+       },
+       ".cm-textfield": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           border: "1px solid silver",
+           padding: ".2em .5em"
+       },
+       "&light .cm-textfield": {
+           backgroundColor: "white"
+       },
+       "&dark .cm-textfield": {
+           border: "1px solid #555",
+           backgroundColor: "inherit"
+       }
+   }, lightDarkIDs$2);
+
+   const observeOptions$2 = {
+       childList: true,
+       characterData: true,
+       subtree: true,
+       attributes: true,
+       characterDataOldValue: true
+   };
+   // IE11 has very broken mutation observers, so we also listen to
+   // DOMCharacterDataModified there
+   const useCharData$2 = browser$2.ie && browser$2.ie_version <= 11;
+   let DOMObserver$2 = class DOMObserver {
+       constructor(view, onChange, onScrollChanged) {
+           this.view = view;
+           this.onChange = onChange;
+           this.onScrollChanged = onScrollChanged;
+           this.active = false;
+           // The known selection. Kept in our own object, as opposed to just
+           // directly accessing the selection because:
+           //  - Safari doesn't report the right selection in shadow DOM
+           //  - Reading from the selection forces a DOM layout
+           //  - This way, we can ignore selectionchange events if we have
+           //    already seen the 'new' selection
+           this.selectionRange = new DOMSelectionState$2;
+           // Set when a selection change is detected, cleared on flush
+           this.selectionChanged = false;
+           this.delayedFlush = -1;
+           this.resizeTimeout = -1;
+           this.queue = [];
+           this.delayedAndroidKey = null;
+           this.scrollTargets = [];
+           this.intersection = null;
+           this.resize = null;
+           this.intersecting = false;
+           this.gapIntersection = null;
+           this.gaps = [];
+           // Timeout for scheduling check of the parents that need scroll handlers
+           this.parentCheck = -1;
+           this.dom = view.contentDOM;
+           this.observer = new MutationObserver(mutations => {
+               for (let mut of mutations)
+                   this.queue.push(mut);
+               // IE11 will sometimes (on typing over a selection or
+               // backspacing out a single character text node) call the
+               // observer callback before actually updating the DOM.
+               //
+               // Unrelatedly, iOS Safari will, when ending a composition,
+               // sometimes first clear it, deliver the mutations, and then
+               // reinsert the finished text. CodeMirror's handling of the
+               // deletion will prevent the reinsertion from happening,
+               // breaking composition.
+               if ((browser$2.ie && browser$2.ie_version <= 11 || browser$2.ios && view.composing) &&
+                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
+                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
+                   this.flushSoon();
+               else
+                   this.flush();
+           });
+           if (useCharData$2)
+               this.onCharData = (event) => {
+                   this.queue.push({ target: event.target,
+                       type: "characterData",
+                       oldValue: event.prevValue });
+                   this.flushSoon();
+               };
+           this.onSelectionChange = this.onSelectionChange.bind(this);
+           window.addEventListener("resize", this.onResize = this.onResize.bind(this));
+           if (typeof ResizeObserver == "function") {
+               this.resize = new ResizeObserver(() => {
+                   if (this.view.docView.lastUpdate < Date.now() - 75)
+                       this.onResize();
+               });
+               this.resize.observe(view.scrollDOM);
+           }
+           window.addEventListener("beforeprint", this.onPrint = this.onPrint.bind(this));
+           this.start();
+           window.addEventListener("scroll", this.onScroll = this.onScroll.bind(this));
+           if (typeof IntersectionObserver == "function") {
+               this.intersection = new IntersectionObserver(entries => {
+                   if (this.parentCheck < 0)
+                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
+                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
+                       this.intersecting = !this.intersecting;
+                       if (this.intersecting != this.view.inView)
+                           this.onScrollChanged(document.createEvent("Event"));
+                   }
+               }, {});
+               this.intersection.observe(this.dom);
+               this.gapIntersection = new IntersectionObserver(entries => {
+                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
+                       this.onScrollChanged(document.createEvent("Event"));
+               }, {});
+           }
+           this.listenForScroll();
+           this.readSelectionRange();
+           this.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
+       }
+       onScroll(e) {
+           if (this.intersecting)
+               this.flush(false);
+           this.onScrollChanged(e);
+       }
+       onResize() {
+           if (this.resizeTimeout < 0)
+               this.resizeTimeout = setTimeout(() => {
+                   this.resizeTimeout = -1;
+                   this.view.requestMeasure();
+               }, 50);
+       }
+       onPrint() {
+           this.view.viewState.printing = true;
+           this.view.measure();
+           setTimeout(() => {
+               this.view.viewState.printing = false;
+               this.view.requestMeasure();
+           }, 500);
+       }
+       updateGaps(gaps) {
+           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
+               this.gapIntersection.disconnect();
+               for (let gap of gaps)
+                   this.gapIntersection.observe(gap);
+               this.gaps = gaps;
+           }
+       }
+       onSelectionChange(event) {
+           if (!this.readSelectionRange() || this.delayedAndroidKey)
+               return;
+           let { view } = this, sel = this.selectionRange;
+           if (view.state.facet(editable$2) ? view.root.activeElement != this.dom : !hasSelection$2(view.dom, sel))
+               return;
+           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
+           if (context && context.ignoreEvent(event))
+               return;
+           // Deletions on IE11 fire their events in the wrong order, giving
+           // us a selection change event before the DOM changes are
+           // reported.
+           // Chrome Android has a similar issue when backspacing out a
+           // selection (#645).
+           if ((browser$2.ie && browser$2.ie_version <= 11 || browser$2.android && browser$2.chrome) && !view.state.selection.main.empty &&
+               // (Selection.isCollapsed isn't reliable on IE)
+               sel.focusNode && isEquivalentPosition$2(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
+               this.flushSoon();
+           else
+               this.flush(false);
+       }
+       readSelectionRange() {
+           let { root } = this.view, domSel = getSelection$2(root);
+           // The Selection object is broken in shadow roots in Safari. See
+           // https://github.com/codemirror/codemirror.next/issues/414
+           let range = browser$2.safari && root.nodeType == 11 && deepActiveElement$1() == this.view.contentDOM &&
+               safariSelectionRangeHack$2(this.view) || domSel;
+           if (this.selectionRange.eq(range))
+               return false;
+           this.selectionRange.setRange(range);
+           return this.selectionChanged = true;
+       }
+       setSelectionRange(anchor, head) {
+           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
+           this.selectionChanged = false;
+       }
+       clearSelectionRange() {
+           this.selectionRange.set(null, 0, null, 0);
+       }
+       listenForScroll() {
+           this.parentCheck = -1;
+           let i = 0, changed = null;
+           for (let dom = this.dom; dom;) {
+               if (dom.nodeType == 1) {
+                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
+                       i++;
+                   else if (!changed)
+                       changed = this.scrollTargets.slice(0, i);
+                   if (changed)
+                       changed.push(dom);
+                   dom = dom.assignedSlot || dom.parentNode;
+               }
+               else if (dom.nodeType == 11) { // Shadow root
+                   dom = dom.host;
+               }
+               else {
+                   break;
+               }
+           }
+           if (i < this.scrollTargets.length && !changed)
+               changed = this.scrollTargets.slice(0, i);
+           if (changed) {
+               for (let dom of this.scrollTargets)
+                   dom.removeEventListener("scroll", this.onScroll);
+               for (let dom of this.scrollTargets = changed)
+                   dom.addEventListener("scroll", this.onScroll);
+           }
+       }
+       ignore(f) {
+           if (!this.active)
+               return f();
+           try {
+               this.stop();
+               return f();
+           }
+           finally {
+               this.start();
+               this.clear();
+           }
+       }
+       start() {
+           if (this.active)
+               return;
+           this.observer.observe(this.dom, observeOptions$2);
+           if (useCharData$2)
+               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
+           this.active = true;
+       }
+       stop() {
+           if (!this.active)
+               return;
+           this.active = false;
+           this.observer.disconnect();
+           if (useCharData$2)
+               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
+       }
+       // Throw away any pending changes
+       clear() {
+           this.processRecords();
+           this.queue.length = 0;
+           this.selectionChanged = false;
+       }
+       // Chrome Android, especially in combination with GBoard, not only
+       // doesn't reliably fire regular key events, but also often
+       // surrounds the effect of enter or backspace with a bunch of
+       // composition events that, when interrupted, cause text duplication
+       // or other kinds of corruption. This hack makes the editor back off
+       // from handling DOM changes for a moment when such a key is
+       // detected (via beforeinput or keydown), and then tries to flush
+       // them or, if that has no effect, dispatches the given key.
+       delayAndroidKey(key, keyCode) {
+           if (!this.delayedAndroidKey)
+               requestAnimationFrame(() => {
+                   let key = this.delayedAndroidKey;
+                   this.delayedAndroidKey = null;
+                   this.delayedFlush = -1;
+                   if (!this.flush())
+                       dispatchKey$2(this.view.contentDOM, key.key, key.keyCode);
+               });
+           // Since backspace beforeinput is sometimes signalled spuriously,
+           // Enter always takes precedence.
+           if (!this.delayedAndroidKey || key == "Enter")
+               this.delayedAndroidKey = { key, keyCode };
+       }
+       flushSoon() {
+           if (this.delayedFlush < 0)
+               this.delayedFlush = window.setTimeout(() => { this.delayedFlush = -1; this.flush(); }, 20);
+       }
+       forceFlush() {
+           if (this.delayedFlush >= 0) {
+               window.clearTimeout(this.delayedFlush);
+               this.delayedFlush = -1;
+               this.flush();
+           }
+       }
+       processRecords() {
+           let records = this.queue;
+           for (let mut of this.observer.takeRecords())
+               records.push(mut);
+           if (records.length)
+               this.queue = [];
+           let from = -1, to = -1, typeOver = false;
+           for (let record of records) {
+               let range = this.readMutation(record);
+               if (!range)
+                   continue;
+               if (range.typeOver)
+                   typeOver = true;
+               if (from == -1) {
+                   ({ from, to } = range);
+               }
+               else {
+                   from = Math.min(range.from, from);
+                   to = Math.max(range.to, to);
+               }
+           }
+           return { from, to, typeOver };
+       }
+       // Apply pending changes, if any
+       flush(readSelection = true) {
+           // Completely hold off flushing when pending keys are set—the code
+           // managing those will make sure processRecords is called and the
+           // view is resynchronized after
+           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
+               return;
+           if (readSelection)
+               this.readSelectionRange();
+           let { from, to, typeOver } = this.processRecords();
+           let newSel = this.selectionChanged && hasSelection$2(this.dom, this.selectionRange);
+           if (from < 0 && !newSel)
+               return;
+           this.selectionChanged = false;
+           let startState = this.view.state;
+           let handled = this.onChange(from, to, typeOver);
+           // The view wasn't updated
+           if (this.view.state == startState)
+               this.view.update([]);
+           return handled;
+       }
+       readMutation(rec) {
+           let cView = this.view.docView.nearest(rec.target);
+           if (!cView || cView.ignoreMutation(rec))
+               return null;
+           cView.markDirty(rec.type == "attributes");
+           if (rec.type == "attributes")
+               cView.dirty |= 4 /* Attrs */;
+           if (rec.type == "childList") {
+               let childBefore = findChild$2(cView, rec.previousSibling || rec.target.previousSibling, -1);
+               let childAfter = findChild$2(cView, rec.nextSibling || rec.target.nextSibling, 1);
+               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
+                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
+           }
+           else if (rec.type == "characterData") {
+               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
+           }
+           else {
+               return null;
+           }
+       }
+       destroy() {
+           var _a, _b, _c;
+           this.stop();
+           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
+           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
+           (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
+           for (let dom of this.scrollTargets)
+               dom.removeEventListener("scroll", this.onScroll);
+           window.removeEventListener("scroll", this.onScroll);
+           window.removeEventListener("resize", this.onResize);
+           window.removeEventListener("beforeprint", this.onPrint);
+           this.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
+           clearTimeout(this.parentCheck);
+           clearTimeout(this.resizeTimeout);
+       }
+   };
+   function findChild$2(cView, dom, dir) {
+       while (dom) {
+           let curView = ContentView$2.get(dom);
+           if (curView && curView.parent == cView)
+               return curView;
+           let parent = dom.parentNode;
+           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
+       }
+       return null;
+   }
+   // Used to work around a Safari Selection/shadow DOM bug (#414)
+   function safariSelectionRangeHack$2(view) {
+       let found = null;
+       // Because Safari (at least in 2018-2021) doesn't provide regular
+       // access to the selection inside a shadowroot, we have to perform a
+       // ridiculous hack to get at it—using `execCommand` to trigger a
+       // `beforeInput` event so that we can read the target range from the
+       // event.
+       function read(event) {
+           event.preventDefault();
+           event.stopImmediatePropagation();
+           found = event.getTargetRanges()[0];
+       }
+       view.contentDOM.addEventListener("beforeinput", read, true);
+       document.execCommand("indent");
+       view.contentDOM.removeEventListener("beforeinput", read, true);
+       if (!found)
+           return null;
+       let anchorNode = found.startContainer, anchorOffset = found.startOffset;
+       let focusNode = found.endContainer, focusOffset = found.endOffset;
+       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
+       // Since such a range doesn't distinguish between anchor and head,
+       // use a heuristic that flips it around if its end matches the
+       // current anchor.
+       if (isEquivalentPosition$2(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
+           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
+       return { anchorNode, anchorOffset, focusNode, focusOffset };
+   }
+
+   function applyDOMChange$2(view, start, end, typeOver) {
+       let change, newSel;
+       let sel = view.state.selection.main;
+       if (start > -1) {
+           let bounds = view.docView.domBoundsAround(start, end, 0);
+           if (!bounds || view.state.readOnly)
+               return false;
+           let { from, to } = bounds;
+           let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints$2(view);
+           let reader = new DOMReader$2(selPoints, view.state);
+           reader.readRange(bounds.startDOM, bounds.endDOM);
+           let preferredPos = sel.from, preferredSide = null;
+           // Prefer anchoring to end when Backspace is pressed (or, on
+           // Android, when something was deleted)
+           if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 ||
+               browser$2.android && reader.text.length < to - from) {
+               preferredPos = sel.to;
+               preferredSide = "end";
+           }
+           let diff = findDiff$2(view.state.doc.sliceString(from, to, LineBreakPlaceholder$2), reader.text, preferredPos - from, preferredSide);
+           if (diff) {
+               // Chrome inserts two newlines when pressing shift-enter at the
+               // end of a line. This drops one of those.
+               if (browser$2.chrome && view.inputState.lastKeyCode == 13 &&
+                   diff.toB == diff.from + 2 && reader.text.slice(diff.from, diff.toB) == LineBreakPlaceholder$2 + LineBreakPlaceholder$2)
+                   diff.toB--;
+               change = { from: from + diff.from, to: from + diff.toA,
+                   insert: Text$2.of(reader.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder$2)) };
+           }
+           newSel = selectionFromPoints$2(selPoints, from);
+       }
+       else if (view.hasFocus || !view.state.facet(editable$2)) {
+           let domSel = view.observer.selectionRange;
+           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
+           let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
+               !contains$2(view.contentDOM, domSel.focusNode)
+               ? view.state.selection.main.head
+               : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
+           let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
+               !contains$2(view.contentDOM, domSel.anchorNode)
+               ? view.state.selection.main.anchor
+               : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
+           if (head != sel.head || anchor != sel.anchor)
+               newSel = EditorSelection$2.single(anchor, head);
+       }
+       if (!change && !newSel)
+           return false;
+       // Heuristic to notice typing over a selected character
+       if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
+           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
+       // If the change is inside the selection and covers most of it,
+       // assume it is a selection replace (with identical characters at
+       // the start/end not included in the diff)
+       else if (change && change.from >= sel.from && change.to <= sel.to &&
+           (change.from != sel.from || change.to != sel.to) &&
+           (sel.to - sel.from) - (change.to - change.from) <= 4)
+           change = {
+               from: sel.from, to: sel.to,
+               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
+           };
+       // Detect insert-period-on-double-space Mac behavior, and transform
+       // it into a regular space insert.
+       else if ((browser$2.mac || browser$2.android) && change && change.from == change.to && change.from == sel.head - 1 &&
+           change.insert.toString() == ".")
+           change = { from: sel.from, to: sel.to, insert: Text$2.of([" "]) };
+       if (change) {
+           let startState = view.state;
+           if (browser$2.ios && view.inputState.flushIOSKey(view))
+               return true;
+           // Android browsers don't fire reasonable key events for enter,
+           // backspace, or delete. So this detects changes that look like
+           // they're caused by those keys, and reinterprets them as key
+           // events. (Some of these keys are also handled by beforeinput
+           // events and the pendingAndroidKey mechanism, but that's not
+           // reliable in all situations.)
+           if (browser$2.android &&
+               ((change.from == sel.from && change.to == sel.to &&
+                   change.insert.length == 1 && change.insert.lines == 2 &&
+                   dispatchKey$2(view.contentDOM, "Enter", 13)) ||
+                   (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 &&
+                       dispatchKey$2(view.contentDOM, "Backspace", 8)) ||
+                   (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
+                       dispatchKey$2(view.contentDOM, "Delete", 46))))
+               return true;
+           let text = change.insert.toString();
+           if (view.state.facet(inputHandler$3).some(h => h(view, change.from, change.to, text)))
+               return true;
+           if (view.inputState.composing >= 0)
+               view.inputState.composing++;
+           let tr;
+           if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
+               (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
+               view.inputState.composing < 0) {
+               let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
+               let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
+               tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
+           }
+           else {
+               let changes = startState.changes(change);
+               let mainSel = newSel && !startState.selection.main.eq(newSel.main) && newSel.main.to <= changes.newLength
+                   ? newSel.main : undefined;
+               // Try to apply a composition change to all cursors
+               if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
+                   change.to <= sel.to && change.to >= sel.to - 10) {
+                   let replaced = view.state.sliceDoc(change.from, change.to);
+                   let compositionRange = compositionSurroundingNode$1(view) || view.state.doc.lineAt(sel.head);
+                   let offset = sel.to - change.to, size = sel.to - sel.from;
+                   tr = startState.changeByRange(range => {
+                       if (range.from == sel.from && range.to == sel.to)
+                           return { changes, range: mainSel || range.map(changes) };
+                       let to = range.to - offset, from = to - replaced.length;
+                       if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
+                           // Unfortunately, there's no way to make multiple
+                           // changes in the same node work without aborting
+                           // composition, so cursors in the composition range are
+                           // ignored.
+                           compositionRange && range.to >= compositionRange.from && range.from <= compositionRange.to)
+                           return { range };
+                       let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
+                       return {
+                           changes: rangeChanges,
+                           range: !mainSel ? range.map(rangeChanges) :
+                               EditorSelection$2.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
+                       };
+                   });
+               }
+               else {
+                   tr = {
+                       changes,
+                       selection: mainSel && startState.selection.replaceRange(mainSel)
+                   };
+               }
+           }
+           let userEvent = "input.type";
+           if (view.composing) {
+               userEvent += ".compose";
+               if (view.inputState.compositionFirstChange) {
+                   userEvent += ".start";
+                   view.inputState.compositionFirstChange = false;
+               }
+           }
+           view.dispatch(tr, { scrollIntoView: true, userEvent });
+           return true;
+       }
+       else if (newSel && !newSel.main.eq(sel)) {
+           let scrollIntoView = false, userEvent = "select";
+           if (view.inputState.lastSelectionTime > Date.now() - 50) {
+               if (view.inputState.lastSelectionOrigin == "select")
+                   scrollIntoView = true;
+               userEvent = view.inputState.lastSelectionOrigin;
+           }
+           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
+           return true;
+       }
+       else {
+           return false;
+       }
+   }
+   function findDiff$2(a, b, preferredPos, preferredSide) {
+       let minLen = Math.min(a.length, b.length);
+       let from = 0;
+       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
+           from++;
+       if (from == minLen && a.length == b.length)
+           return null;
+       let toA = a.length, toB = b.length;
+       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
+           toA--;
+           toB--;
+       }
+       if (preferredSide == "end") {
+           let adjust = Math.max(0, from - Math.min(toA, toB));
+           preferredPos -= toA + adjust - from;
+       }
+       if (toA < from && a.length < b.length) {
+           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
+           from -= move;
+           toB = from + (toB - toA);
+           toA = from;
+       }
+       else if (toB < from) {
+           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
+           from -= move;
+           toA = from + (toA - toB);
+           toB = from;
+       }
+       return { from, toA, toB };
+   }
+   function selectionPoints$2(view) {
+       let result = [];
+       if (view.root.activeElement != view.contentDOM)
+           return result;
+       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
+       if (anchorNode) {
+           result.push(new DOMPoint$2(anchorNode, anchorOffset));
+           if (focusNode != anchorNode || focusOffset != anchorOffset)
+               result.push(new DOMPoint$2(focusNode, focusOffset));
+       }
+       return result;
+   }
+   function selectionFromPoints$2(points, base) {
+       if (points.length == 0)
+           return null;
+       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
+       return anchor > -1 && head > -1 ? EditorSelection$2.single(anchor + base, head + base) : null;
+   }
+
+   // The editor's update state machine looks something like this:
+   //
+   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
+   //                                         ↑      ↓
+   //                                         Updating (measure)
+   //
+   // The difference between 'Idle' and 'Idle (unchecked)' lies in
+   // whether a layout check has been scheduled. A regular update through
+   // the `update` method updates the DOM in a write-only fashion, and
+   // relies on a check (scheduled with `requestAnimationFrame`) to make
+   // sure everything is where it should be and the viewport covers the
+   // visible code. That check continues to measure and then optionally
+   // update until it reaches a coherent state.
+   /**
+   An editor view represents the editor's user interface. It holds
+   the editable DOM surface, and possibly other elements such as the
+   line number gutter. It handles events and dispatches state
+   transactions for editing actions.
+   */
+   let EditorView$2 = class EditorView {
+       /**
+       Construct a new view. You'll want to either provide a `parent`
+       option, or put `view.dom` into your document after creating a
+       view, so that the user can see the editor.
+       */
+       constructor(
+       /**
+       Initialization options.
+       */
+       config = {}) {
+           this.plugins = [];
+           this.pluginMap = new Map;
+           this.editorAttrs = {};
+           this.contentAttrs = {};
+           this.bidiCache = [];
+           this.destroyed = false;
+           /**
+           @internal
+           */
+           this.updateState = 2 /* Updating */;
+           /**
+           @internal
+           */
+           this.measureScheduled = -1;
+           /**
+           @internal
+           */
+           this.measureRequests = [];
+           this.contentDOM = document.createElement("div");
+           this.scrollDOM = document.createElement("div");
+           this.scrollDOM.tabIndex = -1;
+           this.scrollDOM.className = "cm-scroller";
+           this.scrollDOM.appendChild(this.contentDOM);
+           this.announceDOM = document.createElement("div");
+           this.announceDOM.style.cssText = "position: absolute; top: -10000px";
+           this.announceDOM.setAttribute("aria-live", "polite");
+           this.dom = document.createElement("div");
+           this.dom.appendChild(this.announceDOM);
+           this.dom.appendChild(this.scrollDOM);
+           this._dispatch = config.dispatch || ((tr) => this.update([tr]));
+           this.dispatch = this.dispatch.bind(this);
+           this.root = (config.root || getRoot$2(config.parent) || document);
+           this.viewState = new ViewState$2(config.state || EditorState$2.create());
+           this.plugins = this.state.facet(viewPlugin$2).map(spec => new PluginInstance$2(spec));
+           for (let plugin of this.plugins)
+               plugin.update(this);
+           this.observer = new DOMObserver$2(this, (from, to, typeOver) => {
+               return applyDOMChange$2(this, from, to, typeOver);
+           }, event => {
+               this.inputState.runScrollHandlers(this, event);
+               if (this.observer.intersecting)
+                   this.measure();
+           });
+           this.inputState = new InputState$2(this);
+           this.inputState.ensureHandlers(this, this.plugins);
+           this.docView = new DocView$2(this);
+           this.mountStyles();
+           this.updateAttrs();
+           this.updateState = 0 /* Idle */;
+           this.requestMeasure();
+           if (config.parent)
+               config.parent.appendChild(this.dom);
+       }
+       /**
+       The current editor state.
+       */
+       get state() { return this.viewState.state; }
+       /**
+       To be able to display large documents without consuming too much
+       memory or overloading the browser, CodeMirror only draws the
+       code that is visible (plus a margin around it) to the DOM. This
+       property tells you the extent of the current drawn viewport, in
+       document positions.
+       */
+       get viewport() { return this.viewState.viewport; }
+       /**
+       When there are, for example, large collapsed ranges in the
+       viewport, its size can be a lot bigger than the actual visible
+       content. Thus, if you are doing something like styling the
+       content in the viewport, it is preferable to only do so for
+       these ranges, which are the subset of the viewport that is
+       actually drawn.
+       */
+       get visibleRanges() { return this.viewState.visibleRanges; }
+       /**
+       Returns false when the editor is entirely scrolled out of view
+       or otherwise hidden.
+       */
+       get inView() { return this.viewState.inView; }
+       /**
+       Indicates whether the user is currently composing text via
+       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
+       one change has been made in the current composition.
+       */
+       get composing() { return this.inputState.composing > 0; }
+       /**
+       Indicates whether the user is currently in composing state. Note
+       that on some platforms, like Android, this will be the case a
+       lot, since just putting the cursor on a word starts a
+       composition there.
+       */
+       get compositionStarted() { return this.inputState.composing >= 0; }
+       dispatch(...input) {
+           this._dispatch(input.length == 1 && input[0] instanceof Transaction$2 ? input[0]
+               : this.state.update(...input));
+       }
+       /**
+       Update the view for the given array of transactions. This will
+       update the visible document and selection to match the state
+       produced by the transactions, and notify view plugins of the
+       change. You should usually call
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
+       as a primitive.
+       */
+       update(transactions) {
+           if (this.updateState != 0 /* Idle */)
+               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
+           let redrawn = false, attrsChanged = false, update;
+           let state = this.state;
+           for (let tr of transactions) {
+               if (tr.startState != state)
+                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
+               state = tr.state;
+           }
+           if (this.destroyed) {
+               this.viewState.state = state;
+               return;
+           }
+           this.observer.clear();
+           // When the phrases change, redraw the editor
+           if (state.facet(EditorState$2.phrases) != this.state.facet(EditorState$2.phrases))
+               return this.setState(state);
+           update = ViewUpdate$2.create(this, state, transactions);
+           let scrollTarget = this.viewState.scrollTarget;
+           try {
+               this.updateState = 2 /* Updating */;
+               for (let tr of transactions) {
+                   if (scrollTarget)
+                       scrollTarget = scrollTarget.map(tr.changes);
+                   if (tr.scrollIntoView) {
+                       let { main } = tr.state.selection;
+                       scrollTarget = new ScrollTarget$2(main.empty ? main : EditorSelection$2.cursor(main.head, main.head > main.anchor ? -1 : 1));
+                   }
+                   for (let e of tr.effects)
+                       if (e.is(scrollIntoView$4))
+                           scrollTarget = e.value;
+               }
+               this.viewState.update(update, scrollTarget);
+               this.bidiCache = CachedOrder$2.update(this.bidiCache, update.changes);
+               if (!update.empty) {
+                   this.updatePlugins(update);
+                   this.inputState.update(update);
+               }
+               redrawn = this.docView.update(update);
+               if (this.state.facet(styleModule$2) != this.styleModules)
+                   this.mountStyles();
+               attrsChanged = this.updateAttrs();
+               this.showAnnouncements(transactions);
+               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+           }
+           if (update.startState.facet(theme$2) != update.state.facet(theme$2))
+               this.viewState.mustMeasureContent = true;
+           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
+               this.requestMeasure();
+           if (!update.empty)
+               for (let listener of this.state.facet(updateListener$2))
+                   listener(update);
+       }
+       /**
+       Reset the view to the given state. (This will cause the entire
+       document to be redrawn and all view plugins to be reinitialized,
+       so you should probably only use it when the new state isn't
+       derived from the old state. Otherwise, use
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
+       */
+       setState(newState) {
+           if (this.updateState != 0 /* Idle */)
+               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
+           if (this.destroyed) {
+               this.viewState.state = newState;
+               return;
+           }
+           this.updateState = 2 /* Updating */;
+           let hadFocus = this.hasFocus;
+           try {
+               for (let plugin of this.plugins)
+                   plugin.destroy(this);
+               this.viewState = new ViewState$2(newState);
+               this.plugins = newState.facet(viewPlugin$2).map(spec => new PluginInstance$2(spec));
+               this.pluginMap.clear();
+               for (let plugin of this.plugins)
+                   plugin.update(this);
+               this.docView = new DocView$2(this);
+               this.inputState.ensureHandlers(this, this.plugins);
+               this.mountStyles();
+               this.updateAttrs();
+               this.bidiCache = [];
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+           }
+           if (hadFocus)
+               this.focus();
+           this.requestMeasure();
+       }
+       updatePlugins(update) {
+           let prevSpecs = update.startState.facet(viewPlugin$2), specs = update.state.facet(viewPlugin$2);
+           if (prevSpecs != specs) {
+               let newPlugins = [];
+               for (let spec of specs) {
+                   let found = prevSpecs.indexOf(spec);
+                   if (found < 0) {
+                       newPlugins.push(new PluginInstance$2(spec));
+                   }
+                   else {
+                       let plugin = this.plugins[found];
+                       plugin.mustUpdate = update;
+                       newPlugins.push(plugin);
+                   }
+               }
+               for (let plugin of this.plugins)
+                   if (plugin.mustUpdate != update)
+                       plugin.destroy(this);
+               this.plugins = newPlugins;
+               this.pluginMap.clear();
+               this.inputState.ensureHandlers(this, this.plugins);
+           }
+           else {
+               for (let p of this.plugins)
+                   p.mustUpdate = update;
+           }
+           for (let i = 0; i < this.plugins.length; i++)
+               this.plugins[i].update(this);
+       }
+       /**
+       @internal
+       */
+       measure(flush = true) {
+           if (this.destroyed)
+               return;
+           if (this.measureScheduled > -1)
+               cancelAnimationFrame(this.measureScheduled);
+           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
+           if (flush)
+               this.observer.flush();
+           let updated = null;
+           try {
+               for (let i = 0;; i++) {
+                   this.updateState = 1 /* Measuring */;
+                   let oldViewport = this.viewport;
+                   let changed = this.viewState.measure(this);
+                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
+                       break;
+                   if (i > 5) {
+                       console.warn(this.measureRequests.length
+                           ? "Measure loop restarted more than 5 times"
+                           : "Viewport failed to stabilize");
+                       break;
+                   }
+                   let measuring = [];
+                   // Only run measure requests in this cycle when the viewport didn't change
+                   if (!(changed & 4 /* Viewport */))
+                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
+                   let measured = measuring.map(m => {
+                       try {
+                           return m.read(this);
+                       }
+                       catch (e) {
+                           logException$2(this.state, e);
+                           return BadMeasure$2;
+                       }
+                   });
+                   let update = ViewUpdate$2.create(this, this.state, []), redrawn = false, scrolled = false;
+                   update.flags |= changed;
+                   if (!updated)
+                       updated = update;
+                   else
+                       updated.flags |= changed;
+                   this.updateState = 2 /* Updating */;
+                   if (!update.empty) {
+                       this.updatePlugins(update);
+                       this.inputState.update(update);
+                       this.updateAttrs();
+                       redrawn = this.docView.update(update);
+                   }
+                   for (let i = 0; i < measuring.length; i++)
+                       if (measured[i] != BadMeasure$2) {
+                           try {
+                               let m = measuring[i];
+                               if (m.write)
+                                   m.write(measured[i], this);
+                           }
+                           catch (e) {
+                               logException$2(this.state, e);
+                           }
+                       }
+                   if (this.viewState.scrollTarget) {
+                       this.docView.scrollIntoView(this.viewState.scrollTarget);
+                       this.viewState.scrollTarget = null;
+                       scrolled = true;
+                   }
+                   if (redrawn)
+                       this.docView.updateSelection(true);
+                   if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
+                       !scrolled && this.measureRequests.length == 0)
+                       break;
+               }
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+               this.measureScheduled = -1;
+           }
+           if (updated && !updated.empty)
+               for (let listener of this.state.facet(updateListener$2))
+                   listener(updated);
+       }
+       /**
+       Get the CSS classes for the currently active editor themes.
+       */
+       get themeClasses() {
+           return baseThemeID$2 + " " +
+               (this.state.facet(darkTheme$2) ? baseDarkID$2 : baseLightID$2) + " " +
+               this.state.facet(theme$2);
+       }
+       updateAttrs() {
+           let editorAttrs = attrsFromFacet$2(this, editorAttributes$2, {
+               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
+           });
+           let contentAttrs = {
+               spellcheck: "false",
+               autocorrect: "off",
+               autocapitalize: "off",
+               translate: "no",
+               contenteditable: !this.state.facet(editable$2) ? "false" : "true",
+               class: "cm-content",
+               style: `${browser$2.tabSize}: ${this.state.tabSize}`,
+               role: "textbox",
+               "aria-multiline": "true"
+           };
+           if (this.state.readOnly)
+               contentAttrs["aria-readonly"] = "true";
+           attrsFromFacet$2(this, contentAttributes$2, contentAttrs);
+           let changed = this.observer.ignore(() => {
+               let changedContent = updateAttrs$2(this.contentDOM, this.contentAttrs, contentAttrs);
+               let changedEditor = updateAttrs$2(this.dom, this.editorAttrs, editorAttrs);
+               return changedContent || changedEditor;
+           });
+           this.editorAttrs = editorAttrs;
+           this.contentAttrs = contentAttrs;
+           return changed;
+       }
+       showAnnouncements(trs) {
+           let first = true;
+           for (let tr of trs)
+               for (let effect of tr.effects)
+                   if (effect.is(EditorView.announce)) {
+                       if (first)
+                           this.announceDOM.textContent = "";
+                       first = false;
+                       let div = this.announceDOM.appendChild(document.createElement("div"));
+                       div.textContent = effect.value;
+                   }
+       }
+       mountStyles() {
+           this.styleModules = this.state.facet(styleModule$2);
+           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$3).reverse());
+       }
+       readMeasured() {
+           if (this.updateState == 2 /* Updating */)
+               throw new Error("Reading the editor layout isn't allowed during an update");
+           if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
+               this.measure(false);
+       }
+       /**
+       Schedule a layout measurement, optionally providing callbacks to
+       do custom DOM measuring followed by a DOM write phase. Using
+       this is preferable reading DOM layout directly from, for
+       example, an event handler, because it'll make sure measuring and
+       drawing done by other components is synchronized, avoiding
+       unnecessary DOM layout computations.
+       */
+       requestMeasure(request) {
+           if (this.measureScheduled < 0)
+               this.measureScheduled = requestAnimationFrame(() => this.measure());
+           if (request) {
+               if (request.key != null)
+                   for (let i = 0; i < this.measureRequests.length; i++) {
+                       if (this.measureRequests[i].key === request.key) {
+                           this.measureRequests[i] = request;
+                           return;
+                       }
+                   }
+               this.measureRequests.push(request);
+           }
+       }
+       /**
+       Get the value of a specific plugin, if present. Note that
+       plugins that crash can be dropped from a view, so even when you
+       know you registered a given plugin, it is recommended to check
+       the return value of this method.
+       */
+       plugin(plugin) {
+           let known = this.pluginMap.get(plugin);
+           if (known === undefined || known && known.spec != plugin)
+               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
+           return known && known.update(this).value;
+       }
+       /**
+       The top position of the document, in screen coordinates. This
+       may be negative when the editor is scrolled down. Points
+       directly to the top of the first line, not above the padding.
+       */
+       get documentTop() {
+           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
+       }
+       /**
+       Reports the padding above and below the document.
+       */
+       get documentPadding() {
+           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
+       }
+       /**
+       Find the text line or block widget at the given vertical
+       position (which is interpreted as relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
+       */
+       elementAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.elementAtHeight(height);
+       }
+       /**
+       Find the line block (see
+       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
+       height.
+       */
+       lineBlockAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.lineBlockAtHeight(height);
+       }
+       /**
+       Get the extent and vertical position of all [line
+       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
+       are relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
+       */
+       get viewportLineBlocks() {
+           return this.viewState.viewportLines;
+       }
+       /**
+       Find the line block around the given document position. A line
+       block is a range delimited on both sides by either a
+       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
+       start/end of the document. It will usually just hold a line of
+       text, but may be broken into multiple textblocks by block
+       widgets.
+       */
+       lineBlockAt(pos) {
+           return this.viewState.lineBlockAt(pos);
+       }
+       /**
+       The editor's total content height.
+       */
+       get contentHeight() {
+           return this.viewState.contentHeight;
+       }
+       /**
+       Move a cursor position by [grapheme
+       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
+       the motion is away from the line start, or towards it. In
+       bidirectional text, the line is traversed in visual order, using
+       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+       When the start position was the last one on the line, the
+       returned position will be across the line break. If there is no
+       further line, the original position is returned.
+       
+       By default, this method moves over a single cluster. The
+       optional `by` argument can be used to move across more. It will
+       be called with the first cluster as argument, and should return
+       a predicate that determines, for each subsequent cluster,
+       whether it should also be moved over.
+       */
+       moveByChar(start, forward, by) {
+           return skipAtoms$2(this, start, moveByChar$2(this, start, forward, by));
+       }
+       /**
+       Move a cursor position across the next group of either
+       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
+       non-whitespace characters.
+       */
+       moveByGroup(start, forward) {
+           return skipAtoms$2(this, start, moveByChar$2(this, start, forward, initial => byGroup$2(this, start.head, initial)));
+       }
+       /**
+       Move to the next line boundary in the given direction. If
+       `includeWrap` is true, line wrapping is on, and there is a
+       further wrap point on the current line, the wrap point will be
+       returned. Otherwise this function will return the start or end
+       of the line.
+       */
+       moveToLineBoundary(start, forward, includeWrap = true) {
+           return moveToLineBoundary$2(this, start, forward, includeWrap);
+       }
+       /**
+       Move a cursor position vertically. When `distance` isn't given,
+       it defaults to moving to the next line (including wrapped
+       lines). Otherwise, `distance` should provide a positive distance
+       in pixels.
+       
+       When `start` has a
+       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
+       motion will use that as a target horizontal position. Otherwise,
+       the cursor's own horizontal position is used. The returned
+       cursor will have its goal column set to whichever column was
+       used.
+       */
+       moveVertically(start, forward, distance) {
+           return skipAtoms$2(this, start, moveVertically$2(this, start, forward, distance));
+       }
+       /**
+       Find the DOM parent node and offset (child offset if `node` is
+       an element, character offset when it is a text node) at the
+       given document position.
+       
+       Note that for positions that aren't currently in
+       `visibleRanges`, the resulting DOM position isn't necessarily
+       meaningful (it may just point before or after a placeholder
+       element).
+       */
+       domAtPos(pos) {
+           return this.docView.domAtPos(pos);
+       }
+       /**
+       Find the document position at the given DOM node. Can be useful
+       for associating positions with DOM events. Will raise an error
+       when `node` isn't part of the editor content.
+       */
+       posAtDOM(node, offset = 0) {
+           return this.docView.posFromDOM(node, offset);
+       }
+       posAtCoords(coords, precise = true) {
+           this.readMeasured();
+           return posAtCoords$2(this, coords, precise);
+       }
+       /**
+       Get the screen coordinates at the given document position.
+       `side` determines whether the coordinates are based on the
+       element before (-1) or after (1) the position (if no element is
+       available on the given side, the method will transparently use
+       another strategy to get reasonable coordinates).
+       */
+       coordsAtPos(pos, side = 1) {
+           this.readMeasured();
+           let rect = this.docView.coordsAt(pos, side);
+           if (!rect || rect.left == rect.right)
+               return rect;
+           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
+           let span = order[BidiSpan$2.find(order, pos - line.from, -1, side)];
+           return flattenRect$2(rect, (span.dir == Direction$2.LTR) == (side > 0));
+       }
+       /**
+       The default width of a character in the editor. May not
+       accurately reflect the width of all characters (given variable
+       width fonts or styling of invididual ranges).
+       */
+       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
+       /**
+       The default height of a line in the editor. May not be accurate
+       for all lines.
+       */
+       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
+       /**
+       The text direction
+       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
+       CSS property) of the editor's content element.
+       */
+       get textDirection() { return this.viewState.defaultTextDirection; }
+       /**
+       Find the text direction of the block at the given position, as
+       assigned by CSS. If
+       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
+       isn't enabled, or the given position is outside of the viewport,
+       this will always return the same as
+       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
+       this may trigger a DOM layout.
+       */
+       textDirectionAt(pos) {
+           let perLine = this.state.facet(perLineTextDirection$2);
+           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
+               return this.textDirection;
+           this.readMeasured();
+           return this.docView.textDirectionAt(pos);
+       }
+       /**
+       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
+       (as determined by the
+       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
+       CSS property of its content element).
+       */
+       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
+       /**
+       Returns the bidirectional text structure of the given line
+       (which should be in the current document) as an array of span
+       objects. The order of these spans matches the [text
+       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
+       left-to-right, the leftmost spans come first, otherwise the
+       rightmost spans come first.
+       */
+       bidiSpans(line) {
+           if (line.length > MaxBidiLine$2)
+               return trivialOrder$2(line.length);
+           let dir = this.textDirectionAt(line.from);
+           for (let entry of this.bidiCache)
+               if (entry.from == line.from && entry.dir == dir)
+                   return entry.order;
+           let order = computeOrder$2(line.text, dir);
+           this.bidiCache.push(new CachedOrder$2(line.from, line.to, dir, order));
+           return order;
+       }
+       /**
+       Check whether the editor has focus.
+       */
+       get hasFocus() {
+           var _a;
+           // Safari return false for hasFocus when the context menu is open
+           // or closing, which leads us to ignore selection changes from the
+           // context menu because it looks like the editor isn't focused.
+           // This kludges around that.
+           return (document.hasFocus() || browser$2.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
+               this.root.activeElement == this.contentDOM;
+       }
+       /**
+       Put focus on the editor.
+       */
+       focus() {
+           this.observer.ignore(() => {
+               focusPreventScroll$2(this.contentDOM);
+               this.docView.updateSelection();
+           });
+       }
+       /**
+       Clean up this editor view, removing its element from the
+       document, unregistering event handlers, and notifying
+       plugins. The view instance can no longer be used after
+       calling this.
+       */
+       destroy() {
+           for (let plugin of this.plugins)
+               plugin.destroy(this);
+           this.plugins = [];
+           this.inputState.destroy();
+           this.dom.remove();
+           this.observer.destroy();
+           if (this.measureScheduled > -1)
+               cancelAnimationFrame(this.measureScheduled);
+           this.destroyed = true;
+       }
+       /**
+       Returns an effect that can be
+       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
+       cause it to scroll the given position or range into view.
+       */
+       static scrollIntoView(pos, options = {}) {
+           return scrollIntoView$4.of(new ScrollTarget$2(typeof pos == "number" ? EditorSelection$2.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
+       }
+       /**
+       Returns an extension that can be used to add DOM event handlers.
+       The value should be an object mapping event names to handler
+       functions. For any given event, such functions are ordered by
+       extension precedence, and the first handler to return true will
+       be assumed to have handled that event, and no other handlers or
+       built-in behavior will be activated for it. These are registered
+       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
+       for `scroll` handlers, which will be called any time the
+       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
+       its parent nodes is scrolled.
+       */
+       static domEventHandlers(handlers) {
+           return ViewPlugin$2.define(() => ({}), { eventHandlers: handlers });
+       }
+       /**
+       Create a theme extension. The first argument can be a
+       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
+       style spec providing the styles for the theme. These will be
+       prefixed with a generated class for the style.
+       
+       Because the selectors will be prefixed with a scope class, rule
+       that directly match the editor's [wrapper
+       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
+       added—need to be explicitly differentiated by adding an `&` to
+       the selector for that element—for example
+       `&.cm-focused`.
+       
+       When `dark` is set to true, the theme will be marked as dark,
+       which will cause the `&dark` rules from [base
+       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
+       `&light` when a light theme is active).
+       */
+       static theme(spec, options) {
+           let prefix = StyleModule.newName();
+           let result = [theme$2.of(prefix), styleModule$2.of(buildTheme$2(`.${prefix}`, spec))];
+           if (options && options.dark)
+               result.push(darkTheme$2.of(true));
+           return result;
+       }
+       /**
+       Create an extension that adds styles to the base theme. Like
+       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
+       place of the editor wrapper element when directly targeting
+       that. You can also use `&dark` or `&light` instead to only
+       target editors with a dark or light theme.
+       */
+       static baseTheme(spec) {
+           return Prec$2.lowest(styleModule$2.of(buildTheme$2("." + baseThemeID$2, spec, lightDarkIDs$2)));
+       }
+   };
+   /**
+   Facet to add a [style
+   module](https://github.com/marijnh/style-mod#documentation) to
+   an editor view. The view will ensure that the module is
+   mounted in its [document
+   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
+   */
+   EditorView$2.styleModule = styleModule$2;
+   /**
+   An input handler can override the way changes to the editable
+   DOM content are handled. Handlers are passed the document
+   positions between which the change was found, and the new
+   content. When one returns true, no further input handlers are
+   called and the default behavior is prevented.
+   */
+   EditorView$2.inputHandler = inputHandler$3;
+   /**
+   By default, the editor assumes all its content has the same
+   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
+   value to make it read the text direction of every (rendered)
+   line separately.
+   */
+   EditorView$2.perLineTextDirection = perLineTextDirection$2;
+   /**
+   Allows you to provide a function that should be called when the
+   library catches an exception from an extension (mostly from view
+   plugins, but may be used by other extensions to route exceptions
+   from user-code-provided callbacks). This is mostly useful for
+   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
+   */
+   EditorView$2.exceptionSink = exceptionSink$2;
+   /**
+   A facet that can be used to register a function to be called
+   every time the view updates.
+   */
+   EditorView$2.updateListener = updateListener$2;
+   /**
+   Facet that controls whether the editor content DOM is editable.
+   When its highest-precedence value is `false`, the element will
+   not have its `contenteditable` attribute set. (Note that this
+   doesn't affect API calls that change the editor content, even
+   when those are bound to keys or buttons. See the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
+   */
+   EditorView$2.editable = editable$2;
+   /**
+   Allows you to influence the way mouse selection happens. The
+   functions in this facet will be called for a `mousedown` event
+   on the editor, and can return an object that overrides the way a
+   selection is computed from that mouse click or drag.
+   */
+   EditorView$2.mouseSelectionStyle = mouseSelectionStyle$2;
+   /**
+   Facet used to configure whether a given selection drag event
+   should move or copy the selection. The given predicate will be
+   called with the `mousedown` event, and can return `true` when
+   the drag should move the content.
+   */
+   EditorView$2.dragMovesSelection = dragMovesSelection$1$2;
+   /**
+   Facet used to configure whether a given selecting click adds a
+   new range to the existing selection or replaces it entirely. The
+   default behavior is to check `event.metaKey` on macOS, and
+   `event.ctrlKey` elsewhere.
+   */
+   EditorView$2.clickAddsSelectionRange = clickAddsSelectionRange$2;
+   /**
+   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
+   are shown in the view. Decorations can be provided in two
+   ways—directly, or via a function that takes an editor view.
+
+   Only decoration sets provided directly are allowed to influence
+   the editor's vertical layout structure. The ones provided as
+   functions are called _after_ the new viewport has been computed,
+   and thus **must not** introduce block widgets or replacing
+   decorations that cover line breaks.
+   */
+   EditorView$2.decorations = decorations$2;
+   /**
+   Used to provide ranges that should be treated as atoms as far as
+   cursor motion is concerned. This causes methods like
+   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
+   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
+   commands built on top of them) to skip across such regions when
+   a selection endpoint would enter them. This does _not_ prevent
+   direct programmatic [selection
+   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
+   regions.
+   */
+   EditorView$2.atomicRanges = atomicRanges$2;
+   /**
+   Facet that allows extensions to provide additional scroll
+   margins (space around the sides of the scrolling element that
+   should be considered invisible). This can be useful when the
+   plugin introduces elements that cover part of that element (for
+   example a horizontally fixed gutter).
+   */
+   EditorView$2.scrollMargins = scrollMargins$2;
+   /**
+   This facet records whether a dark theme is active. The extension
+   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
+   includes an instance of this when the `dark` option is set to
+   true.
+   */
+   EditorView$2.darkTheme = darkTheme$2;
+   /**
+   Facet that provides additional DOM attributes for the editor's
+   editable DOM element.
+   */
+   EditorView$2.contentAttributes = contentAttributes$2;
+   /**
+   Facet that provides DOM attributes for the editor's outer
+   element.
+   */
+   EditorView$2.editorAttributes = editorAttributes$2;
+   /**
+   An extension that enables line wrapping in the editor (by
+   setting CSS `white-space` to `pre-wrap` in the content).
+   */
+   EditorView$2.lineWrapping = /*@__PURE__*/EditorView$2.contentAttributes.of({ "class": "cm-lineWrapping" });
+   /**
+   State effect used to include screen reader announcements in a
+   transaction. These will be added to the DOM in a visually hidden
+   element with `aria-live="polite"` set, and should be used to
+   describe effects that are visually obvious but may not be
+   noticed by screen reader users (such as moving to the next
+   search match).
+   */
+   EditorView$2.announce = /*@__PURE__*/StateEffect$2.define();
+   // Maximum line length for which we compute accurate bidi info
+   const MaxBidiLine$2 = 4096;
+   const BadMeasure$2 = {};
+   let CachedOrder$2 = class CachedOrder {
+       constructor(from, to, dir, order) {
+           this.from = from;
+           this.to = to;
+           this.dir = dir;
+           this.order = order;
+       }
+       static update(cache, changes) {
+           if (changes.empty)
+               return cache;
+           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction$2.LTR;
+           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
+               let entry = cache[i];
+               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
+                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.order));
+           }
+           return result;
+       }
+   };
+   function attrsFromFacet$2(view, facet, base) {
+       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
+           let source = sources[i], value = typeof source == "function" ? source(view) : source;
+           if (value)
+               combineAttrs$2(value, base);
+       }
+       return base;
+   }
+
+   const CanHidePrimary$2 = !browser$2.ios; // FIXME test IE
+   const themeSpec$2 = {
+       ".cm-line": {
+           "& ::selection": { backgroundColor: "transparent !important" },
+           "&::selection": { backgroundColor: "transparent !important" }
+       }
+   };
+   if (CanHidePrimary$2)
+       themeSpec$2[".cm-line"].caretColor = "transparent !important";
+
+   /**
+   A gutter marker represents a bit of information attached to a line
+   in a specific gutter. Your own custom markers have to extend this
+   class.
+   */
+   let GutterMarker$2 = class GutterMarker extends RangeValue$2 {
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       Compare this marker to another marker of the same type.
+       */
+       eq(other) { return false; }
+       /**
+       Called if the marker has a `toDOM` method and its representation
+       was removed from a gutter.
+       */
+       destroy(dom) { }
+   };
+   GutterMarker$2.prototype.elementClass = "";
+   GutterMarker$2.prototype.toDOM = undefined;
+   GutterMarker$2.prototype.mapMode = MapMode$2.TrackBefore;
+   GutterMarker$2.prototype.startSide = GutterMarker$2.prototype.endSide = -1;
+   GutterMarker$2.prototype.point = true;
+
+   // FIXME profile adding a per-Tree TreeNode cache, validating it by
+   // parent pointer
+   /// The default maximum length of a `TreeBuffer` node (1024).
+   const DefaultBufferLength$1 = 1024;
+   let nextPropID$1 = 0;
+   let Range$3 = class Range {
+       constructor(from, to) {
+           this.from = from;
+           this.to = to;
+       }
+   };
+   /// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
+   /// can have metadata associated with it in props. Instances of this
+   /// class represent prop names.
+   let NodeProp$1 = class NodeProp {
+       /// Create a new node prop type.
+       constructor(config = {}) {
+           this.id = nextPropID$1++;
+           this.perNode = !!config.perNode;
+           this.deserialize = config.deserialize || (() => {
+               throw new Error("This node type doesn't define a deserialize function");
+           });
+       }
+       /// This is meant to be used with
+       /// [`NodeSet.extend`](#common.NodeSet.extend) or
+       /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
+       /// prop values for each node type in the set. Takes a [match
+       /// object](#common.NodeType^match) or function that returns undefined
+       /// if the node type doesn't get this prop, and the prop's value if
+       /// it does.
+       add(match) {
+           if (this.perNode)
+               throw new RangeError("Can't add per-node props to node types");
+           if (typeof match != "function")
+               match = NodeType$1.match(match);
+           return (type) => {
+               let result = match(type);
+               return result === undefined ? null : [this, result];
+           };
+       }
+   };
+   /// Prop that is used to describe matching delimiters. For opening
+   /// delimiters, this holds an array of node names (written as a
+   /// space-separated string when declaring this prop in a grammar)
+   /// for the node types of closing delimiters that match it.
+   NodeProp$1.closedBy = new NodeProp$1({ deserialize: str => str.split(" ") });
+   /// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
+   /// attached to closing delimiters, holding an array of node names
+   /// of types of matching opening delimiters.
+   NodeProp$1.openedBy = new NodeProp$1({ deserialize: str => str.split(" ") });
+   /// Used to assign node types to groups (for example, all node
+   /// types that represent an expression could be tagged with an
+   /// `"Expression"` group).
+   NodeProp$1.group = new NodeProp$1({ deserialize: str => str.split(" ") });
+   /// The hash of the [context](#lr.ContextTracker.constructor)
+   /// that the node was parsed in, if any. Used to limit reuse of
+   /// contextual nodes.
+   NodeProp$1.contextHash = new NodeProp$1({ perNode: true });
+   /// The distance beyond the end of the node that the tokenizer
+   /// looked ahead for any of the tokens inside the node. (The LR
+   /// parser only stores this when it is larger than 25, for
+   /// efficiency reasons.)
+   NodeProp$1.lookAhead = new NodeProp$1({ perNode: true });
+   /// This per-node prop is used to replace a given node, or part of a
+   /// node, with another tree. This is useful to include trees from
+   /// different languages.
+   NodeProp$1.mounted = new NodeProp$1({ perNode: true });
+   const noProps$1 = Object.create(null);
+   /// Each node in a syntax tree has a node type associated with it.
+   let NodeType$1 = class NodeType {
+       /// @internal
+       constructor(
+       /// The name of the node type. Not necessarily unique, but if the
+       /// grammar was written properly, different node types with the
+       /// same name within a node set should play the same semantic
+       /// role.
+       name, 
+       /// @internal
+       props, 
+       /// The id of this node in its set. Corresponds to the term ids
+       /// used in the parser.
+       id, 
+       /// @internal
+       flags = 0) {
+           this.name = name;
+           this.props = props;
+           this.id = id;
+           this.flags = flags;
+       }
+       static define(spec) {
+           let props = spec.props && spec.props.length ? Object.create(null) : noProps$1;
+           let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
+               (spec.error ? 4 /* Error */ : 0) | (spec.name == null ? 8 /* Anonymous */ : 0);
+           let type = new NodeType(spec.name || "", props, spec.id, flags);
+           if (spec.props)
+               for (let src of spec.props) {
+                   if (!Array.isArray(src))
+                       src = src(type);
+                   if (src) {
+                       if (src[0].perNode)
+                           throw new RangeError("Can't store a per-node prop on a node type");
+                       props[src[0].id] = src[1];
+                   }
+               }
+           return type;
+       }
+       /// Retrieves a node prop for this type. Will return `undefined` if
+       /// the prop isn't present on this node.
+       prop(prop) { return this.props[prop.id]; }
+       /// True when this is the top node of a grammar.
+       get isTop() { return (this.flags & 1 /* Top */) > 0; }
+       /// True when this node is produced by a skip rule.
+       get isSkipped() { return (this.flags & 2 /* Skipped */) > 0; }
+       /// Indicates whether this is an error node.
+       get isError() { return (this.flags & 4 /* Error */) > 0; }
+       /// When true, this node type doesn't correspond to a user-declared
+       /// named node, for example because it is used to cache repetition.
+       get isAnonymous() { return (this.flags & 8 /* Anonymous */) > 0; }
+       /// Returns true when this node's name or one of its
+       /// [groups](#common.NodeProp^group) matches the given string.
+       is(name) {
+           if (typeof name == 'string') {
+               if (this.name == name)
+                   return true;
+               let group = this.prop(NodeProp$1.group);
+               return group ? group.indexOf(name) > -1 : false;
+           }
+           return this.id == name;
+       }
+       /// Create a function from node types to arbitrary values by
+       /// specifying an object whose property names are node or
+       /// [group](#common.NodeProp^group) names. Often useful with
+       /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
+       /// names, separated by spaces, in a single property name to map
+       /// multiple node names to a single value.
+       static match(map) {
+           let direct = Object.create(null);
+           for (let prop in map)
+               for (let name of prop.split(" "))
+                   direct[name] = map[prop];
+           return (node) => {
+               for (let groups = node.prop(NodeProp$1.group), i = -1; i < (groups ? groups.length : 0); i++) {
+                   let found = direct[i < 0 ? node.name : groups[i]];
+                   if (found)
+                       return found;
+               }
+           };
+       }
+   };
+   /// An empty dummy node type to use when no actual type is available.
+   NodeType$1.none = new NodeType$1("", Object.create(null), 0, 8 /* Anonymous */);
+   const CachedNode$1 = new WeakMap(), CachedInnerNode$1 = new WeakMap();
+   /// Options that control iteration. Can be combined with the `|`
+   /// operator to enable multiple ones.
+   var IterMode$1;
+   (function (IterMode) {
+       /// When enabled, iteration will only visit [`Tree`](#common.Tree)
+       /// objects, not nodes packed into
+       /// [`TreeBuffer`](#common.TreeBuffer)s.
+       IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
+       /// Enable this to make iteration include anonymous nodes (such as
+       /// the nodes that wrap repeated grammar constructs into a balanced
+       /// tree).
+       IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
+       /// By default, regular [mounted](#common.NodeProp^mounted) nodes
+       /// replace their base node in iteration. Enable this to ignore them
+       /// instead.
+       IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
+       /// This option only applies in
+       /// [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
+       /// library to not enter mounted overlays if one covers the given
+       /// position.
+       IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
+   })(IterMode$1 || (IterMode$1 = {}));
+   /// A piece of syntax tree. There are two ways to approach these
+   /// trees: the way they are actually stored in memory, and the
+   /// convenient way.
+   ///
+   /// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
+   /// objects. By packing detail information into `TreeBuffer` leaf
+   /// nodes, the representation is made a lot more memory-efficient.
+   ///
+   /// However, when you want to actually work with tree nodes, this
+   /// representation is very awkward, so most client code will want to
+   /// use the [`TreeCursor`](#common.TreeCursor) or
+   /// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
+   /// a view on some part of this data structure, and can be used to
+   /// move around to adjacent nodes.
+   let Tree$1 = class Tree {
+       /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
+       constructor(
+       /// The type of the top node.
+       type, 
+       /// This node's child nodes.
+       children, 
+       /// The positions (offsets relative to the start of this tree) of
+       /// the children.
+       positions, 
+       /// The total length of this tree
+       length, 
+       /// Per-node [node props](#common.NodeProp) to associate with this node.
+       props) {
+           this.type = type;
+           this.children = children;
+           this.positions = positions;
+           this.length = length;
+           /// @internal
+           this.props = null;
+           if (props && props.length) {
+               this.props = Object.create(null);
+               for (let [prop, value] of props)
+                   this.props[typeof prop == "number" ? prop : prop.id] = value;
+           }
+       }
+       /// @internal
+       toString() {
+           let mounted = this.prop(NodeProp$1.mounted);
+           if (mounted && !mounted.overlay)
+               return mounted.tree.toString();
+           let children = "";
+           for (let ch of this.children) {
+               let str = ch.toString();
+               if (str) {
+                   if (children)
+                       children += ",";
+                   children += str;
+               }
+           }
+           return !this.type.name ? children :
+               (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
+                   (children.length ? "(" + children + ")" : "");
+       }
+       /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
+       /// the tree. Mode can be used to [control](#common.IterMode) which
+       /// nodes the cursor visits.
+       cursor(mode = 0) {
+           return new TreeCursor$1(this.topNode, mode);
+       }
+       /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
+       /// at the given position and side (see
+       /// [`moveTo`](#common.TreeCursor.moveTo).
+       cursorAt(pos, side = 0, mode = 0) {
+           let scope = CachedNode$1.get(this) || this.topNode;
+           let cursor = new TreeCursor$1(scope);
+           cursor.moveTo(pos, side);
+           CachedNode$1.set(this, cursor._tree);
+           return cursor;
+       }
+       /// Get a [syntax node](#common.SyntaxNode) object for the top of the
+       /// tree.
+       get topNode() {
+           return new TreeNode$1(this, 0, 0, null);
+       }
+       /// Get the [syntax node](#common.SyntaxNode) at the given position.
+       /// If `side` is -1, this will move into nodes that end at the
+       /// position. If 1, it'll move into nodes that start at the
+       /// position. With 0, it'll only enter nodes that cover the position
+       /// from both sides.
+       resolve(pos, side = 0) {
+           let node = resolveNode$1(CachedNode$1.get(this) || this.topNode, pos, side, false);
+           CachedNode$1.set(this, node);
+           return node;
+       }
+       /// Like [`resolve`](#common.Tree.resolve), but will enter
+       /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
+       /// pointing into the innermost overlaid tree at the given position
+       /// (with parent links going through all parent structure, including
+       /// the host trees).
+       resolveInner(pos, side = 0) {
+           let node = resolveNode$1(CachedInnerNode$1.get(this) || this.topNode, pos, side, true);
+           CachedInnerNode$1.set(this, node);
+           return node;
+       }
+       /// Iterate over the tree and its children, calling `enter` for any
+       /// node that touches the `from`/`to` region (if given) before
+       /// running over such a node's children, and `leave` (if given) when
+       /// leaving the node. When `enter` returns `false`, that node will
+       /// not have its children iterated over (or `leave` called).
+       iterate(spec) {
+           let { enter, leave, from = 0, to = this.length } = spec;
+           for (let c = this.cursor((spec.mode || 0) | IterMode$1.IncludeAnonymous);;) {
+               let entered = false;
+               if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
+                   if (c.firstChild())
+                       continue;
+                   entered = true;
+               }
+               for (;;) {
+                   if (entered && leave && !c.type.isAnonymous)
+                       leave(c);
+                   if (c.nextSibling())
+                       break;
+                   if (!c.parent())
+                       return;
+                   entered = true;
+               }
+           }
+       }
+       /// Get the value of the given [node prop](#common.NodeProp) for this
+       /// node. Works with both per-node and per-type props.
+       prop(prop) {
+           return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
+       }
+       /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
+       /// format that can be passed to the [`Tree`](#common.Tree)
+       /// constructor.
+       get propValues() {
+           let result = [];
+           if (this.props)
+               for (let id in this.props)
+                   result.push([+id, this.props[id]]);
+           return result;
+       }
+       /// Balance the direct children of this tree, producing a copy of
+       /// which may have children grouped into subtrees with type
+       /// [`NodeType.none`](#common.NodeType^none).
+       balance(config = {}) {
+           return this.children.length <= 8 /* BranchFactor */ ? this :
+               balanceRange$1(NodeType$1.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType$1.none, children, positions, length)));
+       }
+       /// Build a tree from a postfix-ordered buffer of node information,
+       /// or a cursor over such a buffer.
+       static build(data) { return buildTree$1(data); }
+   };
+   /// The empty tree
+   Tree$1.empty = new Tree$1(NodeType$1.none, [], [], 0);
+   let FlatBufferCursor$1 = class FlatBufferCursor {
+       constructor(buffer, index) {
+           this.buffer = buffer;
+           this.index = index;
+       }
+       get id() { return this.buffer[this.index - 4]; }
+       get start() { return this.buffer[this.index - 3]; }
+       get end() { return this.buffer[this.index - 2]; }
+       get size() { return this.buffer[this.index - 1]; }
+       get pos() { return this.index; }
+       next() { this.index -= 4; }
+       fork() { return new FlatBufferCursor(this.buffer, this.index); }
+   };
+   /// Tree buffers contain (type, start, end, endIndex) quads for each
+   /// node. In such a buffer, nodes are stored in prefix order (parents
+   /// before children, with the endIndex of the parent indicating which
+   /// children belong to it)
+   let TreeBuffer$1 = class TreeBuffer {
+       /// Create a tree buffer.
+       constructor(
+       /// The buffer's content.
+       buffer, 
+       /// The total length of the group of nodes in the buffer.
+       length, 
+       /// The node set used in this buffer.
+       set) {
+           this.buffer = buffer;
+           this.length = length;
+           this.set = set;
+       }
+       /// @internal
+       get type() { return NodeType$1.none; }
+       /// @internal
+       toString() {
+           let result = [];
+           for (let index = 0; index < this.buffer.length;) {
+               result.push(this.childString(index));
+               index = this.buffer[index + 3];
+           }
+           return result.join(",");
+       }
+       /// @internal
+       childString(index) {
+           let id = this.buffer[index], endIndex = this.buffer[index + 3];
+           let type = this.set.types[id], result = type.name;
+           if (/\W/.test(result) && !type.isError)
+               result = JSON.stringify(result);
+           index += 4;
+           if (endIndex == index)
+               return result;
+           let children = [];
+           while (index < endIndex) {
+               children.push(this.childString(index));
+               index = this.buffer[index + 3];
+           }
+           return result + "(" + children.join(",") + ")";
+       }
+       /// @internal
+       findChild(startIndex, endIndex, dir, pos, side) {
+           let { buffer } = this, pick = -1;
+           for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
+               if (checkSide$1(side, pos, buffer[i + 1], buffer[i + 2])) {
+                   pick = i;
+                   if (dir > 0)
+                       break;
+               }
+           }
+           return pick;
+       }
+       /// @internal
+       slice(startI, endI, from, to) {
+           let b = this.buffer;
+           let copy = new Uint16Array(endI - startI);
+           for (let i = startI, j = 0; i < endI;) {
+               copy[j++] = b[i++];
+               copy[j++] = b[i++] - from;
+               copy[j++] = b[i++] - from;
+               copy[j++] = b[i++] - startI;
+           }
+           return new TreeBuffer(copy, to - from, this.set);
+       }
+   };
+   function checkSide$1(side, pos, from, to) {
+       switch (side) {
+           case -2 /* Before */: return from < pos;
+           case -1 /* AtOrBefore */: return to >= pos && from < pos;
+           case 0 /* Around */: return from < pos && to > pos;
+           case 1 /* AtOrAfter */: return from <= pos && to > pos;
+           case 2 /* After */: return to > pos;
+           case 4 /* DontCare */: return true;
+       }
+   }
+   function enterUnfinishedNodesBefore(node, pos) {
+       let scan = node.childBefore(pos);
+       while (scan) {
+           let last = scan.lastChild;
+           if (!last || last.to != scan.to)
+               break;
+           if (last.type.isError && last.from == last.to) {
+               node = scan;
+               scan = last.prevSibling;
+           }
+           else {
+               scan = last;
+           }
+       }
+       return node;
+   }
+   function resolveNode$1(node, pos, side, overlays) {
+       var _a;
+       // Move up to a node that actually holds the position, if possible
+       while (node.from == node.to ||
+           (side < 1 ? node.from >= pos : node.from > pos) ||
+           (side > -1 ? node.to <= pos : node.to < pos)) {
+           let parent = !overlays && node instanceof TreeNode$1 && node.index < 0 ? null : node.parent;
+           if (!parent)
+               return node;
+           node = parent;
+       }
+       let mode = overlays ? 0 : IterMode$1.IgnoreOverlays;
+       // Must go up out of overlays when those do not overlap with pos
+       if (overlays)
+           for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
+               if (scan instanceof TreeNode$1 && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
+                   node = parent;
+           }
+       for (;;) {
+           let inner = node.enter(pos, side, mode);
+           if (!inner)
+               return node;
+           node = inner;
+       }
+   }
+   let TreeNode$1 = class TreeNode {
+       constructor(_tree, from, 
+       // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
+       index, _parent) {
+           this._tree = _tree;
+           this.from = from;
+           this.index = index;
+           this._parent = _parent;
+       }
+       get type() { return this._tree.type; }
+       get name() { return this._tree.type.name; }
+       get to() { return this.from + this._tree.length; }
+       nextChild(i, dir, pos, side, mode = 0) {
+           for (let parent = this;;) {
+               for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
+                   let next = children[i], start = positions[i] + parent.from;
+                   if (!checkSide$1(side, pos, start, start + next.length))
+                       continue;
+                   if (next instanceof TreeBuffer$1) {
+                       if (mode & IterMode$1.ExcludeBuffers)
+                           continue;
+                       let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
+                       if (index > -1)
+                           return new BufferNode$1(new BufferContext$1(parent, next, i, start), null, index);
+                   }
+                   else if ((mode & IterMode$1.IncludeAnonymous) || (!next.type.isAnonymous || hasChild$1(next))) {
+                       let mounted;
+                       if (!(mode & IterMode$1.IgnoreMounts) &&
+                           next.props && (mounted = next.prop(NodeProp$1.mounted)) && !mounted.overlay)
+                           return new TreeNode(mounted.tree, start, i, parent);
+                       let inner = new TreeNode(next, start, i, parent);
+                       return (mode & IterMode$1.IncludeAnonymous) || !inner.type.isAnonymous ? inner
+                           : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
+                   }
+               }
+               if ((mode & IterMode$1.IncludeAnonymous) || !parent.type.isAnonymous)
+                   return null;
+               if (parent.index >= 0)
+                   i = parent.index + dir;
+               else
+                   i = dir < 0 ? -1 : parent._parent._tree.children.length;
+               parent = parent._parent;
+               if (!parent)
+                   return null;
+           }
+       }
+       get firstChild() { return this.nextChild(0, 1, 0, 4 /* DontCare */); }
+       get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* DontCare */); }
+       childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* After */); }
+       childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Before */); }
+       enter(pos, side, mode = 0) {
+           let mounted;
+           if (!(mode & IterMode$1.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp$1.mounted)) && mounted.overlay) {
+               let rPos = pos - this.from;
+               for (let { from, to } of mounted.overlay) {
+                   if ((side > 0 ? from <= rPos : from < rPos) &&
+                       (side < 0 ? to >= rPos : to > rPos))
+                       return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
+               }
+           }
+           return this.nextChild(0, 1, pos, side, mode);
+       }
+       nextSignificantParent() {
+           let val = this;
+           while (val.type.isAnonymous && val._parent)
+               val = val._parent;
+           return val;
+       }
+       get parent() {
+           return this._parent ? this._parent.nextSignificantParent() : null;
+       }
+       get nextSibling() {
+           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* DontCare */) : null;
+       }
+       get prevSibling() {
+           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* DontCare */) : null;
+       }
+       cursor(mode = 0) { return new TreeCursor$1(this, mode); }
+       get tree() { return this._tree; }
+       toTree() { return this._tree; }
+       resolve(pos, side = 0) {
+           return resolveNode$1(this, pos, side, false);
+       }
+       resolveInner(pos, side = 0) {
+           return resolveNode$1(this, pos, side, true);
+       }
+       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore(this, pos); }
+       getChild(type, before = null, after = null) {
+           let r = getChildren$1(this, type, before, after);
+           return r.length ? r[0] : null;
+       }
+       getChildren(type, before = null, after = null) {
+           return getChildren$1(this, type, before, after);
+       }
+       /// @internal
+       toString() { return this._tree.toString(); }
+       get node() { return this; }
+       matchContext(context) { return matchNodeContext$1(this, context); }
+   };
+   function getChildren$1(node, type, before, after) {
+       let cur = node.cursor(), result = [];
+       if (!cur.firstChild())
+           return result;
+       if (before != null)
+           while (!cur.type.is(before))
+               if (!cur.nextSibling())
+                   return result;
+       for (;;) {
+           if (after != null && cur.type.is(after))
+               return result;
+           if (cur.type.is(type))
+               result.push(cur.node);
+           if (!cur.nextSibling())
+               return after == null ? result : [];
+       }
+   }
+   function matchNodeContext$1(node, context, i = context.length - 1) {
+       for (let p = node.parent; i >= 0; p = p.parent) {
+           if (!p)
+               return false;
+           if (!p.type.isAnonymous) {
+               if (context[i] && context[i] != p.name)
+                   return false;
+               i--;
+           }
+       }
+       return true;
+   }
+   let BufferContext$1 = class BufferContext {
+       constructor(parent, buffer, index, start) {
+           this.parent = parent;
+           this.buffer = buffer;
+           this.index = index;
+           this.start = start;
+       }
+   };
+   let BufferNode$1 = class BufferNode {
+       constructor(context, _parent, index) {
+           this.context = context;
+           this._parent = _parent;
+           this.index = index;
+           this.type = context.buffer.set.types[context.buffer.buffer[index]];
+       }
+       get name() { return this.type.name; }
+       get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
+       get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
+       child(dir, pos, side) {
+           let { buffer } = this.context;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
+           return index < 0 ? null : new BufferNode(this.context, this, index);
+       }
+       get firstChild() { return this.child(1, 0, 4 /* DontCare */); }
+       get lastChild() { return this.child(-1, 0, 4 /* DontCare */); }
+       childAfter(pos) { return this.child(1, pos, 2 /* After */); }
+       childBefore(pos) { return this.child(-1, pos, -2 /* Before */); }
+       enter(pos, side, mode = 0) {
+           if (mode & IterMode$1.ExcludeBuffers)
+               return null;
+           let { buffer } = this.context;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
+           return index < 0 ? null : new BufferNode(this.context, this, index);
+       }
+       get parent() {
+           return this._parent || this.context.parent.nextSignificantParent();
+       }
+       externalSibling(dir) {
+           return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* DontCare */);
+       }
+       get nextSibling() {
+           let { buffer } = this.context;
+           let after = buffer.buffer[this.index + 3];
+           if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
+               return new BufferNode(this.context, this._parent, after);
+           return this.externalSibling(1);
+       }
+       get prevSibling() {
+           let { buffer } = this.context;
+           let parentStart = this._parent ? this._parent.index + 4 : 0;
+           if (this.index == parentStart)
+               return this.externalSibling(-1);
+           return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
+       }
+       cursor(mode = 0) { return new TreeCursor$1(this, mode); }
+       get tree() { return null; }
+       toTree() {
+           let children = [], positions = [];
+           let { buffer } = this.context;
+           let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
+           if (endI > startI) {
+               let from = buffer.buffer[this.index + 1], to = buffer.buffer[this.index + 2];
+               children.push(buffer.slice(startI, endI, from, to));
+               positions.push(0);
+           }
+           return new Tree$1(this.type, children, positions, this.to - this.from);
+       }
+       resolve(pos, side = 0) {
+           return resolveNode$1(this, pos, side, false);
+       }
+       resolveInner(pos, side = 0) {
+           return resolveNode$1(this, pos, side, true);
+       }
+       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore(this, pos); }
+       /// @internal
+       toString() { return this.context.buffer.childString(this.index); }
+       getChild(type, before = null, after = null) {
+           let r = getChildren$1(this, type, before, after);
+           return r.length ? r[0] : null;
+       }
+       getChildren(type, before = null, after = null) {
+           return getChildren$1(this, type, before, after);
+       }
+       get node() { return this; }
+       matchContext(context) { return matchNodeContext$1(this, context); }
+   };
+   /// A tree cursor object focuses on a given node in a syntax tree, and
+   /// allows you to move to adjacent nodes.
+   let TreeCursor$1 = class TreeCursor {
+       /// @internal
+       constructor(node, 
+       /// @internal
+       mode = 0) {
+           this.mode = mode;
+           /// @internal
+           this.buffer = null;
+           this.stack = [];
+           /// @internal
+           this.index = 0;
+           this.bufferNode = null;
+           if (node instanceof TreeNode$1) {
+               this.yieldNode(node);
+           }
+           else {
+               this._tree = node.context.parent;
+               this.buffer = node.context;
+               for (let n = node._parent; n; n = n._parent)
+                   this.stack.unshift(n.index);
+               this.bufferNode = node;
+               this.yieldBuf(node.index);
+           }
+       }
+       /// Shorthand for `.type.name`.
+       get name() { return this.type.name; }
+       yieldNode(node) {
+           if (!node)
+               return false;
+           this._tree = node;
+           this.type = node.type;
+           this.from = node.from;
+           this.to = node.to;
+           return true;
+       }
+       yieldBuf(index, type) {
+           this.index = index;
+           let { start, buffer } = this.buffer;
+           this.type = type || buffer.set.types[buffer.buffer[index]];
+           this.from = start + buffer.buffer[index + 1];
+           this.to = start + buffer.buffer[index + 2];
+           return true;
+       }
+       yield(node) {
+           if (!node)
+               return false;
+           if (node instanceof TreeNode$1) {
+               this.buffer = null;
+               return this.yieldNode(node);
+           }
+           this.buffer = node.context;
+           return this.yieldBuf(node.index, node.type);
+       }
+       /// @internal
+       toString() {
+           return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
+       }
+       /// @internal
+       enterChild(dir, pos, side) {
+           if (!this.buffer)
+               return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
+           let { buffer } = this.buffer;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
+           if (index < 0)
+               return false;
+           this.stack.push(this.index);
+           return this.yieldBuf(index);
+       }
+       /// Move the cursor to this node's first child. When this returns
+       /// false, the node has no child, and the cursor has not been moved.
+       firstChild() { return this.enterChild(1, 0, 4 /* DontCare */); }
+       /// Move the cursor to this node's last child.
+       lastChild() { return this.enterChild(-1, 0, 4 /* DontCare */); }
+       /// Move the cursor to the first child that ends after `pos`.
+       childAfter(pos) { return this.enterChild(1, pos, 2 /* After */); }
+       /// Move to the last child that starts before `pos`.
+       childBefore(pos) { return this.enterChild(-1, pos, -2 /* Before */); }
+       /// Move the cursor to the child around `pos`. If side is -1 the
+       /// child may end at that position, when 1 it may start there. This
+       /// will also enter [overlaid](#common.MountedTree.overlay)
+       /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
+       /// set to false.
+       enter(pos, side, mode = this.mode) {
+           if (!this.buffer)
+               return this.yield(this._tree.enter(pos, side, mode));
+           return mode & IterMode$1.ExcludeBuffers ? false : this.enterChild(1, pos, side);
+       }
+       /// Move to the node's parent node, if this isn't the top node.
+       parent() {
+           if (!this.buffer)
+               return this.yieldNode((this.mode & IterMode$1.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
+           if (this.stack.length)
+               return this.yieldBuf(this.stack.pop());
+           let parent = (this.mode & IterMode$1.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
+           this.buffer = null;
+           return this.yieldNode(parent);
+       }
+       /// @internal
+       sibling(dir) {
+           if (!this.buffer)
+               return !this._tree._parent ? false
+                   : this.yield(this._tree.index < 0 ? null
+                       : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* DontCare */, this.mode));
+           let { buffer } = this.buffer, d = this.stack.length - 1;
+           if (dir < 0) {
+               let parentStart = d < 0 ? 0 : this.stack[d] + 4;
+               if (this.index != parentStart)
+                   return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
+           }
+           else {
+               let after = buffer.buffer[this.index + 3];
+               if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
+                   return this.yieldBuf(after);
+           }
+           return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* DontCare */, this.mode)) : false;
+       }
+       /// Move to this node's next sibling, if any.
+       nextSibling() { return this.sibling(1); }
+       /// Move to this node's previous sibling, if any.
+       prevSibling() { return this.sibling(-1); }
+       atLastNode(dir) {
+           let index, parent, { buffer } = this;
+           if (buffer) {
+               if (dir > 0) {
+                   if (this.index < buffer.buffer.buffer.length)
+                       return false;
+               }
+               else {
+                   for (let i = 0; i < this.index; i++)
+                       if (buffer.buffer.buffer[i + 3] < this.index)
+                           return false;
+               }
+               ({ index, parent } = buffer);
+           }
+           else {
+               ({ index, _parent: parent } = this._tree);
+           }
+           for (; parent; { index, _parent: parent } = parent) {
+               if (index > -1)
+                   for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
+                       let child = parent._tree.children[i];
+                       if ((this.mode & IterMode$1.IncludeAnonymous) ||
+                           child instanceof TreeBuffer$1 ||
+                           !child.type.isAnonymous ||
+                           hasChild$1(child))
+                           return false;
+                   }
+           }
+           return true;
+       }
+       move(dir, enter) {
+           if (enter && this.enterChild(dir, 0, 4 /* DontCare */))
+               return true;
+           for (;;) {
+               if (this.sibling(dir))
+                   return true;
+               if (this.atLastNode(dir) || !this.parent())
+                   return false;
+           }
+       }
+       /// Move to the next node in a
+       /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
+       /// traversal, going from a node to its first child or, if the
+       /// current node is empty or `enter` is false, its next sibling or
+       /// the next sibling of the first parent node that has one.
+       next(enter = true) { return this.move(1, enter); }
+       /// Move to the next node in a last-to-first pre-order traveral. A
+       /// node is followed by its last child or, if it has none, its
+       /// previous sibling or the previous sibling of the first parent
+       /// node that has one.
+       prev(enter = true) { return this.move(-1, enter); }
+       /// Move the cursor to the innermost node that covers `pos`. If
+       /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
+       /// it will enter nodes that start at `pos`.
+       moveTo(pos, side = 0) {
+           // Move up to a node that actually holds the position, if possible
+           while (this.from == this.to ||
+               (side < 1 ? this.from >= pos : this.from > pos) ||
+               (side > -1 ? this.to <= pos : this.to < pos))
+               if (!this.parent())
+                   break;
+           // Then scan down into child nodes as far as possible
+           while (this.enterChild(1, pos, side)) { }
+           return this;
+       }
+       /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
+       /// position.
+       get node() {
+           if (!this.buffer)
+               return this._tree;
+           let cache = this.bufferNode, result = null, depth = 0;
+           if (cache && cache.context == this.buffer) {
+               scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
+                   for (let c = cache; c; c = c._parent)
+                       if (c.index == index) {
+                           if (index == this.index)
+                               return c;
+                           result = c;
+                           depth = d + 1;
+                           break scan;
+                       }
+                   index = this.stack[--d];
+               }
+           }
+           for (let i = depth; i < this.stack.length; i++)
+               result = new BufferNode$1(this.buffer, result, this.stack[i]);
+           return this.bufferNode = new BufferNode$1(this.buffer, result, this.index);
+       }
+       /// Get the [tree](#common.Tree) that represents the current node, if
+       /// any. Will return null when the node is in a [tree
+       /// buffer](#common.TreeBuffer).
+       get tree() {
+           return this.buffer ? null : this._tree._tree;
+       }
+       /// Iterate over the current node and all its descendants, calling
+       /// `enter` when entering a node and `leave`, if given, when leaving
+       /// one. When `enter` returns `false`, any children of that node are
+       /// skipped, and `leave` isn't called for it.
+       iterate(enter, leave) {
+           for (let depth = 0;;) {
+               let mustLeave = false;
+               if (this.type.isAnonymous || enter(this) !== false) {
+                   if (this.firstChild()) {
+                       depth++;
+                       continue;
+                   }
+                   if (!this.type.isAnonymous)
+                       mustLeave = true;
+               }
+               for (;;) {
+                   if (mustLeave && leave)
+                       leave(this);
+                   mustLeave = this.type.isAnonymous;
+                   if (this.nextSibling())
+                       break;
+                   if (!depth)
+                       return;
+                   this.parent();
+                   depth--;
+                   mustLeave = true;
+               }
+           }
+       }
+       /// Test whether the current node matches a given context—a sequence
+       /// of direct parent node names. Empty strings in the context array
+       /// are treated as wildcards.
+       matchContext(context) {
+           if (!this.buffer)
+               return matchNodeContext$1(this.node, context);
+           let { buffer } = this.buffer, { types } = buffer.set;
+           for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
+               if (d < 0)
+                   return matchNodeContext$1(this.node, context, i);
+               let type = types[buffer.buffer[this.stack[d]]];
+               if (!type.isAnonymous) {
+                   if (context[i] && context[i] != type.name)
+                       return false;
+                   i--;
+               }
+           }
+           return true;
+       }
+   };
+   function hasChild$1(tree) {
+       return tree.children.some(ch => ch instanceof TreeBuffer$1 || !ch.type.isAnonymous || hasChild$1(ch));
+   }
+   function buildTree$1(data) {
+       var _a;
+       let { buffer, nodeSet, maxBufferLength = DefaultBufferLength$1, reused = [], minRepeatType = nodeSet.types.length } = data;
+       let cursor = Array.isArray(buffer) ? new FlatBufferCursor$1(buffer, buffer.length) : buffer;
+       let types = nodeSet.types;
+       let contextHash = 0, lookAhead = 0;
+       function takeNode(parentStart, minPos, children, positions, inRepeat) {
+           let { id, start, end, size } = cursor;
+           let lookAheadAtStart = lookAhead;
+           while (size < 0) {
+               cursor.next();
+               if (size == -1 /* Reuse */) {
+                   let node = reused[id];
+                   children.push(node);
+                   positions.push(start - parentStart);
+                   return;
+               }
+               else if (size == -3 /* ContextChange */) { // Context change
+                   contextHash = id;
+                   return;
+               }
+               else if (size == -4 /* LookAhead */) {
+                   lookAhead = id;
+                   return;
+               }
+               else {
+                   throw new RangeError(`Unrecognized record size: ${size}`);
+               }
+           }
+           let type = types[id], node, buffer;
+           let startPos = start - parentStart;
+           if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
+               // Small enough for a buffer, and no reused nodes inside
+               let data = new Uint16Array(buffer.size - buffer.skip);
+               let endPos = cursor.pos - buffer.size, index = data.length;
+               while (cursor.pos > endPos)
+                   index = copyToBuffer(buffer.start, data, index);
+               node = new TreeBuffer$1(data, end - buffer.start, nodeSet);
+               startPos = buffer.start - parentStart;
+           }
+           else { // Make it a node
+               let endPos = cursor.pos - size;
+               cursor.next();
+               let localChildren = [], localPositions = [];
+               let localInRepeat = id >= minRepeatType ? id : -1;
+               let lastGroup = 0, lastEnd = end;
+               while (cursor.pos > endPos) {
+                   if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
+                       if (cursor.end <= lastEnd - maxBufferLength) {
+                           makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
+                           lastGroup = localChildren.length;
+                           lastEnd = cursor.end;
+                       }
+                       cursor.next();
+                   }
+                   else {
+                       takeNode(start, endPos, localChildren, localPositions, localInRepeat);
+                   }
+               }
+               if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
+                   makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
+               localChildren.reverse();
+               localPositions.reverse();
+               if (localInRepeat > -1 && lastGroup > 0) {
+                   let make = makeBalanced(type);
+                   node = balanceRange$1(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
+               }
+               else {
+                   node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
+               }
+           }
+           children.push(node);
+           positions.push(startPos);
+       }
+       function makeBalanced(type) {
+           return (children, positions, length) => {
+               let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
+               if (lastI >= 0 && (last = children[lastI]) instanceof Tree$1) {
+                   if (!lastI && last.type == type && last.length == length)
+                       return last;
+                   if (lookAheadProp = last.prop(NodeProp$1.lookAhead))
+                       lookAhead = positions[lastI] + last.length + lookAheadProp;
+               }
+               return makeTree(type, children, positions, length, lookAhead);
+           };
+       }
+       function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {
+           let localChildren = [], localPositions = [];
+           while (children.length > i) {
+               localChildren.push(children.pop());
+               localPositions.push(positions.pop() + base - from);
+           }
+           children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));
+           positions.push(from - base);
+       }
+       function makeTree(type, children, positions, length, lookAhead = 0, props) {
+           if (contextHash) {
+               let pair = [NodeProp$1.contextHash, contextHash];
+               props = props ? [pair].concat(props) : [pair];
+           }
+           if (lookAhead > 25) {
+               let pair = [NodeProp$1.lookAhead, lookAhead];
+               props = props ? [pair].concat(props) : [pair];
+           }
+           return new Tree$1(type, children, positions, length, props);
+       }
+       function findBufferSize(maxSize, inRepeat) {
+           // Scan through the buffer to find previous siblings that fit
+           // together in a TreeBuffer, and don't contain any reused nodes
+           // (which can't be stored in a buffer).
+           // If `inRepeat` is > -1, ignore node boundaries of that type for
+           // nesting, but make sure the end falls either at the start
+           // (`maxSize`) or before such a node.
+           let fork = cursor.fork();
+           let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
+           let result = { size: 0, start: 0, skip: 0 };
+           scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
+               let nodeSize = fork.size;
+               // Pretend nested repeat nodes of the same type don't exist
+               if (fork.id == inRepeat && nodeSize >= 0) {
+                   // Except that we store the current state as a valid return
+                   // value.
+                   result.size = size;
+                   result.start = start;
+                   result.skip = skip;
+                   skip += 4;
+                   size += 4;
+                   fork.next();
+                   continue;
+               }
+               let startPos = fork.pos - nodeSize;
+               if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
+                   break;
+               let localSkipped = fork.id >= minRepeatType ? 4 : 0;
+               let nodeStart = fork.start;
+               fork.next();
+               while (fork.pos > startPos) {
+                   if (fork.size < 0) {
+                       if (fork.size == -3 /* ContextChange */)
+                           localSkipped += 4;
+                       else
+                           break scan;
+                   }
+                   else if (fork.id >= minRepeatType) {
+                       localSkipped += 4;
+                   }
+                   fork.next();
+               }
+               start = nodeStart;
+               size += nodeSize;
+               skip += localSkipped;
+           }
+           if (inRepeat < 0 || size == maxSize) {
+               result.size = size;
+               result.start = start;
+               result.skip = skip;
+           }
+           return result.size > 4 ? result : undefined;
+       }
+       function copyToBuffer(bufferStart, buffer, index) {
+           let { id, start, end, size } = cursor;
+           cursor.next();
+           if (size >= 0 && id < minRepeatType) {
+               let startIndex = index;
+               if (size > 4) {
+                   let endPos = cursor.pos - (size - 4);
+                   while (cursor.pos > endPos)
+                       index = copyToBuffer(bufferStart, buffer, index);
+               }
+               buffer[--index] = startIndex;
+               buffer[--index] = end - bufferStart;
+               buffer[--index] = start - bufferStart;
+               buffer[--index] = id;
+           }
+           else if (size == -3 /* ContextChange */) {
+               contextHash = id;
+           }
+           else if (size == -4 /* LookAhead */) {
+               lookAhead = id;
+           }
+           return index;
+       }
+       let children = [], positions = [];
+       while (cursor.pos > 0)
+           takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
+       let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
+       return new Tree$1(types[data.topID], children.reverse(), positions.reverse(), length);
+   }
+   const nodeSizeCache$1 = new WeakMap;
+   function nodeSize$1(balanceType, node) {
+       if (!balanceType.isAnonymous || node instanceof TreeBuffer$1 || node.type != balanceType)
+           return 1;
+       let size = nodeSizeCache$1.get(node);
+       if (size == null) {
+           size = 1;
+           for (let child of node.children) {
+               if (child.type != balanceType || !(child instanceof Tree$1)) {
+                   size = 1;
+                   break;
+               }
+               size += nodeSize$1(balanceType, child);
+           }
+           nodeSizeCache$1.set(node, size);
+       }
+       return size;
+   }
+   function balanceRange$1(
+   // The type the balanced tree's inner nodes.
+   balanceType, 
+   // The direct children and their positions
+   children, positions, 
+   // The index range in children/positions to use
+   from, to, 
+   // The start position of the nodes, relative to their parent.
+   start, 
+   // Length of the outer node
+   length, 
+   // Function to build the top node of the balanced tree
+   mkTop, 
+   // Function to build internal nodes for the balanced tree
+   mkTree) {
+       let total = 0;
+       for (let i = from; i < to; i++)
+           total += nodeSize$1(balanceType, children[i]);
+       let maxChild = Math.ceil((total * 1.5) / 8 /* BranchFactor */);
+       let localChildren = [], localPositions = [];
+       function divide(children, positions, from, to, offset) {
+           for (let i = from; i < to;) {
+               let groupFrom = i, groupStart = positions[i], groupSize = nodeSize$1(balanceType, children[i]);
+               i++;
+               for (; i < to; i++) {
+                   let nextSize = nodeSize$1(balanceType, children[i]);
+                   if (groupSize + nextSize >= maxChild)
+                       break;
+                   groupSize += nextSize;
+               }
+               if (i == groupFrom + 1) {
+                   if (groupSize > maxChild) {
+                       let only = children[groupFrom]; // Only trees can have a size > 1
+                       divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
+                       continue;
+                   }
+                   localChildren.push(children[groupFrom]);
+               }
+               else {
+                   let length = positions[i - 1] + children[i - 1].length - groupStart;
+                   localChildren.push(balanceRange$1(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
+               }
+               localPositions.push(groupStart + offset - start);
+           }
+       }
+       divide(children, positions, from, to, 0);
+       return (mkTop || mkTree)(localChildren, localPositions, length);
+   }
+
+   /// Tree fragments are used during [incremental
+   /// parsing](#common.Parser.startParse) to track parts of old trees
+   /// that can be reused in a new parse. An array of fragments is used
+   /// to track regions of an old tree whose nodes might be reused in new
+   /// parses. Use the static
+   /// [`applyChanges`](#common.TreeFragment^applyChanges) method to
+   /// update fragments for document changes.
+   let TreeFragment$1 = class TreeFragment {
+       /// Construct a tree fragment.
+       constructor(
+       /// The start of the unchanged range pointed to by this fragment.
+       /// This refers to an offset in the _updated_ document (as opposed
+       /// to the original tree).
+       from, 
+       /// The end of the unchanged range.
+       to, 
+       /// The tree that this fragment is based on.
+       tree, 
+       /// The offset between the fragment's tree and the document that
+       /// this fragment can be used against. Add this when going from
+       /// document to tree positions, subtract it to go from tree to
+       /// document positions.
+       offset, openStart = false, openEnd = false) {
+           this.from = from;
+           this.to = to;
+           this.tree = tree;
+           this.offset = offset;
+           this.open = (openStart ? 1 /* Start */ : 0) | (openEnd ? 2 /* End */ : 0);
+       }
+       /// Whether the start of the fragment represents the start of a
+       /// parse, or the end of a change. (In the second case, it may not
+       /// be safe to reuse some nodes at the start, depending on the
+       /// parsing algorithm.)
+       get openStart() { return (this.open & 1 /* Start */) > 0; }
+       /// Whether the end of the fragment represents the end of a
+       /// full-document parse, or the start of a change.
+       get openEnd() { return (this.open & 2 /* End */) > 0; }
+       /// Create a set of fragments from a freshly parsed tree, or update
+       /// an existing set of fragments by replacing the ones that overlap
+       /// with a tree with content from the new tree. When `partial` is
+       /// true, the parse is treated as incomplete, and the resulting
+       /// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
+       /// true.
+       static addTree(tree, fragments = [], partial = false) {
+           let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
+           for (let f of fragments)
+               if (f.to > tree.length)
+                   result.push(f);
+           return result;
+       }
+       /// Apply a set of edits to an array of fragments, removing or
+       /// splitting fragments as necessary to remove edited ranges, and
+       /// adjusting offsets for fragments that moved.
+       static applyChanges(fragments, changes, minGap = 128) {
+           if (!changes.length)
+               return fragments;
+           let result = [];
+           let fI = 1, nextF = fragments.length ? fragments[0] : null;
+           for (let cI = 0, pos = 0, off = 0;; cI++) {
+               let nextC = cI < changes.length ? changes[cI] : null;
+               let nextPos = nextC ? nextC.fromA : 1e9;
+               if (nextPos - pos >= minGap)
+                   while (nextF && nextF.from < nextPos) {
+                       let cut = nextF;
+                       if (pos >= cut.from || nextPos <= cut.to || off) {
+                           let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
+                           cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
+                       }
+                       if (cut)
+                           result.push(cut);
+                       if (nextF.to > nextPos)
+                           break;
+                       nextF = fI < fragments.length ? fragments[fI++] : null;
+                   }
+               if (!nextC)
+                   break;
+               pos = nextC.toA;
+               off = nextC.toA - nextC.toB;
+           }
+           return result;
+       }
+   };
+   /// A superclass that parsers should extend.
+   let Parser$1 = class Parser {
+       /// Start a parse, returning a [partial parse](#common.PartialParse)
+       /// object. [`fragments`](#common.TreeFragment) can be passed in to
+       /// make the parse incremental.
+       ///
+       /// By default, the entire input is parsed. You can pass `ranges`,
+       /// which should be a sorted array of non-empty, non-overlapping
+       /// ranges, to parse only those ranges. The tree returned in that
+       /// case will start at `ranges[0].from`.
+       startParse(input, fragments, ranges) {
+           if (typeof input == "string")
+               input = new StringInput$1(input);
+           ranges = !ranges ? [new Range$3(0, input.length)] : ranges.length ? ranges.map(r => new Range$3(r.from, r.to)) : [new Range$3(0, 0)];
+           return this.createParse(input, fragments || [], ranges);
+       }
+       /// Run a full parse, returning the resulting tree.
+       parse(input, fragments, ranges) {
+           let parse = this.startParse(input, fragments, ranges);
+           for (;;) {
+               let done = parse.advance();
+               if (done)
+                   return done;
+           }
+       }
+   };
+   let StringInput$1 = class StringInput {
+       constructor(string) {
+           this.string = string;
+       }
+       get length() { return this.string.length; }
+       chunk(from) { return this.string.slice(from); }
+       get lineChunks() { return false; }
+       read(from, to) { return this.string.slice(from, to); }
+   };
+   new NodeProp$1({ perNode: true });
+
+   let nextTagID$1 = 0;
+   /// Highlighting tags are markers that denote a highlighting category.
+   /// They are [associated](#highlight.styleTags) with parts of a syntax
+   /// tree by a language mode, and then mapped to an actual CSS style by
+   /// a [highlighter](#highlight.Highlighter).
+   ///
+   /// Because syntax tree node types and highlight styles have to be
+   /// able to talk the same language, CodeMirror uses a mostly _closed_
+   /// [vocabulary](#highlight.tags) of syntax tags (as opposed to
+   /// traditional open string-based systems, which make it hard for
+   /// highlighting themes to cover all the tokens produced by the
+   /// various languages).
+   ///
+   /// It _is_ possible to [define](#highlight.Tag^define) your own
+   /// highlighting tags for system-internal use (where you control both
+   /// the language package and the highlighter), but such tags will not
+   /// be picked up by regular highlighters (though you can derive them
+   /// from standard tags to allow highlighters to fall back to those).
+   let Tag$1 = class Tag {
+       /// @internal
+       constructor(
+       /// The set of this tag and all its parent tags, starting with
+       /// this one itself and sorted in order of decreasing specificity.
+       set, 
+       /// The base unmodified tag that this one is based on, if it's
+       /// modified @internal
+       base, 
+       /// The modifiers applied to this.base @internal
+       modified) {
+           this.set = set;
+           this.base = base;
+           this.modified = modified;
+           /// @internal
+           this.id = nextTagID$1++;
+       }
+       /// Define a new tag. If `parent` is given, the tag is treated as a
+       /// sub-tag of that parent, and
+       /// [highlighters](#highlight.tagHighlighter) that don't mention
+       /// this tag will try to fall back to the parent tag (or grandparent
+       /// tag, etc).
+       static define(parent) {
+           if (parent === null || parent === void 0 ? void 0 : parent.base)
+               throw new Error("Can not derive from a modified tag");
+           let tag = new Tag([], null, []);
+           tag.set.push(tag);
+           if (parent)
+               for (let t of parent.set)
+                   tag.set.push(t);
+           return tag;
+       }
+       /// Define a tag _modifier_, which is a function that, given a tag,
+       /// will return a tag that is a subtag of the original. Applying the
+       /// same modifier to a twice tag will return the same value (`m1(t1)
+       /// == m1(t1)`) and applying multiple modifiers will, regardless or
+       /// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
+       ///
+       /// When multiple modifiers are applied to a given base tag, each
+       /// smaller set of modifiers is registered as a parent, so that for
+       /// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
+       /// `m1(m3(t1)`, and so on.
+       static defineModifier() {
+           let mod = new Modifier$1;
+           return (tag) => {
+               if (tag.modified.indexOf(mod) > -1)
+                   return tag;
+               return Modifier$1.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
+           };
+       }
+   };
+   let nextModifierID$1 = 0;
+   let Modifier$1 = class Modifier {
+       constructor() {
+           this.instances = [];
+           this.id = nextModifierID$1++;
+       }
+       static get(base, mods) {
+           if (!mods.length)
+               return base;
+           let exists = mods[0].instances.find(t => t.base == base && sameArray$3(mods, t.modified));
+           if (exists)
+               return exists;
+           let set = [], tag = new Tag$1(set, base, mods);
+           for (let m of mods)
+               m.instances.push(tag);
+           let configs = permute(mods);
+           for (let parent of base.set)
+               for (let config of configs)
+                   set.push(Modifier.get(parent, config));
+           return tag;
+       }
+   };
+   function sameArray$3(a, b) {
+       return a.length == b.length && a.every((x, i) => x == b[i]);
+   }
+   function permute(array) {
+       let result = [array];
+       for (let i = 0; i < array.length; i++) {
+           for (let a of permute(array.slice(0, i).concat(array.slice(i + 1))))
+               result.push(a);
+       }
+       return result;
+   }
+   /// This function is used to add a set of tags to a language syntax
+   /// via [`NodeSet.extend`](#common.NodeSet.extend) or
+   /// [`LRParser.configure`](#lr.LRParser.configure).
+   ///
+   /// The argument object maps node selectors to [highlighting
+   /// tags](#highlight.Tag) or arrays of tags.
+   ///
+   /// Node selectors may hold one or more (space-separated) node paths.
+   /// Such a path can be a [node name](#common.NodeType.name), or
+   /// multiple node names (or `*` wildcards) separated by slash
+   /// characters, as in `"Block/Declaration/VariableName"`. Such a path
+   /// matches the final node but only if its direct parent nodes are the
+   /// other nodes mentioned. A `*` in such a path matches any parent,
+   /// but only a single level—wildcards that match multiple parents
+   /// aren't supported, both for efficiency reasons and because Lezer
+   /// trees make it rather hard to reason about what they would match.)
+   ///
+   /// A path can be ended with `/...` to indicate that the tag assigned
+   /// to the node should also apply to all child nodes, even if they
+   /// match their own style (by default, only the innermost style is
+   /// used).
+   ///
+   /// When a path ends in `!`, as in `Attribute!`, no further matching
+   /// happens for the node's child nodes, and the entire node gets the
+   /// given style.
+   ///
+   /// In this notation, node names that contain `/`, `!`, `*`, or `...`
+   /// must be quoted as JSON strings.
+   ///
+   /// For example:
+   ///
+   /// ```javascript
+   /// parser.withProps(
+   ///   styleTags({
+   ///     // Style Number and BigNumber nodes
+   ///     "Number BigNumber": tags.number,
+   ///     // Style Escape nodes whose parent is String
+   ///     "String/Escape": tags.escape,
+   ///     // Style anything inside Attributes nodes
+   ///     "Attributes!": tags.meta,
+   ///     // Add a style to all content inside Italic nodes
+   ///     "Italic/...": tags.emphasis,
+   ///     // Style InvalidString nodes as both `string` and `invalid`
+   ///     "InvalidString": [tags.string, tags.invalid],
+   ///     // Style the node named "/" as punctuation
+   ///     '"/"': tags.punctuation
+   ///   })
+   /// )
+   /// ```
+   function styleTags$1(spec) {
+       let byName = Object.create(null);
+       for (let prop in spec) {
+           let tags = spec[prop];
+           if (!Array.isArray(tags))
+               tags = [tags];
+           for (let part of prop.split(" "))
+               if (part) {
+                   let pieces = [], mode = 2 /* Normal */, rest = part;
+                   for (let pos = 0;;) {
+                       if (rest == "..." && pos > 0 && pos + 3 == part.length) {
+                           mode = 1 /* Inherit */;
+                           break;
+                       }
+                       let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
+                       if (!m)
+                           throw new RangeError("Invalid path: " + part);
+                       pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
+                       pos += m[0].length;
+                       if (pos == part.length)
+                           break;
+                       let next = part[pos++];
+                       if (pos == part.length && next == "!") {
+                           mode = 0 /* Opaque */;
+                           break;
+                       }
+                       if (next != "/")
+                           throw new RangeError("Invalid path: " + part);
+                       rest = part.slice(pos);
+                   }
+                   let last = pieces.length - 1, inner = pieces[last];
+                   if (!inner)
+                       throw new RangeError("Invalid path: " + part);
+                   let rule = new Rule$1(tags, mode, last > 0 ? pieces.slice(0, last) : null);
+                   byName[inner] = rule.sort(byName[inner]);
+               }
+       }
+       return ruleNodeProp$1.add(byName);
+   }
+   const ruleNodeProp$1 = new NodeProp$1();
+   let Rule$1 = class Rule {
+       constructor(tags, mode, context, next) {
+           this.tags = tags;
+           this.mode = mode;
+           this.context = context;
+           this.next = next;
+       }
+       sort(other) {
+           if (!other || other.depth < this.depth) {
+               this.next = other;
+               return this;
+           }
+           other.next = this.sort(other.next);
+           return other;
+       }
+       get depth() { return this.context ? this.context.length : 0; }
+   };
+   /// Define a [highlighter](#highlight.Highlighter) from an array of
+   /// tag/class pairs. Classes associated with more specific tags will
+   /// take precedence.
+   function tagHighlighter$1(tags, options) {
+       let map = Object.create(null);
+       for (let style of tags) {
+           if (!Array.isArray(style.tag))
+               map[style.tag.id] = style.class;
+           else
+               for (let tag of style.tag)
+                   map[tag.id] = style.class;
+       }
+       let { scope, all = null } = {};
+       return {
+           style: (tags) => {
+               let cls = all;
+               for (let tag of tags) {
+                   for (let sub of tag.set) {
+                       let tagClass = map[sub.id];
+                       if (tagClass) {
+                           cls = cls ? cls + " " + tagClass : tagClass;
+                           break;
+                       }
+                   }
+               }
+               return cls;
+           },
+           scope: scope
+       };
+   }
+   const t$1 = Tag$1.define;
+   const comment$1 = t$1(), name$1 = t$1(), typeName$1 = t$1(name$1), propertyName$1 = t$1(name$1), literal$1 = t$1(), string$1 = t$1(literal$1), number$1 = t$1(literal$1), content$1 = t$1(), heading$1 = t$1(content$1), keyword$1 = t$1(), operator$1 = t$1(), punctuation$1 = t$1(), bracket$1 = t$1(punctuation$1), meta$1 = t$1();
+   /// The default set of highlighting [tags](#highlight.Tag).
+   ///
+   /// This collection is heavily biased towards programming languages,
+   /// and necessarily incomplete. A full ontology of syntactic
+   /// constructs would fill a stack of books, and be impractical to
+   /// write themes for. So try to make do with this set. If all else
+   /// fails, [open an
+   /// issue](https://github.com/codemirror/codemirror.next) to propose a
+   /// new tag, or [define](#highlight.Tag^define) a local custom tag for
+   /// your use case.
+   ///
+   /// Note that it is not obligatory to always attach the most specific
+   /// tag possible to an element—if your grammar can't easily
+   /// distinguish a certain type of element (such as a local variable),
+   /// it is okay to style it as its more general variant (a variable).
+   /// 
+   /// For tags that extend some parent tag, the documentation links to
+   /// the parent.
+   const tags$1 = {
+       /// A comment.
+       comment: comment$1,
+       /// A line [comment](#highlight.tags.comment).
+       lineComment: t$1(comment$1),
+       /// A block [comment](#highlight.tags.comment).
+       blockComment: t$1(comment$1),
+       /// A documentation [comment](#highlight.tags.comment).
+       docComment: t$1(comment$1),
+       /// Any kind of identifier.
+       name: name$1,
+       /// The [name](#highlight.tags.name) of a variable.
+       variableName: t$1(name$1),
+       /// A type [name](#highlight.tags.name).
+       typeName: typeName$1,
+       /// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
+       tagName: t$1(typeName$1),
+       /// A property or field [name](#highlight.tags.name).
+       propertyName: propertyName$1,
+       /// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
+       attributeName: t$1(propertyName$1),
+       /// The [name](#highlight.tags.name) of a class.
+       className: t$1(name$1),
+       /// A label [name](#highlight.tags.name).
+       labelName: t$1(name$1),
+       /// A namespace [name](#highlight.tags.name).
+       namespace: t$1(name$1),
+       /// The [name](#highlight.tags.name) of a macro.
+       macroName: t$1(name$1),
+       /// A literal value.
+       literal: literal$1,
+       /// A string [literal](#highlight.tags.literal).
+       string: string$1,
+       /// A documentation [string](#highlight.tags.string).
+       docString: t$1(string$1),
+       /// A character literal (subtag of [string](#highlight.tags.string)).
+       character: t$1(string$1),
+       /// An attribute value (subtag of [string](#highlight.tags.string)).
+       attributeValue: t$1(string$1),
+       /// A number [literal](#highlight.tags.literal).
+       number: number$1,
+       /// An integer [number](#highlight.tags.number) literal.
+       integer: t$1(number$1),
+       /// A floating-point [number](#highlight.tags.number) literal.
+       float: t$1(number$1),
+       /// A boolean [literal](#highlight.tags.literal).
+       bool: t$1(literal$1),
+       /// Regular expression [literal](#highlight.tags.literal).
+       regexp: t$1(literal$1),
+       /// An escape [literal](#highlight.tags.literal), for example a
+       /// backslash escape in a string.
+       escape: t$1(literal$1),
+       /// A color [literal](#highlight.tags.literal).
+       color: t$1(literal$1),
+       /// A URL [literal](#highlight.tags.literal).
+       url: t$1(literal$1),
+       /// A language keyword.
+       keyword: keyword$1,
+       /// The [keyword](#highlight.tags.keyword) for the self or this
+       /// object.
+       self: t$1(keyword$1),
+       /// The [keyword](#highlight.tags.keyword) for null.
+       null: t$1(keyword$1),
+       /// A [keyword](#highlight.tags.keyword) denoting some atomic value.
+       atom: t$1(keyword$1),
+       /// A [keyword](#highlight.tags.keyword) that represents a unit.
+       unit: t$1(keyword$1),
+       /// A modifier [keyword](#highlight.tags.keyword).
+       modifier: t$1(keyword$1),
+       /// A [keyword](#highlight.tags.keyword) that acts as an operator.
+       operatorKeyword: t$1(keyword$1),
+       /// A control-flow related [keyword](#highlight.tags.keyword).
+       controlKeyword: t$1(keyword$1),
+       /// A [keyword](#highlight.tags.keyword) that defines something.
+       definitionKeyword: t$1(keyword$1),
+       /// A [keyword](#highlight.tags.keyword) related to defining or
+       /// interfacing with modules.
+       moduleKeyword: t$1(keyword$1),
+       /// An operator.
+       operator: operator$1,
+       /// An [operator](#highlight.tags.operator) that defines something.
+       derefOperator: t$1(operator$1),
+       /// Arithmetic-related [operator](#highlight.tags.operator).
+       arithmeticOperator: t$1(operator$1),
+       /// Logical [operator](#highlight.tags.operator).
+       logicOperator: t$1(operator$1),
+       /// Bit [operator](#highlight.tags.operator).
+       bitwiseOperator: t$1(operator$1),
+       /// Comparison [operator](#highlight.tags.operator).
+       compareOperator: t$1(operator$1),
+       /// [Operator](#highlight.tags.operator) that updates its operand.
+       updateOperator: t$1(operator$1),
+       /// [Operator](#highlight.tags.operator) that defines something.
+       definitionOperator: t$1(operator$1),
+       /// Type-related [operator](#highlight.tags.operator).
+       typeOperator: t$1(operator$1),
+       /// Control-flow [operator](#highlight.tags.operator).
+       controlOperator: t$1(operator$1),
+       /// Program or markup punctuation.
+       punctuation: punctuation$1,
+       /// [Punctuation](#highlight.tags.punctuation) that separates
+       /// things.
+       separator: t$1(punctuation$1),
+       /// Bracket-style [punctuation](#highlight.tags.punctuation).
+       bracket: bracket$1,
+       /// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
+       /// tokens).
+       angleBracket: t$1(bracket$1),
+       /// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
+       /// tokens).
+       squareBracket: t$1(bracket$1),
+       /// Parentheses (usually `(` and `)` tokens). Subtag of
+       /// [bracket](#highlight.tags.bracket).
+       paren: t$1(bracket$1),
+       /// Braces (usually `{` and `}` tokens). Subtag of
+       /// [bracket](#highlight.tags.bracket).
+       brace: t$1(bracket$1),
+       /// Content, for example plain text in XML or markup documents.
+       content: content$1,
+       /// [Content](#highlight.tags.content) that represents a heading.
+       heading: heading$1,
+       /// A level 1 [heading](#highlight.tags.heading).
+       heading1: t$1(heading$1),
+       /// A level 2 [heading](#highlight.tags.heading).
+       heading2: t$1(heading$1),
+       /// A level 3 [heading](#highlight.tags.heading).
+       heading3: t$1(heading$1),
+       /// A level 4 [heading](#highlight.tags.heading).
+       heading4: t$1(heading$1),
+       /// A level 5 [heading](#highlight.tags.heading).
+       heading5: t$1(heading$1),
+       /// A level 6 [heading](#highlight.tags.heading).
+       heading6: t$1(heading$1),
+       /// A prose separator (such as a horizontal rule).
+       contentSeparator: t$1(content$1),
+       /// [Content](#highlight.tags.content) that represents a list.
+       list: t$1(content$1),
+       /// [Content](#highlight.tags.content) that represents a quote.
+       quote: t$1(content$1),
+       /// [Content](#highlight.tags.content) that is emphasized.
+       emphasis: t$1(content$1),
+       /// [Content](#highlight.tags.content) that is styled strong.
+       strong: t$1(content$1),
+       /// [Content](#highlight.tags.content) that is part of a link.
+       link: t$1(content$1),
+       /// [Content](#highlight.tags.content) that is styled as code or
+       /// monospace.
+       monospace: t$1(content$1),
+       /// [Content](#highlight.tags.content) that has a strike-through
+       /// style.
+       strikethrough: t$1(content$1),
+       /// Inserted text in a change-tracking format.
+       inserted: t$1(),
+       /// Deleted text.
+       deleted: t$1(),
+       /// Changed text.
+       changed: t$1(),
+       /// An invalid or unsyntactic element.
+       invalid: t$1(),
+       /// Metadata or meta-instruction.
+       meta: meta$1,
+       /// [Metadata](#highlight.tags.meta) that applies to the entire
+       /// document.
+       documentMeta: t$1(meta$1),
+       /// [Metadata](#highlight.tags.meta) that annotates or adds
+       /// attributes to a given syntactic element.
+       annotation: t$1(meta$1),
+       /// Processing instruction or preprocessor directive. Subtag of
+       /// [meta](#highlight.tags.meta).
+       processingInstruction: t$1(meta$1),
+       /// [Modifier](#highlight.Tag^defineModifier) that indicates that a
+       /// given element is being defined. Expected to be used with the
+       /// various [name](#highlight.tags.name) tags.
+       definition: Tag$1.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) that indicates that
+       /// something is constant. Mostly expected to be used with
+       /// [variable names](#highlight.tags.variableName).
+       constant: Tag$1.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) used to indicate that
+       /// a [variable](#highlight.tags.variableName) or [property
+       /// name](#highlight.tags.propertyName) is being called or defined
+       /// as a function.
+       function: Tag$1.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) that can be applied to
+       /// [names](#highlight.tags.name) to indicate that they belong to
+       /// the language's standard environment.
+       standard: Tag$1.defineModifier(),
+       /// [Modifier](#highlight.Tag^defineModifier) that indicates a given
+       /// [names](#highlight.tags.name) is local to some scope.
+       local: Tag$1.defineModifier(),
+       /// A generic variant [modifier](#highlight.Tag^defineModifier) that
+       /// can be used to tag language-specific alternative variants of
+       /// some common tag. It is recommended for themes to define special
+       /// forms of at least the [string](#highlight.tags.string) and
+       /// [variable name](#highlight.tags.variableName) tags, since those
+       /// come up a lot.
+       special: Tag$1.defineModifier()
+   };
+   /// This is a highlighter that adds stable, predictable classes to
+   /// tokens, for styling with external CSS.
+   ///
+   /// The following tags are mapped to their name prefixed with `"tok-"`
+   /// (for example `"tok-comment"`):
+   ///
+   /// * [`link`](#highlight.tags.link)
+   /// * [`heading`](#highlight.tags.heading)
+   /// * [`emphasis`](#highlight.tags.emphasis)
+   /// * [`strong`](#highlight.tags.strong)
+   /// * [`keyword`](#highlight.tags.keyword)
+   /// * [`atom`](#highlight.tags.atom) [`bool`](#highlight.tags.bool)
+   /// * [`url`](#highlight.tags.url)
+   /// * [`labelName`](#highlight.tags.labelName)
+   /// * [`inserted`](#highlight.tags.inserted)
+   /// * [`deleted`](#highlight.tags.deleted)
+   /// * [`literal`](#highlight.tags.literal)
+   /// * [`string`](#highlight.tags.string)
+   /// * [`number`](#highlight.tags.number)
+   /// * [`variableName`](#highlight.tags.variableName)
+   /// * [`typeName`](#highlight.tags.typeName)
+   /// * [`namespace`](#highlight.tags.namespace)
+   /// * [`className`](#highlight.tags.className)
+   /// * [`macroName`](#highlight.tags.macroName)
+   /// * [`propertyName`](#highlight.tags.propertyName)
+   /// * [`operator`](#highlight.tags.operator)
+   /// * [`comment`](#highlight.tags.comment)
+   /// * [`meta`](#highlight.tags.meta)
+   /// * [`punctuation`](#highlight.tags.punctuation)
+   /// * [`invalid`](#highlight.tags.invalid)
+   ///
+   /// In addition, these mappings are provided:
+   ///
+   /// * [`regexp`](#highlight.tags.regexp),
+   ///   [`escape`](#highlight.tags.escape), and
+   ///   [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
+   ///   are mapped to `"tok-string2"`
+   /// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
+   ///   to `"tok-variableName2"`
+   /// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
+   ///   to `"tok-variableName tok-local"`
+   /// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
+   ///   to `"tok-variableName tok-definition"`
+   /// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
+   ///   to `"tok-propertyName tok-definition"`
+   tagHighlighter$1([
+       { tag: tags$1.link, class: "tok-link" },
+       { tag: tags$1.heading, class: "tok-heading" },
+       { tag: tags$1.emphasis, class: "tok-emphasis" },
+       { tag: tags$1.strong, class: "tok-strong" },
+       { tag: tags$1.keyword, class: "tok-keyword" },
+       { tag: tags$1.atom, class: "tok-atom" },
+       { tag: tags$1.bool, class: "tok-bool" },
+       { tag: tags$1.url, class: "tok-url" },
+       { tag: tags$1.labelName, class: "tok-labelName" },
+       { tag: tags$1.inserted, class: "tok-inserted" },
+       { tag: tags$1.deleted, class: "tok-deleted" },
+       { tag: tags$1.literal, class: "tok-literal" },
+       { tag: tags$1.string, class: "tok-string" },
+       { tag: tags$1.number, class: "tok-number" },
+       { tag: [tags$1.regexp, tags$1.escape, tags$1.special(tags$1.string)], class: "tok-string2" },
+       { tag: tags$1.variableName, class: "tok-variableName" },
+       { tag: tags$1.local(tags$1.variableName), class: "tok-variableName tok-local" },
+       { tag: tags$1.definition(tags$1.variableName), class: "tok-variableName tok-definition" },
+       { tag: tags$1.special(tags$1.variableName), class: "tok-variableName2" },
+       { tag: tags$1.definition(tags$1.propertyName), class: "tok-propertyName tok-definition" },
+       { tag: tags$1.typeName, class: "tok-typeName" },
+       { tag: tags$1.namespace, class: "tok-namespace" },
+       { tag: tags$1.className, class: "tok-className" },
+       { tag: tags$1.macroName, class: "tok-macroName" },
+       { tag: tags$1.propertyName, class: "tok-propertyName" },
+       { tag: tags$1.operator, class: "tok-operator" },
+       { tag: tags$1.comment, class: "tok-comment" },
+       { tag: tags$1.meta, class: "tok-meta" },
+       { tag: tags$1.invalid, class: "tok-invalid" },
+       { tag: tags$1.punctuation, class: "tok-punctuation" }
+   ]);
+
+   var _a$1;
+   /**
+   Node prop stored in a parser's top syntax node to provide the
+   facet that stores language-specific data for that language.
+   */
+   const languageDataProp$1 = /*@__PURE__*/new NodeProp$1();
+   /**
+   A language object manages parsing and per-language
+   [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
+   managed as a [Lezer](https://lezer.codemirror.net) tree. The class
+   can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
+   subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
+   via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
+   for stream parsers.
+   */
+   let Language$1 = class Language {
+       /**
+       Construct a language object. If you need to invoke this
+       directly, first define a data facet with
+       [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
+       configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
+       to the language's outer syntax node.
+       */
+       constructor(
+       /**
+       The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
+       used for this language.
+       */
+       data, parser, extraExtensions = []) {
+           this.data = data;
+           // Kludge to define EditorState.tree as a debugging helper,
+           // without the EditorState package actually knowing about
+           // languages and lezer trees.
+           if (!EditorState$2.prototype.hasOwnProperty("tree"))
+               Object.defineProperty(EditorState$2.prototype, "tree", { get() { return syntaxTree$1(this); } });
+           this.parser = parser;
+           this.extension = [
+               language$1.of(this),
+               EditorState$2.languageData.of((state, pos, side) => state.facet(languageDataFacetAt(state, pos, side)))
+           ].concat(extraExtensions);
+       }
+       /**
+       Query whether this language is active at the given position.
+       */
+       isActiveAt(state, pos, side = -1) {
+           return languageDataFacetAt(state, pos, side) == this.data;
+       }
+       /**
+       Find the document regions that were parsed using this language.
+       The returned regions will _include_ any nested languages rooted
+       in this language, when those exist.
+       */
+       findRegions(state) {
+           let lang = state.facet(language$1);
+           if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
+               return [{ from: 0, to: state.doc.length }];
+           if (!lang || !lang.allowsNesting)
+               return [];
+           let result = [];
+           let explore = (tree, from) => {
+               if (tree.prop(languageDataProp$1) == this.data) {
+                   result.push({ from, to: from + tree.length });
+                   return;
+               }
+               let mount = tree.prop(NodeProp$1.mounted);
+               if (mount) {
+                   if (mount.tree.prop(languageDataProp$1) == this.data) {
+                       if (mount.overlay)
+                           for (let r of mount.overlay)
+                               result.push({ from: r.from + from, to: r.to + from });
+                       else
+                           result.push({ from: from, to: from + tree.length });
+                       return;
+                   }
+                   else if (mount.overlay) {
+                       let size = result.length;
+                       explore(mount.tree, mount.overlay[0].from + from);
+                       if (result.length > size)
+                           return;
+                   }
+               }
+               for (let i = 0; i < tree.children.length; i++) {
+                   let ch = tree.children[i];
+                   if (ch instanceof Tree$1)
+                       explore(ch, tree.positions[i] + from);
+               }
+           };
+           explore(syntaxTree$1(state), 0);
+           return result;
+       }
+       /**
+       Indicates whether this language allows nested languages. The
+       default implementation returns true.
+       */
+       get allowsNesting() { return true; }
+   };
+   /**
+   @internal
+   */
+   Language$1.setState = /*@__PURE__*/StateEffect$2.define();
+   function languageDataFacetAt(state, pos, side) {
+       let topLang = state.facet(language$1);
+       if (!topLang)
+           return null;
+       let facet = topLang.data;
+       if (topLang.allowsNesting) {
+           for (let node = syntaxTree$1(state).topNode; node; node = node.enter(pos, side, IterMode$1.ExcludeBuffers))
+               facet = node.type.prop(languageDataProp$1) || facet;
+       }
+       return facet;
+   }
+   /**
+   Get the syntax tree for a state, which is the current (possibly
+   incomplete) parse tree of the active
+   [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
+   language available.
+   */
+   function syntaxTree$1(state) {
+       let field = state.field(Language$1.state, false);
+       return field ? field.tree : Tree$1.empty;
+   }
+   // Lezer-style Input object for a Text document.
+   let DocInput$1 = class DocInput {
+       constructor(doc, length = doc.length) {
+           this.doc = doc;
+           this.length = length;
+           this.cursorPos = 0;
+           this.string = "";
+           this.cursor = doc.iter();
+       }
+       syncTo(pos) {
+           this.string = this.cursor.next(pos - this.cursorPos).value;
+           this.cursorPos = pos + this.string.length;
+           return this.cursorPos - this.string.length;
+       }
+       chunk(pos) {
+           this.syncTo(pos);
+           return this.string;
+       }
+       get lineChunks() { return true; }
+       read(from, to) {
+           let stringStart = this.cursorPos - this.string.length;
+           if (from < stringStart || to >= this.cursorPos)
+               return this.doc.sliceString(from, to);
+           else
+               return this.string.slice(from - stringStart, to - stringStart);
+       }
+   };
+   let currentContext$1 = null;
+   /**
+   A parse context provided to parsers working on the editor content.
+   */
+   let ParseContext$1 = class ParseContext {
+       constructor(parser, 
+       /**
+       The current editor state.
+       */
+       state, 
+       /**
+       Tree fragments that can be reused by incremental re-parses.
+       */
+       fragments = [], 
+       /**
+       @internal
+       */
+       tree, 
+       /**
+       @internal
+       */
+       treeLen, 
+       /**
+       The current editor viewport (or some overapproximation
+       thereof). Intended to be used for opportunistically avoiding
+       work (in which case
+       [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
+       should be called to make sure the parser is restarted when the
+       skipped region becomes visible).
+       */
+       viewport, 
+       /**
+       @internal
+       */
+       skipped, 
+       /**
+       This is where skipping parsers can register a promise that,
+       when resolved, will schedule a new parse. It is cleared when
+       the parse worker picks up the promise. @internal
+       */
+       scheduleOn) {
+           this.parser = parser;
+           this.state = state;
+           this.fragments = fragments;
+           this.tree = tree;
+           this.treeLen = treeLen;
+           this.viewport = viewport;
+           this.skipped = skipped;
+           this.scheduleOn = scheduleOn;
+           this.parse = null;
+           /**
+           @internal
+           */
+           this.tempSkipped = [];
+       }
+       /**
+       @internal
+       */
+       static create(parser, state, viewport) {
+           return new ParseContext(parser, state, [], Tree$1.empty, 0, viewport, [], null);
+       }
+       startParse() {
+           return this.parser.startParse(new DocInput$1(this.state.doc), this.fragments);
+       }
+       /**
+       @internal
+       */
+       work(until, upto) {
+           if (upto != null && upto >= this.state.doc.length)
+               upto = undefined;
+           if (this.tree != Tree$1.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
+               this.takeTree();
+               return true;
+           }
+           return this.withContext(() => {
+               var _a;
+               if (typeof until == "number") {
+                   let endTime = Date.now() + until;
+                   until = () => Date.now() > endTime;
+               }
+               if (!this.parse)
+                   this.parse = this.startParse();
+               if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
+                   upto < this.state.doc.length)
+                   this.parse.stopAt(upto);
+               for (;;) {
+                   let done = this.parse.advance();
+                   if (done) {
+                       this.fragments = this.withoutTempSkipped(TreeFragment$1.addTree(done, this.fragments, this.parse.stoppedAt != null));
+                       this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
+                       this.tree = done;
+                       this.parse = null;
+                       if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
+                           this.parse = this.startParse();
+                       else
+                           return true;
+                   }
+                   if (until())
+                       return false;
+               }
+           });
+       }
+       /**
+       @internal
+       */
+       takeTree() {
+           let pos, tree;
+           if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
+               if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
+                   this.parse.stopAt(pos);
+               this.withContext(() => { while (!(tree = this.parse.advance())) { } });
+               this.treeLen = pos;
+               this.tree = tree;
+               this.fragments = this.withoutTempSkipped(TreeFragment$1.addTree(this.tree, this.fragments, true));
+               this.parse = null;
+           }
+       }
+       withContext(f) {
+           let prev = currentContext$1;
+           currentContext$1 = this;
+           try {
+               return f();
+           }
+           finally {
+               currentContext$1 = prev;
+           }
+       }
+       withoutTempSkipped(fragments) {
+           for (let r; r = this.tempSkipped.pop();)
+               fragments = cutFragments$1(fragments, r.from, r.to);
+           return fragments;
+       }
+       /**
+       @internal
+       */
+       changes(changes, newState) {
+           let { fragments, tree, treeLen, viewport, skipped } = this;
+           this.takeTree();
+           if (!changes.empty) {
+               let ranges = [];
+               changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
+               fragments = TreeFragment$1.applyChanges(fragments, ranges);
+               tree = Tree$1.empty;
+               treeLen = 0;
+               viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
+               if (this.skipped.length) {
+                   skipped = [];
+                   for (let r of this.skipped) {
+                       let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
+                       if (from < to)
+                           skipped.push({ from, to });
+                   }
+               }
+           }
+           return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
+       }
+       /**
+       @internal
+       */
+       updateViewport(viewport) {
+           if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
+               return false;
+           this.viewport = viewport;
+           let startLen = this.skipped.length;
+           for (let i = 0; i < this.skipped.length; i++) {
+               let { from, to } = this.skipped[i];
+               if (from < viewport.to && to > viewport.from) {
+                   this.fragments = cutFragments$1(this.fragments, from, to);
+                   this.skipped.splice(i--, 1);
+               }
+           }
+           if (this.skipped.length >= startLen)
+               return false;
+           this.reset();
+           return true;
+       }
+       /**
+       @internal
+       */
+       reset() {
+           if (this.parse) {
+               this.takeTree();
+               this.parse = null;
+           }
+       }
+       /**
+       Notify the parse scheduler that the given region was skipped
+       because it wasn't in view, and the parse should be restarted
+       when it comes into view.
+       */
+       skipUntilInView(from, to) {
+           this.skipped.push({ from, to });
+       }
+       /**
+       Returns a parser intended to be used as placeholder when
+       asynchronously loading a nested parser. It'll skip its input and
+       mark it as not-really-parsed, so that the next update will parse
+       it again.
+       
+       When `until` is given, a reparse will be scheduled when that
+       promise resolves.
+       */
+       static getSkippingParser(until) {
+           return new class extends Parser$1 {
+               createParse(input, fragments, ranges) {
+                   let from = ranges[0].from, to = ranges[ranges.length - 1].to;
+                   let parser = {
+                       parsedPos: from,
+                       advance() {
+                           let cx = currentContext$1;
+                           if (cx) {
+                               for (let r of ranges)
+                                   cx.tempSkipped.push(r);
+                               if (until)
+                                   cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
+                           }
+                           this.parsedPos = to;
+                           return new Tree$1(NodeType$1.none, [], [], to - from);
+                       },
+                       stoppedAt: null,
+                       stopAt() { }
+                   };
+                   return parser;
+               }
+           };
+       }
+       /**
+       @internal
+       */
+       isDone(upto) {
+           upto = Math.min(upto, this.state.doc.length);
+           let frags = this.fragments;
+           return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
+       }
+       /**
+       Get the context for the current parse, or `null` if no editor
+       parse is in progress.
+       */
+       static get() { return currentContext$1; }
+   };
+   function cutFragments$1(fragments, from, to) {
+       return TreeFragment$1.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
+   }
+   let LanguageState$1 = class LanguageState {
+       constructor(
+       // A mutable parse state that is used to preserve work done during
+       // the lifetime of a state when moving to the next state.
+       context) {
+           this.context = context;
+           this.tree = context.tree;
+       }
+       apply(tr) {
+           if (!tr.docChanged && this.tree == this.context.tree)
+               return this;
+           let newCx = this.context.changes(tr.changes, tr.state);
+           // If the previous parse wasn't done, go forward only up to its
+           // end position or the end of the viewport, to avoid slowing down
+           // state updates with parse work beyond the viewport.
+           let upto = this.context.treeLen == tr.startState.doc.length ? undefined
+               : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
+           if (!newCx.work(20 /* Apply */, upto))
+               newCx.takeTree();
+           return new LanguageState(newCx);
+       }
+       static init(state) {
+           let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
+           let parseState = ParseContext$1.create(state.facet(language$1).parser, state, { from: 0, to: vpTo });
+           if (!parseState.work(20 /* Apply */, vpTo))
+               parseState.takeTree();
+           return new LanguageState(parseState);
+       }
+   };
+   Language$1.state = /*@__PURE__*/StateField$2.define({
+       create: LanguageState$1.init,
+       update(value, tr) {
+           for (let e of tr.effects)
+               if (e.is(Language$1.setState))
+                   return e.value;
+           if (tr.startState.facet(language$1) != tr.state.facet(language$1))
+               return LanguageState$1.init(tr.state);
+           return value.apply(tr);
+       }
+   });
+   let requestIdle$1 = (callback) => {
+       let timeout = setTimeout(() => callback(), 500 /* MaxPause */);
+       return () => clearTimeout(timeout);
+   };
+   if (typeof requestIdleCallback != "undefined")
+       requestIdle$1 = (callback) => {
+           let idle = -1, timeout = setTimeout(() => {
+               idle = requestIdleCallback(callback, { timeout: 500 /* MaxPause */ - 100 /* MinPause */ });
+           }, 100 /* MinPause */);
+           return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
+       };
+   const isInputPending$1 = typeof navigator != "undefined" && ((_a$1 = navigator.scheduling) === null || _a$1 === void 0 ? void 0 : _a$1.isInputPending)
+       ? () => navigator.scheduling.isInputPending() : null;
+   const parseWorker$1 = /*@__PURE__*/ViewPlugin$2.fromClass(class ParseWorker {
+       constructor(view) {
+           this.view = view;
+           this.working = null;
+           this.workScheduled = 0;
+           // End of the current time chunk
+           this.chunkEnd = -1;
+           // Milliseconds of budget left for this chunk
+           this.chunkBudget = -1;
+           this.work = this.work.bind(this);
+           this.scheduleWork();
+       }
+       update(update) {
+           let cx = this.view.state.field(Language$1.state).context;
+           if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
+               this.scheduleWork();
+           if (update.docChanged) {
+               if (this.view.hasFocus)
+                   this.chunkBudget += 50 /* ChangeBonus */;
+               this.scheduleWork();
+           }
+           this.checkAsyncSchedule(cx);
+       }
+       scheduleWork() {
+           if (this.working)
+               return;
+           let { state } = this.view, field = state.field(Language$1.state);
+           if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
+               this.working = requestIdle$1(this.work);
+       }
+       work(deadline) {
+           this.working = null;
+           let now = Date.now();
+           if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
+               this.chunkEnd = now + 30000 /* ChunkTime */;
+               this.chunkBudget = 3000 /* ChunkBudget */;
+           }
+           if (this.chunkBudget <= 0)
+               return; // No more budget
+           let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language$1.state);
+           if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* MaxParseAhead */))
+               return;
+           let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Slice */, deadline && !isInputPending$1 ? Math.max(25 /* MinSlice */, deadline.timeRemaining() - 5) : 1e9);
+           let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
+           let done = field.context.work(() => {
+               return isInputPending$1 && isInputPending$1() || Date.now() > endTime;
+           }, vpTo + (viewportFirst ? 0 : 100000 /* MaxParseAhead */));
+           this.chunkBudget -= Date.now() - now;
+           if (done || this.chunkBudget <= 0) {
+               field.context.takeTree();
+               this.view.dispatch({ effects: Language$1.setState.of(new LanguageState$1(field.context)) });
+           }
+           if (this.chunkBudget > 0 && !(done && !viewportFirst))
+               this.scheduleWork();
+           this.checkAsyncSchedule(field.context);
+       }
+       checkAsyncSchedule(cx) {
+           if (cx.scheduleOn) {
+               this.workScheduled++;
+               cx.scheduleOn
+                   .then(() => this.scheduleWork())
+                   .catch(err => logException$2(this.view.state, err))
+                   .then(() => this.workScheduled--);
+               cx.scheduleOn = null;
+           }
+       }
+       destroy() {
+           if (this.working)
+               this.working();
+       }
+       isWorking() {
+           return !!(this.working || this.workScheduled > 0);
+       }
+   }, {
+       eventHandlers: { focus() { this.scheduleWork(); } }
+   });
+   /**
+   The facet used to associate a language with an editor state.
+   */
+   const language$1 = /*@__PURE__*/Facet$2.define({
+       combine(languages) { return languages.length ? languages[0] : null; },
+       enables: [Language$1.state, parseWorker$1]
+   });
+
+   /**
+   Facet that defines a way to provide a function that computes the
+   appropriate indentation depth at the start of a given line, or
+   `null` to indicate no appropriate indentation could be determined.
+   */
+   const indentService = /*@__PURE__*/Facet$2.define();
+   /**
+   Facet for overriding the unit by which indentation happens.
+   Should be a string consisting either entirely of spaces or
+   entirely of tabs. When not set, this defaults to 2 spaces.
+   */
+   const indentUnit$1 = /*@__PURE__*/Facet$2.define({
+       combine: values => {
+           if (!values.length)
+               return "  ";
+           if (!/^(?: +|\t+)$/.test(values[0]))
+               throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
+           return values[0];
+       }
+   });
+   /**
+   Return the _column width_ of an indent unit in the state.
+   Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
+   facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
+   contains tabs.
+   */
+   function getIndentUnit(state) {
+       let unit = state.facet(indentUnit$1);
+       return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
+   }
+   /**
+   Create an indentation string that covers columns 0 to `cols`.
+   Will use tabs for as much of the columns as possible when the
+   [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
+   tabs.
+   */
+   function indentString(state, cols) {
+       let result = "", ts = state.tabSize;
+       if (state.facet(indentUnit$1).charCodeAt(0) == 9)
+           while (cols >= ts) {
+               result += "\t";
+               cols -= ts;
+           }
+       for (let i = 0; i < cols; i++)
+           result += " ";
+       return result;
+   }
+   /**
+   Get the indentation at the given position. Will first consult any
+   [indent services](https://codemirror.net/6/docs/ref/#language.indentService) that are registered,
+   and if none of those return an indentation, this will check the
+   syntax tree for the [indent node prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp)
+   and use that if found. Returns a number when an indentation could
+   be determined, and null otherwise.
+   */
+   function getIndentation(context, pos) {
+       if (context instanceof EditorState$2)
+           context = new IndentContext(context);
+       for (let service of context.state.facet(indentService)) {
+           let result = service(context, pos);
+           if (result != null)
+               return result;
+       }
+       let tree = syntaxTree$1(context.state);
+       return tree ? syntaxIndentation(context, tree, pos) : null;
+   }
+   /**
+   Indentation contexts are used when calling [indentation
+   services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
+   useful in indentation logic, and can selectively override the
+   indentation reported for some lines.
+   */
+   class IndentContext {
+       /**
+       Create an indent context.
+       */
+       constructor(
+       /**
+       The editor state.
+       */
+       state, 
+       /**
+       @internal
+       */
+       options = {}) {
+           this.state = state;
+           this.options = options;
+           this.unit = getIndentUnit(state);
+       }
+       /**
+       Get a description of the line at the given position, taking
+       [simulated line
+       breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
+       into account. If there is such a break at `pos`, the `bias`
+       argument determines whether the part of the line line before or
+       after the break is used.
+       */
+       lineAt(pos, bias = 1) {
+           let line = this.state.doc.lineAt(pos);
+           let { simulateBreak, simulateDoubleBreak } = this.options;
+           if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
+               if (simulateDoubleBreak && simulateBreak == pos)
+                   return { text: "", from: pos };
+               else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
+                   return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
+               else
+                   return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
+           }
+           return line;
+       }
+       /**
+       Get the text directly after `pos`, either the entire line
+       or the next 100 characters, whichever is shorter.
+       */
+       textAfterPos(pos, bias = 1) {
+           if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
+               return "";
+           let { text, from } = this.lineAt(pos, bias);
+           return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
+       }
+       /**
+       Find the column for the given position.
+       */
+       column(pos, bias = 1) {
+           let { text, from } = this.lineAt(pos, bias);
+           let result = this.countColumn(text, pos - from);
+           let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
+           if (override > -1)
+               result += override - this.countColumn(text, text.search(/\S|$/));
+           return result;
+       }
+       /**
+       Find the column position (taking tabs into account) of the given
+       position in the given string.
+       */
+       countColumn(line, pos = line.length) {
+           return countColumn(line, this.state.tabSize, pos);
+       }
+       /**
+       Find the indentation column of the line at the given point.
+       */
+       lineIndent(pos, bias = 1) {
+           let { text, from } = this.lineAt(pos, bias);
+           let override = this.options.overrideIndentation;
+           if (override) {
+               let overriden = override(from);
+               if (overriden > -1)
+                   return overriden;
+           }
+           return this.countColumn(text, text.search(/\S|$/));
+       }
+       /**
+       Returns the [simulated line
+       break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
+       for this context, if any.
+       */
+       get simulatedBreak() {
+           return this.options.simulateBreak || null;
+       }
+   }
+   /**
+   A syntax tree node prop used to associate indentation strategies
+   with node types. Such a strategy is a function from an indentation
+   context to a column number or null, where null indicates that no
+   definitive indentation can be determined.
+   */
+   const indentNodeProp$1 = /*@__PURE__*/new NodeProp$1();
+   // Compute the indentation for a given position from the syntax tree.
+   function syntaxIndentation(cx, ast, pos) {
+       return indentFrom(ast.resolveInner(pos).enterUnfinishedNodesBefore(pos), pos, cx);
+   }
+   function ignoreClosed(cx) {
+       return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
+   }
+   function indentStrategy(tree) {
+       let strategy = tree.type.prop(indentNodeProp$1);
+       if (strategy)
+           return strategy;
+       let first = tree.firstChild, close;
+       if (first && (close = first.type.prop(NodeProp$1.closedBy))) {
+           let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
+           return cx => delimitedStrategy$1(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);
+       }
+       return tree.parent == null ? topIndent : null;
+   }
+   function indentFrom(node, pos, base) {
+       for (; node; node = node.parent) {
+           let strategy = indentStrategy(node);
+           if (strategy)
+               return strategy(TreeIndentContext.create(base, pos, node));
+       }
+       return null;
+   }
+   function topIndent() { return 0; }
+   /**
+   Objects of this type provide context information and helper
+   methods to indentation functions registered on syntax nodes.
+   */
+   class TreeIndentContext extends IndentContext {
+       constructor(base, 
+       /**
+       The position at which indentation is being computed.
+       */
+       pos, 
+       /**
+       The syntax tree node to which the indentation strategy
+       applies.
+       */
+       node) {
+           super(base.state, base.options);
+           this.base = base;
+           this.pos = pos;
+           this.node = node;
+       }
+       /**
+       @internal
+       */
+       static create(base, pos, node) {
+           return new TreeIndentContext(base, pos, node);
+       }
+       /**
+       Get the text directly after `this.pos`, either the entire line
+       or the next 100 characters, whichever is shorter.
+       */
+       get textAfter() {
+           return this.textAfterPos(this.pos);
+       }
+       /**
+       Get the indentation at the reference line for `this.node`, which
+       is the line on which it starts, unless there is a node that is
+       _not_ a parent of this node covering the start of that line. If
+       so, the line at the start of that node is tried, again skipping
+       on if it is covered by another such node.
+       */
+       get baseIndent() {
+           let line = this.state.doc.lineAt(this.node.from);
+           // Skip line starts that are covered by a sibling (or cousin, etc)
+           for (;;) {
+               let atBreak = this.node.resolve(line.from);
+               while (atBreak.parent && atBreak.parent.from == atBreak.from)
+                   atBreak = atBreak.parent;
+               if (isParent(atBreak, this.node))
+                   break;
+               line = this.state.doc.lineAt(atBreak.from);
+           }
+           return this.lineIndent(line.from);
+       }
+       /**
+       Continue looking for indentations in the node's parent nodes,
+       and return the result of that.
+       */
+       continue() {
+           let parent = this.node.parent;
+           return parent ? indentFrom(parent, this.pos, this.base) : 0;
+       }
+   }
+   function isParent(parent, of) {
+       for (let cur = of; cur; cur = cur.parent)
+           if (parent == cur)
+               return true;
+       return false;
+   }
+   // Check whether a delimited node is aligned (meaning there are
+   // non-skipped nodes on the same line as the opening delimiter). And
+   // if so, return the opening token.
+   function bracketedAligned$1(context) {
+       let tree = context.node;
+       let openToken = tree.childAfter(tree.from), last = tree.lastChild;
+       if (!openToken)
+           return null;
+       let sim = context.options.simulateBreak;
+       let openLine = context.state.doc.lineAt(openToken.from);
+       let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
+       for (let pos = openToken.to;;) {
+           let next = tree.childAfter(pos);
+           if (!next || next == last)
+               return null;
+           if (!next.type.isSkipped)
+               return next.from < lineEnd ? openToken : null;
+           pos = next.to;
+       }
+   }
+   function delimitedStrategy$1(context, align, units, closing, closedAt) {
+       let after = context.textAfter, space = after.match(/^\s*/)[0].length;
+       let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
+       let aligned = bracketedAligned$1(context) ;
+       if (aligned)
+           return closed ? context.column(aligned.from) : context.column(aligned.to);
+       return context.baseIndent + (closed ? 0 : context.unit * units);
+   }
+   const DefaultScanDist = 10000, DefaultBrackets = "()[]{}";
+   function matchingNodes(node, dir, brackets) {
+       let byProp = node.prop(dir < 0 ? NodeProp$1.openedBy : NodeProp$1.closedBy);
+       if (byProp)
+           return byProp;
+       if (node.name.length == 1) {
+           let index = brackets.indexOf(node.name);
+           if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
+               return [brackets[index + dir]];
+       }
+       return null;
+   }
+   /**
+   Find the matching bracket for the token at `pos`, scanning
+   direction `dir`. Only the `brackets` and `maxScanDistance`
+   properties are used from `config`, if given. Returns null if no
+   bracket was found at `pos`, or a match result otherwise.
+   */
+   function matchBrackets(state, pos, dir, config = {}) {
+       let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;
+       let tree = syntaxTree$1(state), node = tree.resolveInner(pos, dir);
+       for (let cur = node; cur; cur = cur.parent) {
+           let matches = matchingNodes(cur.type, dir, brackets);
+           if (matches && cur.from < cur.to)
+               return matchMarkedBrackets(state, pos, dir, cur, matches, brackets);
+       }
+       return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
+   }
+   function matchMarkedBrackets(_state, _pos, dir, token, matching, brackets) {
+       let parent = token.parent, firstToken = { from: token.from, to: token.to };
+       let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
+       if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
+           do {
+               if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
+                   if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
+                       return { start: firstToken, end: { from: cursor.from, to: cursor.to }, matched: true };
+                   }
+                   else if (matchingNodes(cursor.type, dir, brackets)) {
+                       depth++;
+                   }
+                   else if (matchingNodes(cursor.type, -dir, brackets)) {
+                       depth--;
+                       if (depth == 0)
+                           return {
+                               start: firstToken,
+                               end: cursor.from == cursor.to ? undefined : { from: cursor.from, to: cursor.to },
+                               matched: false
+                           };
+                   }
+               }
+           } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
+       return { start: firstToken, matched: false };
+   }
+   function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
+       let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
+       let bracket = brackets.indexOf(startCh);
+       if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
+           return null;
+       let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
+       let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
+       for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
+           let text = iter.value;
+           if (dir < 0)
+               distance += text.length;
+           let basePos = pos + distance * dir;
+           for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
+               let found = brackets.indexOf(text[pos]);
+               if (found < 0 || tree.resolve(basePos + pos, 1).type != tokenType)
+                   continue;
+               if ((found % 2 == 0) == (dir > 0)) {
+                   depth++;
+               }
+               else if (depth == 1) { // Closing
+                   return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
+               }
+               else {
+                   depth--;
+               }
+           }
+           if (dir > 0)
+               distance += text.length;
+       }
+       return iter.done ? { start: startToken, matched: false } : null;
+   }
+   const noTokens$1 = /*@__PURE__*/Object.create(null);
+   const typeArray$1 = [NodeType$1.none];
+   const warned$1 = [];
+   const defaultTable$1 = /*@__PURE__*/Object.create(null);
+   for (let [legacyName, name] of [
+       ["variable", "variableName"],
+       ["variable-2", "variableName.special"],
+       ["string-2", "string.special"],
+       ["def", "variableName.definition"],
+       ["tag", "typeName"],
+       ["attribute", "propertyName"],
+       ["type", "typeName"],
+       ["builtin", "variableName.standard"],
+       ["qualifier", "modifier"],
+       ["error", "invalid"],
+       ["header", "heading"],
+       ["property", "propertyName"]
+   ])
+       defaultTable$1[legacyName] = /*@__PURE__*/createTokenType$1(noTokens$1, name);
+   function warnForPart$1(part, msg) {
+       if (warned$1.indexOf(part) > -1)
+           return;
+       warned$1.push(part);
+       console.warn(msg);
+   }
+   function createTokenType$1(extra, tagStr) {
+       let tag = null;
+       for (let part of tagStr.split(".")) {
+           let value = (extra[part] || tags$1[part]);
+           if (!value) {
+               warnForPart$1(part, `Unknown highlighting tag ${part}`);
+           }
+           else if (typeof value == "function") {
+               if (!tag)
+                   warnForPart$1(part, `Modifier ${part} used at start of tag`);
+               else
+                   tag = value(tag);
+           }
+           else {
+               if (tag)
+                   warnForPart$1(part, `Tag ${part} used as modifier`);
+               else
+                   tag = value;
+           }
+       }
+       if (!tag)
+           return 0;
+       let name = tagStr.replace(/ /g, "_"), type = NodeType$1.define({
+           id: typeArray$1.length,
+           name,
+           props: [styleTags$1({ [name]: tag })]
+       });
+       typeArray$1.push(type);
+       return type.id;
+   }
+
+   /**
+   Comment or uncomment the current selection. Will use line comments
+   if available, otherwise falling back to block comments.
+   */
+   const toggleComment = target => {
+       let config = getConfig(target.state);
+       return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
+   };
+   function command(f, option) {
+       return ({ state, dispatch }) => {
+           if (state.readOnly)
+               return false;
+           let tr = f(option, state);
+           if (!tr)
+               return false;
+           dispatch(state.update(tr));
+           return true;
+       };
+   }
+   /**
+   Comment or uncomment the current selection using line comments.
+   The line comment syntax is taken from the
+   [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
+   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
+   */
+   const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* Toggle */);
+   /**
+   Comment or uncomment the current selection using block comments.
+   The block comment syntax is taken from the
+   [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
+   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
+   */
+   const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* Toggle */);
+   /**
+   Comment or uncomment the lines around the current selection using
+   block comments.
+   */
+   const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
+   function getConfig(state, pos = state.selection.main.head) {
+       let data = state.languageDataAt("commentTokens", pos);
+       return data.length ? data[0] : {};
+   }
+   const SearchMargin = 50;
+   /**
+   Determines if the given range is block-commented in the given
+   state.
+   */
+   function findBlockComment(state, { open, close }, from, to) {
+       let textBefore = state.sliceDoc(from - SearchMargin, from);
+       let textAfter = state.sliceDoc(to, to + SearchMargin);
+       let spaceBefore = /\s*$/.exec(textBefore)[0].length, spaceAfter = /^\s*/.exec(textAfter)[0].length;
+       let beforeOff = textBefore.length - spaceBefore;
+       if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&
+           textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {
+           return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },
+               close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };
+       }
+       let startText, endText;
+       if (to - from <= 2 * SearchMargin) {
+           startText = endText = state.sliceDoc(from, to);
+       }
+       else {
+           startText = state.sliceDoc(from, from + SearchMargin);
+           endText = state.sliceDoc(to - SearchMargin, to);
+       }
+       let startSpace = /^\s*/.exec(startText)[0].length, endSpace = /\s*$/.exec(endText)[0].length;
+       let endOff = endText.length - endSpace - close.length;
+       if (startText.slice(startSpace, startSpace + open.length) == open &&
+           endText.slice(endOff, endOff + close.length) == close) {
+           return { open: { pos: from + startSpace + open.length,
+                   margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },
+               close: { pos: to - endSpace - close.length,
+                   margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };
+       }
+       return null;
+   }
+   function selectedLineRanges(state) {
+       let ranges = [];
+       for (let r of state.selection.ranges) {
+           let fromLine = state.doc.lineAt(r.from);
+           let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
+           let last = ranges.length - 1;
+           if (last >= 0 && ranges[last].to > fromLine.from)
+               ranges[last].to = toLine.to;
+           else
+               ranges.push({ from: fromLine.from, to: toLine.to });
+       }
+       return ranges;
+   }
+   // Performs toggle, comment and uncomment of block comments in
+   // languages that support them.
+   function changeBlockComment(option, state, ranges = state.selection.ranges) {
+       let tokens = ranges.map(r => getConfig(state, r.from).block);
+       if (!tokens.every(c => c))
+           return null;
+       let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
+       if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
+           return { changes: state.changes(ranges.map((range, i) => {
+                   if (comments[i])
+                       return [];
+                   return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
+               })) };
+       }
+       else if (option != 1 /* Comment */ && comments.some(c => c)) {
+           let changes = [];
+           for (let i = 0, comment; i < comments.length; i++)
+               if (comment = comments[i]) {
+                   let token = tokens[i], { open, close } = comment;
+                   changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });
+               }
+           return { changes };
+       }
+       return null;
+   }
+   // Performs toggle, comment and uncomment of line comments.
+   function changeLineComment(option, state, ranges = state.selection.ranges) {
+       let lines = [];
+       let prevLine = -1;
+       for (let { from, to } of ranges) {
+           let startI = lines.length, minIndent = 1e9;
+           for (let pos = from; pos <= to;) {
+               let line = state.doc.lineAt(pos);
+               if (line.from > prevLine && (from == to || to > line.from)) {
+                   prevLine = line.from;
+                   let token = getConfig(state, pos).line;
+                   if (!token)
+                       continue;
+                   let indent = /^\s*/.exec(line.text)[0].length;
+                   let empty = indent == line.length;
+                   let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
+                   if (indent < line.text.length && indent < minIndent)
+                       minIndent = indent;
+                   lines.push({ line, comment, token, indent, empty, single: false });
+               }
+               pos = line.to + 1;
+           }
+           if (minIndent < 1e9)
+               for (let i = startI; i < lines.length; i++)
+                   if (lines[i].indent < lines[i].line.text.length)
+                       lines[i].indent = minIndent;
+           if (lines.length == startI + 1)
+               lines[startI].single = true;
+       }
+       if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
+           let changes = [];
+           for (let { line, token, indent, empty, single } of lines)
+               if (single || !empty)
+                   changes.push({ from: line.from + indent, insert: token + " " });
+           let changeSet = state.changes(changes);
+           return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
+       }
+       else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
+           let changes = [];
+           for (let { line, comment, token } of lines)
+               if (comment >= 0) {
+                   let from = line.from + comment, to = from + token.length;
+                   if (line.text[to - line.from] == " ")
+                       to++;
+                   changes.push({ from, to });
+               }
+           return { changes };
+       }
+       return null;
+   }
+
+   const fromHistory = /*@__PURE__*/Annotation$2.define();
+   /**
+   Transaction annotation that will prevent that transaction from
+   being combined with other transactions in the undo history. Given
+   `"before"`, it'll prevent merging with previous transactions. With
+   `"after"`, subsequent transactions won't be combined with this
+   one. With `"full"`, the transaction is isolated on both sides.
+   */
+   const isolateHistory = /*@__PURE__*/Annotation$2.define();
+   /**
+   This facet provides a way to register functions that, given a
+   transaction, provide a set of effects that the history should
+   store when inverting the transaction. This can be used to
+   integrate some kinds of effects in the history, so that they can
+   be undone (and redone again).
+   */
+   const invertedEffects = /*@__PURE__*/Facet$2.define();
+   const historyConfig = /*@__PURE__*/Facet$2.define({
+       combine(configs) {
+           return combineConfig$2(configs, {
+               minDepth: 100,
+               newGroupDelay: 500
+           }, { minDepth: Math.max, newGroupDelay: Math.min });
+       }
+   });
+   function changeEnd(changes) {
+       let end = 0;
+       changes.iterChangedRanges((_, to) => end = to);
+       return end;
+   }
+   const historyField_ = /*@__PURE__*/StateField$2.define({
+       create() {
+           return HistoryState.empty;
+       },
+       update(state, tr) {
+           let config = tr.state.facet(historyConfig);
+           let fromHist = tr.annotation(fromHistory);
+           if (fromHist) {
+               let selection = tr.docChanged ? EditorSelection$2.single(changeEnd(tr.changes)) : undefined;
+               let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
+               let other = from == 0 /* Done */ ? state.undone : state.done;
+               if (item)
+                   other = updateBranch(other, other.length, config.minDepth, item);
+               else
+                   other = addSelection(other, tr.startState.selection);
+               return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
+           }
+           let isolate = tr.annotation(isolateHistory);
+           if (isolate == "full" || isolate == "before")
+               state = state.isolate();
+           if (tr.annotation(Transaction$2.addToHistory) === false)
+               return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;
+           let event = HistEvent.fromTransaction(tr);
+           let time = tr.annotation(Transaction$2.time), userEvent = tr.annotation(Transaction$2.userEvent);
+           if (event)
+               state = state.addChanges(event, time, userEvent, config.newGroupDelay, config.minDepth);
+           else if (tr.selection)
+               state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
+           if (isolate == "full" || isolate == "after")
+               state = state.isolate();
+           return state;
+       },
+       toJSON(value) {
+           return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };
+       },
+       fromJSON(json) {
+           return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));
+       }
+   });
+   /**
+   Create a history extension with the given configuration.
+   */
+   function history(config = {}) {
+       return [
+           historyField_,
+           historyConfig.of(config),
+           EditorView$2.domEventHandlers({
+               beforeinput(e, view) {
+                   let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null;
+                   if (!command)
+                       return false;
+                   e.preventDefault();
+                   return command(view);
+               }
+           })
+       ];
+   }
+   function cmd(side, selection) {
+       return function ({ state, dispatch }) {
+           if (!selection && state.readOnly)
+               return false;
+           let historyState = state.field(historyField_, false);
+           if (!historyState)
+               return false;
+           let tr = historyState.pop(side, state, selection);
+           if (!tr)
+               return false;
+           dispatch(tr);
+           return true;
+       };
+   }
+   /**
+   Undo a single group of history events. Returns false if no group
+   was available.
+   */
+   const undo = /*@__PURE__*/cmd(0 /* Done */, false);
+   /**
+   Redo a group of history events. Returns false if no group was
+   available.
+   */
+   const redo = /*@__PURE__*/cmd(1 /* Undone */, false);
+   /**
+   Undo a change or selection change.
+   */
+   const undoSelection = /*@__PURE__*/cmd(0 /* Done */, true);
+   /**
+   Redo a change or selection change.
+   */
+   const redoSelection = /*@__PURE__*/cmd(1 /* Undone */, true);
+   // History events store groups of changes or effects that need to be
+   // undone/redone together.
+   class HistEvent {
+       constructor(
+       // The changes in this event. Normal events hold at least one
+       // change or effect. But it may be necessary to store selection
+       // events before the first change, in which case a special type of
+       // instance is created which doesn't hold any changes, with
+       // changes == startSelection == undefined
+       changes, 
+       // The effects associated with this event
+       effects, mapped, 
+       // The selection before this event
+       startSelection, 
+       // Stores selection changes after this event, to be used for
+       // selection undo/redo.
+       selectionsAfter) {
+           this.changes = changes;
+           this.effects = effects;
+           this.mapped = mapped;
+           this.startSelection = startSelection;
+           this.selectionsAfter = selectionsAfter;
+       }
+       setSelAfter(after) {
+           return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);
+       }
+       toJSON() {
+           var _a, _b, _c;
+           return {
+               changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),
+               mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),
+               startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),
+               selectionsAfter: this.selectionsAfter.map(s => s.toJSON())
+           };
+       }
+       static fromJSON(json) {
+           return new HistEvent(json.changes && ChangeSet$2.fromJSON(json.changes), [], json.mapped && ChangeDesc$2.fromJSON(json.mapped), json.startSelection && EditorSelection$2.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection$2.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(tr, selection) {
+           let effects = none$4;
+           for (let invert of tr.startState.facet(invertedEffects)) {
+               let result = invert(tr);
+               if (result.length)
+                   effects = effects.concat(result);
+           }
+           if (!effects.length && tr.changes.empty)
+               return null;
+           return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none$4);
+       }
+       static selection(selections) {
+           return new HistEvent(undefined, none$4, undefined, undefined, selections);
+       }
+   }
+   function updateBranch(branch, to, maxLen, newEvent) {
+       let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;
+       let newBranch = branch.slice(start, to);
+       newBranch.push(newEvent);
+       return newBranch;
+   }
+   function isAdjacent(a, b) {
+       let ranges = [], isAdjacent = false;
+       a.iterChangedRanges((f, t) => ranges.push(f, t));
+       b.iterChangedRanges((_f, _t, f, t) => {
+           for (let i = 0; i < ranges.length;) {
+               let from = ranges[i++], to = ranges[i++];
+               if (t >= from && f <= to)
+                   isAdjacent = true;
+           }
+       });
+       return isAdjacent;
+   }
+   function eqSelectionShape(a, b) {
+       return a.ranges.length == b.ranges.length &&
+           a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;
+   }
+   function conc(a, b) {
+       return !a.length ? b : !b.length ? a : a.concat(b);
+   }
+   const none$4 = [];
+   const MaxSelectionsPerEvent = 200;
+   function addSelection(branch, selection) {
+       if (!branch.length) {
+           return [HistEvent.selection([selection])];
+       }
+       else {
+           let lastEvent = branch[branch.length - 1];
+           let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));
+           if (sels.length && sels[sels.length - 1].eq(selection))
+               return branch;
+           sels.push(selection);
+           return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));
+       }
+   }
+   // Assumes the top item has one or more selectionAfter values
+   function popSelection(branch) {
+       let last = branch[branch.length - 1];
+       let newBranch = branch.slice();
+       newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));
+       return newBranch;
+   }
+   // Add a mapping to the top event in the given branch. If this maps
+   // away all the changes and effects in that item, drop it and
+   // propagate the mapping to the next item.
+   function addMappingToBranch(branch, mapping) {
+       if (!branch.length)
+           return branch;
+       let length = branch.length, selections = none$4;
+       while (length) {
+           let event = mapEvent(branch[length - 1], mapping, selections);
+           if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping
+               let result = branch.slice(0, length);
+               result[length - 1] = event;
+               return result;
+           }
+           else { // Drop this event, since there's no changes or effects left
+               mapping = event.mapped;
+               length--;
+               selections = event.selectionsAfter;
+           }
+       }
+       return selections.length ? [HistEvent.selection(selections)] : none$4;
+   }
+   function mapEvent(event, mapping, extraSelections) {
+       let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none$4, extraSelections);
+       // Change-less events don't store mappings (they are always the last event in a branch)
+       if (!event.changes)
+           return HistEvent.selection(selections);
+       let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);
+       let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;
+       return new HistEvent(mappedChanges, StateEffect$2.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);
+   }
+   const joinableUserEvent = /^(input\.type|delete)($|\.)/;
+   class HistoryState {
+       constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {
+           this.done = done;
+           this.undone = undone;
+           this.prevTime = prevTime;
+           this.prevUserEvent = prevUserEvent;
+       }
+       isolate() {
+           return this.prevTime ? new HistoryState(this.done, this.undone) : this;
+       }
+       addChanges(event, time, userEvent, newGroupDelay, maxLen) {
+           let done = this.done, lastEvent = done[done.length - 1];
+           if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&
+               (!userEvent || joinableUserEvent.test(userEvent)) &&
+               ((!lastEvent.selectionsAfter.length &&
+                   time - this.prevTime < newGroupDelay &&
+                   isAdjacent(lastEvent.changes, event.changes)) ||
+                   // For compose (but not compose.start) events, always join with previous event
+                   userEvent == "input.type.compose")) {
+               done = updateBranch(done, done.length - 1, maxLen, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none$4));
+           }
+           else {
+               done = updateBranch(done, done.length, maxLen, event);
+           }
+           return new HistoryState(done, none$4, time, userEvent);
+       }
+       addSelection(selection, time, userEvent, newGroupDelay) {
+           let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none$4;
+           if (last.length > 0 &&
+               time - this.prevTime < newGroupDelay &&
+               userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) &&
+               eqSelectionShape(last[last.length - 1], selection))
+               return this;
+           return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);
+       }
+       addMapping(mapping) {
+           return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
+       }
+       pop(side, state, selection) {
+           let branch = side == 0 /* Done */ ? this.done : this.undone;
+           if (branch.length == 0)
+               return null;
+           let event = branch[branch.length - 1];
+           if (selection && event.selectionsAfter.length) {
+               return state.update({
+                   selection: event.selectionsAfter[event.selectionsAfter.length - 1],
+                   annotations: fromHistory.of({ side, rest: popSelection(branch) }),
+                   userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
+                   scrollIntoView: true
+               });
+           }
+           else if (!event.changes) {
+               return null;
+           }
+           else {
+               let rest = branch.length == 1 ? none$4 : branch.slice(0, branch.length - 1);
+               if (event.mapped)
+                   rest = addMappingToBranch(rest, event.mapped);
+               return state.update({
+                   changes: event.changes,
+                   selection: event.startSelection,
+                   effects: event.effects,
+                   annotations: fromHistory.of({ side, rest }),
+                   filter: false,
+                   userEvent: side == 0 /* Done */ ? "undo" : "redo",
+                   scrollIntoView: true
+               });
+           }
+       }
+   }
+   HistoryState.empty = /*@__PURE__*/new HistoryState(none$4, none$4);
+   /**
+   Default key bindings for the undo history.
+
+   - Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
+   - Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
+   - Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
+   - Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
+   */
+   const historyKeymap = [
+       { key: "Mod-z", run: undo, preventDefault: true },
+       { key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true },
+       { key: "Mod-u", run: undoSelection, preventDefault: true },
+       { key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true }
+   ];
+
+   function updateSel(sel, by) {
+       return EditorSelection$2.create(sel.ranges.map(by), sel.mainIndex);
+   }
+   function setSel(state, selection) {
+       return state.update({ selection, scrollIntoView: true, userEvent: "select" });
+   }
+   function moveSel({ state, dispatch }, how) {
+       let selection = updateSel(state.selection, how);
+       if (selection.eq(state.selection))
+           return false;
+       dispatch(setSel(state, selection));
+       return true;
+   }
+   function rangeEnd(range, forward) {
+       return EditorSelection$2.cursor(forward ? range.to : range.from);
+   }
+   function cursorByChar(view, forward) {
+       return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
+   }
+   function ltrAtCursor(view) {
+       return view.textDirectionAt(view.state.selection.main.head) == Direction$2.LTR;
+   }
+   /**
+   Move the selection one character to the left (which is backward in
+   left-to-right text, forward in right-to-left text).
+   */
+   const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
+   /**
+   Move the selection one character to the right.
+   */
+   const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));
+   function cursorByGroup(view, forward) {
+       return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
+   }
+   /**
+   Move the selection to the left across one group of word or
+   non-word (but also non-space) characters.
+   */
+   const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
+   /**
+   Move the selection one group to the right.
+   */
+   const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));
+   function interestingNode(state, node, bracketProp) {
+       if (node.type.prop(bracketProp))
+           return true;
+       let len = node.to - node.from;
+       return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;
+   }
+   function moveBySyntax(state, start, forward) {
+       let pos = syntaxTree$1(state).resolveInner(start.head);
+       let bracketProp = forward ? NodeProp$1.closedBy : NodeProp$1.openedBy;
+       // Scan forward through child nodes to see if there's an interesting
+       // node ahead.
+       for (let at = start.head;;) {
+           let next = forward ? pos.childAfter(at) : pos.childBefore(at);
+           if (!next)
+               break;
+           if (interestingNode(state, next, bracketProp))
+               pos = next;
+           else
+               at = forward ? next.to : next.from;
+       }
+       let bracket = pos.type.prop(bracketProp), match, newPos;
+       if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched)
+           newPos = forward ? match.end.to : match.end.from;
+       else
+           newPos = forward ? pos.to : pos.from;
+       return EditorSelection$2.cursor(newPos, forward ? -1 : 1);
+   }
+   /**
+   Move the cursor over the next syntactic element to the left.
+   */
+   const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
+   /**
+   Move the cursor over the next syntactic element to the right.
+   */
+   const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
+   function cursorByLine(view, forward) {
+       return moveSel(view, range => {
+           if (!range.empty)
+               return rangeEnd(range, forward);
+           let moved = view.moveVertically(range, forward);
+           return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);
+       });
+   }
+   /**
+   Move the selection one line up.
+   */
+   const cursorLineUp = view => cursorByLine(view, false);
+   /**
+   Move the selection one line down.
+   */
+   const cursorLineDown = view => cursorByLine(view, true);
+   function cursorByPage(view, forward) {
+       let { state } = view, selection = updateSel(state.selection, range => {
+           return range.empty ? view.moveVertically(range, forward, Math.min(view.dom.clientHeight, innerHeight))
+               : rangeEnd(range, forward);
+       });
+       if (selection.eq(state.selection))
+           return false;
+       let startPos = view.coordsAtPos(state.selection.main.head);
+       let scrollRect = view.scrollDOM.getBoundingClientRect();
+       let effect;
+       if (startPos && startPos.top > scrollRect.top && startPos.bottom < scrollRect.bottom &&
+           startPos.top - scrollRect.top <= view.scrollDOM.scrollHeight - view.scrollDOM.scrollTop - view.scrollDOM.clientHeight)
+           effect = EditorView$2.scrollIntoView(selection.main.head, { y: "start", yMargin: startPos.top - scrollRect.top });
+       view.dispatch(setSel(state, selection), { effects: effect });
+       return true;
+   }
+   /**
+   Move the selection one page up.
+   */
+   const cursorPageUp = view => cursorByPage(view, false);
+   /**
+   Move the selection one page down.
+   */
+   const cursorPageDown = view => cursorByPage(view, true);
+   function moveByLineBoundary(view, start, forward) {
+       let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward);
+       if (moved.head == start.head && moved.head != (forward ? line.to : line.from))
+           moved = view.moveToLineBoundary(start, forward, false);
+       if (!forward && moved.head == line.from && line.length) {
+           let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;
+           if (space && start.head != line.from + space)
+               moved = EditorSelection$2.cursor(line.from + space);
+       }
+       return moved;
+   }
+   /**
+   Move the selection to the next line wrap point, or to the end of
+   the line if there isn't one left on this line.
+   */
+   const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));
+   /**
+   Move the selection to previous line wrap point, or failing that to
+   the start of the line. If the line is indented, and the cursor
+   isn't already at the end of the indentation, this will move to the
+   end of the indentation instead of the start of the line.
+   */
+   const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
+   /**
+   Move the selection to the start of the line.
+   */
+   const cursorLineStart = view => moveSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).from, 1));
+   /**
+   Move the selection to the end of the line.
+   */
+   const cursorLineEnd = view => moveSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).to, -1));
+   function toMatchingBracket(state, dispatch, extend) {
+       let found = false, selection = updateSel(state.selection, range => {
+           let matching = matchBrackets(state, range.head, -1)
+               || matchBrackets(state, range.head, 1)
+               || (range.head > 0 && matchBrackets(state, range.head - 1, 1))
+               || (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1));
+           if (!matching || !matching.end)
+               return range;
+           found = true;
+           let head = matching.start.from == range.head ? matching.end.to : matching.end.from;
+           return EditorSelection$2.cursor(head);
+       });
+       if (!found)
+           return false;
+       dispatch(setSel(state, selection));
+       return true;
+   }
+   /**
+   Move the selection to the bracket matching the one it is currently
+   on, if any.
+   */
+   const cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch);
+   function extendSel(view, how) {
+       let selection = updateSel(view.state.selection, range => {
+           let head = how(range);
+           return EditorSelection$2.range(range.anchor, head.head, head.goalColumn);
+       });
+       if (selection.eq(view.state.selection))
+           return false;
+       view.dispatch(setSel(view.state, selection));
+       return true;
+   }
+   function selectByChar(view, forward) {
+       return extendSel(view, range => view.moveByChar(range, forward));
+   }
+   /**
+   Move the selection head one character to the left, while leaving
+   the anchor in place.
+   */
+   const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));
+   /**
+   Move the selection head one character to the right.
+   */
+   const selectCharRight = view => selectByChar(view, ltrAtCursor(view));
+   function selectByGroup(view, forward) {
+       return extendSel(view, range => view.moveByGroup(range, forward));
+   }
+   /**
+   Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
+   the left.
+   */
+   const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));
+   /**
+   Move the selection head one group to the right.
+   */
+   const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));
+   /**
+   Move the selection head over the next syntactic element to the left.
+   */
+   const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
+   /**
+   Move the selection head over the next syntactic element to the right.
+   */
+   const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
+   function selectByLine(view, forward) {
+       return extendSel(view, range => view.moveVertically(range, forward));
+   }
+   /**
+   Move the selection head one line up.
+   */
+   const selectLineUp = view => selectByLine(view, false);
+   /**
+   Move the selection head one line down.
+   */
+   const selectLineDown = view => selectByLine(view, true);
+   function selectByPage(view, forward) {
+       return extendSel(view, range => view.moveVertically(range, forward, Math.min(view.dom.clientHeight, innerHeight)));
+   }
+   /**
+   Move the selection head one page up.
+   */
+   const selectPageUp = view => selectByPage(view, false);
+   /**
+   Move the selection head one page down.
+   */
+   const selectPageDown = view => selectByPage(view, true);
+   /**
+   Move the selection head to the next line boundary.
+   */
+   const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));
+   /**
+   Move the selection head to the previous line boundary.
+   */
+   const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
+   /**
+   Move the selection head to the start of the line.
+   */
+   const selectLineStart = view => extendSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).from));
+   /**
+   Move the selection head to the end of the line.
+   */
+   const selectLineEnd = view => extendSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).to));
+   /**
+   Move the selection to the start of the document.
+   */
+   const cursorDocStart = ({ state, dispatch }) => {
+       dispatch(setSel(state, { anchor: 0 }));
+       return true;
+   };
+   /**
+   Move the selection to the end of the document.
+   */
+   const cursorDocEnd = ({ state, dispatch }) => {
+       dispatch(setSel(state, { anchor: state.doc.length }));
+       return true;
+   };
+   /**
+   Move the selection head to the start of the document.
+   */
+   const selectDocStart = ({ state, dispatch }) => {
+       dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 }));
+       return true;
+   };
+   /**
+   Move the selection head to the end of the document.
+   */
+   const selectDocEnd = ({ state, dispatch }) => {
+       dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length }));
+       return true;
+   };
+   /**
+   Select the entire document.
+   */
+   const selectAll = ({ state, dispatch }) => {
+       dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: "select" }));
+       return true;
+   };
+   /**
+   Expand the selection to cover entire lines.
+   */
+   const selectLine = ({ state, dispatch }) => {
+       let ranges = selectedLineBlocks(state).map(({ from, to }) => EditorSelection$2.range(from, Math.min(to + 1, state.doc.length)));
+       dispatch(state.update({ selection: EditorSelection$2.create(ranges), userEvent: "select" }));
+       return true;
+   };
+   /**
+   Select the next syntactic construct that is larger than the
+   selection. Note that this will only work insofar as the language
+   [provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
+   syntax tree.
+   */
+   const selectParentSyntax = ({ state, dispatch }) => {
+       let selection = updateSel(state.selection, range => {
+           var _a;
+           let context = syntaxTree$1(state).resolveInner(range.head, 1);
+           while (!((context.from < range.from && context.to >= range.to) ||
+               (context.to > range.to && context.from <= range.from) ||
+               !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent)))
+               context = context.parent;
+           return EditorSelection$2.range(context.to, context.from);
+       });
+       dispatch(setSel(state, selection));
+       return true;
+   };
+   /**
+   Simplify the current selection. When multiple ranges are selected,
+   reduce it to its main range. Otherwise, if the selection is
+   non-empty, convert it to a cursor selection.
+   */
+   const simplifySelection = ({ state, dispatch }) => {
+       let cur = state.selection, selection = null;
+       if (cur.ranges.length > 1)
+           selection = EditorSelection$2.create([cur.main]);
+       else if (!cur.main.empty)
+           selection = EditorSelection$2.create([EditorSelection$2.cursor(cur.main.head)]);
+       if (!selection)
+           return false;
+       dispatch(setSel(state, selection));
+       return true;
+   };
+   function deleteBy({ state, dispatch }, by) {
+       if (state.readOnly)
+           return false;
+       let event = "delete.selection";
+       let changes = state.changeByRange(range => {
+           let { from, to } = range;
+           if (from == to) {
+               let towards = by(from);
+               if (towards < from)
+                   event = "delete.backward";
+               else if (towards > from)
+                   event = "delete.forward";
+               from = Math.min(from, towards);
+               to = Math.max(to, towards);
+           }
+           return from == to ? { range } : { changes: { from, to }, range: EditorSelection$2.cursor(from) };
+       });
+       if (changes.changes.empty)
+           return false;
+       dispatch(state.update(changes, { scrollIntoView: true, userEvent: event }));
+       return true;
+   }
+   function skipAtomic(target, pos, forward) {
+       if (target instanceof EditorView$2)
+           for (let ranges of target.state.facet(EditorView$2.atomicRanges).map(f => f(target)))
+               ranges.between(pos, pos, (from, to) => {
+                   if (from < pos && to > pos)
+                       pos = forward ? to : from;
+               });
+       return pos;
+   }
+   const deleteByChar = (target, forward) => deleteBy(target, pos => {
+       let { state } = target, line = state.doc.lineAt(pos), before, targetPos;
+       if (!forward && pos > line.from && pos < line.from + 200 &&
+           !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) {
+           if (before[before.length - 1] == "\t")
+               return pos - 1;
+           let col = countColumn(before, state.tabSize), drop = col % getIndentUnit(state) || getIndentUnit(state);
+           for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++)
+               pos--;
+           targetPos = pos;
+       }
+       else {
+           targetPos = findClusterBreak$3(line.text, pos - line.from, forward, forward) + line.from;
+           if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))
+               targetPos += forward ? 1 : -1;
+       }
+       return skipAtomic(target, targetPos, forward);
+   });
+   /**
+   Delete the selection, or, for cursor selections, the character
+   before the cursor.
+   */
+   const deleteCharBackward = view => deleteByChar(view, false);
+   /**
+   Delete the selection or the character after the cursor.
+   */
+   const deleteCharForward = view => deleteByChar(view, true);
+   const deleteByGroup = (target, forward) => deleteBy(target, start => {
+       let pos = start, { state } = target, line = state.doc.lineAt(pos);
+       let categorize = state.charCategorizer(pos);
+       for (let cat = null;;) {
+           if (pos == (forward ? line.to : line.from)) {
+               if (pos == start && line.number != (forward ? state.doc.lines : 1))
+                   pos += forward ? 1 : -1;
+               break;
+           }
+           let next = findClusterBreak$3(line.text, pos - line.from, forward) + line.from;
+           let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);
+           let nextCat = categorize(nextChar);
+           if (cat != null && nextCat != cat)
+               break;
+           if (nextChar != " " || pos != start)
+               cat = nextCat;
+           pos = next;
+       }
+       return skipAtomic(target, pos, forward);
+   });
+   /**
+   Delete the selection or backward until the end of the next
+   [group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
+   whitespace when they consist of a single space.
+   */
+   const deleteGroupBackward = target => deleteByGroup(target, false);
+   /**
+   Delete the selection or forward until the end of the next group.
+   */
+   const deleteGroupForward = target => deleteByGroup(target, true);
+   /**
+   Delete the selection, or, if it is a cursor selection, delete to
+   the end of the line. If the cursor is directly at the end of the
+   line, delete the line break after it.
+   */
+   const deleteToLineEnd = view => deleteBy(view, pos => {
+       let lineEnd = view.lineBlockAt(pos).to;
+       return skipAtomic(view, pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1), true);
+   });
+   /**
+   Delete the selection, or, if it is a cursor selection, delete to
+   the start of the line. If the cursor is directly at the start of the
+   line, delete the line break before it.
+   */
+   const deleteToLineStart = view => deleteBy(view, pos => {
+       let lineStart = view.lineBlockAt(pos).from;
+       return skipAtomic(view, pos > lineStart ? lineStart : Math.max(0, pos - 1), false);
+   });
+   /**
+   Replace each selection range with a line break, leaving the cursor
+   on the line before the break.
+   */
+   const splitLine = ({ state, dispatch }) => {
+       if (state.readOnly)
+           return false;
+       let changes = state.changeByRange(range => {
+           return { changes: { from: range.from, to: range.to, insert: Text$2.of(["", ""]) },
+               range: EditorSelection$2.cursor(range.from) };
+       });
+       dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
+       return true;
+   };
+   /**
+   Flip the characters before and after the cursor(s).
+   */
+   const transposeChars = ({ state, dispatch }) => {
+       if (state.readOnly)
+           return false;
+       let changes = state.changeByRange(range => {
+           if (!range.empty || range.from == 0 || range.from == state.doc.length)
+               return { range };
+           let pos = range.from, line = state.doc.lineAt(pos);
+           let from = pos == line.from ? pos - 1 : findClusterBreak$3(line.text, pos - line.from, false) + line.from;
+           let to = pos == line.to ? pos + 1 : findClusterBreak$3(line.text, pos - line.from, true) + line.from;
+           return { changes: { from, to, insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos)) },
+               range: EditorSelection$2.cursor(to) };
+       });
+       if (changes.changes.empty)
+           return false;
+       dispatch(state.update(changes, { scrollIntoView: true, userEvent: "move.character" }));
+       return true;
+   };
+   function selectedLineBlocks(state) {
+       let blocks = [], upto = -1;
+       for (let range of state.selection.ranges) {
+           let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to);
+           if (!range.empty && range.to == endLine.from)
+               endLine = state.doc.lineAt(range.to - 1);
+           if (upto >= startLine.number) {
+               let prev = blocks[blocks.length - 1];
+               prev.to = endLine.to;
+               prev.ranges.push(range);
+           }
+           else {
+               blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] });
+           }
+           upto = endLine.number + 1;
+       }
+       return blocks;
+   }
+   function moveLine(state, dispatch, forward) {
+       if (state.readOnly)
+           return false;
+       let changes = [], ranges = [];
+       for (let block of selectedLineBlocks(state)) {
+           if (forward ? block.to == state.doc.length : block.from == 0)
+               continue;
+           let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);
+           let size = nextLine.length + 1;
+           if (forward) {
+               changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state.lineBreak });
+               for (let r of block.ranges)
+                   ranges.push(EditorSelection$2.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
+           }
+           else {
+               changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text });
+               for (let r of block.ranges)
+                   ranges.push(EditorSelection$2.range(r.anchor - size, r.head - size));
+           }
+       }
+       if (!changes.length)
+           return false;
+       dispatch(state.update({
+           changes,
+           scrollIntoView: true,
+           selection: EditorSelection$2.create(ranges, state.selection.mainIndex),
+           userEvent: "move.line"
+       }));
+       return true;
+   }
+   /**
+   Move the selected lines up one line.
+   */
+   const moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false);
+   /**
+   Move the selected lines down one line.
+   */
+   const moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true);
+   function copyLine(state, dispatch, forward) {
+       if (state.readOnly)
+           return false;
+       let changes = [];
+       for (let block of selectedLineBlocks(state)) {
+           if (forward)
+               changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak });
+           else
+               changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) });
+       }
+       dispatch(state.update({ changes, scrollIntoView: true, userEvent: "input.copyline" }));
+       return true;
+   }
+   /**
+   Create a copy of the selected lines. Keep the selection in the top copy.
+   */
+   const copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false);
+   /**
+   Create a copy of the selected lines. Keep the selection in the bottom copy.
+   */
+   const copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true);
+   /**
+   Delete selected lines.
+   */
+   const deleteLine = view => {
+       if (view.state.readOnly)
+           return false;
+       let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => {
+           if (from > 0)
+               from--;
+           else if (to < state.doc.length)
+               to++;
+           return { from, to };
+       }));
+       let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);
+       view.dispatch({ changes, selection, scrollIntoView: true, userEvent: "delete.line" });
+       return true;
+   };
+   function isBetweenBrackets(state, pos) {
+       if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1)))
+           return { from: pos, to: pos };
+       let context = syntaxTree$1(state).resolveInner(pos);
+       let before = context.childBefore(pos), after = context.childAfter(pos), closedBy;
+       if (before && after && before.to <= pos && after.from >= pos &&
+           (closedBy = before.type.prop(NodeProp$1.closedBy)) && closedBy.indexOf(after.name) > -1 &&
+           state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from)
+           return { from: before.to, to: after.from };
+       return null;
+   }
+   /**
+   Replace the selection with a newline and indent the newly created
+   line(s). If the current line consists only of whitespace, this
+   will also delete that whitespace. When the cursor is between
+   matching brackets, an additional newline will be inserted after
+   the cursor.
+   */
+   const insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);
+   /**
+   Create a blank, indented line below the current line.
+   */
+   const insertBlankLine = /*@__PURE__*/newlineAndIndent(true);
+   function newlineAndIndent(atEof) {
+       return ({ state, dispatch }) => {
+           if (state.readOnly)
+               return false;
+           let changes = state.changeByRange(range => {
+               let { from, to } = range, line = state.doc.lineAt(from);
+               let explode = !atEof && from == to && isBetweenBrackets(state, from);
+               if (atEof)
+                   from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;
+               let cx = new IndentContext(state, { simulateBreak: from, simulateDoubleBreak: !!explode });
+               let indent = getIndentation(cx, from);
+               if (indent == null)
+                   indent = /^\s*/.exec(state.doc.lineAt(from).text)[0].length;
+               while (to < line.to && /\s/.test(line.text[to - line.from]))
+                   to++;
+               if (explode)
+                   ({ from, to } = explode);
+               else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from)))
+                   from = line.from;
+               let insert = ["", indentString(state, indent)];
+               if (explode)
+                   insert.push(indentString(state, cx.lineIndent(line.from, -1)));
+               return { changes: { from, to, insert: Text$2.of(insert) },
+                   range: EditorSelection$2.cursor(from + 1 + insert[1].length) };
+           });
+           dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
+           return true;
+       };
+   }
+   function changeBySelectedLine(state, f) {
+       let atLine = -1;
+       return state.changeByRange(range => {
+           let changes = [];
+           for (let pos = range.from; pos <= range.to;) {
+               let line = state.doc.lineAt(pos);
+               if (line.number > atLine && (range.empty || range.to > line.from)) {
+                   f(line, changes, range);
+                   atLine = line.number;
+               }
+               pos = line.to + 1;
+           }
+           let changeSet = state.changes(changes);
+           return { changes,
+               range: EditorSelection$2.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) };
+       });
+   }
+   /**
+   Auto-indent the selected lines. This uses the [indentation service
+   facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
+   information.
+   */
+   const indentSelection = ({ state, dispatch }) => {
+       if (state.readOnly)
+           return false;
+       let updated = Object.create(null);
+       let context = new IndentContext(state, { overrideIndentation: start => {
+               let found = updated[start];
+               return found == null ? -1 : found;
+           } });
+       let changes = changeBySelectedLine(state, (line, changes, range) => {
+           let indent = getIndentation(context, line.from);
+           if (indent == null)
+               return;
+           if (!/\S/.test(line.text))
+               indent = 0;
+           let cur = /^\s*/.exec(line.text)[0];
+           let norm = indentString(state, indent);
+           if (cur != norm || range.from < line.from + cur.length) {
+               updated[line.from] = indent;
+               changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
+           }
+       });
+       if (!changes.changes.empty)
+           dispatch(state.update(changes, { userEvent: "indent" }));
+       return true;
+   };
+   /**
+   Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
+   lines.
+   */
+   const indentMore = ({ state, dispatch }) => {
+       if (state.readOnly)
+           return false;
+       dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
+           changes.push({ from: line.from, insert: state.facet(indentUnit$1) });
+       }), { userEvent: "input.indent" }));
+       return true;
+   };
+   /**
+   Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
+   selected lines.
+   */
+   const indentLess = ({ state, dispatch }) => {
+       if (state.readOnly)
+           return false;
+       dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
+           let space = /^\s*/.exec(line.text)[0];
+           if (!space)
+               return;
+           let col = countColumn(space, state.tabSize), keep = 0;
+           let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));
+           while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep))
+               keep++;
+           changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) });
+       }), { userEvent: "delete.dedent" }));
+       return true;
+   };
+   /**
+   Array of key bindings containing the Emacs-style bindings that are
+   available on macOS by default.
+
+    - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
+    - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
+    - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
+    - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
+    - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
+    - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
+    - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
+    - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
+    - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
+    - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
+    - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
+    - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
+    - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
+    - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
+   */
+   const emacsStyleKeymap = [
+       { key: "Ctrl-b", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
+       { key: "Ctrl-f", run: cursorCharRight, shift: selectCharRight },
+       { key: "Ctrl-p", run: cursorLineUp, shift: selectLineUp },
+       { key: "Ctrl-n", run: cursorLineDown, shift: selectLineDown },
+       { key: "Ctrl-a", run: cursorLineStart, shift: selectLineStart },
+       { key: "Ctrl-e", run: cursorLineEnd, shift: selectLineEnd },
+       { key: "Ctrl-d", run: deleteCharForward },
+       { key: "Ctrl-h", run: deleteCharBackward },
+       { key: "Ctrl-k", run: deleteToLineEnd },
+       { key: "Ctrl-Alt-h", run: deleteGroupBackward },
+       { key: "Ctrl-o", run: splitLine },
+       { key: "Ctrl-t", run: transposeChars },
+       { key: "Ctrl-v", run: cursorPageDown },
+   ];
+   /**
+   An array of key bindings closely sticking to platform-standard or
+   widely used bindings. (This includes the bindings from
+   [`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
+   property changed to `mac`.)
+
+    - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
+    - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
+    - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
+    - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
+    - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
+    - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
+    - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
+    - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
+    - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
+    - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
+    - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
+    - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
+    - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
+    - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
+    - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
+    - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
+    - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
+    - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
+    - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
+    - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
+    - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
+    - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
+    - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
+    - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
+    - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
+    - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
+   */
+   const standardKeymap = /*@__PURE__*/[
+       { key: "ArrowLeft", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
+       { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft },
+       { mac: "Cmd-ArrowLeft", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward },
+       { key: "ArrowRight", run: cursorCharRight, shift: selectCharRight, preventDefault: true },
+       { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight },
+       { mac: "Cmd-ArrowRight", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward },
+       { key: "ArrowUp", run: cursorLineUp, shift: selectLineUp, preventDefault: true },
+       { mac: "Cmd-ArrowUp", run: cursorDocStart, shift: selectDocStart },
+       { mac: "Ctrl-ArrowUp", run: cursorPageUp, shift: selectPageUp },
+       { key: "ArrowDown", run: cursorLineDown, shift: selectLineDown, preventDefault: true },
+       { mac: "Cmd-ArrowDown", run: cursorDocEnd, shift: selectDocEnd },
+       { mac: "Ctrl-ArrowDown", run: cursorPageDown, shift: selectPageDown },
+       { key: "PageUp", run: cursorPageUp, shift: selectPageUp },
+       { key: "PageDown", run: cursorPageDown, shift: selectPageDown },
+       { key: "Home", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true },
+       { key: "Mod-Home", run: cursorDocStart, shift: selectDocStart },
+       { key: "End", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true },
+       { key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd },
+       { key: "Enter", run: insertNewlineAndIndent },
+       { key: "Mod-a", run: selectAll },
+       { key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward },
+       { key: "Delete", run: deleteCharForward },
+       { key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward },
+       { key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward },
+       { mac: "Mod-Backspace", run: deleteToLineStart },
+       { mac: "Mod-Delete", run: deleteToLineEnd }
+   ].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));
+   /**
+   The default keymap. Includes all bindings from
+   [`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
+
+   - Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
+   - Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
+   - Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
+   - Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
+   - Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
+   - Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
+   - Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
+   - Ctrl-Enter (Comd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
+   - Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
+   - Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
+   - Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
+   - Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
+   - Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
+   - Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
+   - Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
+   - Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
+   - Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
+   */
+   const defaultKeymap = /*@__PURE__*/[
+       { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: cursorSyntaxLeft, shift: selectSyntaxLeft },
+       { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: cursorSyntaxRight, shift: selectSyntaxRight },
+       { key: "Alt-ArrowUp", run: moveLineUp },
+       { key: "Shift-Alt-ArrowUp", run: copyLineUp },
+       { key: "Alt-ArrowDown", run: moveLineDown },
+       { key: "Shift-Alt-ArrowDown", run: copyLineDown },
+       { key: "Escape", run: simplifySelection },
+       { key: "Mod-Enter", run: insertBlankLine },
+       { key: "Alt-l", mac: "Ctrl-l", run: selectLine },
+       { key: "Mod-i", run: selectParentSyntax, preventDefault: true },
+       { key: "Mod-[", run: indentLess },
+       { key: "Mod-]", run: indentMore },
+       { key: "Mod-Alt-\\", run: indentSelection },
+       { key: "Shift-Mod-k", run: deleteLine },
+       { key: "Shift-Mod-\\", run: cursorMatchingBracket },
+       { key: "Mod-/", run: toggleComment },
+       { key: "Alt-A", run: toggleBlockComment }
+   ].concat(standardKeymap);
+
+   /**
+   The data structure for documents. @nonabstract
+   */
+   let Text$1 = class Text {
+       /**
+       @internal
+       */
+       constructor() { }
+       /**
+       Get the line description around the given position.
+       */
+       lineAt(pos) {
+           if (pos < 0 || pos > this.length)
+               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
+           return this.lineInner(pos, false, 1, 0);
+       }
+       /**
+       Get the description for the given (1-based) line number.
+       */
+       line(n) {
+           if (n < 1 || n > this.lines)
+               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
+           return this.lineInner(n, true, 1, 0);
+       }
+       /**
+       Replace a range of the text with the given content.
+       */
+       replace(from, to, text) {
+           let parts = [];
+           this.decompose(0, from, parts, 2 /* To */);
+           if (text.length)
+               text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
+           this.decompose(to, this.length, parts, 1 /* From */);
+           return TextNode$1.from(parts, this.length - (to - from) + text.length);
+       }
+       /**
+       Append another document to this one.
+       */
+       append(other) {
+           return this.replace(this.length, this.length, other);
+       }
+       /**
+       Retrieve the text between the given points.
+       */
+       slice(from, to = this.length) {
+           let parts = [];
+           this.decompose(from, to, parts, 0);
+           return TextNode$1.from(parts, to - from);
+       }
+       /**
+       Test whether this text is equal to another instance.
+       */
+       eq(other) {
+           if (other == this)
+               return true;
+           if (other.length != this.length || other.lines != this.lines)
+               return false;
+           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
+           let a = new RawTextCursor$1(this), b = new RawTextCursor$1(other);
+           for (let skip = start, pos = start;;) {
+               a.next(skip);
+               b.next(skip);
+               skip = 0;
+               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
+                   return false;
+               pos += a.value.length;
+               if (a.done || pos >= end)
+                   return true;
+           }
+       }
+       /**
+       Iterate over the text. When `dir` is `-1`, iteration happens
+       from end to start. This will return lines and the breaks between
+       them as separate strings.
+       */
+       iter(dir = 1) { return new RawTextCursor$1(this, dir); }
+       /**
+       Iterate over a range of the text. When `from` > `to`, the
+       iterator will run in reverse.
+       */
+       iterRange(from, to = this.length) { return new PartialTextCursor$1(this, from, to); }
+       /**
+       Return a cursor that iterates over the given range of lines,
+       _without_ returning the line breaks between, and yielding empty
+       strings for empty lines.
+       
+       When `from` and `to` are given, they should be 1-based line numbers.
+       */
+       iterLines(from, to) {
+           let inner;
+           if (from == null) {
+               inner = this.iter();
+           }
+           else {
+               if (to == null)
+                   to = this.lines + 1;
+               let start = this.line(from).from;
+               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
+           }
+           return new LineCursor$1(inner);
+       }
+       /**
+       @internal
+       */
+       toString() { return this.sliceString(0); }
+       /**
+       Convert the document to an array of lines (which can be
+       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
+       */
+       toJSON() {
+           let lines = [];
+           this.flatten(lines);
+           return lines;
+       }
+       /**
+       Create a `Text` instance for the given array of lines.
+       */
+       static of(text) {
+           if (text.length == 0)
+               throw new RangeError("A document must have at least one line");
+           if (text.length == 1 && !text[0])
+               return Text.empty;
+           return text.length <= 32 /* Branch */ ? new TextLeaf$1(text) : TextNode$1.from(TextLeaf$1.split(text, []));
+       }
+   };
+   // Leaves store an array of line strings. There are always line breaks
+   // between these strings. Leaves are limited in size and have to be
+   // contained in TextNode instances for bigger documents.
+   let TextLeaf$1 = class TextLeaf extends Text$1 {
+       constructor(text, length = textLength$1(text)) {
+           super();
+           this.text = text;
+           this.length = length;
+       }
+       get lines() { return this.text.length; }
+       get children() { return null; }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let string = this.text[i], end = offset + string.length;
+               if ((isLine ? line : end) >= target)
+                   return new Line$1(offset, end, line, string);
+               offset = end + 1;
+               line++;
+           }
+       }
+       decompose(from, to, target, open) {
+           let text = from <= 0 && to >= this.length ? this
+               : new TextLeaf(sliceText$1(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
+           if (open & 1 /* From */) {
+               let prev = target.pop();
+               let joined = appendText$1(text.text, prev.text.slice(), 0, text.length);
+               if (joined.length <= 32 /* Branch */) {
+                   target.push(new TextLeaf(joined, prev.length + text.length));
+               }
+               else {
+                   let mid = joined.length >> 1;
+                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
+               }
+           }
+           else {
+               target.push(text);
+           }
+       }
+       replace(from, to, text) {
+           if (!(text instanceof TextLeaf))
+               return super.replace(from, to, text);
+           let lines = appendText$1(this.text, appendText$1(text.text, sliceText$1(this.text, 0, from)), to);
+           let newLen = this.length + text.length - (to - from);
+           if (lines.length <= 32 /* Branch */)
+               return new TextLeaf(lines, newLen);
+           return TextNode$1.from(TextLeaf.split(lines, []), newLen);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           let result = "";
+           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
+               let line = this.text[i], end = pos + line.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += line.slice(Math.max(0, from - pos), to - pos);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let line of this.text)
+               target.push(line);
+       }
+       scanIdentical() { return 0; }
+       static split(text, target) {
+           let part = [], len = -1;
+           for (let line of text) {
+               part.push(line);
+               len += line.length + 1;
+               if (part.length == 32 /* Branch */) {
+                   target.push(new TextLeaf(part, len));
+                   part = [];
+                   len = -1;
+               }
+           }
+           if (len > -1)
+               target.push(new TextLeaf(part, len));
+           return target;
+       }
+   };
+   // Nodes provide the tree structure of the `Text` type. They store a
+   // number of other nodes or leaves, taking care to balance themselves
+   // on changes. There are implied line breaks _between_ the children of
+   // a node (but not before the first or after the last child).
+   let TextNode$1 = class TextNode extends Text$1 {
+       constructor(children, length) {
+           super();
+           this.children = children;
+           this.length = length;
+           this.lines = 0;
+           for (let child of children)
+               this.lines += child.lines;
+       }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
+               if ((isLine ? endLine : end) >= target)
+                   return child.lineInner(target, isLine, line, offset);
+               offset = end + 1;
+               line = endLine + 1;
+           }
+       }
+       decompose(from, to, target, open) {
+           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (from <= end && to >= pos) {
+                   let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
+                   if (pos >= from && end <= to && !childOpen)
+                       target.push(child);
+                   else
+                       child.decompose(from - pos, to - pos, target, childOpen);
+               }
+               pos = end + 1;
+           }
+       }
+       replace(from, to, text) {
+           if (text.lines < this.lines)
+               for (let i = 0, pos = 0; i < this.children.length; i++) {
+                   let child = this.children[i], end = pos + child.length;
+                   // Fast path: if the change only affects one child and the
+                   // child's size remains in the acceptable range, only update
+                   // that child
+                   if (from >= pos && to <= end) {
+                       let updated = child.replace(from - pos, to - pos, text);
+                       let totalLines = this.lines - child.lines + updated.lines;
+                       if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
+                           updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
+                           let copy = this.children.slice();
+                           copy[i] = updated;
+                           return new TextNode(copy, this.length - (to - from) + text.length);
+                       }
+                       return super.replace(pos, end, updated);
+                   }
+                   pos = end + 1;
+               }
+           return super.replace(from, to, text);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           let result = "";
+           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += child.sliceString(from - pos, to - pos, lineSep);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let child of this.children)
+               child.flatten(target);
+       }
+       scanIdentical(other, dir) {
+           if (!(other instanceof TextNode))
+               return 0;
+           let length = 0;
+           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
+               : [this.children.length - 1, other.children.length - 1, -1, -1];
+           for (;; iA += dir, iB += dir) {
+               if (iA == eA || iB == eB)
+                   return length;
+               let chA = this.children[iA], chB = other.children[iB];
+               if (chA != chB)
+                   return length + chA.scanIdentical(chB, dir);
+               length += chA.length + 1;
+           }
+       }
+       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
+           let lines = 0;
+           for (let ch of children)
+               lines += ch.lines;
+           if (lines < 32 /* Branch */) {
+               let flat = [];
+               for (let ch of children)
+                   ch.flatten(flat);
+               return new TextLeaf$1(flat, length);
+           }
+           let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
+           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
+           function add(child) {
+               let last;
+               if (child.lines > maxChunk && child instanceof TextNode) {
+                   for (let node of child.children)
+                       add(node);
+               }
+               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
+                   flush();
+                   chunked.push(child);
+               }
+               else if (child instanceof TextLeaf$1 && currentLines &&
+                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf$1 &&
+                   child.lines + last.lines <= 32 /* Branch */) {
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk[currentChunk.length - 1] = new TextLeaf$1(last.text.concat(child.text), last.length + 1 + child.length);
+               }
+               else {
+                   if (currentLines + child.lines > chunk)
+                       flush();
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk.push(child);
+               }
+           }
+           function flush() {
+               if (currentLines == 0)
+                   return;
+               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
+               currentLen = -1;
+               currentLines = currentChunk.length = 0;
+           }
+           for (let child of children)
+               add(child);
+           flush();
+           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
+       }
+   };
+   Text$1.empty = /*@__PURE__*/new TextLeaf$1([""], 0);
+   function textLength$1(text) {
+       let length = -1;
+       for (let line of text)
+           length += line.length + 1;
+       return length;
+   }
+   function appendText$1(text, target, from = 0, to = 1e9) {
+       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
+           let line = text[i], end = pos + line.length;
+           if (end >= from) {
+               if (end > to)
+                   line = line.slice(0, to - pos);
+               if (pos < from)
+                   line = line.slice(from - pos);
+               if (first) {
+                   target[target.length - 1] += line;
+                   first = false;
+               }
+               else
+                   target.push(line);
+           }
+           pos = end + 1;
+       }
+       return target;
+   }
+   function sliceText$1(text, from, to) {
+       return appendText$1(text, [""], from, to);
+   }
+   let RawTextCursor$1 = class RawTextCursor {
+       constructor(text, dir = 1) {
+           this.dir = dir;
+           this.done = false;
+           this.lineBreak = false;
+           this.value = "";
+           this.nodes = [text];
+           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf$1 ? text.text.length : text.children.length) << 1];
+       }
+       nextInner(skip, dir) {
+           this.done = this.lineBreak = false;
+           for (;;) {
+               let last = this.nodes.length - 1;
+               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
+               let size = top instanceof TextLeaf$1 ? top.text.length : top.children.length;
+               if (offset == (dir > 0 ? size : 0)) {
+                   if (last == 0) {
+                       this.done = true;
+                       this.value = "";
+                       return this;
+                   }
+                   if (dir > 0)
+                       this.offsets[last - 1]++;
+                   this.nodes.pop();
+                   this.offsets.pop();
+               }
+               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
+                   this.offsets[last] += dir;
+                   if (skip == 0) {
+                       this.lineBreak = true;
+                       this.value = "\n";
+                       return this;
+                   }
+                   skip--;
+               }
+               else if (top instanceof TextLeaf$1) {
+                   // Move to the next string
+                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
+                   this.offsets[last] += dir;
+                   if (next.length > Math.max(0, skip)) {
+                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
+                       return this;
+                   }
+                   skip -= next.length;
+               }
+               else {
+                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
+                   if (skip > next.length) {
+                       skip -= next.length;
+                       this.offsets[last] += dir;
+                   }
+                   else {
+                       if (dir < 0)
+                           this.offsets[last]--;
+                       this.nodes.push(next);
+                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf$1 ? next.text.length : next.children.length) << 1);
+                   }
+               }
+           }
+       }
+       next(skip = 0) {
+           if (skip < 0) {
+               this.nextInner(-skip, (-this.dir));
+               skip = this.value.length;
+           }
+           return this.nextInner(skip, this.dir);
+       }
+   };
+   let PartialTextCursor$1 = class PartialTextCursor {
+       constructor(text, start, end) {
+           this.value = "";
+           this.done = false;
+           this.cursor = new RawTextCursor$1(text, start > end ? -1 : 1);
+           this.pos = start > end ? text.length : 0;
+           this.from = Math.min(start, end);
+           this.to = Math.max(start, end);
+       }
+       nextInner(skip, dir) {
+           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
+               this.value = "";
+               this.done = true;
+               return this;
+           }
+           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
+           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
+           if (skip > limit)
+               skip = limit;
+           limit -= skip;
+           let { value } = this.cursor.next(skip);
+           this.pos += (value.length + skip) * dir;
+           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
+           this.done = !this.value;
+           return this;
+       }
+       next(skip = 0) {
+           if (skip < 0)
+               skip = Math.max(skip, this.from - this.pos);
+           else if (skip > 0)
+               skip = Math.min(skip, this.to - this.pos);
+           return this.nextInner(skip, this.cursor.dir);
+       }
+       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
+   };
+   let LineCursor$1 = class LineCursor {
+       constructor(inner) {
+           this.inner = inner;
+           this.afterBreak = true;
+           this.value = "";
+           this.done = false;
+       }
+       next(skip = 0) {
+           let { done, lineBreak, value } = this.inner.next(skip);
+           if (done) {
+               this.done = true;
+               this.value = "";
+           }
+           else if (lineBreak) {
+               if (this.afterBreak) {
+                   this.value = "";
+               }
+               else {
+                   this.afterBreak = true;
+                   this.next();
+               }
+           }
+           else {
+               this.value = value;
+               this.afterBreak = false;
+           }
+           return this;
+       }
+       get lineBreak() { return false; }
+   };
+   if (typeof Symbol != "undefined") {
+       Text$1.prototype[Symbol.iterator] = function () { return this.iter(); };
+       RawTextCursor$1.prototype[Symbol.iterator] = PartialTextCursor$1.prototype[Symbol.iterator] =
+           LineCursor$1.prototype[Symbol.iterator] = function () { return this; };
+   }
+   /**
+   This type describes a line in the document. It is created
+   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
+   */
+   let Line$1 = class Line {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The position of the start of the line.
+       */
+       from, 
+       /**
+       The position at the end of the line (_before_ the line break,
+       or at the end of document for the last line).
+       */
+       to, 
+       /**
+       This line's line number (1-based).
+       */
+       number, 
+       /**
+       The line's content.
+       */
+       text) {
+           this.from = from;
+           this.to = to;
+           this.number = number;
+           this.text = text;
+       }
+       /**
+       The length of the line (not including any line break after it).
+       */
+       get length() { return this.to - this.from; }
+   };
+
+   // Compressed representation of the Grapheme_Cluster_Break=Extend
+   // information from
+   // http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
+   // Each pair of elements represents a range, as an offet from the
+   // previous range and a length. Numbers are in base-36, with the empty
+   // string being a shorthand for 1.
+   let extend = /*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
+   // Convert offsets into absolute values
+   for (let i = 1; i < extend.length; i++)
+       extend[i] += extend[i - 1];
+   function isExtendingChar$1(code) {
+       for (let i = 1; i < extend.length; i += 2)
+           if (extend[i] > code)
+               return extend[i - 1] <= code;
+       return false;
+   }
+   function isRegionalIndicator$1(code) {
+       return code >= 0x1F1E6 && code <= 0x1F1FF;
+   }
+   const ZWJ$1 = 0x200d;
+   /**
+   Returns a next grapheme cluster break _after_ (not equal to)
+   `pos`, if `forward` is true, or before otherwise. Returns `pos`
+   itself if no further cluster break is available in the string.
+   Moves across surrogate pairs, extending characters (when
+   `includeExtending` is true), characters joined with zero-width
+   joiners, and flag emoji.
+   */
+   function findClusterBreak$2(str, pos, forward = true, includeExtending = true) {
+       return (forward ? nextClusterBreak$1 : prevClusterBreak$1)(str, pos, includeExtending);
+   }
+   function nextClusterBreak$1(str, pos, includeExtending) {
+       if (pos == str.length)
+           return pos;
+       // If pos is in the middle of a surrogate pair, move to its start
+       if (pos && surrogateLow$2(str.charCodeAt(pos)) && surrogateHigh$2(str.charCodeAt(pos - 1)))
+           pos--;
+       let prev = codePointAt$2(str, pos);
+       pos += codePointSize$2(prev);
+       while (pos < str.length) {
+           let next = codePointAt$2(str, pos);
+           if (prev == ZWJ$1 || next == ZWJ$1 || includeExtending && isExtendingChar$1(next)) {
+               pos += codePointSize$2(next);
+               prev = next;
+           }
+           else if (isRegionalIndicator$1(next)) {
+               let countBefore = 0, i = pos - 2;
+               while (i >= 0 && isRegionalIndicator$1(codePointAt$2(str, i))) {
+                   countBefore++;
+                   i -= 2;
+               }
+               if (countBefore % 2 == 0)
+                   break;
+               else
+                   pos += 2;
+           }
+           else {
+               break;
+           }
+       }
+       return pos;
+   }
+   function prevClusterBreak$1(str, pos, includeExtending) {
+       while (pos > 0) {
+           let found = nextClusterBreak$1(str, pos - 2, includeExtending);
+           if (found < pos)
+               return found;
+           pos--;
+       }
+       return 0;
+   }
+   function surrogateLow$2(ch) { return ch >= 0xDC00 && ch < 0xE000; }
+   function surrogateHigh$2(ch) { return ch >= 0xD800 && ch < 0xDC00; }
+   /**
+   Find the code point at the given position in a string (like the
+   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
+   string method).
+   */
+   function codePointAt$2(str, pos) {
+       let code0 = str.charCodeAt(pos);
+       if (!surrogateHigh$2(code0) || pos + 1 == str.length)
+           return code0;
+       let code1 = str.charCodeAt(pos + 1);
+       if (!surrogateLow$2(code1))
+           return code0;
+       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
+   }
+   /**
+   Given a Unicode codepoint, return the JavaScript string that
+   respresents it (like
+   [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
+   */
+   function fromCodePoint$1(code) {
+       if (code <= 0xffff)
+           return String.fromCharCode(code);
+       code -= 0x10000;
+       return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
+   }
+   /**
+   The first character that takes up two positions in a JavaScript
+   string. It is often useful to compare with this after calling
+   `codePointAt`, to figure out whether your character takes up 1 or
+   2 index positions.
+   */
+   function codePointSize$2(code) { return code < 0x10000 ? 1 : 2; }
+
+   const DefaultSplit$1 = /\r\n?|\n/;
+   /**
+   Distinguishes different ways in which positions can be mapped.
+   */
+   var MapMode$1 = /*@__PURE__*/(function (MapMode) {
+       /**
+       Map a position to a valid new position, even when its context
+       was deleted.
+       */
+       MapMode[MapMode["Simple"] = 0] = "Simple";
+       /**
+       Return null if deletion happens across the position.
+       */
+       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
+       /**
+       Return null if the character _before_ the position is deleted.
+       */
+       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
+       /**
+       Return null if the character _after_ the position is deleted.
+       */
+       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
+   return MapMode})(MapMode$1 || (MapMode$1 = {}));
+   /**
+   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
+   that doesn't store the inserted text. As such, it can't be
+   applied, but is cheaper to store and manipulate.
+   */
+   let ChangeDesc$1 = class ChangeDesc {
+       // Sections are encoded as pairs of integers. The first is the
+       // length in the current document, and the second is -1 for
+       // unaffected sections, and the length of the replacement content
+       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
+       // 0), and a replacement two positive numbers.
+       constructor(
+       /**
+       @internal
+       */
+       sections) {
+           this.sections = sections;
+       }
+       /**
+       The length of the document before the change.
+       */
+       get length() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2)
+               result += this.sections[i];
+           return result;
+       }
+       /**
+       The length of the document after the change.
+       */
+       get newLength() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let ins = this.sections[i + 1];
+               result += ins < 0 ? this.sections[i] : ins;
+           }
+           return result;
+       }
+       /**
+       False when there are actual changes in this set.
+       */
+       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
+       /**
+       Iterate over the unchanged parts left by these changes. `posA`
+       provides the position of the range in the old document, `posB`
+       the new position in the changed document.
+       */
+       iterGaps(f) {
+           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0) {
+                   f(posA, posB, len);
+                   posB += len;
+               }
+               else {
+                   posB += ins;
+               }
+               posA += len;
+           }
+       }
+       /**
+       Iterate over the ranges changed by these changes. (See
+       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
+       variant that also provides you with the inserted text.)
+       `fromA`/`toA` provides the extent of the change in the starting
+       document, `fromB`/`toB` the extent of the replacement in the
+       changed document.
+       
+       When `individual` is true, adjacent changes (which are kept
+       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
+       reported separately.
+       */
+       iterChangedRanges(f, individual = false) {
+           iterChanges$1(this, f, individual);
+       }
+       /**
+       Get a description of the inverted form of these changes.
+       */
+       get invertedDesc() {
+           let sections = [];
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0)
+                   sections.push(len, ins);
+               else
+                   sections.push(ins, len);
+           }
+           return new ChangeDesc(sections);
+       }
+       /**
+       Compute the combined effect of applying another set of changes
+       after this one. The length of the document after this set should
+       match the length before `other`.
+       */
+       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets$1(this, other); }
+       /**
+       Map this description, which should start with the same document
+       as `other`, over another set of changes, so that it can be
+       applied after it. When `before` is true, map as if the changes
+       in `other` happened before the ones in `this`.
+       */
+       mapDesc(other, before = false) { return other.empty ? this : mapSet$1(this, other, before); }
+       mapPos(pos, assoc = -1, mode = MapMode$1.Simple) {
+           let posA = 0, posB = 0;
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
+               if (ins < 0) {
+                   if (endA > pos)
+                       return posB + (pos - posA);
+                   posB += len;
+               }
+               else {
+                   if (mode != MapMode$1.Simple && endA >= pos &&
+                       (mode == MapMode$1.TrackDel && posA < pos && endA > pos ||
+                           mode == MapMode$1.TrackBefore && posA < pos ||
+                           mode == MapMode$1.TrackAfter && endA > pos))
+                       return null;
+                   if (endA > pos || endA == pos && assoc < 0 && !len)
+                       return pos == posA || assoc < 0 ? posB : posB + ins;
+                   posB += ins;
+               }
+               posA = endA;
+           }
+           if (pos > posA)
+               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
+           return posB;
+       }
+       /**
+       Check whether these changes touch a given range. When one of the
+       changes entirely covers the range, the string `"cover"` is
+       returned.
+       */
+       touchesRange(from, to = from) {
+           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
+               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
+               if (ins >= 0 && pos <= to && end >= from)
+                   return pos < from && end > to ? "cover" : true;
+               pos = end;
+           }
+           return false;
+       }
+       /**
+       @internal
+       */
+       toString() {
+           let result = "";
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
+           }
+           return result;
+       }
+       /**
+       Serialize this change desc to a JSON-representable value.
+       */
+       toJSON() { return this.sections; }
+       /**
+       Create a change desc from its JSON representation (as produced
+       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
+               throw new RangeError("Invalid JSON representation of ChangeDesc");
+           return new ChangeDesc(json);
+       }
+       /**
+       @internal
+       */
+       static create(sections) { return new ChangeDesc(sections); }
+   };
+   /**
+   A change set represents a group of modifications to a document. It
+   stores the document length, and can only be applied to documents
+   with exactly that length.
+   */
+   let ChangeSet$1 = class ChangeSet extends ChangeDesc$1 {
+       constructor(sections, 
+       /**
+       @internal
+       */
+       inserted) {
+           super(sections);
+           this.inserted = inserted;
+       }
+       /**
+       Apply the changes to a document, returning the modified
+       document.
+       */
+       apply(doc) {
+           if (this.length != doc.length)
+               throw new RangeError("Applying change set to a document with the wrong length");
+           iterChanges$1(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
+           return doc;
+       }
+       mapDesc(other, before = false) { return mapSet$1(this, other, before, true); }
+       /**
+       Given the document as it existed _before_ the changes, return a
+       change set that represents the inverse of this set, which could
+       be used to go from the document created by the changes back to
+       the document as it existed before the changes.
+       */
+       invert(doc) {
+           let sections = this.sections.slice(), inserted = [];
+           for (let i = 0, pos = 0; i < sections.length; i += 2) {
+               let len = sections[i], ins = sections[i + 1];
+               if (ins >= 0) {
+                   sections[i] = ins;
+                   sections[i + 1] = len;
+                   let index = i >> 1;
+                   while (inserted.length < index)
+                       inserted.push(Text$1.empty);
+                   inserted.push(len ? doc.slice(pos, pos + len) : Text$1.empty);
+               }
+               pos += len;
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       Combine two subsequent change sets into a single set. `other`
+       must start in the document produced by `this`. If `this` goes
+       `docA` → `docB` and `other` represents `docB` → `docC`, the
+       returned value will represent the change `docA` → `docC`.
+       */
+       compose(other) { return this.empty ? other : other.empty ? this : composeSets$1(this, other, true); }
+       /**
+       Given another change set starting in the same document, maps this
+       change set over the other, producing a new change set that can be
+       applied to the document produced by applying `other`. When
+       `before` is `true`, order changes as if `this` comes before
+       `other`, otherwise (the default) treat `other` as coming first.
+       
+       Given two changes `A` and `B`, `A.compose(B.map(A))` and
+       `B.compose(A.map(B, true))` will produce the same document. This
+       provides a basic form of [operational
+       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
+       and can be used for collaborative editing.
+       */
+       map(other, before = false) { return other.empty ? this : mapSet$1(this, other, before, true); }
+       /**
+       Iterate over the changed ranges in the document, calling `f` for
+       each, with the range in the original document (`fromA`-`toA`)
+       and the range that replaces it in the new document
+       (`fromB`-`toB`).
+       
+       When `individual` is true, adjacent changes are reported
+       separately.
+       */
+       iterChanges(f, individual = false) {
+           iterChanges$1(this, f, individual);
+       }
+       /**
+       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
+       set.
+       */
+       get desc() { return ChangeDesc$1.create(this.sections); }
+       /**
+       @internal
+       */
+       filter(ranges) {
+           let resultSections = [], resultInserted = [], filteredSections = [];
+           let iter = new SectionIter$1(this);
+           done: for (let i = 0, pos = 0;;) {
+               let next = i == ranges.length ? 1e9 : ranges[i++];
+               while (pos < next || pos == next && iter.len == 0) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, next - pos);
+                   addSection$1(filteredSections, len, -1);
+                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
+                   addSection$1(resultSections, len, ins);
+                   if (ins > 0)
+                       addInsert$1(resultInserted, resultSections, iter.text);
+                   iter.forward(len);
+                   pos += len;
+               }
+               let end = ranges[i++];
+               while (pos < end) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, end - pos);
+                   addSection$1(resultSections, len, -1);
+                   addSection$1(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
+                   iter.forward(len);
+                   pos += len;
+               }
+           }
+           return { changes: new ChangeSet(resultSections, resultInserted),
+               filtered: ChangeDesc$1.create(filteredSections) };
+       }
+       /**
+       Serialize this change set to a JSON-representable value.
+       */
+       toJSON() {
+           let parts = [];
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let len = this.sections[i], ins = this.sections[i + 1];
+               if (ins < 0)
+                   parts.push(len);
+               else if (ins == 0)
+                   parts.push([len]);
+               else
+                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
+           }
+           return parts;
+       }
+       /**
+       Create a change set for the given changes, for a document of the
+       given length, using `lineSep` as line separator.
+       */
+       static of(changes, length, lineSep) {
+           let sections = [], inserted = [], pos = 0;
+           let total = null;
+           function flush(force = false) {
+               if (!force && !sections.length)
+                   return;
+               if (pos < length)
+                   addSection$1(sections, length - pos, -1);
+               let set = new ChangeSet(sections, inserted);
+               total = total ? total.compose(set.map(total)) : set;
+               sections = [];
+               inserted = [];
+               pos = 0;
+           }
+           function process(spec) {
+               if (Array.isArray(spec)) {
+                   for (let sub of spec)
+                       process(sub);
+               }
+               else if (spec instanceof ChangeSet) {
+                   if (spec.length != length)
+                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
+                   flush();
+                   total = total ? total.compose(spec.map(total)) : spec;
+               }
+               else {
+                   let { from, to = from, insert } = spec;
+                   if (from > to || from < 0 || to > length)
+                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
+                   let insText = !insert ? Text$1.empty : typeof insert == "string" ? Text$1.of(insert.split(lineSep || DefaultSplit$1)) : insert;
+                   let insLen = insText.length;
+                   if (from == to && insLen == 0)
+                       return;
+                   if (from < pos)
+                       flush();
+                   if (from > pos)
+                       addSection$1(sections, from - pos, -1);
+                   addSection$1(sections, to - from, insLen);
+                   addInsert$1(inserted, sections, insText);
+                   pos = to;
+               }
+           }
+           process(changes);
+           flush(!total);
+           return total;
+       }
+       /**
+       Create an empty changeset of the given length.
+       */
+       static empty(length) {
+           return new ChangeSet(length ? [length, -1] : [], []);
+       }
+       /**
+       Create a changeset from its JSON representation (as produced by
+       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json))
+               throw new RangeError("Invalid JSON representation of ChangeSet");
+           let sections = [], inserted = [];
+           for (let i = 0; i < json.length; i++) {
+               let part = json[i];
+               if (typeof part == "number") {
+                   sections.push(part, -1);
+               }
+               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
+                   throw new RangeError("Invalid JSON representation of ChangeSet");
+               }
+               else if (part.length == 1) {
+                   sections.push(part[0], 0);
+               }
+               else {
+                   while (inserted.length < i)
+                       inserted.push(Text$1.empty);
+                   inserted[i] = Text$1.of(part.slice(1));
+                   sections.push(part[0], inserted[i].length);
+               }
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       @internal
+       */
+       static createSet(sections, inserted) {
+           return new ChangeSet(sections, inserted);
+       }
+   };
+   function addSection$1(sections, len, ins, forceJoin = false) {
+       if (len == 0 && ins <= 0)
+           return;
+       let last = sections.length - 2;
+       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
+           sections[last] += len;
+       else if (len == 0 && sections[last] == 0)
+           sections[last + 1] += ins;
+       else if (forceJoin) {
+           sections[last] += len;
+           sections[last + 1] += ins;
+       }
+       else
+           sections.push(len, ins);
+   }
+   function addInsert$1(values, sections, value) {
+       if (value.length == 0)
+           return;
+       let index = (sections.length - 2) >> 1;
+       if (index < values.length) {
+           values[values.length - 1] = values[values.length - 1].append(value);
+       }
+       else {
+           while (values.length < index)
+               values.push(Text$1.empty);
+           values.push(value);
+       }
+   }
+   function iterChanges$1(desc, f, individual) {
+       let inserted = desc.inserted;
+       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
+           let len = desc.sections[i++], ins = desc.sections[i++];
+           if (ins < 0) {
+               posA += len;
+               posB += len;
+           }
+           else {
+               let endA = posA, endB = posB, text = Text$1.empty;
+               for (;;) {
+                   endA += len;
+                   endB += ins;
+                   if (ins && inserted)
+                       text = text.append(inserted[(i - 2) >> 1]);
+                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
+                       break;
+                   len = desc.sections[i++];
+                   ins = desc.sections[i++];
+               }
+               f(posA, endA, posB, endB, text);
+               posA = endA;
+               posB = endB;
+           }
+       }
+   }
+   function mapSet$1(setA, setB, before, mkSet = false) {
+       let sections = [], insert = mkSet ? [] : null;
+       let a = new SectionIter$1(setA), b = new SectionIter$1(setB);
+       for (let posA = 0, posB = 0;;) {
+           if (a.ins == -1) {
+               posA += a.len;
+               a.next();
+           }
+           else if (b.ins == -1 && posB < posA) {
+               let skip = Math.min(b.len, posA - posB);
+               b.forward(skip);
+               addSection$1(sections, skip, -1);
+               posB += skip;
+           }
+           else if (b.ins >= 0 && (a.done || posB < posA || posB == posA && (b.len < a.len || b.len == a.len && !before))) {
+               addSection$1(sections, b.ins, -1);
+               while (posA > posB && !a.done && posA + a.len < posB + b.len) {
+                   posA += a.len;
+                   a.next();
+               }
+               posB += b.len;
+               b.next();
+           }
+           else if (a.ins >= 0) {
+               let len = 0, end = posA + a.len;
+               for (;;) {
+                   if (b.ins >= 0 && posB > posA && posB + b.len < end) {
+                       len += b.ins;
+                       posB += b.len;
+                       b.next();
+                   }
+                   else if (b.ins == -1 && posB < end) {
+                       let skip = Math.min(b.len, end - posB);
+                       len += skip;
+                       b.forward(skip);
+                       posB += skip;
+                   }
+                   else {
+                       break;
+                   }
+               }
+               addSection$1(sections, len, a.ins);
+               if (insert)
+                   addInsert$1(insert, sections, a.text);
+               posA = end;
+               a.next();
+           }
+           else if (a.done && b.done) {
+               return insert ? ChangeSet$1.createSet(sections, insert) : ChangeDesc$1.create(sections);
+           }
+           else {
+               throw new Error("Mismatched change set lengths");
+           }
+       }
+   }
+   function composeSets$1(setA, setB, mkSet = false) {
+       let sections = [];
+       let insert = mkSet ? [] : null;
+       let a = new SectionIter$1(setA), b = new SectionIter$1(setB);
+       for (let open = false;;) {
+           if (a.done && b.done) {
+               return insert ? ChangeSet$1.createSet(sections, insert) : ChangeDesc$1.create(sections);
+           }
+           else if (a.ins == 0) { // Deletion in A
+               addSection$1(sections, a.len, 0, open);
+               a.next();
+           }
+           else if (b.len == 0 && !b.done) { // Insertion in B
+               addSection$1(sections, 0, b.ins, open);
+               if (insert)
+                   addInsert$1(insert, sections, b.text);
+               b.next();
+           }
+           else if (a.done || b.done) {
+               throw new Error("Mismatched change set lengths");
+           }
+           else {
+               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
+               if (a.ins == -1) {
+                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
+                   addSection$1(sections, len, insB, open);
+                   if (insert && insB)
+                       addInsert$1(insert, sections, b.text);
+               }
+               else if (b.ins == -1) {
+                   addSection$1(sections, a.off ? 0 : a.len, len, open);
+                   if (insert)
+                       addInsert$1(insert, sections, a.textBit(len));
+               }
+               else {
+                   addSection$1(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
+                   if (insert && !b.off)
+                       addInsert$1(insert, sections, b.text);
+               }
+               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
+               a.forward2(len);
+               b.forward(len);
+           }
+       }
+   }
+   let SectionIter$1 = class SectionIter {
+       constructor(set) {
+           this.set = set;
+           this.i = 0;
+           this.next();
+       }
+       next() {
+           let { sections } = this.set;
+           if (this.i < sections.length) {
+               this.len = sections[this.i++];
+               this.ins = sections[this.i++];
+           }
+           else {
+               this.len = 0;
+               this.ins = -2;
+           }
+           this.off = 0;
+       }
+       get done() { return this.ins == -2; }
+       get len2() { return this.ins < 0 ? this.len : this.ins; }
+       get text() {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length ? Text$1.empty : inserted[index];
+       }
+       textBit(len) {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length && !len ? Text$1.empty
+               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
+       }
+       forward(len) {
+           if (len == this.len)
+               this.next();
+           else {
+               this.len -= len;
+               this.off += len;
+           }
+       }
+       forward2(len) {
+           if (this.ins == -1)
+               this.forward(len);
+           else if (len == this.ins)
+               this.next();
+           else {
+               this.ins -= len;
+               this.off += len;
+           }
+       }
+   };
+
+   /**
+   A single selection range. When
+   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
+   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
+   multiple ranges. By default, selections hold exactly one range.
+   */
+   let SelectionRange$1 = class SelectionRange {
+       constructor(
+       /**
+       The lower boundary of the range.
+       */
+       from, 
+       /**
+       The upper boundary of the range.
+       */
+       to, flags) {
+           this.from = from;
+           this.to = to;
+           this.flags = flags;
+       }
+       /**
+       The anchor of the range—the side that doesn't move when you
+       extend it.
+       */
+       get anchor() { return this.flags & 16 /* Inverted */ ? 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 & 16 /* Inverted */ ? 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 & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
+       /**
+       The bidirectional text level associated with this cursor, if
+       any.
+       */
+       get bidiLevel() {
+           let level = this.flags & 3 /* BidiLevelMask */;
+           return level == 3 ? null : level;
+       }
+       /**
+       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 value = this.flags >> 5 /* GoalColumnOffset */;
+           return value == 33554431 /* NoGoalColumn */ ? undefined : value;
+       }
+       /**
+       Map this range through a change, producing a valid range in the
+       updated document.
+       */
+       map(change, assoc = -1) {
+           let from, to;
+           if (this.empty) {
+               from = to = change.mapPos(this.from, assoc);
+           }
+           else {
+               from = change.mapPos(this.from, 1);
+               to = change.mapPos(this.to, -1);
+           }
+           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
+       }
+       /**
+       Extend this range to cover at least `from` to `to`.
+       */
+       extend(from, to = from) {
+           if (from <= this.anchor && to >= this.anchor)
+               return EditorSelection$1.range(from, to);
+           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
+           return EditorSelection$1.range(this.anchor, head);
+       }
+       /**
+       Compare this range to another range.
+       */
+       eq(other) {
+           return this.anchor == other.anchor && this.head == other.head;
+       }
+       /**
+       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(json) {
+           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
+               throw new RangeError("Invalid JSON representation for SelectionRange");
+           return EditorSelection$1.range(json.anchor, json.head);
+       }
+       /**
+       @internal
+       */
+       static create(from, to, flags) {
+           return new SelectionRange(from, to, flags);
+       }
+   };
+   /**
+   An editor selection holds one or more selection ranges.
+   */
+   let EditorSelection$1 = class EditorSelection {
+       constructor(
+       /**
+       The ranges in the selection, sorted by position. Ranges cannot
+       overlap (but they may touch, if they aren't empty).
+       */
+       ranges, 
+       /**
+       The index of the _main_ range in the selection (which is
+       usually the range that was added last).
+       */
+       mainIndex) {
+           this.ranges = ranges;
+           this.mainIndex = mainIndex;
+       }
+       /**
+       Map a selection through a change. Used to adjust the selection
+       position for changes.
+       */
+       map(change, assoc = -1) {
+           if (change.empty)
+               return this;
+           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
+       }
+       /**
+       Compare this selection to another selection.
+       */
+       eq(other) {
+           if (this.ranges.length != other.ranges.length ||
+               this.mainIndex != other.mainIndex)
+               return false;
+           for (let i = 0; i < this.ranges.length; i++)
+               if (!this.ranges[i].eq(other.ranges[i]))
+                   return false;
+           return true;
+       }
+       /**
+       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 EditorSelection([this.main], 0);
+       }
+       /**
+       Extend this selection with an extra range.
+       */
+       addRange(range, main = true) {
+           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
+       }
+       /**
+       Replace a given range with another range, and then normalize the
+       selection to merge and sort ranges if necessary.
+       */
+       replaceRange(range, which = this.mainIndex) {
+           let ranges = this.ranges.slice();
+           ranges[which] = range;
+           return EditorSelection.create(ranges, this.mainIndex);
+       }
+       /**
+       Convert this selection to an object that can be serialized to
+       JSON.
+       */
+       toJSON() {
+           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
+       }
+       /**
+       Create a selection from a JSON representation.
+       */
+       static fromJSON(json) {
+           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
+               throw new RangeError("Invalid JSON representation for EditorSelection");
+           return new EditorSelection(json.ranges.map((r) => SelectionRange$1.fromJSON(r)), json.main);
+       }
+       /**
+       Create a selection holding a single range.
+       */
+       static single(anchor, head = anchor) {
+           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
+       }
+       /**
+       Sort and merge the given set of ranges, creating a valid
+       selection.
+       */
+       static create(ranges, mainIndex = 0) {
+           if (ranges.length == 0)
+               throw new RangeError("A selection needs at least one range");
+           for (let pos = 0, i = 0; i < ranges.length; i++) {
+               let range = ranges[i];
+               if (range.empty ? range.from <= pos : range.from < pos)
+                   return EditorSelection.normalized(ranges.slice(), mainIndex);
+               pos = range.to;
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+       /**
+       Create a cursor selection range at the given position. You can
+       safely ignore the optional arguments in most situations.
+       */
+       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
+           return SelectionRange$1.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
+               (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
+               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
+       }
+       /**
+       Create a selection range.
+       */
+       static range(anchor, head, goalColumn) {
+           let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
+           return head < anchor ? SelectionRange$1.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
+               : SelectionRange$1.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
+       }
+       /**
+       @internal
+       */
+       static normalized(ranges, mainIndex = 0) {
+           let main = ranges[mainIndex];
+           ranges.sort((a, b) => a.from - b.from);
+           mainIndex = ranges.indexOf(main);
+           for (let i = 1; i < ranges.length; i++) {
+               let range = ranges[i], prev = ranges[i - 1];
+               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
+                   let from = prev.from, to = Math.max(range.to, prev.to);
+                   if (i <= mainIndex)
+                       mainIndex--;
+                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
+               }
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+   };
+   function checkSelection$1(selection, docLength) {
+       for (let range of selection.ranges)
+           if (range.to > docLength)
+               throw new RangeError("Selection points outside of document");
+   }
+
+   let nextID$1 = 0;
+   /**
+   A facet is a labeled value that is associated with an editor
+   state. It takes inputs from any number of extensions, and combines
+   those into a single output value.
+
+   Examples of uses of facets are the [tab
+   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
+   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
+   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
+   */
+   let Facet$1 = class Facet {
+       constructor(
+       /**
+       @internal
+       */
+       combine, 
+       /**
+       @internal
+       */
+       compareInput, 
+       /**
+       @internal
+       */
+       compare, isStatic, 
+       /**
+       @internal
+       */
+       extensions) {
+           this.combine = combine;
+           this.compareInput = compareInput;
+           this.compare = compare;
+           this.isStatic = isStatic;
+           this.extensions = extensions;
+           /**
+           @internal
+           */
+           this.id = nextID$1++;
+           this.default = combine([]);
+       }
+       /**
+       Define a new facet.
+       */
+       static define(config = {}) {
+           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$2 : (a, b) => a === b), !!config.static, config.enables);
+       }
+       /**
+       Returns an extension that adds the given value to this facet.
+       */
+       of(value) {
+           return new FacetProvider$1([], this, 0 /* Static */, value);
+       }
+       /**
+       Create an extension that computes a value for the facet from a
+       state. You must take care to declare the parts of the state that
+       this value depends on, since your function is only called again
+       for a new state when one of those parts changed.
+       
+       In cases where your value depends only on a single field, you'll
+       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
+       */
+       compute(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider$1(deps, this, 1 /* Single */, get);
+       }
+       /**
+       Create an extension that computes zero or more values for this
+       facet from a state.
+       */
+       computeN(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider$1(deps, this, 2 /* Multi */, get);
+       }
+       from(field, get) {
+           if (!get)
+               get = x => x;
+           return this.compute([field], state => get(state.field(field)));
+       }
+   };
+   function sameArray$2(a, b) {
+       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
+   }
+   let FacetProvider$1 = class FacetProvider {
+       constructor(dependencies, facet, type, value) {
+           this.dependencies = dependencies;
+           this.facet = facet;
+           this.type = type;
+           this.value = value;
+           this.id = nextID$1++;
+       }
+       dynamicSlot(addresses) {
+           var _a;
+           let getter = this.value;
+           let compare = this.facet.compareInput;
+           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
+           let depDoc = false, depSel = false, depAddrs = [];
+           for (let dep of this.dependencies) {
+               if (dep == "doc")
+                   depDoc = true;
+               else if (dep == "selection")
+                   depSel = true;
+               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
+                   depAddrs.push(addresses[dep.id]);
+           }
+           return {
+               create(state) {
+                   state.values[idx] = getter(state);
+                   return 1 /* Changed */;
+               },
+               update(state, tr) {
+                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll$1(state, depAddrs)) {
+                       let newVal = getter(state);
+                       if (multi ? !compareArray$1(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
+                           state.values[idx] = newVal;
+                           return 1 /* Changed */;
+                       }
+                   }
+                   return 0;
+               },
+               reconfigure: (state, oldState) => {
+                   let newVal = getter(state);
+                   let oldAddr = oldState.config.address[id];
+                   if (oldAddr != null) {
+                       let oldVal = getAddr$1(oldState, oldAddr);
+                       if (this.dependencies.every(dep => {
+                           return dep instanceof Facet$1 ? oldState.facet(dep) === state.facet(dep) :
+                               dep instanceof StateField$1 ? oldState.field(dep, false) == state.field(dep, false) : true;
+                       }) || (multi ? compareArray$1(newVal, oldVal, compare) : compare(newVal, oldVal))) {
+                           state.values[idx] = oldVal;
+                           return 0;
+                       }
+                   }
+                   state.values[idx] = newVal;
+                   return 1 /* Changed */;
+               }
+           };
+       }
+   };
+   function compareArray$1(a, b, compare) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (!compare(a[i], b[i]))
+               return false;
+       return true;
+   }
+   function ensureAll$1(state, addrs) {
+       let changed = false;
+       for (let addr of addrs)
+           if (ensureAddr$1(state, addr) & 1 /* Changed */)
+               changed = true;
+       return changed;
+   }
+   function dynamicFacetSlot$1(addresses, facet, providers) {
+       let providerAddrs = providers.map(p => addresses[p.id]);
+       let providerTypes = providers.map(p => p.type);
+       let dynamic = providerAddrs.filter(p => !(p & 1));
+       let idx = addresses[facet.id] >> 1;
+       function get(state) {
+           let values = [];
+           for (let i = 0; i < providerAddrs.length; i++) {
+               let value = getAddr$1(state, providerAddrs[i]);
+               if (providerTypes[i] == 2 /* Multi */)
+                   for (let val of value)
+                       values.push(val);
+               else
+                   values.push(value);
+           }
+           return facet.combine(values);
+       }
+       return {
+           create(state) {
+               for (let addr of providerAddrs)
+                   ensureAddr$1(state, addr);
+               state.values[idx] = get(state);
+               return 1 /* Changed */;
+           },
+           update(state, tr) {
+               if (!ensureAll$1(state, dynamic))
+                   return 0;
+               let value = get(state);
+               if (facet.compare(value, state.values[idx]))
+                   return 0;
+               state.values[idx] = value;
+               return 1 /* Changed */;
+           },
+           reconfigure(state, oldState) {
+               let depChanged = ensureAll$1(state, providerAddrs);
+               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
+               if (oldProviders && !depChanged && sameArray$2(providers, oldProviders)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               let value = get(state);
+               if (facet.compare(value, oldValue)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               state.values[idx] = value;
+               return 1 /* Changed */;
+           }
+       };
+   }
+   const initField$1 = /*@__PURE__*/Facet$1.define({ static: true });
+   /**
+   Fields can store additional information in an editor state, and
+   keep it in sync with the rest of the state.
+   */
+   let StateField$1 = class StateField {
+       constructor(
+       /**
+       @internal
+       */
+       id, createF, updateF, compareF, 
+       /**
+       @internal
+       */
+       spec) {
+           this.id = id;
+           this.createF = createF;
+           this.updateF = updateF;
+           this.compareF = compareF;
+           this.spec = spec;
+           /**
+           @internal
+           */
+           this.provides = undefined;
+       }
+       /**
+       Define a state field.
+       */
+       static define(config) {
+           let field = new StateField(nextID$1++, config.create, config.update, config.compare || ((a, b) => a === b), config);
+           if (config.provide)
+               field.provides = config.provide(field);
+           return field;
+       }
+       create(state) {
+           let init = state.facet(initField$1).find(i => i.field == this);
+           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
+       }
+       /**
+       @internal
+       */
+       slot(addresses) {
+           let idx = addresses[this.id] >> 1;
+           return {
+               create: (state) => {
+                   state.values[idx] = this.create(state);
+                   return 1 /* Changed */;
+               },
+               update: (state, tr) => {
+                   let oldVal = state.values[idx];
+                   let value = this.updateF(oldVal, tr);
+                   if (this.compareF(oldVal, value))
+                       return 0;
+                   state.values[idx] = value;
+                   return 1 /* Changed */;
+               },
+               reconfigure: (state, oldState) => {
+                   if (oldState.config.address[this.id] != null) {
+                       state.values[idx] = oldState.field(this);
+                       return 0;
+                   }
+                   state.values[idx] = this.create(state);
+                   return 1 /* Changed */;
+               }
+           };
+       }
+       /**
+       Returns an extension that enables this field and overrides the
+       way it is initialized. Can be useful when you need to provide a
+       non-default starting value for the field.
+       */
+       init(create) {
+           return [this, initField$1.of({ field: this, create })];
+       }
+       /**
+       State field instances can be used as
+       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
+       given state.
+       */
+       get extension() { return this; }
+   };
+   const Prec_$1 = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
+   function prec$1(value) {
+       return (ext) => new PrecExtension$1(ext, value);
+   }
+   /**
+   By default extensions are registered in the order they are found
+   in the flattened form of nested array that was provided.
+   Individual extension values can be assigned a precedence to
+   override this. Extensions that do not have a precedence set get
+   the precedence of the nearest parent with a precedence, or
+   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
+   final ordering of extensions is determined by first sorting by
+   precedence and then by order within each precedence.
+   */
+   const Prec$1 = {
+       /**
+       The highest precedence level, for extensions that should end up
+       near the start of the precedence ordering.
+       */
+       highest: /*@__PURE__*/prec$1(Prec_$1.highest),
+       /**
+       A higher-than-default precedence, for extensions that should
+       come before those with default precedence.
+       */
+       high: /*@__PURE__*/prec$1(Prec_$1.high),
+       /**
+       The default precedence, which is also used for extensions
+       without an explicit precedence.
+       */
+       default: /*@__PURE__*/prec$1(Prec_$1.default),
+       /**
+       A lower-than-default precedence.
+       */
+       low: /*@__PURE__*/prec$1(Prec_$1.low),
+       /**
+       The lowest precedence level. Meant for things that should end up
+       near the end of the extension order.
+       */
+       lowest: /*@__PURE__*/prec$1(Prec_$1.lowest)
+   };
+   let PrecExtension$1 = class PrecExtension {
+       constructor(inner, prec) {
+           this.inner = inner;
+           this.prec = prec;
+       }
+   };
+   /**
+   Extension compartments can be used to make a configuration
+   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
+   configuration in a compartment, you can later
+   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
+   transaction.
+   */
+   let Compartment$1 = class Compartment {
+       /**
+       Create an instance of this compartment to add to your [state
+       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
+       */
+       of(ext) { return new CompartmentInstance$1(this, ext); }
+       /**
+       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
+       reconfigures this compartment.
+       */
+       reconfigure(content) {
+           return Compartment.reconfigure.of({ compartment: this, extension: content });
+       }
+       /**
+       Get the current content of the compartment in the state, or
+       `undefined` if it isn't present.
+       */
+       get(state) {
+           return state.config.compartments.get(this);
+       }
+   };
+   let CompartmentInstance$1 = class CompartmentInstance {
+       constructor(compartment, inner) {
+           this.compartment = compartment;
+           this.inner = inner;
+       }
+   };
+   let Configuration$1 = class Configuration {
+       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
+           this.base = base;
+           this.compartments = compartments;
+           this.dynamicSlots = dynamicSlots;
+           this.address = address;
+           this.staticValues = staticValues;
+           this.facets = facets;
+           this.statusTemplate = [];
+           while (this.statusTemplate.length < dynamicSlots.length)
+               this.statusTemplate.push(0 /* Unresolved */);
+       }
+       staticFacet(facet) {
+           let addr = this.address[facet.id];
+           return addr == null ? facet.default : this.staticValues[addr >> 1];
+       }
+       static resolve(base, compartments, oldState) {
+           let fields = [];
+           let facets = Object.create(null);
+           let newCompartments = new Map();
+           for (let ext of flatten$1(base, compartments, newCompartments)) {
+               if (ext instanceof StateField$1)
+                   fields.push(ext);
+               else
+                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
+           }
+           let address = Object.create(null);
+           let staticValues = [];
+           let dynamicSlots = [];
+           for (let field of fields) {
+               address[field.id] = dynamicSlots.length << 1;
+               dynamicSlots.push(a => field.slot(a));
+           }
+           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
+           for (let id in facets) {
+               let providers = facets[id], facet = providers[0].facet;
+               let oldProviders = oldFacets && oldFacets[id] || [];
+               if (providers.every(p => p.type == 0 /* Static */)) {
+                   address[facet.id] = (staticValues.length << 1) | 1;
+                   if (sameArray$2(oldProviders, providers)) {
+                       staticValues.push(oldState.facet(facet));
+                   }
+                   else {
+                       let value = facet.combine(providers.map(p => p.value));
+                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
+                   }
+               }
+               else {
+                   for (let p of providers) {
+                       if (p.type == 0 /* Static */) {
+                           address[p.id] = (staticValues.length << 1) | 1;
+                           staticValues.push(p.value);
+                       }
+                       else {
+                           address[p.id] = dynamicSlots.length << 1;
+                           dynamicSlots.push(a => p.dynamicSlot(a));
+                       }
+                   }
+                   address[facet.id] = dynamicSlots.length << 1;
+                   dynamicSlots.push(a => dynamicFacetSlot$1(a, facet, providers));
+               }
+           }
+           let dynamic = dynamicSlots.map(f => f(address));
+           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
+       }
+   };
+   function flatten$1(extension, compartments, newCompartments) {
+       let result = [[], [], [], [], []];
+       let seen = new Map();
+       function inner(ext, prec) {
+           let known = seen.get(ext);
+           if (known != null) {
+               if (known <= prec)
+                   return;
+               let found = result[known].indexOf(ext);
+               if (found > -1)
+                   result[known].splice(found, 1);
+               if (ext instanceof CompartmentInstance$1)
+                   newCompartments.delete(ext.compartment);
+           }
+           seen.set(ext, prec);
+           if (Array.isArray(ext)) {
+               for (let e of ext)
+                   inner(e, prec);
+           }
+           else if (ext instanceof CompartmentInstance$1) {
+               if (newCompartments.has(ext.compartment))
+                   throw new RangeError(`Duplicate use of compartment in extensions`);
+               let content = compartments.get(ext.compartment) || ext.inner;
+               newCompartments.set(ext.compartment, content);
+               inner(content, prec);
+           }
+           else if (ext instanceof PrecExtension$1) {
+               inner(ext.inner, ext.prec);
+           }
+           else if (ext instanceof StateField$1) {
+               result[prec].push(ext);
+               if (ext.provides)
+                   inner(ext.provides, prec);
+           }
+           else if (ext instanceof FacetProvider$1) {
+               result[prec].push(ext);
+               if (ext.facet.extensions)
+                   inner(ext.facet.extensions, prec);
+           }
+           else {
+               let content = ext.extension;
+               if (!content)
+                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
+               inner(content, prec);
+           }
+       }
+       inner(extension, Prec_$1.default);
+       return result.reduce((a, b) => a.concat(b));
+   }
+   function ensureAddr$1(state, addr) {
+       if (addr & 1)
+           return 2 /* Computed */;
+       let idx = addr >> 1;
+       let status = state.status[idx];
+       if (status == 4 /* Computing */)
+           throw new Error("Cyclic dependency between fields and/or facets");
+       if (status & 2 /* Computed */)
+           return status;
+       state.status[idx] = 4 /* Computing */;
+       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
+       return state.status[idx] = 2 /* Computed */ | changed;
+   }
+   function getAddr$1(state, addr) {
+       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
+   }
+
+   const languageData$1 = /*@__PURE__*/Facet$1.define();
+   const allowMultipleSelections$1 = /*@__PURE__*/Facet$1.define({
+       combine: values => values.some(v => v),
+       static: true
+   });
+   const lineSeparator$1 = /*@__PURE__*/Facet$1.define({
+       combine: values => values.length ? values[0] : undefined,
+       static: true
+   });
+   const changeFilter$1 = /*@__PURE__*/Facet$1.define();
+   const transactionFilter$1 = /*@__PURE__*/Facet$1.define();
+   const transactionExtender$1 = /*@__PURE__*/Facet$1.define();
+   const readOnly$1 = /*@__PURE__*/Facet$1.define({
+       combine: values => values.length ? values[0] : false
+   });
+
+   /**
+   Annotations are tagged values that are used to add metadata to
+   transactions in an extensible way. They should be used to model
+   things that effect the entire transaction (such as its [time
+   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
+   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
+   _alongside_ the other changes made by the transaction, [state
+   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
+   */
+   let Annotation$1 = class Annotation {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The annotation type.
+       */
+       type, 
+       /**
+       The value of this annotation.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Define a new type of annotation.
+       */
+       static define() { return new AnnotationType$1(); }
+   };
+   /**
+   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
+   */
+   let AnnotationType$1 = class AnnotationType {
+       /**
+       Create an instance of this annotation.
+       */
+       of(value) { return new Annotation$1(this, value); }
+   };
+   /**
+   Representation of a type of state effect. Defined with
+   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
+   */
+   let StateEffectType$1 = class StateEffectType {
+       /**
+       @internal
+       */
+       constructor(
+       // The `any` types in these function types are there to work
+       // around TypeScript issue #37631, where the type guard on
+       // `StateEffect.is` mysteriously stops working when these properly
+       // have type `Value`.
+       /**
+       @internal
+       */
+       map) {
+           this.map = map;
+       }
+       /**
+       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
+       type.
+       */
+       of(value) { return new StateEffect$1(this, value); }
+   };
+   /**
+   State effects can be used to represent additional effects
+   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
+   are often useful to model changes to custom [state
+   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
+   document or selection changes.
+   */
+   let StateEffect$1 = class StateEffect {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       @internal
+       */
+       type, 
+       /**
+       The value of this effect.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Map this effect through a position mapping. Will return
+       `undefined` when that ends up deleting the effect.
+       */
+       map(mapping) {
+           let mapped = this.type.map(this.value, mapping);
+           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
+       }
+       /**
+       Tells you whether this effect object is of a given
+       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
+       */
+       is(type) { return this.type == type; }
+       /**
+       Define a new effect type. The type parameter indicates the type
+       of values that his effect holds.
+       */
+       static define(spec = {}) {
+           return new StateEffectType$1(spec.map || (v => v));
+       }
+       /**
+       Map an array of effects through a change set.
+       */
+       static mapEffects(effects, mapping) {
+           if (!effects.length)
+               return effects;
+           let result = [];
+           for (let effect of effects) {
+               let mapped = effect.map(mapping);
+               if (mapped)
+                   result.push(mapped);
+           }
+           return result;
+       }
+   };
+   /**
+   This effect can be used to reconfigure the root extensions of
+   the editor. Doing this will discard any extensions
+   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
+   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
+   compartments.
+   */
+   StateEffect$1.reconfigure = /*@__PURE__*/StateEffect$1.define();
+   /**
+   Append extensions to the top-level configuration of the editor.
+   */
+   StateEffect$1.appendConfig = /*@__PURE__*/StateEffect$1.define();
+   /**
+   Changes to the editor state are grouped into transactions.
+   Typically, a user action creates a single transaction, which may
+   contain any number of document changes, may change the selection,
+   or have other effects. Create a transaction by calling
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
+   dispatch one by calling
+   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
+   */
+   let Transaction$1 = class Transaction {
+       constructor(
+       /**
+       The state from which the transaction starts.
+       */
+       startState, 
+       /**
+       The document changes made by this transaction.
+       */
+       changes, 
+       /**
+       The selection set by this transaction, or undefined if it
+       doesn't explicitly set a selection.
+       */
+       selection, 
+       /**
+       The effects added to the transaction.
+       */
+       effects, 
+       /**
+       @internal
+       */
+       annotations, 
+       /**
+       Whether the selection should be scrolled into view after this
+       transaction is dispatched.
+       */
+       scrollIntoView) {
+           this.startState = startState;
+           this.changes = changes;
+           this.selection = selection;
+           this.effects = effects;
+           this.annotations = annotations;
+           this.scrollIntoView = scrollIntoView;
+           /**
+           @internal
+           */
+           this._doc = null;
+           /**
+           @internal
+           */
+           this._state = null;
+           if (selection)
+               checkSelection$1(selection, changes.newLength);
+           if (!annotations.some((a) => a.type == Transaction.time))
+               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
+       }
+       /**
+       @internal
+       */
+       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
+           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
+       }
+       /**
+       The new document produced by the transaction. Contrary to
+       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
+       force the entire new state to be computed right away, so it is
+       recommended that [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
+       when they need to look at the new document.
+       */
+       get newDoc() {
+           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
+       }
+       /**
+       The new selection produced by the transaction. If
+       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
+       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
+       current selection through the changes made by the transaction.
+       */
+       get newSelection() {
+           return this.selection || this.startState.selection.map(this.changes);
+       }
+       /**
+       The new state created by the transaction. Computed on demand
+       (but retained for subsequent access), so it is recommended not to
+       access it in [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
+       */
+       get state() {
+           if (!this._state)
+               this.startState.applyTransaction(this);
+           return this._state;
+       }
+       /**
+       Get the value of the given annotation type, if any.
+       */
+       annotation(type) {
+           for (let ann of this.annotations)
+               if (ann.type == type)
+                   return ann.value;
+           return undefined;
+       }
+       /**
+       Indicates whether the transaction changed the document.
+       */
+       get docChanged() { return !this.changes.empty; }
+       /**
+       Indicates whether this transaction reconfigures the state
+       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
+       with a top-level configuration
+       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
+       */
+       get reconfigured() { return this.startState.config != this.state.config; }
+       /**
+       Returns true if the transaction has a [user
+       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
+       or more specific than `event`. For example, if the transaction
+       has `"select.pointer"` as user event, `"select"` and
+       `"select.pointer"` will match it.
+       */
+       isUserEvent(event) {
+           let e = this.annotation(Transaction.userEvent);
+           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
+       }
+   };
+   /**
+   Annotation used to store transaction timestamps. Automatically
+   added to every transaction, holding `Date.now()`.
+   */
+   Transaction$1.time = /*@__PURE__*/Annotation$1.define();
+   /**
+   Annotation used to associate a transaction with a user interface
+   event. Holds a string identifying the event, using a
+   dot-separated format to support attaching more specific
+   information. The events used by the core libraries are:
+
+    - `"input"` when content is entered
+      - `"input.type"` for typed input
+        - `"input.type.compose"` for composition
+      - `"input.paste"` for pasted input
+      - `"input.drop"` when adding content with drag-and-drop
+      - `"input.complete"` when autocompleting
+    - `"delete"` when the user deletes content
+      - `"delete.selection"` when deleting the selection
+      - `"delete.forward"` when deleting forward from the selection
+      - `"delete.backward"` when deleting backward from the selection
+      - `"delete.cut"` when cutting to the clipboard
+    - `"move"` when content is moved
+      - `"move.drop"` when content is moved within the editor through drag-and-drop
+    - `"select"` when explicitly changing the selection
+      - `"select.pointer"` when selecting with a mouse or other pointing device
+    - `"undo"` and `"redo"` for history actions
+
+   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
+   whether the annotation matches a given event.
+   */
+   Transaction$1.userEvent = /*@__PURE__*/Annotation$1.define();
+   /**
+   Annotation indicating whether a transaction should be added to
+   the undo history or not.
+   */
+   Transaction$1.addToHistory = /*@__PURE__*/Annotation$1.define();
+   /**
+   Annotation indicating (when present and true) that a transaction
+   represents a change made by some other actor, not the user. This
+   is used, for example, to tag other people's changes in
+   collaborative editing.
+   */
+   Transaction$1.remote = /*@__PURE__*/Annotation$1.define();
+   function joinRanges$1(a, b) {
+       let result = [];
+       for (let iA = 0, iB = 0;;) {
+           let from, to;
+           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
+               from = a[iA++];
+               to = a[iA++];
+           }
+           else if (iB < b.length) {
+               from = b[iB++];
+               to = b[iB++];
+           }
+           else
+               return result;
+           if (!result.length || result[result.length - 1] < from)
+               result.push(from, to);
+           else if (result[result.length - 1] < to)
+               result[result.length - 1] = to;
+       }
+   }
+   function mergeTransaction$1(a, b, sequential) {
+       var _a;
+       let mapForA, mapForB, changes;
+       if (sequential) {
+           mapForA = b.changes;
+           mapForB = ChangeSet$1.empty(b.changes.length);
+           changes = a.changes.compose(b.changes);
+       }
+       else {
+           mapForA = b.changes.map(a.changes);
+           mapForB = a.changes.mapDesc(b.changes, true);
+           changes = a.changes.compose(mapForA);
+       }
+       return {
+           changes,
+           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
+           effects: StateEffect$1.mapEffects(a.effects, mapForA).concat(StateEffect$1.mapEffects(b.effects, mapForB)),
+           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
+           scrollIntoView: a.scrollIntoView || b.scrollIntoView
+       };
+   }
+   function resolveTransactionInner$1(state, spec, docSize) {
+       let sel = spec.selection, annotations = asArray$2(spec.annotations);
+       if (spec.userEvent)
+           annotations = annotations.concat(Transaction$1.userEvent.of(spec.userEvent));
+       return {
+           changes: spec.changes instanceof ChangeSet$1 ? spec.changes
+               : ChangeSet$1.of(spec.changes || [], docSize, state.facet(lineSeparator$1)),
+           selection: sel && (sel instanceof EditorSelection$1 ? sel : EditorSelection$1.single(sel.anchor, sel.head)),
+           effects: asArray$2(spec.effects),
+           annotations,
+           scrollIntoView: !!spec.scrollIntoView
+       };
+   }
+   function resolveTransaction$1(state, specs, filter) {
+       let s = resolveTransactionInner$1(state, specs.length ? specs[0] : {}, state.doc.length);
+       if (specs.length && specs[0].filter === false)
+           filter = false;
+       for (let i = 1; i < specs.length; i++) {
+           if (specs[i].filter === false)
+               filter = false;
+           let seq = !!specs[i].sequential;
+           s = mergeTransaction$1(s, resolveTransactionInner$1(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
+       }
+       let tr = Transaction$1.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
+       return extendTransaction$1(filter ? filterTransaction$1(tr) : tr);
+   }
+   // Finish a transaction by applying filters if necessary.
+   function filterTransaction$1(tr) {
+       let state = tr.startState;
+       // Change filters
+       let result = true;
+       for (let filter of state.facet(changeFilter$1)) {
+           let value = filter(tr);
+           if (value === false) {
+               result = false;
+               break;
+           }
+           if (Array.isArray(value))
+               result = result === true ? value : joinRanges$1(result, value);
+       }
+       if (result !== true) {
+           let changes, back;
+           if (result === false) {
+               back = tr.changes.invertedDesc;
+               changes = ChangeSet$1.empty(state.doc.length);
+           }
+           else {
+               let filtered = tr.changes.filter(result);
+               changes = filtered.changes;
+               back = filtered.filtered.invertedDesc;
+           }
+           tr = Transaction$1.create(state, changes, tr.selection && tr.selection.map(back), StateEffect$1.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
+       }
+       // Transaction filters
+       let filters = state.facet(transactionFilter$1);
+       for (let i = filters.length - 1; i >= 0; i--) {
+           let filtered = filters[i](tr);
+           if (filtered instanceof Transaction$1)
+               tr = filtered;
+           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction$1)
+               tr = filtered[0];
+           else
+               tr = resolveTransaction$1(state, asArray$2(filtered), false);
+       }
+       return tr;
+   }
+   function extendTransaction$1(tr) {
+       let state = tr.startState, extenders = state.facet(transactionExtender$1), spec = tr;
+       for (let i = extenders.length - 1; i >= 0; i--) {
+           let extension = extenders[i](tr);
+           if (extension && Object.keys(extension).length)
+               spec = mergeTransaction$1(tr, resolveTransactionInner$1(state, extension, tr.changes.newLength), true);
+       }
+       return spec == tr ? tr : Transaction$1.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
+   }
+   const none$3 = [];
+   function asArray$2(value) {
+       return value == null ? none$3 : Array.isArray(value) ? value : [value];
+   }
+
+   /**
+   The categories produced by a [character
+   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
+   do things like selecting by word.
+   */
+   var CharCategory$1 = /*@__PURE__*/(function (CharCategory) {
+       /**
+       Word characters.
+       */
+       CharCategory[CharCategory["Word"] = 0] = "Word";
+       /**
+       Whitespace.
+       */
+       CharCategory[CharCategory["Space"] = 1] = "Space";
+       /**
+       Anything else.
+       */
+       CharCategory[CharCategory["Other"] = 2] = "Other";
+   return CharCategory})(CharCategory$1 || (CharCategory$1 = {}));
+   const nonASCIISingleCaseWordChar$1 = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
+   let wordChar$1;
+   try {
+       wordChar$1 = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
+   }
+   catch (_) { }
+   function hasWordChar$1(str) {
+       if (wordChar$1)
+           return wordChar$1.test(str);
+       for (let i = 0; i < str.length; i++) {
+           let ch = str[i];
+           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar$1.test(ch)))
+               return true;
+       }
+       return false;
+   }
+   function makeCategorizer$1(wordChars) {
+       return (char) => {
+           if (!/\S/.test(char))
+               return CharCategory$1.Space;
+           if (hasWordChar$1(char))
+               return CharCategory$1.Word;
+           for (let i = 0; i < wordChars.length; i++)
+               if (char.indexOf(wordChars[i]) > -1)
+                   return CharCategory$1.Word;
+           return CharCategory$1.Other;
+       };
+   }
+
+   /**
+   The editor state class is a persistent (immutable) data structure.
+   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
+   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
+   instance, without modifying the original object.
+
+   As such, _never_ mutate properties of a state directly. That'll
+   just break things.
+   */
+   let EditorState$1 = class EditorState {
+       constructor(
+       /**
+       @internal
+       */
+       config, 
+       /**
+       The current document.
+       */
+       doc, 
+       /**
+       The current selection.
+       */
+       selection, 
+       /**
+       @internal
+       */
+       values, computeSlot, tr) {
+           this.config = config;
+           this.doc = doc;
+           this.selection = selection;
+           this.values = values;
+           this.status = config.statusTemplate.slice();
+           this.computeSlot = computeSlot;
+           // Fill in the computed state immediately, so that further queries
+           // for it made during the update return this state
+           if (tr)
+               tr._state = this;
+           for (let i = 0; i < this.config.dynamicSlots.length; i++)
+               ensureAddr$1(this, i << 1);
+           this.computeSlot = null;
+       }
+       field(field, require = true) {
+           let addr = this.config.address[field.id];
+           if (addr == null) {
+               if (require)
+                   throw new RangeError("Field is not present in this state");
+               return undefined;
+           }
+           ensureAddr$1(this, addr);
+           return getAddr$1(this, addr);
+       }
+       /**
+       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
+       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
+       can be passed. Unless
+       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
+       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
+       are assumed to start in the _current_ document (not the document
+       produced by previous specs), and its
+       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
+       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
+       to the document created by its _own_ changes. The resulting
+       transaction contains the combined effect of all the different
+       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
+       specs take precedence over earlier ones.
+       */
+       update(...specs) {
+           return resolveTransaction$1(this, specs, true);
+       }
+       /**
+       @internal
+       */
+       applyTransaction(tr) {
+           let conf = this.config, { base, compartments } = conf;
+           for (let effect of tr.effects) {
+               if (effect.is(Compartment$1.reconfigure)) {
+                   if (conf) {
+                       compartments = new Map;
+                       conf.compartments.forEach((val, key) => compartments.set(key, val));
+                       conf = null;
+                   }
+                   compartments.set(effect.value.compartment, effect.value.extension);
+               }
+               else if (effect.is(StateEffect$1.reconfigure)) {
+                   conf = null;
+                   base = effect.value;
+               }
+               else if (effect.is(StateEffect$1.appendConfig)) {
+                   conf = null;
+                   base = asArray$2(base).concat(effect.value);
+               }
+           }
+           let startValues;
+           if (!conf) {
+               conf = Configuration$1.resolve(base, compartments, this);
+               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
+               startValues = intermediateState.values;
+           }
+           else {
+               startValues = tr.startState.values.slice();
+           }
+           new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
+       }
+       /**
+       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
+       replaces every selection range with the given content.
+       */
+       replaceSelection(text) {
+           if (typeof text == "string")
+               text = this.toText(text);
+           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
+               range: EditorSelection$1.cursor(range.from + text.length) }));
+       }
+       /**
+       Create a set of changes and a new selection by running the given
+       function for each range in the active selection. The function
+       can return an optional set of changes (in the coordinate space
+       of the start document), plus an updated range (in the coordinate
+       space of the document produced by the call's own changes). This
+       method will merge all the changes and ranges into a single
+       changeset and selection, and return it as a [transaction
+       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
+       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
+       */
+       changeByRange(f) {
+           let sel = this.selection;
+           let result1 = f(sel.ranges[0]);
+           let changes = this.changes(result1.changes), ranges = [result1.range];
+           let effects = asArray$2(result1.effects);
+           for (let i = 1; i < sel.ranges.length; i++) {
+               let result = f(sel.ranges[i]);
+               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
+               for (let j = 0; j < i; j++)
+                   ranges[j] = ranges[j].map(newMapped);
+               let mapBy = changes.mapDesc(newChanges, true);
+               ranges.push(result.range.map(mapBy));
+               changes = changes.compose(newMapped);
+               effects = StateEffect$1.mapEffects(effects, newMapped).concat(StateEffect$1.mapEffects(asArray$2(result.effects), mapBy));
+           }
+           return {
+               changes,
+               selection: EditorSelection$1.create(ranges, sel.mainIndex),
+               effects
+           };
+       }
+       /**
+       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
+       description, taking the state's document length and line
+       separator into account.
+       */
+       changes(spec = []) {
+           if (spec instanceof ChangeSet$1)
+               return spec;
+           return ChangeSet$1.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
+       }
+       /**
+       Using the state's [line
+       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
+       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
+       */
+       toText(string) {
+           return Text$1.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit$1));
+       }
+       /**
+       Return the given range of the document as a string.
+       */
+       sliceDoc(from = 0, to = this.doc.length) {
+           return this.doc.sliceString(from, to, this.lineBreak);
+       }
+       /**
+       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
+       */
+       facet(facet) {
+           let addr = this.config.address[facet.id];
+           if (addr == null)
+               return facet.default;
+           ensureAddr$1(this, addr);
+           return getAddr$1(this, addr);
+       }
+       /**
+       Convert this state to a JSON-serializable object. When custom
+       fields should be serialized, you can pass them in as an object
+       mapping property names (in the resulting object, which should
+       not use `doc` or `selection`) to fields.
+       */
+       toJSON(fields) {
+           let result = {
+               doc: this.sliceDoc(),
+               selection: this.selection.toJSON()
+           };
+           if (fields)
+               for (let prop in fields) {
+                   let value = fields[prop];
+                   if (value instanceof StateField$1)
+                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
+               }
+           return result;
+       }
+       /**
+       Deserialize a state from its JSON representation. When custom
+       fields should be deserialized, pass the same object you passed
+       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
+       third argument.
+       */
+       static fromJSON(json, config = {}, fields) {
+           if (!json || typeof json.doc != "string")
+               throw new RangeError("Invalid JSON representation for EditorState");
+           let fieldInit = [];
+           if (fields)
+               for (let prop in fields) {
+                   let field = fields[prop], value = json[prop];
+                   fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
+               }
+           return EditorState.create({
+               doc: json.doc,
+               selection: EditorSelection$1.fromJSON(json.selection),
+               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
+           });
+       }
+       /**
+       Create a new state. You'll usually only need this when
+       initializing an editor—updated states are created by applying
+       transactions.
+       */
+       static create(config = {}) {
+           let configuration = Configuration$1.resolve(config.extensions || [], new Map);
+           let doc = config.doc instanceof Text$1 ? config.doc
+               : Text$1.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit$1));
+           let selection = !config.selection ? EditorSelection$1.single(0)
+               : config.selection instanceof EditorSelection$1 ? config.selection
+                   : EditorSelection$1.single(config.selection.anchor, config.selection.head);
+           checkSelection$1(selection, doc.length);
+           if (!configuration.staticFacet(allowMultipleSelections$1))
+               selection = selection.asSingle();
+           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
+       }
+       /**
+       The size (in columns) of a tab in the document, determined by
+       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
+       */
+       get tabSize() { return this.facet(EditorState.tabSize); }
+       /**
+       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
+       string for this state.
+       */
+       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
+       /**
+       Returns true when the editor is
+       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
+       */
+       get readOnly() { return this.facet(readOnly$1); }
+       /**
+       Look up a translation for the given phrase (via the
+       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
+       original string if no translation is found.
+       
+       If additional arguments are passed, they will be inserted in
+       place of markers like `$1` (for the first value) and `$2`, etc.
+       A single `$` is equivalent to `$1`, and `$$` will produce a
+       literal dollar sign.
+       */
+       phrase(phrase, ...insert) {
+           for (let map of this.facet(EditorState.phrases))
+               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
+                   phrase = map[phrase];
+                   break;
+               }
+           if (insert.length)
+               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
+                   if (i == "$")
+                       return "$";
+                   let n = +(i || 1);
+                   return n > insert.length ? m : insert[n - 1];
+               });
+           return phrase;
+       }
+       /**
+       Find the values for a given language data field, provided by the
+       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
+       */
+       languageDataAt(name, pos, side = -1) {
+           let values = [];
+           for (let provider of this.facet(languageData$1)) {
+               for (let result of provider(this, pos, side)) {
+                   if (Object.prototype.hasOwnProperty.call(result, name))
+                       values.push(result[name]);
+               }
+           }
+           return values;
+       }
+       /**
+       Return a function that can categorize strings (expected to
+       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
+       into one of:
+       
+        - Word (contains an alphanumeric character or a character
+          explicitly listed in the local language's `"wordChars"`
+          language data, which should be a string)
+        - Space (contains only whitespace)
+        - Other (anything else)
+       */
+       charCategorizer(at) {
+           return makeCategorizer$1(this.languageDataAt("wordChars", at).join(""));
+       }
+       /**
+       Find the word at the given position, meaning the range
+       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
+       around it. If no word characters are adjacent to the position,
+       this returns null.
+       */
+       wordAt(pos) {
+           let { text, from, length } = this.doc.lineAt(pos);
+           let cat = this.charCategorizer(pos);
+           let start = pos - from, end = pos - from;
+           while (start > 0) {
+               let prev = findClusterBreak$2(text, start, false);
+               if (cat(text.slice(prev, start)) != CharCategory$1.Word)
+                   break;
+               start = prev;
+           }
+           while (end < length) {
+               let next = findClusterBreak$2(text, end);
+               if (cat(text.slice(end, next)) != CharCategory$1.Word)
+                   break;
+               end = next;
+           }
+           return start == end ? null : EditorSelection$1.range(start + from, end + from);
+       }
+   };
+   /**
+   A facet that, when enabled, causes the editor to allow multiple
+   ranges to be selected. Be careful though, because by default the
+   editor relies on the native DOM selection, which cannot handle
+   multiple selections. An extension like
+   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
+   secondary selections visible to the user.
+   */
+   EditorState$1.allowMultipleSelections = allowMultipleSelections$1;
+   /**
+   Configures the tab size to use in this state. The first
+   (highest-precedence) value of the facet is used. If no value is
+   given, this defaults to 4.
+   */
+   EditorState$1.tabSize = /*@__PURE__*/Facet$1.define({
+       combine: values => values.length ? values[0] : 4
+   });
+   /**
+   The line separator to use. By default, any of `"\n"`, `"\r\n"`
+   and `"\r"` is treated as a separator when splitting lines, and
+   lines are joined with `"\n"`.
+
+   When you configure a value here, only that precise separator
+   will be used, allowing you to round-trip documents through the
+   editor without normalizing line separators.
+   */
+   EditorState$1.lineSeparator = lineSeparator$1;
+   /**
+   This facet controls the value of the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
+   consulted by commands and extensions that implement editing
+   functionality to determine whether they should apply. It
+   defaults to false, but when its highest-precedence value is
+   `true`, such functionality disables itself.
+
+   Not to be confused with
+   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
+   controls whether the editor's DOM is set to be editable (and
+   thus focusable).
+   */
+   EditorState$1.readOnly = readOnly$1;
+   /**
+   Registers translation phrases. The
+   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
+   all objects registered with this facet to find translations for
+   its argument.
+   */
+   EditorState$1.phrases = /*@__PURE__*/Facet$1.define({
+       compare(a, b) {
+           let kA = Object.keys(a), kB = Object.keys(b);
+           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
+       }
+   });
+   /**
+   A facet used to register [language
+   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
+   */
+   EditorState$1.languageData = languageData$1;
+   /**
+   Facet used to register change filters, which are called for each
+   transaction (unless explicitly
+   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
+   part of the transaction's changes.
+
+   Such a function can return `true` to indicate that it doesn't
+   want to do anything, `false` to completely stop the changes in
+   the transaction, or a set of ranges in which changes should be
+   suppressed. Such ranges are represented as an array of numbers,
+   with each pair of two numbers indicating the start and end of a
+   range. So for example `[10, 20, 100, 110]` suppresses changes
+   between 10 and 20, and between 100 and 110.
+   */
+   EditorState$1.changeFilter = changeFilter$1;
+   /**
+   Facet used to register a hook that gets a chance to update or
+   replace transaction specs before they are applied. This will
+   only be applied for transactions that don't have
+   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
+   can either return a single transaction spec (possibly the input
+   transaction), or an array of specs (which will be combined in
+   the same way as the arguments to
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
+
+   When possible, it is recommended to avoid accessing
+   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
+   since it will force creation of a state that will then be
+   discarded again, if the transaction is actually filtered.
+
+   (This functionality should be used with care. Indiscriminately
+   modifying transaction is likely to break something or degrade
+   the user experience.)
+   */
+   EditorState$1.transactionFilter = transactionFilter$1;
+   /**
+   This is a more limited form of
+   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
+   which can only add
+   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
+   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
+   of filter runs even if the transaction has disabled regular
+   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
+   for effects that don't need to touch the changes or selection,
+   but do want to process every transaction.
+
+   Extenders run _after_ filters, when both are present.
+   */
+   EditorState$1.transactionExtender = transactionExtender$1;
+   Compartment$1.reconfigure = /*@__PURE__*/StateEffect$1.define();
+
+   /**
+   Utility function for combining behaviors to fill in a config
+   object from an array of provided configs. `defaults` should hold
+   default values for all optional fields in `Config`.
+
+   The function will, by default, error
+   when a field gets two values that aren't `===`-equal, but you can
+   provide combine functions per field to do something else.
+   */
+   function combineConfig$1(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
+   combine = {}) {
+       let result = {};
+       for (let config of configs)
+           for (let key of Object.keys(config)) {
+               let value = config[key], current = result[key];
+               if (current === undefined)
+                   result[key] = value;
+               else if (current === value || value === undefined) ; // No conflict
+               else if (Object.hasOwnProperty.call(combine, key))
+                   result[key] = combine[key](current, value);
+               else
+                   throw new Error("Config merge conflict for field " + key);
+           }
+       for (let key in defaults)
+           if (result[key] === undefined)
+               result[key] = defaults[key];
+       return result;
+   }
+
+   /**
+   Each range is associated with a value, which must inherit from
+   this class.
+   */
+   let RangeValue$1 = class RangeValue {
+       /**
+       Compare this value with another value. Used when comparing
+       rangesets. The default implementation compares by identity.
+       Unless you are only creating a fixed number of unique instances
+       of your value type, it is a good idea to implement this
+       properly.
+       */
+       eq(other) { return this == other; }
+       /**
+       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
+       */
+       range(from, to = from) { return Range$2.create(from, to, this); }
+   };
+   RangeValue$1.prototype.startSide = RangeValue$1.prototype.endSide = 0;
+   RangeValue$1.prototype.point = false;
+   RangeValue$1.prototype.mapMode = MapMode$1.TrackDel;
+   /**
+   A range associates a value with a range of positions.
+   */
+   let Range$2 = class Range {
+       constructor(
+       /**
+       The range's start position.
+       */
+       from, 
+       /**
+       Its end position.
+       */
+       to, 
+       /**
+       The value associated with this range.
+       */
+       value) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+       }
+       /**
+       @internal
+       */
+       static create(from, to, value) {
+           return new Range(from, to, value);
+       }
+   };
+   function cmpRange$1(a, b) {
+       return a.from - b.from || a.value.startSide - b.value.startSide;
+   }
+   let Chunk$1 = class Chunk {
+       constructor(from, to, value, 
+       // Chunks are marked with the largest point that occurs
+       // in them (or -1 for no points), so that scans that are
+       // only interested in points (such as the
+       // heightmap-related logic) can skip range-only chunks.
+       maxPoint) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+           this.maxPoint = maxPoint;
+       }
+       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(pos, side, end, startAt = 0) {
+           let arr = end ? this.to : this.from;
+           for (let lo = startAt, hi = arr.length;;) {
+               if (lo == hi)
+                   return lo;
+               let mid = (lo + hi) >> 1;
+               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
+               if (mid == lo)
+                   return diff >= 0 ? lo : hi;
+               if (diff >= 0)
+                   hi = mid;
+               else
+                   lo = mid + 1;
+           }
+       }
+       between(offset, from, to, f) {
+           for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
+               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
+                   return false;
+       }
+       map(offset, changes) {
+           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
+           for (let i = 0; i < this.value.length; i++) {
+               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
+               if (curFrom == curTo) {
+                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
+                   if (mapped == null)
+                       continue;
+                   newFrom = newTo = mapped;
+                   if (val.startSide != val.endSide) {
+                       newTo = changes.mapPos(curFrom, val.endSide);
+                       if (newTo < newFrom)
+                           continue;
+                   }
+               }
+               else {
+                   newFrom = changes.mapPos(curFrom, val.startSide);
+                   newTo = changes.mapPos(curTo, val.endSide);
+                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
+                       continue;
+               }
+               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
+                   continue;
+               if (newPos < 0)
+                   newPos = newFrom;
+               if (val.point)
+                   maxPoint = Math.max(maxPoint, newTo - newFrom);
+               value.push(val);
+               from.push(newFrom - newPos);
+               to.push(newTo - newPos);
+           }
+           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
+       }
+   };
+   /**
+   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
+   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
+   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
+   structure.
+   */
+   let RangeSet$1 = class RangeSet {
+       constructor(
+       /**
+       @internal
+       */
+       chunkPos, 
+       /**
+       @internal
+       */
+       chunk, 
+       /**
+       @internal
+       */
+       nextLayer, 
+       /**
+       @internal
+       */
+       maxPoint) {
+           this.chunkPos = chunkPos;
+           this.chunk = chunk;
+           this.nextLayer = nextLayer;
+           this.maxPoint = maxPoint;
+       }
+       /**
+       @internal
+       */
+       static create(chunkPos, chunk, nextLayer, maxPoint) {
+           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
+       }
+       /**
+       @internal
+       */
+       get length() {
+           let last = this.chunk.length - 1;
+           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
+       }
+       /**
+       The number of ranges in the set.
+       */
+       get size() {
+           if (this.isEmpty)
+               return 0;
+           let size = this.nextLayer.size;
+           for (let chunk of this.chunk)
+               size += chunk.value.length;
+           return size;
+       }
+       /**
+       @internal
+       */
+       chunkEnd(index) {
+           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
+           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
+           let filter = updateSpec.filter;
+           if (add.length == 0 && !filter)
+               return this;
+           if (sort)
+               add = add.slice().sort(cmpRange$1);
+           if (this.isEmpty)
+               return add.length ? RangeSet.of(add) : this;
+           let cur = new LayerCursor$1(this, null, -1).goto(0), i = 0, spill = [];
+           let builder = new RangeSetBuilder$1();
+           while (cur.value || i < add.length) {
+               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
+                   let range = add[i++];
+                   if (!builder.addInner(range.from, range.to, range.value))
+                       spill.push(range);
+               }
+               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
+                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
+                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
+                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
+                   cur.nextChunk();
+               }
+               else {
+                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
+                       if (!builder.addInner(cur.from, cur.to, cur.value))
+                           spill.push(Range$2.create(cur.from, cur.to, cur.value));
+                   }
+                   cur.next();
+               }
+           }
+           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
+               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
+       }
+       /**
+       Map this range set through a set of changes, return the new set.
+       */
+       map(changes) {
+           if (changes.empty || this.isEmpty)
+               return this;
+           let chunks = [], chunkPos = [], maxPoint = -1;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               let touch = changes.touchesRange(start, start + chunk.length);
+               if (touch === false) {
+                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
+                   chunks.push(chunk);
+                   chunkPos.push(changes.mapPos(start));
+               }
+               else if (touch === true) {
+                   let { mapped, pos } = chunk.map(start, changes);
+                   if (mapped) {
+                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
+                       chunks.push(mapped);
+                       chunkPos.push(pos);
+                   }
+               }
+           }
+           let next = this.nextLayer.map(changes);
+           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
+       }
+       /**
+       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(from, to, f) {
+           if (this.isEmpty)
+               return;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               if (to >= start && from <= start + chunk.length &&
+                   chunk.between(start, from - start, to - start, f) === false)
+                   return;
+           }
+           this.nextLayer.between(from, to, f);
+       }
+       /**
+       Iterate over the ranges in this set, in order, including all
+       ranges that end at or after `from`.
+       */
+       iter(from = 0) {
+           return HeapCursor$1.from([this]).goto(from);
+       }
+       /**
+       @internal
+       */
+       get isEmpty() { return this.nextLayer == this; }
+       /**
+       Iterate over the ranges in a collection of sets, in order,
+       starting from `from`.
+       */
+       static iter(sets, from = 0) {
+           return HeapCursor$1.from(sets).goto(from);
+       }
+       /**
+       Iterate over two groups of sets, calling methods on `comparator`
+       to notify it of possible differences.
+       */
+       static compare(oldSets, newSets, 
+       /**
+       This indicates how the underlying data changed between these
+       ranges, and is needed to synchronize the iteration. `from` and
+       `to` are coordinates in the _new_ space, after these changes.
+       */
+       textDiff, comparator, 
+       /**
+       Can be used to ignore all non-point ranges, and points below
+       the given size. When -1, all ranges are compared.
+       */
+       minPointSize = -1) {
+           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let sharedChunks = findSharedChunks$1(a, b, textDiff);
+           let sideA = new SpanCursor$1(a, sharedChunks, minPointSize);
+           let sideB = new SpanCursor$1(b, sharedChunks, minPointSize);
+           textDiff.iterGaps((fromA, fromB, length) => compare$1(sideA, fromA, sideB, fromB, length, comparator));
+           if (textDiff.empty && textDiff.length == 0)
+               compare$1(sideA, 0, sideB, 0, 0, comparator);
+       }
+       /**
+       Compare the contents of two groups of range sets, returning true
+       if they are equivalent in the given range.
+       */
+       static eq(oldSets, newSets, from = 0, to) {
+           if (to == null)
+               to = 1000000000 /* Far */;
+           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
+           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
+           if (a.length != b.length)
+               return false;
+           if (!a.length)
+               return true;
+           let sharedChunks = findSharedChunks$1(a, b);
+           let sideA = new SpanCursor$1(a, sharedChunks, 0).goto(from), sideB = new SpanCursor$1(b, sharedChunks, 0).goto(from);
+           for (;;) {
+               if (sideA.to != sideB.to ||
+                   !sameValues$1(sideA.active, sideB.active) ||
+                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
+                   return false;
+               if (sideA.to > to)
+                   return true;
+               sideA.next();
+               sideB.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(sets, from, to, iterator, 
+       /**
+       When given and greater than -1, only points of at least this
+       size are taken into account.
+       */
+       minPointSize = -1) {
+           let cursor = new SpanCursor$1(sets, null, minPointSize).goto(from), pos = from;
+           let open = cursor.openStart;
+           for (;;) {
+               let curTo = Math.min(cursor.to, to);
+               if (cursor.point) {
+                   iterator.point(pos, curTo, cursor.point, cursor.activeForPoint(cursor.to), open, cursor.pointRank);
+                   open = cursor.openEnd(curTo) + (cursor.to > curTo ? 1 : 0);
+               }
+               else if (curTo > pos) {
+                   iterator.span(pos, curTo, cursor.active, open);
+                   open = cursor.openEnd(curTo);
+               }
+               if (cursor.to > to)
+                   break;
+               pos = cursor.to;
+               cursor.next();
+           }
+           return open;
+       }
+       /**
+       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(ranges, sort = false) {
+           let build = new RangeSetBuilder$1();
+           for (let range of ranges instanceof Range$2 ? [ranges] : sort ? lazySort$1(ranges) : ranges)
+               build.add(range.from, range.to, range.value);
+           return build.finish();
+       }
+   };
+   /**
+   The empty set of ranges.
+   */
+   RangeSet$1.empty = /*@__PURE__*/new RangeSet$1([], [], null, -1);
+   function lazySort$1(ranges) {
+       if (ranges.length > 1)
+           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
+               let cur = ranges[i];
+               if (cmpRange$1(prev, cur) > 0)
+                   return ranges.slice().sort(cmpRange$1);
+               prev = cur;
+           }
+       return ranges;
+   }
+   RangeSet$1.empty.nextLayer = RangeSet$1.empty;
+   /**
+   A range set builder is a data structure that helps build up a
+   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
+   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
+   */
+   let RangeSetBuilder$1 = class RangeSetBuilder {
+       /**
+       Create an empty builder.
+       */
+       constructor() {
+           this.chunks = [];
+           this.chunkPos = [];
+           this.chunkStart = -1;
+           this.last = null;
+           this.lastFrom = -1000000000 /* Far */;
+           this.lastTo = -1000000000 /* Far */;
+           this.from = [];
+           this.to = [];
+           this.value = [];
+           this.maxPoint = -1;
+           this.setMaxPoint = -1;
+           this.nextLayer = null;
+       }
+       finishChunk(newArrays) {
+           this.chunks.push(new Chunk$1(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;
+           if (newArrays) {
+               this.from = [];
+               this.to = [];
+               this.value = [];
+           }
+       }
+       /**
+       Add a range. Ranges should be added in sorted (by `from` and
+       `value.startSide`) order.
+       */
+       add(from, to, value) {
+           if (!this.addInner(from, to, value))
+               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
+       }
+       /**
+       @internal
+       */
+       addInner(from, to, value) {
+           let diff = from - this.lastTo || value.startSide - this.last.endSide;
+           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
+               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
+           if (diff < 0)
+               return false;
+           if (this.from.length == 250 /* ChunkSize */)
+               this.finishChunk(true);
+           if (this.chunkStart < 0)
+               this.chunkStart = from;
+           this.from.push(from - this.chunkStart);
+           this.to.push(to - this.chunkStart);
+           this.last = value;
+           this.lastFrom = from;
+           this.lastTo = to;
+           this.value.push(value);
+           if (value.point)
+               this.maxPoint = Math.max(this.maxPoint, to - from);
+           return true;
+       }
+       /**
+       @internal
+       */
+       addChunk(from, chunk) {
+           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
+               return false;
+           if (this.from.length)
+               this.finishChunk(true);
+           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
+           this.chunks.push(chunk);
+           this.chunkPos.push(from);
+           let last = chunk.value.length - 1;
+           this.last = chunk.value[last];
+           this.lastFrom = chunk.from[last] + from;
+           this.lastTo = chunk.to[last] + from;
+           return true;
+       }
+       /**
+       Finish the range set. Returns the new set. The builder can't be
+       used anymore after this has been called.
+       */
+       finish() { return this.finishInner(RangeSet$1.empty); }
+       /**
+       @internal
+       */
+       finishInner(next) {
+           if (this.from.length)
+               this.finishChunk(false);
+           if (this.chunks.length == 0)
+               return next;
+           let result = RangeSet$1.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
+           this.from = null; // Make sure further `add` calls produce errors
+           return result;
+       }
+   };
+   function findSharedChunks$1(a, b, textDiff) {
+       let inA = new Map();
+       for (let set of a)
+           for (let i = 0; i < set.chunk.length; i++)
+               if (set.chunk[i].maxPoint <= 0)
+                   inA.set(set.chunk[i], set.chunkPos[i]);
+       let shared = new Set();
+       for (let set of b)
+           for (let i = 0; i < set.chunk.length; i++) {
+               let known = inA.get(set.chunk[i]);
+               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
+                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
+                   shared.add(set.chunk[i]);
+           }
+       return shared;
+   }
+   let LayerCursor$1 = class LayerCursor {
+       constructor(layer, skip, minPoint, rank = 0) {
+           this.layer = layer;
+           this.skip = skip;
+           this.minPoint = minPoint;
+           this.rank = rank;
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       get endSide() { return this.value ? this.value.endSide : 0; }
+       goto(pos, side = -1000000000 /* Far */) {
+           this.chunkIndex = this.rangeIndex = 0;
+           this.gotoInner(pos, side, false);
+           return this;
+       }
+       gotoInner(pos, side, forward) {
+           while (this.chunkIndex < this.layer.chunk.length) {
+               let next = this.layer.chunk[this.chunkIndex];
+               if (!(this.skip && this.skip.has(next) ||
+                   this.layer.chunkEnd(this.chunkIndex) < pos ||
+                   next.maxPoint < this.minPoint))
+                   break;
+               this.chunkIndex++;
+               forward = false;
+           }
+           if (this.chunkIndex < this.layer.chunk.length) {
+               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
+               if (!forward || this.rangeIndex < rangeIndex)
+                   this.setRangeIndex(rangeIndex);
+           }
+           this.next();
+       }
+       forward(pos, side) {
+           if ((this.to - pos || this.endSide - side) < 0)
+               this.gotoInner(pos, side, true);
+       }
+       next() {
+           for (;;) {
+               if (this.chunkIndex == this.layer.chunk.length) {
+                   this.from = this.to = 1000000000 /* Far */;
+                   this.value = null;
+                   break;
+               }
+               else {
+                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
+                   let from = chunkPos + chunk.from[this.rangeIndex];
+                   this.from = from;
+                   this.to = chunkPos + chunk.to[this.rangeIndex];
+                   this.value = chunk.value[this.rangeIndex];
+                   this.setRangeIndex(this.rangeIndex + 1);
+                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
+                       break;
+               }
+           }
+       }
+       setRangeIndex(index) {
+           if (index == this.layer.chunk[this.chunkIndex].value.length) {
+               this.chunkIndex++;
+               if (this.skip) {
+                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
+                       this.chunkIndex++;
+               }
+               this.rangeIndex = 0;
+           }
+           else {
+               this.rangeIndex = index;
+           }
+       }
+       nextChunk() {
+           this.chunkIndex++;
+           this.rangeIndex = 0;
+           this.next();
+       }
+       compare(other) {
+           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
+               this.to - other.to || this.endSide - other.endSide;
+       }
+   };
+   let HeapCursor$1 = class HeapCursor {
+       constructor(heap) {
+           this.heap = heap;
+       }
+       static from(sets, skip = null, minPoint = -1) {
+           let heap = [];
+           for (let i = 0; i < sets.length; i++) {
+               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
+                   if (cur.maxPoint >= minPoint)
+                       heap.push(new LayerCursor$1(cur, skip, minPoint, i));
+               }
+           }
+           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       goto(pos, side = -1000000000 /* Far */) {
+           for (let cur of this.heap)
+               cur.goto(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble$1(this.heap, i);
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           for (let cur of this.heap)
+               cur.forward(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble$1(this.heap, i);
+           if ((this.to - pos || this.value.endSide - side) < 0)
+               this.next();
+       }
+       next() {
+           if (this.heap.length == 0) {
+               this.from = this.to = 1000000000 /* Far */;
+               this.value = null;
+               this.rank = -1;
+           }
+           else {
+               let top = this.heap[0];
+               this.from = top.from;
+               this.to = top.to;
+               this.value = top.value;
+               this.rank = top.rank;
+               if (top.value)
+                   top.next();
+               heapBubble$1(this.heap, 0);
+           }
+       }
+   };
+   function heapBubble$1(heap, index) {
+       for (let cur = heap[index];;) {
+           let childIndex = (index << 1) + 1;
+           if (childIndex >= heap.length)
+               break;
+           let child = heap[childIndex];
+           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
+               child = heap[childIndex + 1];
+               childIndex++;
+           }
+           if (cur.compare(child) < 0)
+               break;
+           heap[childIndex] = cur;
+           heap[index] = child;
+           index = childIndex;
+       }
+   }
+   let SpanCursor$1 = class SpanCursor {
+       constructor(sets, skip, minPoint) {
+           this.minPoint = minPoint;
+           this.active = [];
+           this.activeTo = [];
+           this.activeRank = [];
+           this.minActive = -1;
+           // A currently active point range, if any
+           this.point = null;
+           this.pointFrom = 0;
+           this.pointRank = 0;
+           this.to = -1000000000 /* Far */;
+           this.endSide = 0;
+           this.openStart = -1;
+           this.cursor = HeapCursor$1.from(sets, skip, minPoint);
+       }
+       goto(pos, side = -1000000000 /* Far */) {
+           this.cursor.goto(pos, side);
+           this.active.length = this.activeTo.length = this.activeRank.length = 0;
+           this.minActive = -1;
+           this.to = pos;
+           this.endSide = side;
+           this.openStart = -1;
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
+               this.removeActive(this.minActive);
+           this.cursor.forward(pos, side);
+       }
+       removeActive(index) {
+           remove$1(this.active, index);
+           remove$1(this.activeTo, index);
+           remove$1(this.activeRank, index);
+           this.minActive = findMinIndex$1(this.active, this.activeTo);
+       }
+       addActive(trackOpen) {
+           let i = 0, { value, to, rank } = this.cursor;
+           while (i < this.activeRank.length && this.activeRank[i] <= rank)
+               i++;
+           insert$1(this.active, i, value);
+           insert$1(this.activeTo, i, to);
+           insert$1(this.activeRank, i, rank);
+           if (trackOpen)
+               insert$1(trackOpen, i, this.cursor.from);
+           this.minActive = findMinIndex$1(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 from = this.to, wasPoint = this.point;
+           this.point = null;
+           let trackOpen = this.openStart < 0 ? [] : null, trackExtra = 0;
+           for (;;) {
+               let a = this.minActive;
+               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
+                   if (this.activeTo[a] > from) {
+                       this.to = this.activeTo[a];
+                       this.endSide = this.active[a].endSide;
+                       break;
+                   }
+                   this.removeActive(a);
+                   if (trackOpen)
+                       remove$1(trackOpen, a);
+               }
+               else if (!this.cursor.value) {
+                   this.to = this.endSide = 1000000000 /* Far */;
+                   break;
+               }
+               else if (this.cursor.from > from) {
+                   this.to = this.cursor.from;
+                   this.endSide = this.cursor.startSide;
+                   break;
+               }
+               else {
+                   let nextVal = this.cursor.value;
+                   if (!nextVal.point) { // Opening a range
+                       this.addActive(trackOpen);
+                       this.cursor.next();
+                   }
+                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
+                       // Ignore any non-empty points that end precisely at the end of the prev point
+                       this.cursor.next();
+                   }
+                   else { // New point
+                       this.point = nextVal;
+                       this.pointFrom = this.cursor.from;
+                       this.pointRank = this.cursor.rank;
+                       this.to = this.cursor.to;
+                       this.endSide = nextVal.endSide;
+                       if (this.cursor.from < from)
+                           trackExtra = 1;
+                       this.cursor.next();
+                       this.forward(this.to, this.endSide);
+                       break;
+                   }
+               }
+           }
+           if (trackOpen) {
+               let openStart = 0;
+               while (openStart < trackOpen.length && trackOpen[openStart] < from)
+                   openStart++;
+               this.openStart = openStart + trackExtra;
+           }
+       }
+       activeForPoint(to) {
+           if (!this.active.length)
+               return this.active;
+           let active = [];
+           for (let i = this.active.length - 1; i >= 0; i--) {
+               if (this.activeRank[i] < this.pointRank)
+                   break;
+               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
+                   active.push(this.active[i]);
+           }
+           return active.reverse();
+       }
+       openEnd(to) {
+           let open = 0;
+           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
+               open++;
+           return open;
+       }
+   };
+   function compare$1(a, startA, b, startB, length, comparator) {
+       a.goto(startA);
+       b.goto(startB);
+       let endB = startB + length;
+       let pos = startB, dPos = startB - startA;
+       for (;;) {
+           let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;
+           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
+           if (a.point || b.point) {
+               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
+                   sameValues$1(a.activeForPoint(a.to + dPos), b.activeForPoint(b.to))))
+                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
+           }
+           else {
+               if (clipEnd > pos && !sameValues$1(a.active, b.active))
+                   comparator.compareRange(pos, clipEnd, a.active, b.active);
+           }
+           if (end > endB)
+               break;
+           pos = end;
+           if (diff <= 0)
+               a.next();
+           if (diff >= 0)
+               b.next();
+       }
+   }
+   function sameValues$1(a, b) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (a[i] != b[i] && !a[i].eq(b[i]))
+               return false;
+       return true;
+   }
+   function remove$1(array, index) {
+       for (let i = index, e = array.length - 1; i < e; i++)
+           array[i] = array[i + 1];
+       array.pop();
+   }
+   function insert$1(array, index, value) {
+       for (let i = array.length - 1; i >= index; i--)
+           array[i + 1] = array[i];
+       array[index] = value;
+   }
+   function findMinIndex$1(value, array) {
+       let found = -1, foundPos = 1000000000 /* Far */;
+       for (let i = 0; i < array.length; i++)
+           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
+               found = i;
+               foundPos = array[i];
+           }
+       return found;
+   }
+   /**
+   Find the offset that corresponds to the given column position in a
+   string, taking extending characters and tab size into account. By
+   default, the string length is returned when it is too short to
+   reach the column. Pass `strict` true to make it return -1 in that
+   situation.
+   */
+   function findColumn$1(string, col, tabSize, strict) {
+       for (let i = 0, n = 0;;) {
+           if (n >= col)
+               return i;
+           if (i == string.length)
+               break;
+           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
+           i = findClusterBreak$2(string, i);
+       }
+       return strict === true ? -1 : string.length;
+   }
+
+   function getSelection$1(root) {
+       let target;
+       // Browsers differ on whether shadow roots have a getSelection
+       // method. If it exists, use that, otherwise, call it on the
+       // document.
+       if (root.nodeType == 11) { // Shadow root
+           target = root.getSelection ? root : root.ownerDocument;
+       }
+       else {
+           target = root;
+       }
+       return target.getSelection();
+   }
+   function contains$1(dom, node) {
+       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
+   }
+   function deepActiveElement() {
+       let elt = document.activeElement;
+       while (elt && elt.shadowRoot)
+           elt = elt.shadowRoot.activeElement;
+       return elt;
+   }
+   function hasSelection$1(dom, selection) {
+       if (!selection.anchorNode)
+           return false;
+       try {
+           // Firefox will raise 'permission denied' errors when accessing
+           // properties of `sel.anchorNode` when it's in a generated CSS
+           // element.
+           return contains$1(dom, selection.anchorNode);
+       }
+       catch (_) {
+           return false;
+       }
+   }
+   function clientRectsFor$1(dom) {
+       if (dom.nodeType == 3)
+           return textRange$1(dom, 0, dom.nodeValue.length).getClientRects();
+       else if (dom.nodeType == 1)
+           return dom.getClientRects();
+       else
+           return [];
+   }
+   // Scans forward and backward through DOM positions equivalent to the
+   // given one to see if the two are in the same place (i.e. after a
+   // text node vs at the end of that text node)
+   function isEquivalentPosition$1(node, off, targetNode, targetOff) {
+       return targetNode ? (scanFor$1(node, off, targetNode, targetOff, -1) ||
+           scanFor$1(node, off, targetNode, targetOff, 1)) : false;
+   }
+   function domIndex$1(node) {
+       for (var index = 0;; index++) {
+           node = node.previousSibling;
+           if (!node)
+               return index;
+       }
+   }
+   function scanFor$1(node, off, targetNode, targetOff, dir) {
+       for (;;) {
+           if (node == targetNode && off == targetOff)
+               return true;
+           if (off == (dir < 0 ? 0 : maxOffset$1(node))) {
+               if (node.nodeName == "DIV")
+                   return false;
+               let parent = node.parentNode;
+               if (!parent || parent.nodeType != 1)
+                   return false;
+               off = domIndex$1(node) + (dir < 0 ? 0 : 1);
+               node = parent;
+           }
+           else if (node.nodeType == 1) {
+               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
+               if (node.nodeType == 1 && node.contentEditable == "false")
+                   return false;
+               off = dir < 0 ? maxOffset$1(node) : 0;
+           }
+           else {
+               return false;
+           }
+       }
+   }
+   function maxOffset$1(node) {
+       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
+   }
+   const Rect0 = { left: 0, right: 0, top: 0, bottom: 0 };
+   function flattenRect$1(rect, left) {
+       let x = left ? rect.left : rect.right;
+       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
+   }
+   function windowRect$1(win) {
+       return { left: 0, right: win.innerWidth,
+           top: 0, bottom: win.innerHeight };
+   }
+   function scrollRectIntoView$1(dom, rect, side, x, y, xMargin, yMargin, ltr) {
+       let doc = dom.ownerDocument, win = doc.defaultView;
+       for (let cur = dom; cur;) {
+           if (cur.nodeType == 1) { // Element
+               let bounding, top = cur == doc.body;
+               if (top) {
+                   bounding = windowRect$1(win);
+               }
+               else {
+                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
+                       cur = cur.parentNode;
+                       continue;
+                   }
+                   let rect = cur.getBoundingClientRect();
+                   // Make sure scrollbar width isn't included in the rectangle
+                   bounding = { left: rect.left, right: rect.left + cur.clientWidth,
+                       top: rect.top, bottom: rect.top + cur.clientHeight };
+               }
+               let moveX = 0, moveY = 0;
+               if (y == "nearest") {
+                   if (rect.top < bounding.top) {
+                       moveY = -(bounding.top - rect.top + yMargin);
+                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
+                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
+                   }
+                   else if (rect.bottom > bounding.bottom) {
+                       moveY = rect.bottom - bounding.bottom + yMargin;
+                       if (side < 0 && (rect.top - moveY) < bounding.top)
+                           moveY = -(bounding.top + moveY - rect.top + yMargin);
+                   }
+               }
+               else {
+                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
+                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
+                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
+                           rect.bottom - boundingHeight + yMargin;
+                   moveY = targetTop - bounding.top;
+               }
+               if (x == "nearest") {
+                   if (rect.left < bounding.left) {
+                       moveX = -(bounding.left - rect.left + xMargin);
+                       if (side > 0 && rect.right > bounding.right + moveX)
+                           moveX = rect.right - bounding.right + moveX + xMargin;
+                   }
+                   else if (rect.right > bounding.right) {
+                       moveX = rect.right - bounding.right + xMargin;
+                       if (side < 0 && rect.left < bounding.left + moveX)
+                           moveX = -(bounding.left + moveX - rect.left + xMargin);
+                   }
+               }
+               else {
+                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
+                       (x == "start") == ltr ? rect.left - xMargin :
+                           rect.right - (bounding.right - bounding.left) + xMargin;
+                   moveX = targetLeft - bounding.left;
+               }
+               if (moveX || moveY) {
+                   if (top) {
+                       win.scrollBy(moveX, moveY);
+                   }
+                   else {
+                       if (moveY) {
+                           let start = cur.scrollTop;
+                           cur.scrollTop += moveY;
+                           moveY = cur.scrollTop - start;
+                       }
+                       if (moveX) {
+                           let start = cur.scrollLeft;
+                           cur.scrollLeft += moveX;
+                           moveX = cur.scrollLeft - start;
+                       }
+                       rect = { left: rect.left - moveX, top: rect.top - moveY,
+                           right: rect.right - moveX, bottom: rect.bottom - moveY };
+                   }
+               }
+               if (top)
+                   break;
+               cur = cur.assignedSlot || cur.parentNode;
+               x = y = "nearest";
+           }
+           else if (cur.nodeType == 11) { // A shadow root
+               cur = cur.host;
+           }
+           else {
+               break;
+           }
+       }
+   }
+   let DOMSelectionState$1 = class DOMSelectionState {
+       constructor() {
+           this.anchorNode = null;
+           this.anchorOffset = 0;
+           this.focusNode = null;
+           this.focusOffset = 0;
+       }
+       eq(domSel) {
+           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
+               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
+       }
+       setRange(range) {
+           this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
+       }
+       set(anchorNode, anchorOffset, focusNode, focusOffset) {
+           this.anchorNode = anchorNode;
+           this.anchorOffset = anchorOffset;
+           this.focusNode = focusNode;
+           this.focusOffset = focusOffset;
+       }
+   };
+   let preventScrollSupported$1 = null;
+   // Feature-detects support for .focus({preventScroll: true}), and uses
+   // a fallback kludge when not supported.
+   function focusPreventScroll$1(dom) {
+       if (dom.setActive)
+           return dom.setActive(); // in IE
+       if (preventScrollSupported$1)
+           return dom.focus(preventScrollSupported$1);
+       let stack = [];
+       for (let cur = dom; cur; cur = cur.parentNode) {
+           stack.push(cur, cur.scrollTop, cur.scrollLeft);
+           if (cur == cur.ownerDocument)
+               break;
+       }
+       dom.focus(preventScrollSupported$1 == null ? {
+           get preventScroll() {
+               preventScrollSupported$1 = { preventScroll: true };
+               return true;
+           }
+       } : undefined);
+       if (!preventScrollSupported$1) {
+           preventScrollSupported$1 = false;
+           for (let i = 0; i < stack.length;) {
+               let elt = stack[i++], top = stack[i++], left = stack[i++];
+               if (elt.scrollTop != top)
+                   elt.scrollTop = top;
+               if (elt.scrollLeft != left)
+                   elt.scrollLeft = left;
+           }
+       }
+   }
+   let scratchRange$1;
+   function textRange$1(node, from, to = from) {
+       let range = scratchRange$1 || (scratchRange$1 = document.createRange());
+       range.setEnd(node, to);
+       range.setStart(node, from);
+       return range;
+   }
+   function dispatchKey$1(elt, name, code) {
+       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
+       let down = new KeyboardEvent("keydown", options);
+       down.synthetic = true;
+       elt.dispatchEvent(down);
+       let up = new KeyboardEvent("keyup", options);
+       up.synthetic = true;
+       elt.dispatchEvent(up);
+       return down.defaultPrevented || up.defaultPrevented;
+   }
+   function getRoot$1(node) {
+       while (node) {
+           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
+               return node;
+           node = node.assignedSlot || node.parentNode;
+       }
+       return null;
+   }
+   function clearAttributes$1(node) {
+       while (node.attributes.length)
+           node.removeAttributeNode(node.attributes[0]);
+   }
+
+   let DOMPos$1 = class DOMPos {
+       constructor(node, offset, precise = true) {
+           this.node = node;
+           this.offset = offset;
+           this.precise = precise;
+       }
+       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex$1(dom), precise); }
+       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex$1(dom) + 1, precise); }
+   };
+   const noChildren$1 = [];
+   let ContentView$1 = class ContentView {
+       constructor() {
+           this.parent = null;
+           this.dom = null;
+           this.dirty = 2 /* Node */;
+       }
+       get editorView() {
+           if (!this.parent)
+               throw new Error("Accessing view in orphan content view");
+           return this.parent.editorView;
+       }
+       get overrideDOMText() { return null; }
+       get posAtStart() {
+           return this.parent ? this.parent.posBefore(this) : 0;
+       }
+       get posAtEnd() {
+           return this.posAtStart + this.length;
+       }
+       posBefore(view) {
+           let pos = this.posAtStart;
+           for (let child of this.children) {
+               if (child == view)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+           throw new RangeError("Invalid child in posBefore");
+       }
+       posAfter(view) {
+           return this.posBefore(view) + view.length;
+       }
+       // Will return a rectangle directly before (when side < 0), after
+       // (side > 0) or directly on (when the browser supports it) the
+       // given position.
+       coordsAt(_pos, _side) { return null; }
+       sync(track) {
+           if (this.dirty & 2 /* Node */) {
+               let parent = this.dom;
+               let prev = null, next;
+               for (let child of this.children) {
+                   if (child.dirty) {
+                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
+                           let contentView = ContentView.get(next);
+                           if (!contentView || !contentView.parent && contentView.constructor == child.constructor)
+                               child.reuseDOM(next);
+                       }
+                       child.sync(track);
+                       child.dirty = 0 /* Not */;
+                   }
+                   next = prev ? prev.nextSibling : parent.firstChild;
+                   if (track && !track.written && track.node == parent && next != child.dom)
+                       track.written = true;
+                   if (child.dom.parentNode == parent) {
+                       while (next && next != child.dom)
+                           next = rm$1$1(next);
+                   }
+                   else {
+                       parent.insertBefore(child.dom, next);
+                   }
+                   prev = child.dom;
+               }
+               next = prev ? prev.nextSibling : parent.firstChild;
+               if (next && track && track.node == parent)
+                   track.written = true;
+               while (next)
+                   next = rm$1$1(next);
+           }
+           else if (this.dirty & 1 /* Child */) {
+               for (let child of this.children)
+                   if (child.dirty) {
+                       child.sync(track);
+                       child.dirty = 0 /* Not */;
+                   }
+           }
+       }
+       reuseDOM(_dom) { }
+       localPosFromDOM(node, offset) {
+           let after;
+           if (node == this.dom) {
+               after = this.dom.childNodes[offset];
+           }
+           else {
+               let bias = maxOffset$1(node) == 0 ? 0 : offset == 0 ? -1 : 1;
+               for (;;) {
+                   let parent = node.parentNode;
+                   if (parent == this.dom)
+                       break;
+                   if (bias == 0 && parent.firstChild != parent.lastChild) {
+                       if (node == parent.firstChild)
+                           bias = -1;
+                       else
+                           bias = 1;
+                   }
+                   node = parent;
+               }
+               if (bias < 0)
+                   after = node;
+               else
+                   after = node.nextSibling;
+           }
+           if (after == this.dom.firstChild)
+               return 0;
+           while (after && !ContentView.get(after))
+               after = after.nextSibling;
+           if (!after)
+               return this.length;
+           for (let i = 0, pos = 0;; i++) {
+               let child = this.children[i];
+               if (child.dom == after)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+       }
+       domBoundsAround(from, to, offset = 0) {
+           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
+           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos < from && end > to)
+                   return child.domBoundsAround(from, to, pos);
+               if (end >= from && fromI == -1) {
+                   fromI = i;
+                   fromStart = pos;
+               }
+               if (pos > to && child.dom.parentNode == this.dom) {
+                   toI = i;
+                   toEnd = prevEnd;
+                   break;
+               }
+               prevEnd = end;
+               pos = end + child.breakAfter;
+           }
+           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
+               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
+               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
+       }
+       markDirty(andParent = false) {
+           this.dirty |= 2 /* Node */;
+           this.markParentsDirty(andParent);
+       }
+       markParentsDirty(childList) {
+           for (let parent = this.parent; parent; parent = parent.parent) {
+               if (childList)
+                   parent.dirty |= 2 /* Node */;
+               if (parent.dirty & 1 /* Child */)
+                   return;
+               parent.dirty |= 1 /* Child */;
+               childList = false;
+           }
+       }
+       setParent(parent) {
+           if (this.parent != parent) {
+               this.parent = parent;
+               if (this.dirty)
+                   this.markParentsDirty(true);
+           }
+       }
+       setDOM(dom) {
+           if (this.dom)
+               this.dom.cmView = null;
+           this.dom = dom;
+           dom.cmView = this;
+       }
+       get rootView() {
+           for (let v = this;;) {
+               let parent = v.parent;
+               if (!parent)
+                   return v;
+               v = parent;
+           }
+       }
+       replaceChildren(from, to, children = noChildren$1) {
+           this.markDirty();
+           for (let i = from; i < to; i++) {
+               let child = this.children[i];
+               if (child.parent == this)
+                   child.destroy();
+           }
+           this.children.splice(from, to - from, ...children);
+           for (let i = 0; i < children.length; i++)
+               children[i].setParent(this);
+       }
+       ignoreMutation(_rec) { return false; }
+       ignoreEvent(_event) { return false; }
+       childCursor(pos = this.length) {
+           return new ChildCursor$1(this.children, pos, this.children.length);
+       }
+       childPos(pos, bias = 1) {
+           return this.childCursor().findPos(pos, bias);
+       }
+       toString() {
+           let name = this.constructor.name.replace("View", "");
+           return name + (this.children.length ? "(" + this.children.join() + ")" :
+               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
+               (this.breakAfter ? "#" : "");
+       }
+       static get(node) { return node.cmView; }
+       get isEditable() { return true; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           return false;
+       }
+       become(other) { return false; }
+       // When this is a zero-length view with a side, this should return a
+       // number <= 0 to indicate it is before its position, or a
+       // number > 0 when after its position.
+       getSide() { return 0; }
+       destroy() {
+           this.parent = null;
+       }
+   };
+   ContentView$1.prototype.breakAfter = 0;
+   // Remove a DOM node and return its next sibling.
+   function rm$1$1(dom) {
+       let next = dom.nextSibling;
+       dom.parentNode.removeChild(dom);
+       return next;
+   }
+   let ChildCursor$1 = class ChildCursor {
+       constructor(children, pos, i) {
+           this.children = children;
+           this.pos = pos;
+           this.i = i;
+           this.off = 0;
+       }
+       findPos(pos, bias = 1) {
+           for (;;) {
+               if (pos > this.pos || pos == this.pos &&
+                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
+                   this.off = pos - this.pos;
+                   return this;
+               }
+               let next = this.children[--this.i];
+               this.pos -= next.length + next.breakAfter;
+           }
+       }
+   };
+   function replaceRange$1(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
+       let { children } = parent;
+       let before = children.length ? children[fromI] : null;
+       let last = insert.length ? insert[insert.length - 1] : null;
+       let breakAtEnd = last ? last.breakAfter : breakAtStart;
+       // Change within a single child
+       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
+           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
+           return;
+       if (toI < children.length) {
+           let after = children[toI];
+           // Make sure the end of the child after the update is preserved in `after`
+           if (after && toOff < after.length) {
+               // If we're splitting a child, separate part of it to avoid that
+               // being mangled when updating the child before the update.
+               if (fromI == toI) {
+                   after = after.split(toOff);
+                   toOff = 0;
+               }
+               // If the element after the replacement should be merged with
+               // the last replacing element, update `content`
+               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
+                   insert[insert.length - 1] = after;
+               }
+               else {
+                   // Remove the start of the after element, if necessary, and
+                   // add it to `content`.
+                   if (toOff)
+                       after.merge(0, toOff, null, false, 0, openEnd);
+                   insert.push(after);
+               }
+           }
+           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
+               // The element at `toI` is entirely covered by this range.
+               // Preserve its line break, if any.
+               if (last)
+                   last.breakAfter = 1;
+               else
+                   breakAtStart = 1;
+           }
+           // Since we've handled the next element from the current elements
+           // now, make sure `toI` points after that.
+           toI++;
+       }
+       if (before) {
+           before.breakAfter = breakAtStart;
+           if (fromOff > 0) {
+               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
+                   before.breakAfter = insert.shift().breakAfter;
+               }
+               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
+                   before.merge(fromOff, before.length, null, false, openStart, 0);
+               }
+               fromI++;
+           }
+       }
+       // Try to merge widgets on the boundaries of the replacement
+       while (fromI < toI && insert.length) {
+           if (children[toI - 1].become(insert[insert.length - 1])) {
+               toI--;
+               insert.pop();
+               openEnd = insert.length ? 0 : openStart;
+           }
+           else if (children[fromI].become(insert[0])) {
+               fromI++;
+               insert.shift();
+               openStart = insert.length ? 0 : openEnd;
+           }
+           else {
+               break;
+           }
+       }
+       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
+           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
+           fromI--;
+       if (fromI < toI || insert.length)
+           parent.replaceChildren(fromI, toI, insert);
+   }
+   function mergeChildrenInto$1(parent, from, to, insert, openStart, openEnd) {
+       let cur = parent.childCursor();
+       let { i: toI, off: toOff } = cur.findPos(to, 1);
+       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
+       let dLen = from - to;
+       for (let view of insert)
+           dLen += view.length;
+       parent.length += dLen;
+       replaceRange$1(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
+   }
+
+   let nav$1 = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
+   let doc$1 = typeof document != "undefined" ? document : { documentElement: { style: {} } };
+   const ie_edge$1 = /*@__PURE__*//Edge\/(\d+)/.exec(nav$1.userAgent);
+   const ie_upto10$1 = /*@__PURE__*//MSIE \d/.test(nav$1.userAgent);
+   const ie_11up$1 = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav$1.userAgent);
+   const ie$1 = !!(ie_upto10$1 || ie_11up$1 || ie_edge$1);
+   const gecko$1 = !ie$1 && /*@__PURE__*//gecko\/(\d+)/i.test(nav$1.userAgent);
+   const chrome$1 = !ie$1 && /*@__PURE__*//Chrome\/(\d+)/.exec(nav$1.userAgent);
+   const webkit$1 = "webkitFontSmoothing" in doc$1.documentElement.style;
+   const safari$1 = !ie$1 && /*@__PURE__*//Apple Computer/.test(nav$1.vendor);
+   const ios$1 = safari$1 && (/*@__PURE__*//Mobile\/\w+/.test(nav$1.userAgent) || nav$1.maxTouchPoints > 2);
+   var browser$1 = {
+       mac: ios$1 || /*@__PURE__*//Mac/.test(nav$1.platform),
+       windows: /*@__PURE__*//Win/.test(nav$1.platform),
+       linux: /*@__PURE__*//Linux|X11/.test(nav$1.platform),
+       ie: ie$1,
+       ie_version: ie_upto10$1 ? doc$1.documentMode || 6 : ie_11up$1 ? +ie_11up$1[1] : ie_edge$1 ? +ie_edge$1[1] : 0,
+       gecko: gecko$1,
+       gecko_version: gecko$1 ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav$1.userAgent) || [0, 0])[1] : 0,
+       chrome: !!chrome$1,
+       chrome_version: chrome$1 ? +chrome$1[1] : 0,
+       ios: ios$1,
+       android: /*@__PURE__*//Android\b/.test(nav$1.userAgent),
+       webkit: webkit$1,
+       safari: safari$1,
+       webkit_version: webkit$1 ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
+       tabSize: doc$1.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
+   };
+
+   const MaxJoinLen$1 = 256;
+   let TextView$1 = class TextView extends ContentView$1 {
+       constructor(text) {
+           super();
+           this.text = text;
+       }
+       get length() { return this.text.length; }
+       createDOM(textDOM) {
+           this.setDOM(textDOM || document.createTextNode(this.text));
+       }
+       sync(track) {
+           if (!this.dom)
+               this.createDOM();
+           if (this.dom.nodeValue != this.text) {
+               if (track && track.node == this.dom)
+                   track.written = true;
+               this.dom.nodeValue = this.text;
+           }
+       }
+       reuseDOM(dom) {
+           if (dom.nodeType == 3)
+               this.createDOM(dom);
+       }
+       merge(from, to, source) {
+           if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen$1))
+               return false;
+           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = new TextView(this.text.slice(from));
+           this.text = this.text.slice(0, from);
+           this.markDirty();
+           return result;
+       }
+       localPosFromDOM(node, offset) {
+           return node == this.dom ? offset : offset ? this.text.length : 0;
+       }
+       domAtPos(pos) { return new DOMPos$1(this.dom, pos); }
+       domBoundsAround(_from, _to, offset) {
+           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
+       }
+       coordsAt(pos, side) {
+           return textCoords$1(this.dom, pos, side);
+       }
+   };
+   let MarkView$1 = class MarkView extends ContentView$1 {
+       constructor(mark, children = [], length = 0) {
+           super();
+           this.mark = mark;
+           this.children = children;
+           this.length = length;
+           for (let ch of children)
+               ch.setParent(this);
+       }
+       setAttrs(dom) {
+           clearAttributes$1(dom);
+           if (this.mark.class)
+               dom.className = this.mark.class;
+           if (this.mark.attrs)
+               for (let name in this.mark.attrs)
+                   dom.setAttribute(name, this.mark.attrs[name]);
+           return dom;
+       }
+       reuseDOM(node) {
+           if (node.nodeName == this.mark.tagName.toUpperCase()) {
+               this.setDOM(node);
+               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
+           }
+       }
+       sync(track) {
+           if (!this.dom)
+               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
+           else if (this.dirty & 4 /* Attrs */)
+               this.setAttrs(this.dom);
+           super.sync(track);
+       }
+       merge(from, to, source, _hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
+               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
+               return false;
+           mergeChildrenInto$1(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = [], off = 0, detachFrom = -1, i = 0;
+           for (let elt of this.children) {
+               let end = off + elt.length;
+               if (end > from)
+                   result.push(off < from ? elt.split(from - off) : elt);
+               if (detachFrom < 0 && off >= from)
+                   detachFrom = i;
+               off = end;
+               i++;
+           }
+           let length = this.length - from;
+           this.length = from;
+           if (detachFrom > -1) {
+               this.children.length = detachFrom;
+               this.markDirty();
+           }
+           return new MarkView(this.mark, result, length);
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos$1(this.dom, this.children, pos);
+       }
+       coordsAt(pos, side) {
+           return coordsInChildren$1(this, pos, side);
+       }
+   };
+   function textCoords$1(text, pos, side) {
+       let length = text.nodeValue.length;
+       if (pos > length)
+           pos = length;
+       let from = pos, to = pos, flatten = 0;
+       if (pos == 0 && side < 0 || pos == length && side >= 0) {
+           if (!(browser$1.chrome || browser$1.gecko)) { // These browsers reliably return valid rectangles for empty ranges
+               if (pos) {
+                   from--;
+                   flatten = 1;
+               } // FIXME this is wrong in RTL text
+               else if (to < length) {
+                   to++;
+                   flatten = -1;
+               }
+           }
+       }
+       else {
+           if (side < 0)
+               from--;
+           else if (to < length)
+               to++;
+       }
+       let rects = textRange$1(text, from, to).getClientRects();
+       if (!rects.length)
+           return Rect0;
+       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
+       if (browser$1.safari && !flatten && rect.width == 0)
+           rect = Array.prototype.find.call(rects, r => r.width) || rect;
+       return flatten ? flattenRect$1(rect, flatten < 0) : rect || null;
+   }
+   // Also used for collapsed ranges that don't have a placeholder widget!
+   let WidgetView$1 = class WidgetView extends ContentView$1 {
+       constructor(widget, length, side) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.side = side;
+           this.prevWidget = null;
+       }
+       static create(widget, length, side) {
+           return new (widget.customView || WidgetView)(widget, length, side);
+       }
+       split(from) {
+           let result = WidgetView.create(this.widget, this.length - from, this.side);
+           this.length -= from;
+           return result;
+       }
+       sync() {
+           if (!this.dom || !this.widget.updateDOM(this.dom)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(this.editorView));
+               this.dom.contentEditable = "false";
+           }
+       }
+       getSide() { return this.side; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       become(other) {
+           if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
+               if (this.widget.constructor == other.widget.constructor) {
+                   if (!this.widget.eq(other.widget))
+                       this.markDirty(true);
+                   if (this.dom && !this.prevWidget)
+                       this.prevWidget = this.widget;
+                   this.widget = other.widget;
+                   return true;
+               }
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       get overrideDOMText() {
+           if (this.length == 0)
+               return Text$1.empty;
+           let top = this;
+           while (top.parent)
+               top = top.parent;
+           let view = top.editorView, text = view && view.state.doc, start = this.posAtStart;
+           return text ? text.slice(start, start + this.length) : Text$1.empty;
+       }
+       domAtPos(pos) {
+           return pos == 0 ? DOMPos$1.before(this.dom) : DOMPos$1.after(this.dom, pos == this.length);
+       }
+       domBoundsAround() { return null; }
+       coordsAt(pos, side) {
+           let rects = this.dom.getClientRects(), rect = null;
+           if (!rects.length)
+               return Rect0;
+           for (let i = pos > 0 ? rects.length - 1 : 0;; i += (pos > 0 ? -1 : 1)) {
+               rect = rects[i];
+               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
+                   break;
+           }
+           return (pos == 0 && side > 0 || pos == this.length && side <= 0) ? rect : flattenRect$1(rect, pos == 0);
+       }
+       get isEditable() { return false; }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+   };
+   class CompositionView extends WidgetView$1 {
+       domAtPos(pos) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return new DOMPos$1(text, Math.min(pos, text.nodeValue.length));
+           return scanCompositionTree(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos$1(text, Math.min(p, text.nodeValue.length)));
+       }
+       sync() { this.setDOM(this.widget.toDOM()); }
+       localPosFromDOM(node, offset) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return Math.min(offset, this.length);
+           return posFromDOMInCompositionTree(node, offset, topView, text);
+       }
+       ignoreMutation() { return false; }
+       get overrideDOMText() { return null; }
+       coordsAt(pos, side) {
+           let { topView, text } = this.widget;
+           if (!topView)
+               return textCoords$1(text, pos, side);
+           return scanCompositionTree(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords$1(text, pos, side));
+       }
+       destroy() {
+           var _a;
+           super.destroy();
+           (_a = this.widget.topView) === null || _a === void 0 ? void 0 : _a.destroy();
+       }
+       get isEditable() { return true; }
+   }
+   // Uses the old structure of a chunk of content view frozen for
+   // composition to try and find a reasonable DOM location for the given
+   // offset.
+   function scanCompositionTree(pos, side, view, text, enterView, fromText) {
+       if (view instanceof MarkView$1) {
+           for (let child of view.children) {
+               let hasComp = contains$1(child.dom, text);
+               let len = hasComp ? text.nodeValue.length : child.length;
+               if (pos < len || pos == len && child.getSide() <= 0)
+                   return hasComp ? scanCompositionTree(pos, side, child, text, enterView, fromText) : enterView(child, pos, side);
+               pos -= len;
+           }
+           return enterView(view, view.length, -1);
+       }
+       else if (view.dom == text) {
+           return fromText(pos, side);
+       }
+       else {
+           return enterView(view, pos, side);
+       }
+   }
+   function posFromDOMInCompositionTree(node, offset, view, text) {
+       if (view instanceof MarkView$1) {
+           for (let child of view.children) {
+               let pos = 0, hasComp = contains$1(child.dom, text);
+               if (contains$1(child.dom, node))
+                   return pos + (hasComp ? posFromDOMInCompositionTree(node, offset, child, text) : child.localPosFromDOM(node, offset));
+               pos += hasComp ? text.nodeValue.length : child.length;
+           }
+       }
+       else if (view.dom == text) {
+           return Math.min(offset, text.nodeValue.length);
+       }
+       return view.localPosFromDOM(node, offset);
+   }
+   // These are drawn around uneditable widgets to avoid a number of
+   // browser bugs that show up when the cursor is directly next to
+   // uneditable inline content.
+   let WidgetBufferView$1 = class WidgetBufferView extends ContentView$1 {
+       constructor(side) {
+           super();
+           this.side = side;
+       }
+       get length() { return 0; }
+       merge() { return false; }
+       become(other) {
+           return other instanceof WidgetBufferView && other.side == this.side;
+       }
+       split() { return new WidgetBufferView(this.side); }
+       sync() {
+           if (!this.dom) {
+               let dom = document.createElement("img");
+               dom.className = "cm-widgetBuffer";
+               dom.setAttribute("aria-hidden", "true");
+               this.setDOM(dom);
+           }
+       }
+       getSide() { return this.side; }
+       domAtPos(pos) { return DOMPos$1.before(this.dom); }
+       localPosFromDOM() { return 0; }
+       domBoundsAround() { return null; }
+       coordsAt(pos) {
+           let imgRect = this.dom.getBoundingClientRect();
+           // Since the <img> height doesn't correspond to text height, try
+           // to borrow the height from some sibling node.
+           let siblingRect = inlineSiblingRect(this, this.side > 0 ? -1 : 1);
+           return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top
+               ? { left: imgRect.left, right: imgRect.right, top: siblingRect.top, bottom: siblingRect.bottom } : imgRect;
+       }
+       get overrideDOMText() {
+           return Text$1.empty;
+       }
+   };
+   TextView$1.prototype.children = WidgetView$1.prototype.children = WidgetBufferView$1.prototype.children = noChildren$1;
+   function inlineSiblingRect(view, side) {
+       let parent = view.parent, index = parent ? parent.children.indexOf(view) : -1;
+       while (parent && index >= 0) {
+           if (side < 0 ? index > 0 : index < parent.children.length) {
+               let next = parent.children[index + side];
+               if (next instanceof TextView$1) {
+                   let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
+                   if (nextRect)
+                       return nextRect;
+               }
+               index += side;
+           }
+           else if (parent instanceof MarkView$1 && parent.parent) {
+               index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
+               parent = parent.parent;
+           }
+           else {
+               let last = parent.dom.lastChild;
+               if (last && last.nodeName == "BR")
+                   return last.getClientRects()[0];
+               break;
+           }
+       }
+       return undefined;
+   }
+   function inlineDOMAtPos$1(dom, children, pos) {
+       let i = 0;
+       for (let off = 0; i < children.length; i++) {
+           let child = children[i], end = off + child.length;
+           if (end == off && child.getSide() <= 0)
+               continue;
+           if (pos > off && pos < end && child.dom.parentNode == dom)
+               return child.domAtPos(pos - off);
+           if (pos <= off)
+               break;
+           off = end;
+       }
+       for (; i > 0; i--) {
+           let before = children[i - 1].dom;
+           if (before.parentNode == dom)
+               return DOMPos$1.after(before);
+       }
+       return new DOMPos$1(dom, 0);
+   }
+   // Assumes `view`, if a mark view, has precisely 1 child.
+   function joinInlineInto$1(parent, view, open) {
+       let last, { children } = parent;
+       if (open > 0 && view instanceof MarkView$1 && children.length &&
+           (last = children[children.length - 1]) instanceof MarkView$1 && last.mark.eq(view.mark)) {
+           joinInlineInto$1(last, view.children[0], open - 1);
+       }
+       else {
+           children.push(view);
+           view.setParent(parent);
+       }
+       parent.length += view.length;
+   }
+   function coordsInChildren$1(view, pos, side) {
+       for (let off = 0, i = 0; i < view.children.length; i++) {
+           let child = view.children[i], end = off + child.length, next;
+           if ((side <= 0 || end == view.length || child.getSide() > 0 ? end >= pos : end > pos) &&
+               (pos < end || i + 1 == view.children.length || (next = view.children[i + 1]).length || next.getSide() > 0)) {
+               let flatten = 0;
+               if (end == off) {
+                   if (child.getSide() <= 0)
+                       continue;
+                   flatten = side = -child.getSide();
+               }
+               let rect = child.coordsAt(Math.max(0, pos - off), side);
+               return flatten && rect ? flattenRect$1(rect, side < 0) : rect;
+           }
+           off = end;
+       }
+       let last = view.dom.lastChild;
+       if (!last)
+           return view.dom.getBoundingClientRect();
+       let rects = clientRectsFor$1(last);
+       return rects[rects.length - 1] || null;
+   }
+
+   function combineAttrs$1(source, target) {
+       for (let name in source) {
+           if (name == "class" && target.class)
+               target.class += " " + source.class;
+           else if (name == "style" && target.style)
+               target.style += ";" + source.style;
+           else
+               target[name] = source[name];
+       }
+       return target;
+   }
+   function attrsEq$1(a, b) {
+       if (a == b)
+           return true;
+       if (!a || !b)
+           return false;
+       let keysA = Object.keys(a), keysB = Object.keys(b);
+       if (keysA.length != keysB.length)
+           return false;
+       for (let key of keysA) {
+           if (keysB.indexOf(key) == -1 || a[key] !== b[key])
+               return false;
+       }
+       return true;
+   }
+   function updateAttrs$1(dom, prev, attrs) {
+       let changed = null;
+       if (prev)
+           for (let name in prev)
+               if (!(attrs && name in attrs))
+                   dom.removeAttribute(changed = name);
+       if (attrs)
+           for (let name in attrs)
+               if (!(prev && prev[name] == attrs[name]))
+                   dom.setAttribute(changed = name, attrs[name]);
+       return !!changed;
+   }
+
+   /**
+   Widgets added to the content are described by subclasses of this
+   class. Using a description object like that makes it possible to
+   delay creating of the DOM structure for a widget until it is
+   needed, and to avoid redrawing widgets even if the decorations
+   that define them are recreated.
+   */
+   let WidgetType$1 = class WidgetType {
+       /**
+       Compare this instance to another instance of the same type.
+       (TypeScript can't express this, but only instances of the same
+       specific class will be passed to this method.) This is used to
+       avoid redrawing widgets when they are replaced by a new
+       decoration of the same type. The default implementation just
+       returns `false`, which will cause new instances of the widget to
+       always be redrawn.
+       */
+       eq(widget) { return false; }
+       /**
+       Update a DOM element created by a widget of the same type (but
+       different, non-`eq` content) to reflect this widget. May return
+       true to indicate that it could update, false to indicate it
+       couldn't (in which case the widget will be redrawn). The default
+       implementation just returns false.
+       */
+       updateDOM(dom) { return false; }
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       The estimated height this widget will have, to be used when
+       estimating the height of content that hasn't been drawn. May
+       return -1 to indicate you don't know. The default implementation
+       returns -1.
+       */
+       get estimatedHeight() { return -1; }
+       /**
+       Can be used to configure which kinds of events inside the widget
+       should be ignored by the editor. The default is to ignore all
+       events.
+       */
+       ignoreEvent(event) { return true; }
+       /**
+       @internal
+       */
+       get customView() { return null; }
+       /**
+       This is called when the an instance of the widget is removed
+       from the editor view.
+       */
+       destroy(dom) { }
+   };
+   /**
+   The different types of blocks that can occur in an editor view.
+   */
+   var BlockType$1 = /*@__PURE__*/(function (BlockType) {
+       /**
+       A line of text.
+       */
+       BlockType[BlockType["Text"] = 0] = "Text";
+       /**
+       A block widget associated with the position after it.
+       */
+       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
+       /**
+       A block widget associated with the position before it.
+       */
+       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
+       /**
+       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
+       */
+       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
+   return BlockType})(BlockType$1 || (BlockType$1 = {}));
+   /**
+   A decoration provides information on how to draw or style a piece
+   of content. You'll usually use it wrapped in a
+   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
+   @nonabstract
+   */
+   let Decoration$1 = class Decoration extends RangeValue$1 {
+       constructor(
+       /**
+       @internal
+       */
+       startSide, 
+       /**
+       @internal
+       */
+       endSide, 
+       /**
+       @internal
+       */
+       widget, 
+       /**
+       The config object used to create this decoration. You can
+       include additional properties in there to store metadata about
+       your decoration.
+       */
+       spec) {
+           super();
+           this.startSide = startSide;
+           this.endSide = endSide;
+           this.widget = widget;
+           this.spec = spec;
+       }
+       /**
+       @internal
+       */
+       get heightRelevant() { return false; }
+       /**
+       Create a mark decoration, which influences the styling of the
+       content in its range. Nested mark decorations will cause nested
+       DOM elements to be created. Nesting order is determined by
+       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
+       the higher-precedence decorations creating the inner DOM nodes.
+       Such elements are split on line boundaries and on the boundaries
+       of lower-precedence decorations.
+       */
+       static mark(spec) {
+           return new MarkDecoration$1(spec);
+       }
+       /**
+       Create a widget decoration, which displays a DOM element at the
+       given position.
+       */
+       static widget(spec) {
+           let side = spec.side || 0, block = !!spec.block;
+           side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
+           return new PointDecoration$1(spec, side, side, block, spec.widget || null, false);
+       }
+       /**
+       Create a replace decoration which replaces the given range with
+       a widget, or simply hides it.
+       */
+       static replace(spec) {
+           let block = !!spec.block, startSide, endSide;
+           if (spec.isBlockGap) {
+               startSide = -500000000 /* GapStart */;
+               endSide = 400000000 /* GapEnd */;
+           }
+           else {
+               let { start, end } = getInclusive$1(spec, block);
+               startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
+               endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
+           }
+           return new PointDecoration$1(spec, startSide, endSide, block, spec.widget || null, true);
+       }
+       /**
+       Create a line decoration, which can add DOM attributes to the
+       line starting at the given position.
+       */
+       static line(spec) {
+           return new LineDecoration$1(spec);
+       }
+       /**
+       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
+       decorated range or ranges. If the ranges aren't already sorted,
+       pass `true` for `sort` to make the library sort them for you.
+       */
+       static set(of, sort = false) {
+           return RangeSet$1.of(of, sort);
+       }
+       /**
+       @internal
+       */
+       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
+   };
+   /**
+   The empty set of decorations.
+   */
+   Decoration$1.none = RangeSet$1.empty;
+   let MarkDecoration$1 = class MarkDecoration extends Decoration$1 {
+       constructor(spec) {
+           let { start, end } = getInclusive$1(spec);
+           super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
+           this.tagName = spec.tagName || "span";
+           this.class = spec.class || "";
+           this.attrs = spec.attributes || null;
+       }
+       eq(other) {
+           return this == other ||
+               other instanceof MarkDecoration &&
+                   this.tagName == other.tagName &&
+                   this.class == other.class &&
+                   attrsEq$1(this.attrs, other.attrs);
+       }
+       range(from, to = from) {
+           if (from >= to)
+               throw new RangeError("Mark decorations may not be empty");
+           return super.range(from, to);
+       }
+   };
+   MarkDecoration$1.prototype.point = false;
+   let LineDecoration$1 = class LineDecoration extends Decoration$1 {
+       constructor(spec) {
+           super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
+       }
+       eq(other) {
+           return other instanceof LineDecoration && attrsEq$1(this.spec.attributes, other.spec.attributes);
+       }
+       range(from, to = from) {
+           if (to != from)
+               throw new RangeError("Line decoration ranges must be zero-length");
+           return super.range(from, to);
+       }
+   };
+   LineDecoration$1.prototype.mapMode = MapMode$1.TrackBefore;
+   LineDecoration$1.prototype.point = true;
+   let PointDecoration$1 = class PointDecoration extends Decoration$1 {
+       constructor(spec, startSide, endSide, block, widget, isReplace) {
+           super(startSide, endSide, widget, spec);
+           this.block = block;
+           this.isReplace = isReplace;
+           this.mapMode = !block ? MapMode$1.TrackDel : startSide <= 0 ? MapMode$1.TrackBefore : MapMode$1.TrackAfter;
+       }
+       // Only relevant when this.block == true
+       get type() {
+           return this.startSide < this.endSide ? BlockType$1.WidgetRange
+               : this.startSide <= 0 ? BlockType$1.WidgetBefore : BlockType$1.WidgetAfter;
+       }
+       get heightRelevant() { return this.block || !!this.widget && this.widget.estimatedHeight >= 5; }
+       eq(other) {
+           return other instanceof PointDecoration &&
+               widgetsEq$1(this.widget, other.widget) &&
+               this.block == other.block &&
+               this.startSide == other.startSide && this.endSide == other.endSide;
+       }
+       range(from, to = from) {
+           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
+               throw new RangeError("Invalid range for replacement decoration");
+           if (!this.isReplace && to != from)
+               throw new RangeError("Widget decorations can only have zero-length ranges");
+           return super.range(from, to);
+       }
+   };
+   PointDecoration$1.prototype.point = true;
+   function getInclusive$1(spec, block = false) {
+       let { inclusiveStart: start, inclusiveEnd: end } = spec;
+       if (start == null)
+           start = spec.inclusive;
+       if (end == null)
+           end = spec.inclusive;
+       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
+   }
+   function widgetsEq$1(a, b) {
+       return a == b || !!(a && b && a.compare(b));
+   }
+   function addRange$1(from, to, ranges, margin = 0) {
+       let last = ranges.length - 1;
+       if (last >= 0 && ranges[last] + margin >= from)
+           ranges[last] = Math.max(ranges[last], to);
+       else
+           ranges.push(from, to);
+   }
+
+   let LineView$1 = class LineView extends ContentView$1 {
+       constructor() {
+           super(...arguments);
+           this.children = [];
+           this.length = 0;
+           this.prevAttrs = undefined;
+           this.attrs = null;
+           this.breakAfter = 0;
+       }
+       // Consumes source
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source) {
+               if (!(source instanceof LineView))
+                   return false;
+               if (!this.dom)
+                   source.transferDOM(this); // Reuse source.dom when appropriate
+           }
+           if (hasStart)
+               this.setDeco(source ? source.attrs : null);
+           mergeChildrenInto$1(this, from, to, source ? source.children : [], openStart, openEnd);
+           return true;
+       }
+       split(at) {
+           let end = new LineView;
+           end.breakAfter = this.breakAfter;
+           if (this.length == 0)
+               return end;
+           let { i, off } = this.childPos(at);
+           if (off) {
+               end.append(this.children[i].split(off), 0);
+               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
+               i++;
+           }
+           for (let j = i; j < this.children.length; j++)
+               end.append(this.children[j], 0);
+           while (i > 0 && this.children[i - 1].length == 0)
+               this.children[--i].destroy();
+           this.children.length = i;
+           this.markDirty();
+           this.length = at;
+           return end;
+       }
+       transferDOM(other) {
+           if (!this.dom)
+               return;
+           this.markDirty();
+           other.setDOM(this.dom);
+           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
+           this.prevAttrs = undefined;
+           this.dom = null;
+       }
+       setDeco(attrs) {
+           if (!attrsEq$1(this.attrs, attrs)) {
+               if (this.dom) {
+                   this.prevAttrs = this.attrs;
+                   this.markDirty();
+               }
+               this.attrs = attrs;
+           }
+       }
+       append(child, openStart) {
+           joinInlineInto$1(this, child, openStart);
+       }
+       // Only called when building a line view in ContentBuilder
+       addLineDeco(deco) {
+           let attrs = deco.spec.attributes, cls = deco.spec.class;
+           if (attrs)
+               this.attrs = combineAttrs$1(attrs, this.attrs || {});
+           if (cls)
+               this.attrs = combineAttrs$1({ class: cls }, this.attrs || {});
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos$1(this.dom, this.children, pos);
+       }
+       reuseDOM(node) {
+           if (node.nodeName == "DIV") {
+               this.setDOM(node);
+               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
+           }
+       }
+       sync(track) {
+           var _a;
+           if (!this.dom) {
+               this.setDOM(document.createElement("div"));
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           else if (this.dirty & 4 /* Attrs */) {
+               clearAttributes$1(this.dom);
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           if (this.prevAttrs !== undefined) {
+               updateAttrs$1(this.dom, this.prevAttrs, this.attrs);
+               this.dom.classList.add("cm-line");
+               this.prevAttrs = undefined;
+           }
+           super.sync(track);
+           let last = this.dom.lastChild;
+           while (last && ContentView$1.get(last) instanceof MarkView$1)
+               last = last.lastChild;
+           if (!last || !this.length ||
+               last.nodeName != "BR" && ((_a = ContentView$1.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
+                   (!browser$1.ios || !this.children.some(ch => ch instanceof TextView$1))) {
+               let hack = document.createElement("BR");
+               hack.cmIgnore = true;
+               this.dom.appendChild(hack);
+           }
+       }
+       measureTextSize() {
+           if (this.children.length == 0 || this.length > 20)
+               return null;
+           let totalWidth = 0;
+           for (let child of this.children) {
+               if (!(child instanceof TextView$1))
+                   return null;
+               let rects = clientRectsFor$1(child.dom);
+               if (rects.length != 1)
+                   return null;
+               totalWidth += rects[0].width;
+           }
+           return { lineHeight: this.dom.getBoundingClientRect().height,
+               charWidth: totalWidth / this.length };
+       }
+       coordsAt(pos, side) {
+           return coordsInChildren$1(this, pos, side);
+       }
+       become(_other) { return false; }
+       get type() { return BlockType$1.Text; }
+       static find(docView, pos) {
+           for (let i = 0, off = 0; i < docView.children.length; i++) {
+               let block = docView.children[i], end = off + block.length;
+               if (end >= pos) {
+                   if (block instanceof LineView)
+                       return block;
+                   if (end > pos)
+                       break;
+               }
+               off = end + block.breakAfter;
+           }
+           return null;
+       }
+   };
+   let BlockWidgetView$1 = class BlockWidgetView extends ContentView$1 {
+       constructor(widget, length, type) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.type = type;
+           this.breakAfter = 0;
+           this.prevWidget = null;
+       }
+       merge(from, to, source, _takeDeco, openStart, openEnd) {
+           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       domAtPos(pos) {
+           return pos == 0 ? DOMPos$1.before(this.dom) : DOMPos$1.after(this.dom, pos == this.length);
+       }
+       split(at) {
+           let len = this.length - at;
+           this.length = at;
+           let end = new BlockWidgetView(this.widget, len, this.type);
+           end.breakAfter = this.breakAfter;
+           return end;
+       }
+       get children() { return noChildren$1; }
+       sync() {
+           if (!this.dom || !this.widget.updateDOM(this.dom)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(this.editorView));
+               this.dom.contentEditable = "false";
+           }
+       }
+       get overrideDOMText() {
+           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$1.empty;
+       }
+       domBoundsAround() { return null; }
+       become(other) {
+           if (other instanceof BlockWidgetView && other.type == this.type &&
+               other.widget.constructor == this.widget.constructor) {
+               if (!other.widget.eq(this.widget))
+                   this.markDirty(true);
+               if (this.dom && !this.prevWidget)
+                   this.prevWidget = this.widget;
+               this.widget = other.widget;
+               this.length = other.length;
+               this.breakAfter = other.breakAfter;
+               return true;
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+   };
+
+   let ContentBuilder$1 = class ContentBuilder {
+       constructor(doc, pos, end, disallowBlockEffectsFor) {
+           this.doc = doc;
+           this.pos = pos;
+           this.end = end;
+           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
+           this.content = [];
+           this.curLine = null;
+           this.breakAtStart = 0;
+           this.pendingBuffer = 0 /* No */;
+           // Set to false directly after a widget that covers the position after it
+           this.atCursorPos = true;
+           this.openStart = -1;
+           this.openEnd = -1;
+           this.text = "";
+           this.textOff = 0;
+           this.cursor = doc.iter();
+           this.skip = pos;
+       }
+       posCovered() {
+           if (this.content.length == 0)
+               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
+           let last = this.content[this.content.length - 1];
+           return !last.breakAfter && !(last instanceof BlockWidgetView$1 && last.type == BlockType$1.WidgetBefore);
+       }
+       getLine() {
+           if (!this.curLine) {
+               this.content.push(this.curLine = new LineView$1);
+               this.atCursorPos = true;
+           }
+           return this.curLine;
+       }
+       flushBuffer(active) {
+           if (this.pendingBuffer) {
+               this.curLine.append(wrapMarks$1(new WidgetBufferView$1(-1), active), active.length);
+               this.pendingBuffer = 0 /* No */;
+           }
+       }
+       addBlockWidget(view) {
+           this.flushBuffer([]);
+           this.curLine = null;
+           this.content.push(view);
+       }
+       finish(openEnd) {
+           if (!openEnd)
+               this.flushBuffer([]);
+           else
+               this.pendingBuffer = 0 /* No */;
+           if (!this.posCovered())
+               this.getLine();
+       }
+       buildText(length, active, openStart) {
+           while (length > 0) {
+               if (this.textOff == this.text.length) {
+                   let { value, lineBreak, done } = this.cursor.next(this.skip);
+                   this.skip = 0;
+                   if (done)
+                       throw new Error("Ran out of text content when drawing inline views");
+                   if (lineBreak) {
+                       if (!this.posCovered())
+                           this.getLine();
+                       if (this.content.length)
+                           this.content[this.content.length - 1].breakAfter = 1;
+                       else
+                           this.breakAtStart = 1;
+                       this.flushBuffer([]);
+                       this.curLine = null;
+                       length--;
+                       continue;
+                   }
+                   else {
+                       this.text = value;
+                       this.textOff = 0;
+                   }
+               }
+               let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
+               this.flushBuffer(active.slice(0, openStart));
+               this.getLine().append(wrapMarks$1(new TextView$1(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
+               this.atCursorPos = true;
+               this.textOff += take;
+               length -= take;
+               openStart = 0;
+           }
+       }
+       span(from, to, active, openStart) {
+           this.buildText(to - from, active, openStart);
+           this.pos = to;
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       point(from, to, deco, active, openStart, index) {
+           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration$1) {
+               if (deco.block)
+                   throw new RangeError("Block decorations may not be specified via plugins");
+               if (to > this.doc.lineAt(this.pos).to)
+                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
+           }
+           let len = to - from;
+           if (deco instanceof PointDecoration$1) {
+               if (deco.block) {
+                   let { type } = deco;
+                   if (type == BlockType$1.WidgetAfter && !this.posCovered())
+                       this.getLine();
+                   this.addBlockWidget(new BlockWidgetView$1(deco.widget || new NullWidget$1("div"), len, type));
+               }
+               else {
+                   let view = WidgetView$1.create(deco.widget || new NullWidget$1("span"), len, deco.startSide);
+                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
+                   let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
+                   let line = this.getLine();
+                   if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
+                       this.pendingBuffer = 0 /* No */;
+                   this.flushBuffer(active);
+                   if (cursorBefore) {
+                       line.append(wrapMarks$1(new WidgetBufferView$1(1), active), openStart);
+                       openStart = active.length + Math.max(0, openStart - active.length);
+                   }
+                   line.append(wrapMarks$1(view, active), openStart);
+                   this.atCursorPos = cursorAfter;
+                   this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
+               }
+           }
+           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
+               this.getLine().addLineDeco(deco);
+           }
+           if (len) {
+               // Advance the iterator past the replaced content
+               if (this.textOff + len <= this.text.length) {
+                   this.textOff += len;
+               }
+               else {
+                   this.skip += len - (this.text.length - this.textOff);
+                   this.text = "";
+                   this.textOff = 0;
+               }
+               this.pos = to;
+           }
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       static build(text, from, to, decorations, dynamicDecorationMap) {
+           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
+           builder.openEnd = RangeSet$1.spans(decorations, from, to, builder);
+           if (builder.openStart < 0)
+               builder.openStart = builder.openEnd;
+           builder.finish(builder.openEnd);
+           return builder;
+       }
+   };
+   function wrapMarks$1(view, active) {
+       for (let mark of active)
+           view = new MarkView$1(mark, [view], view.length);
+       return view;
+   }
+   let NullWidget$1 = class NullWidget extends WidgetType$1 {
+       constructor(tag) {
+           super();
+           this.tag = tag;
+       }
+       eq(other) { return other.tag == this.tag; }
+       toDOM() { return document.createElement(this.tag); }
+       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
+   };
+
+   const clickAddsSelectionRange$1 = /*@__PURE__*/Facet$1.define();
+   const dragMovesSelection$1$1 = /*@__PURE__*/Facet$1.define();
+   const mouseSelectionStyle$1 = /*@__PURE__*/Facet$1.define();
+   const exceptionSink$1 = /*@__PURE__*/Facet$1.define();
+   const updateListener$1 = /*@__PURE__*/Facet$1.define();
+   const inputHandler$2 = /*@__PURE__*/Facet$1.define();
+   const perLineTextDirection$1 = /*@__PURE__*/Facet$1.define({
+       combine: values => values.some(x => x)
+   });
+   let ScrollTarget$1 = class ScrollTarget {
+       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5) {
+           this.range = range;
+           this.y = y;
+           this.x = x;
+           this.yMargin = yMargin;
+           this.xMargin = xMargin;
+       }
+       map(changes) {
+           return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);
+       }
+   };
+   const scrollIntoView$3 = /*@__PURE__*/StateEffect$1.define({ map: (t, ch) => t.map(ch) });
+   /**
+   Log or report an unhandled exception in client code. Should
+   probably only be used by extension code that allows client code to
+   provide functions, and calls those functions in a context where an
+   exception can't be propagated to calling code in a reasonable way
+   (for example when in an event handler).
+
+   Either calls a handler registered with
+   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
+   `window.onerror`, if defined, or `console.error` (in which case
+   it'll pass `context`, when given, as first argument).
+   */
+   function logException$1(state, exception, context) {
+       let handler = state.facet(exceptionSink$1);
+       if (handler.length)
+           handler[0](exception);
+       else if (window.onerror)
+           window.onerror(String(exception), context, undefined, undefined, exception);
+       else if (context)
+           console.error(context + ":", exception);
+       else
+           console.error(exception);
+   }
+   const editable$1 = /*@__PURE__*/Facet$1.define({ combine: values => values.length ? values[0] : true });
+   let nextPluginID$1 = 0;
+   const viewPlugin$1 = /*@__PURE__*/Facet$1.define();
+   /**
+   View plugins associate stateful values with a view. They can
+   influence the way the content is drawn, and are notified of things
+   that happen in the view.
+   */
+   let ViewPlugin$1 = class ViewPlugin {
+       constructor(
+       /**
+       @internal
+       */
+       id, 
+       /**
+       @internal
+       */
+       create, 
+       /**
+       @internal
+       */
+       domEventHandlers, buildExtensions) {
+           this.id = id;
+           this.create = create;
+           this.domEventHandlers = domEventHandlers;
+           this.extension = buildExtensions(this);
+       }
+       /**
+       Define a plugin from a constructor function that creates the
+       plugin's value, given an editor view.
+       */
+       static define(create, spec) {
+           const { eventHandlers, provide, decorations: deco } = spec || {};
+           return new ViewPlugin(nextPluginID$1++, create, eventHandlers, plugin => {
+               let ext = [viewPlugin$1.of(plugin)];
+               if (deco)
+                   ext.push(decorations$1.of(view => {
+                       let pluginInst = view.plugin(plugin);
+                       return pluginInst ? deco(pluginInst) : Decoration$1.none;
+                   }));
+               if (provide)
+                   ext.push(provide(plugin));
+               return ext;
+           });
+       }
+       /**
+       Create a plugin for a class whose constructor takes a single
+       editor view as argument.
+       */
+       static fromClass(cls, spec) {
+           return ViewPlugin.define(view => new cls(view), spec);
+       }
+   };
+   let PluginInstance$1 = class PluginInstance {
+       constructor(spec) {
+           this.spec = spec;
+           // When starting an update, all plugins have this field set to the
+           // update object, indicating they need to be updated. When finished
+           // updating, it is set to `false`. Retrieving a plugin that needs to
+           // be updated with `view.plugin` forces an eager update.
+           this.mustUpdate = null;
+           // This is null when the plugin is initially created, but
+           // initialized on the first update.
+           this.value = null;
+       }
+       update(view) {
+           if (!this.value) {
+               if (this.spec) {
+                   try {
+                       this.value = this.spec.create(view);
+                   }
+                   catch (e) {
+                       logException$1(view.state, e, "CodeMirror plugin crashed");
+                       this.deactivate();
+                   }
+               }
+           }
+           else if (this.mustUpdate) {
+               let update = this.mustUpdate;
+               this.mustUpdate = null;
+               if (this.value.update) {
+                   try {
+                       this.value.update(update);
+                   }
+                   catch (e) {
+                       logException$1(update.state, e, "CodeMirror plugin crashed");
+                       if (this.value.destroy)
+                           try {
+                               this.value.destroy();
+                           }
+                           catch (_) { }
+                       this.deactivate();
+                   }
+               }
+           }
+           return this;
+       }
+       destroy(view) {
+           var _a;
+           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
+               try {
+                   this.value.destroy();
+               }
+               catch (e) {
+                   logException$1(view.state, e, "CodeMirror plugin crashed");
+               }
+           }
+       }
+       deactivate() {
+           this.spec = this.value = null;
+       }
+   };
+   const editorAttributes$1 = /*@__PURE__*/Facet$1.define();
+   const contentAttributes$1 = /*@__PURE__*/Facet$1.define();
+   // Provide decorations
+   const decorations$1 = /*@__PURE__*/Facet$1.define();
+   const atomicRanges$1 = /*@__PURE__*/Facet$1.define();
+   const scrollMargins$1 = /*@__PURE__*/Facet$1.define();
+   const styleModule$1 = /*@__PURE__*/Facet$1.define();
+   let ChangedRange$1 = class ChangedRange {
+       constructor(fromA, toA, fromB, toB) {
+           this.fromA = fromA;
+           this.toA = toA;
+           this.fromB = fromB;
+           this.toB = toB;
+       }
+       join(other) {
+           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
+       }
+       addToSet(set) {
+           let i = set.length, me = this;
+           for (; i > 0; i--) {
+               let range = set[i - 1];
+               if (range.fromA > me.toA)
+                   continue;
+               if (range.toA < me.fromA)
+                   break;
+               me = me.join(range);
+               set.splice(i - 1, 1);
+           }
+           set.splice(i, 0, me);
+           return set;
+       }
+       static extendWithRanges(diff, ranges) {
+           if (ranges.length == 0)
+               return diff;
+           let result = [];
+           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
+               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
+               let end = next ? next.fromB : 1e9;
+               while (rI < ranges.length && ranges[rI] < end) {
+                   let from = ranges[rI], to = ranges[rI + 1];
+                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
+                   if (fromB <= toB)
+                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
+                   if (to > end)
+                       break;
+                   else
+                       rI += 2;
+               }
+               if (!next)
+                   return result;
+               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
+               posA = next.toA;
+               posB = next.toB;
+           }
+       }
+   };
+   /**
+   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
+   class, which describe what happened, whenever the view is updated.
+   */
+   let ViewUpdate$1 = class ViewUpdate {
+       constructor(
+       /**
+       The editor view that the update is associated with.
+       */
+       view, 
+       /**
+       The new editor state.
+       */
+       state, 
+       /**
+       The transactions involved in the update. May be empty.
+       */
+       transactions) {
+           this.view = view;
+           this.state = state;
+           this.transactions = transactions;
+           /**
+           @internal
+           */
+           this.flags = 0;
+           this.startState = view.state;
+           this.changes = ChangeSet$1.empty(this.startState.doc.length);
+           for (let tr of transactions)
+               this.changes = this.changes.compose(tr.changes);
+           let changedRanges = [];
+           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange$1(fromA, toA, fromB, toB)));
+           this.changedRanges = changedRanges;
+           let focus = view.hasFocus;
+           if (focus != view.inputState.notifiedFocused) {
+               view.inputState.notifiedFocused = focus;
+               this.flags |= 1 /* Focus */;
+           }
+       }
+       /**
+       @internal
+       */
+       static create(view, state, transactions) {
+           return new ViewUpdate(view, state, transactions);
+       }
+       /**
+       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
+       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
+       update.
+       */
+       get viewportChanged() {
+           return (this.flags & 4 /* Viewport */) > 0;
+       }
+       /**
+       Indicates whether the height of a block element in the editor
+       changed in this update.
+       */
+       get heightChanged() {
+           return (this.flags & 2 /* Height */) > 0;
+       }
+       /**
+       Returns true when the document was modified or the size of the
+       editor, or elements within the editor, changed.
+       */
+       get geometryChanged() {
+           return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
+       }
+       /**
+       True when this update indicates a focus change.
+       */
+       get focusChanged() {
+           return (this.flags & 1 /* Focus */) > 0;
+       }
+       /**
+       Whether the document changed in this update.
+       */
+       get docChanged() {
+           return !this.changes.empty;
+       }
+       /**
+       Whether the selection was explicitly set in this update.
+       */
+       get selectionSet() {
+           return this.transactions.some(tr => tr.selection);
+       }
+       /**
+       @internal
+       */
+       get empty() { return this.flags == 0 && this.transactions.length == 0; }
+   };
+
+   /**
+   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+   */
+   var Direction$1 = /*@__PURE__*/(function (Direction) {
+       // (These are chosen to match the base levels, in bidi algorithm
+       // terms, of spans in that direction.)
+       /**
+       Left-to-right.
+       */
+       Direction[Direction["LTR"] = 0] = "LTR";
+       /**
+       Right-to-left.
+       */
+       Direction[Direction["RTL"] = 1] = "RTL";
+   return Direction})(Direction$1 || (Direction$1 = {}));
+   const LTR$1 = Direction$1.LTR, RTL$1 = Direction$1.RTL;
+   // Decode a string with each type encoded as log2(type)
+   function dec$1(str) {
+       let result = [];
+       for (let i = 0; i < str.length; i++)
+           result.push(1 << +str[i]);
+       return result;
+   }
+   // Character types for codepoints 0 to 0xf8
+   const LowTypes$1 = /*@__PURE__*/dec$1("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
+   // Character types for codepoints 0x600 to 0x6f9
+   const ArabicTypes$1 = /*@__PURE__*/dec$1("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
+   const Brackets$1 = /*@__PURE__*/Object.create(null), BracketStack$1 = [];
+   // There's a lot more in
+   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
+   // which are left out to keep code size down.
+   for (let p of ["()", "[]", "{}"]) {
+       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
+       Brackets$1[l] = r;
+       Brackets$1[r] = -l;
+   }
+   function charType$1(ch) {
+       return ch <= 0xf7 ? LowTypes$1[ch] :
+           0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
+               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes$1[ch - 0x600] :
+                   0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
+                       0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
+                           ch == 0x200c ? 256 /* NI */ : 1 /* L */;
+   }
+   const BidiRE$1 = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
+   /**
+   Represents a contiguous range of text that has a single direction
+   (as in left-to-right or right-to-left).
+   */
+   let BidiSpan$1 = class BidiSpan {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the span (relative to the start of the line).
+       */
+       from, 
+       /**
+       The end of the span.
+       */
+       to, 
+       /**
+       The ["bidi
+       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
+       of the span (in this context, 0 means
+       left-to-right, 1 means right-to-left, 2 means left-to-right
+       number inside right-to-left text).
+       */
+       level) {
+           this.from = from;
+           this.to = to;
+           this.level = level;
+       }
+       /**
+       The direction of this span.
+       */
+       get dir() { return this.level % 2 ? RTL$1 : LTR$1; }
+       /**
+       @internal
+       */
+       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
+       /**
+       @internal
+       */
+       static find(order, index, level, assoc) {
+           let maybe = -1;
+           for (let i = 0; i < order.length; i++) {
+               let span = order[i];
+               if (span.from <= index && span.to >= index) {
+                   if (span.level == level)
+                       return i;
+                   // When multiple spans match, if assoc != 0, take the one that
+                   // covers that side, otherwise take the one with the minimum
+                   // level.
+                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
+                       maybe = i;
+               }
+           }
+           if (maybe < 0)
+               throw new RangeError("Index out of range");
+           return maybe;
+       }
+   };
+   // Reused array of character types
+   const types$1 = [];
+   function computeOrder$1(line, direction) {
+       let len = line.length, outerType = direction == LTR$1 ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR$1 ? 2 /* R */ : 1 /* L */;
+       if (!line || outerType == 1 /* L */ && !BidiRE$1.test(line))
+           return trivialOrder$1(len);
+       // W1. Examine each non-spacing mark (NSM) in the level run, and
+       // change the type of the NSM to the type of the previous
+       // character. If the NSM is at the start of the level run, it will
+       // get the type of sor.
+       // W2. Search backwards from each instance of a European number
+       // until the first strong type (R, L, AL, or sor) is found. If an
+       // AL is found, change the type of the European number to Arabic
+       // number.
+       // W3. Change all ALs to R.
+       // (Left after this: L, R, EN, AN, ET, CS, NI)
+       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
+           let type = charType$1(line.charCodeAt(i));
+           if (type == 512 /* NSM */)
+               type = prev;
+           else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
+               type = 16 /* AN */;
+           types$1[i] = type == 4 /* AL */ ? 2 /* R */ : type;
+           if (type & 7 /* Strong */)
+               prevStrong = type;
+           prev = type;
+       }
+       // W5. A sequence of European terminators adjacent to European
+       // numbers changes to all European numbers.
+       // W6. Otherwise, separators and terminators change to Other
+       // Neutral.
+       // W7. Search backwards from each instance of a European number
+       // until the first strong type (R, L, or sor) is found. If an L is
+       // found, then change the type of the European number to L.
+       // (Left after this: L, R, EN+AN, NI)
+       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
+           let type = types$1[i];
+           if (type == 128 /* CS */) {
+               if (i < len - 1 && prev == types$1[i + 1] && (prev & 24 /* Num */))
+                   type = types$1[i] = prev;
+               else
+                   types$1[i] = 256 /* NI */;
+           }
+           else if (type == 64 /* ET */) {
+               let end = i + 1;
+               while (end < len && types$1[end] == 64 /* ET */)
+                   end++;
+               let replace = (i && prev == 8 /* EN */) || (end < len && types$1[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
+               for (let j = i; j < end; j++)
+                   types$1[j] = replace;
+               i = end - 1;
+           }
+           else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
+               types$1[i] = 1 /* L */;
+           }
+           prev = type;
+           if (type & 7 /* Strong */)
+               prevStrong = type;
+       }
+       // N0. Process bracket pairs in an isolating run sequence
+       // sequentially in the logical order of the text positions of the
+       // opening paired brackets using the logic given below. Within this
+       // scope, bidirectional types EN and AN are treated as R.
+       for (let i = 0, sI = 0, context = 0, ch, br, type; i < len; i++) {
+           // Keeps [startIndex, type, strongSeen] triples for each open
+           // bracket on BracketStack.
+           if (br = Brackets$1[ch = line.charCodeAt(i)]) {
+               if (br < 0) { // Closing bracket
+                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                       if (BracketStack$1[sJ + 1] == -br) {
+                           let flags = BracketStack$1[sJ + 2];
+                           let type = (flags & 2 /* EmbedInside */) ? outerType :
+                               !(flags & 4 /* OppositeInside */) ? 0 :
+                                   (flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
+                           if (type)
+                               types$1[i] = types$1[BracketStack$1[sJ]] = type;
+                           sI = sJ;
+                           break;
+                       }
+                   }
+               }
+               else if (BracketStack$1.length == 189 /* MaxDepth */) {
+                   break;
+               }
+               else {
+                   BracketStack$1[sI++] = i;
+                   BracketStack$1[sI++] = ch;
+                   BracketStack$1[sI++] = context;
+               }
+           }
+           else if ((type = types$1[i]) == 2 /* R */ || type == 1 /* L */) {
+               let embed = type == outerType;
+               context = embed ? 0 : 1 /* OppositeBefore */;
+               for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                   let cur = BracketStack$1[sJ + 2];
+                   if (cur & 2 /* EmbedInside */)
+                       break;
+                   if (embed) {
+                       BracketStack$1[sJ + 2] |= 2 /* EmbedInside */;
+                   }
+                   else {
+                       if (cur & 4 /* OppositeInside */)
+                           break;
+                       BracketStack$1[sJ + 2] |= 4 /* OppositeInside */;
+                   }
+               }
+           }
+       }
+       // N1. A sequence of neutrals takes the direction of the
+       // surrounding strong text if the text on both sides has the same
+       // direction. European and Arabic numbers act as if they were R in
+       // terms of their influence on neutrals. Start-of-level-run (sor)
+       // and end-of-level-run (eor) are used at level run boundaries.
+       // N2. Any remaining neutrals take the embedding direction.
+       // (Left after this: L, R, EN+AN)
+       for (let i = 0; i < len; i++) {
+           if (types$1[i] == 256 /* NI */) {
+               let end = i + 1;
+               while (end < len && types$1[end] == 256 /* NI */)
+                   end++;
+               let beforeL = (i ? types$1[i - 1] : outerType) == 1 /* L */;
+               let afterL = (end < len ? types$1[end] : outerType) == 1 /* L */;
+               let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
+               for (let j = i; j < end; j++)
+                   types$1[j] = replace;
+               i = end - 1;
+           }
+       }
+       // Here we depart from the documented algorithm, in order to avoid
+       // building up an actual levels array. Since there are only three
+       // levels (0, 1, 2) in an implementation that doesn't take
+       // explicit embedding into account, we can build up the order on
+       // the fly, without following the level-based algorithm.
+       let order = [];
+       if (outerType == 1 /* L */) {
+           for (let i = 0; i < len;) {
+               let start = i, rtl = types$1[i++] != 1 /* L */;
+               while (i < len && rtl == (types$1[i] != 1 /* L */))
+                   i++;
+               if (rtl) {
+                   for (let j = i; j > start;) {
+                       let end = j, l = types$1[--j] != 2 /* R */;
+                       while (j > start && l == (types$1[j - 1] != 2 /* R */))
+                           j--;
+                       order.push(new BidiSpan$1(j, end, l ? 2 : 1));
+                   }
+               }
+               else {
+                   order.push(new BidiSpan$1(start, i, 0));
+               }
+           }
+       }
+       else {
+           for (let i = 0; i < len;) {
+               let start = i, rtl = types$1[i++] == 2 /* R */;
+               while (i < len && rtl == (types$1[i] == 2 /* R */))
+                   i++;
+               order.push(new BidiSpan$1(start, i, rtl ? 1 : 2));
+           }
+       }
+       return order;
+   }
+   function trivialOrder$1(length) {
+       return [new BidiSpan$1(0, length, 0)];
+   }
+   let movedOver$1 = "";
+   function moveVisually$1(line, order, dir, start, forward) {
+       var _a;
+       let startIndex = start.head - line.from, spanI = -1;
+       if (startIndex == 0) {
+           if (!forward || !line.length)
+               return null;
+           if (order[0].level != dir) {
+               startIndex = order[0].side(false, dir);
+               spanI = 0;
+           }
+       }
+       else if (startIndex == line.length) {
+           if (forward)
+               return null;
+           let last = order[order.length - 1];
+           if (last.level != dir) {
+               startIndex = last.side(true, dir);
+               spanI = order.length - 1;
+           }
+       }
+       if (spanI < 0)
+           spanI = BidiSpan$1.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
+       let span = order[spanI];
+       // End of span. (But not end of line--that was checked for above.)
+       if (startIndex == span.side(forward, dir)) {
+           span = order[spanI += forward ? 1 : -1];
+           startIndex = span.side(!forward, dir);
+       }
+       let indexForward = forward == (span.dir == dir);
+       let nextIndex = findClusterBreak$2(line.text, startIndex, indexForward);
+       movedOver$1 = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
+       if (nextIndex != span.side(forward, dir))
+           return EditorSelection$1.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);
+       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
+       if (!nextSpan && span.level != dir)
+           return EditorSelection$1.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);
+       if (nextSpan && nextSpan.level < span.level)
+           return EditorSelection$1.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
+       return EditorSelection$1.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
+   }
+
+   const LineBreakPlaceholder$1 = "\uffff";
+   let DOMReader$1 = class DOMReader {
+       constructor(points, state) {
+           this.points = points;
+           this.text = "";
+           this.lineSeparator = state.facet(EditorState$1.lineSeparator);
+       }
+       append(text) {
+           this.text += text;
+       }
+       lineBreak() {
+           this.text += LineBreakPlaceholder$1;
+       }
+       readRange(start, end) {
+           if (!start)
+               return this;
+           let parent = start.parentNode;
+           for (let cur = start;;) {
+               this.findPointBefore(parent, cur);
+               this.readNode(cur);
+               let next = cur.nextSibling;
+               if (next == end)
+                   break;
+               let view = ContentView$1.get(cur), nextView = ContentView$1.get(next);
+               if (view && nextView ? view.breakAfter :
+                   (view ? view.breakAfter : isBlockElement$1(cur)) ||
+                       (isBlockElement$1(next) && (cur.nodeName != "BR" || cur.cmIgnore)))
+                   this.lineBreak();
+               cur = next;
+           }
+           this.findPointBefore(parent, end);
+           return this;
+       }
+       readTextNode(node) {
+           let text = node.nodeValue;
+           for (let point of this.points)
+               if (point.node == node)
+                   point.pos = this.text.length + Math.min(point.offset, text.length);
+           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
+               let nextBreak = -1, breakSize = 1, m;
+               if (this.lineSeparator) {
+                   nextBreak = text.indexOf(this.lineSeparator, off);
+                   breakSize = this.lineSeparator.length;
+               }
+               else if (m = re.exec(text)) {
+                   nextBreak = m.index;
+                   breakSize = m[0].length;
+               }
+               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
+               if (nextBreak < 0)
+                   break;
+               this.lineBreak();
+               if (breakSize > 1)
+                   for (let point of this.points)
+                       if (point.node == node && point.pos > this.text.length)
+                           point.pos -= breakSize - 1;
+               off = nextBreak + breakSize;
+           }
+       }
+       readNode(node) {
+           if (node.cmIgnore)
+               return;
+           let view = ContentView$1.get(node);
+           let fromView = view && view.overrideDOMText;
+           if (fromView != null) {
+               this.findPointInside(node, fromView.length);
+               for (let i = fromView.iter(); !i.next().done;) {
+                   if (i.lineBreak)
+                       this.lineBreak();
+                   else
+                       this.append(i.value);
+               }
+           }
+           else if (node.nodeType == 3) {
+               this.readTextNode(node);
+           }
+           else if (node.nodeName == "BR") {
+               if (node.nextSibling)
+                   this.lineBreak();
+           }
+           else if (node.nodeType == 1) {
+               this.readRange(node.firstChild, null);
+           }
+       }
+       findPointBefore(node, next) {
+           for (let point of this.points)
+               if (point.node == node && node.childNodes[point.offset] == next)
+                   point.pos = this.text.length;
+       }
+       findPointInside(node, maxLen) {
+           for (let point of this.points)
+               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
+                   point.pos = this.text.length + Math.min(maxLen, point.offset);
+       }
+   };
+   function isBlockElement$1(node) {
+       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
+   }
+   let DOMPoint$1 = class DOMPoint {
+       constructor(node, offset) {
+           this.node = node;
+           this.offset = offset;
+           this.pos = -1;
+       }
+   };
+
+   let DocView$1 = class DocView extends ContentView$1 {
+       constructor(view) {
+           super();
+           this.view = view;
+           this.compositionDeco = Decoration$1.none;
+           this.decorations = [];
+           this.dynamicDecorationMap = [];
+           // Track a minimum width for the editor. When measuring sizes in
+           // measureVisibleLineHeights, this is updated to point at the width
+           // of a given element and its extent in the document. When a change
+           // happens in that range, these are reset. That way, once we've seen
+           // a line/element of a given length, we keep the editor wide enough
+           // to fit at least that element, until it is changed, at which point
+           // we forget it again.
+           this.minWidth = 0;
+           this.minWidthFrom = 0;
+           this.minWidthTo = 0;
+           // Track whether the DOM selection was set in a lossy way, so that
+           // we don't mess it up when reading it back it
+           this.impreciseAnchor = null;
+           this.impreciseHead = null;
+           this.forceSelection = false;
+           // Used by the resize observer to ignore resizes that we caused
+           // ourselves
+           this.lastUpdate = Date.now();
+           this.setDOM(view.contentDOM);
+           this.children = [new LineView$1];
+           this.children[0].setParent(this);
+           this.updateDeco();
+           this.updateInner([new ChangedRange$1(0, 0, 0, view.state.doc.length)], 0);
+       }
+       get root() { return this.view.root; }
+       get editorView() { return this.view; }
+       get length() { return this.view.state.doc.length; }
+       // Update the document view to a given state. scrollIntoView can be
+       // used as a hint to compute a new viewport that includes that
+       // position, if we know the editor is going to scroll that position
+       // into view.
+       update(update) {
+           let changedRanges = update.changedRanges;
+           if (this.minWidth > 0 && changedRanges.length) {
+               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
+                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
+               }
+               else {
+                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
+                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
+               }
+           }
+           if (this.view.inputState.composing < 0)
+               this.compositionDeco = Decoration$1.none;
+           else if (update.transactions.length || this.dirty)
+               this.compositionDeco = computeCompositionDeco(this.view, update.changes);
+           // When the DOM nodes around the selection are moved to another
+           // parent, Chrome sometimes reports a different selection through
+           // getSelection than the one that it actually shows to the user.
+           // This forces a selection update when lines are joined to work
+           // around that. Issue #54
+           if ((browser$1.ie || browser$1.chrome) && !this.compositionDeco.size && update &&
+               update.state.doc.lines != update.startState.doc.lines)
+               this.forceSelection = true;
+           let prevDeco = this.decorations, deco = this.updateDeco();
+           let decoDiff = findChangedDeco$1(prevDeco, deco, update.changes);
+           changedRanges = ChangedRange$1.extendWithRanges(changedRanges, decoDiff);
+           if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
+               return false;
+           }
+           else {
+               this.updateInner(changedRanges, update.startState.doc.length);
+               if (update.transactions.length)
+                   this.lastUpdate = Date.now();
+               return true;
+           }
+       }
+       // Used by update and the constructor do perform the actual DOM
+       // update
+       updateInner(changes, oldLength) {
+           this.view.viewState.mustMeasureContent = true;
+           this.updateChildren(changes, oldLength);
+           let { observer } = this.view;
+           observer.ignore(() => {
+               // Lock the height during redrawing, since Chrome sometimes
+               // messes with the scroll position during DOM mutation (though
+               // no relayout is triggered and I cannot imagine how it can
+               // recompute the scroll position without a layout)
+               this.dom.style.height = this.view.viewState.contentHeight + "px";
+               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
+               // Chrome will sometimes, when DOM mutations occur directly
+               // around the selection, get confused and report a different
+               // selection from the one it displays (issue #218). This tries
+               // to detect that situation.
+               let track = browser$1.chrome || browser$1.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
+               this.sync(track);
+               this.dirty = 0 /* Not */;
+               if (track && (track.written || observer.selectionRange.focusNode != track.node))
+                   this.forceSelection = true;
+               this.dom.style.height = "";
+           });
+           let gaps = [];
+           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
+               for (let child of this.children)
+                   if (child instanceof BlockWidgetView$1 && child.widget instanceof BlockGapWidget$1)
+                       gaps.push(child.dom);
+           observer.updateGaps(gaps);
+       }
+       updateChildren(changes, oldLength) {
+           let cursor = this.childCursor(oldLength);
+           for (let i = changes.length - 1;; i--) {
+               let next = i >= 0 ? changes[i] : null;
+               if (!next)
+                   break;
+               let { fromA, toA, fromB, toB } = next;
+               let { content, breakAtStart, openStart, openEnd } = ContentBuilder$1.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap);
+               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
+               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
+               replaceRange$1(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
+           }
+       }
+       // Sync the DOM selection to this.state.selection
+       updateSelection(mustRead = false, fromPointer = false) {
+           if (mustRead)
+               this.view.observer.readSelectionRange();
+           if (!(fromPointer || this.mayControlSelection()) ||
+               browser$1.ios && this.view.inputState.rapidCompositionStart)
+               return;
+           let force = this.forceSelection;
+           this.forceSelection = false;
+           let main = this.view.state.selection.main;
+           // FIXME need to handle the case where the selection falls inside a block range
+           let anchor = this.domAtPos(main.anchor);
+           let head = main.empty ? anchor : this.domAtPos(main.head);
+           // Always reset on Firefox when next to an uneditable node to
+           // avoid invisible cursor bugs (#111)
+           if (browser$1.gecko && main.empty && betweenUneditable$1(anchor)) {
+               let dummy = document.createTextNode("");
+               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
+               anchor = head = new DOMPos$1(dummy, 0);
+               force = true;
+           }
+           let domSel = this.view.observer.selectionRange;
+           // If the selection is already here, or in an equivalent position, don't touch it
+           if (force || !domSel.focusNode ||
+               !isEquivalentPosition$1(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
+               !isEquivalentPosition$1(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
+               this.view.observer.ignore(() => {
+                   // Chrome Android will hide the virtual keyboard when tapping
+                   // inside an uneditable node, and not bring it back when we
+                   // move the cursor to its proper position. This tries to
+                   // restore the keyboard by cycling focus.
+                   if (browser$1.android && browser$1.chrome && this.dom.contains(domSel.focusNode) &&
+                       inUneditable$1(domSel.focusNode, this.dom)) {
+                       this.dom.blur();
+                       this.dom.focus({ preventScroll: true });
+                   }
+                   let rawSel = getSelection$1(this.root);
+                   if (main.empty) {
+                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
+                       if (browser$1.gecko) {
+                           let nextTo = nextToUneditable$1(anchor.node, anchor.offset);
+                           if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
+                               let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
+                               if (text)
+                                   anchor = new DOMPos$1(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
+                           }
+                       }
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       if (main.bidiLevel != null && domSel.cursorBidiLevel != null)
+                           domSel.cursorBidiLevel = main.bidiLevel;
+                   }
+                   else if (rawSel.extend) {
+                       // Selection.extend can be used to create an 'inverted' selection
+                       // (one where the focus is before the anchor), but not all
+                       // browsers support it yet.
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       rawSel.extend(head.node, head.offset);
+                   }
+                   else {
+                       // Primitive (IE) way
+                       let range = document.createRange();
+                       if (main.anchor > main.head)
+                           [anchor, head] = [head, anchor];
+                       range.setEnd(head.node, head.offset);
+                       range.setStart(anchor.node, anchor.offset);
+                       rawSel.removeAllRanges();
+                       rawSel.addRange(range);
+                   }
+               });
+               this.view.observer.setSelectionRange(anchor, head);
+           }
+           this.impreciseAnchor = anchor.precise ? null : new DOMPos$1(domSel.anchorNode, domSel.anchorOffset);
+           this.impreciseHead = head.precise ? null : new DOMPos$1(domSel.focusNode, domSel.focusOffset);
+       }
+       enforceCursorAssoc() {
+           if (this.compositionDeco.size)
+               return;
+           let cursor = this.view.state.selection.main;
+           let sel = getSelection$1(this.root);
+           if (!cursor.empty || !cursor.assoc || !sel.modify)
+               return;
+           let line = LineView$1.find(this, cursor.head);
+           if (!line)
+               return;
+           let lineStart = line.posAtStart;
+           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
+               return;
+           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
+           if (!before || !after || before.bottom > after.top)
+               return;
+           let dom = this.domAtPos(cursor.head + cursor.assoc);
+           sel.collapse(dom.node, dom.offset);
+           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
+       }
+       mayControlSelection() {
+           return this.view.state.facet(editable$1) ? this.root.activeElement == this.dom
+               : hasSelection$1(this.dom, this.view.observer.selectionRange);
+       }
+       nearest(dom) {
+           for (let cur = dom; cur;) {
+               let domView = ContentView$1.get(cur);
+               if (domView && domView.rootView == this)
+                   return domView;
+               cur = cur.parentNode;
+           }
+           return null;
+       }
+       posFromDOM(node, offset) {
+           let view = this.nearest(node);
+           if (!view)
+               throw new RangeError("Trying to find position for a DOM position outside of the document");
+           return view.localPosFromDOM(node, offset) + view.posAtStart;
+       }
+       domAtPos(pos) {
+           let { i, off } = this.childCursor().findPos(pos, -1);
+           for (; i < this.children.length - 1;) {
+               let child = this.children[i];
+               if (off < child.length || child instanceof LineView$1)
+                   break;
+               i++;
+               off = 0;
+           }
+           return this.children[i].domAtPos(off);
+       }
+       coordsAt(pos, side) {
+           for (let off = this.length, i = this.children.length - 1;; i--) {
+               let child = this.children[i], start = off - child.breakAfter - child.length;
+               if (pos > start ||
+                   (pos == start && child.type != BlockType$1.WidgetBefore && child.type != BlockType$1.WidgetAfter &&
+                       (!i || side == 2 || this.children[i - 1].breakAfter ||
+                           (this.children[i - 1].type == BlockType$1.WidgetBefore && side > -2))))
+                   return child.coordsAt(pos - start, side);
+               off = start;
+           }
+       }
+       measureVisibleLineHeights(viewport) {
+           let result = [], { from, to } = viewport;
+           let contentWidth = this.view.contentDOM.clientWidth;
+           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
+           let widest = -1, ltr = this.view.textDirection == Direction$1.LTR;
+           for (let pos = 0, i = 0; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (end > to)
+                   break;
+               if (pos >= from) {
+                   let childRect = child.dom.getBoundingClientRect();
+                   result.push(childRect.height);
+                   if (isWider) {
+                       let last = child.dom.lastChild;
+                       let rects = last ? clientRectsFor$1(last) : [];
+                       if (rects.length) {
+                           let rect = rects[rects.length - 1];
+                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
+                           if (width > widest) {
+                               widest = width;
+                               this.minWidth = contentWidth;
+                               this.minWidthFrom = pos;
+                               this.minWidthTo = end;
+                           }
+                       }
+                   }
+               }
+               pos = end + child.breakAfter;
+           }
+           return result;
+       }
+       textDirectionAt(pos) {
+           let { i } = this.childPos(pos, 1);
+           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction$1.RTL : Direction$1.LTR;
+       }
+       measureTextSize() {
+           for (let child of this.children) {
+               if (child instanceof LineView$1) {
+                   let measure = child.measureTextSize();
+                   if (measure)
+                       return measure;
+               }
+           }
+           // If no workable line exists, force a layout of a measurable element
+           let dummy = document.createElement("div"), lineHeight, charWidth;
+           dummy.className = "cm-line";
+           dummy.textContent = "abc def ghi jkl mno pqr stu";
+           this.view.observer.ignore(() => {
+               this.dom.appendChild(dummy);
+               let rect = clientRectsFor$1(dummy.firstChild)[0];
+               lineHeight = dummy.getBoundingClientRect().height;
+               charWidth = rect ? rect.width / 27 : 7;
+               dummy.remove();
+           });
+           return { lineHeight, charWidth };
+       }
+       childCursor(pos = this.length) {
+           // Move back to start of last element when possible, so that
+           // `ChildCursor.findPos` doesn't have to deal with the edge case
+           // of being after the last element.
+           let i = this.children.length;
+           if (i)
+               pos -= this.children[--i].length;
+           return new ChildCursor$1(this.children, pos, i);
+       }
+       computeBlockGapDeco() {
+           let deco = [], vs = this.view.viewState;
+           for (let pos = 0, i = 0;; i++) {
+               let next = i == vs.viewports.length ? null : vs.viewports[i];
+               let end = next ? next.from - 1 : this.length;
+               if (end > pos) {
+                   let height = vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top;
+                   deco.push(Decoration$1.replace({
+                       widget: new BlockGapWidget$1(height),
+                       block: true,
+                       inclusive: true,
+                       isBlockGap: true,
+                   }).range(pos, end));
+               }
+               if (!next)
+                   break;
+               pos = next.to + 1;
+           }
+           return Decoration$1.set(deco);
+       }
+       updateDeco() {
+           let allDeco = this.view.state.facet(decorations$1).map((d, i) => {
+               let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
+               return dynamic ? d(this.view) : d;
+           });
+           for (let i = allDeco.length; i < allDeco.length + 3; i++)
+               this.dynamicDecorationMap[i] = false;
+           return this.decorations = [
+               ...allDeco,
+               this.compositionDeco,
+               this.computeBlockGapDeco(),
+               this.view.viewState.lineGapDeco
+           ];
+       }
+       scrollIntoView(target) {
+           let { range } = target;
+           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
+           if (!rect)
+               return;
+           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
+               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
+                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
+           let mLeft = 0, mRight = 0, mTop = 0, mBottom = 0;
+           for (let margins of this.view.state.facet(scrollMargins$1).map(f => f(this.view)))
+               if (margins) {
+                   let { left, right, top, bottom } = margins;
+                   if (left != null)
+                       mLeft = Math.max(mLeft, left);
+                   if (right != null)
+                       mRight = Math.max(mRight, right);
+                   if (top != null)
+                       mTop = Math.max(mTop, top);
+                   if (bottom != null)
+                       mBottom = Math.max(mBottom, bottom);
+               }
+           let targetRect = {
+               left: rect.left - mLeft, top: rect.top - mTop,
+               right: rect.right + mRight, bottom: rect.bottom + mBottom
+           };
+           scrollRectIntoView$1(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction$1.LTR);
+       }
+   };
+   function betweenUneditable$1(pos) {
+       return pos.node.nodeType == 1 && pos.node.firstChild &&
+           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
+           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
+   }
+   let BlockGapWidget$1 = class BlockGapWidget extends WidgetType$1 {
+       constructor(height) {
+           super();
+           this.height = height;
+       }
+       toDOM() {
+           let elt = document.createElement("div");
+           this.updateDOM(elt);
+           return elt;
+       }
+       eq(other) { return other.height == this.height; }
+       updateDOM(elt) {
+           elt.style.height = this.height + "px";
+           return true;
+       }
+       get estimatedHeight() { return this.height; }
+   };
+   function compositionSurroundingNode(view) {
+       let sel = view.observer.selectionRange;
+       let textNode = sel.focusNode && nearbyTextNode(sel.focusNode, sel.focusOffset, 0);
+       if (!textNode)
+           return null;
+       let cView = view.docView.nearest(textNode);
+       if (!cView)
+           return null;
+       if (cView instanceof LineView$1) {
+           let topNode = textNode;
+           while (topNode.parentNode != cView.dom)
+               topNode = topNode.parentNode;
+           let prev = topNode.previousSibling;
+           while (prev && !ContentView$1.get(prev))
+               prev = prev.previousSibling;
+           let pos = prev ? ContentView$1.get(prev).posAtEnd : cView.posAtStart;
+           return { from: pos, to: pos, node: topNode, text: textNode };
+       }
+       else {
+           for (;;) {
+               let { parent } = cView;
+               if (!parent)
+                   return null;
+               if (parent instanceof LineView$1)
+                   break;
+               cView = parent;
+           }
+           let from = cView.posAtStart;
+           return { from, to: from + cView.length, node: cView.dom, text: textNode };
+       }
+   }
+   function computeCompositionDeco(view, changes) {
+       let surrounding = compositionSurroundingNode(view);
+       if (!surrounding)
+           return Decoration$1.none;
+       let { from, to, node, text: textNode } = surrounding;
+       let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
+       let { state } = view, text = node.nodeType == 3 ? node.nodeValue :
+           new DOMReader$1([], state).readRange(node.firstChild, null).text;
+       if (newTo - newFrom < text.length) {
+           if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder$1) == text)
+               newTo = newFrom + text.length;
+           else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder$1) == text)
+               newFrom = newTo - text.length;
+           else
+               return Decoration$1.none;
+       }
+       else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder$1) != text) {
+           return Decoration$1.none;
+       }
+       let topView = ContentView$1.get(node);
+       if (topView instanceof CompositionView)
+           topView = topView.widget.topView;
+       else if (topView)
+           topView.parent = null;
+       return Decoration$1.set(Decoration$1.replace({ widget: new CompositionWidget(node, textNode, topView), inclusive: true })
+           .range(newFrom, newTo));
+   }
+   class CompositionWidget extends WidgetType$1 {
+       constructor(top, text, topView) {
+           super();
+           this.top = top;
+           this.text = text;
+           this.topView = topView;
+       }
+       eq(other) { return this.top == other.top && this.text == other.text; }
+       toDOM() { return this.top; }
+       ignoreEvent() { return false; }
+       get customView() { return CompositionView; }
+   }
+   function nearbyTextNode(node, offset, side) {
+       for (;;) {
+           if (node.nodeType == 3)
+               return node;
+           if (node.nodeType == 1 && offset > 0 && side <= 0) {
+               node = node.childNodes[offset - 1];
+               offset = maxOffset$1(node);
+           }
+           else if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {
+               node = node.childNodes[offset];
+               offset = 0;
+           }
+           else {
+               return null;
+           }
+       }
+   }
+   function nextToUneditable$1(node, offset) {
+       if (node.nodeType != 1)
+           return 0;
+       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
+           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
+   }
+   let DecorationComparator$1$1 = class DecorationComparator$1 {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange(from, to) { addRange$1(from, to, this.changes); }
+       comparePoint(from, to) { addRange$1(from, to, this.changes); }
+   };
+   function findChangedDeco$1(a, b, diff) {
+       let comp = new DecorationComparator$1$1;
+       RangeSet$1.compare(a, b, diff, comp);
+       return comp.changes;
+   }
+   function inUneditable$1(node, inside) {
+       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
+           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
+               return true;
+           }
+       }
+       return false;
+   }
+
+   function groupAt$1(state, pos, bias = 1) {
+       let categorize = state.charCategorizer(pos);
+       let line = state.doc.lineAt(pos), linePos = pos - line.from;
+       if (line.length == 0)
+           return EditorSelection$1.cursor(pos);
+       if (linePos == 0)
+           bias = 1;
+       else if (linePos == line.length)
+           bias = -1;
+       let from = linePos, to = linePos;
+       if (bias < 0)
+           from = findClusterBreak$2(line.text, linePos, false);
+       else
+           to = findClusterBreak$2(line.text, linePos);
+       let cat = categorize(line.text.slice(from, to));
+       while (from > 0) {
+           let prev = findClusterBreak$2(line.text, from, false);
+           if (categorize(line.text.slice(prev, from)) != cat)
+               break;
+           from = prev;
+       }
+       while (to < line.length) {
+           let next = findClusterBreak$2(line.text, to);
+           if (categorize(line.text.slice(to, next)) != cat)
+               break;
+           to = next;
+       }
+       return EditorSelection$1.range(from + line.from, to + line.from);
+   }
+   // Search the DOM for the {node, offset} position closest to the given
+   // coordinates. Very inefficient and crude, but can usually be avoided
+   // by calling caret(Position|Range)FromPoint instead.
+   function getdx$1(x, rect) {
+       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
+   }
+   function getdy$1(y, rect) {
+       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
+   }
+   function yOverlap$1(a, b) {
+       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
+   }
+   function upTop$1(rect, top) {
+       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
+   }
+   function upBot$1(rect, bottom) {
+       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
+   }
+   function domPosAtCoords$1(parent, x, y) {
+       let closest, closestRect, closestX, closestY;
+       let above, below, aboveRect, belowRect;
+       for (let child = parent.firstChild; child; child = child.nextSibling) {
+           let rects = clientRectsFor$1(child);
+           for (let i = 0; i < rects.length; i++) {
+               let rect = rects[i];
+               if (closestRect && yOverlap$1(closestRect, rect))
+                   rect = upTop$1(upBot$1(rect, closestRect.bottom), closestRect.top);
+               let dx = getdx$1(x, rect), dy = getdy$1(y, rect);
+               if (dx == 0 && dy == 0)
+                   return child.nodeType == 3 ? domPosInText$1(child, x, y) : domPosAtCoords$1(child, x, y);
+               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
+                   closest = child;
+                   closestRect = rect;
+                   closestX = dx;
+                   closestY = dy;
+               }
+               if (dx == 0) {
+                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
+                       above = child;
+                       aboveRect = rect;
+                   }
+                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
+                       below = child;
+                       belowRect = rect;
+                   }
+               }
+               else if (aboveRect && yOverlap$1(aboveRect, rect)) {
+                   aboveRect = upBot$1(aboveRect, rect.bottom);
+               }
+               else if (belowRect && yOverlap$1(belowRect, rect)) {
+                   belowRect = upTop$1(belowRect, rect.top);
+               }
+           }
+       }
+       if (aboveRect && aboveRect.bottom >= y) {
+           closest = above;
+           closestRect = aboveRect;
+       }
+       else if (belowRect && belowRect.top <= y) {
+           closest = below;
+           closestRect = belowRect;
+       }
+       if (!closest)
+           return { node: parent, offset: 0 };
+       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
+       if (closest.nodeType == 3)
+           return domPosInText$1(closest, clipX, y);
+       if (!closestX && closest.contentEditable == "true")
+           return domPosAtCoords$1(closest, clipX, y);
+       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
+           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
+       return { node: parent, offset };
+   }
+   function domPosInText$1(node, x, y) {
+       let len = node.nodeValue.length;
+       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
+       for (let i = 0; i < len; i++) {
+           let rects = textRange$1(node, i, i + 1).getClientRects();
+           for (let j = 0; j < rects.length; j++) {
+               let rect = rects[j];
+               if (rect.top == rect.bottom)
+                   continue;
+               if (!generalSide)
+                   generalSide = x - rect.left;
+               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
+               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
+                   let right = x >= (rect.left + rect.right) / 2, after = right;
+                   if (browser$1.chrome || browser$1.gecko) {
+                       // Check for RTL on browsers that support getting client
+                       // rects for empty ranges.
+                       let rectBefore = textRange$1(node, i).getBoundingClientRect();
+                       if (rectBefore.left == rect.right)
+                           after = !right;
+                   }
+                   if (dy <= 0)
+                       return { node, offset: i + (after ? 1 : 0) };
+                   closestOffset = i + (after ? 1 : 0);
+                   closestDY = dy;
+               }
+           }
+       }
+       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
+   }
+   function posAtCoords$1(view, { x, y }, precise, bias = -1) {
+       var _a;
+       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
+       let block, { docHeight } = view.viewState;
+       let yOffset = y - docTop;
+       if (yOffset < 0)
+           return 0;
+       if (yOffset > docHeight)
+           return view.state.doc.length;
+       // Scan for a text block near the queried y position
+       for (let halfLine = view.defaultLineHeight / 2, bounced = false;;) {
+           block = view.elementAtHeight(yOffset);
+           if (block.type == BlockType$1.Text)
+               break;
+           for (;;) {
+               // Move the y position out of this block
+               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
+               if (yOffset >= 0 && yOffset <= docHeight)
+                   break;
+               // If the document consists entirely of replaced widgets, we
+               // won't find a text block, so return 0
+               if (bounced)
+                   return precise ? null : 0;
+               bounced = true;
+               bias = -bias;
+           }
+       }
+       y = docTop + yOffset;
+       let lineStart = block.from;
+       // If this is outside of the rendered viewport, we can't determine a position
+       if (lineStart < view.viewport.from)
+           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise$1(view, content, block, x, y);
+       if (lineStart > view.viewport.to)
+           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
+               precise ? null : posAtCoordsImprecise$1(view, content, block, x, y);
+       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
+       let doc = view.dom.ownerDocument;
+       let root = view.root.elementFromPoint ? view.root : doc;
+       let element = root.elementFromPoint(x, y);
+       if (element && !view.contentDOM.contains(element))
+           element = null;
+       // If the element is unexpected, clip x at the sides of the content area and try again
+       if (!element) {
+           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
+           element = root.elementFromPoint(x, y);
+           if (element && !view.contentDOM.contains(element))
+               element = null;
+       }
+       // There's visible editor content under the point, so we can try
+       // using caret(Position|Range)FromPoint as a shortcut
+       let node, offset = -1;
+       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
+           if (doc.caretPositionFromPoint) {
+               let pos = doc.caretPositionFromPoint(x, y);
+               if (pos)
+                   ({ offsetNode: node, offset } = pos);
+           }
+           else if (doc.caretRangeFromPoint) {
+               let range = doc.caretRangeFromPoint(x, y);
+               if (range) {
+                   ({ startContainer: node, startOffset: offset } = range);
+                   if (browser$1.safari && isSuspiciousCaretResult(node, offset, x))
+                       node = undefined;
+               }
+           }
+       }
+       // No luck, do our own (potentially expensive) search
+       if (!node || !view.docView.dom.contains(node)) {
+           let line = LineView$1.find(view.docView, lineStart);
+           if (!line)
+               return yOffset > block.top + block.height / 2 ? block.to : block.from;
+           ({ node, offset } = domPosAtCoords$1(line.dom, x, y));
+       }
+       return view.docView.posFromDOM(node, offset);
+   }
+   function posAtCoordsImprecise$1(view, contentRect, block, x, y) {
+       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
+       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
+           let line = Math.floor((y - block.top) / view.defaultLineHeight);
+           into += line * view.viewState.heightOracle.lineLength;
+       }
+       let content = view.state.sliceDoc(block.from, block.to);
+       return block.from + findColumn$1(content, into, view.state.tabSize);
+   }
+   // In case of a high line height, Safari's caretRangeFromPoint treats
+   // the space between lines as belonging to the last character of the
+   // line before. This is used to detect such a result so that it can be
+   // ignored (issue #401).
+   function isSuspiciousCaretResult(node, offset, x) {
+       let len;
+       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
+           return false;
+       for (let next = node.nextSibling; next; next = next.nextSibling)
+           if (next.nodeType != 1 || next.nodeName != "BR")
+               return false;
+       return textRange$1(node, len - 1, len).getBoundingClientRect().left > x;
+   }
+   function moveToLineBoundary$1(view, start, forward, includeWrap) {
+       let line = view.state.doc.lineAt(start.head);
+       let coords = !includeWrap || !view.lineWrapping ? null
+           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
+       if (coords) {
+           let editorRect = view.dom.getBoundingClientRect();
+           let direction = view.textDirectionAt(line.from);
+           let pos = view.posAtCoords({ x: forward == (direction == Direction$1.LTR) ? editorRect.right - 1 : editorRect.left + 1,
+               y: (coords.top + coords.bottom) / 2 });
+           if (pos != null)
+               return EditorSelection$1.cursor(pos, forward ? -1 : 1);
+       }
+       let lineView = LineView$1.find(view.docView, start.head);
+       let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
+       return EditorSelection$1.cursor(end, forward ? -1 : 1);
+   }
+   function moveByChar$1(view, start, forward, by) {
+       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
+       let direction = view.textDirectionAt(line.from);
+       for (let cur = start, check = null;;) {
+           let next = moveVisually$1(line, spans, direction, cur, forward), char = movedOver$1;
+           if (!next) {
+               if (line.number == (forward ? view.state.doc.lines : 1))
+                   return cur;
+               char = "\n";
+               line = view.state.doc.line(line.number + (forward ? 1 : -1));
+               spans = view.bidiSpans(line);
+               next = EditorSelection$1.cursor(forward ? line.from : line.to);
+           }
+           if (!check) {
+               if (!by)
+                   return next;
+               check = by(char);
+           }
+           else if (!check(char)) {
+               return cur;
+           }
+           cur = next;
+       }
+   }
+   function byGroup$1(view, pos, start) {
+       let categorize = view.state.charCategorizer(pos);
+       let cat = categorize(start);
+       return (next) => {
+           let nextCat = categorize(next);
+           if (cat == CharCategory$1.Space)
+               cat = nextCat;
+           return cat == nextCat;
+       };
+   }
+   function moveVertically$1(view, start, forward, distance) {
+       let startPos = start.head, dir = forward ? 1 : -1;
+       if (startPos == (forward ? view.state.doc.length : 0))
+           return EditorSelection$1.cursor(startPos, start.assoc);
+       let goal = start.goalColumn, startY;
+       let rect = view.contentDOM.getBoundingClientRect();
+       let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;
+       if (startCoords) {
+           if (goal == null)
+               goal = startCoords.left - rect.left;
+           startY = dir < 0 ? startCoords.top : startCoords.bottom;
+       }
+       else {
+           let line = view.viewState.lineBlockAt(startPos);
+           if (goal == null)
+               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
+           startY = (dir < 0 ? line.top : line.bottom) + docTop;
+       }
+       let resolvedGoal = rect.left + goal;
+       let dist = distance !== null && distance !== void 0 ? distance : (view.defaultLineHeight >> 1);
+       for (let extra = 0;; extra += 10) {
+           let curY = startY + (dist + extra) * dir;
+           let pos = posAtCoords$1(view, { x: resolvedGoal, y: curY }, false, dir);
+           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))
+               return EditorSelection$1.cursor(pos, start.assoc, undefined, goal);
+       }
+   }
+   function skipAtoms$1(view, oldPos, pos) {
+       let atoms = view.state.facet(atomicRanges$1).map(f => f(view));
+       for (;;) {
+           let moved = false;
+           for (let set of atoms) {
+               set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
+                   if (pos.from > from && pos.from < to) {
+                       pos = oldPos.from > pos.from ? EditorSelection$1.cursor(from, 1) : EditorSelection$1.cursor(to, -1);
+                       moved = true;
+                   }
+               });
+           }
+           if (!moved)
+               return pos;
+       }
+   }
+
+   // This will also be where dragging info and such goes
+   let InputState$1 = class InputState {
+       constructor(view) {
+           this.lastKeyCode = 0;
+           this.lastKeyTime = 0;
+           this.chromeScrollHack = -1;
+           // On iOS, some keys need to have their default behavior happen
+           // (after which we retroactively handle them and reset the DOM) to
+           // avoid messing up the virtual keyboard state.
+           this.pendingIOSKey = undefined;
+           this.lastSelectionOrigin = null;
+           this.lastSelectionTime = 0;
+           this.lastEscPress = 0;
+           this.lastContextMenu = 0;
+           this.scrollHandlers = [];
+           this.registeredEvents = [];
+           this.customHandlers = [];
+           // -1 means not in a composition. Otherwise, this counts the number
+           // of changes made during the composition. The count is used to
+           // avoid treating the start state of the composition, before any
+           // changes have been made, as part of the composition.
+           this.composing = -1;
+           // Tracks whether the next change should be marked as starting the
+           // composition (null means no composition, true means next is the
+           // first, false means first has already been marked for this
+           // composition)
+           this.compositionFirstChange = null;
+           this.compositionEndedAt = 0;
+           this.rapidCompositionStart = false;
+           this.mouseSelection = null;
+           for (let type in handlers$1) {
+               let handler = handlers$1[type];
+               view.contentDOM.addEventListener(type, (event) => {
+                   if (!eventBelongsToEditor$1(view, event) || this.ignoreDuringComposition(event))
+                       return;
+                   if (type == "keydown" && this.keydown(view, event))
+                       return;
+                   if (this.mustFlushObserver(event))
+                       view.observer.forceFlush();
+                   if (this.runCustomHandlers(type, view, event))
+                       event.preventDefault();
+                   else
+                       handler(view, event);
+               });
+               this.registeredEvents.push(type);
+           }
+           if (browser$1.chrome && browser$1.chrome_version >= 102) {
+               // On Chrome 102, viewport updates somehow stop wheel-based
+               // scrolling. Turning off pointer events during the scroll seems
+               // to avoid the issue.
+               view.scrollDOM.addEventListener("wheel", () => {
+                   if (this.chromeScrollHack < 0)
+                       view.contentDOM.style.pointerEvents = "none";
+                   else
+                       window.clearTimeout(this.chromeScrollHack);
+                   this.chromeScrollHack = setTimeout(() => {
+                       this.chromeScrollHack = -1;
+                       view.contentDOM.style.pointerEvents = "";
+                   }, 100);
+               }, { passive: true });
+           }
+           this.notifiedFocused = view.hasFocus;
+           // On Safari adding an input event handler somehow prevents an
+           // issue where the composition vanishes when you press enter.
+           if (browser$1.safari)
+               view.contentDOM.addEventListener("input", () => null);
+       }
+       setSelectionOrigin(origin) {
+           this.lastSelectionOrigin = origin;
+           this.lastSelectionTime = Date.now();
+       }
+       ensureHandlers(view, plugins) {
+           var _a;
+           let handlers;
+           this.customHandlers = [];
+           for (let plugin of plugins)
+               if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {
+                   this.customHandlers.push({ plugin: plugin.value, handlers });
+                   for (let type in handlers)
+                       if (this.registeredEvents.indexOf(type) < 0 && type != "scroll") {
+                           this.registeredEvents.push(type);
+                           view.contentDOM.addEventListener(type, (event) => {
+                               if (!eventBelongsToEditor$1(view, event))
+                                   return;
+                               if (this.runCustomHandlers(type, view, event))
+                                   event.preventDefault();
+                           });
+                       }
+               }
+       }
+       runCustomHandlers(type, view, event) {
+           for (let set of this.customHandlers) {
+               let handler = set.handlers[type];
+               if (handler) {
+                   try {
+                       if (handler.call(set.plugin, event, view) || event.defaultPrevented)
+                           return true;
+                   }
+                   catch (e) {
+                       logException$1(view.state, e);
+                   }
+               }
+           }
+           return false;
+       }
+       runScrollHandlers(view, event) {
+           for (let set of this.customHandlers) {
+               let handler = set.handlers.scroll;
+               if (handler) {
+                   try {
+                       handler.call(set.plugin, event, view);
+                   }
+                   catch (e) {
+                       logException$1(view.state, e);
+                   }
+               }
+           }
+       }
+       keydown(view, event) {
+           // Must always run, even if a custom handler handled the event
+           this.lastKeyCode = event.keyCode;
+           this.lastKeyTime = Date.now();
+           if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
+               return true;
+           // Chrome for Android usually doesn't fire proper key events, but
+           // occasionally does, usually surrounded by a bunch of complicated
+           // composition changes. When an enter or backspace key event is
+           // seen, hold off on handling DOM events for a bit, and then
+           // dispatch it.
+           if (browser$1.android && browser$1.chrome && !event.synthetic &&
+               (event.keyCode == 13 || event.keyCode == 8)) {
+               view.observer.delayAndroidKey(event.key, event.keyCode);
+               return true;
+           }
+           // Prevent the default behavior of Enter on iOS makes the
+           // virtual keyboard get stuck in the wrong (lowercase)
+           // state. So we let it go through, and then, in
+           // applyDOMChange, notify key handlers of it and reset to
+           // the state they produce.
+           let pending;
+           if (browser$1.ios && (pending = PendingKeys$1.find(key => key.keyCode == event.keyCode)) &&
+               !(event.ctrlKey || event.altKey || event.metaKey) && !event.synthetic) {
+               this.pendingIOSKey = pending;
+               setTimeout(() => this.flushIOSKey(view), 250);
+               return true;
+           }
+           return false;
+       }
+       flushIOSKey(view) {
+           let key = this.pendingIOSKey;
+           if (!key)
+               return false;
+           this.pendingIOSKey = undefined;
+           return dispatchKey$1(view.contentDOM, key.key, key.keyCode);
+       }
+       ignoreDuringComposition(event) {
+           if (!/^key/.test(event.type))
+               return false;
+           if (this.composing > 0)
+               return true;
+           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
+           // On some input method editors (IMEs), the Enter key is used to
+           // confirm character selection. On Safari, when Enter is pressed,
+           // compositionend and keydown events are sometimes emitted in the
+           // wrong order. The key event should still be ignored, even when
+           // it happens after the compositionend event.
+           if (browser$1.safari && Date.now() - this.compositionEndedAt < 100) {
+               this.compositionEndedAt = 0;
+               return true;
+           }
+           return false;
+       }
+       mustFlushObserver(event) {
+           return (event.type == "keydown" && event.keyCode != 229) ||
+               event.type == "compositionend" && !browser$1.ios;
+       }
+       startMouseSelection(mouseSelection) {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+           this.mouseSelection = mouseSelection;
+       }
+       update(update) {
+           if (this.mouseSelection)
+               this.mouseSelection.update(update);
+           if (update.transactions.length)
+               this.lastKeyCode = this.lastSelectionTime = 0;
+       }
+       destroy() {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+       }
+   };
+   const PendingKeys$1 = [
+       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
+       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
+       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
+   ];
+   // Key codes for modifier keys
+   const modifierCodes$1 = [16, 17, 18, 20, 91, 92, 224, 225];
+   let MouseSelection$1 = class MouseSelection {
+       constructor(view, startEvent, style, mustSelect) {
+           this.view = view;
+           this.style = style;
+           this.mustSelect = mustSelect;
+           this.lastEvent = startEvent;
+           let doc = view.contentDOM.ownerDocument;
+           doc.addEventListener("mousemove", this.move = this.move.bind(this));
+           doc.addEventListener("mouseup", this.up = this.up.bind(this));
+           this.extend = startEvent.shiftKey;
+           this.multiple = view.state.facet(EditorState$1.allowMultipleSelections) && addsSelectionRange$1(view, startEvent);
+           this.dragMove = dragMovesSelection$2(view, startEvent);
+           this.dragging = isInPrimarySelection$1(view, startEvent) && getClickType$1(startEvent) == 1 ? null : false;
+           // When clicking outside of the selection, immediately apply the
+           // effect of starting the selection
+           if (this.dragging === false) {
+               startEvent.preventDefault();
+               this.select(startEvent);
+           }
+       }
+       move(event) {
+           if (event.buttons == 0)
+               return this.destroy();
+           if (this.dragging !== false)
+               return;
+           this.select(this.lastEvent = event);
+       }
+       up(event) {
+           if (this.dragging == null)
+               this.select(this.lastEvent);
+           if (!this.dragging)
+               event.preventDefault();
+           this.destroy();
+       }
+       destroy() {
+           let doc = this.view.contentDOM.ownerDocument;
+           doc.removeEventListener("mousemove", this.move);
+           doc.removeEventListener("mouseup", this.up);
+           this.view.inputState.mouseSelection = null;
+       }
+       select(event) {
+           let selection = this.style.get(event, this.extend, this.multiple);
+           if (this.mustSelect || !selection.eq(this.view.state.selection) ||
+               selection.main.assoc != this.view.state.selection.main.assoc)
+               this.view.dispatch({
+                   selection,
+                   userEvent: "select.pointer",
+                   scrollIntoView: true
+               });
+           this.mustSelect = false;
+       }
+       update(update) {
+           if (update.docChanged && this.dragging)
+               this.dragging = this.dragging.map(update.changes);
+           if (this.style.update(update))
+               setTimeout(() => this.select(this.lastEvent), 20);
+       }
+   };
+   function addsSelectionRange$1(view, event) {
+       let facet = view.state.facet(clickAddsSelectionRange$1);
+       return facet.length ? facet[0](event) : browser$1.mac ? event.metaKey : event.ctrlKey;
+   }
+   function dragMovesSelection$2(view, event) {
+       let facet = view.state.facet(dragMovesSelection$1$1);
+       return facet.length ? facet[0](event) : browser$1.mac ? !event.altKey : !event.ctrlKey;
+   }
+   function isInPrimarySelection$1(view, event) {
+       let { main } = view.state.selection;
+       if (main.empty)
+           return false;
+       // On boundary clicks, check whether the coordinates are inside the
+       // selection's client rectangles
+       let sel = getSelection$1(view.root);
+       if (sel.rangeCount == 0)
+           return true;
+       let rects = sel.getRangeAt(0).getClientRects();
+       for (let i = 0; i < rects.length; i++) {
+           let rect = rects[i];
+           if (rect.left <= event.clientX && rect.right >= event.clientX &&
+               rect.top <= event.clientY && rect.bottom >= event.clientY)
+               return true;
+       }
+       return false;
+   }
+   function eventBelongsToEditor$1(view, event) {
+       if (!event.bubbles)
+           return true;
+       if (event.defaultPrevented)
+           return false;
+       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
+           if (!node || node.nodeType == 11 || ((cView = ContentView$1.get(node)) && cView.ignoreEvent(event)))
+               return false;
+       return true;
+   }
+   const handlers$1 = /*@__PURE__*/Object.create(null);
+   // This is very crude, but unfortunately both these browsers _pretend_
+   // that they have a clipboard API—all the objects and methods are
+   // there, they just don't work, and they are hard to test.
+   const brokenClipboardAPI$1 = (browser$1.ie && browser$1.ie_version < 15) ||
+       (browser$1.ios && browser$1.webkit_version < 604);
+   function capturePaste$1(view) {
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.focus();
+       setTimeout(() => {
+           view.focus();
+           target.remove();
+           doPaste$1(view, target.value);
+       }, 50);
+   }
+   function doPaste$1(view, input) {
+       let { state } = view, changes, i = 1, text = state.toText(input);
+       let byLine = text.lines == state.selection.ranges.length;
+       let linewise = lastLinewiseCopy$1 != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy$1 == text.toString();
+       if (linewise) {
+           let lastLine = -1;
+           changes = state.changeByRange(range => {
+               let line = state.doc.lineAt(range.from);
+               if (line.from == lastLine)
+                   return { range };
+               lastLine = line.from;
+               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
+               return { changes: { from: line.from, insert },
+                   range: EditorSelection$1.cursor(range.from + insert.length) };
+           });
+       }
+       else if (byLine) {
+           changes = state.changeByRange(range => {
+               let line = text.line(i++);
+               return { changes: { from: range.from, to: range.to, insert: line.text },
+                   range: EditorSelection$1.cursor(range.from + line.length) };
+           });
+       }
+       else {
+           changes = state.replaceSelection(text);
+       }
+       view.dispatch(changes, {
+           userEvent: "input.paste",
+           scrollIntoView: true
+       });
+   }
+   handlers$1.keydown = (view, event) => {
+       view.inputState.setSelectionOrigin("select");
+       if (event.keyCode == 27)
+           view.inputState.lastEscPress = Date.now();
+       else if (modifierCodes$1.indexOf(event.keyCode) < 0)
+           view.inputState.lastEscPress = 0;
+   };
+   let lastTouch = 0;
+   handlers$1.touchstart = (view, e) => {
+       lastTouch = Date.now();
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   handlers$1.touchmove = view => {
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   handlers$1.mousedown = (view, event) => {
+       view.observer.flush();
+       if (lastTouch > Date.now() - 2000 && getClickType$1(event) == 1)
+           return; // Ignore touch interaction
+       let style = null;
+       for (let makeStyle of view.state.facet(mouseSelectionStyle$1)) {
+           style = makeStyle(view, event);
+           if (style)
+               break;
+       }
+       if (!style && event.button == 0)
+           style = basicMouseSelection$1(view, event);
+       if (style) {
+           let mustFocus = view.root.activeElement != view.contentDOM;
+           if (mustFocus)
+               view.observer.ignore(() => focusPreventScroll$1(view.contentDOM));
+           view.inputState.startMouseSelection(new MouseSelection$1(view, event, style, mustFocus));
+       }
+   };
+   function rangeForClick$1(view, pos, bias, type) {
+       if (type == 1) { // Single click
+           return EditorSelection$1.cursor(pos, bias);
+       }
+       else if (type == 2) { // Double click
+           return groupAt$1(view.state, pos, bias);
+       }
+       else { // Triple click
+           let visual = LineView$1.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
+           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
+           if (to < view.state.doc.length && to == line.to)
+               to++;
+           return EditorSelection$1.range(from, to);
+       }
+   }
+   let insideY = (y, rect) => y >= rect.top && y <= rect.bottom;
+   let inside$1 = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right;
+   // Try to determine, for the given coordinates, associated with the
+   // given position, whether they are related to the element before or
+   // the element after the position.
+   function findPositionSide$1(view, pos, x, y) {
+       let line = LineView$1.find(view.docView, pos);
+       if (!line)
+           return 1;
+       let off = pos - line.posAtStart;
+       // Line boundaries point into the line
+       if (off == 0)
+           return 1;
+       if (off == line.length)
+           return -1;
+       // Positions on top of an element point at that element
+       let before = line.coordsAt(off, -1);
+       if (before && inside$1(x, y, before))
+           return -1;
+       let after = line.coordsAt(off, 1);
+       if (after && inside$1(x, y, after))
+           return 1;
+       // This is probably a line wrap point. Pick before if the point is
+       // beside it.
+       return before && insideY(y, before) ? -1 : 1;
+   }
+   function queryPos$1(view, event) {
+       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       return { pos, bias: findPositionSide$1(view, pos, event.clientX, event.clientY) };
+   }
+   const BadMouseDetail$1 = browser$1.ie && browser$1.ie_version <= 11;
+   let lastMouseDown$1 = null, lastMouseDownCount$1 = 0, lastMouseDownTime$1 = 0;
+   function getClickType$1(event) {
+       if (!BadMouseDetail$1)
+           return event.detail;
+       let last = lastMouseDown$1, lastTime = lastMouseDownTime$1;
+       lastMouseDown$1 = event;
+       lastMouseDownTime$1 = Date.now();
+       return lastMouseDownCount$1 = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
+           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount$1 + 1) % 3 : 1;
+   }
+   function basicMouseSelection$1(view, event) {
+       let start = queryPos$1(view, event), type = getClickType$1(event);
+       let startSel = view.state.selection;
+       let last = start, lastEvent = event;
+       return {
+           update(update) {
+               if (update.docChanged) {
+                   if (start)
+                       start.pos = update.changes.mapPos(start.pos);
+                   startSel = startSel.map(update.changes);
+                   lastEvent = null;
+               }
+           },
+           get(event, extend, multiple) {
+               let cur;
+               if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
+                   cur = last;
+               else {
+                   cur = last = queryPos$1(view, event);
+                   lastEvent = event;
+               }
+               if (!cur || !start)
+                   return startSel;
+               let range = rangeForClick$1(view, cur.pos, cur.bias, type);
+               if (start.pos != cur.pos && !extend) {
+                   let startRange = rangeForClick$1(view, start.pos, start.bias, type);
+                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
+                   range = from < range.from ? EditorSelection$1.range(from, to) : EditorSelection$1.range(to, from);
+               }
+               if (extend)
+                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
+               else if (multiple)
+                   return startSel.addRange(range);
+               else
+                   return EditorSelection$1.create([range]);
+           }
+       };
+   }
+   handlers$1.dragstart = (view, event) => {
+       let { selection: { main } } = view.state;
+       let { mouseSelection } = view.inputState;
+       if (mouseSelection)
+           mouseSelection.dragging = main;
+       if (event.dataTransfer) {
+           event.dataTransfer.setData("Text", view.state.sliceDoc(main.from, main.to));
+           event.dataTransfer.effectAllowed = "copyMove";
+       }
+   };
+   function dropText$1(view, event, text, direct) {
+       if (!text)
+           return;
+       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       event.preventDefault();
+       let { mouseSelection } = view.inputState;
+       let del = direct && mouseSelection && mouseSelection.dragging && mouseSelection.dragMove ?
+           { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;
+       let ins = { from: dropPos, insert: text };
+       let changes = view.state.changes(del ? [del, ins] : ins);
+       view.focus();
+       view.dispatch({
+           changes,
+           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
+           userEvent: del ? "move.drop" : "input.drop"
+       });
+   }
+   handlers$1.drop = (view, event) => {
+       if (!event.dataTransfer)
+           return;
+       if (view.state.readOnly)
+           return event.preventDefault();
+       let files = event.dataTransfer.files;
+       if (files && files.length) { // For a file drop, read the file's text.
+           event.preventDefault();
+           let text = Array(files.length), read = 0;
+           let finishFile = () => {
+               if (++read == files.length)
+                   dropText$1(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
+           };
+           for (let i = 0; i < files.length; i++) {
+               let reader = new FileReader;
+               reader.onerror = finishFile;
+               reader.onload = () => {
+                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
+                       text[i] = reader.result;
+                   finishFile();
+               };
+               reader.readAsText(files[i]);
+           }
+       }
+       else {
+           dropText$1(view, event, event.dataTransfer.getData("Text"), true);
+       }
+   };
+   handlers$1.paste = (view, event) => {
+       if (view.state.readOnly)
+           return event.preventDefault();
+       view.observer.flush();
+       let data = brokenClipboardAPI$1 ? null : event.clipboardData;
+       if (data) {
+           doPaste$1(view, data.getData("text/plain"));
+           event.preventDefault();
+       }
+       else {
+           capturePaste$1(view);
+       }
+   };
+   function captureCopy$1(view, text) {
+       // The extra wrapper is somehow necessary on IE/Edge to prevent the
+       // content from being mangled when it is put onto the clipboard
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.value = text;
+       target.focus();
+       target.selectionEnd = text.length;
+       target.selectionStart = 0;
+       setTimeout(() => {
+           target.remove();
+           view.focus();
+       }, 50);
+   }
+   function copiedRange$1(state) {
+       let content = [], ranges = [], linewise = false;
+       for (let range of state.selection.ranges)
+           if (!range.empty) {
+               content.push(state.sliceDoc(range.from, range.to));
+               ranges.push(range);
+           }
+       if (!content.length) {
+           // Nothing selected, do a line-wise copy
+           let upto = -1;
+           for (let { from } of state.selection.ranges) {
+               let line = state.doc.lineAt(from);
+               if (line.number > upto) {
+                   content.push(line.text);
+                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
+               }
+               upto = line.number;
+           }
+           linewise = true;
+       }
+       return { text: content.join(state.lineBreak), ranges, linewise };
+   }
+   let lastLinewiseCopy$1 = null;
+   handlers$1.copy = handlers$1.cut = (view, event) => {
+       let { text, ranges, linewise } = copiedRange$1(view.state);
+       if (!text && !linewise)
+           return;
+       lastLinewiseCopy$1 = linewise ? text : null;
+       let data = brokenClipboardAPI$1 ? null : event.clipboardData;
+       if (data) {
+           event.preventDefault();
+           data.clearData();
+           data.setData("text/plain", text);
+       }
+       else {
+           captureCopy$1(view, text);
+       }
+       if (event.type == "cut" && !view.state.readOnly)
+           view.dispatch({
+               changes: ranges,
+               scrollIntoView: true,
+               userEvent: "delete.cut"
+           });
+   };
+   function updateForFocusChange$1(view) {
+       setTimeout(() => {
+           if (view.hasFocus != view.inputState.notifiedFocused)
+               view.update([]);
+       }, 10);
+   }
+   handlers$1.focus = updateForFocusChange$1;
+   handlers$1.blur = view => {
+       view.observer.clearSelectionRange();
+       updateForFocusChange$1(view);
+   };
+   function forceClearComposition(view, rapid) {
+       if (view.docView.compositionDeco.size) {
+           view.inputState.rapidCompositionStart = rapid;
+           try {
+               view.update([]);
+           }
+           finally {
+               view.inputState.rapidCompositionStart = false;
+           }
+       }
+   }
+   handlers$1.compositionstart = handlers$1.compositionupdate = view => {
+       if (view.inputState.compositionFirstChange == null)
+           view.inputState.compositionFirstChange = true;
+       if (view.inputState.composing < 0) {
+           // FIXME possibly set a timeout to clear it again on Android
+           view.inputState.composing = 0;
+           if (view.docView.compositionDeco.size) {
+               view.observer.flush();
+               forceClearComposition(view, true);
+           }
+       }
+   };
+   handlers$1.compositionend = view => {
+       view.inputState.composing = -1;
+       view.inputState.compositionEndedAt = Date.now();
+       view.inputState.compositionFirstChange = null;
+       setTimeout(() => {
+           if (view.inputState.composing < 0)
+               forceClearComposition(view, false);
+       }, 50);
+   };
+   handlers$1.contextmenu = view => {
+       view.inputState.lastContextMenu = Date.now();
+   };
+   handlers$1.beforeinput = (view, event) => {
+       var _a;
+       // Because Chrome Android doesn't fire useful key events, use
+       // beforeinput to detect backspace (and possibly enter and delete,
+       // but those usually don't even seem to fire beforeinput events at
+       // the moment) and fake a key event for it.
+       //
+       // (preventDefault on beforeinput, though supported in the spec,
+       // seems to do nothing at all on Chrome).
+       let pending;
+       if (browser$1.chrome && browser$1.android && (pending = PendingKeys$1.find(key => key.inputType == event.inputType))) {
+           view.observer.delayAndroidKey(pending.key, pending.keyCode);
+           if (pending.key == "Backspace" || pending.key == "Delete") {
+               let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
+               setTimeout(() => {
+                   var _a;
+                   // Backspacing near uneditable nodes on Chrome Android sometimes
+                   // closes the virtual keyboard. This tries to crudely detect
+                   // that and refocus to get it back.
+                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
+                       view.contentDOM.blur();
+                       view.focus();
+                   }
+               }, 100);
+           }
+       }
+   };
+
+   const wrappingWhiteSpace$1 = ["pre-wrap", "normal", "pre-line", "break-spaces"];
+   let HeightOracle$1 = class HeightOracle {
+       constructor() {
+           this.doc = Text$1.empty;
+           this.lineWrapping = false;
+           this.heightSamples = {};
+           this.lineHeight = 14;
+           this.charWidth = 7;
+           this.lineLength = 30;
+           // Used to track, during updateHeight, if any actual heights changed
+           this.heightChanged = false;
+       }
+       heightForGap(from, to) {
+           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
+           if (this.lineWrapping)
+               lines += Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength);
+           return this.lineHeight * lines;
+       }
+       heightForLine(length) {
+           if (!this.lineWrapping)
+               return this.lineHeight;
+           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
+           return lines * this.lineHeight;
+       }
+       setDoc(doc) { this.doc = doc; return this; }
+       mustRefreshForWrapping(whiteSpace) {
+           return (wrappingWhiteSpace$1.indexOf(whiteSpace) > -1) != this.lineWrapping;
+       }
+       mustRefreshForHeights(lineHeights) {
+           let newHeight = false;
+           for (let i = 0; i < lineHeights.length; i++) {
+               let h = lineHeights[i];
+               if (h < 0) {
+                   i++;
+               }
+               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
+                   newHeight = true;
+                   this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return newHeight;
+       }
+       refresh(whiteSpace, lineHeight, charWidth, lineLength, knownHeights) {
+           let lineWrapping = wrappingWhiteSpace$1.indexOf(whiteSpace) > -1;
+           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
+           this.lineWrapping = lineWrapping;
+           this.lineHeight = lineHeight;
+           this.charWidth = charWidth;
+           this.lineLength = lineLength;
+           if (changed) {
+               this.heightSamples = {};
+               for (let i = 0; i < knownHeights.length; i++) {
+                   let h = knownHeights[i];
+                   if (h < 0)
+                       i++;
+                   else
+                       this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return changed;
+       }
+   };
+   // This object is used by `updateHeight` to make DOM measurements
+   // arrive at the right nides. The `heights` array is a sequence of
+   // block heights, starting from position `from`.
+   let MeasuredHeights$1 = class MeasuredHeights {
+       constructor(from, heights) {
+           this.from = from;
+           this.heights = heights;
+           this.index = 0;
+       }
+       get more() { return this.index < this.heights.length; }
+   };
+   /**
+   Record used to represent information about a block-level element
+   in the editor view.
+   */
+   let BlockInfo$1 = class BlockInfo {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the element in the document.
+       */
+       from, 
+       /**
+       The length of the element.
+       */
+       length, 
+       /**
+       The top position of the element (relative to the top of the
+       document).
+       */
+       top, 
+       /**
+       Its height.
+       */
+       height, 
+       /**
+       The type of element this is. When querying lines, this may be
+       an array of all the blocks that make up the line.
+       */
+       type) {
+           this.from = from;
+           this.length = length;
+           this.top = top;
+           this.height = height;
+           this.type = type;
+       }
+       /**
+       The end of the element as a document position.
+       */
+       get to() { return this.from + this.length; }
+       /**
+       The bottom position of the element.
+       */
+       get bottom() { return this.top + this.height; }
+       /**
+       @internal
+       */
+       join(other) {
+           let detail = (Array.isArray(this.type) ? this.type : [this])
+               .concat(Array.isArray(other.type) ? other.type : [other]);
+           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
+       }
+   };
+   var QueryType$2 = /*@__PURE__*/(function (QueryType) {
+       QueryType[QueryType["ByPos"] = 0] = "ByPos";
+       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
+       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
+   return QueryType})(QueryType$2 || (QueryType$2 = {}));
+   const Epsilon$1 = 1e-3;
+   let HeightMap$1 = class HeightMap {
+       constructor(length, // The number of characters covered
+       height, // Height of this part of the document
+       flags = 2 /* Outdated */) {
+           this.length = length;
+           this.height = height;
+           this.flags = flags;
+       }
+       get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
+       set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
+       setHeight(oracle, height) {
+           if (this.height != height) {
+               if (Math.abs(this.height - height) > Epsilon$1)
+                   oracle.heightChanged = true;
+               this.height = height;
+           }
+       }
+       // Base case is to replace a leaf node, which simply builds a tree
+       // from the new nodes and returns that (HeightMapBranch and
+       // HeightMapGap override this to actually use from/to)
+       replace(_from, _to, nodes) {
+           return HeightMap.of(nodes);
+       }
+       // Again, these are base cases, and are overridden for branch and gap nodes.
+       decomposeLeft(_to, result) { result.push(this); }
+       decomposeRight(_from, result) { result.push(this); }
+       applyChanges(decorations, oldDoc, oracle, changes) {
+           let me = this;
+           for (let i = changes.length - 1; i >= 0; i--) {
+               let { fromA, toA, fromB, toB } = changes[i];
+               let start = me.lineAt(fromA, QueryType$2.ByPosNoHeight, oldDoc, 0, 0);
+               let end = start.to >= toA ? start : me.lineAt(toA, QueryType$2.ByPosNoHeight, oldDoc, 0, 0);
+               toB += end.to - toA;
+               toA = end.to;
+               while (i > 0 && start.from <= changes[i - 1].toA) {
+                   fromA = changes[i - 1].fromA;
+                   fromB = changes[i - 1].fromB;
+                   i--;
+                   if (fromA < start.from)
+                       start = me.lineAt(fromA, QueryType$2.ByPosNoHeight, oldDoc, 0, 0);
+               }
+               fromB += start.from - fromA;
+               fromA = start.from;
+               let nodes = NodeBuilder$1.build(oracle, decorations, fromB, toB);
+               me = me.replace(fromA, toA, nodes);
+           }
+           return me.updateHeight(oracle, 0);
+       }
+       static empty() { return new HeightMapText$1(0, 0); }
+       // nodes uses null values to indicate the position of line breaks.
+       // There are never line breaks at the start or end of the array, or
+       // two line breaks next to each other, and the array isn't allowed
+       // to be empty (same restrictions as return value from the builder).
+       static of(nodes) {
+           if (nodes.length == 1)
+               return nodes[0];
+           let i = 0, j = nodes.length, before = 0, after = 0;
+           for (;;) {
+               if (i == j) {
+                   if (before > after * 2) {
+                       let split = nodes[i - 1];
+                       if (split.break)
+                           nodes.splice(--i, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(--i, 1, split.left, split.right);
+                       j += 1 + split.break;
+                       before -= split.size;
+                   }
+                   else if (after > before * 2) {
+                       let split = nodes[j];
+                       if (split.break)
+                           nodes.splice(j, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(j, 1, split.left, split.right);
+                       j += 2 + split.break;
+                       after -= split.size;
+                   }
+                   else {
+                       break;
+                   }
+               }
+               else if (before < after) {
+                   let next = nodes[i++];
+                   if (next)
+                       before += next.size;
+               }
+               else {
+                   let next = nodes[--j];
+                   if (next)
+                       after += next.size;
+               }
+           }
+           let brk = 0;
+           if (nodes[i - 1] == null) {
+               brk = 1;
+               i--;
+           }
+           else if (nodes[i] == null) {
+               brk = 1;
+               j++;
+           }
+           return new HeightMapBranch$1(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
+       }
+   };
+   HeightMap$1.prototype.size = 1;
+   let HeightMapBlock$1 = class HeightMapBlock extends HeightMap$1 {
+       constructor(length, height, type) {
+           super(length, height);
+           this.type = type;
+       }
+       blockAt(_height, _doc, top, offset) {
+           return new BlockInfo$1(offset, this.length, top, this.height, this.type);
+       }
+       lineAt(_value, _type, doc, top, offset) {
+           return this.blockAt(0, doc, top, offset);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           if (from <= offset + this.length && to >= offset)
+               f(this.blockAt(0, doc, top, offset));
+       }
+       updateHeight(oracle, offset = 0, _force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(oracle, measured.heights[measured.index++]);
+           this.outdated = false;
+           return this;
+       }
+       toString() { return `block(${this.length})`; }
+   };
+   let HeightMapText$1 = class HeightMapText extends HeightMapBlock$1 {
+       constructor(length, height) {
+           super(length, height, BlockType$1.Text);
+           this.collapsed = 0; // Amount of collapsed content in the line
+           this.widgetHeight = 0; // Maximum inline widget height
+       }
+       replace(_from, _to, nodes) {
+           let node = nodes[0];
+           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap$1 && (node.flags & 4 /* SingleLine */)) &&
+               Math.abs(this.length - node.length) < 10) {
+               if (node instanceof HeightMapGap$1)
+                   node = new HeightMapText(node.length, this.height);
+               else
+                   node.height = this.height;
+               if (!this.outdated)
+                   node.outdated = false;
+               return node;
+           }
+           else {
+               return HeightMap$1.of(nodes);
+           }
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(oracle, measured.heights[measured.index++]);
+           else if (force || this.outdated)
+               this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)));
+           this.outdated = false;
+           return this;
+       }
+       toString() {
+           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
+       }
+   };
+   let HeightMapGap$1 = class HeightMapGap extends HeightMap$1 {
+       constructor(length) { super(length, 0); }
+       lines(doc, offset) {
+           let firstLine = doc.lineAt(offset).number, lastLine = doc.lineAt(offset + this.length).number;
+           return { firstLine, lastLine, lineHeight: this.height / (lastLine - firstLine + 1) };
+       }
+       blockAt(height, doc, top, offset) {
+           let { firstLine, lastLine, lineHeight } = this.lines(doc, offset);
+           let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / lineHeight)));
+           let { from, length } = doc.line(firstLine + line);
+           return new BlockInfo$1(from, length, top + lineHeight * line, lineHeight, BlockType$1.Text);
+       }
+       lineAt(value, type, doc, top, offset) {
+           if (type == QueryType$2.ByHeight)
+               return this.blockAt(value, doc, top, offset);
+           if (type == QueryType$2.ByPosNoHeight) {
+               let { from, to } = doc.lineAt(value);
+               return new BlockInfo$1(from, to - from, 0, 0, BlockType$1.Text);
+           }
+           let { firstLine, lineHeight } = this.lines(doc, offset);
+           let { from, length, number } = doc.lineAt(value);
+           return new BlockInfo$1(from, length, top + lineHeight * (number - firstLine), lineHeight, BlockType$1.Text);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           let { firstLine, lineHeight } = this.lines(doc, offset);
+           for (let pos = Math.max(from, offset), end = Math.min(offset + this.length, to); pos <= end;) {
+               let line = doc.lineAt(pos);
+               if (pos == from)
+                   top += lineHeight * (line.number - firstLine);
+               f(new BlockInfo$1(line.from, line.length, top, lineHeight, BlockType$1.Text));
+               top += lineHeight;
+               pos = line.to + 1;
+           }
+       }
+       replace(from, to, nodes) {
+           let after = this.length - to;
+           if (after > 0) {
+               let last = nodes[nodes.length - 1];
+               if (last instanceof HeightMapGap)
+                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
+               else
+                   nodes.push(null, new HeightMapGap(after - 1));
+           }
+           if (from > 0) {
+               let first = nodes[0];
+               if (first instanceof HeightMapGap)
+                   nodes[0] = new HeightMapGap(from + first.length);
+               else
+                   nodes.unshift(new HeightMapGap(from - 1), null);
+           }
+           return HeightMap$1.of(nodes);
+       }
+       decomposeLeft(to, result) {
+           result.push(new HeightMapGap(to - 1), null);
+       }
+       decomposeRight(from, result) {
+           result.push(null, new HeightMapGap(this.length - from - 1));
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let end = offset + this.length;
+           if (measured && measured.from <= offset + this.length && measured.more) {
+               // Fill in part of this gap with measured lines. We know there
+               // can't be widgets or collapsed ranges in those lines, because
+               // they would already have been added to the heightmap (gaps
+               // only contain plain text).
+               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
+               let wasChanged = oracle.heightChanged;
+               if (measured.from > offset)
+                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
+               while (pos <= end && measured.more) {
+                   let len = oracle.doc.lineAt(pos).length;
+                   if (nodes.length)
+                       nodes.push(null);
+                   let height = measured.heights[measured.index++];
+                   if (singleHeight == -1)
+                       singleHeight = height;
+                   else if (Math.abs(height - singleHeight) >= Epsilon$1)
+                       singleHeight = -2;
+                   let line = new HeightMapText$1(len, height);
+                   line.outdated = false;
+                   nodes.push(line);
+                   pos += len + 1;
+               }
+               if (pos <= end)
+                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
+               let result = HeightMap$1.of(nodes);
+               oracle.heightChanged = wasChanged || singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon$1 ||
+                   Math.abs(singleHeight - this.lines(oracle.doc, offset).lineHeight) >= Epsilon$1;
+               return result;
+           }
+           else if (force || this.outdated) {
+               this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));
+               this.outdated = false;
+           }
+           return this;
+       }
+       toString() { return `gap(${this.length})`; }
+   };
+   let HeightMapBranch$1 = class HeightMapBranch extends HeightMap$1 {
+       constructor(left, brk, right) {
+           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
+           this.left = left;
+           this.right = right;
+           this.size = left.size + right.size;
+       }
+       get break() { return this.flags & 1 /* Break */; }
+       blockAt(height, doc, top, offset) {
+           let mid = top + this.left.height;
+           return height < mid ? this.left.blockAt(height, doc, top, offset)
+               : this.right.blockAt(height, doc, mid, offset + this.left.length + this.break);
+       }
+       lineAt(value, type, doc, top, offset) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           let left = type == QueryType$2.ByHeight ? value < rightTop : value < rightOffset;
+           let base = left ? this.left.lineAt(value, type, doc, top, offset)
+               : this.right.lineAt(value, type, doc, rightTop, rightOffset);
+           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
+               return base;
+           let subQuery = type == QueryType$2.ByPosNoHeight ? QueryType$2.ByPosNoHeight : QueryType$2.ByPos;
+           if (left)
+               return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));
+           else
+               return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
+       }
+       forEachLine(from, to, doc, top, offset, f) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           if (this.break) {
+               if (from < rightOffset)
+                   this.left.forEachLine(from, to, doc, top, offset, f);
+               if (to >= rightOffset)
+                   this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
+           }
+           else {
+               let mid = this.lineAt(rightOffset, QueryType$2.ByPos, doc, top, offset);
+               if (from < mid.from)
+                   this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
+               if (mid.to >= from && mid.from <= to)
+                   f(mid);
+               if (to > mid.to)
+                   this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
+           }
+       }
+       replace(from, to, nodes) {
+           let rightStart = this.left.length + this.break;
+           if (to < rightStart)
+               return this.balanced(this.left.replace(from, to, nodes), this.right);
+           if (from > this.left.length)
+               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
+           let result = [];
+           if (from > 0)
+               this.decomposeLeft(from, result);
+           let left = result.length;
+           for (let node of nodes)
+               result.push(node);
+           if (from > 0)
+               mergeGaps$1(result, left - 1);
+           if (to < this.length) {
+               let right = result.length;
+               this.decomposeRight(to, result);
+               mergeGaps$1(result, right);
+           }
+           return HeightMap$1.of(result);
+       }
+       decomposeLeft(to, result) {
+           let left = this.left.length;
+           if (to <= left)
+               return this.left.decomposeLeft(to, result);
+           result.push(this.left);
+           if (this.break) {
+               left++;
+               if (to >= left)
+                   result.push(null);
+           }
+           if (to > left)
+               this.right.decomposeLeft(to - left, result);
+       }
+       decomposeRight(from, result) {
+           let left = this.left.length, right = left + this.break;
+           if (from >= right)
+               return this.right.decomposeRight(from - right, result);
+           if (from < left)
+               this.left.decomposeRight(from, result);
+           if (this.break && from < right)
+               result.push(null);
+           result.push(this.right);
+       }
+       balanced(left, right) {
+           if (left.size > 2 * right.size || right.size > 2 * left.size)
+               return HeightMap$1.of(this.break ? [left, null, right] : [left, right]);
+           this.left = left;
+           this.right = right;
+           this.height = left.height + right.height;
+           this.outdated = left.outdated || right.outdated;
+           this.size = left.size + right.size;
+           this.length = left.length + this.break + right.length;
+           return this;
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
+           if (measured && measured.from <= offset + left.length && measured.more)
+               rebalance = left = left.updateHeight(oracle, offset, force, measured);
+           else
+               left.updateHeight(oracle, offset, force);
+           if (measured && measured.from <= rightStart + right.length && measured.more)
+               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
+           else
+               right.updateHeight(oracle, rightStart, force);
+           if (rebalance)
+               return this.balanced(left, right);
+           this.height = this.left.height + this.right.height;
+           this.outdated = false;
+           return this;
+       }
+       toString() { return this.left + (this.break ? " " : "-") + this.right; }
+   };
+   function mergeGaps$1(nodes, around) {
+       let before, after;
+       if (nodes[around] == null &&
+           (before = nodes[around - 1]) instanceof HeightMapGap$1 &&
+           (after = nodes[around + 1]) instanceof HeightMapGap$1)
+           nodes.splice(around - 1, 3, new HeightMapGap$1(before.length + 1 + after.length));
+   }
+   const relevantWidgetHeight$1 = 5;
+   let NodeBuilder$1 = class NodeBuilder {
+       constructor(pos, oracle) {
+           this.pos = pos;
+           this.oracle = oracle;
+           this.nodes = [];
+           this.lineStart = -1;
+           this.lineEnd = -1;
+           this.covering = null;
+           this.writtenTo = pos;
+       }
+       get isCovered() {
+           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
+       }
+       span(_from, to) {
+           if (this.lineStart > -1) {
+               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
+               if (last instanceof HeightMapText$1)
+                   last.length += end - this.pos;
+               else if (end > this.pos || !this.isCovered)
+                   this.nodes.push(new HeightMapText$1(end - this.pos, -1));
+               this.writtenTo = end;
+               if (to > end) {
+                   this.nodes.push(null);
+                   this.writtenTo++;
+                   this.lineStart = -1;
+               }
+           }
+           this.pos = to;
+       }
+       point(from, to, deco) {
+           if (from < to || deco.heightRelevant) {
+               let height = deco.widget ? deco.widget.estimatedHeight : 0;
+               if (height < 0)
+                   height = this.oracle.lineHeight;
+               let len = to - from;
+               if (deco.block) {
+                   this.addBlock(new HeightMapBlock$1(len, height, deco.type));
+               }
+               else if (len || height >= relevantWidgetHeight$1) {
+                   this.addLineDeco(height, len);
+               }
+           }
+           else if (to > from) {
+               this.span(from, to);
+           }
+           if (this.lineEnd > -1 && this.lineEnd < this.pos)
+               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
+       }
+       enterLine() {
+           if (this.lineStart > -1)
+               return;
+           let { from, to } = this.oracle.doc.lineAt(this.pos);
+           this.lineStart = from;
+           this.lineEnd = to;
+           if (this.writtenTo < from) {
+               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
+                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
+               this.nodes.push(null);
+           }
+           if (this.pos > from)
+               this.nodes.push(new HeightMapText$1(this.pos - from, -1));
+           this.writtenTo = this.pos;
+       }
+       blankContent(from, to) {
+           let gap = new HeightMapGap$1(to - from);
+           if (this.oracle.doc.lineAt(from).to == to)
+               gap.flags |= 4 /* SingleLine */;
+           return gap;
+       }
+       ensureLine() {
+           this.enterLine();
+           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
+           if (last instanceof HeightMapText$1)
+               return last;
+           let line = new HeightMapText$1(0, -1);
+           this.nodes.push(line);
+           return line;
+       }
+       addBlock(block) {
+           this.enterLine();
+           if (block.type == BlockType$1.WidgetAfter && !this.isCovered)
+               this.ensureLine();
+           this.nodes.push(block);
+           this.writtenTo = this.pos = this.pos + block.length;
+           if (block.type != BlockType$1.WidgetBefore)
+               this.covering = block;
+       }
+       addLineDeco(height, length) {
+           let line = this.ensureLine();
+           line.length += length;
+           line.collapsed += length;
+           line.widgetHeight = Math.max(line.widgetHeight, height);
+           this.writtenTo = this.pos = this.pos + length;
+       }
+       finish(from) {
+           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
+           if (this.lineStart > -1 && !(last instanceof HeightMapText$1) && !this.isCovered)
+               this.nodes.push(new HeightMapText$1(0, -1));
+           else if (this.writtenTo < this.pos || last == null)
+               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
+           let pos = from;
+           for (let node of this.nodes) {
+               if (node instanceof HeightMapText$1)
+                   node.updateHeight(this.oracle, pos);
+               pos += node ? node.length : 1;
+           }
+           return this.nodes;
+       }
+       // Always called with a region that on both sides either stretches
+       // to a line break or the end of the document.
+       // The returned array uses null to indicate line breaks, but never
+       // starts or ends in a line break, or has multiple line breaks next
+       // to each other.
+       static build(oracle, decorations, from, to) {
+           let builder = new NodeBuilder(from, oracle);
+           RangeSet$1.spans(decorations, from, to, builder, 0);
+           return builder.finish(from);
+       }
+   };
+   function heightRelevantDecoChanges$1(a, b, diff) {
+       let comp = new DecorationComparator$2;
+       RangeSet$1.compare(a, b, diff, comp, 0);
+       return comp.changes;
+   }
+   let DecorationComparator$2 = class DecorationComparator {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange() { }
+       comparePoint(from, to, a, b) {
+           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
+               addRange$1(from, to, this.changes, 5);
+       }
+   };
+
+   function visiblePixelRange$1(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       let left = Math.max(0, rect.left), right = Math.min(innerWidth, rect.right);
+       let top = Math.max(0, rect.top), bottom = Math.min(innerHeight, rect.bottom);
+       let body = dom.ownerDocument.body;
+       for (let parent = dom.parentNode; parent && parent != body;) {
+           if (parent.nodeType == 1) {
+               let elt = parent;
+               let style = window.getComputedStyle(elt);
+               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
+                   style.overflow != "visible") {
+                   let parentRect = elt.getBoundingClientRect();
+                   left = Math.max(left, parentRect.left);
+                   right = Math.min(right, parentRect.right);
+                   top = Math.max(top, parentRect.top);
+                   bottom = Math.min(bottom, parentRect.bottom);
+               }
+               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
+           }
+           else if (parent.nodeType == 11) { // Shadow root
+               parent = parent.host;
+           }
+           else {
+               break;
+           }
+       }
+       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
+           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
+   }
+   function fullPixelRange$1(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       return { left: 0, right: rect.right - rect.left,
+           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
+   }
+   // Line gaps are placeholder widgets used to hide pieces of overlong
+   // lines within the viewport, as a kludge to keep the editor
+   // responsive when a ridiculously long line is loaded into it.
+   let LineGap$1 = class LineGap {
+       constructor(from, to, size) {
+           this.from = from;
+           this.to = to;
+           this.size = size;
+       }
+       static same(a, b) {
+           if (a.length != b.length)
+               return false;
+           for (let i = 0; i < a.length; i++) {
+               let gA = a[i], gB = b[i];
+               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
+                   return false;
+           }
+           return true;
+       }
+       draw(wrapping) {
+           return Decoration$1.replace({ widget: new LineGapWidget$1(this.size, wrapping) }).range(this.from, this.to);
+       }
+   };
+   let LineGapWidget$1 = class LineGapWidget extends WidgetType$1 {
+       constructor(size, vertical) {
+           super();
+           this.size = size;
+           this.vertical = vertical;
+       }
+       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
+       toDOM() {
+           let elt = document.createElement("div");
+           if (this.vertical) {
+               elt.style.height = this.size + "px";
+           }
+           else {
+               elt.style.width = this.size + "px";
+               elt.style.height = "2px";
+               elt.style.display = "inline-block";
+           }
+           return elt;
+       }
+       get estimatedHeight() { return this.vertical ? this.size : -1; }
+   };
+   let ViewState$1 = class ViewState {
+       constructor(state) {
+           this.state = state;
+           // These are contentDOM-local coordinates
+           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
+           this.inView = true;
+           this.paddingTop = 0;
+           this.paddingBottom = 0;
+           this.contentDOMWidth = 0;
+           this.contentDOMHeight = 0;
+           this.editorHeight = 0;
+           this.editorWidth = 0;
+           this.heightOracle = new HeightOracle$1;
+           // See VP.MaxDOMHeight
+           this.scaler = IdScaler$1;
+           this.scrollTarget = null;
+           // Briefly set to true when printing, to disable viewport limiting
+           this.printing = false;
+           // Flag set when editor content was redrawn, so that the next
+           // measure stage knows it must read DOM layout
+           this.mustMeasureContent = true;
+           this.defaultTextDirection = Direction$1.RTL;
+           this.visibleRanges = [];
+           // Cursor 'assoc' is only significant when the cursor is on a line
+           // wrap point, where it must stick to the character that it is
+           // associated with. Since browsers don't provide a reasonable
+           // interface to set or query this, when a selection is set that
+           // might cause this to be significant, this flag is set. The next
+           // measure phase will check whether the cursor is on a line-wrapping
+           // boundary and, if so, reset it to make sure it is positioned in
+           // the right place.
+           this.mustEnforceCursorAssoc = false;
+           this.stateDeco = state.facet(decorations$1).filter(d => typeof d != "function");
+           this.heightMap = HeightMap$1.empty().applyChanges(this.stateDeco, Text$1.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange$1(0, 0, 0, state.doc.length)]);
+           this.viewport = this.getViewport(0, null);
+           this.updateViewportLines();
+           this.updateForViewport();
+           this.lineGaps = this.ensureLineGaps([]);
+           this.lineGapDeco = Decoration$1.set(this.lineGaps.map(gap => gap.draw(false)));
+           this.computeVisibleRanges();
+       }
+       updateForViewport() {
+           let viewports = [this.viewport], { main } = this.state.selection;
+           for (let i = 0; i <= 1; i++) {
+               let pos = i ? main.head : main.anchor;
+               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
+                   let { from, to } = this.lineBlockAt(pos);
+                   viewports.push(new Viewport$1(from, to));
+               }
+           }
+           this.viewports = viewports.sort((a, b) => a.from - b.from);
+           this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler$1 :
+               new BigScaler$1(this.heightOracle.doc, this.heightMap, this.viewports);
+       }
+       updateViewportLines() {
+           this.viewportLines = [];
+           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, block => {
+               this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock$1(block, this.scaler));
+           });
+       }
+       update(update, scrollTarget = null) {
+           this.state = update.state;
+           let prevDeco = this.stateDeco;
+           this.stateDeco = this.state.facet(decorations$1).filter(d => typeof d != "function");
+           let contentChanges = update.changedRanges;
+           let heightChanges = ChangedRange$1.extendWithRanges(contentChanges, heightRelevantDecoChanges$1(prevDeco, this.stateDeco, update ? update.changes : ChangeSet$1.empty(this.state.doc.length)));
+           let prevHeight = this.heightMap.height;
+           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
+           if (this.heightMap.height != prevHeight)
+               update.flags |= 2 /* Height */;
+           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
+           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
+               !this.viewportIsAppropriate(viewport))
+               viewport = this.getViewport(0, scrollTarget);
+           let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
+               viewport.from != this.viewport.from || viewport.to != this.viewport.to;
+           this.viewport = viewport;
+           this.updateForViewport();
+           if (updateLines)
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
+               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
+           update.flags |= this.computeVisibleRanges();
+           if (scrollTarget)
+               this.scrollTarget = scrollTarget;
+           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
+               update.state.selection.main.empty && update.state.selection.main.assoc)
+               this.mustEnforceCursorAssoc = true;
+       }
+       measure(view) {
+           let dom = view.contentDOM, style = window.getComputedStyle(dom);
+           let oracle = this.heightOracle;
+           let whiteSpace = style.whiteSpace;
+           this.defaultTextDirection = style.direction == "rtl" ? Direction$1.RTL : Direction$1.LTR;
+           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
+           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
+           this.contentDOMHeight = dom.clientHeight;
+           this.mustMeasureContent = false;
+           let result = 0, bias = 0;
+           // Vertical padding
+           let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
+           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
+               this.paddingTop = paddingTop;
+               this.paddingBottom = paddingBottom;
+               result |= 8 /* Geometry */ | 2 /* Height */;
+           }
+           if (this.editorWidth != view.scrollDOM.clientWidth) {
+               if (oracle.lineWrapping)
+                   measureContent = true;
+               this.editorWidth = view.scrollDOM.clientWidth;
+               result |= 8 /* Geometry */;
+           }
+           // Pixel viewport
+           let pixelViewport = (this.printing ? fullPixelRange$1 : visiblePixelRange$1)(dom, this.paddingTop);
+           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
+           this.pixelViewport = pixelViewport;
+           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
+           if (inView != this.inView) {
+               this.inView = inView;
+               if (inView)
+                   measureContent = true;
+           }
+           if (!this.inView)
+               return 0;
+           let contentWidth = dom.clientWidth;
+           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
+               this.contentDOMWidth = contentWidth;
+               this.editorHeight = view.scrollDOM.clientHeight;
+               result |= 8 /* Geometry */;
+           }
+           if (measureContent) {
+               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
+               if (oracle.mustRefreshForHeights(lineHeights))
+                   refresh = true;
+               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
+                   let { lineHeight, charWidth } = view.docView.measureTextSize();
+                   refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
+                   if (refresh) {
+                       view.docView.minWidth = 0;
+                       result |= 8 /* Geometry */;
+                   }
+               }
+               if (dTop > 0 && dBottom > 0)
+                   bias = Math.max(dTop, dBottom);
+               else if (dTop < 0 && dBottom < 0)
+                   bias = Math.min(dTop, dBottom);
+               oracle.heightChanged = false;
+               for (let vp of this.viewports) {
+                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
+                   this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights$1(vp.from, heights));
+               }
+               if (oracle.heightChanged)
+                   result |= 2 /* Height */;
+           }
+           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
+               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
+           if (viewportChange)
+               this.viewport = this.getViewport(bias, this.scrollTarget);
+           this.updateForViewport();
+           if ((result & 2 /* Height */) || viewportChange)
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
+               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
+           result |= this.computeVisibleRanges();
+           if (this.mustEnforceCursorAssoc) {
+               this.mustEnforceCursorAssoc = false;
+               // This is done in the read stage, because moving the selection
+               // to a line end is going to trigger a layout anyway, so it
+               // can't be a pure write. It should be rare that it does any
+               // writing.
+               view.docView.enforceCursorAssoc();
+           }
+           return result;
+       }
+       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
+       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
+       getViewport(bias, scrollTarget) {
+           // This will divide VP.Margin between the top and the
+           // bottom, depending on the bias (the change in viewport position
+           // since the last update). It'll hold a number between 0 and 1
+           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
+           let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
+           let viewport = new Viewport$1(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType$2.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType$2.ByHeight, doc, 0, 0).to);
+           // If scrollTarget is given, make sure the viewport includes that position
+           if (scrollTarget) {
+               let { head } = scrollTarget.range;
+               if (head < viewport.from || head > viewport.to) {
+                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
+                   let block = map.lineAt(head, QueryType$2.ByPos, doc, 0, 0), topPos;
+                   if (scrollTarget.y == "center")
+                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
+                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
+                       topPos = block.top;
+                   else
+                       topPos = block.bottom - viewHeight;
+                   viewport = new Viewport$1(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType$2.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType$2.ByHeight, doc, 0, 0).to);
+               }
+           }
+           return viewport;
+       }
+       mapViewport(viewport, changes) {
+           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
+           return new Viewport$1(this.heightMap.lineAt(from, QueryType$2.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType$2.ByPos, this.state.doc, 0, 0).to);
+       }
+       // Checks if a given viewport covers the visible part of the
+       // document and not too much beyond that.
+       viewportIsAppropriate({ from, to }, bias = 0) {
+           if (!this.inView)
+               return true;
+           let { top } = this.heightMap.lineAt(from, QueryType$2.ByPos, this.state.doc, 0, 0);
+           let { bottom } = this.heightMap.lineAt(to, QueryType$2.ByPos, this.state.doc, 0, 0);
+           let { visibleTop, visibleBottom } = this;
+           return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
+               (to == this.state.doc.length ||
+                   bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
+               (top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
+       }
+       mapLineGaps(gaps, changes) {
+           if (!gaps.length || changes.empty)
+               return gaps;
+           let mapped = [];
+           for (let gap of gaps)
+               if (!changes.touchesRange(gap.from, gap.to))
+                   mapped.push(new LineGap$1(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));
+           return mapped;
+       }
+       // Computes positions in the viewport where the start or end of a
+       // line should be hidden, trying to reuse existing line gaps when
+       // appropriate to avoid unneccesary redraws.
+       // Uses crude character-counting for the positioning and sizing,
+       // since actual DOM coordinates aren't always available and
+       // predictable. Relies on generous margins (see LG.Margin) to hide
+       // the artifacts this might produce from the user.
+       ensureLineGaps(current) {
+           let gaps = [];
+           // This won't work at all in predominantly right-to-left text.
+           if (this.defaultTextDirection != Direction$1.LTR)
+               return gaps;
+           for (let line of this.viewportLines) {
+               if (line.length < 4000 /* DoubleMargin */)
+                   continue;
+               let structure = lineStructure$1(line.from, line.to, this.stateDeco);
+               if (structure.total < 4000 /* DoubleMargin */)
+                   continue;
+               let viewFrom, viewTo;
+               if (this.heightOracle.lineWrapping) {
+                   let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
+                   viewFrom = findPosition$1(structure, (this.visibleTop - line.top - marginHeight) / line.height);
+                   viewTo = findPosition$1(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
+               }
+               else {
+                   let totalWidth = structure.total * this.heightOracle.charWidth;
+                   let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
+                   viewFrom = findPosition$1(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
+                   viewTo = findPosition$1(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
+               }
+               let outside = [];
+               if (viewFrom > line.from)
+                   outside.push({ from: line.from, to: viewFrom });
+               if (viewTo < line.to)
+                   outside.push({ from: viewTo, to: line.to });
+               let sel = this.state.selection.main;
+               // Make sure the gaps don't cover a selection end
+               if (sel.from >= line.from && sel.from <= line.to)
+                   cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
+               if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
+                   cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
+               for (let { from, to } of outside)
+                   if (to - from > 1000 /* HalfMargin */) {
+                       gaps.push(find$1(current, gap => gap.from >= line.from && gap.to <= line.to &&
+                           Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
+                           new LineGap$1(from, to, this.gapSize(line, from, to, structure)));
+                   }
+           }
+           return gaps;
+       }
+       gapSize(line, from, to, structure) {
+           let fraction = findFraction$1(structure, to) - findFraction$1(structure, from);
+           if (this.heightOracle.lineWrapping) {
+               return line.height * fraction;
+           }
+           else {
+               return structure.total * this.heightOracle.charWidth * fraction;
+           }
+       }
+       updateLineGaps(gaps) {
+           if (!LineGap$1.same(gaps, this.lineGaps)) {
+               this.lineGaps = gaps;
+               this.lineGapDeco = Decoration$1.set(gaps.map(gap => gap.draw(this.heightOracle.lineWrapping)));
+           }
+       }
+       computeVisibleRanges() {
+           let deco = this.stateDeco;
+           if (this.lineGaps.length)
+               deco = deco.concat(this.lineGapDeco);
+           let ranges = [];
+           RangeSet$1.spans(deco, this.viewport.from, this.viewport.to, {
+               span(from, to) { ranges.push({ from, to }); },
+               point() { }
+           }, 20);
+           let changed = ranges.length != this.visibleRanges.length ||
+               this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
+           this.visibleRanges = ranges;
+           return changed ? 4 /* Viewport */ : 0;
+       }
+       lineBlockAt(pos) {
+           return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
+               scaleBlock$1(this.heightMap.lineAt(pos, QueryType$2.ByPos, this.state.doc, 0, 0), this.scaler);
+       }
+       lineBlockAtHeight(height) {
+           return scaleBlock$1(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$2.ByHeight, this.state.doc, 0, 0), this.scaler);
+       }
+       elementAtHeight(height) {
+           return scaleBlock$1(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
+       }
+       get docHeight() {
+           return this.scaler.toDOM(this.heightMap.height);
+       }
+       get contentHeight() {
+           return this.docHeight + this.paddingTop + this.paddingBottom;
+       }
+   };
+   let Viewport$1 = class Viewport {
+       constructor(from, to) {
+           this.from = from;
+           this.to = to;
+       }
+   };
+   function lineStructure$1(from, to, stateDeco) {
+       let ranges = [], pos = from, total = 0;
+       RangeSet$1.spans(stateDeco, from, to, {
+           span() { },
+           point(from, to) {
+               if (from > pos) {
+                   ranges.push({ from: pos, to: from });
+                   total += from - pos;
+               }
+               pos = to;
+           }
+       }, 20); // We're only interested in collapsed ranges of a significant size
+       if (pos < to) {
+           ranges.push({ from: pos, to });
+           total += to - pos;
+       }
+       return { total, ranges };
+   }
+   function findPosition$1({ total, ranges }, ratio) {
+       if (ratio <= 0)
+           return ranges[0].from;
+       if (ratio >= 1)
+           return ranges[ranges.length - 1].to;
+       let dist = Math.floor(total * ratio);
+       for (let i = 0;; i++) {
+           let { from, to } = ranges[i], size = to - from;
+           if (dist <= size)
+               return from + dist;
+           dist -= size;
+       }
+   }
+   function findFraction$1(structure, pos) {
+       let counted = 0;
+       for (let { from, to } of structure.ranges) {
+           if (pos <= to) {
+               counted += pos - from;
+               break;
+           }
+           counted += to - from;
+       }
+       return counted / structure.total;
+   }
+   function cutRange(ranges, from, to) {
+       for (let i = 0; i < ranges.length; i++) {
+           let r = ranges[i];
+           if (r.from < to && r.to > from) {
+               let pieces = [];
+               if (r.from < from)
+                   pieces.push({ from: r.from, to: from });
+               if (r.to > to)
+                   pieces.push({ from: to, to: r.to });
+               ranges.splice(i, 1, ...pieces);
+               i += pieces.length - 1;
+           }
+       }
+   }
+   function find$1(array, f) {
+       for (let val of array)
+           if (f(val))
+               return val;
+       return undefined;
+   }
+   // Don't scale when the document height is within the range of what
+   // the DOM can handle.
+   const IdScaler$1 = {
+       toDOM(n) { return n; },
+       fromDOM(n) { return n; },
+       scale: 1
+   };
+   // When the height is too big (> VP.MaxDOMHeight), scale down the
+   // regions outside the viewports so that the total height is
+   // VP.MaxDOMHeight.
+   let BigScaler$1 = class BigScaler {
+       constructor(doc, heightMap, viewports) {
+           let vpHeight = 0, base = 0, domBase = 0;
+           this.viewports = viewports.map(({ from, to }) => {
+               let top = heightMap.lineAt(from, QueryType$2.ByPos, doc, 0, 0).top;
+               let bottom = heightMap.lineAt(to, QueryType$2.ByPos, doc, 0, 0).bottom;
+               vpHeight += bottom - top;
+               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
+           });
+           this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
+           for (let obj of this.viewports) {
+               obj.domTop = domBase + (obj.top - base) * this.scale;
+               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
+               base = obj.bottom;
+           }
+       }
+       toDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.top)
+                   return domBase + (n - base) * this.scale;
+               if (n <= vp.bottom)
+                   return vp.domTop + (n - vp.top);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+       fromDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.domTop)
+                   return base + (n - domBase) / this.scale;
+               if (n <= vp.domBottom)
+                   return vp.top + (n - vp.domTop);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+   };
+   function scaleBlock$1(block, scaler) {
+       if (scaler.scale == 1)
+           return block;
+       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
+       return new BlockInfo$1(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock$1(b, scaler)) : block.type);
+   }
+
+   const theme$1 = /*@__PURE__*/Facet$1.define({ combine: strs => strs.join(" ") });
+   const darkTheme$1 = /*@__PURE__*/Facet$1.define({ combine: values => values.indexOf(true) > -1 });
+   const baseThemeID$1 = /*@__PURE__*/StyleModule.newName(), baseLightID$1 = /*@__PURE__*/StyleModule.newName(), baseDarkID$1 = /*@__PURE__*/StyleModule.newName();
+   const lightDarkIDs$1 = { "&light": "." + baseLightID$1, "&dark": "." + baseDarkID$1 };
+   function buildTheme$1(main, spec, scopes) {
+       return new StyleModule(spec, {
+           finish(sel) {
+               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
+                   if (m == "&")
+                       return main;
+                   if (!scopes || !scopes[m])
+                       throw new RangeError(`Unsupported selector: ${m}`);
+                   return scopes[m];
+               }) : main + " " + sel;
+           }
+       });
+   }
+   const baseTheme$1$2 = /*@__PURE__*/buildTheme$1("." + baseThemeID$1, {
+       "&.cm-editor": {
+           position: "relative !important",
+           boxSizing: "border-box",
+           "&.cm-focused": {
+               // Provide a simple default outline to make sure a focused
+               // editor is visually distinct. Can't leave the default behavior
+               // because that will apply to the content element, which is
+               // inside the scrollable container and doesn't include the
+               // gutters. We also can't use an 'auto' outline, since those
+               // are, for some reason, drawn behind the element content, which
+               // will cause things like the active line background to cover
+               // the outline (#297).
+               outline: "1px dotted #212121"
+           },
+           display: "flex !important",
+           flexDirection: "column"
+       },
+       ".cm-scroller": {
+           display: "flex !important",
+           alignItems: "flex-start !important",
+           fontFamily: "monospace",
+           lineHeight: 1.4,
+           height: "100%",
+           overflowX: "auto",
+           position: "relative",
+           zIndex: 0
+       },
+       ".cm-content": {
+           margin: 0,
+           flexGrow: 2,
+           minHeight: "100%",
+           display: "block",
+           whiteSpace: "pre",
+           wordWrap: "normal",
+           boxSizing: "border-box",
+           padding: "4px 0",
+           outline: "none",
+           "&[contenteditable=true]": {
+               WebkitUserModify: "read-write-plaintext-only",
+           }
+       },
+       ".cm-lineWrapping": {
+           whiteSpace_fallback: "pre-wrap",
+           whiteSpace: "break-spaces",
+           wordBreak: "break-word",
+           overflowWrap: "anywhere"
+       },
+       "&light .cm-content": { caretColor: "black" },
+       "&dark .cm-content": { caretColor: "white" },
+       ".cm-line": {
+           display: "block",
+           padding: "0 2px 0 4px"
+       },
+       ".cm-selectionLayer": {
+           zIndex: -1,
+           contain: "size style"
+       },
+       ".cm-selectionBackground": {
+           position: "absolute",
+       },
+       "&light .cm-selectionBackground": {
+           background: "#d9d9d9"
+       },
+       "&dark .cm-selectionBackground": {
+           background: "#222"
+       },
+       "&light.cm-focused .cm-selectionBackground": {
+           background: "#d7d4f0"
+       },
+       "&dark.cm-focused .cm-selectionBackground": {
+           background: "#233"
+       },
+       ".cm-cursorLayer": {
+           zIndex: 100,
+           contain: "size style",
+           pointerEvents: "none"
+       },
+       "&.cm-focused .cm-cursorLayer": {
+           animation: "steps(1) cm-blink 1.2s infinite"
+       },
+       // Two animations defined so that we can switch between them to
+       // restart the animation without forcing another style
+       // recomputation.
+       "@keyframes cm-blink": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
+       "@keyframes cm-blink2": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
+       ".cm-cursor, .cm-dropCursor": {
+           position: "absolute",
+           borderLeft: "1.2px solid black",
+           marginLeft: "-0.6px",
+           pointerEvents: "none",
+       },
+       ".cm-cursor": {
+           display: "none"
+       },
+       "&dark .cm-cursor": {
+           borderLeftColor: "#444"
+       },
+       "&.cm-focused .cm-cursor": {
+           display: "block"
+       },
+       "&light .cm-activeLine": { backgroundColor: "#f3f9ff" },
+       "&dark .cm-activeLine": { backgroundColor: "#223039" },
+       "&light .cm-specialChar": { color: "red" },
+       "&dark .cm-specialChar": { color: "#f78" },
+       ".cm-gutters": {
+           display: "flex",
+           height: "100%",
+           boxSizing: "border-box",
+           left: 0,
+           zIndex: 200
+       },
+       "&light .cm-gutters": {
+           backgroundColor: "#f5f5f5",
+           color: "#6c6c6c",
+           borderRight: "1px solid #ddd"
+       },
+       "&dark .cm-gutters": {
+           backgroundColor: "#333338",
+           color: "#ccc"
+       },
+       ".cm-gutter": {
+           display: "flex !important",
+           flexDirection: "column",
+           flexShrink: 0,
+           boxSizing: "border-box",
+           minHeight: "100%",
+           overflow: "hidden"
+       },
+       ".cm-gutterElement": {
+           boxSizing: "border-box"
+       },
+       ".cm-lineNumbers .cm-gutterElement": {
+           padding: "0 3px 0 5px",
+           minWidth: "20px",
+           textAlign: "right",
+           whiteSpace: "nowrap"
+       },
+       "&light .cm-activeLineGutter": {
+           backgroundColor: "#e2f2ff"
+       },
+       "&dark .cm-activeLineGutter": {
+           backgroundColor: "#222227"
+       },
+       ".cm-panels": {
+           boxSizing: "border-box",
+           position: "sticky",
+           left: 0,
+           right: 0
+       },
+       "&light .cm-panels": {
+           backgroundColor: "#f5f5f5",
+           color: "black"
+       },
+       "&light .cm-panels-top": {
+           borderBottom: "1px solid #ddd"
+       },
+       "&light .cm-panels-bottom": {
+           borderTop: "1px solid #ddd"
+       },
+       "&dark .cm-panels": {
+           backgroundColor: "#333338",
+           color: "white"
+       },
+       ".cm-tab": {
+           display: "inline-block",
+           overflow: "hidden",
+           verticalAlign: "bottom"
+       },
+       ".cm-widgetBuffer": {
+           verticalAlign: "text-top",
+           height: "1em",
+           display: "inline"
+       },
+       ".cm-placeholder": {
+           color: "#888",
+           display: "inline-block",
+           verticalAlign: "top",
+       },
+       ".cm-button": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           padding: ".2em 1em",
+           borderRadius: "1px"
+       },
+       "&light .cm-button": {
+           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
+           }
+       },
+       "&dark .cm-button": {
+           backgroundImage: "linear-gradient(#393939, #111)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#111, #333)"
+           }
+       },
+       ".cm-textfield": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           border: "1px solid silver",
+           padding: ".2em .5em"
+       },
+       "&light .cm-textfield": {
+           backgroundColor: "white"
+       },
+       "&dark .cm-textfield": {
+           border: "1px solid #555",
+           backgroundColor: "inherit"
+       }
+   }, lightDarkIDs$1);
+
+   const observeOptions$1 = {
+       childList: true,
+       characterData: true,
+       subtree: true,
+       attributes: true,
+       characterDataOldValue: true
+   };
+   // IE11 has very broken mutation observers, so we also listen to
+   // DOMCharacterDataModified there
+   const useCharData$1 = browser$1.ie && browser$1.ie_version <= 11;
+   let DOMObserver$1 = class DOMObserver {
+       constructor(view, onChange, onScrollChanged) {
+           this.view = view;
+           this.onChange = onChange;
+           this.onScrollChanged = onScrollChanged;
+           this.active = false;
+           // The known selection. Kept in our own object, as opposed to just
+           // directly accessing the selection because:
+           //  - Safari doesn't report the right selection in shadow DOM
+           //  - Reading from the selection forces a DOM layout
+           //  - This way, we can ignore selectionchange events if we have
+           //    already seen the 'new' selection
+           this.selectionRange = new DOMSelectionState$1;
+           // Set when a selection change is detected, cleared on flush
+           this.selectionChanged = false;
+           this.delayedFlush = -1;
+           this.resizeTimeout = -1;
+           this.queue = [];
+           this.delayedAndroidKey = null;
+           this.scrollTargets = [];
+           this.intersection = null;
+           this.resize = null;
+           this.intersecting = false;
+           this.gapIntersection = null;
+           this.gaps = [];
+           // Timeout for scheduling check of the parents that need scroll handlers
+           this.parentCheck = -1;
+           this.dom = view.contentDOM;
+           this.observer = new MutationObserver(mutations => {
+               for (let mut of mutations)
+                   this.queue.push(mut);
+               // IE11 will sometimes (on typing over a selection or
+               // backspacing out a single character text node) call the
+               // observer callback before actually updating the DOM.
+               //
+               // Unrelatedly, iOS Safari will, when ending a composition,
+               // sometimes first clear it, deliver the mutations, and then
+               // reinsert the finished text. CodeMirror's handling of the
+               // deletion will prevent the reinsertion from happening,
+               // breaking composition.
+               if ((browser$1.ie && browser$1.ie_version <= 11 || browser$1.ios && view.composing) &&
+                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
+                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
+                   this.flushSoon();
+               else
+                   this.flush();
+           });
+           if (useCharData$1)
+               this.onCharData = (event) => {
+                   this.queue.push({ target: event.target,
+                       type: "characterData",
+                       oldValue: event.prevValue });
+                   this.flushSoon();
+               };
+           this.onSelectionChange = this.onSelectionChange.bind(this);
+           window.addEventListener("resize", this.onResize = this.onResize.bind(this));
+           if (typeof ResizeObserver == "function") {
+               this.resize = new ResizeObserver(() => {
+                   if (this.view.docView.lastUpdate < Date.now() - 75)
+                       this.onResize();
+               });
+               this.resize.observe(view.scrollDOM);
+           }
+           window.addEventListener("beforeprint", this.onPrint = this.onPrint.bind(this));
+           this.start();
+           window.addEventListener("scroll", this.onScroll = this.onScroll.bind(this));
+           if (typeof IntersectionObserver == "function") {
+               this.intersection = new IntersectionObserver(entries => {
+                   if (this.parentCheck < 0)
+                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
+                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
+                       this.intersecting = !this.intersecting;
+                       if (this.intersecting != this.view.inView)
+                           this.onScrollChanged(document.createEvent("Event"));
+                   }
+               }, {});
+               this.intersection.observe(this.dom);
+               this.gapIntersection = new IntersectionObserver(entries => {
+                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
+                       this.onScrollChanged(document.createEvent("Event"));
+               }, {});
+           }
+           this.listenForScroll();
+           this.readSelectionRange();
+           this.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
+       }
+       onScroll(e) {
+           if (this.intersecting)
+               this.flush(false);
+           this.onScrollChanged(e);
+       }
+       onResize() {
+           if (this.resizeTimeout < 0)
+               this.resizeTimeout = setTimeout(() => {
+                   this.resizeTimeout = -1;
+                   this.view.requestMeasure();
+               }, 50);
+       }
+       onPrint() {
+           this.view.viewState.printing = true;
+           this.view.measure();
+           setTimeout(() => {
+               this.view.viewState.printing = false;
+               this.view.requestMeasure();
+           }, 500);
+       }
+       updateGaps(gaps) {
+           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
+               this.gapIntersection.disconnect();
+               for (let gap of gaps)
+                   this.gapIntersection.observe(gap);
+               this.gaps = gaps;
+           }
+       }
+       onSelectionChange(event) {
+           if (!this.readSelectionRange() || this.delayedAndroidKey)
+               return;
+           let { view } = this, sel = this.selectionRange;
+           if (view.state.facet(editable$1) ? view.root.activeElement != this.dom : !hasSelection$1(view.dom, sel))
+               return;
+           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
+           if (context && context.ignoreEvent(event))
+               return;
+           // Deletions on IE11 fire their events in the wrong order, giving
+           // us a selection change event before the DOM changes are
+           // reported.
+           // Chrome Android has a similar issue when backspacing out a
+           // selection (#645).
+           if ((browser$1.ie && browser$1.ie_version <= 11 || browser$1.android && browser$1.chrome) && !view.state.selection.main.empty &&
+               // (Selection.isCollapsed isn't reliable on IE)
+               sel.focusNode && isEquivalentPosition$1(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
+               this.flushSoon();
+           else
+               this.flush(false);
+       }
+       readSelectionRange() {
+           let { root } = this.view, domSel = getSelection$1(root);
+           // The Selection object is broken in shadow roots in Safari. See
+           // https://github.com/codemirror/codemirror.next/issues/414
+           let range = browser$1.safari && root.nodeType == 11 && deepActiveElement() == this.view.contentDOM &&
+               safariSelectionRangeHack$1(this.view) || domSel;
+           if (this.selectionRange.eq(range))
+               return false;
+           this.selectionRange.setRange(range);
+           return this.selectionChanged = true;
+       }
+       setSelectionRange(anchor, head) {
+           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
+           this.selectionChanged = false;
+       }
+       clearSelectionRange() {
+           this.selectionRange.set(null, 0, null, 0);
+       }
+       listenForScroll() {
+           this.parentCheck = -1;
+           let i = 0, changed = null;
+           for (let dom = this.dom; dom;) {
+               if (dom.nodeType == 1) {
+                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
+                       i++;
+                   else if (!changed)
+                       changed = this.scrollTargets.slice(0, i);
+                   if (changed)
+                       changed.push(dom);
+                   dom = dom.assignedSlot || dom.parentNode;
+               }
+               else if (dom.nodeType == 11) { // Shadow root
+                   dom = dom.host;
+               }
+               else {
+                   break;
+               }
+           }
+           if (i < this.scrollTargets.length && !changed)
+               changed = this.scrollTargets.slice(0, i);
+           if (changed) {
+               for (let dom of this.scrollTargets)
+                   dom.removeEventListener("scroll", this.onScroll);
+               for (let dom of this.scrollTargets = changed)
+                   dom.addEventListener("scroll", this.onScroll);
+           }
+       }
+       ignore(f) {
+           if (!this.active)
+               return f();
+           try {
+               this.stop();
+               return f();
+           }
+           finally {
+               this.start();
+               this.clear();
+           }
+       }
+       start() {
+           if (this.active)
+               return;
+           this.observer.observe(this.dom, observeOptions$1);
+           if (useCharData$1)
+               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
+           this.active = true;
+       }
+       stop() {
+           if (!this.active)
+               return;
+           this.active = false;
+           this.observer.disconnect();
+           if (useCharData$1)
+               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
+       }
+       // Throw away any pending changes
+       clear() {
+           this.processRecords();
+           this.queue.length = 0;
+           this.selectionChanged = false;
+       }
+       // Chrome Android, especially in combination with GBoard, not only
+       // doesn't reliably fire regular key events, but also often
+       // surrounds the effect of enter or backspace with a bunch of
+       // composition events that, when interrupted, cause text duplication
+       // or other kinds of corruption. This hack makes the editor back off
+       // from handling DOM changes for a moment when such a key is
+       // detected (via beforeinput or keydown), and then tries to flush
+       // them or, if that has no effect, dispatches the given key.
+       delayAndroidKey(key, keyCode) {
+           if (!this.delayedAndroidKey)
+               requestAnimationFrame(() => {
+                   let key = this.delayedAndroidKey;
+                   this.delayedAndroidKey = null;
+                   this.delayedFlush = -1;
+                   if (!this.flush())
+                       dispatchKey$1(this.view.contentDOM, key.key, key.keyCode);
+               });
+           // Since backspace beforeinput is sometimes signalled spuriously,
+           // Enter always takes precedence.
+           if (!this.delayedAndroidKey || key == "Enter")
+               this.delayedAndroidKey = { key, keyCode };
+       }
+       flushSoon() {
+           if (this.delayedFlush < 0)
+               this.delayedFlush = window.setTimeout(() => { this.delayedFlush = -1; this.flush(); }, 20);
+       }
+       forceFlush() {
+           if (this.delayedFlush >= 0) {
+               window.clearTimeout(this.delayedFlush);
+               this.delayedFlush = -1;
+               this.flush();
+           }
+       }
+       processRecords() {
+           let records = this.queue;
+           for (let mut of this.observer.takeRecords())
+               records.push(mut);
+           if (records.length)
+               this.queue = [];
+           let from = -1, to = -1, typeOver = false;
+           for (let record of records) {
+               let range = this.readMutation(record);
+               if (!range)
+                   continue;
+               if (range.typeOver)
+                   typeOver = true;
+               if (from == -1) {
+                   ({ from, to } = range);
+               }
+               else {
+                   from = Math.min(range.from, from);
+                   to = Math.max(range.to, to);
+               }
+           }
+           return { from, to, typeOver };
+       }
+       // Apply pending changes, if any
+       flush(readSelection = true) {
+           // Completely hold off flushing when pending keys are set—the code
+           // managing those will make sure processRecords is called and the
+           // view is resynchronized after
+           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
+               return;
+           if (readSelection)
+               this.readSelectionRange();
+           let { from, to, typeOver } = this.processRecords();
+           let newSel = this.selectionChanged && hasSelection$1(this.dom, this.selectionRange);
+           if (from < 0 && !newSel)
+               return;
+           this.selectionChanged = false;
+           let startState = this.view.state;
+           let handled = this.onChange(from, to, typeOver);
+           // The view wasn't updated
+           if (this.view.state == startState)
+               this.view.update([]);
+           return handled;
+       }
+       readMutation(rec) {
+           let cView = this.view.docView.nearest(rec.target);
+           if (!cView || cView.ignoreMutation(rec))
+               return null;
+           cView.markDirty(rec.type == "attributes");
+           if (rec.type == "attributes")
+               cView.dirty |= 4 /* Attrs */;
+           if (rec.type == "childList") {
+               let childBefore = findChild$1(cView, rec.previousSibling || rec.target.previousSibling, -1);
+               let childAfter = findChild$1(cView, rec.nextSibling || rec.target.nextSibling, 1);
+               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
+                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
+           }
+           else if (rec.type == "characterData") {
+               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
+           }
+           else {
+               return null;
+           }
+       }
+       destroy() {
+           var _a, _b, _c;
+           this.stop();
+           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
+           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
+           (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
+           for (let dom of this.scrollTargets)
+               dom.removeEventListener("scroll", this.onScroll);
+           window.removeEventListener("scroll", this.onScroll);
+           window.removeEventListener("resize", this.onResize);
+           window.removeEventListener("beforeprint", this.onPrint);
+           this.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
+           clearTimeout(this.parentCheck);
+           clearTimeout(this.resizeTimeout);
+       }
+   };
+   function findChild$1(cView, dom, dir) {
+       while (dom) {
+           let curView = ContentView$1.get(dom);
+           if (curView && curView.parent == cView)
+               return curView;
+           let parent = dom.parentNode;
+           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
+       }
+       return null;
+   }
+   // Used to work around a Safari Selection/shadow DOM bug (#414)
+   function safariSelectionRangeHack$1(view) {
+       let found = null;
+       // Because Safari (at least in 2018-2021) doesn't provide regular
+       // access to the selection inside a shadowroot, we have to perform a
+       // ridiculous hack to get at it—using `execCommand` to trigger a
+       // `beforeInput` event so that we can read the target range from the
+       // event.
+       function read(event) {
+           event.preventDefault();
+           event.stopImmediatePropagation();
+           found = event.getTargetRanges()[0];
+       }
+       view.contentDOM.addEventListener("beforeinput", read, true);
+       document.execCommand("indent");
+       view.contentDOM.removeEventListener("beforeinput", read, true);
+       if (!found)
+           return null;
+       let anchorNode = found.startContainer, anchorOffset = found.startOffset;
+       let focusNode = found.endContainer, focusOffset = found.endOffset;
+       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
+       // Since such a range doesn't distinguish between anchor and head,
+       // use a heuristic that flips it around if its end matches the
+       // current anchor.
+       if (isEquivalentPosition$1(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
+           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
+       return { anchorNode, anchorOffset, focusNode, focusOffset };
+   }
+
+   function applyDOMChange$1(view, start, end, typeOver) {
+       let change, newSel;
+       let sel = view.state.selection.main;
+       if (start > -1) {
+           let bounds = view.docView.domBoundsAround(start, end, 0);
+           if (!bounds || view.state.readOnly)
+               return false;
+           let { from, to } = bounds;
+           let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints$1(view);
+           let reader = new DOMReader$1(selPoints, view.state);
+           reader.readRange(bounds.startDOM, bounds.endDOM);
+           let preferredPos = sel.from, preferredSide = null;
+           // Prefer anchoring to end when Backspace is pressed (or, on
+           // Android, when something was deleted)
+           if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 ||
+               browser$1.android && reader.text.length < to - from) {
+               preferredPos = sel.to;
+               preferredSide = "end";
+           }
+           let diff = findDiff$1(view.state.doc.sliceString(from, to, LineBreakPlaceholder$1), reader.text, preferredPos - from, preferredSide);
+           if (diff) {
+               // Chrome inserts two newlines when pressing shift-enter at the
+               // end of a line. This drops one of those.
+               if (browser$1.chrome && view.inputState.lastKeyCode == 13 &&
+                   diff.toB == diff.from + 2 && reader.text.slice(diff.from, diff.toB) == LineBreakPlaceholder$1 + LineBreakPlaceholder$1)
+                   diff.toB--;
+               change = { from: from + diff.from, to: from + diff.toA,
+                   insert: Text$1.of(reader.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder$1)) };
+           }
+           newSel = selectionFromPoints$1(selPoints, from);
+       }
+       else if (view.hasFocus || !view.state.facet(editable$1)) {
+           let domSel = view.observer.selectionRange;
+           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
+           let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
+               !contains$1(view.contentDOM, domSel.focusNode)
+               ? view.state.selection.main.head
+               : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
+           let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
+               !contains$1(view.contentDOM, domSel.anchorNode)
+               ? view.state.selection.main.anchor
+               : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
+           if (head != sel.head || anchor != sel.anchor)
+               newSel = EditorSelection$1.single(anchor, head);
+       }
+       if (!change && !newSel)
+           return false;
+       // Heuristic to notice typing over a selected character
+       if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
+           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
+       // If the change is inside the selection and covers most of it,
+       // assume it is a selection replace (with identical characters at
+       // the start/end not included in the diff)
+       else if (change && change.from >= sel.from && change.to <= sel.to &&
+           (change.from != sel.from || change.to != sel.to) &&
+           (sel.to - sel.from) - (change.to - change.from) <= 4)
+           change = {
+               from: sel.from, to: sel.to,
+               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
+           };
+       // Detect insert-period-on-double-space Mac behavior, and transform
+       // it into a regular space insert.
+       else if ((browser$1.mac || browser$1.android) && change && change.from == change.to && change.from == sel.head - 1 &&
+           change.insert.toString() == ".")
+           change = { from: sel.from, to: sel.to, insert: Text$1.of([" "]) };
+       if (change) {
+           let startState = view.state;
+           if (browser$1.ios && view.inputState.flushIOSKey(view))
+               return true;
+           // Android browsers don't fire reasonable key events for enter,
+           // backspace, or delete. So this detects changes that look like
+           // they're caused by those keys, and reinterprets them as key
+           // events. (Some of these keys are also handled by beforeinput
+           // events and the pendingAndroidKey mechanism, but that's not
+           // reliable in all situations.)
+           if (browser$1.android &&
+               ((change.from == sel.from && change.to == sel.to &&
+                   change.insert.length == 1 && change.insert.lines == 2 &&
+                   dispatchKey$1(view.contentDOM, "Enter", 13)) ||
+                   (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 &&
+                       dispatchKey$1(view.contentDOM, "Backspace", 8)) ||
+                   (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
+                       dispatchKey$1(view.contentDOM, "Delete", 46))))
+               return true;
+           let text = change.insert.toString();
+           if (view.state.facet(inputHandler$2).some(h => h(view, change.from, change.to, text)))
+               return true;
+           if (view.inputState.composing >= 0)
+               view.inputState.composing++;
+           let tr;
+           if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
+               (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
+               view.inputState.composing < 0) {
+               let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
+               let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
+               tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
+           }
+           else {
+               let changes = startState.changes(change);
+               let mainSel = newSel && !startState.selection.main.eq(newSel.main) && newSel.main.to <= changes.newLength
+                   ? newSel.main : undefined;
+               // Try to apply a composition change to all cursors
+               if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
+                   change.to <= sel.to && change.to >= sel.to - 10) {
+                   let replaced = view.state.sliceDoc(change.from, change.to);
+                   let compositionRange = compositionSurroundingNode(view) || view.state.doc.lineAt(sel.head);
+                   let offset = sel.to - change.to, size = sel.to - sel.from;
+                   tr = startState.changeByRange(range => {
+                       if (range.from == sel.from && range.to == sel.to)
+                           return { changes, range: mainSel || range.map(changes) };
+                       let to = range.to - offset, from = to - replaced.length;
+                       if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
+                           // Unfortunately, there's no way to make multiple
+                           // changes in the same node work without aborting
+                           // composition, so cursors in the composition range are
+                           // ignored.
+                           compositionRange && range.to >= compositionRange.from && range.from <= compositionRange.to)
+                           return { range };
+                       let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
+                       return {
+                           changes: rangeChanges,
+                           range: !mainSel ? range.map(rangeChanges) :
+                               EditorSelection$1.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
+                       };
+                   });
+               }
+               else {
+                   tr = {
+                       changes,
+                       selection: mainSel && startState.selection.replaceRange(mainSel)
+                   };
+               }
+           }
+           let userEvent = "input.type";
+           if (view.composing) {
+               userEvent += ".compose";
+               if (view.inputState.compositionFirstChange) {
+                   userEvent += ".start";
+                   view.inputState.compositionFirstChange = false;
+               }
+           }
+           view.dispatch(tr, { scrollIntoView: true, userEvent });
+           return true;
+       }
+       else if (newSel && !newSel.main.eq(sel)) {
+           let scrollIntoView = false, userEvent = "select";
+           if (view.inputState.lastSelectionTime > Date.now() - 50) {
+               if (view.inputState.lastSelectionOrigin == "select")
+                   scrollIntoView = true;
+               userEvent = view.inputState.lastSelectionOrigin;
+           }
+           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
+           return true;
+       }
+       else {
+           return false;
+       }
+   }
+   function findDiff$1(a, b, preferredPos, preferredSide) {
+       let minLen = Math.min(a.length, b.length);
+       let from = 0;
+       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
+           from++;
+       if (from == minLen && a.length == b.length)
+           return null;
+       let toA = a.length, toB = b.length;
+       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
+           toA--;
+           toB--;
+       }
+       if (preferredSide == "end") {
+           let adjust = Math.max(0, from - Math.min(toA, toB));
+           preferredPos -= toA + adjust - from;
+       }
+       if (toA < from && a.length < b.length) {
+           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
+           from -= move;
+           toB = from + (toB - toA);
+           toA = from;
+       }
+       else if (toB < from) {
+           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
+           from -= move;
+           toA = from + (toA - toB);
+           toB = from;
+       }
+       return { from, toA, toB };
+   }
+   function selectionPoints$1(view) {
+       let result = [];
+       if (view.root.activeElement != view.contentDOM)
+           return result;
+       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
+       if (anchorNode) {
+           result.push(new DOMPoint$1(anchorNode, anchorOffset));
+           if (focusNode != anchorNode || focusOffset != anchorOffset)
+               result.push(new DOMPoint$1(focusNode, focusOffset));
+       }
+       return result;
+   }
+   function selectionFromPoints$1(points, base) {
+       if (points.length == 0)
+           return null;
+       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
+       return anchor > -1 && head > -1 ? EditorSelection$1.single(anchor + base, head + base) : null;
+   }
+
+   // The editor's update state machine looks something like this:
+   //
+   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
+   //                                         ↑      ↓
+   //                                         Updating (measure)
+   //
+   // The difference between 'Idle' and 'Idle (unchecked)' lies in
+   // whether a layout check has been scheduled. A regular update through
+   // the `update` method updates the DOM in a write-only fashion, and
+   // relies on a check (scheduled with `requestAnimationFrame`) to make
+   // sure everything is where it should be and the viewport covers the
+   // visible code. That check continues to measure and then optionally
+   // update until it reaches a coherent state.
+   /**
+   An editor view represents the editor's user interface. It holds
+   the editable DOM surface, and possibly other elements such as the
+   line number gutter. It handles events and dispatches state
+   transactions for editing actions.
+   */
+   let EditorView$1 = class EditorView {
+       /**
+       Construct a new view. You'll want to either provide a `parent`
+       option, or put `view.dom` into your document after creating a
+       view, so that the user can see the editor.
+       */
+       constructor(
+       /**
+       Initialization options.
+       */
+       config = {}) {
+           this.plugins = [];
+           this.pluginMap = new Map;
+           this.editorAttrs = {};
+           this.contentAttrs = {};
+           this.bidiCache = [];
+           this.destroyed = false;
+           /**
+           @internal
+           */
+           this.updateState = 2 /* Updating */;
+           /**
+           @internal
+           */
+           this.measureScheduled = -1;
+           /**
+           @internal
+           */
+           this.measureRequests = [];
+           this.contentDOM = document.createElement("div");
+           this.scrollDOM = document.createElement("div");
+           this.scrollDOM.tabIndex = -1;
+           this.scrollDOM.className = "cm-scroller";
+           this.scrollDOM.appendChild(this.contentDOM);
+           this.announceDOM = document.createElement("div");
+           this.announceDOM.style.cssText = "position: absolute; top: -10000px";
+           this.announceDOM.setAttribute("aria-live", "polite");
+           this.dom = document.createElement("div");
+           this.dom.appendChild(this.announceDOM);
+           this.dom.appendChild(this.scrollDOM);
+           this._dispatch = config.dispatch || ((tr) => this.update([tr]));
+           this.dispatch = this.dispatch.bind(this);
+           this.root = (config.root || getRoot$1(config.parent) || document);
+           this.viewState = new ViewState$1(config.state || EditorState$1.create());
+           this.plugins = this.state.facet(viewPlugin$1).map(spec => new PluginInstance$1(spec));
+           for (let plugin of this.plugins)
+               plugin.update(this);
+           this.observer = new DOMObserver$1(this, (from, to, typeOver) => {
+               return applyDOMChange$1(this, from, to, typeOver);
+           }, event => {
+               this.inputState.runScrollHandlers(this, event);
+               if (this.observer.intersecting)
+                   this.measure();
+           });
+           this.inputState = new InputState$1(this);
+           this.inputState.ensureHandlers(this, this.plugins);
+           this.docView = new DocView$1(this);
+           this.mountStyles();
+           this.updateAttrs();
+           this.updateState = 0 /* Idle */;
+           this.requestMeasure();
+           if (config.parent)
+               config.parent.appendChild(this.dom);
+       }
+       /**
+       The current editor state.
+       */
+       get state() { return this.viewState.state; }
+       /**
+       To be able to display large documents without consuming too much
+       memory or overloading the browser, CodeMirror only draws the
+       code that is visible (plus a margin around it) to the DOM. This
+       property tells you the extent of the current drawn viewport, in
+       document positions.
+       */
+       get viewport() { return this.viewState.viewport; }
+       /**
+       When there are, for example, large collapsed ranges in the
+       viewport, its size can be a lot bigger than the actual visible
+       content. Thus, if you are doing something like styling the
+       content in the viewport, it is preferable to only do so for
+       these ranges, which are the subset of the viewport that is
+       actually drawn.
+       */
+       get visibleRanges() { return this.viewState.visibleRanges; }
+       /**
+       Returns false when the editor is entirely scrolled out of view
+       or otherwise hidden.
+       */
+       get inView() { return this.viewState.inView; }
+       /**
+       Indicates whether the user is currently composing text via
+       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
+       one change has been made in the current composition.
+       */
+       get composing() { return this.inputState.composing > 0; }
+       /**
+       Indicates whether the user is currently in composing state. Note
+       that on some platforms, like Android, this will be the case a
+       lot, since just putting the cursor on a word starts a
+       composition there.
+       */
+       get compositionStarted() { return this.inputState.composing >= 0; }
+       dispatch(...input) {
+           this._dispatch(input.length == 1 && input[0] instanceof Transaction$1 ? input[0]
+               : this.state.update(...input));
+       }
+       /**
+       Update the view for the given array of transactions. This will
+       update the visible document and selection to match the state
+       produced by the transactions, and notify view plugins of the
+       change. You should usually call
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
+       as a primitive.
+       */
+       update(transactions) {
+           if (this.updateState != 0 /* Idle */)
+               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
+           let redrawn = false, attrsChanged = false, update;
+           let state = this.state;
+           for (let tr of transactions) {
+               if (tr.startState != state)
+                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
+               state = tr.state;
+           }
+           if (this.destroyed) {
+               this.viewState.state = state;
+               return;
+           }
+           this.observer.clear();
+           // When the phrases change, redraw the editor
+           if (state.facet(EditorState$1.phrases) != this.state.facet(EditorState$1.phrases))
+               return this.setState(state);
+           update = ViewUpdate$1.create(this, state, transactions);
+           let scrollTarget = this.viewState.scrollTarget;
+           try {
+               this.updateState = 2 /* Updating */;
+               for (let tr of transactions) {
+                   if (scrollTarget)
+                       scrollTarget = scrollTarget.map(tr.changes);
+                   if (tr.scrollIntoView) {
+                       let { main } = tr.state.selection;
+                       scrollTarget = new ScrollTarget$1(main.empty ? main : EditorSelection$1.cursor(main.head, main.head > main.anchor ? -1 : 1));
+                   }
+                   for (let e of tr.effects)
+                       if (e.is(scrollIntoView$3))
+                           scrollTarget = e.value;
+               }
+               this.viewState.update(update, scrollTarget);
+               this.bidiCache = CachedOrder$1.update(this.bidiCache, update.changes);
+               if (!update.empty) {
+                   this.updatePlugins(update);
+                   this.inputState.update(update);
+               }
+               redrawn = this.docView.update(update);
+               if (this.state.facet(styleModule$1) != this.styleModules)
+                   this.mountStyles();
+               attrsChanged = this.updateAttrs();
+               this.showAnnouncements(transactions);
+               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+           }
+           if (update.startState.facet(theme$1) != update.state.facet(theme$1))
+               this.viewState.mustMeasureContent = true;
+           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
+               this.requestMeasure();
+           if (!update.empty)
+               for (let listener of this.state.facet(updateListener$1))
+                   listener(update);
+       }
+       /**
+       Reset the view to the given state. (This will cause the entire
+       document to be redrawn and all view plugins to be reinitialized,
+       so you should probably only use it when the new state isn't
+       derived from the old state. Otherwise, use
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
+       */
+       setState(newState) {
+           if (this.updateState != 0 /* Idle */)
+               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
+           if (this.destroyed) {
+               this.viewState.state = newState;
+               return;
+           }
+           this.updateState = 2 /* Updating */;
+           let hadFocus = this.hasFocus;
+           try {
+               for (let plugin of this.plugins)
+                   plugin.destroy(this);
+               this.viewState = new ViewState$1(newState);
+               this.plugins = newState.facet(viewPlugin$1).map(spec => new PluginInstance$1(spec));
+               this.pluginMap.clear();
+               for (let plugin of this.plugins)
+                   plugin.update(this);
+               this.docView = new DocView$1(this);
+               this.inputState.ensureHandlers(this, this.plugins);
+               this.mountStyles();
+               this.updateAttrs();
+               this.bidiCache = [];
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+           }
+           if (hadFocus)
+               this.focus();
+           this.requestMeasure();
+       }
+       updatePlugins(update) {
+           let prevSpecs = update.startState.facet(viewPlugin$1), specs = update.state.facet(viewPlugin$1);
+           if (prevSpecs != specs) {
+               let newPlugins = [];
+               for (let spec of specs) {
+                   let found = prevSpecs.indexOf(spec);
+                   if (found < 0) {
+                       newPlugins.push(new PluginInstance$1(spec));
+                   }
+                   else {
+                       let plugin = this.plugins[found];
+                       plugin.mustUpdate = update;
+                       newPlugins.push(plugin);
+                   }
+               }
+               for (let plugin of this.plugins)
+                   if (plugin.mustUpdate != update)
+                       plugin.destroy(this);
+               this.plugins = newPlugins;
+               this.pluginMap.clear();
+               this.inputState.ensureHandlers(this, this.plugins);
+           }
+           else {
+               for (let p of this.plugins)
+                   p.mustUpdate = update;
+           }
+           for (let i = 0; i < this.plugins.length; i++)
+               this.plugins[i].update(this);
+       }
+       /**
+       @internal
+       */
+       measure(flush = true) {
+           if (this.destroyed)
+               return;
+           if (this.measureScheduled > -1)
+               cancelAnimationFrame(this.measureScheduled);
+           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
+           if (flush)
+               this.observer.flush();
+           let updated = null;
+           try {
+               for (let i = 0;; i++) {
+                   this.updateState = 1 /* Measuring */;
+                   let oldViewport = this.viewport;
+                   let changed = this.viewState.measure(this);
+                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
+                       break;
+                   if (i > 5) {
+                       console.warn(this.measureRequests.length
+                           ? "Measure loop restarted more than 5 times"
+                           : "Viewport failed to stabilize");
+                       break;
+                   }
+                   let measuring = [];
+                   // Only run measure requests in this cycle when the viewport didn't change
+                   if (!(changed & 4 /* Viewport */))
+                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
+                   let measured = measuring.map(m => {
+                       try {
+                           return m.read(this);
+                       }
+                       catch (e) {
+                           logException$1(this.state, e);
+                           return BadMeasure$1;
+                       }
+                   });
+                   let update = ViewUpdate$1.create(this, this.state, []), redrawn = false, scrolled = false;
+                   update.flags |= changed;
+                   if (!updated)
+                       updated = update;
+                   else
+                       updated.flags |= changed;
+                   this.updateState = 2 /* Updating */;
+                   if (!update.empty) {
+                       this.updatePlugins(update);
+                       this.inputState.update(update);
+                       this.updateAttrs();
+                       redrawn = this.docView.update(update);
+                   }
+                   for (let i = 0; i < measuring.length; i++)
+                       if (measured[i] != BadMeasure$1) {
+                           try {
+                               let m = measuring[i];
+                               if (m.write)
+                                   m.write(measured[i], this);
+                           }
+                           catch (e) {
+                               logException$1(this.state, e);
+                           }
+                       }
+                   if (this.viewState.scrollTarget) {
+                       this.docView.scrollIntoView(this.viewState.scrollTarget);
+                       this.viewState.scrollTarget = null;
+                       scrolled = true;
+                   }
+                   if (redrawn)
+                       this.docView.updateSelection(true);
+                   if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
+                       !scrolled && this.measureRequests.length == 0)
+                       break;
+               }
+           }
+           finally {
+               this.updateState = 0 /* Idle */;
+               this.measureScheduled = -1;
+           }
+           if (updated && !updated.empty)
+               for (let listener of this.state.facet(updateListener$1))
+                   listener(updated);
+       }
+       /**
+       Get the CSS classes for the currently active editor themes.
+       */
+       get themeClasses() {
+           return baseThemeID$1 + " " +
+               (this.state.facet(darkTheme$1) ? baseDarkID$1 : baseLightID$1) + " " +
+               this.state.facet(theme$1);
+       }
+       updateAttrs() {
+           let editorAttrs = attrsFromFacet$1(this, editorAttributes$1, {
+               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
+           });
+           let contentAttrs = {
+               spellcheck: "false",
+               autocorrect: "off",
+               autocapitalize: "off",
+               translate: "no",
+               contenteditable: !this.state.facet(editable$1) ? "false" : "true",
+               class: "cm-content",
+               style: `${browser$1.tabSize}: ${this.state.tabSize}`,
+               role: "textbox",
+               "aria-multiline": "true"
+           };
+           if (this.state.readOnly)
+               contentAttrs["aria-readonly"] = "true";
+           attrsFromFacet$1(this, contentAttributes$1, contentAttrs);
+           let changed = this.observer.ignore(() => {
+               let changedContent = updateAttrs$1(this.contentDOM, this.contentAttrs, contentAttrs);
+               let changedEditor = updateAttrs$1(this.dom, this.editorAttrs, editorAttrs);
+               return changedContent || changedEditor;
+           });
+           this.editorAttrs = editorAttrs;
+           this.contentAttrs = contentAttrs;
+           return changed;
+       }
+       showAnnouncements(trs) {
+           let first = true;
+           for (let tr of trs)
+               for (let effect of tr.effects)
+                   if (effect.is(EditorView.announce)) {
+                       if (first)
+                           this.announceDOM.textContent = "";
+                       first = false;
+                       let div = this.announceDOM.appendChild(document.createElement("div"));
+                       div.textContent = effect.value;
+                   }
+       }
+       mountStyles() {
+           this.styleModules = this.state.facet(styleModule$1);
+           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$2).reverse());
+       }
+       readMeasured() {
+           if (this.updateState == 2 /* Updating */)
+               throw new Error("Reading the editor layout isn't allowed during an update");
+           if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
+               this.measure(false);
+       }
+       /**
+       Schedule a layout measurement, optionally providing callbacks to
+       do custom DOM measuring followed by a DOM write phase. Using
+       this is preferable reading DOM layout directly from, for
+       example, an event handler, because it'll make sure measuring and
+       drawing done by other components is synchronized, avoiding
+       unnecessary DOM layout computations.
+       */
+       requestMeasure(request) {
+           if (this.measureScheduled < 0)
+               this.measureScheduled = requestAnimationFrame(() => this.measure());
+           if (request) {
+               if (request.key != null)
+                   for (let i = 0; i < this.measureRequests.length; i++) {
+                       if (this.measureRequests[i].key === request.key) {
+                           this.measureRequests[i] = request;
+                           return;
+                       }
+                   }
+               this.measureRequests.push(request);
+           }
+       }
+       /**
+       Get the value of a specific plugin, if present. Note that
+       plugins that crash can be dropped from a view, so even when you
+       know you registered a given plugin, it is recommended to check
+       the return value of this method.
+       */
+       plugin(plugin) {
+           let known = this.pluginMap.get(plugin);
+           if (known === undefined || known && known.spec != plugin)
+               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
+           return known && known.update(this).value;
+       }
+       /**
+       The top position of the document, in screen coordinates. This
+       may be negative when the editor is scrolled down. Points
+       directly to the top of the first line, not above the padding.
+       */
+       get documentTop() {
+           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
+       }
+       /**
+       Reports the padding above and below the document.
+       */
+       get documentPadding() {
+           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
+       }
+       /**
+       Find the text line or block widget at the given vertical
+       position (which is interpreted as relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
+       */
+       elementAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.elementAtHeight(height);
+       }
+       /**
+       Find the line block (see
+       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
+       height.
+       */
+       lineBlockAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.lineBlockAtHeight(height);
+       }
+       /**
+       Get the extent and vertical position of all [line
+       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
+       are relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
+       */
+       get viewportLineBlocks() {
+           return this.viewState.viewportLines;
+       }
+       /**
+       Find the line block around the given document position. A line
+       block is a range delimited on both sides by either a
+       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
+       start/end of the document. It will usually just hold a line of
+       text, but may be broken into multiple textblocks by block
+       widgets.
+       */
+       lineBlockAt(pos) {
+           return this.viewState.lineBlockAt(pos);
+       }
+       /**
+       The editor's total content height.
+       */
+       get contentHeight() {
+           return this.viewState.contentHeight;
+       }
+       /**
+       Move a cursor position by [grapheme
+       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
+       the motion is away from the line start, or towards it. In
+       bidirectional text, the line is traversed in visual order, using
+       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+       When the start position was the last one on the line, the
+       returned position will be across the line break. If there is no
+       further line, the original position is returned.
+       
+       By default, this method moves over a single cluster. The
+       optional `by` argument can be used to move across more. It will
+       be called with the first cluster as argument, and should return
+       a predicate that determines, for each subsequent cluster,
+       whether it should also be moved over.
+       */
+       moveByChar(start, forward, by) {
+           return skipAtoms$1(this, start, moveByChar$1(this, start, forward, by));
+       }
+       /**
+       Move a cursor position across the next group of either
+       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
+       non-whitespace characters.
+       */
+       moveByGroup(start, forward) {
+           return skipAtoms$1(this, start, moveByChar$1(this, start, forward, initial => byGroup$1(this, start.head, initial)));
+       }
+       /**
+       Move to the next line boundary in the given direction. If
+       `includeWrap` is true, line wrapping is on, and there is a
+       further wrap point on the current line, the wrap point will be
+       returned. Otherwise this function will return the start or end
+       of the line.
+       */
+       moveToLineBoundary(start, forward, includeWrap = true) {
+           return moveToLineBoundary$1(this, start, forward, includeWrap);
+       }
+       /**
+       Move a cursor position vertically. When `distance` isn't given,
+       it defaults to moving to the next line (including wrapped
+       lines). Otherwise, `distance` should provide a positive distance
+       in pixels.
+       
+       When `start` has a
+       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
+       motion will use that as a target horizontal position. Otherwise,
+       the cursor's own horizontal position is used. The returned
+       cursor will have its goal column set to whichever column was
+       used.
+       */
+       moveVertically(start, forward, distance) {
+           return skipAtoms$1(this, start, moveVertically$1(this, start, forward, distance));
+       }
+       /**
+       Find the DOM parent node and offset (child offset if `node` is
+       an element, character offset when it is a text node) at the
+       given document position.
+       
+       Note that for positions that aren't currently in
+       `visibleRanges`, the resulting DOM position isn't necessarily
+       meaningful (it may just point before or after a placeholder
+       element).
+       */
+       domAtPos(pos) {
+           return this.docView.domAtPos(pos);
+       }
+       /**
+       Find the document position at the given DOM node. Can be useful
+       for associating positions with DOM events. Will raise an error
+       when `node` isn't part of the editor content.
+       */
+       posAtDOM(node, offset = 0) {
+           return this.docView.posFromDOM(node, offset);
+       }
+       posAtCoords(coords, precise = true) {
+           this.readMeasured();
+           return posAtCoords$1(this, coords, precise);
+       }
+       /**
+       Get the screen coordinates at the given document position.
+       `side` determines whether the coordinates are based on the
+       element before (-1) or after (1) the position (if no element is
+       available on the given side, the method will transparently use
+       another strategy to get reasonable coordinates).
+       */
+       coordsAtPos(pos, side = 1) {
+           this.readMeasured();
+           let rect = this.docView.coordsAt(pos, side);
+           if (!rect || rect.left == rect.right)
+               return rect;
+           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
+           let span = order[BidiSpan$1.find(order, pos - line.from, -1, side)];
+           return flattenRect$1(rect, (span.dir == Direction$1.LTR) == (side > 0));
+       }
+       /**
+       The default width of a character in the editor. May not
+       accurately reflect the width of all characters (given variable
+       width fonts or styling of invididual ranges).
+       */
+       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
+       /**
+       The default height of a line in the editor. May not be accurate
+       for all lines.
+       */
+       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
+       /**
+       The text direction
+       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
+       CSS property) of the editor's content element.
+       */
+       get textDirection() { return this.viewState.defaultTextDirection; }
+       /**
+       Find the text direction of the block at the given position, as
+       assigned by CSS. If
+       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
+       isn't enabled, or the given position is outside of the viewport,
+       this will always return the same as
+       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
+       this may trigger a DOM layout.
+       */
+       textDirectionAt(pos) {
+           let perLine = this.state.facet(perLineTextDirection$1);
+           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
+               return this.textDirection;
+           this.readMeasured();
+           return this.docView.textDirectionAt(pos);
+       }
+       /**
+       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
+       (as determined by the
+       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
+       CSS property of its content element).
+       */
+       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
+       /**
+       Returns the bidirectional text structure of the given line
+       (which should be in the current document) as an array of span
+       objects. The order of these spans matches the [text
+       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
+       left-to-right, the leftmost spans come first, otherwise the
+       rightmost spans come first.
+       */
+       bidiSpans(line) {
+           if (line.length > MaxBidiLine$1)
+               return trivialOrder$1(line.length);
+           let dir = this.textDirectionAt(line.from);
+           for (let entry of this.bidiCache)
+               if (entry.from == line.from && entry.dir == dir)
+                   return entry.order;
+           let order = computeOrder$1(line.text, dir);
+           this.bidiCache.push(new CachedOrder$1(line.from, line.to, dir, order));
+           return order;
+       }
+       /**
+       Check whether the editor has focus.
+       */
+       get hasFocus() {
+           var _a;
+           // Safari return false for hasFocus when the context menu is open
+           // or closing, which leads us to ignore selection changes from the
+           // context menu because it looks like the editor isn't focused.
+           // This kludges around that.
+           return (document.hasFocus() || browser$1.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
+               this.root.activeElement == this.contentDOM;
+       }
+       /**
+       Put focus on the editor.
+       */
+       focus() {
+           this.observer.ignore(() => {
+               focusPreventScroll$1(this.contentDOM);
+               this.docView.updateSelection();
+           });
+       }
+       /**
+       Clean up this editor view, removing its element from the
+       document, unregistering event handlers, and notifying
+       plugins. The view instance can no longer be used after
+       calling this.
+       */
+       destroy() {
+           for (let plugin of this.plugins)
+               plugin.destroy(this);
+           this.plugins = [];
+           this.inputState.destroy();
+           this.dom.remove();
+           this.observer.destroy();
+           if (this.measureScheduled > -1)
+               cancelAnimationFrame(this.measureScheduled);
+           this.destroyed = true;
+       }
+       /**
+       Returns an effect that can be
+       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
+       cause it to scroll the given position or range into view.
+       */
+       static scrollIntoView(pos, options = {}) {
+           return scrollIntoView$3.of(new ScrollTarget$1(typeof pos == "number" ? EditorSelection$1.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
+       }
+       /**
+       Returns an extension that can be used to add DOM event handlers.
+       The value should be an object mapping event names to handler
+       functions. For any given event, such functions are ordered by
+       extension precedence, and the first handler to return true will
+       be assumed to have handled that event, and no other handlers or
+       built-in behavior will be activated for it. These are registered
+       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
+       for `scroll` handlers, which will be called any time the
+       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
+       its parent nodes is scrolled.
+       */
+       static domEventHandlers(handlers) {
+           return ViewPlugin$1.define(() => ({}), { eventHandlers: handlers });
+       }
+       /**
+       Create a theme extension. The first argument can be a
+       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
+       style spec providing the styles for the theme. These will be
+       prefixed with a generated class for the style.
+       
+       Because the selectors will be prefixed with a scope class, rule
+       that directly match the editor's [wrapper
+       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
+       added—need to be explicitly differentiated by adding an `&` to
+       the selector for that element—for example
+       `&.cm-focused`.
+       
+       When `dark` is set to true, the theme will be marked as dark,
+       which will cause the `&dark` rules from [base
+       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
+       `&light` when a light theme is active).
+       */
+       static theme(spec, options) {
+           let prefix = StyleModule.newName();
+           let result = [theme$1.of(prefix), styleModule$1.of(buildTheme$1(`.${prefix}`, spec))];
+           if (options && options.dark)
+               result.push(darkTheme$1.of(true));
+           return result;
+       }
+       /**
+       Create an extension that adds styles to the base theme. Like
+       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
+       place of the editor wrapper element when directly targeting
+       that. You can also use `&dark` or `&light` instead to only
+       target editors with a dark or light theme.
+       */
+       static baseTheme(spec) {
+           return Prec$1.lowest(styleModule$1.of(buildTheme$1("." + baseThemeID$1, spec, lightDarkIDs$1)));
+       }
+   };
+   /**
+   Facet to add a [style
+   module](https://github.com/marijnh/style-mod#documentation) to
+   an editor view. The view will ensure that the module is
+   mounted in its [document
+   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
+   */
+   EditorView$1.styleModule = styleModule$1;
+   /**
+   An input handler can override the way changes to the editable
+   DOM content are handled. Handlers are passed the document
+   positions between which the change was found, and the new
+   content. When one returns true, no further input handlers are
+   called and the default behavior is prevented.
+   */
+   EditorView$1.inputHandler = inputHandler$2;
+   /**
+   By default, the editor assumes all its content has the same
+   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
+   value to make it read the text direction of every (rendered)
+   line separately.
+   */
+   EditorView$1.perLineTextDirection = perLineTextDirection$1;
+   /**
+   Allows you to provide a function that should be called when the
+   library catches an exception from an extension (mostly from view
+   plugins, but may be used by other extensions to route exceptions
+   from user-code-provided callbacks). This is mostly useful for
+   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
+   */
+   EditorView$1.exceptionSink = exceptionSink$1;
+   /**
+   A facet that can be used to register a function to be called
+   every time the view updates.
+   */
+   EditorView$1.updateListener = updateListener$1;
+   /**
+   Facet that controls whether the editor content DOM is editable.
+   When its highest-precedence value is `false`, the element will
+   not have its `contenteditable` attribute set. (Note that this
+   doesn't affect API calls that change the editor content, even
+   when those are bound to keys or buttons. See the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
+   */
+   EditorView$1.editable = editable$1;
+   /**
+   Allows you to influence the way mouse selection happens. The
+   functions in this facet will be called for a `mousedown` event
+   on the editor, and can return an object that overrides the way a
+   selection is computed from that mouse click or drag.
+   */
+   EditorView$1.mouseSelectionStyle = mouseSelectionStyle$1;
+   /**
+   Facet used to configure whether a given selection drag event
+   should move or copy the selection. The given predicate will be
+   called with the `mousedown` event, and can return `true` when
+   the drag should move the content.
+   */
+   EditorView$1.dragMovesSelection = dragMovesSelection$1$1;
+   /**
+   Facet used to configure whether a given selecting click adds a
+   new range to the existing selection or replaces it entirely. The
+   default behavior is to check `event.metaKey` on macOS, and
+   `event.ctrlKey` elsewhere.
+   */
+   EditorView$1.clickAddsSelectionRange = clickAddsSelectionRange$1;
+   /**
+   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
+   are shown in the view. Decorations can be provided in two
+   ways—directly, or via a function that takes an editor view.
+
+   Only decoration sets provided directly are allowed to influence
+   the editor's vertical layout structure. The ones provided as
+   functions are called _after_ the new viewport has been computed,
+   and thus **must not** introduce block widgets or replacing
+   decorations that cover line breaks.
+   */
+   EditorView$1.decorations = decorations$1;
+   /**
+   Used to provide ranges that should be treated as atoms as far as
+   cursor motion is concerned. This causes methods like
+   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
+   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
+   commands built on top of them) to skip across such regions when
+   a selection endpoint would enter them. This does _not_ prevent
+   direct programmatic [selection
+   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
+   regions.
+   */
+   EditorView$1.atomicRanges = atomicRanges$1;
+   /**
+   Facet that allows extensions to provide additional scroll
+   margins (space around the sides of the scrolling element that
+   should be considered invisible). This can be useful when the
+   plugin introduces elements that cover part of that element (for
+   example a horizontally fixed gutter).
+   */
+   EditorView$1.scrollMargins = scrollMargins$1;
+   /**
+   This facet records whether a dark theme is active. The extension
+   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
+   includes an instance of this when the `dark` option is set to
+   true.
+   */
+   EditorView$1.darkTheme = darkTheme$1;
+   /**
+   Facet that provides additional DOM attributes for the editor's
+   editable DOM element.
+   */
+   EditorView$1.contentAttributes = contentAttributes$1;
+   /**
+   Facet that provides DOM attributes for the editor's outer
+   element.
+   */
+   EditorView$1.editorAttributes = editorAttributes$1;
+   /**
+   An extension that enables line wrapping in the editor (by
+   setting CSS `white-space` to `pre-wrap` in the content).
+   */
+   EditorView$1.lineWrapping = /*@__PURE__*/EditorView$1.contentAttributes.of({ "class": "cm-lineWrapping" });
+   /**
+   State effect used to include screen reader announcements in a
+   transaction. These will be added to the DOM in a visually hidden
+   element with `aria-live="polite"` set, and should be used to
+   describe effects that are visually obvious but may not be
+   noticed by screen reader users (such as moving to the next
+   search match).
+   */
+   EditorView$1.announce = /*@__PURE__*/StateEffect$1.define();
+   // Maximum line length for which we compute accurate bidi info
+   const MaxBidiLine$1 = 4096;
+   const BadMeasure$1 = {};
+   let CachedOrder$1 = class CachedOrder {
+       constructor(from, to, dir, order) {
+           this.from = from;
+           this.to = to;
+           this.dir = dir;
+           this.order = order;
+       }
+       static update(cache, changes) {
+           if (changes.empty)
+               return cache;
+           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction$1.LTR;
+           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
+               let entry = cache[i];
+               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
+                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.order));
+           }
+           return result;
+       }
+   };
+   function attrsFromFacet$1(view, facet, base) {
+       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
+           let source = sources[i], value = typeof source == "function" ? source(view) : source;
+           if (value)
+               combineAttrs$1(value, base);
+       }
+       return base;
+   }
+
+   const currentPlatform$1 = browser$1.mac ? "mac" : browser$1.windows ? "win" : browser$1.linux ? "linux" : "key";
+   function normalizeKeyName$1(name, platform) {
+       const parts = name.split(/-(?!$)/);
+       let result = parts[parts.length - 1];
+       if (result == "Space")
+           result = " ";
+       let alt, ctrl, shift, meta;
+       for (let i = 0; i < parts.length - 1; ++i) {
+           const mod = parts[i];
+           if (/^(cmd|meta|m)$/i.test(mod))
+               meta = true;
+           else if (/^a(lt)?$/i.test(mod))
+               alt = true;
+           else if (/^(c|ctrl|control)$/i.test(mod))
+               ctrl = true;
+           else if (/^s(hift)?$/i.test(mod))
+               shift = true;
+           else if (/^mod$/i.test(mod)) {
+               if (platform == "mac")
+                   meta = true;
+               else
+                   ctrl = true;
+           }
+           else
+               throw new Error("Unrecognized modifier name: " + mod);
+       }
+       if (alt)
+           result = "Alt-" + result;
+       if (ctrl)
+           result = "Ctrl-" + result;
+       if (meta)
+           result = "Meta-" + result;
+       if (shift)
+           result = "Shift-" + result;
+       return result;
+   }
+   function modifiers$1(name, event, shift) {
+       if (event.altKey)
+           name = "Alt-" + name;
+       if (event.ctrlKey)
+           name = "Ctrl-" + name;
+       if (event.metaKey)
+           name = "Meta-" + name;
+       if (shift !== false && event.shiftKey)
+           name = "Shift-" + name;
+       return name;
+   }
+   const handleKeyEvents$1 = /*@__PURE__*/EditorView$1.domEventHandlers({
+       keydown(event, view) {
+           return runHandlers$1(getKeymap$1(view.state), event, view, "editor");
+       }
+   });
+   /**
+   Facet used for registering keymaps.
+
+   You can add multiple keymaps to an editor. Their priorities
+   determine their precedence (the ones specified early or with high
+   priority get checked first). When a handler has returned `true`
+   for a given key, no further handlers are called.
+   */
+   const keymap$1 = /*@__PURE__*/Facet$1.define({ enables: handleKeyEvents$1 });
+   const Keymaps$1 = /*@__PURE__*/new WeakMap();
+   // This is hidden behind an indirection, rather than directly computed
+   // by the facet, to keep internal types out of the facet's type.
+   function getKeymap$1(state) {
+       let bindings = state.facet(keymap$1);
+       let map = Keymaps$1.get(bindings);
+       if (!map)
+           Keymaps$1.set(bindings, map = buildKeymap$1(bindings.reduce((a, b) => a.concat(b), [])));
+       return map;
+   }
+   /**
+   Run the key handlers registered for a given scope. The event
+   object should be a `"keydown"` event. Returns true if any of the
+   handlers handled it.
+   */
+   function runScopeHandlers(view, event, scope) {
+       return runHandlers$1(getKeymap$1(view.state), event, view, scope);
+   }
+   let storedPrefix$1 = null;
+   const PrefixTimeout$1 = 4000;
+   function buildKeymap$1(bindings, platform = currentPlatform$1) {
+       let bound = Object.create(null);
+       let isPrefix = Object.create(null);
+       let checkPrefix = (name, is) => {
+           let current = isPrefix[name];
+           if (current == null)
+               isPrefix[name] = is;
+           else if (current != is)
+               throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
+       };
+       let add = (scope, key, command, preventDefault) => {
+           let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
+           let parts = key.split(/ (?!$)/).map(k => normalizeKeyName$1(k, platform));
+           for (let i = 1; i < parts.length; i++) {
+               let prefix = parts.slice(0, i).join(" ");
+               checkPrefix(prefix, true);
+               if (!scopeObj[prefix])
+                   scopeObj[prefix] = {
+                       preventDefault: true,
+                       commands: [(view) => {
+                               let ourObj = storedPrefix$1 = { view, prefix, scope };
+                               setTimeout(() => { if (storedPrefix$1 == ourObj)
+                                   storedPrefix$1 = null; }, PrefixTimeout$1);
+                               return true;
+                           }]
+                   };
+           }
+           let full = parts.join(" ");
+           checkPrefix(full, false);
+           let binding = scopeObj[full] || (scopeObj[full] = { preventDefault: false, commands: [] });
+           binding.commands.push(command);
+           if (preventDefault)
+               binding.preventDefault = true;
+       };
+       for (let b of bindings) {
+           let name = b[platform] || b.key;
+           if (!name)
+               continue;
+           for (let scope of b.scope ? b.scope.split(" ") : ["editor"]) {
+               add(scope, name, b.run, b.preventDefault);
+               if (b.shift)
+                   add(scope, "Shift-" + name, b.shift, b.preventDefault);
+           }
+       }
+       return bound;
+   }
+   function runHandlers$1(map, event, view, scope) {
+       let name = keyName(event), isChar = name.length == 1 && name != " ";
+       let prefix = "", fallthrough = false;
+       if (storedPrefix$1 && storedPrefix$1.view == view && storedPrefix$1.scope == scope) {
+           prefix = storedPrefix$1.prefix + " ";
+           if (fallthrough = modifierCodes$1.indexOf(event.keyCode) < 0)
+               storedPrefix$1 = null;
+       }
+       let runFor = (binding) => {
+           if (binding) {
+               for (let cmd of binding.commands)
+                   if (cmd(view))
+                       return true;
+               if (binding.preventDefault)
+                   fallthrough = true;
+           }
+           return false;
+       };
+       let scopeObj = map[scope], baseName;
+       if (scopeObj) {
+           if (runFor(scopeObj[prefix + modifiers$1(name, event, !isChar)]))
+               return true;
+           if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
+               (baseName = base[event.keyCode]) && baseName != name) {
+               if (runFor(scopeObj[prefix + modifiers$1(baseName, event, true)]))
+                   return true;
+           }
+           else if (isChar && event.shiftKey) {
+               if (runFor(scopeObj[prefix + modifiers$1(name, event, true)]))
+                   return true;
+           }
+       }
+       return fallthrough;
+   }
+
+   const CanHidePrimary$1 = !browser$1.ios; // FIXME test IE
+   const themeSpec$1 = {
+       ".cm-line": {
+           "& ::selection": { backgroundColor: "transparent !important" },
+           "&::selection": { backgroundColor: "transparent !important" }
+       }
+   };
+   if (CanHidePrimary$1)
+       themeSpec$1[".cm-line"].caretColor = "transparent !important";
+
+   const panelConfig$1 = /*@__PURE__*/Facet$1.define({
+       combine(configs) {
+           let topContainer, bottomContainer;
+           for (let c of configs) {
+               topContainer = topContainer || c.topContainer;
+               bottomContainer = bottomContainer || c.bottomContainer;
+           }
+           return { topContainer, bottomContainer };
+       }
+   });
+   /**
+   Get the active panel created by the given constructor, if any.
+   This can be useful when you need access to your panels' DOM
+   structure.
+   */
+   function getPanel(view, panel) {
+       let plugin = view.plugin(panelPlugin$1);
+       let index = plugin ? plugin.specs.indexOf(panel) : -1;
+       return index > -1 ? plugin.panels[index] : null;
+   }
+   const panelPlugin$1 = /*@__PURE__*/ViewPlugin$1.fromClass(class {
+       constructor(view) {
+           this.input = view.state.facet(showPanel$1);
+           this.specs = this.input.filter(s => s);
+           this.panels = this.specs.map(spec => spec(view));
+           let conf = view.state.facet(panelConfig$1);
+           this.top = new PanelGroup$1(view, true, conf.topContainer);
+           this.bottom = new PanelGroup$1(view, false, conf.bottomContainer);
+           this.top.sync(this.panels.filter(p => p.top));
+           this.bottom.sync(this.panels.filter(p => !p.top));
+           for (let p of this.panels) {
+               p.dom.classList.add("cm-panel");
+               if (p.mount)
+                   p.mount();
+           }
+       }
+       update(update) {
+           let conf = update.state.facet(panelConfig$1);
+           if (this.top.container != conf.topContainer) {
+               this.top.sync([]);
+               this.top = new PanelGroup$1(update.view, true, conf.topContainer);
+           }
+           if (this.bottom.container != conf.bottomContainer) {
+               this.bottom.sync([]);
+               this.bottom = new PanelGroup$1(update.view, false, conf.bottomContainer);
+           }
+           this.top.syncClasses();
+           this.bottom.syncClasses();
+           let input = update.state.facet(showPanel$1);
+           if (input != this.input) {
+               let specs = input.filter(x => x);
+               let panels = [], top = [], bottom = [], mount = [];
+               for (let spec of specs) {
+                   let known = this.specs.indexOf(spec), panel;
+                   if (known < 0) {
+                       panel = spec(update.view);
+                       mount.push(panel);
+                   }
+                   else {
+                       panel = this.panels[known];
+                       if (panel.update)
+                           panel.update(update);
+                   }
+                   panels.push(panel);
+                   (panel.top ? top : bottom).push(panel);
+               }
+               this.specs = specs;
+               this.panels = panels;
+               this.top.sync(top);
+               this.bottom.sync(bottom);
+               for (let p of mount) {
+                   p.dom.classList.add("cm-panel");
+                   if (p.mount)
+                       p.mount();
+               }
+           }
+           else {
+               for (let p of this.panels)
+                   if (p.update)
+                       p.update(update);
+           }
+       }
+       destroy() {
+           this.top.sync([]);
+           this.bottom.sync([]);
+       }
+   }, {
+       provide: plugin => EditorView$1.scrollMargins.of(view => {
+           let value = view.plugin(plugin);
+           return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
+       })
+   });
+   let PanelGroup$1 = class PanelGroup {
+       constructor(view, top, container) {
+           this.view = view;
+           this.top = top;
+           this.container = container;
+           this.dom = undefined;
+           this.classes = "";
+           this.panels = [];
+           this.syncClasses();
+       }
+       sync(panels) {
+           for (let p of this.panels)
+               if (p.destroy && panels.indexOf(p) < 0)
+                   p.destroy();
+           this.panels = panels;
+           this.syncDOM();
+       }
+       syncDOM() {
+           if (this.panels.length == 0) {
+               if (this.dom) {
+                   this.dom.remove();
+                   this.dom = undefined;
+               }
+               return;
+           }
+           if (!this.dom) {
+               this.dom = document.createElement("div");
+               this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
+               this.dom.style[this.top ? "top" : "bottom"] = "0";
+               let parent = this.container || this.view.dom;
+               parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
+           }
+           let curDOM = this.dom.firstChild;
+           for (let panel of this.panels) {
+               if (panel.dom.parentNode == this.dom) {
+                   while (curDOM != panel.dom)
+                       curDOM = rm$2(curDOM);
+                   curDOM = curDOM.nextSibling;
+               }
+               else {
+                   this.dom.insertBefore(panel.dom, curDOM);
+               }
+           }
+           while (curDOM)
+               curDOM = rm$2(curDOM);
+       }
+       scrollMargin() {
+           return !this.dom || this.container ? 0
+               : Math.max(0, this.top ?
+                   this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
+                   Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
+       }
+       syncClasses() {
+           if (!this.container || this.classes == this.view.themeClasses)
+               return;
+           for (let cls of this.classes.split(" "))
+               if (cls)
+                   this.container.classList.remove(cls);
+           for (let cls of (this.classes = this.view.themeClasses).split(" "))
+               if (cls)
+                   this.container.classList.add(cls);
+       }
+   };
+   function rm$2(node) {
+       let next = node.nextSibling;
+       node.remove();
+       return next;
+   }
+   /**
+   Opening a panel is done by providing a constructor function for
+   the panel through this facet. (The panel is closed again when its
+   constructor is no longer provided.) Values of `null` are ignored.
+   */
+   const showPanel$1 = /*@__PURE__*/Facet$1.define({
+       enables: panelPlugin$1
+   });
+
+   /**
+   A gutter marker represents a bit of information attached to a line
+   in a specific gutter. Your own custom markers have to extend this
+   class.
+   */
+   let GutterMarker$1 = class GutterMarker extends RangeValue$1 {
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       Compare this marker to another marker of the same type.
+       */
+       eq(other) { return false; }
+       /**
+       Called if the marker has a `toDOM` method and its representation
+       was removed from a gutter.
+       */
+       destroy(dom) { }
+   };
+   GutterMarker$1.prototype.elementClass = "";
+   GutterMarker$1.prototype.toDOM = undefined;
+   GutterMarker$1.prototype.mapMode = MapMode$1.TrackBefore;
+   GutterMarker$1.prototype.startSide = GutterMarker$1.prototype.endSide = -1;
+   GutterMarker$1.prototype.point = true;
+
+   function crelt() {
+     var elt = arguments[0];
+     if (typeof elt == "string") elt = document.createElement(elt);
+     var i = 1, next = arguments[1];
+     if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
+       for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
+         var value = next[name];
+         if (typeof value == "string") elt.setAttribute(name, value);
+         else if (value != null) elt[name] = value;
+       }
+       i++;
+     }
+     for (; i < arguments.length; i++) add(elt, arguments[i]);
+     return elt
+   }
+
+   function add(elt, child) {
+     if (typeof child == "string") {
+       elt.appendChild(document.createTextNode(child));
+     } else if (child == null) ; else if (child.nodeType != null) {
+       elt.appendChild(child);
+     } else if (Array.isArray(child)) {
+       for (var i = 0; i < child.length; i++) add(elt, child[i]);
+     } else {
+       throw new RangeError("Unsupported child node: " + child)
+     }
+   }
+
+   const basicNormalize = typeof String.prototype.normalize == "function"
+       ? x => x.normalize("NFKD") : x => x;
+   /**
+   A search cursor provides an iterator over text matches in a
+   document.
+   */
+   class SearchCursor {
+       /**
+       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(text, query, from = 0, to = text.length, normalize) {
+           /**
+           The current match (only holds a meaningful value after
+           [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
+           `done` is false).
+           */
+           this.value = { from: 0, to: 0 };
+           /**
+           Whether the end of the iterated region has been reached.
+           */
+           this.done = false;
+           this.matches = [];
+           this.buffer = "";
+           this.bufferPos = 0;
+           this.iter = text.iterRange(from, to);
+           this.bufferStart = from;
+           this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;
+           this.query = this.normalize(query);
+       }
+       peek() {
+           if (this.bufferPos == this.buffer.length) {
+               this.bufferStart += this.buffer.length;
+               this.iter.next();
+               if (this.iter.done)
+                   return -1;
+               this.bufferPos = 0;
+               this.buffer = this.iter.value;
+           }
+           return codePointAt$2(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() {
+           while (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 next = this.peek();
+               if (next < 0) {
+                   this.done = true;
+                   return this;
+               }
+               let str = fromCodePoint$1(next), start = this.bufferStart + this.bufferPos;
+               this.bufferPos += codePointSize$2(next);
+               let norm = this.normalize(str);
+               for (let i = 0, pos = start;; i++) {
+                   let code = norm.charCodeAt(i);
+                   let match = this.match(code, pos);
+                   if (match) {
+                       this.value = match;
+                       return this;
+                   }
+                   if (i == norm.length - 1)
+                       break;
+                   if (pos == start && i < str.length && str.charCodeAt(i) == code)
+                       pos++;
+               }
+           }
+       }
+       match(code, pos) {
+           let match = null;
+           for (let i = 0; i < this.matches.length; i += 2) {
+               let index = this.matches[i], keep = false;
+               if (this.query.charCodeAt(index) == code) {
+                   if (index == this.query.length - 1) {
+                       match = { from: this.matches[i + 1], to: pos + 1 };
+                   }
+                   else {
+                       this.matches[i]++;
+                       keep = true;
+                   }
+               }
+               if (!keep) {
+                   this.matches.splice(i, 2);
+                   i -= 2;
+               }
+           }
+           if (this.query.charCodeAt(0) == code) {
+               if (this.query.length == 1)
+                   match = { from: pos, to: pos + 1 };
+               else
+                   this.matches.push(1, pos);
+           }
+           return match;
+       }
+   }
+   if (typeof Symbol != "undefined")
+       SearchCursor.prototype[Symbol.iterator] = function () { return this; };
+
+   const empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec("") };
+   const baseFlags = "gm" + (/x/.unicode == null ? "" : "u");
+   /**
+   This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
+   but searches for a regular expression pattern instead of a plain
+   string.
+   */
+   class RegExpCursor {
+       /**
+       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(text, query, options, from = 0, to = text.length) {
+           this.to = to;
+           this.curLine = "";
+           /**
+           Set to `true` when the cursor has reached the end of the search
+           range.
+           */
+           this.done = false;
+           /**
+           Will contain an object with the extent of the match and the
+           match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
+           sucessfully finds a match.
+           */
+           this.value = empty;
+           if (/\\[sWDnr]|\n|\r|\[\^/.test(query))
+               return new MultilineRegExpCursor(text, query, options, from, to);
+           this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
+           this.iter = text.iter();
+           let startLine = text.lineAt(from);
+           this.curLineStart = startLine.from;
+           this.matchPos = from;
+           this.getLine(this.curLineStart);
+       }
+       getLine(skip) {
+           this.iter.next(skip);
+           if (this.iter.lineBreak) {
+               this.curLine = "";
+           }
+           else {
+               this.curLine = this.iter.value;
+               if (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;
+           if (this.curLineStart > this.to)
+               this.curLine = "";
+           else
+               this.getLine(0);
+       }
+       /**
+       Move to the next match, if there is one.
+       */
+       next() {
+           for (let off = this.matchPos - this.curLineStart;;) {
+               this.re.lastIndex = off;
+               let match = this.matchPos <= this.to && this.re.exec(this.curLine);
+               if (match) {
+                   let from = this.curLineStart + match.index, to = from + match[0].length;
+                   this.matchPos = to + (from == to ? 1 : 0);
+                   if (from == this.curLine.length)
+                       this.nextLine();
+                   if (from < to || from > this.value.to) {
+                       this.value = { from, to, match };
+                       return this;
+                   }
+                   off = this.matchPos - this.curLineStart;
+               }
+               else if (this.curLineStart + this.curLine.length < this.to) {
+                   this.nextLine();
+                   off = 0;
+               }
+               else {
+                   this.done = true;
+                   return this;
+               }
+           }
+       }
+   }
+   const flattened = /*@__PURE__*/new WeakMap();
+   // Reusable (partially) flattened document strings
+   class FlattenedDoc {
+       constructor(from, text) {
+           this.from = from;
+           this.text = text;
+       }
+       get to() { return this.from + this.text.length; }
+       static get(doc, from, to) {
+           let cached = flattened.get(doc);
+           if (!cached || cached.from >= to || cached.to <= from) {
+               let flat = new FlattenedDoc(from, doc.sliceString(from, to));
+               flattened.set(doc, flat);
+               return flat;
+           }
+           if (cached.from == from && cached.to == to)
+               return cached;
+           let { text, from: cachedFrom } = cached;
+           if (cachedFrom > from) {
+               text = doc.sliceString(from, cachedFrom) + text;
+               cachedFrom = from;
+           }
+           if (cached.to < to)
+               text += doc.sliceString(cached.to, to);
+           flattened.set(doc, new FlattenedDoc(cachedFrom, text));
+           return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));
+       }
+   }
+   class MultilineRegExpCursor {
+       constructor(text, query, options, from, to) {
+           this.text = text;
+           this.to = to;
+           this.done = false;
+           this.value = empty;
+           this.matchPos = from;
+           this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
+           this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Base */));
+       }
+       chunkEnd(pos) {
+           return pos >= this.to ? this.to : this.text.lineAt(pos).to;
+       }
+       next() {
+           for (;;) {
+               let off = this.re.lastIndex = this.matchPos - this.flat.from;
+               let match = this.re.exec(this.flat.text);
+               // Skip empty matches directly after the last match
+               if (match && !match[0] && match.index == off) {
+                   this.re.lastIndex = off + 1;
+                   match = this.re.exec(this.flat.text);
+               }
+               // If a match goes almost to the end of a noncomplete chunk, try
+               // again, since it'll likely be able to match more
+               if (match && this.flat.to < this.to && match.index + match[0].length > this.flat.text.length - 10)
+                   match = null;
+               if (match) {
+                   let from = this.flat.from + match.index, to = from + match[0].length;
+                   this.value = { from, to, match };
+                   this.matchPos = to + (from == to ? 1 : 0);
+                   return this;
+               }
+               else {
+                   if (this.flat.to == this.to) {
+                       this.done = true;
+                       return this;
+                   }
+                   // Grow the flattened doc
+                   this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
+               }
+           }
+       }
+   }
+   if (typeof Symbol != "undefined") {
+       RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] =
+           function () { return this; };
+   }
+   function validRegExp(source) {
+       try {
+           new RegExp(source, baseFlags);
+           return true;
+       }
+       catch (_a) {
+           return false;
+       }
+   }
+
+   function createLineDialog(view) {
+       let input = crelt("input", { class: "cm-textfield", name: "line" });
+       let dom = crelt("form", {
+           class: "cm-gotoLine",
+           onkeydown: (event) => {
+               if (event.keyCode == 27) { // Escape
+                   event.preventDefault();
+                   view.dispatch({ effects: dialogEffect.of(false) });
+                   view.focus();
+               }
+               else if (event.keyCode == 13) { // Enter
+                   event.preventDefault();
+                   go();
+               }
+           },
+           onsubmit: (event) => {
+               event.preventDefault();
+               go();
+           }
+       }, crelt("label", view.state.phrase("Go to line"), ": ", input), " ", crelt("button", { class: "cm-button", type: "submit" }, view.state.phrase("go")));
+       function go() {
+           let match = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);
+           if (!match)
+               return;
+           let { state } = view, startLine = state.doc.lineAt(state.selection.main.head);
+           let [, sign, ln, cl, percent] = match;
+           let col = cl ? +cl.slice(1) : 0;
+           let line = ln ? +ln : startLine.number;
+           if (ln && percent) {
+               let pc = line / 100;
+               if (sign)
+                   pc = pc * (sign == "-" ? -1 : 1) + (startLine.number / state.doc.lines);
+               line = Math.round(state.doc.lines * pc);
+           }
+           else if (ln && sign) {
+               line = line * (sign == "-" ? -1 : 1) + startLine.number;
+           }
+           let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));
+           view.dispatch({
+               effects: dialogEffect.of(false),
+               selection: EditorSelection$1.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length))),
+               scrollIntoView: true
+           });
+           view.focus();
+       }
+       return { dom };
+   }
+   const dialogEffect = /*@__PURE__*/StateEffect$1.define();
+   const dialogField = /*@__PURE__*/StateField$1.define({
+       create() { return true; },
+       update(value, tr) {
+           for (let e of tr.effects)
+               if (e.is(dialogEffect))
+                   value = e.value;
+           return value;
+       },
+       provide: f => showPanel$1.from(f, val => val ? createLineDialog : null)
+   });
+   /**
+   Command that shows a dialog asking the user for a line number, and
+   when a valid position is provided, moves the cursor to that line.
+
+   Supports line numbers, relative line offsets prefixed with `+` or
+   `-`, document percentages suffixed with `%`, and an optional
+   column position by adding `:` and a second number after the line
+   number.
+
+   The dialog can be styled with the `panel.gotoLine` theme
+   selector.
+   */
+   const gotoLine = view => {
+       let panel = getPanel(view, createLineDialog);
+       if (!panel) {
+           let effects = [dialogEffect.of(true)];
+           if (view.state.field(dialogField, false) == null)
+               effects.push(StateEffect$1.appendConfig.of([dialogField, baseTheme$1$1]));
+           view.dispatch({ effects });
+           panel = getPanel(view, createLineDialog);
+       }
+       if (panel)
+           panel.dom.querySelector("input").focus();
+       return true;
+   };
+   const baseTheme$1$1 = /*@__PURE__*/EditorView$1.baseTheme({
+       ".cm-panel.cm-gotoLine": {
+           padding: "2px 6px 4px",
+           "& label": { fontSize: "80%" }
+       }
+   });
+
+   const defaultHighlightOptions = {
+       highlightWordAroundCursor: false,
+       minSelectionLength: 1,
+       maxMatches: 100,
+       wholeWords: false
+   };
+   const highlightConfig = /*@__PURE__*/Facet$1.define({
+       combine(options) {
+           return combineConfig$1(options, defaultHighlightOptions, {
+               highlightWordAroundCursor: (a, b) => a || b,
+               minSelectionLength: Math.min,
+               maxMatches: Math.min
+           });
+       }
+   });
+   /**
+   This extension highlights text that matches the selection. It uses
+   the `"cm-selectionMatch"` class for the highlighting. When
+   `highlightWordAroundCursor` is enabled, the word at the cursor
+   itself will be highlighted with `"cm-selectionMatch-main"`.
+   */
+   function highlightSelectionMatches(options) {
+       let ext = [defaultTheme, matchHighlighter];
+       return ext;
+   }
+   const matchDeco = /*@__PURE__*/Decoration$1.mark({ class: "cm-selectionMatch" });
+   const mainMatchDeco = /*@__PURE__*/Decoration$1.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
+   // Whether the characters directly outside the given positions are non-word characters
+   function insideWordBoundaries(check, state, from, to) {
+       return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory$1.Word) &&
+           (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory$1.Word);
+   }
+   // Whether the characters directly at the given positions are word characters
+   function insideWord(check, state, from, to) {
+       return check(state.sliceDoc(from, from + 1)) == CharCategory$1.Word
+           && check(state.sliceDoc(to - 1, to)) == CharCategory$1.Word;
+   }
+   const matchHighlighter = /*@__PURE__*/ViewPlugin$1.fromClass(class {
+       constructor(view) {
+           this.decorations = this.getDeco(view);
+       }
+       update(update) {
+           if (update.selectionSet || update.docChanged || update.viewportChanged)
+               this.decorations = this.getDeco(update.view);
+       }
+       getDeco(view) {
+           let conf = view.state.facet(highlightConfig);
+           let { state } = view, sel = state.selection;
+           if (sel.ranges.length > 1)
+               return Decoration$1.none;
+           let range = sel.main, query, check = null;
+           if (range.empty) {
+               if (!conf.highlightWordAroundCursor)
+                   return Decoration$1.none;
+               let word = state.wordAt(range.head);
+               if (!word)
+                   return Decoration$1.none;
+               check = state.charCategorizer(range.head);
+               query = state.sliceDoc(word.from, word.to);
+           }
+           else {
+               let len = range.to - range.from;
+               if (len < conf.minSelectionLength || len > 200)
+                   return Decoration$1.none;
+               if (conf.wholeWords) {
+                   query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?
+                   check = state.charCategorizer(range.head);
+                   if (!(insideWordBoundaries(check, state, range.from, range.to)
+                       && insideWord(check, state, range.from, range.to)))
+                       return Decoration$1.none;
+               }
+               else {
+                   query = state.sliceDoc(range.from, range.to).trim();
+                   if (!query)
+                       return Decoration$1.none;
+               }
+           }
+           let deco = [];
+           for (let part of view.visibleRanges) {
+               let cursor = new SearchCursor(state.doc, query, part.from, part.to);
+               while (!cursor.next().done) {
+                   let { from, to } = cursor.value;
+                   if (!check || insideWordBoundaries(check, state, from, to)) {
+                       if (range.empty && from <= range.from && to >= range.to)
+                           deco.push(mainMatchDeco.range(from, to));
+                       else if (from >= range.to || to <= range.from)
+                           deco.push(matchDeco.range(from, to));
+                       if (deco.length > conf.maxMatches)
+                           return Decoration$1.none;
+                   }
+               }
+           }
+           return Decoration$1.set(deco);
+       }
+   }, {
+       decorations: v => v.decorations
+   });
+   const defaultTheme = /*@__PURE__*/EditorView$1.baseTheme({
+       ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
+       ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
+   });
+   // Select the words around the cursors.
+   const selectWord = ({ state, dispatch }) => {
+       let { selection } = state;
+       let newSel = EditorSelection$1.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection$1.cursor(range.head)), selection.mainIndex);
+       if (newSel.eq(selection))
+           return false;
+       dispatch(state.update({ selection: newSel }));
+       return true;
+   };
+   // Find next occurrence of query relative to last cursor. Wrap around
+   // the document if there are no more matches.
+   function findNextOccurrence(state, query) {
+       let { main, ranges } = state.selection;
+       let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;
+       for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {
+           cursor.next();
+           if (cursor.done) {
+               if (cycled)
+                   return null;
+               cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
+               cycled = true;
+           }
+           else {
+               if (cycled && ranges.some(r => r.from == cursor.value.from))
+                   continue;
+               if (fullWord) {
+                   let word = state.wordAt(cursor.value.from);
+                   if (!word || word.from != cursor.value.from || word.to != cursor.value.to)
+                       continue;
+               }
+               return cursor.value;
+           }
+       }
+   }
+   /**
+   Select next occurrence of the current selection. Expand selection
+   to the surrounding word when the selection is empty.
+   */
+   const selectNextOccurrence = ({ state, dispatch }) => {
+       let { ranges } = state.selection;
+       if (ranges.some(sel => sel.from === sel.to))
+           return selectWord({ state, dispatch });
+       let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);
+       if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText))
+           return false;
+       let range = findNextOccurrence(state, searchedText);
+       if (!range)
+           return false;
+       dispatch(state.update({
+           selection: state.selection.addRange(EditorSelection$1.range(range.from, range.to), false),
+           effects: EditorView$1.scrollIntoView(range.to)
+       }));
+       return true;
+   };
+
+   const searchConfigFacet = /*@__PURE__*/Facet$1.define({
+       combine(configs) {
+           var _a;
+           return {
+               top: configs.reduce((val, conf) => val !== null && val !== void 0 ? val : conf.top, undefined) || false,
+               caseSensitive: configs.reduce((val, conf) => val !== null && val !== void 0 ? val : conf.caseSensitive, undefined) || false,
+               createPanel: ((_a = configs.find(c => c.createPanel)) === null || _a === void 0 ? void 0 : _a.createPanel) || (view => new SearchPanel(view))
+           };
+       }
+   });
+   /**
+   A search query. Part of the editor's search state.
+   */
+   class SearchQuery {
+       /**
+       Create a query object.
+       */
+       constructor(config) {
+           this.search = config.search;
+           this.caseSensitive = !!config.caseSensitive;
+           this.regexp = !!config.regexp;
+           this.replace = config.replace || "";
+           this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
+           this.unquoted = config.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
+       }
+       /**
+       Compare this query to another query.
+       */
+       eq(other) {
+           return this.search == other.search && this.replace == other.replace &&
+               this.caseSensitive == other.caseSensitive && this.regexp == other.regexp;
+       }
+       /**
+       @internal
+       */
+       create() {
+           return this.regexp ? new RegExpQuery(this) : new StringQuery(this);
+       }
+       /**
+       Get a search cursor for this query, searching through the given
+       range in the given document.
+       */
+       getCursor(doc, from = 0, to = doc.length) {
+           return this.regexp ? regexpCursor(this, doc, from, to) : stringCursor(this, doc, from, to);
+       }
+   }
+   let QueryType$1 = class QueryType {
+       constructor(spec) {
+           this.spec = spec;
+       }
+   };
+   function stringCursor(spec, doc, from, to) {
+       return new SearchCursor(doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase());
+   }
+   class StringQuery extends QueryType$1 {
+       constructor(spec) {
+           super(spec);
+       }
+       nextMatch(doc, curFrom, curTo) {
+           let cursor = stringCursor(this.spec, doc, curTo, doc.length).nextOverlapping();
+           if (cursor.done)
+               cursor = stringCursor(this.spec, doc, 0, curFrom).nextOverlapping();
+           return cursor.done ? null : cursor.value;
+       }
+       // Searching in reverse is, rather than implementing inverted search
+       // cursor, done by scanning chunk after chunk forward.
+       prevMatchInRange(doc, from, to) {
+           for (let pos = to;;) {
+               let start = Math.max(from, pos - 10000 /* ChunkSize */ - this.spec.unquoted.length);
+               let cursor = stringCursor(this.spec, doc, start, pos), range = null;
+               while (!cursor.nextOverlapping().done)
+                   range = cursor.value;
+               if (range)
+                   return range;
+               if (start == from)
+                   return null;
+               pos -= 10000 /* ChunkSize */;
+           }
+       }
+       prevMatch(doc, curFrom, curTo) {
+           return this.prevMatchInRange(doc, 0, curFrom) ||
+               this.prevMatchInRange(doc, curTo, doc.length);
+       }
+       getReplacement(_result) { return this.spec.replace; }
+       matchAll(doc, limit) {
+           let cursor = stringCursor(this.spec, doc, 0, doc.length), ranges = [];
+           while (!cursor.next().done) {
+               if (ranges.length >= limit)
+                   return null;
+               ranges.push(cursor.value);
+           }
+           return ranges;
+       }
+       highlight(doc, from, to, add) {
+           let cursor = stringCursor(this.spec, doc, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, doc.length));
+           while (!cursor.next().done)
+               add(cursor.value.from, cursor.value.to);
+       }
+   }
+   function regexpCursor(spec, doc, from, to) {
+       return new RegExpCursor(doc, spec.search, spec.caseSensitive ? undefined : { ignoreCase: true }, from, to);
+   }
+   class RegExpQuery extends QueryType$1 {
+       nextMatch(doc, curFrom, curTo) {
+           let cursor = regexpCursor(this.spec, doc, curTo, doc.length).next();
+           if (cursor.done)
+               cursor = regexpCursor(this.spec, doc, 0, curFrom).next();
+           return cursor.done ? null : cursor.value;
+       }
+       prevMatchInRange(doc, from, to) {
+           for (let size = 1;; size++) {
+               let start = Math.max(from, to - size * 10000 /* ChunkSize */);
+               let cursor = regexpCursor(this.spec, doc, start, to), range = null;
+               while (!cursor.next().done)
+                   range = cursor.value;
+               if (range && (start == from || range.from > start + 10))
+                   return range;
+               if (start == from)
+                   return null;
+           }
+       }
+       prevMatch(doc, curFrom, curTo) {
+           return this.prevMatchInRange(doc, 0, curFrom) ||
+               this.prevMatchInRange(doc, curTo, doc.length);
+       }
+       getReplacement(result) {
+           return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
+               : i == "&" ? result.match[0]
+                   : i != "0" && +i < result.match.length ? result.match[i]
+                       : m);
+       }
+       matchAll(doc, limit) {
+           let cursor = regexpCursor(this.spec, doc, 0, doc.length), ranges = [];
+           while (!cursor.next().done) {
+               if (ranges.length >= limit)
+                   return null;
+               ranges.push(cursor.value);
+           }
+           return ranges;
+       }
+       highlight(doc, from, to, add) {
+           let cursor = regexpCursor(this.spec, doc, Math.max(0, from - 250 /* HighlightMargin */), Math.min(to + 250 /* HighlightMargin */, doc.length));
+           while (!cursor.next().done)
+               add(cursor.value.from, cursor.value.to);
+       }
+   }
+   /**
+   A state effect that updates the current search query. Note that
+   this only has an effect if the search state has been initialized
+   (by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
+   by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
+   once).
+   */
+   const setSearchQuery = /*@__PURE__*/StateEffect$1.define();
+   const togglePanel$2 = /*@__PURE__*/StateEffect$1.define();
+   const searchState = /*@__PURE__*/StateField$1.define({
+       create(state) {
+           return new SearchState(defaultQuery(state).create(), null);
+       },
+       update(value, tr) {
+           for (let effect of tr.effects) {
+               if (effect.is(setSearchQuery))
+                   value = new SearchState(effect.value.create(), value.panel);
+               else if (effect.is(togglePanel$2))
+                   value = new SearchState(value.query, effect.value ? createSearchPanel : null);
+           }
+           return value;
+       },
+       provide: f => showPanel$1.from(f, val => val.panel)
+   });
+   class SearchState {
+       constructor(query, panel) {
+           this.query = query;
+           this.panel = panel;
+       }
+   }
+   const matchMark = /*@__PURE__*/Decoration$1.mark({ class: "cm-searchMatch" }), selectedMatchMark = /*@__PURE__*/Decoration$1.mark({ class: "cm-searchMatch cm-searchMatch-selected" });
+   const searchHighlighter = /*@__PURE__*/ViewPlugin$1.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.decorations = this.highlight(view.state.field(searchState));
+       }
+       update(update) {
+           let state = update.state.field(searchState);
+           if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged)
+               this.decorations = this.highlight(state);
+       }
+       highlight({ query, panel }) {
+           if (!panel || !query.spec.valid)
+               return Decoration$1.none;
+           let { view } = this;
+           let builder = new RangeSetBuilder$1();
+           for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {
+               let { from, to } = ranges[i];
+               while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* HighlightMargin */)
+                   to = ranges[++i].to;
+               query.highlight(view.state.doc, from, to, (from, to) => {
+                   let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);
+                   builder.add(from, to, selected ? selectedMatchMark : matchMark);
+               });
+           }
+           return builder.finish();
+       }
+   }, {
+       decorations: v => v.decorations
+   });
+   function searchCommand(f) {
+       return view => {
+           let state = view.state.field(searchState, false);
+           return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);
+       };
+   }
+   /**
+   Open the search panel if it isn't already open, and move the
+   selection to the first match after the current main selection.
+   Will wrap around to the start of the document when it reaches the
+   end.
+   */
+   const findNext = /*@__PURE__*/searchCommand((view, { query }) => {
+       let { from, to } = view.state.selection.main;
+       let next = query.nextMatch(view.state.doc, from, to);
+       if (!next || next.from == from && next.to == to)
+           return false;
+       view.dispatch({
+           selection: { anchor: next.from, head: next.to },
+           scrollIntoView: true,
+           effects: announceMatch(view, next),
+           userEvent: "select.search"
+       });
+       return true;
+   });
+   /**
+   Move the selection to the previous instance of the search query,
+   before the current main selection. Will wrap past the start
+   of the document to start searching at the end again.
+   */
+   const findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {
+       let { state } = view, { from, to } = state.selection.main;
+       let range = query.prevMatch(state.doc, from, to);
+       if (!range)
+           return false;
+       view.dispatch({
+           selection: { anchor: range.from, head: range.to },
+           scrollIntoView: true,
+           effects: announceMatch(view, range),
+           userEvent: "select.search"
+       });
+       return true;
+   });
+   /**
+   Select all instances of the search query.
+   */
+   const selectMatches = /*@__PURE__*/searchCommand((view, { query }) => {
+       let ranges = query.matchAll(view.state.doc, 1000);
+       if (!ranges || !ranges.length)
+           return false;
+       view.dispatch({
+           selection: EditorSelection$1.create(ranges.map(r => EditorSelection$1.range(r.from, r.to))),
+           userEvent: "select.search.matches"
+       });
+       return true;
+   });
+   /**
+   Select all instances of the currently selected text.
+   */
+   const selectSelectionMatches = ({ state, dispatch }) => {
+       let sel = state.selection;
+       if (sel.ranges.length > 1 || sel.main.empty)
+           return false;
+       let { from, to } = sel.main;
+       let ranges = [], main = 0;
+       for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {
+           if (ranges.length > 1000)
+               return false;
+           if (cur.value.from == from)
+               main = ranges.length;
+           ranges.push(EditorSelection$1.range(cur.value.from, cur.value.to));
+       }
+       dispatch(state.update({
+           selection: EditorSelection$1.create(ranges, main),
+           userEvent: "select.search.matches"
+       }));
+       return true;
+   };
+   /**
+   Replace the current match of the search query.
+   */
+   const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
+       let { state } = view, { from, to } = state.selection.main;
+       if (state.readOnly)
+           return false;
+       let next = query.nextMatch(state.doc, from, from);
+       if (!next)
+           return false;
+       let changes = [], selection, replacement;
+       if (next.from == from && next.to == to) {
+           replacement = state.toText(query.getReplacement(next));
+           changes.push({ from: next.from, to: next.to, insert: replacement });
+           next = query.nextMatch(state.doc, next.from, next.to);
+       }
+       if (next) {
+           let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;
+           selection = { anchor: next.from - off, head: next.to - off };
+       }
+       view.dispatch({
+           changes, selection,
+           scrollIntoView: !!selection,
+           effects: next ? announceMatch(view, next) : undefined,
+           userEvent: "input.replace"
+       });
+       return true;
+   });
+   /**
+   Replace all instances of the search query with the given
+   replacement.
+   */
+   const replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {
+       if (view.state.readOnly)
+           return false;
+       let changes = query.matchAll(view.state.doc, 1e9).map(match => {
+           let { from, to } = match;
+           return { from, to, insert: query.getReplacement(match) };
+       });
+       if (!changes.length)
+           return false;
+       view.dispatch({
+           changes,
+           userEvent: "input.replace.all"
+       });
+       return true;
+   });
+   function createSearchPanel(view) {
+       return view.state.facet(searchConfigFacet).createPanel(view);
+   }
+   function defaultQuery(state, fallback) {
+       var _a;
+       let sel = state.selection.main;
+       let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to);
+       let caseSensitive = (_a = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _a !== void 0 ? _a : state.facet(searchConfigFacet).caseSensitive;
+       return fallback && !selText ? fallback : new SearchQuery({ search: selText.replace(/\n/g, "\\n"), caseSensitive });
+   }
+   /**
+   Make sure the search panel is open and focused.
+   */
+   const openSearchPanel = view => {
+       let state = view.state.field(searchState, false);
+       if (state && state.panel) {
+           let panel = getPanel(view, createSearchPanel);
+           if (!panel)
+               return false;
+           let searchInput = panel.dom.querySelector("[name=search]");
+           if (searchInput != view.root.activeElement) {
+               let query = defaultQuery(view.state, state.query.spec);
+               if (query.valid)
+                   view.dispatch({ effects: setSearchQuery.of(query) });
+               searchInput.focus();
+               searchInput.select();
+           }
+       }
+       else {
+           view.dispatch({ effects: [
+                   togglePanel$2.of(true),
+                   state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect$1.appendConfig.of(searchExtensions)
+               ] });
+       }
+       return true;
+   };
+   /**
+   Close the search panel.
+   */
+   const closeSearchPanel = view => {
+       let state = view.state.field(searchState, false);
+       if (!state || !state.panel)
+           return false;
+       let panel = getPanel(view, createSearchPanel);
+       if (panel && panel.dom.contains(view.root.activeElement))
+           view.focus();
+       view.dispatch({ effects: togglePanel$2.of(false) });
+       return true;
+   };
+   /**
+   Default search-related key bindings.
+
+    - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
+    - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
+    - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
+    - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
+    - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
+   */
+   const searchKeymap = [
+       { key: "Mod-f", run: openSearchPanel, scope: "editor search-panel" },
+       { key: "F3", run: findNext, shift: findPrevious, scope: "editor search-panel", preventDefault: true },
+       { key: "Mod-g", run: findNext, shift: findPrevious, scope: "editor search-panel", preventDefault: true },
+       { key: "Escape", run: closeSearchPanel, scope: "editor search-panel" },
+       { key: "Mod-Shift-l", run: selectSelectionMatches },
+       { key: "Alt-g", run: gotoLine },
+       { key: "Mod-d", run: selectNextOccurrence, preventDefault: true },
+   ];
+   class SearchPanel {
+       constructor(view) {
+           this.view = view;
+           let query = this.query = view.state.field(searchState).query.spec;
+           this.commit = this.commit.bind(this);
+           this.searchField = crelt("input", {
+               value: query.search,
+               placeholder: phrase(view, "Find"),
+               "aria-label": phrase(view, "Find"),
+               class: "cm-textfield",
+               name: "search",
+               onchange: this.commit,
+               onkeyup: this.commit
+           });
+           this.replaceField = crelt("input", {
+               value: query.replace,
+               placeholder: phrase(view, "Replace"),
+               "aria-label": phrase(view, "Replace"),
+               class: "cm-textfield",
+               name: "replace",
+               onchange: this.commit,
+               onkeyup: this.commit
+           });
+           this.caseField = crelt("input", {
+               type: "checkbox",
+               name: "case",
+               checked: query.caseSensitive,
+               onchange: this.commit
+           });
+           this.reField = crelt("input", {
+               type: "checkbox",
+               name: "re",
+               checked: query.regexp,
+               onchange: this.commit
+           });
+           function button(name, onclick, content) {
+               return crelt("button", { class: "cm-button", name, onclick, type: "button" }, content);
+           }
+           this.dom = crelt("div", { onkeydown: (e) => this.keydown(e), class: "cm-search" }, [
+               this.searchField,
+               button("next", () => findNext(view), [phrase(view, "next")]),
+               button("prev", () => findPrevious(view), [phrase(view, "previous")]),
+               button("select", () => selectMatches(view), [phrase(view, "all")]),
+               crelt("label", null, [this.caseField, phrase(view, "match case")]),
+               crelt("label", null, [this.reField, phrase(view, "regexp")]),
+               ...view.state.readOnly ? [] : [
+                   crelt("br"),
+                   this.replaceField,
+                   button("replace", () => replaceNext(view), [phrase(view, "replace")]),
+                   button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")]),
+                   crelt("button", {
+                       name: "close",
+                       onclick: () => closeSearchPanel(view),
+                       "aria-label": phrase(view, "close"),
+                       type: "button"
+                   }, ["×"])
+               ]
+           ]);
+       }
+       commit() {
+           let query = new SearchQuery({
+               search: this.searchField.value,
+               caseSensitive: this.caseField.checked,
+               regexp: this.reField.checked,
+               replace: this.replaceField.value
+           });
+           if (!query.eq(this.query)) {
+               this.query = query;
+               this.view.dispatch({ effects: setSearchQuery.of(query) });
+           }
+       }
+       keydown(e) {
+           if (runScopeHandlers(this.view, e, "search-panel")) {
+               e.preventDefault();
+           }
+           else if (e.keyCode == 13 && e.target == this.searchField) {
+               e.preventDefault();
+               (e.shiftKey ? findPrevious : findNext)(this.view);
+           }
+           else if (e.keyCode == 13 && e.target == this.replaceField) {
+               e.preventDefault();
+               replaceNext(this.view);
+           }
+       }
+       update(update) {
+           for (let tr of update.transactions)
+               for (let effect of tr.effects) {
+                   if (effect.is(setSearchQuery) && !effect.value.eq(this.query))
+                       this.setQuery(effect.value);
+               }
+       }
+       setQuery(query) {
+           this.query = query;
+           this.searchField.value = query.search;
+           this.replaceField.value = query.replace;
+           this.caseField.checked = query.caseSensitive;
+           this.reField.checked = query.regexp;
+       }
+       mount() {
+           this.searchField.select();
+       }
+       get pos() { return 80; }
+       get top() { return this.view.state.facet(searchConfigFacet).top; }
+   }
+   function phrase(view, phrase) { return view.state.phrase(phrase); }
+   const AnnounceMargin = 30;
+   const Break = /[\s\.,:;?!]/;
+   function announceMatch(view, { from, to }) {
+       let lineStart = view.state.doc.lineAt(from).from, lineEnd = view.state.doc.lineAt(to).to;
+       let start = Math.max(lineStart, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);
+       let text = view.state.sliceDoc(start, end);
+       if (start != lineStart) {
+           for (let i = 0; i < AnnounceMargin; i++)
+               if (!Break.test(text[i + 1]) && Break.test(text[i])) {
+                   text = text.slice(i);
+                   break;
+               }
+       }
+       if (end != lineEnd) {
+           for (let i = text.length - 1; i > text.length - AnnounceMargin; i--)
+               if (!Break.test(text[i - 1]) && Break.test(text[i])) {
+                   text = text.slice(0, i);
+                   break;
+               }
+       }
+       return EditorView$1.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${view.state.doc.lineAt(from).number}`);
+   }
+   const baseTheme$5 = /*@__PURE__*/EditorView$1.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" }
+   });
+   const searchExtensions = [
+       searchState,
+       /*@__PURE__*/Prec$1.lowest(searchHighlighter),
+       baseTheme$5
+   ];
+
+   /**
+   An instance of this is passed to completion source functions.
+   */
+   let CompletionContext$1 = class CompletionContext {
+       /**
+       Create a new completion context. (Mostly useful for testing
+       completion sources—in the editor, the extension will create
+       these for you.)
+       */
+       constructor(
+       /**
+       The editor state that the completion happens in.
+       */
+       state, 
+       /**
+       The position at which the completion is happening.
+       */
+       pos, 
+       /**
+       Indicates whether completion was activated explicitly, or
+       implicitly by typing. The usual way to respond to this is to
+       only return completions when either there is part of a
+       completable entity before the cursor, or `explicit` is true.
+       */
+       explicit) {
+           this.state = state;
+           this.pos = pos;
+           this.explicit = explicit;
+           /**
+           @internal
+           */
+           this.abortListeners = [];
+       }
+       /**
+       Get the extent, content, and (if there is a token) type of the
+       token before `this.pos`.
+       */
+       tokenBefore(types) {
+           let token = syntaxTree$2(this.state).resolveInner(this.pos, -1);
+           while (token && types.indexOf(token.name) < 0)
+               token = token.parent;
+           return token ? { from: token.from, to: this.pos,
+               text: this.state.sliceDoc(token.from, this.pos),
+               type: token.type } : null;
+       }
+       /**
+       Get the match of the given expression directly before the
+       cursor.
+       */
+       matchBefore(expr) {
+           let line = this.state.doc.lineAt(this.pos);
+           let start = Math.max(line.from, this.pos - 250);
+           let str = line.text.slice(start - line.from, this.pos - line.from);
+           let found = str.search(ensureAnchor$1(expr, false));
+           return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) };
+       }
+       /**
+       Yields true when the query has been aborted. Can be useful in
+       asynchronous queries to avoid doing work that will be ignored.
+       */
+       get aborted() { return this.abortListeners == null; }
+       /**
+       Allows you to register abort handlers, which will be called when
+       the query is
+       [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
+       */
+       addEventListener(type, listener) {
+           if (type == "abort" && this.abortListeners)
+               this.abortListeners.push(listener);
+       }
+   };
+   function toSet$1(chars) {
+       let flat = Object.keys(chars).join("");
+       let words = /\w/.test(flat);
+       if (words)
+           flat = flat.replace(/\w/g, "");
+       return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
+   }
+   function prefixMatch$1(options) {
+       let first = Object.create(null), rest = Object.create(null);
+       for (let { label } of options) {
+           first[label[0]] = true;
+           for (let i = 1; i < label.length; i++)
+               rest[label[i]] = true;
+       }
+       let source = toSet$1(first) + toSet$1(rest) + "*$";
+       return [new RegExp("^" + source), new RegExp(source)];
+   }
+   /**
+   Given a a fixed array of options, return an autocompleter that
+   completes them.
+   */
+   function completeFromList$1(list) {
+       let options = list.map(o => typeof o == "string" ? { label: o } : o);
+       let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch$1(options);
+       return (context) => {
+           let token = context.matchBefore(match);
+           return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null;
+       };
+   }
+   let Option$1 = class Option {
+       constructor(completion, source, match) {
+           this.completion = completion;
+           this.source = source;
+           this.match = match;
+       }
+   };
+   function cur$1(state) { return state.selection.main.head; }
+   // Make sure the given regexp has a $ at its end and, if `start` is
+   // true, a ^ at its start.
+   function ensureAnchor$1(expr, start) {
+       var _a;
+       let { source } = expr;
+       let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$";
+       if (!addStart && !addEnd)
+           return expr;
+       return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : ""));
+   }
+   /**
+   Helper function that returns a transaction spec which inserts a
+   completion's text in the main selection range, and any other
+   selection range that has the same text in front of it.
+   */
+   function insertCompletionText$1(state, text, from, to) {
+       return Object.assign(Object.assign({}, state.changeByRange(range => {
+           if (range == state.selection.main)
+               return {
+                   changes: { from: from, to: to, insert: text },
+                   range: EditorSelection$3.cursor(from + text.length)
+               };
+           let len = to - from;
+           if (!range.empty ||
+               len && state.sliceDoc(range.from - len, range.from) != state.sliceDoc(from, to))
+               return { range };
+           return {
+               changes: { from: range.from - len, to: range.from, insert: text },
+               range: EditorSelection$3.cursor(range.from - len + text.length)
+           };
+       })), { userEvent: "input.complete" });
+   }
+   function applyCompletion$1(view, option) {
+       const apply = option.completion.apply || option.completion.label;
+       let result = option.source;
+       if (typeof apply == "string")
+           view.dispatch(insertCompletionText$1(view.state, apply, result.from, result.to));
+       else
+           apply(view, option.completion, result.from, result.to);
+   }
+   const SourceCache$1 = /*@__PURE__*/new WeakMap();
+   function asSource$1(source) {
+       if (!Array.isArray(source))
+           return source;
+       let known = SourceCache$1.get(source);
+       if (!known)
+           SourceCache$1.set(source, known = completeFromList$1(source));
+       return known;
+   }
+
+   // A pattern matcher for fuzzy completion matching. Create an instance
+   // once for a pattern, and then use that to match any number of
+   // completions.
+   let FuzzyMatcher$1 = class FuzzyMatcher {
+       constructor(pattern) {
+           this.pattern = pattern;
+           this.chars = [];
+           this.folded = [];
+           // Buffers reused by calls to `match` to track matched character
+           // positions.
+           this.any = [];
+           this.precise = [];
+           this.byWord = [];
+           for (let p = 0; p < pattern.length;) {
+               let char = codePointAt$4(pattern, p), size = codePointSize$4(char);
+               this.chars.push(char);
+               let part = pattern.slice(p, p + size), upper = part.toUpperCase();
+               this.folded.push(codePointAt$4(upper == part ? part.toLowerCase() : upper, 0));
+               p += size;
+           }
+           this.astral = pattern.length != this.chars.length;
+       }
+       // Matches a given word (completion) against the pattern (input).
+       // Will return null for no match, and otherwise an array that starts
+       // with the match score, followed by any number of `from, to` pairs
+       // indicating the matched parts of `word`.
+       //
+       // The score is a number that is more negative the worse the match
+       // is. See `Penalty` above.
+       match(word) {
+           if (this.pattern.length == 0)
+               return [0];
+           if (word.length < this.pattern.length)
+               return null;
+           let { chars, folded, any, precise, byWord } = this;
+           // For single-character queries, only match when they occur right
+           // at the start
+           if (chars.length == 1) {
+               let first = codePointAt$4(word, 0);
+               return first == chars[0] ? [0, 0, codePointSize$4(first)]
+                   : first == folded[0] ? [-200 /* CaseFold */, 0, codePointSize$4(first)] : null;
+           }
+           let direct = word.indexOf(this.pattern);
+           if (direct == 0)
+               return [0, 0, this.pattern.length];
+           let len = chars.length, anyTo = 0;
+           if (direct < 0) {
+               for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) {
+                   let next = codePointAt$4(word, i);
+                   if (next == chars[anyTo] || next == folded[anyTo])
+                       any[anyTo++] = i;
+                   i += codePointSize$4(next);
+               }
+               // No match, exit immediately
+               if (anyTo < len)
+                   return null;
+           }
+           // This tracks the extent of the precise (non-folded, not
+           // necessarily adjacent) match
+           let preciseTo = 0;
+           // Tracks whether there is a match that hits only characters that
+           // appear to be starting words. `byWordFolded` is set to true when
+           // a case folded character is encountered in such a match
+           let byWordTo = 0, byWordFolded = false;
+           // If we've found a partial adjacent match, these track its state
+           let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
+           let hasLower = /[a-z]/.test(word), wordAdjacent = true;
+           // Go over the option's text, scanning for the various kinds of matches
+           for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* NonWord */; i < e && byWordTo < len;) {
+               let next = codePointAt$4(word, i);
+               if (direct < 0) {
+                   if (preciseTo < len && next == chars[preciseTo])
+                       precise[preciseTo++] = i;
+                   if (adjacentTo < len) {
+                       if (next == chars[adjacentTo] || next == folded[adjacentTo]) {
+                           if (adjacentTo == 0)
+                               adjacentStart = i;
+                           adjacentEnd = i + 1;
+                           adjacentTo++;
+                       }
+                       else {
+                           adjacentTo = 0;
+                       }
+                   }
+               }
+               let ch, type = next < 0xff
+                   ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Lower */ : next >= 65 && next <= 90 ? 1 /* Upper */ : 0 /* NonWord */)
+                   : ((ch = fromCodePoint$2(next)) != ch.toLowerCase() ? 1 /* Upper */ : ch != ch.toUpperCase() ? 2 /* Lower */ : 0 /* NonWord */);
+               if (!i || type == 1 /* Upper */ && hasLower || prevType == 0 /* NonWord */ && type != 0 /* NonWord */) {
+                   if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
+                       byWord[byWordTo++] = i;
+                   else if (byWord.length)
+                       wordAdjacent = false;
+               }
+               prevType = type;
+               i += codePointSize$4(next);
+           }
+           if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
+               return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0), byWord, word);
+           if (adjacentTo == len && adjacentStart == 0)
+               return [-200 /* CaseFold */ - word.length, 0, adjacentEnd];
+           if (direct > -1)
+               return [-700 /* NotStart */ - word.length, direct, direct + this.pattern.length];
+           if (adjacentTo == len)
+               return [-200 /* CaseFold */ + -700 /* NotStart */ - word.length, adjacentStart, adjacentEnd];
+           if (byWordTo == len)
+               return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0) + -700 /* NotStart */ +
+                   (wordAdjacent ? 0 : -1100 /* Gap */), byWord, word);
+           return chars.length == 2 ? null : this.result((any[0] ? -700 /* NotStart */ : 0) + -200 /* CaseFold */ + -1100 /* Gap */, any, word);
+       }
+       result(score, positions, word) {
+           let result = [score - word.length], i = 1;
+           for (let pos of positions) {
+               let to = pos + (this.astral ? codePointSize$4(codePointAt$4(word, pos)) : 1);
+               if (i > 1 && result[i - 1] == pos)
+                   result[i - 1] = to;
+               else {
+                   result[i++] = pos;
+                   result[i++] = to;
+               }
+           }
+           return result;
+       }
+   };
+
+   const completionConfig$1 = /*@__PURE__*/Facet$3.define({
+       combine(configs) {
+           return combineConfig$3(configs, {
+               activateOnTyping: true,
+               override: null,
+               closeOnBlur: true,
+               maxRenderedOptions: 100,
+               defaultKeymap: true,
+               optionClass: () => "",
+               aboveCursor: false,
+               icons: true,
+               addToOptions: []
+           }, {
+               defaultKeymap: (a, b) => a && b,
+               closeOnBlur: (a, b) => a && b,
+               icons: (a, b) => a && b,
+               optionClass: (a, b) => c => joinClass$1(a(c), b(c)),
+               addToOptions: (a, b) => a.concat(b)
+           });
+       }
+   });
+   function joinClass$1(a, b) {
+       return a ? b ? a + " " + b : a : b;
+   }
+
+   function optionContent$1(config) {
+       let content = config.addToOptions.slice();
+       if (config.icons)
+           content.push({
+               render(completion) {
+                   let icon = document.createElement("div");
+                   icon.classList.add("cm-completionIcon");
+                   if (completion.type)
+                       icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls));
+                   icon.setAttribute("aria-hidden", "true");
+                   return icon;
+               },
+               position: 20
+           });
+       content.push({
+           render(completion, _s, match) {
+               let labelElt = document.createElement("span");
+               labelElt.className = "cm-completionLabel";
+               let { label } = completion, off = 0;
+               for (let j = 1; j < match.length;) {
+                   let from = match[j++], to = match[j++];
+                   if (from > off)
+                       labelElt.appendChild(document.createTextNode(label.slice(off, from)));
+                   let span = labelElt.appendChild(document.createElement("span"));
+                   span.appendChild(document.createTextNode(label.slice(from, to)));
+                   span.className = "cm-completionMatchedText";
+                   off = to;
+               }
+               if (off < label.length)
+                   labelElt.appendChild(document.createTextNode(label.slice(off)));
+               return labelElt;
+           },
+           position: 50
+       }, {
+           render(completion) {
+               if (!completion.detail)
+                   return null;
+               let detailElt = document.createElement("span");
+               detailElt.className = "cm-completionDetail";
+               detailElt.textContent = completion.detail;
+               return detailElt;
+           },
+           position: 80
+       });
+       return content.sort((a, b) => a.position - b.position).map(a => a.render);
+   }
+   function rangeAroundSelected$1(total, selected, max) {
+       if (total <= max)
+           return { from: 0, to: total };
+       if (selected <= (total >> 1)) {
+           let off = Math.floor(selected / max);
+           return { from: off * max, to: (off + 1) * max };
+       }
+       let off = Math.floor((total - selected) / max);
+       return { from: total - (off + 1) * max, to: total - off * max };
+   }
+   let CompletionTooltip$1 = class CompletionTooltip {
+       constructor(view, stateField) {
+           this.view = view;
+           this.stateField = stateField;
+           this.info = null;
+           this.placeInfo = {
+               read: () => this.measureInfo(),
+               write: (pos) => this.positionInfo(pos),
+               key: this
+           };
+           let cState = view.state.field(stateField);
+           let { options, selected } = cState.open;
+           let config = view.state.facet(completionConfig$1);
+           this.optionContent = optionContent$1(config);
+           this.optionClass = config.optionClass;
+           this.range = rangeAroundSelected$1(options.length, selected, config.maxRenderedOptions);
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-tooltip-autocomplete";
+           this.dom.addEventListener("mousedown", (e) => {
+               for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) {
+                   if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) {
+                       applyCompletion$1(view, options[+match[1]]);
+                       e.preventDefault();
+                       return;
+                   }
+               }
+           });
+           this.list = this.dom.appendChild(this.createListBox(options, cState.id, this.range));
+           this.list.addEventListener("scroll", () => {
+               if (this.info)
+                   this.view.requestMeasure(this.placeInfo);
+           });
+       }
+       mount() { this.updateSel(); }
+       update(update) {
+           if (update.state.field(this.stateField) != update.startState.field(this.stateField))
+               this.updateSel();
+       }
+       positioned() {
+           if (this.info)
+               this.view.requestMeasure(this.placeInfo);
+       }
+       updateSel() {
+           let cState = this.view.state.field(this.stateField), open = cState.open;
+           if (open.selected < this.range.from || open.selected >= this.range.to) {
+               this.range = rangeAroundSelected$1(open.options.length, open.selected, this.view.state.facet(completionConfig$1).maxRenderedOptions);
+               this.list.remove();
+               this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
+               this.list.addEventListener("scroll", () => {
+                   if (this.info)
+                       this.view.requestMeasure(this.placeInfo);
+               });
+           }
+           if (this.updateSelectedOption(open.selected)) {
+               if (this.info) {
+                   this.info.remove();
+                   this.info = null;
+               }
+               let { completion } = open.options[open.selected];
+               let { info } = completion;
+               if (!info)
+                   return;
+               let infoResult = typeof info === 'string' ? document.createTextNode(info) : info(completion);
+               if (!infoResult)
+                   return;
+               if ('then' in infoResult) {
+                   infoResult.then(node => {
+                       if (node && this.view.state.field(this.stateField, false) == cState)
+                           this.addInfoPane(node);
+                   }).catch(e => logException$3(this.view.state, e, "completion info"));
+               }
+               else {
+                   this.addInfoPane(infoResult);
+               }
+           }
+       }
+       addInfoPane(content) {
+           let dom = this.info = document.createElement("div");
+           dom.className = "cm-tooltip cm-completionInfo";
+           dom.appendChild(content);
+           this.dom.appendChild(dom);
+           this.view.requestMeasure(this.placeInfo);
+       }
+       updateSelectedOption(selected) {
+           let set = null;
+           for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) {
+               if (i == selected) {
+                   if (!opt.hasAttribute("aria-selected")) {
+                       opt.setAttribute("aria-selected", "true");
+                       set = opt;
+                   }
+               }
+               else {
+                   if (opt.hasAttribute("aria-selected"))
+                       opt.removeAttribute("aria-selected");
+               }
+           }
+           if (set)
+               scrollIntoView$2(this.list, set);
+           return set;
+       }
+       measureInfo() {
+           let sel = this.dom.querySelector("[aria-selected]");
+           if (!sel || !this.info)
+               return null;
+           let listRect = this.dom.getBoundingClientRect();
+           let infoRect = this.info.getBoundingClientRect();
+           let selRect = sel.getBoundingClientRect();
+           if (selRect.top > Math.min(innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
+               return null;
+           let top = Math.max(0, Math.min(selRect.top, innerHeight - infoRect.height)) - listRect.top;
+           let left = this.view.textDirection == Direction$3.RTL;
+           let spaceLeft = listRect.left, spaceRight = innerWidth - listRect.right;
+           if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
+               left = false;
+           else if (!left && spaceRight < Math.min(infoRect.width, spaceLeft))
+               left = true;
+           return { top, left };
+       }
+       positionInfo(pos) {
+           if (this.info) {
+               this.info.style.top = (pos ? pos.top : -1e6) + "px";
+               if (pos) {
+                   this.info.classList.toggle("cm-completionInfo-left", pos.left);
+                   this.info.classList.toggle("cm-completionInfo-right", !pos.left);
+               }
+           }
+       }
+       createListBox(options, id, range) {
+           const ul = document.createElement("ul");
+           ul.id = id;
+           ul.setAttribute("role", "listbox");
+           ul.setAttribute("aria-expanded", "true");
+           ul.setAttribute("aria-label", this.view.state.phrase("Completions"));
+           for (let i = range.from; i < range.to; i++) {
+               let { completion, match } = options[i];
+               const li = ul.appendChild(document.createElement("li"));
+               li.id = id + "-" + i;
+               li.setAttribute("role", "option");
+               let cls = this.optionClass(completion);
+               if (cls)
+                   li.className = cls;
+               for (let source of this.optionContent) {
+                   let node = source(completion, this.view.state, match);
+                   if (node)
+                       li.appendChild(node);
+               }
+           }
+           if (range.from)
+               ul.classList.add("cm-completionListIncompleteTop");
+           if (range.to < options.length)
+               ul.classList.add("cm-completionListIncompleteBottom");
+           return ul;
+       }
+   };
+   // We allocate a new function instance every time the completion
+   // changes to force redrawing/repositioning of the tooltip
+   function completionTooltip$1(stateField) {
+       return (view) => new CompletionTooltip$1(view, stateField);
+   }
+   function scrollIntoView$2(container, element) {
+       let parent = container.getBoundingClientRect();
+       let self = element.getBoundingClientRect();
+       if (self.top < parent.top)
+           container.scrollTop -= parent.top - self.top;
+       else if (self.bottom > parent.bottom)
+           container.scrollTop += self.bottom - parent.bottom;
+   }
+
+   // Used to pick a preferred option when two options with the same
+   // label occur in the result.
+   function score$1(option) {
+       return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) +
+           (option.type ? 1 : 0);
+   }
+   function sortOptions$1(active, state) {
+       let options = [], i = 0;
+       for (let a of active)
+           if (a.hasResult()) {
+               if (a.result.filter === false) {
+                   let getMatch = a.result.getMatch;
+                   for (let option of a.result.options) {
+                       let match = [1e9 - i++];
+                       if (getMatch)
+                           for (let n of getMatch(option))
+                               match.push(n);
+                       options.push(new Option$1(option, a, match));
+                   }
+               }
+               else {
+                   let matcher = new FuzzyMatcher$1(state.sliceDoc(a.from, a.to)), match;
+                   for (let option of a.result.options)
+                       if (match = matcher.match(option.label)) {
+                           if (option.boost != null)
+                               match[0] += option.boost;
+                           options.push(new Option$1(option, a, match));
+                       }
+               }
+           }
+       let result = [], prev = null;
+       for (let opt of options.sort(cmpOption)) {
+           if (!prev || prev.label != opt.completion.label || prev.detail != opt.completion.detail ||
+               (prev.type != null && opt.completion.type != null && prev.type != opt.completion.type) ||
+               prev.apply != opt.completion.apply)
+               result.push(opt);
+           else if (score$1(opt.completion) > score$1(prev))
+               result[result.length - 1] = opt;
+           prev = opt.completion;
+       }
+       return result;
+   }
+   let CompletionDialog$1 = class CompletionDialog {
+       constructor(options, attrs, tooltip, timestamp, selected) {
+           this.options = options;
+           this.attrs = attrs;
+           this.tooltip = tooltip;
+           this.timestamp = timestamp;
+           this.selected = selected;
+       }
+       setSelected(selected, id) {
+           return selected == this.selected || selected >= this.options.length ? this
+               : new CompletionDialog(this.options, makeAttrs$1(id, selected), this.tooltip, this.timestamp, selected);
+       }
+       static build(active, state, id, prev, conf) {
+           let options = sortOptions$1(active, state);
+           if (!options.length)
+               return null;
+           let selected = 0;
+           if (prev && prev.selected) {
+               let selectedValue = prev.options[prev.selected].completion;
+               for (let i = 0; i < options.length; i++)
+                   if (options[i].completion == selectedValue) {
+                       selected = i;
+                       break;
+                   }
+           }
+           return new CompletionDialog(options, makeAttrs$1(id, selected), {
+               pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
+               create: completionTooltip$1(completionState$1),
+               above: conf.aboveCursor,
+           }, prev ? prev.timestamp : Date.now(), selected);
+       }
+       map(changes) {
+           return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected);
+       }
+   };
+   let CompletionState$1 = class CompletionState {
+       constructor(active, id, open) {
+           this.active = active;
+           this.id = id;
+           this.open = open;
+       }
+       static start() {
+           return new CompletionState(none$2, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
+       }
+       update(tr) {
+           let { state } = tr, conf = state.facet(completionConfig$1);
+           let sources = conf.override ||
+               state.languageDataAt("autocomplete", cur$1(state)).map(asSource$1);
+           let active = sources.map(source => {
+               let value = this.active.find(s => s.source == source) ||
+                   new ActiveSource$1(source, this.active.some(a => a.state != 0 /* Inactive */) ? 1 /* Pending */ : 0 /* Inactive */);
+               return value.update(tr, conf);
+           });
+           if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
+               active = this.active;
+           let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
+               !sameResults$1(active, this.active) ? CompletionDialog$1.build(active, state, this.id, this.open, conf)
+               : this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
+           if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
+               active = active.map(a => a.hasResult() ? new ActiveSource$1(a.source, 0 /* Inactive */) : a);
+           for (let effect of tr.effects)
+               if (effect.is(setSelectedEffect$1))
+                   open = open && open.setSelected(effect.value, this.id);
+           return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
+       }
+       get tooltip() { return this.open ? this.open.tooltip : null; }
+       get attrs() { return this.open ? this.open.attrs : baseAttrs$1; }
+   };
+   function sameResults$1(a, b) {
+       if (a == b)
+           return true;
+       for (let iA = 0, iB = 0;;) {
+           while (iA < a.length && !a[iA].hasResult)
+               iA++;
+           while (iB < b.length && !b[iB].hasResult)
+               iB++;
+           let endA = iA == a.length, endB = iB == b.length;
+           if (endA || endB)
+               return endA == endB;
+           if (a[iA++].result != b[iB++].result)
+               return false;
+       }
+   }
+   const baseAttrs$1 = {
+       "aria-autocomplete": "list"
+   };
+   function makeAttrs$1(id, selected) {
+       return {
+           "aria-autocomplete": "list",
+           "aria-haspopup": "listbox",
+           "aria-activedescendant": id + "-" + selected,
+           "aria-controls": id
+       };
+   }
+   const none$2 = [];
+   function cmpOption(a, b) {
+       let dScore = b.match[0] - a.match[0];
+       if (dScore)
+           return dScore;
+       return a.completion.label.localeCompare(b.completion.label);
+   }
+   function getUserEvent(tr) {
+       return tr.isUserEvent("input.type") ? "input" : tr.isUserEvent("delete.backward") ? "delete" : null;
+   }
+   let ActiveSource$1 = class ActiveSource {
+       constructor(source, state, explicitPos = -1) {
+           this.source = source;
+           this.state = state;
+           this.explicitPos = explicitPos;
+       }
+       hasResult() { return false; }
+       update(tr, conf) {
+           let event = getUserEvent(tr), value = this;
+           if (event)
+               value = value.handleUserEvent(tr, event, conf);
+           else if (tr.docChanged)
+               value = value.handleChange(tr);
+           else if (tr.selection && value.state != 0 /* Inactive */)
+               value = new ActiveSource(value.source, 0 /* Inactive */);
+           for (let effect of tr.effects) {
+               if (effect.is(startCompletionEffect$1))
+                   value = new ActiveSource(value.source, 1 /* Pending */, effect.value ? cur$1(tr.state) : -1);
+               else if (effect.is(closeCompletionEffect$1))
+                   value = new ActiveSource(value.source, 0 /* Inactive */);
+               else if (effect.is(setActiveEffect$1))
+                   for (let active of effect.value)
+                       if (active.source == value.source)
+                           value = active;
+           }
+           return value;
+       }
+       handleUserEvent(tr, type, conf) {
+           return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* Pending */);
+       }
+       handleChange(tr) {
+           return tr.changes.touchesRange(cur$1(tr.startState)) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
+       }
+       map(changes) {
+           return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
+       }
+   };
+   let ActiveResult$1 = class ActiveResult extends ActiveSource$1 {
+       constructor(source, explicitPos, result, from, to) {
+           super(source, 2 /* Result */, explicitPos);
+           this.result = result;
+           this.from = from;
+           this.to = to;
+       }
+       hasResult() { return true; }
+       handleUserEvent(tr, type, conf) {
+           var _a;
+           let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1);
+           let pos = cur$1(tr.state);
+           if ((this.explicitPos < 0 ? pos <= from : pos < this.from) ||
+               pos > to ||
+               type == "delete" && cur$1(tr.startState) == this.from)
+               return new ActiveSource$1(this.source, type == "input" && conf.activateOnTyping ? 1 /* Pending */ : 0 /* Inactive */);
+           let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos), updated;
+           if (checkValid$1(this.result.validFor, tr.state, from, to))
+               return new ActiveResult(this.source, explicitPos, this.result, from, to);
+           if (this.result.update &&
+               (updated = this.result.update(this.result, from, to, new CompletionContext$1(tr.state, pos, explicitPos >= 0))))
+               return new ActiveResult(this.source, explicitPos, updated, updated.from, (_a = updated.to) !== null && _a !== void 0 ? _a : cur$1(tr.state));
+           return new ActiveSource$1(this.source, 1 /* Pending */, explicitPos);
+       }
+       handleChange(tr) {
+           return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource$1(this.source, 0 /* Inactive */) : this.map(tr.changes);
+       }
+       map(mapping) {
+           return mapping.empty ? this :
+               new ActiveResult(this.source, this.explicitPos < 0 ? -1 : mapping.mapPos(this.explicitPos), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
+       }
+   };
+   function checkValid$1(validFor, state, from, to) {
+       if (!validFor)
+           return false;
+       let text = state.sliceDoc(from, to);
+       return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor$1(validFor, true).test(text);
+   }
+   const startCompletionEffect$1 = /*@__PURE__*/StateEffect$3.define();
+   const closeCompletionEffect$1 = /*@__PURE__*/StateEffect$3.define();
+   const setActiveEffect$1 = /*@__PURE__*/StateEffect$3.define({
+       map(sources, mapping) { return sources.map(s => s.map(mapping)); }
+   });
+   const setSelectedEffect$1 = /*@__PURE__*/StateEffect$3.define();
+   const completionState$1 = /*@__PURE__*/StateField$3.define({
+       create() { return CompletionState$1.start(); },
+       update(value, tr) { return value.update(tr); },
+       provide: f => [
+           showTooltip$1.from(f, val => val.tooltip),
+           EditorView$3.contentAttributes.from(f, state => state.attrs)
+       ]
+   });
+
+   const CompletionInteractMargin = 75;
+   /**
+   Returns a command that moves the completion selection forward or
+   backward by the given amount.
+   */
+   function moveCompletionSelection$1(forward, by = "option") {
+       return (view) => {
+           let cState = view.state.field(completionState$1, false);
+           if (!cState || !cState.open || Date.now() - cState.open.timestamp < CompletionInteractMargin)
+               return false;
+           let step = 1, tooltip;
+           if (by == "page" && (tooltip = getTooltip$1(view, cState.open.tooltip)))
+               step = Math.max(2, Math.floor(tooltip.dom.offsetHeight /
+                   tooltip.dom.querySelector("li").offsetHeight) - 1);
+           let selected = cState.open.selected + step * (forward ? 1 : -1), { length } = cState.open.options;
+           if (selected < 0)
+               selected = by == "page" ? 0 : length - 1;
+           else if (selected >= length)
+               selected = by == "page" ? length - 1 : 0;
+           view.dispatch({ effects: setSelectedEffect$1.of(selected) });
+           return true;
+       };
+   }
+   /**
+   Accept the current completion.
+   */
+   const acceptCompletion$1 = (view) => {
+       let cState = view.state.field(completionState$1, false);
+       if (view.state.readOnly || !cState || !cState.open || Date.now() - cState.open.timestamp < CompletionInteractMargin)
+           return false;
+       applyCompletion$1(view, cState.open.options[cState.open.selected]);
+       return true;
+   };
+   /**
+   Explicitly start autocompletion.
+   */
+   const startCompletion$1 = (view) => {
+       let cState = view.state.field(completionState$1, false);
+       if (!cState)
+           return false;
+       view.dispatch({ effects: startCompletionEffect$1.of(true) });
+       return true;
+   };
+   /**
+   Close the currently active completion.
+   */
+   const closeCompletion$1 = (view) => {
+       let cState = view.state.field(completionState$1, false);
+       if (!cState || !cState.active.some(a => a.state != 0 /* Inactive */))
+           return false;
+       view.dispatch({ effects: closeCompletionEffect$1.of(null) });
+       return true;
+   };
+   let RunningQuery$1 = class RunningQuery {
+       constructor(active, context) {
+           this.active = active;
+           this.context = context;
+           this.time = Date.now();
+           this.updates = [];
+           // Note that 'undefined' means 'not done yet', whereas 'null' means
+           // 'query returned null'.
+           this.done = undefined;
+       }
+   };
+   const DebounceTime = 50, MaxUpdateCount$1 = 50, MinAbortTime$1 = 1000;
+   const completionPlugin$1 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.debounceUpdate = -1;
+           this.running = [];
+           this.debounceAccept = -1;
+           this.composing = 0 /* None */;
+           for (let active of view.state.field(completionState$1).active)
+               if (active.state == 1 /* Pending */)
+                   this.startQuery(active);
+       }
+       update(update) {
+           let cState = update.state.field(completionState$1);
+           if (!update.selectionSet && !update.docChanged && update.startState.field(completionState$1) == cState)
+               return;
+           let doesReset = update.transactions.some(tr => {
+               return (tr.selection || tr.docChanged) && !getUserEvent(tr);
+           });
+           for (let i = 0; i < this.running.length; i++) {
+               let query = this.running[i];
+               if (doesReset ||
+                   query.updates.length + update.transactions.length > MaxUpdateCount$1 && Date.now() - query.time > MinAbortTime$1) {
+                   for (let handler of query.context.abortListeners) {
+                       try {
+                           handler();
+                       }
+                       catch (e) {
+                           logException$3(this.view.state, e);
+                       }
+                   }
+                   query.context.abortListeners = null;
+                   this.running.splice(i--, 1);
+               }
+               else {
+                   query.updates.push(...update.transactions);
+               }
+           }
+           if (this.debounceUpdate > -1)
+               clearTimeout(this.debounceUpdate);
+           this.debounceUpdate = cState.active.some(a => a.state == 1 /* Pending */ && !this.running.some(q => q.active.source == a.source))
+               ? setTimeout(() => this.startUpdate(), DebounceTime) : -1;
+           if (this.composing != 0 /* None */)
+               for (let tr of update.transactions) {
+                   if (getUserEvent(tr) == "input")
+                       this.composing = 2 /* Changed */;
+                   else if (this.composing == 2 /* Changed */ && tr.selection)
+                       this.composing = 3 /* ChangedAndMoved */;
+               }
+       }
+       startUpdate() {
+           this.debounceUpdate = -1;
+           let { state } = this.view, cState = state.field(completionState$1);
+           for (let active of cState.active) {
+               if (active.state == 1 /* Pending */ && !this.running.some(r => r.active.source == active.source))
+                   this.startQuery(active);
+           }
+       }
+       startQuery(active) {
+           let { state } = this.view, pos = cur$1(state);
+           let context = new CompletionContext$1(state, pos, active.explicitPos == pos);
+           let pending = new RunningQuery$1(active, context);
+           this.running.push(pending);
+           Promise.resolve(active.source(context)).then(result => {
+               if (!pending.context.aborted) {
+                   pending.done = result || null;
+                   this.scheduleAccept();
+               }
+           }, err => {
+               this.view.dispatch({ effects: closeCompletionEffect$1.of(null) });
+               logException$3(this.view.state, err);
+           });
+       }
+       scheduleAccept() {
+           if (this.running.every(q => q.done !== undefined))
+               this.accept();
+           else if (this.debounceAccept < 0)
+               this.debounceAccept = setTimeout(() => this.accept(), DebounceTime);
+       }
+       // For each finished query in this.running, try to create a result
+       // or, if appropriate, restart the query.
+       accept() {
+           var _a;
+           if (this.debounceAccept > -1)
+               clearTimeout(this.debounceAccept);
+           this.debounceAccept = -1;
+           let updated = [];
+           let conf = this.view.state.facet(completionConfig$1);
+           for (let i = 0; i < this.running.length; i++) {
+               let query = this.running[i];
+               if (query.done === undefined)
+                   continue;
+               this.running.splice(i--, 1);
+               if (query.done) {
+                   let active = new ActiveResult$1(query.active.source, query.active.explicitPos, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : cur$1(query.updates.length ? query.updates[0].startState : this.view.state));
+                   // Replay the transactions that happened since the start of
+                   // the request and see if that preserves the result
+                   for (let tr of query.updates)
+                       active = active.update(tr, conf);
+                   if (active.hasResult()) {
+                       updated.push(active);
+                       continue;
+                   }
+               }
+               let current = this.view.state.field(completionState$1).active.find(a => a.source == query.active.source);
+               if (current && current.state == 1 /* Pending */) {
+                   if (query.done == null) {
+                       // Explicitly failed. Should clear the pending status if it
+                       // hasn't been re-set in the meantime.
+                       let active = new ActiveSource$1(query.active.source, 0 /* Inactive */);
+                       for (let tr of query.updates)
+                           active = active.update(tr, conf);
+                       if (active.state != 1 /* Pending */)
+                           updated.push(active);
+                   }
+                   else {
+                       // Cleared by subsequent transactions. Restart.
+                       this.startQuery(current);
+                   }
+               }
+           }
+           if (updated.length)
+               this.view.dispatch({ effects: setActiveEffect$1.of(updated) });
+       }
+   }, {
+       eventHandlers: {
+           blur() {
+               let state = this.view.state.field(completionState$1, false);
+               if (state && state.tooltip && this.view.state.facet(completionConfig$1).closeOnBlur)
+                   this.view.dispatch({ effects: closeCompletionEffect$1.of(null) });
+           },
+           compositionstart() {
+               this.composing = 1 /* Started */;
+           },
+           compositionend() {
+               if (this.composing == 3 /* ChangedAndMoved */) {
+                   // Safari fires compositionend events synchronously, possibly
+                   // from inside an update, so dispatch asynchronously to avoid reentrancy
+                   setTimeout(() => this.view.dispatch({ effects: startCompletionEffect$1.of(false) }), 20);
+               }
+               this.composing = 0 /* None */;
+           }
+       }
+   });
+
+   const baseTheme$4 = /*@__PURE__*/EditorView$3.baseTheme({
+       ".cm-tooltip.cm-tooltip-autocomplete": {
+           "& > ul": {
+               fontFamily: "monospace",
+               whiteSpace: "nowrap",
+               overflow: "hidden auto",
+               maxWidth_fallback: "700px",
+               maxWidth: "min(700px, 95vw)",
+               minWidth: "250px",
+               maxHeight: "10em",
+               listStyle: "none",
+               margin: 0,
+               padding: 0,
+               "& > li": {
+                   overflowX: "hidden",
+                   textOverflow: "ellipsis",
+                   cursor: "pointer",
+                   padding: "1px 3px",
+                   lineHeight: 1.2
+               },
+           }
+       },
+       "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
+           background: "#17c",
+           color: "white",
+       },
+       "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
+           background: "#347",
+           color: "white",
+       },
+       ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
+           content: '"···"',
+           opacity: 0.5,
+           display: "block",
+           textAlign: "center"
+       },
+       ".cm-tooltip.cm-completionInfo": {
+           position: "absolute",
+           padding: "3px 9px",
+           width: "max-content",
+           maxWidth: "300px",
+       },
+       ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
+       ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
+       "&light .cm-snippetField": { backgroundColor: "#00000022" },
+       "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
+       ".cm-snippetFieldPosition": {
+           verticalAlign: "text-top",
+           width: 0,
+           height: "1.15em",
+           margin: "0 -0.7px -.7em",
+           borderLeft: "1.4px dotted #888"
+       },
+       ".cm-completionMatchedText": {
+           textDecoration: "underline"
+       },
+       ".cm-completionDetail": {
+           marginLeft: "0.5em",
+           fontStyle: "italic"
+       },
+       ".cm-completionIcon": {
+           fontSize: "90%",
+           width: ".8em",
+           display: "inline-block",
+           textAlign: "center",
+           paddingRight: ".6em",
+           opacity: "0.6"
+       },
+       ".cm-completionIcon-function, .cm-completionIcon-method": {
+           "&:after": { content: "'ƒ'" }
+       },
+       ".cm-completionIcon-class": {
+           "&:after": { content: "'○'" }
+       },
+       ".cm-completionIcon-interface": {
+           "&:after": { content: "'◌'" }
+       },
+       ".cm-completionIcon-variable": {
+           "&:after": { content: "'𝑥'" }
+       },
+       ".cm-completionIcon-constant": {
+           "&:after": { content: "'𝐶'" }
+       },
+       ".cm-completionIcon-type": {
+           "&:after": { content: "'𝑡'" }
+       },
+       ".cm-completionIcon-enum": {
+           "&:after": { content: "'∪'" }
+       },
+       ".cm-completionIcon-property": {
+           "&:after": { content: "'□'" }
+       },
+       ".cm-completionIcon-keyword": {
+           "&:after": { content: "'🔑\uFE0E'" } // Disable emoji rendering
+       },
+       ".cm-completionIcon-namespace": {
+           "&:after": { content: "'▢'" }
+       },
+       ".cm-completionIcon-text": {
+           "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
+       }
+   });
+
+   const defaults$1 = {
+       brackets: ["(", "[", "{", "'", '"'],
+       before: ")]}:;>"
+   };
+   const closeBracketEffect = /*@__PURE__*/StateEffect$3.define({
+       map(value, mapping) {
+           let mapped = mapping.mapPos(value, -1, MapMode$3.TrackAfter);
+           return mapped == null ? undefined : mapped;
+       }
+   });
+   const skipBracketEffect = /*@__PURE__*/StateEffect$3.define({
+       map(value, mapping) { return mapping.mapPos(value); }
+   });
+   const closedBracket$1 = /*@__PURE__*/new class extends RangeValue$3 {
+   };
+   closedBracket$1.startSide = 1;
+   closedBracket$1.endSide = -1;
+   const bracketState = /*@__PURE__*/StateField$3.define({
+       create() { return RangeSet$3.empty; },
+       update(value, tr) {
+           if (tr.selection) {
+               let lineStart = tr.state.doc.lineAt(tr.selection.main.head).from;
+               let prevLineStart = tr.startState.doc.lineAt(tr.startState.selection.main.head).from;
+               if (lineStart != tr.changes.mapPos(prevLineStart, -1))
+                   value = RangeSet$3.empty;
+           }
+           value = value.map(tr.changes);
+           for (let effect of tr.effects) {
+               if (effect.is(closeBracketEffect))
+                   value = value.update({ add: [closedBracket$1.range(effect.value, effect.value + 1)] });
+               else if (effect.is(skipBracketEffect))
+                   value = value.update({ filter: from => from != effect.value });
+           }
+           return value;
+       }
+   });
+   /**
+   Extension to enable bracket-closing behavior. When a closeable
+   bracket is typed, its closing bracket is immediately inserted
+   after the cursor. When closing a bracket directly in front of a
+   closing bracket inserted by the extension, the cursor moves over
+   that bracket.
+   */
+   function closeBrackets() {
+       return [inputHandler$1, bracketState];
+   }
+   const definedClosing = "()[]{}<>";
+   function closing(ch) {
+       for (let i = 0; i < definedClosing.length; i += 2)
+           if (definedClosing.charCodeAt(i) == ch)
+               return definedClosing.charAt(i + 1);
+       return fromCodePoint$2(ch < 128 ? ch : ch + 1);
+   }
+   function config(state, pos) {
+       return state.languageDataAt("closeBrackets", pos)[0] || defaults$1;
+   }
+   const android$1 = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
+   const inputHandler$1 = /*@__PURE__*/EditorView$3.inputHandler.of((view, from, to, insert) => {
+       if ((android$1 ? view.composing : view.compositionStarted) || view.state.readOnly)
+           return false;
+       let sel = view.state.selection.main;
+       if (insert.length > 2 || insert.length == 2 && codePointSize$4(codePointAt$4(insert, 0)) == 1 ||
+           from != sel.from || to != sel.to)
+           return false;
+       let tr = insertBracket(view.state, insert);
+       if (!tr)
+           return false;
+       view.dispatch(tr);
+       return true;
+   });
+   /**
+   Command that implements deleting a pair of matching brackets when
+   the cursor is between them.
+   */
+   const deleteBracketPair = ({ state, dispatch }) => {
+       if (state.readOnly)
+           return false;
+       let conf = config(state, state.selection.main.head);
+       let tokens = conf.brackets || defaults$1.brackets;
+       let dont = null, changes = state.changeByRange(range => {
+           if (range.empty) {
+               let before = prevChar(state.doc, range.head);
+               for (let token of tokens) {
+                   if (token == before && nextChar(state.doc, range.head) == closing(codePointAt$4(token, 0)))
+                       return { changes: { from: range.head - token.length, to: range.head + token.length },
+                           range: EditorSelection$3.cursor(range.head - token.length),
+                           userEvent: "delete.backward" };
+               }
+           }
+           return { range: dont = range };
+       });
+       if (!dont)
+           dispatch(state.update(changes, { scrollIntoView: true }));
+       return !dont;
+   };
+   /**
+   Close-brackets related key bindings. Binds Backspace to
+   [`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
+   */
+   const closeBracketsKeymap = [
+       { key: "Backspace", run: deleteBracketPair }
+   ];
+   /**
+   Implements the extension's behavior on text insertion. If the
+   given string counts as a bracket in the language around the
+   selection, and replacing the selection with it requires custom
+   behavior (inserting a closing version or skipping past a
+   previously-closed bracket), this function returns a transaction
+   representing that custom behavior. (You only need this if you want
+   to programmatically insert brackets—the
+   [`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
+   take care of running this for user input.)
+   */
+   function insertBracket(state, bracket) {
+       let conf = config(state, state.selection.main.head);
+       let tokens = conf.brackets || defaults$1.brackets;
+       for (let tok of tokens) {
+           let closed = closing(codePointAt$4(tok, 0));
+           if (bracket == tok)
+               return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1)
+                   : handleOpen(state, tok, closed, conf.before || defaults$1.before);
+           if (bracket == closed && closedBracketAt(state, state.selection.main.from))
+               return handleClose(state, tok, closed);
+       }
+       return null;
+   }
+   function closedBracketAt(state, pos) {
+       let found = false;
+       state.field(bracketState).between(0, state.doc.length, from => {
+           if (from == pos)
+               found = true;
+       });
+       return found;
+   }
+   function nextChar(doc, pos) {
+       let next = doc.sliceString(pos, pos + 2);
+       return next.slice(0, codePointSize$4(codePointAt$4(next, 0)));
+   }
+   function prevChar(doc, pos) {
+       let prev = doc.sliceString(pos - 2, pos);
+       return codePointSize$4(codePointAt$4(prev, 0)) == prev.length ? prev : prev.slice(1);
+   }
+   function handleOpen(state, open, close, closeBefore) {
+       let dont = null, changes = state.changeByRange(range => {
+           if (!range.empty)
+               return { changes: [{ insert: open, from: range.from }, { insert: close, from: range.to }],
+                   effects: closeBracketEffect.of(range.to + open.length),
+                   range: EditorSelection$3.range(range.anchor + open.length, range.head + open.length) };
+           let next = nextChar(state.doc, range.head);
+           if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1)
+               return { changes: { insert: open + close, from: range.head },
+                   effects: closeBracketEffect.of(range.head + open.length),
+                   range: EditorSelection$3.cursor(range.head + open.length) };
+           return { range: dont = range };
+       });
+       return dont ? null : state.update(changes, {
+           scrollIntoView: true,
+           userEvent: "input.type"
+       });
+   }
+   function handleClose(state, _open, close) {
+       let dont = null, moved = state.selection.ranges.map(range => {
+           if (range.empty && nextChar(state.doc, range.head) == close)
+               return EditorSelection$3.cursor(range.head + close.length);
+           return dont = range;
+       });
+       return dont ? null : state.update({
+           selection: EditorSelection$3.create(moved, state.selection.mainIndex),
+           scrollIntoView: true,
+           effects: state.selection.ranges.map(({ from }) => skipBracketEffect.of(from))
+       });
+   }
+   // Handles cases where the open and close token are the same, and
+   // possibly triple quotes (as in `"""abc"""`-style quoting).
+   function handleSame(state, token, allowTriple) {
+       let dont = null, changes = state.changeByRange(range => {
+           if (!range.empty)
+               return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }],
+                   effects: closeBracketEffect.of(range.to + token.length),
+                   range: EditorSelection$3.range(range.anchor + token.length, range.head + token.length) };
+           let pos = range.head, next = nextChar(state.doc, pos);
+           if (next == token) {
+               if (nodeStart(state, pos)) {
+                   return { changes: { insert: token + token, from: pos },
+                       effects: closeBracketEffect.of(pos + token.length),
+                       range: EditorSelection$3.cursor(pos + token.length) };
+               }
+               else if (closedBracketAt(state, pos)) {
+                   let isTriple = allowTriple && state.sliceDoc(pos, pos + token.length * 3) == token + token + token;
+                   return { range: EditorSelection$3.cursor(pos + token.length * (isTriple ? 3 : 1)),
+                       effects: skipBracketEffect.of(pos) };
+               }
+           }
+           else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token &&
+               nodeStart(state, pos - 2 * token.length)) {
+               return { changes: { insert: token + token + token + token, from: pos },
+                   effects: closeBracketEffect.of(pos + token.length),
+                   range: EditorSelection$3.cursor(pos + token.length) };
+           }
+           else if (state.charCategorizer(pos)(next) != CharCategory$3.Word) {
+               let prev = state.sliceDoc(pos - 1, pos);
+               if (prev != token && state.charCategorizer(pos)(prev) != CharCategory$3.Word && !probablyInString(state, pos, token))
+                   return { changes: { insert: token + token, from: pos },
+                       effects: closeBracketEffect.of(pos + token.length),
+                       range: EditorSelection$3.cursor(pos + token.length) };
+           }
+           return { range: dont = range };
+       });
+       return dont ? null : state.update(changes, {
+           scrollIntoView: true,
+           userEvent: "input.type"
+       });
+   }
+   function nodeStart(state, pos) {
+       let tree = syntaxTree$2(state).resolveInner(pos + 1);
+       return tree.parent && tree.from == pos;
+   }
+   function probablyInString(state, pos, quoteToken) {
+       let node = syntaxTree$2(state).resolveInner(pos, -1);
+       for (let i = 0; i < 5; i++) {
+           if (state.sliceDoc(node.from, node.from + quoteToken.length) == quoteToken)
+               return true;
+           let parent = node.to == pos && node.parent;
+           if (!parent)
+               break;
+           node = parent;
+       }
+       return false;
+   }
+
+   /**
+   Returns an extension that enables autocompletion.
+   */
+   function autocompletion$1(config = {}) {
+       return [
+           completionState$1,
+           completionConfig$1.of(config),
+           completionPlugin$1,
+           completionKeymapExt$1,
+           baseTheme$4
+       ];
+   }
+   /**
+   Basic keybindings for autocompletion.
+
+    - Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
+    - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
+    - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
+    - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
+    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
+    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
+    - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
+   */
+   const completionKeymap$1 = [
+       { key: "Ctrl-Space", run: startCompletion$1 },
+       { key: "Escape", run: closeCompletion$1 },
+       { key: "ArrowDown", run: /*@__PURE__*/moveCompletionSelection$1(true) },
+       { key: "ArrowUp", run: /*@__PURE__*/moveCompletionSelection$1(false) },
+       { key: "PageDown", run: /*@__PURE__*/moveCompletionSelection$1(true, "page") },
+       { key: "PageUp", run: /*@__PURE__*/moveCompletionSelection$1(false, "page") },
+       { key: "Enter", run: acceptCompletion$1 }
+   ];
+   const completionKeymapExt$1 = /*@__PURE__*/Prec$3.highest(/*@__PURE__*/keymap$2.computeN([completionConfig$1], state => state.facet(completionConfig$1).defaultKeymap ? [completionKeymap$1] : []));
+
+   let SelectedDiagnostic$1 = class SelectedDiagnostic {
+       constructor(from, to, diagnostic) {
+           this.from = from;
+           this.to = to;
+           this.diagnostic = diagnostic;
+       }
+   };
+   let LintState$1 = class LintState {
+       constructor(diagnostics, panel, selected) {
+           this.diagnostics = diagnostics;
+           this.panel = panel;
+           this.selected = selected;
+       }
+       static init(diagnostics, panel, state) {
+           // Filter the list of diagnostics for which to create markers
+           let markedDiagnostics = diagnostics;
+           let diagnosticFilter = state.facet(lintConfig$1).markerFilter;
+           if (diagnosticFilter)
+               markedDiagnostics = diagnosticFilter(markedDiagnostics);
+           let ranges = Decoration$3.set(markedDiagnostics.map((d) => {
+               // For zero-length ranges or ranges covering only a line break, create a widget
+               return d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from)
+                   ? Decoration$3.widget({
+                       widget: new DiagnosticWidget$1(d),
+                       diagnostic: d
+                   }).range(d.from)
+                   : Decoration$3.mark({
+                       attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
+                       diagnostic: d
+                   }).range(d.from, d.to);
+           }), true);
+           return new LintState(ranges, panel, findDiagnostic$1(ranges));
+       }
+   };
+   function findDiagnostic$1(diagnostics, diagnostic = null, after = 0) {
+       let found = null;
+       diagnostics.between(after, 1e9, (from, to, { spec }) => {
+           if (diagnostic && spec.diagnostic != diagnostic)
+               return;
+           found = new SelectedDiagnostic$1(from, to, spec.diagnostic);
+           return false;
+       });
+       return found;
+   }
+   function hideTooltip$1(tr, tooltip) {
+       return !!(tr.effects.some(e => e.is(setDiagnosticsEffect$1)) || tr.changes.touchesRange(tooltip.pos));
+   }
+   function maybeEnableLint(state, effects) {
+       return state.field(lintState$1, false) ? effects : effects.concat(StateEffect$3.appendConfig.of([
+           lintState$1,
+           EditorView$3.decorations.compute([lintState$1], state => {
+               let { selected, panel } = state.field(lintState$1);
+               return !selected || !panel || selected.from == selected.to ? Decoration$3.none : Decoration$3.set([
+                   activeMark.range(selected.from, selected.to)
+               ]);
+           }),
+           hoverTooltip(lintTooltip, { hideOn: hideTooltip$1 }),
+           baseTheme$3
+       ]));
+   }
+   /**
+   Returns a transaction spec which updates the current set of
+   diagnostics, and enables the lint extension if if wasn't already
+   active.
+   */
+   function setDiagnostics(state, diagnostics) {
+       return {
+           effects: maybeEnableLint(state, [setDiagnosticsEffect$1.of(diagnostics)])
+       };
+   }
+   /**
+   The state effect that updates the set of active diagnostics. Can
+   be useful when writing an extension that needs to track these.
+   */
+   const setDiagnosticsEffect$1 = /*@__PURE__*/StateEffect$3.define();
+   const togglePanel$1 = /*@__PURE__*/StateEffect$3.define();
+   const movePanelSelection$1 = /*@__PURE__*/StateEffect$3.define();
+   const lintState$1 = /*@__PURE__*/StateField$3.define({
+       create() {
+           return new LintState$1(Decoration$3.none, null, null);
+       },
+       update(value, tr) {
+           if (tr.docChanged) {
+               let mapped = value.diagnostics.map(tr.changes), selected = null;
+               if (value.selected) {
+                   let selPos = tr.changes.mapPos(value.selected.from, 1);
+                   selected = findDiagnostic$1(mapped, value.selected.diagnostic, selPos) || findDiagnostic$1(mapped, null, selPos);
+               }
+               value = new LintState$1(mapped, value.panel, selected);
+           }
+           for (let effect of tr.effects) {
+               if (effect.is(setDiagnosticsEffect$1)) {
+                   value = LintState$1.init(effect.value, value.panel, tr.state);
+               }
+               else if (effect.is(togglePanel$1)) {
+                   value = new LintState$1(value.diagnostics, effect.value ? LintPanel$1.open : null, value.selected);
+               }
+               else if (effect.is(movePanelSelection$1)) {
+                   value = new LintState$1(value.diagnostics, value.panel, effect.value);
+               }
+           }
+           return value;
+       },
+       provide: f => [showPanel$2.from(f, val => val.panel),
+           EditorView$3.decorations.from(f, s => s.diagnostics)]
+   });
+   const activeMark = /*@__PURE__*/Decoration$3.mark({ class: "cm-lintRange cm-lintRange-active" });
+   function lintTooltip(view, pos, side) {
+       let { diagnostics } = view.state.field(lintState$1);
+       let found = [], stackStart = 2e8, stackEnd = 0;
+       diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
+           if (pos >= from && pos <= to &&
+               (from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
+               found.push(spec.diagnostic);
+               stackStart = Math.min(from, stackStart);
+               stackEnd = Math.max(to, stackEnd);
+           }
+       });
+       let diagnosticFilter = view.state.facet(lintConfig$1).tooltipFilter;
+       if (diagnosticFilter)
+           found = diagnosticFilter(found);
+       if (!found.length)
+           return null;
+       return {
+           pos: stackStart,
+           end: stackEnd,
+           above: view.state.doc.lineAt(stackStart).to < stackEnd,
+           create() {
+               return { dom: diagnosticsTooltip$1(view, found) };
+           }
+       };
+   }
+   function diagnosticsTooltip$1(view, diagnostics) {
+       return crelt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic$1(view, d, false)));
+   }
+   /**
+   Command to open and focus the lint panel.
+   */
+   const openLintPanel = (view) => {
+       let field = view.state.field(lintState$1, false);
+       if (!field || !field.panel)
+           view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel$1.of(true)]) });
+       let panel = getPanel$1(view, LintPanel$1.open);
+       if (panel)
+           panel.dom.querySelector(".cm-panel-lint ul").focus();
+       return true;
+   };
+   /**
+   Command to close the lint panel, when open.
+   */
+   const closeLintPanel$1 = (view) => {
+       let field = view.state.field(lintState$1, false);
+       if (!field || !field.panel)
+           return false;
+       view.dispatch({ effects: togglePanel$1.of(false) });
+       return true;
+   };
+   /**
+   Move the selection to the next diagnostic.
+   */
+   const nextDiagnostic = (view) => {
+       let field = view.state.field(lintState$1, false);
+       if (!field)
+           return false;
+       let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1);
+       if (!next.value) {
+           next = field.diagnostics.iter(0);
+           if (!next.value || next.from == sel.from && next.to == sel.to)
+               return false;
+       }
+       view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true });
+       return true;
+   };
+   /**
+   A set of default key bindings for the lint functionality.
+
+   - Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
+   - F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
+   */
+   const lintKeymap = [
+       { key: "Mod-Shift-m", run: openLintPanel },
+       { key: "F8", run: nextDiagnostic }
+   ];
+   const lintPlugin = /*@__PURE__*/ViewPlugin$3.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.timeout = -1;
+           this.set = true;
+           let { delay } = view.state.facet(lintConfig$1);
+           this.lintTime = Date.now() + delay;
+           this.run = this.run.bind(this);
+           this.timeout = setTimeout(this.run, delay);
+       }
+       run() {
+           let now = Date.now();
+           if (now < this.lintTime - 10) {
+               setTimeout(this.run, this.lintTime - now);
+           }
+           else {
+               this.set = false;
+               let { state } = this.view, { sources } = state.facet(lintConfig$1);
+               Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
+                   let all = annotations.reduce((a, b) => a.concat(b));
+                   if (this.view.state.doc == state.doc)
+                       this.view.dispatch(setDiagnostics(this.view.state, all));
+               }, error => { logException$3(this.view.state, error); });
+           }
+       }
+       update(update) {
+           let config = update.state.facet(lintConfig$1);
+           if (update.docChanged || config != update.startState.facet(lintConfig$1)) {
+               this.lintTime = Date.now() + config.delay;
+               if (!this.set) {
+                   this.set = true;
+                   this.timeout = setTimeout(this.run, config.delay);
+               }
+           }
+       }
+       force() {
+           if (this.set) {
+               this.lintTime = Date.now();
+               this.run();
+           }
+       }
+       destroy() {
+           clearTimeout(this.timeout);
+       }
+   });
+   const lintConfig$1 = /*@__PURE__*/Facet$3.define({
+       combine(input) {
+           return Object.assign({ sources: input.map(i => i.source) }, combineConfig$3(input.map(i => i.config), {
+               delay: 750,
+               markerFilter: null,
+               tooltipFilter: null
+           }));
+       },
+       enables: lintPlugin
+   });
+   function assignKeys$1(actions) {
+       let assigned = [];
+       if (actions)
+           actions: for (let { name } of actions) {
+               for (let i = 0; i < name.length; i++) {
+                   let ch = name[i];
+                   if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
+                       assigned.push(ch);
+                       continue actions;
+                   }
+               }
+               assigned.push("");
+           }
+       return assigned;
+   }
+   function renderDiagnostic$1(view, diagnostic, inPanel) {
+       var _a;
+       let keys = inPanel ? assignKeys$1(diagnostic.actions) : [];
+       return crelt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, crelt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
+           let click = (e) => {
+               e.preventDefault();
+               let found = findDiagnostic$1(view.state.field(lintState$1).diagnostics, diagnostic);
+               if (found)
+                   action.apply(view, found.from, found.to);
+           };
+           let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
+           let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
+               crelt("u", name.slice(keyIndex, keyIndex + 1)),
+               name.slice(keyIndex + 1)];
+           return crelt("button", {
+               type: "button",
+               class: "cm-diagnosticAction",
+               onclick: click,
+               onmousedown: click,
+               "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
+           }, nameElt);
+       }), diagnostic.source && crelt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
+   }
+   let DiagnosticWidget$1 = class DiagnosticWidget extends WidgetType$3 {
+       constructor(diagnostic) {
+           super();
+           this.diagnostic = diagnostic;
+       }
+       eq(other) { return other.diagnostic == this.diagnostic; }
+       toDOM() {
+           return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
+       }
+   };
+   let PanelItem$1 = class PanelItem {
+       constructor(view, diagnostic) {
+           this.diagnostic = diagnostic;
+           this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
+           this.dom = renderDiagnostic$1(view, diagnostic, true);
+           this.dom.id = this.id;
+           this.dom.setAttribute("role", "option");
+       }
+   };
+   let LintPanel$1 = class LintPanel {
+       constructor(view) {
+           this.view = view;
+           this.items = [];
+           let onkeydown = (event) => {
+               if (event.keyCode == 27) { // Escape
+                   closeLintPanel$1(this.view);
+                   this.view.focus();
+               }
+               else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
+                   this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
+               }
+               else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
+                   this.moveSelection((this.selectedIndex + 1) % this.items.length);
+               }
+               else if (event.keyCode == 36) { // Home
+                   this.moveSelection(0);
+               }
+               else if (event.keyCode == 35) { // End
+                   this.moveSelection(this.items.length - 1);
+               }
+               else if (event.keyCode == 13) { // Enter
+                   this.view.focus();
+               }
+               else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
+                   let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys$1(diagnostic.actions);
+                   for (let i = 0; i < keys.length; i++)
+                       if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
+                           let found = findDiagnostic$1(this.view.state.field(lintState$1).diagnostics, diagnostic);
+                           if (found)
+                               diagnostic.actions[i].apply(view, found.from, found.to);
+                       }
+               }
+               else {
+                   return;
+               }
+               event.preventDefault();
+           };
+           let onclick = (event) => {
+               for (let i = 0; i < this.items.length; i++) {
+                   if (this.items[i].dom.contains(event.target))
+                       this.moveSelection(i);
+               }
+           };
+           this.list = crelt("ul", {
+               tabIndex: 0,
+               role: "listbox",
+               "aria-label": this.view.state.phrase("Diagnostics"),
+               onkeydown,
+               onclick
+           });
+           this.dom = crelt("div", { class: "cm-panel-lint" }, this.list, crelt("button", {
+               type: "button",
+               name: "close",
+               "aria-label": this.view.state.phrase("close"),
+               onclick: () => closeLintPanel$1(this.view)
+           }, "×"));
+           this.update();
+       }
+       get selectedIndex() {
+           let selected = this.view.state.field(lintState$1).selected;
+           if (!selected)
+               return -1;
+           for (let i = 0; i < this.items.length; i++)
+               if (this.items[i].diagnostic == selected.diagnostic)
+                   return i;
+           return -1;
+       }
+       update() {
+           let { diagnostics, selected } = this.view.state.field(lintState$1);
+           let i = 0, needsSync = false, newSelectedItem = null;
+           diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
+               let found = -1, item;
+               for (let j = i; j < this.items.length; j++)
+                   if (this.items[j].diagnostic == spec.diagnostic) {
+                       found = j;
+                       break;
+                   }
+               if (found < 0) {
+                   item = new PanelItem$1(this.view, spec.diagnostic);
+                   this.items.splice(i, 0, item);
+                   needsSync = true;
+               }
+               else {
+                   item = this.items[found];
+                   if (found > i) {
+                       this.items.splice(i, found - i);
+                       needsSync = true;
+                   }
+               }
+               if (selected && item.diagnostic == selected.diagnostic) {
+                   if (!item.dom.hasAttribute("aria-selected")) {
+                       item.dom.setAttribute("aria-selected", "true");
+                       newSelectedItem = item;
+                   }
+               }
+               else if (item.dom.hasAttribute("aria-selected")) {
+                   item.dom.removeAttribute("aria-selected");
+               }
+               i++;
+           });
+           while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
+               needsSync = true;
+               this.items.pop();
+           }
+           if (this.items.length == 0) {
+               this.items.push(new PanelItem$1(this.view, {
+                   from: -1, to: -1,
+                   severity: "info",
+                   message: this.view.state.phrase("No diagnostics")
+               }));
+               needsSync = true;
+           }
+           if (newSelectedItem) {
+               this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
+               this.view.requestMeasure({
+                   key: this,
+                   read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
+                   write: ({ sel, panel }) => {
+                       if (sel.top < panel.top)
+                           this.list.scrollTop -= panel.top - sel.top;
+                       else if (sel.bottom > panel.bottom)
+                           this.list.scrollTop += sel.bottom - panel.bottom;
+                   }
+               });
+           }
+           else if (this.selectedIndex < 0) {
+               this.list.removeAttribute("aria-activedescendant");
+           }
+           if (needsSync)
+               this.sync();
+       }
+       sync() {
+           let domPos = this.list.firstChild;
+           function rm() {
+               let prev = domPos;
+               domPos = prev.nextSibling;
+               prev.remove();
+           }
+           for (let item of this.items) {
+               if (item.dom.parentNode == this.list) {
+                   while (domPos != item.dom)
+                       rm();
+                   domPos = item.dom.nextSibling;
+               }
+               else {
+                   this.list.insertBefore(item.dom, domPos);
+               }
+           }
+           while (domPos)
+               rm();
+       }
+       moveSelection(selectedIndex) {
+           if (this.selectedIndex < 0)
+               return;
+           let field = this.view.state.field(lintState$1);
+           let selection = findDiagnostic$1(field.diagnostics, this.items[selectedIndex].diagnostic);
+           if (!selection)
+               return;
+           this.view.dispatch({
+               selection: { anchor: selection.from, head: selection.to },
+               scrollIntoView: true,
+               effects: movePanelSelection$1.of(selection)
+           });
+       }
+       static open(view) { return new LintPanel(view); }
+   };
+   function svg$1(content, attrs = `viewBox="0 0 40 40"`) {
+       return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
+   }
+   function underline(color) {
+       return svg$1(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
+   }
+   const baseTheme$3 = /*@__PURE__*/EditorView$3.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-diagnosticAction": {
+           font: "inherit",
+           border: "none",
+           padding: "2px 4px",
+           backgroundColor: "#444",
+           color: "white",
+           borderRadius: "3px",
+           marginLeft: "8px"
+       },
+       ".cm-diagnosticSource": {
+           fontSize: "70%",
+           opacity: .7
+       },
+       ".cm-lintRange": {
+           backgroundPosition: "left bottom",
+           backgroundRepeat: "repeat-x",
+           paddingBottom: "0.7px",
+       },
+       ".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") },
+       ".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") },
+       ".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") },
+       ".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-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
+           }
+       }
+   });
+
+   /**
+   This is an extension value that just pulls together a number of
+   extensions that you might want in a basic editor. It is meant as a
+   convenient helper to quickly set up CodeMirror without installing
+   and importing a lot of separate packages.
+
+   Specifically, it includes...
+
+    - [the default command bindings](https://codemirror.net/6/docs/ref/#commands.defaultKeymap)
+    - [line numbers](https://codemirror.net/6/docs/ref/#view.lineNumbers)
+    - [special character highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars)
+    - [the undo history](https://codemirror.net/6/docs/ref/#commands.history)
+    - [a fold gutter](https://codemirror.net/6/docs/ref/#language.foldGutter)
+    - [custom selection drawing](https://codemirror.net/6/docs/ref/#view.drawSelection)
+    - [drop cursor](https://codemirror.net/6/docs/ref/#view.dropCursor)
+    - [multiple selections](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
+    - [reindentation on input](https://codemirror.net/6/docs/ref/#language.indentOnInput)
+    - [the default highlight style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle) (as fallback)
+    - [bracket matching](https://codemirror.net/6/docs/ref/#language.bracketMatching)
+    - [bracket closing](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets)
+    - [autocompletion](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion)
+    - [rectangular selection](https://codemirror.net/6/docs/ref/#view.rectangularSelection) and [crosshair cursor](https://codemirror.net/6/docs/ref/#view.crosshairCursor)
+    - [active line highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLine)
+    - [active line gutter highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLineGutter)
+    - [selection match highlighting](https://codemirror.net/6/docs/ref/#search.highlightSelectionMatches)
+    - [search](https://codemirror.net/6/docs/ref/#search.searchKeymap)
+    - [linting](https://codemirror.net/6/docs/ref/#lint.lintKeymap)
+
+   (You'll probably want to add some language package to your setup
+   too.)
+
+   This package does not allow customization. The idea is that, once
+   you decide you want to configure your editor more precisely, you
+   take this package's source (which is just a bunch of imports and
+   an array literal), copy it into your own code, and adjust it as
+   desired.
+   */
+   const basicSetup = [
+       /*@__PURE__*/lineNumbers$1(),
+       /*@__PURE__*/highlightActiveLineGutter(),
+       /*@__PURE__*/highlightSpecialChars(),
+       /*@__PURE__*/history(),
+       /*@__PURE__*/foldGutter(),
+       /*@__PURE__*/drawSelection(),
+       /*@__PURE__*/dropCursor(),
+       /*@__PURE__*/EditorState$3.allowMultipleSelections.of(true),
+       /*@__PURE__*/indentOnInput(),
+       /*@__PURE__*/syntaxHighlighting$1(defaultHighlightStyle, { fallback: true }),
+       /*@__PURE__*/bracketMatching(),
+       /*@__PURE__*/closeBrackets(),
+       /*@__PURE__*/autocompletion$1(),
+       /*@__PURE__*/rectangularSelection(),
+       /*@__PURE__*/crosshairCursor(),
+       /*@__PURE__*/highlightActiveLine(),
+       /*@__PURE__*/highlightSelectionMatches(),
+       /*@__PURE__*/keymap$2.of([
+           ...closeBracketsKeymap,
+           ...defaultKeymap,
+           ...searchKeymap,
+           ...historyKeymap,
+           ...foldKeymap,
+           ...completionKeymap$1,
+           ...lintKeymap
+       ])
+   ];
+
+   /**
+   The default maximum length of a `TreeBuffer` node.
+   */
+   const DefaultBufferLength = 1024;
+   let nextPropID = 0;
+   let Range$1 = class Range {
+       constructor(from, to) {
+           this.from = from;
+           this.to = to;
+       }
+   };
+   /**
+   Each [node type](#common.NodeType) or [individual tree](#common.Tree)
+   can have metadata associated with it in props. Instances of this
+   class represent prop names.
+   */
+   class NodeProp {
+       /**
+       Create a new node prop type.
+       */
+       constructor(config = {}) {
+           this.id = nextPropID++;
+           this.perNode = !!config.perNode;
+           this.deserialize = config.deserialize || (() => {
+               throw new Error("This node type doesn't define a deserialize function");
+           });
+       }
+       /**
+       This is meant to be used with
+       [`NodeSet.extend`](#common.NodeSet.extend) or
+       [`LRParser.configure`](#lr.ParserConfig.props) to compute
+       prop values for each node type in the set. Takes a [match
+       object](#common.NodeType^match) or function that returns undefined
+       if the node type doesn't get this prop, and the prop's value if
+       it does.
+       */
+       add(match) {
+           if (this.perNode)
+               throw new RangeError("Can't add per-node props to node types");
+           if (typeof match != "function")
+               match = NodeType.match(match);
+           return (type) => {
+               let result = match(type);
+               return result === undefined ? null : [this, result];
+           };
+       }
+   }
+   /**
+   Prop that is used to describe matching delimiters. For opening
+   delimiters, this holds an array of node names (written as a
+   space-separated string when declaring this prop in a grammar)
+   for the node types of closing delimiters that match it.
+   */
+   NodeProp.closedBy = new NodeProp({ deserialize: str => str.split(" ") });
+   /**
+   The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
+   attached to closing delimiters, holding an array of node names
+   of types of matching opening delimiters.
+   */
+   NodeProp.openedBy = new NodeProp({ deserialize: str => str.split(" ") });
+   /**
+   Used to assign node types to groups (for example, all node
+   types that represent an expression could be tagged with an
+   `"Expression"` group).
+   */
+   NodeProp.group = new NodeProp({ deserialize: str => str.split(" ") });
+   /**
+   Attached to nodes to indicate these should be
+   [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
+   in a bidirectional text isolate, so that direction-neutral
+   characters on their sides don't incorrectly get associated with
+   surrounding text. You'll generally want to set this for nodes
+   that contain arbitrary text, like strings and comments, and for
+   nodes that appear _inside_ arbitrary text, like HTML tags. When
+   not given a value, in a grammar declaration, defaults to
+   `"auto"`.
+   */
+   NodeProp.isolate = new NodeProp({ deserialize: value => {
+           if (value && value != "rtl" && value != "ltr" && value != "auto")
+               throw new RangeError("Invalid value for isolate: " + value);
+           return value || "auto";
+       } });
+   /**
+   The hash of the [context](#lr.ContextTracker.constructor)
+   that the node was parsed in, if any. Used to limit reuse of
+   contextual nodes.
+   */
+   NodeProp.contextHash = new NodeProp({ perNode: true });
+   /**
+   The distance beyond the end of the node that the tokenizer
+   looked ahead for any of the tokens inside the node. (The LR
+   parser only stores this when it is larger than 25, for
+   efficiency reasons.)
+   */
+   NodeProp.lookAhead = new NodeProp({ perNode: true });
+   /**
+   This per-node prop is used to replace a given node, or part of a
+   node, with another tree. This is useful to include trees from
+   different languages in mixed-language parsers.
+   */
+   NodeProp.mounted = new NodeProp({ perNode: true });
+   /**
+   A mounted tree, which can be [stored](#common.NodeProp^mounted) on
+   a tree node to indicate that parts of its content are
+   represented by another tree.
+   */
+   class MountedTree {
+       constructor(
+       /**
+       The inner tree.
+       */
+       tree, 
+       /**
+       If this is null, this tree replaces the entire node (it will
+       be included in the regular iteration instead of its host
+       node). If not, only the given ranges are considered to be
+       covered by this tree. This is used for trees that are mixed in
+       a way that isn't strictly hierarchical. Such mounted trees are
+       only entered by [`resolveInner`](#common.Tree.resolveInner)
+       and [`enter`](#common.SyntaxNode.enter).
+       */
+       overlay, 
+       /**
+       The parser used to create this subtree.
+       */
+       parser) {
+           this.tree = tree;
+           this.overlay = overlay;
+           this.parser = parser;
+       }
+       /**
+       @internal
+       */
+       static get(tree) {
+           return tree && tree.props && tree.props[NodeProp.mounted.id];
+       }
+   }
+   const noProps = Object.create(null);
+   /**
+   Each node in a syntax tree has a node type associated with it.
+   */
+   class NodeType {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The name of the node type. Not necessarily unique, but if the
+       grammar was written properly, different node types with the
+       same name within a node set should play the same semantic
+       role.
+       */
+       name, 
+       /**
+       @internal
+       */
+       props, 
+       /**
+       The id of this node in its set. Corresponds to the term ids
+       used in the parser.
+       */
+       id, 
+       /**
+       @internal
+       */
+       flags = 0) {
+           this.name = name;
+           this.props = props;
+           this.id = id;
+           this.flags = flags;
+       }
+       /**
+       Define a node type.
+       */
+       static define(spec) {
+           let props = spec.props && spec.props.length ? Object.create(null) : noProps;
+           let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |
+               (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);
+           let type = new NodeType(spec.name || "", props, spec.id, flags);
+           if (spec.props)
+               for (let src of spec.props) {
+                   if (!Array.isArray(src))
+                       src = src(type);
+                   if (src) {
+                       if (src[0].perNode)
+                           throw new RangeError("Can't store a per-node prop on a node type");
+                       props[src[0].id] = src[1];
+                   }
+               }
+           return type;
+       }
+       /**
+       Retrieves a node prop for this type. Will return `undefined` if
+       the prop isn't present on this node.
+       */
+       prop(prop) { return this.props[prop.id]; }
+       /**
+       True when this is the top node of a grammar.
+       */
+       get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }
+       /**
+       True when this node is produced by a skip rule.
+       */
+       get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }
+       /**
+       Indicates whether this is an error node.
+       */
+       get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }
+       /**
+       When true, this node type doesn't correspond to a user-declared
+       named node, for example because it is used to cache repetition.
+       */
+       get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }
+       /**
+       Returns true when this node's name or one of its
+       [groups](#common.NodeProp^group) matches the given string.
+       */
+       is(name) {
+           if (typeof name == 'string') {
+               if (this.name == name)
+                   return true;
+               let group = this.prop(NodeProp.group);
+               return group ? group.indexOf(name) > -1 : false;
+           }
+           return this.id == name;
+       }
+       /**
+       Create a function from node types to arbitrary values by
+       specifying an object whose property names are node or
+       [group](#common.NodeProp^group) names. Often useful with
+       [`NodeProp.add`](#common.NodeProp.add). You can put multiple
+       names, separated by spaces, in a single property name to map
+       multiple node names to a single value.
+       */
+       static match(map) {
+           let direct = Object.create(null);
+           for (let prop in map)
+               for (let name of prop.split(" "))
+                   direct[name] = map[prop];
+           return (node) => {
+               for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
+                   let found = direct[i < 0 ? node.name : groups[i]];
+                   if (found)
+                       return found;
+               }
+           };
+       }
+   }
+   /**
+   An empty dummy node type to use when no actual type is available.
+   */
+   NodeType.none = new NodeType("", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);
+   /**
+   A node set holds a collection of node types. It is used to
+   compactly represent trees by storing their type ids, rather than a
+   full pointer to the type object, in a numeric array. Each parser
+   [has](#lr.LRParser.nodeSet) a node set, and [tree
+   buffers](#common.TreeBuffer) can only store collections of nodes
+   from the same set. A set can have a maximum of 2**16 (65536) node
+   types in it, so that the ids fit into 16-bit typed array slots.
+   */
+   class NodeSet {
+       /**
+       Create a set with the given types. The `id` property of each
+       type should correspond to its position within the array.
+       */
+       constructor(
+       /**
+       The node types in this set, by id.
+       */
+       types) {
+           this.types = types;
+           for (let i = 0; i < types.length; i++)
+               if (types[i].id != i)
+                   throw new RangeError("Node type ids should correspond to array positions when creating a node set");
+       }
+       /**
+       Create a copy of this set with some node properties added. The
+       arguments to this method can be created with
+       [`NodeProp.add`](#common.NodeProp.add).
+       */
+       extend(...props) {
+           let newTypes = [];
+           for (let type of this.types) {
+               let newProps = null;
+               for (let source of props) {
+                   let add = source(type);
+                   if (add) {
+                       if (!newProps)
+                           newProps = Object.assign({}, type.props);
+                       newProps[add[0].id] = add[1];
+                   }
+               }
+               newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
+           }
+           return new NodeSet(newTypes);
+       }
+   }
+   const CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();
+   /**
+   Options that control iteration. Can be combined with the `|`
+   operator to enable multiple ones.
+   */
+   var IterMode;
+   (function (IterMode) {
+       /**
+       When enabled, iteration will only visit [`Tree`](#common.Tree)
+       objects, not nodes packed into
+       [`TreeBuffer`](#common.TreeBuffer)s.
+       */
+       IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
+       /**
+       Enable this to make iteration include anonymous nodes (such as
+       the nodes that wrap repeated grammar constructs into a balanced
+       tree).
+       */
+       IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
+       /**
+       By default, regular [mounted](#common.NodeProp^mounted) nodes
+       replace their base node in iteration. Enable this to ignore them
+       instead.
+       */
+       IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
+       /**
+       This option only applies in
+       [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
+       library to not enter mounted overlays if one covers the given
+       position.
+       */
+       IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
+   })(IterMode || (IterMode = {}));
+   /**
+   A piece of syntax tree. There are two ways to approach these
+   trees: the way they are actually stored in memory, and the
+   convenient way.
+
+   Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
+   objects. By packing detail information into `TreeBuffer` leaf
+   nodes, the representation is made a lot more memory-efficient.
+
+   However, when you want to actually work with tree nodes, this
+   representation is very awkward, so most client code will want to
+   use the [`TreeCursor`](#common.TreeCursor) or
+   [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
+   a view on some part of this data structure, and can be used to
+   move around to adjacent nodes.
+   */
+   class Tree {
+       /**
+       Construct a new tree. See also [`Tree.build`](#common.Tree^build).
+       */
+       constructor(
+       /**
+       The type of the top node.
+       */
+       type, 
+       /**
+       This node's child nodes.
+       */
+       children, 
+       /**
+       The positions (offsets relative to the start of this tree) of
+       the children.
+       */
+       positions, 
+       /**
+       The total length of this tree
+       */
+       length, 
+       /**
+       Per-node [node props](#common.NodeProp) to associate with this node.
+       */
+       props) {
+           this.type = type;
+           this.children = children;
+           this.positions = positions;
+           this.length = length;
+           /**
+           @internal
+           */
+           this.props = null;
+           if (props && props.length) {
+               this.props = Object.create(null);
+               for (let [prop, value] of props)
+                   this.props[typeof prop == "number" ? prop : prop.id] = value;
+           }
+       }
+       /**
+       @internal
+       */
+       toString() {
+           let mounted = MountedTree.get(this);
+           if (mounted && !mounted.overlay)
+               return mounted.tree.toString();
+           let children = "";
+           for (let ch of this.children) {
+               let str = ch.toString();
+               if (str) {
+                   if (children)
+                       children += ",";
+                   children += str;
+               }
+           }
+           return !this.type.name ? children :
+               (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
+                   (children.length ? "(" + children + ")" : "");
+       }
+       /**
+       Get a [tree cursor](#common.TreeCursor) positioned at the top of
+       the tree. Mode can be used to [control](#common.IterMode) which
+       nodes the cursor visits.
+       */
+       cursor(mode = 0) {
+           return new TreeCursor(this.topNode, mode);
+       }
+       /**
+       Get a [tree cursor](#common.TreeCursor) pointing into this tree
+       at the given position and side (see
+       [`moveTo`](#common.TreeCursor.moveTo).
+       */
+       cursorAt(pos, side = 0, mode = 0) {
+           let scope = CachedNode.get(this) || this.topNode;
+           let cursor = new TreeCursor(scope);
+           cursor.moveTo(pos, side);
+           CachedNode.set(this, cursor._tree);
+           return cursor;
+       }
+       /**
+       Get a [syntax node](#common.SyntaxNode) object for the top of the
+       tree.
+       */
+       get topNode() {
+           return new TreeNode(this, 0, 0, null);
+       }
+       /**
+       Get the [syntax node](#common.SyntaxNode) at the given position.
+       If `side` is -1, this will move into nodes that end at the
+       position. If 1, it'll move into nodes that start at the
+       position. With 0, it'll only enter nodes that cover the position
+       from both sides.
+       
+       Note that this will not enter
+       [overlays](#common.MountedTree.overlay), and you often want
+       [`resolveInner`](#common.Tree.resolveInner) instead.
+       */
+       resolve(pos, side = 0) {
+           let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
+           CachedNode.set(this, node);
+           return node;
+       }
+       /**
+       Like [`resolve`](#common.Tree.resolve), but will enter
+       [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
+       pointing into the innermost overlaid tree at the given position
+       (with parent links going through all parent structure, including
+       the host trees).
+       */
+       resolveInner(pos, side = 0) {
+           let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
+           CachedInnerNode.set(this, node);
+           return node;
+       }
+       /**
+       In some situations, it can be useful to iterate through all
+       nodes around a position, including those in overlays that don't
+       directly cover the position. This method gives you an iterator
+       that will produce all nodes, from small to big, around the given
+       position.
+       */
+       resolveStack(pos, side = 0) {
+           return stackIterator(this, pos, side);
+       }
+       /**
+       Iterate over the tree and its children, calling `enter` for any
+       node that touches the `from`/`to` region (if given) before
+       running over such a node's children, and `leave` (if given) when
+       leaving the node. When `enter` returns `false`, that node will
+       not have its children iterated over (or `leave` called).
+       */
+       iterate(spec) {
+           let { enter, leave, from = 0, to = this.length } = spec;
+           let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
+           for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {
+               let entered = false;
+               if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
+                   if (c.firstChild())
+                       continue;
+                   entered = true;
+               }
+               for (;;) {
+                   if (entered && leave && (anon || !c.type.isAnonymous))
+                       leave(c);
+                   if (c.nextSibling())
+                       break;
+                   if (!c.parent())
+                       return;
+                   entered = true;
+               }
+           }
+       }
+       /**
+       Get the value of the given [node prop](#common.NodeProp) for this
+       node. Works with both per-node and per-type props.
+       */
+       prop(prop) {
+           return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
+       }
+       /**
+       Returns the node's [per-node props](#common.NodeProp.perNode) in a
+       format that can be passed to the [`Tree`](#common.Tree)
+       constructor.
+       */
+       get propValues() {
+           let result = [];
+           if (this.props)
+               for (let id in this.props)
+                   result.push([+id, this.props[id]]);
+           return result;
+       }
+       /**
+       Balance the direct children of this tree, producing a copy of
+       which may have children grouped into subtrees with type
+       [`NodeType.none`](#common.NodeType^none).
+       */
+       balance(config = {}) {
+           return this.children.length <= 8 /* Balance.BranchFactor */ ? this :
+               balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
+       }
+       /**
+       Build a tree from a postfix-ordered buffer of node information,
+       or a cursor over such a buffer.
+       */
+       static build(data) { return buildTree(data); }
+   }
+   /**
+   The empty tree
+   */
+   Tree.empty = new Tree(NodeType.none, [], [], 0);
+   class FlatBufferCursor {
+       constructor(buffer, index) {
+           this.buffer = buffer;
+           this.index = index;
+       }
+       get id() { return this.buffer[this.index - 4]; }
+       get start() { return this.buffer[this.index - 3]; }
+       get end() { return this.buffer[this.index - 2]; }
+       get size() { return this.buffer[this.index - 1]; }
+       get pos() { return this.index; }
+       next() { this.index -= 4; }
+       fork() { return new FlatBufferCursor(this.buffer, this.index); }
+   }
+   /**
+   Tree buffers contain (type, start, end, endIndex) quads for each
+   node. In such a buffer, nodes are stored in prefix order (parents
+   before children, with the endIndex of the parent indicating which
+   children belong to it).
+   */
+   class TreeBuffer {
+       /**
+       Create a tree buffer.
+       */
+       constructor(
+       /**
+       The buffer's content.
+       */
+       buffer, 
+       /**
+       The total length of the group of nodes in the buffer.
+       */
+       length, 
+       /**
+       The node set used in this buffer.
+       */
+       set) {
+           this.buffer = buffer;
+           this.length = length;
+           this.set = set;
+       }
+       /**
+       @internal
+       */
+       get type() { return NodeType.none; }
+       /**
+       @internal
+       */
+       toString() {
+           let result = [];
+           for (let index = 0; index < this.buffer.length;) {
+               result.push(this.childString(index));
+               index = this.buffer[index + 3];
+           }
+           return result.join(",");
+       }
+       /**
+       @internal
+       */
+       childString(index) {
+           let id = this.buffer[index], endIndex = this.buffer[index + 3];
+           let type = this.set.types[id], result = type.name;
+           if (/\W/.test(result) && !type.isError)
+               result = JSON.stringify(result);
+           index += 4;
+           if (endIndex == index)
+               return result;
+           let children = [];
+           while (index < endIndex) {
+               children.push(this.childString(index));
+               index = this.buffer[index + 3];
+           }
+           return result + "(" + children.join(",") + ")";
+       }
+       /**
+       @internal
+       */
+       findChild(startIndex, endIndex, dir, pos, side) {
+           let { buffer } = this, pick = -1;
+           for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
+               if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
+                   pick = i;
+                   if (dir > 0)
+                       break;
+               }
+           }
+           return pick;
+       }
+       /**
+       @internal
+       */
+       slice(startI, endI, from) {
+           let b = this.buffer;
+           let copy = new Uint16Array(endI - startI), len = 0;
+           for (let i = startI, j = 0; i < endI;) {
+               copy[j++] = b[i++];
+               copy[j++] = b[i++] - from;
+               let to = copy[j++] = b[i++] - from;
+               copy[j++] = b[i++] - startI;
+               len = Math.max(len, to);
+           }
+           return new TreeBuffer(copy, len, this.set);
+       }
+   }
+   function checkSide(side, pos, from, to) {
+       switch (side) {
+           case -2 /* Side.Before */: return from < pos;
+           case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;
+           case 0 /* Side.Around */: return from < pos && to > pos;
+           case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;
+           case 2 /* Side.After */: return to > pos;
+           case 4 /* Side.DontCare */: return true;
+       }
+   }
+   function resolveNode(node, pos, side, overlays) {
+       var _a;
+       // Move up to a node that actually holds the position, if possible
+       while (node.from == node.to ||
+           (side < 1 ? node.from >= pos : node.from > pos) ||
+           (side > -1 ? node.to <= pos : node.to < pos)) {
+           let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
+           if (!parent)
+               return node;
+           node = parent;
+       }
+       let mode = overlays ? 0 : IterMode.IgnoreOverlays;
+       // Must go up out of overlays when those do not overlap with pos
+       if (overlays)
+           for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
+               if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
+                   node = parent;
+           }
+       for (;;) {
+           let inner = node.enter(pos, side, mode);
+           if (!inner)
+               return node;
+           node = inner;
+       }
+   }
+   class BaseNode {
+       cursor(mode = 0) { return new TreeCursor(this, mode); }
+       getChild(type, before = null, after = null) {
+           let r = getChildren(this, type, before, after);
+           return r.length ? r[0] : null;
+       }
+       getChildren(type, before = null, after = null) {
+           return getChildren(this, type, before, after);
+       }
+       resolve(pos, side = 0) {
+           return resolveNode(this, pos, side, false);
+       }
+       resolveInner(pos, side = 0) {
+           return resolveNode(this, pos, side, true);
+       }
+       matchContext(context) {
+           return matchNodeContext(this.parent, context);
+       }
+       enterUnfinishedNodesBefore(pos) {
+           let scan = this.childBefore(pos), node = this;
+           while (scan) {
+               let last = scan.lastChild;
+               if (!last || last.to != scan.to)
+                   break;
+               if (last.type.isError && last.from == last.to) {
+                   node = scan;
+                   scan = last.prevSibling;
+               }
+               else {
+                   scan = last;
+               }
+           }
+           return node;
+       }
+       get node() { return this; }
+       get next() { return this.parent; }
+   }
+   class TreeNode extends BaseNode {
+       constructor(_tree, from, 
+       // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
+       index, _parent) {
+           super();
+           this._tree = _tree;
+           this.from = from;
+           this.index = index;
+           this._parent = _parent;
+       }
+       get type() { return this._tree.type; }
+       get name() { return this._tree.type.name; }
+       get to() { return this.from + this._tree.length; }
+       nextChild(i, dir, pos, side, mode = 0) {
+           for (let parent = this;;) {
+               for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
+                   let next = children[i], start = positions[i] + parent.from;
+                   if (!checkSide(side, pos, start, start + next.length))
+                       continue;
+                   if (next instanceof TreeBuffer) {
+                       if (mode & IterMode.ExcludeBuffers)
+                           continue;
+                       let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
+                       if (index > -1)
+                           return new BufferNode(new BufferContext(parent, next, i, start), null, index);
+                   }
+                   else if ((mode & IterMode.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {
+                       let mounted;
+                       if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
+                           return new TreeNode(mounted.tree, start, i, parent);
+                       let inner = new TreeNode(next, start, i, parent);
+                       return (mode & IterMode.IncludeAnonymous) || !inner.type.isAnonymous ? inner
+                           : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
+                   }
+               }
+               if ((mode & IterMode.IncludeAnonymous) || !parent.type.isAnonymous)
+                   return null;
+               if (parent.index >= 0)
+                   i = parent.index + dir;
+               else
+                   i = dir < 0 ? -1 : parent._parent._tree.children.length;
+               parent = parent._parent;
+               if (!parent)
+                   return null;
+           }
+       }
+       get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); }
+       get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }
+       childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }
+       childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }
+       enter(pos, side, mode = 0) {
+           let mounted;
+           if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
+               let rPos = pos - this.from;
+               for (let { from, to } of mounted.overlay) {
+                   if ((side > 0 ? from <= rPos : from < rPos) &&
+                       (side < 0 ? to >= rPos : to > rPos))
+                       return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
+               }
+           }
+           return this.nextChild(0, 1, pos, side, mode);
+       }
+       nextSignificantParent() {
+           let val = this;
+           while (val.type.isAnonymous && val._parent)
+               val = val._parent;
+           return val;
+       }
+       get parent() {
+           return this._parent ? this._parent.nextSignificantParent() : null;
+       }
+       get nextSibling() {
+           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null;
+       }
+       get prevSibling() {
+           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null;
+       }
+       get tree() { return this._tree; }
+       toTree() { return this._tree; }
+       /**
+       @internal
+       */
+       toString() { return this._tree.toString(); }
+   }
+   function getChildren(node, type, before, after) {
+       let cur = node.cursor(), result = [];
+       if (!cur.firstChild())
+           return result;
+       if (before != null)
+           for (let found = false; !found;) {
+               found = cur.type.is(before);
+               if (!cur.nextSibling())
+                   return result;
+           }
+       for (;;) {
+           if (after != null && cur.type.is(after))
+               return result;
+           if (cur.type.is(type))
+               result.push(cur.node);
+           if (!cur.nextSibling())
+               return after == null ? result : [];
+       }
+   }
+   function matchNodeContext(node, context, i = context.length - 1) {
+       for (let p = node; i >= 0; p = p.parent) {
+           if (!p)
+               return false;
+           if (!p.type.isAnonymous) {
+               if (context[i] && context[i] != p.name)
+                   return false;
+               i--;
+           }
+       }
+       return true;
+   }
+   class BufferContext {
+       constructor(parent, buffer, index, start) {
+           this.parent = parent;
+           this.buffer = buffer;
+           this.index = index;
+           this.start = start;
+       }
+   }
+   class BufferNode extends BaseNode {
+       get name() { return this.type.name; }
+       get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
+       get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
+       constructor(context, _parent, index) {
+           super();
+           this.context = context;
+           this._parent = _parent;
+           this.index = index;
+           this.type = context.buffer.set.types[context.buffer.buffer[index]];
+       }
+       child(dir, pos, side) {
+           let { buffer } = this.context;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
+           return index < 0 ? null : new BufferNode(this.context, this, index);
+       }
+       get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }
+       get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }
+       childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }
+       childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }
+       enter(pos, side, mode = 0) {
+           if (mode & IterMode.ExcludeBuffers)
+               return null;
+           let { buffer } = this.context;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
+           return index < 0 ? null : new BufferNode(this.context, this, index);
+       }
+       get parent() {
+           return this._parent || this.context.parent.nextSignificantParent();
+       }
+       externalSibling(dir) {
+           return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */);
+       }
+       get nextSibling() {
+           let { buffer } = this.context;
+           let after = buffer.buffer[this.index + 3];
+           if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
+               return new BufferNode(this.context, this._parent, after);
+           return this.externalSibling(1);
+       }
+       get prevSibling() {
+           let { buffer } = this.context;
+           let parentStart = this._parent ? this._parent.index + 4 : 0;
+           if (this.index == parentStart)
+               return this.externalSibling(-1);
+           return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
+       }
+       get tree() { return null; }
+       toTree() {
+           let children = [], positions = [];
+           let { buffer } = this.context;
+           let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
+           if (endI > startI) {
+               let from = buffer.buffer[this.index + 1];
+               children.push(buffer.slice(startI, endI, from));
+               positions.push(0);
+           }
+           return new Tree(this.type, children, positions, this.to - this.from);
+       }
+       /**
+       @internal
+       */
+       toString() { return this.context.buffer.childString(this.index); }
+   }
+   function iterStack(heads) {
+       if (!heads.length)
+           return null;
+       let pick = 0, picked = heads[0];
+       for (let i = 1; i < heads.length; i++) {
+           let node = heads[i];
+           if (node.from > picked.from || node.to < picked.to) {
+               picked = node;
+               pick = i;
+           }
+       }
+       let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
+       let newHeads = heads.slice();
+       if (next)
+           newHeads[pick] = next;
+       else
+           newHeads.splice(pick, 1);
+       return new StackIterator(newHeads, picked);
+   }
+   class StackIterator {
+       constructor(heads, node) {
+           this.heads = heads;
+           this.node = node;
+       }
+       get next() { return iterStack(this.heads); }
+   }
+   function stackIterator(tree, pos, side) {
+       let inner = tree.resolveInner(pos, side), layers = null;
+       for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {
+           if (scan.index < 0) { // This is an overlay root
+               let parent = scan.parent;
+               (layers || (layers = [inner])).push(parent.resolve(pos, side));
+               scan = parent;
+           }
+           else {
+               let mount = MountedTree.get(scan.tree);
+               // Relevant overlay branching off
+               if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
+                   let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
+                   (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
+               }
+           }
+       }
+       return layers ? iterStack(layers) : inner;
+   }
+   /**
+   A tree cursor object focuses on a given node in a syntax tree, and
+   allows you to move to adjacent nodes.
+   */
+   class TreeCursor {
+       /**
+       Shorthand for `.type.name`.
+       */
+       get name() { return this.type.name; }
+       /**
+       @internal
+       */
+       constructor(node, 
+       /**
+       @internal
+       */
+       mode = 0) {
+           this.mode = mode;
+           /**
+           @internal
+           */
+           this.buffer = null;
+           this.stack = [];
+           /**
+           @internal
+           */
+           this.index = 0;
+           this.bufferNode = null;
+           if (node instanceof TreeNode) {
+               this.yieldNode(node);
+           }
+           else {
+               this._tree = node.context.parent;
+               this.buffer = node.context;
+               for (let n = node._parent; n; n = n._parent)
+                   this.stack.unshift(n.index);
+               this.bufferNode = node;
+               this.yieldBuf(node.index);
+           }
+       }
+       yieldNode(node) {
+           if (!node)
+               return false;
+           this._tree = node;
+           this.type = node.type;
+           this.from = node.from;
+           this.to = node.to;
+           return true;
+       }
+       yieldBuf(index, type) {
+           this.index = index;
+           let { start, buffer } = this.buffer;
+           this.type = type || buffer.set.types[buffer.buffer[index]];
+           this.from = start + buffer.buffer[index + 1];
+           this.to = start + buffer.buffer[index + 2];
+           return true;
+       }
+       /**
+       @internal
+       */
+       yield(node) {
+           if (!node)
+               return false;
+           if (node instanceof TreeNode) {
+               this.buffer = null;
+               return this.yieldNode(node);
+           }
+           this.buffer = node.context;
+           return this.yieldBuf(node.index, node.type);
+       }
+       /**
+       @internal
+       */
+       toString() {
+           return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
+       }
+       /**
+       @internal
+       */
+       enterChild(dir, pos, side) {
+           if (!this.buffer)
+               return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
+           let { buffer } = this.buffer;
+           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
+           if (index < 0)
+               return false;
+           this.stack.push(this.index);
+           return this.yieldBuf(index);
+       }
+       /**
+       Move the cursor to this node's first child. When this returns
+       false, the node has no child, and the cursor has not been moved.
+       */
+       firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); }
+       /**
+       Move the cursor to this node's last child.
+       */
+       lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); }
+       /**
+       Move the cursor to the first child that ends after `pos`.
+       */
+       childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); }
+       /**
+       Move to the last child that starts before `pos`.
+       */
+       childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); }
+       /**
+       Move the cursor to the child around `pos`. If side is -1 the
+       child may end at that position, when 1 it may start there. This
+       will also enter [overlaid](#common.MountedTree.overlay)
+       [mounted](#common.NodeProp^mounted) trees unless `overlays` is
+       set to false.
+       */
+       enter(pos, side, mode = this.mode) {
+           if (!this.buffer)
+               return this.yield(this._tree.enter(pos, side, mode));
+           return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
+       }
+       /**
+       Move to the node's parent node, if this isn't the top node.
+       */
+       parent() {
+           if (!this.buffer)
+               return this.yieldNode((this.mode & IterMode.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
+           if (this.stack.length)
+               return this.yieldBuf(this.stack.pop());
+           let parent = (this.mode & IterMode.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
+           this.buffer = null;
+           return this.yieldNode(parent);
+       }
+       /**
+       @internal
+       */
+       sibling(dir) {
+           if (!this.buffer)
+               return !this._tree._parent ? false
+                   : this.yield(this._tree.index < 0 ? null
+                       : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode));
+           let { buffer } = this.buffer, d = this.stack.length - 1;
+           if (dir < 0) {
+               let parentStart = d < 0 ? 0 : this.stack[d] + 4;
+               if (this.index != parentStart)
+                   return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
+           }
+           else {
+               let after = buffer.buffer[this.index + 3];
+               if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
+                   return this.yieldBuf(after);
+           }
+           return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false;
+       }
+       /**
+       Move to this node's next sibling, if any.
+       */
+       nextSibling() { return this.sibling(1); }
+       /**
+       Move to this node's previous sibling, if any.
+       */
+       prevSibling() { return this.sibling(-1); }
+       atLastNode(dir) {
+           let index, parent, { buffer } = this;
+           if (buffer) {
+               if (dir > 0) {
+                   if (this.index < buffer.buffer.buffer.length)
+                       return false;
+               }
+               else {
+                   for (let i = 0; i < this.index; i++)
+                       if (buffer.buffer.buffer[i + 3] < this.index)
+                           return false;
+               }
+               ({ index, parent } = buffer);
+           }
+           else {
+               ({ index, _parent: parent } = this._tree);
+           }
+           for (; parent; { index, _parent: parent } = parent) {
+               if (index > -1)
+                   for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
+                       let child = parent._tree.children[i];
+                       if ((this.mode & IterMode.IncludeAnonymous) ||
+                           child instanceof TreeBuffer ||
+                           !child.type.isAnonymous ||
+                           hasChild(child))
+                           return false;
+                   }
+           }
+           return true;
+       }
+       move(dir, enter) {
+           if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */))
+               return true;
+           for (;;) {
+               if (this.sibling(dir))
+                   return true;
+               if (this.atLastNode(dir) || !this.parent())
+                   return false;
+           }
+       }
+       /**
+       Move to the next node in a
+       [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
+       traversal, going from a node to its first child or, if the
+       current node is empty or `enter` is false, its next sibling or
+       the next sibling of the first parent node that has one.
+       */
+       next(enter = true) { return this.move(1, enter); }
+       /**
+       Move to the next node in a last-to-first pre-order traversal. A
+       node is followed by its last child or, if it has none, its
+       previous sibling or the previous sibling of the first parent
+       node that has one.
+       */
+       prev(enter = true) { return this.move(-1, enter); }
+       /**
+       Move the cursor to the innermost node that covers `pos`. If
+       `side` is -1, it will enter nodes that end at `pos`. If it is 1,
+       it will enter nodes that start at `pos`.
+       */
+       moveTo(pos, side = 0) {
+           // Move up to a node that actually holds the position, if possible
+           while (this.from == this.to ||
+               (side < 1 ? this.from >= pos : this.from > pos) ||
+               (side > -1 ? this.to <= pos : this.to < pos))
+               if (!this.parent())
+                   break;
+           // Then scan down into child nodes as far as possible
+           while (this.enterChild(1, pos, side)) { }
+           return this;
+       }
+       /**
+       Get a [syntax node](#common.SyntaxNode) at the cursor's current
+       position.
+       */
+       get node() {
+           if (!this.buffer)
+               return this._tree;
+           let cache = this.bufferNode, result = null, depth = 0;
+           if (cache && cache.context == this.buffer) {
+               scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
+                   for (let c = cache; c; c = c._parent)
+                       if (c.index == index) {
+                           if (index == this.index)
+                               return c;
+                           result = c;
+                           depth = d + 1;
+                           break scan;
+                       }
+                   index = this.stack[--d];
+               }
+           }
+           for (let i = depth; i < this.stack.length; i++)
+               result = new BufferNode(this.buffer, result, this.stack[i]);
+           return this.bufferNode = new BufferNode(this.buffer, result, this.index);
+       }
+       /**
+       Get the [tree](#common.Tree) that represents the current node, if
+       any. Will return null when the node is in a [tree
+       buffer](#common.TreeBuffer).
+       */
+       get tree() {
+           return this.buffer ? null : this._tree._tree;
+       }
+       /**
+       Iterate over the current node and all its descendants, calling
+       `enter` when entering a node and `leave`, if given, when leaving
+       one. When `enter` returns `false`, any children of that node are
+       skipped, and `leave` isn't called for it.
+       */
+       iterate(enter, leave) {
+           for (let depth = 0;;) {
+               let mustLeave = false;
+               if (this.type.isAnonymous || enter(this) !== false) {
+                   if (this.firstChild()) {
+                       depth++;
+                       continue;
+                   }
+                   if (!this.type.isAnonymous)
+                       mustLeave = true;
+               }
+               for (;;) {
+                   if (mustLeave && leave)
+                       leave(this);
+                   mustLeave = this.type.isAnonymous;
+                   if (!depth)
+                       return;
+                   if (this.nextSibling())
+                       break;
+                   this.parent();
+                   depth--;
+                   mustLeave = true;
+               }
+           }
+       }
+       /**
+       Test whether the current node matches a given context—a sequence
+       of direct parent node names. Empty strings in the context array
+       are treated as wildcards.
+       */
+       matchContext(context) {
+           if (!this.buffer)
+               return matchNodeContext(this.node.parent, context);
+           let { buffer } = this.buffer, { types } = buffer.set;
+           for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
+               if (d < 0)
+                   return matchNodeContext(this._tree, context, i);
+               let type = types[buffer.buffer[this.stack[d]]];
+               if (!type.isAnonymous) {
+                   if (context[i] && context[i] != type.name)
+                       return false;
+                   i--;
+               }
+           }
+           return true;
+       }
+   }
+   function hasChild(tree) {
+       return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
+   }
+   function buildTree(data) {
+       var _a;
+       let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
+       let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
+       let types = nodeSet.types;
+       let contextHash = 0, lookAhead = 0;
+       function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
+           let { id, start, end, size } = cursor;
+           let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
+           while (size < 0) {
+               cursor.next();
+               if (size == -1 /* SpecialRecord.Reuse */) {
+                   let node = reused[id];
+                   children.push(node);
+                   positions.push(start - parentStart);
+                   return;
+               }
+               else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change
+                   contextHash = id;
+                   return;
+               }
+               else if (size == -4 /* SpecialRecord.LookAhead */) {
+                   lookAhead = id;
+                   return;
+               }
+               else {
+                   throw new RangeError(`Unrecognized record size: ${size}`);
+               }
+           }
+           let type = types[id], node, buffer;
+           let startPos = start - parentStart;
+           if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
+               // Small enough for a buffer, and no reused nodes inside
+               let data = new Uint16Array(buffer.size - buffer.skip);
+               let endPos = cursor.pos - buffer.size, index = data.length;
+               while (cursor.pos > endPos)
+                   index = copyToBuffer(buffer.start, data, index);
+               node = new TreeBuffer(data, end - buffer.start, nodeSet);
+               startPos = buffer.start - parentStart;
+           }
+           else { // Make it a node
+               let endPos = cursor.pos - size;
+               cursor.next();
+               let localChildren = [], localPositions = [];
+               let localInRepeat = id >= minRepeatType ? id : -1;
+               let lastGroup = 0, lastEnd = end;
+               while (cursor.pos > endPos) {
+                   if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
+                       if (cursor.end <= lastEnd - maxBufferLength) {
+                           makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
+                           lastGroup = localChildren.length;
+                           lastEnd = cursor.end;
+                       }
+                       cursor.next();
+                   }
+                   else if (depth > 2500 /* CutOff.Depth */) {
+                       takeFlatNode(start, endPos, localChildren, localPositions);
+                   }
+                   else {
+                       takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
+                   }
+               }
+               if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
+                   makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
+               localChildren.reverse();
+               localPositions.reverse();
+               if (localInRepeat > -1 && lastGroup > 0) {
+                   let make = makeBalanced(type, contextAtStart);
+                   node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
+               }
+               else {
+                   node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
+               }
+           }
+           children.push(node);
+           positions.push(startPos);
+       }
+       function takeFlatNode(parentStart, minPos, children, positions) {
+           let nodes = []; // Temporary, inverted array of leaf nodes found, with absolute positions
+           let nodeCount = 0, stopAt = -1;
+           while (cursor.pos > minPos) {
+               let { id, start, end, size } = cursor;
+               if (size > 4) { // Not a leaf
+                   cursor.next();
+               }
+               else if (stopAt > -1 && start < stopAt) {
+                   break;
+               }
+               else {
+                   if (stopAt < 0)
+                       stopAt = end - maxBufferLength;
+                   nodes.push(id, start, end);
+                   nodeCount++;
+                   cursor.next();
+               }
+           }
+           if (nodeCount) {
+               let buffer = new Uint16Array(nodeCount * 4);
+               let start = nodes[nodes.length - 2];
+               for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
+                   buffer[j++] = nodes[i];
+                   buffer[j++] = nodes[i + 1] - start;
+                   buffer[j++] = nodes[i + 2] - start;
+                   buffer[j++] = j;
+               }
+               children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));
+               positions.push(start - parentStart);
+           }
+       }
+       function makeBalanced(type, contextHash) {
+           return (children, positions, length) => {
+               let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
+               if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
+                   if (!lastI && last.type == type && last.length == length)
+                       return last;
+                   if (lookAheadProp = last.prop(NodeProp.lookAhead))
+                       lookAhead = positions[lastI] + last.length + lookAheadProp;
+               }
+               return makeTree(type, children, positions, length, lookAhead, contextHash);
+           };
+       }
+       function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead, contextHash) {
+           let localChildren = [], localPositions = [];
+           while (children.length > i) {
+               localChildren.push(children.pop());
+               localPositions.push(positions.pop() + base - from);
+           }
+           children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to, contextHash));
+           positions.push(from - base);
+       }
+       function makeTree(type, children, positions, length, lookAhead, contextHash, props) {
+           if (contextHash) {
+               let pair = [NodeProp.contextHash, contextHash];
+               props = props ? [pair].concat(props) : [pair];
+           }
+           if (lookAhead > 25) {
+               let pair = [NodeProp.lookAhead, lookAhead];
+               props = props ? [pair].concat(props) : [pair];
+           }
+           return new Tree(type, children, positions, length, props);
+       }
+       function findBufferSize(maxSize, inRepeat) {
+           // Scan through the buffer to find previous siblings that fit
+           // together in a TreeBuffer, and don't contain any reused nodes
+           // (which can't be stored in a buffer).
+           // If `inRepeat` is > -1, ignore node boundaries of that type for
+           // nesting, but make sure the end falls either at the start
+           // (`maxSize`) or before such a node.
+           let fork = cursor.fork();
+           let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
+           let result = { size: 0, start: 0, skip: 0 };
+           scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
+               let nodeSize = fork.size;
+               // Pretend nested repeat nodes of the same type don't exist
+               if (fork.id == inRepeat && nodeSize >= 0) {
+                   // Except that we store the current state as a valid return
+                   // value.
+                   result.size = size;
+                   result.start = start;
+                   result.skip = skip;
+                   skip += 4;
+                   size += 4;
+                   fork.next();
+                   continue;
+               }
+               let startPos = fork.pos - nodeSize;
+               if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
+                   break;
+               let localSkipped = fork.id >= minRepeatType ? 4 : 0;
+               let nodeStart = fork.start;
+               fork.next();
+               while (fork.pos > startPos) {
+                   if (fork.size < 0) {
+                       if (fork.size == -3 /* SpecialRecord.ContextChange */)
+                           localSkipped += 4;
+                       else
+                           break scan;
+                   }
+                   else if (fork.id >= minRepeatType) {
+                       localSkipped += 4;
+                   }
+                   fork.next();
+               }
+               start = nodeStart;
+               size += nodeSize;
+               skip += localSkipped;
+           }
+           if (inRepeat < 0 || size == maxSize) {
+               result.size = size;
+               result.start = start;
+               result.skip = skip;
+           }
+           return result.size > 4 ? result : undefined;
+       }
+       function copyToBuffer(bufferStart, buffer, index) {
+           let { id, start, end, size } = cursor;
+           cursor.next();
+           if (size >= 0 && id < minRepeatType) {
+               let startIndex = index;
+               if (size > 4) {
+                   let endPos = cursor.pos - (size - 4);
+                   while (cursor.pos > endPos)
+                       index = copyToBuffer(bufferStart, buffer, index);
+               }
+               buffer[--index] = startIndex;
+               buffer[--index] = end - bufferStart;
+               buffer[--index] = start - bufferStart;
+               buffer[--index] = id;
+           }
+           else if (size == -3 /* SpecialRecord.ContextChange */) {
+               contextHash = id;
+           }
+           else if (size == -4 /* SpecialRecord.LookAhead */) {
+               lookAhead = id;
+           }
+           return index;
+       }
+       let children = [], positions = [];
+       while (cursor.pos > 0)
+           takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
+       let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
+       return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
+   }
+   const nodeSizeCache = new WeakMap;
+   function nodeSize(balanceType, node) {
+       if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
+           return 1;
+       let size = nodeSizeCache.get(node);
+       if (size == null) {
+           size = 1;
+           for (let child of node.children) {
+               if (child.type != balanceType || !(child instanceof Tree)) {
+                   size = 1;
+                   break;
+               }
+               size += nodeSize(balanceType, child);
+           }
+           nodeSizeCache.set(node, size);
+       }
+       return size;
+   }
+   function balanceRange(
+   // The type the balanced tree's inner nodes.
+   balanceType, 
+   // The direct children and their positions
+   children, positions, 
+   // The index range in children/positions to use
+   from, to, 
+   // The start position of the nodes, relative to their parent.
+   start, 
+   // Length of the outer node
+   length, 
+   // Function to build the top node of the balanced tree
+   mkTop, 
+   // Function to build internal nodes for the balanced tree
+   mkTree) {
+       let total = 0;
+       for (let i = from; i < to; i++)
+           total += nodeSize(balanceType, children[i]);
+       let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);
+       let localChildren = [], localPositions = [];
+       function divide(children, positions, from, to, offset) {
+           for (let i = from; i < to;) {
+               let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
+               i++;
+               for (; i < to; i++) {
+                   let nextSize = nodeSize(balanceType, children[i]);
+                   if (groupSize + nextSize >= maxChild)
+                       break;
+                   groupSize += nextSize;
+               }
+               if (i == groupFrom + 1) {
+                   if (groupSize > maxChild) {
+                       let only = children[groupFrom]; // Only trees can have a size > 1
+                       divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
+                       continue;
+                   }
+                   localChildren.push(children[groupFrom]);
+               }
+               else {
+                   let length = positions[i - 1] + children[i - 1].length - groupStart;
+                   localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
+               }
+               localPositions.push(groupStart + offset - start);
+           }
+       }
+       divide(children, positions, from, to, 0);
+       return (mkTop || mkTree)(localChildren, localPositions, length);
+   }
+   /**
+   Provides a way to associate values with pieces of trees. As long
+   as that part of the tree is reused, the associated values can be
+   retrieved from an updated tree.
+   */
+   class NodeWeakMap {
+       constructor() {
+           this.map = new WeakMap();
+       }
+       setBuffer(buffer, index, value) {
+           let inner = this.map.get(buffer);
+           if (!inner)
+               this.map.set(buffer, inner = new Map);
+           inner.set(index, value);
+       }
+       getBuffer(buffer, index) {
+           let inner = this.map.get(buffer);
+           return inner && inner.get(index);
+       }
+       /**
+       Set the value for this syntax node.
+       */
+       set(node, value) {
+           if (node instanceof BufferNode)
+               this.setBuffer(node.context.buffer, node.index, value);
+           else if (node instanceof TreeNode)
+               this.map.set(node.tree, value);
+       }
+       /**
+       Retrieve value for this syntax node, if it exists in the map.
+       */
+       get(node) {
+           return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index)
+               : node instanceof TreeNode ? this.map.get(node.tree) : undefined;
+       }
+       /**
+       Set the value for the node that a cursor currently points to.
+       */
+       cursorSet(cursor, value) {
+           if (cursor.buffer)
+               this.setBuffer(cursor.buffer.buffer, cursor.index, value);
+           else
+               this.map.set(cursor.tree, value);
+       }
+       /**
+       Retrieve the value for the node that a cursor currently points
+       to.
+       */
+       cursorGet(cursor) {
+           return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
+       }
+   }
+
+   /**
+   Tree fragments are used during [incremental
+   parsing](#common.Parser.startParse) to track parts of old trees
+   that can be reused in a new parse. An array of fragments is used
+   to track regions of an old tree whose nodes might be reused in new
+   parses. Use the static
+   [`applyChanges`](#common.TreeFragment^applyChanges) method to
+   update fragments for document changes.
+   */
+   class TreeFragment {
+       /**
+       Construct a tree fragment. You'll usually want to use
+       [`addTree`](#common.TreeFragment^addTree) and
+       [`applyChanges`](#common.TreeFragment^applyChanges) instead of
+       calling this directly.
+       */
+       constructor(
+       /**
+       The start of the unchanged range pointed to by this fragment.
+       This refers to an offset in the _updated_ document (as opposed
+       to the original tree).
+       */
+       from, 
+       /**
+       The end of the unchanged range.
+       */
+       to, 
+       /**
+       The tree that this fragment is based on.
+       */
+       tree, 
+       /**
+       The offset between the fragment's tree and the document that
+       this fragment can be used against. Add this when going from
+       document to tree positions, subtract it to go from tree to
+       document positions.
+       */
+       offset, openStart = false, openEnd = false) {
+           this.from = from;
+           this.to = to;
+           this.tree = tree;
+           this.offset = offset;
+           this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0);
+       }
+       /**
+       Whether the start of the fragment represents the start of a
+       parse, or the end of a change. (In the second case, it may not
+       be safe to reuse some nodes at the start, depending on the
+       parsing algorithm.)
+       */
+       get openStart() { return (this.open & 1 /* Open.Start */) > 0; }
+       /**
+       Whether the end of the fragment represents the end of a
+       full-document parse, or the start of a change.
+       */
+       get openEnd() { return (this.open & 2 /* Open.End */) > 0; }
+       /**
+       Create a set of fragments from a freshly parsed tree, or update
+       an existing set of fragments by replacing the ones that overlap
+       with a tree with content from the new tree. When `partial` is
+       true, the parse is treated as incomplete, and the resulting
+       fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
+       true.
+       */
+       static addTree(tree, fragments = [], partial = false) {
+           let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
+           for (let f of fragments)
+               if (f.to > tree.length)
+                   result.push(f);
+           return result;
+       }
+       /**
+       Apply a set of edits to an array of fragments, removing or
+       splitting fragments as necessary to remove edited ranges, and
+       adjusting offsets for fragments that moved.
+       */
+       static applyChanges(fragments, changes, minGap = 128) {
+           if (!changes.length)
+               return fragments;
+           let result = [];
+           let fI = 1, nextF = fragments.length ? fragments[0] : null;
+           for (let cI = 0, pos = 0, off = 0;; cI++) {
+               let nextC = cI < changes.length ? changes[cI] : null;
+               let nextPos = nextC ? nextC.fromA : 1e9;
+               if (nextPos - pos >= minGap)
+                   while (nextF && nextF.from < nextPos) {
+                       let cut = nextF;
+                       if (pos >= cut.from || nextPos <= cut.to || off) {
+                           let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
+                           cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
+                       }
+                       if (cut)
+                           result.push(cut);
+                       if (nextF.to > nextPos)
+                           break;
+                       nextF = fI < fragments.length ? fragments[fI++] : null;
+                   }
+               if (!nextC)
+                   break;
+               pos = nextC.toA;
+               off = nextC.toA - nextC.toB;
+           }
+           return result;
+       }
+   }
+   /**
+   A superclass that parsers should extend.
+   */
+   class Parser {
+       /**
+       Start a parse, returning a [partial parse](#common.PartialParse)
+       object. [`fragments`](#common.TreeFragment) can be passed in to
+       make the parse incremental.
+       
+       By default, the entire input is parsed. You can pass `ranges`,
+       which should be a sorted array of non-empty, non-overlapping
+       ranges, to parse only those ranges. The tree returned in that
+       case will start at `ranges[0].from`.
+       */
+       startParse(input, fragments, ranges) {
+           if (typeof input == "string")
+               input = new StringInput(input);
+           ranges = !ranges ? [new Range$1(0, input.length)] : ranges.length ? ranges.map(r => new Range$1(r.from, r.to)) : [new Range$1(0, 0)];
+           return this.createParse(input, fragments || [], ranges);
+       }
+       /**
+       Run a full parse, returning the resulting tree.
+       */
+       parse(input, fragments, ranges) {
+           let parse = this.startParse(input, fragments, ranges);
+           for (;;) {
+               let done = parse.advance();
+               if (done)
+                   return done;
+           }
+       }
+   }
+   class StringInput {
+       constructor(string) {
+           this.string = string;
+       }
+       get length() { return this.string.length; }
+       chunk(from) { return this.string.slice(from); }
+       get lineChunks() { return false; }
+       read(from, to) { return this.string.slice(from, to); }
+   }
+   new NodeProp({ perNode: true });
+
+   /**
+   A parse stack. These are used internally by the parser to track
+   parsing progress. They also provide some properties and methods
+   that external code such as a tokenizer can use to get information
+   about the parse state.
+   */
+   class Stack {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The parse that this stack is part of @internal
+       */
+       p, 
+       /**
+       Holds state, input pos, buffer index triplets for all but the
+       top state @internal
+       */
+       stack, 
+       /**
+       The current parse state @internal
+       */
+       state, 
+       // The position at which the next reduce should take place. This
+       // can be less than `this.pos` when skipped expressions have been
+       // added to the stack (which should be moved outside of the next
+       // reduction)
+       /**
+       @internal
+       */
+       reducePos, 
+       /**
+       The input position up to which this stack has parsed.
+       */
+       pos, 
+       /**
+       The dynamic score of the stack, including dynamic precedence
+       and error-recovery penalties
+       @internal
+       */
+       score, 
+       // The output buffer. Holds (type, start, end, size) quads
+       // representing nodes created by the parser, where `size` is
+       // amount of buffer array entries covered by this node.
+       /**
+       @internal
+       */
+       buffer, 
+       // The base offset of the buffer. When stacks are split, the split
+       // instance shared the buffer history with its parent up to
+       // `bufferBase`, which is the absolute offset (including the
+       // offset of previous splits) into the buffer at which this stack
+       // starts writing.
+       /**
+       @internal
+       */
+       bufferBase, 
+       /**
+       @internal
+       */
+       curContext, 
+       /**
+       @internal
+       */
+       lookAhead = 0, 
+       // A parent stack from which this was split off, if any. This is
+       // set up so that it always points to a stack that has some
+       // additional buffer content, never to a stack with an equal
+       // `bufferBase`.
+       /**
+       @internal
+       */
+       parent) {
+           this.p = p;
+           this.stack = stack;
+           this.state = state;
+           this.reducePos = reducePos;
+           this.pos = pos;
+           this.score = score;
+           this.buffer = buffer;
+           this.bufferBase = bufferBase;
+           this.curContext = curContext;
+           this.lookAhead = lookAhead;
+           this.parent = parent;
+       }
+       /**
+       @internal
+       */
+       toString() {
+           return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
+       }
+       // Start an empty stack
+       /**
+       @internal
+       */
+       static start(p, state, pos = 0) {
+           let cx = p.parser.context;
+           return new Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
+       }
+       /**
+       The stack's current [context](#lr.ContextTracker) value, if
+       any. Its type will depend on the context tracker's type
+       parameter, or it will be `null` if there is no context
+       tracker.
+       */
+       get context() { return this.curContext ? this.curContext.context : null; }
+       // Push a state onto the stack, tracking its start position as well
+       // as the buffer base at that point.
+       /**
+       @internal
+       */
+       pushState(state, start) {
+           this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
+           this.state = state;
+       }
+       // Apply a reduce action
+       /**
+       @internal
+       */
+       reduce(action) {
+           var _a;
+           let depth = action >> 19 /* Action.ReduceDepthShift */, type = action & 65535 /* Action.ValueMask */;
+           let { parser } = this.p;
+           let lookaheadRecord = this.reducePos < this.pos - 25 /* Lookahead.Margin */;
+           if (lookaheadRecord)
+               this.setLookAhead(this.pos);
+           let dPrec = parser.dynamicPrecedence(type);
+           if (dPrec)
+               this.score += dPrec;
+           if (depth == 0) {
+               this.pushState(parser.getGoto(this.state, type, true), this.reducePos);
+               // Zero-depth reductions are a special case—they add stuff to
+               // the stack without popping anything off.
+               if (type < parser.minRepeatTerm)
+                   this.storeNode(type, this.reducePos, this.reducePos, lookaheadRecord ? 8 : 4, true);
+               this.reduceContext(type, this.reducePos);
+               return;
+           }
+           // Find the base index into `this.stack`, content after which will
+           // be dropped. Note that with `StayFlag` reductions we need to
+           // consume two extra frames (the dummy parent node for the skipped
+           // expression and the state that we'll be staying in, which should
+           // be moved to `this.state`).
+           let base = this.stack.length - ((depth - 1) * 3) - (action & 262144 /* Action.StayFlag */ ? 6 : 0);
+           let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start;
+           // This is a kludge to try and detect overly deep left-associative
+           // trees, which will not increase the parse stack depth and thus
+           // won't be caught by the regular stack-depth limit check.
+           if (size >= 2000 /* Recover.MinBigReduction */ && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) {
+               if (start == this.p.lastBigReductionStart) {
+                   this.p.bigReductionCount++;
+                   this.p.lastBigReductionSize = size;
+               }
+               else if (this.p.lastBigReductionSize < size) {
+                   this.p.bigReductionCount = 1;
+                   this.p.lastBigReductionStart = start;
+                   this.p.lastBigReductionSize = size;
+               }
+           }
+           let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
+           // Store normal terms or `R -> R R` repeat reductions
+           if (type < parser.minRepeatTerm || (action & 131072 /* Action.RepeatFlag */)) {
+               let pos = parser.stateFlag(this.state, 1 /* StateFlag.Skipped */) ? this.pos : this.reducePos;
+               this.storeNode(type, start, pos, count + 4, true);
+           }
+           if (action & 262144 /* Action.StayFlag */) {
+               this.state = this.stack[base];
+           }
+           else {
+               let baseStateID = this.stack[base - 3];
+               this.state = parser.getGoto(baseStateID, type, true);
+           }
+           while (this.stack.length > base)
+               this.stack.pop();
+           this.reduceContext(type, start);
+       }
+       // Shift a value into the buffer
+       /**
+       @internal
+       */
+       storeNode(term, start, end, size = 4, mustSink = false) {
+           if (term == 0 /* Term.Err */ &&
+               (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
+               // Try to omit/merge adjacent error nodes
+               let cur = this, top = this.buffer.length;
+               if (top == 0 && cur.parent) {
+                   top = cur.bufferBase - cur.parent.bufferBase;
+                   cur = cur.parent;
+               }
+               if (top > 0 && cur.buffer[top - 4] == 0 /* Term.Err */ && cur.buffer[top - 1] > -1) {
+                   if (start == end)
+                       return;
+                   if (cur.buffer[top - 2] >= start) {
+                       cur.buffer[top - 2] = end;
+                       return;
+                   }
+               }
+           }
+           if (!mustSink || this.pos == end) { // Simple case, just append
+               this.buffer.push(term, start, end, size);
+           }
+           else { // There may be skipped nodes that have to be moved forward
+               let index = this.buffer.length;
+               if (index > 0 && this.buffer[index - 4] != 0 /* Term.Err */) {
+                   let mustMove = false;
+                   for (let scan = index; scan > 0 && this.buffer[scan - 2] > end; scan -= 4) {
+                       if (this.buffer[scan - 1] >= 0) {
+                           mustMove = true;
+                           break;
+                       }
+                   }
+                   if (mustMove)
+                       while (index > 0 && this.buffer[index - 2] > end) {
+                           // Move this record forward
+                           this.buffer[index] = this.buffer[index - 4];
+                           this.buffer[index + 1] = this.buffer[index - 3];
+                           this.buffer[index + 2] = this.buffer[index - 2];
+                           this.buffer[index + 3] = this.buffer[index - 1];
+                           index -= 4;
+                           if (size > 4)
+                               size -= 4;
+                       }
+               }
+               this.buffer[index] = term;
+               this.buffer[index + 1] = start;
+               this.buffer[index + 2] = end;
+               this.buffer[index + 3] = size;
+           }
+       }
+       // Apply a shift action
+       /**
+       @internal
+       */
+       shift(action, type, start, end) {
+           if (action & 131072 /* Action.GotoFlag */) {
+               this.pushState(action & 65535 /* Action.ValueMask */, this.pos);
+           }
+           else if ((action & 262144 /* Action.StayFlag */) == 0) { // Regular shift
+               let nextState = action, { parser } = this.p;
+               if (end > this.pos || type <= parser.maxNode) {
+                   this.pos = end;
+                   if (!parser.stateFlag(nextState, 1 /* StateFlag.Skipped */))
+                       this.reducePos = end;
+               }
+               this.pushState(nextState, start);
+               this.shiftContext(type, start);
+               if (type <= parser.maxNode)
+                   this.buffer.push(type, start, end, 4);
+           }
+           else { // Shift-and-stay, which means this is a skipped token
+               this.pos = end;
+               this.shiftContext(type, start);
+               if (type <= this.p.parser.maxNode)
+                   this.buffer.push(type, start, end, 4);
+           }
+       }
+       // Apply an action
+       /**
+       @internal
+       */
+       apply(action, next, nextStart, nextEnd) {
+           if (action & 65536 /* Action.ReduceFlag */)
+               this.reduce(action);
+           else
+               this.shift(action, next, nextStart, nextEnd);
+       }
+       // Add a prebuilt (reused) node into the buffer.
+       /**
+       @internal
+       */
+       useNode(value, next) {
+           let index = this.p.reused.length - 1;
+           if (index < 0 || this.p.reused[index] != value) {
+               this.p.reused.push(value);
+               index++;
+           }
+           let start = this.pos;
+           this.reducePos = this.pos = start + value.length;
+           this.pushState(next, start);
+           this.buffer.push(index, start, this.reducePos, -1 /* size == -1 means this is a reused value */);
+           if (this.curContext)
+               this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
+       }
+       // Split the stack. Due to the buffer sharing and the fact
+       // that `this.stack` tends to stay quite shallow, this isn't very
+       // expensive.
+       /**
+       @internal
+       */
+       split() {
+           let parent = this;
+           let off = parent.buffer.length;
+           // Because the top of the buffer (after this.pos) may be mutated
+           // to reorder reductions and skipped tokens, and shared buffers
+           // should be immutable, this copies any outstanding skipped tokens
+           // to the new buffer, and puts the base pointer before them.
+           while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
+               off -= 4;
+           let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
+           // Make sure parent points to an actual parent with content, if there is such a parent.
+           while (parent && base == parent.bufferBase)
+               parent = parent.parent;
+           return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
+       }
+       // Try to recover from an error by 'deleting' (ignoring) one token.
+       /**
+       @internal
+       */
+       recoverByDelete(next, nextEnd) {
+           let isNode = next <= this.p.parser.maxNode;
+           if (isNode)
+               this.storeNode(next, this.pos, nextEnd, 4);
+           this.storeNode(0 /* Term.Err */, this.pos, nextEnd, isNode ? 8 : 4);
+           this.pos = this.reducePos = nextEnd;
+           this.score -= 190 /* Recover.Delete */;
+       }
+       /**
+       Check if the given term would be able to be shifted (optionally
+       after some reductions) on this stack. This can be useful for
+       external tokenizers that want to make sure they only provide a
+       given token when it applies.
+       */
+       canShift(term) {
+           for (let sim = new SimulatedStack(this);;) {
+               let action = this.p.parser.stateSlot(sim.state, 4 /* ParseState.DefaultReduce */) || this.p.parser.hasAction(sim.state, term);
+               if (action == 0)
+                   return false;
+               if ((action & 65536 /* Action.ReduceFlag */) == 0)
+                   return true;
+               sim.reduce(action);
+           }
+       }
+       // Apply up to Recover.MaxNext recovery actions that conceptually
+       // inserts some missing token or rule.
+       /**
+       @internal
+       */
+       recoverByInsert(next) {
+           if (this.stack.length >= 300 /* Recover.MaxInsertStackDepth */)
+               return [];
+           let nextStates = this.p.parser.nextStates(this.state);
+           if (nextStates.length > 4 /* Recover.MaxNext */ << 1 || this.stack.length >= 120 /* Recover.DampenInsertStackDepth */) {
+               let best = [];
+               for (let i = 0, s; i < nextStates.length; i += 2) {
+                   if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
+                       best.push(nextStates[i], s);
+               }
+               if (this.stack.length < 120 /* Recover.DampenInsertStackDepth */)
+                   for (let i = 0; best.length < 4 /* Recover.MaxNext */ << 1 && i < nextStates.length; i += 2) {
+                       let s = nextStates[i + 1];
+                       if (!best.some((v, i) => (i & 1) && v == s))
+                           best.push(nextStates[i], s);
+                   }
+               nextStates = best;
+           }
+           let result = [];
+           for (let i = 0; i < nextStates.length && result.length < 4 /* Recover.MaxNext */; i += 2) {
+               let s = nextStates[i + 1];
+               if (s == this.state)
+                   continue;
+               let stack = this.split();
+               stack.pushState(s, this.pos);
+               stack.storeNode(0 /* Term.Err */, stack.pos, stack.pos, 4, true);
+               stack.shiftContext(nextStates[i], this.pos);
+               stack.reducePos = this.pos;
+               stack.score -= 200 /* Recover.Insert */;
+               result.push(stack);
+           }
+           return result;
+       }
+       // Force a reduce, if possible. Return false if that can't
+       // be done.
+       /**
+       @internal
+       */
+       forceReduce() {
+           let { parser } = this.p;
+           let reduce = parser.stateSlot(this.state, 5 /* ParseState.ForcedReduce */);
+           if ((reduce & 65536 /* Action.ReduceFlag */) == 0)
+               return false;
+           if (!parser.validAction(this.state, reduce)) {
+               let depth = reduce >> 19 /* Action.ReduceDepthShift */, term = reduce & 65535 /* Action.ValueMask */;
+               let target = this.stack.length - depth * 3;
+               if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) {
+                   let backup = this.findForcedReduction();
+                   if (backup == null)
+                       return false;
+                   reduce = backup;
+               }
+               this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
+               this.score -= 100 /* Recover.Reduce */;
+           }
+           this.reducePos = this.pos;
+           this.reduce(reduce);
+           return true;
+       }
+       /**
+       Try to scan through the automaton to find some kind of reduction
+       that can be applied. Used when the regular ForcedReduce field
+       isn't a valid action. @internal
+       */
+       findForcedReduction() {
+           let { parser } = this.p, seen = [];
+           let explore = (state, depth) => {
+               if (seen.includes(state))
+                   return;
+               seen.push(state);
+               return parser.allActions(state, (action) => {
+                   if (action & (262144 /* Action.StayFlag */ | 131072 /* Action.GotoFlag */)) ;
+                   else if (action & 65536 /* Action.ReduceFlag */) {
+                       let rDepth = (action >> 19 /* Action.ReduceDepthShift */) - depth;
+                       if (rDepth > 1) {
+                           let term = action & 65535 /* Action.ValueMask */, target = this.stack.length - rDepth * 3;
+                           if (target >= 0 && parser.getGoto(this.stack[target], term, false) >= 0)
+                               return (rDepth << 19 /* Action.ReduceDepthShift */) | 65536 /* Action.ReduceFlag */ | term;
+                       }
+                   }
+                   else {
+                       let found = explore(action, depth + 1);
+                       if (found != null)
+                           return found;
+                   }
+               });
+           };
+           return explore(this.state, 0);
+       }
+       /**
+       @internal
+       */
+       forceAll() {
+           while (!this.p.parser.stateFlag(this.state, 2 /* StateFlag.Accepting */)) {
+               if (!this.forceReduce()) {
+                   this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
+                   break;
+               }
+           }
+           return this;
+       }
+       /**
+       Check whether this state has no further actions (assumed to be a direct descendant of the
+       top state, since any other states must be able to continue
+       somehow). @internal
+       */
+       get deadEnd() {
+           if (this.stack.length != 3)
+               return false;
+           let { parser } = this.p;
+           return parser.data[parser.stateSlot(this.state, 1 /* ParseState.Actions */)] == 65535 /* Seq.End */ &&
+               !parser.stateSlot(this.state, 4 /* ParseState.DefaultReduce */);
+       }
+       /**
+       Restart the stack (put it back in its start state). Only safe
+       when this.stack.length == 3 (state is directly below the top
+       state). @internal
+       */
+       restart() {
+           this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
+           this.state = this.stack[0];
+           this.stack.length = 0;
+       }
+       /**
+       @internal
+       */
+       sameState(other) {
+           if (this.state != other.state || this.stack.length != other.stack.length)
+               return false;
+           for (let i = 0; i < this.stack.length; i += 3)
+               if (this.stack[i] != other.stack[i])
+                   return false;
+           return true;
+       }
+       /**
+       Get the parser used by this stack.
+       */
+       get parser() { return this.p.parser; }
+       /**
+       Test whether a given dialect (by numeric ID, as exported from
+       the terms file) is enabled.
+       */
+       dialectEnabled(dialectID) { return this.p.parser.dialect.flags[dialectID]; }
+       shiftContext(term, start) {
+           if (this.curContext)
+               this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
+       }
+       reduceContext(term, start) {
+           if (this.curContext)
+               this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
+       }
+       /**
+       @internal
+       */
+       emitContext() {
+           let last = this.buffer.length - 1;
+           if (last < 0 || this.buffer[last] != -3)
+               this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
+       }
+       /**
+       @internal
+       */
+       emitLookAhead() {
+           let last = this.buffer.length - 1;
+           if (last < 0 || this.buffer[last] != -4)
+               this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
+       }
+       updateContext(context) {
+           if (context != this.curContext.context) {
+               let newCx = new StackContext(this.curContext.tracker, context);
+               if (newCx.hash != this.curContext.hash)
+                   this.emitContext();
+               this.curContext = newCx;
+           }
+       }
+       /**
+       @internal
+       */
+       setLookAhead(lookAhead) {
+           if (lookAhead > this.lookAhead) {
+               this.emitLookAhead();
+               this.lookAhead = lookAhead;
+           }
+       }
+       /**
+       @internal
+       */
+       close() {
+           if (this.curContext && this.curContext.tracker.strict)
+               this.emitContext();
+           if (this.lookAhead > 0)
+               this.emitLookAhead();
+       }
+   }
+   class StackContext {
+       constructor(tracker, context) {
+           this.tracker = tracker;
+           this.context = context;
+           this.hash = tracker.strict ? tracker.hash(context) : 0;
+       }
+   }
+   // Used to cheaply run some reductions to scan ahead without mutating
+   // an entire stack
+   class SimulatedStack {
+       constructor(start) {
+           this.start = start;
+           this.state = start.state;
+           this.stack = start.stack;
+           this.base = this.stack.length;
+       }
+       reduce(action) {
+           let term = action & 65535 /* Action.ValueMask */, depth = action >> 19 /* Action.ReduceDepthShift */;
+           if (depth == 0) {
+               if (this.stack == this.start.stack)
+                   this.stack = this.stack.slice();
+               this.stack.push(this.state, 0, 0);
+               this.base += 3;
+           }
+           else {
+               this.base -= (depth - 1) * 3;
+           }
+           let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
+           this.state = goto;
+       }
+   }
+   // This is given to `Tree.build` to build a buffer, and encapsulates
+   // the parent-stack-walking necessary to read the nodes.
+   class StackBufferCursor {
+       constructor(stack, pos, index) {
+           this.stack = stack;
+           this.pos = pos;
+           this.index = index;
+           this.buffer = stack.buffer;
+           if (this.index == 0)
+               this.maybeNext();
+       }
+       static create(stack, pos = stack.bufferBase + stack.buffer.length) {
+           return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
+       }
+       maybeNext() {
+           let next = this.stack.parent;
+           if (next != null) {
+               this.index = this.stack.bufferBase - next.bufferBase;
+               this.stack = next;
+               this.buffer = next.buffer;
+           }
+       }
+       get id() { return this.buffer[this.index - 4]; }
+       get start() { return this.buffer[this.index - 3]; }
+       get end() { return this.buffer[this.index - 2]; }
+       get size() { return this.buffer[this.index - 1]; }
+       next() {
+           this.index -= 4;
+           this.pos -= 4;
+           if (this.index == 0)
+               this.maybeNext();
+       }
+       fork() {
+           return new StackBufferCursor(this.stack, this.pos, this.index);
+       }
+   }
+
+   // See lezer-generator/src/encode.ts for comments about the encoding
+   // used here
+   function decodeArray(input, Type = Uint16Array) {
+       if (typeof input != "string")
+           return input;
+       let array = null;
+       for (let pos = 0, out = 0; pos < input.length;) {
+           let value = 0;
+           for (;;) {
+               let next = input.charCodeAt(pos++), stop = false;
+               if (next == 126 /* Encode.BigValCode */) {
+                   value = 65535 /* Encode.BigVal */;
+                   break;
+               }
+               if (next >= 92 /* Encode.Gap2 */)
+                   next--;
+               if (next >= 34 /* Encode.Gap1 */)
+                   next--;
+               let digit = next - 32 /* Encode.Start */;
+               if (digit >= 46 /* Encode.Base */) {
+                   digit -= 46 /* Encode.Base */;
+                   stop = true;
+               }
+               value += digit;
+               if (stop)
+                   break;
+               value *= 46 /* Encode.Base */;
+           }
+           if (array)
+               array[out++] = value;
+           else
+               array = new Type(value);
+       }
+       return array;
+   }
+
+   class CachedToken {
+       constructor() {
+           this.start = -1;
+           this.value = -1;
+           this.end = -1;
+           this.extended = -1;
+           this.lookAhead = 0;
+           this.mask = 0;
+           this.context = 0;
+       }
+   }
+   const nullToken = new CachedToken;
+   /**
+   [Tokenizers](#lr.ExternalTokenizer) interact with the input
+   through this interface. It presents the input as a stream of
+   characters, tracking lookahead and hiding the complexity of
+   [ranges](#common.Parser.parse^ranges) from tokenizer code.
+   */
+   class InputStream {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       @internal
+       */
+       input, 
+       /**
+       @internal
+       */
+       ranges) {
+           this.input = input;
+           this.ranges = ranges;
+           /**
+           @internal
+           */
+           this.chunk = "";
+           /**
+           @internal
+           */
+           this.chunkOff = 0;
+           /**
+           Backup chunk
+           */
+           this.chunk2 = "";
+           this.chunk2Pos = 0;
+           /**
+           The character code of the next code unit in the input, or -1
+           when the stream is at the end of the input.
+           */
+           this.next = -1;
+           /**
+           @internal
+           */
+           this.token = nullToken;
+           this.rangeIndex = 0;
+           this.pos = this.chunkPos = ranges[0].from;
+           this.range = ranges[0];
+           this.end = ranges[ranges.length - 1].to;
+           this.readNext();
+       }
+       /**
+       @internal
+       */
+       resolveOffset(offset, assoc) {
+           let range = this.range, index = this.rangeIndex;
+           let pos = this.pos + offset;
+           while (pos < range.from) {
+               if (!index)
+                   return null;
+               let next = this.ranges[--index];
+               pos -= range.from - next.to;
+               range = next;
+           }
+           while (assoc < 0 ? pos > range.to : pos >= range.to) {
+               if (index == this.ranges.length - 1)
+                   return null;
+               let next = this.ranges[++index];
+               pos += next.from - range.to;
+               range = next;
+           }
+           return pos;
+       }
+       /**
+       @internal
+       */
+       clipPos(pos) {
+           if (pos >= this.range.from && pos < this.range.to)
+               return pos;
+           for (let range of this.ranges)
+               if (range.to > pos)
+                   return Math.max(pos, range.from);
+           return this.end;
+       }
+       /**
+       Look at a code unit near the stream position. `.peek(0)` equals
+       `.next`, `.peek(-1)` gives you the previous character, and so
+       on.
+       
+       Note that looking around during tokenizing creates dependencies
+       on potentially far-away content, which may reduce the
+       effectiveness incremental parsing—when looking forward—or even
+       cause invalid reparses when looking backward more than 25 code
+       units, since the library does not track lookbehind.
+       */
+       peek(offset) {
+           let idx = this.chunkOff + offset, pos, result;
+           if (idx >= 0 && idx < this.chunk.length) {
+               pos = this.pos + offset;
+               result = this.chunk.charCodeAt(idx);
+           }
+           else {
+               let resolved = this.resolveOffset(offset, 1);
+               if (resolved == null)
+                   return -1;
+               pos = resolved;
+               if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
+                   result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
+               }
+               else {
+                   let i = this.rangeIndex, range = this.range;
+                   while (range.to <= pos)
+                       range = this.ranges[++i];
+                   this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
+                   if (pos + this.chunk2.length > range.to)
+                       this.chunk2 = this.chunk2.slice(0, range.to - pos);
+                   result = this.chunk2.charCodeAt(0);
+               }
+           }
+           if (pos >= this.token.lookAhead)
+               this.token.lookAhead = pos + 1;
+           return result;
+       }
+       /**
+       Accept a token. By default, the end of the token is set to the
+       current stream position, but you can pass an offset (relative to
+       the stream position) to change that.
+       */
+       acceptToken(token, endOffset = 0) {
+           let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
+           if (end == null || end < this.token.start)
+               throw new RangeError("Token end out of bounds");
+           this.token.value = token;
+           this.token.end = end;
+       }
+       /**
+       Accept a token ending at a specific given position.
+       */
+       acceptTokenTo(token, endPos) {
+           this.token.value = token;
+           this.token.end = endPos;
+       }
+       getChunk() {
+           if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
+               let { chunk, chunkPos } = this;
+               this.chunk = this.chunk2;
+               this.chunkPos = this.chunk2Pos;
+               this.chunk2 = chunk;
+               this.chunk2Pos = chunkPos;
+               this.chunkOff = this.pos - this.chunkPos;
+           }
+           else {
+               this.chunk2 = this.chunk;
+               this.chunk2Pos = this.chunkPos;
+               let nextChunk = this.input.chunk(this.pos);
+               let end = this.pos + nextChunk.length;
+               this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
+               this.chunkPos = this.pos;
+               this.chunkOff = 0;
+           }
+       }
+       readNext() {
+           if (this.chunkOff >= this.chunk.length) {
+               this.getChunk();
+               if (this.chunkOff == this.chunk.length)
+                   return this.next = -1;
+           }
+           return this.next = this.chunk.charCodeAt(this.chunkOff);
+       }
+       /**
+       Move the stream forward N (defaults to 1) code units. Returns
+       the new value of [`next`](#lr.InputStream.next).
+       */
+       advance(n = 1) {
+           this.chunkOff += n;
+           while (this.pos + n >= this.range.to) {
+               if (this.rangeIndex == this.ranges.length - 1)
+                   return this.setDone();
+               n -= this.range.to - this.pos;
+               this.range = this.ranges[++this.rangeIndex];
+               this.pos = this.range.from;
+           }
+           this.pos += n;
+           if (this.pos >= this.token.lookAhead)
+               this.token.lookAhead = this.pos + 1;
+           return this.readNext();
+       }
+       setDone() {
+           this.pos = this.chunkPos = this.end;
+           this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
+           this.chunk = "";
+           return this.next = -1;
+       }
+       /**
+       @internal
+       */
+       reset(pos, token) {
+           if (token) {
+               this.token = token;
+               token.start = pos;
+               token.lookAhead = pos + 1;
+               token.value = token.extended = -1;
+           }
+           else {
+               this.token = nullToken;
+           }
+           if (this.pos != pos) {
+               this.pos = pos;
+               if (pos == this.end) {
+                   this.setDone();
+                   return this;
+               }
+               while (pos < this.range.from)
+                   this.range = this.ranges[--this.rangeIndex];
+               while (pos >= this.range.to)
+                   this.range = this.ranges[++this.rangeIndex];
+               if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
+                   this.chunkOff = pos - this.chunkPos;
+               }
+               else {
+                   this.chunk = "";
+                   this.chunkOff = 0;
+               }
+               this.readNext();
+           }
+           return this;
+       }
+       /**
+       @internal
+       */
+       read(from, to) {
+           if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
+               return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
+           if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
+               return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
+           if (from >= this.range.from && to <= this.range.to)
+               return this.input.read(from, to);
+           let result = "";
+           for (let r of this.ranges) {
+               if (r.from >= to)
+                   break;
+               if (r.to > from)
+                   result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
+           }
+           return result;
+       }
+   }
+   /**
+   @internal
+   */
+   class TokenGroup {
+       constructor(data, id) {
+           this.data = data;
+           this.id = id;
+       }
+       token(input, stack) {
+           let { parser } = stack.p;
+           readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable);
+       }
+   }
+   TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
+   /**
+   @hide
+   */
+   class LocalTokenGroup {
+       constructor(data, precTable, elseToken) {
+           this.precTable = precTable;
+           this.elseToken = elseToken;
+           this.data = typeof data == "string" ? decodeArray(data) : data;
+       }
+       token(input, stack) {
+           let start = input.pos, skipped = 0;
+           for (;;) {
+               let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
+               readToken(this.data, input, stack, 0, this.data, this.precTable);
+               if (input.token.value > -1)
+                   break;
+               if (this.elseToken == null)
+                   return;
+               if (!atEof)
+                   skipped++;
+               if (nextPos == null)
+                   break;
+               input.reset(nextPos, input.token);
+           }
+           if (skipped) {
+               input.reset(start, input.token);
+               input.acceptToken(this.elseToken, skipped);
+           }
+       }
+   }
+   LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
+   /**
+   `@external tokens` declarations in the grammar should resolve to
+   an instance of this class.
+   */
+   class ExternalTokenizer {
+       /**
+       Create a tokenizer. The first argument is the function that,
+       given an input stream, scans for the types of tokens it
+       recognizes at the stream's position, and calls
+       [`acceptToken`](#lr.InputStream.acceptToken) when it finds
+       one.
+       */
+       constructor(
+       /**
+       @internal
+       */
+       token, options = {}) {
+           this.token = token;
+           this.contextual = !!options.contextual;
+           this.fallback = !!options.fallback;
+           this.extend = !!options.extend;
+       }
+   }
+   // Tokenizer data is stored a big uint16 array containing, for each
+   // state:
+   //
+   //  - A group bitmask, indicating what token groups are reachable from
+   //    this state, so that paths that can only lead to tokens not in
+   //    any of the current groups can be cut off early.
+   //
+   //  - The position of the end of the state's sequence of accepting
+   //    tokens
+   //
+   //  - The number of outgoing edges for the state
+   //
+   //  - The accepting tokens, as (token id, group mask) pairs
+   //
+   //  - The outgoing edges, as (start character, end character, state
+   //    index) triples, with end character being exclusive
+   //
+   // This function interprets that data, running through a stream as
+   // long as new states with the a matching group mask can be reached,
+   // and updating `input.token` when it matches a token.
+   function readToken(data, input, stack, group, precTable, precOffset) {
+       let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
+       scan: for (;;) {
+           if ((groupMask & data[state]) == 0)
+               break;
+           let accEnd = data[state + 1];
+           // Check whether this state can lead to a token in the current group
+           // Accept tokens in this state, possibly overwriting
+           // lower-precedence / shorter tokens
+           for (let i = state + 3; i < accEnd; i += 2)
+               if ((data[i + 1] & groupMask) > 0) {
+                   let term = data[i];
+                   if (dialect.allows(term) &&
+                       (input.token.value == -1 || input.token.value == term ||
+                           overrides(term, input.token.value, precTable, precOffset))) {
+                       input.acceptToken(term);
+                       break;
+                   }
+               }
+           let next = input.next, low = 0, high = data[state + 2];
+           // Special case for EOF
+           if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 /* Seq.End */) {
+               state = data[accEnd + high * 3 - 1];
+               continue scan;
+           }
+           // Do a binary search on the state's edges
+           for (; low < high;) {
+               let mid = (low + high) >> 1;
+               let index = accEnd + mid + (mid << 1);
+               let from = data[index], to = data[index + 1] || 0x10000;
+               if (next < from)
+                   high = mid;
+               else if (next >= to)
+                   low = mid + 1;
+               else {
+                   state = data[index + 2];
+                   input.advance();
+                   continue scan;
+               }
+           }
+           break;
+       }
+   }
+   function findOffset(data, start, term) {
+       for (let i = start, next; (next = data[i]) != 65535 /* Seq.End */; i++)
+           if (next == term)
+               return i - start;
+       return -1;
+   }
+   function overrides(token, prev, tableData, tableOffset) {
+       let iPrev = findOffset(tableData, tableOffset, prev);
+       return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
+   }
+
+   // Environment variable used to control console output
+   const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
+   let stackIDs = null;
+   function cutAt(tree, pos, side) {
+       let cursor = tree.cursor(IterMode.IncludeAnonymous);
+       cursor.moveTo(pos);
+       for (;;) {
+           if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
+               for (;;) {
+                   if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
+                       return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25 /* Lookahead.Margin */))
+                           : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25 /* Lookahead.Margin */));
+                   if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
+                       break;
+                   if (!cursor.parent())
+                       return side < 0 ? 0 : tree.length;
+               }
+       }
+   }
+   class FragmentCursor {
+       constructor(fragments, nodeSet) {
+           this.fragments = fragments;
+           this.nodeSet = nodeSet;
+           this.i = 0;
+           this.fragment = null;
+           this.safeFrom = -1;
+           this.safeTo = -1;
+           this.trees = [];
+           this.start = [];
+           this.index = [];
+           this.nextFragment();
+       }
+       nextFragment() {
+           let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
+           if (fr) {
+               this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
+               this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
+               while (this.trees.length) {
+                   this.trees.pop();
+                   this.start.pop();
+                   this.index.pop();
+               }
+               this.trees.push(fr.tree);
+               this.start.push(-fr.offset);
+               this.index.push(0);
+               this.nextStart = this.safeFrom;
+           }
+           else {
+               this.nextStart = 1e9;
+           }
+       }
+       // `pos` must be >= any previously given `pos` for this cursor
+       nodeAt(pos) {
+           if (pos < this.nextStart)
+               return null;
+           while (this.fragment && this.safeTo <= pos)
+               this.nextFragment();
+           if (!this.fragment)
+               return null;
+           for (;;) {
+               let last = this.trees.length - 1;
+               if (last < 0) { // End of tree
+                   this.nextFragment();
+                   return null;
+               }
+               let top = this.trees[last], index = this.index[last];
+               if (index == top.children.length) {
+                   this.trees.pop();
+                   this.start.pop();
+                   this.index.pop();
+                   continue;
+               }
+               let next = top.children[index];
+               let start = this.start[last] + top.positions[index];
+               if (start > pos) {
+                   this.nextStart = start;
+                   return null;
+               }
+               if (next instanceof Tree) {
+                   if (start == pos) {
+                       if (start < this.safeFrom)
+                           return null;
+                       let end = start + next.length;
+                       if (end <= this.safeTo) {
+                           let lookAhead = next.prop(NodeProp.lookAhead);
+                           if (!lookAhead || end + lookAhead < this.fragment.to)
+                               return next;
+                       }
+                   }
+                   this.index[last]++;
+                   if (start + next.length >= Math.max(this.safeFrom, pos)) { // Enter this node
+                       this.trees.push(next);
+                       this.start.push(start);
+                       this.index.push(0);
+                   }
+               }
+               else {
+                   this.index[last]++;
+                   this.nextStart = start + next.length;
+               }
+           }
+       }
+   }
+   class TokenCache {
+       constructor(parser, stream) {
+           this.stream = stream;
+           this.tokens = [];
+           this.mainToken = null;
+           this.actions = [];
+           this.tokens = parser.tokenizers.map(_ => new CachedToken);
+       }
+       getActions(stack) {
+           let actionIndex = 0;
+           let main = null;
+           let { parser } = stack.p, { tokenizers } = parser;
+           let mask = parser.stateSlot(stack.state, 3 /* ParseState.TokenizerMask */);
+           let context = stack.curContext ? stack.curContext.hash : 0;
+           let lookAhead = 0;
+           for (let i = 0; i < tokenizers.length; i++) {
+               if (((1 << i) & mask) == 0)
+                   continue;
+               let tokenizer = tokenizers[i], token = this.tokens[i];
+               if (main && !tokenizer.fallback)
+                   continue;
+               if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
+                   this.updateCachedToken(token, tokenizer, stack);
+                   token.mask = mask;
+                   token.context = context;
+               }
+               if (token.lookAhead > token.end + 25 /* Lookahead.Margin */)
+                   lookAhead = Math.max(token.lookAhead, lookAhead);
+               if (token.value != 0 /* Term.Err */) {
+                   let startIndex = actionIndex;
+                   if (token.extended > -1)
+                       actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
+                   actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
+                   if (!tokenizer.extend) {
+                       main = token;
+                       if (actionIndex > startIndex)
+                           break;
+                   }
+               }
+           }
+           while (this.actions.length > actionIndex)
+               this.actions.pop();
+           if (lookAhead)
+               stack.setLookAhead(lookAhead);
+           if (!main && stack.pos == this.stream.end) {
+               main = new CachedToken;
+               main.value = stack.p.parser.eofTerm;
+               main.start = main.end = stack.pos;
+               actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
+           }
+           this.mainToken = main;
+           return this.actions;
+       }
+       getMainToken(stack) {
+           if (this.mainToken)
+               return this.mainToken;
+           let main = new CachedToken, { pos, p } = stack;
+           main.start = pos;
+           main.end = Math.min(pos + 1, p.stream.end);
+           main.value = pos == p.stream.end ? p.parser.eofTerm : 0 /* Term.Err */;
+           return main;
+       }
+       updateCachedToken(token, tokenizer, stack) {
+           let start = this.stream.clipPos(stack.pos);
+           tokenizer.token(this.stream.reset(start, token), stack);
+           if (token.value > -1) {
+               let { parser } = stack.p;
+               for (let i = 0; i < parser.specialized.length; i++)
+                   if (parser.specialized[i] == token.value) {
+                       let result = parser.specializers[i](this.stream.read(token.start, token.end), stack);
+                       if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
+                           if ((result & 1) == 0 /* Specialize.Specialize */)
+                               token.value = result >> 1;
+                           else
+                               token.extended = result >> 1;
+                           break;
+                       }
+                   }
+           }
+           else {
+               token.value = 0 /* Term.Err */;
+               token.end = this.stream.clipPos(start + 1);
+           }
+       }
+       putAction(action, token, end, index) {
+           // Don't add duplicate actions
+           for (let i = 0; i < index; i += 3)
+               if (this.actions[i] == action)
+                   return index;
+           this.actions[index++] = action;
+           this.actions[index++] = token;
+           this.actions[index++] = end;
+           return index;
+       }
+       addActions(stack, token, end, index) {
+           let { state } = stack, { parser } = stack.p, { data } = parser;
+           for (let set = 0; set < 2; set++) {
+               for (let i = parser.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */);; i += 3) {
+                   if (data[i] == 65535 /* Seq.End */) {
+                       if (data[i + 1] == 1 /* Seq.Next */) {
+                           i = pair(data, i + 2);
+                       }
+                       else {
+                           if (index == 0 && data[i + 1] == 2 /* Seq.Other */)
+                               index = this.putAction(pair(data, i + 2), token, end, index);
+                           break;
+                       }
+                   }
+                   if (data[i] == token)
+                       index = this.putAction(pair(data, i + 1), token, end, index);
+               }
+           }
+           return index;
+       }
+   }
+   class Parse {
+       constructor(parser, input, fragments, ranges) {
+           this.parser = parser;
+           this.input = input;
+           this.ranges = ranges;
+           this.recovering = 0;
+           this.nextStackID = 0x2654; // ♔, ♕, ♖, ♗, ♘, ♙, ♠, ♡, ♢, ♣, ♤, ♥, ♦, ♧
+           this.minStackPos = 0;
+           this.reused = [];
+           this.stoppedAt = null;
+           this.lastBigReductionStart = -1;
+           this.lastBigReductionSize = 0;
+           this.bigReductionCount = 0;
+           this.stream = new InputStream(input, ranges);
+           this.tokens = new TokenCache(parser, this.stream);
+           this.topTerm = parser.top[1];
+           let { from } = ranges[0];
+           this.stacks = [Stack.start(this, parser.top[0], from)];
+           this.fragments = fragments.length && this.stream.end - from > parser.bufferLength * 4
+               ? new FragmentCursor(fragments, parser.nodeSet) : null;
+       }
+       get parsedPos() {
+           return this.minStackPos;
+       }
+       // Move the parser forward. This will process all parse stacks at
+       // `this.pos` and try to advance them to a further position. If no
+       // stack for such a position is found, it'll start error-recovery.
+       //
+       // When the parse is finished, this will return a syntax tree. When
+       // not, it returns `null`.
+       advance() {
+           let stacks = this.stacks, pos = this.minStackPos;
+           // This will hold stacks beyond `pos`.
+           let newStacks = this.stacks = [];
+           let stopped, stoppedTokens;
+           // If a large amount of reductions happened with the same start
+           // position, force the stack out of that production in order to
+           // avoid creating a tree too deep to recurse through.
+           // (This is an ugly kludge, because unfortunately there is no
+           // straightforward, cheap way to check for this happening, due to
+           // the history of reductions only being available in an
+           // expensive-to-access format in the stack buffers.)
+           if (this.bigReductionCount > 300 /* Rec.MaxLeftAssociativeReductionCount */ && stacks.length == 1) {
+               let [s] = stacks;
+               while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) { }
+               this.bigReductionCount = this.lastBigReductionSize = 0;
+           }
+           // Keep advancing any stacks at `pos` until they either move
+           // forward or can't be advanced. Gather stacks that can't be
+           // advanced further in `stopped`.
+           for (let i = 0; i < stacks.length; i++) {
+               let stack = stacks[i];
+               for (;;) {
+                   this.tokens.mainToken = null;
+                   if (stack.pos > pos) {
+                       newStacks.push(stack);
+                   }
+                   else if (this.advanceStack(stack, newStacks, stacks)) {
+                       continue;
+                   }
+                   else {
+                       if (!stopped) {
+                           stopped = [];
+                           stoppedTokens = [];
+                       }
+                       stopped.push(stack);
+                       let tok = this.tokens.getMainToken(stack);
+                       stoppedTokens.push(tok.value, tok.end);
+                   }
+                   break;
+               }
+           }
+           if (!newStacks.length) {
+               let finished = stopped && findFinished(stopped);
+               if (finished) {
+                   if (verbose)
+                       console.log("Finish with " + this.stackID(finished));
+                   return this.stackToTree(finished);
+               }
+               if (this.parser.strict) {
+                   if (verbose && stopped)
+                       console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
+                   throw new SyntaxError("No parse at " + pos);
+               }
+               if (!this.recovering)
+                   this.recovering = 5 /* Rec.Distance */;
+           }
+           if (this.recovering && stopped) {
+               let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0]
+                   : this.runRecovery(stopped, stoppedTokens, newStacks);
+               if (finished) {
+                   if (verbose)
+                       console.log("Force-finish " + this.stackID(finished));
+                   return this.stackToTree(finished.forceAll());
+               }
+           }
+           if (this.recovering) {
+               let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3 /* Rec.MaxRemainingPerStep */;
+               if (newStacks.length > maxRemaining) {
+                   newStacks.sort((a, b) => b.score - a.score);
+                   while (newStacks.length > maxRemaining)
+                       newStacks.pop();
+               }
+               if (newStacks.some(s => s.reducePos > pos))
+                   this.recovering--;
+           }
+           else if (newStacks.length > 1) {
+               // Prune stacks that are in the same state, or that have been
+               // running without splitting for a while, to avoid getting stuck
+               // with multiple successful stacks running endlessly on.
+               outer: for (let i = 0; i < newStacks.length - 1; i++) {
+                   let stack = newStacks[i];
+                   for (let j = i + 1; j < newStacks.length; j++) {
+                       let other = newStacks[j];
+                       if (stack.sameState(other) ||
+                           stack.buffer.length > 500 /* Rec.MinBufferLengthPrune */ && other.buffer.length > 500 /* Rec.MinBufferLengthPrune */) {
+                           if (((stack.score - other.score) || (stack.buffer.length - other.buffer.length)) > 0) {
+                               newStacks.splice(j--, 1);
+                           }
+                           else {
+                               newStacks.splice(i--, 1);
+                               continue outer;
+                           }
+                       }
+                   }
+               }
+               if (newStacks.length > 12 /* Rec.MaxStackCount */)
+                   newStacks.splice(12 /* Rec.MaxStackCount */, newStacks.length - 12 /* Rec.MaxStackCount */);
+           }
+           this.minStackPos = newStacks[0].pos;
+           for (let i = 1; i < newStacks.length; i++)
+               if (newStacks[i].pos < this.minStackPos)
+                   this.minStackPos = newStacks[i].pos;
+           return null;
+       }
+       stopAt(pos) {
+           if (this.stoppedAt != null && this.stoppedAt < pos)
+               throw new RangeError("Can't move stoppedAt forward");
+           this.stoppedAt = pos;
+       }
+       // Returns an updated version of the given stack, or null if the
+       // stack can't advance normally. When `split` and `stacks` are
+       // given, stacks split off by ambiguous operations will be pushed to
+       // `split`, or added to `stacks` if they move `pos` forward.
+       advanceStack(stack, stacks, split) {
+           let start = stack.pos, { parser } = this;
+           let base = verbose ? this.stackID(stack) + " -> " : "";
+           if (this.stoppedAt != null && start > this.stoppedAt)
+               return stack.forceReduce() ? stack : null;
+           if (this.fragments) {
+               let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
+               for (let cached = this.fragments.nodeAt(start); cached;) {
+                   let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser.getGoto(stack.state, cached.type.id) : -1;
+                   if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
+                       stack.useNode(cached, match);
+                       if (verbose)
+                           console.log(base + this.stackID(stack) + ` (via reuse of ${parser.getName(cached.type.id)})`);
+                       return true;
+                   }
+                   if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
+                       break;
+                   let inner = cached.children[0];
+                   if (inner instanceof Tree && cached.positions[0] == 0)
+                       cached = inner;
+                   else
+                       break;
+               }
+           }
+           let defaultReduce = parser.stateSlot(stack.state, 4 /* ParseState.DefaultReduce */);
+           if (defaultReduce > 0) {
+               stack.reduce(defaultReduce);
+               if (verbose)
+                   console.log(base + this.stackID(stack) + ` (via always-reduce ${parser.getName(defaultReduce & 65535 /* Action.ValueMask */)})`);
+               return true;
+           }
+           if (stack.stack.length >= 8400 /* Rec.CutDepth */) {
+               while (stack.stack.length > 6000 /* Rec.CutTo */ && stack.forceReduce()) { }
+           }
+           let actions = this.tokens.getActions(stack);
+           for (let i = 0; i < actions.length;) {
+               let action = actions[i++], term = actions[i++], end = actions[i++];
+               let last = i == actions.length || !split;
+               let localStack = last ? stack : stack.split();
+               let main = this.tokens.mainToken;
+               localStack.apply(action, term, main ? main.start : localStack.pos, end);
+               if (verbose)
+                   console.log(base + this.stackID(localStack) + ` (via ${(action & 65536 /* Action.ReduceFlag */) == 0 ? "shift"
+                    : `reduce of ${parser.getName(action & 65535 /* Action.ValueMask */)}`} for ${parser.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
+               if (last)
+                   return true;
+               else if (localStack.pos > start)
+                   stacks.push(localStack);
+               else
+                   split.push(localStack);
+           }
+           return false;
+       }
+       // Advance a given stack forward as far as it will go. Returns the
+       // (possibly updated) stack if it got stuck, or null if it moved
+       // forward and was given to `pushStackDedup`.
+       advanceFully(stack, newStacks) {
+           let pos = stack.pos;
+           for (;;) {
+               if (!this.advanceStack(stack, null, null))
+                   return false;
+               if (stack.pos > pos) {
+                   pushStackDedup(stack, newStacks);
+                   return true;
+               }
+           }
+       }
+       runRecovery(stacks, tokens, newStacks) {
+           let finished = null, restarted = false;
+           for (let i = 0; i < stacks.length; i++) {
+               let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
+               let base = verbose ? this.stackID(stack) + " -> " : "";
+               if (stack.deadEnd) {
+                   if (restarted)
+                       continue;
+                   restarted = true;
+                   stack.restart();
+                   if (verbose)
+                       console.log(base + this.stackID(stack) + " (restarted)");
+                   let done = this.advanceFully(stack, newStacks);
+                   if (done)
+                       continue;
+               }
+               let force = stack.split(), forceBase = base;
+               for (let j = 0; force.forceReduce() && j < 10 /* Rec.ForceReduceLimit */; j++) {
+                   if (verbose)
+                       console.log(forceBase + this.stackID(force) + " (via force-reduce)");
+                   let done = this.advanceFully(force, newStacks);
+                   if (done)
+                       break;
+                   if (verbose)
+                       forceBase = this.stackID(force) + " -> ";
+               }
+               for (let insert of stack.recoverByInsert(token)) {
+                   if (verbose)
+                       console.log(base + this.stackID(insert) + " (via recover-insert)");
+                   this.advanceFully(insert, newStacks);
+               }
+               if (this.stream.end > stack.pos) {
+                   if (tokenEnd == stack.pos) {
+                       tokenEnd++;
+                       token = 0 /* Term.Err */;
+                   }
+                   stack.recoverByDelete(token, tokenEnd);
+                   if (verbose)
+                       console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
+                   pushStackDedup(stack, newStacks);
+               }
+               else if (!finished || finished.score < stack.score) {
+                   finished = stack;
+               }
+           }
+           return finished;
+       }
+       // Convert the stack's buffer to a syntax tree.
+       stackToTree(stack) {
+           stack.close();
+           return Tree.build({ buffer: StackBufferCursor.create(stack),
+               nodeSet: this.parser.nodeSet,
+               topID: this.topTerm,
+               maxBufferLength: this.parser.bufferLength,
+               reused: this.reused,
+               start: this.ranges[0].from,
+               length: stack.pos - this.ranges[0].from,
+               minRepeatType: this.parser.minRepeatTerm });
+       }
+       stackID(stack) {
+           let id = (stackIDs || (stackIDs = new WeakMap)).get(stack);
+           if (!id)
+               stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
+           return id + stack;
+       }
+   }
+   function pushStackDedup(stack, newStacks) {
+       for (let i = 0; i < newStacks.length; i++) {
+           let other = newStacks[i];
+           if (other.pos == stack.pos && other.sameState(stack)) {
+               if (newStacks[i].score < stack.score)
+                   newStacks[i] = stack;
+               return;
+           }
+       }
+       newStacks.push(stack);
+   }
+   class Dialect {
+       constructor(source, flags, disabled) {
+           this.source = source;
+           this.flags = flags;
+           this.disabled = disabled;
+       }
+       allows(term) { return !this.disabled || this.disabled[term] == 0; }
+   }
+   const id = x => x;
+   /**
+   Context trackers are used to track stateful context (such as
+   indentation in the Python grammar, or parent elements in the XML
+   grammar) needed by external tokenizers. You declare them in a
+   grammar file as `@context exportName from "module"`.
+
+   Context values should be immutable, and can be updated (replaced)
+   on shift or reduce actions.
+
+   The export used in a `@context` declaration should be of this
+   type.
+   */
+   class ContextTracker {
+       /**
+       Define a context tracker.
+       */
+       constructor(spec) {
+           this.start = spec.start;
+           this.shift = spec.shift || id;
+           this.reduce = spec.reduce || id;
+           this.reuse = spec.reuse || id;
+           this.hash = spec.hash || (() => 0);
+           this.strict = spec.strict !== false;
+       }
+   }
+   /**
+   Holds the parse tables for a given grammar, as generated by
+   `lezer-generator`, and provides [methods](#common.Parser) to parse
+   content with.
+   */
+   class LRParser extends Parser {
+       /**
+       @internal
+       */
+       constructor(spec) {
+           super();
+           /**
+           @internal
+           */
+           this.wrappers = [];
+           if (spec.version != 14 /* File.Version */)
+               throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14 /* File.Version */})`);
+           let nodeNames = spec.nodeNames.split(" ");
+           this.minRepeatTerm = nodeNames.length;
+           for (let i = 0; i < spec.repeatNodeCount; i++)
+               nodeNames.push("");
+           let topTerms = Object.keys(spec.topRules).map(r => spec.topRules[r][1]);
+           let nodeProps = [];
+           for (let i = 0; i < nodeNames.length; i++)
+               nodeProps.push([]);
+           function setProp(nodeID, prop, value) {
+               nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
+           }
+           if (spec.nodeProps)
+               for (let propSpec of spec.nodeProps) {
+                   let prop = propSpec[0];
+                   if (typeof prop == "string")
+                       prop = NodeProp[prop];
+                   for (let i = 1; i < propSpec.length;) {
+                       let next = propSpec[i++];
+                       if (next >= 0) {
+                           setProp(next, prop, propSpec[i++]);
+                       }
+                       else {
+                           let value = propSpec[i + -next];
+                           for (let j = -next; j > 0; j--)
+                               setProp(propSpec[i++], prop, value);
+                           i++;
+                       }
+                   }
+               }
+           this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType.define({
+               name: i >= this.minRepeatTerm ? undefined : name,
+               id: i,
+               props: nodeProps[i],
+               top: topTerms.indexOf(i) > -1,
+               error: i == 0,
+               skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
+           })));
+           if (spec.propSources)
+               this.nodeSet = this.nodeSet.extend(...spec.propSources);
+           this.strict = false;
+           this.bufferLength = DefaultBufferLength;
+           let tokenArray = decodeArray(spec.tokenData);
+           this.context = spec.context;
+           this.specializerSpecs = spec.specialized || [];
+           this.specialized = new Uint16Array(this.specializerSpecs.length);
+           for (let i = 0; i < this.specializerSpecs.length; i++)
+               this.specialized[i] = this.specializerSpecs[i].term;
+           this.specializers = this.specializerSpecs.map(getSpecializer);
+           this.states = decodeArray(spec.states, Uint32Array);
+           this.data = decodeArray(spec.stateData);
+           this.goto = decodeArray(spec.goto);
+           this.maxTerm = spec.maxTerm;
+           this.tokenizers = spec.tokenizers.map(value => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
+           this.topRules = spec.topRules;
+           this.dialects = spec.dialects || {};
+           this.dynamicPrecedences = spec.dynamicPrecedences || null;
+           this.tokenPrecTable = spec.tokenPrec;
+           this.termNames = spec.termNames || null;
+           this.maxNode = this.nodeSet.types.length - 1;
+           this.dialect = this.parseDialect();
+           this.top = this.topRules[Object.keys(this.topRules)[0]];
+       }
+       createParse(input, fragments, ranges) {
+           let parse = new Parse(this, input, fragments, ranges);
+           for (let w of this.wrappers)
+               parse = w(parse, input, fragments, ranges);
+           return parse;
+       }
+       /**
+       Get a goto table entry @internal
+       */
+       getGoto(state, term, loose = false) {
+           let table = this.goto;
+           if (term >= table[0])
+               return -1;
+           for (let pos = table[term + 1];;) {
+               let groupTag = table[pos++], last = groupTag & 1;
+               let target = table[pos++];
+               if (last && loose)
+                   return target;
+               for (let end = pos + (groupTag >> 1); pos < end; pos++)
+                   if (table[pos] == state)
+                       return target;
+               if (last)
+                   return -1;
+           }
+       }
+       /**
+       Check if this state has an action for a given terminal @internal
+       */
+       hasAction(state, terminal) {
+           let data = this.data;
+           for (let set = 0; set < 2; set++) {
+               for (let i = this.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */), next;; i += 3) {
+                   if ((next = data[i]) == 65535 /* Seq.End */) {
+                       if (data[i + 1] == 1 /* Seq.Next */)
+                           next = data[i = pair(data, i + 2)];
+                       else if (data[i + 1] == 2 /* Seq.Other */)
+                           return pair(data, i + 2);
+                       else
+                           break;
+                   }
+                   if (next == terminal || next == 0 /* Term.Err */)
+                       return pair(data, i + 1);
+               }
+           }
+           return 0;
+       }
+       /**
+       @internal
+       */
+       stateSlot(state, slot) {
+           return this.states[(state * 6 /* ParseState.Size */) + slot];
+       }
+       /**
+       @internal
+       */
+       stateFlag(state, flag) {
+           return (this.stateSlot(state, 0 /* ParseState.Flags */) & flag) > 0;
+       }
+       /**
+       @internal
+       */
+       validAction(state, action) {
+           return !!this.allActions(state, a => a == action ? true : null);
+       }
+       /**
+       @internal
+       */
+       allActions(state, action) {
+           let deflt = this.stateSlot(state, 4 /* ParseState.DefaultReduce */);
+           let result = deflt ? action(deflt) : undefined;
+           for (let i = this.stateSlot(state, 1 /* ParseState.Actions */); result == null; i += 3) {
+               if (this.data[i] == 65535 /* Seq.End */) {
+                   if (this.data[i + 1] == 1 /* Seq.Next */)
+                       i = pair(this.data, i + 2);
+                   else
+                       break;
+               }
+               result = action(pair(this.data, i + 1));
+           }
+           return result;
+       }
+       /**
+       Get the states that can follow this one through shift actions or
+       goto jumps. @internal
+       */
+       nextStates(state) {
+           let result = [];
+           for (let i = this.stateSlot(state, 1 /* ParseState.Actions */);; i += 3) {
+               if (this.data[i] == 65535 /* Seq.End */) {
+                   if (this.data[i + 1] == 1 /* Seq.Next */)
+                       i = pair(this.data, i + 2);
+                   else
+                       break;
+               }
+               if ((this.data[i + 2] & (65536 /* Action.ReduceFlag */ >> 16)) == 0) {
+                   let value = this.data[i + 1];
+                   if (!result.some((v, i) => (i & 1) && v == value))
+                       result.push(this.data[i], value);
+               }
+           }
+           return result;
+       }
+       /**
+       Configure the parser. Returns a new parser instance that has the
+       given settings modified. Settings not provided in `config` are
+       kept from the original parser.
+       */
+       configure(config) {
+           // Hideous reflection-based kludge to make it easy to create a
+           // slightly modified copy of a parser.
+           let copy = Object.assign(Object.create(LRParser.prototype), this);
+           if (config.props)
+               copy.nodeSet = this.nodeSet.extend(...config.props);
+           if (config.top) {
+               let info = this.topRules[config.top];
+               if (!info)
+                   throw new RangeError(`Invalid top rule name ${config.top}`);
+               copy.top = info;
+           }
+           if (config.tokenizers)
+               copy.tokenizers = this.tokenizers.map(t => {
+                   let found = config.tokenizers.find(r => r.from == t);
+                   return found ? found.to : t;
+               });
+           if (config.specializers) {
+               copy.specializers = this.specializers.slice();
+               copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
+                   let found = config.specializers.find(r => r.from == s.external);
+                   if (!found)
+                       return s;
+                   let spec = Object.assign(Object.assign({}, s), { external: found.to });
+                   copy.specializers[i] = getSpecializer(spec);
+                   return spec;
+               });
+           }
+           if (config.contextTracker)
+               copy.context = config.contextTracker;
+           if (config.dialect)
+               copy.dialect = this.parseDialect(config.dialect);
+           if (config.strict != null)
+               copy.strict = config.strict;
+           if (config.wrap)
+               copy.wrappers = copy.wrappers.concat(config.wrap);
+           if (config.bufferLength != null)
+               copy.bufferLength = config.bufferLength;
+           return copy;
+       }
+       /**
+       Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
+       are registered for this parser.
+       */
+       hasWrappers() {
+           return this.wrappers.length > 0;
+       }
+       /**
+       Returns the name associated with a given term. This will only
+       work for all terms when the parser was generated with the
+       `--names` option. By default, only the names of tagged terms are
+       stored.
+       */
+       getName(term) {
+           return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
+       }
+       /**
+       The eof term id is always allocated directly after the node
+       types. @internal
+       */
+       get eofTerm() { return this.maxNode + 1; }
+       /**
+       The type of top node produced by the parser.
+       */
+       get topNode() { return this.nodeSet.types[this.top[1]]; }
+       /**
+       @internal
+       */
+       dynamicPrecedence(term) {
+           let prec = this.dynamicPrecedences;
+           return prec == null ? 0 : prec[term] || 0;
+       }
+       /**
+       @internal
+       */
+       parseDialect(dialect) {
+           let values = Object.keys(this.dialects), flags = values.map(() => false);
+           if (dialect)
+               for (let part of dialect.split(" ")) {
+                   let id = values.indexOf(part);
+                   if (id >= 0)
+                       flags[id] = true;
+               }
+           let disabled = null;
+           for (let i = 0; i < values.length; i++)
+               if (!flags[i]) {
+                   for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535 /* Seq.End */;)
+                       (disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
+               }
+           return new Dialect(dialect, flags, disabled);
+       }
+       /**
+       Used by the output of the parser generator. Not available to
+       user code. @hide
+       */
+       static deserialize(spec) {
+           return new LRParser(spec);
+       }
+   }
+   function pair(data, off) { return data[off] | (data[off + 1] << 16); }
+   function findFinished(stacks) {
+       let best = null;
+       for (let stack of stacks) {
+           let stopped = stack.p.stoppedAt;
+           if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) &&
+               stack.p.parser.stateFlag(stack.state, 2 /* StateFlag.Accepting */) &&
+               (!best || best.score < stack.score))
+               best = stack;
+       }
+       return best;
+   }
+   function getSpecializer(spec) {
+       if (spec.external) {
+           let mask = spec.extend ? 1 /* Specialize.Extend */ : 0 /* Specialize.Specialize */;
+           return (value, stack) => (spec.external(value, stack) << 1) | mask;
+       }
+       return spec.get;
+   }
+
+   let nextTagID = 0;
+   /**
+   Highlighting tags are markers that denote a highlighting category.
+   They are [associated](#highlight.styleTags) with parts of a syntax
+   tree by a language mode, and then mapped to an actual CSS style by
+   a [highlighter](#highlight.Highlighter).
+
+   Because syntax tree node types and highlight styles have to be
+   able to talk the same language, CodeMirror uses a mostly _closed_
+   [vocabulary](#highlight.tags) of syntax tags (as opposed to
+   traditional open string-based systems, which make it hard for
+   highlighting themes to cover all the tokens produced by the
+   various languages).
+
+   It _is_ possible to [define](#highlight.Tag^define) your own
+   highlighting tags for system-internal use (where you control both
+   the language package and the highlighter), but such tags will not
+   be picked up by regular highlighters (though you can derive them
+   from standard tags to allow highlighters to fall back to those).
+   */
+   class Tag {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The optional name of the base tag @internal
+       */
+       name, 
+       /**
+       The set of this tag and all its parent tags, starting with
+       this one itself and sorted in order of decreasing specificity.
+       */
+       set, 
+       /**
+       The base unmodified tag that this one is based on, if it's
+       modified @internal
+       */
+       base, 
+       /**
+       The modifiers applied to this.base @internal
+       */
+       modified) {
+           this.name = name;
+           this.set = set;
+           this.base = base;
+           this.modified = modified;
+           /**
+           @internal
+           */
+           this.id = nextTagID++;
+       }
+       toString() {
+           let { name } = this;
+           for (let mod of this.modified)
+               if (mod.name)
+                   name = `${mod.name}(${name})`;
+           return name;
+       }
+       static define(nameOrParent, parent) {
+           let name = typeof nameOrParent == "string" ? nameOrParent : "?";
+           if (nameOrParent instanceof Tag)
+               parent = nameOrParent;
+           if (parent === null || parent === void 0 ? void 0 : parent.base)
+               throw new Error("Can not derive from a modified tag");
+           let tag = new Tag(name, [], null, []);
+           tag.set.push(tag);
+           if (parent)
+               for (let t of parent.set)
+                   tag.set.push(t);
+           return tag;
+       }
+       /**
+       Define a tag _modifier_, which is a function that, given a tag,
+       will return a tag that is a subtag of the original. Applying the
+       same modifier to a twice tag will return the same value (`m1(t1)
+       == m1(t1)`) and applying multiple modifiers will, regardless or
+       order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
+       
+       When multiple modifiers are applied to a given base tag, each
+       smaller set of modifiers is registered as a parent, so that for
+       example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
+       `m1(m3(t1)`, and so on.
+       */
+       static defineModifier(name) {
+           let mod = new Modifier(name);
+           return (tag) => {
+               if (tag.modified.indexOf(mod) > -1)
+                   return tag;
+               return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
+           };
+       }
+   }
+   let nextModifierID = 0;
+   class Modifier {
+       constructor(name) {
+           this.name = name;
+           this.instances = [];
+           this.id = nextModifierID++;
+       }
+       static get(base, mods) {
+           if (!mods.length)
+               return base;
+           let exists = mods[0].instances.find(t => t.base == base && sameArray$1(mods, t.modified));
+           if (exists)
+               return exists;
+           let set = [], tag = new Tag(base.name, set, base, mods);
+           for (let m of mods)
+               m.instances.push(tag);
+           let configs = powerSet(mods);
+           for (let parent of base.set)
+               if (!parent.modified.length)
+                   for (let config of configs)
+                       set.push(Modifier.get(parent, config));
+           return tag;
+       }
+   }
+   function sameArray$1(a, b) {
+       return a.length == b.length && a.every((x, i) => x == b[i]);
+   }
+   function powerSet(array) {
+       let sets = [[]];
+       for (let i = 0; i < array.length; i++) {
+           for (let j = 0, e = sets.length; j < e; j++) {
+               sets.push(sets[j].concat(array[i]));
+           }
+       }
+       return sets.sort((a, b) => b.length - a.length);
+   }
+   /**
+   This function is used to add a set of tags to a language syntax
+   via [`NodeSet.extend`](#common.NodeSet.extend) or
+   [`LRParser.configure`](#lr.LRParser.configure).
+
+   The argument object maps node selectors to [highlighting
+   tags](#highlight.Tag) or arrays of tags.
+
+   Node selectors may hold one or more (space-separated) node paths.
+   Such a path can be a [node name](#common.NodeType.name), or
+   multiple node names (or `*` wildcards) separated by slash
+   characters, as in `"Block/Declaration/VariableName"`. Such a path
+   matches the final node but only if its direct parent nodes are the
+   other nodes mentioned. A `*` in such a path matches any parent,
+   but only a single level—wildcards that match multiple parents
+   aren't supported, both for efficiency reasons and because Lezer
+   trees make it rather hard to reason about what they would match.)
+
+   A path can be ended with `/...` to indicate that the tag assigned
+   to the node should also apply to all child nodes, even if they
+   match their own style (by default, only the innermost style is
+   used).
+
+   When a path ends in `!`, as in `Attribute!`, no further matching
+   happens for the node's child nodes, and the entire node gets the
+   given style.
+
+   In this notation, node names that contain `/`, `!`, `*`, or `...`
+   must be quoted as JSON strings.
+
+   For example:
+
+   ```javascript
+   parser.withProps(
+     styleTags({
+       // Style Number and BigNumber nodes
+       "Number BigNumber": tags.number,
+       // Style Escape nodes whose parent is String
+       "String/Escape": tags.escape,
+       // Style anything inside Attributes nodes
+       "Attributes!": tags.meta,
+       // Add a style to all content inside Italic nodes
+       "Italic/...": tags.emphasis,
+       // Style InvalidString nodes as both `string` and `invalid`
+       "InvalidString": [tags.string, tags.invalid],
+       // Style the node named "/" as punctuation
+       '"/"': tags.punctuation
+     })
+   )
+   ```
+   */
+   function styleTags(spec) {
+       let byName = Object.create(null);
+       for (let prop in spec) {
+           let tags = spec[prop];
+           if (!Array.isArray(tags))
+               tags = [tags];
+           for (let part of prop.split(" "))
+               if (part) {
+                   let pieces = [], mode = 2 /* Mode.Normal */, rest = part;
+                   for (let pos = 0;;) {
+                       if (rest == "..." && pos > 0 && pos + 3 == part.length) {
+                           mode = 1 /* Mode.Inherit */;
+                           break;
+                       }
+                       let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
+                       if (!m)
+                           throw new RangeError("Invalid path: " + part);
+                       pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
+                       pos += m[0].length;
+                       if (pos == part.length)
+                           break;
+                       let next = part[pos++];
+                       if (pos == part.length && next == "!") {
+                           mode = 0 /* Mode.Opaque */;
+                           break;
+                       }
+                       if (next != "/")
+                           throw new RangeError("Invalid path: " + part);
+                       rest = part.slice(pos);
+                   }
+                   let last = pieces.length - 1, inner = pieces[last];
+                   if (!inner)
+                       throw new RangeError("Invalid path: " + part);
+                   let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);
+                   byName[inner] = rule.sort(byName[inner]);
+               }
+       }
+       return ruleNodeProp.add(byName);
+   }
+   const ruleNodeProp = new NodeProp();
+   class Rule {
+       constructor(tags, mode, context, next) {
+           this.tags = tags;
+           this.mode = mode;
+           this.context = context;
+           this.next = next;
+       }
+       get opaque() { return this.mode == 0 /* Mode.Opaque */; }
+       get inherit() { return this.mode == 1 /* Mode.Inherit */; }
+       sort(other) {
+           if (!other || other.depth < this.depth) {
+               this.next = other;
+               return this;
+           }
+           other.next = this.sort(other.next);
+           return other;
+       }
+       get depth() { return this.context ? this.context.length : 0; }
+   }
+   Rule.empty = new Rule([], 2 /* Mode.Normal */, null);
+   /**
+   Define a [highlighter](#highlight.Highlighter) from an array of
+   tag/class pairs. Classes associated with more specific tags will
+   take precedence.
+   */
+   function tagHighlighter(tags, options) {
+       let map = Object.create(null);
+       for (let style of tags) {
+           if (!Array.isArray(style.tag))
+               map[style.tag.id] = style.class;
+           else
+               for (let tag of style.tag)
+                   map[tag.id] = style.class;
+       }
+       let { scope, all = null } = options || {};
+       return {
+           style: (tags) => {
+               let cls = all;
+               for (let tag of tags) {
+                   for (let sub of tag.set) {
+                       let tagClass = map[sub.id];
+                       if (tagClass) {
+                           cls = cls ? cls + " " + tagClass : tagClass;
+                           break;
+                       }
+                   }
+               }
+               return cls;
+           },
+           scope
+       };
+   }
+   function highlightTags(highlighters, tags) {
+       let result = null;
+       for (let highlighter of highlighters) {
+           let value = highlighter.style(tags);
+           if (value)
+               result = result ? result + " " + value : value;
+       }
+       return result;
+   }
+   /**
+   Highlight the given [tree](#common.Tree) with the given
+   [highlighter](#highlight.Highlighter). Often, the higher-level
+   [`highlightCode`](#highlight.highlightCode) function is easier to
+   use.
+   */
+   function highlightTree(tree, highlighter, 
+   /**
+   Assign styling to a region of the text. Will be called, in order
+   of position, for any ranges where more than zero classes apply.
+   `classes` is a space separated string of CSS classes.
+   */
+   putStyle, 
+   /**
+   The start of the range to highlight.
+   */
+   from = 0, 
+   /**
+   The end of the range.
+   */
+   to = tree.length) {
+       let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
+       builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
+       builder.flush(to);
+   }
+   class HighlightBuilder {
+       constructor(at, highlighters, span) {
+           this.at = at;
+           this.highlighters = highlighters;
+           this.span = span;
+           this.class = "";
+       }
+       startSpan(at, cls) {
+           if (cls != this.class) {
+               this.flush(at);
+               if (at > this.at)
+                   this.at = at;
+               this.class = cls;
+           }
+       }
+       flush(to) {
+           if (to > this.at && this.class)
+               this.span(this.at, to, this.class);
+       }
+       highlightRange(cursor, from, to, inheritedClass, highlighters) {
+           let { type, from: start, to: end } = cursor;
+           if (start >= to || end <= from)
+               return;
+           if (type.isTop)
+               highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
+           let cls = inheritedClass;
+           let rule = getStyleTags(cursor) || Rule.empty;
+           let tagCls = highlightTags(highlighters, rule.tags);
+           if (tagCls) {
+               if (cls)
+                   cls += " ";
+               cls += tagCls;
+               if (rule.mode == 1 /* Mode.Inherit */)
+                   inheritedClass += (inheritedClass ? " " : "") + tagCls;
+           }
+           this.startSpan(Math.max(from, start), cls);
+           if (rule.opaque)
+               return;
+           let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
+           if (mounted && mounted.overlay) {
+               let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
+               let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
+               let hasChild = cursor.firstChild();
+               for (let i = 0, pos = start;; i++) {
+                   let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
+                   let nextPos = next ? next.from + start : end;
+                   let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
+                   if (rangeFrom < rangeTo && hasChild) {
+                       while (cursor.from < rangeTo) {
+                           this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
+                           this.startSpan(Math.min(rangeTo, cursor.to), cls);
+                           if (cursor.to >= nextPos || !cursor.nextSibling())
+                               break;
+                       }
+                   }
+                   if (!next || nextPos > to)
+                       break;
+                   pos = next.to + start;
+                   if (pos > from) {
+                       this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters);
+                       this.startSpan(Math.min(to, pos), cls);
+                   }
+               }
+               if (hasChild)
+                   cursor.parent();
+           }
+           else if (cursor.firstChild()) {
+               if (mounted)
+                   inheritedClass = "";
+               do {
+                   if (cursor.to <= from)
+                       continue;
+                   if (cursor.from >= to)
+                       break;
+                   this.highlightRange(cursor, from, to, inheritedClass, highlighters);
+                   this.startSpan(Math.min(to, cursor.to), cls);
+               } while (cursor.nextSibling());
+               cursor.parent();
+           }
+       }
+   }
+   /**
+   Match a syntax node's [highlight rules](#highlight.styleTags). If
+   there's a match, return its set of tags, and whether it is
+   opaque (uses a `!`) or applies to all child nodes (`/...`).
+   */
+   function getStyleTags(node) {
+       let rule = node.type.prop(ruleNodeProp);
+       while (rule && rule.context && !node.matchContext(rule.context))
+           rule = rule.next;
+       return rule || null;
+   }
+   const t = Tag.define;
+   const comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();
+   /**
+   The default set of highlighting [tags](#highlight.Tag).
+
+   This collection is heavily biased towards programming languages,
+   and necessarily incomplete. A full ontology of syntactic
+   constructs would fill a stack of books, and be impractical to
+   write themes for. So try to make do with this set. If all else
+   fails, [open an
+   issue](https://github.com/codemirror/codemirror.next) to propose a
+   new tag, or [define](#highlight.Tag^define) a local custom tag for
+   your use case.
+
+   Note that it is not obligatory to always attach the most specific
+   tag possible to an element—if your grammar can't easily
+   distinguish a certain type of element (such as a local variable),
+   it is okay to style it as its more general variant (a variable).
+
+   For tags that extend some parent tag, the documentation links to
+   the parent.
+   */
+   const tags = {
+       /**
+       A comment.
+       */
+       comment,
+       /**
+       A line [comment](#highlight.tags.comment).
+       */
+       lineComment: t(comment),
+       /**
+       A block [comment](#highlight.tags.comment).
+       */
+       blockComment: t(comment),
+       /**
+       A documentation [comment](#highlight.tags.comment).
+       */
+       docComment: t(comment),
+       /**
+       Any kind of identifier.
+       */
+       name,
+       /**
+       The [name](#highlight.tags.name) of a variable.
+       */
+       variableName: t(name),
+       /**
+       A type [name](#highlight.tags.name).
+       */
+       typeName: typeName,
+       /**
+       A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
+       */
+       tagName: t(typeName),
+       /**
+       A property or field [name](#highlight.tags.name).
+       */
+       propertyName: propertyName,
+       /**
+       An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
+       */
+       attributeName: t(propertyName),
+       /**
+       The [name](#highlight.tags.name) of a class.
+       */
+       className: t(name),
+       /**
+       A label [name](#highlight.tags.name).
+       */
+       labelName: t(name),
+       /**
+       A namespace [name](#highlight.tags.name).
+       */
+       namespace: t(name),
+       /**
+       The [name](#highlight.tags.name) of a macro.
+       */
+       macroName: t(name),
+       /**
+       A literal value.
+       */
+       literal,
+       /**
+       A string [literal](#highlight.tags.literal).
+       */
+       string,
+       /**
+       A documentation [string](#highlight.tags.string).
+       */
+       docString: t(string),
+       /**
+       A character literal (subtag of [string](#highlight.tags.string)).
+       */
+       character: t(string),
+       /**
+       An attribute value (subtag of [string](#highlight.tags.string)).
+       */
+       attributeValue: t(string),
+       /**
+       A number [literal](#highlight.tags.literal).
+       */
+       number,
+       /**
+       An integer [number](#highlight.tags.number) literal.
+       */
+       integer: t(number),
+       /**
+       A floating-point [number](#highlight.tags.number) literal.
+       */
+       float: t(number),
+       /**
+       A boolean [literal](#highlight.tags.literal).
+       */
+       bool: t(literal),
+       /**
+       Regular expression [literal](#highlight.tags.literal).
+       */
+       regexp: t(literal),
+       /**
+       An escape [literal](#highlight.tags.literal), for example a
+       backslash escape in a string.
+       */
+       escape: t(literal),
+       /**
+       A color [literal](#highlight.tags.literal).
+       */
+       color: t(literal),
+       /**
+       A URL [literal](#highlight.tags.literal).
+       */
+       url: t(literal),
+       /**
+       A language keyword.
+       */
+       keyword,
+       /**
+       The [keyword](#highlight.tags.keyword) for the self or this
+       object.
+       */
+       self: t(keyword),
+       /**
+       The [keyword](#highlight.tags.keyword) for null.
+       */
+       null: t(keyword),
+       /**
+       A [keyword](#highlight.tags.keyword) denoting some atomic value.
+       */
+       atom: t(keyword),
+       /**
+       A [keyword](#highlight.tags.keyword) that represents a unit.
+       */
+       unit: t(keyword),
+       /**
+       A modifier [keyword](#highlight.tags.keyword).
+       */
+       modifier: t(keyword),
+       /**
+       A [keyword](#highlight.tags.keyword) that acts as an operator.
+       */
+       operatorKeyword: t(keyword),
+       /**
+       A control-flow related [keyword](#highlight.tags.keyword).
+       */
+       controlKeyword: t(keyword),
+       /**
+       A [keyword](#highlight.tags.keyword) that defines something.
+       */
+       definitionKeyword: t(keyword),
+       /**
+       A [keyword](#highlight.tags.keyword) related to defining or
+       interfacing with modules.
+       */
+       moduleKeyword: t(keyword),
+       /**
+       An operator.
+       */
+       operator,
+       /**
+       An [operator](#highlight.tags.operator) that dereferences something.
+       */
+       derefOperator: t(operator),
+       /**
+       Arithmetic-related [operator](#highlight.tags.operator).
+       */
+       arithmeticOperator: t(operator),
+       /**
+       Logical [operator](#highlight.tags.operator).
+       */
+       logicOperator: t(operator),
+       /**
+       Bit [operator](#highlight.tags.operator).
+       */
+       bitwiseOperator: t(operator),
+       /**
+       Comparison [operator](#highlight.tags.operator).
+       */
+       compareOperator: t(operator),
+       /**
+       [Operator](#highlight.tags.operator) that updates its operand.
+       */
+       updateOperator: t(operator),
+       /**
+       [Operator](#highlight.tags.operator) that defines something.
+       */
+       definitionOperator: t(operator),
+       /**
+       Type-related [operator](#highlight.tags.operator).
+       */
+       typeOperator: t(operator),
+       /**
+       Control-flow [operator](#highlight.tags.operator).
+       */
+       controlOperator: t(operator),
+       /**
+       Program or markup punctuation.
+       */
+       punctuation,
+       /**
+       [Punctuation](#highlight.tags.punctuation) that separates
+       things.
+       */
+       separator: t(punctuation),
+       /**
+       Bracket-style [punctuation](#highlight.tags.punctuation).
+       */
+       bracket,
+       /**
+       Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
+       tokens).
+       */
+       angleBracket: t(bracket),
+       /**
+       Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
+       tokens).
+       */
+       squareBracket: t(bracket),
+       /**
+       Parentheses (usually `(` and `)` tokens). Subtag of
+       [bracket](#highlight.tags.bracket).
+       */
+       paren: t(bracket),
+       /**
+       Braces (usually `{` and `}` tokens). Subtag of
+       [bracket](#highlight.tags.bracket).
+       */
+       brace: t(bracket),
+       /**
+       Content, for example plain text in XML or markup documents.
+       */
+       content,
+       /**
+       [Content](#highlight.tags.content) that represents a heading.
+       */
+       heading,
+       /**
+       A level 1 [heading](#highlight.tags.heading).
+       */
+       heading1: t(heading),
+       /**
+       A level 2 [heading](#highlight.tags.heading).
+       */
+       heading2: t(heading),
+       /**
+       A level 3 [heading](#highlight.tags.heading).
+       */
+       heading3: t(heading),
+       /**
+       A level 4 [heading](#highlight.tags.heading).
+       */
+       heading4: t(heading),
+       /**
+       A level 5 [heading](#highlight.tags.heading).
+       */
+       heading5: t(heading),
+       /**
+       A level 6 [heading](#highlight.tags.heading).
+       */
+       heading6: t(heading),
+       /**
+       A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
+       */
+       contentSeparator: t(content),
+       /**
+       [Content](#highlight.tags.content) that represents a list.
+       */
+       list: t(content),
+       /**
+       [Content](#highlight.tags.content) that represents a quote.
+       */
+       quote: t(content),
+       /**
+       [Content](#highlight.tags.content) that is emphasized.
+       */
+       emphasis: t(content),
+       /**
+       [Content](#highlight.tags.content) that is styled strong.
+       */
+       strong: t(content),
+       /**
+       [Content](#highlight.tags.content) that is part of a link.
+       */
+       link: t(content),
+       /**
+       [Content](#highlight.tags.content) that is styled as code or
+       monospace.
+       */
+       monospace: t(content),
+       /**
+       [Content](#highlight.tags.content) that has a strike-through
+       style.
+       */
+       strikethrough: t(content),
+       /**
+       Inserted text in a change-tracking format.
+       */
+       inserted: t(),
+       /**
+       Deleted text.
+       */
+       deleted: t(),
+       /**
+       Changed text.
+       */
+       changed: t(),
+       /**
+       An invalid or unsyntactic element.
+       */
+       invalid: t(),
+       /**
+       Metadata or meta-instruction.
+       */
+       meta,
+       /**
+       [Metadata](#highlight.tags.meta) that applies to the entire
+       document.
+       */
+       documentMeta: t(meta),
+       /**
+       [Metadata](#highlight.tags.meta) that annotates or adds
+       attributes to a given syntactic element.
+       */
+       annotation: t(meta),
+       /**
+       Processing instruction or preprocessor directive. Subtag of
+       [meta](#highlight.tags.meta).
+       */
+       processingInstruction: t(meta),
+       /**
+       [Modifier](#highlight.Tag^defineModifier) that indicates that a
+       given element is being defined. Expected to be used with the
+       various [name](#highlight.tags.name) tags.
+       */
+       definition: Tag.defineModifier("definition"),
+       /**
+       [Modifier](#highlight.Tag^defineModifier) that indicates that
+       something is constant. Mostly expected to be used with
+       [variable names](#highlight.tags.variableName).
+       */
+       constant: Tag.defineModifier("constant"),
+       /**
+       [Modifier](#highlight.Tag^defineModifier) used to indicate that
+       a [variable](#highlight.tags.variableName) or [property
+       name](#highlight.tags.propertyName) is being called or defined
+       as a function.
+       */
+       function: Tag.defineModifier("function"),
+       /**
+       [Modifier](#highlight.Tag^defineModifier) that can be applied to
+       [names](#highlight.tags.name) to indicate that they belong to
+       the language's standard environment.
+       */
+       standard: Tag.defineModifier("standard"),
+       /**
+       [Modifier](#highlight.Tag^defineModifier) that indicates a given
+       [names](#highlight.tags.name) is local to some scope.
+       */
+       local: Tag.defineModifier("local"),
+       /**
+       A generic variant [modifier](#highlight.Tag^defineModifier) that
+       can be used to tag language-specific alternative variants of
+       some common tag. It is recommended for themes to define special
+       forms of at least the [string](#highlight.tags.string) and
+       [variable name](#highlight.tags.variableName) tags, since those
+       come up a lot.
+       */
+       special: Tag.defineModifier("special")
+   };
+   for (let name in tags) {
+       let val = tags[name];
+       if (val instanceof Tag)
+           val.name = name;
+   }
+   /**
+   This is a highlighter that adds stable, predictable classes to
+   tokens, for styling with external CSS.
+
+   The following tags are mapped to their name prefixed with `"tok-"`
+   (for example `"tok-comment"`):
+
+   * [`link`](#highlight.tags.link)
+   * [`heading`](#highlight.tags.heading)
+   * [`emphasis`](#highlight.tags.emphasis)
+   * [`strong`](#highlight.tags.strong)
+   * [`keyword`](#highlight.tags.keyword)
+   * [`atom`](#highlight.tags.atom)
+   * [`bool`](#highlight.tags.bool)
+   * [`url`](#highlight.tags.url)
+   * [`labelName`](#highlight.tags.labelName)
+   * [`inserted`](#highlight.tags.inserted)
+   * [`deleted`](#highlight.tags.deleted)
+   * [`literal`](#highlight.tags.literal)
+   * [`string`](#highlight.tags.string)
+   * [`number`](#highlight.tags.number)
+   * [`variableName`](#highlight.tags.variableName)
+   * [`typeName`](#highlight.tags.typeName)
+   * [`namespace`](#highlight.tags.namespace)
+   * [`className`](#highlight.tags.className)
+   * [`macroName`](#highlight.tags.macroName)
+   * [`propertyName`](#highlight.tags.propertyName)
+   * [`operator`](#highlight.tags.operator)
+   * [`comment`](#highlight.tags.comment)
+   * [`meta`](#highlight.tags.meta)
+   * [`punctuation`](#highlight.tags.punctuation)
+   * [`invalid`](#highlight.tags.invalid)
+
+   In addition, these mappings are provided:
+
+   * [`regexp`](#highlight.tags.regexp),
+     [`escape`](#highlight.tags.escape), and
+     [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
+     are mapped to `"tok-string2"`
+   * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
+     to `"tok-variableName2"`
+   * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
+     to `"tok-variableName tok-local"`
+   * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
+     to `"tok-variableName tok-definition"`
+   * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
+     to `"tok-propertyName tok-definition"`
+   */
+   tagHighlighter([
+       { tag: tags.link, class: "tok-link" },
+       { tag: tags.heading, class: "tok-heading" },
+       { tag: tags.emphasis, class: "tok-emphasis" },
+       { tag: tags.strong, class: "tok-strong" },
+       { tag: tags.keyword, class: "tok-keyword" },
+       { tag: tags.atom, class: "tok-atom" },
+       { tag: tags.bool, class: "tok-bool" },
+       { tag: tags.url, class: "tok-url" },
+       { tag: tags.labelName, class: "tok-labelName" },
+       { tag: tags.inserted, class: "tok-inserted" },
+       { tag: tags.deleted, class: "tok-deleted" },
+       { tag: tags.literal, class: "tok-literal" },
+       { tag: tags.string, class: "tok-string" },
+       { tag: tags.number, class: "tok-number" },
+       { tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" },
+       { tag: tags.variableName, class: "tok-variableName" },
+       { tag: tags.local(tags.variableName), class: "tok-variableName tok-local" },
+       { tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" },
+       { tag: tags.special(tags.variableName), class: "tok-variableName2" },
+       { tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" },
+       { tag: tags.typeName, class: "tok-typeName" },
+       { tag: tags.namespace, class: "tok-namespace" },
+       { tag: tags.className, class: "tok-className" },
+       { tag: tags.macroName, class: "tok-macroName" },
+       { tag: tags.propertyName, class: "tok-propertyName" },
+       { tag: tags.operator, class: "tok-operator" },
+       { tag: tags.comment, class: "tok-comment" },
+       { tag: tags.meta, class: "tok-meta" },
+       { tag: tags.invalid, class: "tok-invalid" },
+       { tag: tags.punctuation, class: "tok-punctuation" }
+   ]);
+
+   // This file was generated by lezer-generator. You probably shouldn't edit it.
+   const noSemi = 314,
+     noSemiType = 315,
+     incdec = 1,
+     incdecPrefix = 2,
+     questionDot = 3,
+     JSXStartTag = 4,
+     insertSemi = 316,
+     spaces = 318,
+     newline = 319,
+     LineComment = 5,
+     BlockComment = 6,
+     Dialect_jsx = 0;
+
+   /* Hand-written tokenizers for JavaScript tokens that can't be
+      expressed by lezer's built-in tokenizer. */
+
+   const space = [9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200,
+                  8201, 8202, 8232, 8233, 8239, 8287, 12288];
+
+   const braceR = 125, semicolon = 59, slash = 47, star = 42, plus = 43, minus = 45, lt = 60, comma = 44,
+         question = 63, dot = 46, bracketL = 91;
+
+   const trackNewline = new ContextTracker({
+     start: false,
+     shift(context, term) {
+       return term == LineComment || term == BlockComment || term == spaces ? context : term == newline
+     },
+     strict: false
+   });
+
+   const insertSemicolon = new ExternalTokenizer((input, stack) => {
+     let {next} = input;
+     if (next == braceR || next == -1 || stack.context)
+       input.acceptToken(insertSemi);
+   }, {contextual: true, fallback: true});
+
+   const noSemicolon = new ExternalTokenizer((input, stack) => {
+     let {next} = input, after;
+     if (space.indexOf(next) > -1) return
+     if (next == slash && ((after = input.peek(1)) == slash || after == star)) return
+     if (next != braceR && next != semicolon && next != -1 && !stack.context)
+       input.acceptToken(noSemi);
+   }, {contextual: true});
+
+   const noSemicolonType = new ExternalTokenizer((input, stack) => {
+     if (input.next == bracketL && !stack.context) input.acceptToken(noSemiType);
+   }, {contextual: true});
+
+   const operatorToken = new ExternalTokenizer((input, stack) => {
+     let {next} = input;
+     if (next == plus || next == minus) {
+       input.advance();
+       if (next == input.next) {
+         input.advance();
+         let mayPostfix = !stack.context && stack.canShift(incdec);
+         input.acceptToken(mayPostfix ? incdec : incdecPrefix);
+       }
+     } else if (next == question && input.peek(1) == dot) {
+       input.advance(); input.advance();
+       if (input.next < 48 || input.next > 57) // No digit after
+         input.acceptToken(questionDot);
+     }
+   }, {contextual: true});
+
+   function identifierChar(ch, start) {
+     return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch == 95 || ch >= 192 ||
+       !start && ch >= 48 && ch <= 57
+   }
+
+   const jsx = new ExternalTokenizer((input, stack) => {
+     if (input.next != lt || !stack.dialectEnabled(Dialect_jsx)) return
+     input.advance();
+     if (input.next == slash) return
+     // Scan for an identifier followed by a comma or 'extends', don't
+     // treat this as a start tag if present.
+     let back = 0;
+     while (space.indexOf(input.next) > -1) { input.advance(); back++; }
+     if (identifierChar(input.next, true)) {
+       input.advance();
+       back++;
+       while (identifierChar(input.next, false)) { input.advance(); back++; }
+       while (space.indexOf(input.next) > -1) { input.advance(); back++; }
+       if (input.next == comma) return
+       for (let i = 0;; i++) {
+         if (i == 7) {
+           if (!identifierChar(input.next, true)) return
+           break
+         }
+         if (input.next != "extends".charCodeAt(i)) break
+         input.advance();
+         back++;
+       }
+     }
+     input.acceptToken(JSXStartTag, -back);
+   });
+
+   const jsHighlight = styleTags({
+     "get set async static": tags.modifier,
+     "for while do if else switch try catch finally return throw break continue default case": tags.controlKeyword,
+     "in of await yield void typeof delete instanceof": tags.operatorKeyword,
+     "let var const using function class extends": tags.definitionKeyword,
+     "import export from": tags.moduleKeyword,
+     "with debugger as new": tags.keyword,
+     TemplateString: tags.special(tags.string),
+     super: tags.atom,
+     BooleanLiteral: tags.bool,
+     this: tags.self,
+     null: tags.null,
+     Star: tags.modifier,
+     VariableName: tags.variableName,
+     "CallExpression/VariableName TaggedTemplateExpression/VariableName": tags.function(tags.variableName),
+     VariableDefinition: tags.definition(tags.variableName),
+     Label: tags.labelName,
+     PropertyName: tags.propertyName,
+     PrivatePropertyName: tags.special(tags.propertyName),
+     "CallExpression/MemberExpression/PropertyName": tags.function(tags.propertyName),
+     "FunctionDeclaration/VariableDefinition": tags.function(tags.definition(tags.variableName)),
+     "ClassDeclaration/VariableDefinition": tags.definition(tags.className),
+     "NewExpression/VariableName": tags.className,
+     PropertyDefinition: tags.definition(tags.propertyName),
+     PrivatePropertyDefinition: tags.definition(tags.special(tags.propertyName)),
+     UpdateOp: tags.updateOperator,
+     "LineComment Hashbang": tags.lineComment,
+     BlockComment: tags.blockComment,
+     Number: tags.number,
+     String: tags.string,
+     Escape: tags.escape,
+     ArithOp: tags.arithmeticOperator,
+     LogicOp: tags.logicOperator,
+     BitOp: tags.bitwiseOperator,
+     CompareOp: tags.compareOperator,
+     RegExp: tags.regexp,
+     Equals: tags.definitionOperator,
+     Arrow: tags.function(tags.punctuation),
+     ": Spread": tags.punctuation,
+     "( )": tags.paren,
+     "[ ]": tags.squareBracket,
+     "{ }": tags.brace,
+     "InterpolationStart InterpolationEnd": tags.special(tags.brace),
+     ".": tags.derefOperator,
+     ", ;": tags.separator,
+     "@": tags.meta,
+
+     TypeName: tags.typeName,
+     TypeDefinition: tags.definition(tags.typeName),
+     "type enum interface implements namespace module declare": tags.definitionKeyword,
+     "abstract global Privacy readonly override": tags.modifier,
+     "is keyof unique infer asserts": tags.operatorKeyword,
+
+     JSXAttributeValue: tags.attributeValue,
+     JSXText: tags.content,
+     "JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": tags.angleBracket,
+     "JSXIdentifier JSXNameSpacedName": tags.tagName,
+     "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName,
+     "JSXBuiltin/JSXIdentifier": tags.standard(tags.tagName)
+   });
+
+   // This file was generated by lezer-generator. You probably shouldn't edit it.
+   const spec_identifier = {__proto__:null,export:20, as:25, from:33, default:36, async:41, function:42, const:52, extends:56, this:60, true:68, false:68, null:80, void:84, typeof:88, super:104, new:138, delete:150, yield:159, await:163, class:168, public:231, private:231, protected:231, readonly:233, instanceof:252, satisfies:255, in:256, import:290, keyof:347, unique:351, infer:357, asserts:393, is:395, abstract:415, implements:417, type:419, let:422, var:424, using:427, interface:433, enum:437, namespace:443, module:445, declare:449, global:453, for:472, of:481, while:484, with:488, do:492, if:496, else:498, switch:502, case:508, try:514, catch:518, finally:522, return:526, throw:530, break:534, continue:538, debugger:542};
+   const spec_word = {__proto__:null,async:125, get:127, set:129, declare:191, public:193, private:193, protected:193, static:195, abstract:197, override:199, readonly:205, accessor:207, new:399};
+   const spec_LessThan = {__proto__:null,"<":189};
+   const parser = LRParser.deserialize({
+     version: 14,
+     states: "$EOQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#D_O.QQlO'#DeO.bQlO'#DpO%[QlO'#DxO0fQlO'#EQOOQ!0Lf'#EY'#EYO1PQ`O'#EVOOQO'#En'#EnOOQO'#Ij'#IjO1XQ`O'#GrO1dQ`O'#EmO1iQ`O'#EmO3hQ!0MxO'#JpO6[Q!0MxO'#JqO6uQ`O'#F[O6zQ,UO'#FsOOQ!0Lf'#Fe'#FeO7VO7dO'#FeO7eQMhO'#F{O9UQ`O'#FzOOQ!0Lf'#Jq'#JqOOQ!0Lb'#Jp'#JpO9ZQ`O'#GvOOQ['#K]'#K]O9fQ`O'#IWO9kQ!0LrO'#IXOOQ['#J^'#J^OOQ['#I]'#I]Q`QlOOQ`QlOOO9sQ!L^O'#DtO9zQlO'#D|O:RQlO'#EOO9aQ`O'#GrO:YQMhO'#CoO:hQ`O'#ElO:sQ`O'#EwO:xQMhO'#FdO;gQ`O'#GrOOQO'#K^'#K^O;lQ`O'#K^O;zQ`O'#GzO;zQ`O'#G{O;zQ`O'#G}O9aQ`O'#HQO<qQ`O'#HTO>YQ`O'#CeO>jQ`O'#HaO>rQ`O'#HgO>rQ`O'#HiO`QlO'#HkO>rQ`O'#HmO>rQ`O'#HpO>wQ`O'#HvO>|Q!0LsO'#H|O%[QlO'#IOO?XQ!0LsO'#IQO?dQ!0LsO'#ISO9kQ!0LrO'#IUO?oQ!0MxO'#CiO@qQpO'#DjQOQ`OOO%[QlO'#EOOAXQ`O'#ERO:YQMhO'#ElOAdQ`O'#ElOAoQ!bO'#FdOOQ['#Cg'#CgOOQ!0Lb'#Do'#DoOOQ!0Lb'#Jt'#JtO%[QlO'#JtOOQO'#Jw'#JwOOQO'#If'#IfOBoQpO'#EeOOQ!0Lb'#Ed'#EdOOQ!0Lb'#J{'#J{OCkQ!0MSO'#EeOCuQpO'#EUOOQO'#Jv'#JvODZQpO'#JwOEhQpO'#EUOCuQpO'#EePEuO&2DjO'#CbPOOO)CD{)CD{OOOO'#I^'#I^OFQO#tO,59UOOQ!0Lh,59U,59UOOOO'#I_'#I_OF`O&jO,59UOFnQ!L^O'#DaOOOO'#Ia'#IaOFuO#@ItO,59yOOQ!0Lf,59y,59yOGTQlO'#IbOGhQ`O'#JrOIgQ!fO'#JrO+}QlO'#JrOInQ`O,5:POJUQ`O'#EnOJcQ`O'#KROJnQ`O'#KQOJnQ`O'#KQOJvQ`O,5;[OJ{Q`O'#KPOOQ!0Ln,5:[,5:[OKSQlO,5:[OMQQ!0MxO,5:dOMqQ`O,5:lON[Q!0LrO'#KOONcQ`O'#J}O9ZQ`O'#J}ONwQ`O'#J}O! PQ`O,5;ZO! UQ`O'#J}O!#ZQ!fO'#JqOOQ!0Lh'#Ci'#CiO%[QlO'#EQO!#yQ!fO,5:qOOQS'#Jx'#JxOOQO-E<h-E<hO9aQ`O,5=^O!$aQ`O,5=^O!$fQlO,5;XO!&iQMhO'#EiO!(SQ`O,5;XO!(XQlO'#DwO!(cQpO,5;bO!(kQpO,5;bO%[QlO,5;bOOQ['#FS'#FSOOQ['#FU'#FUO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cOOQ['#FY'#FYO!(yQlO,5;sOOQ!0Lf,5;x,5;xOOQ!0Lf,5;y,5;yOOQ!0Lf,5;{,5;{O%[QlO'#InO!*|Q!0LrO,5<hO%[QlO,5;cO!&iQMhO,5;cO!+kQMhO,5;cO!-]QMhO'#E[O%[QlO,5;vOOQ!0Lf,5;z,5;zO!-dQ,UO'#FiO!.aQ,UO'#KVO!-{Q,UO'#KVO!.hQ,UO'#KVOOQO'#KV'#KVO!.|Q,UO,5<ROOOW,5<_,5<_O!/_QlO'#FuOOOW'#Im'#ImO7VO7dO,5<PO!/fQ,UO'#FwOOQ!0Lf,5<P,5<PO!0VQ$IUO'#CwOOQ!0Lh'#C{'#C{O!0jO#@ItO'#DPO!1WQMjO,5<dO!1_Q`O,5<gO!2zQ(CWO'#GWO!3XQ`O'#GXO!3^Q`O'#GXO!4|Q(CWO'#G]O!6RQpO'#GaOOQO'#Gm'#GmO!+rQMhO'#GlOOQO'#Go'#GoO!+rQMhO'#GnO!6tQ$IUO'#JjOOQ!0Lh'#Jj'#JjO!7OQ`O'#JiO!7^Q`O'#JhO!7fQ`O'#CuOOQ!0Lh'#Cy'#CyO!7qQ`O'#C{OOQ!0Lh'#DT'#DTOOQ!0Lh'#DV'#DVO1SQ`O'#DXO!+rQMhO'#GOO!+rQMhO'#GQO!7vQ`O'#GSO!7{Q`O'#GTO!3^Q`O'#GZO!+rQMhO'#G`O;zQ`O'#JiO!8QQ`O'#EoO!8oQ`O,5<fOOQ!0Lb'#Cr'#CrO!8wQ`O'#EpO!9qQpO'#EqOOQ!0Lb'#KP'#KPO!9xQ!0LrO'#K_O9kQ!0LrO,5=bO`QlO,5>rOOQ['#Jf'#JfOOQ[,5>s,5>sOOQ[-E<Z-E<ZO!;wQ!0MxO,5:`O!9lQpO,5:^O!>bQ!0MxO,5:hO%[QlO,5:hO!@xQ!0MxO,5:jOOQO,5@x,5@xO!AiQMhO,5=^O!AwQ!0LrO'#JgO9UQ`O'#JgO!BYQ!0LrO,59ZO!BeQpO,59ZO!BmQMhO,59ZO:YQMhO,59ZO!BxQ`O,5;XO!CQQ`O'#H`O!CfQ`O'#KbO%[QlO,5;|O!9lQpO,5<OO!CnQ`O,5=yO!CsQ`O,5=yO!CxQ`O,5=yO9kQ!0LrO,5=yO;zQ`O,5=iOOQO'#Cw'#CwO!DWQpO,5=fO!D`QMhO,5=gO!DkQ`O,5=iO!DpQ!bO,5=lO!DxQ`O'#K^O>wQ`O'#HVO9aQ`O'#HXO!D}Q`O'#HXO:YQMhO'#HZO!ESQ`O'#HZOOQ[,5=o,5=oO!EXQ`O'#H[O!EjQ`O'#CoO!EoQ`O,59PO!EyQ`O,59PO!HOQlO,59POOQ[,59P,59PO!H`Q!0LrO,59PO%[QlO,59PO!JkQlO'#HcOOQ['#Hd'#HdOOQ['#He'#HeO`QlO,5={O!KRQ`O,5={O`QlO,5>RO`QlO,5>TO!KWQ`O,5>VO`QlO,5>XO!K]Q`O,5>[O!KbQlO,5>bOOQ[,5>h,5>hO%[QlO,5>hO9kQ!0LrO,5>jOOQ[,5>l,5>lO# lQ`O,5>lOOQ[,5>n,5>nO# lQ`O,5>nOOQ[,5>p,5>pO#!YQpO'#D]O%[QlO'#JtO#!{QpO'#JtO##VQpO'#DkO##hQpO'#DkO#%yQlO'#DkO#&QQ`O'#JsO#&YQ`O,5:UO#&_Q`O'#ErO#&mQ`O'#KSO#&uQ`O,5;]O#&zQpO'#DkO#'XQpO'#ETOOQ!0Lf,5:m,5:mO%[QlO,5:mO#'`Q`O,5:mO>wQ`O,5;WO!BeQpO,5;WO!BmQMhO,5;WO:YQMhO,5;WO#'hQ`O,5@`O#'mQ07dO,5:qOOQO-E<d-E<dO#(sQ!0MSO,5;POCuQpO,5:pO#(}QpO,5:pOCuQpO,5;PO!BYQ!0LrO,5:pOOQ!0Lb'#Eh'#EhOOQO,5;P,5;PO%[QlO,5;PO#)[Q!0LrO,5;PO#)gQ!0LrO,5;PO!BeQpO,5:pOOQO,5;V,5;VO#)uQ!0LrO,5;PPOOO'#I['#I[P#*ZO&2DjO,58|POOO,58|,58|OOOO-E<[-E<[OOQ!0Lh1G.p1G.pOOOO-E<]-E<]OOOO,59{,59{O#*fQ!bO,59{OOOO-E<_-E<_OOQ!0Lf1G/e1G/eO#*kQ!fO,5>|O+}QlO,5>|OOQO,5?S,5?SO#*uQlO'#IbOOQO-E<`-E<`O#+SQ`O,5@^O#+[Q!fO,5@^O#+cQ`O,5@lOOQ!0Lf1G/k1G/kO%[QlO,5@mO#+kQ`O'#IhOOQO-E<f-E<fO#+cQ`O,5@lOOQ!0Lb1G0v1G0vOOQ!0Ln1G/v1G/vOOQ!0Ln1G0W1G0WO%[QlO,5@jO#,PQ!0LrO,5@jO#,bQ!0LrO,5@jO#,iQ`O,5@iO9ZQ`O,5@iO#,qQ`O,5@iO#-PQ`O'#IkO#,iQ`O,5@iOOQ!0Lb1G0u1G0uO!(cQpO,5:sO!(nQpO,5:sOOQS,5:u,5:uO#-qQdO,5:uO#-yQMhO1G2xO9aQ`O1G2xOOQ!0Lf1G0s1G0sO#.XQ!0MxO1G0sO#/^Q!0MvO,5;TOOQ!0Lh'#GV'#GVO#/zQ!0MzO'#JjO!$fQlO1G0sO#2VQ!fO'#JuO%[QlO'#JuO#2aQ`O,5:cOOQ!0Lh'#D]'#D]OOQ!0Lf1G0|1G0|O%[QlO1G0|OOQ!0Lf1G1e1G1eO#2fQ`O1G0|O#4zQ!0MxO1G0}O#5RQ!0MxO1G0}O#7iQ!0MxO1G0}O#7pQ!0MxO1G0}O#:WQ!0MxO1G0}O#<nQ!0MxO1G0}O#<uQ!0MxO1G0}O#<|Q!0MxO1G0}O#?dQ!0MxO1G0}O#?kQ!0MxO1G0}O#AxQ?MtO'#CiO#CsQ?MtO1G1_O#CzQ?MtO'#JqO#D_Q!0MxO,5?YOOQ!0Lb-E<l-E<lO#FlQ!0MxO1G0}O#GiQ!0MzO1G0}OOQ!0Lf1G0}1G0}O#HlQMjO'#JzO#HvQ`O,5:vO#H{Q!0MxO1G1bO#IoQ,UO,5<VO#IwQ,UO,5<WO#JPQ,UO'#FnO#JhQ`O'#FmOOQO'#KW'#KWOOQO'#Il'#IlO#JmQ,UO1G1mOOQ!0Lf1G1m1G1mOOOW1G1x1G1xO#KOQ?MtO'#JpO#KYQ`O,5<aO!(yQlO,5<aOOOW-E<k-E<kOOQ!0Lf1G1k1G1kO#K_QpO'#KVOOQ!0Lf,5<c,5<cO#KgQpO,5<cO#KlQMhO'#DROOOO'#I`'#I`O#KsO#@ItO,59kOOQ!0Lh,59k,59kO%[QlO1G2OO!7{Q`O'#IpO#LOQ`O,5<yOOQ!0Lh,5<v,5<vO!+rQMhO'#IsO#LlQMjO,5=WO!+rQMhO'#IuO#M_QMjO,5=YO!&iQMhO,5=[OOQO1G2R1G2RO#MiQ!dO'#CrO#M|Q(CWO'#EpO$ RQpO'#GaO$ iQ!dO,5<rO$ pQ`O'#KYO9ZQ`O'#KYO$!OQ`O,5<tO!+rQMhO,5<sO$!TQ`O'#GYO$!fQ`O,5<sO$!kQ!dO'#GVO$!xQ!dO'#KZO$#SQ`O'#KZO!&iQMhO'#KZO$#XQ`O,5<wO$#^QlO'#JtO$#hQpO'#GbO##hQpO'#GbO$#yQ`O'#GfO!3^Q`O'#GjO$$OQ!0LrO'#IrO$$ZQpO,5<{OOQ!0Lp,5<{,5<{O$$bQpO'#GbO$$oQpO'#GcO$%QQpO'#GcO$%VQMjO,5=WO$%gQMjO,5=YOOQ!0Lh,5=],5=]O!+rQMhO,5@TO!+rQMhO,5@TO$%wQ`O'#IwO$&VQ`O,5@SO$&_Q`O,59aOOQ!0Lh,59g,59gO$'UQ$IYO,59sOOQ!0Lh'#Jn'#JnO$'wQMjO,5<jO$(jQMjO,5<lO@iQ`O,5<nOOQ!0Lh,5<o,5<oO$(tQ`O,5<uO$(yQMjO,5<zO$)ZQ`O,5@TO$)iQ`O'#J}O!$fQlO1G2QO$)nQ`O1G2QO9ZQ`O'#KQO9ZQ`O'#ErO%[QlO'#ErO9ZQ`O'#IyO$)sQ!0LrO,5@yOOQ[1G2|1G2|OOQ[1G4^1G4^OOQ!0Lf1G/z1G/zOOQ!0Lf1G/x1G/xO$+uQ!0MxO1G0SOOQ[1G2x1G2xO!&iQMhO1G2xO%[QlO1G2xO#-|Q`O1G2xO$-yQMhO'#EiOOQ!0Lb,5@R,5@RO$.WQ!0LrO,5@ROOQ[1G.u1G.uO!BYQ!0LrO1G.uO!BeQpO1G.uO!BmQMhO1G.uO$.iQ`O1G0sO$.nQ`O'#CiO$.yQ`O'#KcO$/RQ`O,5=zO$/WQ`O'#KcO$/]Q`O'#KcO$/kQ`O'#JPO$/yQ`O,5@|O$0RQ!fO1G1hOOQ!0Lf1G1j1G1jO9aQ`O1G3eO@iQ`O1G3eO$0YQ`O1G3eO$0_Q`O1G3eOOQ[1G3e1G3eO!DkQ`O1G3TO!&iQMhO1G3QO$0dQ`O1G3QOOQ[1G3R1G3RO!&iQMhO1G3RO$0iQ`O1G3RO$0qQpO'#HPOOQ[1G3T1G3TO!5|QpO'#I{O!DpQ!bO1G3WOOQ[1G3W1G3WOOQ[,5=q,5=qO$0yQMhO,5=sO9aQ`O,5=sO$#yQ`O,5=uO9UQ`O,5=uO!BeQpO,5=uO!BmQMhO,5=uO:YQMhO,5=uO$1XQ`O'#KaO$1dQ`O,5=vOOQ[1G.k1G.kO$1iQ!0LrO1G.kO@iQ`O1G.kO$1tQ`O1G.kO9kQ!0LrO1G.kO$3|Q!fO,5AOO$4ZQ`O,5AOO9ZQ`O,5AOO$4fQlO,5=}O$4mQ`O,5=}OOQ[1G3g1G3gO`QlO1G3gOOQ[1G3m1G3mOOQ[1G3o1G3oO>rQ`O1G3qO$4rQlO1G3sO$8vQlO'#HrOOQ[1G3v1G3vO$9TQ`O'#HxO>wQ`O'#HzOOQ[1G3|1G3|O$9]QlO1G3|O9kQ!0LrO1G4SOOQ[1G4U1G4UOOQ!0Lb'#G^'#G^O9kQ!0LrO1G4WO9kQ!0LrO1G4YO$=dQ`O,5@`O!(yQlO,5;^O9ZQ`O,5;^O>wQ`O,5:VO!(yQlO,5:VO!BeQpO,5:VO$=iQ?MtO,5:VOOQO,5;^,5;^O$=sQpO'#IcO$>ZQ`O,5@_OOQ!0Lf1G/p1G/pO$>cQpO'#IiO$>mQ`O,5@nOOQ!0Lb1G0w1G0wO##hQpO,5:VOOQO'#Ie'#IeO$>uQpO,5:oOOQ!0Ln,5:o,5:oO#'cQ`O1G0XOOQ!0Lf1G0X1G0XO%[QlO1G0XOOQ!0Lf1G0r1G0rO>wQ`O1G0rO!BeQpO1G0rO!BmQMhO1G0rOOQ!0Lb1G5z1G5zO!BYQ!0LrO1G0[OOQO1G0k1G0kO%[QlO1G0kO$>|Q!0LrO1G0kO$?XQ!0LrO1G0kO!BeQpO1G0[OCuQpO1G0[O$?gQ!0LrO1G0kOOQO1G0[1G0[O$?{Q!0MxO1G0kPOOO-E<Y-E<YPOOO1G.h1G.hOOOO1G/g1G/gO$@VQ!bO,5<hO$@_Q!fO1G4hOOQO1G4n1G4nO%[QlO,5>|O$@iQ`O1G5xO$@qQ`O1G6WO$@yQ!fO1G6XO9ZQ`O,5?SO$ATQ!0MxO1G6UO%[QlO1G6UO$AeQ!0LrO1G6UO$AvQ`O1G6TO$AvQ`O1G6TO9ZQ`O1G6TO$BOQ`O,5?VO9ZQ`O,5?VOOQO,5?V,5?VO$BdQ`O,5?VO$)iQ`O,5?VOOQO-E<i-E<iOOQS1G0_1G0_OOQS1G0a1G0aO#-tQ`O1G0aOOQ[7+(d7+(dO!&iQMhO7+(dO%[QlO7+(dO$BrQ`O7+(dO$B}QMhO7+(dO$C]Q!0MzO,5=WO$EhQ!0MzO,5=YO$GsQ!0MzO,5=WO$JUQ!0MzO,5=YO$LgQ!0MzO,59sO$NlQ!0MzO,5<jO%!wQ!0MzO,5<lO%%SQ!0MzO,5<zOOQ!0Lf7+&_7+&_O%'eQ!0MxO7+&_O%(XQlO'#IdO%(fQ`O,5@aO%(nQ!fO,5@aOOQ!0Lf1G/}1G/}O%(xQ`O7+&hOOQ!0Lf7+&h7+&hO%(}Q?MtO,5:dO%[QlO7+&yO%)XQ?MtO,5:`O%)fQ?MtO,5:hO%)pQ?MtO,5:jO%)zQMhO'#IgO%*UQ`O,5@fOOQ!0Lh1G0b1G0bOOQO1G1q1G1qOOQO1G1r1G1rO%*^Q!jO,5<YO!(yQlO,5<XOOQO-E<j-E<jOOQ!0Lf7+'X7+'XOOOW7+'d7+'dOOOW1G1{1G1{O%*iQ`O1G1{OOQ!0Lf1G1}1G1}OOOO,59m,59mO%*nQ!dO,59mOOOO-E<^-E<^OOQ!0Lh1G/V1G/VO%*uQ!0MxO7+'jOOQ!0Lh,5?[,5?[O%+iQMhO1G2eP%+pQ`O'#IpPOQ!0Lh-E<n-E<nO%,^QMjO,5?_OOQ!0Lh-E<q-E<qO%-PQMjO,5?aOOQ!0Lh-E<s-E<sO%-ZQ!dO1G2vO%-bQ!dO'#CrO%-xQMhO'#KQO$#^QlO'#JtOOQ!0Lh1G2^1G2^O%.PQ`O'#IoO%.eQ`O,5@tO%.eQ`O,5@tO%.mQ`O,5@tO%.xQ`O,5@tOOQO1G2`1G2`O%/WQMjO1G2_O!+rQMhO1G2_O%/hQ(CWO'#IqO%/uQ`O,5@uO!&iQMhO,5@uO%/}Q!dO,5@uOOQ!0Lh1G2c1G2cO%2_Q!fO'#CiO%2iQ`O,5=OOOQ!0Lb,5<|,5<|O%2qQpO,5<|OOQ!0Lb,5<},5<}OCfQ`O,5<|O%2|QpO,5<|OOQ!0Lb,5=Q,5=QO$)iQ`O,5=UOOQO,5?^,5?^OOQO-E<p-E<pOOQ!0Lp1G2g1G2gO##hQpO,5<|O$#^QlO,5=OO%3[Q`O,5<}O%3gQpO,5<}O!+rQMhO'#IsO%4aQMjO1G2rO!+rQMhO'#IuO%5SQMjO1G2tO%5^QMjO1G5oO%5hQMjO1G5oOOQO,5?c,5?cOOQO-E<u-E<uOOQO1G.{1G.{O!9lQpO,59uO%[QlO,59uOOQ!0Lh,5<i,5<iO%5uQ`O1G2YO!+rQMhO1G2aO!+rQMhO1G5oO!+rQMhO1G5oO%5zQ!0MxO7+'lOOQ!0Lf7+'l7+'lO!$fQlO7+'lO%6nQ`O,5;^OOQ!0Lb,5?e,5?eOOQ!0Lb-E<w-E<wO%6sQ!dO'#K[O#'cQ`O7+(dO4UQ!fO7+(dO$BuQ`O7+(dO%6}Q!0MvO'#CiO%7nQ!0LrO,5=RO%8PQ!0MvO,5=RO%8dQ`O,5=ROOQ!0Lb1G5m1G5mOOQ[7+$a7+$aO!BYQ!0LrO7+$aO!BeQpO7+$aO!$fQlO7+&_O%8lQ`O'#JOO%9TQ`O,5@}OOQO1G3f1G3fO9aQ`O,5@}O%9TQ`O,5@}O%9]Q`O,5@}OOQO,5?k,5?kOOQO-E<}-E<}OOQ!0Lf7+'S7+'SO%9bQ`O7+)PO9kQ!0LrO7+)PO9aQ`O7+)PO@iQ`O7+)POOQ[7+(o7+(oO%9gQ!0MvO7+(lO!&iQMhO7+(lO!DfQ`O7+(mOOQ[7+(m7+(mO!&iQMhO7+(mO%9qQ`O'#K`O%9|Q`O,5=kOOQO,5?g,5?gOOQO-E<y-E<yOOQ[7+(r7+(rO%;`QpO'#HYOOQ[1G3_1G3_O!&iQMhO1G3_O%[QlO1G3_O%;gQ`O1G3_O%;rQMhO1G3_O9kQ!0LrO1G3aO$#yQ`O1G3aO9UQ`O1G3aO!BeQpO1G3aO!BmQMhO1G3aO%<QQ`O'#I}O%<fQ`O,5@{O%<nQpO,5@{OOQ!0Lb1G3b1G3bOOQ[7+$V7+$VO@iQ`O7+$VO9kQ!0LrO7+$VO%<yQ`O7+$VO%[QlO1G6jO%[QlO1G6kO%=OQ!0LrO1G6jO%=YQlO1G3iO%=aQ`O1G3iO%=fQlO1G3iOOQ[7+)R7+)RO9kQ!0LrO7+)]O`QlO7+)_OOQ['#Kf'#KfOOQ['#JQ'#JQO%=mQlO,5>^OOQ[,5>^,5>^O%[QlO'#HsO%=zQ`O'#HuOOQ[,5>d,5>dO9ZQ`O,5>dOOQ[,5>f,5>fOOQ[7+)h7+)hOOQ[7+)n7+)nOOQ[7+)r7+)rOOQ[7+)t7+)tO%>PQpO1G5zO%>kQ?MtO1G0xO%>uQ`O1G0xOOQO1G/q1G/qO%?QQ?MtO1G/qO>wQ`O1G/qO!(yQlO'#DkOOQO,5>},5>}OOQO-E<a-E<aOOQO,5?T,5?TOOQO-E<g-E<gO!BeQpO1G/qOOQO-E<c-E<cOOQ!0Ln1G0Z1G0ZOOQ!0Lf7+%s7+%sO#'cQ`O7+%sOOQ!0Lf7+&^7+&^O>wQ`O7+&^O!BeQpO7+&^OOQO7+%v7+%vO$?{Q!0MxO7+&VOOQO7+&V7+&VO%[QlO7+&VO%?[Q!0LrO7+&VO!BYQ!0LrO7+%vO!BeQpO7+%vO%?gQ!0LrO7+&VO%?uQ!0MxO7++pO%[QlO7++pO%@VQ`O7++oO%@VQ`O7++oOOQO1G4q1G4qO9ZQ`O1G4qO%@_Q`O1G4qOOQS7+%{7+%{O#'cQ`O<<LOO4UQ!fO<<LOO%@mQ`O<<LOOOQ[<<LO<<LOO!&iQMhO<<LOO%[QlO<<LOO%@uQ`O<<LOO%AQQ!0MzO,5?_O%C]Q!0MzO,5?aO%EhQ!0MzO1G2_O%GyQ!0MzO1G2rO%JUQ!0MzO1G2tO%LaQ!fO,5?OO%[QlO,5?OOOQO-E<b-E<bO%LkQ`O1G5{OOQ!0Lf<<JS<<JSO%LsQ?MtO1G0sO%NzQ?MtO1G0}O& RQ?MtO1G0}O&#SQ?MtO1G0}O&#ZQ?MtO1G0}O&%[Q?MtO1G0}O&']Q?MtO1G0}O&'dQ?MtO1G0}O&'kQ?MtO1G0}O&)lQ?MtO1G0}O&)sQ?MtO1G0}O&)zQ!0MxO<<JeO&+rQ?MtO1G0}O&,oQ?MvO1G0}O&-rQ?MvO'#JjO&/xQ?MtO1G1bO&0VQ?MtO1G0SO&0aQMjO,5?ROOQO-E<e-E<eO!(yQlO'#FpOOQO'#KX'#KXOOQO1G1t1G1tO&0kQ`O1G1sO&0pQ?MtO,5?YOOOW7+'g7+'gOOOO1G/X1G/XO&0zQ!dO1G4vOOQ!0Lh7+(P7+(PP!&iQMhO,5?[O!+rQMhO7+(bO&1RQ`O,5?ZO9ZQ`O,5?ZOOQO-E<m-E<mO&1aQ`O1G6`O&1aQ`O1G6`O&1iQ`O1G6`O&1tQMjO7+'yO&2UQ!dO,5?]O&2`Q`O,5?]O!&iQMhO,5?]OOQO-E<o-E<oO&2eQ!dO1G6aO&2oQ`O1G6aO&2wQ`O1G2jO!&iQMhO1G2jOOQ!0Lb1G2h1G2hOOQ!0Lb1G2i1G2iO%2qQpO1G2hO!BeQpO1G2hOCfQ`O1G2hOOQ!0Lb1G2p1G2pO&2|QpO1G2hO&3[Q`O1G2jO$)iQ`O1G2iOCfQ`O1G2iO$#^QlO1G2jO&3dQ`O1G2iO&4WQMjO,5?_OOQ!0Lh-E<r-E<rO&4yQMjO,5?aOOQ!0Lh-E<t-E<tO!+rQMhO7++ZOOQ!0Lh1G/a1G/aO&5TQ`O1G/aOOQ!0Lh7+'t7+'tO&5YQMjO7+'{O&5jQMjO7++ZO&5tQMjO7++ZO&6RQ!0MxO<<KWOOQ!0Lf<<KW<<KWO&6uQ`O1G0xO!&iQMhO'#IxO&6zQ`O,5@vO&8|Q!fO<<LOO!&iQMhO1G2mO&9TQ!0LrO1G2mOOQ[<<G{<<G{O!BYQ!0LrO<<G{O&9fQ!0MxO<<IyOOQ!0Lf<<Iy<<IyOOQO,5?j,5?jO&:YQ`O,5?jO&:_Q`O,5?jOOQO-E<|-E<|O&:mQ`O1G6iO&:mQ`O1G6iO9aQ`O1G6iO@iQ`O<<LkOOQ[<<Lk<<LkO&:uQ`O<<LkO9kQ!0LrO<<LkOOQ[<<LW<<LWO%9gQ!0MvO<<LWOOQ[<<LX<<LXO!DfQ`O<<LXO&:zQpO'#IzO&;VQ`O,5@zO!(yQlO,5@zOOQ[1G3V1G3VOOQO'#I|'#I|O9kQ!0LrO'#I|O&;_QpO,5=tOOQ[,5=t,5=tO&;fQpO'#EeO&;mQpO'#GdO&;rQ`O7+(yO&;wQ`O7+(yOOQ[7+(y7+(yO!&iQMhO7+(yO%[QlO7+(yO&<PQ`O7+(yOOQ[7+({7+({O9kQ!0LrO7+({O$#yQ`O7+({O9UQ`O7+({O!BeQpO7+({O&<[Q`O,5?iOOQO-E<{-E<{OOQO'#H]'#H]O&<gQ`O1G6gO9kQ!0LrO<<GqOOQ[<<Gq<<GqO@iQ`O<<GqO&<oQ`O7+,UO&<tQ`O7+,VO%[QlO7+,UO%[QlO7+,VOOQ[7+)T7+)TO&<yQ`O7+)TO&=OQlO7+)TO&=VQ`O7+)TOOQ[<<Lw<<LwOOQ[<<Ly<<LyOOQ[-E=O-E=OOOQ[1G3x1G3xO&=[Q`O,5>_OOQ[,5>a,5>aO&=aQ`O1G4OO9ZQ`O7+&dO!(yQlO7+&dOOQO7+%]7+%]O&=fQ?MtO1G6XO>wQ`O7+%]OOQ!0Lf<<I_<<I_OOQ!0Lf<<Ix<<IxO>wQ`O<<IxOOQO<<Iq<<IqO$?{Q!0MxO<<IqO%[QlO<<IqOOQO<<Ib<<IbO!BYQ!0LrO<<IbO&=pQ!0LrO<<IqO&={Q!0MxO<= [O&>]Q`O<= ZOOQO7+*]7+*]O9ZQ`O7+*]OOQ[ANAjANAjO&>eQ!fOANAjO!&iQMhOANAjO#'cQ`OANAjO4UQ!fOANAjO&>lQ`OANAjO%[QlOANAjO&>tQ!0MzO7+'yO&AVQ!0MzO,5?_O&CbQ!0MzO,5?aO&EmQ!0MzO7+'{O&HOQ!fO1G4jO&HYQ?MtO7+&_O&J^Q?MvO,5=WO&LeQ?MvO,5=YO&LuQ?MvO,5=WO&MVQ?MvO,5=YO&MgQ?MvO,59sO' mQ?MvO,5<jO'#pQ?MvO,5<lO'&UQ?MvO,5<zO''zQ?MtO7+'jO'(XQ?MtO7+'lO'(fQ`O,5<[OOQO7+'_7+'_OOQ!0Lh7+*b7+*bO'(kQMjO<<K|OOQO1G4u1G4uO'(rQ`O1G4uO'(}Q`O1G4uO')]Q`O7++zO')]Q`O7++zO!&iQMhO1G4wO')eQ!dO1G4wO')oQ`O7++{O')wQ`O7+(UO'*SQ!dO7+(UOOQ!0Lb7+(S7+(SOOQ!0Lb7+(T7+(TO!BeQpO7+(SOCfQ`O7+(SO'*^Q`O7+(UO!&iQMhO7+(UO$)iQ`O7+(TO'*cQ`O7+(UOCfQ`O7+(TO'*kQMjO<<NuOOQ!0Lh7+${7+${O!+rQMhO<<NuO'*uQ!dO,5?dOOQO-E<v-E<vO'+PQ!0MvO7+(XO!&iQMhO7+(XOOQ[AN=gAN=gO9aQ`O1G5UOOQO1G5U1G5UO'+aQ`O1G5UO'+fQ`O7+,TO'+fQ`O7+,TO9kQ!0LrOANBVO@iQ`OANBVOOQ[ANBVANBVOOQ[ANArANArOOQ[ANAsANAsO'+nQ`O,5?fOOQO-E<x-E<xO'+yQ?MtO1G6fOOQO,5?h,5?hOOQO-E<z-E<zOOQ[1G3`1G3`O',TQ`O,5=OOOQ[<<Le<<LeO!&iQMhO<<LeO&;rQ`O<<LeO',YQ`O<<LeO%[QlO<<LeOOQ[<<Lg<<LgO9kQ!0LrO<<LgO$#yQ`O<<LgO9UQ`O<<LgO',bQpO1G5TO',mQ`O7+,ROOQ[AN=]AN=]O9kQ!0LrOAN=]OOQ[<= p<= pOOQ[<= q<= qO',uQ`O<= pO',zQ`O<= qOOQ[<<Lo<<LoO'-PQ`O<<LoO'-UQlO<<LoOOQ[1G3y1G3yO>wQ`O7+)jO'-]Q`O<<JOO'-hQ?MtO<<JOOOQO<<Hw<<HwOOQ!0LfAN?dAN?dOOQOAN?]AN?]O$?{Q!0MxOAN?]OOQOAN>|AN>|O%[QlOAN?]OOQO<<Mw<<MwOOQ[G27UG27UO!&iQMhOG27UO#'cQ`OG27UO'-rQ!fOG27UO4UQ!fOG27UO'-yQ`OG27UO'.RQ?MtO<<JeO'.`Q?MvO1G2_O'0UQ?MvO,5?_O'2XQ?MvO,5?aO'4[Q?MvO1G2rO'6_Q?MvO1G2tO'8bQ?MtO<<KWO'8oQ?MtO<<IyOOQO1G1v1G1vO!+rQMhOANAhOOQO7+*a7+*aO'8|Q`O7+*aO'9XQ`O<= fO'9aQ!dO7+*cOOQ!0Lb<<Kp<<KpO$)iQ`O<<KpOCfQ`O<<KpO'9kQ`O<<KpO!&iQMhO<<KpOOQ!0Lb<<Kn<<KnO!BeQpO<<KnO'9vQ!dO<<KpOOQ!0Lb<<Ko<<KoO':QQ`O<<KpO!&iQMhO<<KpO$)iQ`O<<KoO':VQMjOANDaO':aQ!0MvO<<KsOOQO7+*p7+*pO9aQ`O7+*pO':qQ`O<= oOOQ[G27qG27qO9kQ!0LrOG27qO!(yQlO1G5QO':yQ`O7+,QO';RQ`O1G2jO&;rQ`OANBPOOQ[ANBPANBPO!&iQMhOANBPO';WQ`OANBPOOQ[ANBRANBRO9kQ!0LrOANBRO$#yQ`OANBROOQO'#H^'#H^OOQO7+*o7+*oOOQ[G22wG22wOOQ[ANE[ANE[OOQ[ANE]ANE]OOQ[ANBZANBZO';`Q`OANBZOOQ[<<MU<<MUO!(yQlOAN?jOOQOG24wG24wO$?{Q!0MxOG24wO#'cQ`OLD,pOOQ[LD,pLD,pO!&iQMhOLD,pO';eQ!fOLD,pO';lQ?MvO7+'yO'=bQ?MvO,5?_O'?eQ?MvO,5?aO'AhQ?MvO7+'{O'C^QMjOG27SOOQO<<M{<<M{OOQ!0LbANA[ANA[O$)iQ`OANA[OCfQ`OANA[O'CnQ!dOANA[OOQ!0LbANAYANAYO'CuQ`OANA[O!&iQMhOANA[O'DQQ!dOANA[OOQ!0LbANAZANAZOOQO<<N[<<N[OOQ[LD-]LD-]O'D[Q?MtO7+*lOOQO'#Ge'#GeOOQ[G27kG27kO&;rQ`OG27kO!&iQMhOG27kOOQ[G27mG27mO9kQ!0LrOG27mOOQ[G27uG27uO'DfQ?MtOG25UOOQOLD*cLD*cOOQ[!$(![!$(![O#'cQ`O!$(![O!&iQMhO!$(![O'DpQ!0MzOG27SOOQ!0LbG26vG26vO$)iQ`OG26vO'GRQ`OG26vOCfQ`OG26vO'G^Q!dOG26vO!&iQMhOG26vOOQ[LD-VLD-VO&;rQ`OLD-VOOQ[LD-XLD-XOOQ[!)9Ev!)9EvO#'cQ`O!)9EvOOQ!0LbLD,bLD,bO$)iQ`OLD,bOCfQ`OLD,bO'GeQ`OLD,bO'GpQ!dOLD,bOOQ[!$(!q!$(!qOOQ[!.K;b!.K;bO'GwQ?MvOG27SOOQ!0Lb!$( |!$( |O$)iQ`O!$( |OCfQ`O!$( |O'ImQ`O!$( |OOQ!0Lb!)9Eh!)9EhO$)iQ`O!)9EhOCfQ`O!)9EhOOQ!0Lb!.K;S!.K;SO$)iQ`O!.K;SOOQ!0Lb!4/0n!4/0nO!(yQlO'#DxO1PQ`O'#EVO'IxQ!fO'#JpO'JPQ!L^O'#DtO'JWQlO'#D|O'J_Q!fO'#CiO'LuQ!fO'#CiO!(yQlO'#EOO'MVQlO,5;XO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO'#InO( YQ`O,5<hO!(yQlO,5;cO( bQMhO,5;cO(!{QMhO,5;cO!(yQlO,5;vO!&iQMhO'#GlO( bQMhO'#GlO!&iQMhO'#GnO( bQMhO'#GnO1SQ`O'#DXO1SQ`O'#DXO!&iQMhO'#GOO( bQMhO'#GOO!&iQMhO'#GQO( bQMhO'#GQO!&iQMhO'#G`O( bQMhO'#G`O!(yQlO,5:hO(#SQpO'#D]O(#^QpO'#JtO!(yQlO,5@mO'MVQlO1G0sO(#hQ?MtO'#CiO!(yQlO1G2OO!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO(#rQ!dO'#CrO!&iQMhO,5<sO( bQMhO,5<sO'MVQlO1G2QO!(yQlO7+&yO!&iQMhO1G2_O( bQMhO1G2_O!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO!&iQMhO1G2aO( bQMhO1G2aO'MVQlO7+'lO'MVQlO7+&_O!&iQMhOANAhO( bQMhOANAhO($VQ`O'#EmO($[Q`O'#EmO($dQ`O'#F[O($iQ`O'#EwO($nQ`O'#KRO($yQ`O'#KPO(%UQ`O,5;XO(%ZQMjO,5<dO(%bQ`O'#GXO(%gQ`O'#GXO(%lQ`O,5<fO(%tQ`O,5;XO(%|Q?MtO1G1_O(&TQ`O,5<sO(&YQ`O,5<sO(&_Q`O,5<uO(&dQ`O,5<uO(&iQ`O1G2QO(&nQ`O1G0sO(&sQMjO<<K|O(&zQMjO<<K|O7eQMhO'#F{O9UQ`O'#FzOAdQ`O'#ElO!(yQlO,5;sO!3^Q`O'#GXO!3^Q`O'#GXO!3^Q`O'#GZO!3^Q`O'#GZO!+rQMhO7+(bO!+rQMhO7+(bO%-ZQ!dO1G2vO%-ZQ!dO1G2vO!&iQMhO,5=[O!&iQMhO,5=[",
+     stateData: "((P~O'zOS'{OSTOS'|RQ~OPYOQYOSfOY!VOaqOdzOeyOj!POnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!swO!vxO!z]O$V|O$miO%g}O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO&U!WO&[!XO&^!YO&`!ZO&b![O&e!]O&k!^O&q!_O&s!`O&u!aO&w!bO&y!cO(RSO(TTO(WUO(_VO(m[O~OWtO~P`OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa!wOq!nO!Q!oO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!xO#U!pO#V!pO#Y!zO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O'|!{O~OP]XR]X[]Xa]Xp]X!O]X!Q]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X'x]X(_]X(p]X(w]X(x]X~O!e%QX~P(qO_!}O(T#PO(U!}O(V#PO~O_#QO(V#PO(W#PO(X#QO~Ov#SO!S#TO(`#TO(a#VO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R;{O(TTO(WUO(_VO(m[O~O!Y#ZO!Z#WO!W(fP!W(tP~P+}O![#cO~P`OPYOQYOSfOd!jOe!iOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(TTO(WUO(_VO(m[O~On#mO!Y#iO!z]O#g#lO#h#iO(R;|O!i(qP~P.iO!j#oO(R#nO~O!v#sO!z]O%g#tO~O#i#uO~O!e#vO#i#uO~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z$_O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa(dX'x(dX'u(dX!i(dX!W(dX!](dX%h(dX!e(dX~P1qO#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX!](eX%h(eX~Oa(eX'x(eX'u(eX!W(eX!i(eXt(eX!e(eX~P4UO#^$eO~O$[$hO$^$gO$e$mO~OSfO!]$nO$h$oO$j$qO~Oh%VOj%cOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R$sO(TTO(WUO(_$uO(w$}O(x%POg([P~O!j%dO~O!Q%gO!]%hO(R%fO~O!e%lO~Oa%mO'x%mO~O!O%qO~P%[O(S!lO~P%[O%m%uO~P%[Oh%VO!j%dO(R%fO(S!lO~Oe%|O!j%dO(R%fO~O#t$RO~O!O&RO!]&OO!j&QO%i&UO(R%fO(S!lO(TTO(WUO`)UP~O!v#sO~O%r&WO!Q)QX!])QX(R)QX~O(R&XO~Oj!PO!s&^O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO~Od&cOe&bO!v&`O%g&aO%z&_O~P<POd&fOeyOj!PO!]&eO!s&^O!vxO!z]O%g}O%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO~Ob&iO#^&lO%i&gO(S!lO~P=UO!j&mO!s&qO~O!j#oO~O!]XO~Oa%mO'v&yO'x%mO~Oa%mO'v&|O'x%mO~Oa%mO'v'OO'x%mO~O'u]X!W]Xt]X!i]X&Y]X!]]X%h]X!e]X~P(qO!`']O!a'UO!b'UO(S!lO(TTO(WUO~Oq'SO!Q'RO!Y'VO(c'QO![(gP![(vP~P@]Ol'`O!]'^O(R%fO~Oe'eO!j%dO(R%fO~O!O&RO!j&QO~Oq!nO!Q!oO!z;wO#R!pO#S!pO#U!pO#V!pO(S!lO(TTO(WUO(c!mO(m!sO~O!`'kO!a'jO!b'jO#T!pO#Y'lO#Z'lO~PAwOa%mOh%VO!e#vO!j%dO'x%mO(p'nO~O!n'rO#^'pO~PCVOq!nO!Q!oO(TTO(WUO(c!mO(m!sO~O!]XOq(kX!Q(kX!`(kX!a(kX!b(kX!z(kX#R(kX#S(kX#T(kX#U(kX#V(kX#Y(kX#Z(kX(S(kX(T(kX(W(kX(c(kX(m(kX~O!a'jO!b'jO(S!lO~PCuO'}'vO(O'vO(P'xO~O_!}O(T'zO(U!}O(V'zO~O_#QO(V'zO(W'zO(X#QO~Ot'|O~P%[Ov#SO!S#TO(`#TO(a(PO~O!Y(RO!W'UX!W'[X!Z'UX!Z'[X~P+}O!Z(TO!W(fX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z(TO!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~O!W(fX~PGpO!W(YO~O!W(sX!Z(sX!e(sX!i(sX(p(sX~O#^(sX#i#bX![(sX~PIsO#^(ZO!W(uX!Z(uX~O!Z([O!W(tX~O!W(_O~O#^$eO~PIsO![(`O~P`OR#zO!O#yO!Q#{O!j#xO(_VOP!la[!lap!la!Z!la!n!la#P!la#l!la#m!la#n!la#o!la#p!la#q!la#r!la#s!la#t!la#u!la#w!la#y!la#z!la(p!la(w!la(x!la~Oa!la'x!la'u!la!W!la!i!lat!la!]!la%h!la!e!la~PKZO!i(aO~O!e#vO#^(bO(p'nO!Z(rXa(rX'x(rX~O!i(rX~PMvO!Q%gO!]%hO!z]O#g(gO#h(fO(R%fO~O!Z(hO!i(qX~O!i(jO~O!Q%gO!]%hO#h(fO(R%fO~OP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O!e#vO!i(eX~P! dOR(lO!O(kO!j#xO#Q$dO!z!ya!Q!ya~O!v!ya%g!ya!]!ya#g!ya#h!ya(R!ya~P!#eO!v(pO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~O#i(vO~O!Y(xO!i(iP~P%[O(c(zO(m[O~O!Q(|O!j#xO(c(zO(m[O~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z$_Oa$pa'x$pa'u$pa!i$pa!W$pa!]$pa%h$pa!e$pa~Oj)bO~P!&iOh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Og(nP~P!+rO!O)gO!e)fO!]$]X$Y$]X$[$]X$^$]X$e$]X~O!e)fO!](yX$Y(yX$[(yX$^(yX$e(yX~O!O)gO~P!-{O!O)gO!](yX$Y(yX$[(yX$^(yX$e(yX~O!])iO$Y)mO$[)hO$^)hO$e)nO~O!Y)qO~P!(yO$[$hO$^$gO$e)uO~Ol$yX!O$yX#Q$yX'w$yX(w$yX(x$yX~OgkXg$yXlkX!ZkX#^kX~P!/qOv)wO(`)xO(a)zO~Ol*TO!O)|O'w)}O(w$}O(x%PO~Og){O~P!0uOg*UO~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q*WO!]*XO!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~O!Y*[O(R*VO!i(|P~P!1dO#i*^O~O!j*_O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R*aO(TTO(WUO(_$uO(w$}O(x%PO~O!Y*dO!W(}P~P!3cOp*pOq!nO!Q*fO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO(c!mO~O![*mO~P!5WO#Q$dOl(^X!O(^X'w(^X(w(^X(x(^X!Z(^X#^(^X~Og(^X#}(^X~P!6YOl*uO#^*tOg(]X!Z(]X~O!Z*vOg([X~Oj%cO(R&XOg([P~Oq*yO~O!j+OO~O(R(tO~On+TO!Q%gO!Y#iO!]%hO!z]O#g#lO#h#iO(R%fO!i(qP~O!e#vO#i+UO~O!Q%gO!Y+WO!Z([O!]%hO(R%fO!W(tP~Oq'YO!Q+YO!Y+XO(TTO(WUO(c(zO~O![(vP~P!9]O!Z+ZOa)RX'x)RX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa!ha!Z!ha'x!ha'u!ha!W!ha!i!hat!ha!]!ha%h!ha!e!ha~P!:TOR#zO!O#yO!Q#{O!j#xO(_VOP!pa[!pap!pa!Z!pa!n!pa#P!pa#l!pa#m!pa#n!pa#o!pa#p!pa#q!pa#r!pa#s!pa#t!pa#u!pa#w!pa#y!pa#z!pa(p!pa(w!pa(x!pa~Oa!pa'x!pa'u!pa!W!pa!i!pat!pa!]!pa%h!pa!e!pa~P!<kOR#zO!O#yO!Q#{O!j#xO(_VOP!ra[!rap!ra!Z!ra!n!ra#P!ra#l!ra#m!ra#n!ra#o!ra#p!ra#q!ra#r!ra#s!ra#t!ra#u!ra#w!ra#y!ra#z!ra(p!ra(w!ra(x!ra~Oa!ra'x!ra'u!ra!W!ra!i!rat!ra!]!ra%h!ra!e!ra~P!?ROh%VOl+dO!]'^O%h+cO~O!e+fOa(ZX!](ZX'x(ZX!Z(ZX~Oa%mO!]XO'x%mO~Oh%VO!j%dO~Oh%VO!j%dO(R%fO~O!e#vO#i(vO~Ob+qO%i+rO(R+nO(TTO(WUO![)VP~O!Z+sO`)UX~O[+wO~O`+xO~O!]&OO(R%fO(S!lO`)UP~Oh%VO#^+}O~Oh%VOl,QO!]$|O~O!],SO~O!O,UO!]XO~O%m%uO~O!v,ZO~Oe,`O~Ob,aO(R#nO(TTO(WUO![)TP~Oe%|O~O%i!QO(R&XO~P=UO[,fO`,eO~OPYOQYOSfOdzOeyOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!guO!jZO!mYO!nYO!oYO!qvO!vxO!z]O$miO%g}O(TTO(WUO(_VO(m[O~O!]!eO!s!gO$V!kO(R!dO~P!FRO`,eOa%mO'x%mO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa,kOj!OO!swO%k!OO%l!OO%m!OO~P!HkO!j&mO~O&[,qO~O!],sO~O&m,uO&o,vOP&jaQ&jaS&jaY&jaa&jad&jae&jaj&jan&jap&jaq&jar&jax&jaz&ja|&ja!Q&ja!U&ja!V&ja!]&ja!g&ja!j&ja!m&ja!n&ja!o&ja!q&ja!s&ja!v&ja!z&ja$V&ja$m&ja%g&ja%i&ja%k&ja%l&ja%m&ja%p&ja%r&ja%u&ja%v&ja%x&ja&U&ja&[&ja&^&ja&`&ja&b&ja&e&ja&k&ja&q&ja&s&ja&u&ja&w&ja&y&ja'u&ja(R&ja(T&ja(W&ja(_&ja(m&ja![&ja&c&jab&ja&h&ja~O(R,{O~Oh!cX!Z!PX![!PX!e!PX!e!cX!j!cX#^!PX~O!Z!cX![!cX~P# qO!e-QO#^-POh(hX!Z#fX![#fX!e(hX!j(hX~O!Z(hX![(hX~P#!dOh%VO!e-SO!j%dO!Z!_X![!_X~Oq!nO!Q!oO(TTO(WUO(c!mO~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(TTO(WUO(_VO(m[O~O(R<rO~P##yO!Z-WO![(gX~O![-YO~O!e-QO#^-PO!Z#fX![#fX~O!Z-ZO![(vX~O![-]O~O!a-^O!b-^O(S!lO~P##hO![-aO~P'_Ol-dO!]'^O~O!W-iO~Oq!ya!`!ya!a!ya!b!ya#R!ya#S!ya#T!ya#U!ya#V!ya#Y!ya#Z!ya(S!ya(T!ya(W!ya(c!ya(m!ya~P!#eO!n-nO#^-lO~PCVO!a-pO!b-pO(S!lO~PCuOa%mO#^-lO'x%mO~Oa%mO!e#vO#^-lO'x%mO~Oa%mO!e#vO!n-nO#^-lO'x%mO(p'nO~O'}'vO(O'vO(P-uO~Ot-vO~O!W'Ua!Z'Ua~P!:TO!Y-zO!W'UX!Z'UX~P%[O!Z(TO!W(fa~O!W(fa~PGpO!Z([O!W(ta~O!Q%gO!Y.OO!]%hO(R%fO!W'[X!Z'[X~O#^.QO!Z(ra!i(raa(ra'x(ra~O!e#vO~P#,PO!Z(hO!i(qa~O!Q%gO!]%hO#h.UO(R%fO~On.ZO!Q%gO!Y.WO!]%hO!z]O#g.YO#h.WO(R%fO!Z'_X!i'_X~OR._O!j#xO~Oh%VOl.bO!]'^O%h.aO~Oa#ai!Z#ai'x#ai'u#ai!W#ai!i#ait#ai!]#ai%h#ai!e#ai~P!:TOl=|O!O)|O'w)}O(w$}O(x%PO~O#i#]aa#]a#^#]a'x#]a!Z#]a!i#]a!]#]a!W#]a~P#.{O#i(^XP(^XR(^X[(^Xa(^Xp(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X'x(^X(_(^X(p(^X!i(^X!W(^X'u(^Xt(^X!](^X%h(^X!e(^X~P!6YO!Z.oO!i(iX~P!:TO!i.rO~O!W.tO~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kia#kip#ki!Z#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#l#ki~P#2kO#l$OO~P#2kOP$[OR#zOp$aO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO[#kia#ki!Z#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#p#ki~P#5YO#p$QO~P#5YOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO(_VOa#ki!Z#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#u#ki~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO(_VO(x#}Oa#ki!Z#ki#y#ki#z#ki'x#ki(p#ki(w#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#w$UO~P#:_O#w#ki~P#:_O#u$SO~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO(_VO(w#|O(x#}Oa#ki!Z#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#y#ki~P#=TO#y$WO~P#=TOP]XR]X[]Xp]X!O]X!Q]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X!Z]X![]X~O#}]X~P#?rOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO#y<XO#z<YO(_VO(p$YO(w#|O(x#}O~O#}.vO~P#BPO#Q$dO#^<`O$P<`O#}(eX![(eX~P! dOa'ba!Z'ba'x'ba'u'ba!i'ba!W'bat'ba!]'ba%h'ba!e'ba~P!:TO[#kia#kip#ki!Z#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO(w#ki(x#ki~P#EROl=|O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P#ERO!Z.zOg(nX~P!0uOg.|O~Oa$Oi!Z$Oi'x$Oi'u$Oi!W$Oi!i$Oit$Oi!]$Oi%h$Oi!e$Oi~P!:TO$[.}O$^.}O~O$[/OO$^/OO~O!e)fO#^/PO!]$bX$Y$bX$[$bX$^$bX$e$bX~O!Y/QO~O!])iO$Y/SO$[)hO$^)hO$e/TO~O!Z<ZO![(dX~P#BPO![/UO~O!e)fO$e(yX~O$e/WO~Ot/XO~P!&iOv)wO(`)xO(a/[O~O!Q/_O~O(w$}Ol%`a!O%`a'w%`a(x%`a!Z%`a#^%`a~Og%`a#}%`a~P#LTO(x%POl%ba!O%ba'w%ba(w%ba!Z%ba#^%ba~Og%ba#}%ba~P#LvO!ZfX!efX!ifX!i$yX(pfX~P!/qO!Y/hO!Z([O(R/gO!W(tP!W(}P~P!1dOp*pO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO~Oq<oO!Q/iO!Y+XO![*mO(c<nO![(vP~P#NaO!i/jO~P#.{O!Z/kO!e#vO(p'nO!i(|X~O!i/pO~O!Q%gO!Y*[O!]%hO(R%fO!i(|P~O#i/rO~O!W$yX!Z$yX!e%QX~P!/qO!Z/sO!W(}X~P#.{O!e/uO~O!W/wO~OnkO(R/xO~P.iOh%VOp/}O!e#vO!j%dO(p'nO~O!e+fO~Oa%mO!Z0RO'x%mO~O![0TO~P!5WO!a0UO!b0UO(S!lO~P##hOq!nO!Q0VO(TTO(WUO(c!mO~O#Y0XO~Og%`a!Z%`a#^%`a#}%`a~P!0uOg%ba!Z%ba#^%ba#}%ba~P!0uOj%cO(R&XOg'kX!Z'kX~O!Z*vOg([a~Og0bO~OR0cO!O0cO!Q0dO#Q$dOl{a'w{a(w{a(x{a!Z{a#^{a~Og{a#}{a~P$&dO!O)|O'w)}Ol$ra(w$ra(x$ra!Z$ra#^$ra~Og$ra#}$ra~P$'`O!O)|O'w)}Ol$ta(w$ta(x$ta!Z$ta#^$ta~Og$ta#}$ta~P$(RO#i0gO~Og%Sa!Z%Sa#^%Sa#}%Sa~P!0uOl0iO#^0hOg(]a!Z(]a~O!e#vO~O#i0lO~O!Z+ZOa)Ra'x)Ra~OR#zO!O#yO!Q#{O!j#xO(_VOP!pi[!pip!pi!Z!pi!n!pi#P!pi#l!pi#m!pi#n!pi#o!pi#p!pi#q!pi#r!pi#s!pi#t!pi#u!pi#w!pi#y!pi#z!pi(p!pi(w!pi(x!pi~Oa!pi'x!pi'u!pi!W!pi!i!pit!pi!]!pi%h!pi!e!pi~P$*OOh%VOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~On0vO%[0wO(R0tO~P$,fO!e+fOa(Za!](Za'x(Za!Z(Za~O#i0|O~O[]X!ZfX![fX~O!Z0}O![)VX~O![1PO~O[1QO~Ob1SO(R+nO(TTO(WUO~O!]&OO(R%fO`'sX!Z'sX~O!Z+sO`)Ua~O!i1VO~P!:TO[1YO~O`1ZO~O#^1^O~Ol1aO!]$|O~O(c(zO![)SP~Oh%VOl1jO!]1gO%h1iO~O[1tO!Z1rO![)TX~O![1uO~O`1wOa%mO'x%mO~O(R#nO(TTO(WUO~O#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O#t1zO&Y1{Oa(eX~P$2PO#^$eO#t1zO&Y1{O~Oa1}O~P%[Oa2PO~O&c2SOP&aiQ&aiS&aiY&aia&aid&aie&aij&ain&aip&aiq&air&aix&aiz&ai|&ai!Q&ai!U&ai!V&ai!]&ai!g&ai!j&ai!m&ai!n&ai!o&ai!q&ai!s&ai!v&ai!z&ai$V&ai$m&ai%g&ai%i&ai%k&ai%l&ai%m&ai%p&ai%r&ai%u&ai%v&ai%x&ai&U&ai&[&ai&^&ai&`&ai&b&ai&e&ai&k&ai&q&ai&s&ai&u&ai&w&ai&y&ai'u&ai(R&ai(T&ai(W&ai(_&ai(m&ai![&aib&ai&h&ai~Ob2YO![2WO&h2XO~P`O!]XO!j2[O~O&o,vOP&jiQ&jiS&jiY&jia&jid&jie&jij&jin&jip&jiq&jir&jix&jiz&ji|&ji!Q&ji!U&ji!V&ji!]&ji!g&ji!j&ji!m&ji!n&ji!o&ji!q&ji!s&ji!v&ji!z&ji$V&ji$m&ji%g&ji%i&ji%k&ji%l&ji%m&ji%p&ji%r&ji%u&ji%v&ji%x&ji&U&ji&[&ji&^&ji&`&ji&b&ji&e&ji&k&ji&q&ji&s&ji&u&ji&w&ji&y&ji'u&ji(R&ji(T&ji(W&ji(_&ji(m&ji![&ji&c&jib&ji&h&ji~O!W2bO~O!Z!_a![!_a~P#BPOq!nO!Q!oO!Y2hO(c!mO!Z'VX!['VX~P@]O!Z-WO![(ga~O!Z']X![']X~P!9]O!Z-ZO![(va~O![2oO~P'_Oa%mO#^2xO'x%mO~Oa%mO!e#vO#^2xO'x%mO~Oa%mO!e#vO!n2|O#^2xO'x%mO(p'nO~Oa%mO'x%mO~P!:TO!Z$_Ot$pa~O!W'Ui!Z'Ui~P!:TO!Z(TO!W(fi~O!Z([O!W(ti~O!W(ui!Z(ui~P!:TO!Z(ri!i(ria(ri'x(ri~P!:TO#^3OO!Z(ri!i(ria(ri'x(ri~O!Z(hO!i(qi~O!Q%gO!]%hO!z]O#g3TO#h3SO(R%fO~O!Q%gO!]%hO#h3SO(R%fO~Ol3[O!]'^O%h3ZO~Oh%VOl3[O!]'^O%h3ZO~O#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`at%`a!]%`a%h%`a!e%`a~P#LTO#i%baP%baR%ba[%baa%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%bat%ba!]%ba%h%ba!e%ba~P#LvO#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!Z%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`a#^%`at%`a!]%`a%h%`a!e%`a~P#.{O#i%baP%baR%ba[%baa%bap%ba!Q%ba!Z%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%ba#^%bat%ba!]%ba%h%ba!e%ba~P#.{O#i{aP{a[{aa{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a'x{a(_{a(p{a!i{a!W{a'u{at{a!]{a%h{a!e{a~P$&dO#i$raP$raR$ra[$raa$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra'x$ra(_$ra(p$ra!i$ra!W$ra'u$rat$ra!]$ra%h$ra!e$ra~P$'`O#i$taP$taR$ta[$taa$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta'x$ta(_$ta(p$ta!i$ta!W$ta'u$tat$ta!]$ta%h$ta!e$ta~P$(RO#i%SaP%SaR%Sa[%Saa%Sap%Sa!Q%Sa!Z%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa'x%Sa(_%Sa(p%Sa!i%Sa!W%Sa'u%Sa#^%Sat%Sa!]%Sa%h%Sa!e%Sa~P#.{Oa#aq!Z#aq'x#aq'u#aq!W#aq!i#aqt#aq!]#aq%h#aq!e#aq~P!:TO!Y3dO!Z'WX!i'WX~P%[O!Z.oO!i(ia~O!Z.oO!i(ia~P!:TO!W3gO~O#}!la![!la~PKZO#}!ha!Z!ha![!ha~P#BPO#}!pa![!pa~P!<kO#}!ra![!ra~P!?ROg'ZX!Z'ZX~P!+rO!Z.zOg(na~OSfO!]3{O$c3|O~O![4QO~Ot4RO~P#.{Oa$lq!Z$lq'x$lq'u$lq!W$lq!i$lqt$lq!]$lq%h$lq!e$lq~P!:TO!W4TO~P!&iO!Q4UO~O!O)|O'w)}O(x%POl'ga(w'ga!Z'ga#^'ga~Og'ga#}'ga~P%+uO!O)|O'w)}Ol'ia(w'ia(x'ia!Z'ia#^'ia~Og'ia#}'ia~P%,hO(p$YO~P#.{O!WfX!W$yX!ZfX!Z$yX!e%QX#^fX~P!/qO(R<xO~P!1dO!Q%gO!Y4XO!]%hO(R%fO!Z'cX!i'cX~O!Z/kO!i(|a~O!Z/kO!e#vO!i(|a~O!Z/kO!e#vO(p'nO!i(|a~Og${i!Z${i#^${i#}${i~P!0uO!Y4aO!W'eX!Z'eX~P!3cO!Z/sO!W(}a~O!Z/sO!W(}a~P#.{OP]XR]X[]Xp]X!O]X!Q]X!W]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!e%XX#t%XX~P%0XO!e#vO#t4fO~Oh%VO!e#vO!j%dO~Oh%VOp4kO!j%dO(p'nO~Op4pO!e#vO(p'nO~Oq!nO!Q4qO(TTO(WUO(c!mO~O(w$}Ol%`i!O%`i'w%`i(x%`i!Z%`i#^%`i~Og%`i#}%`i~P%3xO(x%POl%bi!O%bi'w%bi(w%bi!Z%bi#^%bi~Og%bi#}%bi~P%4kOg(]i!Z(]i~P!0uO#^4wOg(]i!Z(]i~P!0uO!i4zO~Oa$nq!Z$nq'x$nq'u$nq!W$nq!i$nqt$nq!]$nq%h$nq!e$nq~P!:TO!W5QO~O!Z5RO!])OX~P#.{Oa]Xa$yX!]]X!]$yX%]]X'x]X'x$yX!Z]X!Z$yX~P!/qO%]5UOa%Za!]%Za'x%Za!Z%Za~OlmX!OmX'wmX(wmX(xmX~P%7nOn5VO(R#nO~Ob5]O%i5^O(R+nO(TTO(WUO!Z'rX!['rX~O!Z0}O![)Va~O[5bO~O`5cO~Oa%mO'x%mO~P#.{O!Z5kO#^5mO![)SX~O![5nO~Op5tOq!nO!Q*fO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!pO#U!pO#V!pO#Y5sO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O![5rO~P%:ROl5yO!]1gO%h5xO~Oh%VOl5yO!]1gO%h5xO~Ob6QO(R#nO(TTO(WUO!Z'qX!['qX~O!Z1rO![)Ta~O(TTO(WUO(c6SO~O`6WO~O#t6ZO&Y6[O~PMvO!i6]O~P%[Oa6_O~Oa6_O~P%[Ob2YO![6dO&h2XO~P`O!e6fO~O!e6hOh(hi!Z(hi![(hi!e(hi!j(hip(hi(p(hi~O!Z#fi![#fi~P#BPO#^6iO!Z#fi![#fi~O!Z!_i![!_i~P#BPOa%mO#^6rO'x%mO~Oa%mO!e#vO#^6rO'x%mO~O!Z(rq!i(rqa(rq'x(rq~P!:TO!Z(hO!i(qq~O!Q%gO!]%hO#h6yO(R%fO~O!]'^O%h6|O~Ol7QO!]'^O%h6|O~O#i'gaP'gaR'ga['gaa'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga'x'ga(_'ga(p'ga!i'ga!W'ga'u'gat'ga!]'ga%h'ga!e'ga~P%+uO#i'iaP'iaR'ia['iaa'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia'x'ia(_'ia(p'ia!i'ia!W'ia'u'iat'ia!]'ia%h'ia!e'ia~P%,hO#i${iP${iR${i[${ia${ip${i!Q${i!Z${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i'x${i(_${i(p${i!i${i!W${i'u${i#^${it${i!]${i%h${i!e${i~P#.{O#i%`iP%`iR%`i[%`ia%`ip%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i'x%`i(_%`i(p%`i!i%`i!W%`i'u%`it%`i!]%`i%h%`i!e%`i~P%3xO#i%biP%biR%bi[%bia%bip%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi'x%bi(_%bi(p%bi!i%bi!W%bi'u%bit%bi!]%bi%h%bi!e%bi~P%4kO!Z'Wa!i'Wa~P!:TO!Z.oO!i(ii~O#}#ai!Z#ai![#ai~P#BPOP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kip#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#l#ki~P%MQO#l<PO~P%MQOP$[OR#zOp<]O!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO[#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#p#ki~P& YO#p<RO~P& YOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO(_VO#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#u#ki~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO(_VO(x#}O#y#ki#z#ki#}#ki(p#ki(w#ki!Z#ki![#ki~O#w<VO~P&%cO#w#ki~P&%cO#u<TO~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO(_VO(w#|O(x#}O#z#ki#}#ki(p#ki!Z#ki![#ki~O#y#ki~P&'rO#y<XO~P&'rOa#{y!Z#{y'x#{y'u#{y!W#{y!i#{yt#{y!]#{y%h#{y!e#{y~P!:TO[#kip#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki!Z#ki![#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO(w#ki(x#ki~P&*nOl=}O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P&*nO#Q$dOP(^XR(^X[(^Xl(^Xp(^X!O(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X#}(^X'w(^X(_(^X(p(^X(w(^X(x(^X!Z(^X![(^X~O#}$Oi!Z$Oi![$Oi~P#BPO#}!pi![!pi~P$*OOg'Za!Z'Za~P!0uO![7dO~O!Z'ba!['ba~P#BPO!W7eO~P#.{O!e#vO(p'nO!Z'ca!i'ca~O!Z/kO!i(|i~O!Z/kO!e#vO!i(|i~Og${q!Z${q#^${q#}${q~P!0uO!W'ea!Z'ea~P#.{O!e7lO~O!Z/sO!W(}i~P#.{O!Z/sO!W(}i~O!W7oO~Oh%VOp7tO!j%dO(p'nO~O!e#vO#t7vO~Op7yO!e#vO(p'nO~O!O)|O'w)}O(x%POl'ha(w'ha!Z'ha#^'ha~Og'ha#}'ha~P&3oO!O)|O'w)}Ol'ja(w'ja(x'ja!Z'ja#^'ja~Og'ja#}'ja~P&4bO!W7{O~Og$}q!Z$}q#^$}q#}$}q~P!0uOg(]q!Z(]q~P!0uO#^7|Og(]q!Z(]q~P!0uOa$ny!Z$ny'x$ny'u$ny!W$ny!i$nyt$ny!]$ny%h$ny!e$ny~P!:TO!e6hO~O!Z5RO!])Oa~O!]'^OP$SaR$Sa[$Sap$Sa!O$Sa!Q$Sa!Z$Sa!j$Sa!n$Sa#P$Sa#l$Sa#m$Sa#n$Sa#o$Sa#p$Sa#q$Sa#r$Sa#s$Sa#t$Sa#u$Sa#w$Sa#y$Sa#z$Sa(_$Sa(p$Sa(w$Sa(x$Sa~O%h6|O~P&7SO%]8QOa%Zi!]%Zi'x%Zi!Z%Zi~Oa#ay!Z#ay'x#ay'u#ay!W#ay!i#ayt#ay!]#ay%h#ay!e#ay~P!:TO[8SO~Ob8UO(R+nO(TTO(WUO~O!Z0}O![)Vi~O`8YO~O(c(zO!Z'nX!['nX~O!Z5kO![)Sa~O![8cO~P%:RO(m!sO~P$$oO#Y8dO~O!]1gO~O!]1gO%h8fO~Ol8iO!]1gO%h8fO~O[8nO!Z'qa!['qa~O!Z1rO![)Ti~O!i8rO~O!i8sO~O!i8vO~O!i8vO~P%[Oa8xO~O!e8yO~O!i8zO~O!Z(ui![(ui~P#BPOa%mO#^9SO'x%mO~O!Z(ry!i(rya(ry'x(ry~P!:TO!Z(hO!i(qy~O%h9VO~P&7SO!]'^O%h9VO~O#i${qP${qR${q[${qa${qp${q!Q${q!Z${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q'x${q(_${q(p${q!i${q!W${q'u${q#^${qt${q!]${q%h${q!e${q~P#.{O#i'haP'haR'ha['haa'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha'x'ha(_'ha(p'ha!i'ha!W'ha'u'hat'ha!]'ha%h'ha!e'ha~P&3oO#i'jaP'jaR'ja['jaa'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja'x'ja(_'ja(p'ja!i'ja!W'ja'u'jat'ja!]'ja%h'ja!e'ja~P&4bO#i$}qP$}qR$}q[$}qa$}qp$}q!Q$}q!Z$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q'x$}q(_$}q(p$}q!i$}q!W$}q'u$}q#^$}qt$}q!]$}q%h$}q!e$}q~P#.{O!Z'Wi!i'Wi~P!:TO#}#aq!Z#aq![#aq~P#BPO(w$}OP%`aR%`a[%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a#}%`a(_%`a(p%`a!Z%`a![%`a~Ol%`a!O%`a'w%`a(x%`a~P&HgO(x%POP%baR%ba[%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba#}%ba(_%ba(p%ba!Z%ba![%ba~Ol%ba!O%ba'w%ba(w%ba~P&JnOl=}O!O)|O'w)}O(x%PO~P&HgOl=}O!O)|O'w)}O(w$}O~P&JnOR0cO!O0cO!Q0dO#Q$dOP{a[{al{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a#}{a'w{a(_{a(p{a(w{a(x{a!Z{a![{a~O!O)|O'w)}OP$raR$ra[$ral$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra#}$ra(_$ra(p$ra(w$ra(x$ra!Z$ra![$ra~O!O)|O'w)}OP$taR$ta[$tal$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta#}$ta(_$ta(p$ta(w$ta(x$ta!Z$ta![$ta~Ol=}O!O)|O'w)}O(w$}O(x%PO~OP%SaR%Sa[%Sap%Sa!Q%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa#}%Sa(_%Sa(p%Sa!Z%Sa![%Sa~P'%sO#}$lq!Z$lq![$lq~P#BPO#}$nq!Z$nq![$nq~P#BPO![9dO~O#}9eO~P!0uO!e#vO!Z'ci!i'ci~O!e#vO(p'nO!Z'ci!i'ci~O!Z/kO!i(|q~O!W'ei!Z'ei~P#.{O!Z/sO!W(}q~Op9lO!e#vO(p'nO~O[9nO!W9mO~P#.{O!W9mO~O!e#vO#t9tO~Og(]y!Z(]y~P!0uO!Z'la!]'la~P#.{Oa%Zq!]%Zq'x%Zq!Z%Zq~P#.{O[9yO~O!Z0}O![)Vq~O#^9}O!Z'na!['na~O!Z5kO![)Si~P#BPO!Q:PO~O!]1gO%h:SO~O(TTO(WUO(c:XO~O!Z1rO![)Tq~O!i:[O~O!i:]O~O!i:^O~O!i:^O~P%[O#^:aO!Z#fy![#fy~O!Z#fy![#fy~P#BPO%h:fO~P&7SO!]'^O%h:fO~O#}#{y!Z#{y![#{y~P#BPOP${iR${i[${ip${i!Q${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i#}${i(_${i(p${i!Z${i![${i~P'%sO!O)|O'w)}O(x%POP'gaR'ga['gal'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga#}'ga(_'ga(p'ga(w'ga!Z'ga!['ga~O!O)|O'w)}OP'iaR'ia['ial'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia#}'ia(_'ia(p'ia(w'ia(x'ia!Z'ia!['ia~O(w$}OP%`iR%`i[%`il%`ip%`i!O%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i#}%`i'w%`i(_%`i(p%`i(x%`i!Z%`i![%`i~O(x%POP%biR%bi[%bil%bip%bi!O%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi#}%bi'w%bi(_%bi(p%bi(w%bi!Z%bi![%bi~O#}$ny!Z$ny![$ny~P#BPO#}#ay!Z#ay![#ay~P#BPO!e#vO!Z'cq!i'cq~O!Z/kO!i(|y~O!W'eq!Z'eq~P#.{Op:pO!e#vO(p'nO~O[:tO!W:sO~P#.{O!W:sO~Og(]!R!Z(]!R~P!0uOa%Zy!]%Zy'x%Zy!Z%Zy~P#.{O!Z0}O![)Vy~O!Z5kO![)Sq~O(R:zO~O!]1gO%h:}O~O!i;QO~O%h;VO~P&7SOP${qR${q[${qp${q!Q${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q#}${q(_${q(p${q!Z${q![${q~P'%sO!O)|O'w)}O(x%POP'haR'ha['hal'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha#}'ha(_'ha(p'ha(w'ha!Z'ha!['ha~O!O)|O'w)}OP'jaR'ja['jal'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja#}'ja(_'ja(p'ja(w'ja(x'ja!Z'ja!['ja~OP$}qR$}q[$}qp$}q!Q$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q#}$}q(_$}q(p$}q!Z$}q![$}q~P'%sOg%d!Z!Z%d!Z#^%d!Z#}%d!Z~P!0uO!W;ZO~P#.{Op;[O!e#vO(p'nO~O[;^O!W;ZO~P#.{O!Z'nq!['nq~P#BPO!Z#f!Z![#f!Z~P#BPO#i%d!ZP%d!ZR%d!Z[%d!Za%d!Zp%d!Z!Q%d!Z!Z%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z'x%d!Z(_%d!Z(p%d!Z!i%d!Z!W%d!Z'u%d!Z#^%d!Zt%d!Z!]%d!Z%h%d!Z!e%d!Z~P#.{Op;fO!e#vO(p'nO~O!W;gO~P#.{Op;nO!e#vO(p'nO~O!W;oO~P#.{OP%d!ZR%d!Z[%d!Zp%d!Z!Q%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z#}%d!Z(_%d!Z(p%d!Z!Z%d!Z![%d!Z~P'%sOp;rO!e#vO(p'nO~Ot(dX~P1qO!O%qO~P!(yO(S!lO~P!(yO!WfX!ZfX#^fX~P%0XOP]XR]X[]Xp]X!O]X!Q]X!Z]X!ZfX!j]X!n]X#P]X#Q]X#^]X#^fX#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!efX!i]X!ifX(pfX~P'JlOP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]XO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z<ZO![$pa~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<fO!Q${O!]$|O!g=wO!j$xO#h<lO$V%_O$s<hO$u<jO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Oj)bO~P( bOp!cX(p!cX~P# qOp(hX(p(hX~P#!dO![]X![fX~P'JlO!WfX!W$yX!ZfX!Z$yX#^fX~P!/qO#i<OO~O!e#vO#i<OO~O#^<`O~O#t<SO~O#^<pO!Z(uX![(uX~O#^<`O!Z(sX![(sX~O#i<qO~Og<sO~P!0uO#i<yO~O#i<zO~O!e#vO#i<{O~O!e#vO#i<qO~O#}<|O~P#BPO#i<}O~O#i=OO~O#i=TO~O#i=UO~O#i=VO~O#i=WO~O#}=XO~P!0uO#}=YO~P!0uO#Q#R#S#U#V#Y#g#h#s$m$s$u$x%[%]%g%h%i%p%r%u%v%x%z~'|T#m!V'z(S#nq#l#op!O'{$['{(R$^(c~",
+     goto: "$8f)ZPPPPPP)[PP)_P)pP+Q/VPPPP6aPP6wPP<oP@cP@yP@yPPP@yPCRP@yP@yP@yPCVPC[PCyPHsPPPHwPPPPHwKzPPPLQLrPHwPHwPP! QHwPPPHwPHwP!#XHwP!&o!'t!'}P!(q!(u!(q!,SPPPPPPP!,s!'tPP!-T!.uP!2RHwHw!2W!5d!:Q!:Q!>PPPP!>XHwPPPPPPPPPP!AhP!BuPPHw!DWPHwPHwHwHwHwHwPHw!EjP!HtP!KzP!LO!LY!L^!L^P!HqP!Lb!LbP# hP# lHwPHw# r#$wCV@yP@yP@y@yP#&U@y@y#(h@y#+`@y#-l@y@y#.[#0p#0p#0u#1O#0p#1ZPP#0pP@y#1s@y#5r@y@y6aPPP#9wPPP#:b#:bP#:bP#:x#:bPP#;OP#:uP#:u#;c#:u#;}#<T#<W)_#<Z)_P#<b#<b#<bP)_P)_P)_P)_PP)_P#<h#<kP#<k)_P#<oP#<rP)_P)_P)_P)_P)_P)_)_PP#<x#=O#=Z#=a#=g#=m#=s#>R#>X#>c#>i#>s#>y#?Z#?a#@R#@e#@k#@q#AP#Af#CZ#Ci#Cp#E[#Ej#G[#Gj#Gp#Gv#G|#HW#H^#Hd#Hn#IQ#IWPPPPPPPPPPP#I^PPPPPPP#JR#MY#Nr#Ny$ RPPP$&mP$&v$)o$0Y$0]$0`$1_$1b$1i$1qP$1w$1zP$2h$2l$3d$4r$4w$5_PP$5d$5j$5n$5q$5u$5y$6u$7^$7u$7y$7|$8P$8V$8Y$8^$8bR!|RoqOXst!Z#d%l&p&r&s&u,n,s2S2VY!vQ'^-`1g5qQ%svQ%{yQ&S|Q&h!VS'U!e-WQ'd!iS'j!r!yU*h$|*X*lQ+l%|Q+y&UQ,_&bQ-^']Q-h'eQ-p'kQ0U*nQ1q,`R<m;z%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y,k,n,s-d-l-z.Q.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3d4q5y6Z6[6_6r8i8x9SS#q];w!r)]$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sU*{%[<e<fQ+q&OQ,a&eQ,h&mQ0r+dQ0u+fQ1S+rQ1y,fQ3W.bQ5V0wQ5]0}Q6Q1rQ7O3[Q8U5^R9Y7Q'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s!S!nQ!r!v!y!z$|'U']'^'j'k'l*h*l*n*o-W-^-`-p0U0X1g5q5s%[$ti#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}Q&V|Q'S!eS'Y%h-ZQ+q&OQ,a&eQ0f+OQ1S+rQ1X+xQ1x,eQ1y,fQ5]0}Q5f1ZQ6Q1rQ6T1tQ6U1wQ8U5^Q8X5cQ8q6WQ9|8YQ:Y8nR<o*XrnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VR,c&i&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=r=s[#]WZ#W#Z'V(R!b%im#h#i#l$x%d%g([(f(g(h*W*[*_+W+X+Z,j-Q.O.U.V.W.Y/h/k2[3S3T4X6h6yQ%vxQ%zyS&P|&UQ&]!TQ'a!hQ'c!iQ(o#sS+k%{%|Q+o&OQ,Y&`Q,^&bS-g'd'eQ.d(pQ0{+lQ1R+rQ1T+sQ1W+wQ1l,ZS1p,_,`Q2t-hQ5[0}Q5`1QQ5e1YQ6P1qQ8T5^Q8W5bQ9x8SR:w9y!U$zi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y!^%xy!i!u%z%{%|'T'c'd'e'i's*g+k+l-T-g-h-o/{0O0{2m2t2{4i4j4m7s9pQ+e%vQ,O&YQ,R&ZQ,]&bQ.c(oQ1k,YU1o,^,_,`Q3].dQ5z1lS6O1p1qQ8m6P#f=t#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}o=u<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YW%Ti%V*v=pS&Y!Q&gQ&Z!RQ&[!SQ+S%cR+|&W%]%Si#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}T)x$u)yV*{%[<e<fW'Y!e%h*X-ZS({#y#zQ+`%qQ+v&RS.](k(lQ1b,SQ4x0cR8^5k'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s$i$^c#Y#e%p%r%t(Q(W(r(w)P)Q)R)S)T)U)V)W)X)Y)[)^)`)e)o+a+u-U-s-x-}.P.n.q.u.w.x.y/]0j2c2f2v2}3c3h3i3j3k3l3m3n3o3p3q3r3s3t3w3x4P5O5Y6k6q6v7V7W7a7b8`8|9Q9[9b9c:c:y;R;x=gT#TV#U'RkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ'W!eR2i-W!W!nQ!e!r!v!y!z$|'U']'^'j'k'l*X*h*l*n*o-W-^-`-p0U0X1g5q5sR1d,UnqOXst!Z#d%l&p&r&s&u,n,s2S2VQ&w!^Q't!xS(q#u<OQ+i%yQ,W&]Q,X&_Q-e'bQ-r'mS.m(v<qS0k+U<{Q0y+jQ1f,VQ2Z,uQ2],vQ2e-RQ2r-fQ2u-jS5P0l=VQ5W0zS5Z0|=WQ6j2gQ6n2sQ6s2zQ8R5XQ8}6lQ9O6oQ9R6tR:`8z$d$]c#Y#e%r%t(Q(W(r(w)P)Q)R)S)T)U)V)W)X)Y)[)^)`)e)o+a+u-U-s-x-}.P.n.q.u.x.y/]0j2c2f2v2}3c3h3i3j3k3l3m3n3o3p3q3r3s3t3w3x4P5O5Y6k6q6v7V7W7a7b8`8|9Q9[9b9c:c:y;R;x=gS(m#p'gQ(}#zS+_%p.wS.^(l(nR3U._'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sS#q];wQ&r!XQ&s!YQ&u![Q&v!]R2R,qQ'_!hQ+b%vQ-c'aS.`(o+eQ2p-bW3Y.c.d0q0sQ6m2qW6z3V3X3]5TU9U6{6}7PU:e9W9X9ZS;T:d:gQ;b;UR;j;cU!wQ'^-`T5o1g5q!Q_OXZ`st!V!Z#d#h%d%l&g&i&p&r&s&u(h,n,s.V2S2V]!pQ!r'^-`1g5qT#q];w%^{OPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SS({#y#zS.](k(l!s=^$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sU$fd)],hS(n#p'gU*s%R(u3vU0e*z.i7]Q5T0rQ6{3WQ9X7OR:g9Ym!tQ!r!v!y!z'^'j'k'l-`-p1g5q5sQ'r!uS(d#g1|S-n'i'uQ/n*ZQ/{*gQ2|-qQ4]/oQ4i/}Q4j0OQ4o0WQ7h4WS7s4k4mS7w4p4rQ9g7iQ9k7oQ9p7tQ9u7yS:o9l9mS;Y:p:sS;e;Z;[S;m;f;gS;q;n;oR;t;rQ#wbQ'q!uS(c#g1|S(e#m+TQ+V%eQ+g%wQ+m%}U-m'i'r'uQ.R(dQ/m*ZQ/|*gQ0P*iQ0x+hQ1m,[S2y-n-qQ3R.ZS4[/n/oQ4e/yS4h/{0WQ4l0QQ5|1nQ6u2|Q7g4WQ7k4]U7r4i4o4rQ7u4nQ8k5}S9f7h7iQ9j7oQ9r7wQ9s7xQ:V8lQ:m9gS:n9k9mQ:v9uQ;P:WS;X:o:sS;d;Y;ZS;l;e;gS;p;m;oQ;s;qQ;u;tQ=a=[Q=l=eR=m=fV!wQ'^-`%^aOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SS#wz!j!r=Z$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sR=a=r%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SQ%ej!^%wy!i!u%z%{%|'T'c'd'e'i's*g+k+l-T-g-h-o/{0O0{2m2t2{4i4j4m7s9pS%}z!jQ+h%xQ,[&bW1n,],^,_,`U5}1o1p1qS8l6O6PQ:W8m!r=[$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ=e=qR=f=r%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SY#bWZ#W#Z(R!b%im#h#i#l$x%d%g([(f(g(h*W*[*_+W+X+Z,j-Q.O.U.V.W.Y/h/k2[3S3T4X6h6yQ,i&m!p=]$Z$n)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sR=`'VU'Z!e%h*XR2k-Z%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y,k,n,s-d-l-z.Q.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3d4q5y6Z6[6_6r8i8x9S!r)]$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ,h&mQ0r+dQ3W.bQ7O3[R9Y7Q!b$Tc#Y%p(Q(W(r(w)X)Y)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;x!P<U)[)o-U.w2c2f3h3q3r3w4P6k7W7a7b8`8|9[9b9c:y;R=g!f$Vc#Y%p(Q(W(r(w)U)V)X)Y)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;x!T<W)[)o-U.w2c2f3h3n3o3q3r3w4P6k7W7a7b8`8|9[9b9c:y;R=g!^$Zc#Y%p(Q(W(r(w)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;xQ4V/fz=s)[)o-U.w2c2f3h3w4P6k7W7a7b8`8|9[9b9c:y;R=gQ=x=zR=y={'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sS$oh$pR3|/P'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/P/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sT$kf$qQ$ifS)h$l)lR)t$qT$jf$qT)j$l)l'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/P/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sT$oh$pQ$rhR)s$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9S!s=q$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s#glOPXZst!Z!`!o#S#d#o#{$n%l&i&l&m&p&r&s&u&y'R'`(|)q*f+Y+d,k,n,s-d.b/Q/i0V0d1j1z1{1}2P2S2V2X3[3{4q5y6Z6[6_7Q8i8x!U%Ri$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y#f(u#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}Q+P%`Q/^)|o3v<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!U$yi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=yQ*`$zU*i$|*X*lQ+Q%aQ0Q*j#f=c#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n=d<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YQ=h=tQ=i=uQ=j=vR=k=w!U%Ri$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y#f(u#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}o3v<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YnoOXst!Z#d%l&p&r&s&u,n,s2S2VS*c${*WQ,|&|Q,}'OR4`/s%[%Si#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}Q,P&ZQ1`,RQ5i1_R8]5jV*k$|*X*lU*k$|*X*lT5p1g5qS/y*f/iQ4n0VT7x4q:PQ+g%wQ0P*iQ0x+hQ1m,[Q5|1nQ8k5}Q:V8lR;P:W!U%Oi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=yx*P$v)c*Q*r+R/q0^0_3y4^4{4|4}7f7z9v:l=b=n=oS0Y*q0Z#f<a#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n<b<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!d<t(s)a*Y*b.e.h.l/Y/f/v0p1]3`4S4_4c5h7R7U7m7p7}8P9i9q9w:q:u;W;];h=z={`<u3u7X7[7`9]:h:k;kS=P.g3aT=Q7Z9`!U%Qi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y|*R$v)c*S*q+R/b/q0^0_3y4^4s4{4|4}7f7z9v:l=b=n=oS0[*r0]#f<c#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n<d<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!h<v(s)a*Y*b.f.g.l/Y/f/v0p1]3^3`4S4_4c5h7R7S7U7m7p7}8P9i9q9w:q:u;W;];h=z={d<w3u7Y7Z7`9]9^:h:i:k;kS=R.h3bT=S7[9arnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VQ&d!UR,k&mrnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VR&d!UQ,T&[R1[+|snOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VQ1h,YS5w1k1lU8e5u5v5zS:R8g8hS:{:Q:TQ;_:|R;i;`Q&k!VR,d&gR6T1tR:Y8nS&P|&UR1T+sQ&p!WR,n&qR,t&vT2T,s2VR,x&wQ,w&wR2^,xQ'w!{R-t'wSsOtQ#dXT%os#dQ#OTR'y#OQ#RUR'{#RQ)y$uR/Z)yQ#UVR(O#UQ#XWU(U#X(V-{Q(V#YR-{(WQ-X'WR2j-XQ.p(wS3e.p3fR3f.qQ-`'^R2n-`Y!rQ'^-`1g5qR'h!rQ.{)cR3z.{U#_W%g*WU(]#_(^-|Q(^#`R-|(XQ-['ZR2l-[t`OXst!V!Z#d%l&g&i&p&r&s&u,n,s2S2VS#hZ%dU#r`#h.VR.V(hQ(i#jQ.S(eW.[(i.S3P6wQ3P.TR6w3QQ)l$lR/R)lQ$phR)r$pQ$`cU)_$`-w<[Q-w;xR<[)oQ/l*ZW4Y/l4Z7j9hU4Z/m/n/oS7j4[4]R9h7k$e*O$v(s)a)c*Y*b*q*r*|*}+R.g.h.j.k.l/Y/b/d/f/q/v0^0_0p1]3^3_3`3u3y4S4^4_4c4s4u4{4|4}5h7R7S7T7U7Z7[7^7_7`7f7m7p7z7}8P9]9^9_9i9q9v9w:h:i:j:k:l:q:u;W;];h;k=b=n=o=z={Q/t*bU4b/t4d7nQ4d/vR7n4cS*l$|*XR0S*lx*Q$v)c*q*r+R/q0^0_3y4^4{4|4}7f7z9v:l=b=n=o!d.e(s)a*Y*b.g.h.l/Y/f/v0p1]3`4S4_4c5h7R7U7m7p7}8P9i9q9w:q:u;W;];h=z={U/c*Q.e7Xa7X3u7Z7[7`9]:h:k;kQ0Z*qQ3a.gU4t0Z3a9`R9`7Z|*S$v)c*q*r+R/b/q0^0_3y4^4s4{4|4}7f7z9v:l=b=n=o!h.f(s)a*Y*b.g.h.l/Y/f/v0p1]3^3`4S4_4c5h7R7S7U7m7p7}8P9i9q9w:q:u;W;];h=z={U/e*S.f7Ye7Y3u7Z7[7`9]9^:h:i:k;kQ0]*rQ3b.hU4v0]3b9aR9a7[Q*w%UR0a*wQ5S0pR8O5SQ+[%jR0o+[Q5l1bS8_5l:OR:O8`Q,V&]R1e,VQ5q1gR8b5qQ1s,aS6R1s8oR8o6TQ1O+oW5_1O5a8V9zQ5a1RQ8V5`R9z8WQ+t&PR1U+tQ2V,sR6c2VYrOXst#dQ&t!ZQ+^%lQ,m&pQ,o&rQ,p&sQ,r&uQ2Q,nS2T,s2VR6b2SQ%npQ&x!_Q&{!aQ&}!bQ'P!cQ'o!uQ+]%kQ+i%yQ+{&VQ,c&kQ,z&zW-k'i'q'r'uQ-r'mQ0R*kQ0y+jS1v,d,gQ2_,yQ2`,|Q2a,}Q2u-jW2w-m-n-q-sQ5W0zQ5d1XQ5g1]Q5{1mQ6V1xQ6a2RU6p2v2y2|Q6s2zQ8R5XQ8Z5fQ8[5hQ8a5pQ8j5|Q8p6US9P6q6uQ9R6tQ9{8XQ:U8kQ:Z8qQ:b9QQ:x9|Q;O:VQ;S:cR;a;PQ%yyQ'b!iQ'm!uU+j%z%{%|Q-R'TU-f'c'd'eS-j'i'sQ/z*gS0z+k+lQ2g-TS2s-g-hQ2z-oS4g/{0OQ5X0{Q6l2mQ6o2tQ6t2{U7q4i4j4mQ9o7sR:r9pS$wi=pR*x%VU%Ui%V=pR0`*vQ$viS(s#v+fS)a$b$cQ)c$dQ*Y$xS*b${*WQ*q%OQ*r%QQ*|%]Q*}%^Q+R%bQ.g<aQ.h<cQ.j<gQ.k<iQ.l<kQ/Y)wQ/b*PQ/d*RQ/f*TQ/q*^S/v*d/hQ0^*tQ0_*ul0p+c,Q.a1a1i3Z5x6|8f9V:S:f:};VQ1]+}Q3^<tQ3_<vQ3`<yS3u<^<_Q3y.zS4S/_4UQ4^/rQ4_/sQ4c/uQ4s0YQ4u0[Q4{0gQ4|0hQ4}0iQ5h1^Q7R<}Q7S=PQ7T=RQ7U=TQ7Z<bQ7[<dQ7^<hQ7_<jQ7`<lQ7f4VQ7m4aQ7p4fQ7z4wQ7}5RQ8P5UQ9]<zQ9^<uQ9_<wQ9i7lQ9q7vQ9v7|Q9w8QQ:h=OQ:i=QQ:j=SQ:k=UQ:l9eQ:q9nQ:u9tQ;W=XQ;]:tQ;h;^Q;k=YQ=b=pQ=n=xQ=o=yQ=z=|R={=}Q*z%[Q.i<eR7]<fnpOXst!Z#d%l&p&r&s&u,n,s2S2VQ!fPS#fZ#oQ&z!`W'f!o*f0V4qQ'}#SQ)O#{Q)p$nS,g&i&lQ,l&mQ,y&yS-O'R/iQ-b'`Q.s(|Q/V)qQ0m+YQ0s+dQ2O,kQ2q-dQ3X.bQ4O/QQ4y0dQ5v1jQ6X1zQ6Y1{Q6^1}Q6`2PQ6e2XQ7P3[Q7c3{Q8h5yQ8t6ZQ8u6[Q8w6_Q9Z7QQ:T8iR:_8x#[cOPXZst!Z!`!o#d#o#{%l&i&l&m&p&r&s&u&y'R'`(|*f+Y+d,k,n,s-d.b/i0V0d1j1z1{1}2P2S2V2X3[4q5y6Z6[6_7Q8i8xQ#YWQ#eYQ%puQ%rvS%tw!gS(Q#W(TQ(W#ZQ(r#uQ(w#xQ)P$OQ)Q$PQ)R$QQ)S$RQ)T$SQ)U$TQ)V$UQ)W$VQ)X$WQ)Y$XQ)[$ZQ)^$_Q)`$aQ)e$eW)o$n)q/Q3{Q+a%sQ+u&QS-U'V2hQ-s'pS-x(R-zQ-}(ZQ.P(bQ.n(vQ.q(xQ.u;vQ.w;yQ.x;zQ.y;}Q/]){Q0j+UQ2c-PQ2f-SQ2v-lQ2}.QQ3c.oQ3h<OQ3i<PQ3j<QQ3k<RQ3l<SQ3m<TQ3n<UQ3o<VQ3p<WQ3q<XQ3r<YQ3s.vQ3t<]Q3w<`Q3x<mQ4P<ZQ5O0lQ5Y0|Q6k<pQ6q2xQ6v3OQ7V3dQ7W<qQ7a<sQ7b<{Q8`5mQ8|6iQ9Q6rQ9[<|Q9b=VQ9c=WQ:c9SQ:y9}Q;R:aQ;x#SR=g=sR#[WR'X!el!tQ!r!v!y!z'^'j'k'l-`-p1g5q5sS'T!e-WU*g$|*X*lS-T'U']S0O*h*nQ0W*oQ2m-^Q4m0UR4r0XR(y#xQ!fQT-_'^-`]!qQ!r'^-`1g5qQ#p]R'g;wR)d$dY!uQ'^-`1g5qQ'i!rS's!v!yS'u!z5sS-o'j'kQ-q'lR2{-pT#kZ%dS#jZ%dS%jm,jU(e#h#i#lS.T(f(gQ.X(hQ0n+ZQ3Q.UU3R.V.W.YS6x3S3TR9T6yd#^W#W#Z%g(R([*W+W.O/hr#gZm#h#i#l%d(f(g(h+Z.U.V.W.Y3S3T6yS*Z$x*_Q/o*[Q1|,jQ2d-QQ4W/kQ6g2[Q7i4XQ8{6hT=_'V+XV#aW%g*WU#`W%g*WS(S#W([U(X#Z+W/hS-V'V+XT-y(R.OV'[!e%h*XQ$lfR)v$qT)k$l)lR3}/PT*]$x*_T*e${*WQ0q+cQ1_,QQ3V.aQ5j1aQ5u1iQ6}3ZQ8g5xQ9W6|Q:Q8fQ:d9VQ:|:SQ;U:fQ;`:}R;c;VnqOXst!Z#d%l&p&r&s&u,n,s2S2VQ&j!VR,c&gtmOXst!U!V!Z#d%l&g&p&r&s&u,n,s2S2VR,j&mT%km,jR1c,SR,b&eQ&T|R+z&UR+p&OT&n!W&qT&o!W&qT2U,s2V",
+     nodeNames: "⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",
+     maxTerm: 378,
+     context: trackNewline,
+     nodeProps: [
+       ["isolate", -8,5,6,14,35,37,49,51,53,""],
+       ["group", -26,9,17,19,66,206,210,214,215,217,220,223,233,235,241,243,245,247,250,256,262,264,266,268,270,272,273,"Statement",-34,13,14,30,33,34,40,49,52,53,55,60,68,70,74,78,80,82,83,108,109,118,119,135,138,140,141,142,143,144,146,147,166,168,170,"Expression",-23,29,31,35,39,41,43,172,174,176,177,179,180,181,183,184,185,187,188,189,200,202,204,205,"Type",-3,86,101,107,"ClassItem"],
+       ["openedBy", 23,"<",36,"InterpolationStart",54,"[",58,"{",71,"(",159,"JSXStartCloseTag"],
+       ["closedBy", -2,24,167,">",38,"InterpolationEnd",48,"]",59,"}",72,")",164,"JSXEndTag"]
+     ],
+     propSources: [jsHighlight],
+     skippedNodes: [0,5,6,276],
+     repeatNodeCount: 37,
+     tokenData: "$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$<r#p#q$=h#q#r$>x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(UpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(UpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$h&j(Up(X!b'z0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(V#S$h&j'{0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Up(X!b'{0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$h&j!n),Q(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(T':f$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$h&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$c`$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$c``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$c`$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(X!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Up(X!bOY%ZYZ&cZq%Zqr<Srs&}st%ZtuCruw%Zwx(rx!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr(r<__WS$h&j(Up(X!bOY<SYZ&cZr<Srs=^sw<Swx@nx!^<S!^!_Bm!_#O<S#O#P>`#P#o<S#o#pBm#p;'S<S;'S;=`Cl<%lO<S(Q=g]WS$h&j(X!bOY=^YZ&cZw=^wx>`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$h&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(X!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$h&j(UpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(UpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Up(X!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l<S%9[C}i$h&j(m%1l(Up(X!bOY%ZYZ&cZr%Zrs&}st%ZtuCruw%Zwx(rx!Q%Z!Q![Cr![!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr%9[EoP;=`<%lCr07[FRk$h&j(Up(X!b$[#t(R,2j(c$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr+dHRk$h&j(Up(X!b$[#tOY%ZYZ&cZr%Zrs&}st%ZtuGvuw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Gv![!^%Z!^!_*g!_!c%Z!c!}Gv!}#O%Z#O#P&c#P#R%Z#R#SGv#S#T%Z#T#oGv#o#p*g#p$g%Z$g;'SGv;'S;=`Iv<%lOGv+dIyP;=`<%lGv07[JPP;=`<%lEr(KWJ_`$h&j(Up(X!b#n(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWKl_$h&j$P(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,#xLva(x+JY$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sv%ZvwM{wx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWNW`$h&j#y(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At! c_(W';W$h&j(UpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b'l!!i_$h&j(UpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b&z!#mX$h&jOw!#hwx6cx!^!#h!^!_!$Y!_#o!#h#o#p!$Y#p;'S!#h;'S;=`!$r<%lO!#h`!$]TOw!$Ywx7]x;'S!$Y;'S;=`!$l<%lO!$Y`!$oP;=`<%l!$Y&z!$uP;=`<%l!#h'l!%R]$c`$h&j(UpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r!Q!&PZ(UpOY!%zYZ!$YZr!%zrs!$Ysw!%zwx!&rx#O!%z#O#P!$Y#P;'S!%z;'S;=`!']<%lO!%z!Q!&yU$c`(UpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)r!Q!'`P;=`<%l!%z'l!'fP;=`<%l!!b/5|!'t_!j/.^$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#&U!)O_!i!Lf$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z-!n!*[b$h&j(Up(X!b(S%&f#o(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rxz%Zz{!+d{!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW!+o`$h&j(Up(X!b#l(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;x!,|`$h&j(Up(X!bp+4YOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,$U!.Z_!Z+Jf$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!/ec$h&j(Up(X!b!O.2^OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!0p!P!Q%Z!Q![!3Y![!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!0ya$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!2O!P!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!2Z_!Y!L^$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!3eg$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!3Y![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S!3Y#S#X%Z#X#Y!4|#Y#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!5Vg$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx{%Z{|!6n|}%Z}!O!6n!O!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!6wc$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!8_c$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!9uf$h&j(Up(X!b#m(ChOY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcxz!;Zz{#-}{!P!;Z!P!Q#/d!Q!^!;Z!^!_#(i!_!`#7S!`!a#8i!a!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z?O!;fb$h&j(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z>^!<w`$h&j(X!b!V7`OY!<nYZ&cZw!<nwx!=yx!P!<n!P!Q!Eq!Q!^!<n!^!_!Gr!_!}!<n!}#O!KS#O#P!Dy#P#o!<n#o#p!Gr#p;'S!<n;'S;=`!L]<%lO!<n<z!>Q^$h&j!V7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!?Td$h&j!V7`O!^&c!_#W&c#W#X!>|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!V7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!V7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c<z!C][$h&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#O!CW#O#P!DR#P#Q!=y#Q#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DWX$h&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DvP;=`<%l!CW<z!EOX$h&jOY!=yYZ&cZ!^!=y!^!_!@c!_#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!EnP;=`<%l!=y>^!Ezl$h&j(X!b!V7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(X!b!V7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(X!b!V7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(X!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$h&j(X!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!<n#Q#o!KS#o#p!JU#p;'S!KS;'S;=`!LV<%lO!KS>^!LYP;=`<%l!KS>^!L`P;=`<%l!<n=l!Ll`$h&j(Up!V7`OY!LcYZ&cZr!Lcrs!=ys!P!Lc!P!Q!Mn!Q!^!Lc!^!_# o!_!}!Lc!}#O#%P#O#P!Dy#P#o!Lc#o#p# o#p;'S!Lc;'S;=`#&Y<%lO!Lc=l!Mwl$h&j(Up!V7`OY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#W(r#W#X!Mn#X#Z(r#Z#[!Mn#[#](r#]#^!Mn#^#a(r#a#b!Mn#b#g(r#g#h!Mn#h#i(r#i#j!Mn#j#k!Mn#k#m(r#m#n!Mn#n#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r8Q# vZ(Up!V7`OY# oZr# ors!@cs!P# o!P!Q#!i!Q!}# o!}#O#$R#O#P!Bq#P;'S# o;'S;=`#$y<%lO# o8Q#!pe(Up!V7`OY)rZr)rs#O)r#P#W)r#W#X#!i#X#Z)r#Z#[#!i#[#])r#]#^#!i#^#a)r#a#b#!i#b#g)r#g#h#!i#h#i)r#i#j#!i#j#k#!i#k#m)r#m#n#!i#n;'S)r;'S;=`*Z<%lO)r8Q#$WX(UpOY#$RZr#$Rrs!Ars#O#$R#O#P!B[#P#Q# o#Q;'S#$R;'S;=`#$s<%lO#$R8Q#$vP;=`<%l#$R8Q#$|P;=`<%l# o=l#%W^$h&j(UpOY#%PYZ&cZr#%Prs!CWs!^#%P!^!_#$R!_#O#%P#O#P!DR#P#Q!Lc#Q#o#%P#o#p#$R#p;'S#%P;'S;=`#&S<%lO#%P=l#&VP;=`<%l#%P=l#&]P;=`<%l!Lc?O#&kn$h&j(Up(X!b!V7`OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#W%Z#W#X#&`#X#Z%Z#Z#[#&`#[#]%Z#]#^#&`#^#a%Z#a#b#&`#b#g%Z#g#h#&`#h#i%Z#i#j#&`#j#k#&`#k#m%Z#m#n#&`#n#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z9d#(r](Up(X!b!V7`OY#(iZr#(irs!Grsw#(iwx# ox!P#(i!P!Q#)k!Q!}#(i!}#O#+`#O#P!Bq#P;'S#(i;'S;=`#,`<%lO#(i9d#)th(Up(X!b!V7`OY*gZr*grs'}sw*gwx)rx#O*g#P#W*g#W#X#)k#X#Z*g#Z#[#)k#[#]*g#]#^#)k#^#a*g#a#b#)k#b#g*g#g#h#)k#h#i*g#i#j#)k#j#k#)k#k#m*g#m#n#)k#n;'S*g;'S;=`+Z<%lO*g9d#+gZ(Up(X!bOY#+`Zr#+`rs!JUsw#+`wx#$Rx#O#+`#O#P!B[#P#Q#(i#Q;'S#+`;'S;=`#,Y<%lO#+`9d#,]P;=`<%l#+`9d#,cP;=`<%l#(i?O#,o`$h&j(Up(X!bOY#,fYZ&cZr#,frs!KSsw#,fwx#%Px!^#,f!^!_#+`!_#O#,f#O#P!DR#P#Q!;Z#Q#o#,f#o#p#+`#p;'S#,f;'S;=`#-q<%lO#,f?O#-tP;=`<%l#,f?O#-zP;=`<%l!;Z07[#.[b$h&j(Up(X!b'|0/l!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z07[#/o_$h&j(Up(X!bT0/lOY#/dYZ&cZr#/drs#0nsw#/dwx#4Ox!^#/d!^!_#5}!_#O#/d#O#P#1p#P#o#/d#o#p#5}#p;'S#/d;'S;=`#6|<%lO#/d06j#0w]$h&j(X!bT0/lOY#0nYZ&cZw#0nwx#1px!^#0n!^!_#3R!_#O#0n#O#P#1p#P#o#0n#o#p#3R#p;'S#0n;'S;=`#3x<%lO#0n05W#1wX$h&jT0/lOY#1pYZ&cZ!^#1p!^!_#2d!_#o#1p#o#p#2d#p;'S#1p;'S;=`#2{<%lO#1p0/l#2iST0/lOY#2dZ;'S#2d;'S;=`#2u<%lO#2d0/l#2xP;=`<%l#2d05W#3OP;=`<%l#1p01O#3YW(X!bT0/lOY#3RZw#3Rwx#2dx#O#3R#O#P#2d#P;'S#3R;'S;=`#3r<%lO#3R01O#3uP;=`<%l#3R06j#3{P;=`<%l#0n05x#4X]$h&j(UpT0/lOY#4OYZ&cZr#4Ors#1ps!^#4O!^!_#5Q!_#O#4O#O#P#1p#P#o#4O#o#p#5Q#p;'S#4O;'S;=`#5w<%lO#4O00^#5XW(UpT0/lOY#5QZr#5Qrs#2ds#O#5Q#O#P#2d#P;'S#5Q;'S;=`#5q<%lO#5Q00^#5tP;=`<%l#5Q05x#5zP;=`<%l#4O01p#6WY(Up(X!bT0/lOY#5}Zr#5}rs#3Rsw#5}wx#5Qx#O#5}#O#P#2d#P;'S#5};'S;=`#6v<%lO#5}01p#6yP;=`<%l#5}07[#7PP;=`<%l#/d)3h#7ab$h&j$P(Ch(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;ZAt#8vb$Y#t$h&j(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z'Ad#:Zp$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#U%Z#U#V#?i#V#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#<jk$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!e$b$h&j#})Lv(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#P-<U(Up(X!b$m7`OY*gZr*grs'}sw*gwx)rx!P*g!P!Q#MO!Q!^*g!^!_#Mt!_!`$ f!`#O*g#P;'S*g;'S;=`+Z<%lO*g(n#MXX$j&j(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El#M}Z#p(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx!_*g!_!`#Np!`#O*g#P;'S*g;'S;=`+Z<%lO*g(El#NyX$P(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El$ oX#q(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g*)x$!ga#^*!Y$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`!a$#l!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(K[$#w_#i(Cl$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x$%Vag!*r#q(Ch$e#|$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`$&[!`!a$'f!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$&g_#q(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$'qa#p(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`!a$(v!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$)R`#p(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(Kd$*`a(p(Ct$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!a%Z!a!b$+e!b#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$+p`$h&j#z(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%#`$,}_!z$Ip$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f$.X_!Q0,v$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(n$/]Z$h&jO!^$0O!^!_$0f!_#i$0O#i#j$0k#j#l$0O#l#m$2^#m#o$0O#o#p$0f#p;'S$0O;'S;=`$4i<%lO$0O(n$0VT_#S$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c#S$0kO_#S(n$0p[$h&jO!Q&c!Q![$1f![!^&c!_!c&c!c!i$1f!i#T&c#T#Z$1f#Z#o&c#o#p$3|#p;'S&c;'S;=`&w<%lO&c(n$1kZ$h&jO!Q&c!Q![$2^![!^&c!_!c&c!c!i$2^!i#T&c#T#Z$2^#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$2cZ$h&jO!Q&c!Q![$3U![!^&c!_!c&c!c!i$3U!i#T&c#T#Z$3U#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$3ZZ$h&jO!Q&c!Q![$0O![!^&c!_!c&c!c!i$0O!i#T&c#T#Z$0O#Z#o&c#p;'S&c;'S;=`&w<%lO&c#S$4PR!Q![$4Y!c!i$4Y#T#Z$4Y#S$4]S!Q![$4Y!c!i$4Y#T#Z$4Y#q#r$0f(n$4lP;=`<%l$0O#1[$4z_!W#)l$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$6U`#w(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;p$7c_$h&j(Up(X!b(_+4QOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$8qk$h&j(Up(X!b(R,2j$^#t(c$I[OY%ZYZ&cZr%Zrs&}st%Ztu$8buw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$8b![!^%Z!^!_*g!_!c%Z!c!}$8b!}#O%Z#O#P&c#P#R%Z#R#S$8b#S#T%Z#T#o$8b#o#p*g#p$g%Z$g;'S$8b;'S;=`$<l<%lO$8b+d$:qk$h&j(Up(X!b$^#tOY%ZYZ&cZr%Zrs&}st%Ztu$:fuw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$:f![!^%Z!^!_*g!_!c%Z!c!}$:f!}#O%Z#O#P&c#P#R%Z#R#S$:f#S#T%Z#T#o$:f#o#p*g#p$g%Z$g;'S$:f;'S;=`$<f<%lO$:f+d$<iP;=`<%l$:f07[$<oP;=`<%l$8b#Jf$<{X!]#Hb(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g,#x$=sa(w+JY$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p#q$+e#q;'S%Z;'S;=`+a<%lO%Z)>v$?V_![(CdtBr$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!o7`$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$h&j(Up(X!b'z0/l$[#t(R,2j(c$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$h&j(Up(X!b'{0/l$[#t(R,2j(c$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",
+     tokenizers: [noSemicolon, noSemicolonType, operatorToken, jsx, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, insertSemicolon, new LocalTokenGroup("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOv~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!S~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(a~~", 141, 338), new LocalTokenGroup("j~RQYZXz{^~^O(O~~aP!P!Qd~iO(P~~", 25, 321)],
+     topRules: {"Script":[0,7],"SingleExpression":[1,274],"SingleClassItem":[2,275]},
+     dialects: {jsx: 0, ts: 15091},
+     dynamicPrecedences: {"78":1,"80":1,"92":1,"168":1,"198":1},
+     specialized: [{term: 325, get: (value) => spec_identifier[value] || -1},{term: 341, get: (value) => spec_word[value] || -1},{term: 93, get: (value) => spec_LessThan[value] || -1}],
+     tokenPrec: 15116
+   });
+
+   // These are filled with ranges (rangeFrom[i] up to but not including
+   // rangeTo[i]) of code points that count as extending characters.
+   let rangeFrom = [], rangeTo = []
+
+   ;(() => {
+     // Compressed representation of the Grapheme_Cluster_Break=Extend
+     // information from
+     // http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
+     // Each pair of elements represents a range, as an offet from the
+     // previous range and a length. Numbers are in base-36, with the empty
+     // string being a shorthand for 1.
+     let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
+     for (let i = 0, n = 0; i < numbers.length; i++)
+       (i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i]);
+   })();
+
+   function isExtendingChar(code) {
+     if (code < 768) return false
+     for (let from = 0, to = rangeFrom.length;;) {
+       let mid = (from + to) >> 1;
+       if (code < rangeFrom[mid]) to = mid;
+       else if (code >= rangeTo[mid]) from = mid + 1;
+       else return true
+       if (from == to) return false
+     }
+   }
+
+   function isRegionalIndicator(code) {
+     return code >= 0x1F1E6 && code <= 0x1F1FF
+   }
+
+   const ZWJ = 0x200d;
+
+   function findClusterBreak$1(str, pos, forward = true, includeExtending = true) {
+     return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
+   }
+
+   function nextClusterBreak(str, pos, includeExtending) {
+     if (pos == str.length) return pos
+     // If pos is in the middle of a surrogate pair, move to its start
+     if (pos && surrogateLow$1(str.charCodeAt(pos)) && surrogateHigh$1(str.charCodeAt(pos - 1))) pos--;
+     let prev = codePointAt$1(str, pos);
+     pos += codePointSize$1(prev);
+     while (pos < str.length) {
+       let next = codePointAt$1(str, pos);
+       if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
+         pos += codePointSize$1(next);
+         prev = next;
+       } else if (isRegionalIndicator(next)) {
+         let countBefore = 0, i = pos - 2;
+         while (i >= 0 && isRegionalIndicator(codePointAt$1(str, i))) { countBefore++; i -= 2; }
+         if (countBefore % 2 == 0) break
+         else pos += 2;
+       } else {
+         break
+       }
+     }
+     return pos
+   }
+
+   function prevClusterBreak(str, pos, includeExtending) {
+     while (pos > 0) {
+       let found = nextClusterBreak(str, pos - 2, includeExtending);
+       if (found < pos) return found
+       pos--;
+     }
+     return 0
+   }
+
+   function codePointAt$1(str, pos) {
+     let code0 = str.charCodeAt(pos);
+     if (!surrogateHigh$1(code0) || pos + 1 == str.length) return code0
+     let code1 = str.charCodeAt(pos + 1);
+     if (!surrogateLow$1(code1)) return code0
+     return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
+   }
+
+   function surrogateLow$1(ch) { return ch >= 0xDC00 && ch < 0xE000 }
+   function surrogateHigh$1(ch) { return ch >= 0xD800 && ch < 0xDC00 }
+   function codePointSize$1(code) { return code < 0x10000 ? 1 : 2 }
+
+   /**
+   The data structure for documents. @nonabstract
+   */
+   class Text {
+       /**
+       Get the line description around the given position.
+       */
+       lineAt(pos) {
+           if (pos < 0 || pos > this.length)
+               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
+           return this.lineInner(pos, false, 1, 0);
+       }
+       /**
+       Get the description for the given (1-based) line number.
+       */
+       line(n) {
+           if (n < 1 || n > this.lines)
+               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
+           return this.lineInner(n, true, 1, 0);
+       }
+       /**
+       Replace a range of the text with the given content.
+       */
+       replace(from, to, text) {
+           [from, to] = clip(this, from, to);
+           let parts = [];
+           this.decompose(0, from, parts, 2 /* Open.To */);
+           if (text.length)
+               text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);
+           this.decompose(to, this.length, parts, 1 /* Open.From */);
+           return TextNode.from(parts, this.length - (to - from) + text.length);
+       }
+       /**
+       Append another document to this one.
+       */
+       append(other) {
+           return this.replace(this.length, this.length, other);
+       }
+       /**
+       Retrieve the text between the given points.
+       */
+       slice(from, to = this.length) {
+           [from, to] = clip(this, from, to);
+           let parts = [];
+           this.decompose(from, to, parts, 0);
+           return TextNode.from(parts, to - from);
+       }
+       /**
+       Test whether this text is equal to another instance.
+       */
+       eq(other) {
+           if (other == this)
+               return true;
+           if (other.length != this.length || other.lines != this.lines)
+               return false;
+           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
+           let a = new RawTextCursor(this), b = new RawTextCursor(other);
+           for (let skip = start, pos = start;;) {
+               a.next(skip);
+               b.next(skip);
+               skip = 0;
+               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
+                   return false;
+               pos += a.value.length;
+               if (a.done || pos >= end)
+                   return true;
+           }
+       }
+       /**
+       Iterate over the text. When `dir` is `-1`, iteration happens
+       from end to start. This will return lines and the breaks between
+       them as separate strings.
+       */
+       iter(dir = 1) { return new RawTextCursor(this, dir); }
+       /**
+       Iterate over a range of the text. When `from` > `to`, the
+       iterator will run in reverse.
+       */
+       iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); }
+       /**
+       Return a cursor that iterates over the given range of lines,
+       _without_ returning the line breaks between, and yielding empty
+       strings for empty lines.
+       
+       When `from` and `to` are given, they should be 1-based line numbers.
+       */
+       iterLines(from, to) {
+           let inner;
+           if (from == null) {
+               inner = this.iter();
+           }
+           else {
+               if (to == null)
+                   to = this.lines + 1;
+               let start = this.line(from).from;
+               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
+           }
+           return new LineCursor(inner);
+       }
+       /**
+       Return the document as a string, using newline characters to
+       separate lines.
+       */
+       toString() { return this.sliceString(0); }
+       /**
+       Convert the document to an array of lines (which can be
+       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
+       */
+       toJSON() {
+           let lines = [];
+           this.flatten(lines);
+           return lines;
+       }
+       /**
+       @internal
+       */
+       constructor() { }
+       /**
+       Create a `Text` instance for the given array of lines.
+       */
+       static of(text) {
+           if (text.length == 0)
+               throw new RangeError("A document must have at least one line");
+           if (text.length == 1 && !text[0])
+               return Text.empty;
+           return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
+       }
+   }
+   // Leaves store an array of line strings. There are always line breaks
+   // between these strings. Leaves are limited in size and have to be
+   // contained in TextNode instances for bigger documents.
+   class TextLeaf extends Text {
+       constructor(text, length = textLength(text)) {
+           super();
+           this.text = text;
+           this.length = length;
+       }
+       get lines() { return this.text.length; }
+       get children() { return null; }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let string = this.text[i], end = offset + string.length;
+               if ((isLine ? line : end) >= target)
+                   return new Line(offset, end, line, string);
+               offset = end + 1;
+               line++;
+           }
+       }
+       decompose(from, to, target, open) {
+           let text = from <= 0 && to >= this.length ? this
+               : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
+           if (open & 1 /* Open.From */) {
+               let prev = target.pop();
+               let joined = appendText(text.text, prev.text.slice(), 0, text.length);
+               if (joined.length <= 32 /* Tree.Branch */) {
+                   target.push(new TextLeaf(joined, prev.length + text.length));
+               }
+               else {
+                   let mid = joined.length >> 1;
+                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
+               }
+           }
+           else {
+               target.push(text);
+           }
+       }
+       replace(from, to, text) {
+           if (!(text instanceof TextLeaf))
+               return super.replace(from, to, text);
+           [from, to] = clip(this, from, to);
+           let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
+           let newLen = this.length + text.length - (to - from);
+           if (lines.length <= 32 /* Tree.Branch */)
+               return new TextLeaf(lines, newLen);
+           return TextNode.from(TextLeaf.split(lines, []), newLen);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           [from, to] = clip(this, from, to);
+           let result = "";
+           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
+               let line = this.text[i], end = pos + line.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += line.slice(Math.max(0, from - pos), to - pos);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let line of this.text)
+               target.push(line);
+       }
+       scanIdentical() { return 0; }
+       static split(text, target) {
+           let part = [], len = -1;
+           for (let line of text) {
+               part.push(line);
+               len += line.length + 1;
+               if (part.length == 32 /* Tree.Branch */) {
+                   target.push(new TextLeaf(part, len));
+                   part = [];
+                   len = -1;
+               }
+           }
+           if (len > -1)
+               target.push(new TextLeaf(part, len));
+           return target;
+       }
+   }
+   // Nodes provide the tree structure of the `Text` type. They store a
+   // number of other nodes or leaves, taking care to balance themselves
+   // on changes. There are implied line breaks _between_ the children of
+   // a node (but not before the first or after the last child).
+   class TextNode extends Text {
+       constructor(children, length) {
+           super();
+           this.children = children;
+           this.length = length;
+           this.lines = 0;
+           for (let child of children)
+               this.lines += child.lines;
+       }
+       lineInner(target, isLine, line, offset) {
+           for (let i = 0;; i++) {
+               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
+               if ((isLine ? endLine : end) >= target)
+                   return child.lineInner(target, isLine, line, offset);
+               offset = end + 1;
+               line = endLine + 1;
+           }
+       }
+       decompose(from, to, target, open) {
+           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (from <= end && to >= pos) {
+                   let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));
+                   if (pos >= from && end <= to && !childOpen)
+                       target.push(child);
+                   else
+                       child.decompose(from - pos, to - pos, target, childOpen);
+               }
+               pos = end + 1;
+           }
+       }
+       replace(from, to, text) {
+           [from, to] = clip(this, from, to);
+           if (text.lines < this.lines)
+               for (let i = 0, pos = 0; i < this.children.length; i++) {
+                   let child = this.children[i], end = pos + child.length;
+                   // Fast path: if the change only affects one child and the
+                   // child's size remains in the acceptable range, only update
+                   // that child
+                   if (from >= pos && to <= end) {
+                       let updated = child.replace(from - pos, to - pos, text);
+                       let totalLines = this.lines - child.lines + updated.lines;
+                       if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&
+                           updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {
+                           let copy = this.children.slice();
+                           copy[i] = updated;
+                           return new TextNode(copy, this.length - (to - from) + text.length);
+                       }
+                       return super.replace(pos, end, updated);
+                   }
+                   pos = end + 1;
+               }
+           return super.replace(from, to, text);
+       }
+       sliceString(from, to = this.length, lineSep = "\n") {
+           [from, to] = clip(this, from, to);
+           let result = "";
+           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos > from && i)
+                   result += lineSep;
+               if (from < end && to > pos)
+                   result += child.sliceString(from - pos, to - pos, lineSep);
+               pos = end + 1;
+           }
+           return result;
+       }
+       flatten(target) {
+           for (let child of this.children)
+               child.flatten(target);
+       }
+       scanIdentical(other, dir) {
+           if (!(other instanceof TextNode))
+               return 0;
+           let length = 0;
+           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
+               : [this.children.length - 1, other.children.length - 1, -1, -1];
+           for (;; iA += dir, iB += dir) {
+               if (iA == eA || iB == eB)
+                   return length;
+               let chA = this.children[iA], chB = other.children[iB];
+               if (chA != chB)
+                   return length + chA.scanIdentical(chB, dir);
+               length += chA.length + 1;
+           }
+       }
+       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
+           let lines = 0;
+           for (let ch of children)
+               lines += ch.lines;
+           if (lines < 32 /* Tree.Branch */) {
+               let flat = [];
+               for (let ch of children)
+                   ch.flatten(flat);
+               return new TextLeaf(flat, length);
+           }
+           let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
+           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
+           function add(child) {
+               let last;
+               if (child.lines > maxChunk && child instanceof TextNode) {
+                   for (let node of child.children)
+                       add(node);
+               }
+               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
+                   flush();
+                   chunked.push(child);
+               }
+               else if (child instanceof TextLeaf && currentLines &&
+                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&
+                   child.lines + last.lines <= 32 /* Tree.Branch */) {
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
+               }
+               else {
+                   if (currentLines + child.lines > chunk)
+                       flush();
+                   currentLines += child.lines;
+                   currentLen += child.length + 1;
+                   currentChunk.push(child);
+               }
+           }
+           function flush() {
+               if (currentLines == 0)
+                   return;
+               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
+               currentLen = -1;
+               currentLines = currentChunk.length = 0;
+           }
+           for (let child of children)
+               add(child);
+           flush();
+           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
+       }
+   }
+   Text.empty = /*@__PURE__*/new TextLeaf([""], 0);
+   function textLength(text) {
+       let length = -1;
+       for (let line of text)
+           length += line.length + 1;
+       return length;
+   }
+   function appendText(text, target, from = 0, to = 1e9) {
+       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
+           let line = text[i], end = pos + line.length;
+           if (end >= from) {
+               if (end > to)
+                   line = line.slice(0, to - pos);
+               if (pos < from)
+                   line = line.slice(from - pos);
+               if (first) {
+                   target[target.length - 1] += line;
+                   first = false;
+               }
+               else
+                   target.push(line);
+           }
+           pos = end + 1;
+       }
+       return target;
+   }
+   function sliceText(text, from, to) {
+       return appendText(text, [""], from, to);
+   }
+   class RawTextCursor {
+       constructor(text, dir = 1) {
+           this.dir = dir;
+           this.done = false;
+           this.lineBreak = false;
+           this.value = "";
+           this.nodes = [text];
+           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];
+       }
+       nextInner(skip, dir) {
+           this.done = this.lineBreak = false;
+           for (;;) {
+               let last = this.nodes.length - 1;
+               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
+               let size = top instanceof TextLeaf ? top.text.length : top.children.length;
+               if (offset == (dir > 0 ? size : 0)) {
+                   if (last == 0) {
+                       this.done = true;
+                       this.value = "";
+                       return this;
+                   }
+                   if (dir > 0)
+                       this.offsets[last - 1]++;
+                   this.nodes.pop();
+                   this.offsets.pop();
+               }
+               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
+                   this.offsets[last] += dir;
+                   if (skip == 0) {
+                       this.lineBreak = true;
+                       this.value = "\n";
+                       return this;
+                   }
+                   skip--;
+               }
+               else if (top instanceof TextLeaf) {
+                   // Move to the next string
+                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
+                   this.offsets[last] += dir;
+                   if (next.length > Math.max(0, skip)) {
+                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
+                       return this;
+                   }
+                   skip -= next.length;
+               }
+               else {
+                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
+                   if (skip > next.length) {
+                       skip -= next.length;
+                       this.offsets[last] += dir;
+                   }
+                   else {
+                       if (dir < 0)
+                           this.offsets[last]--;
+                       this.nodes.push(next);
+                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);
+                   }
+               }
+           }
+       }
+       next(skip = 0) {
+           if (skip < 0) {
+               this.nextInner(-skip, (-this.dir));
+               skip = this.value.length;
+           }
+           return this.nextInner(skip, this.dir);
+       }
+   }
+   class PartialTextCursor {
+       constructor(text, start, end) {
+           this.value = "";
+           this.done = false;
+           this.cursor = new RawTextCursor(text, start > end ? -1 : 1);
+           this.pos = start > end ? text.length : 0;
+           this.from = Math.min(start, end);
+           this.to = Math.max(start, end);
+       }
+       nextInner(skip, dir) {
+           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
+               this.value = "";
+               this.done = true;
+               return this;
+           }
+           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
+           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
+           if (skip > limit)
+               skip = limit;
+           limit -= skip;
+           let { value } = this.cursor.next(skip);
+           this.pos += (value.length + skip) * dir;
+           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
+           this.done = !this.value;
+           return this;
+       }
+       next(skip = 0) {
+           if (skip < 0)
+               skip = Math.max(skip, this.from - this.pos);
+           else if (skip > 0)
+               skip = Math.min(skip, this.to - this.pos);
+           return this.nextInner(skip, this.cursor.dir);
+       }
+       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
+   }
+   class LineCursor {
+       constructor(inner) {
+           this.inner = inner;
+           this.afterBreak = true;
+           this.value = "";
+           this.done = false;
+       }
+       next(skip = 0) {
+           let { done, lineBreak, value } = this.inner.next(skip);
+           if (done && this.afterBreak) {
+               this.value = "";
+               this.afterBreak = false;
+           }
+           else if (done) {
+               this.done = true;
+               this.value = "";
+           }
+           else if (lineBreak) {
+               if (this.afterBreak) {
+                   this.value = "";
+               }
+               else {
+                   this.afterBreak = true;
+                   this.next();
+               }
+           }
+           else {
+               this.value = value;
+               this.afterBreak = false;
+           }
+           return this;
+       }
+       get lineBreak() { return false; }
+   }
+   if (typeof Symbol != "undefined") {
+       Text.prototype[Symbol.iterator] = function () { return this.iter(); };
+       RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =
+           LineCursor.prototype[Symbol.iterator] = function () { return this; };
+   }
+   /**
+   This type describes a line in the document. It is created
+   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
+   */
+   class Line {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The position of the start of the line.
+       */
+       from, 
+       /**
+       The position at the end of the line (_before_ the line break,
+       or at the end of document for the last line).
+       */
+       to, 
+       /**
+       This line's line number (1-based).
+       */
+       number, 
+       /**
+       The line's content.
+       */
+       text) {
+           this.from = from;
+           this.to = to;
+           this.number = number;
+           this.text = text;
+       }
+       /**
+       The length of the line (not including any line break after it).
+       */
+       get length() { return this.to - this.from; }
+   }
+   function clip(text, from, to) {
+       from = Math.max(0, Math.min(text.length, from));
+       return [from, Math.max(from, Math.min(text.length, to))];
+   }
+
+   /**
+   Returns a next grapheme cluster break _after_ (not equal to)
+   `pos`, if `forward` is true, or before otherwise. Returns `pos`
+   itself if no further cluster break is available in the string.
+   Moves across surrogate pairs, extending characters (when
+   `includeExtending` is true), characters joined with zero-width
+   joiners, and flag emoji.
+   */
+   function findClusterBreak(str, pos, forward = true, includeExtending = true) {
+       return findClusterBreak$1(str, pos, forward, includeExtending);
+   }
+   function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000; }
+   function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00; }
+   /**
+   Find the code point at the given position in a string (like the
+   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
+   string method).
+   */
+   function codePointAt(str, pos) {
+       let code0 = str.charCodeAt(pos);
+       if (!surrogateHigh(code0) || pos + 1 == str.length)
+           return code0;
+       let code1 = str.charCodeAt(pos + 1);
+       if (!surrogateLow(code1))
+           return code0;
+       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
+   }
+   /**
+   Given a Unicode codepoint, return the JavaScript string that
+   respresents it (like
+   [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
+   */
+   function fromCodePoint(code) {
+       if (code <= 0xffff)
+           return String.fromCharCode(code);
+       code -= 0x10000;
+       return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
+   }
+   /**
+   The amount of positions a character takes up in a JavaScript string.
+   */
+   function codePointSize(code) { return code < 0x10000 ? 1 : 2; }
+
+   const DefaultSplit = /\r\n?|\n/;
+   /**
+   Distinguishes different ways in which positions can be mapped.
+   */
+   var MapMode = /*@__PURE__*/(function (MapMode) {
+       /**
+       Map a position to a valid new position, even when its context
+       was deleted.
+       */
+       MapMode[MapMode["Simple"] = 0] = "Simple";
+       /**
+       Return null if deletion happens across the position.
+       */
+       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
+       /**
+       Return null if the character _before_ the position is deleted.
+       */
+       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
+       /**
+       Return null if the character _after_ the position is deleted.
+       */
+       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
+   return MapMode})(MapMode || (MapMode = {}));
+   /**
+   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
+   that doesn't store the inserted text. As such, it can't be
+   applied, but is cheaper to store and manipulate.
+   */
+   class ChangeDesc {
+       // Sections are encoded as pairs of integers. The first is the
+       // length in the current document, and the second is -1 for
+       // unaffected sections, and the length of the replacement content
+       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
+       // 0), and a replacement two positive numbers.
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       @internal
+       */
+       sections) {
+           this.sections = sections;
+       }
+       /**
+       The length of the document before the change.
+       */
+       get length() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2)
+               result += this.sections[i];
+           return result;
+       }
+       /**
+       The length of the document after the change.
+       */
+       get newLength() {
+           let result = 0;
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let ins = this.sections[i + 1];
+               result += ins < 0 ? this.sections[i] : ins;
+           }
+           return result;
+       }
+       /**
+       False when there are actual changes in this set.
+       */
+       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
+       /**
+       Iterate over the unchanged parts left by these changes. `posA`
+       provides the position of the range in the old document, `posB`
+       the new position in the changed document.
+       */
+       iterGaps(f) {
+           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0) {
+                   f(posA, posB, len);
+                   posB += len;
+               }
+               else {
+                   posB += ins;
+               }
+               posA += len;
+           }
+       }
+       /**
+       Iterate over the ranges changed by these changes. (See
+       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
+       variant that also provides you with the inserted text.)
+       `fromA`/`toA` provides the extent of the change in the starting
+       document, `fromB`/`toB` the extent of the replacement in the
+       changed document.
+       
+       When `individual` is true, adjacent changes (which are kept
+       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
+       reported separately.
+       */
+       iterChangedRanges(f, individual = false) {
+           iterChanges(this, f, individual);
+       }
+       /**
+       Get a description of the inverted form of these changes.
+       */
+       get invertedDesc() {
+           let sections = [];
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               if (ins < 0)
+                   sections.push(len, ins);
+               else
+                   sections.push(ins, len);
+           }
+           return new ChangeDesc(sections);
+       }
+       /**
+       Compute the combined effect of applying another set of changes
+       after this one. The length of the document after this set should
+       match the length before `other`.
+       */
+       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets(this, other); }
+       /**
+       Map this description, which should start with the same document
+       as `other`, over another set of changes, so that it can be
+       applied after it. When `before` is true, map as if the changes
+       in `this` happened before the ones in `other`.
+       */
+       mapDesc(other, before = false) { return other.empty ? this : mapSet(this, other, before); }
+       mapPos(pos, assoc = -1, mode = MapMode.Simple) {
+           let posA = 0, posB = 0;
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
+               if (ins < 0) {
+                   if (endA > pos)
+                       return posB + (pos - posA);
+                   posB += len;
+               }
+               else {
+                   if (mode != MapMode.Simple && endA >= pos &&
+                       (mode == MapMode.TrackDel && posA < pos && endA > pos ||
+                           mode == MapMode.TrackBefore && posA < pos ||
+                           mode == MapMode.TrackAfter && endA > pos))
+                       return null;
+                   if (endA > pos || endA == pos && assoc < 0 && !len)
+                       return pos == posA || assoc < 0 ? posB : posB + ins;
+                   posB += ins;
+               }
+               posA = endA;
+           }
+           if (pos > posA)
+               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
+           return posB;
+       }
+       /**
+       Check whether these changes touch a given range. When one of the
+       changes entirely covers the range, the string `"cover"` is
+       returned.
+       */
+       touchesRange(from, to = from) {
+           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
+               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
+               if (ins >= 0 && pos <= to && end >= from)
+                   return pos < from && end > to ? "cover" : true;
+               pos = end;
+           }
+           return false;
+       }
+       /**
+       @internal
+       */
+       toString() {
+           let result = "";
+           for (let i = 0; i < this.sections.length;) {
+               let len = this.sections[i++], ins = this.sections[i++];
+               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
+           }
+           return result;
+       }
+       /**
+       Serialize this change desc to a JSON-representable value.
+       */
+       toJSON() { return this.sections; }
+       /**
+       Create a change desc from its JSON representation (as produced
+       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
+               throw new RangeError("Invalid JSON representation of ChangeDesc");
+           return new ChangeDesc(json);
+       }
+       /**
+       @internal
+       */
+       static create(sections) { return new ChangeDesc(sections); }
+   }
+   /**
+   A change set represents a group of modifications to a document. It
+   stores the document length, and can only be applied to documents
+   with exactly that length.
+   */
+   class ChangeSet extends ChangeDesc {
+       constructor(sections, 
+       /**
+       @internal
+       */
+       inserted) {
+           super(sections);
+           this.inserted = inserted;
+       }
+       /**
+       Apply the changes to a document, returning the modified
+       document.
+       */
+       apply(doc) {
+           if (this.length != doc.length)
+               throw new RangeError("Applying change set to a document with the wrong length");
+           iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
+           return doc;
+       }
+       mapDesc(other, before = false) { return mapSet(this, other, before, true); }
+       /**
+       Given the document as it existed _before_ the changes, return a
+       change set that represents the inverse of this set, which could
+       be used to go from the document created by the changes back to
+       the document as it existed before the changes.
+       */
+       invert(doc) {
+           let sections = this.sections.slice(), inserted = [];
+           for (let i = 0, pos = 0; i < sections.length; i += 2) {
+               let len = sections[i], ins = sections[i + 1];
+               if (ins >= 0) {
+                   sections[i] = ins;
+                   sections[i + 1] = len;
+                   let index = i >> 1;
+                   while (inserted.length < index)
+                       inserted.push(Text.empty);
+                   inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);
+               }
+               pos += len;
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       Combine two subsequent change sets into a single set. `other`
+       must start in the document produced by `this`. If `this` goes
+       `docA` → `docB` and `other` represents `docB` → `docC`, the
+       returned value will represent the change `docA` → `docC`.
+       */
+       compose(other) { return this.empty ? other : other.empty ? this : composeSets(this, other, true); }
+       /**
+       Given another change set starting in the same document, maps this
+       change set over the other, producing a new change set that can be
+       applied to the document produced by applying `other`. When
+       `before` is `true`, order changes as if `this` comes before
+       `other`, otherwise (the default) treat `other` as coming first.
+       
+       Given two changes `A` and `B`, `A.compose(B.map(A))` and
+       `B.compose(A.map(B, true))` will produce the same document. This
+       provides a basic form of [operational
+       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
+       and can be used for collaborative editing.
+       */
+       map(other, before = false) { return other.empty ? this : mapSet(this, other, before, true); }
+       /**
+       Iterate over the changed ranges in the document, calling `f` for
+       each, with the range in the original document (`fromA`-`toA`)
+       and the range that replaces it in the new document
+       (`fromB`-`toB`).
+       
+       When `individual` is true, adjacent changes are reported
+       separately.
+       */
+       iterChanges(f, individual = false) {
+           iterChanges(this, f, individual);
+       }
+       /**
+       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
+       set.
+       */
+       get desc() { return ChangeDesc.create(this.sections); }
+       /**
+       @internal
+       */
+       filter(ranges) {
+           let resultSections = [], resultInserted = [], filteredSections = [];
+           let iter = new SectionIter(this);
+           done: for (let i = 0, pos = 0;;) {
+               let next = i == ranges.length ? 1e9 : ranges[i++];
+               while (pos < next || pos == next && iter.len == 0) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, next - pos);
+                   addSection(filteredSections, len, -1);
+                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
+                   addSection(resultSections, len, ins);
+                   if (ins > 0)
+                       addInsert(resultInserted, resultSections, iter.text);
+                   iter.forward(len);
+                   pos += len;
+               }
+               let end = ranges[i++];
+               while (pos < end) {
+                   if (iter.done)
+                       break done;
+                   let len = Math.min(iter.len, end - pos);
+                   addSection(resultSections, len, -1);
+                   addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
+                   iter.forward(len);
+                   pos += len;
+               }
+           }
+           return { changes: new ChangeSet(resultSections, resultInserted),
+               filtered: ChangeDesc.create(filteredSections) };
+       }
+       /**
+       Serialize this change set to a JSON-representable value.
+       */
+       toJSON() {
+           let parts = [];
+           for (let i = 0; i < this.sections.length; i += 2) {
+               let len = this.sections[i], ins = this.sections[i + 1];
+               if (ins < 0)
+                   parts.push(len);
+               else if (ins == 0)
+                   parts.push([len]);
+               else
+                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
+           }
+           return parts;
+       }
+       /**
+       Create a change set for the given changes, for a document of the
+       given length, using `lineSep` as line separator.
+       */
+       static of(changes, length, lineSep) {
+           let sections = [], inserted = [], pos = 0;
+           let total = null;
+           function flush(force = false) {
+               if (!force && !sections.length)
+                   return;
+               if (pos < length)
+                   addSection(sections, length - pos, -1);
+               let set = new ChangeSet(sections, inserted);
+               total = total ? total.compose(set.map(total)) : set;
+               sections = [];
+               inserted = [];
+               pos = 0;
+           }
+           function process(spec) {
+               if (Array.isArray(spec)) {
+                   for (let sub of spec)
+                       process(sub);
+               }
+               else if (spec instanceof ChangeSet) {
+                   if (spec.length != length)
+                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
+                   flush();
+                   total = total ? total.compose(spec.map(total)) : spec;
+               }
+               else {
+                   let { from, to = from, insert } = spec;
+                   if (from > to || from < 0 || to > length)
+                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
+                   let insText = !insert ? Text.empty : typeof insert == "string" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;
+                   let insLen = insText.length;
+                   if (from == to && insLen == 0)
+                       return;
+                   if (from < pos)
+                       flush();
+                   if (from > pos)
+                       addSection(sections, from - pos, -1);
+                   addSection(sections, to - from, insLen);
+                   addInsert(inserted, sections, insText);
+                   pos = to;
+               }
+           }
+           process(changes);
+           flush(!total);
+           return total;
+       }
+       /**
+       Create an empty changeset of the given length.
+       */
+       static empty(length) {
+           return new ChangeSet(length ? [length, -1] : [], []);
+       }
+       /**
+       Create a changeset from its JSON representation (as produced by
+       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
+       */
+       static fromJSON(json) {
+           if (!Array.isArray(json))
+               throw new RangeError("Invalid JSON representation of ChangeSet");
+           let sections = [], inserted = [];
+           for (let i = 0; i < json.length; i++) {
+               let part = json[i];
+               if (typeof part == "number") {
+                   sections.push(part, -1);
+               }
+               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
+                   throw new RangeError("Invalid JSON representation of ChangeSet");
+               }
+               else if (part.length == 1) {
+                   sections.push(part[0], 0);
+               }
+               else {
+                   while (inserted.length < i)
+                       inserted.push(Text.empty);
+                   inserted[i] = Text.of(part.slice(1));
+                   sections.push(part[0], inserted[i].length);
+               }
+           }
+           return new ChangeSet(sections, inserted);
+       }
+       /**
+       @internal
+       */
+       static createSet(sections, inserted) {
+           return new ChangeSet(sections, inserted);
+       }
+   }
+   function addSection(sections, len, ins, forceJoin = false) {
+       if (len == 0 && ins <= 0)
+           return;
+       let last = sections.length - 2;
+       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
+           sections[last] += len;
+       else if (last >= 0 && len == 0 && sections[last] == 0)
+           sections[last + 1] += ins;
+       else if (forceJoin) {
+           sections[last] += len;
+           sections[last + 1] += ins;
+       }
+       else
+           sections.push(len, ins);
+   }
+   function addInsert(values, sections, value) {
+       if (value.length == 0)
+           return;
+       let index = (sections.length - 2) >> 1;
+       if (index < values.length) {
+           values[values.length - 1] = values[values.length - 1].append(value);
+       }
+       else {
+           while (values.length < index)
+               values.push(Text.empty);
+           values.push(value);
+       }
+   }
+   function iterChanges(desc, f, individual) {
+       let inserted = desc.inserted;
+       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
+           let len = desc.sections[i++], ins = desc.sections[i++];
+           if (ins < 0) {
+               posA += len;
+               posB += len;
+           }
+           else {
+               let endA = posA, endB = posB, text = Text.empty;
+               for (;;) {
+                   endA += len;
+                   endB += ins;
+                   if (ins && inserted)
+                       text = text.append(inserted[(i - 2) >> 1]);
+                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
+                       break;
+                   len = desc.sections[i++];
+                   ins = desc.sections[i++];
+               }
+               f(posA, endA, posB, endB, text);
+               posA = endA;
+               posB = endB;
+           }
+       }
+   }
+   function mapSet(setA, setB, before, mkSet = false) {
+       // Produce a copy of setA that applies to the document after setB
+       // has been applied (assuming both start at the same document).
+       let sections = [], insert = mkSet ? [] : null;
+       let a = new SectionIter(setA), b = new SectionIter(setB);
+       // Iterate over both sets in parallel. inserted tracks, for changes
+       // in A that have to be processed piece-by-piece, whether their
+       // content has been inserted already, and refers to the section
+       // index.
+       for (let inserted = -1;;) {
+           if (a.done && b.len || b.done && a.len) {
+               throw new Error("Mismatched change set lengths");
+           }
+           else if (a.ins == -1 && b.ins == -1) {
+               // Move across ranges skipped by both sets.
+               let len = Math.min(a.len, b.len);
+               addSection(sections, len, -1);
+               a.forward(len);
+               b.forward(len);
+           }
+           else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {
+               // If there's a change in B that comes before the next change in
+               // A (ordered by start pos, then len, then before flag), skip
+               // that (and process any changes in A it covers).
+               let len = b.len;
+               addSection(sections, b.ins, -1);
+               while (len) {
+                   let piece = Math.min(a.len, len);
+                   if (a.ins >= 0 && inserted < a.i && a.len <= piece) {
+                       addSection(sections, 0, a.ins);
+                       if (insert)
+                           addInsert(insert, sections, a.text);
+                       inserted = a.i;
+                   }
+                   a.forward(piece);
+                   len -= piece;
+               }
+               b.next();
+           }
+           else if (a.ins >= 0) {
+               // Process the part of a change in A up to the start of the next
+               // non-deletion change in B (if overlapping).
+               let len = 0, left = a.len;
+               while (left) {
+                   if (b.ins == -1) {
+                       let piece = Math.min(left, b.len);
+                       len += piece;
+                       left -= piece;
+                       b.forward(piece);
+                   }
+                   else if (b.ins == 0 && b.len < left) {
+                       left -= b.len;
+                       b.next();
+                   }
+                   else {
+                       break;
+                   }
+               }
+               addSection(sections, len, inserted < a.i ? a.ins : 0);
+               if (insert && inserted < a.i)
+                   addInsert(insert, sections, a.text);
+               inserted = a.i;
+               a.forward(a.len - left);
+           }
+           else if (a.done && b.done) {
+               return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
+           }
+           else {
+               throw new Error("Mismatched change set lengths");
+           }
+       }
+   }
+   function composeSets(setA, setB, mkSet = false) {
+       let sections = [];
+       let insert = mkSet ? [] : null;
+       let a = new SectionIter(setA), b = new SectionIter(setB);
+       for (let open = false;;) {
+           if (a.done && b.done) {
+               return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
+           }
+           else if (a.ins == 0) { // Deletion in A
+               addSection(sections, a.len, 0, open);
+               a.next();
+           }
+           else if (b.len == 0 && !b.done) { // Insertion in B
+               addSection(sections, 0, b.ins, open);
+               if (insert)
+                   addInsert(insert, sections, b.text);
+               b.next();
+           }
+           else if (a.done || b.done) {
+               throw new Error("Mismatched change set lengths");
+           }
+           else {
+               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
+               if (a.ins == -1) {
+                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
+                   addSection(sections, len, insB, open);
+                   if (insert && insB)
+                       addInsert(insert, sections, b.text);
+               }
+               else if (b.ins == -1) {
+                   addSection(sections, a.off ? 0 : a.len, len, open);
+                   if (insert)
+                       addInsert(insert, sections, a.textBit(len));
+               }
+               else {
+                   addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
+                   if (insert && !b.off)
+                       addInsert(insert, sections, b.text);
+               }
+               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
+               a.forward2(len);
+               b.forward(len);
+           }
+       }
+   }
+   class SectionIter {
+       constructor(set) {
+           this.set = set;
+           this.i = 0;
+           this.next();
+       }
+       next() {
+           let { sections } = this.set;
+           if (this.i < sections.length) {
+               this.len = sections[this.i++];
+               this.ins = sections[this.i++];
+           }
+           else {
+               this.len = 0;
+               this.ins = -2;
+           }
+           this.off = 0;
+       }
+       get done() { return this.ins == -2; }
+       get len2() { return this.ins < 0 ? this.len : this.ins; }
+       get text() {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length ? Text.empty : inserted[index];
+       }
+       textBit(len) {
+           let { inserted } = this.set, index = (this.i - 2) >> 1;
+           return index >= inserted.length && !len ? Text.empty
+               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
+       }
+       forward(len) {
+           if (len == this.len)
+               this.next();
+           else {
+               this.len -= len;
+               this.off += len;
+           }
+       }
+       forward2(len) {
+           if (this.ins == -1)
+               this.forward(len);
+           else if (len == this.ins)
+               this.next();
+           else {
+               this.ins -= len;
+               this.off += len;
+           }
+       }
+   }
+
+   /**
+   A single selection range. When
+   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
+   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
+   multiple ranges. By default, selections hold exactly one range.
+   */
+   class SelectionRange {
+       constructor(
+       /**
+       The lower boundary of the range.
+       */
+       from, 
+       /**
+       The upper boundary of the range.
+       */
+       to, flags) {
+           this.from = from;
+           this.to = to;
+           this.flags = flags;
+       }
+       /**
+       The anchor of the range—the side that doesn't move when you
+       extend it.
+       */
+       get anchor() { return this.flags & 32 /* RangeFlag.Inverted */ ? 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 /* RangeFlag.Inverted */ ? 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 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 16 /* RangeFlag.AssocAfter */ ? 1 : 0; }
+       /**
+       The bidirectional text level associated with this cursor, if
+       any.
+       */
+       get bidiLevel() {
+           let level = this.flags & 7 /* RangeFlag.BidiLevelMask */;
+           return level == 7 ? null : level;
+       }
+       /**
+       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 value = this.flags >> 6 /* RangeFlag.GoalColumnOffset */;
+           return value == 16777215 /* RangeFlag.NoGoalColumn */ ? undefined : value;
+       }
+       /**
+       Map this range through a change, producing a valid range in the
+       updated document.
+       */
+       map(change, assoc = -1) {
+           let from, to;
+           if (this.empty) {
+               from = to = change.mapPos(this.from, assoc);
+           }
+           else {
+               from = change.mapPos(this.from, 1);
+               to = change.mapPos(this.to, -1);
+           }
+           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
+       }
+       /**
+       Extend this range to cover at least `from` to `to`.
+       */
+       extend(from, to = from) {
+           if (from <= this.anchor && to >= this.anchor)
+               return EditorSelection.range(from, to);
+           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
+           return EditorSelection.range(this.anchor, head);
+       }
+       /**
+       Compare this range to another range.
+       */
+       eq(other, includeAssoc = false) {
+           return this.anchor == other.anchor && this.head == other.head &&
+               (!includeAssoc || !this.empty || this.assoc == other.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(json) {
+           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
+               throw new RangeError("Invalid JSON representation for SelectionRange");
+           return EditorSelection.range(json.anchor, json.head);
+       }
+       /**
+       @internal
+       */
+       static create(from, to, flags) {
+           return new SelectionRange(from, to, flags);
+       }
+   }
+   /**
+   An editor selection holds one or more selection ranges.
+   */
+   class EditorSelection {
+       constructor(
+       /**
+       The ranges in the selection, sorted by position. Ranges cannot
+       overlap (but they may touch, if they aren't empty).
+       */
+       ranges, 
+       /**
+       The index of the _main_ range in the selection (which is
+       usually the range that was added last).
+       */
+       mainIndex) {
+           this.ranges = ranges;
+           this.mainIndex = mainIndex;
+       }
+       /**
+       Map a selection through a change. Used to adjust the selection
+       position for changes.
+       */
+       map(change, assoc = -1) {
+           if (change.empty)
+               return this;
+           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), 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(other, includeAssoc = false) {
+           if (this.ranges.length != other.ranges.length ||
+               this.mainIndex != other.mainIndex)
+               return false;
+           for (let i = 0; i < this.ranges.length; i++)
+               if (!this.ranges[i].eq(other.ranges[i], includeAssoc))
+                   return false;
+           return true;
+       }
+       /**
+       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 EditorSelection([this.main], 0);
+       }
+       /**
+       Extend this selection with an extra range.
+       */
+       addRange(range, main = true) {
+           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
+       }
+       /**
+       Replace a given range with another range, and then normalize the
+       selection to merge and sort ranges if necessary.
+       */
+       replaceRange(range, which = this.mainIndex) {
+           let ranges = this.ranges.slice();
+           ranges[which] = range;
+           return EditorSelection.create(ranges, this.mainIndex);
+       }
+       /**
+       Convert this selection to an object that can be serialized to
+       JSON.
+       */
+       toJSON() {
+           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
+       }
+       /**
+       Create a selection from a JSON representation.
+       */
+       static fromJSON(json) {
+           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
+               throw new RangeError("Invalid JSON representation for EditorSelection");
+           return new EditorSelection(json.ranges.map((r) => SelectionRange.fromJSON(r)), json.main);
+       }
+       /**
+       Create a selection holding a single range.
+       */
+       static single(anchor, head = anchor) {
+           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
+       }
+       /**
+       Sort and merge the given set of ranges, creating a valid
+       selection.
+       */
+       static create(ranges, mainIndex = 0) {
+           if (ranges.length == 0)
+               throw new RangeError("A selection needs at least one range");
+           for (let pos = 0, i = 0; i < ranges.length; i++) {
+               let range = ranges[i];
+               if (range.empty ? range.from <= pos : range.from < pos)
+                   return EditorSelection.normalized(ranges.slice(), mainIndex);
+               pos = range.to;
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+       /**
+       Create a cursor selection range at the given position. You can
+       safely ignore the optional arguments in most situations.
+       */
+       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
+           return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */) |
+               (bidiLevel == null ? 7 : Math.min(6, bidiLevel)) |
+               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */));
+       }
+       /**
+       Create a selection range.
+       */
+       static range(anchor, head, goalColumn, bidiLevel) {
+           let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */) |
+               (bidiLevel == null ? 7 : Math.min(6, bidiLevel));
+           return head < anchor ? SelectionRange.create(head, anchor, 32 /* RangeFlag.Inverted */ | 16 /* RangeFlag.AssocAfter */ | flags)
+               : SelectionRange.create(anchor, head, (head > anchor ? 8 /* RangeFlag.AssocBefore */ : 0) | flags);
+       }
+       /**
+       @internal
+       */
+       static normalized(ranges, mainIndex = 0) {
+           let main = ranges[mainIndex];
+           ranges.sort((a, b) => a.from - b.from);
+           mainIndex = ranges.indexOf(main);
+           for (let i = 1; i < ranges.length; i++) {
+               let range = ranges[i], prev = ranges[i - 1];
+               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
+                   let from = prev.from, to = Math.max(range.to, prev.to);
+                   if (i <= mainIndex)
+                       mainIndex--;
+                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
+               }
+           }
+           return new EditorSelection(ranges, mainIndex);
+       }
+   }
+   function checkSelection(selection, docLength) {
+       for (let range of selection.ranges)
+           if (range.to > docLength)
+               throw new RangeError("Selection points outside of document");
+   }
+
+   let nextID = 0;
+   /**
+   A facet is a labeled value that is associated with an editor
+   state. It takes inputs from any number of extensions, and combines
+   those into a single output value.
+
+   Examples of uses of facets are the [tab
+   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
+   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
+   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
+
+   Note that `Facet` instances can be used anywhere where
+   [`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.
+   */
+   class Facet {
+       constructor(
+       /**
+       @internal
+       */
+       combine, 
+       /**
+       @internal
+       */
+       compareInput, 
+       /**
+       @internal
+       */
+       compare, isStatic, enables) {
+           this.combine = combine;
+           this.compareInput = compareInput;
+           this.compare = compare;
+           this.isStatic = isStatic;
+           /**
+           @internal
+           */
+           this.id = nextID++;
+           this.default = combine([]);
+           this.extensions = typeof enables == "function" ? enables(this) : enables;
+       }
+       /**
+       Returns a facet reader for this facet, which can be used to
+       [read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
+       */
+       get reader() { return this; }
+       /**
+       Define a new facet.
+       */
+       static define(config = {}) {
+           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables);
+       }
+       /**
+       Returns an extension that adds the given value to this facet.
+       */
+       of(value) {
+           return new FacetProvider([], this, 0 /* Provider.Static */, value);
+       }
+       /**
+       Create an extension that computes a value for the facet from a
+       state. You must take care to declare the parts of the state that
+       this value depends on, since your function is only called again
+       for a new state when one of those parts changed.
+       
+       In cases where your value depends only on a single field, you'll
+       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
+       */
+       compute(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider(deps, this, 1 /* Provider.Single */, get);
+       }
+       /**
+       Create an extension that computes zero or more values for this
+       facet from a state.
+       */
+       computeN(deps, get) {
+           if (this.isStatic)
+               throw new Error("Can't compute a static facet");
+           return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);
+       }
+       from(field, get) {
+           if (!get)
+               get = x => x;
+           return this.compute([field], state => get(state.field(field)));
+       }
+   }
+   function sameArray(a, b) {
+       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
+   }
+   class FacetProvider {
+       constructor(dependencies, facet, type, value) {
+           this.dependencies = dependencies;
+           this.facet = facet;
+           this.type = type;
+           this.value = value;
+           this.id = nextID++;
+       }
+       dynamicSlot(addresses) {
+           var _a;
+           let getter = this.value;
+           let compare = this.facet.compareInput;
+           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;
+           let depDoc = false, depSel = false, depAddrs = [];
+           for (let dep of this.dependencies) {
+               if (dep == "doc")
+                   depDoc = true;
+               else if (dep == "selection")
+                   depSel = true;
+               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
+                   depAddrs.push(addresses[dep.id]);
+           }
+           return {
+               create(state) {
+                   state.values[idx] = getter(state);
+                   return 1 /* SlotStatus.Changed */;
+               },
+               update(state, tr) {
+                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {
+                       let newVal = getter(state);
+                       if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
+                           state.values[idx] = newVal;
+                           return 1 /* SlotStatus.Changed */;
+                       }
+                   }
+                   return 0;
+               },
+               reconfigure: (state, oldState) => {
+                   let newVal, oldAddr = oldState.config.address[id];
+                   if (oldAddr != null) {
+                       let oldVal = getAddr(oldState, oldAddr);
+                       if (this.dependencies.every(dep => {
+                           return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :
+                               dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
+                       }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {
+                           state.values[idx] = oldVal;
+                           return 0;
+                       }
+                   }
+                   else {
+                       newVal = getter(state);
+                   }
+                   state.values[idx] = newVal;
+                   return 1 /* SlotStatus.Changed */;
+               }
+           };
+       }
+   }
+   function compareArray(a, b, compare) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (!compare(a[i], b[i]))
+               return false;
+       return true;
+   }
+   function ensureAll(state, addrs) {
+       let changed = false;
+       for (let addr of addrs)
+           if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)
+               changed = true;
+       return changed;
+   }
+   function dynamicFacetSlot(addresses, facet, providers) {
+       let providerAddrs = providers.map(p => addresses[p.id]);
+       let providerTypes = providers.map(p => p.type);
+       let dynamic = providerAddrs.filter(p => !(p & 1));
+       let idx = addresses[facet.id] >> 1;
+       function get(state) {
+           let values = [];
+           for (let i = 0; i < providerAddrs.length; i++) {
+               let value = getAddr(state, providerAddrs[i]);
+               if (providerTypes[i] == 2 /* Provider.Multi */)
+                   for (let val of value)
+                       values.push(val);
+               else
+                   values.push(value);
+           }
+           return facet.combine(values);
+       }
+       return {
+           create(state) {
+               for (let addr of providerAddrs)
+                   ensureAddr(state, addr);
+               state.values[idx] = get(state);
+               return 1 /* SlotStatus.Changed */;
+           },
+           update(state, tr) {
+               if (!ensureAll(state, dynamic))
+                   return 0;
+               let value = get(state);
+               if (facet.compare(value, state.values[idx]))
+                   return 0;
+               state.values[idx] = value;
+               return 1 /* SlotStatus.Changed */;
+           },
+           reconfigure(state, oldState) {
+               let depChanged = ensureAll(state, providerAddrs);
+               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
+               if (oldProviders && !depChanged && sameArray(providers, oldProviders)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               let value = get(state);
+               if (facet.compare(value, oldValue)) {
+                   state.values[idx] = oldValue;
+                   return 0;
+               }
+               state.values[idx] = value;
+               return 1 /* SlotStatus.Changed */;
+           }
+       };
+   }
+   const initField = /*@__PURE__*/Facet.define({ static: true });
+   /**
+   Fields can store additional information in an editor state, and
+   keep it in sync with the rest of the state.
+   */
+   class StateField {
+       constructor(
+       /**
+       @internal
+       */
+       id, createF, updateF, compareF, 
+       /**
+       @internal
+       */
+       spec) {
+           this.id = id;
+           this.createF = createF;
+           this.updateF = updateF;
+           this.compareF = compareF;
+           this.spec = spec;
+           /**
+           @internal
+           */
+           this.provides = undefined;
+       }
+       /**
+       Define a state field.
+       */
+       static define(config) {
+           let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);
+           if (config.provide)
+               field.provides = config.provide(field);
+           return field;
+       }
+       create(state) {
+           let init = state.facet(initField).find(i => i.field == this);
+           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
+       }
+       /**
+       @internal
+       */
+       slot(addresses) {
+           let idx = addresses[this.id] >> 1;
+           return {
+               create: (state) => {
+                   state.values[idx] = this.create(state);
+                   return 1 /* SlotStatus.Changed */;
+               },
+               update: (state, tr) => {
+                   let oldVal = state.values[idx];
+                   let value = this.updateF(oldVal, tr);
+                   if (this.compareF(oldVal, value))
+                       return 0;
+                   state.values[idx] = value;
+                   return 1 /* SlotStatus.Changed */;
+               },
+               reconfigure: (state, oldState) => {
+                   if (oldState.config.address[this.id] != null) {
+                       state.values[idx] = oldState.field(this);
+                       return 0;
+                   }
+                   state.values[idx] = this.create(state);
+                   return 1 /* SlotStatus.Changed */;
+               }
+           };
+       }
+       /**
+       Returns an extension that enables this field and overrides the
+       way it is initialized. Can be useful when you need to provide a
+       non-default starting value for the field.
+       */
+       init(create) {
+           return [this, initField.of({ field: this, create })];
+       }
+       /**
+       State field instances can be used as
+       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
+       given state.
+       */
+       get extension() { return this; }
+   }
+   const Prec_ = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
+   function prec(value) {
+       return (ext) => new PrecExtension(ext, value);
+   }
+   /**
+   By default extensions are registered in the order they are found
+   in the flattened form of nested array that was provided.
+   Individual extension values can be assigned a precedence to
+   override this. Extensions that do not have a precedence set get
+   the precedence of the nearest parent with a precedence, or
+   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
+   final ordering of extensions is determined by first sorting by
+   precedence and then by order within each precedence.
+   */
+   const Prec = {
+       /**
+       The highest precedence level, for extensions that should end up
+       near the start of the precedence ordering.
+       */
+       highest: /*@__PURE__*/prec(Prec_.highest),
+       /**
+       A higher-than-default precedence, for extensions that should
+       come before those with default precedence.
+       */
+       high: /*@__PURE__*/prec(Prec_.high),
+       /**
+       The default precedence, which is also used for extensions
+       without an explicit precedence.
+       */
+       default: /*@__PURE__*/prec(Prec_.default),
+       /**
+       A lower-than-default precedence.
+       */
+       low: /*@__PURE__*/prec(Prec_.low),
+       /**
+       The lowest precedence level. Meant for things that should end up
+       near the end of the extension order.
+       */
+       lowest: /*@__PURE__*/prec(Prec_.lowest)
+   };
+   class PrecExtension {
+       constructor(inner, prec) {
+           this.inner = inner;
+           this.prec = prec;
+       }
+   }
+   /**
+   Extension compartments can be used to make a configuration
+   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
+   configuration in a compartment, you can later
+   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
+   transaction.
+   */
+   class Compartment {
+       /**
+       Create an instance of this compartment to add to your [state
+       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
+       */
+       of(ext) { return new CompartmentInstance(this, ext); }
+       /**
+       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
+       reconfigures this compartment.
+       */
+       reconfigure(content) {
+           return Compartment.reconfigure.of({ compartment: this, extension: content });
+       }
+       /**
+       Get the current content of the compartment in the state, or
+       `undefined` if it isn't present.
+       */
+       get(state) {
+           return state.config.compartments.get(this);
+       }
+   }
+   class CompartmentInstance {
+       constructor(compartment, inner) {
+           this.compartment = compartment;
+           this.inner = inner;
+       }
+   }
+   class Configuration {
+       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
+           this.base = base;
+           this.compartments = compartments;
+           this.dynamicSlots = dynamicSlots;
+           this.address = address;
+           this.staticValues = staticValues;
+           this.facets = facets;
+           this.statusTemplate = [];
+           while (this.statusTemplate.length < dynamicSlots.length)
+               this.statusTemplate.push(0 /* SlotStatus.Unresolved */);
+       }
+       staticFacet(facet) {
+           let addr = this.address[facet.id];
+           return addr == null ? facet.default : this.staticValues[addr >> 1];
+       }
+       static resolve(base, compartments, oldState) {
+           let fields = [];
+           let facets = Object.create(null);
+           let newCompartments = new Map();
+           for (let ext of flatten(base, compartments, newCompartments)) {
+               if (ext instanceof StateField)
+                   fields.push(ext);
+               else
+                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
+           }
+           let address = Object.create(null);
+           let staticValues = [];
+           let dynamicSlots = [];
+           for (let field of fields) {
+               address[field.id] = dynamicSlots.length << 1;
+               dynamicSlots.push(a => field.slot(a));
+           }
+           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
+           for (let id in facets) {
+               let providers = facets[id], facet = providers[0].facet;
+               let oldProviders = oldFacets && oldFacets[id] || [];
+               if (providers.every(p => p.type == 0 /* Provider.Static */)) {
+                   address[facet.id] = (staticValues.length << 1) | 1;
+                   if (sameArray(oldProviders, providers)) {
+                       staticValues.push(oldState.facet(facet));
+                   }
+                   else {
+                       let value = facet.combine(providers.map(p => p.value));
+                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
+                   }
+               }
+               else {
+                   for (let p of providers) {
+                       if (p.type == 0 /* Provider.Static */) {
+                           address[p.id] = (staticValues.length << 1) | 1;
+                           staticValues.push(p.value);
+                       }
+                       else {
+                           address[p.id] = dynamicSlots.length << 1;
+                           dynamicSlots.push(a => p.dynamicSlot(a));
+                       }
+                   }
+                   address[facet.id] = dynamicSlots.length << 1;
+                   dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));
+               }
+           }
+           let dynamic = dynamicSlots.map(f => f(address));
+           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
+       }
+   }
+   function flatten(extension, compartments, newCompartments) {
+       let result = [[], [], [], [], []];
+       let seen = new Map();
+       function inner(ext, prec) {
+           let known = seen.get(ext);
+           if (known != null) {
+               if (known <= prec)
+                   return;
+               let found = result[known].indexOf(ext);
+               if (found > -1)
+                   result[known].splice(found, 1);
+               if (ext instanceof CompartmentInstance)
+                   newCompartments.delete(ext.compartment);
+           }
+           seen.set(ext, prec);
+           if (Array.isArray(ext)) {
+               for (let e of ext)
+                   inner(e, prec);
+           }
+           else if (ext instanceof CompartmentInstance) {
+               if (newCompartments.has(ext.compartment))
+                   throw new RangeError(`Duplicate use of compartment in extensions`);
+               let content = compartments.get(ext.compartment) || ext.inner;
+               newCompartments.set(ext.compartment, content);
+               inner(content, prec);
+           }
+           else if (ext instanceof PrecExtension) {
+               inner(ext.inner, ext.prec);
+           }
+           else if (ext instanceof StateField) {
+               result[prec].push(ext);
+               if (ext.provides)
+                   inner(ext.provides, prec);
+           }
+           else if (ext instanceof FacetProvider) {
+               result[prec].push(ext);
+               if (ext.facet.extensions)
+                   inner(ext.facet.extensions, Prec_.default);
+           }
+           else {
+               let content = ext.extension;
+               if (!content)
+                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
+               inner(content, prec);
+           }
+       }
+       inner(extension, Prec_.default);
+       return result.reduce((a, b) => a.concat(b));
+   }
+   function ensureAddr(state, addr) {
+       if (addr & 1)
+           return 2 /* SlotStatus.Computed */;
+       let idx = addr >> 1;
+       let status = state.status[idx];
+       if (status == 4 /* SlotStatus.Computing */)
+           throw new Error("Cyclic dependency between fields and/or facets");
+       if (status & 2 /* SlotStatus.Computed */)
+           return status;
+       state.status[idx] = 4 /* SlotStatus.Computing */;
+       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
+       return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;
+   }
+   function getAddr(state, addr) {
+       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
+   }
+
+   const languageData = /*@__PURE__*/Facet.define();
+   const allowMultipleSelections = /*@__PURE__*/Facet.define({
+       combine: values => values.some(v => v),
+       static: true
+   });
+   const lineSeparator = /*@__PURE__*/Facet.define({
+       combine: values => values.length ? values[0] : undefined,
+       static: true
+   });
+   const changeFilter = /*@__PURE__*/Facet.define();
+   const transactionFilter = /*@__PURE__*/Facet.define();
+   const transactionExtender = /*@__PURE__*/Facet.define();
+   const readOnly = /*@__PURE__*/Facet.define({
+       combine: values => values.length ? values[0] : false
+   });
+
+   /**
+   Annotations are tagged values that are used to add metadata to
+   transactions in an extensible way. They should be used to model
+   things that effect the entire transaction (such as its [time
+   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
+   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
+   _alongside_ the other changes made by the transaction, [state
+   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
+   */
+   class Annotation {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The annotation type.
+       */
+       type, 
+       /**
+       The value of this annotation.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Define a new type of annotation.
+       */
+       static define() { return new AnnotationType(); }
+   }
+   /**
+   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
+   */
+   class AnnotationType {
+       /**
+       Create an instance of this annotation.
+       */
+       of(value) { return new Annotation(this, value); }
+   }
+   /**
+   Representation of a type of state effect. Defined with
+   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
+   */
+   class StateEffectType {
+       /**
+       @internal
+       */
+       constructor(
+       // The `any` types in these function types are there to work
+       // around TypeScript issue #37631, where the type guard on
+       // `StateEffect.is` mysteriously stops working when these properly
+       // have type `Value`.
+       /**
+       @internal
+       */
+       map) {
+           this.map = map;
+       }
+       /**
+       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
+       type.
+       */
+       of(value) { return new StateEffect(this, value); }
+   }
+   /**
+   State effects can be used to represent additional effects
+   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
+   are often useful to model changes to custom [state
+   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
+   document or selection changes.
+   */
+   class StateEffect {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       @internal
+       */
+       type, 
+       /**
+       The value of this effect.
+       */
+       value) {
+           this.type = type;
+           this.value = value;
+       }
+       /**
+       Map this effect through a position mapping. Will return
+       `undefined` when that ends up deleting the effect.
+       */
+       map(mapping) {
+           let mapped = this.type.map(this.value, mapping);
+           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
+       }
+       /**
+       Tells you whether this effect object is of a given
+       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
+       */
+       is(type) { return this.type == type; }
+       /**
+       Define a new effect type. The type parameter indicates the type
+       of values that his effect holds. It should be a type that
+       doesn't include `undefined`, since that is used in
+       [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
+       removed.
+       */
+       static define(spec = {}) {
+           return new StateEffectType(spec.map || (v => v));
+       }
+       /**
+       Map an array of effects through a change set.
+       */
+       static mapEffects(effects, mapping) {
+           if (!effects.length)
+               return effects;
+           let result = [];
+           for (let effect of effects) {
+               let mapped = effect.map(mapping);
+               if (mapped)
+                   result.push(mapped);
+           }
+           return result;
+       }
+   }
+   /**
+   This effect can be used to reconfigure the root extensions of
+   the editor. Doing this will discard any extensions
+   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
+   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
+   compartments.
+   */
+   StateEffect.reconfigure = /*@__PURE__*/StateEffect.define();
+   /**
+   Append extensions to the top-level configuration of the editor.
+   */
+   StateEffect.appendConfig = /*@__PURE__*/StateEffect.define();
+   /**
+   Changes to the editor state are grouped into transactions.
+   Typically, a user action creates a single transaction, which may
+   contain any number of document changes, may change the selection,
+   or have other effects. Create a transaction by calling
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
+   dispatch one by calling
+   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
+   */
+   class Transaction {
+       constructor(
+       /**
+       The state from which the transaction starts.
+       */
+       startState, 
+       /**
+       The document changes made by this transaction.
+       */
+       changes, 
+       /**
+       The selection set by this transaction, or undefined if it
+       doesn't explicitly set a selection.
+       */
+       selection, 
+       /**
+       The effects added to the transaction.
+       */
+       effects, 
+       /**
+       @internal
+       */
+       annotations, 
+       /**
+       Whether the selection should be scrolled into view after this
+       transaction is dispatched.
+       */
+       scrollIntoView) {
+           this.startState = startState;
+           this.changes = changes;
+           this.selection = selection;
+           this.effects = effects;
+           this.annotations = annotations;
+           this.scrollIntoView = scrollIntoView;
+           /**
+           @internal
+           */
+           this._doc = null;
+           /**
+           @internal
+           */
+           this._state = null;
+           if (selection)
+               checkSelection(selection, changes.newLength);
+           if (!annotations.some((a) => a.type == Transaction.time))
+               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
+       }
+       /**
+       @internal
+       */
+       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
+           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
+       }
+       /**
+       The new document produced by the transaction. Contrary to
+       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
+       force the entire new state to be computed right away, so it is
+       recommended that [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
+       when they need to look at the new document.
+       */
+       get newDoc() {
+           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
+       }
+       /**
+       The new selection produced by the transaction. If
+       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
+       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
+       current selection through the changes made by the transaction.
+       */
+       get newSelection() {
+           return this.selection || this.startState.selection.map(this.changes);
+       }
+       /**
+       The new state created by the transaction. Computed on demand
+       (but retained for subsequent access), so it is recommended not to
+       access it in [transaction
+       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
+       */
+       get state() {
+           if (!this._state)
+               this.startState.applyTransaction(this);
+           return this._state;
+       }
+       /**
+       Get the value of the given annotation type, if any.
+       */
+       annotation(type) {
+           for (let ann of this.annotations)
+               if (ann.type == type)
+                   return ann.value;
+           return undefined;
+       }
+       /**
+       Indicates whether the transaction changed the document.
+       */
+       get docChanged() { return !this.changes.empty; }
+       /**
+       Indicates whether this transaction reconfigures the state
+       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
+       with a top-level configuration
+       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
+       */
+       get reconfigured() { return this.startState.config != this.state.config; }
+       /**
+       Returns true if the transaction has a [user
+       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
+       or more specific than `event`. For example, if the transaction
+       has `"select.pointer"` as user event, `"select"` and
+       `"select.pointer"` will match it.
+       */
+       isUserEvent(event) {
+           let e = this.annotation(Transaction.userEvent);
+           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
+       }
+   }
+   /**
+   Annotation used to store transaction timestamps. Automatically
+   added to every transaction, holding `Date.now()`.
+   */
+   Transaction.time = /*@__PURE__*/Annotation.define();
+   /**
+   Annotation used to associate a transaction with a user interface
+   event. Holds a string identifying the event, using a
+   dot-separated format to support attaching more specific
+   information. The events used by the core libraries are:
+
+    - `"input"` when content is entered
+      - `"input.type"` for typed input
+        - `"input.type.compose"` for composition
+      - `"input.paste"` for pasted input
+      - `"input.drop"` when adding content with drag-and-drop
+      - `"input.complete"` when autocompleting
+    - `"delete"` when the user deletes content
+      - `"delete.selection"` when deleting the selection
+      - `"delete.forward"` when deleting forward from the selection
+      - `"delete.backward"` when deleting backward from the selection
+      - `"delete.cut"` when cutting to the clipboard
+    - `"move"` when content is moved
+      - `"move.drop"` when content is moved within the editor through drag-and-drop
+    - `"select"` when explicitly changing the selection
+      - `"select.pointer"` when selecting with a mouse or other pointing device
+    - `"undo"` and `"redo"` for history actions
+
+   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
+   whether the annotation matches a given event.
+   */
+   Transaction.userEvent = /*@__PURE__*/Annotation.define();
+   /**
+   Annotation indicating whether a transaction should be added to
+   the undo history or not.
+   */
+   Transaction.addToHistory = /*@__PURE__*/Annotation.define();
+   /**
+   Annotation indicating (when present and true) that a transaction
+   represents a change made by some other actor, not the user. This
+   is used, for example, to tag other people's changes in
+   collaborative editing.
+   */
+   Transaction.remote = /*@__PURE__*/Annotation.define();
+   function joinRanges(a, b) {
+       let result = [];
+       for (let iA = 0, iB = 0;;) {
+           let from, to;
+           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
+               from = a[iA++];
+               to = a[iA++];
+           }
+           else if (iB < b.length) {
+               from = b[iB++];
+               to = b[iB++];
+           }
+           else
+               return result;
+           if (!result.length || result[result.length - 1] < from)
+               result.push(from, to);
+           else if (result[result.length - 1] < to)
+               result[result.length - 1] = to;
+       }
+   }
+   function mergeTransaction(a, b, sequential) {
+       var _a;
+       let mapForA, mapForB, changes;
+       if (sequential) {
+           mapForA = b.changes;
+           mapForB = ChangeSet.empty(b.changes.length);
+           changes = a.changes.compose(b.changes);
+       }
+       else {
+           mapForA = b.changes.map(a.changes);
+           mapForB = a.changes.mapDesc(b.changes, true);
+           changes = a.changes.compose(mapForA);
+       }
+       return {
+           changes,
+           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
+           effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),
+           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
+           scrollIntoView: a.scrollIntoView || b.scrollIntoView
+       };
+   }
+   function resolveTransactionInner(state, spec, docSize) {
+       let sel = spec.selection, annotations = asArray$1(spec.annotations);
+       if (spec.userEvent)
+           annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));
+       return {
+           changes: spec.changes instanceof ChangeSet ? spec.changes
+               : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),
+           selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),
+           effects: asArray$1(spec.effects),
+           annotations,
+           scrollIntoView: !!spec.scrollIntoView
+       };
+   }
+   function resolveTransaction(state, specs, filter) {
+       let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);
+       if (specs.length && specs[0].filter === false)
+           filter = false;
+       for (let i = 1; i < specs.length; i++) {
+           if (specs[i].filter === false)
+               filter = false;
+           let seq = !!specs[i].sequential;
+           s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
+       }
+       let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
+       return extendTransaction(filter ? filterTransaction(tr) : tr);
+   }
+   // Finish a transaction by applying filters if necessary.
+   function filterTransaction(tr) {
+       let state = tr.startState;
+       // Change filters
+       let result = true;
+       for (let filter of state.facet(changeFilter)) {
+           let value = filter(tr);
+           if (value === false) {
+               result = false;
+               break;
+           }
+           if (Array.isArray(value))
+               result = result === true ? value : joinRanges(result, value);
+       }
+       if (result !== true) {
+           let changes, back;
+           if (result === false) {
+               back = tr.changes.invertedDesc;
+               changes = ChangeSet.empty(state.doc.length);
+           }
+           else {
+               let filtered = tr.changes.filter(result);
+               changes = filtered.changes;
+               back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;
+           }
+           tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
+       }
+       // Transaction filters
+       let filters = state.facet(transactionFilter);
+       for (let i = filters.length - 1; i >= 0; i--) {
+           let filtered = filters[i](tr);
+           if (filtered instanceof Transaction)
+               tr = filtered;
+           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction)
+               tr = filtered[0];
+           else
+               tr = resolveTransaction(state, asArray$1(filtered), false);
+       }
+       return tr;
+   }
+   function extendTransaction(tr) {
+       let state = tr.startState, extenders = state.facet(transactionExtender), spec = tr;
+       for (let i = extenders.length - 1; i >= 0; i--) {
+           let extension = extenders[i](tr);
+           if (extension && Object.keys(extension).length)
+               spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
+       }
+       return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
+   }
+   const none$1 = [];
+   function asArray$1(value) {
+       return value == null ? none$1 : Array.isArray(value) ? value : [value];
+   }
+
+   /**
+   The categories produced by a [character
+   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
+   do things like selecting by word.
+   */
+   var CharCategory = /*@__PURE__*/(function (CharCategory) {
+       /**
+       Word characters.
+       */
+       CharCategory[CharCategory["Word"] = 0] = "Word";
+       /**
+       Whitespace.
+       */
+       CharCategory[CharCategory["Space"] = 1] = "Space";
+       /**
+       Anything else.
+       */
+       CharCategory[CharCategory["Other"] = 2] = "Other";
+   return CharCategory})(CharCategory || (CharCategory = {}));
+   const nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
+   let wordChar;
+   try {
+       wordChar = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
+   }
+   catch (_) { }
+   function hasWordChar(str) {
+       if (wordChar)
+           return wordChar.test(str);
+       for (let i = 0; i < str.length; i++) {
+           let ch = str[i];
+           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)))
+               return true;
+       }
+       return false;
+   }
+   function makeCategorizer(wordChars) {
+       return (char) => {
+           if (!/\S/.test(char))
+               return CharCategory.Space;
+           if (hasWordChar(char))
+               return CharCategory.Word;
+           for (let i = 0; i < wordChars.length; i++)
+               if (char.indexOf(wordChars[i]) > -1)
+                   return CharCategory.Word;
+           return CharCategory.Other;
+       };
+   }
+
+   /**
+   The editor state class is a persistent (immutable) data structure.
+   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
+   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
+   instance, without modifying the original object.
+
+   As such, _never_ mutate properties of a state directly. That'll
+   just break things.
+   */
+   class EditorState {
+       constructor(
+       /**
+       @internal
+       */
+       config, 
+       /**
+       The current document.
+       */
+       doc, 
+       /**
+       The current selection.
+       */
+       selection, 
+       /**
+       @internal
+       */
+       values, computeSlot, tr) {
+           this.config = config;
+           this.doc = doc;
+           this.selection = selection;
+           this.values = values;
+           this.status = config.statusTemplate.slice();
+           this.computeSlot = computeSlot;
+           // Fill in the computed state immediately, so that further queries
+           // for it made during the update return this state
+           if (tr)
+               tr._state = this;
+           for (let i = 0; i < this.config.dynamicSlots.length; i++)
+               ensureAddr(this, i << 1);
+           this.computeSlot = null;
+       }
+       field(field, require = true) {
+           let addr = this.config.address[field.id];
+           if (addr == null) {
+               if (require)
+                   throw new RangeError("Field is not present in this state");
+               return undefined;
+           }
+           ensureAddr(this, addr);
+           return getAddr(this, addr);
+       }
+       /**
+       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
+       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
+       can be passed. Unless
+       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
+       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
+       are assumed to start in the _current_ document (not the document
+       produced by previous specs), and its
+       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
+       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
+       to the document created by its _own_ changes. The resulting
+       transaction contains the combined effect of all the different
+       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
+       specs take precedence over earlier ones.
+       */
+       update(...specs) {
+           return resolveTransaction(this, specs, true);
+       }
+       /**
+       @internal
+       */
+       applyTransaction(tr) {
+           let conf = this.config, { base, compartments } = conf;
+           for (let effect of tr.effects) {
+               if (effect.is(Compartment.reconfigure)) {
+                   if (conf) {
+                       compartments = new Map;
+                       conf.compartments.forEach((val, key) => compartments.set(key, val));
+                       conf = null;
+                   }
+                   compartments.set(effect.value.compartment, effect.value.extension);
+               }
+               else if (effect.is(StateEffect.reconfigure)) {
+                   conf = null;
+                   base = effect.value;
+               }
+               else if (effect.is(StateEffect.appendConfig)) {
+                   conf = null;
+                   base = asArray$1(base).concat(effect.value);
+               }
+           }
+           let startValues;
+           if (!conf) {
+               conf = Configuration.resolve(base, compartments, this);
+               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
+               startValues = intermediateState.values;
+           }
+           else {
+               startValues = tr.startState.values.slice();
+           }
+           let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();
+           new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);
+       }
+       /**
+       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
+       replaces every selection range with the given content.
+       */
+       replaceSelection(text) {
+           if (typeof text == "string")
+               text = this.toText(text);
+           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
+               range: EditorSelection.cursor(range.from + text.length) }));
+       }
+       /**
+       Create a set of changes and a new selection by running the given
+       function for each range in the active selection. The function
+       can return an optional set of changes (in the coordinate space
+       of the start document), plus an updated range (in the coordinate
+       space of the document produced by the call's own changes). This
+       method will merge all the changes and ranges into a single
+       changeset and selection, and return it as a [transaction
+       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
+       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
+       */
+       changeByRange(f) {
+           let sel = this.selection;
+           let result1 = f(sel.ranges[0]);
+           let changes = this.changes(result1.changes), ranges = [result1.range];
+           let effects = asArray$1(result1.effects);
+           for (let i = 1; i < sel.ranges.length; i++) {
+               let result = f(sel.ranges[i]);
+               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
+               for (let j = 0; j < i; j++)
+                   ranges[j] = ranges[j].map(newMapped);
+               let mapBy = changes.mapDesc(newChanges, true);
+               ranges.push(result.range.map(mapBy));
+               changes = changes.compose(newMapped);
+               effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray$1(result.effects), mapBy));
+           }
+           return {
+               changes,
+               selection: EditorSelection.create(ranges, sel.mainIndex),
+               effects
+           };
+       }
+       /**
+       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
+       description, taking the state's document length and line
+       separator into account.
+       */
+       changes(spec = []) {
+           if (spec instanceof ChangeSet)
+               return spec;
+           return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
+       }
+       /**
+       Using the state's [line
+       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
+       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
+       */
+       toText(string) {
+           return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
+       }
+       /**
+       Return the given range of the document as a string.
+       */
+       sliceDoc(from = 0, to = this.doc.length) {
+           return this.doc.sliceString(from, to, this.lineBreak);
+       }
+       /**
+       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
+       */
+       facet(facet) {
+           let addr = this.config.address[facet.id];
+           if (addr == null)
+               return facet.default;
+           ensureAddr(this, addr);
+           return getAddr(this, addr);
+       }
+       /**
+       Convert this state to a JSON-serializable object. When custom
+       fields should be serialized, you can pass them in as an object
+       mapping property names (in the resulting object, which should
+       not use `doc` or `selection`) to fields.
+       */
+       toJSON(fields) {
+           let result = {
+               doc: this.sliceDoc(),
+               selection: this.selection.toJSON()
+           };
+           if (fields)
+               for (let prop in fields) {
+                   let value = fields[prop];
+                   if (value instanceof StateField && this.config.address[value.id] != null)
+                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
+               }
+           return result;
+       }
+       /**
+       Deserialize a state from its JSON representation. When custom
+       fields should be deserialized, pass the same object you passed
+       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
+       third argument.
+       */
+       static fromJSON(json, config = {}, fields) {
+           if (!json || typeof json.doc != "string")
+               throw new RangeError("Invalid JSON representation for EditorState");
+           let fieldInit = [];
+           if (fields)
+               for (let prop in fields) {
+                   if (Object.prototype.hasOwnProperty.call(json, prop)) {
+                       let field = fields[prop], value = json[prop];
+                       fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
+                   }
+               }
+           return EditorState.create({
+               doc: json.doc,
+               selection: EditorSelection.fromJSON(json.selection),
+               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
+           });
+       }
+       /**
+       Create a new state. You'll usually only need this when
+       initializing an editor—updated states are created by applying
+       transactions.
+       */
+       static create(config = {}) {
+           let configuration = Configuration.resolve(config.extensions || [], new Map);
+           let doc = config.doc instanceof Text ? config.doc
+               : Text.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
+           let selection = !config.selection ? EditorSelection.single(0)
+               : config.selection instanceof EditorSelection ? config.selection
+                   : EditorSelection.single(config.selection.anchor, config.selection.head);
+           checkSelection(selection, doc.length);
+           if (!configuration.staticFacet(allowMultipleSelections))
+               selection = selection.asSingle();
+           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
+       }
+       /**
+       The size (in columns) of a tab in the document, determined by
+       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
+       */
+       get tabSize() { return this.facet(EditorState.tabSize); }
+       /**
+       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
+       string for this state.
+       */
+       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
+       /**
+       Returns true when the editor is
+       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
+       */
+       get readOnly() { return this.facet(readOnly); }
+       /**
+       Look up a translation for the given phrase (via the
+       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
+       original string if no translation is found.
+       
+       If additional arguments are passed, they will be inserted in
+       place of markers like `$1` (for the first value) and `$2`, etc.
+       A single `$` is equivalent to `$1`, and `$$` will produce a
+       literal dollar sign.
+       */
+       phrase(phrase, ...insert) {
+           for (let map of this.facet(EditorState.phrases))
+               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
+                   phrase = map[phrase];
+                   break;
+               }
+           if (insert.length)
+               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
+                   if (i == "$")
+                       return "$";
+                   let n = +(i || 1);
+                   return !n || n > insert.length ? m : insert[n - 1];
+               });
+           return phrase;
+       }
+       /**
+       Find the values for a given language data field, provided by the
+       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
+       
+       Examples of language data fields are...
+       
+       - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
+         comment syntax.
+       - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
+         for providing language-specific completion sources.
+       - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
+         characters that should be considered part of words in this
+         language.
+       - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
+         bracket closing behavior.
+       */
+       languageDataAt(name, pos, side = -1) {
+           let values = [];
+           for (let provider of this.facet(languageData)) {
+               for (let result of provider(this, pos, side)) {
+                   if (Object.prototype.hasOwnProperty.call(result, name))
+                       values.push(result[name]);
+               }
+           }
+           return values;
+       }
+       /**
+       Return a function that can categorize strings (expected to
+       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
+       into one of:
+       
+        - Word (contains an alphanumeric character or a character
+          explicitly listed in the local language's `"wordChars"`
+          language data, which should be a string)
+        - Space (contains only whitespace)
+        - Other (anything else)
+       */
+       charCategorizer(at) {
+           return makeCategorizer(this.languageDataAt("wordChars", at).join(""));
+       }
+       /**
+       Find the word at the given position, meaning the range
+       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
+       around it. If no word characters are adjacent to the position,
+       this returns null.
+       */
+       wordAt(pos) {
+           let { text, from, length } = this.doc.lineAt(pos);
+           let cat = this.charCategorizer(pos);
+           let start = pos - from, end = pos - from;
+           while (start > 0) {
+               let prev = findClusterBreak(text, start, false);
+               if (cat(text.slice(prev, start)) != CharCategory.Word)
+                   break;
+               start = prev;
+           }
+           while (end < length) {
+               let next = findClusterBreak(text, end);
+               if (cat(text.slice(end, next)) != CharCategory.Word)
+                   break;
+               end = next;
+           }
+           return start == end ? null : EditorSelection.range(start + from, end + from);
+       }
+   }
+   /**
+   A facet that, when enabled, causes the editor to allow multiple
+   ranges to be selected. Be careful though, because by default the
+   editor relies on the native DOM selection, which cannot handle
+   multiple selections. An extension like
+   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
+   secondary selections visible to the user.
+   */
+   EditorState.allowMultipleSelections = allowMultipleSelections;
+   /**
+   Configures the tab size to use in this state. The first
+   (highest-precedence) value of the facet is used. If no value is
+   given, this defaults to 4.
+   */
+   EditorState.tabSize = /*@__PURE__*/Facet.define({
+       combine: values => values.length ? values[0] : 4
+   });
+   /**
+   The line separator to use. By default, any of `"\n"`, `"\r\n"`
+   and `"\r"` is treated as a separator when splitting lines, and
+   lines are joined with `"\n"`.
+
+   When you configure a value here, only that precise separator
+   will be used, allowing you to round-trip documents through the
+   editor without normalizing line separators.
+   */
+   EditorState.lineSeparator = lineSeparator;
+   /**
+   This facet controls the value of the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
+   consulted by commands and extensions that implement editing
+   functionality to determine whether they should apply. It
+   defaults to false, but when its highest-precedence value is
+   `true`, such functionality disables itself.
+
+   Not to be confused with
+   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
+   controls whether the editor's DOM is set to be editable (and
+   thus focusable).
+   */
+   EditorState.readOnly = readOnly;
+   /**
+   Registers translation phrases. The
+   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
+   all objects registered with this facet to find translations for
+   its argument.
+   */
+   EditorState.phrases = /*@__PURE__*/Facet.define({
+       compare(a, b) {
+           let kA = Object.keys(a), kB = Object.keys(b);
+           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
+       }
+   });
+   /**
+   A facet used to register [language
+   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
+   */
+   EditorState.languageData = languageData;
+   /**
+   Facet used to register change filters, which are called for each
+   transaction (unless explicitly
+   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
+   part of the transaction's changes.
+
+   Such a function can return `true` to indicate that it doesn't
+   want to do anything, `false` to completely stop the changes in
+   the transaction, or a set of ranges in which changes should be
+   suppressed. Such ranges are represented as an array of numbers,
+   with each pair of two numbers indicating the start and end of a
+   range. So for example `[10, 20, 100, 110]` suppresses changes
+   between 10 and 20, and between 100 and 110.
+   */
+   EditorState.changeFilter = changeFilter;
+   /**
+   Facet used to register a hook that gets a chance to update or
+   replace transaction specs before they are applied. This will
+   only be applied for transactions that don't have
+   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
+   can either return a single transaction spec (possibly the input
+   transaction), or an array of specs (which will be combined in
+   the same way as the arguments to
+   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
+
+   When possible, it is recommended to avoid accessing
+   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
+   since it will force creation of a state that will then be
+   discarded again, if the transaction is actually filtered.
+
+   (This functionality should be used with care. Indiscriminately
+   modifying transaction is likely to break something or degrade
+   the user experience.)
+   */
+   EditorState.transactionFilter = transactionFilter;
+   /**
+   This is a more limited form of
+   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
+   which can only add
+   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
+   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
+   of filter runs even if the transaction has disabled regular
+   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
+   for effects that don't need to touch the changes or selection,
+   but do want to process every transaction.
+
+   Extenders run _after_ filters, when both are present.
+   */
+   EditorState.transactionExtender = transactionExtender;
+   Compartment.reconfigure = /*@__PURE__*/StateEffect.define();
+
+   /**
+   Utility function for combining behaviors to fill in a config
+   object from an array of provided configs. `defaults` should hold
+   default values for all optional fields in `Config`.
+
+   The function will, by default, error
+   when a field gets two values that aren't `===`-equal, but you can
+   provide combine functions per field to do something else.
+   */
+   function combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
+   combine = {}) {
+       let result = {};
+       for (let config of configs)
+           for (let key of Object.keys(config)) {
+               let value = config[key], current = result[key];
+               if (current === undefined)
+                   result[key] = value;
+               else if (current === value || value === undefined) ; // No conflict
+               else if (Object.hasOwnProperty.call(combine, key))
+                   result[key] = combine[key](current, value);
+               else
+                   throw new Error("Config merge conflict for field " + key);
+           }
+       for (let key in defaults)
+           if (result[key] === undefined)
+               result[key] = defaults[key];
+       return result;
+   }
+
+   /**
+   Each range is associated with a value, which must inherit from
+   this class.
+   */
+   class RangeValue {
+       /**
+       Compare this value with another value. Used when comparing
+       rangesets. The default implementation compares by identity.
+       Unless you are only creating a fixed number of unique instances
+       of your value type, it is a good idea to implement this
+       properly.
+       */
+       eq(other) { return this == other; }
+       /**
+       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
+       */
+       range(from, to = from) { return Range.create(from, to, this); }
+   }
+   RangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;
+   RangeValue.prototype.point = false;
+   RangeValue.prototype.mapMode = MapMode.TrackDel;
+   /**
+   A range associates a value with a range of positions.
+   */
+   class Range {
+       constructor(
+       /**
+       The range's start position.
+       */
+       from, 
+       /**
+       Its end position.
+       */
+       to, 
+       /**
+       The value associated with this range.
+       */
+       value) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+       }
+       /**
+       @internal
+       */
+       static create(from, to, value) {
+           return new Range(from, to, value);
+       }
+   }
+   function cmpRange(a, b) {
+       return a.from - b.from || a.value.startSide - b.value.startSide;
+   }
+   class Chunk {
+       constructor(from, to, value, 
+       // Chunks are marked with the largest point that occurs
+       // in them (or -1 for no points), so that scans that are
+       // only interested in points (such as the
+       // heightmap-related logic) can skip range-only chunks.
+       maxPoint) {
+           this.from = from;
+           this.to = to;
+           this.value = value;
+           this.maxPoint = maxPoint;
+       }
+       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(pos, side, end, startAt = 0) {
+           let arr = end ? this.to : this.from;
+           for (let lo = startAt, hi = arr.length;;) {
+               if (lo == hi)
+                   return lo;
+               let mid = (lo + hi) >> 1;
+               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
+               if (mid == lo)
+                   return diff >= 0 ? lo : hi;
+               if (diff >= 0)
+                   hi = mid;
+               else
+                   lo = mid + 1;
+           }
+       }
+       between(offset, from, to, f) {
+           for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)
+               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
+                   return false;
+       }
+       map(offset, changes) {
+           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
+           for (let i = 0; i < this.value.length; i++) {
+               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
+               if (curFrom == curTo) {
+                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
+                   if (mapped == null)
+                       continue;
+                   newFrom = newTo = mapped;
+                   if (val.startSide != val.endSide) {
+                       newTo = changes.mapPos(curFrom, val.endSide);
+                       if (newTo < newFrom)
+                           continue;
+                   }
+               }
+               else {
+                   newFrom = changes.mapPos(curFrom, val.startSide);
+                   newTo = changes.mapPos(curTo, val.endSide);
+                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
+                       continue;
+               }
+               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
+                   continue;
+               if (newPos < 0)
+                   newPos = newFrom;
+               if (val.point)
+                   maxPoint = Math.max(maxPoint, newTo - newFrom);
+               value.push(val);
+               from.push(newFrom - newPos);
+               to.push(newTo - newPos);
+           }
+           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
+       }
+   }
+   /**
+   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
+   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
+   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
+   structure.
+   */
+   class RangeSet {
+       constructor(
+       /**
+       @internal
+       */
+       chunkPos, 
+       /**
+       @internal
+       */
+       chunk, 
+       /**
+       @internal
+       */
+       nextLayer, 
+       /**
+       @internal
+       */
+       maxPoint) {
+           this.chunkPos = chunkPos;
+           this.chunk = chunk;
+           this.nextLayer = nextLayer;
+           this.maxPoint = maxPoint;
+       }
+       /**
+       @internal
+       */
+       static create(chunkPos, chunk, nextLayer, maxPoint) {
+           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
+       }
+       /**
+       @internal
+       */
+       get length() {
+           let last = this.chunk.length - 1;
+           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
+       }
+       /**
+       The number of ranges in the set.
+       */
+       get size() {
+           if (this.isEmpty)
+               return 0;
+           let size = this.nextLayer.size;
+           for (let chunk of this.chunk)
+               size += chunk.value.length;
+           return size;
+       }
+       /**
+       @internal
+       */
+       chunkEnd(index) {
+           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
+           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
+           let filter = updateSpec.filter;
+           if (add.length == 0 && !filter)
+               return this;
+           if (sort)
+               add = add.slice().sort(cmpRange);
+           if (this.isEmpty)
+               return add.length ? RangeSet.of(add) : this;
+           let cur = new LayerCursor(this, null, -1).goto(0), i = 0, spill = [];
+           let builder = new RangeSetBuilder();
+           while (cur.value || i < add.length) {
+               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
+                   let range = add[i++];
+                   if (!builder.addInner(range.from, range.to, range.value))
+                       spill.push(range);
+               }
+               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
+                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
+                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
+                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
+                   cur.nextChunk();
+               }
+               else {
+                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
+                       if (!builder.addInner(cur.from, cur.to, cur.value))
+                           spill.push(Range.create(cur.from, cur.to, cur.value));
+                   }
+                   cur.next();
+               }
+           }
+           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
+               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
+       }
+       /**
+       Map this range set through a set of changes, return the new set.
+       */
+       map(changes) {
+           if (changes.empty || this.isEmpty)
+               return this;
+           let chunks = [], chunkPos = [], maxPoint = -1;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               let touch = changes.touchesRange(start, start + chunk.length);
+               if (touch === false) {
+                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
+                   chunks.push(chunk);
+                   chunkPos.push(changes.mapPos(start));
+               }
+               else if (touch === true) {
+                   let { mapped, pos } = chunk.map(start, changes);
+                   if (mapped) {
+                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
+                       chunks.push(mapped);
+                       chunkPos.push(pos);
+                   }
+               }
+           }
+           let next = this.nextLayer.map(changes);
+           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
+       }
+       /**
+       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(from, to, f) {
+           if (this.isEmpty)
+               return;
+           for (let i = 0; i < this.chunk.length; i++) {
+               let start = this.chunkPos[i], chunk = this.chunk[i];
+               if (to >= start && from <= start + chunk.length &&
+                   chunk.between(start, from - start, to - start, f) === false)
+                   return;
+           }
+           this.nextLayer.between(from, to, f);
+       }
+       /**
+       Iterate over the ranges in this set, in order, including all
+       ranges that end at or after `from`.
+       */
+       iter(from = 0) {
+           return HeapCursor.from([this]).goto(from);
+       }
+       /**
+       @internal
+       */
+       get isEmpty() { return this.nextLayer == this; }
+       /**
+       Iterate over the ranges in a collection of sets, in order,
+       starting from `from`.
+       */
+       static iter(sets, from = 0) {
+           return HeapCursor.from(sets).goto(from);
+       }
+       /**
+       Iterate over two groups of sets, calling methods on `comparator`
+       to notify it of possible differences.
+       */
+       static compare(oldSets, newSets, 
+       /**
+       This indicates how the underlying data changed between these
+       ranges, and is needed to synchronize the iteration.
+       */
+       textDiff, comparator, 
+       /**
+       Can be used to ignore all non-point ranges, and points below
+       the given size. When -1, all ranges are compared.
+       */
+       minPointSize = -1) {
+           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
+           let sharedChunks = findSharedChunks(a, b, textDiff);
+           let sideA = new SpanCursor(a, sharedChunks, minPointSize);
+           let sideB = new SpanCursor(b, sharedChunks, minPointSize);
+           textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));
+           if (textDiff.empty && textDiff.length == 0)
+               compare(sideA, 0, sideB, 0, 0, comparator);
+       }
+       /**
+       Compare the contents of two groups of range sets, returning true
+       if they are equivalent in the given range.
+       */
+       static eq(oldSets, newSets, from = 0, to) {
+           if (to == null)
+               to = 1000000000 /* C.Far */ - 1;
+           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
+           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
+           if (a.length != b.length)
+               return false;
+           if (!a.length)
+               return true;
+           let sharedChunks = findSharedChunks(a, b);
+           let sideA = new SpanCursor(a, sharedChunks, 0).goto(from), sideB = new SpanCursor(b, sharedChunks, 0).goto(from);
+           for (;;) {
+               if (sideA.to != sideB.to ||
+                   !sameValues(sideA.active, sideB.active) ||
+                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
+                   return false;
+               if (sideA.to > to)
+                   return true;
+               sideA.next();
+               sideB.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(sets, from, to, iterator, 
+       /**
+       When given and greater than -1, only points of at least this
+       size are taken into account.
+       */
+       minPointSize = -1) {
+           let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;
+           let openRanges = cursor.openStart;
+           for (;;) {
+               let curTo = Math.min(cursor.to, to);
+               if (cursor.point) {
+                   let active = cursor.activeForPoint(cursor.to);
+                   let openCount = cursor.pointFrom < from ? active.length + 1
+                       : cursor.point.startSide < 0 ? active.length
+                           : Math.min(active.length, openRanges);
+                   iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);
+                   openRanges = Math.min(cursor.openEnd(curTo), active.length);
+               }
+               else if (curTo > pos) {
+                   iterator.span(pos, curTo, cursor.active, openRanges);
+                   openRanges = cursor.openEnd(curTo);
+               }
+               if (cursor.to > to)
+                   return openRanges + (cursor.point && cursor.to > to ? 1 : 0);
+               pos = cursor.to;
+               cursor.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(ranges, sort = false) {
+           let build = new RangeSetBuilder();
+           for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges)
+               build.add(range.from, range.to, range.value);
+           return build.finish();
+       }
+       /**
+       Join an array of range sets into a single set.
+       */
+       static join(sets) {
+           if (!sets.length)
+               return RangeSet.empty;
+           let result = sets[sets.length - 1];
+           for (let i = sets.length - 2; i >= 0; i--) {
+               for (let layer = sets[i]; layer != RangeSet.empty; layer = layer.nextLayer)
+                   result = new RangeSet(layer.chunkPos, layer.chunk, result, Math.max(layer.maxPoint, result.maxPoint));
+           }
+           return result;
+       }
+   }
+   /**
+   The empty set of ranges.
+   */
+   RangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);
+   function lazySort(ranges) {
+       if (ranges.length > 1)
+           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
+               let cur = ranges[i];
+               if (cmpRange(prev, cur) > 0)
+                   return ranges.slice().sort(cmpRange);
+               prev = cur;
+           }
+       return ranges;
+   }
+   RangeSet.empty.nextLayer = RangeSet.empty;
+   /**
+   A range set builder is a data structure that helps build up a
+   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
+   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
+   */
+   class RangeSetBuilder {
+       finishChunk(newArrays) {
+           this.chunks.push(new Chunk(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;
+           if (newArrays) {
+               this.from = [];
+               this.to = [];
+               this.value = [];
+           }
+       }
+       /**
+       Create an empty builder.
+       */
+       constructor() {
+           this.chunks = [];
+           this.chunkPos = [];
+           this.chunkStart = -1;
+           this.last = null;
+           this.lastFrom = -1000000000 /* C.Far */;
+           this.lastTo = -1000000000 /* C.Far */;
+           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(from, to, value) {
+           if (!this.addInner(from, to, value))
+               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
+       }
+       /**
+       @internal
+       */
+       addInner(from, to, value) {
+           let diff = from - this.lastTo || value.startSide - this.last.endSide;
+           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
+               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
+           if (diff < 0)
+               return false;
+           if (this.from.length == 250 /* C.ChunkSize */)
+               this.finishChunk(true);
+           if (this.chunkStart < 0)
+               this.chunkStart = from;
+           this.from.push(from - this.chunkStart);
+           this.to.push(to - this.chunkStart);
+           this.last = value;
+           this.lastFrom = from;
+           this.lastTo = to;
+           this.value.push(value);
+           if (value.point)
+               this.maxPoint = Math.max(this.maxPoint, to - from);
+           return true;
+       }
+       /**
+       @internal
+       */
+       addChunk(from, chunk) {
+           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
+               return false;
+           if (this.from.length)
+               this.finishChunk(true);
+           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
+           this.chunks.push(chunk);
+           this.chunkPos.push(from);
+           let last = chunk.value.length - 1;
+           this.last = chunk.value[last];
+           this.lastFrom = chunk.from[last] + from;
+           this.lastTo = chunk.to[last] + from;
+           return true;
+       }
+       /**
+       Finish the range set. Returns the new set. The builder can't be
+       used anymore after this has been called.
+       */
+       finish() { return this.finishInner(RangeSet.empty); }
+       /**
+       @internal
+       */
+       finishInner(next) {
+           if (this.from.length)
+               this.finishChunk(false);
+           if (this.chunks.length == 0)
+               return next;
+           let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
+           this.from = null; // Make sure further `add` calls produce errors
+           return result;
+       }
+   }
+   function findSharedChunks(a, b, textDiff) {
+       let inA = new Map();
+       for (let set of a)
+           for (let i = 0; i < set.chunk.length; i++)
+               if (set.chunk[i].maxPoint <= 0)
+                   inA.set(set.chunk[i], set.chunkPos[i]);
+       let shared = new Set();
+       for (let set of b)
+           for (let i = 0; i < set.chunk.length; i++) {
+               let known = inA.get(set.chunk[i]);
+               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
+                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
+                   shared.add(set.chunk[i]);
+           }
+       return shared;
+   }
+   class LayerCursor {
+       constructor(layer, skip, minPoint, rank = 0) {
+           this.layer = layer;
+           this.skip = skip;
+           this.minPoint = minPoint;
+           this.rank = rank;
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       get endSide() { return this.value ? this.value.endSide : 0; }
+       goto(pos, side = -1000000000 /* C.Far */) {
+           this.chunkIndex = this.rangeIndex = 0;
+           this.gotoInner(pos, side, false);
+           return this;
+       }
+       gotoInner(pos, side, forward) {
+           while (this.chunkIndex < this.layer.chunk.length) {
+               let next = this.layer.chunk[this.chunkIndex];
+               if (!(this.skip && this.skip.has(next) ||
+                   this.layer.chunkEnd(this.chunkIndex) < pos ||
+                   next.maxPoint < this.minPoint))
+                   break;
+               this.chunkIndex++;
+               forward = false;
+           }
+           if (this.chunkIndex < this.layer.chunk.length) {
+               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
+               if (!forward || this.rangeIndex < rangeIndex)
+                   this.setRangeIndex(rangeIndex);
+           }
+           this.next();
+       }
+       forward(pos, side) {
+           if ((this.to - pos || this.endSide - side) < 0)
+               this.gotoInner(pos, side, true);
+       }
+       next() {
+           for (;;) {
+               if (this.chunkIndex == this.layer.chunk.length) {
+                   this.from = this.to = 1000000000 /* C.Far */;
+                   this.value = null;
+                   break;
+               }
+               else {
+                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
+                   let from = chunkPos + chunk.from[this.rangeIndex];
+                   this.from = from;
+                   this.to = chunkPos + chunk.to[this.rangeIndex];
+                   this.value = chunk.value[this.rangeIndex];
+                   this.setRangeIndex(this.rangeIndex + 1);
+                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
+                       break;
+               }
+           }
+       }
+       setRangeIndex(index) {
+           if (index == this.layer.chunk[this.chunkIndex].value.length) {
+               this.chunkIndex++;
+               if (this.skip) {
+                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
+                       this.chunkIndex++;
+               }
+               this.rangeIndex = 0;
+           }
+           else {
+               this.rangeIndex = index;
+           }
+       }
+       nextChunk() {
+           this.chunkIndex++;
+           this.rangeIndex = 0;
+           this.next();
+       }
+       compare(other) {
+           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
+               this.to - other.to || this.endSide - other.endSide;
+       }
+   }
+   class HeapCursor {
+       constructor(heap) {
+           this.heap = heap;
+       }
+       static from(sets, skip = null, minPoint = -1) {
+           let heap = [];
+           for (let i = 0; i < sets.length; i++) {
+               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
+                   if (cur.maxPoint >= minPoint)
+                       heap.push(new LayerCursor(cur, skip, minPoint, i));
+               }
+           }
+           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
+       }
+       get startSide() { return this.value ? this.value.startSide : 0; }
+       goto(pos, side = -1000000000 /* C.Far */) {
+           for (let cur of this.heap)
+               cur.goto(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble(this.heap, i);
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           for (let cur of this.heap)
+               cur.forward(pos, side);
+           for (let i = this.heap.length >> 1; i >= 0; i--)
+               heapBubble(this.heap, i);
+           if ((this.to - pos || this.value.endSide - side) < 0)
+               this.next();
+       }
+       next() {
+           if (this.heap.length == 0) {
+               this.from = this.to = 1000000000 /* C.Far */;
+               this.value = null;
+               this.rank = -1;
+           }
+           else {
+               let top = this.heap[0];
+               this.from = top.from;
+               this.to = top.to;
+               this.value = top.value;
+               this.rank = top.rank;
+               if (top.value)
+                   top.next();
+               heapBubble(this.heap, 0);
+           }
+       }
+   }
+   function heapBubble(heap, index) {
+       for (let cur = heap[index];;) {
+           let childIndex = (index << 1) + 1;
+           if (childIndex >= heap.length)
+               break;
+           let child = heap[childIndex];
+           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
+               child = heap[childIndex + 1];
+               childIndex++;
+           }
+           if (cur.compare(child) < 0)
+               break;
+           heap[childIndex] = cur;
+           heap[index] = child;
+           index = childIndex;
+       }
+   }
+   class SpanCursor {
+       constructor(sets, skip, minPoint) {
+           this.minPoint = minPoint;
+           this.active = [];
+           this.activeTo = [];
+           this.activeRank = [];
+           this.minActive = -1;
+           // A currently active point range, if any
+           this.point = null;
+           this.pointFrom = 0;
+           this.pointRank = 0;
+           this.to = -1000000000 /* C.Far */;
+           this.endSide = 0;
+           // The amount of open active ranges at the start of the iterator.
+           // Not including points.
+           this.openStart = -1;
+           this.cursor = HeapCursor.from(sets, skip, minPoint);
+       }
+       goto(pos, side = -1000000000 /* C.Far */) {
+           this.cursor.goto(pos, side);
+           this.active.length = this.activeTo.length = this.activeRank.length = 0;
+           this.minActive = -1;
+           this.to = pos;
+           this.endSide = side;
+           this.openStart = -1;
+           this.next();
+           return this;
+       }
+       forward(pos, side) {
+           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
+               this.removeActive(this.minActive);
+           this.cursor.forward(pos, side);
+       }
+       removeActive(index) {
+           remove(this.active, index);
+           remove(this.activeTo, index);
+           remove(this.activeRank, index);
+           this.minActive = findMinIndex(this.active, this.activeTo);
+       }
+       addActive(trackOpen) {
+           let i = 0, { value, to, rank } = this.cursor;
+           // Organize active marks by rank first, then by size
+           while (i < this.activeRank.length && (rank - this.activeRank[i] || to - this.activeTo[i]) > 0)
+               i++;
+           insert(this.active, i, value);
+           insert(this.activeTo, i, to);
+           insert(this.activeRank, i, rank);
+           if (trackOpen)
+               insert(trackOpen, i, this.cursor.from);
+           this.minActive = findMinIndex(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 from = this.to, wasPoint = this.point;
+           this.point = null;
+           let trackOpen = this.openStart < 0 ? [] : null;
+           for (;;) {
+               let a = this.minActive;
+               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
+                   if (this.activeTo[a] > from) {
+                       this.to = this.activeTo[a];
+                       this.endSide = this.active[a].endSide;
+                       break;
+                   }
+                   this.removeActive(a);
+                   if (trackOpen)
+                       remove(trackOpen, a);
+               }
+               else if (!this.cursor.value) {
+                   this.to = this.endSide = 1000000000 /* C.Far */;
+                   break;
+               }
+               else if (this.cursor.from > from) {
+                   this.to = this.cursor.from;
+                   this.endSide = this.cursor.startSide;
+                   break;
+               }
+               else {
+                   let nextVal = this.cursor.value;
+                   if (!nextVal.point) { // Opening a range
+                       this.addActive(trackOpen);
+                       this.cursor.next();
+                   }
+                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
+                       // Ignore any non-empty points that end precisely at the end of the prev point
+                       this.cursor.next();
+                   }
+                   else { // New point
+                       this.point = nextVal;
+                       this.pointFrom = this.cursor.from;
+                       this.pointRank = this.cursor.rank;
+                       this.to = this.cursor.to;
+                       this.endSide = nextVal.endSide;
+                       this.cursor.next();
+                       this.forward(this.to, this.endSide);
+                       break;
+                   }
+               }
+           }
+           if (trackOpen) {
+               this.openStart = 0;
+               for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)
+                   this.openStart++;
+           }
+       }
+       activeForPoint(to) {
+           if (!this.active.length)
+               return this.active;
+           let active = [];
+           for (let i = this.active.length - 1; i >= 0; i--) {
+               if (this.activeRank[i] < this.pointRank)
+                   break;
+               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
+                   active.push(this.active[i]);
+           }
+           return active.reverse();
+       }
+       openEnd(to) {
+           let open = 0;
+           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
+               open++;
+           return open;
+       }
+   }
+   function compare(a, startA, b, startB, length, comparator) {
+       a.goto(startA);
+       b.goto(startB);
+       let endB = startB + length;
+       let pos = startB, dPos = startB - startA;
+       for (;;) {
+           let dEnd = (a.to + dPos) - b.to, diff = dEnd || a.endSide - b.endSide;
+           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
+           if (a.point || b.point) {
+               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
+                   sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))
+                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
+           }
+           else {
+               if (clipEnd > pos && !sameValues(a.active, b.active))
+                   comparator.compareRange(pos, clipEnd, a.active, b.active);
+           }
+           if (end > endB)
+               break;
+           if ((dEnd || a.openEnd != b.openEnd) && comparator.boundChange)
+               comparator.boundChange(end);
+           pos = end;
+           if (diff <= 0)
+               a.next();
+           if (diff >= 0)
+               b.next();
+       }
+   }
+   function sameValues(a, b) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (a[i] != b[i] && !a[i].eq(b[i]))
+               return false;
+       return true;
+   }
+   function remove(array, index) {
+       for (let i = index, e = array.length - 1; i < e; i++)
+           array[i] = array[i + 1];
+       array.pop();
+   }
+   function insert(array, index, value) {
+       for (let i = array.length - 1; i >= index; i--)
+           array[i + 1] = array[i];
+       array[index] = value;
+   }
+   function findMinIndex(value, array) {
+       let found = -1, foundPos = 1000000000 /* C.Far */;
+       for (let i = 0; i < array.length; i++)
+           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
+               found = i;
+               foundPos = array[i];
+           }
+       return found;
+   }
+   /**
+   Find the offset that corresponds to the given column position in a
+   string, taking extending characters and tab size into account. By
+   default, the string length is returned when it is too short to
+   reach the column. Pass `strict` true to make it return -1 in that
+   situation.
+   */
+   function findColumn(string, col, tabSize, strict) {
+       for (let i = 0, n = 0;;) {
+           if (n >= col)
+               return i;
+           if (i == string.length)
+               break;
+           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
+           i = findClusterBreak(string, i);
+       }
+       return strict === true ? -1 : string.length;
+   }
+
+   function getSelection(root) {
+       let target;
+       // Browsers differ on whether shadow roots have a getSelection
+       // method. If it exists, use that, otherwise, call it on the
+       // document.
+       if (root.nodeType == 11) { // Shadow root
+           target = root.getSelection ? root : root.ownerDocument;
+       }
+       else {
+           target = root;
+       }
+       return target.getSelection();
+   }
+   function contains(dom, node) {
+       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
+   }
+   function hasSelection(dom, selection) {
+       if (!selection.anchorNode)
+           return false;
+       try {
+           // Firefox will raise 'permission denied' errors when accessing
+           // properties of `sel.anchorNode` when it's in a generated CSS
+           // element.
+           return contains(dom, selection.anchorNode);
+       }
+       catch (_) {
+           return false;
+       }
+   }
+   function clientRectsFor(dom) {
+       if (dom.nodeType == 3)
+           return textRange(dom, 0, dom.nodeValue.length).getClientRects();
+       else if (dom.nodeType == 1)
+           return dom.getClientRects();
+       else
+           return [];
+   }
+   // Scans forward and backward through DOM positions equivalent to the
+   // given one to see if the two are in the same place (i.e. after a
+   // text node vs at the end of that text node)
+   function isEquivalentPosition(node, off, targetNode, targetOff) {
+       return targetNode ? (scanFor(node, off, targetNode, targetOff, -1) ||
+           scanFor(node, off, targetNode, targetOff, 1)) : false;
+   }
+   function domIndex(node) {
+       for (var index = 0;; index++) {
+           node = node.previousSibling;
+           if (!node)
+               return index;
+       }
+   }
+   function isBlockElement(node) {
+       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
+   }
+   function scanFor(node, off, targetNode, targetOff, dir) {
+       for (;;) {
+           if (node == targetNode && off == targetOff)
+               return true;
+           if (off == (dir < 0 ? 0 : maxOffset(node))) {
+               if (node.nodeName == "DIV")
+                   return false;
+               let parent = node.parentNode;
+               if (!parent || parent.nodeType != 1)
+                   return false;
+               off = domIndex(node) + (dir < 0 ? 0 : 1);
+               node = parent;
+           }
+           else if (node.nodeType == 1) {
+               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
+               if (node.nodeType == 1 && node.contentEditable == "false")
+                   return false;
+               off = dir < 0 ? maxOffset(node) : 0;
+           }
+           else {
+               return false;
+           }
+       }
+   }
+   function maxOffset(node) {
+       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
+   }
+   function flattenRect(rect, left) {
+       let x = left ? rect.left : rect.right;
+       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
+   }
+   function windowRect(win) {
+       let vp = win.visualViewport;
+       if (vp)
+           return {
+               left: 0, right: vp.width,
+               top: 0, bottom: vp.height
+           };
+       return { left: 0, right: win.innerWidth,
+           top: 0, bottom: win.innerHeight };
+   }
+   function getScale(elt, rect) {
+       let scaleX = rect.width / elt.offsetWidth;
+       let scaleY = rect.height / elt.offsetHeight;
+       if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX) || Math.abs(rect.width - elt.offsetWidth) < 1)
+           scaleX = 1;
+       if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY) || Math.abs(rect.height - elt.offsetHeight) < 1)
+           scaleY = 1;
+       return { scaleX, scaleY };
+   }
+   function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
+       let doc = dom.ownerDocument, win = doc.defaultView || window;
+       for (let cur = dom, stop = false; cur && !stop;) {
+           if (cur.nodeType == 1) { // Element
+               let bounding, top = cur == doc.body;
+               let scaleX = 1, scaleY = 1;
+               if (top) {
+                   bounding = windowRect(win);
+               }
+               else {
+                   if (/^(fixed|sticky)$/.test(getComputedStyle(cur).position))
+                       stop = true;
+                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
+                       cur = cur.assignedSlot || cur.parentNode;
+                       continue;
+                   }
+                   let rect = cur.getBoundingClientRect();
+                   ({ scaleX, scaleY } = getScale(cur, rect));
+                   // Make sure scrollbar width isn't included in the rectangle
+                   bounding = { left: rect.left, right: rect.left + cur.clientWidth * scaleX,
+                       top: rect.top, bottom: rect.top + cur.clientHeight * scaleY };
+               }
+               let moveX = 0, moveY = 0;
+               if (y == "nearest") {
+                   if (rect.top < bounding.top) {
+                       moveY = -(bounding.top - rect.top + yMargin);
+                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
+                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
+                   }
+                   else if (rect.bottom > bounding.bottom) {
+                       moveY = rect.bottom - bounding.bottom + yMargin;
+                       if (side < 0 && (rect.top - moveY) < bounding.top)
+                           moveY = -(bounding.top + moveY - rect.top + yMargin);
+                   }
+               }
+               else {
+                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
+                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
+                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
+                           rect.bottom - boundingHeight + yMargin;
+                   moveY = targetTop - bounding.top;
+               }
+               if (x == "nearest") {
+                   if (rect.left < bounding.left) {
+                       moveX = -(bounding.left - rect.left + xMargin);
+                       if (side > 0 && rect.right > bounding.right + moveX)
+                           moveX = rect.right - bounding.right + moveX + xMargin;
+                   }
+                   else if (rect.right > bounding.right) {
+                       moveX = rect.right - bounding.right + xMargin;
+                       if (side < 0 && rect.left < bounding.left + moveX)
+                           moveX = -(bounding.left + moveX - rect.left + xMargin);
+                   }
+               }
+               else {
+                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
+                       (x == "start") == ltr ? rect.left - xMargin :
+                           rect.right - (bounding.right - bounding.left) + xMargin;
+                   moveX = targetLeft - bounding.left;
+               }
+               if (moveX || moveY) {
+                   if (top) {
+                       win.scrollBy(moveX, moveY);
+                   }
+                   else {
+                       let movedX = 0, movedY = 0;
+                       if (moveY) {
+                           let start = cur.scrollTop;
+                           cur.scrollTop += moveY / scaleY;
+                           movedY = (cur.scrollTop - start) * scaleY;
+                       }
+                       if (moveX) {
+                           let start = cur.scrollLeft;
+                           cur.scrollLeft += moveX / scaleX;
+                           movedX = (cur.scrollLeft - start) * scaleX;
+                       }
+                       rect = { left: rect.left - movedX, top: rect.top - movedY,
+                           right: rect.right - movedX, bottom: rect.bottom - movedY };
+                       if (movedX && Math.abs(movedX - moveX) < 1)
+                           x = "nearest";
+                       if (movedY && Math.abs(movedY - moveY) < 1)
+                           y = "nearest";
+                   }
+               }
+               if (top)
+                   break;
+               cur = cur.assignedSlot || cur.parentNode;
+           }
+           else if (cur.nodeType == 11) { // A shadow root
+               cur = cur.host;
+           }
+           else {
+               break;
+           }
+       }
+   }
+   function scrollableParents(dom) {
+       let doc = dom.ownerDocument, x, y;
+       for (let cur = dom.parentNode; cur;) {
+           if (cur == doc.body || (x && y)) {
+               break;
+           }
+           else if (cur.nodeType == 1) {
+               if (!y && cur.scrollHeight > cur.clientHeight)
+                   y = cur;
+               if (!x && cur.scrollWidth > cur.clientWidth)
+                   x = cur;
+               cur = cur.assignedSlot || cur.parentNode;
+           }
+           else if (cur.nodeType == 11) {
+               cur = cur.host;
+           }
+           else {
+               break;
+           }
+       }
+       return { x, y };
+   }
+   class DOMSelectionState {
+       constructor() {
+           this.anchorNode = null;
+           this.anchorOffset = 0;
+           this.focusNode = null;
+           this.focusOffset = 0;
+       }
+       eq(domSel) {
+           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
+               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
+       }
+       setRange(range) {
+           let { anchorNode, focusNode } = range;
+           // Clip offsets to node size to avoid crashes when Safari reports bogus offsets (#1152)
+           this.set(anchorNode, Math.min(range.anchorOffset, anchorNode ? maxOffset(anchorNode) : 0), focusNode, Math.min(range.focusOffset, focusNode ? maxOffset(focusNode) : 0));
+       }
+       set(anchorNode, anchorOffset, focusNode, focusOffset) {
+           this.anchorNode = anchorNode;
+           this.anchorOffset = anchorOffset;
+           this.focusNode = focusNode;
+           this.focusOffset = focusOffset;
+       }
+   }
+   let preventScrollSupported = null;
+   // Feature-detects support for .focus({preventScroll: true}), and uses
+   // a fallback kludge when not supported.
+   function focusPreventScroll(dom) {
+       if (dom.setActive)
+           return dom.setActive(); // in IE
+       if (preventScrollSupported)
+           return dom.focus(preventScrollSupported);
+       let stack = [];
+       for (let cur = dom; cur; cur = cur.parentNode) {
+           stack.push(cur, cur.scrollTop, cur.scrollLeft);
+           if (cur == cur.ownerDocument)
+               break;
+       }
+       dom.focus(preventScrollSupported == null ? {
+           get preventScroll() {
+               preventScrollSupported = { preventScroll: true };
+               return true;
+           }
+       } : undefined);
+       if (!preventScrollSupported) {
+           preventScrollSupported = false;
+           for (let i = 0; i < stack.length;) {
+               let elt = stack[i++], top = stack[i++], left = stack[i++];
+               if (elt.scrollTop != top)
+                   elt.scrollTop = top;
+               if (elt.scrollLeft != left)
+                   elt.scrollLeft = left;
+           }
+       }
+   }
+   let scratchRange;
+   function textRange(node, from, to = from) {
+       let range = scratchRange || (scratchRange = document.createRange());
+       range.setEnd(node, to);
+       range.setStart(node, from);
+       return range;
+   }
+   function dispatchKey(elt, name, code, mods) {
+       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
+       if (mods)
+           ({ altKey: options.altKey, ctrlKey: options.ctrlKey, shiftKey: options.shiftKey, metaKey: options.metaKey } = mods);
+       let down = new KeyboardEvent("keydown", options);
+       down.synthetic = true;
+       elt.dispatchEvent(down);
+       let up = new KeyboardEvent("keyup", options);
+       up.synthetic = true;
+       elt.dispatchEvent(up);
+       return down.defaultPrevented || up.defaultPrevented;
+   }
+   function getRoot(node) {
+       while (node) {
+           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
+               return node;
+           node = node.assignedSlot || node.parentNode;
+       }
+       return null;
+   }
+   function clearAttributes(node) {
+       while (node.attributes.length)
+           node.removeAttributeNode(node.attributes[0]);
+   }
+   function atElementStart(doc, selection) {
+       let node = selection.focusNode, offset = selection.focusOffset;
+       if (!node || selection.anchorNode != node || selection.anchorOffset != offset)
+           return false;
+       // Safari can report bogus offsets (#1152)
+       offset = Math.min(offset, maxOffset(node));
+       for (;;) {
+           if (offset) {
+               if (node.nodeType != 1)
+                   return false;
+               let prev = node.childNodes[offset - 1];
+               if (prev.contentEditable == "false")
+                   offset--;
+               else {
+                   node = prev;
+                   offset = maxOffset(node);
+               }
+           }
+           else if (node == doc) {
+               return true;
+           }
+           else {
+               offset = domIndex(node);
+               node = node.parentNode;
+           }
+       }
+   }
+   function isScrolledToBottom(elt) {
+       return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);
+   }
+   function textNodeBefore(startNode, startOffset) {
+       for (let node = startNode, offset = startOffset;;) {
+           if (node.nodeType == 3 && offset > 0) {
+               return { node: node, offset: offset };
+           }
+           else if (node.nodeType == 1 && offset > 0) {
+               if (node.contentEditable == "false")
+                   return null;
+               node = node.childNodes[offset - 1];
+               offset = maxOffset(node);
+           }
+           else if (node.parentNode && !isBlockElement(node)) {
+               offset = domIndex(node);
+               node = node.parentNode;
+           }
+           else {
+               return null;
+           }
+       }
+   }
+   function textNodeAfter(startNode, startOffset) {
+       for (let node = startNode, offset = startOffset;;) {
+           if (node.nodeType == 3 && offset < node.nodeValue.length) {
+               return { node: node, offset: offset };
+           }
+           else if (node.nodeType == 1 && offset < node.childNodes.length) {
+               if (node.contentEditable == "false")
+                   return null;
+               node = node.childNodes[offset];
+               offset = 0;
+           }
+           else if (node.parentNode && !isBlockElement(node)) {
+               offset = domIndex(node) + 1;
+               node = node.parentNode;
+           }
+           else {
+               return null;
+           }
+       }
+   }
+
+   class DOMPos {
+       constructor(node, offset, precise = true) {
+           this.node = node;
+           this.offset = offset;
+           this.precise = precise;
+       }
+       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom), precise); }
+       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom) + 1, precise); }
+   }
+   const noChildren = [];
+   class ContentView {
+       constructor() {
+           this.parent = null;
+           this.dom = null;
+           this.flags = 2 /* ViewFlag.NodeDirty */;
+       }
+       get overrideDOMText() { return null; }
+       get posAtStart() {
+           return this.parent ? this.parent.posBefore(this) : 0;
+       }
+       get posAtEnd() {
+           return this.posAtStart + this.length;
+       }
+       posBefore(view) {
+           let pos = this.posAtStart;
+           for (let child of this.children) {
+               if (child == view)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+           throw new RangeError("Invalid child in posBefore");
+       }
+       posAfter(view) {
+           return this.posBefore(view) + view.length;
+       }
+       sync(view, track) {
+           if (this.flags & 2 /* ViewFlag.NodeDirty */) {
+               let parent = this.dom;
+               let prev = null, next;
+               for (let child of this.children) {
+                   if (child.flags & 7 /* ViewFlag.Dirty */) {
+                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
+                           let contentView = ContentView.get(next);
+                           if (!contentView || !contentView.parent && contentView.canReuseDOM(child))
+                               child.reuseDOM(next);
+                       }
+                       child.sync(view, track);
+                       child.flags &= ~7 /* ViewFlag.Dirty */;
+                   }
+                   next = prev ? prev.nextSibling : parent.firstChild;
+                   if (track && !track.written && track.node == parent && next != child.dom)
+                       track.written = true;
+                   if (child.dom.parentNode == parent) {
+                       while (next && next != child.dom)
+                           next = rm$1(next);
+                   }
+                   else {
+                       parent.insertBefore(child.dom, next);
+                   }
+                   prev = child.dom;
+               }
+               next = prev ? prev.nextSibling : parent.firstChild;
+               if (next && track && track.node == parent)
+                   track.written = true;
+               while (next)
+                   next = rm$1(next);
+           }
+           else if (this.flags & 1 /* ViewFlag.ChildDirty */) {
+               for (let child of this.children)
+                   if (child.flags & 7 /* ViewFlag.Dirty */) {
+                       child.sync(view, track);
+                       child.flags &= ~7 /* ViewFlag.Dirty */;
+                   }
+           }
+       }
+       reuseDOM(_dom) { }
+       localPosFromDOM(node, offset) {
+           let after;
+           if (node == this.dom) {
+               after = this.dom.childNodes[offset];
+           }
+           else {
+               let bias = maxOffset(node) == 0 ? 0 : offset == 0 ? -1 : 1;
+               for (;;) {
+                   let parent = node.parentNode;
+                   if (parent == this.dom)
+                       break;
+                   if (bias == 0 && parent.firstChild != parent.lastChild) {
+                       if (node == parent.firstChild)
+                           bias = -1;
+                       else
+                           bias = 1;
+                   }
+                   node = parent;
+               }
+               if (bias < 0)
+                   after = node;
+               else
+                   after = node.nextSibling;
+           }
+           if (after == this.dom.firstChild)
+               return 0;
+           while (after && !ContentView.get(after))
+               after = after.nextSibling;
+           if (!after)
+               return this.length;
+           for (let i = 0, pos = 0;; i++) {
+               let child = this.children[i];
+               if (child.dom == after)
+                   return pos;
+               pos += child.length + child.breakAfter;
+           }
+       }
+       domBoundsAround(from, to, offset = 0) {
+           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
+           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (pos < from && end > to)
+                   return child.domBoundsAround(from, to, pos);
+               if (end >= from && fromI == -1) {
+                   fromI = i;
+                   fromStart = pos;
+               }
+               if (pos > to && child.dom.parentNode == this.dom) {
+                   toI = i;
+                   toEnd = prevEnd;
+                   break;
+               }
+               prevEnd = end;
+               pos = end + child.breakAfter;
+           }
+           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
+               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
+               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
+       }
+       markDirty(andParent = false) {
+           this.flags |= 2 /* ViewFlag.NodeDirty */;
+           this.markParentsDirty(andParent);
+       }
+       markParentsDirty(childList) {
+           for (let parent = this.parent; parent; parent = parent.parent) {
+               if (childList)
+                   parent.flags |= 2 /* ViewFlag.NodeDirty */;
+               if (parent.flags & 1 /* ViewFlag.ChildDirty */)
+                   return;
+               parent.flags |= 1 /* ViewFlag.ChildDirty */;
+               childList = false;
+           }
+       }
+       setParent(parent) {
+           if (this.parent != parent) {
+               this.parent = parent;
+               if (this.flags & 7 /* ViewFlag.Dirty */)
+                   this.markParentsDirty(true);
+           }
+       }
+       setDOM(dom) {
+           if (this.dom == dom)
+               return;
+           if (this.dom)
+               this.dom.cmView = null;
+           this.dom = dom;
+           dom.cmView = this;
+       }
+       get rootView() {
+           for (let v = this;;) {
+               let parent = v.parent;
+               if (!parent)
+                   return v;
+               v = parent;
+           }
+       }
+       replaceChildren(from, to, children = noChildren) {
+           this.markDirty();
+           for (let i = from; i < to; i++) {
+               let child = this.children[i];
+               if (child.parent == this && children.indexOf(child) < 0)
+                   child.destroy();
+           }
+           if (children.length < 250)
+               this.children.splice(from, to - from, ...children);
+           else
+               this.children = [].concat(this.children.slice(0, from), children, this.children.slice(to));
+           for (let i = 0; i < children.length; i++)
+               children[i].setParent(this);
+       }
+       ignoreMutation(_rec) { return false; }
+       ignoreEvent(_event) { return false; }
+       childCursor(pos = this.length) {
+           return new ChildCursor(this.children, pos, this.children.length);
+       }
+       childPos(pos, bias = 1) {
+           return this.childCursor().findPos(pos, bias);
+       }
+       toString() {
+           let name = this.constructor.name.replace("View", "");
+           return name + (this.children.length ? "(" + this.children.join() + ")" :
+               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
+               (this.breakAfter ? "#" : "");
+       }
+       static get(node) { return node.cmView; }
+       get isEditable() { return true; }
+       get isWidget() { return false; }
+       get isHidden() { return false; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           return false;
+       }
+       become(other) { return false; }
+       canReuseDOM(other) {
+           return other.constructor == this.constructor && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);
+       }
+       // When this is a zero-length view with a side, this should return a
+       // number <= 0 to indicate it is before its position, or a
+       // number > 0 when after its position.
+       getSide() { return 0; }
+       destroy() {
+           for (let child of this.children)
+               if (child.parent == this)
+                   child.destroy();
+           this.parent = null;
+       }
+   }
+   ContentView.prototype.breakAfter = 0;
+   // Remove a DOM node and return its next sibling.
+   function rm$1(dom) {
+       let next = dom.nextSibling;
+       dom.parentNode.removeChild(dom);
+       return next;
+   }
+   class ChildCursor {
+       constructor(children, pos, i) {
+           this.children = children;
+           this.pos = pos;
+           this.i = i;
+           this.off = 0;
+       }
+       findPos(pos, bias = 1) {
+           for (;;) {
+               if (pos > this.pos || pos == this.pos &&
+                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
+                   this.off = pos - this.pos;
+                   return this;
+               }
+               let next = this.children[--this.i];
+               this.pos -= next.length + next.breakAfter;
+           }
+       }
+   }
+   function replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
+       let { children } = parent;
+       let before = children.length ? children[fromI] : null;
+       let last = insert.length ? insert[insert.length - 1] : null;
+       let breakAtEnd = last ? last.breakAfter : breakAtStart;
+       // Change within a single child
+       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
+           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
+           return;
+       if (toI < children.length) {
+           let after = children[toI];
+           // Make sure the end of the child after the update is preserved in `after`
+           if (after && (toOff < after.length || after.breakAfter && (last === null || last === void 0 ? void 0 : last.breakAfter))) {
+               // If we're splitting a child, separate part of it to avoid that
+               // being mangled when updating the child before the update.
+               if (fromI == toI) {
+                   after = after.split(toOff);
+                   toOff = 0;
+               }
+               // If the element after the replacement should be merged with
+               // the last replacing element, update `content`
+               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
+                   insert[insert.length - 1] = after;
+               }
+               else {
+                   // Remove the start of the after element, if necessary, and
+                   // add it to `content`.
+                   if (toOff || after.children.length && !after.children[0].length)
+                       after.merge(0, toOff, null, false, 0, openEnd);
+                   insert.push(after);
+               }
+           }
+           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
+               // The element at `toI` is entirely covered by this range.
+               // Preserve its line break, if any.
+               if (last)
+                   last.breakAfter = 1;
+               else
+                   breakAtStart = 1;
+           }
+           // Since we've handled the next element from the current elements
+           // now, make sure `toI` points after that.
+           toI++;
+       }
+       if (before) {
+           before.breakAfter = breakAtStart;
+           if (fromOff > 0) {
+               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
+                   before.breakAfter = insert.shift().breakAfter;
+               }
+               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
+                   before.merge(fromOff, before.length, null, false, openStart, 0);
+               }
+               fromI++;
+           }
+       }
+       // Try to merge widgets on the boundaries of the replacement
+       while (fromI < toI && insert.length) {
+           if (children[toI - 1].become(insert[insert.length - 1])) {
+               toI--;
+               insert.pop();
+               openEnd = insert.length ? 0 : openStart;
+           }
+           else if (children[fromI].become(insert[0])) {
+               fromI++;
+               insert.shift();
+               openStart = insert.length ? 0 : openEnd;
+           }
+           else {
+               break;
+           }
+       }
+       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
+           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
+           fromI--;
+       if (fromI < toI || insert.length)
+           parent.replaceChildren(fromI, toI, insert);
+   }
+   function mergeChildrenInto(parent, from, to, insert, openStart, openEnd) {
+       let cur = parent.childCursor();
+       let { i: toI, off: toOff } = cur.findPos(to, 1);
+       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
+       let dLen = from - to;
+       for (let view of insert)
+           dLen += view.length;
+       parent.length += dLen;
+       replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
+   }
+
+   let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
+   let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
+   const ie_edge = /*@__PURE__*//Edge\/(\d+)/.exec(nav.userAgent);
+   const ie_upto10 = /*@__PURE__*//MSIE \d/.test(nav.userAgent);
+   const ie_11up = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
+   const ie = !!(ie_upto10 || ie_11up || ie_edge);
+   const gecko = !ie && /*@__PURE__*//gecko\/(\d+)/i.test(nav.userAgent);
+   const chrome = !ie && /*@__PURE__*//Chrome\/(\d+)/.exec(nav.userAgent);
+   const webkit = "webkitFontSmoothing" in doc.documentElement.style;
+   const safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);
+   const ios = safari && (/*@__PURE__*//Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
+   var browser = {
+       mac: ios || /*@__PURE__*//Mac/.test(nav.platform),
+       windows: /*@__PURE__*//Win/.test(nav.platform),
+       linux: /*@__PURE__*//Linux|X11/.test(nav.platform),
+       ie,
+       ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
+       gecko,
+       gecko_version: gecko ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
+       chrome: !!chrome,
+       chrome_version: chrome ? +chrome[1] : 0,
+       ios,
+       android: /*@__PURE__*//Android\b/.test(nav.userAgent),
+       webkit,
+       safari,
+       webkit_version: webkit ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
+       tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
+   };
+
+   const MaxJoinLen = 256;
+   class TextView extends ContentView {
+       constructor(text) {
+           super();
+           this.text = text;
+       }
+       get length() { return this.text.length; }
+       createDOM(textDOM) {
+           this.setDOM(textDOM || document.createTextNode(this.text));
+       }
+       sync(view, track) {
+           if (!this.dom)
+               this.createDOM();
+           if (this.dom.nodeValue != this.text) {
+               if (track && track.node == this.dom)
+                   track.written = true;
+               this.dom.nodeValue = this.text;
+           }
+       }
+       reuseDOM(dom) {
+           if (dom.nodeType == 3)
+               this.createDOM(dom);
+       }
+       merge(from, to, source) {
+           if ((this.flags & 8 /* ViewFlag.Composition */) ||
+               source && (!(source instanceof TextView) ||
+                   this.length - (to - from) + source.length > MaxJoinLen ||
+                   (source.flags & 8 /* ViewFlag.Composition */)))
+               return false;
+           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = new TextView(this.text.slice(from));
+           this.text = this.text.slice(0, from);
+           this.markDirty();
+           result.flags |= this.flags & 8 /* ViewFlag.Composition */;
+           return result;
+       }
+       localPosFromDOM(node, offset) {
+           return node == this.dom ? offset : offset ? this.text.length : 0;
+       }
+       domAtPos(pos) { return new DOMPos(this.dom, pos); }
+       domBoundsAround(_from, _to, offset) {
+           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
+       }
+       coordsAt(pos, side) {
+           return textCoords(this.dom, pos, side);
+       }
+   }
+   class MarkView extends ContentView {
+       constructor(mark, children = [], length = 0) {
+           super();
+           this.mark = mark;
+           this.children = children;
+           this.length = length;
+           for (let ch of children)
+               ch.setParent(this);
+       }
+       setAttrs(dom) {
+           clearAttributes(dom);
+           if (this.mark.class)
+               dom.className = this.mark.class;
+           if (this.mark.attrs)
+               for (let name in this.mark.attrs)
+                   dom.setAttribute(name, this.mark.attrs[name]);
+           return dom;
+       }
+       canReuseDOM(other) {
+           return super.canReuseDOM(other) && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);
+       }
+       reuseDOM(node) {
+           if (node.nodeName == this.mark.tagName.toUpperCase()) {
+               this.setDOM(node);
+               this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;
+           }
+       }
+       sync(view, track) {
+           if (!this.dom)
+               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
+           else if (this.flags & 4 /* ViewFlag.AttrsDirty */)
+               this.setAttrs(this.dom);
+           super.sync(view, track);
+       }
+       merge(from, to, source, _hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
+               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
+               return false;
+           mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart - 1, openEnd - 1);
+           this.markDirty();
+           return true;
+       }
+       split(from) {
+           let result = [], off = 0, detachFrom = -1, i = 0;
+           for (let elt of this.children) {
+               let end = off + elt.length;
+               if (end > from)
+                   result.push(off < from ? elt.split(from - off) : elt);
+               if (detachFrom < 0 && off >= from)
+                   detachFrom = i;
+               off = end;
+               i++;
+           }
+           let length = this.length - from;
+           this.length = from;
+           if (detachFrom > -1) {
+               this.children.length = detachFrom;
+               this.markDirty();
+           }
+           return new MarkView(this.mark, result, length);
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos(this, pos);
+       }
+       coordsAt(pos, side) {
+           return coordsInChildren(this, pos, side);
+       }
+   }
+   function textCoords(text, pos, side) {
+       let length = text.nodeValue.length;
+       if (pos > length)
+           pos = length;
+       let from = pos, to = pos, flatten = 0;
+       if (pos == 0 && side < 0 || pos == length && side >= 0) {
+           if (!(browser.chrome || browser.gecko)) { // These browsers reliably return valid rectangles for empty ranges
+               if (pos) {
+                   from--;
+                   flatten = 1;
+               } // FIXME this is wrong in RTL text
+               else if (to < length) {
+                   to++;
+                   flatten = -1;
+               }
+           }
+       }
+       else {
+           if (side < 0)
+               from--;
+           else if (to < length)
+               to++;
+       }
+       let rects = textRange(text, from, to).getClientRects();
+       if (!rects.length)
+           return null;
+       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
+       if (browser.safari && !flatten && rect.width == 0)
+           rect = Array.prototype.find.call(rects, r => r.width) || rect;
+       return flatten ? flattenRect(rect, flatten < 0) : rect || null;
+   }
+   // Also used for collapsed ranges that don't have a placeholder widget!
+   class WidgetView extends ContentView {
+       static create(widget, length, side) {
+           return new WidgetView(widget, length, side);
+       }
+       constructor(widget, length, side) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.side = side;
+           this.prevWidget = null;
+       }
+       split(from) {
+           let result = WidgetView.create(this.widget, this.length - from, this.side);
+           this.length -= from;
+           return result;
+       }
+       sync(view) {
+           if (!this.dom || !this.widget.updateDOM(this.dom, view)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(view));
+               if (!this.widget.editable)
+                   this.dom.contentEditable = "false";
+           }
+       }
+       getSide() { return this.side; }
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       become(other) {
+           if (other instanceof WidgetView && other.side == this.side &&
+               this.widget.constructor == other.widget.constructor) {
+               if (!this.widget.compare(other.widget))
+                   this.markDirty(true);
+               if (this.dom && !this.prevWidget)
+                   this.prevWidget = this.widget;
+               this.widget = other.widget;
+               this.length = other.length;
+               return true;
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       get overrideDOMText() {
+           if (this.length == 0)
+               return Text.empty;
+           let top = this;
+           while (top.parent)
+               top = top.parent;
+           let { view } = top, text = view && view.state.doc, start = this.posAtStart;
+           return text ? text.slice(start, start + this.length) : Text.empty;
+       }
+       domAtPos(pos) {
+           return (this.length ? pos == 0 : this.side > 0)
+               ? DOMPos.before(this.dom)
+               : DOMPos.after(this.dom, pos == this.length);
+       }
+       domBoundsAround() { return null; }
+       coordsAt(pos, side) {
+           let custom = this.widget.coordsAt(this.dom, pos, side);
+           if (custom)
+               return custom;
+           let rects = this.dom.getClientRects(), rect = null;
+           if (!rects.length)
+               return null;
+           let fromBack = this.side ? this.side < 0 : pos > 0;
+           for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {
+               rect = rects[i];
+               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
+                   break;
+           }
+           return flattenRect(rect, !fromBack);
+       }
+       get isEditable() { return false; }
+       get isWidget() { return true; }
+       get isHidden() { return this.widget.isHidden; }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+   }
+   // These are drawn around uneditable widgets to avoid a number of
+   // browser bugs that show up when the cursor is directly next to
+   // uneditable inline content.
+   class WidgetBufferView extends ContentView {
+       constructor(side) {
+           super();
+           this.side = side;
+       }
+       get length() { return 0; }
+       merge() { return false; }
+       become(other) {
+           return other instanceof WidgetBufferView && other.side == this.side;
+       }
+       split() { return new WidgetBufferView(this.side); }
+       sync() {
+           if (!this.dom) {
+               let dom = document.createElement("img");
+               dom.className = "cm-widgetBuffer";
+               dom.setAttribute("aria-hidden", "true");
+               this.setDOM(dom);
+           }
+       }
+       getSide() { return this.side; }
+       domAtPos(pos) { return this.side > 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom); }
+       localPosFromDOM() { return 0; }
+       domBoundsAround() { return null; }
+       coordsAt(pos) {
+           return this.dom.getBoundingClientRect();
+       }
+       get overrideDOMText() {
+           return Text.empty;
+       }
+       get isHidden() { return true; }
+   }
+   TextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;
+   function inlineDOMAtPos(parent, pos) {
+       let dom = parent.dom, { children } = parent, i = 0;
+       for (let off = 0; i < children.length; i++) {
+           let child = children[i], end = off + child.length;
+           if (end == off && child.getSide() <= 0)
+               continue;
+           if (pos > off && pos < end && child.dom.parentNode == dom)
+               return child.domAtPos(pos - off);
+           if (pos <= off)
+               break;
+           off = end;
+       }
+       for (let j = i; j > 0; j--) {
+           let prev = children[j - 1];
+           if (prev.dom.parentNode == dom)
+               return prev.domAtPos(prev.length);
+       }
+       for (let j = i; j < children.length; j++) {
+           let next = children[j];
+           if (next.dom.parentNode == dom)
+               return next.domAtPos(0);
+       }
+       return new DOMPos(dom, 0);
+   }
+   // Assumes `view`, if a mark view, has precisely 1 child.
+   function joinInlineInto(parent, view, open) {
+       let last, { children } = parent;
+       if (open > 0 && view instanceof MarkView && children.length &&
+           (last = children[children.length - 1]) instanceof MarkView && last.mark.eq(view.mark)) {
+           joinInlineInto(last, view.children[0], open - 1);
+       }
+       else {
+           children.push(view);
+           view.setParent(parent);
+       }
+       parent.length += view.length;
+   }
+   function coordsInChildren(view, pos, side) {
+       let before = null, beforePos = -1, after = null, afterPos = -1;
+       function scan(view, pos) {
+           for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {
+               let child = view.children[i], end = off + child.length;
+               if (end >= pos) {
+                   if (child.children.length) {
+                       scan(child, pos - off);
+                   }
+                   else if ((!after || after.isHidden && side > 0) &&
+                       (end > pos || off == end && child.getSide() > 0)) {
+                       after = child;
+                       afterPos = pos - off;
+                   }
+                   else if (off < pos || (off == end && child.getSide() < 0) && !child.isHidden) {
+                       before = child;
+                       beforePos = pos - off;
+                   }
+               }
+               off = end;
+           }
+       }
+       scan(view, pos);
+       let target = (side < 0 ? before : after) || before || after;
+       if (target)
+           return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);
+       return fallbackRect(view);
+   }
+   function fallbackRect(view) {
+       let last = view.dom.lastChild;
+       if (!last)
+           return view.dom.getBoundingClientRect();
+       let rects = clientRectsFor(last);
+       return rects[rects.length - 1] || null;
+   }
+
+   function combineAttrs(source, target) {
+       for (let name in source) {
+           if (name == "class" && target.class)
+               target.class += " " + source.class;
+           else if (name == "style" && target.style)
+               target.style += ";" + source.style;
+           else
+               target[name] = source[name];
+       }
+       return target;
+   }
+   const noAttrs$1 = /*@__PURE__*/Object.create(null);
+   function attrsEq(a, b, ignore) {
+       if (a == b)
+           return true;
+       if (!a)
+           a = noAttrs$1;
+       if (!b)
+           b = noAttrs$1;
+       let keysA = Object.keys(a), keysB = Object.keys(b);
+       if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) !=
+           keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0))
+           return false;
+       for (let key of keysA) {
+           if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key]))
+               return false;
+       }
+       return true;
+   }
+   function updateAttrs(dom, prev, attrs) {
+       let changed = false;
+       if (prev)
+           for (let name in prev)
+               if (!(attrs && name in attrs)) {
+                   changed = true;
+                   if (name == "style")
+                       dom.style.cssText = "";
+                   else
+                       dom.removeAttribute(name);
+               }
+       if (attrs)
+           for (let name in attrs)
+               if (!(prev && prev[name] == attrs[name])) {
+                   changed = true;
+                   if (name == "style")
+                       dom.style.cssText = attrs[name];
+                   else
+                       dom.setAttribute(name, attrs[name]);
+               }
+       return changed;
+   }
+   function getAttrs(dom) {
+       let attrs = Object.create(null);
+       for (let i = 0; i < dom.attributes.length; i++) {
+           let attr = dom.attributes[i];
+           attrs[attr.name] = attr.value;
+       }
+       return attrs;
+   }
+
+   /**
+   Widgets added to the content are described by subclasses of this
+   class. Using a description object like that makes it possible to
+   delay creating of the DOM structure for a widget until it is
+   needed, and to avoid redrawing widgets even if the decorations
+   that define them are recreated.
+   */
+   class WidgetType {
+       /**
+       Compare this instance to another instance of the same type.
+       (TypeScript can't express this, but only instances of the same
+       specific class will be passed to this method.) This is used to
+       avoid redrawing widgets when they are replaced by a new
+       decoration of the same type. The default implementation just
+       returns `false`, which will cause new instances of the widget to
+       always be redrawn.
+       */
+       eq(widget) { return false; }
+       /**
+       Update a DOM element created by a widget of the same type (but
+       different, non-`eq` content) to reflect this widget. May return
+       true to indicate that it could update, false to indicate it
+       couldn't (in which case the widget will be redrawn). The default
+       implementation just returns false.
+       */
+       updateDOM(dom, view) { return false; }
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       The estimated height this widget will have, to be used when
+       estimating the height of content that hasn't been drawn. May
+       return -1 to indicate you don't know. The default implementation
+       returns -1.
+       */
+       get estimatedHeight() { return -1; }
+       /**
+       For inline widgets that are displayed inline (as opposed to
+       `inline-block`) and introduce line breaks (through `<br>` tags
+       or textual newlines), this must indicate the amount of line
+       breaks they introduce. Defaults to 0.
+       */
+       get lineBreaks() { return 0; }
+       /**
+       Can be used to configure which kinds of events inside the widget
+       should be ignored by the editor. The default is to ignore all
+       events.
+       */
+       ignoreEvent(event) { return true; }
+       /**
+       Override the way screen coordinates for positions at/in the
+       widget are found. `pos` will be the offset into the widget, and
+       `side` the side of the position that is being queried—less than
+       zero for before, greater than zero for after, and zero for
+       directly at that position.
+       */
+       coordsAt(dom, pos, side) { return null; }
+       /**
+       @internal
+       */
+       get isHidden() { return false; }
+       /**
+       @internal
+       */
+       get editable() { return false; }
+       /**
+       This is called when the an instance of the widget is removed
+       from the editor view.
+       */
+       destroy(dom) { }
+   }
+   /**
+   The different types of blocks that can occur in an editor view.
+   */
+   var BlockType = /*@__PURE__*/(function (BlockType) {
+       /**
+       A line of text.
+       */
+       BlockType[BlockType["Text"] = 0] = "Text";
+       /**
+       A block widget associated with the position after it.
+       */
+       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
+       /**
+       A block widget associated with the position before it.
+       */
+       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
+       /**
+       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
+       */
+       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
+   return BlockType})(BlockType || (BlockType = {}));
+   /**
+   A decoration provides information on how to draw or style a piece
+   of content. You'll usually use it wrapped in a
+   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
+   @nonabstract
+   */
+   class Decoration extends RangeValue {
+       constructor(
+       /**
+       @internal
+       */
+       startSide, 
+       /**
+       @internal
+       */
+       endSide, 
+       /**
+       @internal
+       */
+       widget, 
+       /**
+       The config object used to create this decoration. You can
+       include additional properties in there to store metadata about
+       your decoration.
+       */
+       spec) {
+           super();
+           this.startSide = startSide;
+           this.endSide = endSide;
+           this.widget = widget;
+           this.spec = spec;
+       }
+       /**
+       @internal
+       */
+       get heightRelevant() { return false; }
+       /**
+       Create a mark decoration, which influences the styling of the
+       content in its range. Nested mark decorations will cause nested
+       DOM elements to be created. Nesting order is determined by
+       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
+       the higher-precedence decorations creating the inner DOM nodes.
+       Such elements are split on line boundaries and on the boundaries
+       of lower-precedence decorations.
+       */
+       static mark(spec) {
+           return new MarkDecoration(spec);
+       }
+       /**
+       Create a widget decoration, which displays a DOM element at the
+       given position.
+       */
+       static widget(spec) {
+           let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;
+           side += (block && !spec.inlineOrder)
+               ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */)
+               : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
+           return new PointDecoration(spec, side, side, block, spec.widget || null, false);
+       }
+       /**
+       Create a replace decoration which replaces the given range with
+       a widget, or simply hides it.
+       */
+       static replace(spec) {
+           let block = !!spec.block, startSide, endSide;
+           if (spec.isBlockGap) {
+               startSide = -500000000 /* Side.GapStart */;
+               endSide = 400000000 /* Side.GapEnd */;
+           }
+           else {
+               let { start, end } = getInclusive(spec, block);
+               startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
+               endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
+           }
+           return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
+       }
+       /**
+       Create a line decoration, which can add DOM attributes to the
+       line starting at the given position.
+       */
+       static line(spec) {
+           return new LineDecoration(spec);
+       }
+       /**
+       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
+       decorated range or ranges. If the ranges aren't already sorted,
+       pass `true` for `sort` to make the library sort them for you.
+       */
+       static set(of, sort = false) {
+           return RangeSet.of(of, sort);
+       }
+       /**
+       @internal
+       */
+       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
+   }
+   /**
+   The empty set of decorations.
+   */
+   Decoration.none = RangeSet.empty;
+   class MarkDecoration extends Decoration {
+       constructor(spec) {
+           let { start, end } = getInclusive(spec);
+           super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
+           this.tagName = spec.tagName || "span";
+           this.class = spec.class || "";
+           this.attrs = spec.attributes || null;
+       }
+       eq(other) {
+           var _a, _b;
+           return this == other ||
+               other instanceof MarkDecoration &&
+                   this.tagName == other.tagName &&
+                   (this.class || ((_a = this.attrs) === null || _a === void 0 ? void 0 : _a.class)) == (other.class || ((_b = other.attrs) === null || _b === void 0 ? void 0 : _b.class)) &&
+                   attrsEq(this.attrs, other.attrs, "class");
+       }
+       range(from, to = from) {
+           if (from >= to)
+               throw new RangeError("Mark decorations may not be empty");
+           return super.range(from, to);
+       }
+   }
+   MarkDecoration.prototype.point = false;
+   class LineDecoration extends Decoration {
+       constructor(spec) {
+           super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
+       }
+       eq(other) {
+           return other instanceof LineDecoration &&
+               this.spec.class == other.spec.class &&
+               attrsEq(this.spec.attributes, other.spec.attributes);
+       }
+       range(from, to = from) {
+           if (to != from)
+               throw new RangeError("Line decoration ranges must be zero-length");
+           return super.range(from, to);
+       }
+   }
+   LineDecoration.prototype.mapMode = MapMode.TrackBefore;
+   LineDecoration.prototype.point = true;
+   class PointDecoration extends Decoration {
+       constructor(spec, startSide, endSide, block, widget, isReplace) {
+           super(startSide, endSide, widget, spec);
+           this.block = block;
+           this.isReplace = isReplace;
+           this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter;
+       }
+       // Only relevant when this.block == true
+       get type() {
+           return this.startSide != this.endSide ? BlockType.WidgetRange
+               : this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;
+       }
+       get heightRelevant() {
+           return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
+       }
+       eq(other) {
+           return other instanceof PointDecoration &&
+               widgetsEq(this.widget, other.widget) &&
+               this.block == other.block &&
+               this.startSide == other.startSide && this.endSide == other.endSide;
+       }
+       range(from, to = from) {
+           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
+               throw new RangeError("Invalid range for replacement decoration");
+           if (!this.isReplace && to != from)
+               throw new RangeError("Widget decorations can only have zero-length ranges");
+           return super.range(from, to);
+       }
+   }
+   PointDecoration.prototype.point = true;
+   function getInclusive(spec, block = false) {
+       let { inclusiveStart: start, inclusiveEnd: end } = spec;
+       if (start == null)
+           start = spec.inclusive;
+       if (end == null)
+           end = spec.inclusive;
+       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
+   }
+   function widgetsEq(a, b) {
+       return a == b || !!(a && b && a.compare(b));
+   }
+   function addRange(from, to, ranges, margin = 0) {
+       let last = ranges.length - 1;
+       if (last >= 0 && ranges[last] + margin >= from)
+           ranges[last] = Math.max(ranges[last], to);
+       else
+           ranges.push(from, to);
+   }
+
+   class LineView extends ContentView {
+       constructor() {
+           super(...arguments);
+           this.children = [];
+           this.length = 0;
+           this.prevAttrs = undefined;
+           this.attrs = null;
+           this.breakAfter = 0;
+       }
+       // Consumes source
+       merge(from, to, source, hasStart, openStart, openEnd) {
+           if (source) {
+               if (!(source instanceof LineView))
+                   return false;
+               if (!this.dom)
+                   source.transferDOM(this); // Reuse source.dom when appropriate
+           }
+           if (hasStart)
+               this.setDeco(source ? source.attrs : null);
+           mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart, openEnd);
+           return true;
+       }
+       split(at) {
+           let end = new LineView;
+           end.breakAfter = this.breakAfter;
+           if (this.length == 0)
+               return end;
+           let { i, off } = this.childPos(at);
+           if (off) {
+               end.append(this.children[i].split(off), 0);
+               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
+               i++;
+           }
+           for (let j = i; j < this.children.length; j++)
+               end.append(this.children[j], 0);
+           while (i > 0 && this.children[i - 1].length == 0)
+               this.children[--i].destroy();
+           this.children.length = i;
+           this.markDirty();
+           this.length = at;
+           return end;
+       }
+       transferDOM(other) {
+           if (!this.dom)
+               return;
+           this.markDirty();
+           other.setDOM(this.dom);
+           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
+           this.prevAttrs = undefined;
+           this.dom = null;
+       }
+       setDeco(attrs) {
+           if (!attrsEq(this.attrs, attrs)) {
+               if (this.dom) {
+                   this.prevAttrs = this.attrs;
+                   this.markDirty();
+               }
+               this.attrs = attrs;
+           }
+       }
+       append(child, openStart) {
+           joinInlineInto(this, child, openStart);
+       }
+       // Only called when building a line view in ContentBuilder
+       addLineDeco(deco) {
+           let attrs = deco.spec.attributes, cls = deco.spec.class;
+           if (attrs)
+               this.attrs = combineAttrs(attrs, this.attrs || {});
+           if (cls)
+               this.attrs = combineAttrs({ class: cls }, this.attrs || {});
+       }
+       domAtPos(pos) {
+           return inlineDOMAtPos(this, pos);
+       }
+       reuseDOM(node) {
+           if (node.nodeName == "DIV") {
+               this.setDOM(node);
+               this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;
+           }
+       }
+       sync(view, track) {
+           var _a;
+           if (!this.dom) {
+               this.setDOM(document.createElement("div"));
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           else if (this.flags & 4 /* ViewFlag.AttrsDirty */) {
+               clearAttributes(this.dom);
+               this.dom.className = "cm-line";
+               this.prevAttrs = this.attrs ? null : undefined;
+           }
+           if (this.prevAttrs !== undefined) {
+               updateAttrs(this.dom, this.prevAttrs, this.attrs);
+               this.dom.classList.add("cm-line");
+               this.prevAttrs = undefined;
+           }
+           super.sync(view, track);
+           let last = this.dom.lastChild;
+           while (last && ContentView.get(last) instanceof MarkView)
+               last = last.lastChild;
+           if (!last || !this.length ||
+               last.nodeName != "BR" && ((_a = ContentView.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
+                   (!browser.ios || !this.children.some(ch => ch instanceof TextView))) {
+               let hack = document.createElement("BR");
+               hack.cmIgnore = true;
+               this.dom.appendChild(hack);
+           }
+       }
+       measureTextSize() {
+           if (this.children.length == 0 || this.length > 20)
+               return null;
+           let totalWidth = 0, textHeight;
+           for (let child of this.children) {
+               if (!(child instanceof TextView) || /[^ -~]/.test(child.text))
+                   return null;
+               let rects = clientRectsFor(child.dom);
+               if (rects.length != 1)
+                   return null;
+               totalWidth += rects[0].width;
+               textHeight = rects[0].height;
+           }
+           return !totalWidth ? null : {
+               lineHeight: this.dom.getBoundingClientRect().height,
+               charWidth: totalWidth / this.length,
+               textHeight
+           };
+       }
+       coordsAt(pos, side) {
+           let rect = coordsInChildren(this, pos, side);
+           // Correct rectangle height for empty lines when the returned
+           // height is larger than the text height.
+           if (!this.children.length && rect && this.parent) {
+               let { heightOracle } = this.parent.view.viewState, height = rect.bottom - rect.top;
+               if (Math.abs(height - heightOracle.lineHeight) < 2 && heightOracle.textHeight < height) {
+                   let dist = (height - heightOracle.textHeight) / 2;
+                   return { top: rect.top + dist, bottom: rect.bottom - dist, left: rect.left, right: rect.left };
+               }
+           }
+           return rect;
+       }
+       become(other) {
+           return other instanceof LineView && this.children.length == 0 && other.children.length == 0 &&
+               attrsEq(this.attrs, other.attrs) && this.breakAfter == other.breakAfter;
+       }
+       covers() { return true; }
+       static find(docView, pos) {
+           for (let i = 0, off = 0; i < docView.children.length; i++) {
+               let block = docView.children[i], end = off + block.length;
+               if (end >= pos) {
+                   if (block instanceof LineView)
+                       return block;
+                   if (end > pos)
+                       break;
+               }
+               off = end + block.breakAfter;
+           }
+           return null;
+       }
+   }
+   class BlockWidgetView extends ContentView {
+       constructor(widget, length, deco) {
+           super();
+           this.widget = widget;
+           this.length = length;
+           this.deco = deco;
+           this.breakAfter = 0;
+           this.prevWidget = null;
+       }
+       merge(from, to, source, _takeDeco, openStart, openEnd) {
+           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
+               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
+               return false;
+           this.length = from + (source ? source.length : 0) + (this.length - to);
+           return true;
+       }
+       domAtPos(pos) {
+           return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);
+       }
+       split(at) {
+           let len = this.length - at;
+           this.length = at;
+           let end = new BlockWidgetView(this.widget, len, this.deco);
+           end.breakAfter = this.breakAfter;
+           return end;
+       }
+       get children() { return noChildren; }
+       sync(view) {
+           if (!this.dom || !this.widget.updateDOM(this.dom, view)) {
+               if (this.dom && this.prevWidget)
+                   this.prevWidget.destroy(this.dom);
+               this.prevWidget = null;
+               this.setDOM(this.widget.toDOM(view));
+               if (!this.widget.editable)
+                   this.dom.contentEditable = "false";
+           }
+       }
+       get overrideDOMText() {
+           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;
+       }
+       domBoundsAround() { return null; }
+       become(other) {
+           if (other instanceof BlockWidgetView &&
+               other.widget.constructor == this.widget.constructor) {
+               if (!other.widget.compare(this.widget))
+                   this.markDirty(true);
+               if (this.dom && !this.prevWidget)
+                   this.prevWidget = this.widget;
+               this.widget = other.widget;
+               this.length = other.length;
+               this.deco = other.deco;
+               this.breakAfter = other.breakAfter;
+               return true;
+           }
+           return false;
+       }
+       ignoreMutation() { return true; }
+       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
+       get isEditable() { return false; }
+       get isWidget() { return true; }
+       coordsAt(pos, side) {
+           let custom = this.widget.coordsAt(this.dom, pos, side);
+           if (custom)
+               return custom;
+           if (this.widget instanceof BlockGapWidget)
+               return null;
+           return flattenRect(this.dom.getBoundingClientRect(), this.length ? pos == 0 : side <= 0);
+       }
+       destroy() {
+           super.destroy();
+           if (this.dom)
+               this.widget.destroy(this.dom);
+       }
+       covers(side) {
+           let { startSide, endSide } = this.deco;
+           return startSide == endSide ? false : side < 0 ? startSide < 0 : endSide > 0;
+       }
+   }
+   class BlockGapWidget extends WidgetType {
+       constructor(height) {
+           super();
+           this.height = height;
+       }
+       toDOM() {
+           let elt = document.createElement("div");
+           elt.className = "cm-gap";
+           this.updateDOM(elt);
+           return elt;
+       }
+       eq(other) { return other.height == this.height; }
+       updateDOM(elt) {
+           elt.style.height = this.height + "px";
+           return true;
+       }
+       get editable() { return true; }
+       get estimatedHeight() { return this.height; }
+       ignoreEvent() { return false; }
+   }
+
+   class ContentBuilder {
+       constructor(doc, pos, end, disallowBlockEffectsFor) {
+           this.doc = doc;
+           this.pos = pos;
+           this.end = end;
+           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
+           this.content = [];
+           this.curLine = null;
+           this.breakAtStart = 0;
+           this.pendingBuffer = 0 /* Buf.No */;
+           this.bufferMarks = [];
+           // Set to false directly after a widget that covers the position after it
+           this.atCursorPos = true;
+           this.openStart = -1;
+           this.openEnd = -1;
+           this.text = "";
+           this.textOff = 0;
+           this.cursor = doc.iter();
+           this.skip = pos;
+       }
+       posCovered() {
+           if (this.content.length == 0)
+               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
+           let last = this.content[this.content.length - 1];
+           return !(last.breakAfter || last instanceof BlockWidgetView && last.deco.endSide < 0);
+       }
+       getLine() {
+           if (!this.curLine) {
+               this.content.push(this.curLine = new LineView);
+               this.atCursorPos = true;
+           }
+           return this.curLine;
+       }
+       flushBuffer(active = this.bufferMarks) {
+           if (this.pendingBuffer) {
+               this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
+               this.pendingBuffer = 0 /* Buf.No */;
+           }
+       }
+       addBlockWidget(view) {
+           this.flushBuffer();
+           this.curLine = null;
+           this.content.push(view);
+       }
+       finish(openEnd) {
+           if (this.pendingBuffer && openEnd <= this.bufferMarks.length)
+               this.flushBuffer();
+           else
+               this.pendingBuffer = 0 /* Buf.No */;
+           if (!this.posCovered() &&
+               !(openEnd && this.content.length && this.content[this.content.length - 1] instanceof BlockWidgetView))
+               this.getLine();
+       }
+       buildText(length, active, openStart) {
+           while (length > 0) {
+               if (this.textOff == this.text.length) {
+                   let { value, lineBreak, done } = this.cursor.next(this.skip);
+                   this.skip = 0;
+                   if (done)
+                       throw new Error("Ran out of text content when drawing inline views");
+                   if (lineBreak) {
+                       if (!this.posCovered())
+                           this.getLine();
+                       if (this.content.length)
+                           this.content[this.content.length - 1].breakAfter = 1;
+                       else
+                           this.breakAtStart = 1;
+                       this.flushBuffer();
+                       this.curLine = null;
+                       this.atCursorPos = true;
+                       length--;
+                       continue;
+                   }
+                   else {
+                       this.text = value;
+                       this.textOff = 0;
+                   }
+               }
+               let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
+               this.flushBuffer(active.slice(active.length - openStart));
+               this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
+               this.atCursorPos = true;
+               this.textOff += take;
+               length -= take;
+               openStart = 0;
+           }
+       }
+       span(from, to, active, openStart) {
+           this.buildText(to - from, active, openStart);
+           this.pos = to;
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       point(from, to, deco, active, openStart, index) {
+           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration) {
+               if (deco.block)
+                   throw new RangeError("Block decorations may not be specified via plugins");
+               if (to > this.doc.lineAt(this.pos).to)
+                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
+           }
+           let len = to - from;
+           if (deco instanceof PointDecoration) {
+               if (deco.block) {
+                   if (deco.startSide > 0 && !this.posCovered())
+                       this.getLine();
+                   this.addBlockWidget(new BlockWidgetView(deco.widget || NullWidget.block, len, deco));
+               }
+               else {
+                   let view = WidgetView.create(deco.widget || NullWidget.inline, len, len ? 0 : deco.startSide);
+                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length &&
+                       (from < to || deco.startSide > 0);
+                   let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);
+                   let line = this.getLine();
+                   if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore && !view.isEditable)
+                       this.pendingBuffer = 0 /* Buf.No */;
+                   this.flushBuffer(active);
+                   if (cursorBefore) {
+                       line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
+                       openStart = active.length + Math.max(0, openStart - active.length);
+                   }
+                   line.append(wrapMarks(view, active), openStart);
+                   this.atCursorPos = cursorAfter;
+                   this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to || openStart > active.length ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
+                   if (this.pendingBuffer)
+                       this.bufferMarks = active.slice();
+               }
+           }
+           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
+               this.getLine().addLineDeco(deco);
+           }
+           if (len) {
+               // Advance the iterator past the replaced content
+               if (this.textOff + len <= this.text.length) {
+                   this.textOff += len;
+               }
+               else {
+                   this.skip += len - (this.text.length - this.textOff);
+                   this.text = "";
+                   this.textOff = 0;
+               }
+               this.pos = to;
+           }
+           if (this.openStart < 0)
+               this.openStart = openStart;
+       }
+       static build(text, from, to, decorations, dynamicDecorationMap) {
+           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
+           builder.openEnd = RangeSet.spans(decorations, from, to, builder);
+           if (builder.openStart < 0)
+               builder.openStart = builder.openEnd;
+           builder.finish(builder.openEnd);
+           return builder;
+       }
+   }
+   function wrapMarks(view, active) {
+       for (let mark of active)
+           view = new MarkView(mark, [view], view.length);
+       return view;
+   }
+   class NullWidget extends WidgetType {
+       constructor(tag) {
+           super();
+           this.tag = tag;
+       }
+       eq(other) { return other.tag == this.tag; }
+       toDOM() { return document.createElement(this.tag); }
+       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
+       get isHidden() { return true; }
+   }
+   NullWidget.inline = /*@__PURE__*/new NullWidget("span");
+   NullWidget.block = /*@__PURE__*/new NullWidget("div");
+
+   /**
+   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+   */
+   var Direction = /*@__PURE__*/(function (Direction) {
+       // (These are chosen to match the base levels, in bidi algorithm
+       // terms, of spans in that direction.)
+       /**
+       Left-to-right.
+       */
+       Direction[Direction["LTR"] = 0] = "LTR";
+       /**
+       Right-to-left.
+       */
+       Direction[Direction["RTL"] = 1] = "RTL";
+   return Direction})(Direction || (Direction = {}));
+   const LTR = Direction.LTR, RTL = Direction.RTL;
+   // Decode a string with each type encoded as log2(type)
+   function dec(str) {
+       let result = [];
+       for (let i = 0; i < str.length; i++)
+           result.push(1 << +str[i]);
+       return result;
+   }
+   // Character types for codepoints 0 to 0xf8
+   const LowTypes = /*@__PURE__*/dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
+   // Character types for codepoints 0x600 to 0x6f9
+   const ArabicTypes = /*@__PURE__*/dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
+   const Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];
+   // There's a lot more in
+   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
+   // which are left out to keep code size down.
+   for (let p of ["()", "[]", "{}"]) {
+       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
+       Brackets[l] = r;
+       Brackets[r] = -l;
+   }
+   function charType(ch) {
+       return ch <= 0xf7 ? LowTypes[ch] :
+           0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
+               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
+                   0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
+                       0x2000 <= ch && ch <= 0x200c ? 256 /* T.NI */ :
+                           0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ : 1 /* T.L */;
+   }
+   const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
+   /**
+   Represents a contiguous range of text that has a single direction
+   (as in left-to-right or right-to-left).
+   */
+   class BidiSpan {
+       /**
+       The direction of this span.
+       */
+       get dir() { return this.level % 2 ? RTL : LTR; }
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the span (relative to the start of the line).
+       */
+       from, 
+       /**
+       The end of the span.
+       */
+       to, 
+       /**
+       The ["bidi
+       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
+       of the span (in this context, 0 means
+       left-to-right, 1 means right-to-left, 2 means left-to-right
+       number inside right-to-left text).
+       */
+       level) {
+           this.from = from;
+           this.to = to;
+           this.level = level;
+       }
+       /**
+       @internal
+       */
+       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
+       /**
+       @internal
+       */
+       forward(forward, dir) { return forward == (this.dir == dir); }
+       /**
+       @internal
+       */
+       static find(order, index, level, assoc) {
+           let maybe = -1;
+           for (let i = 0; i < order.length; i++) {
+               let span = order[i];
+               if (span.from <= index && span.to >= index) {
+                   if (span.level == level)
+                       return i;
+                   // When multiple spans match, if assoc != 0, take the one that
+                   // covers that side, otherwise take the one with the minimum
+                   // level.
+                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
+                       maybe = i;
+               }
+           }
+           if (maybe < 0)
+               throw new RangeError("Index out of range");
+           return maybe;
+       }
+   }
+   function isolatesEq(a, b) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++) {
+           let iA = a[i], iB = b[i];
+           if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))
+               return false;
+       }
+       return true;
+   }
+   // Reused array of character types
+   const types = [];
+   // Fill in the character types (in `types`) from `from` to `to` and
+   // apply W normalization rules.
+   function computeCharTypes(line, rFrom, rTo, isolates, outerType) {
+       for (let iI = 0; iI <= isolates.length; iI++) {
+           let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
+           let prevType = iI ? 256 /* T.NI */ : outerType;
+           // W1. Examine each non-spacing mark (NSM) in the level run, and
+           // change the type of the NSM to the type of the previous
+           // character. If the NSM is at the start of the level run, it will
+           // get the type of sor.
+           // W2. Search backwards from each instance of a European number
+           // until the first strong type (R, L, AL, or sor) is found. If an
+           // AL is found, change the type of the European number to Arabic
+           // number.
+           // W3. Change all ALs to R.
+           // (Left after this: L, R, EN, AN, ET, CS, NI)
+           for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {
+               let type = charType(line.charCodeAt(i));
+               if (type == 512 /* T.NSM */)
+                   type = prev;
+               else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
+                   type = 16 /* T.AN */;
+               types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
+               if (type & 7 /* T.Strong */)
+                   prevStrong = type;
+               prev = type;
+           }
+           // W5. A sequence of European terminators adjacent to European
+           // numbers changes to all European numbers.
+           // W6. Otherwise, separators and terminators change to Other
+           // Neutral.
+           // W7. Search backwards from each instance of a European number
+           // until the first strong type (R, L, or sor) is found. If an L is
+           // found, then change the type of the European number to L.
+           // (Left after this: L, R, EN+AN, NI)
+           for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {
+               let type = types[i];
+               if (type == 128 /* T.CS */) {
+                   if (i < to - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
+                       type = types[i] = prev;
+                   else
+                       types[i] = 256 /* T.NI */;
+               }
+               else if (type == 64 /* T.ET */) {
+                   let end = i + 1;
+                   while (end < to && types[end] == 64 /* T.ET */)
+                       end++;
+                   let replace = (i && prev == 8 /* T.EN */) || (end < rTo && types[end] == 8 /* T.EN */) ? (prevStrong == 1 /* T.L */ ? 1 /* T.L */ : 8 /* T.EN */) : 256 /* T.NI */;
+                   for (let j = i; j < end; j++)
+                       types[j] = replace;
+                   i = end - 1;
+               }
+               else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
+                   types[i] = 1 /* T.L */;
+               }
+               prev = type;
+               if (type & 7 /* T.Strong */)
+                   prevStrong = type;
+           }
+       }
+   }
+   // Process brackets throughout a run sequence.
+   function processBracketPairs(line, rFrom, rTo, isolates, outerType) {
+       let oppositeType = outerType == 1 /* T.L */ ? 2 /* T.R */ : 1 /* T.L */;
+       for (let iI = 0, sI = 0, context = 0; iI <= isolates.length; iI++) {
+           let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
+           // N0. Process bracket pairs in an isolating run sequence
+           // sequentially in the logical order of the text positions of the
+           // opening paired brackets using the logic given below. Within this
+           // scope, bidirectional types EN and AN are treated as R.
+           for (let i = from, ch, br, type; i < to; i++) {
+               // Keeps [startIndex, type, strongSeen] triples for each open
+               // bracket on BracketStack.
+               if (br = Brackets[ch = line.charCodeAt(i)]) {
+                   if (br < 0) { // Closing bracket
+                       for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                           if (BracketStack[sJ + 1] == -br) {
+                               let flags = BracketStack[sJ + 2];
+                               let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
+                                   !(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
+                                       (flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
+                               if (type)
+                                   types[i] = types[BracketStack[sJ]] = type;
+                               sI = sJ;
+                               break;
+                           }
+                       }
+                   }
+                   else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
+                       break;
+                   }
+                   else {
+                       BracketStack[sI++] = i;
+                       BracketStack[sI++] = ch;
+                       BracketStack[sI++] = context;
+                   }
+               }
+               else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
+                   let embed = type == outerType;
+                   context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
+                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
+                       let cur = BracketStack[sJ + 2];
+                       if (cur & 2 /* Bracketed.EmbedInside */)
+                           break;
+                       if (embed) {
+                           BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
+                       }
+                       else {
+                           if (cur & 4 /* Bracketed.OppositeInside */)
+                               break;
+                           BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
+                       }
+                   }
+               }
+           }
+       }
+   }
+   function processNeutrals(rFrom, rTo, isolates, outerType) {
+       for (let iI = 0, prev = outerType; iI <= isolates.length; iI++) {
+           let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
+           // N1. A sequence of neutrals takes the direction of the
+           // surrounding strong text if the text on both sides has the same
+           // direction. European and Arabic numbers act as if they were R in
+           // terms of their influence on neutrals. Start-of-level-run (sor)
+           // and end-of-level-run (eor) are used at level run boundaries.
+           // N2. Any remaining neutrals take the embedding direction.
+           // (Left after this: L, R, EN+AN)
+           for (let i = from; i < to;) {
+               let type = types[i];
+               if (type == 256 /* T.NI */) {
+                   let end = i + 1;
+                   for (;;) {
+                       if (end == to) {
+                           if (iI == isolates.length)
+                               break;
+                           end = isolates[iI++].to;
+                           to = iI < isolates.length ? isolates[iI].from : rTo;
+                       }
+                       else if (types[end] == 256 /* T.NI */) {
+                           end++;
+                       }
+                       else {
+                           break;
+                       }
+                   }
+                   let beforeL = prev == 1 /* T.L */;
+                   let afterL = (end < rTo ? types[end] : outerType) == 1 /* T.L */;
+                   let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
+                   for (let j = end, jI = iI, fromJ = jI ? isolates[jI - 1].to : rFrom; j > i;) {
+                       if (j == fromJ) {
+                           j = isolates[--jI].from;
+                           fromJ = jI ? isolates[jI - 1].to : rFrom;
+                       }
+                       types[--j] = replace;
+                   }
+                   i = end;
+               }
+               else {
+                   prev = type;
+                   i++;
+               }
+           }
+       }
+   }
+   // Find the contiguous ranges of character types in a given range, and
+   // emit spans for them. Flip the order of the spans as appropriate
+   // based on the level, and call through to compute the spans for
+   // isolates at the proper point.
+   function emitSpans(line, from, to, level, baseLevel, isolates, order) {
+       let ourType = level % 2 ? 2 /* T.R */ : 1 /* T.L */;
+       if ((level % 2) == (baseLevel % 2)) { // Same dir as base direction, don't flip
+           for (let iCh = from, iI = 0; iCh < to;) {
+               // Scan a section of characters in direction ourType, unless
+               // there's another type of char right after iCh, in which case
+               // we scan a section of other characters (which, if ourType ==
+               // T.L, may contain both T.R and T.AN chars).
+               let sameDir = true, isNum = false;
+               if (iI == isolates.length || iCh < isolates[iI].from) {
+                   let next = types[iCh];
+                   if (next != ourType) {
+                       sameDir = false;
+                       isNum = next == 16 /* T.AN */;
+                   }
+               }
+               // Holds an array of isolates to pass to a recursive call if we
+               // must recurse (to distinguish T.AN inside an RTL section in
+               // LTR text), null if we can emit directly
+               let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;
+               let localLevel = sameDir ? level : level + 1;
+               let iScan = iCh;
+               run: for (;;) {
+                   if (iI < isolates.length && iScan == isolates[iI].from) {
+                       if (isNum)
+                           break run;
+                       let iso = isolates[iI];
+                       // Scan ahead to verify that there is another char in this dir after the isolate(s)
+                       if (!sameDir)
+                           for (let upto = iso.to, jI = iI + 1;;) {
+                               if (upto == to)
+                                   break run;
+                               if (jI < isolates.length && isolates[jI].from == upto)
+                                   upto = isolates[jI++].to;
+                               else if (types[upto] == ourType)
+                                   break run;
+                               else
+                                   break;
+                           }
+                       iI++;
+                       if (recurse) {
+                           recurse.push(iso);
+                       }
+                       else {
+                           if (iso.from > iCh)
+                               order.push(new BidiSpan(iCh, iso.from, localLevel));
+                           let dirSwap = (iso.direction == LTR) != !(localLevel % 2);
+                           computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
+                           iCh = iso.to;
+                       }
+                       iScan = iso.to;
+                   }
+                   else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {
+                       break;
+                   }
+                   else {
+                       iScan++;
+                   }
+               }
+               if (recurse)
+                   emitSpans(line, iCh, iScan, level + 1, baseLevel, recurse, order);
+               else if (iCh < iScan)
+                   order.push(new BidiSpan(iCh, iScan, localLevel));
+               iCh = iScan;
+           }
+       }
+       else {
+           // Iterate in reverse to flip the span order. Same code again, but
+           // going from the back of the section to the front
+           for (let iCh = to, iI = isolates.length; iCh > from;) {
+               let sameDir = true, isNum = false;
+               if (!iI || iCh > isolates[iI - 1].to) {
+                   let next = types[iCh - 1];
+                   if (next != ourType) {
+                       sameDir = false;
+                       isNum = next == 16 /* T.AN */;
+                   }
+               }
+               let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;
+               let localLevel = sameDir ? level : level + 1;
+               let iScan = iCh;
+               run: for (;;) {
+                   if (iI && iScan == isolates[iI - 1].to) {
+                       if (isNum)
+                           break run;
+                       let iso = isolates[--iI];
+                       // Scan ahead to verify that there is another char in this dir after the isolate(s)
+                       if (!sameDir)
+                           for (let upto = iso.from, jI = iI;;) {
+                               if (upto == from)
+                                   break run;
+                               if (jI && isolates[jI - 1].to == upto)
+                                   upto = isolates[--jI].from;
+                               else if (types[upto - 1] == ourType)
+                                   break run;
+                               else
+                                   break;
+                           }
+                       if (recurse) {
+                           recurse.push(iso);
+                       }
+                       else {
+                           if (iso.to < iCh)
+                               order.push(new BidiSpan(iso.to, iCh, localLevel));
+                           let dirSwap = (iso.direction == LTR) != !(localLevel % 2);
+                           computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
+                           iCh = iso.from;
+                       }
+                       iScan = iso.from;
+                   }
+                   else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {
+                       break;
+                   }
+                   else {
+                       iScan--;
+                   }
+               }
+               if (recurse)
+                   emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);
+               else if (iScan < iCh)
+                   order.push(new BidiSpan(iScan, iCh, localLevel));
+               iCh = iScan;
+           }
+       }
+   }
+   function computeSectionOrder(line, level, baseLevel, isolates, from, to, order) {
+       let outerType = (level % 2 ? 2 /* T.R */ : 1 /* T.L */);
+       computeCharTypes(line, from, to, isolates, outerType);
+       processBracketPairs(line, from, to, isolates, outerType);
+       processNeutrals(from, to, isolates, outerType);
+       emitSpans(line, from, to, level, baseLevel, isolates, order);
+   }
+   function computeOrder(line, direction, isolates) {
+       if (!line)
+           return [new BidiSpan(0, 0, direction == RTL ? 1 : 0)];
+       if (direction == LTR && !isolates.length && !BidiRE.test(line))
+           return trivialOrder(line.length);
+       if (isolates.length)
+           while (line.length > types.length)
+               types[types.length] = 256 /* T.NI */; // Make sure types array has no gaps
+       let order = [], level = direction == LTR ? 0 : 1;
+       computeSectionOrder(line, level, level, isolates, 0, line.length, order);
+       return order;
+   }
+   function trivialOrder(length) {
+       return [new BidiSpan(0, length, 0)];
+   }
+   let movedOver = "";
+   // This implementation moves strictly visually, without concern for a
+   // traversal visiting every logical position in the string. It will
+   // still do so for simple input, but situations like multiple isolates
+   // with the same level next to each other, or text going against the
+   // main dir at the end of the line, will make some positions
+   // unreachable with this motion. Each visible cursor position will
+   // correspond to the lower-level bidi span that touches it.
+   //
+   // The alternative would be to solve an order globally for a given
+   // line, making sure that it includes every position, but that would
+   // require associating non-canonical (higher bidi span level)
+   // positions with a given visual position, which is likely to confuse
+   // people. (And would generally be a lot more complicated.)
+   function moveVisually(line, order, dir, start, forward) {
+       var _a;
+       let startIndex = start.head - line.from;
+       let spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
+       let span = order[spanI], spanEnd = span.side(forward, dir);
+       // End of span
+       if (startIndex == spanEnd) {
+           let nextI = spanI += forward ? 1 : -1;
+           if (nextI < 0 || nextI >= order.length)
+               return null;
+           span = order[spanI = nextI];
+           startIndex = span.side(!forward, dir);
+           spanEnd = span.side(forward, dir);
+       }
+       let nextIndex = findClusterBreak(line.text, startIndex, span.forward(forward, dir));
+       if (nextIndex < span.from || nextIndex > span.to)
+           nextIndex = spanEnd;
+       movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
+       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
+       if (nextSpan && nextIndex == spanEnd && nextSpan.level + (forward ? 0 : 1) < span.level)
+           return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
+       return EditorSelection.cursor(nextIndex + line.from, span.forward(forward, dir) ? -1 : 1, span.level);
+   }
+   function autoDirection(text, from, to) {
+       for (let i = from; i < to; i++) {
+           let type = charType(text.charCodeAt(i));
+           if (type == 1 /* T.L */)
+               return LTR;
+           if (type == 2 /* T.R */ || type == 4 /* T.AL */)
+               return RTL;
+       }
+       return LTR;
+   }
+
+   const clickAddsSelectionRange = /*@__PURE__*/Facet.define();
+   const dragMovesSelection$1 = /*@__PURE__*/Facet.define();
+   const mouseSelectionStyle = /*@__PURE__*/Facet.define();
+   const exceptionSink = /*@__PURE__*/Facet.define();
+   const updateListener = /*@__PURE__*/Facet.define();
+   const inputHandler = /*@__PURE__*/Facet.define();
+   const focusChangeEffect = /*@__PURE__*/Facet.define();
+   const clipboardInputFilter = /*@__PURE__*/Facet.define();
+   const clipboardOutputFilter = /*@__PURE__*/Facet.define();
+   const perLineTextDirection = /*@__PURE__*/Facet.define({
+       combine: values => values.some(x => x)
+   });
+   const nativeSelectionHidden = /*@__PURE__*/Facet.define({
+       combine: values => values.some(x => x)
+   });
+   const scrollHandler = /*@__PURE__*/Facet.define();
+   class ScrollTarget {
+       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5, 
+       // This data structure is abused to also store precise scroll
+       // snapshots, instead of a `scrollIntoView` request. When this
+       // flag is `true`, `range` points at a position in the reference
+       // line, `yMargin` holds the difference between the top of that
+       // line and the top of the editor, and `xMargin` holds the
+       // editor's `scrollLeft`.
+       isSnapshot = false) {
+           this.range = range;
+           this.y = y;
+           this.x = x;
+           this.yMargin = yMargin;
+           this.xMargin = xMargin;
+           this.isSnapshot = isSnapshot;
+       }
+       map(changes) {
+           return changes.empty ? this :
+               new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
+       }
+       clip(state) {
+           return this.range.to <= state.doc.length ? this :
+               new ScrollTarget(EditorSelection.cursor(state.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
+       }
+   }
+   const scrollIntoView$1 = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });
+   const setEditContextFormatting = /*@__PURE__*/StateEffect.define();
+   /**
+   Log or report an unhandled exception in client code. Should
+   probably only be used by extension code that allows client code to
+   provide functions, and calls those functions in a context where an
+   exception can't be propagated to calling code in a reasonable way
+   (for example when in an event handler).
+
+   Either calls a handler registered with
+   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
+   `window.onerror`, if defined, or `console.error` (in which case
+   it'll pass `context`, when given, as first argument).
+   */
+   function logException(state, exception, context) {
+       let handler = state.facet(exceptionSink);
+       if (handler.length)
+           handler[0](exception);
+       else if (window.onerror)
+           window.onerror(String(exception), context, undefined, undefined, exception);
+       else if (context)
+           console.error(context + ":", exception);
+       else
+           console.error(exception);
+   }
+   const editable = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : true });
+   let nextPluginID = 0;
+   const viewPlugin = /*@__PURE__*/Facet.define();
+   /**
+   View plugins associate stateful values with a view. They can
+   influence the way the content is drawn, and are notified of things
+   that happen in the view.
+   */
+   class ViewPlugin {
+       constructor(
+       /**
+       @internal
+       */
+       id, 
+       /**
+       @internal
+       */
+       create, 
+       /**
+       @internal
+       */
+       domEventHandlers, 
+       /**
+       @internal
+       */
+       domEventObservers, buildExtensions) {
+           this.id = id;
+           this.create = create;
+           this.domEventHandlers = domEventHandlers;
+           this.domEventObservers = domEventObservers;
+           this.extension = buildExtensions(this);
+       }
+       /**
+       Define a plugin from a constructor function that creates the
+       plugin's value, given an editor view.
+       */
+       static define(create, spec) {
+           const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
+           return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, plugin => {
+               let ext = [viewPlugin.of(plugin)];
+               if (deco)
+                   ext.push(decorations.of(view => {
+                       let pluginInst = view.plugin(plugin);
+                       return pluginInst ? deco(pluginInst) : Decoration.none;
+                   }));
+               if (provide)
+                   ext.push(provide(plugin));
+               return ext;
+           });
+       }
+       /**
+       Create a plugin for a class whose constructor takes a single
+       editor view as argument.
+       */
+       static fromClass(cls, spec) {
+           return ViewPlugin.define(view => new cls(view), spec);
+       }
+   }
+   class PluginInstance {
+       constructor(spec) {
+           this.spec = spec;
+           // When starting an update, all plugins have this field set to the
+           // update object, indicating they need to be updated. When finished
+           // updating, it is set to `false`. Retrieving a plugin that needs to
+           // be updated with `view.plugin` forces an eager update.
+           this.mustUpdate = null;
+           // This is null when the plugin is initially created, but
+           // initialized on the first update.
+           this.value = null;
+       }
+       update(view) {
+           if (!this.value) {
+               if (this.spec) {
+                   try {
+                       this.value = this.spec.create(view);
+                   }
+                   catch (e) {
+                       logException(view.state, e, "CodeMirror plugin crashed");
+                       this.deactivate();
+                   }
+               }
+           }
+           else if (this.mustUpdate) {
+               let update = this.mustUpdate;
+               this.mustUpdate = null;
+               if (this.value.update) {
+                   try {
+                       this.value.update(update);
+                   }
+                   catch (e) {
+                       logException(update.state, e, "CodeMirror plugin crashed");
+                       if (this.value.destroy)
+                           try {
+                               this.value.destroy();
+                           }
+                           catch (_) { }
+                       this.deactivate();
+                   }
+               }
+           }
+           return this;
+       }
+       destroy(view) {
+           var _a;
+           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
+               try {
+                   this.value.destroy();
+               }
+               catch (e) {
+                   logException(view.state, e, "CodeMirror plugin crashed");
+               }
+           }
+       }
+       deactivate() {
+           this.spec = this.value = null;
+       }
+   }
+   const editorAttributes = /*@__PURE__*/Facet.define();
+   const contentAttributes = /*@__PURE__*/Facet.define();
+   // Provide decorations
+   const decorations = /*@__PURE__*/Facet.define();
+   const outerDecorations = /*@__PURE__*/Facet.define();
+   const atomicRanges = /*@__PURE__*/Facet.define();
+   const bidiIsolatedRanges = /*@__PURE__*/Facet.define();
+   function getIsolatedRanges(view, line) {
+       let isolates = view.state.facet(bidiIsolatedRanges);
+       if (!isolates.length)
+           return isolates;
+       let sets = isolates.map(i => i instanceof Function ? i(view) : i);
+       let result = [];
+       RangeSet.spans(sets, line.from, line.to, {
+           point() { },
+           span(fromDoc, toDoc, active, open) {
+               let from = fromDoc - line.from, to = toDoc - line.from;
+               let level = result;
+               for (let i = active.length - 1; i >= 0; i--, open--) {
+                   let direction = active[i].spec.bidiIsolate, update;
+                   if (direction == null)
+                       direction = autoDirection(line.text, from, to);
+                   if (open > 0 && level.length &&
+                       (update = level[level.length - 1]).to == from && update.direction == direction) {
+                       update.to = to;
+                       level = update.inner;
+                   }
+                   else {
+                       let add = { from, to, direction, inner: [] };
+                       level.push(add);
+                       level = add.inner;
+                   }
+               }
+           }
+       });
+       return result;
+   }
+   const scrollMargins = /*@__PURE__*/Facet.define();
+   function getScrollMargins(view) {
+       let left = 0, right = 0, top = 0, bottom = 0;
+       for (let source of view.state.facet(scrollMargins)) {
+           let m = source(view);
+           if (m) {
+               if (m.left != null)
+                   left = Math.max(left, m.left);
+               if (m.right != null)
+                   right = Math.max(right, m.right);
+               if (m.top != null)
+                   top = Math.max(top, m.top);
+               if (m.bottom != null)
+                   bottom = Math.max(bottom, m.bottom);
+           }
+       }
+       return { left, right, top, bottom };
+   }
+   const styleModule = /*@__PURE__*/Facet.define();
+   class ChangedRange {
+       constructor(fromA, toA, fromB, toB) {
+           this.fromA = fromA;
+           this.toA = toA;
+           this.fromB = fromB;
+           this.toB = toB;
+       }
+       join(other) {
+           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
+       }
+       addToSet(set) {
+           let i = set.length, me = this;
+           for (; i > 0; i--) {
+               let range = set[i - 1];
+               if (range.fromA > me.toA)
+                   continue;
+               if (range.toA < me.fromA)
+                   break;
+               me = me.join(range);
+               set.splice(i - 1, 1);
+           }
+           set.splice(i, 0, me);
+           return set;
+       }
+       static extendWithRanges(diff, ranges) {
+           if (ranges.length == 0)
+               return diff;
+           let result = [];
+           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
+               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
+               let end = next ? next.fromB : 1e9;
+               while (rI < ranges.length && ranges[rI] < end) {
+                   let from = ranges[rI], to = ranges[rI + 1];
+                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
+                   if (fromB <= toB)
+                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
+                   if (to > end)
+                       break;
+                   else
+                       rI += 2;
+               }
+               if (!next)
+                   return result;
+               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
+               posA = next.toA;
+               posB = next.toB;
+           }
+       }
+   }
+   /**
+   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
+   class, which describe what happened, whenever the view is updated.
+   */
+   class ViewUpdate {
+       constructor(
+       /**
+       The editor view that the update is associated with.
+       */
+       view, 
+       /**
+       The new editor state.
+       */
+       state, 
+       /**
+       The transactions involved in the update. May be empty.
+       */
+       transactions) {
+           this.view = view;
+           this.state = state;
+           this.transactions = transactions;
+           /**
+           @internal
+           */
+           this.flags = 0;
+           this.startState = view.state;
+           this.changes = ChangeSet.empty(this.startState.doc.length);
+           for (let tr of transactions)
+               this.changes = this.changes.compose(tr.changes);
+           let changedRanges = [];
+           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));
+           this.changedRanges = changedRanges;
+       }
+       /**
+       @internal
+       */
+       static create(view, state, transactions) {
+           return new ViewUpdate(view, state, transactions);
+       }
+       /**
+       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
+       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
+       update.
+       */
+       get viewportChanged() {
+           return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
+       }
+       /**
+       Returns true when
+       [`viewportChanged`](https://codemirror.net/6/docs/ref/#view.ViewUpdate.viewportChanged) is true
+       and the viewport change is not just the result of mapping it in
+       response to document changes.
+       */
+       get viewportMoved() {
+           return (this.flags & 8 /* UpdateFlag.ViewportMoved */) > 0;
+       }
+       /**
+       Indicates whether the height of a block element in the editor
+       changed in this update.
+       */
+       get heightChanged() {
+           return (this.flags & 2 /* UpdateFlag.Height */) > 0;
+       }
+       /**
+       Returns true when the document was modified or the size of the
+       editor, or elements within the editor, changed.
+       */
+       get geometryChanged() {
+           return this.docChanged || (this.flags & (16 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
+       }
+       /**
+       True when this update indicates a focus change.
+       */
+       get focusChanged() {
+           return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
+       }
+       /**
+       Whether the document changed in this update.
+       */
+       get docChanged() {
+           return !this.changes.empty;
+       }
+       /**
+       Whether the selection was explicitly set in this update.
+       */
+       get selectionSet() {
+           return this.transactions.some(tr => tr.selection);
+       }
+       /**
+       @internal
+       */
+       get empty() { return this.flags == 0 && this.transactions.length == 0; }
+   }
+
+   class DocView extends ContentView {
+       get length() { return this.view.state.doc.length; }
+       constructor(view) {
+           super();
+           this.view = view;
+           this.decorations = [];
+           this.dynamicDecorationMap = [false];
+           this.domChanged = null;
+           this.hasComposition = null;
+           this.markedForComposition = new Set;
+           this.editContextFormatting = Decoration.none;
+           this.lastCompositionAfterCursor = false;
+           // Track a minimum width for the editor. When measuring sizes in
+           // measureVisibleLineHeights, this is updated to point at the width
+           // of a given element and its extent in the document. When a change
+           // happens in that range, these are reset. That way, once we've seen
+           // a line/element of a given length, we keep the editor wide enough
+           // to fit at least that element, until it is changed, at which point
+           // we forget it again.
+           this.minWidth = 0;
+           this.minWidthFrom = 0;
+           this.minWidthTo = 0;
+           // Track whether the DOM selection was set in a lossy way, so that
+           // we don't mess it up when reading it back it
+           this.impreciseAnchor = null;
+           this.impreciseHead = null;
+           this.forceSelection = false;
+           // Used by the resize observer to ignore resizes that we caused
+           // ourselves
+           this.lastUpdate = Date.now();
+           this.setDOM(view.contentDOM);
+           this.children = [new LineView];
+           this.children[0].setParent(this);
+           this.updateDeco();
+           this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0, null);
+       }
+       // Update the document view to a given state.
+       update(update) {
+           var _a;
+           let changedRanges = update.changedRanges;
+           if (this.minWidth > 0 && changedRanges.length) {
+               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
+                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
+               }
+               else {
+                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
+                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
+               }
+           }
+           this.updateEditContextFormatting(update);
+           let readCompositionAt = -1;
+           if (this.view.inputState.composing >= 0 && !this.view.observer.editContext) {
+               if ((_a = this.domChanged) === null || _a === void 0 ? void 0 : _a.newSel)
+                   readCompositionAt = this.domChanged.newSel.head;
+               else if (!touchesComposition(update.changes, this.hasComposition) && !update.selectionSet)
+                   readCompositionAt = update.state.selection.main.head;
+           }
+           let composition = readCompositionAt > -1 ? findCompositionRange(this.view, update.changes, readCompositionAt) : null;
+           this.domChanged = null;
+           if (this.hasComposition) {
+               this.markedForComposition.clear();
+               let { from, to } = this.hasComposition;
+               changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))
+                   .addToSet(changedRanges.slice());
+           }
+           this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;
+           // When the DOM nodes around the selection are moved to another
+           // parent, Chrome sometimes reports a different selection through
+           // getSelection than the one that it actually shows to the user.
+           // This forces a selection update when lines are joined to work
+           // around that. Issue #54
+           if ((browser.ie || browser.chrome) && !composition && update &&
+               update.state.doc.lines != update.startState.doc.lines)
+               this.forceSelection = true;
+           let prevDeco = this.decorations, deco = this.updateDeco();
+           let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
+           changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
+           if (!(this.flags & 7 /* ViewFlag.Dirty */) && changedRanges.length == 0) {
+               return false;
+           }
+           else {
+               this.updateInner(changedRanges, update.startState.doc.length, composition);
+               if (update.transactions.length)
+                   this.lastUpdate = Date.now();
+               return true;
+           }
+       }
+       // Used by update and the constructor do perform the actual DOM
+       // update
+       updateInner(changes, oldLength, composition) {
+           this.view.viewState.mustMeasureContent = true;
+           this.updateChildren(changes, oldLength, composition);
+           let { observer } = this.view;
+           observer.ignore(() => {
+               // Lock the height during redrawing, since Chrome sometimes
+               // messes with the scroll position during DOM mutation (though
+               // no relayout is triggered and I cannot imagine how it can
+               // recompute the scroll position without a layout)
+               this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + "px";
+               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
+               // Chrome will sometimes, when DOM mutations occur directly
+               // around the selection, get confused and report a different
+               // selection from the one it displays (issue #218). This tries
+               // to detect that situation.
+               let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
+               this.sync(this.view, track);
+               this.flags &= ~7 /* ViewFlag.Dirty */;
+               if (track && (track.written || observer.selectionRange.focusNode != track.node))
+                   this.forceSelection = true;
+               this.dom.style.height = "";
+           });
+           this.markedForComposition.forEach(cView => cView.flags &= ~8 /* ViewFlag.Composition */);
+           let gaps = [];
+           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
+               for (let child of this.children)
+                   if (child instanceof BlockWidgetView && child.widget instanceof BlockGapWidget)
+                       gaps.push(child.dom);
+           observer.updateGaps(gaps);
+       }
+       updateChildren(changes, oldLength, composition) {
+           let ranges = composition ? composition.range.addToSet(changes.slice()) : changes;
+           let cursor = this.childCursor(oldLength);
+           for (let i = ranges.length - 1;; i--) {
+               let next = i >= 0 ? ranges[i] : null;
+               if (!next)
+                   break;
+               let { fromA, toA, fromB, toB } = next, content, breakAtStart, openStart, openEnd;
+               if (composition && composition.range.fromB < toB && composition.range.toB > fromB) {
+                   let before = ContentBuilder.build(this.view.state.doc, fromB, composition.range.fromB, this.decorations, this.dynamicDecorationMap);
+                   let after = ContentBuilder.build(this.view.state.doc, composition.range.toB, toB, this.decorations, this.dynamicDecorationMap);
+                   breakAtStart = before.breakAtStart;
+                   openStart = before.openStart;
+                   openEnd = after.openEnd;
+                   let compLine = this.compositionView(composition);
+                   if (after.breakAtStart) {
+                       compLine.breakAfter = 1;
+                   }
+                   else if (after.content.length &&
+                       compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {
+                       compLine.breakAfter = after.content[0].breakAfter;
+                       after.content.shift();
+                   }
+                   if (before.content.length &&
+                       compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {
+                       before.content.pop();
+                   }
+                   content = before.content.concat(compLine).concat(after.content);
+               }
+               else {
+                   ({ content, breakAtStart, openStart, openEnd } =
+                       ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap));
+               }
+               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
+               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
+               replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
+           }
+           if (composition)
+               this.fixCompositionDOM(composition);
+       }
+       updateEditContextFormatting(update) {
+           this.editContextFormatting = this.editContextFormatting.map(update.changes);
+           for (let tr of update.transactions)
+               for (let effect of tr.effects)
+                   if (effect.is(setEditContextFormatting)) {
+                       this.editContextFormatting = effect.value;
+                   }
+       }
+       compositionView(composition) {
+           let cur = new TextView(composition.text.nodeValue);
+           cur.flags |= 8 /* ViewFlag.Composition */;
+           for (let { deco } of composition.marks)
+               cur = new MarkView(deco, [cur], cur.length);
+           let line = new LineView;
+           line.append(cur, 0);
+           return line;
+       }
+       fixCompositionDOM(composition) {
+           let fix = (dom, cView) => {
+               cView.flags |= 8 /* ViewFlag.Composition */ | (cView.children.some(c => c.flags & 7 /* ViewFlag.Dirty */) ? 1 /* ViewFlag.ChildDirty */ : 0);
+               this.markedForComposition.add(cView);
+               let prev = ContentView.get(dom);
+               if (prev && prev != cView)
+                   prev.dom = null;
+               cView.setDOM(dom);
+           };
+           let pos = this.childPos(composition.range.fromB, 1);
+           let cView = this.children[pos.i];
+           fix(composition.line, cView);
+           for (let i = composition.marks.length - 1; i >= -1; i--) {
+               pos = cView.childPos(pos.off, 1);
+               cView = cView.children[pos.i];
+               fix(i >= 0 ? composition.marks[i].node : composition.text, cView);
+           }
+       }
+       // Sync the DOM selection to this.state.selection
+       updateSelection(mustRead = false, fromPointer = false) {
+           if (mustRead || !this.view.observer.selectionRange.focusNode)
+               this.view.observer.readSelectionRange();
+           let activeElt = this.view.root.activeElement, focused = activeElt == this.dom;
+           let selectionNotFocus = !focused && !(this.view.state.facet(editable) || this.dom.tabIndex > -1) &&
+               hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));
+           if (!(focused || fromPointer || selectionNotFocus))
+               return;
+           let force = this.forceSelection;
+           this.forceSelection = false;
+           let main = this.view.state.selection.main;
+           let anchor = this.moveToLine(this.domAtPos(main.anchor));
+           let head = main.empty ? anchor : this.moveToLine(this.domAtPos(main.head));
+           // Always reset on Firefox when next to an uneditable node to
+           // avoid invisible cursor bugs (#111)
+           if (browser.gecko && main.empty && !this.hasComposition && betweenUneditable(anchor)) {
+               let dummy = document.createTextNode("");
+               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
+               anchor = head = new DOMPos(dummy, 0);
+               force = true;
+           }
+           let domSel = this.view.observer.selectionRange;
+           // If the selection is already here, or in an equivalent position, don't touch it
+           if (force || !domSel.focusNode || (!isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
+               !isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) && !this.suppressWidgetCursorChange(domSel, main)) {
+               this.view.observer.ignore(() => {
+                   // Chrome Android will hide the virtual keyboard when tapping
+                   // inside an uneditable node, and not bring it back when we
+                   // move the cursor to its proper position. This tries to
+                   // restore the keyboard by cycling focus.
+                   if (browser.android && browser.chrome && this.dom.contains(domSel.focusNode) &&
+                       inUneditable(domSel.focusNode, this.dom)) {
+                       this.dom.blur();
+                       this.dom.focus({ preventScroll: true });
+                   }
+                   let rawSel = getSelection(this.view.root);
+                   if (!rawSel) ;
+                   else if (main.empty) {
+                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
+                       if (browser.gecko) {
+                           let nextTo = nextToUneditable(anchor.node, anchor.offset);
+                           if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
+                               let text = (nextTo == 1 /* NextTo.Before */ ? textNodeBefore : textNodeAfter)(anchor.node, anchor.offset);
+                               if (text)
+                                   anchor = new DOMPos(text.node, text.offset);
+                           }
+                       }
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       if (main.bidiLevel != null && rawSel.caretBidiLevel !== undefined)
+                           rawSel.caretBidiLevel = main.bidiLevel;
+                   }
+                   else if (rawSel.extend) {
+                       // Selection.extend can be used to create an 'inverted' selection
+                       // (one where the focus is before the anchor), but not all
+                       // browsers support it yet.
+                       rawSel.collapse(anchor.node, anchor.offset);
+                       // Safari will ignore the call above when the editor is
+                       // hidden, and then raise an error on the call to extend
+                       // (#940).
+                       try {
+                           rawSel.extend(head.node, head.offset);
+                       }
+                       catch (_) { }
+                   }
+                   else {
+                       // Primitive (IE) way
+                       let range = document.createRange();
+                       if (main.anchor > main.head)
+                           [anchor, head] = [head, anchor];
+                       range.setEnd(head.node, head.offset);
+                       range.setStart(anchor.node, anchor.offset);
+                       rawSel.removeAllRanges();
+                       rawSel.addRange(range);
+                   }
+                   if (selectionNotFocus && this.view.root.activeElement == this.dom) {
+                       this.dom.blur();
+                       if (activeElt)
+                           activeElt.focus();
+                   }
+               });
+               this.view.observer.setSelectionRange(anchor, head);
+           }
+           this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);
+           this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);
+       }
+       // If a zero-length widget is inserted next to the cursor during
+       // composition, avoid moving it across it and disrupting the
+       // composition.
+       suppressWidgetCursorChange(sel, cursor) {
+           return this.hasComposition && cursor.empty &&
+               isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset) &&
+               this.posFromDOM(sel.focusNode, sel.focusOffset) == cursor.head;
+       }
+       enforceCursorAssoc() {
+           if (this.hasComposition)
+               return;
+           let { view } = this, cursor = view.state.selection.main;
+           let sel = getSelection(view.root);
+           let { anchorNode, anchorOffset } = view.observer.selectionRange;
+           if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
+               return;
+           let line = LineView.find(this, cursor.head);
+           if (!line)
+               return;
+           let lineStart = line.posAtStart;
+           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
+               return;
+           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
+           if (!before || !after || before.bottom > after.top)
+               return;
+           let dom = this.domAtPos(cursor.head + cursor.assoc);
+           sel.collapse(dom.node, dom.offset);
+           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
+           // This can go wrong in corner cases like single-character lines,
+           // so check and reset if necessary.
+           view.observer.readSelectionRange();
+           let newRange = view.observer.selectionRange;
+           if (view.docView.posFromDOM(newRange.anchorNode, newRange.anchorOffset) != cursor.from)
+               sel.collapse(anchorNode, anchorOffset);
+       }
+       // If a position is in/near a block widget, move it to a nearby text
+       // line, since we don't want the cursor inside a block widget.
+       moveToLine(pos) {
+           // Block widgets will return positions before/after them, which
+           // are thus directly in the document DOM element.
+           let dom = this.dom, newPos;
+           if (pos.node != dom)
+               return pos;
+           for (let i = pos.offset; !newPos && i < dom.childNodes.length; i++) {
+               let view = ContentView.get(dom.childNodes[i]);
+               if (view instanceof LineView)
+                   newPos = view.domAtPos(0);
+           }
+           for (let i = pos.offset - 1; !newPos && i >= 0; i--) {
+               let view = ContentView.get(dom.childNodes[i]);
+               if (view instanceof LineView)
+                   newPos = view.domAtPos(view.length);
+           }
+           return newPos ? new DOMPos(newPos.node, newPos.offset, true) : pos;
+       }
+       nearest(dom) {
+           for (let cur = dom; cur;) {
+               let domView = ContentView.get(cur);
+               if (domView && domView.rootView == this)
+                   return domView;
+               cur = cur.parentNode;
+           }
+           return null;
+       }
+       posFromDOM(node, offset) {
+           let view = this.nearest(node);
+           if (!view)
+               throw new RangeError("Trying to find position for a DOM position outside of the document");
+           return view.localPosFromDOM(node, offset) + view.posAtStart;
+       }
+       domAtPos(pos) {
+           let { i, off } = this.childCursor().findPos(pos, -1);
+           for (; i < this.children.length - 1;) {
+               let child = this.children[i];
+               if (off < child.length || child instanceof LineView)
+                   break;
+               i++;
+               off = 0;
+           }
+           return this.children[i].domAtPos(off);
+       }
+       coordsAt(pos, side) {
+           let best = null, bestPos = 0;
+           for (let off = this.length, i = this.children.length - 1; i >= 0; i--) {
+               let child = this.children[i], end = off - child.breakAfter, start = end - child.length;
+               if (end < pos)
+                   break;
+               if (start <= pos && (start < pos || child.covers(-1)) && (end > pos || child.covers(1)) &&
+                   (!best || child instanceof LineView && !(best instanceof LineView && side >= 0))) {
+                   best = child;
+                   bestPos = start;
+               }
+               else if (best && start == pos && end == pos && child instanceof BlockWidgetView && Math.abs(side) < 2) {
+                   if (child.deco.startSide < 0)
+                       break;
+                   else if (i)
+                       best = null;
+               }
+               off = start;
+           }
+           return best ? best.coordsAt(pos - bestPos, side) : null;
+       }
+       coordsForChar(pos) {
+           let { i, off } = this.childPos(pos, 1), child = this.children[i];
+           if (!(child instanceof LineView))
+               return null;
+           while (child.children.length) {
+               let { i, off: childOff } = child.childPos(off, 1);
+               for (;; i++) {
+                   if (i == child.children.length)
+                       return null;
+                   if ((child = child.children[i]).length)
+                       break;
+               }
+               off = childOff;
+           }
+           if (!(child instanceof TextView))
+               return null;
+           let end = findClusterBreak(child.text, off);
+           if (end == off)
+               return null;
+           let rects = textRange(child.dom, off, end).getClientRects();
+           for (let i = 0; i < rects.length; i++) {
+               let rect = rects[i];
+               if (i == rects.length - 1 || rect.top < rect.bottom && rect.left < rect.right)
+                   return rect;
+           }
+           return null;
+       }
+       measureVisibleLineHeights(viewport) {
+           let result = [], { from, to } = viewport;
+           let contentWidth = this.view.contentDOM.clientWidth;
+           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
+           let widest = -1, ltr = this.view.textDirection == Direction.LTR;
+           for (let pos = 0, i = 0; i < this.children.length; i++) {
+               let child = this.children[i], end = pos + child.length;
+               if (end > to)
+                   break;
+               if (pos >= from) {
+                   let childRect = child.dom.getBoundingClientRect();
+                   result.push(childRect.height);
+                   if (isWider) {
+                       let last = child.dom.lastChild;
+                       let rects = last ? clientRectsFor(last) : [];
+                       if (rects.length) {
+                           let rect = rects[rects.length - 1];
+                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
+                           if (width > widest) {
+                               widest = width;
+                               this.minWidth = contentWidth;
+                               this.minWidthFrom = pos;
+                               this.minWidthTo = end;
+                           }
+                       }
+                   }
+               }
+               pos = end + child.breakAfter;
+           }
+           return result;
+       }
+       textDirectionAt(pos) {
+           let { i } = this.childPos(pos, 1);
+           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction.RTL : Direction.LTR;
+       }
+       measureTextSize() {
+           for (let child of this.children) {
+               if (child instanceof LineView) {
+                   let measure = child.measureTextSize();
+                   if (measure)
+                       return measure;
+               }
+           }
+           // If no workable line exists, force a layout of a measurable element
+           let dummy = document.createElement("div"), lineHeight, charWidth, textHeight;
+           dummy.className = "cm-line";
+           dummy.style.width = "99999px";
+           dummy.style.position = "absolute";
+           dummy.textContent = "abc def ghi jkl mno pqr stu";
+           this.view.observer.ignore(() => {
+               this.dom.appendChild(dummy);
+               let rect = clientRectsFor(dummy.firstChild)[0];
+               lineHeight = dummy.getBoundingClientRect().height;
+               charWidth = rect ? rect.width / 27 : 7;
+               textHeight = rect ? rect.height : lineHeight;
+               dummy.remove();
+           });
+           return { lineHeight, charWidth, textHeight };
+       }
+       childCursor(pos = this.length) {
+           // Move back to start of last element when possible, so that
+           // `ChildCursor.findPos` doesn't have to deal with the edge case
+           // of being after the last element.
+           let i = this.children.length;
+           if (i)
+               pos -= this.children[--i].length;
+           return new ChildCursor(this.children, pos, i);
+       }
+       computeBlockGapDeco() {
+           let deco = [], vs = this.view.viewState;
+           for (let pos = 0, i = 0;; i++) {
+               let next = i == vs.viewports.length ? null : vs.viewports[i];
+               let end = next ? next.from - 1 : this.length;
+               if (end > pos) {
+                   let height = (vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top) / this.view.scaleY;
+                   deco.push(Decoration.replace({
+                       widget: new BlockGapWidget(height),
+                       block: true,
+                       inclusive: true,
+                       isBlockGap: true,
+                   }).range(pos, end));
+               }
+               if (!next)
+                   break;
+               pos = next.to + 1;
+           }
+           return Decoration.set(deco);
+       }
+       updateDeco() {
+           let i = 1;
+           let allDeco = this.view.state.facet(decorations).map(d => {
+               let dynamic = this.dynamicDecorationMap[i++] = typeof d == "function";
+               return dynamic ? d(this.view) : d;
+           });
+           let dynamicOuter = false, outerDeco = this.view.state.facet(outerDecorations).map((d, i) => {
+               let dynamic = typeof d == "function";
+               if (dynamic)
+                   dynamicOuter = true;
+               return dynamic ? d(this.view) : d;
+           });
+           if (outerDeco.length) {
+               this.dynamicDecorationMap[i++] = dynamicOuter;
+               allDeco.push(RangeSet.join(outerDeco));
+           }
+           this.decorations = [
+               this.editContextFormatting,
+               ...allDeco,
+               this.computeBlockGapDeco(),
+               this.view.viewState.lineGapDeco
+           ];
+           while (i < this.decorations.length)
+               this.dynamicDecorationMap[i++] = false;
+           return this.decorations;
+       }
+       scrollIntoView(target) {
+           if (target.isSnapshot) {
+               let ref = this.view.viewState.lineBlockAt(target.range.head);
+               this.view.scrollDOM.scrollTop = ref.top - target.yMargin;
+               this.view.scrollDOM.scrollLeft = target.xMargin;
+               return;
+           }
+           for (let handler of this.view.state.facet(scrollHandler)) {
+               try {
+                   if (handler(this.view, target.range, target))
+                       return true;
+               }
+               catch (e) {
+                   logException(this.view.state, e, "scroll handler");
+               }
+           }
+           let { range } = target;
+           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
+           if (!rect)
+               return;
+           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
+               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
+                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
+           let margins = getScrollMargins(this.view);
+           let targetRect = {
+               left: rect.left - margins.left, top: rect.top - margins.top,
+               right: rect.right + margins.right, bottom: rect.bottom + margins.bottom
+           };
+           let { offsetWidth, offsetHeight } = this.view.scrollDOM;
+           scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, Math.max(Math.min(target.xMargin, offsetWidth), -offsetWidth), Math.max(Math.min(target.yMargin, offsetHeight), -offsetHeight), this.view.textDirection == Direction.LTR);
+       }
+   }
+   function betweenUneditable(pos) {
+       return pos.node.nodeType == 1 && pos.node.firstChild &&
+           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
+           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
+   }
+   function findCompositionNode(view, headPos) {
+       let sel = view.observer.selectionRange;
+       if (!sel.focusNode)
+           return null;
+       let textBefore = textNodeBefore(sel.focusNode, sel.focusOffset);
+       let textAfter = textNodeAfter(sel.focusNode, sel.focusOffset);
+       let textNode = textBefore || textAfter;
+       if (textAfter && textBefore && textAfter.node != textBefore.node) {
+           let descAfter = ContentView.get(textAfter.node);
+           if (!descAfter || descAfter instanceof TextView && descAfter.text != textAfter.node.nodeValue) {
+               textNode = textAfter;
+           }
+           else if (view.docView.lastCompositionAfterCursor) {
+               let descBefore = ContentView.get(textBefore.node);
+               if (!(!descBefore || descBefore instanceof TextView && descBefore.text != textBefore.node.nodeValue))
+                   textNode = textAfter;
+           }
+       }
+       view.docView.lastCompositionAfterCursor = textNode != textBefore;
+       if (!textNode)
+           return null;
+       let from = headPos - textNode.offset;
+       return { from, to: from + textNode.node.nodeValue.length, node: textNode.node };
+   }
+   function findCompositionRange(view, changes, headPos) {
+       let found = findCompositionNode(view, headPos);
+       if (!found)
+           return null;
+       let { node: textNode, from, to } = found, text = textNode.nodeValue;
+       // Don't try to preserve multi-line compositions
+       if (/[\n\r]/.test(text))
+           return null;
+       if (view.state.doc.sliceString(found.from, found.to) != text)
+           return null;
+       let inv = changes.invertedDesc;
+       let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);
+       let marks = [];
+       for (let parent = textNode.parentNode;; parent = parent.parentNode) {
+           let parentView = ContentView.get(parent);
+           if (parentView instanceof MarkView)
+               marks.push({ node: parent, deco: parentView.mark });
+           else if (parentView instanceof LineView || parent.nodeName == "DIV" && parent.parentNode == view.contentDOM)
+               return { range, text: textNode, marks, line: parent };
+           else if (parent != view.contentDOM)
+               marks.push({ node: parent, deco: new MarkDecoration({
+                       inclusive: true,
+                       attributes: getAttrs(parent),
+                       tagName: parent.tagName.toLowerCase()
+                   }) });
+           else
+               return null;
+       }
+   }
+   function nextToUneditable(node, offset) {
+       if (node.nodeType != 1)
+           return 0;
+       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
+           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
+   }
+   let DecorationComparator$1 = class DecorationComparator {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange(from, to) { addRange(from, to, this.changes); }
+       comparePoint(from, to) { addRange(from, to, this.changes); }
+       boundChange(pos) { addRange(pos, pos, this.changes); }
+   };
+   function findChangedDeco(a, b, diff) {
+       let comp = new DecorationComparator$1;
+       RangeSet.compare(a, b, diff, comp);
+       return comp.changes;
+   }
+   function inUneditable(node, inside) {
+       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
+           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
+               return true;
+           }
+       }
+       return false;
+   }
+   function touchesComposition(changes, composition) {
+       let touched = false;
+       if (composition)
+           changes.iterChangedRanges((from, to) => {
+               if (from < composition.to && to > composition.from)
+                   touched = true;
+           });
+       return touched;
+   }
+
+   function groupAt(state, pos, bias = 1) {
+       let categorize = state.charCategorizer(pos);
+       let line = state.doc.lineAt(pos), linePos = pos - line.from;
+       if (line.length == 0)
+           return EditorSelection.cursor(pos);
+       if (linePos == 0)
+           bias = 1;
+       else if (linePos == line.length)
+           bias = -1;
+       let from = linePos, to = linePos;
+       if (bias < 0)
+           from = findClusterBreak(line.text, linePos, false);
+       else
+           to = findClusterBreak(line.text, linePos);
+       let cat = categorize(line.text.slice(from, to));
+       while (from > 0) {
+           let prev = findClusterBreak(line.text, from, false);
+           if (categorize(line.text.slice(prev, from)) != cat)
+               break;
+           from = prev;
+       }
+       while (to < line.length) {
+           let next = findClusterBreak(line.text, to);
+           if (categorize(line.text.slice(to, next)) != cat)
+               break;
+           to = next;
+       }
+       return EditorSelection.range(from + line.from, to + line.from);
+   }
+   // Search the DOM for the {node, offset} position closest to the given
+   // coordinates. Very inefficient and crude, but can usually be avoided
+   // by calling caret(Position|Range)FromPoint instead.
+   function getdx(x, rect) {
+       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
+   }
+   function getdy(y, rect) {
+       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
+   }
+   function yOverlap(a, b) {
+       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
+   }
+   function upTop(rect, top) {
+       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
+   }
+   function upBot(rect, bottom) {
+       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
+   }
+   function domPosAtCoords(parent, x, y) {
+       let closest, closestRect, closestX, closestY, closestOverlap = false;
+       let above, below, aboveRect, belowRect;
+       for (let child = parent.firstChild; child; child = child.nextSibling) {
+           let rects = clientRectsFor(child);
+           for (let i = 0; i < rects.length; i++) {
+               let rect = rects[i];
+               if (closestRect && yOverlap(closestRect, rect))
+                   rect = upTop(upBot(rect, closestRect.bottom), closestRect.top);
+               let dx = getdx(x, rect), dy = getdy(y, rect);
+               if (dx == 0 && dy == 0)
+                   return child.nodeType == 3 ? domPosInText(child, x, y) : domPosAtCoords(child, x, y);
+               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
+                   closest = child;
+                   closestRect = rect;
+                   closestX = dx;
+                   closestY = dy;
+                   let side = dy ? (y < rect.top ? -1 : 1) : dx ? (x < rect.left ? -1 : 1) : 0;
+                   closestOverlap = !side || (side > 0 ? i < rects.length - 1 : i > 0);
+               }
+               if (dx == 0) {
+                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
+                       above = child;
+                       aboveRect = rect;
+                   }
+                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
+                       below = child;
+                       belowRect = rect;
+                   }
+               }
+               else if (aboveRect && yOverlap(aboveRect, rect)) {
+                   aboveRect = upBot(aboveRect, rect.bottom);
+               }
+               else if (belowRect && yOverlap(belowRect, rect)) {
+                   belowRect = upTop(belowRect, rect.top);
+               }
+           }
+       }
+       if (aboveRect && aboveRect.bottom >= y) {
+           closest = above;
+           closestRect = aboveRect;
+       }
+       else if (belowRect && belowRect.top <= y) {
+           closest = below;
+           closestRect = belowRect;
+       }
+       if (!closest)
+           return { node: parent, offset: 0 };
+       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
+       if (closest.nodeType == 3)
+           return domPosInText(closest, clipX, y);
+       if (closestOverlap && closest.contentEditable != "false")
+           return domPosAtCoords(closest, clipX, y);
+       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
+           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
+       return { node: parent, offset };
+   }
+   function domPosInText(node, x, y) {
+       let len = node.nodeValue.length;
+       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
+       for (let i = 0; i < len; i++) {
+           let rects = textRange(node, i, i + 1).getClientRects();
+           for (let j = 0; j < rects.length; j++) {
+               let rect = rects[j];
+               if (rect.top == rect.bottom)
+                   continue;
+               if (!generalSide)
+                   generalSide = x - rect.left;
+               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
+               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
+                   let right = x >= (rect.left + rect.right) / 2, after = right;
+                   if (browser.chrome || browser.gecko) {
+                       // Check for RTL on browsers that support getting client
+                       // rects for empty ranges.
+                       let rectBefore = textRange(node, i).getBoundingClientRect();
+                       if (rectBefore.left == rect.right)
+                           after = !right;
+                   }
+                   if (dy <= 0)
+                       return { node, offset: i + (after ? 1 : 0) };
+                   closestOffset = i + (after ? 1 : 0);
+                   closestDY = dy;
+               }
+           }
+       }
+       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
+   }
+   function posAtCoords(view, coords, precise, bias = -1) {
+       var _a, _b;
+       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
+       let block, { docHeight } = view.viewState;
+       let { x, y } = coords, yOffset = y - docTop;
+       if (yOffset < 0)
+           return 0;
+       if (yOffset > docHeight)
+           return view.state.doc.length;
+       // Scan for a text block near the queried y position
+       for (let halfLine = view.viewState.heightOracle.textHeight / 2, bounced = false;;) {
+           block = view.elementAtHeight(yOffset);
+           if (block.type == BlockType.Text)
+               break;
+           for (;;) {
+               // Move the y position out of this block
+               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
+               if (yOffset >= 0 && yOffset <= docHeight)
+                   break;
+               // If the document consists entirely of replaced widgets, we
+               // won't find a text block, so return 0
+               if (bounced)
+                   return precise ? null : 0;
+               bounced = true;
+               bias = -bias;
+           }
+       }
+       y = docTop + yOffset;
+       let lineStart = block.from;
+       // If this is outside of the rendered viewport, we can't determine a position
+       if (lineStart < view.viewport.from)
+           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise(view, content, block, x, y);
+       if (lineStart > view.viewport.to)
+           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
+               precise ? null : posAtCoordsImprecise(view, content, block, x, y);
+       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
+       let doc = view.dom.ownerDocument;
+       let root = view.root.elementFromPoint ? view.root : doc;
+       let element = root.elementFromPoint(x, y);
+       if (element && !view.contentDOM.contains(element))
+           element = null;
+       // If the element is unexpected, clip x at the sides of the content area and try again
+       if (!element) {
+           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
+           element = root.elementFromPoint(x, y);
+           if (element && !view.contentDOM.contains(element))
+               element = null;
+       }
+       // There's visible editor content under the point, so we can try
+       // using caret(Position|Range)FromPoint as a shortcut
+       let node, offset = -1;
+       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
+           if (doc.caretPositionFromPoint) {
+               let pos = doc.caretPositionFromPoint(x, y);
+               if (pos)
+                   ({ offsetNode: node, offset } = pos);
+           }
+           else if (doc.caretRangeFromPoint) {
+               let range = doc.caretRangeFromPoint(x, y);
+               if (range) {
+                   ({ startContainer: node, startOffset: offset } = range);
+                   if (!view.contentDOM.contains(node) ||
+                       browser.safari && isSuspiciousSafariCaretResult(node, offset, x) ||
+                       browser.chrome && isSuspiciousChromeCaretResult(node, offset, x))
+                       node = undefined;
+               }
+           }
+           // Chrome will return offsets into <input> elements without child
+           // nodes, which will lead to a null deref below, so clip the
+           // offset to the node size.
+           if (node)
+               offset = Math.min(maxOffset(node), offset);
+       }
+       // No luck, do our own (potentially expensive) search
+       if (!node || !view.docView.dom.contains(node)) {
+           let line = LineView.find(view.docView, lineStart);
+           if (!line)
+               return yOffset > block.top + block.height / 2 ? block.to : block.from;
+           ({ node, offset } = domPosAtCoords(line.dom, x, y));
+       }
+       let nearest = view.docView.nearest(node);
+       if (!nearest)
+           return null;
+       if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {
+           let rect = nearest.dom.getBoundingClientRect();
+           return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2
+               ? nearest.posAtStart : nearest.posAtEnd;
+       }
+       else {
+           return nearest.localPosFromDOM(node, offset) + nearest.posAtStart;
+       }
+   }
+   function posAtCoordsImprecise(view, contentRect, block, x, y) {
+       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
+       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
+           let textHeight = view.viewState.heightOracle.textHeight;
+           let line = Math.floor((y - block.top - (view.defaultLineHeight - textHeight) * 0.5) / textHeight);
+           into += line * view.viewState.heightOracle.lineLength;
+       }
+       let content = view.state.sliceDoc(block.from, block.to);
+       return block.from + findColumn(content, into, view.state.tabSize);
+   }
+   // In case of a high line height, Safari's caretRangeFromPoint treats
+   // the space between lines as belonging to the last character of the
+   // line before. This is used to detect such a result so that it can be
+   // ignored (issue #401).
+   function isSuspiciousSafariCaretResult(node, offset, x) {
+       let len;
+       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
+           return false;
+       for (let next = node.nextSibling; next; next = next.nextSibling)
+           if (next.nodeType != 1 || next.nodeName != "BR")
+               return false;
+       return textRange(node, len - 1, len).getBoundingClientRect().left > x;
+   }
+   // Chrome will move positions between lines to the start of the next line
+   function isSuspiciousChromeCaretResult(node, offset, x) {
+       if (offset != 0)
+           return false;
+       for (let cur = node;;) {
+           let parent = cur.parentNode;
+           if (!parent || parent.nodeType != 1 || parent.firstChild != cur)
+               return false;
+           if (parent.classList.contains("cm-line"))
+               break;
+           cur = parent;
+       }
+       let rect = node.nodeType == 1 ? node.getBoundingClientRect()
+           : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
+       return x - rect.left > 5;
+   }
+   function blockAt(view, pos) {
+       let line = view.lineBlockAt(pos);
+       if (Array.isArray(line.type))
+           for (let l of line.type) {
+               if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))
+                   return l;
+           }
+       return line;
+   }
+   function moveToLineBoundary(view, start, forward, includeWrap) {
+       let line = blockAt(view, start.head);
+       let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
+           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
+       if (coords) {
+           let editorRect = view.dom.getBoundingClientRect();
+           let direction = view.textDirectionAt(line.from);
+           let pos = view.posAtCoords({ x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,
+               y: (coords.top + coords.bottom) / 2 });
+           if (pos != null)
+               return EditorSelection.cursor(pos, forward ? -1 : 1);
+       }
+       return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);
+   }
+   function moveByChar(view, start, forward, by) {
+       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
+       let direction = view.textDirectionAt(line.from);
+       for (let cur = start, check = null;;) {
+           let next = moveVisually(line, spans, direction, cur, forward), char = movedOver;
+           if (!next) {
+               if (line.number == (forward ? view.state.doc.lines : 1))
+                   return cur;
+               char = "\n";
+               line = view.state.doc.line(line.number + (forward ? 1 : -1));
+               spans = view.bidiSpans(line);
+               next = view.visualLineSide(line, !forward);
+           }
+           if (!check) {
+               if (!by)
+                   return next;
+               check = by(char);
+           }
+           else if (!check(char)) {
+               return cur;
+           }
+           cur = next;
+       }
+   }
+   function byGroup(view, pos, start) {
+       let categorize = view.state.charCategorizer(pos);
+       let cat = categorize(start);
+       return (next) => {
+           let nextCat = categorize(next);
+           if (cat == CharCategory.Space)
+               cat = nextCat;
+           return cat == nextCat;
+       };
+   }
+   function moveVertically(view, start, forward, distance) {
+       let startPos = start.head, dir = forward ? 1 : -1;
+       if (startPos == (forward ? view.state.doc.length : 0))
+           return EditorSelection.cursor(startPos, start.assoc);
+       let goal = start.goalColumn, startY;
+       let rect = view.contentDOM.getBoundingClientRect();
+       let startCoords = view.coordsAtPos(startPos, start.assoc || -1), docTop = view.documentTop;
+       if (startCoords) {
+           if (goal == null)
+               goal = startCoords.left - rect.left;
+           startY = dir < 0 ? startCoords.top : startCoords.bottom;
+       }
+       else {
+           let line = view.viewState.lineBlockAt(startPos);
+           if (goal == null)
+               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
+           startY = (dir < 0 ? line.top : line.bottom) + docTop;
+       }
+       let resolvedGoal = rect.left + goal;
+       let dist = distance !== null && distance !== void 0 ? distance : (view.viewState.heightOracle.textHeight >> 1);
+       for (let extra = 0;; extra += 10) {
+           let curY = startY + (dist + extra) * dir;
+           let pos = posAtCoords(view, { x: resolvedGoal, y: curY }, false, dir);
+           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos)) {
+               let charRect = view.docView.coordsForChar(pos);
+               let assoc = !charRect || curY < charRect.top ? -1 : 1;
+               return EditorSelection.cursor(pos, assoc, undefined, goal);
+           }
+       }
+   }
+   function skipAtomicRanges(atoms, pos, bias) {
+       for (;;) {
+           let moved = 0;
+           for (let set of atoms) {
+               set.between(pos - 1, pos + 1, (from, to, value) => {
+                   if (pos > from && pos < to) {
+                       let side = moved || bias || (pos - from < to - pos ? -1 : 1);
+                       pos = side < 0 ? from : to;
+                       moved = side;
+                   }
+               });
+           }
+           if (!moved)
+               return pos;
+       }
+   }
+   function skipAtoms(view, oldPos, pos) {
+       let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);
+       return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);
+   }
+
+   const LineBreakPlaceholder = "\uffff";
+   class DOMReader {
+       constructor(points, state) {
+           this.points = points;
+           this.text = "";
+           this.lineSeparator = state.facet(EditorState.lineSeparator);
+       }
+       append(text) {
+           this.text += text;
+       }
+       lineBreak() {
+           this.text += LineBreakPlaceholder;
+       }
+       readRange(start, end) {
+           if (!start)
+               return this;
+           let parent = start.parentNode;
+           for (let cur = start;;) {
+               this.findPointBefore(parent, cur);
+               let oldLen = this.text.length;
+               this.readNode(cur);
+               let next = cur.nextSibling;
+               if (next == end)
+                   break;
+               let view = ContentView.get(cur), nextView = ContentView.get(next);
+               if (view && nextView ? view.breakAfter :
+                   (view ? view.breakAfter : isBlockElement(cur)) ||
+                       (isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore) && this.text.length > oldLen))
+                   this.lineBreak();
+               cur = next;
+           }
+           this.findPointBefore(parent, end);
+           return this;
+       }
+       readTextNode(node) {
+           let text = node.nodeValue;
+           for (let point of this.points)
+               if (point.node == node)
+                   point.pos = this.text.length + Math.min(point.offset, text.length);
+           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
+               let nextBreak = -1, breakSize = 1, m;
+               if (this.lineSeparator) {
+                   nextBreak = text.indexOf(this.lineSeparator, off);
+                   breakSize = this.lineSeparator.length;
+               }
+               else if (m = re.exec(text)) {
+                   nextBreak = m.index;
+                   breakSize = m[0].length;
+               }
+               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
+               if (nextBreak < 0)
+                   break;
+               this.lineBreak();
+               if (breakSize > 1)
+                   for (let point of this.points)
+                       if (point.node == node && point.pos > this.text.length)
+                           point.pos -= breakSize - 1;
+               off = nextBreak + breakSize;
+           }
+       }
+       readNode(node) {
+           if (node.cmIgnore)
+               return;
+           let view = ContentView.get(node);
+           let fromView = view && view.overrideDOMText;
+           if (fromView != null) {
+               this.findPointInside(node, fromView.length);
+               for (let i = fromView.iter(); !i.next().done;) {
+                   if (i.lineBreak)
+                       this.lineBreak();
+                   else
+                       this.append(i.value);
+               }
+           }
+           else if (node.nodeType == 3) {
+               this.readTextNode(node);
+           }
+           else if (node.nodeName == "BR") {
+               if (node.nextSibling)
+                   this.lineBreak();
+           }
+           else if (node.nodeType == 1) {
+               this.readRange(node.firstChild, null);
+           }
+       }
+       findPointBefore(node, next) {
+           for (let point of this.points)
+               if (point.node == node && node.childNodes[point.offset] == next)
+                   point.pos = this.text.length;
+       }
+       findPointInside(node, length) {
+           for (let point of this.points)
+               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
+                   point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);
+       }
+   }
+   function isAtEnd(parent, node, offset) {
+       for (;;) {
+           if (!node || offset < maxOffset(node))
+               return false;
+           if (node == parent)
+               return true;
+           offset = domIndex(node) + 1;
+           node = node.parentNode;
+       }
+   }
+   class DOMPoint {
+       constructor(node, offset) {
+           this.node = node;
+           this.offset = offset;
+           this.pos = -1;
+       }
+   }
+
+   class DOMChange {
+       constructor(view, start, end, typeOver) {
+           this.typeOver = typeOver;
+           this.bounds = null;
+           this.text = "";
+           this.domChanged = start > -1;
+           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
+           if (view.state.readOnly && start > -1) {
+               // Ignore changes when the editor is read-only
+               this.newSel = null;
+           }
+           else if (start > -1 && (this.bounds = view.docView.domBoundsAround(start, end, 0))) {
+               let selPoints = iHead || iAnchor ? [] : selectionPoints(view);
+               let reader = new DOMReader(selPoints, view.state);
+               reader.readRange(this.bounds.startDOM, this.bounds.endDOM);
+               this.text = reader.text;
+               this.newSel = selectionFromPoints(selPoints, this.bounds.from);
+           }
+           else {
+               let domSel = view.observer.selectionRange;
+               let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
+                   !contains(view.contentDOM, domSel.focusNode)
+                   ? view.state.selection.main.head
+                   : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
+               let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
+                   !contains(view.contentDOM, domSel.anchorNode)
+                   ? view.state.selection.main.anchor
+                   : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
+               // iOS will refuse to select the block gaps when doing
+               // select-all.
+               // Chrome will put the selection *inside* them, confusing
+               // posFromDOM
+               let vp = view.viewport;
+               if ((browser.ios || browser.chrome) && view.state.selection.main.empty && head != anchor &&
+                   (vp.from > 0 || vp.to < view.state.doc.length)) {
+                   let from = Math.min(head, anchor), to = Math.max(head, anchor);
+                   let offFrom = vp.from - from, offTo = vp.to - to;
+                   if ((offFrom == 0 || offFrom == 1 || from == 0) && (offTo == 0 || offTo == -1 || to == view.state.doc.length)) {
+                       head = 0;
+                       anchor = view.state.doc.length;
+                   }
+               }
+               this.newSel = EditorSelection.single(anchor, head);
+           }
+       }
+   }
+   function applyDOMChange(view, domChange) {
+       let change;
+       let { newSel } = domChange, sel = view.state.selection.main;
+       let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;
+       if (domChange.bounds) {
+           let { from, to } = domChange.bounds;
+           let preferredPos = sel.from, preferredSide = null;
+           // Prefer anchoring to end when Backspace is pressed (or, on
+           // Android, when something was deleted)
+           if (lastKey === 8 || browser.android && domChange.text.length < to - from) {
+               preferredPos = sel.to;
+               preferredSide = "end";
+           }
+           let diff = findDiff(view.state.doc.sliceString(from, to, LineBreakPlaceholder), domChange.text, preferredPos - from, preferredSide);
+           if (diff) {
+               // Chrome inserts two newlines when pressing shift-enter at the
+               // end of a line. DomChange drops one of those.
+               if (browser.chrome && lastKey == 13 &&
+                   diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)
+                   diff.toB--;
+               change = { from: from + diff.from, to: from + diff.toA,
+                   insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
+           }
+       }
+       else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
+           newSel = null;
+       }
+       if (!change && !newSel)
+           return false;
+       if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {
+           // Heuristic to notice typing over a selected character
+           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
+       }
+       else if (change && change.from >= sel.from && change.to <= sel.to &&
+           (change.from != sel.from || change.to != sel.to) &&
+           (sel.to - sel.from) - (change.to - change.from) <= 4) {
+           // If the change is inside the selection and covers most of it,
+           // assume it is a selection replace (with identical characters at
+           // the start/end not included in the diff)
+           change = {
+               from: sel.from, to: sel.to,
+               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
+           };
+       }
+       else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&
+           /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
+           // Detect insert-period-on-double-space Mac and Android behavior,
+           // and transform it into a regular space insert.
+           if (newSel && change.insert.length == 2)
+               newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
+           change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
+       }
+       else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&
+           change.insert.toString() == "\n " && view.lineWrapping) {
+           // In Chrome, if you insert a space at the start of a wrapped
+           // line, it will actually insert a newline and a space, causing a
+           // bogus new line to be created in CodeMirror (#968)
+           if (newSel)
+               newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
+           change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
+       }
+       if (change) {
+           return applyDOMChangeInner(view, change, newSel, lastKey);
+       }
+       else if (newSel && !newSel.main.eq(sel)) {
+           let scrollIntoView = false, userEvent = "select";
+           if (view.inputState.lastSelectionTime > Date.now() - 50) {
+               if (view.inputState.lastSelectionOrigin == "select")
+                   scrollIntoView = true;
+               userEvent = view.inputState.lastSelectionOrigin;
+           }
+           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
+           return true;
+       }
+       else {
+           return false;
+       }
+   }
+   function applyDOMChangeInner(view, change, newSel, lastKey = -1) {
+       if (browser.ios && view.inputState.flushIOSKey(change))
+           return true;
+       let sel = view.state.selection.main;
+       // Android browsers don't fire reasonable key events for enter,
+       // backspace, or delete. So this detects changes that look like
+       // they're caused by those keys, and reinterprets them as key
+       // events. (Some of these keys are also handled by beforeinput
+       // events and the pendingAndroidKey mechanism, but that's not
+       // reliable in all situations.)
+       if (browser.android &&
+           ((change.to == sel.to &&
+               // GBoard will sometimes remove a space it just inserted
+               // after a completion when you press enter
+               (change.from == sel.from || change.from == sel.from - 1 && view.state.sliceDoc(change.from, sel.from) == " ") &&
+               change.insert.length == 1 && change.insert.lines == 2 &&
+               dispatchKey(view.contentDOM, "Enter", 13)) ||
+               ((change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 ||
+                   lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) &&
+                   dispatchKey(view.contentDOM, "Backspace", 8)) ||
+               (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
+                   dispatchKey(view.contentDOM, "Delete", 46))))
+           return true;
+       let text = change.insert.toString();
+       if (view.inputState.composing >= 0)
+           view.inputState.composing++;
+       let defaultTr;
+       let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));
+       if (!view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text, defaultInsert)))
+           view.dispatch(defaultInsert());
+       return true;
+   }
+   function applyDefaultInsert(view, change, newSel) {
+       let tr, startState = view.state, sel = startState.selection.main;
+       if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
+           (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
+           view.inputState.composing < 0) {
+           let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
+           let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
+           tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
+       }
+       else {
+           let changes = startState.changes(change);
+           let mainSel = newSel && newSel.main.to <= changes.newLength ? newSel.main : undefined;
+           // Try to apply a composition change to all cursors
+           if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
+               change.to <= sel.to && change.to >= sel.to - 10) {
+               let replaced = view.state.sliceDoc(change.from, change.to);
+               let compositionRange, composition = newSel && findCompositionNode(view, newSel.main.head);
+               if (composition) {
+                   let dLen = change.insert.length - (change.to - change.from);
+                   compositionRange = { from: composition.from, to: composition.to - dLen };
+               }
+               else {
+                   compositionRange = view.state.doc.lineAt(sel.head);
+               }
+               let offset = sel.to - change.to, size = sel.to - sel.from;
+               tr = startState.changeByRange(range => {
+                   if (range.from == sel.from && range.to == sel.to)
+                       return { changes, range: mainSel || range.map(changes) };
+                   let to = range.to - offset, from = to - replaced.length;
+                   if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
+                       // Unfortunately, there's no way to make multiple
+                       // changes in the same node work without aborting
+                       // composition, so cursors in the composition range are
+                       // ignored.
+                       range.to >= compositionRange.from && range.from <= compositionRange.to)
+                       return { range };
+                   let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
+                   return {
+                       changes: rangeChanges,
+                       range: !mainSel ? range.map(rangeChanges) :
+                           EditorSelection.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
+                   };
+               });
+           }
+           else {
+               tr = {
+                   changes,
+                   selection: mainSel && startState.selection.replaceRange(mainSel)
+               };
+           }
+       }
+       let userEvent = "input.type";
+       if (view.composing ||
+           view.inputState.compositionPendingChange && view.inputState.compositionEndedAt > Date.now() - 50) {
+           view.inputState.compositionPendingChange = false;
+           userEvent += ".compose";
+           if (view.inputState.compositionFirstChange) {
+               userEvent += ".start";
+               view.inputState.compositionFirstChange = false;
+           }
+       }
+       return startState.update(tr, { userEvent, scrollIntoView: true });
+   }
+   function findDiff(a, b, preferredPos, preferredSide) {
+       let minLen = Math.min(a.length, b.length);
+       let from = 0;
+       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
+           from++;
+       if (from == minLen && a.length == b.length)
+           return null;
+       let toA = a.length, toB = b.length;
+       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
+           toA--;
+           toB--;
+       }
+       if (preferredSide == "end") {
+           let adjust = Math.max(0, from - Math.min(toA, toB));
+           preferredPos -= toA + adjust - from;
+       }
+       if (toA < from && a.length < b.length) {
+           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
+           from -= move;
+           toB = from + (toB - toA);
+           toA = from;
+       }
+       else if (toB < from) {
+           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
+           from -= move;
+           toA = from + (toA - toB);
+           toB = from;
+       }
+       return { from, toA, toB };
+   }
+   function selectionPoints(view) {
+       let result = [];
+       if (view.root.activeElement != view.contentDOM)
+           return result;
+       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
+       if (anchorNode) {
+           result.push(new DOMPoint(anchorNode, anchorOffset));
+           if (focusNode != anchorNode || focusOffset != anchorOffset)
+               result.push(new DOMPoint(focusNode, focusOffset));
+       }
+       return result;
+   }
+   function selectionFromPoints(points, base) {
+       if (points.length == 0)
+           return null;
+       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
+       return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;
+   }
+
+   class InputState {
+       setSelectionOrigin(origin) {
+           this.lastSelectionOrigin = origin;
+           this.lastSelectionTime = Date.now();
+       }
+       constructor(view) {
+           this.view = view;
+           this.lastKeyCode = 0;
+           this.lastKeyTime = 0;
+           this.lastTouchTime = 0;
+           this.lastFocusTime = 0;
+           this.lastScrollTop = 0;
+           this.lastScrollLeft = 0;
+           // On iOS, some keys need to have their default behavior happen
+           // (after which we retroactively handle them and reset the DOM) to
+           // avoid messing up the virtual keyboard state.
+           this.pendingIOSKey = undefined;
+           /**
+           When enabled (>-1), tab presses are not given to key handlers,
+           leaving the browser's default behavior. If >0, the mode expires
+           at that timestamp, and any other keypress clears it.
+           Esc enables temporary tab focus mode for two seconds when not
+           otherwise handled.
+           */
+           this.tabFocusMode = -1;
+           this.lastSelectionOrigin = null;
+           this.lastSelectionTime = 0;
+           this.lastContextMenu = 0;
+           this.scrollHandlers = [];
+           this.handlers = Object.create(null);
+           // -1 means not in a composition. Otherwise, this counts the number
+           // of changes made during the composition. The count is used to
+           // avoid treating the start state of the composition, before any
+           // changes have been made, as part of the composition.
+           this.composing = -1;
+           // Tracks whether the next change should be marked as starting the
+           // composition (null means no composition, true means next is the
+           // first, false means first has already been marked for this
+           // composition)
+           this.compositionFirstChange = null;
+           // End time of the previous composition
+           this.compositionEndedAt = 0;
+           // Used in a kludge to detect when an Enter keypress should be
+           // considered part of the composition on Safari, which fires events
+           // in the wrong order
+           this.compositionPendingKey = false;
+           // Used to categorize changes as part of a composition, even when
+           // the mutation events fire shortly after the compositionend event
+           this.compositionPendingChange = false;
+           this.mouseSelection = null;
+           // When a drag from the editor is active, this points at the range
+           // being dragged.
+           this.draggedContent = null;
+           this.handleEvent = this.handleEvent.bind(this);
+           this.notifiedFocused = view.hasFocus;
+           // On Safari adding an input event handler somehow prevents an
+           // issue where the composition vanishes when you press enter.
+           if (browser.safari)
+               view.contentDOM.addEventListener("input", () => null);
+           if (browser.gecko)
+               firefoxCopyCutHack(view.contentDOM.ownerDocument);
+       }
+       handleEvent(event) {
+           if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event))
+               return;
+           if (event.type == "keydown" && this.keydown(event))
+               return;
+           this.runHandlers(event.type, event);
+       }
+       runHandlers(type, event) {
+           let handlers = this.handlers[type];
+           if (handlers) {
+               for (let observer of handlers.observers)
+                   observer(this.view, event);
+               for (let handler of handlers.handlers) {
+                   if (event.defaultPrevented)
+                       break;
+                   if (handler(this.view, event)) {
+                       event.preventDefault();
+                       break;
+                   }
+               }
+           }
+       }
+       ensureHandlers(plugins) {
+           let handlers = computeHandlers(plugins), prev = this.handlers, dom = this.view.contentDOM;
+           for (let type in handlers)
+               if (type != "scroll") {
+                   let passive = !handlers[type].handlers.length;
+                   let exists = prev[type];
+                   if (exists && passive != !exists.handlers.length) {
+                       dom.removeEventListener(type, this.handleEvent);
+                       exists = null;
+                   }
+                   if (!exists)
+                       dom.addEventListener(type, this.handleEvent, { passive });
+               }
+           for (let type in prev)
+               if (type != "scroll" && !handlers[type])
+                   dom.removeEventListener(type, this.handleEvent);
+           this.handlers = handlers;
+       }
+       keydown(event) {
+           // Must always run, even if a custom handler handled the event
+           this.lastKeyCode = event.keyCode;
+           this.lastKeyTime = Date.now();
+           if (event.keyCode == 9 && this.tabFocusMode > -1 && (!this.tabFocusMode || Date.now() <= this.tabFocusMode))
+               return true;
+           if (this.tabFocusMode > 0 && event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)
+               this.tabFocusMode = -1;
+           // Chrome for Android usually doesn't fire proper key events, but
+           // occasionally does, usually surrounded by a bunch of complicated
+           // composition changes. When an enter or backspace key event is
+           // seen, hold off on handling DOM events for a bit, and then
+           // dispatch it.
+           if (browser.android && browser.chrome && !event.synthetic &&
+               (event.keyCode == 13 || event.keyCode == 8)) {
+               this.view.observer.delayAndroidKey(event.key, event.keyCode);
+               return true;
+           }
+           // Preventing the default behavior of Enter on iOS makes the
+           // virtual keyboard get stuck in the wrong (lowercase)
+           // state. So we let it go through, and then, in
+           // applyDOMChange, notify key handlers of it and reset to
+           // the state they produce.
+           let pending;
+           if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&
+               ((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||
+                   EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {
+               this.pendingIOSKey = pending || event;
+               setTimeout(() => this.flushIOSKey(), 250);
+               return true;
+           }
+           if (event.keyCode != 229)
+               this.view.observer.forceFlush();
+           return false;
+       }
+       flushIOSKey(change) {
+           let key = this.pendingIOSKey;
+           if (!key)
+               return false;
+           // This looks like an autocorrection before Enter
+           if (key.key == "Enter" && change && change.from < change.to && /^\S+$/.test(change.insert.toString()))
+               return false;
+           this.pendingIOSKey = undefined;
+           return dispatchKey(this.view.contentDOM, key.key, key.keyCode, key instanceof KeyboardEvent ? key : undefined);
+       }
+       ignoreDuringComposition(event) {
+           if (!/^key/.test(event.type))
+               return false;
+           if (this.composing > 0)
+               return true;
+           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
+           // On some input method editors (IMEs), the Enter key is used to
+           // confirm character selection. On Safari, when Enter is pressed,
+           // compositionend and keydown events are sometimes emitted in the
+           // wrong order. The key event should still be ignored, even when
+           // it happens after the compositionend event.
+           if (browser.safari && !browser.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100) {
+               this.compositionPendingKey = false;
+               return true;
+           }
+           return false;
+       }
+       startMouseSelection(mouseSelection) {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+           this.mouseSelection = mouseSelection;
+       }
+       update(update) {
+           this.view.observer.update(update);
+           if (this.mouseSelection)
+               this.mouseSelection.update(update);
+           if (this.draggedContent && update.docChanged)
+               this.draggedContent = this.draggedContent.map(update.changes);
+           if (update.transactions.length)
+               this.lastKeyCode = this.lastSelectionTime = 0;
+       }
+       destroy() {
+           if (this.mouseSelection)
+               this.mouseSelection.destroy();
+       }
+   }
+   function bindHandler(plugin, handler) {
+       return (view, event) => {
+           try {
+               return handler.call(plugin, event, view);
+           }
+           catch (e) {
+               logException(view.state, e);
+           }
+       };
+   }
+   function computeHandlers(plugins) {
+       let result = Object.create(null);
+       function record(type) {
+           return result[type] || (result[type] = { observers: [], handlers: [] });
+       }
+       for (let plugin of plugins) {
+           let spec = plugin.spec;
+           if (spec && spec.domEventHandlers)
+               for (let type in spec.domEventHandlers) {
+                   let f = spec.domEventHandlers[type];
+                   if (f)
+                       record(type).handlers.push(bindHandler(plugin.value, f));
+               }
+           if (spec && spec.domEventObservers)
+               for (let type in spec.domEventObservers) {
+                   let f = spec.domEventObservers[type];
+                   if (f)
+                       record(type).observers.push(bindHandler(plugin.value, f));
+               }
+       }
+       for (let type in handlers)
+           record(type).handlers.push(handlers[type]);
+       for (let type in observers)
+           record(type).observers.push(observers[type]);
+       return result;
+   }
+   const PendingKeys = [
+       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
+       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
+       { key: "Enter", keyCode: 13, inputType: "insertLineBreak" },
+       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
+   ];
+   const EmacsyPendingKeys = "dthko";
+   // Key codes for modifier keys
+   const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
+   const dragScrollMargin = 6;
+   function dragScrollSpeed(dist) {
+       return Math.max(0, dist) * 0.7 + 8;
+   }
+   function dist(a, b) {
+       return Math.max(Math.abs(a.clientX - b.clientX), Math.abs(a.clientY - b.clientY));
+   }
+   class MouseSelection {
+       constructor(view, startEvent, style, mustSelect) {
+           this.view = view;
+           this.startEvent = startEvent;
+           this.style = style;
+           this.mustSelect = mustSelect;
+           this.scrollSpeed = { x: 0, y: 0 };
+           this.scrolling = -1;
+           this.lastEvent = startEvent;
+           this.scrollParents = scrollableParents(view.contentDOM);
+           this.atoms = view.state.facet(atomicRanges).map(f => f(view));
+           let doc = view.contentDOM.ownerDocument;
+           doc.addEventListener("mousemove", this.move = this.move.bind(this));
+           doc.addEventListener("mouseup", this.up = this.up.bind(this));
+           this.extend = startEvent.shiftKey;
+           this.multiple = view.state.facet(EditorState.allowMultipleSelections) && addsSelectionRange(view, startEvent);
+           this.dragging = isInPrimarySelection(view, startEvent) && getClickType(startEvent) == 1 ? null : false;
+       }
+       start(event) {
+           // When clicking outside of the selection, immediately apply the
+           // effect of starting the selection
+           if (this.dragging === false)
+               this.select(event);
+       }
+       move(event) {
+           if (event.buttons == 0)
+               return this.destroy();
+           if (this.dragging || this.dragging == null && dist(this.startEvent, event) < 10)
+               return;
+           this.select(this.lastEvent = event);
+           let sx = 0, sy = 0;
+           let left = 0, top = 0, right = this.view.win.innerWidth, bottom = this.view.win.innerHeight;
+           if (this.scrollParents.x)
+               ({ left, right } = this.scrollParents.x.getBoundingClientRect());
+           if (this.scrollParents.y)
+               ({ top, bottom } = this.scrollParents.y.getBoundingClientRect());
+           let margins = getScrollMargins(this.view);
+           if (event.clientX - margins.left <= left + dragScrollMargin)
+               sx = -dragScrollSpeed(left - event.clientX);
+           else if (event.clientX + margins.right >= right - dragScrollMargin)
+               sx = dragScrollSpeed(event.clientX - right);
+           if (event.clientY - margins.top <= top + dragScrollMargin)
+               sy = -dragScrollSpeed(top - event.clientY);
+           else if (event.clientY + margins.bottom >= bottom - dragScrollMargin)
+               sy = dragScrollSpeed(event.clientY - bottom);
+           this.setScrollSpeed(sx, sy);
+       }
+       up(event) {
+           if (this.dragging == null)
+               this.select(this.lastEvent);
+           if (!this.dragging)
+               event.preventDefault();
+           this.destroy();
+       }
+       destroy() {
+           this.setScrollSpeed(0, 0);
+           let doc = this.view.contentDOM.ownerDocument;
+           doc.removeEventListener("mousemove", this.move);
+           doc.removeEventListener("mouseup", this.up);
+           this.view.inputState.mouseSelection = this.view.inputState.draggedContent = null;
+       }
+       setScrollSpeed(sx, sy) {
+           this.scrollSpeed = { x: sx, y: sy };
+           if (sx || sy) {
+               if (this.scrolling < 0)
+                   this.scrolling = setInterval(() => this.scroll(), 50);
+           }
+           else if (this.scrolling > -1) {
+               clearInterval(this.scrolling);
+               this.scrolling = -1;
+           }
+       }
+       scroll() {
+           let { x, y } = this.scrollSpeed;
+           if (x && this.scrollParents.x) {
+               this.scrollParents.x.scrollLeft += x;
+               x = 0;
+           }
+           if (y && this.scrollParents.y) {
+               this.scrollParents.y.scrollTop += y;
+               y = 0;
+           }
+           if (x || y)
+               this.view.win.scrollBy(x, y);
+           if (this.dragging === false)
+               this.select(this.lastEvent);
+       }
+       skipAtoms(sel) {
+           let ranges = null;
+           for (let i = 0; i < sel.ranges.length; i++) {
+               let range = sel.ranges[i], updated = null;
+               if (range.empty) {
+                   let pos = skipAtomicRanges(this.atoms, range.from, 0);
+                   if (pos != range.from)
+                       updated = EditorSelection.cursor(pos, -1);
+               }
+               else {
+                   let from = skipAtomicRanges(this.atoms, range.from, -1);
+                   let to = skipAtomicRanges(this.atoms, range.to, 1);
+                   if (from != range.from || to != range.to)
+                       updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
+               }
+               if (updated) {
+                   if (!ranges)
+                       ranges = sel.ranges.slice();
+                   ranges[i] = updated;
+               }
+           }
+           return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;
+       }
+       select(event) {
+           let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
+           if (this.mustSelect || !selection.eq(view.state.selection, this.dragging === false))
+               this.view.dispatch({
+                   selection,
+                   userEvent: "select.pointer"
+               });
+           this.mustSelect = false;
+       }
+       update(update) {
+           if (update.transactions.some(tr => tr.isUserEvent("input.type")))
+               this.destroy();
+           else if (this.style.update(update))
+               setTimeout(() => this.select(this.lastEvent), 20);
+       }
+   }
+   function addsSelectionRange(view, event) {
+       let facet = view.state.facet(clickAddsSelectionRange);
+       return facet.length ? facet[0](event) : browser.mac ? event.metaKey : event.ctrlKey;
+   }
+   function dragMovesSelection(view, event) {
+       let facet = view.state.facet(dragMovesSelection$1);
+       return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;
+   }
+   function isInPrimarySelection(view, event) {
+       let { main } = view.state.selection;
+       if (main.empty)
+           return false;
+       // On boundary clicks, check whether the coordinates are inside the
+       // selection's client rectangles
+       let sel = getSelection(view.root);
+       if (!sel || sel.rangeCount == 0)
+           return true;
+       let rects = sel.getRangeAt(0).getClientRects();
+       for (let i = 0; i < rects.length; i++) {
+           let rect = rects[i];
+           if (rect.left <= event.clientX && rect.right >= event.clientX &&
+               rect.top <= event.clientY && rect.bottom >= event.clientY)
+               return true;
+       }
+       return false;
+   }
+   function eventBelongsToEditor(view, event) {
+       if (!event.bubbles)
+           return true;
+       if (event.defaultPrevented)
+           return false;
+       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
+           if (!node || node.nodeType == 11 || ((cView = ContentView.get(node)) && cView.ignoreEvent(event)))
+               return false;
+       return true;
+   }
+   const handlers = /*@__PURE__*/Object.create(null);
+   const observers = /*@__PURE__*/Object.create(null);
+   // This is very crude, but unfortunately both these browsers _pretend_
+   // that they have a clipboard API—all the objects and methods are
+   // there, they just don't work, and they are hard to test.
+   const brokenClipboardAPI = (browser.ie && browser.ie_version < 15) ||
+       (browser.ios && browser.webkit_version < 604);
+   function capturePaste(view) {
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.focus();
+       setTimeout(() => {
+           view.focus();
+           target.remove();
+           doPaste(view, target.value);
+       }, 50);
+   }
+   function textFilter(state, facet, text) {
+       for (let filter of state.facet(facet))
+           text = filter(text, state);
+       return text;
+   }
+   function doPaste(view, input) {
+       input = textFilter(view.state, clipboardInputFilter, input);
+       let { state } = view, changes, i = 1, text = state.toText(input);
+       let byLine = text.lines == state.selection.ranges.length;
+       let linewise = lastLinewiseCopy != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy == text.toString();
+       if (linewise) {
+           let lastLine = -1;
+           changes = state.changeByRange(range => {
+               let line = state.doc.lineAt(range.from);
+               if (line.from == lastLine)
+                   return { range };
+               lastLine = line.from;
+               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
+               return { changes: { from: line.from, insert },
+                   range: EditorSelection.cursor(range.from + insert.length) };
+           });
+       }
+       else if (byLine) {
+           changes = state.changeByRange(range => {
+               let line = text.line(i++);
+               return { changes: { from: range.from, to: range.to, insert: line.text },
+                   range: EditorSelection.cursor(range.from + line.length) };
+           });
+       }
+       else {
+           changes = state.replaceSelection(text);
+       }
+       view.dispatch(changes, {
+           userEvent: "input.paste",
+           scrollIntoView: true
+       });
+   }
+   observers.scroll = view => {
+       view.inputState.lastScrollTop = view.scrollDOM.scrollTop;
+       view.inputState.lastScrollLeft = view.scrollDOM.scrollLeft;
+   };
+   handlers.keydown = (view, event) => {
+       view.inputState.setSelectionOrigin("select");
+       if (event.keyCode == 27 && view.inputState.tabFocusMode != 0)
+           view.inputState.tabFocusMode = Date.now() + 2000;
+       return false;
+   };
+   observers.touchstart = (view, e) => {
+       view.inputState.lastTouchTime = Date.now();
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   observers.touchmove = view => {
+       view.inputState.setSelectionOrigin("select.pointer");
+   };
+   handlers.mousedown = (view, event) => {
+       view.observer.flush();
+       if (view.inputState.lastTouchTime > Date.now() - 2000)
+           return false; // Ignore touch interaction
+       let style = null;
+       for (let makeStyle of view.state.facet(mouseSelectionStyle)) {
+           style = makeStyle(view, event);
+           if (style)
+               break;
+       }
+       if (!style && event.button == 0)
+           style = basicMouseSelection(view, event);
+       if (style) {
+           let mustFocus = !view.hasFocus;
+           view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));
+           if (mustFocus)
+               view.observer.ignore(() => {
+                   focusPreventScroll(view.contentDOM);
+                   let active = view.root.activeElement;
+                   if (active && !active.contains(view.contentDOM))
+                       active.blur();
+               });
+           let mouseSel = view.inputState.mouseSelection;
+           if (mouseSel) {
+               mouseSel.start(event);
+               return mouseSel.dragging === false;
+           }
+       }
+       return false;
+   };
+   function rangeForClick(view, pos, bias, type) {
+       if (type == 1) { // Single click
+           return EditorSelection.cursor(pos, bias);
+       }
+       else if (type == 2) { // Double click
+           return groupAt(view.state, pos, bias);
+       }
+       else { // Triple click
+           let visual = LineView.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
+           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
+           if (to < view.state.doc.length && to == line.to)
+               to++;
+           return EditorSelection.range(from, to);
+       }
+   }
+   let inside = (x, y, rect) => y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;
+   // Try to determine, for the given coordinates, associated with the
+   // given position, whether they are related to the element before or
+   // the element after the position.
+   function findPositionSide(view, pos, x, y) {
+       let line = LineView.find(view.docView, pos);
+       if (!line)
+           return 1;
+       let off = pos - line.posAtStart;
+       // Line boundaries point into the line
+       if (off == 0)
+           return 1;
+       if (off == line.length)
+           return -1;
+       // Positions on top of an element point at that element
+       let before = line.coordsAt(off, -1);
+       if (before && inside(x, y, before))
+           return -1;
+       let after = line.coordsAt(off, 1);
+       if (after && inside(x, y, after))
+           return 1;
+       // This is probably a line wrap point. Pick before if the point is
+       // above its bottom.
+       return before && before.bottom >= y ? -1 : 1;
+   }
+   function queryPos(view, event) {
+       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };
+   }
+   const BadMouseDetail = browser.ie && browser.ie_version <= 11;
+   let lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;
+   function getClickType(event) {
+       if (!BadMouseDetail)
+           return event.detail;
+       let last = lastMouseDown, lastTime = lastMouseDownTime;
+       lastMouseDown = event;
+       lastMouseDownTime = Date.now();
+       return lastMouseDownCount = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
+           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;
+   }
+   function basicMouseSelection(view, event) {
+       let start = queryPos(view, event), type = getClickType(event);
+       let startSel = view.state.selection;
+       return {
+           update(update) {
+               if (update.docChanged) {
+                   start.pos = update.changes.mapPos(start.pos);
+                   startSel = startSel.map(update.changes);
+               }
+           },
+           get(event, extend, multiple) {
+               let cur = queryPos(view, event), removed;
+               let range = rangeForClick(view, cur.pos, cur.bias, type);
+               if (start.pos != cur.pos && !extend) {
+                   let startRange = rangeForClick(view, start.pos, start.bias, type);
+                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
+                   range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);
+               }
+               if (extend)
+                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
+               else if (multiple && type == 1 && startSel.ranges.length > 1 && (removed = removeRangeAround(startSel, cur.pos)))
+                   return removed;
+               else if (multiple)
+                   return startSel.addRange(range);
+               else
+                   return EditorSelection.create([range]);
+           }
+       };
+   }
+   function removeRangeAround(sel, pos) {
+       for (let i = 0; i < sel.ranges.length; i++) {
+           let { from, to } = sel.ranges[i];
+           if (from <= pos && to >= pos)
+               return EditorSelection.create(sel.ranges.slice(0, i).concat(sel.ranges.slice(i + 1)), sel.mainIndex == i ? 0 : sel.mainIndex - (sel.mainIndex > i ? 1 : 0));
+       }
+       return null;
+   }
+   handlers.dragstart = (view, event) => {
+       let { selection: { main: range } } = view.state;
+       if (event.target.draggable) {
+           let cView = view.docView.nearest(event.target);
+           if (cView && cView.isWidget) {
+               let from = cView.posAtStart, to = from + cView.length;
+               if (from >= range.to || to <= range.from)
+                   range = EditorSelection.range(from, to);
+           }
+       }
+       let { inputState } = view;
+       if (inputState.mouseSelection)
+           inputState.mouseSelection.dragging = true;
+       inputState.draggedContent = range;
+       if (event.dataTransfer) {
+           event.dataTransfer.setData("Text", textFilter(view.state, clipboardOutputFilter, view.state.sliceDoc(range.from, range.to)));
+           event.dataTransfer.effectAllowed = "copyMove";
+       }
+       return false;
+   };
+   handlers.dragend = view => {
+       view.inputState.draggedContent = null;
+       return false;
+   };
+   function dropText(view, event, text, direct) {
+       text = textFilter(view.state, clipboardInputFilter, text);
+       if (!text)
+           return;
+       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
+       let { draggedContent } = view.inputState;
+       let del = direct && draggedContent && dragMovesSelection(view, event)
+           ? { from: draggedContent.from, to: draggedContent.to } : null;
+       let ins = { from: dropPos, insert: text };
+       let changes = view.state.changes(del ? [del, ins] : ins);
+       view.focus();
+       view.dispatch({
+           changes,
+           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
+           userEvent: del ? "move.drop" : "input.drop"
+       });
+       view.inputState.draggedContent = null;
+   }
+   handlers.drop = (view, event) => {
+       if (!event.dataTransfer)
+           return false;
+       if (view.state.readOnly)
+           return true;
+       let files = event.dataTransfer.files;
+       if (files && files.length) { // For a file drop, read the file's text.
+           let text = Array(files.length), read = 0;
+           let finishFile = () => {
+               if (++read == files.length)
+                   dropText(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
+           };
+           for (let i = 0; i < files.length; i++) {
+               let reader = new FileReader;
+               reader.onerror = finishFile;
+               reader.onload = () => {
+                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
+                       text[i] = reader.result;
+                   finishFile();
+               };
+               reader.readAsText(files[i]);
+           }
+           return true;
+       }
+       else {
+           let text = event.dataTransfer.getData("Text");
+           if (text) {
+               dropText(view, event, text, true);
+               return true;
+           }
+       }
+       return false;
+   };
+   handlers.paste = (view, event) => {
+       if (view.state.readOnly)
+           return true;
+       view.observer.flush();
+       let data = brokenClipboardAPI ? null : event.clipboardData;
+       if (data) {
+           doPaste(view, data.getData("text/plain") || data.getData("text/uri-list"));
+           return true;
+       }
+       else {
+           capturePaste(view);
+           return false;
+       }
+   };
+   function captureCopy(view, text) {
+       // The extra wrapper is somehow necessary on IE/Edge to prevent the
+       // content from being mangled when it is put onto the clipboard
+       let parent = view.dom.parentNode;
+       if (!parent)
+           return;
+       let target = parent.appendChild(document.createElement("textarea"));
+       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
+       target.value = text;
+       target.focus();
+       target.selectionEnd = text.length;
+       target.selectionStart = 0;
+       setTimeout(() => {
+           target.remove();
+           view.focus();
+       }, 50);
+   }
+   function copiedRange(state) {
+       let content = [], ranges = [], linewise = false;
+       for (let range of state.selection.ranges)
+           if (!range.empty) {
+               content.push(state.sliceDoc(range.from, range.to));
+               ranges.push(range);
+           }
+       if (!content.length) {
+           // Nothing selected, do a line-wise copy
+           let upto = -1;
+           for (let { from } of state.selection.ranges) {
+               let line = state.doc.lineAt(from);
+               if (line.number > upto) {
+                   content.push(line.text);
+                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
+               }
+               upto = line.number;
+           }
+           linewise = true;
+       }
+       return { text: textFilter(state, clipboardOutputFilter, content.join(state.lineBreak)), ranges, linewise };
+   }
+   let lastLinewiseCopy = null;
+   handlers.copy = handlers.cut = (view, event) => {
+       let { text, ranges, linewise } = copiedRange(view.state);
+       if (!text && !linewise)
+           return false;
+       lastLinewiseCopy = linewise ? text : null;
+       if (event.type == "cut" && !view.state.readOnly)
+           view.dispatch({
+               changes: ranges,
+               scrollIntoView: true,
+               userEvent: "delete.cut"
+           });
+       let data = brokenClipboardAPI ? null : event.clipboardData;
+       if (data) {
+           data.clearData();
+           data.setData("text/plain", text);
+           return true;
+       }
+       else {
+           captureCopy(view, text);
+           return false;
+       }
+   };
+   const isFocusChange = /*@__PURE__*/Annotation.define();
+   function focusChangeTransaction(state, focus) {
+       let effects = [];
+       for (let getEffect of state.facet(focusChangeEffect)) {
+           let effect = getEffect(state, focus);
+           if (effect)
+               effects.push(effect);
+       }
+       return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
+   }
+   function updateForFocusChange(view) {
+       setTimeout(() => {
+           let focus = view.hasFocus;
+           if (focus != view.inputState.notifiedFocused) {
+               let tr = focusChangeTransaction(view.state, focus);
+               if (tr)
+                   view.dispatch(tr);
+               else
+                   view.update([]);
+           }
+       }, 10);
+   }
+   observers.focus = view => {
+       view.inputState.lastFocusTime = Date.now();
+       // When focusing reset the scroll position, move it back to where it was
+       if (!view.scrollDOM.scrollTop && (view.inputState.lastScrollTop || view.inputState.lastScrollLeft)) {
+           view.scrollDOM.scrollTop = view.inputState.lastScrollTop;
+           view.scrollDOM.scrollLeft = view.inputState.lastScrollLeft;
+       }
+       updateForFocusChange(view);
+   };
+   observers.blur = view => {
+       view.observer.clearSelectionRange();
+       updateForFocusChange(view);
+   };
+   observers.compositionstart = observers.compositionupdate = view => {
+       if (view.observer.editContext)
+           return; // Composition handled by edit context
+       if (view.inputState.compositionFirstChange == null)
+           view.inputState.compositionFirstChange = true;
+       if (view.inputState.composing < 0) {
+           // FIXME possibly set a timeout to clear it again on Android
+           view.inputState.composing = 0;
+       }
+   };
+   observers.compositionend = view => {
+       if (view.observer.editContext)
+           return; // Composition handled by edit context
+       view.inputState.composing = -1;
+       view.inputState.compositionEndedAt = Date.now();
+       view.inputState.compositionPendingKey = true;
+       view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;
+       view.inputState.compositionFirstChange = null;
+       if (browser.chrome && browser.android) {
+           // Delay flushing for a bit on Android because it'll often fire a
+           // bunch of contradictory changes in a row at end of compositon
+           view.observer.flushSoon();
+       }
+       else if (view.inputState.compositionPendingChange) {
+           // If we found pending records, schedule a flush.
+           Promise.resolve().then(() => view.observer.flush());
+       }
+       else {
+           // Otherwise, make sure that, if no changes come in soon, the
+           // composition view is cleared.
+           setTimeout(() => {
+               if (view.inputState.composing < 0 && view.docView.hasComposition)
+                   view.update([]);
+           }, 50);
+       }
+   };
+   observers.contextmenu = view => {
+       view.inputState.lastContextMenu = Date.now();
+   };
+   handlers.beforeinput = (view, event) => {
+       var _a, _b;
+       // In EditContext mode, we must handle insertReplacementText events
+       // directly, to make spell checking corrections work
+       if (event.inputType == "insertReplacementText" && view.observer.editContext) {
+           let text = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData("text/plain"), ranges = event.getTargetRanges();
+           if (text && ranges.length) {
+               let r = ranges[0];
+               let from = view.posAtDOM(r.startContainer, r.startOffset), to = view.posAtDOM(r.endContainer, r.endOffset);
+               applyDOMChangeInner(view, { from, to, insert: view.state.toText(text) }, null);
+               return true;
+           }
+       }
+       // Because Chrome Android doesn't fire useful key events, use
+       // beforeinput to detect backspace (and possibly enter and delete,
+       // but those usually don't even seem to fire beforeinput events at
+       // the moment) and fake a key event for it.
+       //
+       // (preventDefault on beforeinput, though supported in the spec,
+       // seems to do nothing at all on Chrome).
+       let pending;
+       if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {
+           view.observer.delayAndroidKey(pending.key, pending.keyCode);
+           if (pending.key == "Backspace" || pending.key == "Delete") {
+               let startViewHeight = ((_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.height) || 0;
+               setTimeout(() => {
+                   var _a;
+                   // Backspacing near uneditable nodes on Chrome Android sometimes
+                   // closes the virtual keyboard. This tries to crudely detect
+                   // that and refocus to get it back.
+                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
+                       view.contentDOM.blur();
+                       view.focus();
+                   }
+               }, 100);
+           }
+       }
+       if (browser.ios && event.inputType == "deleteContentForward") {
+           // For some reason, DOM changes (and beforeinput) happen _before_
+           // the key event for ctrl-d on iOS when using an external
+           // keyboard.
+           view.observer.flushSoon();
+       }
+       // Safari will occasionally forget to fire compositionend at the end of a dead-key composition
+       if (browser.safari && event.inputType == "insertText" && view.inputState.composing >= 0) {
+           setTimeout(() => observers.compositionend(view, event), 20);
+       }
+       return false;
+   };
+   const appliedFirefoxHack = /*@__PURE__*/new Set;
+   // In Firefox, when cut/copy handlers are added to the document, that
+   // somehow avoids a bug where those events aren't fired when the
+   // selection is empty. See https://github.com/codemirror/dev/issues/1082
+   // and https://bugzilla.mozilla.org/show_bug.cgi?id=995961
+   function firefoxCopyCutHack(doc) {
+       if (!appliedFirefoxHack.has(doc)) {
+           appliedFirefoxHack.add(doc);
+           doc.addEventListener("copy", () => { });
+           doc.addEventListener("cut", () => { });
+       }
+   }
+
+   const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line", "break-spaces"];
+   // Used to track, during updateHeight, if any actual heights changed
+   let heightChangeFlag = false;
+   function clearHeightChangeFlag() { heightChangeFlag = false; }
+   class HeightOracle {
+       constructor(lineWrapping) {
+           this.lineWrapping = lineWrapping;
+           this.doc = Text.empty;
+           this.heightSamples = {};
+           this.lineHeight = 14; // The height of an entire line (line-height)
+           this.charWidth = 7;
+           this.textHeight = 14; // The height of the actual font (font-size)
+           this.lineLength = 30;
+       }
+       heightForGap(from, to) {
+           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
+           if (this.lineWrapping)
+               lines += Math.max(0, Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength));
+           return this.lineHeight * lines;
+       }
+       heightForLine(length) {
+           if (!this.lineWrapping)
+               return this.lineHeight;
+           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
+           return lines * this.lineHeight;
+       }
+       setDoc(doc) { this.doc = doc; return this; }
+       mustRefreshForWrapping(whiteSpace) {
+           return (wrappingWhiteSpace.indexOf(whiteSpace) > -1) != this.lineWrapping;
+       }
+       mustRefreshForHeights(lineHeights) {
+           let newHeight = false;
+           for (let i = 0; i < lineHeights.length; i++) {
+               let h = lineHeights[i];
+               if (h < 0) {
+                   i++;
+               }
+               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
+                   newHeight = true;
+                   this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return newHeight;
+       }
+       refresh(whiteSpace, lineHeight, charWidth, textHeight, lineLength, knownHeights) {
+           let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;
+           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
+           this.lineWrapping = lineWrapping;
+           this.lineHeight = lineHeight;
+           this.charWidth = charWidth;
+           this.textHeight = textHeight;
+           this.lineLength = lineLength;
+           if (changed) {
+               this.heightSamples = {};
+               for (let i = 0; i < knownHeights.length; i++) {
+                   let h = knownHeights[i];
+                   if (h < 0)
+                       i++;
+                   else
+                       this.heightSamples[Math.floor(h * 10)] = true;
+               }
+           }
+           return changed;
+       }
+   }
+   // This object is used by `updateHeight` to make DOM measurements
+   // arrive at the right nides. The `heights` array is a sequence of
+   // block heights, starting from position `from`.
+   class MeasuredHeights {
+       constructor(from, heights) {
+           this.from = from;
+           this.heights = heights;
+           this.index = 0;
+       }
+       get more() { return this.index < this.heights.length; }
+   }
+   /**
+   Record used to represent information about a block-level element
+   in the editor view.
+   */
+   class BlockInfo {
+       /**
+       @internal
+       */
+       constructor(
+       /**
+       The start of the element in the document.
+       */
+       from, 
+       /**
+       The length of the element.
+       */
+       length, 
+       /**
+       The top position of the element (relative to the top of the
+       document).
+       */
+       top, 
+       /**
+       Its height.
+       */
+       height, 
+       /**
+       @internal Weird packed field that holds an array of children
+       for composite blocks, a decoration for block widgets, and a
+       number indicating the amount of widget-create line breaks for
+       text blocks.
+       */
+       _content) {
+           this.from = from;
+           this.length = length;
+           this.top = top;
+           this.height = height;
+           this._content = _content;
+       }
+       /**
+       The type of element this is. When querying lines, this may be
+       an array of all the blocks that make up the line.
+       */
+       get type() {
+           return typeof this._content == "number" ? BlockType.Text :
+               Array.isArray(this._content) ? this._content : this._content.type;
+       }
+       /**
+       The end of the element as a document position.
+       */
+       get to() { return this.from + this.length; }
+       /**
+       The bottom position of the element.
+       */
+       get bottom() { return this.top + this.height; }
+       /**
+       If this is a widget block, this will return the widget
+       associated with it.
+       */
+       get widget() {
+           return this._content instanceof PointDecoration ? this._content.widget : null;
+       }
+       /**
+       If this is a textblock, this holds the number of line breaks
+       that appear in widgets inside the block.
+       */
+       get widgetLineBreaks() {
+           return typeof this._content == "number" ? this._content : 0;
+       }
+       /**
+       @internal
+       */
+       join(other) {
+           let content = (Array.isArray(this._content) ? this._content : [this])
+               .concat(Array.isArray(other._content) ? other._content : [other]);
+           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);
+       }
+   }
+   var QueryType = /*@__PURE__*/(function (QueryType) {
+       QueryType[QueryType["ByPos"] = 0] = "ByPos";
+       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
+       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
+   return QueryType})(QueryType || (QueryType = {}));
+   const Epsilon = 1e-3;
+   class HeightMap {
+       constructor(length, // The number of characters covered
+       height, // Height of this part of the document
+       flags = 2 /* Flag.Outdated */) {
+           this.length = length;
+           this.height = height;
+           this.flags = flags;
+       }
+       get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
+       set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
+       setHeight(height) {
+           if (this.height != height) {
+               if (Math.abs(this.height - height) > Epsilon)
+                   heightChangeFlag = true;
+               this.height = height;
+           }
+       }
+       // Base case is to replace a leaf node, which simply builds a tree
+       // from the new nodes and returns that (HeightMapBranch and
+       // HeightMapGap override this to actually use from/to)
+       replace(_from, _to, nodes) {
+           return HeightMap.of(nodes);
+       }
+       // Again, these are base cases, and are overridden for branch and gap nodes.
+       decomposeLeft(_to, result) { result.push(this); }
+       decomposeRight(_from, result) { result.push(this); }
+       applyChanges(decorations, oldDoc, oracle, changes) {
+           let me = this, doc = oracle.doc;
+           for (let i = changes.length - 1; i >= 0; i--) {
+               let { fromA, toA, fromB, toB } = changes[i];
+               let start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle.setDoc(oldDoc), 0, 0);
+               let end = start.to >= toA ? start : me.lineAt(toA, QueryType.ByPosNoHeight, oracle, 0, 0);
+               toB += end.to - toA;
+               toA = end.to;
+               while (i > 0 && start.from <= changes[i - 1].toA) {
+                   fromA = changes[i - 1].fromA;
+                   fromB = changes[i - 1].fromB;
+                   i--;
+                   if (fromA < start.from)
+                       start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle, 0, 0);
+               }
+               fromB += start.from - fromA;
+               fromA = start.from;
+               let nodes = NodeBuilder.build(oracle.setDoc(doc), decorations, fromB, toB);
+               me = replace(me, me.replace(fromA, toA, nodes));
+           }
+           return me.updateHeight(oracle, 0);
+       }
+       static empty() { return new HeightMapText(0, 0); }
+       // nodes uses null values to indicate the position of line breaks.
+       // There are never line breaks at the start or end of the array, or
+       // two line breaks next to each other, and the array isn't allowed
+       // to be empty (same restrictions as return value from the builder).
+       static of(nodes) {
+           if (nodes.length == 1)
+               return nodes[0];
+           let i = 0, j = nodes.length, before = 0, after = 0;
+           for (;;) {
+               if (i == j) {
+                   if (before > after * 2) {
+                       let split = nodes[i - 1];
+                       if (split.break)
+                           nodes.splice(--i, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(--i, 1, split.left, split.right);
+                       j += 1 + split.break;
+                       before -= split.size;
+                   }
+                   else if (after > before * 2) {
+                       let split = nodes[j];
+                       if (split.break)
+                           nodes.splice(j, 1, split.left, null, split.right);
+                       else
+                           nodes.splice(j, 1, split.left, split.right);
+                       j += 2 + split.break;
+                       after -= split.size;
+                   }
+                   else {
+                       break;
+                   }
+               }
+               else if (before < after) {
+                   let next = nodes[i++];
+                   if (next)
+                       before += next.size;
+               }
+               else {
+                   let next = nodes[--j];
+                   if (next)
+                       after += next.size;
+               }
+           }
+           let brk = 0;
+           if (nodes[i - 1] == null) {
+               brk = 1;
+               i--;
+           }
+           else if (nodes[i] == null) {
+               brk = 1;
+               j++;
+           }
+           return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
+       }
+   }
+   function replace(old, val) {
+       if (old == val)
+           return old;
+       if (old.constructor != val.constructor)
+           heightChangeFlag = true;
+       return val;
+   }
+   HeightMap.prototype.size = 1;
+   class HeightMapBlock extends HeightMap {
+       constructor(length, height, deco) {
+           super(length, height);
+           this.deco = deco;
+       }
+       blockAt(_height, _oracle, top, offset) {
+           return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);
+       }
+       lineAt(_value, _type, oracle, top, offset) {
+           return this.blockAt(0, oracle, top, offset);
+       }
+       forEachLine(from, to, oracle, top, offset, f) {
+           if (from <= offset + this.length && to >= offset)
+               f(this.blockAt(0, oracle, top, offset));
+       }
+       updateHeight(oracle, offset = 0, _force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(measured.heights[measured.index++]);
+           this.outdated = false;
+           return this;
+       }
+       toString() { return `block(${this.length})`; }
+   }
+   class HeightMapText extends HeightMapBlock {
+       constructor(length, height) {
+           super(length, height, null);
+           this.collapsed = 0; // Amount of collapsed content in the line
+           this.widgetHeight = 0; // Maximum inline widget height
+           this.breaks = 0; // Number of widget-introduced line breaks on the line
+       }
+       blockAt(_height, _oracle, top, offset) {
+           return new BlockInfo(offset, this.length, top, this.height, this.breaks);
+       }
+       replace(_from, _to, nodes) {
+           let node = nodes[0];
+           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
+               Math.abs(this.length - node.length) < 10) {
+               if (node instanceof HeightMapGap)
+                   node = new HeightMapText(node.length, this.height);
+               else
+                   node.height = this.height;
+               if (!this.outdated)
+                   node.outdated = false;
+               return node;
+           }
+           else {
+               return HeightMap.of(nodes);
+           }
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           if (measured && measured.from <= offset && measured.more)
+               this.setHeight(measured.heights[measured.index++]);
+           else if (force || this.outdated)
+               this.setHeight(Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +
+                   this.breaks * oracle.lineHeight);
+           this.outdated = false;
+           return this;
+       }
+       toString() {
+           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
+       }
+   }
+   class HeightMapGap extends HeightMap {
+       constructor(length) { super(length, 0); }
+       heightMetrics(oracle, offset) {
+           let firstLine = oracle.doc.lineAt(offset).number, lastLine = oracle.doc.lineAt(offset + this.length).number;
+           let lines = lastLine - firstLine + 1;
+           let perLine, perChar = 0;
+           if (oracle.lineWrapping) {
+               let totalPerLine = Math.min(this.height, oracle.lineHeight * lines);
+               perLine = totalPerLine / lines;
+               if (this.length > lines + 1)
+                   perChar = (this.height - totalPerLine) / (this.length - lines - 1);
+           }
+           else {
+               perLine = this.height / lines;
+           }
+           return { firstLine, lastLine, perLine, perChar };
+       }
+       blockAt(height, oracle, top, offset) {
+           let { firstLine, lastLine, perLine, perChar } = this.heightMetrics(oracle, offset);
+           if (oracle.lineWrapping) {
+               let guess = offset + (height < oracle.lineHeight ? 0
+                   : Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length));
+               let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;
+               let lineTop = Math.max(top, height - lineHeight / 2);
+               return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);
+           }
+           else {
+               let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
+               let { from, length } = oracle.doc.line(firstLine + line);
+               return new BlockInfo(from, length, top + perLine * line, perLine, 0);
+           }
+       }
+       lineAt(value, type, oracle, top, offset) {
+           if (type == QueryType.ByHeight)
+               return this.blockAt(value, oracle, top, offset);
+           if (type == QueryType.ByPosNoHeight) {
+               let { from, to } = oracle.doc.lineAt(value);
+               return new BlockInfo(from, to - from, 0, 0, 0);
+           }
+           let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
+           let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;
+           let linesAbove = line.number - firstLine;
+           let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
+           return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);
+       }
+       forEachLine(from, to, oracle, top, offset, f) {
+           from = Math.max(from, offset);
+           to = Math.min(to, offset + this.length);
+           let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
+           for (let pos = from, lineTop = top; pos <= to;) {
+               let line = oracle.doc.lineAt(pos);
+               if (pos == from) {
+                   let linesAbove = line.number - firstLine;
+                   lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
+               }
+               let lineHeight = perLine + perChar * line.length;
+               f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));
+               lineTop += lineHeight;
+               pos = line.to + 1;
+           }
+       }
+       replace(from, to, nodes) {
+           let after = this.length - to;
+           if (after > 0) {
+               let last = nodes[nodes.length - 1];
+               if (last instanceof HeightMapGap)
+                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
+               else
+                   nodes.push(null, new HeightMapGap(after - 1));
+           }
+           if (from > 0) {
+               let first = nodes[0];
+               if (first instanceof HeightMapGap)
+                   nodes[0] = new HeightMapGap(from + first.length);
+               else
+                   nodes.unshift(new HeightMapGap(from - 1), null);
+           }
+           return HeightMap.of(nodes);
+       }
+       decomposeLeft(to, result) {
+           result.push(new HeightMapGap(to - 1), null);
+       }
+       decomposeRight(from, result) {
+           result.push(null, new HeightMapGap(this.length - from - 1));
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let end = offset + this.length;
+           if (measured && measured.from <= offset + this.length && measured.more) {
+               // Fill in part of this gap with measured lines. We know there
+               // can't be widgets or collapsed ranges in those lines, because
+               // they would already have been added to the heightmap (gaps
+               // only contain plain text).
+               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
+               if (measured.from > offset)
+                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
+               while (pos <= end && measured.more) {
+                   let len = oracle.doc.lineAt(pos).length;
+                   if (nodes.length)
+                       nodes.push(null);
+                   let height = measured.heights[measured.index++];
+                   if (singleHeight == -1)
+                       singleHeight = height;
+                   else if (Math.abs(height - singleHeight) >= Epsilon)
+                       singleHeight = -2;
+                   let line = new HeightMapText(len, height);
+                   line.outdated = false;
+                   nodes.push(line);
+                   pos += len + 1;
+               }
+               if (pos <= end)
+                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
+               let result = HeightMap.of(nodes);
+               if (singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon ||
+                   Math.abs(singleHeight - this.heightMetrics(oracle, offset).perLine) >= Epsilon)
+                   heightChangeFlag = true;
+               return replace(this, result);
+           }
+           else if (force || this.outdated) {
+               this.setHeight(oracle.heightForGap(offset, offset + this.length));
+               this.outdated = false;
+           }
+           return this;
+       }
+       toString() { return `gap(${this.length})`; }
+   }
+   class HeightMapBranch extends HeightMap {
+       constructor(left, brk, right) {
+           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
+           this.left = left;
+           this.right = right;
+           this.size = left.size + right.size;
+       }
+       get break() { return this.flags & 1 /* Flag.Break */; }
+       blockAt(height, oracle, top, offset) {
+           let mid = top + this.left.height;
+           return height < mid ? this.left.blockAt(height, oracle, top, offset)
+               : this.right.blockAt(height, oracle, mid, offset + this.left.length + this.break);
+       }
+       lineAt(value, type, oracle, top, offset) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           let left = type == QueryType.ByHeight ? value < rightTop : value < rightOffset;
+           let base = left ? this.left.lineAt(value, type, oracle, top, offset)
+               : this.right.lineAt(value, type, oracle, rightTop, rightOffset);
+           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
+               return base;
+           let subQuery = type == QueryType.ByPosNoHeight ? QueryType.ByPosNoHeight : QueryType.ByPos;
+           if (left)
+               return base.join(this.right.lineAt(rightOffset, subQuery, oracle, rightTop, rightOffset));
+           else
+               return this.left.lineAt(rightOffset, subQuery, oracle, top, offset).join(base);
+       }
+       forEachLine(from, to, oracle, top, offset, f) {
+           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
+           if (this.break) {
+               if (from < rightOffset)
+                   this.left.forEachLine(from, to, oracle, top, offset, f);
+               if (to >= rightOffset)
+                   this.right.forEachLine(from, to, oracle, rightTop, rightOffset, f);
+           }
+           else {
+               let mid = this.lineAt(rightOffset, QueryType.ByPos, oracle, top, offset);
+               if (from < mid.from)
+                   this.left.forEachLine(from, mid.from - 1, oracle, top, offset, f);
+               if (mid.to >= from && mid.from <= to)
+                   f(mid);
+               if (to > mid.to)
+                   this.right.forEachLine(mid.to + 1, to, oracle, rightTop, rightOffset, f);
+           }
+       }
+       replace(from, to, nodes) {
+           let rightStart = this.left.length + this.break;
+           if (to < rightStart)
+               return this.balanced(this.left.replace(from, to, nodes), this.right);
+           if (from > this.left.length)
+               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
+           let result = [];
+           if (from > 0)
+               this.decomposeLeft(from, result);
+           let left = result.length;
+           for (let node of nodes)
+               result.push(node);
+           if (from > 0)
+               mergeGaps(result, left - 1);
+           if (to < this.length) {
+               let right = result.length;
+               this.decomposeRight(to, result);
+               mergeGaps(result, right);
+           }
+           return HeightMap.of(result);
+       }
+       decomposeLeft(to, result) {
+           let left = this.left.length;
+           if (to <= left)
+               return this.left.decomposeLeft(to, result);
+           result.push(this.left);
+           if (this.break) {
+               left++;
+               if (to >= left)
+                   result.push(null);
+           }
+           if (to > left)
+               this.right.decomposeLeft(to - left, result);
+       }
+       decomposeRight(from, result) {
+           let left = this.left.length, right = left + this.break;
+           if (from >= right)
+               return this.right.decomposeRight(from - right, result);
+           if (from < left)
+               this.left.decomposeRight(from, result);
+           if (this.break && from < right)
+               result.push(null);
+           result.push(this.right);
+       }
+       balanced(left, right) {
+           if (left.size > 2 * right.size || right.size > 2 * left.size)
+               return HeightMap.of(this.break ? [left, null, right] : [left, right]);
+           this.left = replace(this.left, left);
+           this.right = replace(this.right, right);
+           this.setHeight(left.height + right.height);
+           this.outdated = left.outdated || right.outdated;
+           this.size = left.size + right.size;
+           this.length = left.length + this.break + right.length;
+           return this;
+       }
+       updateHeight(oracle, offset = 0, force = false, measured) {
+           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
+           if (measured && measured.from <= offset + left.length && measured.more)
+               rebalance = left = left.updateHeight(oracle, offset, force, measured);
+           else
+               left.updateHeight(oracle, offset, force);
+           if (measured && measured.from <= rightStart + right.length && measured.more)
+               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
+           else
+               right.updateHeight(oracle, rightStart, force);
+           if (rebalance)
+               return this.balanced(left, right);
+           this.height = this.left.height + this.right.height;
+           this.outdated = false;
+           return this;
+       }
+       toString() { return this.left + (this.break ? " " : "-") + this.right; }
+   }
+   function mergeGaps(nodes, around) {
+       let before, after;
+       if (nodes[around] == null &&
+           (before = nodes[around - 1]) instanceof HeightMapGap &&
+           (after = nodes[around + 1]) instanceof HeightMapGap)
+           nodes.splice(around - 1, 3, new HeightMapGap(before.length + 1 + after.length));
+   }
+   const relevantWidgetHeight = 5;
+   class NodeBuilder {
+       constructor(pos, oracle) {
+           this.pos = pos;
+           this.oracle = oracle;
+           this.nodes = [];
+           this.lineStart = -1;
+           this.lineEnd = -1;
+           this.covering = null;
+           this.writtenTo = pos;
+       }
+       get isCovered() {
+           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
+       }
+       span(_from, to) {
+           if (this.lineStart > -1) {
+               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
+               if (last instanceof HeightMapText)
+                   last.length += end - this.pos;
+               else if (end > this.pos || !this.isCovered)
+                   this.nodes.push(new HeightMapText(end - this.pos, -1));
+               this.writtenTo = end;
+               if (to > end) {
+                   this.nodes.push(null);
+                   this.writtenTo++;
+                   this.lineStart = -1;
+               }
+           }
+           this.pos = to;
+       }
+       point(from, to, deco) {
+           if (from < to || deco.heightRelevant) {
+               let height = deco.widget ? deco.widget.estimatedHeight : 0;
+               let breaks = deco.widget ? deco.widget.lineBreaks : 0;
+               if (height < 0)
+                   height = this.oracle.lineHeight;
+               let len = to - from;
+               if (deco.block) {
+                   this.addBlock(new HeightMapBlock(len, height, deco));
+               }
+               else if (len || breaks || height >= relevantWidgetHeight) {
+                   this.addLineDeco(height, breaks, len);
+               }
+           }
+           else if (to > from) {
+               this.span(from, to);
+           }
+           if (this.lineEnd > -1 && this.lineEnd < this.pos)
+               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
+       }
+       enterLine() {
+           if (this.lineStart > -1)
+               return;
+           let { from, to } = this.oracle.doc.lineAt(this.pos);
+           this.lineStart = from;
+           this.lineEnd = to;
+           if (this.writtenTo < from) {
+               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
+                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
+               this.nodes.push(null);
+           }
+           if (this.pos > from)
+               this.nodes.push(new HeightMapText(this.pos - from, -1));
+           this.writtenTo = this.pos;
+       }
+       blankContent(from, to) {
+           let gap = new HeightMapGap(to - from);
+           if (this.oracle.doc.lineAt(from).to == to)
+               gap.flags |= 4 /* Flag.SingleLine */;
+           return gap;
+       }
+       ensureLine() {
+           this.enterLine();
+           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
+           if (last instanceof HeightMapText)
+               return last;
+           let line = new HeightMapText(0, -1);
+           this.nodes.push(line);
+           return line;
+       }
+       addBlock(block) {
+           this.enterLine();
+           let deco = block.deco;
+           if (deco && deco.startSide > 0 && !this.isCovered)
+               this.ensureLine();
+           this.nodes.push(block);
+           this.writtenTo = this.pos = this.pos + block.length;
+           if (deco && deco.endSide > 0)
+               this.covering = block;
+       }
+       addLineDeco(height, breaks, length) {
+           let line = this.ensureLine();
+           line.length += length;
+           line.collapsed += length;
+           line.widgetHeight = Math.max(line.widgetHeight, height);
+           line.breaks += breaks;
+           this.writtenTo = this.pos = this.pos + length;
+       }
+       finish(from) {
+           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
+           if (this.lineStart > -1 && !(last instanceof HeightMapText) && !this.isCovered)
+               this.nodes.push(new HeightMapText(0, -1));
+           else if (this.writtenTo < this.pos || last == null)
+               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
+           let pos = from;
+           for (let node of this.nodes) {
+               if (node instanceof HeightMapText)
+                   node.updateHeight(this.oracle, pos);
+               pos += node ? node.length : 1;
+           }
+           return this.nodes;
+       }
+       // Always called with a region that on both sides either stretches
+       // to a line break or the end of the document.
+       // The returned array uses null to indicate line breaks, but never
+       // starts or ends in a line break, or has multiple line breaks next
+       // to each other.
+       static build(oracle, decorations, from, to) {
+           let builder = new NodeBuilder(from, oracle);
+           RangeSet.spans(decorations, from, to, builder, 0);
+           return builder.finish(from);
+       }
+   }
+   function heightRelevantDecoChanges(a, b, diff) {
+       let comp = new DecorationComparator;
+       RangeSet.compare(a, b, diff, comp, 0);
+       return comp.changes;
+   }
+   class DecorationComparator {
+       constructor() {
+           this.changes = [];
+       }
+       compareRange() { }
+       comparePoint(from, to, a, b) {
+           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
+               addRange(from, to, this.changes, 5);
+       }
+   }
+
+   function visiblePixelRange(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       let doc = dom.ownerDocument, win = doc.defaultView || window;
+       let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);
+       let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);
+       for (let parent = dom.parentNode; parent && parent != doc.body;) {
+           if (parent.nodeType == 1) {
+               let elt = parent;
+               let style = window.getComputedStyle(elt);
+               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
+                   style.overflow != "visible") {
+                   let parentRect = elt.getBoundingClientRect();
+                   left = Math.max(left, parentRect.left);
+                   right = Math.min(right, parentRect.right);
+                   top = Math.max(top, parentRect.top);
+                   bottom = Math.min(parent == dom.parentNode ? win.innerHeight : bottom, parentRect.bottom);
+               }
+               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
+           }
+           else if (parent.nodeType == 11) { // Shadow root
+               parent = parent.host;
+           }
+           else {
+               break;
+           }
+       }
+       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
+           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
+   }
+   function fullPixelRange(dom, paddingTop) {
+       let rect = dom.getBoundingClientRect();
+       return { left: 0, right: rect.right - rect.left,
+           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
+   }
+   // Line gaps are placeholder widgets used to hide pieces of overlong
+   // lines within the viewport, as a kludge to keep the editor
+   // responsive when a ridiculously long line is loaded into it.
+   class LineGap {
+       constructor(from, to, size, displaySize) {
+           this.from = from;
+           this.to = to;
+           this.size = size;
+           this.displaySize = displaySize;
+       }
+       static same(a, b) {
+           if (a.length != b.length)
+               return false;
+           for (let i = 0; i < a.length; i++) {
+               let gA = a[i], gB = b[i];
+               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
+                   return false;
+           }
+           return true;
+       }
+       draw(viewState, wrapping) {
+           return Decoration.replace({
+               widget: new LineGapWidget(this.displaySize * (wrapping ? viewState.scaleY : viewState.scaleX), wrapping)
+           }).range(this.from, this.to);
+       }
+   }
+   class LineGapWidget extends WidgetType {
+       constructor(size, vertical) {
+           super();
+           this.size = size;
+           this.vertical = vertical;
+       }
+       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
+       toDOM() {
+           let elt = document.createElement("div");
+           if (this.vertical) {
+               elt.style.height = this.size + "px";
+           }
+           else {
+               elt.style.width = this.size + "px";
+               elt.style.height = "2px";
+               elt.style.display = "inline-block";
+           }
+           return elt;
+       }
+       get estimatedHeight() { return this.vertical ? this.size : -1; }
+   }
+   class ViewState {
+       constructor(state) {
+           this.state = state;
+           // These are contentDOM-local coordinates
+           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
+           this.inView = true;
+           this.paddingTop = 0; // Padding above the document, scaled
+           this.paddingBottom = 0; // Padding below the document, scaled
+           this.contentDOMWidth = 0; // contentDOM.getBoundingClientRect().width
+           this.contentDOMHeight = 0; // contentDOM.getBoundingClientRect().height
+           this.editorHeight = 0; // scrollDOM.clientHeight, unscaled
+           this.editorWidth = 0; // scrollDOM.clientWidth, unscaled
+           this.scrollTop = 0; // Last seen scrollDOM.scrollTop, scaled
+           this.scrolledToBottom = false;
+           // The CSS-transformation scale of the editor (transformed size /
+           // concrete size)
+           this.scaleX = 1;
+           this.scaleY = 1;
+           // The vertical position (document-relative) to which to anchor the
+           // scroll position. -1 means anchor to the end of the document.
+           this.scrollAnchorPos = 0;
+           // The height at the anchor position. Set by the DOM update phase.
+           // -1 means no height available.
+           this.scrollAnchorHeight = -1;
+           // See VP.MaxDOMHeight
+           this.scaler = IdScaler;
+           this.scrollTarget = null;
+           // Briefly set to true when printing, to disable viewport limiting
+           this.printing = false;
+           // Flag set when editor content was redrawn, so that the next
+           // measure stage knows it must read DOM layout
+           this.mustMeasureContent = true;
+           this.defaultTextDirection = Direction.LTR;
+           this.visibleRanges = [];
+           // Cursor 'assoc' is only significant when the cursor is on a line
+           // wrap point, where it must stick to the character that it is
+           // associated with. Since browsers don't provide a reasonable
+           // interface to set or query this, when a selection is set that
+           // might cause this to be significant, this flag is set. The next
+           // measure phase will check whether the cursor is on a line-wrapping
+           // boundary and, if so, reset it to make sure it is positioned in
+           // the right place.
+           this.mustEnforceCursorAssoc = false;
+           let guessWrapping = state.facet(contentAttributes).some(v => typeof v != "function" && v.class == "cm-lineWrapping");
+           this.heightOracle = new HeightOracle(guessWrapping);
+           this.stateDeco = state.facet(decorations).filter(d => typeof d != "function");
+           this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
+           for (let i = 0; i < 2; i++) {
+               this.viewport = this.getViewport(0, null);
+               if (!this.updateForViewport())
+                   break;
+           }
+           this.updateViewportLines();
+           this.lineGaps = this.ensureLineGaps([]);
+           this.lineGapDeco = Decoration.set(this.lineGaps.map(gap => gap.draw(this, false)));
+           this.computeVisibleRanges();
+       }
+       updateForViewport() {
+           let viewports = [this.viewport], { main } = this.state.selection;
+           for (let i = 0; i <= 1; i++) {
+               let pos = i ? main.head : main.anchor;
+               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
+                   let { from, to } = this.lineBlockAt(pos);
+                   viewports.push(new Viewport(from, to));
+               }
+           }
+           this.viewports = viewports.sort((a, b) => a.from - b.from);
+           return this.updateScaler();
+       }
+       updateScaler() {
+           let scaler = this.scaler;
+           this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
+               new BigScaler(this.heightOracle, this.heightMap, this.viewports);
+           return scaler.eq(this.scaler) ? 0 : 2 /* UpdateFlag.Height */;
+       }
+       updateViewportLines() {
+           this.viewportLines = [];
+           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, block => {
+               this.viewportLines.push(scaleBlock(block, this.scaler));
+           });
+       }
+       update(update, scrollTarget = null) {
+           this.state = update.state;
+           let prevDeco = this.stateDeco;
+           this.stateDeco = this.state.facet(decorations).filter(d => typeof d != "function");
+           let contentChanges = update.changedRanges;
+           let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));
+           let prevHeight = this.heightMap.height;
+           let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);
+           clearHeightChangeFlag();
+           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
+           if (this.heightMap.height != prevHeight || heightChangeFlag)
+               update.flags |= 2 /* UpdateFlag.Height */;
+           if (scrollAnchor) {
+               this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);
+               this.scrollAnchorHeight = scrollAnchor.top;
+           }
+           else {
+               this.scrollAnchorPos = -1;
+               this.scrollAnchorHeight = this.heightMap.height;
+           }
+           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
+           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
+               !this.viewportIsAppropriate(viewport))
+               viewport = this.getViewport(0, scrollTarget);
+           let viewportChange = viewport.from != this.viewport.from || viewport.to != this.viewport.to;
+           this.viewport = viewport;
+           update.flags |= this.updateForViewport();
+           if (viewportChange || !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */))
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))
+               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
+           update.flags |= this.computeVisibleRanges(update.changes);
+           if (scrollTarget)
+               this.scrollTarget = scrollTarget;
+           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
+               update.state.selection.main.empty && update.state.selection.main.assoc &&
+               !update.state.facet(nativeSelectionHidden))
+               this.mustEnforceCursorAssoc = true;
+       }
+       measure(view) {
+           let dom = view.contentDOM, style = window.getComputedStyle(dom);
+           let oracle = this.heightOracle;
+           let whiteSpace = style.whiteSpace;
+           this.defaultTextDirection = style.direction == "rtl" ? Direction.RTL : Direction.LTR;
+           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
+           let domRect = dom.getBoundingClientRect();
+           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != domRect.height;
+           this.contentDOMHeight = domRect.height;
+           this.mustMeasureContent = false;
+           let result = 0, bias = 0;
+           if (domRect.width && domRect.height) {
+               let { scaleX, scaleY } = getScale(dom, domRect);
+               if (scaleX > .005 && Math.abs(this.scaleX - scaleX) > .005 ||
+                   scaleY > .005 && Math.abs(this.scaleY - scaleY) > .005) {
+                   this.scaleX = scaleX;
+                   this.scaleY = scaleY;
+                   result |= 16 /* UpdateFlag.Geometry */;
+                   refresh = measureContent = true;
+               }
+           }
+           // Vertical padding
+           let paddingTop = (parseInt(style.paddingTop) || 0) * this.scaleY;
+           let paddingBottom = (parseInt(style.paddingBottom) || 0) * this.scaleY;
+           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
+               this.paddingTop = paddingTop;
+               this.paddingBottom = paddingBottom;
+               result |= 16 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
+           }
+           if (this.editorWidth != view.scrollDOM.clientWidth) {
+               if (oracle.lineWrapping)
+                   measureContent = true;
+               this.editorWidth = view.scrollDOM.clientWidth;
+               result |= 16 /* UpdateFlag.Geometry */;
+           }
+           let scrollTop = view.scrollDOM.scrollTop * this.scaleY;
+           if (this.scrollTop != scrollTop) {
+               this.scrollAnchorHeight = -1;
+               this.scrollTop = scrollTop;
+           }
+           this.scrolledToBottom = isScrolledToBottom(view.scrollDOM);
+           // Pixel viewport
+           let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
+           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
+           this.pixelViewport = pixelViewport;
+           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
+           if (inView != this.inView) {
+               this.inView = inView;
+               if (inView)
+                   measureContent = true;
+           }
+           if (!this.inView && !this.scrollTarget)
+               return 0;
+           let contentWidth = domRect.width;
+           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
+               this.contentDOMWidth = domRect.width;
+               this.editorHeight = view.scrollDOM.clientHeight;
+               result |= 16 /* UpdateFlag.Geometry */;
+           }
+           if (measureContent) {
+               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
+               if (oracle.mustRefreshForHeights(lineHeights))
+                   refresh = true;
+               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
+                   let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();
+                   refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);
+                   if (refresh) {
+                       view.docView.minWidth = 0;
+                       result |= 16 /* UpdateFlag.Geometry */;
+                   }
+               }
+               if (dTop > 0 && dBottom > 0)
+                   bias = Math.max(dTop, dBottom);
+               else if (dTop < 0 && dBottom < 0)
+                   bias = Math.min(dTop, dBottom);
+               clearHeightChangeFlag();
+               for (let vp of this.viewports) {
+                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
+                   this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
+               }
+               if (heightChangeFlag)
+                   result |= 2 /* UpdateFlag.Height */;
+           }
+           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
+               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||
+                   this.scrollTarget.range.head > this.viewport.to);
+           if (viewportChange) {
+               if (result & 2 /* UpdateFlag.Height */)
+                   result |= this.updateScaler();
+               this.viewport = this.getViewport(bias, this.scrollTarget);
+               result |= this.updateForViewport();
+           }
+           if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
+               this.updateViewportLines();
+           if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))
+               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));
+           result |= this.computeVisibleRanges();
+           if (this.mustEnforceCursorAssoc) {
+               this.mustEnforceCursorAssoc = false;
+               // This is done in the read stage, because moving the selection
+               // to a line end is going to trigger a layout anyway, so it
+               // can't be a pure write. It should be rare that it does any
+               // writing.
+               view.docView.enforceCursorAssoc();
+           }
+           return result;
+       }
+       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
+       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
+       getViewport(bias, scrollTarget) {
+           // This will divide VP.Margin between the top and the
+           // bottom, depending on the bias (the change in viewport position
+           // since the last update). It'll hold a number between 0 and 1
+           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
+           let map = this.heightMap, oracle = this.heightOracle;
+           let { visibleTop, visibleBottom } = this;
+           let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).to);
+           // If scrollTarget is given, make sure the viewport includes that position
+           if (scrollTarget) {
+               let { head } = scrollTarget.range;
+               if (head < viewport.from || head > viewport.to) {
+                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
+                   let block = map.lineAt(head, QueryType.ByPos, oracle, 0, 0), topPos;
+                   if (scrollTarget.y == "center")
+                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
+                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
+                       topPos = block.top;
+                   else
+                       topPos = block.bottom - viewHeight;
+                   viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).to);
+               }
+           }
+           return viewport;
+       }
+       mapViewport(viewport, changes) {
+           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
+           return new Viewport(this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0).to);
+       }
+       // Checks if a given viewport covers the visible part of the
+       // document and not too much beyond that.
+       viewportIsAppropriate({ from, to }, bias = 0) {
+           if (!this.inView)
+               return true;
+           let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);
+           let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);
+           let { visibleTop, visibleBottom } = this;
+           return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
+               (to == this.state.doc.length ||
+                   bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
+               (top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
+       }
+       mapLineGaps(gaps, changes) {
+           if (!gaps.length || changes.empty)
+               return gaps;
+           let mapped = [];
+           for (let gap of gaps)
+               if (!changes.touchesRange(gap.from, gap.to))
+                   mapped.push(new LineGap(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size, gap.displaySize));
+           return mapped;
+       }
+       // Computes positions in the viewport where the start or end of a
+       // line should be hidden, trying to reuse existing line gaps when
+       // appropriate to avoid unneccesary redraws.
+       // Uses crude character-counting for the positioning and sizing,
+       // since actual DOM coordinates aren't always available and
+       // predictable. Relies on generous margins (see LG.Margin) to hide
+       // the artifacts this might produce from the user.
+       ensureLineGaps(current, mayMeasure) {
+           let wrapping = this.heightOracle.lineWrapping;
+           let margin = wrapping ? 10000 /* LG.MarginWrap */ : 2000 /* LG.Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;
+           // The non-wrapping logic won't work at all in predominantly right-to-left text.
+           if (this.defaultTextDirection != Direction.LTR && !wrapping)
+               return [];
+           let gaps = [];
+           let addGap = (from, to, line, structure) => {
+               if (to - from < halfMargin)
+                   return;
+               let sel = this.state.selection.main, avoid = [sel.from];
+               if (!sel.empty)
+                   avoid.push(sel.to);
+               for (let pos of avoid) {
+                   if (pos > from && pos < to) {
+                       addGap(from, pos - 10 /* LG.SelectionMargin */, line, structure);
+                       addGap(pos + 10 /* LG.SelectionMargin */, to, line, structure);
+                       return;
+                   }
+               }
+               let gap = find(current, gap => gap.from >= line.from && gap.to <= line.to &&
+                   Math.abs(gap.from - from) < halfMargin && Math.abs(gap.to - to) < halfMargin &&
+                   !avoid.some(pos => gap.from < pos && gap.to > pos));
+               if (!gap) {
+                   // When scrolling down, snap gap ends to line starts to avoid shifts in wrapping
+                   if (to < line.to && mayMeasure && wrapping &&
+                       mayMeasure.visibleRanges.some(r => r.from <= to && r.to >= to)) {
+                       let lineStart = mayMeasure.moveToLineBoundary(EditorSelection.cursor(to), false, true).head;
+                       if (lineStart > from)
+                           to = lineStart;
+                   }
+                   let size = this.gapSize(line, from, to, structure);
+                   let displaySize = wrapping || size < 2000000 /* VP.MaxHorizGap */ ? size : 2000000 /* VP.MaxHorizGap */;
+                   gap = new LineGap(from, to, size, displaySize);
+               }
+               gaps.push(gap);
+           };
+           let checkLine = (line) => {
+               if (line.length < doubleMargin || line.type != BlockType.Text)
+                   return;
+               let structure = lineStructure(line.from, line.to, this.stateDeco);
+               if (structure.total < doubleMargin)
+                   return;
+               let target = this.scrollTarget ? this.scrollTarget.range.head : null;
+               let viewFrom, viewTo;
+               if (wrapping) {
+                   let marginHeight = (margin / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
+                   let top, bot;
+                   if (target != null) {
+                       let targetFrac = findFraction(structure, target);
+                       let spaceFrac = ((this.visibleBottom - this.visibleTop) / 2 + marginHeight) / line.height;
+                       top = targetFrac - spaceFrac;
+                       bot = targetFrac + spaceFrac;
+                   }
+                   else {
+                       top = (this.visibleTop - line.top - marginHeight) / line.height;
+                       bot = (this.visibleBottom - line.top + marginHeight) / line.height;
+                   }
+                   viewFrom = findPosition(structure, top);
+                   viewTo = findPosition(structure, bot);
+               }
+               else {
+                   let totalWidth = structure.total * this.heightOracle.charWidth;
+                   let marginWidth = margin * this.heightOracle.charWidth;
+                   let horizOffset = 0;
+                   if (totalWidth > 2000000 /* VP.MaxHorizGap */)
+                       for (let old of current) {
+                           if (old.from >= line.from && old.from < line.to && old.size != old.displaySize &&
+                               old.from * this.heightOracle.charWidth + horizOffset < this.pixelViewport.left)
+                               horizOffset = old.size - old.displaySize;
+                       }
+                   let pxLeft = this.pixelViewport.left + horizOffset, pxRight = this.pixelViewport.right + horizOffset;
+                   let left, right;
+                   if (target != null) {
+                       let targetFrac = findFraction(structure, target);
+                       let spaceFrac = ((pxRight - pxLeft) / 2 + marginWidth) / totalWidth;
+                       left = targetFrac - spaceFrac;
+                       right = targetFrac + spaceFrac;
+                   }
+                   else {
+                       left = (pxLeft - marginWidth) / totalWidth;
+                       right = (pxRight + marginWidth) / totalWidth;
+                   }
+                   viewFrom = findPosition(structure, left);
+                   viewTo = findPosition(structure, right);
+               }
+               if (viewFrom > line.from)
+                   addGap(line.from, viewFrom, line, structure);
+               if (viewTo < line.to)
+                   addGap(viewTo, line.to, line, structure);
+           };
+           for (let line of this.viewportLines) {
+               if (Array.isArray(line.type))
+                   line.type.forEach(checkLine);
+               else
+                   checkLine(line);
+           }
+           return gaps;
+       }
+       gapSize(line, from, to, structure) {
+           let fraction = findFraction(structure, to) - findFraction(structure, from);
+           if (this.heightOracle.lineWrapping) {
+               return line.height * fraction;
+           }
+           else {
+               return structure.total * this.heightOracle.charWidth * fraction;
+           }
+       }
+       updateLineGaps(gaps) {
+           if (!LineGap.same(gaps, this.lineGaps)) {
+               this.lineGaps = gaps;
+               this.lineGapDeco = Decoration.set(gaps.map(gap => gap.draw(this, this.heightOracle.lineWrapping)));
+           }
+       }
+       computeVisibleRanges(changes) {
+           let deco = this.stateDeco;
+           if (this.lineGaps.length)
+               deco = deco.concat(this.lineGapDeco);
+           let ranges = [];
+           RangeSet.spans(deco, this.viewport.from, this.viewport.to, {
+               span(from, to) { ranges.push({ from, to }); },
+               point() { }
+           }, 20);
+           let changed = 0;
+           if (ranges.length != this.visibleRanges.length) {
+               changed = 8 /* UpdateFlag.ViewportMoved */ | 4 /* UpdateFlag.Viewport */;
+           }
+           else {
+               for (let i = 0; i < ranges.length && !(changed & 8 /* UpdateFlag.ViewportMoved */); i++) {
+                   let old = this.visibleRanges[i], nw = ranges[i];
+                   if (old.from != nw.from || old.to != nw.to) {
+                       changed |= 4 /* UpdateFlag.Viewport */;
+                       if (!(changes && changes.mapPos(old.from, -1) == nw.from && changes.mapPos(old.to, 1) == nw.to))
+                           changed |= 8 /* UpdateFlag.ViewportMoved */;
+                   }
+               }
+           }
+           this.visibleRanges = ranges;
+           return changed;
+       }
+       lineBlockAt(pos) {
+           return (pos >= this.viewport.from && pos <= this.viewport.to &&
+               this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
+               scaleBlock(this.heightMap.lineAt(pos, QueryType.ByPos, this.heightOracle, 0, 0), this.scaler);
+       }
+       lineBlockAtHeight(height) {
+           return (height >= this.viewportLines[0].top && height <= this.viewportLines[this.viewportLines.length - 1].bottom &&
+               this.viewportLines.find(l => l.top <= height && l.bottom >= height)) ||
+               scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.heightOracle, 0, 0), this.scaler);
+       }
+       scrollAnchorAt(scrollTop) {
+           let block = this.lineBlockAtHeight(scrollTop + 8);
+           return block.from >= this.viewport.from || this.viewportLines[0].top - scrollTop > 200 ? block : this.viewportLines[0];
+       }
+       elementAtHeight(height) {
+           return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.heightOracle, 0, 0), this.scaler);
+       }
+       get docHeight() {
+           return this.scaler.toDOM(this.heightMap.height);
+       }
+       get contentHeight() {
+           return this.docHeight + this.paddingTop + this.paddingBottom;
+       }
+   }
+   class Viewport {
+       constructor(from, to) {
+           this.from = from;
+           this.to = to;
+       }
+   }
+   function lineStructure(from, to, stateDeco) {
+       let ranges = [], pos = from, total = 0;
+       RangeSet.spans(stateDeco, from, to, {
+           span() { },
+           point(from, to) {
+               if (from > pos) {
+                   ranges.push({ from: pos, to: from });
+                   total += from - pos;
+               }
+               pos = to;
+           }
+       }, 20); // We're only interested in collapsed ranges of a significant size
+       if (pos < to) {
+           ranges.push({ from: pos, to });
+           total += to - pos;
+       }
+       return { total, ranges };
+   }
+   function findPosition({ total, ranges }, ratio) {
+       if (ratio <= 0)
+           return ranges[0].from;
+       if (ratio >= 1)
+           return ranges[ranges.length - 1].to;
+       let dist = Math.floor(total * ratio);
+       for (let i = 0;; i++) {
+           let { from, to } = ranges[i], size = to - from;
+           if (dist <= size)
+               return from + dist;
+           dist -= size;
+       }
+   }
+   function findFraction(structure, pos) {
+       let counted = 0;
+       for (let { from, to } of structure.ranges) {
+           if (pos <= to) {
+               counted += pos - from;
+               break;
+           }
+           counted += to - from;
+       }
+       return counted / structure.total;
+   }
+   function find(array, f) {
+       for (let val of array)
+           if (f(val))
+               return val;
+       return undefined;
+   }
+   // Don't scale when the document height is within the range of what
+   // the DOM can handle.
+   const IdScaler = {
+       toDOM(n) { return n; },
+       fromDOM(n) { return n; },
+       scale: 1,
+       eq(other) { return other == this; }
+   };
+   // When the height is too big (> VP.MaxDOMHeight), scale down the
+   // regions outside the viewports so that the total height is
+   // VP.MaxDOMHeight.
+   class BigScaler {
+       constructor(oracle, heightMap, viewports) {
+           let vpHeight = 0, base = 0, domBase = 0;
+           this.viewports = viewports.map(({ from, to }) => {
+               let top = heightMap.lineAt(from, QueryType.ByPos, oracle, 0, 0).top;
+               let bottom = heightMap.lineAt(to, QueryType.ByPos, oracle, 0, 0).bottom;
+               vpHeight += bottom - top;
+               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
+           });
+           this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
+           for (let obj of this.viewports) {
+               obj.domTop = domBase + (obj.top - base) * this.scale;
+               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
+               base = obj.bottom;
+           }
+       }
+       toDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.top)
+                   return domBase + (n - base) * this.scale;
+               if (n <= vp.bottom)
+                   return vp.domTop + (n - vp.top);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+       fromDOM(n) {
+           for (let i = 0, base = 0, domBase = 0;; i++) {
+               let vp = i < this.viewports.length ? this.viewports[i] : null;
+               if (!vp || n < vp.domTop)
+                   return base + (n - domBase) / this.scale;
+               if (n <= vp.domBottom)
+                   return vp.top + (n - vp.domTop);
+               base = vp.bottom;
+               domBase = vp.domBottom;
+           }
+       }
+       eq(other) {
+           if (!(other instanceof BigScaler))
+               return false;
+           return this.scale == other.scale && this.viewports.length == other.viewports.length &&
+               this.viewports.every((vp, i) => vp.from == other.viewports[i].from && vp.to == other.viewports[i].to);
+       }
+   }
+   function scaleBlock(block, scaler) {
+       if (scaler.scale == 1)
+           return block;
+       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
+       return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);
+   }
+
+   const theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(" ") });
+   const darkTheme = /*@__PURE__*/Facet.define({ combine: values => values.indexOf(true) > -1 });
+   const baseThemeID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();
+   const lightDarkIDs = { "&light": "." + baseLightID, "&dark": "." + baseDarkID };
+   function buildTheme(main, spec, scopes) {
+       return new StyleModule(spec, {
+           finish(sel) {
+               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
+                   if (m == "&")
+                       return main;
+                   if (!scopes || !scopes[m])
+                       throw new RangeError(`Unsupported selector: ${m}`);
+                   return scopes[m];
+               }) : main + " " + sel;
+           }
+       });
+   }
+   const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
+       "&": {
+           position: "relative !important",
+           boxSizing: "border-box",
+           "&.cm-focused": {
+               // Provide a simple default outline to make sure a focused
+               // editor is visually distinct. Can't leave the default behavior
+               // because that will apply to the content element, which is
+               // inside the scrollable container and doesn't include the
+               // gutters. We also can't use an 'auto' outline, since those
+               // are, for some reason, drawn behind the element content, which
+               // will cause things like the active line background to cover
+               // the outline (#297).
+               outline: "1px dotted #212121"
+           },
+           display: "flex !important",
+           flexDirection: "column"
+       },
+       ".cm-scroller": {
+           display: "flex !important",
+           alignItems: "flex-start !important",
+           fontFamily: "monospace",
+           lineHeight: 1.4,
+           height: "100%",
+           overflowX: "auto",
+           position: "relative",
+           zIndex: 0,
+           overflowAnchor: "none",
+       },
+       ".cm-content": {
+           margin: 0,
+           flexGrow: 2,
+           flexShrink: 0,
+           display: "block",
+           whiteSpace: "pre",
+           wordWrap: "normal", // https://github.com/codemirror/dev/issues/456
+           boxSizing: "border-box",
+           minHeight: "100%",
+           padding: "4px 0",
+           outline: "none",
+           "&[contenteditable=true]": {
+               WebkitUserModify: "read-write-plaintext-only",
+           }
+       },
+       ".cm-lineWrapping": {
+           whiteSpace_fallback: "pre-wrap", // For IE
+           whiteSpace: "break-spaces",
+           wordBreak: "break-word", // For Safari, which doesn't support overflow-wrap: anywhere
+           overflowWrap: "anywhere",
+           flexShrink: 1
+       },
+       "&light .cm-content": { caretColor: "black" },
+       "&dark .cm-content": { caretColor: "white" },
+       ".cm-line": {
+           display: "block",
+           padding: "0 2px 0 6px"
+       },
+       ".cm-layer": {
+           position: "absolute",
+           left: 0,
+           top: 0,
+           contain: "size style",
+           "& > *": {
+               position: "absolute"
+           }
+       },
+       "&light .cm-selectionBackground": {
+           background: "#d9d9d9"
+       },
+       "&dark .cm-selectionBackground": {
+           background: "#222"
+       },
+       "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
+           background: "#d7d4f0"
+       },
+       "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
+           background: "#233"
+       },
+       ".cm-cursorLayer": {
+           pointerEvents: "none"
+       },
+       "&.cm-focused > .cm-scroller > .cm-cursorLayer": {
+           animation: "steps(1) cm-blink 1.2s infinite"
+       },
+       // Two animations defined so that we can switch between them to
+       // restart the animation without forcing another style
+       // recomputation.
+       "@keyframes cm-blink": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
+       "@keyframes cm-blink2": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
+       ".cm-cursor, .cm-dropCursor": {
+           borderLeft: "1.2px solid black",
+           marginLeft: "-0.6px",
+           pointerEvents: "none",
+       },
+       ".cm-cursor": {
+           display: "none"
+       },
+       "&dark .cm-cursor": {
+           borderLeftColor: "#ddd"
+       },
+       ".cm-dropCursor": {
+           position: "absolute"
+       },
+       "&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
+           display: "block"
+       },
+       ".cm-iso": {
+           unicodeBidi: "isolate"
+       },
+       ".cm-announced": {
+           position: "fixed",
+           top: "-10000px"
+       },
+       "@media print": {
+           ".cm-announced": { display: "none" }
+       },
+       "&light .cm-activeLine": { backgroundColor: "#cceeff44" },
+       "&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
+       "&light .cm-specialChar": { color: "red" },
+       "&dark .cm-specialChar": { color: "#f78" },
+       ".cm-gutters": {
+           flexShrink: 0,
+           display: "flex",
+           height: "100%",
+           boxSizing: "border-box",
+           insetInlineStart: 0,
+           zIndex: 200
+       },
+       "&light .cm-gutters": {
+           backgroundColor: "#f5f5f5",
+           color: "#6c6c6c",
+           borderRight: "1px solid #ddd"
+       },
+       "&dark .cm-gutters": {
+           backgroundColor: "#333338",
+           color: "#ccc"
+       },
+       ".cm-gutter": {
+           display: "flex !important", // Necessary -- prevents margin collapsing
+           flexDirection: "column",
+           flexShrink: 0,
+           boxSizing: "border-box",
+           minHeight: "100%",
+           overflow: "hidden"
+       },
+       ".cm-gutterElement": {
+           boxSizing: "border-box"
+       },
+       ".cm-lineNumbers .cm-gutterElement": {
+           padding: "0 3px 0 5px",
+           minWidth: "20px",
+           textAlign: "right",
+           whiteSpace: "nowrap"
+       },
+       "&light .cm-activeLineGutter": {
+           backgroundColor: "#e2f2ff"
+       },
+       "&dark .cm-activeLineGutter": {
+           backgroundColor: "#222227"
+       },
+       ".cm-panels": {
+           boxSizing: "border-box",
+           position: "sticky",
+           left: 0,
+           right: 0,
+           zIndex: 300
+       },
+       "&light .cm-panels": {
+           backgroundColor: "#f5f5f5",
+           color: "black"
+       },
+       "&light .cm-panels-top": {
+           borderBottom: "1px solid #ddd"
+       },
+       "&light .cm-panels-bottom": {
+           borderTop: "1px solid #ddd"
+       },
+       "&dark .cm-panels": {
+           backgroundColor: "#333338",
+           color: "white"
+       },
+       ".cm-tab": {
+           display: "inline-block",
+           overflow: "hidden",
+           verticalAlign: "bottom"
+       },
+       ".cm-widgetBuffer": {
+           verticalAlign: "text-top",
+           height: "1em",
+           width: 0,
+           display: "inline"
+       },
+       ".cm-placeholder": {
+           color: "#888",
+           display: "inline-block",
+           verticalAlign: "top",
+       },
+       ".cm-highlightSpace": {
+           backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
+           backgroundPosition: "center",
+       },
+       ".cm-highlightTab": {
+           backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
+           backgroundSize: "auto 100%",
+           backgroundPosition: "right 90%",
+           backgroundRepeat: "no-repeat"
+       },
+       ".cm-trailingSpace": {
+           backgroundColor: "#ff332255"
+       },
+       ".cm-button": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           padding: ".2em 1em",
+           borderRadius: "1px"
+       },
+       "&light .cm-button": {
+           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
+           }
+       },
+       "&dark .cm-button": {
+           backgroundImage: "linear-gradient(#393939, #111)",
+           border: "1px solid #888",
+           "&:active": {
+               backgroundImage: "linear-gradient(#111, #333)"
+           }
+       },
+       ".cm-textfield": {
+           verticalAlign: "middle",
+           color: "inherit",
+           fontSize: "70%",
+           border: "1px solid silver",
+           padding: ".2em .5em"
+       },
+       "&light .cm-textfield": {
+           backgroundColor: "white"
+       },
+       "&dark .cm-textfield": {
+           border: "1px solid #555",
+           backgroundColor: "inherit"
+       }
+   }, lightDarkIDs);
+
+   const observeOptions = {
+       childList: true,
+       characterData: true,
+       subtree: true,
+       attributes: true,
+       characterDataOldValue: true
+   };
+   // IE11 has very broken mutation observers, so we also listen to
+   // DOMCharacterDataModified there
+   const useCharData = browser.ie && browser.ie_version <= 11;
+   class DOMObserver {
+       constructor(view) {
+           this.view = view;
+           this.active = false;
+           this.editContext = null;
+           // The known selection. Kept in our own object, as opposed to just
+           // directly accessing the selection because:
+           //  - Safari doesn't report the right selection in shadow DOM
+           //  - Reading from the selection forces a DOM layout
+           //  - This way, we can ignore selectionchange events if we have
+           //    already seen the 'new' selection
+           this.selectionRange = new DOMSelectionState;
+           // Set when a selection change is detected, cleared on flush
+           this.selectionChanged = false;
+           this.delayedFlush = -1;
+           this.resizeTimeout = -1;
+           this.queue = [];
+           this.delayedAndroidKey = null;
+           this.flushingAndroidKey = -1;
+           this.lastChange = 0;
+           this.scrollTargets = [];
+           this.intersection = null;
+           this.resizeScroll = null;
+           this.intersecting = false;
+           this.gapIntersection = null;
+           this.gaps = [];
+           this.printQuery = null;
+           // Timeout for scheduling check of the parents that need scroll handlers
+           this.parentCheck = -1;
+           this.dom = view.contentDOM;
+           this.observer = new MutationObserver(mutations => {
+               for (let mut of mutations)
+                   this.queue.push(mut);
+               // IE11 will sometimes (on typing over a selection or
+               // backspacing out a single character text node) call the
+               // observer callback before actually updating the DOM.
+               //
+               // Unrelatedly, iOS Safari will, when ending a composition,
+               // sometimes first clear it, deliver the mutations, and then
+               // reinsert the finished text. CodeMirror's handling of the
+               // deletion will prevent the reinsertion from happening,
+               // breaking composition.
+               if ((browser.ie && browser.ie_version <= 11 || browser.ios && view.composing) &&
+                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
+                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
+                   this.flushSoon();
+               else
+                   this.flush();
+           });
+           if (window.EditContext && view.constructor.EDIT_CONTEXT !== false &&
+               // Chrome <126 doesn't support inverted selections in edit context (#1392)
+               !(browser.chrome && browser.chrome_version < 126)) {
+               this.editContext = new EditContextManager(view);
+               if (view.state.facet(editable))
+                   view.contentDOM.editContext = this.editContext.editContext;
+           }
+           if (useCharData)
+               this.onCharData = (event) => {
+                   this.queue.push({ target: event.target,
+                       type: "characterData",
+                       oldValue: event.prevValue });
+                   this.flushSoon();
+               };
+           this.onSelectionChange = this.onSelectionChange.bind(this);
+           this.onResize = this.onResize.bind(this);
+           this.onPrint = this.onPrint.bind(this);
+           this.onScroll = this.onScroll.bind(this);
+           if (window.matchMedia)
+               this.printQuery = window.matchMedia("print");
+           if (typeof ResizeObserver == "function") {
+               this.resizeScroll = new ResizeObserver(() => {
+                   var _a;
+                   if (((_a = this.view.docView) === null || _a === void 0 ? void 0 : _a.lastUpdate) < Date.now() - 75)
+                       this.onResize();
+               });
+               this.resizeScroll.observe(view.scrollDOM);
+           }
+           this.addWindowListeners(this.win = view.win);
+           this.start();
+           if (typeof IntersectionObserver == "function") {
+               this.intersection = new IntersectionObserver(entries => {
+                   if (this.parentCheck < 0)
+                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
+                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
+                       this.intersecting = !this.intersecting;
+                       if (this.intersecting != this.view.inView)
+                           this.onScrollChanged(document.createEvent("Event"));
+                   }
+               }, { threshold: [0, .001] });
+               this.intersection.observe(this.dom);
+               this.gapIntersection = new IntersectionObserver(entries => {
+                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
+                       this.onScrollChanged(document.createEvent("Event"));
+               }, {});
+           }
+           this.listenForScroll();
+           this.readSelectionRange();
+       }
+       onScrollChanged(e) {
+           this.view.inputState.runHandlers("scroll", e);
+           if (this.intersecting)
+               this.view.measure();
+       }
+       onScroll(e) {
+           if (this.intersecting)
+               this.flush(false);
+           if (this.editContext)
+               this.view.requestMeasure(this.editContext.measureReq);
+           this.onScrollChanged(e);
+       }
+       onResize() {
+           if (this.resizeTimeout < 0)
+               this.resizeTimeout = setTimeout(() => {
+                   this.resizeTimeout = -1;
+                   this.view.requestMeasure();
+               }, 50);
+       }
+       onPrint(event) {
+           if ((event.type == "change" || !event.type) && !event.matches)
+               return;
+           this.view.viewState.printing = true;
+           this.view.measure();
+           setTimeout(() => {
+               this.view.viewState.printing = false;
+               this.view.requestMeasure();
+           }, 500);
+       }
+       updateGaps(gaps) {
+           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
+               this.gapIntersection.disconnect();
+               for (let gap of gaps)
+                   this.gapIntersection.observe(gap);
+               this.gaps = gaps;
+           }
+       }
+       onSelectionChange(event) {
+           let wasChanged = this.selectionChanged;
+           if (!this.readSelectionRange() || this.delayedAndroidKey)
+               return;
+           let { view } = this, sel = this.selectionRange;
+           if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(this.dom, sel))
+               return;
+           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
+           if (context && context.ignoreEvent(event)) {
+               if (!wasChanged)
+                   this.selectionChanged = false;
+               return;
+           }
+           // Deletions on IE11 fire their events in the wrong order, giving
+           // us a selection change event before the DOM changes are
+           // reported.
+           // Chrome Android has a similar issue when backspacing out a
+           // selection (#645).
+           if ((browser.ie && browser.ie_version <= 11 || browser.android && browser.chrome) && !view.state.selection.main.empty &&
+               // (Selection.isCollapsed isn't reliable on IE)
+               sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
+               this.flushSoon();
+           else
+               this.flush(false);
+       }
+       readSelectionRange() {
+           let { view } = this;
+           // The Selection object is broken in shadow roots in Safari. See
+           // https://github.com/codemirror/dev/issues/414
+           let selection = getSelection(view.root);
+           if (!selection)
+               return false;
+           let range = browser.safari && view.root.nodeType == 11 &&
+               view.root.activeElement == this.dom &&
+               safariSelectionRangeHack(this.view, selection) || selection;
+           if (!range || this.selectionRange.eq(range))
+               return false;
+           let local = hasSelection(this.dom, range);
+           // Detect the situation where the browser has, on focus, moved the
+           // selection to the start of the content element. Reset it to the
+           // position from the editor state.
+           if (local && !this.selectionChanged &&
+               view.inputState.lastFocusTime > Date.now() - 200 &&
+               view.inputState.lastTouchTime < Date.now() - 300 &&
+               atElementStart(this.dom, range)) {
+               this.view.inputState.lastFocusTime = 0;
+               view.docView.updateSelection();
+               return false;
+           }
+           this.selectionRange.setRange(range);
+           if (local)
+               this.selectionChanged = true;
+           return true;
+       }
+       setSelectionRange(anchor, head) {
+           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
+           this.selectionChanged = false;
+       }
+       clearSelectionRange() {
+           this.selectionRange.set(null, 0, null, 0);
+       }
+       listenForScroll() {
+           this.parentCheck = -1;
+           let i = 0, changed = null;
+           for (let dom = this.dom; dom;) {
+               if (dom.nodeType == 1) {
+                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
+                       i++;
+                   else if (!changed)
+                       changed = this.scrollTargets.slice(0, i);
+                   if (changed)
+                       changed.push(dom);
+                   dom = dom.assignedSlot || dom.parentNode;
+               }
+               else if (dom.nodeType == 11) { // Shadow root
+                   dom = dom.host;
+               }
+               else {
+                   break;
+               }
+           }
+           if (i < this.scrollTargets.length && !changed)
+               changed = this.scrollTargets.slice(0, i);
+           if (changed) {
+               for (let dom of this.scrollTargets)
+                   dom.removeEventListener("scroll", this.onScroll);
+               for (let dom of this.scrollTargets = changed)
+                   dom.addEventListener("scroll", this.onScroll);
+           }
+       }
+       ignore(f) {
+           if (!this.active)
+               return f();
+           try {
+               this.stop();
+               return f();
+           }
+           finally {
+               this.start();
+               this.clear();
+           }
+       }
+       start() {
+           if (this.active)
+               return;
+           this.observer.observe(this.dom, observeOptions);
+           if (useCharData)
+               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
+           this.active = true;
+       }
+       stop() {
+           if (!this.active)
+               return;
+           this.active = false;
+           this.observer.disconnect();
+           if (useCharData)
+               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
+       }
+       // Throw away any pending changes
+       clear() {
+           this.processRecords();
+           this.queue.length = 0;
+           this.selectionChanged = false;
+       }
+       // Chrome Android, especially in combination with GBoard, not only
+       // doesn't reliably fire regular key events, but also often
+       // surrounds the effect of enter or backspace with a bunch of
+       // composition events that, when interrupted, cause text duplication
+       // or other kinds of corruption. This hack makes the editor back off
+       // from handling DOM changes for a moment when such a key is
+       // detected (via beforeinput or keydown), and then tries to flush
+       // them or, if that has no effect, dispatches the given key.
+       delayAndroidKey(key, keyCode) {
+           var _a;
+           if (!this.delayedAndroidKey) {
+               let flush = () => {
+                   let key = this.delayedAndroidKey;
+                   if (key) {
+                       this.clearDelayedAndroidKey();
+                       this.view.inputState.lastKeyCode = key.keyCode;
+                       this.view.inputState.lastKeyTime = Date.now();
+                       let flushed = this.flush();
+                       if (!flushed && key.force)
+                           dispatchKey(this.dom, key.key, key.keyCode);
+                   }
+               };
+               this.flushingAndroidKey = this.view.win.requestAnimationFrame(flush);
+           }
+           // Since backspace beforeinput is sometimes signalled spuriously,
+           // Enter always takes precedence.
+           if (!this.delayedAndroidKey || key == "Enter")
+               this.delayedAndroidKey = {
+                   key, keyCode,
+                   // Only run the key handler when no changes are detected if
+                   // this isn't coming right after another change, in which case
+                   // it is probably part of a weird chain of updates, and should
+                   // be ignored if it returns the DOM to its previous state.
+                   force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
+               };
+       }
+       clearDelayedAndroidKey() {
+           this.win.cancelAnimationFrame(this.flushingAndroidKey);
+           this.delayedAndroidKey = null;
+           this.flushingAndroidKey = -1;
+       }
+       flushSoon() {
+           if (this.delayedFlush < 0)
+               this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
+       }
+       forceFlush() {
+           if (this.delayedFlush >= 0) {
+               this.view.win.cancelAnimationFrame(this.delayedFlush);
+               this.delayedFlush = -1;
+           }
+           this.flush();
+       }
+       pendingRecords() {
+           for (let mut of this.observer.takeRecords())
+               this.queue.push(mut);
+           return this.queue;
+       }
+       processRecords() {
+           let records = this.pendingRecords();
+           if (records.length)
+               this.queue = [];
+           let from = -1, to = -1, typeOver = false;
+           for (let record of records) {
+               let range = this.readMutation(record);
+               if (!range)
+                   continue;
+               if (range.typeOver)
+                   typeOver = true;
+               if (from == -1) {
+                   ({ from, to } = range);
+               }
+               else {
+                   from = Math.min(range.from, from);
+                   to = Math.max(range.to, to);
+               }
+           }
+           return { from, to, typeOver };
+       }
+       readChange() {
+           let { from, to, typeOver } = this.processRecords();
+           let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
+           if (from < 0 && !newSel)
+               return null;
+           if (from > -1)
+               this.lastChange = Date.now();
+           this.view.inputState.lastFocusTime = 0;
+           this.selectionChanged = false;
+           let change = new DOMChange(this.view, from, to, typeOver);
+           this.view.docView.domChanged = { newSel: change.newSel ? change.newSel.main : null };
+           return change;
+       }
+       // Apply pending changes, if any
+       flush(readSelection = true) {
+           // Completely hold off flushing when pending keys are set—the code
+           // managing those will make sure processRecords is called and the
+           // view is resynchronized after
+           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
+               return false;
+           if (readSelection)
+               this.readSelectionRange();
+           let domChange = this.readChange();
+           if (!domChange) {
+               this.view.requestMeasure();
+               return false;
+           }
+           let startState = this.view.state;
+           let handled = applyDOMChange(this.view, domChange);
+           // The view wasn't updated but DOM/selection changes were seen. Reset the view.
+           if (this.view.state == startState &&
+               (domChange.domChanged || domChange.newSel && !domChange.newSel.main.eq(this.view.state.selection.main)))
+               this.view.update([]);
+           return handled;
+       }
+       readMutation(rec) {
+           let cView = this.view.docView.nearest(rec.target);
+           if (!cView || cView.ignoreMutation(rec))
+               return null;
+           cView.markDirty(rec.type == "attributes");
+           if (rec.type == "attributes")
+               cView.flags |= 4 /* ViewFlag.AttrsDirty */;
+           if (rec.type == "childList") {
+               let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
+               let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
+               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
+                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
+           }
+           else if (rec.type == "characterData") {
+               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
+           }
+           else {
+               return null;
+           }
+       }
+       setWindow(win) {
+           if (win != this.win) {
+               this.removeWindowListeners(this.win);
+               this.win = win;
+               this.addWindowListeners(this.win);
+           }
+       }
+       addWindowListeners(win) {
+           win.addEventListener("resize", this.onResize);
+           if (this.printQuery) {
+               if (this.printQuery.addEventListener)
+                   this.printQuery.addEventListener("change", this.onPrint);
+               else
+                   this.printQuery.addListener(this.onPrint);
+           }
+           else
+               win.addEventListener("beforeprint", this.onPrint);
+           win.addEventListener("scroll", this.onScroll);
+           win.document.addEventListener("selectionchange", this.onSelectionChange);
+       }
+       removeWindowListeners(win) {
+           win.removeEventListener("scroll", this.onScroll);
+           win.removeEventListener("resize", this.onResize);
+           if (this.printQuery) {
+               if (this.printQuery.removeEventListener)
+                   this.printQuery.removeEventListener("change", this.onPrint);
+               else
+                   this.printQuery.removeListener(this.onPrint);
+           }
+           else
+               win.removeEventListener("beforeprint", this.onPrint);
+           win.document.removeEventListener("selectionchange", this.onSelectionChange);
+       }
+       update(update) {
+           if (this.editContext) {
+               this.editContext.update(update);
+               if (update.startState.facet(editable) != update.state.facet(editable))
+                   update.view.contentDOM.editContext = update.state.facet(editable) ? this.editContext.editContext : null;
+           }
+       }
+       destroy() {
+           var _a, _b, _c;
+           this.stop();
+           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
+           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
+           (_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();
+           for (let dom of this.scrollTargets)
+               dom.removeEventListener("scroll", this.onScroll);
+           this.removeWindowListeners(this.win);
+           clearTimeout(this.parentCheck);
+           clearTimeout(this.resizeTimeout);
+           this.win.cancelAnimationFrame(this.delayedFlush);
+           this.win.cancelAnimationFrame(this.flushingAndroidKey);
+           if (this.editContext) {
+               this.view.contentDOM.editContext = null;
+               this.editContext.destroy();
+           }
+       }
+   }
+   function findChild(cView, dom, dir) {
+       while (dom) {
+           let curView = ContentView.get(dom);
+           if (curView && curView.parent == cView)
+               return curView;
+           let parent = dom.parentNode;
+           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
+       }
+       return null;
+   }
+   function buildSelectionRangeFromRange(view, range) {
+       let anchorNode = range.startContainer, anchorOffset = range.startOffset;
+       let focusNode = range.endContainer, focusOffset = range.endOffset;
+       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
+       // Since such a range doesn't distinguish between anchor and head,
+       // use a heuristic that flips it around if its end matches the
+       // current anchor.
+       if (isEquivalentPosition(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
+           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
+       return { anchorNode, anchorOffset, focusNode, focusOffset };
+   }
+   // Used to work around a Safari Selection/shadow DOM bug (#414)
+   function safariSelectionRangeHack(view, selection) {
+       if (selection.getComposedRanges) {
+           let range = selection.getComposedRanges(view.root)[0];
+           if (range)
+               return buildSelectionRangeFromRange(view, range);
+       }
+       let found = null;
+       // Because Safari (at least in 2018-2021) doesn't provide regular
+       // access to the selection inside a shadowroot, we have to perform a
+       // ridiculous hack to get at it—using `execCommand` to trigger a
+       // `beforeInput` event so that we can read the target range from the
+       // event.
+       function read(event) {
+           event.preventDefault();
+           event.stopImmediatePropagation();
+           found = event.getTargetRanges()[0];
+       }
+       view.contentDOM.addEventListener("beforeinput", read, true);
+       view.dom.ownerDocument.execCommand("indent");
+       view.contentDOM.removeEventListener("beforeinput", read, true);
+       return found ? buildSelectionRangeFromRange(view, found) : null;
+   }
+   class EditContextManager {
+       constructor(view) {
+           // The document window for which the text in the context is
+           // maintained. For large documents, this may be smaller than the
+           // editor document. This window always includes the selection head.
+           this.from = 0;
+           this.to = 0;
+           // When applying a transaction, this is used to compare the change
+           // made to the context content to the change in the transaction in
+           // order to make the minimal changes to the context (since touching
+           // that sometimes breaks series of multiple edits made for a single
+           // user action on some Android keyboards)
+           this.pendingContextChange = null;
+           this.handlers = Object.create(null);
+           // Kludge to work around the fact that EditContext does not respond
+           // well to having its content updated during a composition (see #1472)
+           this.composing = null;
+           this.resetRange(view.state);
+           let context = this.editContext = new window.EditContext({
+               text: view.state.doc.sliceString(this.from, this.to),
+               selectionStart: this.toContextPos(Math.max(this.from, Math.min(this.to, view.state.selection.main.anchor))),
+               selectionEnd: this.toContextPos(view.state.selection.main.head)
+           });
+           this.handlers.textupdate = e => {
+               let { anchor } = view.state.selection.main;
+               let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
+               if (view.inputState.composing >= 0 && !this.composing)
+                   this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
+               let change = { from, to, insert: Text.of(e.text.split("\n")) };
+               // If the window doesn't include the anchor, assume changes
+               // adjacent to a side go up to the anchor.
+               if (change.from == this.from && anchor < this.from)
+                   change.from = anchor;
+               else if (change.to == this.to && anchor > this.to)
+                   change.to = anchor;
+               // Edit contexts sometimes fire empty changes
+               if (change.from == change.to && !change.insert.length)
+                   return;
+               this.pendingContextChange = change;
+               if (!view.state.readOnly) {
+                   let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
+                   applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart, newLen), this.toEditorPos(e.selectionEnd, newLen)));
+               }
+               // If the transaction didn't flush our change, revert it so
+               // that the context is in sync with the editor state again.
+               if (this.pendingContextChange) {
+                   this.revertPending(view.state);
+                   this.setSelection(view.state);
+               }
+           };
+           this.handlers.characterboundsupdate = e => {
+               let rects = [], prev = null;
+               for (let i = this.toEditorPos(e.rangeStart), end = this.toEditorPos(e.rangeEnd); i < end; i++) {
+                   let rect = view.coordsForChar(i);
+                   prev = (rect && new DOMRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top))
+                       || prev || new DOMRect;
+                   rects.push(prev);
+               }
+               context.updateCharacterBounds(e.rangeStart, rects);
+           };
+           this.handlers.textformatupdate = e => {
+               let deco = [];
+               for (let format of e.getTextFormats()) {
+                   let lineStyle = format.underlineStyle, thickness = format.underlineThickness;
+                   if (lineStyle != "None" && thickness != "None") {
+                       let from = this.toEditorPos(format.rangeStart), to = this.toEditorPos(format.rangeEnd);
+                       if (from < to) {
+                           let style = `text-decoration: underline ${lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${thickness == "Thin" ? 1 : 2}px`;
+                           deco.push(Decoration.mark({ attributes: { style } }).range(from, to));
+                       }
+                   }
+               }
+               view.dispatch({ effects: setEditContextFormatting.of(Decoration.set(deco)) });
+           };
+           this.handlers.compositionstart = () => {
+               if (view.inputState.composing < 0) {
+                   view.inputState.composing = 0;
+                   view.inputState.compositionFirstChange = true;
+               }
+           };
+           this.handlers.compositionend = () => {
+               view.inputState.composing = -1;
+               view.inputState.compositionFirstChange = null;
+               if (this.composing) {
+                   let { drifted } = this.composing;
+                   this.composing = null;
+                   if (drifted)
+                       this.reset(view.state);
+               }
+           };
+           for (let event in this.handlers)
+               context.addEventListener(event, this.handlers[event]);
+           this.measureReq = { read: view => {
+                   this.editContext.updateControlBounds(view.contentDOM.getBoundingClientRect());
+                   let sel = getSelection(view.root);
+                   if (sel && sel.rangeCount)
+                       this.editContext.updateSelectionBounds(sel.getRangeAt(0).getBoundingClientRect());
+               } };
+       }
+       applyEdits(update) {
+           let off = 0, abort = false, pending = this.pendingContextChange;
+           update.changes.iterChanges((fromA, toA, _fromB, _toB, insert) => {
+               if (abort)
+                   return;
+               let dLen = insert.length - (toA - fromA);
+               if (pending && toA >= pending.to) {
+                   if (pending.from == fromA && pending.to == toA && pending.insert.eq(insert)) {
+                       pending = this.pendingContextChange = null; // Match
+                       off += dLen;
+                       this.to += dLen;
+                       return;
+                   }
+                   else { // Mismatch, revert
+                       pending = null;
+                       this.revertPending(update.state);
+                   }
+               }
+               fromA += off;
+               toA += off;
+               if (toA <= this.from) { // Before the window
+                   this.from += dLen;
+                   this.to += dLen;
+               }
+               else if (fromA < this.to) { // Overlaps with window
+                   if (fromA < this.from || toA > this.to || (this.to - this.from) + insert.length > 30000 /* CxVp.MaxSize */) {
+                       abort = true;
+                       return;
+                   }
+                   this.editContext.updateText(this.toContextPos(fromA), this.toContextPos(toA), insert.toString());
+                   this.to += dLen;
+               }
+               off += dLen;
+           });
+           if (pending && !abort)
+               this.revertPending(update.state);
+           return !abort;
+       }
+       update(update) {
+           let reverted = this.pendingContextChange;
+           if (this.composing && (this.composing.drifted || update.transactions.some(tr => !tr.isUserEvent("input.type") && tr.changes.touchesRange(this.from, this.to)))) {
+               this.composing.drifted = true;
+               this.composing.editorBase = update.changes.mapPos(this.composing.editorBase);
+           }
+           else if (!this.applyEdits(update) || !this.rangeIsValid(update.state)) {
+               this.pendingContextChange = null;
+               this.reset(update.state);
+           }
+           else if (update.docChanged || update.selectionSet || reverted) {
+               this.setSelection(update.state);
+           }
+           if (update.geometryChanged || update.docChanged || update.selectionSet)
+               update.view.requestMeasure(this.measureReq);
+       }
+       resetRange(state) {
+           let { head } = state.selection.main;
+           this.from = Math.max(0, head - 10000 /* CxVp.Margin */);
+           this.to = Math.min(state.doc.length, head + 10000 /* CxVp.Margin */);
+       }
+       reset(state) {
+           this.resetRange(state);
+           this.editContext.updateText(0, this.editContext.text.length, state.doc.sliceString(this.from, this.to));
+           this.setSelection(state);
+       }
+       revertPending(state) {
+           let pending = this.pendingContextChange;
+           this.pendingContextChange = null;
+           this.editContext.updateText(this.toContextPos(pending.from), this.toContextPos(pending.from + pending.insert.length), state.doc.sliceString(pending.from, pending.to));
+       }
+       setSelection(state) {
+           let { main } = state.selection;
+           let start = this.toContextPos(Math.max(this.from, Math.min(this.to, main.anchor)));
+           let end = this.toContextPos(main.head);
+           if (this.editContext.selectionStart != start || this.editContext.selectionEnd != end)
+               this.editContext.updateSelection(start, end);
+       }
+       rangeIsValid(state) {
+           let { head } = state.selection.main;
+           return !(this.from > 0 && head - this.from < 500 /* CxVp.MinMargin */ ||
+               this.to < state.doc.length && this.to - head < 500 /* CxVp.MinMargin */ ||
+               this.to - this.from > 10000 /* CxVp.Margin */ * 3);
+       }
+       toEditorPos(contextPos, clipLen = this.to - this.from) {
+           contextPos = Math.min(contextPos, clipLen);
+           let c = this.composing;
+           return c && c.drifted ? c.editorBase + (contextPos - c.contextBase) : contextPos + this.from;
+       }
+       toContextPos(editorPos) {
+           let c = this.composing;
+           return c && c.drifted ? c.contextBase + (editorPos - c.editorBase) : editorPos - this.from;
+       }
+       destroy() {
+           for (let event in this.handlers)
+               this.editContext.removeEventListener(event, this.handlers[event]);
+       }
+   }
+
+   // The editor's update state machine looks something like this:
+   //
+   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
+   //                                         ↑      ↓
+   //                                         Updating (measure)
+   //
+   // The difference between 'Idle' and 'Idle (unchecked)' lies in
+   // whether a layout check has been scheduled. A regular update through
+   // the `update` method updates the DOM in a write-only fashion, and
+   // relies on a check (scheduled with `requestAnimationFrame`) to make
+   // sure everything is where it should be and the viewport covers the
+   // visible code. That check continues to measure and then optionally
+   // update until it reaches a coherent state.
+   /**
+   An editor view represents the editor's user interface. It holds
+   the editable DOM surface, and possibly other elements such as the
+   line number gutter. It handles events and dispatches state
+   transactions for editing actions.
+   */
+   class EditorView {
+       /**
+       The current editor state.
+       */
+       get state() { return this.viewState.state; }
+       /**
+       To be able to display large documents without consuming too much
+       memory or overloading the browser, CodeMirror only draws the
+       code that is visible (plus a margin around it) to the DOM. This
+       property tells you the extent of the current drawn viewport, in
+       document positions.
+       */
+       get viewport() { return this.viewState.viewport; }
+       /**
+       When there are, for example, large collapsed ranges in the
+       viewport, its size can be a lot bigger than the actual visible
+       content. Thus, if you are doing something like styling the
+       content in the viewport, it is preferable to only do so for
+       these ranges, which are the subset of the viewport that is
+       actually drawn.
+       */
+       get visibleRanges() { return this.viewState.visibleRanges; }
+       /**
+       Returns false when the editor is entirely scrolled out of view
+       or otherwise hidden.
+       */
+       get inView() { return this.viewState.inView; }
+       /**
+       Indicates whether the user is currently composing text via
+       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
+       one change has been made in the current composition.
+       */
+       get composing() { return this.inputState.composing > 0; }
+       /**
+       Indicates whether the user is currently in composing state. Note
+       that on some platforms, like Android, this will be the case a
+       lot, since just putting the cursor on a word starts a
+       composition there.
+       */
+       get compositionStarted() { return this.inputState.composing >= 0; }
+       /**
+       The document or shadow root that the view lives in.
+       */
+       get root() { return this._root; }
+       /**
+       @internal
+       */
+       get win() { return this.dom.ownerDocument.defaultView || window; }
+       /**
+       Construct a new view. You'll want to either provide a `parent`
+       option, or put `view.dom` into your document after creating a
+       view, so that the user can see the editor.
+       */
+       constructor(config = {}) {
+           var _a;
+           this.plugins = [];
+           this.pluginMap = new Map;
+           this.editorAttrs = {};
+           this.contentAttrs = {};
+           this.bidiCache = [];
+           this.destroyed = false;
+           /**
+           @internal
+           */
+           this.updateState = 2 /* UpdateState.Updating */;
+           /**
+           @internal
+           */
+           this.measureScheduled = -1;
+           /**
+           @internal
+           */
+           this.measureRequests = [];
+           this.contentDOM = document.createElement("div");
+           this.scrollDOM = document.createElement("div");
+           this.scrollDOM.tabIndex = -1;
+           this.scrollDOM.className = "cm-scroller";
+           this.scrollDOM.appendChild(this.contentDOM);
+           this.announceDOM = document.createElement("div");
+           this.announceDOM.className = "cm-announced";
+           this.announceDOM.setAttribute("aria-live", "polite");
+           this.dom = document.createElement("div");
+           this.dom.appendChild(this.announceDOM);
+           this.dom.appendChild(this.scrollDOM);
+           if (config.parent)
+               config.parent.appendChild(this.dom);
+           let { dispatch } = config;
+           this.dispatchTransactions = config.dispatchTransactions ||
+               (dispatch && ((trs) => trs.forEach(tr => dispatch(tr, this)))) ||
+               ((trs) => this.update(trs));
+           this.dispatch = this.dispatch.bind(this);
+           this._root = (config.root || getRoot(config.parent) || document);
+           this.viewState = new ViewState(config.state || EditorState.create(config));
+           if (config.scrollTo && config.scrollTo.is(scrollIntoView$1))
+               this.viewState.scrollTarget = config.scrollTo.value.clip(this.viewState.state);
+           this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
+           for (let plugin of this.plugins)
+               plugin.update(this);
+           this.observer = new DOMObserver(this);
+           this.inputState = new InputState(this);
+           this.inputState.ensureHandlers(this.plugins);
+           this.docView = new DocView(this);
+           this.mountStyles();
+           this.updateAttrs();
+           this.updateState = 0 /* UpdateState.Idle */;
+           this.requestMeasure();
+           if ((_a = document.fonts) === null || _a === void 0 ? void 0 : _a.ready)
+               document.fonts.ready.then(() => this.requestMeasure());
+       }
+       dispatch(...input) {
+           let trs = input.length == 1 && input[0] instanceof Transaction ? input
+               : input.length == 1 && Array.isArray(input[0]) ? input[0]
+                   : [this.state.update(...input)];
+           this.dispatchTransactions(trs, this);
+       }
+       /**
+       Update the view for the given array of transactions. This will
+       update the visible document and selection to match the state
+       produced by the transactions, and notify view plugins of the
+       change. You should usually call
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
+       as a primitive.
+       */
+       update(transactions) {
+           if (this.updateState != 0 /* UpdateState.Idle */)
+               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
+           let redrawn = false, attrsChanged = false, update;
+           let state = this.state;
+           for (let tr of transactions) {
+               if (tr.startState != state)
+                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
+               state = tr.state;
+           }
+           if (this.destroyed) {
+               this.viewState.state = state;
+               return;
+           }
+           let focus = this.hasFocus, focusFlag = 0, dispatchFocus = null;
+           if (transactions.some(tr => tr.annotation(isFocusChange))) {
+               this.inputState.notifiedFocused = focus;
+               // If a focus-change transaction is being dispatched, set this update flag.
+               focusFlag = 1 /* UpdateFlag.Focus */;
+           }
+           else if (focus != this.inputState.notifiedFocused) {
+               this.inputState.notifiedFocused = focus;
+               // Schedule a separate focus transaction if necessary, otherwise
+               // add a flag to this update
+               dispatchFocus = focusChangeTransaction(state, focus);
+               if (!dispatchFocus)
+                   focusFlag = 1 /* UpdateFlag.Focus */;
+           }
+           // If there was a pending DOM change, eagerly read it and try to
+           // apply it after the given transactions.
+           let pendingKey = this.observer.delayedAndroidKey, domChange = null;
+           if (pendingKey) {
+               this.observer.clearDelayedAndroidKey();
+               domChange = this.observer.readChange();
+               // Only try to apply DOM changes if the transactions didn't
+               // change the doc or selection.
+               if (domChange && !this.state.doc.eq(state.doc) || !this.state.selection.eq(state.selection))
+                   domChange = null;
+           }
+           else {
+               this.observer.clear();
+           }
+           // When the phrases change, redraw the editor
+           if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases))
+               return this.setState(state);
+           update = ViewUpdate.create(this, state, transactions);
+           update.flags |= focusFlag;
+           let scrollTarget = this.viewState.scrollTarget;
+           try {
+               this.updateState = 2 /* UpdateState.Updating */;
+               for (let tr of transactions) {
+                   if (scrollTarget)
+                       scrollTarget = scrollTarget.map(tr.changes);
+                   if (tr.scrollIntoView) {
+                       let { main } = tr.state.selection;
+                       scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1));
+                   }
+                   for (let e of tr.effects)
+                       if (e.is(scrollIntoView$1))
+                           scrollTarget = e.value.clip(this.state);
+               }
+               this.viewState.update(update, scrollTarget);
+               this.bidiCache = CachedOrder.update(this.bidiCache, update.changes);
+               if (!update.empty) {
+                   this.updatePlugins(update);
+                   this.inputState.update(update);
+               }
+               redrawn = this.docView.update(update);
+               if (this.state.facet(styleModule) != this.styleModules)
+                   this.mountStyles();
+               attrsChanged = this.updateAttrs();
+               this.showAnnouncements(transactions);
+               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
+           }
+           finally {
+               this.updateState = 0 /* UpdateState.Idle */;
+           }
+           if (update.startState.facet(theme) != update.state.facet(theme))
+               this.viewState.mustMeasureContent = true;
+           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
+               this.requestMeasure();
+           if (redrawn)
+               this.docViewUpdate();
+           if (!update.empty)
+               for (let listener of this.state.facet(updateListener)) {
+                   try {
+                       listener(update);
+                   }
+                   catch (e) {
+                       logException(this.state, e, "update listener");
+                   }
+               }
+           if (dispatchFocus || domChange)
+               Promise.resolve().then(() => {
+                   if (dispatchFocus && this.state == dispatchFocus.startState)
+                       this.dispatch(dispatchFocus);
+                   if (domChange) {
+                       if (!applyDOMChange(this, domChange) && pendingKey.force)
+                           dispatchKey(this.contentDOM, pendingKey.key, pendingKey.keyCode);
+                   }
+               });
+       }
+       /**
+       Reset the view to the given state. (This will cause the entire
+       document to be redrawn and all view plugins to be reinitialized,
+       so you should probably only use it when the new state isn't
+       derived from the old state. Otherwise, use
+       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
+       */
+       setState(newState) {
+           if (this.updateState != 0 /* UpdateState.Idle */)
+               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
+           if (this.destroyed) {
+               this.viewState.state = newState;
+               return;
+           }
+           this.updateState = 2 /* UpdateState.Updating */;
+           let hadFocus = this.hasFocus;
+           try {
+               for (let plugin of this.plugins)
+                   plugin.destroy(this);
+               this.viewState = new ViewState(newState);
+               this.plugins = newState.facet(viewPlugin).map(spec => new PluginInstance(spec));
+               this.pluginMap.clear();
+               for (let plugin of this.plugins)
+                   plugin.update(this);
+               this.docView.destroy();
+               this.docView = new DocView(this);
+               this.inputState.ensureHandlers(this.plugins);
+               this.mountStyles();
+               this.updateAttrs();
+               this.bidiCache = [];
+           }
+           finally {
+               this.updateState = 0 /* UpdateState.Idle */;
+           }
+           if (hadFocus)
+               this.focus();
+           this.requestMeasure();
+       }
+       updatePlugins(update) {
+           let prevSpecs = update.startState.facet(viewPlugin), specs = update.state.facet(viewPlugin);
+           if (prevSpecs != specs) {
+               let newPlugins = [];
+               for (let spec of specs) {
+                   let found = prevSpecs.indexOf(spec);
+                   if (found < 0) {
+                       newPlugins.push(new PluginInstance(spec));
+                   }
+                   else {
+                       let plugin = this.plugins[found];
+                       plugin.mustUpdate = update;
+                       newPlugins.push(plugin);
+                   }
+               }
+               for (let plugin of this.plugins)
+                   if (plugin.mustUpdate != update)
+                       plugin.destroy(this);
+               this.plugins = newPlugins;
+               this.pluginMap.clear();
+           }
+           else {
+               for (let p of this.plugins)
+                   p.mustUpdate = update;
+           }
+           for (let i = 0; i < this.plugins.length; i++)
+               this.plugins[i].update(this);
+           if (prevSpecs != specs)
+               this.inputState.ensureHandlers(this.plugins);
+       }
+       docViewUpdate() {
+           for (let plugin of this.plugins) {
+               let val = plugin.value;
+               if (val && val.docViewUpdate) {
+                   try {
+                       val.docViewUpdate(this);
+                   }
+                   catch (e) {
+                       logException(this.state, e, "doc view update listener");
+                   }
+               }
+           }
+       }
+       /**
+       @internal
+       */
+       measure(flush = true) {
+           if (this.destroyed)
+               return;
+           if (this.measureScheduled > -1)
+               this.win.cancelAnimationFrame(this.measureScheduled);
+           if (this.observer.delayedAndroidKey) {
+               this.measureScheduled = -1;
+               this.requestMeasure();
+               return;
+           }
+           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
+           if (flush)
+               this.observer.forceFlush();
+           let updated = null;
+           let sDOM = this.scrollDOM, scrollTop = sDOM.scrollTop * this.scaleY;
+           let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
+           if (Math.abs(scrollTop - this.viewState.scrollTop) > 1)
+               scrollAnchorHeight = -1;
+           this.viewState.scrollAnchorHeight = -1;
+           try {
+               for (let i = 0;; i++) {
+                   if (scrollAnchorHeight < 0) {
+                       if (isScrolledToBottom(sDOM)) {
+                           scrollAnchorPos = -1;
+                           scrollAnchorHeight = this.viewState.heightMap.height;
+                       }
+                       else {
+                           let block = this.viewState.scrollAnchorAt(scrollTop);
+                           scrollAnchorPos = block.from;
+                           scrollAnchorHeight = block.top;
+                       }
+                   }
+                   this.updateState = 1 /* UpdateState.Measuring */;
+                   let changed = this.viewState.measure(this);
+                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
+                       break;
+                   if (i > 5) {
+                       console.warn(this.measureRequests.length
+                           ? "Measure loop restarted more than 5 times"
+                           : "Viewport failed to stabilize");
+                       break;
+                   }
+                   let measuring = [];
+                   // Only run measure requests in this cycle when the viewport didn't change
+                   if (!(changed & 4 /* UpdateFlag.Viewport */))
+                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
+                   let measured = measuring.map(m => {
+                       try {
+                           return m.read(this);
+                       }
+                       catch (e) {
+                           logException(this.state, e);
+                           return BadMeasure;
+                       }
+                   });
+                   let update = ViewUpdate.create(this, this.state, []), redrawn = false;
+                   update.flags |= changed;
+                   if (!updated)
+                       updated = update;
+                   else
+                       updated.flags |= changed;
+                   this.updateState = 2 /* UpdateState.Updating */;
+                   if (!update.empty) {
+                       this.updatePlugins(update);
+                       this.inputState.update(update);
+                       this.updateAttrs();
+                       redrawn = this.docView.update(update);
+                       if (redrawn)
+                           this.docViewUpdate();
+                   }
+                   for (let i = 0; i < measuring.length; i++)
+                       if (measured[i] != BadMeasure) {
+                           try {
+                               let m = measuring[i];
+                               if (m.write)
+                                   m.write(measured[i], this);
+                           }
+                           catch (e) {
+                               logException(this.state, e);
+                           }
+                       }
+                   if (redrawn)
+                       this.docView.updateSelection(true);
+                   if (!update.viewportChanged && this.measureRequests.length == 0) {
+                       if (this.viewState.editorHeight) {
+                           if (this.viewState.scrollTarget) {
+                               this.docView.scrollIntoView(this.viewState.scrollTarget);
+                               this.viewState.scrollTarget = null;
+                               scrollAnchorHeight = -1;
+                               continue;
+                           }
+                           else {
+                               let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :
+                                   this.viewState.lineBlockAt(scrollAnchorPos).top;
+                               let diff = newAnchorHeight - scrollAnchorHeight;
+                               if (diff > 1 || diff < -1) {
+                                   scrollTop = scrollTop + diff;
+                                   sDOM.scrollTop = scrollTop / this.scaleY;
+                                   scrollAnchorHeight = -1;
+                                   continue;
+                               }
+                           }
+                       }
+                       break;
+                   }
+               }
+           }
+           finally {
+               this.updateState = 0 /* UpdateState.Idle */;
+               this.measureScheduled = -1;
+           }
+           if (updated && !updated.empty)
+               for (let listener of this.state.facet(updateListener))
+                   listener(updated);
+       }
+       /**
+       Get the CSS classes for the currently active editor themes.
+       */
+       get themeClasses() {
+           return baseThemeID + " " +
+               (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + " " +
+               this.state.facet(theme);
+       }
+       updateAttrs() {
+           let editorAttrs = attrsFromFacet(this, editorAttributes, {
+               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
+           });
+           let contentAttrs = {
+               spellcheck: "false",
+               autocorrect: "off",
+               autocapitalize: "off",
+               writingsuggestions: "false",
+               translate: "no",
+               contenteditable: !this.state.facet(editable) ? "false" : "true",
+               class: "cm-content",
+               style: `${browser.tabSize}: ${this.state.tabSize}`,
+               role: "textbox",
+               "aria-multiline": "true"
+           };
+           if (this.state.readOnly)
+               contentAttrs["aria-readonly"] = "true";
+           attrsFromFacet(this, contentAttributes, contentAttrs);
+           let changed = this.observer.ignore(() => {
+               let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
+               let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);
+               return changedContent || changedEditor;
+           });
+           this.editorAttrs = editorAttrs;
+           this.contentAttrs = contentAttrs;
+           return changed;
+       }
+       showAnnouncements(trs) {
+           let first = true;
+           for (let tr of trs)
+               for (let effect of tr.effects)
+                   if (effect.is(EditorView.announce)) {
+                       if (first)
+                           this.announceDOM.textContent = "";
+                       first = false;
+                       let div = this.announceDOM.appendChild(document.createElement("div"));
+                       div.textContent = effect.value;
+                   }
+       }
+       mountStyles() {
+           this.styleModules = this.state.facet(styleModule);
+           let nonce = this.state.facet(EditorView.cspNonce);
+           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse(), nonce ? { nonce } : undefined);
+       }
+       readMeasured() {
+           if (this.updateState == 2 /* UpdateState.Updating */)
+               throw new Error("Reading the editor layout isn't allowed during an update");
+           if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
+               this.measure(false);
+       }
+       /**
+       Schedule a layout measurement, optionally providing callbacks to
+       do custom DOM measuring followed by a DOM write phase. Using
+       this is preferable reading DOM layout directly from, for
+       example, an event handler, because it'll make sure measuring and
+       drawing done by other components is synchronized, avoiding
+       unnecessary DOM layout computations.
+       */
+       requestMeasure(request) {
+           if (this.measureScheduled < 0)
+               this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
+           if (request) {
+               if (this.measureRequests.indexOf(request) > -1)
+                   return;
+               if (request.key != null)
+                   for (let i = 0; i < this.measureRequests.length; i++) {
+                       if (this.measureRequests[i].key === request.key) {
+                           this.measureRequests[i] = request;
+                           return;
+                       }
+                   }
+               this.measureRequests.push(request);
+           }
+       }
+       /**
+       Get the value of a specific plugin, if present. Note that
+       plugins that crash can be dropped from a view, so even when you
+       know you registered a given plugin, it is recommended to check
+       the return value of this method.
+       */
+       plugin(plugin) {
+           let known = this.pluginMap.get(plugin);
+           if (known === undefined || known && known.spec != plugin)
+               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
+           return known && known.update(this).value;
+       }
+       /**
+       The top position of the document, in screen coordinates. This
+       may be negative when the editor is scrolled down. Points
+       directly to the top of the first line, not above the padding.
+       */
+       get documentTop() {
+           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
+       }
+       /**
+       Reports the padding above and below the document.
+       */
+       get documentPadding() {
+           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
+       }
+       /**
+       If the editor is transformed with CSS, this provides the scale
+       along the X axis. Otherwise, it will just be 1. Note that
+       transforms other than translation and scaling are not supported.
+       */
+       get scaleX() { return this.viewState.scaleX; }
+       /**
+       Provide the CSS transformed scale along the Y axis.
+       */
+       get scaleY() { return this.viewState.scaleY; }
+       /**
+       Find the text line or block widget at the given vertical
+       position (which is interpreted as relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).
+       */
+       elementAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.elementAtHeight(height);
+       }
+       /**
+       Find the line block (see
+       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
+       height, again interpreted relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
+       */
+       lineBlockAtHeight(height) {
+           this.readMeasured();
+           return this.viewState.lineBlockAtHeight(height);
+       }
+       /**
+       Get the extent and vertical position of all [line
+       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
+       are relative to the [top of the
+       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
+       */
+       get viewportLineBlocks() {
+           return this.viewState.viewportLines;
+       }
+       /**
+       Find the line block around the given document position. A line
+       block is a range delimited on both sides by either a
+       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line break, or the
+       start/end of the document. It will usually just hold a line of
+       text, but may be broken into multiple textblocks by block
+       widgets.
+       */
+       lineBlockAt(pos) {
+           return this.viewState.lineBlockAt(pos);
+       }
+       /**
+       The editor's total content height.
+       */
+       get contentHeight() {
+           return this.viewState.contentHeight;
+       }
+       /**
+       Move a cursor position by [grapheme
+       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
+       the motion is away from the line start, or towards it. In
+       bidirectional text, the line is traversed in visual order, using
+       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
+       When the start position was the last one on the line, the
+       returned position will be across the line break. If there is no
+       further line, the original position is returned.
+       
+       By default, this method moves over a single cluster. The
+       optional `by` argument can be used to move across more. It will
+       be called with the first cluster as argument, and should return
+       a predicate that determines, for each subsequent cluster,
+       whether it should also be moved over.
+       */
+       moveByChar(start, forward, by) {
+           return skipAtoms(this, start, moveByChar(this, start, forward, by));
+       }
+       /**
+       Move a cursor position across the next group of either
+       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
+       non-whitespace characters.
+       */
+       moveByGroup(start, forward) {
+           return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));
+       }
+       /**
+       Get the cursor position visually at the start or end of a line.
+       Note that this may differ from the _logical_ position at its
+       start or end (which is simply at `line.from`/`line.to`) if text
+       at the start or end goes against the line's base text direction.
+       */
+       visualLineSide(line, end) {
+           let order = this.bidiSpans(line), dir = this.textDirectionAt(line.from);
+           let span = order[end ? order.length - 1 : 0];
+           return EditorSelection.cursor(span.side(end, dir) + line.from, span.forward(!end, dir) ? 1 : -1);
+       }
+       /**
+       Move to the next line boundary in the given direction. If
+       `includeWrap` is true, line wrapping is on, and there is a
+       further wrap point on the current line, the wrap point will be
+       returned. Otherwise this function will return the start or end
+       of the line.
+       */
+       moveToLineBoundary(start, forward, includeWrap = true) {
+           return moveToLineBoundary(this, start, forward, includeWrap);
+       }
+       /**
+       Move a cursor position vertically. When `distance` isn't given,
+       it defaults to moving to the next line (including wrapped
+       lines). Otherwise, `distance` should provide a positive distance
+       in pixels.
+       
+       When `start` has a
+       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
+       motion will use that as a target horizontal position. Otherwise,
+       the cursor's own horizontal position is used. The returned
+       cursor will have its goal column set to whichever column was
+       used.
+       */
+       moveVertically(start, forward, distance) {
+           return skipAtoms(this, start, moveVertically(this, start, forward, distance));
+       }
+       /**
+       Find the DOM parent node and offset (child offset if `node` is
+       an element, character offset when it is a text node) at the
+       given document position.
+       
+       Note that for positions that aren't currently in
+       `visibleRanges`, the resulting DOM position isn't necessarily
+       meaningful (it may just point before or after a placeholder
+       element).
+       */
+       domAtPos(pos) {
+           return this.docView.domAtPos(pos);
+       }
+       /**
+       Find the document position at the given DOM node. Can be useful
+       for associating positions with DOM events. Will raise an error
+       when `node` isn't part of the editor content.
+       */
+       posAtDOM(node, offset = 0) {
+           return this.docView.posFromDOM(node, offset);
+       }
+       posAtCoords(coords, precise = true) {
+           this.readMeasured();
+           return posAtCoords(this, coords, precise);
+       }
+       /**
+       Get the screen coordinates at the given document position.
+       `side` determines whether the coordinates are based on the
+       element before (-1) or after (1) the position (if no element is
+       available on the given side, the method will transparently use
+       another strategy to get reasonable coordinates).
+       */
+       coordsAtPos(pos, side = 1) {
+           this.readMeasured();
+           let rect = this.docView.coordsAt(pos, side);
+           if (!rect || rect.left == rect.right)
+               return rect;
+           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
+           let span = order[BidiSpan.find(order, pos - line.from, -1, side)];
+           return flattenRect(rect, (span.dir == Direction.LTR) == (side > 0));
+       }
+       /**
+       Return the rectangle around a given character. If `pos` does not
+       point in front of a character that is in the viewport and
+       rendered (i.e. not replaced, not a line break), this will return
+       null. For space characters that are a line wrap point, this will
+       return the position before the line break.
+       */
+       coordsForChar(pos) {
+           this.readMeasured();
+           return this.docView.coordsForChar(pos);
+       }
+       /**
+       The default width of a character in the editor. May not
+       accurately reflect the width of all characters (given variable
+       width fonts or styling of invididual ranges).
+       */
+       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
+       /**
+       The default height of a line in the editor. May not be accurate
+       for all lines.
+       */
+       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
+       /**
+       The text direction
+       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
+       CSS property) of the editor's content element.
+       */
+       get textDirection() { return this.viewState.defaultTextDirection; }
+       /**
+       Find the text direction of the block at the given position, as
+       assigned by CSS. If
+       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
+       isn't enabled, or the given position is outside of the viewport,
+       this will always return the same as
+       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
+       this may trigger a DOM layout.
+       */
+       textDirectionAt(pos) {
+           let perLine = this.state.facet(perLineTextDirection);
+           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
+               return this.textDirection;
+           this.readMeasured();
+           return this.docView.textDirectionAt(pos);
+       }
+       /**
+       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
+       (as determined by the
+       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
+       CSS property of its content element).
+       */
+       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
+       /**
+       Returns the bidirectional text structure of the given line
+       (which should be in the current document) as an array of span
+       objects. The order of these spans matches the [text
+       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
+       left-to-right, the leftmost spans come first, otherwise the
+       rightmost spans come first.
+       */
+       bidiSpans(line) {
+           if (line.length > MaxBidiLine)
+               return trivialOrder(line.length);
+           let dir = this.textDirectionAt(line.from), isolates;
+           for (let entry of this.bidiCache) {
+               if (entry.from == line.from && entry.dir == dir &&
+                   (entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line))))
+                   return entry.order;
+           }
+           if (!isolates)
+               isolates = getIsolatedRanges(this, line);
+           let order = computeOrder(line.text, dir, isolates);
+           this.bidiCache.push(new CachedOrder(line.from, line.to, dir, isolates, true, order));
+           return order;
+       }
+       /**
+       Check whether the editor has focus.
+       */
+       get hasFocus() {
+           var _a;
+           // Safari return false for hasFocus when the context menu is open
+           // or closing, which leads us to ignore selection changes from the
+           // context menu because it looks like the editor isn't focused.
+           // This kludges around that.
+           return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
+               this.root.activeElement == this.contentDOM;
+       }
+       /**
+       Put focus on the editor.
+       */
+       focus() {
+           this.observer.ignore(() => {
+               focusPreventScroll(this.contentDOM);
+               this.docView.updateSelection();
+           });
+       }
+       /**
+       Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only
+       necessary when moving the editor's existing DOM to a new window or shadow root.
+       */
+       setRoot(root) {
+           if (this._root != root) {
+               this._root = root;
+               this.observer.setWindow((root.nodeType == 9 ? root : root.ownerDocument).defaultView || window);
+               this.mountStyles();
+           }
+       }
+       /**
+       Clean up this editor view, removing its element from the
+       document, unregistering event handlers, and notifying
+       plugins. The view instance can no longer be used after
+       calling this.
+       */
+       destroy() {
+           if (this.root.activeElement == this.contentDOM)
+               this.contentDOM.blur();
+           for (let plugin of this.plugins)
+               plugin.destroy(this);
+           this.plugins = [];
+           this.inputState.destroy();
+           this.docView.destroy();
+           this.dom.remove();
+           this.observer.destroy();
+           if (this.measureScheduled > -1)
+               this.win.cancelAnimationFrame(this.measureScheduled);
+           this.destroyed = true;
+       }
+       /**
+       Returns an effect that can be
+       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
+       cause it to scroll the given position or range into view.
+       */
+       static scrollIntoView(pos, options = {}) {
+           return scrollIntoView$1.of(new ScrollTarget(typeof pos == "number" ? EditorSelection.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
+       }
+       /**
+       Return an effect that resets the editor to its current (at the
+       time this method was called) scroll position. Note that this
+       only affects the editor's own scrollable element, not parents.
+       See also
+       [`EditorViewConfig.scrollTo`](https://codemirror.net/6/docs/ref/#view.EditorViewConfig.scrollTo).
+       
+       The effect should be used with a document identical to the one
+       it was created for. Failing to do so is not an error, but may
+       not scroll to the expected position. You can
+       [map](https://codemirror.net/6/docs/ref/#state.StateEffect.map) the effect to account for changes.
+       */
+       scrollSnapshot() {
+           let { scrollTop, scrollLeft } = this.scrollDOM;
+           let ref = this.viewState.scrollAnchorAt(scrollTop);
+           return scrollIntoView$1.of(new ScrollTarget(EditorSelection.cursor(ref.from), "start", "start", ref.top - scrollTop, scrollLeft, true));
+       }
+       /**
+       Enable or disable tab-focus mode, which disables key bindings
+       for Tab and Shift-Tab, letting the browser's default
+       focus-changing behavior go through instead. This is useful to
+       prevent trapping keyboard users in your editor.
+       
+       Without argument, this toggles the mode. With a boolean, it
+       enables (true) or disables it (false). Given a number, it
+       temporarily enables the mode until that number of milliseconds
+       have passed or another non-Tab key is pressed.
+       */
+       setTabFocusMode(to) {
+           if (to == null)
+               this.inputState.tabFocusMode = this.inputState.tabFocusMode < 0 ? 0 : -1;
+           else if (typeof to == "boolean")
+               this.inputState.tabFocusMode = to ? 0 : -1;
+           else if (this.inputState.tabFocusMode != 0)
+               this.inputState.tabFocusMode = Date.now() + to;
+       }
+       /**
+       Returns an extension that can be used to add DOM event handlers.
+       The value should be an object mapping event names to handler
+       functions. For any given event, such functions are ordered by
+       extension precedence, and the first handler to return true will
+       be assumed to have handled that event, and no other handlers or
+       built-in behavior will be activated for it. These are registered
+       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
+       for `scroll` handlers, which will be called any time the
+       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
+       its parent nodes is scrolled.
+       */
+       static domEventHandlers(handlers) {
+           return ViewPlugin.define(() => ({}), { eventHandlers: handlers });
+       }
+       /**
+       Create an extension that registers DOM event observers. Contrary
+       to event [handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers),
+       observers can't be prevented from running by a higher-precedence
+       handler returning true. They also don't prevent other handlers
+       and observers from running when they return true, and should not
+       call `preventDefault`.
+       */
+       static domEventObservers(observers) {
+           return ViewPlugin.define(() => ({}), { eventObservers: observers });
+       }
+       /**
+       Create a theme extension. The first argument can be a
+       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
+       style spec providing the styles for the theme. These will be
+       prefixed with a generated class for the style.
+       
+       Because the selectors will be prefixed with a scope class, rule
+       that directly match the editor's [wrapper
+       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
+       added—need to be explicitly differentiated by adding an `&` to
+       the selector for that element—for example
+       `&.cm-focused`.
+       
+       When `dark` is set to true, the theme will be marked as dark,
+       which will cause the `&dark` rules from [base
+       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
+       `&light` when a light theme is active).
+       */
+       static theme(spec, options) {
+           let prefix = StyleModule.newName();
+           let result = [theme.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];
+           if (options && options.dark)
+               result.push(darkTheme.of(true));
+           return result;
+       }
+       /**
+       Create an extension that adds styles to the base theme. Like
+       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
+       place of the editor wrapper element when directly targeting
+       that. You can also use `&dark` or `&light` instead to only
+       target editors with a dark or light theme.
+       */
+       static baseTheme(spec) {
+           return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
+       }
+       /**
+       Retrieve an editor view instance from the view's DOM
+       representation.
+       */
+       static findFromDOM(dom) {
+           var _a;
+           let content = dom.querySelector(".cm-content");
+           let cView = content && ContentView.get(content) || ContentView.get(dom);
+           return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
+       }
+   }
+   /**
+   Facet to add a [style
+   module](https://github.com/marijnh/style-mod#documentation) to
+   an editor view. The view will ensure that the module is
+   mounted in its [document
+   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
+   */
+   EditorView.styleModule = styleModule;
+   /**
+   An input handler can override the way changes to the editable
+   DOM content are handled. Handlers are passed the document
+   positions between which the change was found, and the new
+   content. When one returns true, no further input handlers are
+   called and the default behavior is prevented.
+
+   The `insert` argument can be used to get the default transaction
+   that would be applied for this input. This can be useful when
+   dispatching the custom behavior as a separate transaction.
+   */
+   EditorView.inputHandler = inputHandler;
+   /**
+   Functions provided in this facet will be used to transform text
+   pasted or dropped into the editor.
+   */
+   EditorView.clipboardInputFilter = clipboardInputFilter;
+   /**
+   Transform text copied or dragged from the editor.
+   */
+   EditorView.clipboardOutputFilter = clipboardOutputFilter;
+   /**
+   Scroll handlers can override how things are scrolled into view.
+   If they return `true`, no further handling happens for the
+   scrolling. If they return false, the default scroll behavior is
+   applied. Scroll handlers should never initiate editor updates.
+   */
+   EditorView.scrollHandler = scrollHandler;
+   /**
+   This facet can be used to provide functions that create effects
+   to be dispatched when the editor's focus state changes.
+   */
+   EditorView.focusChangeEffect = focusChangeEffect;
+   /**
+   By default, the editor assumes all its content has the same
+   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
+   value to make it read the text direction of every (rendered)
+   line separately.
+   */
+   EditorView.perLineTextDirection = perLineTextDirection;
+   /**
+   Allows you to provide a function that should be called when the
+   library catches an exception from an extension (mostly from view
+   plugins, but may be used by other extensions to route exceptions
+   from user-code-provided callbacks). This is mostly useful for
+   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
+   */
+   EditorView.exceptionSink = exceptionSink;
+   /**
+   A facet that can be used to register a function to be called
+   every time the view updates.
+   */
+   EditorView.updateListener = updateListener;
+   /**
+   Facet that controls whether the editor content DOM is editable.
+   When its highest-precedence value is `false`, the element will
+   not have its `contenteditable` attribute set. (Note that this
+   doesn't affect API calls that change the editor content, even
+   when those are bound to keys or buttons. See the
+   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
+   */
+   EditorView.editable = editable;
+   /**
+   Allows you to influence the way mouse selection happens. The
+   functions in this facet will be called for a `mousedown` event
+   on the editor, and can return an object that overrides the way a
+   selection is computed from that mouse click or drag.
+   */
+   EditorView.mouseSelectionStyle = mouseSelectionStyle;
+   /**
+   Facet used to configure whether a given selection drag event
+   should move or copy the selection. The given predicate will be
+   called with the `mousedown` event, and can return `true` when
+   the drag should move the content.
+   */
+   EditorView.dragMovesSelection = dragMovesSelection$1;
+   /**
+   Facet used to configure whether a given selecting click adds a
+   new range to the existing selection or replaces it entirely. The
+   default behavior is to check `event.metaKey` on macOS, and
+   `event.ctrlKey` elsewhere.
+   */
+   EditorView.clickAddsSelectionRange = clickAddsSelectionRange;
+   /**
+   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
+   are shown in the view. Decorations can be provided in two
+   ways—directly, or via a function that takes an editor view.
+
+   Only decoration sets provided directly are allowed to influence
+   the editor's vertical layout structure. The ones provided as
+   functions are called _after_ the new viewport has been computed,
+   and thus **must not** introduce block widgets or replacing
+   decorations that cover line breaks.
+
+   If you want decorated ranges to behave like atomic units for
+   cursor motion and deletion purposes, also provide the range set
+   containing the decorations to
+   [`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
+   */
+   EditorView.decorations = decorations;
+   /**
+   Facet that works much like
+   [`decorations`](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), but puts its
+   inputs at the very bottom of the precedence stack, meaning mark
+   decorations provided here will only be split by other, partially
+   overlapping \`outerDecorations\` ranges, and wrap around all
+   regular decorations. Use this for mark elements that should, as
+   much as possible, remain in one piece.
+   */
+   EditorView.outerDecorations = outerDecorations;
+   /**
+   Used to provide ranges that should be treated as atoms as far as
+   cursor motion is concerned. This causes methods like
+   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
+   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
+   commands built on top of them) to skip across such regions when
+   a selection endpoint would enter them. This does _not_ prevent
+   direct programmatic [selection
+   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
+   regions.
+   */
+   EditorView.atomicRanges = atomicRanges;
+   /**
+   When range decorations add a `unicode-bidi: isolate` style, they
+   should also include a
+   [`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property
+   in their decoration spec, and be exposed through this facet, so
+   that the editor can compute the proper text order. (Other values
+   for `unicode-bidi`, except of course `normal`, are not
+   supported.)
+   */
+   EditorView.bidiIsolatedRanges = bidiIsolatedRanges;
+   /**
+   Facet that allows extensions to provide additional scroll
+   margins (space around the sides of the scrolling element that
+   should be considered invisible). This can be useful when the
+   plugin introduces elements that cover part of that element (for
+   example a horizontally fixed gutter).
+   */
+   EditorView.scrollMargins = scrollMargins;
+   /**
+   This facet records whether a dark theme is active. The extension
+   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
+   includes an instance of this when the `dark` option is set to
+   true.
+   */
+   EditorView.darkTheme = darkTheme;
+   /**
+   Provides a Content Security Policy nonce to use when creating
+   the style sheets for the editor. Holds the empty string when no
+   nonce has been provided.
+   */
+   EditorView.cspNonce = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : "" });
+   /**
+   Facet that provides additional DOM attributes for the editor's
+   editable DOM element.
+   */
+   EditorView.contentAttributes = contentAttributes;
+   /**
+   Facet that provides DOM attributes for the editor's outer
+   element.
+   */
+   EditorView.editorAttributes = editorAttributes;
+   /**
+   An extension that enables line wrapping in the editor (by
+   setting CSS `white-space` to `pre-wrap` in the content).
+   */
+   EditorView.lineWrapping = /*@__PURE__*/EditorView.contentAttributes.of({ "class": "cm-lineWrapping" });
+   /**
+   State effect used to include screen reader announcements in a
+   transaction. These will be added to the DOM in a visually hidden
+   element with `aria-live="polite"` set, and should be used to
+   describe effects that are visually obvious but may not be
+   noticed by screen reader users (such as moving to the next
+   search match).
+   */
+   EditorView.announce = /*@__PURE__*/StateEffect.define();
+   // Maximum line length for which we compute accurate bidi info
+   const MaxBidiLine = 4096;
+   const BadMeasure = {};
+   class CachedOrder {
+       constructor(from, to, dir, isolates, fresh, order) {
+           this.from = from;
+           this.to = to;
+           this.dir = dir;
+           this.isolates = isolates;
+           this.fresh = fresh;
+           this.order = order;
+       }
+       static update(cache, changes) {
+           if (changes.empty && !cache.some(c => c.fresh))
+               return cache;
+           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction.LTR;
+           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
+               let entry = cache[i];
+               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
+                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.isolates, false, entry.order));
+           }
+           return result;
+       }
+   }
+   function attrsFromFacet(view, facet, base) {
+       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
+           let source = sources[i], value = typeof source == "function" ? source(view) : source;
+           if (value)
+               combineAttrs(value, base);
+       }
+       return base;
+   }
+
+   const currentPlatform = browser.mac ? "mac" : browser.windows ? "win" : browser.linux ? "linux" : "key";
+   function normalizeKeyName(name, platform) {
+       const parts = name.split(/-(?!$)/);
+       let result = parts[parts.length - 1];
+       if (result == "Space")
+           result = " ";
+       let alt, ctrl, shift, meta;
+       for (let i = 0; i < parts.length - 1; ++i) {
+           const mod = parts[i];
+           if (/^(cmd|meta|m)$/i.test(mod))
+               meta = true;
+           else if (/^a(lt)?$/i.test(mod))
+               alt = true;
+           else if (/^(c|ctrl|control)$/i.test(mod))
+               ctrl = true;
+           else if (/^s(hift)?$/i.test(mod))
+               shift = true;
+           else if (/^mod$/i.test(mod)) {
+               if (platform == "mac")
+                   meta = true;
+               else
+                   ctrl = true;
+           }
+           else
+               throw new Error("Unrecognized modifier name: " + mod);
+       }
+       if (alt)
+           result = "Alt-" + result;
+       if (ctrl)
+           result = "Ctrl-" + result;
+       if (meta)
+           result = "Meta-" + result;
+       if (shift)
+           result = "Shift-" + result;
+       return result;
+   }
+   function modifiers(name, event, shift) {
+       if (event.altKey)
+           name = "Alt-" + name;
+       if (event.ctrlKey)
+           name = "Ctrl-" + name;
+       if (event.metaKey)
+           name = "Meta-" + name;
+       if (shift !== false && event.shiftKey)
+           name = "Shift-" + name;
+       return name;
+   }
+   const handleKeyEvents = /*@__PURE__*/Prec.default(/*@__PURE__*/EditorView.domEventHandlers({
+       keydown(event, view) {
+           return runHandlers(getKeymap(view.state), event, view, "editor");
+       }
+   }));
+   /**
+   Facet used for registering keymaps.
+
+   You can add multiple keymaps to an editor. Their priorities
+   determine their precedence (the ones specified early or with high
+   priority get checked first). When a handler has returned `true`
+   for a given key, no further handlers are called.
+   */
+   const keymap = /*@__PURE__*/Facet.define({ enables: handleKeyEvents });
+   const Keymaps = /*@__PURE__*/new WeakMap();
+   // This is hidden behind an indirection, rather than directly computed
+   // by the facet, to keep internal types out of the facet's type.
+   function getKeymap(state) {
+       let bindings = state.facet(keymap);
+       let map = Keymaps.get(bindings);
+       if (!map)
+           Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));
+       return map;
+   }
+   let storedPrefix = null;
+   const PrefixTimeout = 4000;
+   function buildKeymap(bindings, platform = currentPlatform) {
+       let bound = Object.create(null);
+       let isPrefix = Object.create(null);
+       let checkPrefix = (name, is) => {
+           let current = isPrefix[name];
+           if (current == null)
+               isPrefix[name] = is;
+           else if (current != is)
+               throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
+       };
+       let add = (scope, key, command, preventDefault, stopPropagation) => {
+           var _a, _b;
+           let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
+           let parts = key.split(/ (?!$)/).map(k => normalizeKeyName(k, platform));
+           for (let i = 1; i < parts.length; i++) {
+               let prefix = parts.slice(0, i).join(" ");
+               checkPrefix(prefix, true);
+               if (!scopeObj[prefix])
+                   scopeObj[prefix] = {
+                       preventDefault: true,
+                       stopPropagation: false,
+                       run: [(view) => {
+                               let ourObj = storedPrefix = { view, prefix, scope };
+                               setTimeout(() => { if (storedPrefix == ourObj)
+                                   storedPrefix = null; }, PrefixTimeout);
+                               return true;
+                           }]
+                   };
+           }
+           let full = parts.join(" ");
+           checkPrefix(full, false);
+           let binding = scopeObj[full] || (scopeObj[full] = {
+               preventDefault: false,
+               stopPropagation: false,
+               run: ((_b = (_a = scopeObj._any) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.slice()) || []
+           });
+           if (command)
+               binding.run.push(command);
+           if (preventDefault)
+               binding.preventDefault = true;
+           if (stopPropagation)
+               binding.stopPropagation = true;
+       };
+       for (let b of bindings) {
+           let scopes = b.scope ? b.scope.split(" ") : ["editor"];
+           if (b.any)
+               for (let scope of scopes) {
+                   let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
+                   if (!scopeObj._any)
+                       scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };
+                   let { any } = b;
+                   for (let key in scopeObj)
+                       scopeObj[key].run.push(view => any(view, currentKeyEvent));
+               }
+           let name = b[platform] || b.key;
+           if (!name)
+               continue;
+           for (let scope of scopes) {
+               add(scope, name, b.run, b.preventDefault, b.stopPropagation);
+               if (b.shift)
+                   add(scope, "Shift-" + name, b.shift, b.preventDefault, b.stopPropagation);
+           }
+       }
+       return bound;
+   }
+   let currentKeyEvent = null;
+   function runHandlers(map, event, view, scope) {
+       currentKeyEvent = event;
+       let name = keyName(event);
+       let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != " ";
+       let prefix = "", handled = false, prevented = false, stopPropagation = false;
+       if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
+           prefix = storedPrefix.prefix + " ";
+           if (modifierCodes.indexOf(event.keyCode) < 0) {
+               prevented = true;
+               storedPrefix = null;
+           }
+       }
+       let ran = new Set;
+       let runFor = (binding) => {
+           if (binding) {
+               for (let cmd of binding.run)
+                   if (!ran.has(cmd)) {
+                       ran.add(cmd);
+                       if (cmd(view)) {
+                           if (binding.stopPropagation)
+                               stopPropagation = true;
+                           return true;
+                       }
+                   }
+               if (binding.preventDefault) {
+                   if (binding.stopPropagation)
+                       stopPropagation = true;
+                   prevented = true;
+               }
+           }
+           return false;
+       };
+       let scopeObj = map[scope], baseName, shiftName;
+       if (scopeObj) {
+           if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {
+               handled = true;
+           }
+           else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
+               // Ctrl-Alt may be used for AltGr on Windows
+               !(browser.windows && event.ctrlKey && event.altKey) &&
+               (baseName = base[event.keyCode]) && baseName != name) {
+               if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
+                   handled = true;
+               }
+               else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName &&
+                   runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) {
+                   handled = true;
+               }
+           }
+           else if (isChar && event.shiftKey &&
+               runFor(scopeObj[prefix + modifiers(name, event, true)])) {
+               handled = true;
+           }
+           if (!handled && runFor(scopeObj._any))
+               handled = true;
+       }
+       if (prevented)
+           handled = true;
+       if (handled && stopPropagation)
+           event.stopPropagation();
+       currentKeyEvent = null;
+       return handled;
+   }
+
+   const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
+   const themeSpec = {
+       ".cm-line": {
+           "& ::selection, &::selection": { backgroundColor: "transparent !important" },
+       },
+       ".cm-content": {
+           "& :focus": {
+               caretColor: "initial !important",
+               "&::selection, & ::selection": {
+                   backgroundColor: "Highlight !important"
+               }
+           }
+       }
+   };
+   if (CanHidePrimary)
+       themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
+
+   const Outside = "-10000px";
+   class TooltipViewManager {
+       constructor(view, facet, createTooltipView, removeTooltipView) {
+           this.facet = facet;
+           this.createTooltipView = createTooltipView;
+           this.removeTooltipView = removeTooltipView;
+           this.input = view.state.facet(facet);
+           this.tooltips = this.input.filter(t => t);
+           let prev = null;
+           this.tooltipViews = this.tooltips.map(t => prev = createTooltipView(t, prev));
+       }
+       update(update, above) {
+           var _a;
+           let input = update.state.facet(this.facet);
+           let tooltips = input.filter(x => x);
+           if (input === this.input) {
+               for (let t of this.tooltipViews)
+                   if (t.update)
+                       t.update(update);
+               return false;
+           }
+           let tooltipViews = [], newAbove = above ? [] : null;
+           for (let i = 0; i < tooltips.length; i++) {
+               let tip = tooltips[i], known = -1;
+               if (!tip)
+                   continue;
+               for (let i = 0; i < this.tooltips.length; i++) {
+                   let other = this.tooltips[i];
+                   if (other && other.create == tip.create)
+                       known = i;
+               }
+               if (known < 0) {
+                   tooltipViews[i] = this.createTooltipView(tip, i ? tooltipViews[i - 1] : null);
+                   if (newAbove)
+                       newAbove[i] = !!tip.above;
+               }
+               else {
+                   let tooltipView = tooltipViews[i] = this.tooltipViews[known];
+                   if (newAbove)
+                       newAbove[i] = above[known];
+                   if (tooltipView.update)
+                       tooltipView.update(update);
+               }
+           }
+           for (let t of this.tooltipViews)
+               if (tooltipViews.indexOf(t) < 0) {
+                   this.removeTooltipView(t);
+                   (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
+               }
+           if (above) {
+               newAbove.forEach((val, i) => above[i] = val);
+               above.length = newAbove.length;
+           }
+           this.input = input;
+           this.tooltips = tooltips;
+           this.tooltipViews = tooltipViews;
+           return true;
+       }
+   }
+   function windowSpace(view) {
+       let { win } = view;
+       return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
+   }
+   const tooltipConfig = /*@__PURE__*/Facet.define({
+       combine: values => {
+           var _a, _b, _c;
+           return ({
+               position: browser.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
+               parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
+               tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,
+           });
+       }
+   });
+   const knownHeight = /*@__PURE__*/new WeakMap();
+   const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.above = [];
+           this.inView = true;
+           this.madeAbsolute = false;
+           this.lastTransaction = 0;
+           this.measureTimeout = -1;
+           let config = view.state.facet(tooltipConfig);
+           this.position = config.position;
+           this.parent = config.parent;
+           this.classes = view.themeClasses;
+           this.createContainer();
+           this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
+           this.resizeObserver = typeof ResizeObserver == "function" ? new ResizeObserver(() => this.measureSoon()) : null;
+           this.manager = new TooltipViewManager(view, showTooltip, (t, p) => this.createTooltip(t, p), t => {
+               if (this.resizeObserver)
+                   this.resizeObserver.unobserve(t.dom);
+               t.dom.remove();
+           });
+           this.above = this.manager.tooltips.map(t => !!t.above);
+           this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
+               if (Date.now() > this.lastTransaction - 50 &&
+                   entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
+                   this.measureSoon();
+           }, { threshold: [1] }) : null;
+           this.observeIntersection();
+           view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
+           this.maybeMeasure();
+       }
+       createContainer() {
+           if (this.parent) {
+               this.container = document.createElement("div");
+               this.container.style.position = "relative";
+               this.container.className = this.view.themeClasses;
+               this.parent.appendChild(this.container);
+           }
+           else {
+               this.container = this.view.dom;
+           }
+       }
+       observeIntersection() {
+           if (this.intersectionObserver) {
+               this.intersectionObserver.disconnect();
+               for (let tooltip of this.manager.tooltipViews)
+                   this.intersectionObserver.observe(tooltip.dom);
+           }
+       }
+       measureSoon() {
+           if (this.measureTimeout < 0)
+               this.measureTimeout = setTimeout(() => {
+                   this.measureTimeout = -1;
+                   this.maybeMeasure();
+               }, 50);
+       }
+       update(update) {
+           if (update.transactions.length)
+               this.lastTransaction = Date.now();
+           let updated = this.manager.update(update, this.above);
+           if (updated)
+               this.observeIntersection();
+           let shouldMeasure = updated || update.geometryChanged;
+           let newConfig = update.state.facet(tooltipConfig);
+           if (newConfig.position != this.position && !this.madeAbsolute) {
+               this.position = newConfig.position;
+               for (let t of this.manager.tooltipViews)
+                   t.dom.style.position = this.position;
+               shouldMeasure = true;
+           }
+           if (newConfig.parent != this.parent) {
+               if (this.parent)
+                   this.container.remove();
+               this.parent = newConfig.parent;
+               this.createContainer();
+               for (let t of this.manager.tooltipViews)
+                   this.container.appendChild(t.dom);
+               shouldMeasure = true;
+           }
+           else if (this.parent && this.view.themeClasses != this.classes) {
+               this.classes = this.container.className = this.view.themeClasses;
+           }
+           if (shouldMeasure)
+               this.maybeMeasure();
+       }
+       createTooltip(tooltip, prev) {
+           let tooltipView = tooltip.create(this.view);
+           let before = prev ? prev.dom : null;
+           tooltipView.dom.classList.add("cm-tooltip");
+           if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
+               let arrow = document.createElement("div");
+               arrow.className = "cm-tooltip-arrow";
+               tooltipView.dom.appendChild(arrow);
+           }
+           tooltipView.dom.style.position = this.position;
+           tooltipView.dom.style.top = Outside;
+           tooltipView.dom.style.left = "0px";
+           this.container.insertBefore(tooltipView.dom, before);
+           if (tooltipView.mount)
+               tooltipView.mount(this.view);
+           if (this.resizeObserver)
+               this.resizeObserver.observe(tooltipView.dom);
+           return tooltipView;
+       }
+       destroy() {
+           var _a, _b, _c;
+           this.view.win.removeEventListener("resize", this.measureSoon);
+           for (let tooltipView of this.manager.tooltipViews) {
+               tooltipView.dom.remove();
+               (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);
+           }
+           if (this.parent)
+               this.container.remove();
+           (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
+           (_c = this.intersectionObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
+           clearTimeout(this.measureTimeout);
+       }
+       readMeasure() {
+           let scaleX = 1, scaleY = 1, makeAbsolute = false;
+           if (this.position == "fixed" && this.manager.tooltipViews.length) {
+               let { dom } = this.manager.tooltipViews[0];
+               if (browser.gecko) {
+                   // Firefox sets the element's `offsetParent` to the
+                   // transformed element when a transform interferes with fixed
+                   // positioning.
+                   makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
+               }
+               else if (dom.style.top == Outside && dom.style.left == "0px") {
+                   // On other browsers, we have to awkwardly try and use other
+                   // information to detect a transform.
+                   let rect = dom.getBoundingClientRect();
+                   makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
+               }
+           }
+           if (makeAbsolute || this.position == "absolute") {
+               if (this.parent) {
+                   let rect = this.parent.getBoundingClientRect();
+                   if (rect.width && rect.height) {
+                       scaleX = rect.width / this.parent.offsetWidth;
+                       scaleY = rect.height / this.parent.offsetHeight;
+                   }
+               }
+               else {
+                   ({ scaleX, scaleY } = this.view.viewState);
+               }
+           }
+           let visible = this.view.scrollDOM.getBoundingClientRect(), margins = getScrollMargins(this.view);
+           return {
+               visible: {
+                   left: visible.left + margins.left, top: visible.top + margins.top,
+                   right: visible.right - margins.right, bottom: visible.bottom - margins.bottom
+               },
+               parent: this.parent ? this.container.getBoundingClientRect() : this.view.dom.getBoundingClientRect(),
+               pos: this.manager.tooltips.map((t, i) => {
+                   let tv = this.manager.tooltipViews[i];
+                   return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
+               }),
+               size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
+               space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
+               scaleX, scaleY, makeAbsolute
+           };
+       }
+       writeMeasure(measured) {
+           var _a;
+           if (measured.makeAbsolute) {
+               this.madeAbsolute = true;
+               this.position = "absolute";
+               for (let t of this.manager.tooltipViews)
+                   t.dom.style.position = "absolute";
+           }
+           let { visible, space, scaleX, scaleY } = measured;
+           let others = [];
+           for (let i = 0; i < this.manager.tooltips.length; i++) {
+               let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
+               let pos = measured.pos[i], size = measured.size[i];
+               // Hide tooltips that are outside of the editor.
+               if (!pos || tooltip.clip !== false && (pos.bottom <= Math.max(visible.top, space.top) ||
+                   pos.top >= Math.min(visible.bottom, space.bottom) ||
+                   pos.right < Math.max(visible.left, space.left) - .1 ||
+                   pos.left > Math.min(visible.right, space.right) + .1)) {
+                   dom.style.top = Outside;
+                   continue;
+               }
+               let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
+               let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
+               let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
+               let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
+               let left = size.width > space.right - space.left
+                   ? (ltr ? space.left : space.right - size.width)
+                   : ltr ? Math.max(space.left, Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width))
+                       : Math.min(Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x), space.right - width);
+               let above = this.above[i];
+               if (!tooltip.strictSide && (above
+                   ? pos.top - height - arrowHeight - offset.y < space.top
+                   : pos.bottom + height + arrowHeight + offset.y > space.bottom) &&
+                   above == (space.bottom - pos.bottom > pos.top - space.top))
+                   above = this.above[i] = !above;
+               let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
+               if (spaceVert < height && tView.resize !== false) {
+                   if (spaceVert < this.view.defaultLineHeight) {
+                       dom.style.top = Outside;
+                       continue;
+                   }
+                   knownHeight.set(tView, height);
+                   dom.style.height = (height = spaceVert) / scaleY + "px";
+               }
+               else if (dom.style.height) {
+                   dom.style.height = "";
+               }
+               let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
+               let right = left + width;
+               if (tView.overlap !== true)
+                   for (let r of others)
+                       if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
+                           top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
+               if (this.position == "absolute") {
+                   dom.style.top = (top - measured.parent.top) / scaleY + "px";
+                   setLeftStyle(dom, (left - measured.parent.left) / scaleX);
+               }
+               else {
+                   dom.style.top = top / scaleY + "px";
+                   setLeftStyle(dom, left / scaleX);
+               }
+               if (arrow) {
+                   let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);
+                   arrow.style.left = arrowLeft / scaleX + "px";
+               }
+               if (tView.overlap !== true)
+                   others.push({ left, top, right, bottom: top + height });
+               dom.classList.toggle("cm-tooltip-above", above);
+               dom.classList.toggle("cm-tooltip-below", !above);
+               if (tView.positioned)
+                   tView.positioned(measured.space);
+           }
+       }
+       maybeMeasure() {
+           if (this.manager.tooltips.length) {
+               if (this.view.inView)
+                   this.view.requestMeasure(this.measureReq);
+               if (this.inView != this.view.inView) {
+                   this.inView = this.view.inView;
+                   if (!this.inView)
+                       for (let tv of this.manager.tooltipViews)
+                           tv.dom.style.top = Outside;
+               }
+           }
+       }
+   }, {
+       eventObservers: {
+           scroll() { this.maybeMeasure(); }
+       }
+   });
+   function setLeftStyle(elt, value) {
+       let current = parseInt(elt.style.left, 10);
+       if (isNaN(current) || Math.abs(value - current) > 1)
+           elt.style.left = value + "px";
+   }
+   const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
+       ".cm-tooltip": {
+           zIndex: 500,
+           boxSizing: "border-box"
+       },
+       "&light .cm-tooltip": {
+           border: "1px solid #bbb",
+           backgroundColor: "#f5f5f5"
+       },
+       "&light .cm-tooltip-section:not(:first-child)": {
+           borderTop: "1px solid #bbb",
+       },
+       "&dark .cm-tooltip": {
+           backgroundColor: "#333338",
+           color: "white"
+       },
+       ".cm-tooltip-arrow": {
+           height: `${7 /* Arrow.Size */}px`,
+           width: `${7 /* Arrow.Size */ * 2}px`,
+           position: "absolute",
+           zIndex: -1,
+           overflow: "hidden",
+           "&:before, &:after": {
+               content: "''",
+               position: "absolute",
+               width: 0,
+               height: 0,
+               borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
+               borderRight: `${7 /* Arrow.Size */}px solid transparent`,
+           },
+           ".cm-tooltip-above &": {
+               bottom: `-${7 /* Arrow.Size */}px`,
+               "&:before": {
+                   borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
+               },
+               "&:after": {
+                   borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
+                   bottom: "1px"
+               }
+           },
+           ".cm-tooltip-below &": {
+               top: `-${7 /* Arrow.Size */}px`,
+               "&:before": {
+                   borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
+               },
+               "&:after": {
+                   borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
+                   top: "1px"
+               }
+           },
+       },
+       "&dark .cm-tooltip .cm-tooltip-arrow": {
+           "&:before": {
+               borderTopColor: "#333338",
+               borderBottomColor: "#333338"
+           },
+           "&:after": {
+               borderTopColor: "transparent",
+               borderBottomColor: "transparent"
+           }
+       }
+   });
+   const noOffset = { x: 0, y: 0 };
+   /**
+   Facet to which an extension can add a value to show a tooltip.
+   */
+   const showTooltip = /*@__PURE__*/Facet.define({
+       enables: [tooltipPlugin, baseTheme$2]
+   });
+   /**
+   Get the active tooltip view for a given tooltip, if available.
+   */
+   function getTooltip(view, tooltip) {
+       let plugin = view.plugin(tooltipPlugin);
+       if (!plugin)
+           return null;
+       let found = plugin.manager.tooltips.indexOf(tooltip);
+       return found < 0 ? null : plugin.manager.tooltipViews[found];
+   }
+
+   const panelConfig = /*@__PURE__*/Facet.define({
+       combine(configs) {
+           let topContainer, bottomContainer;
+           for (let c of configs) {
+               topContainer = topContainer || c.topContainer;
+               bottomContainer = bottomContainer || c.bottomContainer;
+           }
+           return { topContainer, bottomContainer };
+       }
+   });
+   const panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+       constructor(view) {
+           this.input = view.state.facet(showPanel);
+           this.specs = this.input.filter(s => s);
+           this.panels = this.specs.map(spec => spec(view));
+           let conf = view.state.facet(panelConfig);
+           this.top = new PanelGroup(view, true, conf.topContainer);
+           this.bottom = new PanelGroup(view, false, conf.bottomContainer);
+           this.top.sync(this.panels.filter(p => p.top));
+           this.bottom.sync(this.panels.filter(p => !p.top));
+           for (let p of this.panels) {
+               p.dom.classList.add("cm-panel");
+               if (p.mount)
+                   p.mount();
+           }
+       }
+       update(update) {
+           let conf = update.state.facet(panelConfig);
+           if (this.top.container != conf.topContainer) {
+               this.top.sync([]);
+               this.top = new PanelGroup(update.view, true, conf.topContainer);
+           }
+           if (this.bottom.container != conf.bottomContainer) {
+               this.bottom.sync([]);
+               this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);
+           }
+           this.top.syncClasses();
+           this.bottom.syncClasses();
+           let input = update.state.facet(showPanel);
+           if (input != this.input) {
+               let specs = input.filter(x => x);
+               let panels = [], top = [], bottom = [], mount = [];
+               for (let spec of specs) {
+                   let known = this.specs.indexOf(spec), panel;
+                   if (known < 0) {
+                       panel = spec(update.view);
+                       mount.push(panel);
+                   }
+                   else {
+                       panel = this.panels[known];
+                       if (panel.update)
+                           panel.update(update);
+                   }
+                   panels.push(panel);
+                   (panel.top ? top : bottom).push(panel);
+               }
+               this.specs = specs;
+               this.panels = panels;
+               this.top.sync(top);
+               this.bottom.sync(bottom);
+               for (let p of mount) {
+                   p.dom.classList.add("cm-panel");
+                   if (p.mount)
+                       p.mount();
+               }
+           }
+           else {
+               for (let p of this.panels)
+                   if (p.update)
+                       p.update(update);
+           }
+       }
+       destroy() {
+           this.top.sync([]);
+           this.bottom.sync([]);
+       }
+   }, {
+       provide: plugin => EditorView.scrollMargins.of(view => {
+           let value = view.plugin(plugin);
+           return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
+       })
+   });
+   class PanelGroup {
+       constructor(view, top, container) {
+           this.view = view;
+           this.top = top;
+           this.container = container;
+           this.dom = undefined;
+           this.classes = "";
+           this.panels = [];
+           this.syncClasses();
+       }
+       sync(panels) {
+           for (let p of this.panels)
+               if (p.destroy && panels.indexOf(p) < 0)
+                   p.destroy();
+           this.panels = panels;
+           this.syncDOM();
+       }
+       syncDOM() {
+           if (this.panels.length == 0) {
+               if (this.dom) {
+                   this.dom.remove();
+                   this.dom = undefined;
+               }
+               return;
+           }
+           if (!this.dom) {
+               this.dom = document.createElement("div");
+               this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
+               this.dom.style[this.top ? "top" : "bottom"] = "0";
+               let parent = this.container || this.view.dom;
+               parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
+           }
+           let curDOM = this.dom.firstChild;
+           for (let panel of this.panels) {
+               if (panel.dom.parentNode == this.dom) {
+                   while (curDOM != panel.dom)
+                       curDOM = rm(curDOM);
+                   curDOM = curDOM.nextSibling;
+               }
+               else {
+                   this.dom.insertBefore(panel.dom, curDOM);
+               }
+           }
+           while (curDOM)
+               curDOM = rm(curDOM);
+       }
+       scrollMargin() {
+           return !this.dom || this.container ? 0
+               : Math.max(0, this.top ?
+                   this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
+                   Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
+       }
+       syncClasses() {
+           if (!this.container || this.classes == this.view.themeClasses)
+               return;
+           for (let cls of this.classes.split(" "))
+               if (cls)
+                   this.container.classList.remove(cls);
+           for (let cls of (this.classes = this.view.themeClasses).split(" "))
+               if (cls)
+                   this.container.classList.add(cls);
+       }
+   }
+   function rm(node) {
+       let next = node.nextSibling;
+       node.remove();
+       return next;
+   }
+   /**
+   Opening a panel is done by providing a constructor function for
+   the panel through this facet. (The panel is closed again when its
+   constructor is no longer provided.) Values of `null` are ignored.
+   */
+   const showPanel = /*@__PURE__*/Facet.define({
+       enables: panelPlugin
+   });
+
+   /**
+   A gutter marker represents a bit of information attached to a line
+   in a specific gutter. Your own custom markers have to extend this
+   class.
+   */
+   class GutterMarker extends RangeValue {
+       /**
+       @internal
+       */
+       compare(other) {
+           return this == other || this.constructor == other.constructor && this.eq(other);
+       }
+       /**
+       Compare this marker to another marker of the same type.
+       */
+       eq(other) { return false; }
+       /**
+       Called if the marker has a `toDOM` method and its representation
+       was removed from a gutter.
+       */
+       destroy(dom) { }
+   }
+   GutterMarker.prototype.elementClass = "";
+   GutterMarker.prototype.toDOM = undefined;
+   GutterMarker.prototype.mapMode = MapMode.TrackBefore;
+   GutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;
+   GutterMarker.prototype.point = true;
+   /**
+   Facet used to add a class to all gutter elements for a given line.
+   Markers given to this facet should _only_ define an
+   [`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a
+   [`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear
+   in all gutters for the line).
+   */
+   const gutterLineClass = /*@__PURE__*/Facet.define();
+   /**
+   Facet used to add a class to all gutter elements next to a widget.
+   Should not provide widgets with a `toDOM` method.
+   */
+   const gutterWidgetClass = /*@__PURE__*/Facet.define();
+   const defaults = {
+       class: "",
+       renderEmptyElements: false,
+       elementStyle: "",
+       markers: () => RangeSet.empty,
+       lineMarker: () => null,
+       widgetMarker: () => null,
+       lineMarkerChange: null,
+       initialSpacer: null,
+       updateSpacer: null,
+       domEventHandlers: {}
+   };
+   const activeGutters = /*@__PURE__*/Facet.define();
+   /**
+   Define an editor gutter. The order in which the gutters appear is
+   determined by their extension priority.
+   */
+   function gutter(config) {
+       return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults), config))];
+   }
+   const unfixGutters = /*@__PURE__*/Facet.define({
+       combine: values => values.some(x => x)
+   });
+   /**
+   The gutter-drawing plugin is automatically enabled when you add a
+   gutter, but you can use this function to explicitly configure it.
+
+   Unless `fixed` is explicitly set to `false`, the gutters are
+   fixed, meaning they don't scroll along with the content
+   horizontally (except on Internet Explorer, which doesn't support
+   CSS [`position:
+   sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
+   */
+   function gutters(config) {
+       let result = [
+           gutterView,
+       ];
+       return result;
+   }
+   const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.prevViewport = view.viewport;
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-gutters";
+           this.dom.setAttribute("aria-hidden", "true");
+           this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
+           this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));
+           for (let gutter of this.gutters)
+               this.dom.appendChild(gutter.dom);
+           this.fixed = !view.state.facet(unfixGutters);
+           if (this.fixed) {
+               // FIXME IE11 fallback, which doesn't support position: sticky,
+               // by using position: relative + event handlers that realign the
+               // gutter (or just force fixed=false on IE11?)
+               this.dom.style.position = "sticky";
+           }
+           this.syncGutters(false);
+           view.scrollDOM.insertBefore(this.dom, view.contentDOM);
+       }
+       update(update) {
+           if (this.updateGutters(update)) {
+               // Detach during sync when the viewport changed significantly
+               // (such as during scrolling), since for large updates that is
+               // faster.
+               let vpA = this.prevViewport, vpB = update.view.viewport;
+               let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);
+               this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);
+           }
+           if (update.geometryChanged) {
+               this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
+           }
+           if (this.view.state.facet(unfixGutters) != !this.fixed) {
+               this.fixed = !this.fixed;
+               this.dom.style.position = this.fixed ? "sticky" : "";
+           }
+           this.prevViewport = update.view.viewport;
+       }
+       syncGutters(detach) {
+           let after = this.dom.nextSibling;
+           if (detach)
+               this.dom.remove();
+           let lineClasses = RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);
+           let classSet = [];
+           let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
+           for (let line of this.view.viewportLineBlocks) {
+               if (classSet.length)
+                   classSet = [];
+               if (Array.isArray(line.type)) {
+                   let first = true;
+                   for (let b of line.type) {
+                       if (b.type == BlockType.Text && first) {
+                           advanceCursor(lineClasses, classSet, b.from);
+                           for (let cx of contexts)
+                               cx.line(this.view, b, classSet);
+                           first = false;
+                       }
+                       else if (b.widget) {
+                           for (let cx of contexts)
+                               cx.widget(this.view, b);
+                       }
+                   }
+               }
+               else if (line.type == BlockType.Text) {
+                   advanceCursor(lineClasses, classSet, line.from);
+                   for (let cx of contexts)
+                       cx.line(this.view, line, classSet);
+               }
+               else if (line.widget) {
+                   for (let cx of contexts)
+                       cx.widget(this.view, line);
+               }
+           }
+           for (let cx of contexts)
+               cx.finish();
+           if (detach)
+               this.view.scrollDOM.insertBefore(this.dom, after);
+       }
+       updateGutters(update) {
+           let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);
+           let change = update.docChanged || update.heightChanged || update.viewportChanged ||
+               !RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);
+           if (prev == cur) {
+               for (let gutter of this.gutters)
+                   if (gutter.update(update))
+                       change = true;
+           }
+           else {
+               change = true;
+               let gutters = [];
+               for (let conf of cur) {
+                   let known = prev.indexOf(conf);
+                   if (known < 0) {
+                       gutters.push(new SingleGutterView(this.view, conf));
+                   }
+                   else {
+                       this.gutters[known].update(update);
+                       gutters.push(this.gutters[known]);
+                   }
+               }
+               for (let g of this.gutters) {
+                   g.dom.remove();
+                   if (gutters.indexOf(g) < 0)
+                       g.destroy();
+               }
+               for (let g of gutters)
+                   this.dom.appendChild(g.dom);
+               this.gutters = gutters;
+           }
+           return change;
+       }
+       destroy() {
+           for (let view of this.gutters)
+               view.destroy();
+           this.dom.remove();
+       }
+   }, {
+       provide: plugin => EditorView.scrollMargins.of(view => {
+           let value = view.plugin(plugin);
+           if (!value || value.gutters.length == 0 || !value.fixed)
+               return null;
+           return view.textDirection == Direction.LTR
+               ? { left: value.dom.offsetWidth * view.scaleX }
+               : { right: value.dom.offsetWidth * view.scaleX };
+       })
+   });
+   function asArray(val) { return (Array.isArray(val) ? val : [val]); }
+   function advanceCursor(cursor, collect, pos) {
+       while (cursor.value && cursor.from <= pos) {
+           if (cursor.from == pos)
+               collect.push(cursor.value);
+           cursor.next();
+       }
+   }
+   class UpdateContext {
+       constructor(gutter, viewport, height) {
+           this.gutter = gutter;
+           this.height = height;
+           this.i = 0;
+           this.cursor = RangeSet.iter(gutter.markers, viewport.from);
+       }
+       addElement(view, block, markers) {
+           let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;
+           if (this.i == gutter.elements.length) {
+               let newElt = new GutterElement(view, height, above, markers);
+               gutter.elements.push(newElt);
+               gutter.dom.appendChild(newElt.dom);
+           }
+           else {
+               gutter.elements[this.i].update(view, height, above, markers);
+           }
+           this.height = block.bottom;
+           this.i++;
+       }
+       line(view, line, extraMarkers) {
+           let localMarkers = [];
+           advanceCursor(this.cursor, localMarkers, line.from);
+           if (extraMarkers.length)
+               localMarkers = localMarkers.concat(extraMarkers);
+           let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
+           if (forLine)
+               localMarkers.unshift(forLine);
+           let gutter = this.gutter;
+           if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
+               return;
+           this.addElement(view, line, localMarkers);
+       }
+       widget(view, block) {
+           let marker = this.gutter.config.widgetMarker(view, block.widget, block), markers = marker ? [marker] : null;
+           for (let cls of view.state.facet(gutterWidgetClass)) {
+               let marker = cls(view, block.widget, block);
+               if (marker)
+                   (markers || (markers = [])).push(marker);
+           }
+           if (markers)
+               this.addElement(view, block, markers);
+       }
+       finish() {
+           let gutter = this.gutter;
+           while (gutter.elements.length > this.i) {
+               let last = gutter.elements.pop();
+               gutter.dom.removeChild(last.dom);
+               last.destroy();
+           }
+       }
+   }
+   class SingleGutterView {
+       constructor(view, config) {
+           this.view = view;
+           this.config = config;
+           this.elements = [];
+           this.spacer = null;
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
+           for (let prop in config.domEventHandlers) {
+               this.dom.addEventListener(prop, (event) => {
+                   let target = event.target, y;
+                   if (target != this.dom && this.dom.contains(target)) {
+                       while (target.parentNode != this.dom)
+                           target = target.parentNode;
+                       let rect = target.getBoundingClientRect();
+                       y = (rect.top + rect.bottom) / 2;
+                   }
+                   else {
+                       y = event.clientY;
+                   }
+                   let line = view.lineBlockAtHeight(y - view.documentTop);
+                   if (config.domEventHandlers[prop](view, line, event))
+                       event.preventDefault();
+               });
+           }
+           this.markers = asArray(config.markers(view));
+           if (config.initialSpacer) {
+               this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);
+               this.dom.appendChild(this.spacer.dom);
+               this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none";
+           }
+       }
+       update(update) {
+           let prevMarkers = this.markers;
+           this.markers = asArray(this.config.markers(update.view));
+           if (this.spacer && this.config.updateSpacer) {
+               let updated = this.config.updateSpacer(this.spacer.markers[0], update);
+               if (updated != this.spacer.markers[0])
+                   this.spacer.update(update.view, 0, 0, [updated]);
+           }
+           let vp = update.view.viewport;
+           return !RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||
+               (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);
+       }
+       destroy() {
+           for (let elt of this.elements)
+               elt.destroy();
+       }
+   }
+   class GutterElement {
+       constructor(view, height, above, markers) {
+           this.height = -1;
+           this.above = 0;
+           this.markers = [];
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-gutterElement";
+           this.update(view, height, above, markers);
+       }
+       update(view, height, above, markers) {
+           if (this.height != height) {
+               this.height = height;
+               this.dom.style.height = height + "px";
+           }
+           if (this.above != above)
+               this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
+           if (!sameMarkers(this.markers, markers))
+               this.setMarkers(view, markers);
+       }
+       setMarkers(view, markers) {
+           let cls = "cm-gutterElement", domPos = this.dom.firstChild;
+           for (let iNew = 0, iOld = 0;;) {
+               let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;
+               if (marker) {
+                   let c = marker.elementClass;
+                   if (c)
+                       cls += " " + c;
+                   for (let i = iOld; i < this.markers.length; i++)
+                       if (this.markers[i].compare(marker)) {
+                           skipTo = i;
+                           matched = true;
+                           break;
+                       }
+               }
+               else {
+                   skipTo = this.markers.length;
+               }
+               while (iOld < skipTo) {
+                   let next = this.markers[iOld++];
+                   if (next.toDOM) {
+                       next.destroy(domPos);
+                       let after = domPos.nextSibling;
+                       domPos.remove();
+                       domPos = after;
+                   }
+               }
+               if (!marker)
+                   break;
+               if (marker.toDOM) {
+                   if (matched)
+                       domPos = domPos.nextSibling;
+                   else
+                       this.dom.insertBefore(marker.toDOM(view), domPos);
+               }
+               if (matched)
+                   iOld++;
+           }
+           this.dom.className = cls;
+           this.markers = markers;
+       }
+       destroy() {
+           this.setMarkers(null, []); // First argument not used unless creating markers
+       }
+   }
+   function sameMarkers(a, b) {
+       if (a.length != b.length)
+           return false;
+       for (let i = 0; i < a.length; i++)
+           if (!a[i].compare(b[i]))
+               return false;
+       return true;
+   }
+   /**
+   Facet used to provide markers to the line number gutter.
+   */
+   const lineNumberMarkers = /*@__PURE__*/Facet.define();
+   /**
+   Facet used to create markers in the line number gutter next to widgets.
+   */
+   const lineNumberWidgetMarker = /*@__PURE__*/Facet.define();
+   const lineNumberConfig = /*@__PURE__*/Facet.define({
+       combine(values) {
+           return combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {
+               domEventHandlers(a, b) {
+                   let result = Object.assign({}, a);
+                   for (let event in b) {
+                       let exists = result[event], add = b[event];
+                       result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;
+                   }
+                   return result;
+               }
+           });
+       }
+   });
+   class NumberMarker extends GutterMarker {
+       constructor(number) {
+           super();
+           this.number = number;
+       }
+       eq(other) { return this.number == other.number; }
+       toDOM() { return document.createTextNode(this.number); }
+   }
+   function formatNumber(view, number) {
+       return view.state.facet(lineNumberConfig).formatNumber(number, view.state);
+   }
+   const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({
+       class: "cm-lineNumbers",
+       renderEmptyElements: false,
+       markers(view) { return view.state.facet(lineNumberMarkers); },
+       lineMarker(view, line, others) {
+           if (others.some(m => m.toDOM))
+               return null;
+           return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
+       },
+       widgetMarker: (view, widget, block) => {
+           for (let m of view.state.facet(lineNumberWidgetMarker)) {
+               let result = m(view, widget, block);
+               if (result)
+                   return result;
+           }
+           return null;
+       },
+       lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
+       initialSpacer(view) {
+           return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
+       },
+       updateSpacer(spacer, update) {
+           let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
+           return max == spacer.number ? spacer : new NumberMarker(max);
+       },
+       domEventHandlers: state.facet(lineNumberConfig).domEventHandlers
+   }));
+   /**
+   Create a line number gutter extension.
+   */
+   function lineNumbers(config = {}) {
+       return [
+           lineNumberConfig.of(config),
+           gutters(),
+           lineNumberGutter
+       ];
+   }
+   function maxLineNumber(lines) {
+       let last = 9;
+       while (last < lines)
+           last = last * 10 + 9;
+       return last;
+   }
+
+   var _a;
+   /**
+   Node prop stored in a parser's top syntax node to provide the
+   facet that stores language-specific data for that language.
+   */
+   const languageDataProp = /*@__PURE__*/new NodeProp();
+   /**
+   Helper function to define a facet (to be added to the top syntax
+   node(s) for a language via
+   [`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be
+   used to associate language data with the language. You
+   probably only need this when subclassing
+   [`Language`](https://codemirror.net/6/docs/ref/#language.Language).
+   */
+   function defineLanguageFacet(baseData) {
+       return Facet.define({
+           combine: baseData ? values => values.concat(baseData) : undefined
+       });
+   }
+   /**
+   Syntax node prop used to register sublanguages. Should be added to
+   the top level node type for the language.
+   */
+   const sublanguageProp = /*@__PURE__*/new NodeProp();
+   /**
+   A language object manages parsing and per-language
+   [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
+   managed as a [Lezer](https://lezer.codemirror.net) tree. The class
+   can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
+   subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
+   via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
+   for stream parsers.
+   */
+   class Language {
+       /**
+       Construct a language object. If you need to invoke this
+       directly, first define a data facet with
+       [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
+       configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
+       to the language's outer syntax node.
+       */
+       constructor(
+       /**
+       The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
+       used for this language.
+       */
+       data, parser, extraExtensions = [], 
+       /**
+       A language name.
+       */
+       name = "") {
+           this.data = data;
+           this.name = name;
+           // Kludge to define EditorState.tree as a debugging helper,
+           // without the EditorState package actually knowing about
+           // languages and lezer trees.
+           if (!EditorState.prototype.hasOwnProperty("tree"))
+               Object.defineProperty(EditorState.prototype, "tree", { get() { return syntaxTree(this); } });
+           this.parser = parser;
+           this.extension = [
+               language.of(this),
+               EditorState.languageData.of((state, pos, side) => {
+                   let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);
+                   if (!data)
+                       return [];
+                   let base = state.facet(data), sub = top.type.prop(sublanguageProp);
+                   if (sub) {
+                       let innerNode = top.resolve(pos - top.from, side);
+                       for (let sublang of sub)
+                           if (sublang.test(innerNode, state)) {
+                               let data = state.facet(sublang.facet);
+                               return sublang.type == "replace" ? data : data.concat(base);
+                           }
+                   }
+                   return base;
+               })
+           ].concat(extraExtensions);
+       }
+       /**
+       Query whether this language is active at the given position.
+       */
+       isActiveAt(state, pos, side = -1) {
+           return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;
+       }
+       /**
+       Find the document regions that were parsed using this language.
+       The returned regions will _include_ any nested languages rooted
+       in this language, when those exist.
+       */
+       findRegions(state) {
+           let lang = state.facet(language);
+           if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
+               return [{ from: 0, to: state.doc.length }];
+           if (!lang || !lang.allowsNesting)
+               return [];
+           let result = [];
+           let explore = (tree, from) => {
+               if (tree.prop(languageDataProp) == this.data) {
+                   result.push({ from, to: from + tree.length });
+                   return;
+               }
+               let mount = tree.prop(NodeProp.mounted);
+               if (mount) {
+                   if (mount.tree.prop(languageDataProp) == this.data) {
+                       if (mount.overlay)
+                           for (let r of mount.overlay)
+                               result.push({ from: r.from + from, to: r.to + from });
+                       else
+                           result.push({ from: from, to: from + tree.length });
+                       return;
+                   }
+                   else if (mount.overlay) {
+                       let size = result.length;
+                       explore(mount.tree, mount.overlay[0].from + from);
+                       if (result.length > size)
+                           return;
+                   }
+               }
+               for (let i = 0; i < tree.children.length; i++) {
+                   let ch = tree.children[i];
+                   if (ch instanceof Tree)
+                       explore(ch, tree.positions[i] + from);
+               }
+           };
+           explore(syntaxTree(state), 0);
+           return result;
+       }
+       /**
+       Indicates whether this language allows nested languages. The
+       default implementation returns true.
+       */
+       get allowsNesting() { return true; }
+   }
+   /**
+   @internal
+   */
+   Language.setState = /*@__PURE__*/StateEffect.define();
+   function topNodeAt(state, pos, side) {
+       let topLang = state.facet(language), tree = syntaxTree(state).topNode;
+       if (!topLang || topLang.allowsNesting) {
+           for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers))
+               if (node.type.isTop)
+                   tree = node;
+       }
+       return tree;
+   }
+   /**
+   A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
+   [LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
+   parsers.
+   */
+   class LRLanguage extends Language {
+       constructor(data, parser, name) {
+           super(data, parser, [], name);
+           this.parser = parser;
+       }
+       /**
+       Define a language from a parser.
+       */
+       static define(spec) {
+           let data = defineLanguageFacet(spec.languageData);
+           return new LRLanguage(data, spec.parser.configure({
+               props: [languageDataProp.add(type => type.isTop ? data : undefined)]
+           }), spec.name);
+       }
+       /**
+       Create a new instance of this language with a reconfigured
+       version of its parser and optionally a new name.
+       */
+       configure(options, name) {
+           return new LRLanguage(this.data, this.parser.configure(options), name || this.name);
+       }
+       get allowsNesting() { return this.parser.hasWrappers(); }
+   }
+   /**
+   Get the syntax tree for a state, which is the current (possibly
+   incomplete) parse tree of the active
+   [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
+   language available.
+   */
+   function syntaxTree(state) {
+       let field = state.field(Language.state, false);
+       return field ? field.tree : Tree.empty;
+   }
+   /**
+   Lezer-style
+   [`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
+   object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
+   */
+   class DocInput {
+       /**
+       Create an input object for the given document.
+       */
+       constructor(doc) {
+           this.doc = doc;
+           this.cursorPos = 0;
+           this.string = "";
+           this.cursor = doc.iter();
+       }
+       get length() { return this.doc.length; }
+       syncTo(pos) {
+           this.string = this.cursor.next(pos - this.cursorPos).value;
+           this.cursorPos = pos + this.string.length;
+           return this.cursorPos - this.string.length;
+       }
+       chunk(pos) {
+           this.syncTo(pos);
+           return this.string;
+       }
+       get lineChunks() { return true; }
+       read(from, to) {
+           let stringStart = this.cursorPos - this.string.length;
+           if (from < stringStart || to >= this.cursorPos)
+               return this.doc.sliceString(from, to);
+           else
+               return this.string.slice(from - stringStart, to - stringStart);
+       }
+   }
+   let currentContext = null;
+   /**
+   A parse context provided to parsers working on the editor content.
+   */
+   class ParseContext {
+       constructor(parser, 
+       /**
+       The current editor state.
+       */
+       state, 
+       /**
+       Tree fragments that can be reused by incremental re-parses.
+       */
+       fragments = [], 
+       /**
+       @internal
+       */
+       tree, 
+       /**
+       @internal
+       */
+       treeLen, 
+       /**
+       The current editor viewport (or some overapproximation
+       thereof). Intended to be used for opportunistically avoiding
+       work (in which case
+       [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
+       should be called to make sure the parser is restarted when the
+       skipped region becomes visible).
+       */
+       viewport, 
+       /**
+       @internal
+       */
+       skipped, 
+       /**
+       This is where skipping parsers can register a promise that,
+       when resolved, will schedule a new parse. It is cleared when
+       the parse worker picks up the promise. @internal
+       */
+       scheduleOn) {
+           this.parser = parser;
+           this.state = state;
+           this.fragments = fragments;
+           this.tree = tree;
+           this.treeLen = treeLen;
+           this.viewport = viewport;
+           this.skipped = skipped;
+           this.scheduleOn = scheduleOn;
+           this.parse = null;
+           /**
+           @internal
+           */
+           this.tempSkipped = [];
+       }
+       /**
+       @internal
+       */
+       static create(parser, state, viewport) {
+           return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
+       }
+       startParse() {
+           return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
+       }
+       /**
+       @internal
+       */
+       work(until, upto) {
+           if (upto != null && upto >= this.state.doc.length)
+               upto = undefined;
+           if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
+               this.takeTree();
+               return true;
+           }
+           return this.withContext(() => {
+               var _a;
+               if (typeof until == "number") {
+                   let endTime = Date.now() + until;
+                   until = () => Date.now() > endTime;
+               }
+               if (!this.parse)
+                   this.parse = this.startParse();
+               if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
+                   upto < this.state.doc.length)
+                   this.parse.stopAt(upto);
+               for (;;) {
+                   let done = this.parse.advance();
+                   if (done) {
+                       this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));
+                       this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
+                       this.tree = done;
+                       this.parse = null;
+                       if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
+                           this.parse = this.startParse();
+                       else
+                           return true;
+                   }
+                   if (until())
+                       return false;
+               }
+           });
+       }
+       /**
+       @internal
+       */
+       takeTree() {
+           let pos, tree;
+           if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
+               if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
+                   this.parse.stopAt(pos);
+               this.withContext(() => { while (!(tree = this.parse.advance())) { } });
+               this.treeLen = pos;
+               this.tree = tree;
+               this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));
+               this.parse = null;
+           }
+       }
+       withContext(f) {
+           let prev = currentContext;
+           currentContext = this;
+           try {
+               return f();
+           }
+           finally {
+               currentContext = prev;
+           }
+       }
+       withoutTempSkipped(fragments) {
+           for (let r; r = this.tempSkipped.pop();)
+               fragments = cutFragments(fragments, r.from, r.to);
+           return fragments;
+       }
+       /**
+       @internal
+       */
+       changes(changes, newState) {
+           let { fragments, tree, treeLen, viewport, skipped } = this;
+           this.takeTree();
+           if (!changes.empty) {
+               let ranges = [];
+               changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
+               fragments = TreeFragment.applyChanges(fragments, ranges);
+               tree = Tree.empty;
+               treeLen = 0;
+               viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
+               if (this.skipped.length) {
+                   skipped = [];
+                   for (let r of this.skipped) {
+                       let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
+                       if (from < to)
+                           skipped.push({ from, to });
+                   }
+               }
+           }
+           return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
+       }
+       /**
+       @internal
+       */
+       updateViewport(viewport) {
+           if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
+               return false;
+           this.viewport = viewport;
+           let startLen = this.skipped.length;
+           for (let i = 0; i < this.skipped.length; i++) {
+               let { from, to } = this.skipped[i];
+               if (from < viewport.to && to > viewport.from) {
+                   this.fragments = cutFragments(this.fragments, from, to);
+                   this.skipped.splice(i--, 1);
+               }
+           }
+           if (this.skipped.length >= startLen)
+               return false;
+           this.reset();
+           return true;
+       }
+       /**
+       @internal
+       */
+       reset() {
+           if (this.parse) {
+               this.takeTree();
+               this.parse = null;
+           }
+       }
+       /**
+       Notify the parse scheduler that the given region was skipped
+       because it wasn't in view, and the parse should be restarted
+       when it comes into view.
+       */
+       skipUntilInView(from, to) {
+           this.skipped.push({ from, to });
+       }
+       /**
+       Returns a parser intended to be used as placeholder when
+       asynchronously loading a nested parser. It'll skip its input and
+       mark it as not-really-parsed, so that the next update will parse
+       it again.
+       
+       When `until` is given, a reparse will be scheduled when that
+       promise resolves.
+       */
+       static getSkippingParser(until) {
+           return new class extends Parser {
+               createParse(input, fragments, ranges) {
+                   let from = ranges[0].from, to = ranges[ranges.length - 1].to;
+                   let parser = {
+                       parsedPos: from,
+                       advance() {
+                           let cx = currentContext;
+                           if (cx) {
+                               for (let r of ranges)
+                                   cx.tempSkipped.push(r);
+                               if (until)
+                                   cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
+                           }
+                           this.parsedPos = to;
+                           return new Tree(NodeType.none, [], [], to - from);
+                       },
+                       stoppedAt: null,
+                       stopAt() { }
+                   };
+                   return parser;
+               }
+           };
+       }
+       /**
+       @internal
+       */
+       isDone(upto) {
+           upto = Math.min(upto, this.state.doc.length);
+           let frags = this.fragments;
+           return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
+       }
+       /**
+       Get the context for the current parse, or `null` if no editor
+       parse is in progress.
+       */
+       static get() { return currentContext; }
+   }
+   function cutFragments(fragments, from, to) {
+       return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
+   }
+   class LanguageState {
+       constructor(
+       // A mutable parse state that is used to preserve work done during
+       // the lifetime of a state when moving to the next state.
+       context) {
+           this.context = context;
+           this.tree = context.tree;
+       }
+       apply(tr) {
+           if (!tr.docChanged && this.tree == this.context.tree)
+               return this;
+           let newCx = this.context.changes(tr.changes, tr.state);
+           // If the previous parse wasn't done, go forward only up to its
+           // end position or the end of the viewport, to avoid slowing down
+           // state updates with parse work beyond the viewport.
+           let upto = this.context.treeLen == tr.startState.doc.length ? undefined
+               : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
+           if (!newCx.work(20 /* Work.Apply */, upto))
+               newCx.takeTree();
+           return new LanguageState(newCx);
+       }
+       static init(state) {
+           let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);
+           let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
+           if (!parseState.work(20 /* Work.Apply */, vpTo))
+               parseState.takeTree();
+           return new LanguageState(parseState);
+       }
+   }
+   Language.state = /*@__PURE__*/StateField.define({
+       create: LanguageState.init,
+       update(value, tr) {
+           for (let e of tr.effects)
+               if (e.is(Language.setState))
+                   return e.value;
+           if (tr.startState.facet(language) != tr.state.facet(language))
+               return LanguageState.init(tr.state);
+           return value.apply(tr);
+       }
+   });
+   let requestIdle = (callback) => {
+       let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);
+       return () => clearTimeout(timeout);
+   };
+   if (typeof requestIdleCallback != "undefined")
+       requestIdle = (callback) => {
+           let idle = -1, timeout = setTimeout(() => {
+               idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });
+           }, 100 /* Work.MinPause */);
+           return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
+       };
+   const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
+       ? () => navigator.scheduling.isInputPending() : null;
+   const parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {
+       constructor(view) {
+           this.view = view;
+           this.working = null;
+           this.workScheduled = 0;
+           // End of the current time chunk
+           this.chunkEnd = -1;
+           // Milliseconds of budget left for this chunk
+           this.chunkBudget = -1;
+           this.work = this.work.bind(this);
+           this.scheduleWork();
+       }
+       update(update) {
+           let cx = this.view.state.field(Language.state).context;
+           if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
+               this.scheduleWork();
+           if (update.docChanged || update.selectionSet) {
+               if (this.view.hasFocus)
+                   this.chunkBudget += 50 /* Work.ChangeBonus */;
+               this.scheduleWork();
+           }
+           this.checkAsyncSchedule(cx);
+       }
+       scheduleWork() {
+           if (this.working)
+               return;
+           let { state } = this.view, field = state.field(Language.state);
+           if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
+               this.working = requestIdle(this.work);
+       }
+       work(deadline) {
+           this.working = null;
+           let now = Date.now();
+           if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
+               this.chunkEnd = now + 30000 /* Work.ChunkTime */;
+               this.chunkBudget = 3000 /* Work.ChunkBudget */;
+           }
+           if (this.chunkBudget <= 0)
+               return; // No more budget
+           let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
+           if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))
+               return;
+           let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);
+           let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
+           let done = field.context.work(() => {
+               return isInputPending && isInputPending() || Date.now() > endTime;
+           }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));
+           this.chunkBudget -= Date.now() - now;
+           if (done || this.chunkBudget <= 0) {
+               field.context.takeTree();
+               this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });
+           }
+           if (this.chunkBudget > 0 && !(done && !viewportFirst))
+               this.scheduleWork();
+           this.checkAsyncSchedule(field.context);
+       }
+       checkAsyncSchedule(cx) {
+           if (cx.scheduleOn) {
+               this.workScheduled++;
+               cx.scheduleOn
+                   .then(() => this.scheduleWork())
+                   .catch(err => logException(this.view.state, err))
+                   .then(() => this.workScheduled--);
+               cx.scheduleOn = null;
+           }
+       }
+       destroy() {
+           if (this.working)
+               this.working();
+       }
+       isWorking() {
+           return !!(this.working || this.workScheduled > 0);
+       }
+   }, {
+       eventHandlers: { focus() { this.scheduleWork(); } }
+   });
+   /**
+   The facet used to associate a language with an editor state. Used
+   by `Language` object's `extension` property (so you don't need to
+   manually wrap your languages in this). Can be used to access the
+   current language on a state.
+   */
+   const language = /*@__PURE__*/Facet.define({
+       combine(languages) { return languages.length ? languages[0] : null; },
+       enables: language => [
+           Language.state,
+           parseWorker,
+           EditorView.contentAttributes.compute([language], state => {
+               let lang = state.facet(language);
+               return lang && lang.name ? { "data-language": lang.name } : {};
+           })
+       ]
+   });
+   /**
+   This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
+   optional set of supporting extensions. Language packages are
+   encouraged to export a function that optionally takes a
+   configuration object and returns a `LanguageSupport` instance, as
+   the main way for client code to use the package.
+   */
+   class LanguageSupport {
+       /**
+       Create a language support object.
+       */
+       constructor(
+       /**
+       The language object.
+       */
+       language, 
+       /**
+       An optional set of supporting extensions. When nesting a
+       language in another language, the outer language is encouraged
+       to include the supporting extensions for its inner languages
+       in its own set of support extensions.
+       */
+       support = []) {
+           this.language = language;
+           this.support = support;
+           this.extension = [language, support];
+       }
+   }
+   /**
+   Facet for overriding the unit by which indentation happens. Should
+   be a string consisting either entirely of the same whitespace
+   character. When not set, this defaults to 2 spaces.
+   */
+   const indentUnit = /*@__PURE__*/Facet.define({
+       combine: values => {
+           if (!values.length)
+               return "  ";
+           let unit = values[0];
+           if (!unit || /\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))
+               throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
+           return unit;
+       }
+   });
+   /**
+   A syntax tree node prop used to associate indentation strategies
+   with node types. Such a strategy is a function from an indentation
+   context to a column number (see also
+   [`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null
+   indicates that no definitive indentation can be determined.
+   */
+   const indentNodeProp = /*@__PURE__*/new NodeProp();
+   // Check whether a delimited node is aligned (meaning there are
+   // non-skipped nodes on the same line as the opening delimiter). And
+   // if so, return the opening token.
+   function bracketedAligned(context) {
+       let tree = context.node;
+       let openToken = tree.childAfter(tree.from), last = tree.lastChild;
+       if (!openToken)
+           return null;
+       let sim = context.options.simulateBreak;
+       let openLine = context.state.doc.lineAt(openToken.from);
+       let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
+       for (let pos = openToken.to;;) {
+           let next = tree.childAfter(pos);
+           if (!next || next == last)
+               return null;
+           if (!next.type.isSkipped) {
+               if (next.from >= lineEnd)
+                   return null;
+               let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
+               return { from: openToken.from, to: openToken.to + space };
+           }
+           pos = next.to;
+       }
+   }
+   /**
+   An indentation strategy for delimited (usually bracketed) nodes.
+   Will, by default, indent one unit more than the parent's base
+   indent unless the line starts with a closing token. When `align`
+   is true and there are non-skipped nodes on the node's opening
+   line, the content of the node will be aligned with the end of the
+   opening node, like this:
+
+       foo(bar,
+           baz)
+   */
+   function delimitedIndent({ closing, align = true, units = 1 }) {
+       return (context) => delimitedStrategy(context, align, units, closing);
+   }
+   function delimitedStrategy(context, align, units, closing, closedAt) {
+       let after = context.textAfter, space = after.match(/^\s*/)[0].length;
+       let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
+       let aligned = align ? bracketedAligned(context) : null;
+       if (aligned)
+           return closed ? context.column(aligned.from) : context.column(aligned.to);
+       return context.baseIndent + (closed ? 0 : context.unit * units);
+   }
+   /**
+   An indentation strategy that aligns a node's content to its base
+   indentation.
+   */
+   const flatIndent = (context) => context.baseIndent;
+   /**
+   Creates an indentation strategy that, by default, indents
+   continued lines one unit more than the node's base indentation.
+   You can provide `except` to prevent indentation of lines that
+   match a pattern (for example `/^else\b/` in `if`/`else`
+   constructs), and you can change the amount of units used with the
+   `units` option.
+   */
+   function continuedIndent({ except, units = 1 } = {}) {
+       return (context) => {
+           let matchExcept = except && except.test(context.textAfter);
+           return context.baseIndent + (matchExcept ? 0 : units * context.unit);
+       };
+   }
+   /**
+   This node prop is used to associate folding information with
+   syntax node types. Given a syntax node, it should check whether
+   that tree is foldable and return the range that can be collapsed
+   when it is.
+   */
+   const foldNodeProp = /*@__PURE__*/new NodeProp();
+   /**
+   [Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
+   the first and the last child of a syntax node. Useful for nodes
+   that start and end with delimiters.
+   */
+   function foldInside(node) {
+       let first = node.firstChild, last = node.lastChild;
+       return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;
+   }
+
+   /**
+   A highlight style associates CSS styles with higlighting
+   [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
+   */
+   class HighlightStyle {
+       constructor(
+       /**
+       The tag styles used to create this highlight style.
+       */
+       specs, options) {
+           this.specs = specs;
+           let modSpec;
+           function def(spec) {
+               let cls = StyleModule.newName();
+               (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
+               return cls;
+           }
+           const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
+           const scopeOpt = options.scope;
+           this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
+               : scopeOpt ? (type) => type == scopeOpt : undefined;
+           this.style = tagHighlighter(specs.map(style => ({
+               tag: style.tag,
+               class: style.class || def(Object.assign({}, style, { tag: null }))
+           })), {
+               all,
+           }).style;
+           this.module = modSpec ? new StyleModule(modSpec) : null;
+           this.themeType = options.themeType;
+       }
+       /**
+       Create a highlighter style that associates the given styles to
+       the given tags. The specs must be objects that hold a style tag
+       or array of tags in their `tag` property, and either a single
+       `class` property providing a static CSS class (for highlighter
+       that rely on external styling), or a
+       [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
+       set of CSS properties (which define the styling for those tags).
+       
+       The CSS rules created for a highlighter will be emitted in the
+       order of the spec's properties. That means that for elements that
+       have multiple tags associated with them, styles defined further
+       down in the list will have a higher CSS precedence than styles
+       defined earlier.
+       */
+       static define(specs, options) {
+           return new HighlightStyle(specs, options || {});
+       }
+   }
+   const highlighterFacet = /*@__PURE__*/Facet.define();
+   const fallbackHighlighter = /*@__PURE__*/Facet.define({
+       combine(values) { return values.length ? [values[0]] : null; }
+   });
+   function getHighlighters(state) {
+       let main = state.facet(highlighterFacet);
+       return main.length ? main : state.facet(fallbackHighlighter);
+   }
+   /**
+   Wrap a highlighter in an editor extension that uses it to apply
+   syntax highlighting to the editor content.
+
+   When multiple (non-fallback) styles are provided, the styling
+   applied is the union of the classes they emit.
+   */
+   function syntaxHighlighting(highlighter, options) {
+       let ext = [treeHighlighter], themeType;
+       if (highlighter instanceof HighlightStyle) {
+           if (highlighter.module)
+               ext.push(EditorView.styleModule.of(highlighter.module));
+           themeType = highlighter.themeType;
+       }
+       if (themeType)
+           ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {
+               return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
+           }));
+       else
+           ext.push(highlighterFacet.of(highlighter));
+       return ext;
+   }
+   class TreeHighlighter {
+       constructor(view) {
+           this.markCache = Object.create(null);
+           this.tree = syntaxTree(view.state);
+           this.decorations = this.buildDeco(view, getHighlighters(view.state));
+           this.decoratedTo = view.viewport.to;
+       }
+       update(update) {
+           let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);
+           let styleChange = highlighters != getHighlighters(update.startState);
+           let { viewport } = update.view, decoratedToMapped = update.changes.mapPos(this.decoratedTo, 1);
+           if (tree.length < viewport.to && !styleChange && tree.type == this.tree.type && decoratedToMapped >= viewport.to) {
+               this.decorations = this.decorations.map(update.changes);
+               this.decoratedTo = decoratedToMapped;
+           }
+           else if (tree != this.tree || update.viewportChanged || styleChange) {
+               this.tree = tree;
+               this.decorations = this.buildDeco(update.view, highlighters);
+               this.decoratedTo = viewport.to;
+           }
+       }
+       buildDeco(view, highlighters) {
+           if (!highlighters || !this.tree.length)
+               return Decoration.none;
+           let builder = new RangeSetBuilder();
+           for (let { from, to } of view.visibleRanges) {
+               highlightTree(this.tree, highlighters, (from, to, style) => {
+                   builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));
+               }, from, to);
+           }
+           return builder.finish();
+       }
+   }
+   const treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {
+       decorations: v => v.decorations
+   }));
+   /**
+   A default highlight style (works well with light themes).
+   */
+   /*@__PURE__*/HighlightStyle.define([
+       { tag: tags.meta,
+           color: "#404740" },
+       { tag: tags.link,
+           textDecoration: "underline" },
+       { tag: tags.heading,
+           textDecoration: "underline",
+           fontWeight: "bold" },
+       { tag: tags.emphasis,
+           fontStyle: "italic" },
+       { tag: tags.strong,
+           fontWeight: "bold" },
+       { tag: tags.strikethrough,
+           textDecoration: "line-through" },
+       { tag: tags.keyword,
+           color: "#708" },
+       { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
+           color: "#219" },
+       { tag: [tags.literal, tags.inserted],
+           color: "#164" },
+       { tag: [tags.string, tags.deleted],
+           color: "#a11" },
+       { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],
+           color: "#e40" },
+       { tag: /*@__PURE__*/tags.definition(tags.variableName),
+           color: "#00f" },
+       { tag: /*@__PURE__*/tags.local(tags.variableName),
+           color: "#30a" },
+       { tag: [tags.typeName, tags.namespace],
+           color: "#085" },
+       { tag: tags.className,
+           color: "#167" },
+       { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],
+           color: "#256" },
+       { tag: /*@__PURE__*/tags.definition(tags.propertyName),
+           color: "#00c" },
+       { tag: tags.comment,
+           color: "#940" },
+       { tag: tags.invalid,
+           color: "#f00" }
+   ]);
+   const noTokens = /*@__PURE__*/Object.create(null);
+   const typeArray = [NodeType.none];
+   const warned = [];
+   // Cache of node types by name and tags
+   const byTag = /*@__PURE__*/Object.create(null);
+   const defaultTable = /*@__PURE__*/Object.create(null);
+   for (let [legacyName, name] of [
+       ["variable", "variableName"],
+       ["variable-2", "variableName.special"],
+       ["string-2", "string.special"],
+       ["def", "variableName.definition"],
+       ["tag", "tagName"],
+       ["attribute", "attributeName"],
+       ["type", "typeName"],
+       ["builtin", "variableName.standard"],
+       ["qualifier", "modifier"],
+       ["error", "invalid"],
+       ["header", "heading"],
+       ["property", "propertyName"]
+   ])
+       defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);
+   function warnForPart(part, msg) {
+       if (warned.indexOf(part) > -1)
+           return;
+       warned.push(part);
+       console.warn(msg);
+   }
+   function createTokenType(extra, tagStr) {
+       let tags$1 = [];
+       for (let name of tagStr.split(" ")) {
+           let found = [];
+           for (let part of name.split(".")) {
+               let value = (extra[part] || tags[part]);
+               if (!value) {
+                   warnForPart(part, `Unknown highlighting tag ${part}`);
+               }
+               else if (typeof value == "function") {
+                   if (!found.length)
+                       warnForPart(part, `Modifier ${part} used at start of tag`);
+                   else
+                       found = found.map(value);
+               }
+               else {
+                   if (found.length)
+                       warnForPart(part, `Tag ${part} used as modifier`);
+                   else
+                       found = Array.isArray(value) ? value : [value];
+               }
+           }
+           for (let tag of found)
+               tags$1.push(tag);
+       }
+       if (!tags$1.length)
+           return 0;
+       let name = tagStr.replace(/ /g, "_"), key = name + " " + tags$1.map(t => t.id);
+       let known = byTag[key];
+       if (known)
+           return known.id;
+       let type = byTag[key] = NodeType.define({
+           id: typeArray.length,
+           name,
+           props: [styleTags({ [name]: tags$1 })]
+       });
+       typeArray.push(type);
+       return type.id;
+   }
+   ({
+       rtl: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "rtl" }, bidiIsolate: Direction.RTL }),
+       ltr: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "ltr" }, bidiIsolate: Direction.LTR }),
+       auto: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "auto" }, bidiIsolate: null })
+   });
+
+   /**
+   An instance of this is passed to completion source functions.
+   */
+   class CompletionContext {
+       /**
+       Create a new completion context. (Mostly useful for testing
+       completion sources—in the editor, the extension will create
+       these for you.)
+       */
+       constructor(
+       /**
+       The editor state that the completion happens in.
+       */
+       state, 
+       /**
+       The position at which the completion is happening.
+       */
+       pos, 
+       /**
+       Indicates whether completion was activated explicitly, or
+       implicitly by typing. The usual way to respond to this is to
+       only return completions when either there is part of a
+       completable entity before the cursor, or `explicit` is true.
+       */
+       explicit, 
+       /**
+       The editor view. May be undefined if the context was created
+       in a situation where there is no such view available, such as
+       in synchronous updates via
+       [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
+       or when called by test code.
+       */
+       view) {
+           this.state = state;
+           this.pos = pos;
+           this.explicit = explicit;
+           this.view = view;
+           /**
+           @internal
+           */
+           this.abortListeners = [];
+           /**
+           @internal
+           */
+           this.abortOnDocChange = false;
+       }
+       /**
+       Get the extent, content, and (if there is a token) type of the
+       token before `this.pos`.
+       */
+       tokenBefore(types) {
+           let token = syntaxTree(this.state).resolveInner(this.pos, -1);
+           while (token && types.indexOf(token.name) < 0)
+               token = token.parent;
+           return token ? { from: token.from, to: this.pos,
+               text: this.state.sliceDoc(token.from, this.pos),
+               type: token.type } : null;
+       }
+       /**
+       Get the match of the given expression directly before the
+       cursor.
+       */
+       matchBefore(expr) {
+           let line = this.state.doc.lineAt(this.pos);
+           let start = Math.max(line.from, this.pos - 250);
+           let str = line.text.slice(start - line.from, this.pos - line.from);
+           let found = str.search(ensureAnchor(expr, false));
+           return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) };
+       }
+       /**
+       Yields true when the query has been aborted. Can be useful in
+       asynchronous queries to avoid doing work that will be ignored.
+       */
+       get aborted() { return this.abortListeners == null; }
+       /**
+       Allows you to register abort handlers, which will be called when
+       the query is
+       [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
+       
+       By default, running queries will not be aborted for regular
+       typing or backspacing, on the assumption that they are likely to
+       return a result with a
+       [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
+       allows the result to be used after all. Passing `onDocChange:
+       true` will cause this query to be aborted for any document
+       change.
+       */
+       addEventListener(type, listener, options) {
+           if (type == "abort" && this.abortListeners) {
+               this.abortListeners.push(listener);
+               if (options && options.onDocChange)
+                   this.abortOnDocChange = true;
+           }
+       }
+   }
+   function toSet(chars) {
+       let flat = Object.keys(chars).join("");
+       let words = /\w/.test(flat);
+       if (words)
+           flat = flat.replace(/\w/g, "");
+       return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
+   }
+   function prefixMatch(options) {
+       let first = Object.create(null), rest = Object.create(null);
+       for (let { label } of options) {
+           first[label[0]] = true;
+           for (let i = 1; i < label.length; i++)
+               rest[label[i]] = true;
+       }
+       let source = toSet(first) + toSet(rest) + "*$";
+       return [new RegExp("^" + source), new RegExp(source)];
+   }
+   /**
+   Given a a fixed array of options, return an autocompleter that
+   completes them.
+   */
+   function completeFromList(list) {
+       let options = list.map(o => typeof o == "string" ? { label: o } : o);
+       let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options);
+       return (context) => {
+           let token = context.matchBefore(match);
+           return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null;
+       };
+   }
+   /**
+   Wrap the given completion source so that it will not fire when the
+   cursor is in a syntax node with one of the given names.
+   */
+   function ifNotIn(nodes, source) {
+       return (context) => {
+           for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) {
+               if (nodes.indexOf(pos.name) > -1)
+                   return null;
+               if (pos.type.isTop)
+                   break;
+           }
+           return source(context);
+       };
+   }
+   class Option {
+       constructor(completion, source, match, score) {
+           this.completion = completion;
+           this.source = source;
+           this.match = match;
+           this.score = score;
+       }
+   }
+   function cur(state) { return state.selection.main.from; }
+   // Make sure the given regexp has a $ at its end and, if `start` is
+   // true, a ^ at its start.
+   function ensureAnchor(expr, start) {
+       var _a;
+       let { source } = expr;
+       let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$";
+       if (!addStart && !addEnd)
+           return expr;
+       return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : ""));
+   }
+   /**
+   This annotation is added to transactions that are produced by
+   picking a completion.
+   */
+   const pickedCompletion = /*@__PURE__*/Annotation.define();
+   /**
+   Helper function that returns a transaction spec which inserts a
+   completion's text in the main selection range, and any other
+   selection range that has the same text in front of it.
+   */
+   function insertCompletionText(state, text, from, to) {
+       let { main } = state.selection, fromOff = from - main.from, toOff = to - main.from;
+       return Object.assign(Object.assign({}, state.changeByRange(range => {
+           if (range != main && from != to &&
+               state.sliceDoc(range.from + fromOff, range.from + toOff) != state.sliceDoc(from, to))
+               return { range };
+           let lines = state.toText(text);
+           return {
+               changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: lines },
+               range: EditorSelection.cursor(range.from + fromOff + lines.length)
+           };
+       })), { scrollIntoView: true, userEvent: "input.complete" });
+   }
+   const SourceCache = /*@__PURE__*/new WeakMap();
+   function asSource(source) {
+       if (!Array.isArray(source))
+           return source;
+       let known = SourceCache.get(source);
+       if (!known)
+           SourceCache.set(source, known = completeFromList(source));
+       return known;
+   }
+   const startCompletionEffect = /*@__PURE__*/StateEffect.define();
+   const closeCompletionEffect = /*@__PURE__*/StateEffect.define();
+
+   // A pattern matcher for fuzzy completion matching. Create an instance
+   // once for a pattern, and then use that to match any number of
+   // completions.
+   class FuzzyMatcher {
+       constructor(pattern) {
+           this.pattern = pattern;
+           this.chars = [];
+           this.folded = [];
+           // Buffers reused by calls to `match` to track matched character
+           // positions.
+           this.any = [];
+           this.precise = [];
+           this.byWord = [];
+           this.score = 0;
+           this.matched = [];
+           for (let p = 0; p < pattern.length;) {
+               let char = codePointAt(pattern, p), size = codePointSize(char);
+               this.chars.push(char);
+               let part = pattern.slice(p, p + size), upper = part.toUpperCase();
+               this.folded.push(codePointAt(upper == part ? part.toLowerCase() : upper, 0));
+               p += size;
+           }
+           this.astral = pattern.length != this.chars.length;
+       }
+       ret(score, matched) {
+           this.score = score;
+           this.matched = matched;
+           return this;
+       }
+       // Matches a given word (completion) against the pattern (input).
+       // Will return a boolean indicating whether there was a match and,
+       // on success, set `this.score` to the score, `this.matched` to an
+       // array of `from, to` pairs indicating the matched parts of `word`.
+       //
+       // The score is a number that is more negative the worse the match
+       // is. See `Penalty` above.
+       match(word) {
+           if (this.pattern.length == 0)
+               return this.ret(-100 /* Penalty.NotFull */, []);
+           if (word.length < this.pattern.length)
+               return null;
+           let { chars, folded, any, precise, byWord } = this;
+           // For single-character queries, only match when they occur right
+           // at the start
+           if (chars.length == 1) {
+               let first = codePointAt(word, 0), firstSize = codePointSize(first);
+               let score = firstSize == word.length ? 0 : -100 /* Penalty.NotFull */;
+               if (first == chars[0]) ;
+               else if (first == folded[0])
+                   score += -200 /* Penalty.CaseFold */;
+               else
+                   return null;
+               return this.ret(score, [0, firstSize]);
+           }
+           let direct = word.indexOf(this.pattern);
+           if (direct == 0)
+               return this.ret(word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */, [0, this.pattern.length]);
+           let len = chars.length, anyTo = 0;
+           if (direct < 0) {
+               for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) {
+                   let next = codePointAt(word, i);
+                   if (next == chars[anyTo] || next == folded[anyTo])
+                       any[anyTo++] = i;
+                   i += codePointSize(next);
+               }
+               // No match, exit immediately
+               if (anyTo < len)
+                   return null;
+           }
+           // This tracks the extent of the precise (non-folded, not
+           // necessarily adjacent) match
+           let preciseTo = 0;
+           // Tracks whether there is a match that hits only characters that
+           // appear to be starting words. `byWordFolded` is set to true when
+           // a case folded character is encountered in such a match
+           let byWordTo = 0, byWordFolded = false;
+           // If we've found a partial adjacent match, these track its state
+           let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
+           let hasLower = /[a-z]/.test(word), wordAdjacent = true;
+           // Go over the option's text, scanning for the various kinds of matches
+           for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) {
+               let next = codePointAt(word, i);
+               if (direct < 0) {
+                   if (preciseTo < len && next == chars[preciseTo])
+                       precise[preciseTo++] = i;
+                   if (adjacentTo < len) {
+                       if (next == chars[adjacentTo] || next == folded[adjacentTo]) {
+                           if (adjacentTo == 0)
+                               adjacentStart = i;
+                           adjacentEnd = i + 1;
+                           adjacentTo++;
+                       }
+                       else {
+                           adjacentTo = 0;
+                       }
+                   }
+               }
+               let ch, type = next < 0xff
+                   ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */)
+                   : ((ch = fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */);
+               if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) {
+                   if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
+                       byWord[byWordTo++] = i;
+                   else if (byWord.length)
+                       wordAdjacent = false;
+               }
+               prevType = type;
+               i += codePointSize(next);
+           }
+           if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
+               return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word);
+           if (adjacentTo == len && adjacentStart == 0)
+               return this.ret(-200 /* Penalty.CaseFold */ - word.length + (adjacentEnd == word.length ? 0 : -100 /* Penalty.NotFull */), [0, adjacentEnd]);
+           if (direct > -1)
+               return this.ret(-700 /* Penalty.NotStart */ - word.length, [direct, direct + this.pattern.length]);
+           if (adjacentTo == len)
+               return this.ret(-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, [adjacentStart, adjacentEnd]);
+           if (byWordTo == len)
+               return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ +
+                   (wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word);
+           return chars.length == 2 ? null
+               : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word);
+       }
+       result(score, positions, word) {
+           let result = [], i = 0;
+           for (let pos of positions) {
+               let to = pos + (this.astral ? codePointSize(codePointAt(word, pos)) : 1);
+               if (i && result[i - 1] == pos)
+                   result[i - 1] = to;
+               else {
+                   result[i++] = pos;
+                   result[i++] = to;
+               }
+           }
+           return this.ret(score - word.length, result);
+       }
+   }
+   class StrictMatcher {
+       constructor(pattern) {
+           this.pattern = pattern;
+           this.matched = [];
+           this.score = 0;
+           this.folded = pattern.toLowerCase();
+       }
+       match(word) {
+           if (word.length < this.pattern.length)
+               return null;
+           let start = word.slice(0, this.pattern.length);
+           let match = start == this.pattern ? 0 : start.toLowerCase() == this.folded ? -200 /* Penalty.CaseFold */ : null;
+           if (match == null)
+               return null;
+           this.matched = [0, start.length];
+           this.score = match + (word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */);
+           return this;
+       }
+   }
+
+   const completionConfig = /*@__PURE__*/Facet.define({
+       combine(configs) {
+           return combineConfig(configs, {
+               activateOnTyping: true,
+               activateOnCompletion: () => false,
+               activateOnTypingDelay: 100,
+               selectOnOpen: true,
+               override: null,
+               closeOnBlur: true,
+               maxRenderedOptions: 100,
+               defaultKeymap: true,
+               tooltipClass: () => "",
+               optionClass: () => "",
+               aboveCursor: false,
+               icons: true,
+               addToOptions: [],
+               positionInfo: defaultPositionInfo,
+               filterStrict: false,
+               compareCompletions: (a, b) => a.label.localeCompare(b.label),
+               interactionDelay: 75,
+               updateSyncTime: 100
+           }, {
+               defaultKeymap: (a, b) => a && b,
+               closeOnBlur: (a, b) => a && b,
+               icons: (a, b) => a && b,
+               tooltipClass: (a, b) => c => joinClass(a(c), b(c)),
+               optionClass: (a, b) => c => joinClass(a(c), b(c)),
+               addToOptions: (a, b) => a.concat(b),
+               filterStrict: (a, b) => a || b,
+           });
+       }
+   });
+   function joinClass(a, b) {
+       return a ? b ? a + " " + b : a : b;
+   }
+   function defaultPositionInfo(view, list, option, info, space, tooltip) {
+       let rtl = view.textDirection == Direction.RTL, left = rtl, narrow = false;
+       let side = "top", offset, maxWidth;
+       let spaceLeft = list.left - space.left, spaceRight = space.right - list.right;
+       let infoWidth = info.right - info.left, infoHeight = info.bottom - info.top;
+       if (left && spaceLeft < Math.min(infoWidth, spaceRight))
+           left = false;
+       else if (!left && spaceRight < Math.min(infoWidth, spaceLeft))
+           left = true;
+       if (infoWidth <= (left ? spaceLeft : spaceRight)) {
+           offset = Math.max(space.top, Math.min(option.top, space.bottom - infoHeight)) - list.top;
+           maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight);
+       }
+       else {
+           narrow = true;
+           maxWidth = Math.min(400 /* Info.Width */, (rtl ? list.right : space.right - list.left) - 30 /* Info.Margin */);
+           let spaceBelow = space.bottom - list.bottom;
+           if (spaceBelow >= infoHeight || spaceBelow > list.top) { // Below the completion
+               offset = option.bottom - list.top;
+           }
+           else { // Above it
+               side = "bottom";
+               offset = list.bottom - option.top;
+           }
+       }
+       let scaleY = (list.bottom - list.top) / tooltip.offsetHeight;
+       let scaleX = (list.right - list.left) / tooltip.offsetWidth;
+       return {
+           style: `${side}: ${offset / scaleY}px; max-width: ${maxWidth / scaleX}px`,
+           class: "cm-completionInfo-" + (narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right")
+       };
+   }
+
+   function optionContent(config) {
+       let content = config.addToOptions.slice();
+       if (config.icons)
+           content.push({
+               render(completion) {
+                   let icon = document.createElement("div");
+                   icon.classList.add("cm-completionIcon");
+                   if (completion.type)
+                       icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls));
+                   icon.setAttribute("aria-hidden", "true");
+                   return icon;
+               },
+               position: 20
+           });
+       content.push({
+           render(completion, _s, _v, match) {
+               let labelElt = document.createElement("span");
+               labelElt.className = "cm-completionLabel";
+               let label = completion.displayLabel || completion.label, off = 0;
+               for (let j = 0; j < match.length;) {
+                   let from = match[j++], to = match[j++];
+                   if (from > off)
+                       labelElt.appendChild(document.createTextNode(label.slice(off, from)));
+                   let span = labelElt.appendChild(document.createElement("span"));
+                   span.appendChild(document.createTextNode(label.slice(from, to)));
+                   span.className = "cm-completionMatchedText";
+                   off = to;
+               }
+               if (off < label.length)
+                   labelElt.appendChild(document.createTextNode(label.slice(off)));
+               return labelElt;
+           },
+           position: 50
+       }, {
+           render(completion) {
+               if (!completion.detail)
+                   return null;
+               let detailElt = document.createElement("span");
+               detailElt.className = "cm-completionDetail";
+               detailElt.textContent = completion.detail;
+               return detailElt;
+           },
+           position: 80
+       });
+       return content.sort((a, b) => a.position - b.position).map(a => a.render);
+   }
+   function rangeAroundSelected(total, selected, max) {
+       if (total <= max)
+           return { from: 0, to: total };
+       if (selected < 0)
+           selected = 0;
+       if (selected <= (total >> 1)) {
+           let off = Math.floor(selected / max);
+           return { from: off * max, to: (off + 1) * max };
+       }
+       let off = Math.floor((total - selected) / max);
+       return { from: total - (off + 1) * max, to: total - off * max };
+   }
+   class CompletionTooltip {
+       constructor(view, stateField, applyCompletion) {
+           this.view = view;
+           this.stateField = stateField;
+           this.applyCompletion = applyCompletion;
+           this.info = null;
+           this.infoDestroy = null;
+           this.placeInfoReq = {
+               read: () => this.measureInfo(),
+               write: (pos) => this.placeInfo(pos),
+               key: this
+           };
+           this.space = null;
+           this.currentClass = "";
+           let cState = view.state.field(stateField);
+           let { options, selected } = cState.open;
+           let config = view.state.facet(completionConfig);
+           this.optionContent = optionContent(config);
+           this.optionClass = config.optionClass;
+           this.tooltipClass = config.tooltipClass;
+           this.range = rangeAroundSelected(options.length, selected, config.maxRenderedOptions);
+           this.dom = document.createElement("div");
+           this.dom.className = "cm-tooltip-autocomplete";
+           this.updateTooltipClass(view.state);
+           this.dom.addEventListener("mousedown", (e) => {
+               let { options } = view.state.field(stateField).open;
+               for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) {
+                   if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) {
+                       this.applyCompletion(view, options[+match[1]]);
+                       e.preventDefault();
+                       return;
+                   }
+               }
+           });
+           this.dom.addEventListener("focusout", (e) => {
+               let state = view.state.field(this.stateField, false);
+               if (state && state.tooltip && view.state.facet(completionConfig).closeOnBlur &&
+                   e.relatedTarget != view.contentDOM)
+                   view.dispatch({ effects: closeCompletionEffect.of(null) });
+           });
+           this.showOptions(options, cState.id);
+       }
+       mount() { this.updateSel(); }
+       showOptions(options, id) {
+           if (this.list)
+               this.list.remove();
+           this.list = this.dom.appendChild(this.createListBox(options, id, this.range));
+           this.list.addEventListener("scroll", () => {
+               if (this.info)
+                   this.view.requestMeasure(this.placeInfoReq);
+           });
+       }
+       update(update) {
+           var _a;
+           let cState = update.state.field(this.stateField);
+           let prevState = update.startState.field(this.stateField);
+           this.updateTooltipClass(update.state);
+           if (cState != prevState) {
+               let { options, selected, disabled } = cState.open;
+               if (!prevState.open || prevState.open.options != options) {
+                   this.range = rangeAroundSelected(options.length, selected, update.state.facet(completionConfig).maxRenderedOptions);
+                   this.showOptions(options, cState.id);
+               }
+               this.updateSel();
+               if (disabled != ((_a = prevState.open) === null || _a === void 0 ? void 0 : _a.disabled))
+                   this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!disabled);
+           }
+       }
+       updateTooltipClass(state) {
+           let cls = this.tooltipClass(state);
+           if (cls != this.currentClass) {
+               for (let c of this.currentClass.split(" "))
+                   if (c)
+                       this.dom.classList.remove(c);
+               for (let c of cls.split(" "))
+                   if (c)
+                       this.dom.classList.add(c);
+               this.currentClass = cls;
+           }
+       }
+       positioned(space) {
+           this.space = space;
+           if (this.info)
+               this.view.requestMeasure(this.placeInfoReq);
+       }
+       updateSel() {
+           let cState = this.view.state.field(this.stateField), open = cState.open;
+           if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
+               this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
+               this.showOptions(open.options, cState.id);
+           }
+           if (this.updateSelectedOption(open.selected)) {
+               this.destroyInfo();
+               let { completion } = open.options[open.selected];
+               let { info } = completion;
+               if (!info)
+                   return;
+               let infoResult = typeof info === "string" ? document.createTextNode(info) : info(completion);
+               if (!infoResult)
+                   return;
+               if ("then" in infoResult) {
+                   infoResult.then(obj => {
+                       if (obj && this.view.state.field(this.stateField, false) == cState)
+                           this.addInfoPane(obj, completion);
+                   }).catch(e => logException(this.view.state, e, "completion info"));
+               }
+               else {
+                   this.addInfoPane(infoResult, completion);
+               }
+           }
+       }
+       addInfoPane(content, completion) {
+           this.destroyInfo();
+           let wrap = this.info = document.createElement("div");
+           wrap.className = "cm-tooltip cm-completionInfo";
+           if (content.nodeType != null) {
+               wrap.appendChild(content);
+               this.infoDestroy = null;
+           }
+           else {
+               let { dom, destroy } = content;
+               wrap.appendChild(dom);
+               this.infoDestroy = destroy || null;
+           }
+           this.dom.appendChild(wrap);
+           this.view.requestMeasure(this.placeInfoReq);
+       }
+       updateSelectedOption(selected) {
+           let set = null;
+           for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) {
+               if (opt.nodeName != "LI" || !opt.id) {
+                   i--; // A section header
+               }
+               else if (i == selected) {
+                   if (!opt.hasAttribute("aria-selected")) {
+                       opt.setAttribute("aria-selected", "true");
+                       set = opt;
+                   }
+               }
+               else {
+                   if (opt.hasAttribute("aria-selected"))
+                       opt.removeAttribute("aria-selected");
+               }
+           }
+           if (set)
+               scrollIntoView(this.list, set);
+           return set;
+       }
+       measureInfo() {
+           let sel = this.dom.querySelector("[aria-selected]");
+           if (!sel || !this.info)
+               return null;
+           let listRect = this.dom.getBoundingClientRect();
+           let infoRect = this.info.getBoundingClientRect();
+           let selRect = sel.getBoundingClientRect();
+           let space = this.space;
+           if (!space) {
+               let win = this.dom.ownerDocument.defaultView || window;
+               space = { left: 0, top: 0, right: win.innerWidth, bottom: win.innerHeight };
+           }
+           if (selRect.top > Math.min(space.bottom, listRect.bottom) - 10 ||
+               selRect.bottom < Math.max(space.top, listRect.top) + 10)
+               return null;
+           return this.view.state.facet(completionConfig).positionInfo(this.view, listRect, selRect, infoRect, space, this.dom);
+       }
+       placeInfo(pos) {
+           if (this.info) {
+               if (pos) {
+                   if (pos.style)
+                       this.info.style.cssText = pos.style;
+                   this.info.className = "cm-tooltip cm-completionInfo " + (pos.class || "");
+               }
+               else {
+                   this.info.style.cssText = "top: -1e6px";
+               }
+           }
+       }
+       createListBox(options, id, range) {
+           const ul = document.createElement("ul");
+           ul.id = id;
+           ul.setAttribute("role", "listbox");
+           ul.setAttribute("aria-expanded", "true");
+           ul.setAttribute("aria-label", this.view.state.phrase("Completions"));
+           let curSection = null;
+           for (let i = range.from; i < range.to; i++) {
+               let { completion, match } = options[i], { section } = completion;
+               if (section) {
+                   let name = typeof section == "string" ? section : section.name;
+                   if (name != curSection && (i > range.from || range.from == 0)) {
+                       curSection = name;
+                       if (typeof section != "string" && section.header) {
+                           ul.appendChild(section.header(section));
+                       }
+                       else {
+                           let header = ul.appendChild(document.createElement("completion-section"));
+                           header.textContent = name;
+                       }
+                   }
+               }
+               const li = ul.appendChild(document.createElement("li"));
+               li.id = id + "-" + i;
+               li.setAttribute("role", "option");
+               let cls = this.optionClass(completion);
+               if (cls)
+                   li.className = cls;
+               for (let source of this.optionContent) {
+                   let node = source(completion, this.view.state, this.view, match);
+                   if (node)
+                       li.appendChild(node);
+               }
+           }
+           if (range.from)
+               ul.classList.add("cm-completionListIncompleteTop");
+           if (range.to < options.length)
+               ul.classList.add("cm-completionListIncompleteBottom");
+           return ul;
+       }
+       destroyInfo() {
+           if (this.info) {
+               if (this.infoDestroy)
+                   this.infoDestroy();
+               this.info.remove();
+               this.info = null;
+           }
+       }
+       destroy() {
+           this.destroyInfo();
+       }
+   }
+   function completionTooltip(stateField, applyCompletion) {
+       return (view) => new CompletionTooltip(view, stateField, applyCompletion);
+   }
+   function scrollIntoView(container, element) {
+       let parent = container.getBoundingClientRect();
+       let self = element.getBoundingClientRect();
+       let scaleY = parent.height / container.offsetHeight;
+       if (self.top < parent.top)
+           container.scrollTop -= (parent.top - self.top) / scaleY;
+       else if (self.bottom > parent.bottom)
+           container.scrollTop += (self.bottom - parent.bottom) / scaleY;
+   }
+
+   // Used to pick a preferred option when two options with the same
+   // label occur in the result.
+   function score(option) {
+       return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) +
+           (option.type ? 1 : 0);
+   }
+   function sortOptions(active, state) {
+       let options = [];
+       let sections = null;
+       let addOption = (option) => {
+           options.push(option);
+           let { section } = option.completion;
+           if (section) {
+               if (!sections)
+                   sections = [];
+               let name = typeof section == "string" ? section : section.name;
+               if (!sections.some(s => s.name == name))
+                   sections.push(typeof section == "string" ? { name } : section);
+           }
+       };
+       let conf = state.facet(completionConfig);
+       for (let a of active)
+           if (a.hasResult()) {
+               let getMatch = a.result.getMatch;
+               if (a.result.filter === false) {
+                   for (let option of a.result.options) {
+                       addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length));
+                   }
+               }
+               else {
+                   let pattern = state.sliceDoc(a.from, a.to), match;
+                   let matcher = conf.filterStrict ? new StrictMatcher(pattern) : new FuzzyMatcher(pattern);
+                   for (let option of a.result.options)
+                       if (match = matcher.match(option.label)) {
+                           let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : [];
+                           addOption(new Option(option, a.source, matched, match.score + (option.boost || 0)));
+                       }
+               }
+           }
+       if (sections) {
+           let sectionOrder = Object.create(null), pos = 0;
+           let cmp = (a, b) => { var _a, _b; return ((_a = a.rank) !== null && _a !== void 0 ? _a : 1e9) - ((_b = b.rank) !== null && _b !== void 0 ? _b : 1e9) || (a.name < b.name ? -1 : 1); };
+           for (let s of sections.sort(cmp)) {
+               pos -= 1e5;
+               sectionOrder[s.name] = pos;
+           }
+           for (let option of options) {
+               let { section } = option.completion;
+               if (section)
+                   option.score += sectionOrder[typeof section == "string" ? section : section.name];
+           }
+       }
+       let result = [], prev = null;
+       let compare = conf.compareCompletions;
+       for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) {
+           let cur = opt.completion;
+           if (!prev || prev.label != cur.label || prev.detail != cur.detail ||
+               (prev.type != null && cur.type != null && prev.type != cur.type) ||
+               prev.apply != cur.apply || prev.boost != cur.boost)
+               result.push(opt);
+           else if (score(opt.completion) > score(prev))
+               result[result.length - 1] = opt;
+           prev = opt.completion;
+       }
+       return result;
+   }
+   class CompletionDialog {
+       constructor(options, attrs, tooltip, timestamp, selected, disabled) {
+           this.options = options;
+           this.attrs = attrs;
+           this.tooltip = tooltip;
+           this.timestamp = timestamp;
+           this.selected = selected;
+           this.disabled = disabled;
+       }
+       setSelected(selected, id) {
+           return selected == this.selected || selected >= this.options.length ? this
+               : new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
+       }
+       static build(active, state, id, prev, conf, didSetActive) {
+           if (prev && !didSetActive && active.some(s => s.isPending))
+               return prev.setDisabled();
+           let options = sortOptions(active, state);
+           if (!options.length)
+               return prev && active.some(a => a.isPending) ? prev.setDisabled() : null;
+           let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;
+           if (prev && prev.selected != selected && prev.selected != -1) {
+               let selectedValue = prev.options[prev.selected].completion;
+               for (let i = 0; i < options.length; i++)
+                   if (options[i].completion == selectedValue) {
+                       selected = i;
+                       break;
+                   }
+           }
+           return new CompletionDialog(options, makeAttrs(id, selected), {
+               pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
+               create: createTooltip,
+               above: conf.aboveCursor,
+           }, prev ? prev.timestamp : Date.now(), selected, false);
+       }
+       map(changes) {
+           return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected, this.disabled);
+       }
+       setDisabled() {
+           return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true);
+       }
+   }
+   class CompletionState {
+       constructor(active, id, open) {
+           this.active = active;
+           this.id = id;
+           this.open = open;
+       }
+       static start() {
+           return new CompletionState(none, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
+       }
+       update(tr) {
+           let { state } = tr, conf = state.facet(completionConfig);
+           let sources = conf.override ||
+               state.languageDataAt("autocomplete", cur(state)).map(asSource);
+           let active = sources.map(source => {
+               let value = this.active.find(s => s.source == source) ||
+                   new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */);
+               return value.update(tr, conf);
+           });
+           if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
+               active = this.active;
+           let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect));
+           if (open && tr.docChanged)
+               open = open.map(tr.changes);
+           if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
+               !sameResults(active, this.active) || didSet)
+               open = CompletionDialog.build(active, state, this.id, open, conf, didSet);
+           else if (open && open.disabled && !active.some(a => a.isPending))
+               open = null;
+           if (!open && active.every(a => !a.isPending) && active.some(a => a.hasResult()))
+               active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
+           for (let effect of tr.effects)
+               if (effect.is(setSelectedEffect))
+                   open = open && open.setSelected(effect.value, this.id);
+           return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
+       }
+       get tooltip() { return this.open ? this.open.tooltip : null; }
+       get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; }
+   }
+   function sameResults(a, b) {
+       if (a == b)
+           return true;
+       for (let iA = 0, iB = 0;;) {
+           while (iA < a.length && !a[iA].hasResult())
+               iA++;
+           while (iB < b.length && !b[iB].hasResult())
+               iB++;
+           let endA = iA == a.length, endB = iB == b.length;
+           if (endA || endB)
+               return endA == endB;
+           if (a[iA++].result != b[iB++].result)
+               return false;
+       }
+   }
+   const baseAttrs = {
+       "aria-autocomplete": "list"
+   };
+   const noAttrs = {};
+   function makeAttrs(id, selected) {
+       let result = {
+           "aria-autocomplete": "list",
+           "aria-haspopup": "listbox",
+           "aria-controls": id
+       };
+       if (selected > -1)
+           result["aria-activedescendant"] = id + "-" + selected;
+       return result;
+   }
+   const none = [];
+   function getUpdateType(tr, conf) {
+       if (tr.isUserEvent("input.complete")) {
+           let completion = tr.annotation(pickedCompletion);
+           if (completion && conf.activateOnCompletion(completion))
+               return 4 /* UpdateType.Activate */ | 8 /* UpdateType.Reset */;
+       }
+       let typing = tr.isUserEvent("input.type");
+       return typing && conf.activateOnTyping ? 4 /* UpdateType.Activate */ | 1 /* UpdateType.Typing */
+           : typing ? 1 /* UpdateType.Typing */
+               : tr.isUserEvent("delete.backward") ? 2 /* UpdateType.Backspacing */
+                   : tr.selection ? 8 /* UpdateType.Reset */
+                       : tr.docChanged ? 16 /* UpdateType.ResetIfTouching */ : 0 /* UpdateType.None */;
+   }
+   class ActiveSource {
+       constructor(source, state, explicit = false) {
+           this.source = source;
+           this.state = state;
+           this.explicit = explicit;
+       }
+       hasResult() { return false; }
+       get isPending() { return this.state == 1 /* State.Pending */; }
+       update(tr, conf) {
+           let type = getUpdateType(tr, conf), value = this;
+           if ((type & 8 /* UpdateType.Reset */) || (type & 16 /* UpdateType.ResetIfTouching */) && this.touches(tr))
+               value = new ActiveSource(value.source, 0 /* State.Inactive */);
+           if ((type & 4 /* UpdateType.Activate */) && value.state == 0 /* State.Inactive */)
+               value = new ActiveSource(this.source, 1 /* State.Pending */);
+           value = value.updateFor(tr, type);
+           for (let effect of tr.effects) {
+               if (effect.is(startCompletionEffect))
+                   value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value);
+               else if (effect.is(closeCompletionEffect))
+                   value = new ActiveSource(value.source, 0 /* State.Inactive */);
+               else if (effect.is(setActiveEffect))
+                   for (let active of effect.value)
+                       if (active.source == value.source)
+                           value = active;
+           }
+           return value;
+       }
+       updateFor(tr, type) { return this.map(tr.changes); }
+       map(changes) { return this; }
+       touches(tr) {
+           return tr.changes.touchesRange(cur(tr.state));
+       }
+   }
+   class ActiveResult extends ActiveSource {
+       constructor(source, explicit, limit, result, from, to) {
+           super(source, 3 /* State.Result */, explicit);
+           this.limit = limit;
+           this.result = result;
+           this.from = from;
+           this.to = to;
+       }
+       hasResult() { return true; }
+       updateFor(tr, type) {
+           var _a;
+           if (!(type & 3 /* UpdateType.SimpleInteraction */))
+               return this.map(tr.changes);
+           let result = this.result;
+           if (result.map && !tr.changes.empty)
+               result = result.map(result, tr.changes);
+           let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1);
+           let pos = cur(tr.state);
+           if (pos > to || !result ||
+               (type & 2 /* UpdateType.Backspacing */) && (cur(tr.startState) == this.from || pos < this.limit))
+               return new ActiveSource(this.source, type & 4 /* UpdateType.Activate */ ? 1 /* State.Pending */ : 0 /* State.Inactive */);
+           let limit = tr.changes.mapPos(this.limit);
+           if (checkValid(result.validFor, tr.state, from, to))
+               return new ActiveResult(this.source, this.explicit, limit, result, from, to);
+           if (result.update &&
+               (result = result.update(result, from, to, new CompletionContext(tr.state, pos, false))))
+               return new ActiveResult(this.source, this.explicit, limit, result, result.from, (_a = result.to) !== null && _a !== void 0 ? _a : cur(tr.state));
+           return new ActiveSource(this.source, 1 /* State.Pending */, this.explicit);
+       }
+       map(mapping) {
+           if (mapping.empty)
+               return this;
+           let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
+           if (!result)
+               return new ActiveSource(this.source, 0 /* State.Inactive */);
+           return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
+       }
+       touches(tr) {
+           return tr.changes.touchesRange(this.from, this.to);
+       }
+   }
+   function checkValid(validFor, state, from, to) {
+       if (!validFor)
+           return false;
+       let text = state.sliceDoc(from, to);
+       return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text);
+   }
+   const setActiveEffect = /*@__PURE__*/StateEffect.define({
+       map(sources, mapping) { return sources.map(s => s.map(mapping)); }
+   });
+   const setSelectedEffect = /*@__PURE__*/StateEffect.define();
+   const completionState = /*@__PURE__*/StateField.define({
+       create() { return CompletionState.start(); },
+       update(value, tr) { return value.update(tr); },
+       provide: f => [
+           showTooltip.from(f, val => val.tooltip),
+           EditorView.contentAttributes.from(f, state => state.attrs)
+       ]
+   });
+   function applyCompletion(view, option) {
+       const apply = option.completion.apply || option.completion.label;
+       let result = view.state.field(completionState).active.find(a => a.source == option.source);
+       if (!(result instanceof ActiveResult))
+           return false;
+       if (typeof apply == "string")
+           view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to)), { annotations: pickedCompletion.of(option.completion) }));
+       else
+           apply(view, option.completion, result.from, result.to);
+       return true;
+   }
+   const createTooltip = /*@__PURE__*/completionTooltip(completionState, applyCompletion);
+
+   /**
+   Returns a command that moves the completion selection forward or
+   backward by the given amount.
+   */
+   function moveCompletionSelection(forward, by = "option") {
+       return (view) => {
+           let cState = view.state.field(completionState, false);
+           if (!cState || !cState.open || cState.open.disabled ||
+               Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
+               return false;
+           let step = 1, tooltip;
+           if (by == "page" && (tooltip = getTooltip(view, cState.open.tooltip)))
+               step = Math.max(2, Math.floor(tooltip.dom.offsetHeight /
+                   tooltip.dom.querySelector("li").offsetHeight) - 1);
+           let { length } = cState.open.options;
+           let selected = cState.open.selected > -1 ? cState.open.selected + step * (forward ? 1 : -1) : forward ? 0 : length - 1;
+           if (selected < 0)
+               selected = by == "page" ? 0 : length - 1;
+           else if (selected >= length)
+               selected = by == "page" ? length - 1 : 0;
+           view.dispatch({ effects: setSelectedEffect.of(selected) });
+           return true;
+       };
+   }
+   /**
+   Accept the current completion.
+   */
+   const acceptCompletion = (view) => {
+       let cState = view.state.field(completionState, false);
+       if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || cState.open.disabled ||
+           Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
+           return false;
+       return applyCompletion(view, cState.open.options[cState.open.selected]);
+   };
+   /**
+   Explicitly start autocompletion.
+   */
+   const startCompletion = (view) => {
+       let cState = view.state.field(completionState, false);
+       if (!cState)
+           return false;
+       view.dispatch({ effects: startCompletionEffect.of(true) });
+       return true;
+   };
+   /**
+   Close the currently active completion.
+   */
+   const closeCompletion = (view) => {
+       let cState = view.state.field(completionState, false);
+       if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */))
+           return false;
+       view.dispatch({ effects: closeCompletionEffect.of(null) });
+       return true;
+   };
+   class RunningQuery {
+       constructor(active, context) {
+           this.active = active;
+           this.context = context;
+           this.time = Date.now();
+           this.updates = [];
+           // Note that 'undefined' means 'not done yet', whereas 'null' means
+           // 'query returned null'.
+           this.done = undefined;
+       }
+   }
+   const MaxUpdateCount = 50, MinAbortTime = 1000;
+   const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+       constructor(view) {
+           this.view = view;
+           this.debounceUpdate = -1;
+           this.running = [];
+           this.debounceAccept = -1;
+           this.pendingStart = false;
+           this.composing = 0 /* CompositionState.None */;
+           for (let active of view.state.field(completionState).active)
+               if (active.isPending)
+                   this.startQuery(active);
+       }
+       update(update) {
+           let cState = update.state.field(completionState);
+           let conf = update.state.facet(completionConfig);
+           if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState)
+               return;
+           let doesReset = update.transactions.some(tr => {
+               let type = getUpdateType(tr, conf);
+               return (type & 8 /* UpdateType.Reset */) || (tr.selection || tr.docChanged) && !(type & 3 /* UpdateType.SimpleInteraction */);
+           });
+           for (let i = 0; i < this.running.length; i++) {
+               let query = this.running[i];
+               if (doesReset ||
+                   query.context.abortOnDocChange && update.docChanged ||
+                   query.updates.length + update.transactions.length > MaxUpdateCount && Date.now() - query.time > MinAbortTime) {
+                   for (let handler of query.context.abortListeners) {
+                       try {
+                           handler();
+                       }
+                       catch (e) {
+                           logException(this.view.state, e);
+                       }
+                   }
+                   query.context.abortListeners = null;
+                   this.running.splice(i--, 1);
+               }
+               else {
+                   query.updates.push(...update.transactions);
+               }
+           }
+           if (this.debounceUpdate > -1)
+               clearTimeout(this.debounceUpdate);
+           if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect))))
+               this.pendingStart = true;
+           let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay;
+           this.debounceUpdate = cState.active.some(a => a.isPending && !this.running.some(q => q.active.source == a.source))
+               ? setTimeout(() => this.startUpdate(), delay) : -1;
+           if (this.composing != 0 /* CompositionState.None */)
+               for (let tr of update.transactions) {
+                   if (tr.isUserEvent("input.type"))
+                       this.composing = 2 /* CompositionState.Changed */;
+                   else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
+                       this.composing = 3 /* CompositionState.ChangedAndMoved */;
+               }
+       }
+       startUpdate() {
+           this.debounceUpdate = -1;
+           this.pendingStart = false;
+           let { state } = this.view, cState = state.field(completionState);
+           for (let active of cState.active) {
+               if (active.isPending && !this.running.some(r => r.active.source == active.source))
+                   this.startQuery(active);
+           }
+           if (this.running.length && cState.open && cState.open.disabled)
+               this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
+       }
+       startQuery(active) {
+           let { state } = this.view, pos = cur(state);
+           let context = new CompletionContext(state, pos, active.explicit, this.view);
+           let pending = new RunningQuery(active, context);
+           this.running.push(pending);
+           Promise.resolve(active.source(context)).then(result => {
+               if (!pending.context.aborted) {
+                   pending.done = result || null;
+                   this.scheduleAccept();
+               }
+           }, err => {
+               this.view.dispatch({ effects: closeCompletionEffect.of(null) });
+               logException(this.view.state, err);
+           });
+       }
+       scheduleAccept() {
+           if (this.running.every(q => q.done !== undefined))
+               this.accept();
+           else if (this.debounceAccept < 0)
+               this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
+       }
+       // For each finished query in this.running, try to create a result
+       // or, if appropriate, restart the query.
+       accept() {
+           var _a;
+           if (this.debounceAccept > -1)
+               clearTimeout(this.debounceAccept);
+           this.debounceAccept = -1;
+           let updated = [];
+           let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState);
+           for (let i = 0; i < this.running.length; i++) {
+               let query = this.running[i];
+               if (query.done === undefined)
+                   continue;
+               this.running.splice(i--, 1);
+               if (query.done) {
+                   let pos = cur(query.updates.length ? query.updates[0].startState : this.view.state);
+                   let limit = Math.min(pos, query.done.from + (query.active.explicit ? 0 : 1));
+                   let active = new ActiveResult(query.active.source, query.active.explicit, limit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : pos);
+                   // Replay the transactions that happened since the start of
+                   // the request and see if that preserves the result
+                   for (let tr of query.updates)
+                       active = active.update(tr, conf);
+                   if (active.hasResult()) {
+                       updated.push(active);
+                       continue;
+                   }
+               }
+               let current = cState.active.find(a => a.source == query.active.source);
+               if (current && current.isPending) {
+                   if (query.done == null) {
+                       // Explicitly failed. Should clear the pending status if it
+                       // hasn't been re-set in the meantime.
+                       let active = new ActiveSource(query.active.source, 0 /* State.Inactive */);
+                       for (let tr of query.updates)
+                           active = active.update(tr, conf);
+                       if (!active.isPending)
+                           updated.push(active);
+                   }
+                   else {
+                       // Cleared by subsequent transactions. Restart.
+                       this.startQuery(current);
+                   }
+               }
+           }
+           if (updated.length || cState.open && cState.open.disabled)
+               this.view.dispatch({ effects: setActiveEffect.of(updated) });
+       }
+   }, {
+       eventHandlers: {
+           blur(event) {
+               let state = this.view.state.field(completionState, false);
+               if (state && state.tooltip && this.view.state.facet(completionConfig).closeOnBlur) {
+                   let dialog = state.open && getTooltip(this.view, state.open.tooltip);
+                   if (!dialog || !dialog.dom.contains(event.relatedTarget))
+                       setTimeout(() => this.view.dispatch({ effects: closeCompletionEffect.of(null) }), 10);
+               }
+           },
+           compositionstart() {
+               this.composing = 1 /* CompositionState.Started */;
+           },
+           compositionend() {
+               if (this.composing == 3 /* CompositionState.ChangedAndMoved */) {
+                   // Safari fires compositionend events synchronously, possibly
+                   // from inside an update, so dispatch asynchronously to avoid reentrancy
+                   setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20);
+               }
+               this.composing = 0 /* CompositionState.None */;
+           }
+       }
+   });
+   const windows = typeof navigator == "object" && /*@__PURE__*//Win/.test(navigator.platform);
+   const commitCharacters = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.domEventHandlers({
+       keydown(event, view) {
+           let field = view.state.field(completionState, false);
+           if (!field || !field.open || field.open.disabled || field.open.selected < 0 ||
+               event.key.length > 1 || event.ctrlKey && !(windows && event.altKey) || event.metaKey)
+               return false;
+           let option = field.open.options[field.open.selected];
+           let result = field.active.find(a => a.source == option.source);
+           let commitChars = option.completion.commitCharacters || result.result.commitCharacters;
+           if (commitChars && commitChars.indexOf(event.key) > -1)
+               applyCompletion(view, option);
+           return false;
+       }
+   }));
+
+   const baseTheme = /*@__PURE__*/EditorView.baseTheme({
+       ".cm-tooltip.cm-tooltip-autocomplete": {
+           "& > ul": {
+               fontFamily: "monospace",
+               whiteSpace: "nowrap",
+               overflow: "hidden auto",
+               maxWidth_fallback: "700px",
+               maxWidth: "min(700px, 95vw)",
+               minWidth: "250px",
+               maxHeight: "10em",
+               height: "100%",
+               listStyle: "none",
+               margin: 0,
+               padding: 0,
+               "& > li, & > completion-section": {
+                   padding: "1px 3px",
+                   lineHeight: 1.2
+               },
+               "& > li": {
+                   overflowX: "hidden",
+                   textOverflow: "ellipsis",
+                   cursor: "pointer"
+               },
+               "& > completion-section": {
+                   display: "list-item",
+                   borderBottom: "1px solid silver",
+                   paddingLeft: "0.5em",
+                   opacity: 0.7
+               }
+           }
+       },
+       "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
+           background: "#17c",
+           color: "white",
+       },
+       "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
+           background: "#777",
+       },
+       "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
+           background: "#347",
+           color: "white",
+       },
+       "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
+           background: "#444",
+       },
+       ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
+           content: '"···"',
+           opacity: 0.5,
+           display: "block",
+           textAlign: "center"
+       },
+       ".cm-tooltip.cm-completionInfo": {
+           position: "absolute",
+           padding: "3px 9px",
+           width: "max-content",
+           maxWidth: `${400 /* Info.Width */}px`,
+           boxSizing: "border-box",
+           whiteSpace: "pre-line"
+       },
+       ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
+       ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
+       ".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` },
+       ".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` },
+       "&light .cm-snippetField": { backgroundColor: "#00000022" },
+       "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
+       ".cm-snippetFieldPosition": {
+           verticalAlign: "text-top",
+           width: 0,
+           height: "1.15em",
+           display: "inline-block",
+           margin: "0 -0.7px -.7em",
+           borderLeft: "1.4px dotted #888"
+       },
+       ".cm-completionMatchedText": {
+           textDecoration: "underline"
+       },
+       ".cm-completionDetail": {
+           marginLeft: "0.5em",
+           fontStyle: "italic"
+       },
+       ".cm-completionIcon": {
+           fontSize: "90%",
+           width: ".8em",
+           display: "inline-block",
+           textAlign: "center",
+           paddingRight: ".6em",
+           opacity: "0.6",
+           boxSizing: "content-box"
+       },
+       ".cm-completionIcon-function, .cm-completionIcon-method": {
+           "&:after": { content: "'ƒ'" }
+       },
+       ".cm-completionIcon-class": {
+           "&:after": { content: "'○'" }
+       },
+       ".cm-completionIcon-interface": {
+           "&:after": { content: "'◌'" }
+       },
+       ".cm-completionIcon-variable": {
+           "&:after": { content: "'𝑥'" }
+       },
+       ".cm-completionIcon-constant": {
+           "&:after": { content: "'𝐶'" }
+       },
+       ".cm-completionIcon-type": {
+           "&:after": { content: "'𝑡'" }
+       },
+       ".cm-completionIcon-enum": {
+           "&:after": { content: "'∪'" }
+       },
+       ".cm-completionIcon-property": {
+           "&:after": { content: "'□'" }
+       },
+       ".cm-completionIcon-keyword": {
+           "&:after": { content: "'🔑\uFE0E'" } // Disable emoji rendering
+       },
+       ".cm-completionIcon-namespace": {
+           "&:after": { content: "'▢'" }
+       },
+       ".cm-completionIcon-text": {
+           "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
+       }
+   });
+
+   class FieldPos {
+       constructor(field, line, from, to) {
+           this.field = field;
+           this.line = line;
+           this.from = from;
+           this.to = to;
+       }
+   }
+   class FieldRange {
+       constructor(field, from, to) {
+           this.field = field;
+           this.from = from;
+           this.to = to;
+       }
+       map(changes) {
+           let from = changes.mapPos(this.from, -1, MapMode.TrackDel);
+           let to = changes.mapPos(this.to, 1, MapMode.TrackDel);
+           return from == null || to == null ? null : new FieldRange(this.field, from, to);
+       }
+   }
+   class Snippet {
+       constructor(lines, fieldPositions) {
+           this.lines = lines;
+           this.fieldPositions = fieldPositions;
+       }
+       instantiate(state, pos) {
+           let text = [], lineStart = [pos];
+           let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0];
+           for (let line of this.lines) {
+               if (text.length) {
+                   let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length;
+                   for (let i = 0; i < tabs; i++)
+                       indent += state.facet(indentUnit);
+                   lineStart.push(pos + indent.length - tabs);
+                   line = indent + line.slice(tabs);
+               }
+               text.push(line);
+               pos += line.length + 1;
+           }
+           let ranges = this.fieldPositions.map(pos => new FieldRange(pos.field, lineStart[pos.line] + pos.from, lineStart[pos.line] + pos.to));
+           return { text, ranges };
+       }
+       static parse(template) {
+           let fields = [];
+           let lines = [], positions = [], m;
+           for (let line of template.split(/\r\n?|\n/)) {
+               while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
+                   let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
+                   let name = rawName.replace(/\\[{}]/g, m => m[1]);
+                   for (let i = 0; i < fields.length; i++) {
+                       if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
+                           found = i;
+                   }
+                   if (found < 0) {
+                       let i = 0;
+                       while (i < fields.length && (seq == null || (fields[i].seq != null && fields[i].seq < seq)))
+                           i++;
+                       fields.splice(i, 0, { seq, name });
+                       found = i;
+                       for (let pos of positions)
+                           if (pos.field >= found)
+                               pos.field++;
+                   }
+                   positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
+                   line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
+               }
+               line = line.replace(/\\([{}])/g, (_, brace, index) => {
+                   for (let pos of positions)
+                       if (pos.line == lines.length && pos.from > index) {
+                           pos.from--;
+                           pos.to--;
+                       }
+                   return brace;
+               });
+               lines.push(line);
+           }
+           return new Snippet(lines, positions);
+       }
+   }
+   let fieldMarker = /*@__PURE__*/Decoration.widget({ widget: /*@__PURE__*/new class extends WidgetType {
+           toDOM() {
+               let span = document.createElement("span");
+               span.className = "cm-snippetFieldPosition";
+               return span;
+           }
+           ignoreEvent() { return false; }
+       } });
+   let fieldRange = /*@__PURE__*/Decoration.mark({ class: "cm-snippetField" });
+   class ActiveSnippet {
+       constructor(ranges, active) {
+           this.ranges = ranges;
+           this.active = active;
+           this.deco = Decoration.set(ranges.map(r => (r.from == r.to ? fieldMarker : fieldRange).range(r.from, r.to)));
+       }
+       map(changes) {
+           let ranges = [];
+           for (let r of this.ranges) {
+               let mapped = r.map(changes);
+               if (!mapped)
+                   return null;
+               ranges.push(mapped);
+           }
+           return new ActiveSnippet(ranges, this.active);
+       }
+       selectionInsideField(sel) {
+           return sel.ranges.every(range => this.ranges.some(r => r.field == this.active && r.from <= range.from && r.to >= range.to));
+       }
+   }
+   const setActive = /*@__PURE__*/StateEffect.define({
+       map(value, changes) { return value && value.map(changes); }
+   });
+   const moveToField = /*@__PURE__*/StateEffect.define();
+   const snippetState = /*@__PURE__*/StateField.define({
+       create() { return null; },
+       update(value, tr) {
+           for (let effect of tr.effects) {
+               if (effect.is(setActive))
+                   return effect.value;
+               if (effect.is(moveToField) && value)
+                   return new ActiveSnippet(value.ranges, effect.value);
+           }
+           if (value && tr.docChanged)
+               value = value.map(tr.changes);
+           if (value && tr.selection && !value.selectionInsideField(tr.selection))
+               value = null;
+           return value;
+       },
+       provide: f => EditorView.decorations.from(f, val => val ? val.deco : Decoration.none)
+   });
+   function fieldSelection(ranges, field) {
+       return EditorSelection.create(ranges.filter(r => r.field == field).map(r => EditorSelection.range(r.from, r.to)));
+   }
+   /**
+   Convert a snippet template to a function that can
+   [apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
+   using syntax like this:
+
+       "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
+
+   Each `${}` placeholder (you may also use `#{}`) indicates a field
+   that the user can fill in. Its name, if any, will be the default
+   content for the field.
+
+   When the snippet is activated by calling the returned function,
+   the code is inserted at the given position. Newlines in the
+   template are indented by the indentation of the start line, plus
+   one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
+   the newline.
+
+   On activation, (all instances of) the first field are selected.
+   The user can move between fields with Tab and Shift-Tab as long as
+   the fields are active. Moving to the last field or moving the
+   cursor out of the current field deactivates the fields.
+
+   The order of fields defaults to textual order, but you can add
+   numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
+   a custom order.
+
+   To include a literal `{` or `}` in your template, put a backslash
+   in front of it. This will be removed and the brace will not be
+   interpreted as indicating a placeholder.
+   */
+   function snippet(template) {
+       let snippet = Snippet.parse(template);
+       return (editor, completion, from, to) => {
+           let { text, ranges } = snippet.instantiate(editor.state, from);
+           let { main } = editor.state.selection;
+           let spec = {
+               changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) },
+               scrollIntoView: true,
+               annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
+           };
+           if (ranges.length)
+               spec.selection = fieldSelection(ranges, 0);
+           if (ranges.some(r => r.field > 0)) {
+               let active = new ActiveSnippet(ranges, 0);
+               let effects = spec.effects = [setActive.of(active)];
+               if (editor.state.field(snippetState, false) === undefined)
+                   effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
+           }
+           editor.dispatch(editor.state.update(spec));
+       };
+   }
+   function moveField(dir) {
+       return ({ state, dispatch }) => {
+           let active = state.field(snippetState, false);
+           if (!active || dir < 0 && active.active == 0)
+               return false;
+           let next = active.active + dir, last = dir > 0 && !active.ranges.some(r => r.field == next + dir);
+           dispatch(state.update({
+               selection: fieldSelection(active.ranges, next),
+               effects: setActive.of(last ? null : new ActiveSnippet(active.ranges, next)),
+               scrollIntoView: true
+           }));
+           return true;
+       };
+   }
+   /**
+   A command that clears the active snippet, if any.
+   */
+   const clearSnippet = ({ state, dispatch }) => {
+       let active = state.field(snippetState, false);
+       if (!active)
+           return false;
+       dispatch(state.update({ effects: setActive.of(null) }));
+       return true;
+   };
+   /**
+   Move to the next snippet field, if available.
+   */
+   const nextSnippetField = /*@__PURE__*/moveField(1);
+   /**
+   Move to the previous snippet field, if available.
+   */
+   const prevSnippetField = /*@__PURE__*/moveField(-1);
+   const defaultSnippetKeymap = [
+       { key: "Tab", run: nextSnippetField, shift: prevSnippetField },
+       { key: "Escape", run: clearSnippet }
+   ];
+   /**
+   A facet that can be used to configure the key bindings used by
+   snippets. The default binds Tab to
+   [`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
+   [`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
+   to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
+   */
+   const snippetKeymap = /*@__PURE__*/Facet.define({
+       combine(maps) { return maps.length ? maps[0] : defaultSnippetKeymap; }
+   });
+   const addSnippetKeymap = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.compute([snippetKeymap], state => state.facet(snippetKeymap)));
+   /**
+   Create a completion from a snippet. Returns an object with the
+   properties from `completion`, plus an `apply` function that
+   applies the snippet.
+   */
+   function snippetCompletion(template, completion) {
+       return Object.assign(Object.assign({}, completion), { apply: snippet(template) });
+   }
+   const snippetPointerHandler = /*@__PURE__*/EditorView.domEventHandlers({
+       mousedown(event, view) {
+           let active = view.state.field(snippetState, false), pos;
+           if (!active || (pos = view.posAtCoords({ x: event.clientX, y: event.clientY })) == null)
+               return false;
+           let match = active.ranges.find(r => r.from <= pos && r.to >= pos);
+           if (!match || match.field == active.active)
+               return false;
+           view.dispatch({
+               selection: fieldSelection(active.ranges, match.field),
+               effects: setActive.of(active.ranges.some(r => r.field > match.field)
+                   ? new ActiveSnippet(active.ranges, match.field) : null),
+               scrollIntoView: true
+           });
+           return true;
+       }
+   });
+   const closedBracket = /*@__PURE__*/new class extends RangeValue {
+   };
+   closedBracket.startSide = 1;
+   closedBracket.endSide = -1;
+
+   /**
+   Returns an extension that enables autocompletion.
+   */
+   function autocompletion(config = {}) {
+       return [
+           commitCharacters,
+           completionState,
+           completionConfig.of(config),
+           completionPlugin,
+           completionKeymapExt,
+           baseTheme
+       ];
+   }
+   /**
+   Basic keybindings for autocompletion.
+
+    - Ctrl-Space (and Alt-\` on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
+    - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
+    - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
+    - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
+    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
+    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
+    - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
+   */
+   const completionKeymap = [
+       { key: "Ctrl-Space", run: startCompletion },
+       { mac: "Alt-`", run: startCompletion },
+       { key: "Escape", run: closeCompletion },
+       { key: "ArrowDown", run: /*@__PURE__*/moveCompletionSelection(true) },
+       { key: "ArrowUp", run: /*@__PURE__*/moveCompletionSelection(false) },
+       { key: "PageDown", run: /*@__PURE__*/moveCompletionSelection(true, "page") },
+       { key: "PageUp", run: /*@__PURE__*/moveCompletionSelection(false, "page") },
+       { key: "Enter", run: acceptCompletion }
+   ];
+   const completionKeymapExt = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
+
+   /**
+   A collection of JavaScript-related
+   [snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
+   */
+   const snippets = [
+       /*@__PURE__*/snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
+           label: "function",
+           detail: "definition",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
+           label: "for",
+           detail: "loop",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
+           label: "for",
+           detail: "of loop",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("do {\n\t${}\n} while (${})", {
+           label: "do",
+           detail: "loop",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("while (${}) {\n\t${}\n}", {
+           label: "while",
+           detail: "loop",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
+           label: "try",
+           detail: "/ catch block",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n}", {
+           label: "if",
+           detail: "block",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", {
+           label: "if",
+           detail: "/ else block",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
+           label: "class",
+           detail: "definition",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("import {${names}} from \"${module}\"\n${}", {
+           label: "import",
+           detail: "named",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("import ${name} from \"${module}\"\n${}", {
+           label: "import",
+           detail: "default",
+           type: "keyword"
+       })
+   ];
+   /**
+   A collection of snippet completions for TypeScript. Includes the
+   JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
+   */
+   const typescriptSnippets = /*@__PURE__*/snippets.concat([
+       /*@__PURE__*/snippetCompletion("interface ${name} {\n\t${}\n}", {
+           label: "interface",
+           detail: "definition",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("type ${name} = ${type}", {
+           label: "type",
+           detail: "definition",
+           type: "keyword"
+       }),
+       /*@__PURE__*/snippetCompletion("enum ${name} {\n\t${}\n}", {
+           label: "enum",
+           detail: "definition",
+           type: "keyword"
+       })
+   ]);
+
+   const cache = /*@__PURE__*/new NodeWeakMap();
+   const ScopeNodes = /*@__PURE__*/new Set([
+       "Script", "Block",
+       "FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration",
+       "ForStatement"
+   ]);
+   function defID(type) {
+       return (node, def) => {
+           let id = node.node.getChild("VariableDefinition");
+           if (id)
+               def(id, type);
+           return true;
+       };
+   }
+   const functionContext = ["FunctionDeclaration"];
+   const gatherCompletions = {
+       FunctionDeclaration: /*@__PURE__*/defID("function"),
+       ClassDeclaration: /*@__PURE__*/defID("class"),
+       ClassExpression: () => true,
+       EnumDeclaration: /*@__PURE__*/defID("constant"),
+       TypeAliasDeclaration: /*@__PURE__*/defID("type"),
+       NamespaceDeclaration: /*@__PURE__*/defID("namespace"),
+       VariableDefinition(node, def) { if (!node.matchContext(functionContext))
+           def(node, "variable"); },
+       TypeDefinition(node, def) { def(node, "type"); },
+       __proto__: null
+   };
+   function getScope(doc, node) {
+       let cached = cache.get(node);
+       if (cached)
+           return cached;
+       let completions = [], top = true;
+       function def(node, type) {
+           let name = doc.sliceString(node.from, node.to);
+           completions.push({ label: name, type });
+       }
+       node.cursor(IterMode.IncludeAnonymous).iterate(node => {
+           if (top) {
+               top = false;
+           }
+           else if (node.name) {
+               let gather = gatherCompletions[node.name];
+               if (gather && gather(node, def) || ScopeNodes.has(node.name))
+                   return false;
+           }
+           else if (node.to - node.from > 8192) {
+               // Allow caching for bigger internal nodes
+               for (let c of getScope(doc, node.node))
+                   completions.push(c);
+               return false;
+           }
+       });
+       cache.set(node, completions);
+       return completions;
+   }
+   const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
+   const dontComplete = [
+       "TemplateString", "String", "RegExp",
+       "LineComment", "BlockComment",
+       "VariableDefinition", "TypeDefinition", "Label",
+       "PropertyDefinition", "PropertyName",
+       "PrivatePropertyDefinition", "PrivatePropertyName",
+       ".", "?."
+   ];
+   /**
+   Completion source that looks up locally defined names in
+   JavaScript code.
+   */
+   function localCompletionSource(context) {
+       let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
+       if (dontComplete.indexOf(inner.name) > -1)
+           return null;
+       let isWord = inner.name == "VariableName" ||
+           inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
+       if (!isWord && !context.explicit)
+           return null;
+       let options = [];
+       for (let pos = inner; pos; pos = pos.parent) {
+           if (ScopeNodes.has(pos.name))
+               options = options.concat(getScope(context.state.doc, pos));
+       }
+       return {
+           options,
+           from: isWord ? inner.from : context.pos,
+           validFor: Identifier
+       };
+   }
+
+   /**
+   A language provider based on the [Lezer JavaScript
+   parser](https://github.com/lezer-parser/javascript), extended with
+   highlighting and indentation information.
+   */
+   const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
+       name: "javascript",
+       parser: /*@__PURE__*/parser.configure({
+           props: [
+               /*@__PURE__*/indentNodeProp.add({
+                   IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
+                   TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
+                   LabeledStatement: flatIndent,
+                   SwitchBody: context => {
+                       let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
+                       return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
+                   },
+                   Block: /*@__PURE__*/delimitedIndent({ closing: "}" }),
+                   ArrowFunction: cx => cx.baseIndent + cx.unit,
+                   "TemplateString BlockComment": () => null,
+                   "Statement Property": /*@__PURE__*/continuedIndent({ except: /^{/ }),
+                   JSXElement(context) {
+                       let closed = /^\s*<\//.test(context.textAfter);
+                       return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
+                   },
+                   JSXEscape(context) {
+                       let closed = /\s*\}/.test(context.textAfter);
+                       return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
+                   },
+                   "JSXOpenTag JSXSelfClosingTag"(context) {
+                       return context.column(context.node.from) + context.unit;
+                   }
+               }),
+               /*@__PURE__*/foldNodeProp.add({
+                   "Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": foldInside,
+                   BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
+               })
+           ]
+       }),
+       languageData: {
+           closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
+           commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
+           indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
+           wordChars: "$"
+       }
+   });
+   const jsxSublanguage = {
+       test: node => /^JSX/.test(node.name),
+       facet: /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } })
+   };
+   /**
+   A language provider for TypeScript.
+   */
+   const typescriptLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "ts" }, "typescript");
+   /**
+   Language provider for JSX.
+   */
+   const jsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
+       dialect: "jsx",
+       props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
+   });
+   /**
+   Language provider for JSX + TypeScript.
+   */
+   const tsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
+       dialect: "jsx ts",
+       props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
+   }, "typescript");
+   let kwCompletion = (name) => ({ label: name, type: "keyword" });
+   const keywords = /*@__PURE__*/"break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);
+   const typescriptKeywords = /*@__PURE__*/keywords.concat(/*@__PURE__*/["declare", "implements", "private", "protected", "public"].map(kwCompletion));
+   /**
+   JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
+   and local variable completion.
+   */
+   function javascript(config = {}) {
+       let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage)
+           : config.typescript ? typescriptLanguage : javascriptLanguage;
+       let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords);
+       return new LanguageSupport(lang, [
+           javascriptLanguage.data.of({
+               autocomplete: ifNotIn(dontComplete, completeFromList(completions))
+           }),
+           javascriptLanguage.data.of({
+               autocomplete: localCompletionSource
+           }),
+           config.jsx ? autoCloseTags : [],
+       ]);
+   }
+   function findOpenTag(node) {
+       for (;;) {
+           if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag")
+               return node;
+           if (node.name == "JSXEscape" || !node.parent)
+               return null;
+           node = node.parent;
+       }
+   }
+   function elementName(doc, tree, max = doc.length) {
+       for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
+           if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
+               ch.name == "JSXMemberExpression")
+               return doc.sliceString(ch.from, Math.min(ch.to, max));
+       }
+       return "";
+   }
+   const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
+   /**
+   Extension that will automatically insert JSX close tags when a `>` or
+   `/` is typed.
+   */
+   const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
+       if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
+           from != to || (text != ">" && text != "/") ||
+           !javascriptLanguage.isActiveAt(view.state, from, -1))
+           return false;
+       let base = defaultInsert(), { state } = base;
+       let closeTags = state.changeByRange(range => {
+           var _a;
+           let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name;
+           if (around.name == "JSXStartTag")
+               around = around.parent;
+           if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
+           else if (text == ">" && around.name == "JSXFragmentTag") {
+               return { range, changes: { from: head, insert: `</>` } };
+           }
+           else if (text == "/" && around.name == "JSXStartCloseTag") {
+               let empty = around.parent, base = empty.parent;
+               if (base && empty.from == head - 2 &&
+                   ((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
+                   let insert = `${name}>`;
+                   return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
+               }
+           }
+           else if (text == ">") {
+               let openTag = findOpenTag(around);
+               if (openTag && openTag.name == "JSXOpenTag" &&
+                   !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
+                   (name = elementName(state.doc, openTag, head)))
+                   return { range, changes: { from: head, insert: `</${name}>` } };
+           }
+           return { range };
+       });
+       if (closeTags.changes.empty)
+           return false;
+       view.dispatch([
+           base,
+           state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
+       ]);
+       return true;
+   });
+
+   // Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
+   const chalky = "#e5c07b", coral = "#e06c75", cyan = "#56b6c2", invalid = "#ffffff", ivory = "#abb2bf", stone = "#7d8799", // Brightened compared to original to increase contrast
+   malibu = "#61afef", sage = "#98c379", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#2c313a", background = "#282c34", tooltipBackground = "#353a42", selection = "#3E4451", cursor = "#528bff";
+   /**
+   The editor theme styles for One Dark.
+   */
+   const oneDarkTheme = /*@__PURE__*/EditorView.theme({
+       "&": {
+           color: ivory,
+           backgroundColor: background
+       },
+       ".cm-content": {
+           caretColor: cursor
+       },
+       ".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
+       "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
+       ".cm-panels": { backgroundColor: darkBackground, color: ivory },
+       ".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: background,
+           color: stone,
+           border: "none"
+       },
+       ".cm-activeLineGutter": {
+           backgroundColor: highlightBackground
+       },
+       ".cm-foldPlaceholder": {
+           backgroundColor: "transparent",
+           border: "none",
+           color: "#ddd"
+       },
+       ".cm-tooltip": {
+           border: "none",
+           backgroundColor: tooltipBackground
+       },
+       ".cm-tooltip .cm-tooltip-arrow:before": {
+           borderTopColor: "transparent",
+           borderBottomColor: "transparent"
+       },
+       ".cm-tooltip .cm-tooltip-arrow:after": {
+           borderTopColor: tooltipBackground,
+           borderBottomColor: tooltipBackground
+       },
+       ".cm-tooltip-autocomplete": {
+           "& > ul > li[aria-selected]": {
+               backgroundColor: highlightBackground,
+               color: ivory
+           }
+       }
+   }, { dark: true });
+   /**
+   The highlighting style for code in the One Dark theme.
+   */
+   const oneDarkHighlightStyle = /*@__PURE__*/HighlightStyle.define([
+       { tag: tags.keyword,
+           color: violet },
+       { tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
+           color: coral },
+       { tag: [/*@__PURE__*/tags.function(tags.variableName), tags.labelName],
+           color: malibu },
+       { tag: [tags.color, /*@__PURE__*/tags.constant(tags.name), /*@__PURE__*/tags.standard(tags.name)],
+           color: whiskey },
+       { tag: [/*@__PURE__*/tags.definition(tags.name), tags.separator],
+           color: ivory },
+       { tag: [tags.typeName, tags.className, tags.number, tags.changed, tags.annotation, tags.modifier, tags.self, tags.namespace],
+           color: chalky },
+       { tag: [tags.operator, tags.operatorKeyword, tags.url, tags.escape, tags.regexp, tags.link, /*@__PURE__*/tags.special(tags.string)],
+           color: cyan },
+       { tag: [tags.meta, tags.comment],
+           color: stone },
+       { tag: tags.strong,
+           fontWeight: "bold" },
+       { tag: tags.emphasis,
+           fontStyle: "italic" },
+       { tag: tags.strikethrough,
+           textDecoration: "line-through" },
+       { tag: tags.link,
+           color: stone,
+           textDecoration: "underline" },
+       { tag: tags.heading,
+           fontWeight: "bold",
+           color: coral },
+       { tag: [tags.atom, tags.bool, /*@__PURE__*/tags.special(tags.variableName)],
+           color: whiskey },
+       { tag: [tags.processingInstruction, tags.string, tags.inserted],
+           color: sage },
+       { tag: tags.invalid,
+           color: invalid },
+   ]);
+   /**
+   Extension to enable the One Dark theme (both the editor theme and
+   the highlight style).
+   */
+   const oneDark = [oneDarkTheme, /*@__PURE__*/syntaxHighlighting(oneDarkHighlightStyle)];
+
+   class SelectedDiagnostic {
+       constructor(from, to, diagnostic) {
+           this.from = from;
+           this.to = to;
+           this.diagnostic = diagnostic;
+       }
+   }
+   class LintState {
+       constructor(diagnostics, panel, selected) {
+           this.diagnostics = diagnostics;
+           this.panel = panel;
+           this.selected = selected;
+       }
+       static init(diagnostics, panel, state) {
+           // Filter the list of diagnostics for which to create markers
+           let markedDiagnostics = diagnostics;
+           let diagnosticFilter = state.facet(lintConfig).markerFilter;
+           if (diagnosticFilter)
+               markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
+           let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
+           let deco = new RangeSetBuilder(), active = [], pos = 0;
+           for (let i = 0;;) {
+               let next = i == sorted.length ? null : sorted[i];
+               if (!next && !active.length)
+                   break;
+               let from, to;
+               if (active.length) {
+                   from = pos;
+                   to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8);
+               }
+               else {
+                   from = next.from;
+                   to = next.to;
+                   active.push(next);
+                   i++;
+               }
+               while (i < sorted.length) {
+                   let next = sorted[i];
+                   if (next.from == from && (next.to > next.from || next.to == from)) {
+                       active.push(next);
+                       i++;
+                       to = Math.min(next.to, to);
+                   }
+                   else {
+                       to = Math.min(next.from, to);
+                       break;
+                   }
+               }
+               let sev = maxSeverity(active);
+               if (active.some(d => d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from))) {
+                   deco.add(from, from, Decoration.widget({
+                       widget: new DiagnosticWidget(sev),
+                       diagnostics: active.slice()
+                   }));
+               }
+               else {
+                   let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, "");
+                   deco.add(from, to, Decoration.mark({
+                       class: "cm-lintRange cm-lintRange-" + sev + markClass,
+                       diagnostics: active.slice(),
+                       inclusiveEnd: active.some(a => a.to > to)
+                   }));
+               }
+               pos = to;
+               for (let i = 0; i < active.length; i++)
+                   if (active[i].to <= pos)
+                       active.splice(i--, 1);
+           }
+           let set = deco.finish();
+           return new LintState(set, panel, findDiagnostic(set));
+       }
+   }
+   function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
+       let found = null;
+       diagnostics.between(after, 1e9, (from, to, { spec }) => {
+           if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0)
+               return;
+           if (!found)
+               found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]);
+           else if (spec.diagnostics.indexOf(found.diagnostic) < 0)
+               return false;
+           else
+               found = new SelectedDiagnostic(found.from, to, found.diagnostic);
+       });
+       return found;
+   }
+   function hideTooltip(tr, tooltip) {
+       let from = tooltip.pos, to = tooltip.end || from;
+       let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
+       if (result != null)
+           return result;
+       let line = tr.startState.doc.lineAt(tooltip.pos);
+       return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
+   }
+   /**
+   The state effect that updates the set of active diagnostics. Can
+   be useful when writing an extension that needs to track these.
+   */
+   const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
+   const togglePanel = /*@__PURE__*/StateEffect.define();
+   const movePanelSelection = /*@__PURE__*/StateEffect.define();
+   const lintState = /*@__PURE__*/StateField.define({
+       create() {
+           return new LintState(Decoration.none, null, null);
+       },
+       update(value, tr) {
+           if (tr.docChanged && value.diagnostics.size) {
+               let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
+               if (value.selected) {
+                   let selPos = tr.changes.mapPos(value.selected.from, 1);
+                   selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
+               }
+               if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel)
+                   panel = null;
+               value = new LintState(mapped, panel, selected);
+           }
+           for (let effect of tr.effects) {
+               if (effect.is(setDiagnosticsEffect)) {
+                   let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
+                   value = LintState.init(effect.value, panel, tr.state);
+               }
+               else if (effect.is(togglePanel)) {
+                   value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
+               }
+               else if (effect.is(movePanelSelection)) {
+                   value = new LintState(value.diagnostics, value.panel, effect.value);
+               }
+           }
+           return value;
+       },
+       provide: f => [showPanel.from(f, val => val.panel),
+           EditorView.decorations.from(f, s => s.diagnostics)]
+   });
+   function diagnosticsTooltip(view, diagnostics) {
+       return crelt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
+   }
+   /**
+   Command to close the lint panel, when open.
+   */
+   const closeLintPanel = (view) => {
+       let field = view.state.field(lintState, false);
+       if (!field || !field.panel)
+           return false;
+       view.dispatch({ effects: togglePanel.of(false) });
+       return true;
+   };
+   const lintConfig = /*@__PURE__*/Facet.define({
+       combine(input) {
+           return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
+               delay: 750,
+               markerFilter: null,
+               tooltipFilter: null,
+               needsRefresh: null,
+               hideOn: () => null,
+           }, {
+               needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
+           }));
+       }
+   });
+   function assignKeys(actions) {
+       let assigned = [];
+       if (actions)
+           actions: for (let { name } of actions) {
+               for (let i = 0; i < name.length; i++) {
+                   let ch = name[i];
+                   if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
+                       assigned.push(ch);
+                       continue actions;
+                   }
+               }
+               assigned.push("");
+           }
+       return assigned;
+   }
+   function renderDiagnostic(view, diagnostic, inPanel) {
+       var _a;
+       let keys = inPanel ? assignKeys(diagnostic.actions) : [];
+       return crelt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, crelt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
+           let fired = false, click = (e) => {
+               e.preventDefault();
+               if (fired)
+                   return;
+               fired = true;
+               let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
+               if (found)
+                   action.apply(view, found.from, found.to);
+           };
+           let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
+           let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
+               crelt("u", name.slice(keyIndex, keyIndex + 1)),
+               name.slice(keyIndex + 1)];
+           return crelt("button", {
+               type: "button",
+               class: "cm-diagnosticAction",
+               onclick: click,
+               onmousedown: click,
+               "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
+           }, nameElt);
+       }), diagnostic.source && crelt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
+   }
+   class DiagnosticWidget extends WidgetType {
+       constructor(sev) {
+           super();
+           this.sev = sev;
+       }
+       eq(other) { return other.sev == this.sev; }
+       toDOM() {
+           return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
+       }
+   }
+   class PanelItem {
+       constructor(view, diagnostic) {
+           this.diagnostic = diagnostic;
+           this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
+           this.dom = renderDiagnostic(view, diagnostic, true);
+           this.dom.id = this.id;
+           this.dom.setAttribute("role", "option");
+       }
+   }
+   class LintPanel {
+       constructor(view) {
+           this.view = view;
+           this.items = [];
+           let onkeydown = (event) => {
+               if (event.keyCode == 27) { // Escape
+                   closeLintPanel(this.view);
+                   this.view.focus();
+               }
+               else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
+                   this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
+               }
+               else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
+                   this.moveSelection((this.selectedIndex + 1) % this.items.length);
+               }
+               else if (event.keyCode == 36) { // Home
+                   this.moveSelection(0);
+               }
+               else if (event.keyCode == 35) { // End
+                   this.moveSelection(this.items.length - 1);
+               }
+               else if (event.keyCode == 13) { // Enter
+                   this.view.focus();
+               }
+               else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
+                   let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions);
+                   for (let i = 0; i < keys.length; i++)
+                       if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
+                           let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
+                           if (found)
+                               diagnostic.actions[i].apply(view, found.from, found.to);
+                       }
+               }
+               else {
+                   return;
+               }
+               event.preventDefault();
+           };
+           let onclick = (event) => {
+               for (let i = 0; i < this.items.length; i++) {
+                   if (this.items[i].dom.contains(event.target))
+                       this.moveSelection(i);
+               }
+           };
+           this.list = crelt("ul", {
+               tabIndex: 0,
+               role: "listbox",
+               "aria-label": this.view.state.phrase("Diagnostics"),
+               onkeydown,
+               onclick
+           });
+           this.dom = crelt("div", { class: "cm-panel-lint" }, this.list, crelt("button", {
+               type: "button",
+               name: "close",
+               "aria-label": this.view.state.phrase("close"),
+               onclick: () => closeLintPanel(this.view)
+           }, "×"));
+           this.update();
+       }
+       get selectedIndex() {
+           let selected = this.view.state.field(lintState).selected;
+           if (!selected)
+               return -1;
+           for (let i = 0; i < this.items.length; i++)
+               if (this.items[i].diagnostic == selected.diagnostic)
+                   return i;
+           return -1;
+       }
+       update() {
+           let { diagnostics, selected } = this.view.state.field(lintState);
+           let i = 0, needsSync = false, newSelectedItem = null;
+           let seen = new Set();
+           diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
+               for (let diagnostic of spec.diagnostics) {
+                   if (seen.has(diagnostic))
+                       continue;
+                   seen.add(diagnostic);
+                   let found = -1, item;
+                   for (let j = i; j < this.items.length; j++)
+                       if (this.items[j].diagnostic == diagnostic) {
+                           found = j;
+                           break;
+                       }
+                   if (found < 0) {
+                       item = new PanelItem(this.view, diagnostic);
+                       this.items.splice(i, 0, item);
+                       needsSync = true;
+                   }
+                   else {
+                       item = this.items[found];
+                       if (found > i) {
+                           this.items.splice(i, found - i);
+                           needsSync = true;
+                       }
+                   }
+                   if (selected && item.diagnostic == selected.diagnostic) {
+                       if (!item.dom.hasAttribute("aria-selected")) {
+                           item.dom.setAttribute("aria-selected", "true");
+                           newSelectedItem = item;
+                       }
+                   }
+                   else if (item.dom.hasAttribute("aria-selected")) {
+                       item.dom.removeAttribute("aria-selected");
+                   }
+                   i++;
+               }
+           });
+           while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
+               needsSync = true;
+               this.items.pop();
+           }
+           if (this.items.length == 0) {
+               this.items.push(new PanelItem(this.view, {
+                   from: -1, to: -1,
+                   severity: "info",
+                   message: this.view.state.phrase("No diagnostics")
+               }));
+               needsSync = true;
+           }
+           if (newSelectedItem) {
+               this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
+               this.view.requestMeasure({
+                   key: this,
+                   read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
+                   write: ({ sel, panel }) => {
+                       let scaleY = panel.height / this.list.offsetHeight;
+                       if (sel.top < panel.top)
+                           this.list.scrollTop -= (panel.top - sel.top) / scaleY;
+                       else if (sel.bottom > panel.bottom)
+                           this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY;
+                   }
+               });
+           }
+           else if (this.selectedIndex < 0) {
+               this.list.removeAttribute("aria-activedescendant");
+           }
+           if (needsSync)
+               this.sync();
+       }
+       sync() {
+           let domPos = this.list.firstChild;
+           function rm() {
+               let prev = domPos;
+               domPos = prev.nextSibling;
+               prev.remove();
+           }
+           for (let item of this.items) {
+               if (item.dom.parentNode == this.list) {
+                   while (domPos != item.dom)
+                       rm();
+                   domPos = item.dom.nextSibling;
+               }
+               else {
+                   this.list.insertBefore(item.dom, domPos);
+               }
+           }
+           while (domPos)
+               rm();
+       }
+       moveSelection(selectedIndex) {
+           if (this.selectedIndex < 0)
+               return;
+           let field = this.view.state.field(lintState);
+           let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
+           if (!selection)
+               return;
+           this.view.dispatch({
+               selection: { anchor: selection.from, head: selection.to },
+               scrollIntoView: true,
+               effects: movePanelSelection.of(selection)
+           });
+       }
+       static open(view) { return new LintPanel(view); }
+   }
+   function svg(content, attrs = `viewBox="0 0 40 40"`) {
+       return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
+   }
+   function severityWeight(sev) {
+       return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
+   }
+   function maxSeverity(diagnostics) {
+       let sev = "hint", weight = 1;
+       for (let d of diagnostics) {
+           let w = severityWeight(d.severity);
+           if (w > weight) {
+               weight = w;
+               sev = d.severity;
+           }
+       }
+       return sev;
+   }
+   class LintGutterMarker extends GutterMarker {
+       constructor(diagnostics) {
+           super();
+           this.diagnostics = diagnostics;
+           this.severity = maxSeverity(diagnostics);
+       }
+       toDOM(view) {
+           let elt = document.createElement("div");
+           elt.className = "cm-lint-marker cm-lint-marker-" + this.severity;
+           let diagnostics = this.diagnostics;
+           let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter;
+           if (diagnosticsFilter)
+               diagnostics = diagnosticsFilter(diagnostics, view.state);
+           if (diagnostics.length)
+               elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics);
+           return elt;
+       }
+   }
+   function trackHoverOn(view, marker) {
+       let mousemove = (event) => {
+           let rect = marker.getBoundingClientRect();
+           if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
+               event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
+               return;
+           for (let target = event.target; target; target = target.parentNode) {
+               if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
+                   return;
+           }
+           window.removeEventListener("mousemove", mousemove);
+           if (view.state.field(lintGutterTooltip))
+               view.dispatch({ effects: setLintGutterTooltip.of(null) });
+       };
+       window.addEventListener("mousemove", mousemove);
+   }
+   function gutterMarkerMouseOver(view, marker, diagnostics) {
+       function hovered() {
+           let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
+           const linePos = view.coordsAtPos(line.from);
+           if (linePos) {
+               view.dispatch({ effects: setLintGutterTooltip.of({
+                       pos: line.from,
+                       above: false,
+                       clip: false,
+                       create() {
+                           return {
+                               dom: diagnosticsTooltip(view, diagnostics),
+                               getCoords: () => marker.getBoundingClientRect()
+                           };
+                       }
+                   }) });
+           }
+           marker.onmouseout = marker.onmousemove = null;
+           trackHoverOn(view, marker);
+       }
+       let { hoverTime } = view.state.facet(lintGutterConfig);
+       let hoverTimeout = setTimeout(hovered, hoverTime);
+       marker.onmouseout = () => {
+           clearTimeout(hoverTimeout);
+           marker.onmouseout = marker.onmousemove = null;
+       };
+       marker.onmousemove = () => {
+           clearTimeout(hoverTimeout);
+           hoverTimeout = setTimeout(hovered, hoverTime);
+       };
+   }
+   function markersForDiagnostics(doc, diagnostics) {
+       let byLine = Object.create(null);
+       for (let diagnostic of diagnostics) {
+           let line = doc.lineAt(diagnostic.from);
+           (byLine[line.from] || (byLine[line.from] = [])).push(diagnostic);
+       }
+       let markers = [];
+       for (let line in byLine) {
+           markers.push(new LintGutterMarker(byLine[line]).range(+line));
+       }
+       return RangeSet.of(markers, true);
+   }
+   const lintGutterExtension = /*@__PURE__*/gutter({
+       class: "cm-gutter-lint",
+       markers: view => view.state.field(lintGutterMarkers),
+       widgetMarker: (view, widget, block) => {
+           let diagnostics = [];
+           view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
+               if (from > block.from && from < block.to)
+                   diagnostics.push(...value.diagnostics);
+           });
+           return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
+       }
+   });
+   const lintGutterMarkers = /*@__PURE__*/StateField.define({
+       create() {
+           return RangeSet.empty;
+       },
+       update(markers, tr) {
+           markers = markers.map(tr.changes);
+           let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter;
+           for (let effect of tr.effects) {
+               if (effect.is(setDiagnosticsEffect)) {
+                   let diagnostics = effect.value;
+                   if (diagnosticFilter)
+                       diagnostics = diagnosticFilter(diagnostics || [], tr.state);
+                   markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0));
+               }
+           }
+           return markers;
+       }
+   });
+   const setLintGutterTooltip = /*@__PURE__*/StateEffect.define();
+   const lintGutterTooltip = /*@__PURE__*/StateField.define({
+       create() { return null; },
+       update(tooltip, tr) {
+           if (tooltip && tr.docChanged)
+               tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
+           return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
+       },
+       provide: field => showTooltip.from(field)
+   });
+   const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
+       ".cm-gutter-lint": {
+           width: "1.4em",
+           "& .cm-gutterElement": {
+               padding: ".2em"
+           }
+       },
+       ".cm-lint-marker": {
+           width: "1em",
+           height: "1em"
+       },
+       ".cm-lint-marker-info": {
+           content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
+       },
+       ".cm-lint-marker-warning": {
+           content: /*@__PURE__*/svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
+       },
+       ".cm-lint-marker-error": {
+           content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
+       },
+   });
+   const lintGutterConfig = /*@__PURE__*/Facet.define({
+       combine(configs) {
+           return combineConfig(configs, {
+               hoverTime: 300 /* Hover.Time */,
+               markerFilter: null,
+               tooltipFilter: null
+           });
+       }
+   });
+   /**
+   Returns an extension that installs a gutter showing markers for
+   each line that has diagnostics, which can be hovered over to see
+   the diagnostics.
+   */
+   function lintGutter(config = {}) {
+       return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
+   }
+
+   window.basicSetup = basicSetup;
+   window.javascript = javascript;
+   window.oneDark = oneDark;
+   window.EditorView = EditorView;
+   window.EditorState = EditorState;
+   window.lintGutter = lintGutter;
+   window.autocompletion = autocompletion;
+   window.language = language;
+   window.lineNumbers = lineNumbers;
+
+})();
diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index 167919d8b..a7273ef17 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1139,6 +1139,7 @@
         .hidden {
             display: none;
         }
+
     </style>
 </head>
 
@@ -1230,15 +1231,39 @@ <h2 th:text="${contractFilePath}"></h2>
     const testDetails = {};
 </script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jsonlint/1.6.0/jsonlint.min.js"></script>
-<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">
-<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">
-<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">
-<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/addon/lint/lint.min.css">
-<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">-->
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">-->
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">-->
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/addon/lint/lint.min.css">-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>-->
+<script src="codemirror-bundle.js"></script>
+<script>
+      window.onload = function () {
+        const examplePreDiv = document.createElement("div");
+        examplePreDiv.style.height = "400px";
+        examplePreDiv.style.width = "600px";
+        examplePreDiv.style.border = "1px solid #ccc";
+
+        // Create the editor
+        const editor = new window.EditorView({
+          state: window.EditorState.create({
+            doc: '{"hello":"hello"}',
+            extensions: [
+              window.basicSetup,
+              window.javascript()
+            ],
+          }),
+          parent: examplePreDiv,
+        });
+
+        // Append the div to the body
+        document.body.appendChild(examplePreDiv);
+      };
+</script>
 <script>var escapedChars={b:"\b",f:"\f",n:"\n",r:"\r",t:"	",'"':'"',"/":"/","\\":"\\"},A_CODE="a".charCodeAt();const jsonMapParser=function(e,n,r){var a={},t=0,o=0,c=0,i=r&&r.bigint&&"undefined"!=typeof BigInt;return{data:function n(r,a){f(),E(r,"value");var t,o,$,g,S=l();switch(S){case"t":s("rue"),g=!0;break;case"f":s("alse"),g=!1;break;case"n":s("ull"),g=null;break;case'"':g=u();break;case"[":g=function e(r){f();var a=[],t=0;if("]"==l())return a;for(v();;){var o=r+"/"+t;a.push(n(o)),f();var c=l();if("]"==c)break;","!=c&&k(),f(),t++}return a}(r);break;case"{":g=function e(r){f();var a={};if("}"==l())return a;for(v();;){var t=d();'"'!=l()&&k();var o=u(),c=r+"/"+escapeJsonPointer(o);b(c,"key",t),E(c,"keyEnd"),f(),":"!=l()&&k(),f(),a[o]=n(c),f();var i=l();if("}"==i)break;","!=i&&k(),f()}return a}(r);break;default:v(),"-0123456789".indexOf(S)>=0?g=(t="",o=!0,"-"==e[c]&&(t+=l()),t+="0"==e[c]?l():p(),"."==e[c]&&(t+=l()+p(),o=!1),("e"==e[c]||"E"==e[c])&&(t+=l(),("+"==e[c]||"-"==e[c])&&(t+=l()),t+=p(),o=!1),$=+t,i&&o&&($>Number.MAX_SAFE_INTEGER||$<Number.MIN_SAFE_INTEGER)?BigInt(t):$):h()}return E(r,"valueEnd"),f(),a&&c<e.length&&h(),g}("",!0),pointers:a};function f(){loop:for(;c<e.length;){switch(e[c]){case" ":o++;break;case"	":o+=4;break;case"\r":o=0;break;case"\n":o=0,t++;break;default:break loop}c++}}function u(){for(var e,n="";'"'!=(e=l());)"\\"==e?(e=l())in escapedChars?n+=escapedChars[e]:"u"==e?n+=$():k():n+=e;return n}function s(e){for(var n=0;n<e.length;n++)l()!==e[n]&&k()}function l(){g();var n=e[c];return c++,o++,n}function v(){c--,o--}function $(){for(var e=4,n=0;e--;){n<<=4;var r=l().toLowerCase();r>="a"&&r<="f"?n+=r.charCodeAt()-A_CODE+10:r>="0"&&r<="9"?n+=+r:k()}return String.fromCharCode(n)}function p(){for(var n="";e[c]>="0"&&e[c]<="9";)n+=l();if(n.length)return n;g(),h()}function E(e,n){b(e,n,d())}function b(e,n,r){a[e]=a[e]||{},a[e][n]=r}function d(){return{line:t,column:o,pos:c}}function h(){throw SyntaxError("Unexpected token "+e[c]+" in JSON at position "+c)}function k(){v(),h()}function g(){if(c>=e.length)throw SyntaxError("Unexpected end of JSON input")}},jsonMapStringify=function(e,n,r){if(validType(e)){var a,t,o=0,c="object"==typeof r?r.space:r;switch(typeof c){case"number":var i=c>10?10:c<0?0:Math.floor(c);c=i&&k(i," "),a=i,t=i;break;case"string":c=c.slice(0,10),a=0,t=0;for(var f=0;f<c.length;f++){var u=c[f];switch(u){case" ":t++;break;case"	":t+=4;break;case"\r":t=0;break;case"\n":t=0,o++;break;default:throw Error("whitespace characters not allowed in JSON")}a++}break;default:c=void 0}var s="",l={},v=0,$=0,p=0,E=r&&r.es6&&"function"==typeof Map;return function e(n,r,a){switch(h(a,"value"),typeof n){case"number":case"bigint":case"boolean":b(""+n);break;case"string":b(quoted(n));break;case"object":null===n?b("null"):"function"==typeof n.toJSON?b(quoted(n.toJSON())):Array.isArray(n)?t():E?n.constructor.BYTES_PER_ELEMENT?t():n instanceof Map?i():n instanceof Set?i(!0):o():o()}function t(){if(n.length){b("[");for(var t=r+1,o=0;o<n.length;o++){o&&b(","),d(t);var c=validType(n[o])?n[o]:null;e(c,t,a+"/"+o)}d(r),b("]")}else b("[]")}function o(){var t=Object.keys(n);if(t.length){b("{");for(var o=r+1,i=0;i<t.length;i++){var f=t[i],u=n[f];if(validType(u)){i&&b(",");var s=a+"/"+escapeJsonPointer(f);d(o),h(s,"key"),b(quoted(f)),h(s,"keyEnd"),b(":"),c&&b(" "),e(u,o,s)}}d(r),b("}")}else b("{}")}function i(t){if(n.size){b("{");for(var o=r+1,i=!0,f=n.entries(),u=f.next();!u.done;){var s=u.value,l=s[0],v=!!t||s[1];if(validType(v)){i||b(","),i=!1;var $=a+"/"+escapeJsonPointer(l);d(o),h($,"key"),b(quoted(l)),h($,"keyEnd"),b(":"),c&&b(" "),e(v,o,$)}u=f.next()}d(r),b("}")}else b("{}")}h(a,"valueEnd")}(e,0,""),{json:s,pointers:l}}function b(e){$+=e.length,p+=e.length,s+=e}function d(e){if(c){for(s+="\n"+k(e,c),v++,$=0;e--;)o?(v+=o,$=t):$+=t,p+=a;p+=1}}function h(e,n){l[e]=l[e]||{},l[e][n]={line:v,column:$,pos:p}}function k(e,n){return Array(e+1).join(n)}};var VALID_TYPES=["number","bigint","boolean","string","object"];function validType(e){return VALID_TYPES.indexOf(typeof e)>=0}var ESC_QUOTE=/"|\\/g,ESC_B=/[\b]/g,ESC_F=/\f/g,ESC_N=/\n/g,ESC_R=/\r/g,ESC_T=/\t/g;function quoted(e){return'"'+(e=e.replace(ESC_QUOTE,"\\$&").replace(ESC_F,"\\f").replace(ESC_B,"\\b").replace(ESC_N,"\\n").replace(ESC_R,"\\r").replace(ESC_T,"\\t"))+'"'}var ESC_0=/~/g,ESC_1=/\//g;function escapeJsonPointer(e){return e.replace(ESC_0,"~0").replace(ESC_1,"~1")}</script>
 </body>
 <script>
@@ -1824,19 +1849,30 @@ <h2 th:text="${contractFilePath}"></h2>
         detailsFragment.appendChild(detailsDropdown);
         detailsFragment.appendChild(detailsPre);
 
-        const editor = CodeMirror(examplePreDiv, {
-            value: example.exampleJson,
-            autoRefresh: true,
-            mode: "application/json",
-            theme: "dracula",
-            lineNumbers: true,
-            autoCloseBrackets: true,
-            matchBrackets: true,
-            styleActiveLine: true,
-            lint: true,
-            gutters: ["CodeMirror-lint-markers"]
-        });
-
+    console.log(window.EditorView);
+    console.log(window.EditorState);
+    console.log(window.basicSetup);
+    console.log(window.javascript);
+    console.log(window.autocompletion);
+    console.log(window.lintGutter);
+    console.log(window.lineNumbers);
+    console.log(window.oneDark);
+
+
+    const editor = new window.EditorView({
+    state: window.EditorState.create({
+      doc: '{"hello":"hello"}',
+      extensions: [
+        window.basicSetup,
+        window.javascript(),
+        window.autocompletion(),
+        window.lintGutter(),
+        window.lineNumbers(),
+        window.oneDark
+      ],
+    }),
+    parent: examplePrevDiv
+  });
         if (example.errorList) {
             if (Array.isArray(example.errorList) && example.errorList.every(item => typeof item === 'object')) {
                 highlightErrorLines(editor, example.errorList, example.exampleJson);

From 6431e0e0405ce805c687967c5bef9516e6cf6ea4 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Fri, 20 Dec 2024 22:29:56 +0530
Subject: [PATCH 02/14] Added tit tats

---
 .../resources/static/codemirror-bundle.esm.js |  3351 +-
 .../resources/static/codemirror-bundle.js     | 67545 ----------------
 .../resources/templates/examples/index.html   |   225 +-
 3 files changed, 2686 insertions(+), 68435 deletions(-)
 delete mode 100644 core/src/main/resources/static/codemirror-bundle.js

diff --git a/core/src/main/resources/static/codemirror-bundle.esm.js b/core/src/main/resources/static/codemirror-bundle.esm.js
index 4f42d8555..eaa729472 100644
--- a/core/src/main/resources/static/codemirror-bundle.esm.js
+++ b/core/src/main/resources/static/codemirror-bundle.esm.js
@@ -3086,7 +3086,7 @@ RangeValue.prototype.mapMode = MapMode.TrackDel;
 /**
 A range associates a value with a range of positions.
 */
-let Range$1 = class Range {
+class Range$1 {
     constructor(
     /**
     The range's start position.
@@ -3108,9 +3108,9 @@ let Range$1 = class Range {
     @internal
     */
     static create(from, to, value) {
-        return new Range(from, to, value);
+        return new Range$1(from, to, value);
     }
-};
+}
 function cmpRange(a, b) {
     return a.from - b.from || a.value.startSide - b.value.startSide;
 }
@@ -4970,9 +4970,9 @@ const gecko = !ie && /*@__PURE__*//gecko\/(\d+)/i.test(nav.userAgent);
 const chrome = !ie && /*@__PURE__*//Chrome\/(\d+)/.exec(nav.userAgent);
 const webkit = "webkitFontSmoothing" in doc.documentElement.style;
 const safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);
-const ios = safari && (/*@__PURE__*//Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
+const ios$1 = safari && (/*@__PURE__*//Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
 var browser = {
-    mac: ios || /*@__PURE__*//Mac/.test(nav.platform),
+    mac: ios$1 || /*@__PURE__*//Mac/.test(nav.platform),
     windows: /*@__PURE__*//Win/.test(nav.platform),
     linux: /*@__PURE__*//Linux|X11/.test(nav.platform),
     ie,
@@ -4981,7 +4981,7 @@ var browser = {
     gecko_version: gecko ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
     chrome: !!chrome,
     chrome_version: chrome ? +chrome[1] : 0,
-    ios,
+    ios: ios$1,
     android: /*@__PURE__*//Android\b/.test(nav.userAgent),
     webkit,
     safari,
@@ -13827,7 +13827,7 @@ that was dragged over will be selected, as one selection
 [range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.
 */
 function rectangularSelection(options) {
-    let filter = (e => e.altKey && e.button == 0);
+    let filter = (options === null || options === void 0 ? void 0 : options.eventFilter) || (e => e.altKey && e.button == 0);
     return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
 }
 const keys = {
@@ -13877,8 +13877,8 @@ function crosshairCursor(options = {}) {
     ];
 }
 
-const Outside = "-10000px";
-class TooltipViewManager {
+const Outside$1 = "-10000px";
+class TooltipViewManager$1 {
     constructor(view, facet, createTooltipView, removeTooltipView) {
         this.facet = facet;
         this.createTooltipView = createTooltipView;
@@ -13936,22 +13936,28 @@ class TooltipViewManager {
         return true;
     }
 }
-function windowSpace(view) {
+/**
+Creates an extension that configures tooltip behavior.
+*/
+function tooltips(config = {}) {
+    return tooltipConfig$1.of(config);
+}
+function windowSpace$1(view) {
     let { win } = view;
     return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
 }
-const tooltipConfig = /*@__PURE__*/Facet.define({
+const tooltipConfig$1 = /*@__PURE__*/Facet.define({
     combine: values => {
         var _a, _b, _c;
         return ({
             position: browser.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
             parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
-            tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,
+            tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace$1,
         });
     }
 });
 const knownHeight = /*@__PURE__*/new WeakMap();
-const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+const tooltipPlugin$1 = /*@__PURE__*/ViewPlugin.fromClass(class {
     constructor(view) {
         this.view = view;
         this.above = [];
@@ -13959,14 +13965,14 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
         this.madeAbsolute = false;
         this.lastTransaction = 0;
         this.measureTimeout = -1;
-        let config = view.state.facet(tooltipConfig);
+        let config = view.state.facet(tooltipConfig$1);
         this.position = config.position;
         this.parent = config.parent;
         this.classes = view.themeClasses;
         this.createContainer();
         this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
         this.resizeObserver = typeof ResizeObserver == "function" ? new ResizeObserver(() => this.measureSoon()) : null;
-        this.manager = new TooltipViewManager(view, showTooltip, (t, p) => this.createTooltip(t, p), t => {
+        this.manager = new TooltipViewManager$1(view, showTooltip$1, (t, p) => this.createTooltip(t, p), t => {
             if (this.resizeObserver)
                 this.resizeObserver.unobserve(t.dom);
             t.dom.remove();
@@ -14013,7 +14019,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
         if (updated)
             this.observeIntersection();
         let shouldMeasure = updated || update.geometryChanged;
-        let newConfig = update.state.facet(tooltipConfig);
+        let newConfig = update.state.facet(tooltipConfig$1);
         if (newConfig.position != this.position && !this.madeAbsolute) {
             this.position = newConfig.position;
             for (let t of this.manager.tooltipViews)
@@ -14045,7 +14051,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
             tooltipView.dom.appendChild(arrow);
         }
         tooltipView.dom.style.position = this.position;
-        tooltipView.dom.style.top = Outside;
+        tooltipView.dom.style.top = Outside$1;
         tooltipView.dom.style.left = "0px";
         this.container.insertBefore(tooltipView.dom, before);
         if (tooltipView.mount)
@@ -14077,7 +14083,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
                 // positioning.
                 makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
             }
-            else if (dom.style.top == Outside && dom.style.left == "0px") {
+            else if (dom.style.top == Outside$1 && dom.style.left == "0px") {
                 // On other browsers, we have to awkwardly try and use other
                 // information to detect a transform.
                 let rect = dom.getBoundingClientRect();
@@ -14108,7 +14114,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
                 return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
             }),
             size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
-            space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
+            space: this.view.state.facet(tooltipConfig$1).tooltipSpace(this.view),
             scaleX, scaleY, makeAbsolute
         };
     }
@@ -14130,13 +14136,13 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
                 pos.top >= Math.min(visible.bottom, space.bottom) ||
                 pos.right < Math.max(visible.left, space.left) - .1 ||
                 pos.left > Math.min(visible.right, space.right) + .1)) {
-                dom.style.top = Outside;
+                dom.style.top = Outside$1;
                 continue;
             }
             let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
             let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
             let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
-            let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
+            let offset = tView.offset || noOffset$1, ltr = this.view.textDirection == Direction.LTR;
             let left = size.width > space.right - space.left
                 ? (ltr ? space.left : space.right - size.width)
                 : ltr ? Math.max(space.left, Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width))
@@ -14150,7 +14156,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
             let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
             if (spaceVert < height && tView.resize !== false) {
                 if (spaceVert < this.view.defaultLineHeight) {
-                    dom.style.top = Outside;
+                    dom.style.top = Outside$1;
                     continue;
                 }
                 knownHeight.set(tView, height);
@@ -14193,7 +14199,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
                 this.inView = this.view.inView;
                 if (!this.inView)
                     for (let tv of this.manager.tooltipViews)
-                        tv.dom.style.top = Outside;
+                        tv.dom.style.top = Outside$1;
             }
         }
     }
@@ -14207,7 +14213,7 @@ function setLeftStyle(elt, value) {
     if (isNaN(current) || Math.abs(value - current) > 1)
         elt.style.left = value + "px";
 }
-const baseTheme$4 = /*@__PURE__*/EditorView.baseTheme({
+const baseTheme$5 = /*@__PURE__*/EditorView.baseTheme({
     ".cm-tooltip": {
         zIndex: 500,
         boxSizing: "border-box"
@@ -14269,27 +14275,27 @@ const baseTheme$4 = /*@__PURE__*/EditorView.baseTheme({
         }
     }
 });
-const noOffset = { x: 0, y: 0 };
+const noOffset$1 = { x: 0, y: 0 };
 /**
 Facet to which an extension can add a value to show a tooltip.
 */
-const showTooltip = /*@__PURE__*/Facet.define({
-    enables: [tooltipPlugin, baseTheme$4]
+const showTooltip$1 = /*@__PURE__*/Facet.define({
+    enables: [tooltipPlugin$1, baseTheme$5]
 });
-const showHoverTooltip = /*@__PURE__*/Facet.define({
+const showHoverTooltip$1 = /*@__PURE__*/Facet.define({
     combine: inputs => inputs.reduce((a, i) => a.concat(i), [])
 });
-class HoverTooltipHost {
+class HoverTooltipHost$1 {
     // Needs to be static so that host tooltip instances always match
     static create(view) {
-        return new HoverTooltipHost(view);
+        return new HoverTooltipHost$1(view);
     }
     constructor(view) {
         this.view = view;
         this.mounted = false;
         this.dom = document.createElement("div");
         this.dom.classList.add("cm-tooltip-hover");
-        this.manager = new TooltipViewManager(view, showHoverTooltip, (t, p) => this.createHostedView(t, p), t => t.dom.remove());
+        this.manager = new TooltipViewManager$1(view, showHoverTooltip$1, (t, p) => this.createHostedView(t, p), t => t.dom.remove());
     }
     createHostedView(tooltip, prev) {
         let hostedView = tooltip.create(this.view);
@@ -14338,19 +14344,19 @@ class HoverTooltipHost {
     get overlap() { return this.passProp("overlap"); }
     get resize() { return this.passProp("resize"); }
 }
-const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
-    let tooltips = state.facet(showHoverTooltip);
+const showHoverTooltipHost$1 = /*@__PURE__*/showTooltip$1.compute([showHoverTooltip$1], state => {
+    let tooltips = state.facet(showHoverTooltip$1);
     if (tooltips.length === 0)
         return null;
     return {
         pos: Math.min(...tooltips.map(t => t.pos)),
         end: Math.max(...tooltips.map(t => { var _a; return (_a = t.end) !== null && _a !== void 0 ? _a : t.pos; })),
-        create: HoverTooltipHost.create,
+        create: HoverTooltipHost$1.create,
         above: tooltips[0].above,
         arrow: tooltips.some(t => t.arrow),
     };
 });
-class HoverPlugin {
+class HoverPlugin$1 {
     constructor(view, source, field, setHover, hoverTime) {
         this.view = view;
         this.source = source;
@@ -14425,8 +14431,8 @@ class HoverPlugin {
         }
     }
     get tooltip() {
-        let plugin = this.view.plugin(tooltipPlugin);
-        let index = plugin ? plugin.manager.tooltips.findIndex(t => t.create == HoverTooltipHost.create) : -1;
+        let plugin = this.view.plugin(tooltipPlugin$1);
+        let index = plugin ? plugin.manager.tooltips.findIndex(t => t.create == HoverTooltipHost$1.create) : -1;
         return index > -1 ? plugin.manager.tooltipViews[index] : null;
     }
     mousemove(event) {
@@ -14435,10 +14441,10 @@ class HoverPlugin {
         if (this.hoverTimeout < 0)
             this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
         let { active, tooltip } = this;
-        if (active.length && tooltip && !isInTooltip(tooltip.dom, event) || this.pending) {
+        if (active.length && tooltip && !isInTooltip$1(tooltip.dom, event) || this.pending) {
             let { pos } = active[0] || this.pending, end = (_b = (_a = active[0]) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : pos;
             if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
-                : !isOverRange(this.view, pos, end, event.clientX, event.clientY))) {
+                : !isOverRange$1(this.view, pos, end, event.clientX, event.clientY))) {
                 this.view.dispatch({ effects: this.setHover.of([]) });
                 this.pending = null;
             }
@@ -14472,7 +14478,7 @@ class HoverPlugin {
     }
 }
 const tooltipMargin = 4;
-function isInTooltip(tooltip, event) {
+function isInTooltip$1(tooltip, event) {
     let { left, right, top, bottom } = tooltip.getBoundingClientRect(), arrow;
     if (arrow = tooltip.querySelector(".cm-tooltip-arrow")) {
         let arrowRect = arrow.getBoundingClientRect();
@@ -14482,7 +14488,7 @@ function isInTooltip(tooltip, event) {
     return event.clientX >= left - tooltipMargin && event.clientX <= right + tooltipMargin &&
         event.clientY >= top - tooltipMargin && event.clientY <= bottom + tooltipMargin;
 }
-function isOverRange(view, from, to, x, y, margin) {
+function isOverRange$1(view, from, to, x, y, margin) {
     let rect = view.scrollDOM.getBoundingClientRect();
     let docBottom = view.documentTop + view.documentPadding.top + view.contentHeight;
     if (rect.left > x || rect.right < x || rect.top > y || Math.min(rect.bottom, docBottom) < y)
@@ -14508,7 +14514,7 @@ but also provides an `active` property holding a state field that
 can be used to read the currently active tooltips produced by this
 extension.
 */
-function hoverTooltip(source, options = {}) {
+function hoverTooltip$1(source, options = {}) {
     let setHover = StateEffect.define();
     let hoverState = StateField.define({
         create() { return []; },
@@ -14536,19 +14542,19 @@ function hoverTooltip(source, options = {}) {
             for (let effect of tr.effects) {
                 if (effect.is(setHover))
                     value = effect.value;
-                if (effect.is(closeHoverTooltipEffect))
+                if (effect.is(closeHoverTooltipEffect$1))
                     value = [];
             }
             return value;
         },
-        provide: f => showHoverTooltip.from(f)
+        provide: f => showHoverTooltip$1.from(f)
     });
     return {
         active: hoverState,
         extension: [
             hoverState,
-            ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
-            showHoverTooltipHost
+            ViewPlugin.define(view => new HoverPlugin$1(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
+            showHoverTooltipHost$1
         ]
     };
 }
@@ -14556,13 +14562,13 @@ function hoverTooltip(source, options = {}) {
 Get the active tooltip view for a given tooltip, if available.
 */
 function getTooltip(view, tooltip) {
-    let plugin = view.plugin(tooltipPlugin);
+    let plugin = view.plugin(tooltipPlugin$1);
     if (!plugin)
         return null;
     let found = plugin.manager.tooltips.indexOf(tooltip);
     return found < 0 ? null : plugin.manager.tooltipViews[found];
 }
-const closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();
+const closeHoverTooltipEffect$1 = /*@__PURE__*/StateEffect.define();
 
 const panelConfig = /*@__PURE__*/Facet.define({
     combine(configs) {
@@ -14810,6 +14816,8 @@ function gutters(config) {
     let result = [
         gutterView,
     ];
+    if (config && config.fixed === false)
+        result.push(unfixGutters.of(true));
     return result;
 }
 const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
@@ -15225,7 +15233,7 @@ function highlightActiveLineGutter() {
 /**
 The default maximum length of a `TreeBuffer` node.
 */
-const DefaultBufferLength = 1024;
+const DefaultBufferLength$1 = 1024;
 let nextPropID$1 = 0;
 class Range {
     constructor(from, to) {
@@ -15238,7 +15246,7 @@ Each [node type](#common.NodeType) or [individual tree](#common.Tree)
 can have metadata associated with it in props. Instances of this
 class represent prop names.
 */
-let NodeProp$1 = class NodeProp {
+class NodeProp$1 {
     /**
     Create a new node prop type.
     */
@@ -15268,7 +15276,7 @@ let NodeProp$1 = class NodeProp {
             return result === undefined ? null : [this, result];
         };
     }
-};
+}
 /**
 Prop that is used to describe matching delimiters. For opening
 delimiters, this holds an array of node names (written as a
@@ -15363,7 +15371,7 @@ const noProps$1 = Object.create(null);
 /**
 Each node in a syntax tree has a node type associated with it.
 */
-let NodeType$1 = class NodeType {
+class NodeType$1 {
     /**
     @internal
     */
@@ -15400,7 +15408,7 @@ let NodeType$1 = class NodeType {
         let props = spec.props && spec.props.length ? Object.create(null) : noProps$1;
         let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |
             (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);
-        let type = new NodeType(spec.name || "", props, spec.id, flags);
+        let type = new NodeType$1(spec.name || "", props, spec.id, flags);
         if (spec.props)
             for (let src of spec.props) {
                 if (!Array.isArray(src))
@@ -15469,7 +15477,7 @@ let NodeType$1 = class NodeType {
             }
         };
     }
-};
+}
 /**
 An empty dummy node type to use when no actual type is available.
 */
@@ -15520,7 +15528,7 @@ class NodeSet {
         return new NodeSet(newTypes);
     }
 }
-const CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();
+const CachedNode$1 = new WeakMap(), CachedInnerNode$1 = new WeakMap();
 /**
 Options that control iteration. Can be combined with the `|`
 operator to enable multiple ones.
@@ -15569,7 +15577,7 @@ use the [`TreeCursor`](#common.TreeCursor) or
 a view on some part of this data structure, and can be used to
 move around to adjacent nodes.
 */
-class Tree {
+class Tree$1 {
     /**
     Construct a new tree. See also [`Tree.build`](#common.Tree^build).
     */
@@ -15635,7 +15643,7 @@ class Tree {
     nodes the cursor visits.
     */
     cursor(mode = 0) {
-        return new TreeCursor(this.topNode, mode);
+        return new TreeCursor$1(this.topNode, mode);
     }
     /**
     Get a [tree cursor](#common.TreeCursor) pointing into this tree
@@ -15643,10 +15651,10 @@ class Tree {
     [`moveTo`](#common.TreeCursor.moveTo).
     */
     cursorAt(pos, side = 0, mode = 0) {
-        let scope = CachedNode.get(this) || this.topNode;
-        let cursor = new TreeCursor(scope);
+        let scope = CachedNode$1.get(this) || this.topNode;
+        let cursor = new TreeCursor$1(scope);
         cursor.moveTo(pos, side);
-        CachedNode.set(this, cursor._tree);
+        CachedNode$1.set(this, cursor._tree);
         return cursor;
     }
     /**
@@ -15654,7 +15662,7 @@ class Tree {
     tree.
     */
     get topNode() {
-        return new TreeNode(this, 0, 0, null);
+        return new TreeNode$1(this, 0, 0, null);
     }
     /**
     Get the [syntax node](#common.SyntaxNode) at the given position.
@@ -15668,8 +15676,8 @@ class Tree {
     [`resolveInner`](#common.Tree.resolveInner) instead.
     */
     resolve(pos, side = 0) {
-        let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
-        CachedNode.set(this, node);
+        let node = resolveNode$1(CachedNode$1.get(this) || this.topNode, pos, side, false);
+        CachedNode$1.set(this, node);
         return node;
     }
     /**
@@ -15680,8 +15688,8 @@ class Tree {
     the host trees).
     */
     resolveInner(pos, side = 0) {
-        let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
-        CachedInnerNode.set(this, node);
+        let node = resolveNode$1(CachedInnerNode$1.get(this) || this.topNode, pos, side, true);
+        CachedInnerNode$1.set(this, node);
         return node;
     }
     /**
@@ -15748,19 +15756,19 @@ class Tree {
     */
     balance(config = {}) {
         return this.children.length <= 8 /* Balance.BranchFactor */ ? this :
-            balanceRange(NodeType$1.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType$1.none, children, positions, length)));
+            balanceRange$1(NodeType$1.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree$1(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree$1(NodeType$1.none, children, positions, length)));
     }
     /**
     Build a tree from a postfix-ordered buffer of node information,
     or a cursor over such a buffer.
     */
-    static build(data) { return buildTree(data); }
+    static build(data) { return buildTree$1(data); }
 }
 /**
 The empty tree
 */
-Tree.empty = new Tree(NodeType$1.none, [], [], 0);
-class FlatBufferCursor {
+Tree$1.empty = new Tree$1(NodeType$1.none, [], [], 0);
+class FlatBufferCursor$1 {
     constructor(buffer, index) {
         this.buffer = buffer;
         this.index = index;
@@ -15771,7 +15779,7 @@ class FlatBufferCursor {
     get size() { return this.buffer[this.index - 1]; }
     get pos() { return this.index; }
     next() { this.index -= 4; }
-    fork() { return new FlatBufferCursor(this.buffer, this.index); }
+    fork() { return new FlatBufferCursor$1(this.buffer, this.index); }
 }
 /**
 Tree buffers contain (type, start, end, endIndex) quads for each
@@ -15779,7 +15787,7 @@ node. In such a buffer, nodes are stored in prefix order (parents
 before children, with the endIndex of the parent indicating which
 children belong to it).
 */
-class TreeBuffer {
+class TreeBuffer$1 {
     /**
     Create a tree buffer.
     */
@@ -15839,7 +15847,7 @@ class TreeBuffer {
     findChild(startIndex, endIndex, dir, pos, side) {
         let { buffer } = this, pick = -1;
         for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
-            if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
+            if (checkSide$1(side, pos, buffer[i + 1], buffer[i + 2])) {
                 pick = i;
                 if (dir > 0)
                     break;
@@ -15860,10 +15868,10 @@ class TreeBuffer {
             copy[j++] = b[i++] - startI;
             len = Math.max(len, to);
         }
-        return new TreeBuffer(copy, len, this.set);
+        return new TreeBuffer$1(copy, len, this.set);
     }
 }
-function checkSide(side, pos, from, to) {
+function checkSide$1(side, pos, from, to) {
     switch (side) {
         case -2 /* Side.Before */: return from < pos;
         case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;
@@ -15873,13 +15881,13 @@ function checkSide(side, pos, from, to) {
         case 4 /* Side.DontCare */: return true;
     }
 }
-function resolveNode(node, pos, side, overlays) {
+function resolveNode$1(node, pos, side, overlays) {
     var _a;
     // Move up to a node that actually holds the position, if possible
     while (node.from == node.to ||
         (side < 1 ? node.from >= pos : node.from > pos) ||
         (side > -1 ? node.to <= pos : node.to < pos)) {
-        let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
+        let parent = !overlays && node instanceof TreeNode$1 && node.index < 0 ? null : node.parent;
         if (!parent)
             return node;
         node = parent;
@@ -15888,7 +15896,7 @@ function resolveNode(node, pos, side, overlays) {
     // Must go up out of overlays when those do not overlap with pos
     if (overlays)
         for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
-            if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
+            if (scan instanceof TreeNode$1 && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
                 node = parent;
         }
     for (;;) {
@@ -15899,22 +15907,22 @@ function resolveNode(node, pos, side, overlays) {
     }
 }
 class BaseNode {
-    cursor(mode = 0) { return new TreeCursor(this, mode); }
+    cursor(mode = 0) { return new TreeCursor$1(this, mode); }
     getChild(type, before = null, after = null) {
-        let r = getChildren(this, type, before, after);
+        let r = getChildren$1(this, type, before, after);
         return r.length ? r[0] : null;
     }
     getChildren(type, before = null, after = null) {
-        return getChildren(this, type, before, after);
+        return getChildren$1(this, type, before, after);
     }
     resolve(pos, side = 0) {
-        return resolveNode(this, pos, side, false);
+        return resolveNode$1(this, pos, side, false);
     }
     resolveInner(pos, side = 0) {
-        return resolveNode(this, pos, side, true);
+        return resolveNode$1(this, pos, side, true);
     }
     matchContext(context) {
-        return matchNodeContext(this.parent, context);
+        return matchNodeContext$1(this.parent, context);
     }
     enterUnfinishedNodesBefore(pos) {
         let scan = this.childBefore(pos), node = this;
@@ -15935,7 +15943,7 @@ class BaseNode {
     get node() { return this; }
     get next() { return this.parent; }
 }
-class TreeNode extends BaseNode {
+class TreeNode$1 extends BaseNode {
     constructor(_tree, from, 
     // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
     index, _parent) {
@@ -15952,20 +15960,20 @@ class TreeNode extends BaseNode {
         for (let parent = this;;) {
             for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
                 let next = children[i], start = positions[i] + parent.from;
-                if (!checkSide(side, pos, start, start + next.length))
+                if (!checkSide$1(side, pos, start, start + next.length))
                     continue;
-                if (next instanceof TreeBuffer) {
+                if (next instanceof TreeBuffer$1) {
                     if (mode & IterMode$1.ExcludeBuffers)
                         continue;
                     let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
                     if (index > -1)
-                        return new BufferNode(new BufferContext(parent, next, i, start), null, index);
+                        return new BufferNode$1(new BufferContext$1(parent, next, i, start), null, index);
                 }
-                else if ((mode & IterMode$1.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {
+                else if ((mode & IterMode$1.IncludeAnonymous) || (!next.type.isAnonymous || hasChild$1(next))) {
                     let mounted;
                     if (!(mode & IterMode$1.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
-                        return new TreeNode(mounted.tree, start, i, parent);
-                    let inner = new TreeNode(next, start, i, parent);
+                        return new TreeNode$1(mounted.tree, start, i, parent);
+                    let inner = new TreeNode$1(next, start, i, parent);
                     return (mode & IterMode$1.IncludeAnonymous) || !inner.type.isAnonymous ? inner
                         : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
                 }
@@ -15992,7 +16000,7 @@ class TreeNode extends BaseNode {
             for (let { from, to } of mounted.overlay) {
                 if ((side > 0 ? from <= rPos : from < rPos) &&
                     (side < 0 ? to >= rPos : to > rPos))
-                    return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
+                    return new TreeNode$1(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
             }
         }
         return this.nextChild(0, 1, pos, side, mode);
@@ -16019,7 +16027,7 @@ class TreeNode extends BaseNode {
     */
     toString() { return this._tree.toString(); }
 }
-function getChildren(node, type, before, after) {
+function getChildren$1(node, type, before, after) {
     let cur = node.cursor(), result = [];
     if (!cur.firstChild())
         return result;
@@ -16038,7 +16046,7 @@ function getChildren(node, type, before, after) {
             return after == null ? result : [];
     }
 }
-function matchNodeContext(node, context, i = context.length - 1) {
+function matchNodeContext$1(node, context, i = context.length - 1) {
     for (let p = node; i >= 0; p = p.parent) {
         if (!p)
             return false;
@@ -16050,7 +16058,7 @@ function matchNodeContext(node, context, i = context.length - 1) {
     }
     return true;
 }
-class BufferContext {
+class BufferContext$1 {
     constructor(parent, buffer, index, start) {
         this.parent = parent;
         this.buffer = buffer;
@@ -16058,7 +16066,7 @@ class BufferContext {
         this.start = start;
     }
 }
-class BufferNode extends BaseNode {
+class BufferNode$1 extends BaseNode {
     get name() { return this.type.name; }
     get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
     get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
@@ -16072,7 +16080,7 @@ class BufferNode extends BaseNode {
     child(dir, pos, side) {
         let { buffer } = this.context;
         let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
-        return index < 0 ? null : new BufferNode(this.context, this, index);
+        return index < 0 ? null : new BufferNode$1(this.context, this, index);
     }
     get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }
     get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }
@@ -16083,7 +16091,7 @@ class BufferNode extends BaseNode {
             return null;
         let { buffer } = this.context;
         let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
-        return index < 0 ? null : new BufferNode(this.context, this, index);
+        return index < 0 ? null : new BufferNode$1(this.context, this, index);
     }
     get parent() {
         return this._parent || this.context.parent.nextSignificantParent();
@@ -16095,7 +16103,7 @@ class BufferNode extends BaseNode {
         let { buffer } = this.context;
         let after = buffer.buffer[this.index + 3];
         if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
-            return new BufferNode(this.context, this._parent, after);
+            return new BufferNode$1(this.context, this._parent, after);
         return this.externalSibling(1);
     }
     get prevSibling() {
@@ -16103,7 +16111,7 @@ class BufferNode extends BaseNode {
         let parentStart = this._parent ? this._parent.index + 4 : 0;
         if (this.index == parentStart)
             return this.externalSibling(-1);
-        return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
+        return new BufferNode$1(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
     }
     get tree() { return null; }
     toTree() {
@@ -16115,7 +16123,7 @@ class BufferNode extends BaseNode {
             children.push(buffer.slice(startI, endI, from));
             positions.push(0);
         }
-        return new Tree(this.type, children, positions, this.to - this.from);
+        return new Tree$1(this.type, children, positions, this.to - this.from);
     }
     /**
     @internal
@@ -16133,7 +16141,7 @@ function iterStack(heads) {
             pick = i;
         }
     }
-    let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
+    let next = picked instanceof TreeNode$1 && picked.index < 0 ? null : picked.parent;
     let newHeads = heads.slice();
     if (next)
         newHeads[pick] = next;
@@ -16150,7 +16158,7 @@ class StackIterator {
 }
 function stackIterator(tree, pos, side) {
     let inner = tree.resolveInner(pos, side), layers = null;
-    for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {
+    for (let scan = inner instanceof TreeNode$1 ? inner : inner.context.parent; scan; scan = scan.parent) {
         if (scan.index < 0) { // This is an overlay root
             let parent = scan.parent;
             (layers || (layers = [inner])).push(parent.resolve(pos, side));
@@ -16160,8 +16168,8 @@ function stackIterator(tree, pos, side) {
             let mount = MountedTree.get(scan.tree);
             // Relevant overlay branching off
             if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
-                let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
-                (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
+                let root = new TreeNode$1(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
+                (layers || (layers = [inner])).push(resolveNode$1(root, pos, side, false));
             }
         }
     }
@@ -16171,7 +16179,7 @@ function stackIterator(tree, pos, side) {
 A tree cursor object focuses on a given node in a syntax tree, and
 allows you to move to adjacent nodes.
 */
-class TreeCursor {
+class TreeCursor$1 {
     /**
     Shorthand for `.type.name`.
     */
@@ -16195,7 +16203,7 @@ class TreeCursor {
         */
         this.index = 0;
         this.bufferNode = null;
-        if (node instanceof TreeNode) {
+        if (node instanceof TreeNode$1) {
             this.yieldNode(node);
         }
         else {
@@ -16230,7 +16238,7 @@ class TreeCursor {
     yield(node) {
         if (!node)
             return false;
-        if (node instanceof TreeNode) {
+        if (node instanceof TreeNode$1) {
             this.buffer = null;
             return this.yieldNode(node);
         }
@@ -16348,9 +16356,9 @@ class TreeCursor {
                 for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
                     let child = parent._tree.children[i];
                     if ((this.mode & IterMode$1.IncludeAnonymous) ||
-                        child instanceof TreeBuffer ||
+                        child instanceof TreeBuffer$1 ||
                         !child.type.isAnonymous ||
-                        hasChild(child))
+                        hasChild$1(child))
                         return false;
                 }
         }
@@ -16419,8 +16427,8 @@ class TreeCursor {
             }
         }
         for (let i = depth; i < this.stack.length; i++)
-            result = new BufferNode(this.buffer, result, this.stack[i]);
-        return this.bufferNode = new BufferNode(this.buffer, result, this.index);
+            result = new BufferNode$1(this.buffer, result, this.stack[i]);
+        return this.bufferNode = new BufferNode$1(this.buffer, result, this.index);
     }
     /**
     Get the [tree](#common.Tree) that represents the current node, if
@@ -16468,11 +16476,11 @@ class TreeCursor {
     */
     matchContext(context) {
         if (!this.buffer)
-            return matchNodeContext(this.node.parent, context);
+            return matchNodeContext$1(this.node.parent, context);
         let { buffer } = this.buffer, { types } = buffer.set;
         for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
             if (d < 0)
-                return matchNodeContext(this._tree, context, i);
+                return matchNodeContext$1(this._tree, context, i);
             let type = types[buffer.buffer[this.stack[d]]];
             if (!type.isAnonymous) {
                 if (context[i] && context[i] != type.name)
@@ -16483,13 +16491,13 @@ class TreeCursor {
         return true;
     }
 }
-function hasChild(tree) {
-    return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
+function hasChild$1(tree) {
+    return tree.children.some(ch => ch instanceof TreeBuffer$1 || !ch.type.isAnonymous || hasChild$1(ch));
 }
-function buildTree(data) {
+function buildTree$1(data) {
     var _a;
-    let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
-    let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
+    let { buffer, nodeSet, maxBufferLength = DefaultBufferLength$1, reused = [], minRepeatType = nodeSet.types.length } = data;
+    let cursor = Array.isArray(buffer) ? new FlatBufferCursor$1(buffer, buffer.length) : buffer;
     let types = nodeSet.types;
     let contextHash = 0, lookAhead = 0;
     function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
@@ -16523,7 +16531,7 @@ function buildTree(data) {
             let endPos = cursor.pos - buffer.size, index = data.length;
             while (cursor.pos > endPos)
                 index = copyToBuffer(buffer.start, data, index);
-            node = new TreeBuffer(data, end - buffer.start, nodeSet);
+            node = new TreeBuffer$1(data, end - buffer.start, nodeSet);
             startPos = buffer.start - parentStart;
         }
         else { // Make it a node
@@ -16554,7 +16562,7 @@ function buildTree(data) {
             localPositions.reverse();
             if (localInRepeat > -1 && lastGroup > 0) {
                 let make = makeBalanced(type, contextAtStart);
-                node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
+                node = balanceRange$1(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
             }
             else {
                 node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
@@ -16591,14 +16599,14 @@ function buildTree(data) {
                 buffer[j++] = nodes[i + 2] - start;
                 buffer[j++] = j;
             }
-            children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));
+            children.push(new TreeBuffer$1(buffer, nodes[2] - start, nodeSet));
             positions.push(start - parentStart);
         }
     }
     function makeBalanced(type, contextHash) {
         return (children, positions, length) => {
             let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
-            if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
+            if (lastI >= 0 && (last = children[lastI]) instanceof Tree$1) {
                 if (!lastI && last.type == type && last.length == length)
                     return last;
                 if (lookAheadProp = last.prop(NodeProp$1.lookAhead))
@@ -16625,7 +16633,7 @@ function buildTree(data) {
             let pair = [NodeProp$1.lookAhead, lookAhead];
             props = props ? [pair].concat(props) : [pair];
         }
-        return new Tree(type, children, positions, length, props);
+        return new Tree$1(type, children, positions, length, props);
     }
     function findBufferSize(maxSize, inRepeat) {
         // Scan through the buffer to find previous siblings that fit
@@ -16707,27 +16715,27 @@ function buildTree(data) {
     while (cursor.pos > 0)
         takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
     let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
-    return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
+    return new Tree$1(types[data.topID], children.reverse(), positions.reverse(), length);
 }
-const nodeSizeCache = new WeakMap;
-function nodeSize(balanceType, node) {
-    if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
+const nodeSizeCache$1 = new WeakMap;
+function nodeSize$1(balanceType, node) {
+    if (!balanceType.isAnonymous || node instanceof TreeBuffer$1 || node.type != balanceType)
         return 1;
-    let size = nodeSizeCache.get(node);
+    let size = nodeSizeCache$1.get(node);
     if (size == null) {
         size = 1;
         for (let child of node.children) {
-            if (child.type != balanceType || !(child instanceof Tree)) {
+            if (child.type != balanceType || !(child instanceof Tree$1)) {
                 size = 1;
                 break;
             }
-            size += nodeSize(balanceType, child);
+            size += nodeSize$1(balanceType, child);
         }
-        nodeSizeCache.set(node, size);
+        nodeSizeCache$1.set(node, size);
     }
     return size;
 }
-function balanceRange(
+function balanceRange$1(
 // The type the balanced tree's inner nodes.
 balanceType, 
 // The direct children and their positions
@@ -16744,15 +16752,15 @@ mkTop,
 mkTree) {
     let total = 0;
     for (let i = from; i < to; i++)
-        total += nodeSize(balanceType, children[i]);
+        total += nodeSize$1(balanceType, children[i]);
     let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);
     let localChildren = [], localPositions = [];
     function divide(children, positions, from, to, offset) {
         for (let i = from; i < to;) {
-            let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
+            let groupFrom = i, groupStart = positions[i], groupSize = nodeSize$1(balanceType, children[i]);
             i++;
             for (; i < to; i++) {
-                let nextSize = nodeSize(balanceType, children[i]);
+                let nextSize = nodeSize$1(balanceType, children[i]);
                 if (groupSize + nextSize >= maxChild)
                     break;
                 groupSize += nextSize;
@@ -16767,7 +16775,7 @@ mkTree) {
             }
             else {
                 let length = positions[i - 1] + children[i - 1].length - groupStart;
-                localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
+                localChildren.push(balanceRange$1(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
             }
             localPositions.push(groupStart + offset - start);
         }
@@ -16798,17 +16806,17 @@ class NodeWeakMap {
     Set the value for this syntax node.
     */
     set(node, value) {
-        if (node instanceof BufferNode)
+        if (node instanceof BufferNode$1)
             this.setBuffer(node.context.buffer, node.index, value);
-        else if (node instanceof TreeNode)
+        else if (node instanceof TreeNode$1)
             this.map.set(node.tree, value);
     }
     /**
     Retrieve value for this syntax node, if it exists in the map.
     */
     get(node) {
-        return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index)
-            : node instanceof TreeNode ? this.map.get(node.tree) : undefined;
+        return node instanceof BufferNode$1 ? this.getBuffer(node.context.buffer, node.index)
+            : node instanceof TreeNode$1 ? this.map.get(node.tree) : undefined;
     }
     /**
     Set the value for the node that a cursor currently points to.
@@ -17968,7 +17976,7 @@ class Language {
             }
             for (let i = 0; i < tree.children.length; i++) {
                 let ch = tree.children[i];
-                if (ch instanceof Tree)
+                if (ch instanceof Tree$1)
                     explore(ch, tree.positions[i] + from);
             }
         };
@@ -18030,7 +18038,7 @@ language available.
 */
 function syntaxTree(state) {
     let field = state.field(Language.state, false);
-    return field ? field.tree : Tree.empty;
+    return field ? field.tree : Tree$1.empty;
 }
 /**
 Lezer-style
@@ -18125,7 +18133,7 @@ class ParseContext {
     @internal
     */
     static create(parser, state, viewport) {
-        return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
+        return new ParseContext(parser, state, [], Tree$1.empty, 0, viewport, [], null);
     }
     startParse() {
         return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
@@ -18136,7 +18144,7 @@ class ParseContext {
     work(until, upto) {
         if (upto != null && upto >= this.state.doc.length)
             upto = undefined;
-        if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
+        if (this.tree != Tree$1.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
             this.takeTree();
             return true;
         }
@@ -18208,7 +18216,7 @@ class ParseContext {
             let ranges = [];
             changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
             fragments = TreeFragment.applyChanges(fragments, ranges);
-            tree = Tree.empty;
+            tree = Tree$1.empty;
             treeLen = 0;
             viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
             if (this.skipped.length) {
@@ -18283,7 +18291,7 @@ class ParseContext {
                                 cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
                         }
                         this.parsedPos = to;
-                        return new Tree(NodeType$1.none, [], [], to - from);
+                        return new Tree$1(NodeType$1.none, [], [], to - from);
                     },
                     stoppedAt: null,
                     stopAt() { }
@@ -19142,6 +19150,8 @@ Create an extension that configures code folding.
 */
 function codeFolding(config) {
     let result = [foldState, baseTheme$1$2];
+    if (config)
+        result.push(foldConfig.of(config));
     return result;
 }
 function widgetToDOM(view, prepared) {
@@ -19435,7 +19445,7 @@ const defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([
         color: "#f00" }
 ]);
 
-const baseTheme$3 = /*@__PURE__*/EditorView.baseTheme({
+const baseTheme$4 = /*@__PURE__*/EditorView.baseTheme({
     "&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
     "&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
 });
@@ -19483,7 +19493,7 @@ const bracketMatchingState = /*@__PURE__*/StateField.define({
 });
 const bracketMatchingUnique = [
     bracketMatchingState,
-    baseTheme$3
+    baseTheme$4
 ];
 /**
 Create an extension that enables bracket matching. Whenever the
@@ -19671,6 +19681,7 @@ function createTokenType(extra, tagStr) {
 // FIXME profile adding a per-Tree TreeNode cache, validating it by
 // parent pointer
 /// The default maximum length of a `TreeBuffer` node (1024).
+const DefaultBufferLength = 1024;
 let nextPropID = 0;
 /// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
 /// can have metadata associated with it in props. Instances of this
@@ -19812,6 +19823,7 @@ class NodeType {
 }
 /// An empty dummy node type to use when no actual type is available.
 NodeType.none = new NodeType("", Object.create(null), 0, 8 /* Anonymous */);
+const CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();
 /// Options that control iteration. Can be combined with the `|`
 /// operator to enable multiple ones.
 var IterMode;
@@ -19834,553 +19846,1574 @@ var IterMode;
     /// position.
     IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
 })(IterMode || (IterMode = {}));
-new NodeProp({ perNode: true });
-
-/**
-Comment or uncomment the current selection. Will use line comments
-if available, otherwise falling back to block comments.
-*/
-const toggleComment = target => {
-    let config = getConfig(target.state);
-    return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
-};
-function command(f, option) {
-    return ({ state, dispatch }) => {
-        if (state.readOnly)
-            return false;
-        let tr = f(option, state);
-        if (!tr)
-            return false;
-        dispatch(state.update(tr));
-        return true;
-    };
-}
-/**
-Comment or uncomment the current selection using line comments.
-The line comment syntax is taken from the
-[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
-data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
-*/
-const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* Toggle */);
-/**
-Comment or uncomment the current selection using block comments.
-The block comment syntax is taken from the
-[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
-data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
-*/
-const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* Toggle */);
-/**
-Comment or uncomment the lines around the current selection using
-block comments.
-*/
-const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
-function getConfig(state, pos = state.selection.main.head) {
-    let data = state.languageDataAt("commentTokens", pos);
-    return data.length ? data[0] : {};
-}
-const SearchMargin = 50;
-/**
-Determines if the given range is block-commented in the given
-state.
-*/
-function findBlockComment(state, { open, close }, from, to) {
-    let textBefore = state.sliceDoc(from - SearchMargin, from);
-    let textAfter = state.sliceDoc(to, to + SearchMargin);
-    let spaceBefore = /\s*$/.exec(textBefore)[0].length, spaceAfter = /^\s*/.exec(textAfter)[0].length;
-    let beforeOff = textBefore.length - spaceBefore;
-    if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&
-        textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {
-        return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },
-            close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };
+/// A piece of syntax tree. There are two ways to approach these
+/// trees: the way they are actually stored in memory, and the
+/// convenient way.
+///
+/// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
+/// objects. By packing detail information into `TreeBuffer` leaf
+/// nodes, the representation is made a lot more memory-efficient.
+///
+/// However, when you want to actually work with tree nodes, this
+/// representation is very awkward, so most client code will want to
+/// use the [`TreeCursor`](#common.TreeCursor) or
+/// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
+/// a view on some part of this data structure, and can be used to
+/// move around to adjacent nodes.
+class Tree {
+    /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
+    constructor(
+    /// The type of the top node.
+    type, 
+    /// This node's child nodes.
+    children, 
+    /// The positions (offsets relative to the start of this tree) of
+    /// the children.
+    positions, 
+    /// The total length of this tree
+    length, 
+    /// Per-node [node props](#common.NodeProp) to associate with this node.
+    props) {
+        this.type = type;
+        this.children = children;
+        this.positions = positions;
+        this.length = length;
+        /// @internal
+        this.props = null;
+        if (props && props.length) {
+            this.props = Object.create(null);
+            for (let [prop, value] of props)
+                this.props[typeof prop == "number" ? prop : prop.id] = value;
+        }
     }
-    let startText, endText;
-    if (to - from <= 2 * SearchMargin) {
-        startText = endText = state.sliceDoc(from, to);
+    /// @internal
+    toString() {
+        let mounted = this.prop(NodeProp.mounted);
+        if (mounted && !mounted.overlay)
+            return mounted.tree.toString();
+        let children = "";
+        for (let ch of this.children) {
+            let str = ch.toString();
+            if (str) {
+                if (children)
+                    children += ",";
+                children += str;
+            }
+        }
+        return !this.type.name ? children :
+            (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
+                (children.length ? "(" + children + ")" : "");
     }
-    else {
-        startText = state.sliceDoc(from, from + SearchMargin);
-        endText = state.sliceDoc(to - SearchMargin, to);
+    /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
+    /// the tree. Mode can be used to [control](#common.IterMode) which
+    /// nodes the cursor visits.
+    cursor(mode = 0) {
+        return new TreeCursor(this.topNode, mode);
     }
-    let startSpace = /^\s*/.exec(startText)[0].length, endSpace = /\s*$/.exec(endText)[0].length;
-    let endOff = endText.length - endSpace - close.length;
-    if (startText.slice(startSpace, startSpace + open.length) == open &&
-        endText.slice(endOff, endOff + close.length) == close) {
-        return { open: { pos: from + startSpace + open.length,
-                margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },
-            close: { pos: to - endSpace - close.length,
-                margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };
+    /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
+    /// at the given position and side (see
+    /// [`moveTo`](#common.TreeCursor.moveTo).
+    cursorAt(pos, side = 0, mode = 0) {
+        let scope = CachedNode.get(this) || this.topNode;
+        let cursor = new TreeCursor(scope);
+        cursor.moveTo(pos, side);
+        CachedNode.set(this, cursor._tree);
+        return cursor;
     }
-    return null;
-}
-function selectedLineRanges(state) {
-    let ranges = [];
-    for (let r of state.selection.ranges) {
-        let fromLine = state.doc.lineAt(r.from);
-        let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
-        let last = ranges.length - 1;
-        if (last >= 0 && ranges[last].to > fromLine.from)
-            ranges[last].to = toLine.to;
-        else
-            ranges.push({ from: fromLine.from, to: toLine.to });
+    /// Get a [syntax node](#common.SyntaxNode) object for the top of the
+    /// tree.
+    get topNode() {
+        return new TreeNode(this, 0, 0, null);
     }
-    return ranges;
-}
-// Performs toggle, comment and uncomment of block comments in
-// languages that support them.
-function changeBlockComment(option, state, ranges = state.selection.ranges) {
-    let tokens = ranges.map(r => getConfig(state, r.from).block);
-    if (!tokens.every(c => c))
-        return null;
-    let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
-    if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
-        return { changes: state.changes(ranges.map((range, i) => {
-                if (comments[i])
-                    return [];
-                return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
-            })) };
+    /// Get the [syntax node](#common.SyntaxNode) at the given position.
+    /// If `side` is -1, this will move into nodes that end at the
+    /// position. If 1, it'll move into nodes that start at the
+    /// position. With 0, it'll only enter nodes that cover the position
+    /// from both sides.
+    resolve(pos, side = 0) {
+        let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
+        CachedNode.set(this, node);
+        return node;
     }
-    else if (option != 1 /* Comment */ && comments.some(c => c)) {
-        let changes = [];
-        for (let i = 0, comment; i < comments.length; i++)
-            if (comment = comments[i]) {
-                let token = tokens[i], { open, close } = comment;
-                changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });
-            }
-        return { changes };
+    /// Like [`resolve`](#common.Tree.resolve), but will enter
+    /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
+    /// pointing into the innermost overlaid tree at the given position
+    /// (with parent links going through all parent structure, including
+    /// the host trees).
+    resolveInner(pos, side = 0) {
+        let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
+        CachedInnerNode.set(this, node);
+        return node;
     }
-    return null;
-}
-// Performs toggle, comment and uncomment of line comments.
-function changeLineComment(option, state, ranges = state.selection.ranges) {
-    let lines = [];
-    let prevLine = -1;
-    for (let { from, to } of ranges) {
-        let startI = lines.length, minIndent = 1e9;
-        for (let pos = from; pos <= to;) {
-            let line = state.doc.lineAt(pos);
-            if (line.from > prevLine && (from == to || to > line.from)) {
-                prevLine = line.from;
-                let token = getConfig(state, pos).line;
-                if (!token)
+    /// Iterate over the tree and its children, calling `enter` for any
+    /// node that touches the `from`/`to` region (if given) before
+    /// running over such a node's children, and `leave` (if given) when
+    /// leaving the node. When `enter` returns `false`, that node will
+    /// not have its children iterated over (or `leave` called).
+    iterate(spec) {
+        let { enter, leave, from = 0, to = this.length } = spec;
+        for (let c = this.cursor((spec.mode || 0) | IterMode.IncludeAnonymous);;) {
+            let entered = false;
+            if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
+                if (c.firstChild())
                     continue;
-                let indent = /^\s*/.exec(line.text)[0].length;
-                let empty = indent == line.length;
-                let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
-                if (indent < line.text.length && indent < minIndent)
-                    minIndent = indent;
-                lines.push({ line, comment, token, indent, empty, single: false });
+                entered = true;
+            }
+            for (;;) {
+                if (entered && leave && !c.type.isAnonymous)
+                    leave(c);
+                if (c.nextSibling())
+                    break;
+                if (!c.parent())
+                    return;
+                entered = true;
             }
-            pos = line.to + 1;
         }
-        if (minIndent < 1e9)
-            for (let i = startI; i < lines.length; i++)
-                if (lines[i].indent < lines[i].line.text.length)
-                    lines[i].indent = minIndent;
-        if (lines.length == startI + 1)
-            lines[startI].single = true;
     }
-    if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
-        let changes = [];
-        for (let { line, token, indent, empty, single } of lines)
-            if (single || !empty)
-                changes.push({ from: line.from + indent, insert: token + " " });
-        let changeSet = state.changes(changes);
-        return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
+    /// Get the value of the given [node prop](#common.NodeProp) for this
+    /// node. Works with both per-node and per-type props.
+    prop(prop) {
+        return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
     }
-    else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
-        let changes = [];
-        for (let { line, comment, token } of lines)
-            if (comment >= 0) {
-                let from = line.from + comment, to = from + token.length;
-                if (line.text[to - line.from] == " ")
-                    to++;
-                changes.push({ from, to });
-            }
-        return { changes };
+    /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
+    /// format that can be passed to the [`Tree`](#common.Tree)
+    /// constructor.
+    get propValues() {
+        let result = [];
+        if (this.props)
+            for (let id in this.props)
+                result.push([+id, this.props[id]]);
+        return result;
     }
-    return null;
+    /// Balance the direct children of this tree, producing a copy of
+    /// which may have children grouped into subtrees with type
+    /// [`NodeType.none`](#common.NodeType^none).
+    balance(config = {}) {
+        return this.children.length <= 8 /* BranchFactor */ ? this :
+            balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
+    }
+    /// Build a tree from a postfix-ordered buffer of node information,
+    /// or a cursor over such a buffer.
+    static build(data) { return buildTree(data); }
 }
-
-const fromHistory = /*@__PURE__*/Annotation.define();
-/**
-Transaction annotation that will prevent that transaction from
-being combined with other transactions in the undo history. Given
-`"before"`, it'll prevent merging with previous transactions. With
-`"after"`, subsequent transactions won't be combined with this
-one. With `"full"`, the transaction is isolated on both sides.
-*/
-const isolateHistory = /*@__PURE__*/Annotation.define();
-/**
-This facet provides a way to register functions that, given a
-transaction, provide a set of effects that the history should
-store when inverting the transaction. This can be used to
-integrate some kinds of effects in the history, so that they can
-be undone (and redone again).
-*/
-const invertedEffects = /*@__PURE__*/Facet.define();
-const historyConfig = /*@__PURE__*/Facet.define({
-    combine(configs) {
-        return combineConfig(configs, {
-            minDepth: 100,
-            newGroupDelay: 500
-        }, { minDepth: Math.max, newGroupDelay: Math.min });
+/// The empty tree
+Tree.empty = new Tree(NodeType.none, [], [], 0);
+class FlatBufferCursor {
+    constructor(buffer, index) {
+        this.buffer = buffer;
+        this.index = index;
     }
-});
-function changeEnd(changes) {
-    let end = 0;
-    changes.iterChangedRanges((_, to) => end = to);
-    return end;
+    get id() { return this.buffer[this.index - 4]; }
+    get start() { return this.buffer[this.index - 3]; }
+    get end() { return this.buffer[this.index - 2]; }
+    get size() { return this.buffer[this.index - 1]; }
+    get pos() { return this.index; }
+    next() { this.index -= 4; }
+    fork() { return new FlatBufferCursor(this.buffer, this.index); }
 }
-const historyField_ = /*@__PURE__*/StateField.define({
-    create() {
-        return HistoryState.empty;
-    },
-    update(state, tr) {
-        let config = tr.state.facet(historyConfig);
-        let fromHist = tr.annotation(fromHistory);
-        if (fromHist) {
-            let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;
-            let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
-            let other = from == 0 /* Done */ ? state.undone : state.done;
-            if (item)
-                other = updateBranch(other, other.length, config.minDepth, item);
-            else
-                other = addSelection(other, tr.startState.selection);
-            return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
+/// Tree buffers contain (type, start, end, endIndex) quads for each
+/// node. In such a buffer, nodes are stored in prefix order (parents
+/// before children, with the endIndex of the parent indicating which
+/// children belong to it)
+class TreeBuffer {
+    /// Create a tree buffer.
+    constructor(
+    /// The buffer's content.
+    buffer, 
+    /// The total length of the group of nodes in the buffer.
+    length, 
+    /// The node set used in this buffer.
+    set) {
+        this.buffer = buffer;
+        this.length = length;
+        this.set = set;
+    }
+    /// @internal
+    get type() { return NodeType.none; }
+    /// @internal
+    toString() {
+        let result = [];
+        for (let index = 0; index < this.buffer.length;) {
+            result.push(this.childString(index));
+            index = this.buffer[index + 3];
         }
-        let isolate = tr.annotation(isolateHistory);
-        if (isolate == "full" || isolate == "before")
-            state = state.isolate();
-        if (tr.annotation(Transaction.addToHistory) === false)
-            return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;
-        let event = HistEvent.fromTransaction(tr);
-        let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent);
-        if (event)
-            state = state.addChanges(event, time, userEvent, config.newGroupDelay, config.minDepth);
-        else if (tr.selection)
-            state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
-        if (isolate == "full" || isolate == "after")
-            state = state.isolate();
-        return state;
-    },
-    toJSON(value) {
-        return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };
-    },
-    fromJSON(json) {
-        return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));
+        return result.join(",");
     }
-});
-/**
-Create a history extension with the given configuration.
-*/
-function history(config = {}) {
-    return [
-        historyField_,
-        historyConfig.of(config),
-        EditorView.domEventHandlers({
-            beforeinput(e, view) {
-                let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null;
-                if (!command)
-                    return false;
-                e.preventDefault();
-                return command(view);
+    /// @internal
+    childString(index) {
+        let id = this.buffer[index], endIndex = this.buffer[index + 3];
+        let type = this.set.types[id], result = type.name;
+        if (/\W/.test(result) && !type.isError)
+            result = JSON.stringify(result);
+        index += 4;
+        if (endIndex == index)
+            return result;
+        let children = [];
+        while (index < endIndex) {
+            children.push(this.childString(index));
+            index = this.buffer[index + 3];
+        }
+        return result + "(" + children.join(",") + ")";
+    }
+    /// @internal
+    findChild(startIndex, endIndex, dir, pos, side) {
+        let { buffer } = this, pick = -1;
+        for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
+            if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
+                pick = i;
+                if (dir > 0)
+                    break;
             }
-        })
-    ];
+        }
+        return pick;
+    }
+    /// @internal
+    slice(startI, endI, from, to) {
+        let b = this.buffer;
+        let copy = new Uint16Array(endI - startI);
+        for (let i = startI, j = 0; i < endI;) {
+            copy[j++] = b[i++];
+            copy[j++] = b[i++] - from;
+            copy[j++] = b[i++] - from;
+            copy[j++] = b[i++] - startI;
+        }
+        return new TreeBuffer(copy, to - from, this.set);
+    }
 }
-function cmd(side, selection) {
-    return function ({ state, dispatch }) {
-        if (!selection && state.readOnly)
-            return false;
-        let historyState = state.field(historyField_, false);
-        if (!historyState)
-            return false;
-        let tr = historyState.pop(side, state, selection);
-        if (!tr)
-            return false;
-        dispatch(tr);
-        return true;
-    };
+function checkSide(side, pos, from, to) {
+    switch (side) {
+        case -2 /* Before */: return from < pos;
+        case -1 /* AtOrBefore */: return to >= pos && from < pos;
+        case 0 /* Around */: return from < pos && to > pos;
+        case 1 /* AtOrAfter */: return from <= pos && to > pos;
+        case 2 /* After */: return to > pos;
+        case 4 /* DontCare */: return true;
+    }
+}
+function enterUnfinishedNodesBefore(node, pos) {
+    let scan = node.childBefore(pos);
+    while (scan) {
+        let last = scan.lastChild;
+        if (!last || last.to != scan.to)
+            break;
+        if (last.type.isError && last.from == last.to) {
+            node = scan;
+            scan = last.prevSibling;
+        }
+        else {
+            scan = last;
+        }
+    }
+    return node;
 }
-/**
-Undo a single group of history events. Returns false if no group
-was available.
-*/
-const undo = /*@__PURE__*/cmd(0 /* Done */, false);
-/**
-Redo a group of history events. Returns false if no group was
-available.
-*/
-const redo = /*@__PURE__*/cmd(1 /* Undone */, false);
-/**
-Undo a change or selection change.
-*/
-const undoSelection = /*@__PURE__*/cmd(0 /* Done */, true);
-/**
-Redo a change or selection change.
-*/
-const redoSelection = /*@__PURE__*/cmd(1 /* Undone */, true);
-// History events store groups of changes or effects that need to be
-// undone/redone together.
-class HistEvent {
-    constructor(
-    // The changes in this event. Normal events hold at least one
-    // change or effect. But it may be necessary to store selection
-    // events before the first change, in which case a special type of
-    // instance is created which doesn't hold any changes, with
-    // changes == startSelection == undefined
-    changes, 
-    // The effects associated with this event
-    effects, mapped, 
-    // The selection before this event
-    startSelection, 
-    // Stores selection changes after this event, to be used for
-    // selection undo/redo.
-    selectionsAfter) {
-        this.changes = changes;
-        this.effects = effects;
-        this.mapped = mapped;
-        this.startSelection = startSelection;
-        this.selectionsAfter = selectionsAfter;
+function resolveNode(node, pos, side, overlays) {
+    var _a;
+    // Move up to a node that actually holds the position, if possible
+    while (node.from == node.to ||
+        (side < 1 ? node.from >= pos : node.from > pos) ||
+        (side > -1 ? node.to <= pos : node.to < pos)) {
+        let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
+        if (!parent)
+            return node;
+        node = parent;
     }
-    setSelAfter(after) {
-        return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);
+    let mode = overlays ? 0 : IterMode.IgnoreOverlays;
+    // Must go up out of overlays when those do not overlap with pos
+    if (overlays)
+        for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
+            if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
+                node = parent;
+        }
+    for (;;) {
+        let inner = node.enter(pos, side, mode);
+        if (!inner)
+            return node;
+        node = inner;
     }
-    toJSON() {
-        var _a, _b, _c;
-        return {
-            changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),
-            mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),
-            startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),
-            selectionsAfter: this.selectionsAfter.map(s => s.toJSON())
-        };
+}
+class TreeNode {
+    constructor(_tree, from, 
+    // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
+    index, _parent) {
+        this._tree = _tree;
+        this.from = from;
+        this.index = index;
+        this._parent = _parent;
     }
-    static fromJSON(json) {
-        return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.fromJSON));
+    get type() { return this._tree.type; }
+    get name() { return this._tree.type.name; }
+    get to() { return this.from + this._tree.length; }
+    nextChild(i, dir, pos, side, mode = 0) {
+        for (let parent = this;;) {
+            for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
+                let next = children[i], start = positions[i] + parent.from;
+                if (!checkSide(side, pos, start, start + next.length))
+                    continue;
+                if (next instanceof TreeBuffer) {
+                    if (mode & IterMode.ExcludeBuffers)
+                        continue;
+                    let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
+                    if (index > -1)
+                        return new BufferNode(new BufferContext(parent, next, i, start), null, index);
+                }
+                else if ((mode & IterMode.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {
+                    let mounted;
+                    if (!(mode & IterMode.IgnoreMounts) &&
+                        next.props && (mounted = next.prop(NodeProp.mounted)) && !mounted.overlay)
+                        return new TreeNode(mounted.tree, start, i, parent);
+                    let inner = new TreeNode(next, start, i, parent);
+                    return (mode & IterMode.IncludeAnonymous) || !inner.type.isAnonymous ? inner
+                        : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
+                }
+            }
+            if ((mode & IterMode.IncludeAnonymous) || !parent.type.isAnonymous)
+                return null;
+            if (parent.index >= 0)
+                i = parent.index + dir;
+            else
+                i = dir < 0 ? -1 : parent._parent._tree.children.length;
+            parent = parent._parent;
+            if (!parent)
+                return null;
+        }
     }
-    // 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(tr, selection) {
-        let effects = none$1;
-        for (let invert of tr.startState.facet(invertedEffects)) {
-            let result = invert(tr);
-            if (result.length)
-                effects = effects.concat(result);
+    get firstChild() { return this.nextChild(0, 1, 0, 4 /* DontCare */); }
+    get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* DontCare */); }
+    childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* After */); }
+    childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Before */); }
+    enter(pos, side, mode = 0) {
+        let mounted;
+        if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp.mounted)) && mounted.overlay) {
+            let rPos = pos - this.from;
+            for (let { from, to } of mounted.overlay) {
+                if ((side > 0 ? from <= rPos : from < rPos) &&
+                    (side < 0 ? to >= rPos : to > rPos))
+                    return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
+            }
         }
-        if (!effects.length && tr.changes.empty)
-            return null;
-        return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none$1);
+        return this.nextChild(0, 1, pos, side, mode);
     }
-    static selection(selections) {
-        return new HistEvent(undefined, none$1, undefined, undefined, selections);
+    nextSignificantParent() {
+        let val = this;
+        while (val.type.isAnonymous && val._parent)
+            val = val._parent;
+        return val;
     }
-}
-function updateBranch(branch, to, maxLen, newEvent) {
-    let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;
-    let newBranch = branch.slice(start, to);
-    newBranch.push(newEvent);
-    return newBranch;
-}
-function isAdjacent(a, b) {
-    let ranges = [], isAdjacent = false;
-    a.iterChangedRanges((f, t) => ranges.push(f, t));
-    b.iterChangedRanges((_f, _t, f, t) => {
-        for (let i = 0; i < ranges.length;) {
-            let from = ranges[i++], to = ranges[i++];
-            if (t >= from && f <= to)
-                isAdjacent = true;
-        }
-    });
-    return isAdjacent;
-}
-function eqSelectionShape(a, b) {
-    return a.ranges.length == b.ranges.length &&
-        a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;
-}
-function conc(a, b) {
-    return !a.length ? b : !b.length ? a : a.concat(b);
-}
-const none$1 = [];
-const MaxSelectionsPerEvent = 200;
-function addSelection(branch, selection) {
-    if (!branch.length) {
-        return [HistEvent.selection([selection])];
+    get parent() {
+        return this._parent ? this._parent.nextSignificantParent() : null;
     }
-    else {
-        let lastEvent = branch[branch.length - 1];
-        let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));
-        if (sels.length && sels[sels.length - 1].eq(selection))
-            return branch;
-        sels.push(selection);
-        return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));
+    get nextSibling() {
+        return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* DontCare */) : null;
     }
+    get prevSibling() {
+        return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* DontCare */) : null;
+    }
+    cursor(mode = 0) { return new TreeCursor(this, mode); }
+    get tree() { return this._tree; }
+    toTree() { return this._tree; }
+    resolve(pos, side = 0) {
+        return resolveNode(this, pos, side, false);
+    }
+    resolveInner(pos, side = 0) {
+        return resolveNode(this, pos, side, true);
+    }
+    enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore(this, pos); }
+    getChild(type, before = null, after = null) {
+        let r = getChildren(this, type, before, after);
+        return r.length ? r[0] : null;
+    }
+    getChildren(type, before = null, after = null) {
+        return getChildren(this, type, before, after);
+    }
+    /// @internal
+    toString() { return this._tree.toString(); }
+    get node() { return this; }
+    matchContext(context) { return matchNodeContext(this, context); }
 }
-// Assumes the top item has one or more selectionAfter values
-function popSelection(branch) {
-    let last = branch[branch.length - 1];
-    let newBranch = branch.slice();
-    newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));
-    return newBranch;
-}
-// Add a mapping to the top event in the given branch. If this maps
-// away all the changes and effects in that item, drop it and
-// propagate the mapping to the next item.
-function addMappingToBranch(branch, mapping) {
-    if (!branch.length)
-        return branch;
-    let length = branch.length, selections = none$1;
-    while (length) {
-        let event = mapEvent(branch[length - 1], mapping, selections);
-        if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping
-            let result = branch.slice(0, length);
-            result[length - 1] = event;
+function getChildren(node, type, before, after) {
+    let cur = node.cursor(), result = [];
+    if (!cur.firstChild())
+        return result;
+    if (before != null)
+        while (!cur.type.is(before))
+            if (!cur.nextSibling())
+                return result;
+    for (;;) {
+        if (after != null && cur.type.is(after))
             return result;
-        }
-        else { // Drop this event, since there's no changes or effects left
-            mapping = event.mapped;
-            length--;
-            selections = event.selectionsAfter;
+        if (cur.type.is(type))
+            result.push(cur.node);
+        if (!cur.nextSibling())
+            return after == null ? result : [];
+    }
+}
+function matchNodeContext(node, context, i = context.length - 1) {
+    for (let p = node.parent; i >= 0; p = p.parent) {
+        if (!p)
+            return false;
+        if (!p.type.isAnonymous) {
+            if (context[i] && context[i] != p.name)
+                return false;
+            i--;
         }
     }
-    return selections.length ? [HistEvent.selection(selections)] : none$1;
+    return true;
 }
-function mapEvent(event, mapping, extraSelections) {
-    let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none$1, extraSelections);
-    // Change-less events don't store mappings (they are always the last event in a branch)
-    if (!event.changes)
-        return HistEvent.selection(selections);
-    let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);
-    let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;
-    return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);
+class BufferContext {
+    constructor(parent, buffer, index, start) {
+        this.parent = parent;
+        this.buffer = buffer;
+        this.index = index;
+        this.start = start;
+    }
 }
-const joinableUserEvent = /^(input\.type|delete)($|\.)/;
-class HistoryState {
-    constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {
-        this.done = done;
-        this.undone = undone;
-        this.prevTime = prevTime;
-        this.prevUserEvent = prevUserEvent;
+class BufferNode {
+    constructor(context, _parent, index) {
+        this.context = context;
+        this._parent = _parent;
+        this.index = index;
+        this.type = context.buffer.set.types[context.buffer.buffer[index]];
     }
-    isolate() {
-        return this.prevTime ? new HistoryState(this.done, this.undone) : this;
+    get name() { return this.type.name; }
+    get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
+    get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
+    child(dir, pos, side) {
+        let { buffer } = this.context;
+        let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
+        return index < 0 ? null : new BufferNode(this.context, this, index);
     }
-    addChanges(event, time, userEvent, newGroupDelay, maxLen) {
-        let done = this.done, lastEvent = done[done.length - 1];
-        if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&
-            (!userEvent || joinableUserEvent.test(userEvent)) &&
-            ((!lastEvent.selectionsAfter.length &&
-                time - this.prevTime < newGroupDelay &&
-                isAdjacent(lastEvent.changes, event.changes)) ||
-                // For compose (but not compose.start) events, always join with previous event
-                userEvent == "input.type.compose")) {
-            done = updateBranch(done, done.length - 1, maxLen, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none$1));
+    get firstChild() { return this.child(1, 0, 4 /* DontCare */); }
+    get lastChild() { return this.child(-1, 0, 4 /* DontCare */); }
+    childAfter(pos) { return this.child(1, pos, 2 /* After */); }
+    childBefore(pos) { return this.child(-1, pos, -2 /* Before */); }
+    enter(pos, side, mode = 0) {
+        if (mode & IterMode.ExcludeBuffers)
+            return null;
+        let { buffer } = this.context;
+        let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
+        return index < 0 ? null : new BufferNode(this.context, this, index);
+    }
+    get parent() {
+        return this._parent || this.context.parent.nextSignificantParent();
+    }
+    externalSibling(dir) {
+        return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* DontCare */);
+    }
+    get nextSibling() {
+        let { buffer } = this.context;
+        let after = buffer.buffer[this.index + 3];
+        if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
+            return new BufferNode(this.context, this._parent, after);
+        return this.externalSibling(1);
+    }
+    get prevSibling() {
+        let { buffer } = this.context;
+        let parentStart = this._parent ? this._parent.index + 4 : 0;
+        if (this.index == parentStart)
+            return this.externalSibling(-1);
+        return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
+    }
+    cursor(mode = 0) { return new TreeCursor(this, mode); }
+    get tree() { return null; }
+    toTree() {
+        let children = [], positions = [];
+        let { buffer } = this.context;
+        let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
+        if (endI > startI) {
+            let from = buffer.buffer[this.index + 1], to = buffer.buffer[this.index + 2];
+            children.push(buffer.slice(startI, endI, from, to));
+            positions.push(0);
+        }
+        return new Tree(this.type, children, positions, this.to - this.from);
+    }
+    resolve(pos, side = 0) {
+        return resolveNode(this, pos, side, false);
+    }
+    resolveInner(pos, side = 0) {
+        return resolveNode(this, pos, side, true);
+    }
+    enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore(this, pos); }
+    /// @internal
+    toString() { return this.context.buffer.childString(this.index); }
+    getChild(type, before = null, after = null) {
+        let r = getChildren(this, type, before, after);
+        return r.length ? r[0] : null;
+    }
+    getChildren(type, before = null, after = null) {
+        return getChildren(this, type, before, after);
+    }
+    get node() { return this; }
+    matchContext(context) { return matchNodeContext(this, context); }
+}
+/// A tree cursor object focuses on a given node in a syntax tree, and
+/// allows you to move to adjacent nodes.
+class TreeCursor {
+    /// @internal
+    constructor(node, 
+    /// @internal
+    mode = 0) {
+        this.mode = mode;
+        /// @internal
+        this.buffer = null;
+        this.stack = [];
+        /// @internal
+        this.index = 0;
+        this.bufferNode = null;
+        if (node instanceof TreeNode) {
+            this.yieldNode(node);
         }
         else {
-            done = updateBranch(done, done.length, maxLen, event);
+            this._tree = node.context.parent;
+            this.buffer = node.context;
+            for (let n = node._parent; n; n = n._parent)
+                this.stack.unshift(n.index);
+            this.bufferNode = node;
+            this.yieldBuf(node.index);
         }
-        return new HistoryState(done, none$1, time, userEvent);
     }
-    addSelection(selection, time, userEvent, newGroupDelay) {
-        let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none$1;
-        if (last.length > 0 &&
-            time - this.prevTime < newGroupDelay &&
-            userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) &&
-            eqSelectionShape(last[last.length - 1], selection))
-            return this;
-        return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);
+    /// Shorthand for `.type.name`.
+    get name() { return this.type.name; }
+    yieldNode(node) {
+        if (!node)
+            return false;
+        this._tree = node;
+        this.type = node.type;
+        this.from = node.from;
+        this.to = node.to;
+        return true;
     }
-    addMapping(mapping) {
-        return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
+    yieldBuf(index, type) {
+        this.index = index;
+        let { start, buffer } = this.buffer;
+        this.type = type || buffer.set.types[buffer.buffer[index]];
+        this.from = start + buffer.buffer[index + 1];
+        this.to = start + buffer.buffer[index + 2];
+        return true;
     }
-    pop(side, state, selection) {
-        let branch = side == 0 /* Done */ ? this.done : this.undone;
-        if (branch.length == 0)
-            return null;
-        let event = branch[branch.length - 1];
-        if (selection && event.selectionsAfter.length) {
-            return state.update({
-                selection: event.selectionsAfter[event.selectionsAfter.length - 1],
-                annotations: fromHistory.of({ side, rest: popSelection(branch) }),
-                userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
-                scrollIntoView: true
-            });
+    yield(node) {
+        if (!node)
+            return false;
+        if (node instanceof TreeNode) {
+            this.buffer = null;
+            return this.yieldNode(node);
         }
-        else if (!event.changes) {
-            return null;
+        this.buffer = node.context;
+        return this.yieldBuf(node.index, node.type);
+    }
+    /// @internal
+    toString() {
+        return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
+    }
+    /// @internal
+    enterChild(dir, pos, side) {
+        if (!this.buffer)
+            return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
+        let { buffer } = this.buffer;
+        let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
+        if (index < 0)
+            return false;
+        this.stack.push(this.index);
+        return this.yieldBuf(index);
+    }
+    /// Move the cursor to this node's first child. When this returns
+    /// false, the node has no child, and the cursor has not been moved.
+    firstChild() { return this.enterChild(1, 0, 4 /* DontCare */); }
+    /// Move the cursor to this node's last child.
+    lastChild() { return this.enterChild(-1, 0, 4 /* DontCare */); }
+    /// Move the cursor to the first child that ends after `pos`.
+    childAfter(pos) { return this.enterChild(1, pos, 2 /* After */); }
+    /// Move to the last child that starts before `pos`.
+    childBefore(pos) { return this.enterChild(-1, pos, -2 /* Before */); }
+    /// Move the cursor to the child around `pos`. If side is -1 the
+    /// child may end at that position, when 1 it may start there. This
+    /// will also enter [overlaid](#common.MountedTree.overlay)
+    /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
+    /// set to false.
+    enter(pos, side, mode = this.mode) {
+        if (!this.buffer)
+            return this.yield(this._tree.enter(pos, side, mode));
+        return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
+    }
+    /// Move to the node's parent node, if this isn't the top node.
+    parent() {
+        if (!this.buffer)
+            return this.yieldNode((this.mode & IterMode.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
+        if (this.stack.length)
+            return this.yieldBuf(this.stack.pop());
+        let parent = (this.mode & IterMode.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
+        this.buffer = null;
+        return this.yieldNode(parent);
+    }
+    /// @internal
+    sibling(dir) {
+        if (!this.buffer)
+            return !this._tree._parent ? false
+                : this.yield(this._tree.index < 0 ? null
+                    : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* DontCare */, this.mode));
+        let { buffer } = this.buffer, d = this.stack.length - 1;
+        if (dir < 0) {
+            let parentStart = d < 0 ? 0 : this.stack[d] + 4;
+            if (this.index != parentStart)
+                return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
         }
         else {
-            let rest = branch.length == 1 ? none$1 : branch.slice(0, branch.length - 1);
-            if (event.mapped)
-                rest = addMappingToBranch(rest, event.mapped);
-            return state.update({
-                changes: event.changes,
-                selection: event.startSelection,
-                effects: event.effects,
-                annotations: fromHistory.of({ side, rest }),
-                filter: false,
-                userEvent: side == 0 /* Done */ ? "undo" : "redo",
-                scrollIntoView: true
-            });
+            let after = buffer.buffer[this.index + 3];
+            if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
+                return this.yieldBuf(after);
         }
+        return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* DontCare */, this.mode)) : false;
     }
-}
-HistoryState.empty = /*@__PURE__*/new HistoryState(none$1, none$1);
-/**
-Default key bindings for the undo history.
-
-- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
-- Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
-- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
-- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
-*/
-const historyKeymap = [
-    { key: "Mod-z", run: undo, preventDefault: true },
-    { key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true },
-    { key: "Mod-u", run: undoSelection, preventDefault: true },
-    { key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true }
-];
-
-function updateSel(sel, by) {
-    return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);
-}
-function setSel(state, selection) {
-    return state.update({ selection, scrollIntoView: true, userEvent: "select" });
-}
-function moveSel({ state, dispatch }, how) {
-    let selection = updateSel(state.selection, how);
-    if (selection.eq(state.selection))
-        return false;
-    dispatch(setSel(state, selection));
-    return true;
-}
-function rangeEnd(range, forward) {
-    return EditorSelection.cursor(forward ? range.to : range.from);
-}
-function cursorByChar(view, forward) {
-    return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
-}
-function ltrAtCursor(view) {
-    return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;
-}
-/**
-Move the selection one character to the left (which is backward in
-left-to-right text, forward in right-to-left text).
-*/
-const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
-/**
-Move the selection one character to the right.
-*/
-const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));
-function cursorByGroup(view, forward) {
-    return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
-}
-/**
-Move the selection to the left across one group of word or
-non-word (but also non-space) characters.
-*/
-const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
-/**
+    /// Move to this node's next sibling, if any.
+    nextSibling() { return this.sibling(1); }
+    /// Move to this node's previous sibling, if any.
+    prevSibling() { return this.sibling(-1); }
+    atLastNode(dir) {
+        let index, parent, { buffer } = this;
+        if (buffer) {
+            if (dir > 0) {
+                if (this.index < buffer.buffer.buffer.length)
+                    return false;
+            }
+            else {
+                for (let i = 0; i < this.index; i++)
+                    if (buffer.buffer.buffer[i + 3] < this.index)
+                        return false;
+            }
+            ({ index, parent } = buffer);
+        }
+        else {
+            ({ index, _parent: parent } = this._tree);
+        }
+        for (; parent; { index, _parent: parent } = parent) {
+            if (index > -1)
+                for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
+                    let child = parent._tree.children[i];
+                    if ((this.mode & IterMode.IncludeAnonymous) ||
+                        child instanceof TreeBuffer ||
+                        !child.type.isAnonymous ||
+                        hasChild(child))
+                        return false;
+                }
+        }
+        return true;
+    }
+    move(dir, enter) {
+        if (enter && this.enterChild(dir, 0, 4 /* DontCare */))
+            return true;
+        for (;;) {
+            if (this.sibling(dir))
+                return true;
+            if (this.atLastNode(dir) || !this.parent())
+                return false;
+        }
+    }
+    /// Move to the next node in a
+    /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
+    /// traversal, going from a node to its first child or, if the
+    /// current node is empty or `enter` is false, its next sibling or
+    /// the next sibling of the first parent node that has one.
+    next(enter = true) { return this.move(1, enter); }
+    /// Move to the next node in a last-to-first pre-order traveral. A
+    /// node is followed by its last child or, if it has none, its
+    /// previous sibling or the previous sibling of the first parent
+    /// node that has one.
+    prev(enter = true) { return this.move(-1, enter); }
+    /// Move the cursor to the innermost node that covers `pos`. If
+    /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
+    /// it will enter nodes that start at `pos`.
+    moveTo(pos, side = 0) {
+        // Move up to a node that actually holds the position, if possible
+        while (this.from == this.to ||
+            (side < 1 ? this.from >= pos : this.from > pos) ||
+            (side > -1 ? this.to <= pos : this.to < pos))
+            if (!this.parent())
+                break;
+        // Then scan down into child nodes as far as possible
+        while (this.enterChild(1, pos, side)) { }
+        return this;
+    }
+    /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
+    /// position.
+    get node() {
+        if (!this.buffer)
+            return this._tree;
+        let cache = this.bufferNode, result = null, depth = 0;
+        if (cache && cache.context == this.buffer) {
+            scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
+                for (let c = cache; c; c = c._parent)
+                    if (c.index == index) {
+                        if (index == this.index)
+                            return c;
+                        result = c;
+                        depth = d + 1;
+                        break scan;
+                    }
+                index = this.stack[--d];
+            }
+        }
+        for (let i = depth; i < this.stack.length; i++)
+            result = new BufferNode(this.buffer, result, this.stack[i]);
+        return this.bufferNode = new BufferNode(this.buffer, result, this.index);
+    }
+    /// Get the [tree](#common.Tree) that represents the current node, if
+    /// any. Will return null when the node is in a [tree
+    /// buffer](#common.TreeBuffer).
+    get tree() {
+        return this.buffer ? null : this._tree._tree;
+    }
+    /// Iterate over the current node and all its descendants, calling
+    /// `enter` when entering a node and `leave`, if given, when leaving
+    /// one. When `enter` returns `false`, any children of that node are
+    /// skipped, and `leave` isn't called for it.
+    iterate(enter, leave) {
+        for (let depth = 0;;) {
+            let mustLeave = false;
+            if (this.type.isAnonymous || enter(this) !== false) {
+                if (this.firstChild()) {
+                    depth++;
+                    continue;
+                }
+                if (!this.type.isAnonymous)
+                    mustLeave = true;
+            }
+            for (;;) {
+                if (mustLeave && leave)
+                    leave(this);
+                mustLeave = this.type.isAnonymous;
+                if (this.nextSibling())
+                    break;
+                if (!depth)
+                    return;
+                this.parent();
+                depth--;
+                mustLeave = true;
+            }
+        }
+    }
+    /// Test whether the current node matches a given context—a sequence
+    /// of direct parent node names. Empty strings in the context array
+    /// are treated as wildcards.
+    matchContext(context) {
+        if (!this.buffer)
+            return matchNodeContext(this.node, context);
+        let { buffer } = this.buffer, { types } = buffer.set;
+        for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
+            if (d < 0)
+                return matchNodeContext(this.node, context, i);
+            let type = types[buffer.buffer[this.stack[d]]];
+            if (!type.isAnonymous) {
+                if (context[i] && context[i] != type.name)
+                    return false;
+                i--;
+            }
+        }
+        return true;
+    }
+}
+function hasChild(tree) {
+    return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
+}
+function buildTree(data) {
+    var _a;
+    let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
+    let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
+    let types = nodeSet.types;
+    let contextHash = 0, lookAhead = 0;
+    function takeNode(parentStart, minPos, children, positions, inRepeat) {
+        let { id, start, end, size } = cursor;
+        let lookAheadAtStart = lookAhead;
+        while (size < 0) {
+            cursor.next();
+            if (size == -1 /* Reuse */) {
+                let node = reused[id];
+                children.push(node);
+                positions.push(start - parentStart);
+                return;
+            }
+            else if (size == -3 /* ContextChange */) { // Context change
+                contextHash = id;
+                return;
+            }
+            else if (size == -4 /* LookAhead */) {
+                lookAhead = id;
+                return;
+            }
+            else {
+                throw new RangeError(`Unrecognized record size: ${size}`);
+            }
+        }
+        let type = types[id], node, buffer;
+        let startPos = start - parentStart;
+        if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
+            // Small enough for a buffer, and no reused nodes inside
+            let data = new Uint16Array(buffer.size - buffer.skip);
+            let endPos = cursor.pos - buffer.size, index = data.length;
+            while (cursor.pos > endPos)
+                index = copyToBuffer(buffer.start, data, index);
+            node = new TreeBuffer(data, end - buffer.start, nodeSet);
+            startPos = buffer.start - parentStart;
+        }
+        else { // Make it a node
+            let endPos = cursor.pos - size;
+            cursor.next();
+            let localChildren = [], localPositions = [];
+            let localInRepeat = id >= minRepeatType ? id : -1;
+            let lastGroup = 0, lastEnd = end;
+            while (cursor.pos > endPos) {
+                if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
+                    if (cursor.end <= lastEnd - maxBufferLength) {
+                        makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
+                        lastGroup = localChildren.length;
+                        lastEnd = cursor.end;
+                    }
+                    cursor.next();
+                }
+                else {
+                    takeNode(start, endPos, localChildren, localPositions, localInRepeat);
+                }
+            }
+            if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
+                makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
+            localChildren.reverse();
+            localPositions.reverse();
+            if (localInRepeat > -1 && lastGroup > 0) {
+                let make = makeBalanced(type);
+                node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
+            }
+            else {
+                node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
+            }
+        }
+        children.push(node);
+        positions.push(startPos);
+    }
+    function makeBalanced(type) {
+        return (children, positions, length) => {
+            let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
+            if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
+                if (!lastI && last.type == type && last.length == length)
+                    return last;
+                if (lookAheadProp = last.prop(NodeProp.lookAhead))
+                    lookAhead = positions[lastI] + last.length + lookAheadProp;
+            }
+            return makeTree(type, children, positions, length, lookAhead);
+        };
+    }
+    function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {
+        let localChildren = [], localPositions = [];
+        while (children.length > i) {
+            localChildren.push(children.pop());
+            localPositions.push(positions.pop() + base - from);
+        }
+        children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));
+        positions.push(from - base);
+    }
+    function makeTree(type, children, positions, length, lookAhead = 0, props) {
+        if (contextHash) {
+            let pair = [NodeProp.contextHash, contextHash];
+            props = props ? [pair].concat(props) : [pair];
+        }
+        if (lookAhead > 25) {
+            let pair = [NodeProp.lookAhead, lookAhead];
+            props = props ? [pair].concat(props) : [pair];
+        }
+        return new Tree(type, children, positions, length, props);
+    }
+    function findBufferSize(maxSize, inRepeat) {
+        // Scan through the buffer to find previous siblings that fit
+        // together in a TreeBuffer, and don't contain any reused nodes
+        // (which can't be stored in a buffer).
+        // If `inRepeat` is > -1, ignore node boundaries of that type for
+        // nesting, but make sure the end falls either at the start
+        // (`maxSize`) or before such a node.
+        let fork = cursor.fork();
+        let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
+        let result = { size: 0, start: 0, skip: 0 };
+        scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
+            let nodeSize = fork.size;
+            // Pretend nested repeat nodes of the same type don't exist
+            if (fork.id == inRepeat && nodeSize >= 0) {
+                // Except that we store the current state as a valid return
+                // value.
+                result.size = size;
+                result.start = start;
+                result.skip = skip;
+                skip += 4;
+                size += 4;
+                fork.next();
+                continue;
+            }
+            let startPos = fork.pos - nodeSize;
+            if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
+                break;
+            let localSkipped = fork.id >= minRepeatType ? 4 : 0;
+            let nodeStart = fork.start;
+            fork.next();
+            while (fork.pos > startPos) {
+                if (fork.size < 0) {
+                    if (fork.size == -3 /* ContextChange */)
+                        localSkipped += 4;
+                    else
+                        break scan;
+                }
+                else if (fork.id >= minRepeatType) {
+                    localSkipped += 4;
+                }
+                fork.next();
+            }
+            start = nodeStart;
+            size += nodeSize;
+            skip += localSkipped;
+        }
+        if (inRepeat < 0 || size == maxSize) {
+            result.size = size;
+            result.start = start;
+            result.skip = skip;
+        }
+        return result.size > 4 ? result : undefined;
+    }
+    function copyToBuffer(bufferStart, buffer, index) {
+        let { id, start, end, size } = cursor;
+        cursor.next();
+        if (size >= 0 && id < minRepeatType) {
+            let startIndex = index;
+            if (size > 4) {
+                let endPos = cursor.pos - (size - 4);
+                while (cursor.pos > endPos)
+                    index = copyToBuffer(bufferStart, buffer, index);
+            }
+            buffer[--index] = startIndex;
+            buffer[--index] = end - bufferStart;
+            buffer[--index] = start - bufferStart;
+            buffer[--index] = id;
+        }
+        else if (size == -3 /* ContextChange */) {
+            contextHash = id;
+        }
+        else if (size == -4 /* LookAhead */) {
+            lookAhead = id;
+        }
+        return index;
+    }
+    let children = [], positions = [];
+    while (cursor.pos > 0)
+        takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
+    let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
+    return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
+}
+const nodeSizeCache = new WeakMap;
+function nodeSize(balanceType, node) {
+    if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
+        return 1;
+    let size = nodeSizeCache.get(node);
+    if (size == null) {
+        size = 1;
+        for (let child of node.children) {
+            if (child.type != balanceType || !(child instanceof Tree)) {
+                size = 1;
+                break;
+            }
+            size += nodeSize(balanceType, child);
+        }
+        nodeSizeCache.set(node, size);
+    }
+    return size;
+}
+function balanceRange(
+// The type the balanced tree's inner nodes.
+balanceType, 
+// The direct children and their positions
+children, positions, 
+// The index range in children/positions to use
+from, to, 
+// The start position of the nodes, relative to their parent.
+start, 
+// Length of the outer node
+length, 
+// Function to build the top node of the balanced tree
+mkTop, 
+// Function to build internal nodes for the balanced tree
+mkTree) {
+    let total = 0;
+    for (let i = from; i < to; i++)
+        total += nodeSize(balanceType, children[i]);
+    let maxChild = Math.ceil((total * 1.5) / 8 /* BranchFactor */);
+    let localChildren = [], localPositions = [];
+    function divide(children, positions, from, to, offset) {
+        for (let i = from; i < to;) {
+            let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
+            i++;
+            for (; i < to; i++) {
+                let nextSize = nodeSize(balanceType, children[i]);
+                if (groupSize + nextSize >= maxChild)
+                    break;
+                groupSize += nextSize;
+            }
+            if (i == groupFrom + 1) {
+                if (groupSize > maxChild) {
+                    let only = children[groupFrom]; // Only trees can have a size > 1
+                    divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
+                    continue;
+                }
+                localChildren.push(children[groupFrom]);
+            }
+            else {
+                let length = positions[i - 1] + children[i - 1].length - groupStart;
+                localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
+            }
+            localPositions.push(groupStart + offset - start);
+        }
+    }
+    divide(children, positions, from, to, 0);
+    return (mkTop || mkTree)(localChildren, localPositions, length);
+}
+new NodeProp({ perNode: true });
+
+/**
+Comment or uncomment the current selection. Will use line comments
+if available, otherwise falling back to block comments.
+*/
+const toggleComment = target => {
+    let config = getConfig(target.state);
+    return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
+};
+function command(f, option) {
+    return ({ state, dispatch }) => {
+        if (state.readOnly)
+            return false;
+        let tr = f(option, state);
+        if (!tr)
+            return false;
+        dispatch(state.update(tr));
+        return true;
+    };
+}
+/**
+Comment or uncomment the current selection using line comments.
+The line comment syntax is taken from the
+[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
+*/
+const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* Toggle */);
+/**
+Comment or uncomment the current selection using block comments.
+The block comment syntax is taken from the
+[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
+data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
+*/
+const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* Toggle */);
+/**
+Comment or uncomment the lines around the current selection using
+block comments.
+*/
+const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
+function getConfig(state, pos = state.selection.main.head) {
+    let data = state.languageDataAt("commentTokens", pos);
+    return data.length ? data[0] : {};
+}
+const SearchMargin = 50;
+/**
+Determines if the given range is block-commented in the given
+state.
+*/
+function findBlockComment(state, { open, close }, from, to) {
+    let textBefore = state.sliceDoc(from - SearchMargin, from);
+    let textAfter = state.sliceDoc(to, to + SearchMargin);
+    let spaceBefore = /\s*$/.exec(textBefore)[0].length, spaceAfter = /^\s*/.exec(textAfter)[0].length;
+    let beforeOff = textBefore.length - spaceBefore;
+    if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&
+        textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {
+        return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },
+            close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };
+    }
+    let startText, endText;
+    if (to - from <= 2 * SearchMargin) {
+        startText = endText = state.sliceDoc(from, to);
+    }
+    else {
+        startText = state.sliceDoc(from, from + SearchMargin);
+        endText = state.sliceDoc(to - SearchMargin, to);
+    }
+    let startSpace = /^\s*/.exec(startText)[0].length, endSpace = /\s*$/.exec(endText)[0].length;
+    let endOff = endText.length - endSpace - close.length;
+    if (startText.slice(startSpace, startSpace + open.length) == open &&
+        endText.slice(endOff, endOff + close.length) == close) {
+        return { open: { pos: from + startSpace + open.length,
+                margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },
+            close: { pos: to - endSpace - close.length,
+                margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };
+    }
+    return null;
+}
+function selectedLineRanges(state) {
+    let ranges = [];
+    for (let r of state.selection.ranges) {
+        let fromLine = state.doc.lineAt(r.from);
+        let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
+        let last = ranges.length - 1;
+        if (last >= 0 && ranges[last].to > fromLine.from)
+            ranges[last].to = toLine.to;
+        else
+            ranges.push({ from: fromLine.from, to: toLine.to });
+    }
+    return ranges;
+}
+// Performs toggle, comment and uncomment of block comments in
+// languages that support them.
+function changeBlockComment(option, state, ranges = state.selection.ranges) {
+    let tokens = ranges.map(r => getConfig(state, r.from).block);
+    if (!tokens.every(c => c))
+        return null;
+    let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
+    if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
+        return { changes: state.changes(ranges.map((range, i) => {
+                if (comments[i])
+                    return [];
+                return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
+            })) };
+    }
+    else if (option != 1 /* Comment */ && comments.some(c => c)) {
+        let changes = [];
+        for (let i = 0, comment; i < comments.length; i++)
+            if (comment = comments[i]) {
+                let token = tokens[i], { open, close } = comment;
+                changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });
+            }
+        return { changes };
+    }
+    return null;
+}
+// Performs toggle, comment and uncomment of line comments.
+function changeLineComment(option, state, ranges = state.selection.ranges) {
+    let lines = [];
+    let prevLine = -1;
+    for (let { from, to } of ranges) {
+        let startI = lines.length, minIndent = 1e9;
+        for (let pos = from; pos <= to;) {
+            let line = state.doc.lineAt(pos);
+            if (line.from > prevLine && (from == to || to > line.from)) {
+                prevLine = line.from;
+                let token = getConfig(state, pos).line;
+                if (!token)
+                    continue;
+                let indent = /^\s*/.exec(line.text)[0].length;
+                let empty = indent == line.length;
+                let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
+                if (indent < line.text.length && indent < minIndent)
+                    minIndent = indent;
+                lines.push({ line, comment, token, indent, empty, single: false });
+            }
+            pos = line.to + 1;
+        }
+        if (minIndent < 1e9)
+            for (let i = startI; i < lines.length; i++)
+                if (lines[i].indent < lines[i].line.text.length)
+                    lines[i].indent = minIndent;
+        if (lines.length == startI + 1)
+            lines[startI].single = true;
+    }
+    if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
+        let changes = [];
+        for (let { line, token, indent, empty, single } of lines)
+            if (single || !empty)
+                changes.push({ from: line.from + indent, insert: token + " " });
+        let changeSet = state.changes(changes);
+        return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
+    }
+    else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
+        let changes = [];
+        for (let { line, comment, token } of lines)
+            if (comment >= 0) {
+                let from = line.from + comment, to = from + token.length;
+                if (line.text[to - line.from] == " ")
+                    to++;
+                changes.push({ from, to });
+            }
+        return { changes };
+    }
+    return null;
+}
+
+const fromHistory = /*@__PURE__*/Annotation.define();
+/**
+Transaction annotation that will prevent that transaction from
+being combined with other transactions in the undo history. Given
+`"before"`, it'll prevent merging with previous transactions. With
+`"after"`, subsequent transactions won't be combined with this
+one. With `"full"`, the transaction is isolated on both sides.
+*/
+const isolateHistory = /*@__PURE__*/Annotation.define();
+/**
+This facet provides a way to register functions that, given a
+transaction, provide a set of effects that the history should
+store when inverting the transaction. This can be used to
+integrate some kinds of effects in the history, so that they can
+be undone (and redone again).
+*/
+const invertedEffects = /*@__PURE__*/Facet.define();
+const historyConfig = /*@__PURE__*/Facet.define({
+    combine(configs) {
+        return combineConfig(configs, {
+            minDepth: 100,
+            newGroupDelay: 500
+        }, { minDepth: Math.max, newGroupDelay: Math.min });
+    }
+});
+function changeEnd(changes) {
+    let end = 0;
+    changes.iterChangedRanges((_, to) => end = to);
+    return end;
+}
+const historyField_ = /*@__PURE__*/StateField.define({
+    create() {
+        return HistoryState.empty;
+    },
+    update(state, tr) {
+        let config = tr.state.facet(historyConfig);
+        let fromHist = tr.annotation(fromHistory);
+        if (fromHist) {
+            let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;
+            let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
+            let other = from == 0 /* Done */ ? state.undone : state.done;
+            if (item)
+                other = updateBranch(other, other.length, config.minDepth, item);
+            else
+                other = addSelection(other, tr.startState.selection);
+            return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
+        }
+        let isolate = tr.annotation(isolateHistory);
+        if (isolate == "full" || isolate == "before")
+            state = state.isolate();
+        if (tr.annotation(Transaction.addToHistory) === false)
+            return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;
+        let event = HistEvent.fromTransaction(tr);
+        let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent);
+        if (event)
+            state = state.addChanges(event, time, userEvent, config.newGroupDelay, config.minDepth);
+        else if (tr.selection)
+            state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
+        if (isolate == "full" || isolate == "after")
+            state = state.isolate();
+        return state;
+    },
+    toJSON(value) {
+        return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };
+    },
+    fromJSON(json) {
+        return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));
+    }
+});
+/**
+Create a history extension with the given configuration.
+*/
+function history(config = {}) {
+    return [
+        historyField_,
+        historyConfig.of(config),
+        EditorView.domEventHandlers({
+            beforeinput(e, view) {
+                let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null;
+                if (!command)
+                    return false;
+                e.preventDefault();
+                return command(view);
+            }
+        })
+    ];
+}
+function cmd(side, selection) {
+    return function ({ state, dispatch }) {
+        if (!selection && state.readOnly)
+            return false;
+        let historyState = state.field(historyField_, false);
+        if (!historyState)
+            return false;
+        let tr = historyState.pop(side, state, selection);
+        if (!tr)
+            return false;
+        dispatch(tr);
+        return true;
+    };
+}
+/**
+Undo a single group of history events. Returns false if no group
+was available.
+*/
+const undo = /*@__PURE__*/cmd(0 /* Done */, false);
+/**
+Redo a group of history events. Returns false if no group was
+available.
+*/
+const redo = /*@__PURE__*/cmd(1 /* Undone */, false);
+/**
+Undo a change or selection change.
+*/
+const undoSelection = /*@__PURE__*/cmd(0 /* Done */, true);
+/**
+Redo a change or selection change.
+*/
+const redoSelection = /*@__PURE__*/cmd(1 /* Undone */, true);
+// History events store groups of changes or effects that need to be
+// undone/redone together.
+class HistEvent {
+    constructor(
+    // The changes in this event. Normal events hold at least one
+    // change or effect. But it may be necessary to store selection
+    // events before the first change, in which case a special type of
+    // instance is created which doesn't hold any changes, with
+    // changes == startSelection == undefined
+    changes, 
+    // The effects associated with this event
+    effects, mapped, 
+    // The selection before this event
+    startSelection, 
+    // Stores selection changes after this event, to be used for
+    // selection undo/redo.
+    selectionsAfter) {
+        this.changes = changes;
+        this.effects = effects;
+        this.mapped = mapped;
+        this.startSelection = startSelection;
+        this.selectionsAfter = selectionsAfter;
+    }
+    setSelAfter(after) {
+        return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);
+    }
+    toJSON() {
+        var _a, _b, _c;
+        return {
+            changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),
+            mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),
+            startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),
+            selectionsAfter: this.selectionsAfter.map(s => s.toJSON())
+        };
+    }
+    static fromJSON(json) {
+        return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.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(tr, selection) {
+        let effects = none$1;
+        for (let invert of tr.startState.facet(invertedEffects)) {
+            let result = invert(tr);
+            if (result.length)
+                effects = effects.concat(result);
+        }
+        if (!effects.length && tr.changes.empty)
+            return null;
+        return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none$1);
+    }
+    static selection(selections) {
+        return new HistEvent(undefined, none$1, undefined, undefined, selections);
+    }
+}
+function updateBranch(branch, to, maxLen, newEvent) {
+    let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;
+    let newBranch = branch.slice(start, to);
+    newBranch.push(newEvent);
+    return newBranch;
+}
+function isAdjacent(a, b) {
+    let ranges = [], isAdjacent = false;
+    a.iterChangedRanges((f, t) => ranges.push(f, t));
+    b.iterChangedRanges((_f, _t, f, t) => {
+        for (let i = 0; i < ranges.length;) {
+            let from = ranges[i++], to = ranges[i++];
+            if (t >= from && f <= to)
+                isAdjacent = true;
+        }
+    });
+    return isAdjacent;
+}
+function eqSelectionShape(a, b) {
+    return a.ranges.length == b.ranges.length &&
+        a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;
+}
+function conc(a, b) {
+    return !a.length ? b : !b.length ? a : a.concat(b);
+}
+const none$1 = [];
+const MaxSelectionsPerEvent = 200;
+function addSelection(branch, selection) {
+    if (!branch.length) {
+        return [HistEvent.selection([selection])];
+    }
+    else {
+        let lastEvent = branch[branch.length - 1];
+        let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));
+        if (sels.length && sels[sels.length - 1].eq(selection))
+            return branch;
+        sels.push(selection);
+        return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));
+    }
+}
+// Assumes the top item has one or more selectionAfter values
+function popSelection(branch) {
+    let last = branch[branch.length - 1];
+    let newBranch = branch.slice();
+    newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));
+    return newBranch;
+}
+// Add a mapping to the top event in the given branch. If this maps
+// away all the changes and effects in that item, drop it and
+// propagate the mapping to the next item.
+function addMappingToBranch(branch, mapping) {
+    if (!branch.length)
+        return branch;
+    let length = branch.length, selections = none$1;
+    while (length) {
+        let event = mapEvent(branch[length - 1], mapping, selections);
+        if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping
+            let result = branch.slice(0, length);
+            result[length - 1] = event;
+            return result;
+        }
+        else { // Drop this event, since there's no changes or effects left
+            mapping = event.mapped;
+            length--;
+            selections = event.selectionsAfter;
+        }
+    }
+    return selections.length ? [HistEvent.selection(selections)] : none$1;
+}
+function mapEvent(event, mapping, extraSelections) {
+    let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none$1, extraSelections);
+    // Change-less events don't store mappings (they are always the last event in a branch)
+    if (!event.changes)
+        return HistEvent.selection(selections);
+    let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);
+    let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;
+    return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);
+}
+const joinableUserEvent = /^(input\.type|delete)($|\.)/;
+class HistoryState {
+    constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {
+        this.done = done;
+        this.undone = undone;
+        this.prevTime = prevTime;
+        this.prevUserEvent = prevUserEvent;
+    }
+    isolate() {
+        return this.prevTime ? new HistoryState(this.done, this.undone) : this;
+    }
+    addChanges(event, time, userEvent, newGroupDelay, maxLen) {
+        let done = this.done, lastEvent = done[done.length - 1];
+        if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&
+            (!userEvent || joinableUserEvent.test(userEvent)) &&
+            ((!lastEvent.selectionsAfter.length &&
+                time - this.prevTime < newGroupDelay &&
+                isAdjacent(lastEvent.changes, event.changes)) ||
+                // For compose (but not compose.start) events, always join with previous event
+                userEvent == "input.type.compose")) {
+            done = updateBranch(done, done.length - 1, maxLen, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none$1));
+        }
+        else {
+            done = updateBranch(done, done.length, maxLen, event);
+        }
+        return new HistoryState(done, none$1, time, userEvent);
+    }
+    addSelection(selection, time, userEvent, newGroupDelay) {
+        let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none$1;
+        if (last.length > 0 &&
+            time - this.prevTime < newGroupDelay &&
+            userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) &&
+            eqSelectionShape(last[last.length - 1], selection))
+            return this;
+        return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);
+    }
+    addMapping(mapping) {
+        return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
+    }
+    pop(side, state, selection) {
+        let branch = side == 0 /* Done */ ? this.done : this.undone;
+        if (branch.length == 0)
+            return null;
+        let event = branch[branch.length - 1];
+        if (selection && event.selectionsAfter.length) {
+            return state.update({
+                selection: event.selectionsAfter[event.selectionsAfter.length - 1],
+                annotations: fromHistory.of({ side, rest: popSelection(branch) }),
+                userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
+                scrollIntoView: true
+            });
+        }
+        else if (!event.changes) {
+            return null;
+        }
+        else {
+            let rest = branch.length == 1 ? none$1 : branch.slice(0, branch.length - 1);
+            if (event.mapped)
+                rest = addMappingToBranch(rest, event.mapped);
+            return state.update({
+                changes: event.changes,
+                selection: event.startSelection,
+                effects: event.effects,
+                annotations: fromHistory.of({ side, rest }),
+                filter: false,
+                userEvent: side == 0 /* Done */ ? "undo" : "redo",
+                scrollIntoView: true
+            });
+        }
+    }
+}
+HistoryState.empty = /*@__PURE__*/new HistoryState(none$1, none$1);
+/**
+Default key bindings for the undo history.
+
+- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
+- Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
+- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
+- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
+*/
+const historyKeymap = [
+    { key: "Mod-z", run: undo, preventDefault: true },
+    { key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true },
+    { key: "Mod-u", run: undoSelection, preventDefault: true },
+    { key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true }
+];
+
+function updateSel(sel, by) {
+    return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);
+}
+function setSel(state, selection) {
+    return state.update({ selection, scrollIntoView: true, userEvent: "select" });
+}
+function moveSel({ state, dispatch }, how) {
+    let selection = updateSel(state.selection, how);
+    if (selection.eq(state.selection))
+        return false;
+    dispatch(setSel(state, selection));
+    return true;
+}
+function rangeEnd(range, forward) {
+    return EditorSelection.cursor(forward ? range.to : range.from);
+}
+function cursorByChar(view, forward) {
+    return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
+}
+function ltrAtCursor(view) {
+    return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;
+}
+/**
+Move the selection one character to the left (which is backward in
+left-to-right text, forward in right-to-left text).
+*/
+const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
+/**
+Move the selection one character to the right.
+*/
+const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));
+function cursorByGroup(view, forward) {
+    return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
+}
+/**
+Move the selection to the left across one group of word or
+non-word (but also non-space) characters.
+*/
+const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
+/**
 Move the selection one group to the right.
 */
 const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));
@@ -20500,7 +21533,7 @@ function toMatchingBracket(state, dispatch, extend) {
             return range;
         found = true;
         let head = matching.start.from == range.head ? matching.end.to : matching.end.from;
-        return EditorSelection.cursor(head);
+        return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head);
     });
     if (!found)
         return false;
@@ -20511,7 +21544,7 @@ function toMatchingBracket(state, dispatch, extend) {
 Move the selection to the bracket matching the one it is currently
 on, if any.
 */
-const cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch);
+const cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, false);
 function extendSel(view, how) {
     let selection = updateSel(view.state.selection, range => {
         let head = how(range);
@@ -21601,6 +22634,8 @@ itself will be highlighted with `"cm-selectionMatch-main"`.
 */
 function highlightSelectionMatches(options) {
     let ext = [defaultTheme, matchHighlighter];
+    if (options)
+        ext.push(highlightConfig.of(options));
     return ext;
 }
 const matchDeco = /*@__PURE__*/Decoration.mark({ class: "cm-selectionMatch" });
@@ -22259,7 +23294,7 @@ function announceMatch(view, { from, to }) {
     }
     return EditorView.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${view.state.doc.lineAt(from).number}`);
 }
-const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
+const baseTheme$3 = /*@__PURE__*/EditorView.baseTheme({
     ".cm-panel.cm-search": {
         padding: "2px 6px 4px",
         position: "relative",
@@ -22292,7 +23327,7 @@ const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
 const searchExtensions = [
     searchState,
     /*@__PURE__*/Prec.lowest(searchHighlighter),
-    baseTheme$2
+    baseTheme$3
 ];
 
 /**
@@ -23289,7 +24324,7 @@ const completionState = /*@__PURE__*/StateField.define({
     create() { return CompletionState.start(); },
     update(value, tr) { return value.update(tr); },
     provide: f => [
-        showTooltip.from(f, val => val.tooltip),
+        showTooltip$1.from(f, val => val.tooltip),
         EditorView.contentAttributes.from(f, state => state.attrs)
     ]
 });
@@ -23546,7 +24581,7 @@ const commitCharacters = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.domEv
     }
 }));
 
-const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
+const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
     ".cm-tooltip.cm-tooltip-autocomplete": {
         "& > ul": {
             fontFamily: "monospace",
@@ -23848,7 +24883,7 @@ function snippet(template) {
             let active = new ActiveSnippet(ranges, 0);
             let effects = spec.effects = [setActive.of(active)];
             if (editor.state.field(snippetState, false) === undefined)
-                effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme$1]));
+                effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme$2]));
         }
         editor.dispatch(editor.state.update(spec));
     };
@@ -24181,7 +25216,7 @@ function autocompletion(config = {}) {
         completionConfig.of(config),
         completionPlugin,
         completionKeymapExt,
-        baseTheme$1
+        baseTheme$2
     ];
 }
 /**
@@ -24305,6 +25340,16 @@ function maybeEnableLint(state, effects) {
     return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
 }
 /**
+Returns a transaction spec which updates the current set of
+diagnostics, and enables the lint extension if if wasn't already
+active.
+*/
+function setDiagnostics(state, diagnostics) {
+    return {
+        effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
+    };
+}
+/**
 The state effect that updates the set of active diagnostics. Can
 be useful when writing an extension that needs to track these.
 */
@@ -24421,6 +25466,65 @@ const lintKeymap = [
     { key: "Mod-Shift-m", run: openLintPanel, preventDefault: true },
     { key: "F8", run: nextDiagnostic }
 ];
+const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
+        this.view = view;
+        this.timeout = -1;
+        this.set = true;
+        let { delay } = view.state.facet(lintConfig);
+        this.lintTime = Date.now() + delay;
+        this.run = this.run.bind(this);
+        this.timeout = setTimeout(this.run, delay);
+    }
+    run() {
+        clearTimeout(this.timeout);
+        let now = Date.now();
+        if (now < this.lintTime - 10) {
+            this.timeout = setTimeout(this.run, this.lintTime - now);
+        }
+        else {
+            this.set = false;
+            let { state } = this.view, { sources } = state.facet(lintConfig);
+            if (sources.length)
+                batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => {
+                    if (this.view.state.doc == state.doc)
+                        this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b))));
+                }, error => { logException(this.view.state, error); });
+        }
+    }
+    update(update) {
+        let config = update.state.facet(lintConfig);
+        if (update.docChanged || config != update.startState.facet(lintConfig) ||
+            config.needsRefresh && config.needsRefresh(update)) {
+            this.lintTime = Date.now() + config.delay;
+            if (!this.set) {
+                this.set = true;
+                this.timeout = setTimeout(this.run, config.delay);
+            }
+        }
+    }
+    force() {
+        if (this.set) {
+            this.lintTime = Date.now();
+            this.run();
+        }
+    }
+    destroy() {
+        clearTimeout(this.timeout);
+    }
+});
+function batchResults(promises, sink, error) {
+    let collected = [], timeout = -1;
+    for (let p of promises)
+        p.then(value => {
+            collected.push(value);
+            clearTimeout(timeout);
+            if (collected.length == promises.length)
+                sink(collected);
+            else
+                timeout = setTimeout(() => sink(collected), 200);
+        }, error);
+}
 const lintConfig = /*@__PURE__*/Facet.define({
     combine(input) {
         return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
@@ -24434,6 +25538,19 @@ const lintConfig = /*@__PURE__*/Facet.define({
         }));
     }
 });
+/**
+Given a diagnostic source, this function returns an extension that
+enables linting with that source. It will be called whenever the
+editor is idle (after its content changed). If `null` is given as
+source, this only configures the lint extension.
+*/
+function linter(source, config = {}) {
+    return [
+        lintConfig.of({ source, config }),
+        lintPlugin,
+        lintExtensions
+    ];
+}
 function assignKeys(actions) {
     let assigned = [];
     if (actions)
@@ -24674,7 +25791,7 @@ function svg(content, attrs = `viewBox="0 0 40 40"`) {
 function underline(color) {
     return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
 }
-const baseTheme = /*@__PURE__*/EditorView.baseTheme({
+const baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({
     ".cm-diagnostic": {
         padding: "3px 6px 3px 8px",
         marginLeft: "-1px",
@@ -24894,7 +26011,7 @@ const lintGutterTooltip = /*@__PURE__*/StateField.define({
             tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
         return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
     },
-    provide: field => showTooltip.from(field)
+    provide: field => showTooltip$1.from(field)
 });
 const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
     ".cm-gutter-lint": {
@@ -24925,8 +26042,8 @@ const lintExtensions = [
             activeMark.range(selected.from, selected.to)
         ]);
     }),
-    /*@__PURE__*/hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
-    baseTheme
+    /*@__PURE__*/hoverTooltip$1(lintTooltip, { hideOn: hideTooltip }),
+    baseTheme$1
 ];
 const lintGutterConfig = /*@__PURE__*/Facet.define({
     combine(configs) {
@@ -26125,7 +27242,7 @@ class FragmentCursor {
                 this.nextStart = start;
                 return null;
             }
-            if (next instanceof Tree) {
+            if (next instanceof Tree$1) {
                 if (start == pos) {
                     if (start < this.safeFrom)
                         return null;
@@ -26424,10 +27541,10 @@ class Parse {
                         console.log(base + this.stackID(stack) + ` (via reuse of ${parser.getName(cached.type.id)})`);
                     return true;
                 }
-                if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
+                if (!(cached instanceof Tree$1) || cached.children.length == 0 || cached.positions[0] > 0)
                     break;
                 let inner = cached.children[0];
-                if (inner instanceof Tree && cached.positions[0] == 0)
+                if (inner instanceof Tree$1 && cached.positions[0] == 0)
                     cached = inner;
                 else
                     break;
@@ -26526,7 +27643,7 @@ class Parse {
     // Convert the stack's buffer to a syntax tree.
     stackToTree(stack) {
         stack.close();
-        return Tree.build({ buffer: StackBufferCursor.create(stack),
+        return Tree$1.build({ buffer: StackBufferCursor.create(stack),
             nodeSet: this.parser.nodeSet,
             topID: this.topTerm,
             maxBufferLength: this.parser.bufferLength,
@@ -26644,7 +27761,7 @@ class LRParser extends Parser {
         if (spec.propSources)
             this.nodeSet = this.nodeSet.extend(...spec.propSources);
         this.strict = false;
-        this.bufferLength = DefaultBufferLength;
+        this.bufferLength = DefaultBufferLength$1;
         let tokenArray = decodeArray(spec.tokenData);
         this.context = spec.context;
         this.specializerSpecs = spec.specialized || [];
@@ -27054,7 +28171,7 @@ const jsHighlight = styleTags({
 const spec_identifier = {__proto__:null,export:20, as:25, from:33, default:36, async:41, function:42, const:52, extends:56, this:60, true:68, false:68, null:80, void:84, typeof:88, super:104, new:138, delete:150, yield:159, await:163, class:168, public:231, private:231, protected:231, readonly:233, instanceof:252, satisfies:255, in:256, import:290, keyof:347, unique:351, infer:357, asserts:393, is:395, abstract:415, implements:417, type:419, let:422, var:424, using:427, interface:433, enum:437, namespace:443, module:445, declare:449, global:453, for:472, of:481, while:484, with:488, do:492, if:496, else:498, switch:502, case:508, try:514, catch:518, finally:522, return:526, throw:530, break:534, continue:538, debugger:542};
 const spec_word = {__proto__:null,async:125, get:127, set:129, declare:191, public:193, private:193, protected:193, static:195, abstract:197, override:199, readonly:205, accessor:207, new:399};
 const spec_LessThan = {__proto__:null,"<":189};
-const parser = LRParser.deserialize({
+const parser$1 = LRParser.deserialize({
   version: 14,
   states: "$EOQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#D_O.QQlO'#DeO.bQlO'#DpO%[QlO'#DxO0fQlO'#EQOOQ!0Lf'#EY'#EYO1PQ`O'#EVOOQO'#En'#EnOOQO'#Ij'#IjO1XQ`O'#GrO1dQ`O'#EmO1iQ`O'#EmO3hQ!0MxO'#JpO6[Q!0MxO'#JqO6uQ`O'#F[O6zQ,UO'#FsOOQ!0Lf'#Fe'#FeO7VO7dO'#FeO7eQMhO'#F{O9UQ`O'#FzOOQ!0Lf'#Jq'#JqOOQ!0Lb'#Jp'#JpO9ZQ`O'#GvOOQ['#K]'#K]O9fQ`O'#IWO9kQ!0LrO'#IXOOQ['#J^'#J^OOQ['#I]'#I]Q`QlOOQ`QlOOO9sQ!L^O'#DtO9zQlO'#D|O:RQlO'#EOO9aQ`O'#GrO:YQMhO'#CoO:hQ`O'#ElO:sQ`O'#EwO:xQMhO'#FdO;gQ`O'#GrOOQO'#K^'#K^O;lQ`O'#K^O;zQ`O'#GzO;zQ`O'#G{O;zQ`O'#G}O9aQ`O'#HQO<qQ`O'#HTO>YQ`O'#CeO>jQ`O'#HaO>rQ`O'#HgO>rQ`O'#HiO`QlO'#HkO>rQ`O'#HmO>rQ`O'#HpO>wQ`O'#HvO>|Q!0LsO'#H|O%[QlO'#IOO?XQ!0LsO'#IQO?dQ!0LsO'#ISO9kQ!0LrO'#IUO?oQ!0MxO'#CiO@qQpO'#DjQOQ`OOO%[QlO'#EOOAXQ`O'#ERO:YQMhO'#ElOAdQ`O'#ElOAoQ!bO'#FdOOQ['#Cg'#CgOOQ!0Lb'#Do'#DoOOQ!0Lb'#Jt'#JtO%[QlO'#JtOOQO'#Jw'#JwOOQO'#If'#IfOBoQpO'#EeOOQ!0Lb'#Ed'#EdOOQ!0Lb'#J{'#J{OCkQ!0MSO'#EeOCuQpO'#EUOOQO'#Jv'#JvODZQpO'#JwOEhQpO'#EUOCuQpO'#EePEuO&2DjO'#CbPOOO)CD{)CD{OOOO'#I^'#I^OFQO#tO,59UOOQ!0Lh,59U,59UOOOO'#I_'#I_OF`O&jO,59UOFnQ!L^O'#DaOOOO'#Ia'#IaOFuO#@ItO,59yOOQ!0Lf,59y,59yOGTQlO'#IbOGhQ`O'#JrOIgQ!fO'#JrO+}QlO'#JrOInQ`O,5:POJUQ`O'#EnOJcQ`O'#KROJnQ`O'#KQOJnQ`O'#KQOJvQ`O,5;[OJ{Q`O'#KPOOQ!0Ln,5:[,5:[OKSQlO,5:[OMQQ!0MxO,5:dOMqQ`O,5:lON[Q!0LrO'#KOONcQ`O'#J}O9ZQ`O'#J}ONwQ`O'#J}O! PQ`O,5;ZO! UQ`O'#J}O!#ZQ!fO'#JqOOQ!0Lh'#Ci'#CiO%[QlO'#EQO!#yQ!fO,5:qOOQS'#Jx'#JxOOQO-E<h-E<hO9aQ`O,5=^O!$aQ`O,5=^O!$fQlO,5;XO!&iQMhO'#EiO!(SQ`O,5;XO!(XQlO'#DwO!(cQpO,5;bO!(kQpO,5;bO%[QlO,5;bOOQ['#FS'#FSOOQ['#FU'#FUO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cOOQ['#FY'#FYO!(yQlO,5;sOOQ!0Lf,5;x,5;xOOQ!0Lf,5;y,5;yOOQ!0Lf,5;{,5;{O%[QlO'#InO!*|Q!0LrO,5<hO%[QlO,5;cO!&iQMhO,5;cO!+kQMhO,5;cO!-]QMhO'#E[O%[QlO,5;vOOQ!0Lf,5;z,5;zO!-dQ,UO'#FiO!.aQ,UO'#KVO!-{Q,UO'#KVO!.hQ,UO'#KVOOQO'#KV'#KVO!.|Q,UO,5<ROOOW,5<_,5<_O!/_QlO'#FuOOOW'#Im'#ImO7VO7dO,5<PO!/fQ,UO'#FwOOQ!0Lf,5<P,5<PO!0VQ$IUO'#CwOOQ!0Lh'#C{'#C{O!0jO#@ItO'#DPO!1WQMjO,5<dO!1_Q`O,5<gO!2zQ(CWO'#GWO!3XQ`O'#GXO!3^Q`O'#GXO!4|Q(CWO'#G]O!6RQpO'#GaOOQO'#Gm'#GmO!+rQMhO'#GlOOQO'#Go'#GoO!+rQMhO'#GnO!6tQ$IUO'#JjOOQ!0Lh'#Jj'#JjO!7OQ`O'#JiO!7^Q`O'#JhO!7fQ`O'#CuOOQ!0Lh'#Cy'#CyO!7qQ`O'#C{OOQ!0Lh'#DT'#DTOOQ!0Lh'#DV'#DVO1SQ`O'#DXO!+rQMhO'#GOO!+rQMhO'#GQO!7vQ`O'#GSO!7{Q`O'#GTO!3^Q`O'#GZO!+rQMhO'#G`O;zQ`O'#JiO!8QQ`O'#EoO!8oQ`O,5<fOOQ!0Lb'#Cr'#CrO!8wQ`O'#EpO!9qQpO'#EqOOQ!0Lb'#KP'#KPO!9xQ!0LrO'#K_O9kQ!0LrO,5=bO`QlO,5>rOOQ['#Jf'#JfOOQ[,5>s,5>sOOQ[-E<Z-E<ZO!;wQ!0MxO,5:`O!9lQpO,5:^O!>bQ!0MxO,5:hO%[QlO,5:hO!@xQ!0MxO,5:jOOQO,5@x,5@xO!AiQMhO,5=^O!AwQ!0LrO'#JgO9UQ`O'#JgO!BYQ!0LrO,59ZO!BeQpO,59ZO!BmQMhO,59ZO:YQMhO,59ZO!BxQ`O,5;XO!CQQ`O'#H`O!CfQ`O'#KbO%[QlO,5;|O!9lQpO,5<OO!CnQ`O,5=yO!CsQ`O,5=yO!CxQ`O,5=yO9kQ!0LrO,5=yO;zQ`O,5=iOOQO'#Cw'#CwO!DWQpO,5=fO!D`QMhO,5=gO!DkQ`O,5=iO!DpQ!bO,5=lO!DxQ`O'#K^O>wQ`O'#HVO9aQ`O'#HXO!D}Q`O'#HXO:YQMhO'#HZO!ESQ`O'#HZOOQ[,5=o,5=oO!EXQ`O'#H[O!EjQ`O'#CoO!EoQ`O,59PO!EyQ`O,59PO!HOQlO,59POOQ[,59P,59PO!H`Q!0LrO,59PO%[QlO,59PO!JkQlO'#HcOOQ['#Hd'#HdOOQ['#He'#HeO`QlO,5={O!KRQ`O,5={O`QlO,5>RO`QlO,5>TO!KWQ`O,5>VO`QlO,5>XO!K]Q`O,5>[O!KbQlO,5>bOOQ[,5>h,5>hO%[QlO,5>hO9kQ!0LrO,5>jOOQ[,5>l,5>lO# lQ`O,5>lOOQ[,5>n,5>nO# lQ`O,5>nOOQ[,5>p,5>pO#!YQpO'#D]O%[QlO'#JtO#!{QpO'#JtO##VQpO'#DkO##hQpO'#DkO#%yQlO'#DkO#&QQ`O'#JsO#&YQ`O,5:UO#&_Q`O'#ErO#&mQ`O'#KSO#&uQ`O,5;]O#&zQpO'#DkO#'XQpO'#ETOOQ!0Lf,5:m,5:mO%[QlO,5:mO#'`Q`O,5:mO>wQ`O,5;WO!BeQpO,5;WO!BmQMhO,5;WO:YQMhO,5;WO#'hQ`O,5@`O#'mQ07dO,5:qOOQO-E<d-E<dO#(sQ!0MSO,5;POCuQpO,5:pO#(}QpO,5:pOCuQpO,5;PO!BYQ!0LrO,5:pOOQ!0Lb'#Eh'#EhOOQO,5;P,5;PO%[QlO,5;PO#)[Q!0LrO,5;PO#)gQ!0LrO,5;PO!BeQpO,5:pOOQO,5;V,5;VO#)uQ!0LrO,5;PPOOO'#I['#I[P#*ZO&2DjO,58|POOO,58|,58|OOOO-E<[-E<[OOQ!0Lh1G.p1G.pOOOO-E<]-E<]OOOO,59{,59{O#*fQ!bO,59{OOOO-E<_-E<_OOQ!0Lf1G/e1G/eO#*kQ!fO,5>|O+}QlO,5>|OOQO,5?S,5?SO#*uQlO'#IbOOQO-E<`-E<`O#+SQ`O,5@^O#+[Q!fO,5@^O#+cQ`O,5@lOOQ!0Lf1G/k1G/kO%[QlO,5@mO#+kQ`O'#IhOOQO-E<f-E<fO#+cQ`O,5@lOOQ!0Lb1G0v1G0vOOQ!0Ln1G/v1G/vOOQ!0Ln1G0W1G0WO%[QlO,5@jO#,PQ!0LrO,5@jO#,bQ!0LrO,5@jO#,iQ`O,5@iO9ZQ`O,5@iO#,qQ`O,5@iO#-PQ`O'#IkO#,iQ`O,5@iOOQ!0Lb1G0u1G0uO!(cQpO,5:sO!(nQpO,5:sOOQS,5:u,5:uO#-qQdO,5:uO#-yQMhO1G2xO9aQ`O1G2xOOQ!0Lf1G0s1G0sO#.XQ!0MxO1G0sO#/^Q!0MvO,5;TOOQ!0Lh'#GV'#GVO#/zQ!0MzO'#JjO!$fQlO1G0sO#2VQ!fO'#JuO%[QlO'#JuO#2aQ`O,5:cOOQ!0Lh'#D]'#D]OOQ!0Lf1G0|1G0|O%[QlO1G0|OOQ!0Lf1G1e1G1eO#2fQ`O1G0|O#4zQ!0MxO1G0}O#5RQ!0MxO1G0}O#7iQ!0MxO1G0}O#7pQ!0MxO1G0}O#:WQ!0MxO1G0}O#<nQ!0MxO1G0}O#<uQ!0MxO1G0}O#<|Q!0MxO1G0}O#?dQ!0MxO1G0}O#?kQ!0MxO1G0}O#AxQ?MtO'#CiO#CsQ?MtO1G1_O#CzQ?MtO'#JqO#D_Q!0MxO,5?YOOQ!0Lb-E<l-E<lO#FlQ!0MxO1G0}O#GiQ!0MzO1G0}OOQ!0Lf1G0}1G0}O#HlQMjO'#JzO#HvQ`O,5:vO#H{Q!0MxO1G1bO#IoQ,UO,5<VO#IwQ,UO,5<WO#JPQ,UO'#FnO#JhQ`O'#FmOOQO'#KW'#KWOOQO'#Il'#IlO#JmQ,UO1G1mOOQ!0Lf1G1m1G1mOOOW1G1x1G1xO#KOQ?MtO'#JpO#KYQ`O,5<aO!(yQlO,5<aOOOW-E<k-E<kOOQ!0Lf1G1k1G1kO#K_QpO'#KVOOQ!0Lf,5<c,5<cO#KgQpO,5<cO#KlQMhO'#DROOOO'#I`'#I`O#KsO#@ItO,59kOOQ!0Lh,59k,59kO%[QlO1G2OO!7{Q`O'#IpO#LOQ`O,5<yOOQ!0Lh,5<v,5<vO!+rQMhO'#IsO#LlQMjO,5=WO!+rQMhO'#IuO#M_QMjO,5=YO!&iQMhO,5=[OOQO1G2R1G2RO#MiQ!dO'#CrO#M|Q(CWO'#EpO$ RQpO'#GaO$ iQ!dO,5<rO$ pQ`O'#KYO9ZQ`O'#KYO$!OQ`O,5<tO!+rQMhO,5<sO$!TQ`O'#GYO$!fQ`O,5<sO$!kQ!dO'#GVO$!xQ!dO'#KZO$#SQ`O'#KZO!&iQMhO'#KZO$#XQ`O,5<wO$#^QlO'#JtO$#hQpO'#GbO##hQpO'#GbO$#yQ`O'#GfO!3^Q`O'#GjO$$OQ!0LrO'#IrO$$ZQpO,5<{OOQ!0Lp,5<{,5<{O$$bQpO'#GbO$$oQpO'#GcO$%QQpO'#GcO$%VQMjO,5=WO$%gQMjO,5=YOOQ!0Lh,5=],5=]O!+rQMhO,5@TO!+rQMhO,5@TO$%wQ`O'#IwO$&VQ`O,5@SO$&_Q`O,59aOOQ!0Lh,59g,59gO$'UQ$IYO,59sOOQ!0Lh'#Jn'#JnO$'wQMjO,5<jO$(jQMjO,5<lO@iQ`O,5<nOOQ!0Lh,5<o,5<oO$(tQ`O,5<uO$(yQMjO,5<zO$)ZQ`O,5@TO$)iQ`O'#J}O!$fQlO1G2QO$)nQ`O1G2QO9ZQ`O'#KQO9ZQ`O'#ErO%[QlO'#ErO9ZQ`O'#IyO$)sQ!0LrO,5@yOOQ[1G2|1G2|OOQ[1G4^1G4^OOQ!0Lf1G/z1G/zOOQ!0Lf1G/x1G/xO$+uQ!0MxO1G0SOOQ[1G2x1G2xO!&iQMhO1G2xO%[QlO1G2xO#-|Q`O1G2xO$-yQMhO'#EiOOQ!0Lb,5@R,5@RO$.WQ!0LrO,5@ROOQ[1G.u1G.uO!BYQ!0LrO1G.uO!BeQpO1G.uO!BmQMhO1G.uO$.iQ`O1G0sO$.nQ`O'#CiO$.yQ`O'#KcO$/RQ`O,5=zO$/WQ`O'#KcO$/]Q`O'#KcO$/kQ`O'#JPO$/yQ`O,5@|O$0RQ!fO1G1hOOQ!0Lf1G1j1G1jO9aQ`O1G3eO@iQ`O1G3eO$0YQ`O1G3eO$0_Q`O1G3eOOQ[1G3e1G3eO!DkQ`O1G3TO!&iQMhO1G3QO$0dQ`O1G3QOOQ[1G3R1G3RO!&iQMhO1G3RO$0iQ`O1G3RO$0qQpO'#HPOOQ[1G3T1G3TO!5|QpO'#I{O!DpQ!bO1G3WOOQ[1G3W1G3WOOQ[,5=q,5=qO$0yQMhO,5=sO9aQ`O,5=sO$#yQ`O,5=uO9UQ`O,5=uO!BeQpO,5=uO!BmQMhO,5=uO:YQMhO,5=uO$1XQ`O'#KaO$1dQ`O,5=vOOQ[1G.k1G.kO$1iQ!0LrO1G.kO@iQ`O1G.kO$1tQ`O1G.kO9kQ!0LrO1G.kO$3|Q!fO,5AOO$4ZQ`O,5AOO9ZQ`O,5AOO$4fQlO,5=}O$4mQ`O,5=}OOQ[1G3g1G3gO`QlO1G3gOOQ[1G3m1G3mOOQ[1G3o1G3oO>rQ`O1G3qO$4rQlO1G3sO$8vQlO'#HrOOQ[1G3v1G3vO$9TQ`O'#HxO>wQ`O'#HzOOQ[1G3|1G3|O$9]QlO1G3|O9kQ!0LrO1G4SOOQ[1G4U1G4UOOQ!0Lb'#G^'#G^O9kQ!0LrO1G4WO9kQ!0LrO1G4YO$=dQ`O,5@`O!(yQlO,5;^O9ZQ`O,5;^O>wQ`O,5:VO!(yQlO,5:VO!BeQpO,5:VO$=iQ?MtO,5:VOOQO,5;^,5;^O$=sQpO'#IcO$>ZQ`O,5@_OOQ!0Lf1G/p1G/pO$>cQpO'#IiO$>mQ`O,5@nOOQ!0Lb1G0w1G0wO##hQpO,5:VOOQO'#Ie'#IeO$>uQpO,5:oOOQ!0Ln,5:o,5:oO#'cQ`O1G0XOOQ!0Lf1G0X1G0XO%[QlO1G0XOOQ!0Lf1G0r1G0rO>wQ`O1G0rO!BeQpO1G0rO!BmQMhO1G0rOOQ!0Lb1G5z1G5zO!BYQ!0LrO1G0[OOQO1G0k1G0kO%[QlO1G0kO$>|Q!0LrO1G0kO$?XQ!0LrO1G0kO!BeQpO1G0[OCuQpO1G0[O$?gQ!0LrO1G0kOOQO1G0[1G0[O$?{Q!0MxO1G0kPOOO-E<Y-E<YPOOO1G.h1G.hOOOO1G/g1G/gO$@VQ!bO,5<hO$@_Q!fO1G4hOOQO1G4n1G4nO%[QlO,5>|O$@iQ`O1G5xO$@qQ`O1G6WO$@yQ!fO1G6XO9ZQ`O,5?SO$ATQ!0MxO1G6UO%[QlO1G6UO$AeQ!0LrO1G6UO$AvQ`O1G6TO$AvQ`O1G6TO9ZQ`O1G6TO$BOQ`O,5?VO9ZQ`O,5?VOOQO,5?V,5?VO$BdQ`O,5?VO$)iQ`O,5?VOOQO-E<i-E<iOOQS1G0_1G0_OOQS1G0a1G0aO#-tQ`O1G0aOOQ[7+(d7+(dO!&iQMhO7+(dO%[QlO7+(dO$BrQ`O7+(dO$B}QMhO7+(dO$C]Q!0MzO,5=WO$EhQ!0MzO,5=YO$GsQ!0MzO,5=WO$JUQ!0MzO,5=YO$LgQ!0MzO,59sO$NlQ!0MzO,5<jO%!wQ!0MzO,5<lO%%SQ!0MzO,5<zOOQ!0Lf7+&_7+&_O%'eQ!0MxO7+&_O%(XQlO'#IdO%(fQ`O,5@aO%(nQ!fO,5@aOOQ!0Lf1G/}1G/}O%(xQ`O7+&hOOQ!0Lf7+&h7+&hO%(}Q?MtO,5:dO%[QlO7+&yO%)XQ?MtO,5:`O%)fQ?MtO,5:hO%)pQ?MtO,5:jO%)zQMhO'#IgO%*UQ`O,5@fOOQ!0Lh1G0b1G0bOOQO1G1q1G1qOOQO1G1r1G1rO%*^Q!jO,5<YO!(yQlO,5<XOOQO-E<j-E<jOOQ!0Lf7+'X7+'XOOOW7+'d7+'dOOOW1G1{1G1{O%*iQ`O1G1{OOQ!0Lf1G1}1G1}OOOO,59m,59mO%*nQ!dO,59mOOOO-E<^-E<^OOQ!0Lh1G/V1G/VO%*uQ!0MxO7+'jOOQ!0Lh,5?[,5?[O%+iQMhO1G2eP%+pQ`O'#IpPOQ!0Lh-E<n-E<nO%,^QMjO,5?_OOQ!0Lh-E<q-E<qO%-PQMjO,5?aOOQ!0Lh-E<s-E<sO%-ZQ!dO1G2vO%-bQ!dO'#CrO%-xQMhO'#KQO$#^QlO'#JtOOQ!0Lh1G2^1G2^O%.PQ`O'#IoO%.eQ`O,5@tO%.eQ`O,5@tO%.mQ`O,5@tO%.xQ`O,5@tOOQO1G2`1G2`O%/WQMjO1G2_O!+rQMhO1G2_O%/hQ(CWO'#IqO%/uQ`O,5@uO!&iQMhO,5@uO%/}Q!dO,5@uOOQ!0Lh1G2c1G2cO%2_Q!fO'#CiO%2iQ`O,5=OOOQ!0Lb,5<|,5<|O%2qQpO,5<|OOQ!0Lb,5<},5<}OCfQ`O,5<|O%2|QpO,5<|OOQ!0Lb,5=Q,5=QO$)iQ`O,5=UOOQO,5?^,5?^OOQO-E<p-E<pOOQ!0Lp1G2g1G2gO##hQpO,5<|O$#^QlO,5=OO%3[Q`O,5<}O%3gQpO,5<}O!+rQMhO'#IsO%4aQMjO1G2rO!+rQMhO'#IuO%5SQMjO1G2tO%5^QMjO1G5oO%5hQMjO1G5oOOQO,5?c,5?cOOQO-E<u-E<uOOQO1G.{1G.{O!9lQpO,59uO%[QlO,59uOOQ!0Lh,5<i,5<iO%5uQ`O1G2YO!+rQMhO1G2aO!+rQMhO1G5oO!+rQMhO1G5oO%5zQ!0MxO7+'lOOQ!0Lf7+'l7+'lO!$fQlO7+'lO%6nQ`O,5;^OOQ!0Lb,5?e,5?eOOQ!0Lb-E<w-E<wO%6sQ!dO'#K[O#'cQ`O7+(dO4UQ!fO7+(dO$BuQ`O7+(dO%6}Q!0MvO'#CiO%7nQ!0LrO,5=RO%8PQ!0MvO,5=RO%8dQ`O,5=ROOQ!0Lb1G5m1G5mOOQ[7+$a7+$aO!BYQ!0LrO7+$aO!BeQpO7+$aO!$fQlO7+&_O%8lQ`O'#JOO%9TQ`O,5@}OOQO1G3f1G3fO9aQ`O,5@}O%9TQ`O,5@}O%9]Q`O,5@}OOQO,5?k,5?kOOQO-E<}-E<}OOQ!0Lf7+'S7+'SO%9bQ`O7+)PO9kQ!0LrO7+)PO9aQ`O7+)PO@iQ`O7+)POOQ[7+(o7+(oO%9gQ!0MvO7+(lO!&iQMhO7+(lO!DfQ`O7+(mOOQ[7+(m7+(mO!&iQMhO7+(mO%9qQ`O'#K`O%9|Q`O,5=kOOQO,5?g,5?gOOQO-E<y-E<yOOQ[7+(r7+(rO%;`QpO'#HYOOQ[1G3_1G3_O!&iQMhO1G3_O%[QlO1G3_O%;gQ`O1G3_O%;rQMhO1G3_O9kQ!0LrO1G3aO$#yQ`O1G3aO9UQ`O1G3aO!BeQpO1G3aO!BmQMhO1G3aO%<QQ`O'#I}O%<fQ`O,5@{O%<nQpO,5@{OOQ!0Lb1G3b1G3bOOQ[7+$V7+$VO@iQ`O7+$VO9kQ!0LrO7+$VO%<yQ`O7+$VO%[QlO1G6jO%[QlO1G6kO%=OQ!0LrO1G6jO%=YQlO1G3iO%=aQ`O1G3iO%=fQlO1G3iOOQ[7+)R7+)RO9kQ!0LrO7+)]O`QlO7+)_OOQ['#Kf'#KfOOQ['#JQ'#JQO%=mQlO,5>^OOQ[,5>^,5>^O%[QlO'#HsO%=zQ`O'#HuOOQ[,5>d,5>dO9ZQ`O,5>dOOQ[,5>f,5>fOOQ[7+)h7+)hOOQ[7+)n7+)nOOQ[7+)r7+)rOOQ[7+)t7+)tO%>PQpO1G5zO%>kQ?MtO1G0xO%>uQ`O1G0xOOQO1G/q1G/qO%?QQ?MtO1G/qO>wQ`O1G/qO!(yQlO'#DkOOQO,5>},5>}OOQO-E<a-E<aOOQO,5?T,5?TOOQO-E<g-E<gO!BeQpO1G/qOOQO-E<c-E<cOOQ!0Ln1G0Z1G0ZOOQ!0Lf7+%s7+%sO#'cQ`O7+%sOOQ!0Lf7+&^7+&^O>wQ`O7+&^O!BeQpO7+&^OOQO7+%v7+%vO$?{Q!0MxO7+&VOOQO7+&V7+&VO%[QlO7+&VO%?[Q!0LrO7+&VO!BYQ!0LrO7+%vO!BeQpO7+%vO%?gQ!0LrO7+&VO%?uQ!0MxO7++pO%[QlO7++pO%@VQ`O7++oO%@VQ`O7++oOOQO1G4q1G4qO9ZQ`O1G4qO%@_Q`O1G4qOOQS7+%{7+%{O#'cQ`O<<LOO4UQ!fO<<LOO%@mQ`O<<LOOOQ[<<LO<<LOO!&iQMhO<<LOO%[QlO<<LOO%@uQ`O<<LOO%AQQ!0MzO,5?_O%C]Q!0MzO,5?aO%EhQ!0MzO1G2_O%GyQ!0MzO1G2rO%JUQ!0MzO1G2tO%LaQ!fO,5?OO%[QlO,5?OOOQO-E<b-E<bO%LkQ`O1G5{OOQ!0Lf<<JS<<JSO%LsQ?MtO1G0sO%NzQ?MtO1G0}O& RQ?MtO1G0}O&#SQ?MtO1G0}O&#ZQ?MtO1G0}O&%[Q?MtO1G0}O&']Q?MtO1G0}O&'dQ?MtO1G0}O&'kQ?MtO1G0}O&)lQ?MtO1G0}O&)sQ?MtO1G0}O&)zQ!0MxO<<JeO&+rQ?MtO1G0}O&,oQ?MvO1G0}O&-rQ?MvO'#JjO&/xQ?MtO1G1bO&0VQ?MtO1G0SO&0aQMjO,5?ROOQO-E<e-E<eO!(yQlO'#FpOOQO'#KX'#KXOOQO1G1t1G1tO&0kQ`O1G1sO&0pQ?MtO,5?YOOOW7+'g7+'gOOOO1G/X1G/XO&0zQ!dO1G4vOOQ!0Lh7+(P7+(PP!&iQMhO,5?[O!+rQMhO7+(bO&1RQ`O,5?ZO9ZQ`O,5?ZOOQO-E<m-E<mO&1aQ`O1G6`O&1aQ`O1G6`O&1iQ`O1G6`O&1tQMjO7+'yO&2UQ!dO,5?]O&2`Q`O,5?]O!&iQMhO,5?]OOQO-E<o-E<oO&2eQ!dO1G6aO&2oQ`O1G6aO&2wQ`O1G2jO!&iQMhO1G2jOOQ!0Lb1G2h1G2hOOQ!0Lb1G2i1G2iO%2qQpO1G2hO!BeQpO1G2hOCfQ`O1G2hOOQ!0Lb1G2p1G2pO&2|QpO1G2hO&3[Q`O1G2jO$)iQ`O1G2iOCfQ`O1G2iO$#^QlO1G2jO&3dQ`O1G2iO&4WQMjO,5?_OOQ!0Lh-E<r-E<rO&4yQMjO,5?aOOQ!0Lh-E<t-E<tO!+rQMhO7++ZOOQ!0Lh1G/a1G/aO&5TQ`O1G/aOOQ!0Lh7+'t7+'tO&5YQMjO7+'{O&5jQMjO7++ZO&5tQMjO7++ZO&6RQ!0MxO<<KWOOQ!0Lf<<KW<<KWO&6uQ`O1G0xO!&iQMhO'#IxO&6zQ`O,5@vO&8|Q!fO<<LOO!&iQMhO1G2mO&9TQ!0LrO1G2mOOQ[<<G{<<G{O!BYQ!0LrO<<G{O&9fQ!0MxO<<IyOOQ!0Lf<<Iy<<IyOOQO,5?j,5?jO&:YQ`O,5?jO&:_Q`O,5?jOOQO-E<|-E<|O&:mQ`O1G6iO&:mQ`O1G6iO9aQ`O1G6iO@iQ`O<<LkOOQ[<<Lk<<LkO&:uQ`O<<LkO9kQ!0LrO<<LkOOQ[<<LW<<LWO%9gQ!0MvO<<LWOOQ[<<LX<<LXO!DfQ`O<<LXO&:zQpO'#IzO&;VQ`O,5@zO!(yQlO,5@zOOQ[1G3V1G3VOOQO'#I|'#I|O9kQ!0LrO'#I|O&;_QpO,5=tOOQ[,5=t,5=tO&;fQpO'#EeO&;mQpO'#GdO&;rQ`O7+(yO&;wQ`O7+(yOOQ[7+(y7+(yO!&iQMhO7+(yO%[QlO7+(yO&<PQ`O7+(yOOQ[7+({7+({O9kQ!0LrO7+({O$#yQ`O7+({O9UQ`O7+({O!BeQpO7+({O&<[Q`O,5?iOOQO-E<{-E<{OOQO'#H]'#H]O&<gQ`O1G6gO9kQ!0LrO<<GqOOQ[<<Gq<<GqO@iQ`O<<GqO&<oQ`O7+,UO&<tQ`O7+,VO%[QlO7+,UO%[QlO7+,VOOQ[7+)T7+)TO&<yQ`O7+)TO&=OQlO7+)TO&=VQ`O7+)TOOQ[<<Lw<<LwOOQ[<<Ly<<LyOOQ[-E=O-E=OOOQ[1G3x1G3xO&=[Q`O,5>_OOQ[,5>a,5>aO&=aQ`O1G4OO9ZQ`O7+&dO!(yQlO7+&dOOQO7+%]7+%]O&=fQ?MtO1G6XO>wQ`O7+%]OOQ!0Lf<<I_<<I_OOQ!0Lf<<Ix<<IxO>wQ`O<<IxOOQO<<Iq<<IqO$?{Q!0MxO<<IqO%[QlO<<IqOOQO<<Ib<<IbO!BYQ!0LrO<<IbO&=pQ!0LrO<<IqO&={Q!0MxO<= [O&>]Q`O<= ZOOQO7+*]7+*]O9ZQ`O7+*]OOQ[ANAjANAjO&>eQ!fOANAjO!&iQMhOANAjO#'cQ`OANAjO4UQ!fOANAjO&>lQ`OANAjO%[QlOANAjO&>tQ!0MzO7+'yO&AVQ!0MzO,5?_O&CbQ!0MzO,5?aO&EmQ!0MzO7+'{O&HOQ!fO1G4jO&HYQ?MtO7+&_O&J^Q?MvO,5=WO&LeQ?MvO,5=YO&LuQ?MvO,5=WO&MVQ?MvO,5=YO&MgQ?MvO,59sO' mQ?MvO,5<jO'#pQ?MvO,5<lO'&UQ?MvO,5<zO''zQ?MtO7+'jO'(XQ?MtO7+'lO'(fQ`O,5<[OOQO7+'_7+'_OOQ!0Lh7+*b7+*bO'(kQMjO<<K|OOQO1G4u1G4uO'(rQ`O1G4uO'(}Q`O1G4uO')]Q`O7++zO')]Q`O7++zO!&iQMhO1G4wO')eQ!dO1G4wO')oQ`O7++{O')wQ`O7+(UO'*SQ!dO7+(UOOQ!0Lb7+(S7+(SOOQ!0Lb7+(T7+(TO!BeQpO7+(SOCfQ`O7+(SO'*^Q`O7+(UO!&iQMhO7+(UO$)iQ`O7+(TO'*cQ`O7+(UOCfQ`O7+(TO'*kQMjO<<NuOOQ!0Lh7+${7+${O!+rQMhO<<NuO'*uQ!dO,5?dOOQO-E<v-E<vO'+PQ!0MvO7+(XO!&iQMhO7+(XOOQ[AN=gAN=gO9aQ`O1G5UOOQO1G5U1G5UO'+aQ`O1G5UO'+fQ`O7+,TO'+fQ`O7+,TO9kQ!0LrOANBVO@iQ`OANBVOOQ[ANBVANBVOOQ[ANArANArOOQ[ANAsANAsO'+nQ`O,5?fOOQO-E<x-E<xO'+yQ?MtO1G6fOOQO,5?h,5?hOOQO-E<z-E<zOOQ[1G3`1G3`O',TQ`O,5=OOOQ[<<Le<<LeO!&iQMhO<<LeO&;rQ`O<<LeO',YQ`O<<LeO%[QlO<<LeOOQ[<<Lg<<LgO9kQ!0LrO<<LgO$#yQ`O<<LgO9UQ`O<<LgO',bQpO1G5TO',mQ`O7+,ROOQ[AN=]AN=]O9kQ!0LrOAN=]OOQ[<= p<= pOOQ[<= q<= qO',uQ`O<= pO',zQ`O<= qOOQ[<<Lo<<LoO'-PQ`O<<LoO'-UQlO<<LoOOQ[1G3y1G3yO>wQ`O7+)jO'-]Q`O<<JOO'-hQ?MtO<<JOOOQO<<Hw<<HwOOQ!0LfAN?dAN?dOOQOAN?]AN?]O$?{Q!0MxOAN?]OOQOAN>|AN>|O%[QlOAN?]OOQO<<Mw<<MwOOQ[G27UG27UO!&iQMhOG27UO#'cQ`OG27UO'-rQ!fOG27UO4UQ!fOG27UO'-yQ`OG27UO'.RQ?MtO<<JeO'.`Q?MvO1G2_O'0UQ?MvO,5?_O'2XQ?MvO,5?aO'4[Q?MvO1G2rO'6_Q?MvO1G2tO'8bQ?MtO<<KWO'8oQ?MtO<<IyOOQO1G1v1G1vO!+rQMhOANAhOOQO7+*a7+*aO'8|Q`O7+*aO'9XQ`O<= fO'9aQ!dO7+*cOOQ!0Lb<<Kp<<KpO$)iQ`O<<KpOCfQ`O<<KpO'9kQ`O<<KpO!&iQMhO<<KpOOQ!0Lb<<Kn<<KnO!BeQpO<<KnO'9vQ!dO<<KpOOQ!0Lb<<Ko<<KoO':QQ`O<<KpO!&iQMhO<<KpO$)iQ`O<<KoO':VQMjOANDaO':aQ!0MvO<<KsOOQO7+*p7+*pO9aQ`O7+*pO':qQ`O<= oOOQ[G27qG27qO9kQ!0LrOG27qO!(yQlO1G5QO':yQ`O7+,QO';RQ`O1G2jO&;rQ`OANBPOOQ[ANBPANBPO!&iQMhOANBPO';WQ`OANBPOOQ[ANBRANBRO9kQ!0LrOANBRO$#yQ`OANBROOQO'#H^'#H^OOQO7+*o7+*oOOQ[G22wG22wOOQ[ANE[ANE[OOQ[ANE]ANE]OOQ[ANBZANBZO';`Q`OANBZOOQ[<<MU<<MUO!(yQlOAN?jOOQOG24wG24wO$?{Q!0MxOG24wO#'cQ`OLD,pOOQ[LD,pLD,pO!&iQMhOLD,pO';eQ!fOLD,pO';lQ?MvO7+'yO'=bQ?MvO,5?_O'?eQ?MvO,5?aO'AhQ?MvO7+'{O'C^QMjOG27SOOQO<<M{<<M{OOQ!0LbANA[ANA[O$)iQ`OANA[OCfQ`OANA[O'CnQ!dOANA[OOQ!0LbANAYANAYO'CuQ`OANA[O!&iQMhOANA[O'DQQ!dOANA[OOQ!0LbANAZANAZOOQO<<N[<<N[OOQ[LD-]LD-]O'D[Q?MtO7+*lOOQO'#Ge'#GeOOQ[G27kG27kO&;rQ`OG27kO!&iQMhOG27kOOQ[G27mG27mO9kQ!0LrOG27mOOQ[G27uG27uO'DfQ?MtOG25UOOQOLD*cLD*cOOQ[!$(![!$(![O#'cQ`O!$(![O!&iQMhO!$(![O'DpQ!0MzOG27SOOQ!0LbG26vG26vO$)iQ`OG26vO'GRQ`OG26vOCfQ`OG26vO'G^Q!dOG26vO!&iQMhOG26vOOQ[LD-VLD-VO&;rQ`OLD-VOOQ[LD-XLD-XOOQ[!)9Ev!)9EvO#'cQ`O!)9EvOOQ!0LbLD,bLD,bO$)iQ`OLD,bOCfQ`OLD,bO'GeQ`OLD,bO'GpQ!dOLD,bOOQ[!$(!q!$(!qOOQ[!.K;b!.K;bO'GwQ?MvOG27SOOQ!0Lb!$( |!$( |O$)iQ`O!$( |OCfQ`O!$( |O'ImQ`O!$( |OOQ!0Lb!)9Eh!)9EhO$)iQ`O!)9EhOCfQ`O!)9EhOOQ!0Lb!.K;S!.K;SO$)iQ`O!.K;SOOQ!0Lb!4/0n!4/0nO!(yQlO'#DxO1PQ`O'#EVO'IxQ!fO'#JpO'JPQ!L^O'#DtO'JWQlO'#D|O'J_Q!fO'#CiO'LuQ!fO'#CiO!(yQlO'#EOO'MVQlO,5;XO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO'#InO( YQ`O,5<hO!(yQlO,5;cO( bQMhO,5;cO(!{QMhO,5;cO!(yQlO,5;vO!&iQMhO'#GlO( bQMhO'#GlO!&iQMhO'#GnO( bQMhO'#GnO1SQ`O'#DXO1SQ`O'#DXO!&iQMhO'#GOO( bQMhO'#GOO!&iQMhO'#GQO( bQMhO'#GQO!&iQMhO'#G`O( bQMhO'#G`O!(yQlO,5:hO(#SQpO'#D]O(#^QpO'#JtO!(yQlO,5@mO'MVQlO1G0sO(#hQ?MtO'#CiO!(yQlO1G2OO!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO(#rQ!dO'#CrO!&iQMhO,5<sO( bQMhO,5<sO'MVQlO1G2QO!(yQlO7+&yO!&iQMhO1G2_O( bQMhO1G2_O!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO!&iQMhO1G2aO( bQMhO1G2aO'MVQlO7+'lO'MVQlO7+&_O!&iQMhOANAhO( bQMhOANAhO($VQ`O'#EmO($[Q`O'#EmO($dQ`O'#F[O($iQ`O'#EwO($nQ`O'#KRO($yQ`O'#KPO(%UQ`O,5;XO(%ZQMjO,5<dO(%bQ`O'#GXO(%gQ`O'#GXO(%lQ`O,5<fO(%tQ`O,5;XO(%|Q?MtO1G1_O(&TQ`O,5<sO(&YQ`O,5<sO(&_Q`O,5<uO(&dQ`O,5<uO(&iQ`O1G2QO(&nQ`O1G0sO(&sQMjO<<K|O(&zQMjO<<K|O7eQMhO'#F{O9UQ`O'#FzOAdQ`O'#ElO!(yQlO,5;sO!3^Q`O'#GXO!3^Q`O'#GXO!3^Q`O'#GZO!3^Q`O'#GZO!+rQMhO7+(bO!+rQMhO7+(bO%-ZQ!dO1G2vO%-ZQ!dO1G2vO!&iQMhO,5=[O!&iQMhO,5=[",
   stateData: "((P~O'zOS'{OSTOS'|RQ~OPYOQYOSfOY!VOaqOdzOeyOj!POnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!swO!vxO!z]O$V|O$miO%g}O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO&U!WO&[!XO&^!YO&`!ZO&b![O&e!]O&k!^O&q!_O&s!`O&u!aO&w!bO&y!cO(RSO(TTO(WUO(_VO(m[O~OWtO~P`OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa!wOq!nO!Q!oO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!xO#U!pO#V!pO#Y!zO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O'|!{O~OP]XR]X[]Xa]Xp]X!O]X!Q]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X'x]X(_]X(p]X(w]X(x]X~O!e%QX~P(qO_!}O(T#PO(U!}O(V#PO~O_#QO(V#PO(W#PO(X#QO~Ov#SO!S#TO(`#TO(a#VO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R;{O(TTO(WUO(_VO(m[O~O!Y#ZO!Z#WO!W(fP!W(tP~P+}O![#cO~P`OPYOQYOSfOd!jOe!iOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(TTO(WUO(_VO(m[O~On#mO!Y#iO!z]O#g#lO#h#iO(R;|O!i(qP~P.iO!j#oO(R#nO~O!v#sO!z]O%g#tO~O#i#uO~O!e#vO#i#uO~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z$_O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa(dX'x(dX'u(dX!i(dX!W(dX!](dX%h(dX!e(dX~P1qO#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX!](eX%h(eX~Oa(eX'x(eX'u(eX!W(eX!i(eXt(eX!e(eX~P4UO#^$eO~O$[$hO$^$gO$e$mO~OSfO!]$nO$h$oO$j$qO~Oh%VOj%cOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R$sO(TTO(WUO(_$uO(w$}O(x%POg([P~O!j%dO~O!Q%gO!]%hO(R%fO~O!e%lO~Oa%mO'x%mO~O!O%qO~P%[O(S!lO~P%[O%m%uO~P%[Oh%VO!j%dO(R%fO(S!lO~Oe%|O!j%dO(R%fO~O#t$RO~O!O&RO!]&OO!j&QO%i&UO(R%fO(S!lO(TTO(WUO`)UP~O!v#sO~O%r&WO!Q)QX!])QX(R)QX~O(R&XO~Oj!PO!s&^O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO~Od&cOe&bO!v&`O%g&aO%z&_O~P<POd&fOeyOj!PO!]&eO!s&^O!vxO!z]O%g}O%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO~Ob&iO#^&lO%i&gO(S!lO~P=UO!j&mO!s&qO~O!j#oO~O!]XO~Oa%mO'v&yO'x%mO~Oa%mO'v&|O'x%mO~Oa%mO'v'OO'x%mO~O'u]X!W]Xt]X!i]X&Y]X!]]X%h]X!e]X~P(qO!`']O!a'UO!b'UO(S!lO(TTO(WUO~Oq'SO!Q'RO!Y'VO(c'QO![(gP![(vP~P@]Ol'`O!]'^O(R%fO~Oe'eO!j%dO(R%fO~O!O&RO!j&QO~Oq!nO!Q!oO!z;wO#R!pO#S!pO#U!pO#V!pO(S!lO(TTO(WUO(c!mO(m!sO~O!`'kO!a'jO!b'jO#T!pO#Y'lO#Z'lO~PAwOa%mOh%VO!e#vO!j%dO'x%mO(p'nO~O!n'rO#^'pO~PCVOq!nO!Q!oO(TTO(WUO(c!mO(m!sO~O!]XOq(kX!Q(kX!`(kX!a(kX!b(kX!z(kX#R(kX#S(kX#T(kX#U(kX#V(kX#Y(kX#Z(kX(S(kX(T(kX(W(kX(c(kX(m(kX~O!a'jO!b'jO(S!lO~PCuO'}'vO(O'vO(P'xO~O_!}O(T'zO(U!}O(V'zO~O_#QO(V'zO(W'zO(X#QO~Ot'|O~P%[Ov#SO!S#TO(`#TO(a(PO~O!Y(RO!W'UX!W'[X!Z'UX!Z'[X~P+}O!Z(TO!W(fX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z(TO!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~O!W(fX~PGpO!W(YO~O!W(sX!Z(sX!e(sX!i(sX(p(sX~O#^(sX#i#bX![(sX~PIsO#^(ZO!W(uX!Z(uX~O!Z([O!W(tX~O!W(_O~O#^$eO~PIsO![(`O~P`OR#zO!O#yO!Q#{O!j#xO(_VOP!la[!lap!la!Z!la!n!la#P!la#l!la#m!la#n!la#o!la#p!la#q!la#r!la#s!la#t!la#u!la#w!la#y!la#z!la(p!la(w!la(x!la~Oa!la'x!la'u!la!W!la!i!lat!la!]!la%h!la!e!la~PKZO!i(aO~O!e#vO#^(bO(p'nO!Z(rXa(rX'x(rX~O!i(rX~PMvO!Q%gO!]%hO!z]O#g(gO#h(fO(R%fO~O!Z(hO!i(qX~O!i(jO~O!Q%gO!]%hO#h(fO(R%fO~OP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O!e#vO!i(eX~P! dOR(lO!O(kO!j#xO#Q$dO!z!ya!Q!ya~O!v!ya%g!ya!]!ya#g!ya#h!ya(R!ya~P!#eO!v(pO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~O#i(vO~O!Y(xO!i(iP~P%[O(c(zO(m[O~O!Q(|O!j#xO(c(zO(m[O~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z$_Oa$pa'x$pa'u$pa!i$pa!W$pa!]$pa%h$pa!e$pa~Oj)bO~P!&iOh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Og(nP~P!+rO!O)gO!e)fO!]$]X$Y$]X$[$]X$^$]X$e$]X~O!e)fO!](yX$Y(yX$[(yX$^(yX$e(yX~O!O)gO~P!-{O!O)gO!](yX$Y(yX$[(yX$^(yX$e(yX~O!])iO$Y)mO$[)hO$^)hO$e)nO~O!Y)qO~P!(yO$[$hO$^$gO$e)uO~Ol$yX!O$yX#Q$yX'w$yX(w$yX(x$yX~OgkXg$yXlkX!ZkX#^kX~P!/qOv)wO(`)xO(a)zO~Ol*TO!O)|O'w)}O(w$}O(x%PO~Og){O~P!0uOg*UO~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q*WO!]*XO!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~O!Y*[O(R*VO!i(|P~P!1dO#i*^O~O!j*_O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R*aO(TTO(WUO(_$uO(w$}O(x%PO~O!Y*dO!W(}P~P!3cOp*pOq!nO!Q*fO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO(c!mO~O![*mO~P!5WO#Q$dOl(^X!O(^X'w(^X(w(^X(x(^X!Z(^X#^(^X~Og(^X#}(^X~P!6YOl*uO#^*tOg(]X!Z(]X~O!Z*vOg([X~Oj%cO(R&XOg([P~Oq*yO~O!j+OO~O(R(tO~On+TO!Q%gO!Y#iO!]%hO!z]O#g#lO#h#iO(R%fO!i(qP~O!e#vO#i+UO~O!Q%gO!Y+WO!Z([O!]%hO(R%fO!W(tP~Oq'YO!Q+YO!Y+XO(TTO(WUO(c(zO~O![(vP~P!9]O!Z+ZOa)RX'x)RX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa!ha!Z!ha'x!ha'u!ha!W!ha!i!hat!ha!]!ha%h!ha!e!ha~P!:TOR#zO!O#yO!Q#{O!j#xO(_VOP!pa[!pap!pa!Z!pa!n!pa#P!pa#l!pa#m!pa#n!pa#o!pa#p!pa#q!pa#r!pa#s!pa#t!pa#u!pa#w!pa#y!pa#z!pa(p!pa(w!pa(x!pa~Oa!pa'x!pa'u!pa!W!pa!i!pat!pa!]!pa%h!pa!e!pa~P!<kOR#zO!O#yO!Q#{O!j#xO(_VOP!ra[!rap!ra!Z!ra!n!ra#P!ra#l!ra#m!ra#n!ra#o!ra#p!ra#q!ra#r!ra#s!ra#t!ra#u!ra#w!ra#y!ra#z!ra(p!ra(w!ra(x!ra~Oa!ra'x!ra'u!ra!W!ra!i!rat!ra!]!ra%h!ra!e!ra~P!?ROh%VOl+dO!]'^O%h+cO~O!e+fOa(ZX!](ZX'x(ZX!Z(ZX~Oa%mO!]XO'x%mO~Oh%VO!j%dO~Oh%VO!j%dO(R%fO~O!e#vO#i(vO~Ob+qO%i+rO(R+nO(TTO(WUO![)VP~O!Z+sO`)UX~O[+wO~O`+xO~O!]&OO(R%fO(S!lO`)UP~Oh%VO#^+}O~Oh%VOl,QO!]$|O~O!],SO~O!O,UO!]XO~O%m%uO~O!v,ZO~Oe,`O~Ob,aO(R#nO(TTO(WUO![)TP~Oe%|O~O%i!QO(R&XO~P=UO[,fO`,eO~OPYOQYOSfOdzOeyOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!guO!jZO!mYO!nYO!oYO!qvO!vxO!z]O$miO%g}O(TTO(WUO(_VO(m[O~O!]!eO!s!gO$V!kO(R!dO~P!FRO`,eOa%mO'x%mO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa,kOj!OO!swO%k!OO%l!OO%m!OO~P!HkO!j&mO~O&[,qO~O!],sO~O&m,uO&o,vOP&jaQ&jaS&jaY&jaa&jad&jae&jaj&jan&jap&jaq&jar&jax&jaz&ja|&ja!Q&ja!U&ja!V&ja!]&ja!g&ja!j&ja!m&ja!n&ja!o&ja!q&ja!s&ja!v&ja!z&ja$V&ja$m&ja%g&ja%i&ja%k&ja%l&ja%m&ja%p&ja%r&ja%u&ja%v&ja%x&ja&U&ja&[&ja&^&ja&`&ja&b&ja&e&ja&k&ja&q&ja&s&ja&u&ja&w&ja&y&ja'u&ja(R&ja(T&ja(W&ja(_&ja(m&ja![&ja&c&jab&ja&h&ja~O(R,{O~Oh!cX!Z!PX![!PX!e!PX!e!cX!j!cX#^!PX~O!Z!cX![!cX~P# qO!e-QO#^-POh(hX!Z#fX![#fX!e(hX!j(hX~O!Z(hX![(hX~P#!dOh%VO!e-SO!j%dO!Z!_X![!_X~Oq!nO!Q!oO(TTO(WUO(c!mO~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(TTO(WUO(_VO(m[O~O(R<rO~P##yO!Z-WO![(gX~O![-YO~O!e-QO#^-PO!Z#fX![#fX~O!Z-ZO![(vX~O![-]O~O!a-^O!b-^O(S!lO~P##hO![-aO~P'_Ol-dO!]'^O~O!W-iO~Oq!ya!`!ya!a!ya!b!ya#R!ya#S!ya#T!ya#U!ya#V!ya#Y!ya#Z!ya(S!ya(T!ya(W!ya(c!ya(m!ya~P!#eO!n-nO#^-lO~PCVO!a-pO!b-pO(S!lO~PCuOa%mO#^-lO'x%mO~Oa%mO!e#vO#^-lO'x%mO~Oa%mO!e#vO!n-nO#^-lO'x%mO(p'nO~O'}'vO(O'vO(P-uO~Ot-vO~O!W'Ua!Z'Ua~P!:TO!Y-zO!W'UX!Z'UX~P%[O!Z(TO!W(fa~O!W(fa~PGpO!Z([O!W(ta~O!Q%gO!Y.OO!]%hO(R%fO!W'[X!Z'[X~O#^.QO!Z(ra!i(raa(ra'x(ra~O!e#vO~P#,PO!Z(hO!i(qa~O!Q%gO!]%hO#h.UO(R%fO~On.ZO!Q%gO!Y.WO!]%hO!z]O#g.YO#h.WO(R%fO!Z'_X!i'_X~OR._O!j#xO~Oh%VOl.bO!]'^O%h.aO~Oa#ai!Z#ai'x#ai'u#ai!W#ai!i#ait#ai!]#ai%h#ai!e#ai~P!:TOl=|O!O)|O'w)}O(w$}O(x%PO~O#i#]aa#]a#^#]a'x#]a!Z#]a!i#]a!]#]a!W#]a~P#.{O#i(^XP(^XR(^X[(^Xa(^Xp(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X'x(^X(_(^X(p(^X!i(^X!W(^X'u(^Xt(^X!](^X%h(^X!e(^X~P!6YO!Z.oO!i(iX~P!:TO!i.rO~O!W.tO~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kia#kip#ki!Z#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#l#ki~P#2kO#l$OO~P#2kOP$[OR#zOp$aO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO[#kia#ki!Z#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#p#ki~P#5YO#p$QO~P#5YOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO(_VOa#ki!Z#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#u#ki~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO(_VO(x#}Oa#ki!Z#ki#y#ki#z#ki'x#ki(p#ki(w#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#w$UO~P#:_O#w#ki~P#:_O#u$SO~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO(_VO(w#|O(x#}Oa#ki!Z#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#y#ki~P#=TO#y$WO~P#=TOP]XR]X[]Xp]X!O]X!Q]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X!Z]X![]X~O#}]X~P#?rOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO#y<XO#z<YO(_VO(p$YO(w#|O(x#}O~O#}.vO~P#BPO#Q$dO#^<`O$P<`O#}(eX![(eX~P! dOa'ba!Z'ba'x'ba'u'ba!i'ba!W'bat'ba!]'ba%h'ba!e'ba~P!:TO[#kia#kip#ki!Z#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO(w#ki(x#ki~P#EROl=|O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P#ERO!Z.zOg(nX~P!0uOg.|O~Oa$Oi!Z$Oi'x$Oi'u$Oi!W$Oi!i$Oit$Oi!]$Oi%h$Oi!e$Oi~P!:TO$[.}O$^.}O~O$[/OO$^/OO~O!e)fO#^/PO!]$bX$Y$bX$[$bX$^$bX$e$bX~O!Y/QO~O!])iO$Y/SO$[)hO$^)hO$e/TO~O!Z<ZO![(dX~P#BPO![/UO~O!e)fO$e(yX~O$e/WO~Ot/XO~P!&iOv)wO(`)xO(a/[O~O!Q/_O~O(w$}Ol%`a!O%`a'w%`a(x%`a!Z%`a#^%`a~Og%`a#}%`a~P#LTO(x%POl%ba!O%ba'w%ba(w%ba!Z%ba#^%ba~Og%ba#}%ba~P#LvO!ZfX!efX!ifX!i$yX(pfX~P!/qO!Y/hO!Z([O(R/gO!W(tP!W(}P~P!1dOp*pO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO~Oq<oO!Q/iO!Y+XO![*mO(c<nO![(vP~P#NaO!i/jO~P#.{O!Z/kO!e#vO(p'nO!i(|X~O!i/pO~O!Q%gO!Y*[O!]%hO(R%fO!i(|P~O#i/rO~O!W$yX!Z$yX!e%QX~P!/qO!Z/sO!W(}X~P#.{O!e/uO~O!W/wO~OnkO(R/xO~P.iOh%VOp/}O!e#vO!j%dO(p'nO~O!e+fO~Oa%mO!Z0RO'x%mO~O![0TO~P!5WO!a0UO!b0UO(S!lO~P##hOq!nO!Q0VO(TTO(WUO(c!mO~O#Y0XO~Og%`a!Z%`a#^%`a#}%`a~P!0uOg%ba!Z%ba#^%ba#}%ba~P!0uOj%cO(R&XOg'kX!Z'kX~O!Z*vOg([a~Og0bO~OR0cO!O0cO!Q0dO#Q$dOl{a'w{a(w{a(x{a!Z{a#^{a~Og{a#}{a~P$&dO!O)|O'w)}Ol$ra(w$ra(x$ra!Z$ra#^$ra~Og$ra#}$ra~P$'`O!O)|O'w)}Ol$ta(w$ta(x$ta!Z$ta#^$ta~Og$ta#}$ta~P$(RO#i0gO~Og%Sa!Z%Sa#^%Sa#}%Sa~P!0uOl0iO#^0hOg(]a!Z(]a~O!e#vO~O#i0lO~O!Z+ZOa)Ra'x)Ra~OR#zO!O#yO!Q#{O!j#xO(_VOP!pi[!pip!pi!Z!pi!n!pi#P!pi#l!pi#m!pi#n!pi#o!pi#p!pi#q!pi#r!pi#s!pi#t!pi#u!pi#w!pi#y!pi#z!pi(p!pi(w!pi(x!pi~Oa!pi'x!pi'u!pi!W!pi!i!pit!pi!]!pi%h!pi!e!pi~P$*OOh%VOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~On0vO%[0wO(R0tO~P$,fO!e+fOa(Za!](Za'x(Za!Z(Za~O#i0|O~O[]X!ZfX![fX~O!Z0}O![)VX~O![1PO~O[1QO~Ob1SO(R+nO(TTO(WUO~O!]&OO(R%fO`'sX!Z'sX~O!Z+sO`)Ua~O!i1VO~P!:TO[1YO~O`1ZO~O#^1^O~Ol1aO!]$|O~O(c(zO![)SP~Oh%VOl1jO!]1gO%h1iO~O[1tO!Z1rO![)TX~O![1uO~O`1wOa%mO'x%mO~O(R#nO(TTO(WUO~O#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O#t1zO&Y1{Oa(eX~P$2PO#^$eO#t1zO&Y1{O~Oa1}O~P%[Oa2PO~O&c2SOP&aiQ&aiS&aiY&aia&aid&aie&aij&ain&aip&aiq&air&aix&aiz&ai|&ai!Q&ai!U&ai!V&ai!]&ai!g&ai!j&ai!m&ai!n&ai!o&ai!q&ai!s&ai!v&ai!z&ai$V&ai$m&ai%g&ai%i&ai%k&ai%l&ai%m&ai%p&ai%r&ai%u&ai%v&ai%x&ai&U&ai&[&ai&^&ai&`&ai&b&ai&e&ai&k&ai&q&ai&s&ai&u&ai&w&ai&y&ai'u&ai(R&ai(T&ai(W&ai(_&ai(m&ai![&aib&ai&h&ai~Ob2YO![2WO&h2XO~P`O!]XO!j2[O~O&o,vOP&jiQ&jiS&jiY&jia&jid&jie&jij&jin&jip&jiq&jir&jix&jiz&ji|&ji!Q&ji!U&ji!V&ji!]&ji!g&ji!j&ji!m&ji!n&ji!o&ji!q&ji!s&ji!v&ji!z&ji$V&ji$m&ji%g&ji%i&ji%k&ji%l&ji%m&ji%p&ji%r&ji%u&ji%v&ji%x&ji&U&ji&[&ji&^&ji&`&ji&b&ji&e&ji&k&ji&q&ji&s&ji&u&ji&w&ji&y&ji'u&ji(R&ji(T&ji(W&ji(_&ji(m&ji![&ji&c&jib&ji&h&ji~O!W2bO~O!Z!_a![!_a~P#BPOq!nO!Q!oO!Y2hO(c!mO!Z'VX!['VX~P@]O!Z-WO![(ga~O!Z']X![']X~P!9]O!Z-ZO![(va~O![2oO~P'_Oa%mO#^2xO'x%mO~Oa%mO!e#vO#^2xO'x%mO~Oa%mO!e#vO!n2|O#^2xO'x%mO(p'nO~Oa%mO'x%mO~P!:TO!Z$_Ot$pa~O!W'Ui!Z'Ui~P!:TO!Z(TO!W(fi~O!Z([O!W(ti~O!W(ui!Z(ui~P!:TO!Z(ri!i(ria(ri'x(ri~P!:TO#^3OO!Z(ri!i(ria(ri'x(ri~O!Z(hO!i(qi~O!Q%gO!]%hO!z]O#g3TO#h3SO(R%fO~O!Q%gO!]%hO#h3SO(R%fO~Ol3[O!]'^O%h3ZO~Oh%VOl3[O!]'^O%h3ZO~O#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`at%`a!]%`a%h%`a!e%`a~P#LTO#i%baP%baR%ba[%baa%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%bat%ba!]%ba%h%ba!e%ba~P#LvO#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!Z%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`a#^%`at%`a!]%`a%h%`a!e%`a~P#.{O#i%baP%baR%ba[%baa%bap%ba!Q%ba!Z%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%ba#^%bat%ba!]%ba%h%ba!e%ba~P#.{O#i{aP{a[{aa{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a'x{a(_{a(p{a!i{a!W{a'u{at{a!]{a%h{a!e{a~P$&dO#i$raP$raR$ra[$raa$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra'x$ra(_$ra(p$ra!i$ra!W$ra'u$rat$ra!]$ra%h$ra!e$ra~P$'`O#i$taP$taR$ta[$taa$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta'x$ta(_$ta(p$ta!i$ta!W$ta'u$tat$ta!]$ta%h$ta!e$ta~P$(RO#i%SaP%SaR%Sa[%Saa%Sap%Sa!Q%Sa!Z%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa'x%Sa(_%Sa(p%Sa!i%Sa!W%Sa'u%Sa#^%Sat%Sa!]%Sa%h%Sa!e%Sa~P#.{Oa#aq!Z#aq'x#aq'u#aq!W#aq!i#aqt#aq!]#aq%h#aq!e#aq~P!:TO!Y3dO!Z'WX!i'WX~P%[O!Z.oO!i(ia~O!Z.oO!i(ia~P!:TO!W3gO~O#}!la![!la~PKZO#}!ha!Z!ha![!ha~P#BPO#}!pa![!pa~P!<kO#}!ra![!ra~P!?ROg'ZX!Z'ZX~P!+rO!Z.zOg(na~OSfO!]3{O$c3|O~O![4QO~Ot4RO~P#.{Oa$lq!Z$lq'x$lq'u$lq!W$lq!i$lqt$lq!]$lq%h$lq!e$lq~P!:TO!W4TO~P!&iO!Q4UO~O!O)|O'w)}O(x%POl'ga(w'ga!Z'ga#^'ga~Og'ga#}'ga~P%+uO!O)|O'w)}Ol'ia(w'ia(x'ia!Z'ia#^'ia~Og'ia#}'ia~P%,hO(p$YO~P#.{O!WfX!W$yX!ZfX!Z$yX!e%QX#^fX~P!/qO(R<xO~P!1dO!Q%gO!Y4XO!]%hO(R%fO!Z'cX!i'cX~O!Z/kO!i(|a~O!Z/kO!e#vO!i(|a~O!Z/kO!e#vO(p'nO!i(|a~Og${i!Z${i#^${i#}${i~P!0uO!Y4aO!W'eX!Z'eX~P!3cO!Z/sO!W(}a~O!Z/sO!W(}a~P#.{OP]XR]X[]Xp]X!O]X!Q]X!W]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!e%XX#t%XX~P%0XO!e#vO#t4fO~Oh%VO!e#vO!j%dO~Oh%VOp4kO!j%dO(p'nO~Op4pO!e#vO(p'nO~Oq!nO!Q4qO(TTO(WUO(c!mO~O(w$}Ol%`i!O%`i'w%`i(x%`i!Z%`i#^%`i~Og%`i#}%`i~P%3xO(x%POl%bi!O%bi'w%bi(w%bi!Z%bi#^%bi~Og%bi#}%bi~P%4kOg(]i!Z(]i~P!0uO#^4wOg(]i!Z(]i~P!0uO!i4zO~Oa$nq!Z$nq'x$nq'u$nq!W$nq!i$nqt$nq!]$nq%h$nq!e$nq~P!:TO!W5QO~O!Z5RO!])OX~P#.{Oa]Xa$yX!]]X!]$yX%]]X'x]X'x$yX!Z]X!Z$yX~P!/qO%]5UOa%Za!]%Za'x%Za!Z%Za~OlmX!OmX'wmX(wmX(xmX~P%7nOn5VO(R#nO~Ob5]O%i5^O(R+nO(TTO(WUO!Z'rX!['rX~O!Z0}O![)Va~O[5bO~O`5cO~Oa%mO'x%mO~P#.{O!Z5kO#^5mO![)SX~O![5nO~Op5tOq!nO!Q*fO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!pO#U!pO#V!pO#Y5sO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O![5rO~P%:ROl5yO!]1gO%h5xO~Oh%VOl5yO!]1gO%h5xO~Ob6QO(R#nO(TTO(WUO!Z'qX!['qX~O!Z1rO![)Ta~O(TTO(WUO(c6SO~O`6WO~O#t6ZO&Y6[O~PMvO!i6]O~P%[Oa6_O~Oa6_O~P%[Ob2YO![6dO&h2XO~P`O!e6fO~O!e6hOh(hi!Z(hi![(hi!e(hi!j(hip(hi(p(hi~O!Z#fi![#fi~P#BPO#^6iO!Z#fi![#fi~O!Z!_i![!_i~P#BPOa%mO#^6rO'x%mO~Oa%mO!e#vO#^6rO'x%mO~O!Z(rq!i(rqa(rq'x(rq~P!:TO!Z(hO!i(qq~O!Q%gO!]%hO#h6yO(R%fO~O!]'^O%h6|O~Ol7QO!]'^O%h6|O~O#i'gaP'gaR'ga['gaa'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga'x'ga(_'ga(p'ga!i'ga!W'ga'u'gat'ga!]'ga%h'ga!e'ga~P%+uO#i'iaP'iaR'ia['iaa'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia'x'ia(_'ia(p'ia!i'ia!W'ia'u'iat'ia!]'ia%h'ia!e'ia~P%,hO#i${iP${iR${i[${ia${ip${i!Q${i!Z${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i'x${i(_${i(p${i!i${i!W${i'u${i#^${it${i!]${i%h${i!e${i~P#.{O#i%`iP%`iR%`i[%`ia%`ip%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i'x%`i(_%`i(p%`i!i%`i!W%`i'u%`it%`i!]%`i%h%`i!e%`i~P%3xO#i%biP%biR%bi[%bia%bip%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi'x%bi(_%bi(p%bi!i%bi!W%bi'u%bit%bi!]%bi%h%bi!e%bi~P%4kO!Z'Wa!i'Wa~P!:TO!Z.oO!i(ii~O#}#ai!Z#ai![#ai~P#BPOP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kip#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#l#ki~P%MQO#l<PO~P%MQOP$[OR#zOp<]O!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO[#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#p#ki~P& YO#p<RO~P& YOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO(_VO#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#u#ki~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO(_VO(x#}O#y#ki#z#ki#}#ki(p#ki(w#ki!Z#ki![#ki~O#w<VO~P&%cO#w#ki~P&%cO#u<TO~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO(_VO(w#|O(x#}O#z#ki#}#ki(p#ki!Z#ki![#ki~O#y#ki~P&'rO#y<XO~P&'rOa#{y!Z#{y'x#{y'u#{y!W#{y!i#{yt#{y!]#{y%h#{y!e#{y~P!:TO[#kip#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki!Z#ki![#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO(w#ki(x#ki~P&*nOl=}O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P&*nO#Q$dOP(^XR(^X[(^Xl(^Xp(^X!O(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X#}(^X'w(^X(_(^X(p(^X(w(^X(x(^X!Z(^X![(^X~O#}$Oi!Z$Oi![$Oi~P#BPO#}!pi![!pi~P$*OOg'Za!Z'Za~P!0uO![7dO~O!Z'ba!['ba~P#BPO!W7eO~P#.{O!e#vO(p'nO!Z'ca!i'ca~O!Z/kO!i(|i~O!Z/kO!e#vO!i(|i~Og${q!Z${q#^${q#}${q~P!0uO!W'ea!Z'ea~P#.{O!e7lO~O!Z/sO!W(}i~P#.{O!Z/sO!W(}i~O!W7oO~Oh%VOp7tO!j%dO(p'nO~O!e#vO#t7vO~Op7yO!e#vO(p'nO~O!O)|O'w)}O(x%POl'ha(w'ha!Z'ha#^'ha~Og'ha#}'ha~P&3oO!O)|O'w)}Ol'ja(w'ja(x'ja!Z'ja#^'ja~Og'ja#}'ja~P&4bO!W7{O~Og$}q!Z$}q#^$}q#}$}q~P!0uOg(]q!Z(]q~P!0uO#^7|Og(]q!Z(]q~P!0uOa$ny!Z$ny'x$ny'u$ny!W$ny!i$nyt$ny!]$ny%h$ny!e$ny~P!:TO!e6hO~O!Z5RO!])Oa~O!]'^OP$SaR$Sa[$Sap$Sa!O$Sa!Q$Sa!Z$Sa!j$Sa!n$Sa#P$Sa#l$Sa#m$Sa#n$Sa#o$Sa#p$Sa#q$Sa#r$Sa#s$Sa#t$Sa#u$Sa#w$Sa#y$Sa#z$Sa(_$Sa(p$Sa(w$Sa(x$Sa~O%h6|O~P&7SO%]8QOa%Zi!]%Zi'x%Zi!Z%Zi~Oa#ay!Z#ay'x#ay'u#ay!W#ay!i#ayt#ay!]#ay%h#ay!e#ay~P!:TO[8SO~Ob8UO(R+nO(TTO(WUO~O!Z0}O![)Vi~O`8YO~O(c(zO!Z'nX!['nX~O!Z5kO![)Sa~O![8cO~P%:RO(m!sO~P$$oO#Y8dO~O!]1gO~O!]1gO%h8fO~Ol8iO!]1gO%h8fO~O[8nO!Z'qa!['qa~O!Z1rO![)Ti~O!i8rO~O!i8sO~O!i8vO~O!i8vO~P%[Oa8xO~O!e8yO~O!i8zO~O!Z(ui![(ui~P#BPOa%mO#^9SO'x%mO~O!Z(ry!i(rya(ry'x(ry~P!:TO!Z(hO!i(qy~O%h9VO~P&7SO!]'^O%h9VO~O#i${qP${qR${q[${qa${qp${q!Q${q!Z${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q'x${q(_${q(p${q!i${q!W${q'u${q#^${qt${q!]${q%h${q!e${q~P#.{O#i'haP'haR'ha['haa'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha'x'ha(_'ha(p'ha!i'ha!W'ha'u'hat'ha!]'ha%h'ha!e'ha~P&3oO#i'jaP'jaR'ja['jaa'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja'x'ja(_'ja(p'ja!i'ja!W'ja'u'jat'ja!]'ja%h'ja!e'ja~P&4bO#i$}qP$}qR$}q[$}qa$}qp$}q!Q$}q!Z$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q'x$}q(_$}q(p$}q!i$}q!W$}q'u$}q#^$}qt$}q!]$}q%h$}q!e$}q~P#.{O!Z'Wi!i'Wi~P!:TO#}#aq!Z#aq![#aq~P#BPO(w$}OP%`aR%`a[%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a#}%`a(_%`a(p%`a!Z%`a![%`a~Ol%`a!O%`a'w%`a(x%`a~P&HgO(x%POP%baR%ba[%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba#}%ba(_%ba(p%ba!Z%ba![%ba~Ol%ba!O%ba'w%ba(w%ba~P&JnOl=}O!O)|O'w)}O(x%PO~P&HgOl=}O!O)|O'w)}O(w$}O~P&JnOR0cO!O0cO!Q0dO#Q$dOP{a[{al{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a#}{a'w{a(_{a(p{a(w{a(x{a!Z{a![{a~O!O)|O'w)}OP$raR$ra[$ral$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra#}$ra(_$ra(p$ra(w$ra(x$ra!Z$ra![$ra~O!O)|O'w)}OP$taR$ta[$tal$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta#}$ta(_$ta(p$ta(w$ta(x$ta!Z$ta![$ta~Ol=}O!O)|O'w)}O(w$}O(x%PO~OP%SaR%Sa[%Sap%Sa!Q%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa#}%Sa(_%Sa(p%Sa!Z%Sa![%Sa~P'%sO#}$lq!Z$lq![$lq~P#BPO#}$nq!Z$nq![$nq~P#BPO![9dO~O#}9eO~P!0uO!e#vO!Z'ci!i'ci~O!e#vO(p'nO!Z'ci!i'ci~O!Z/kO!i(|q~O!W'ei!Z'ei~P#.{O!Z/sO!W(}q~Op9lO!e#vO(p'nO~O[9nO!W9mO~P#.{O!W9mO~O!e#vO#t9tO~Og(]y!Z(]y~P!0uO!Z'la!]'la~P#.{Oa%Zq!]%Zq'x%Zq!Z%Zq~P#.{O[9yO~O!Z0}O![)Vq~O#^9}O!Z'na!['na~O!Z5kO![)Si~P#BPO!Q:PO~O!]1gO%h:SO~O(TTO(WUO(c:XO~O!Z1rO![)Tq~O!i:[O~O!i:]O~O!i:^O~O!i:^O~P%[O#^:aO!Z#fy![#fy~O!Z#fy![#fy~P#BPO%h:fO~P&7SO!]'^O%h:fO~O#}#{y!Z#{y![#{y~P#BPOP${iR${i[${ip${i!Q${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i#}${i(_${i(p${i!Z${i![${i~P'%sO!O)|O'w)}O(x%POP'gaR'ga['gal'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga#}'ga(_'ga(p'ga(w'ga!Z'ga!['ga~O!O)|O'w)}OP'iaR'ia['ial'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia#}'ia(_'ia(p'ia(w'ia(x'ia!Z'ia!['ia~O(w$}OP%`iR%`i[%`il%`ip%`i!O%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i#}%`i'w%`i(_%`i(p%`i(x%`i!Z%`i![%`i~O(x%POP%biR%bi[%bil%bip%bi!O%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi#}%bi'w%bi(_%bi(p%bi(w%bi!Z%bi![%bi~O#}$ny!Z$ny![$ny~P#BPO#}#ay!Z#ay![#ay~P#BPO!e#vO!Z'cq!i'cq~O!Z/kO!i(|y~O!W'eq!Z'eq~P#.{Op:pO!e#vO(p'nO~O[:tO!W:sO~P#.{O!W:sO~Og(]!R!Z(]!R~P!0uOa%Zy!]%Zy'x%Zy!Z%Zy~P#.{O!Z0}O![)Vy~O!Z5kO![)Sq~O(R:zO~O!]1gO%h:}O~O!i;QO~O%h;VO~P&7SOP${qR${q[${qp${q!Q${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q#}${q(_${q(p${q!Z${q![${q~P'%sO!O)|O'w)}O(x%POP'haR'ha['hal'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha#}'ha(_'ha(p'ha(w'ha!Z'ha!['ha~O!O)|O'w)}OP'jaR'ja['jal'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja#}'ja(_'ja(p'ja(w'ja(x'ja!Z'ja!['ja~OP$}qR$}q[$}qp$}q!Q$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q#}$}q(_$}q(p$}q!Z$}q![$}q~P'%sOg%d!Z!Z%d!Z#^%d!Z#}%d!Z~P!0uO!W;ZO~P#.{Op;[O!e#vO(p'nO~O[;^O!W;ZO~P#.{O!Z'nq!['nq~P#BPO!Z#f!Z![#f!Z~P#BPO#i%d!ZP%d!ZR%d!Z[%d!Za%d!Zp%d!Z!Q%d!Z!Z%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z'x%d!Z(_%d!Z(p%d!Z!i%d!Z!W%d!Z'u%d!Z#^%d!Zt%d!Z!]%d!Z%h%d!Z!e%d!Z~P#.{Op;fO!e#vO(p'nO~O!W;gO~P#.{Op;nO!e#vO(p'nO~O!W;oO~P#.{OP%d!ZR%d!Z[%d!Zp%d!Z!Q%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z#}%d!Z(_%d!Z(p%d!Z!Z%d!Z![%d!Z~P'%sOp;rO!e#vO(p'nO~Ot(dX~P1qO!O%qO~P!(yO(S!lO~P!(yO!WfX!ZfX#^fX~P%0XOP]XR]X[]Xp]X!O]X!Q]X!Z]X!ZfX!j]X!n]X#P]X#Q]X#^]X#^fX#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!efX!i]X!ifX(pfX~P'JlOP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]XO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z<ZO![$pa~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<fO!Q${O!]$|O!g=wO!j$xO#h<lO$V%_O$s<hO$u<jO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Oj)bO~P( bOp!cX(p!cX~P# qOp(hX(p(hX~P#!dO![]X![fX~P'JlO!WfX!W$yX!ZfX!Z$yX#^fX~P!/qO#i<OO~O!e#vO#i<OO~O#^<`O~O#t<SO~O#^<pO!Z(uX![(uX~O#^<`O!Z(sX![(sX~O#i<qO~Og<sO~P!0uO#i<yO~O#i<zO~O!e#vO#i<{O~O!e#vO#i<qO~O#}<|O~P#BPO#i<}O~O#i=OO~O#i=TO~O#i=UO~O#i=VO~O#i=WO~O#}=XO~P!0uO#}=YO~P!0uO#Q#R#S#U#V#Y#g#h#s$m$s$u$x%[%]%g%h%i%p%r%u%v%x%z~'|T#m!V'z(S#nq#l#op!O'{$['{(R$^(c~",
@@ -27258,7 +28375,7 @@ highlighting and indentation information.
 */
 const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
     name: "javascript",
-    parser: /*@__PURE__*/parser.configure({
+    parser: /*@__PURE__*/parser$1.configure({
         props: [
             /*@__PURE__*/indentNodeProp.add({
                 IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
@@ -27349,166 +28466,780 @@ function findOpenTag(node) {
         node = node.parent;
     }
 }
-function elementName(doc, tree, max = doc.length) {
-    for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
-        if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
-            ch.name == "JSXMemberExpression")
-            return doc.sliceString(ch.from, Math.min(ch.to, max));
-    }
-    return "";
+function elementName(doc, tree, max = doc.length) {
+    for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
+        if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
+            ch.name == "JSXMemberExpression")
+            return doc.sliceString(ch.from, Math.min(ch.to, max));
+    }
+    return "";
+}
+const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
+/**
+Extension that will automatically insert JSX close tags when a `>` or
+`/` is typed.
+*/
+const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
+    if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
+        from != to || (text != ">" && text != "/") ||
+        !javascriptLanguage.isActiveAt(view.state, from, -1))
+        return false;
+    let base = defaultInsert(), { state } = base;
+    let closeTags = state.changeByRange(range => {
+        var _a;
+        let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name;
+        if (around.name == "JSXStartTag")
+            around = around.parent;
+        if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
+        else if (text == ">" && around.name == "JSXFragmentTag") {
+            return { range, changes: { from: head, insert: `</>` } };
+        }
+        else if (text == "/" && around.name == "JSXStartCloseTag") {
+            let empty = around.parent, base = empty.parent;
+            if (base && empty.from == head - 2 &&
+                ((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
+                let insert = `${name}>`;
+                return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
+            }
+        }
+        else if (text == ">") {
+            let openTag = findOpenTag(around);
+            if (openTag && openTag.name == "JSXOpenTag" &&
+                !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
+                (name = elementName(state.doc, openTag, head)))
+                return { range, changes: { from: head, insert: `</${name}>` } };
+        }
+        return { range };
+    });
+    if (closeTags.changes.empty)
+        return false;
+    view.dispatch([
+        base,
+        state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
+    ]);
+    return true;
+});
+
+// Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
+const chalky = "#e5c07b", coral = "#e06c75", cyan = "#56b6c2", invalid = "#ffffff", ivory = "#abb2bf", stone = "#7d8799", // Brightened compared to original to increase contrast
+malibu = "#61afef", sage = "#98c379", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#2c313a", background = "#282c34", tooltipBackground = "#353a42", selection = "#3E4451", cursor = "#528bff";
+/**
+The editor theme styles for One Dark.
+*/
+const oneDarkTheme = /*@__PURE__*/EditorView.theme({
+    "&": {
+        color: ivory,
+        backgroundColor: background
+    },
+    ".cm-content": {
+        caretColor: cursor
+    },
+    ".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
+    "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
+    ".cm-panels": { backgroundColor: darkBackground, color: ivory },
+    ".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: background,
+        color: stone,
+        border: "none"
+    },
+    ".cm-activeLineGutter": {
+        backgroundColor: highlightBackground
+    },
+    ".cm-foldPlaceholder": {
+        backgroundColor: "transparent",
+        border: "none",
+        color: "#ddd"
+    },
+    ".cm-tooltip": {
+        border: "none",
+        backgroundColor: tooltipBackground
+    },
+    ".cm-tooltip .cm-tooltip-arrow:before": {
+        borderTopColor: "transparent",
+        borderBottomColor: "transparent"
+    },
+    ".cm-tooltip .cm-tooltip-arrow:after": {
+        borderTopColor: tooltipBackground,
+        borderBottomColor: tooltipBackground
+    },
+    ".cm-tooltip-autocomplete": {
+        "& > ul > li[aria-selected]": {
+            backgroundColor: highlightBackground,
+            color: ivory
+        }
+    }
+}, { dark: true });
+/**
+The highlighting style for code in the One Dark theme.
+*/
+const oneDarkHighlightStyle = /*@__PURE__*/HighlightStyle.define([
+    { tag: tags.keyword,
+        color: violet },
+    { tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
+        color: coral },
+    { tag: [/*@__PURE__*/tags.function(tags.variableName), tags.labelName],
+        color: malibu },
+    { tag: [tags.color, /*@__PURE__*/tags.constant(tags.name), /*@__PURE__*/tags.standard(tags.name)],
+        color: whiskey },
+    { tag: [/*@__PURE__*/tags.definition(tags.name), tags.separator],
+        color: ivory },
+    { tag: [tags.typeName, tags.className, tags.number, tags.changed, tags.annotation, tags.modifier, tags.self, tags.namespace],
+        color: chalky },
+    { tag: [tags.operator, tags.operatorKeyword, tags.url, tags.escape, tags.regexp, tags.link, /*@__PURE__*/tags.special(tags.string)],
+        color: cyan },
+    { tag: [tags.meta, tags.comment],
+        color: stone },
+    { tag: tags.strong,
+        fontWeight: "bold" },
+    { tag: tags.emphasis,
+        fontStyle: "italic" },
+    { tag: tags.strikethrough,
+        textDecoration: "line-through" },
+    { tag: tags.link,
+        color: stone,
+        textDecoration: "underline" },
+    { tag: tags.heading,
+        fontWeight: "bold",
+        color: coral },
+    { tag: [tags.atom, tags.bool, /*@__PURE__*/tags.special(tags.variableName)],
+        color: whiskey },
+    { tag: [tags.processingInstruction, tags.string, tags.inserted],
+        color: sage },
+    { tag: tags.invalid,
+        color: invalid },
+]);
+/**
+Extension to enable the One Dark theme (both the editor theme and
+the highlight style).
+*/
+const oneDark = [oneDarkTheme, /*@__PURE__*/syntaxHighlighting(oneDarkHighlightStyle)];
+
+const jsonHighlighting = styleTags({
+  String: tags.string,
+  Number: tags.number,
+  "True False": tags.bool,
+  PropertyName: tags.propertyName,
+  Null: tags.null,
+  ",": tags.separator,
+  "[ ]": tags.squareBracket,
+  "{ }": tags.brace
+});
+
+// This file was generated by lezer-generator. You probably shouldn't edit it.
+const parser = LRParser.deserialize({
+  version: 14,
+  states: "$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",
+  stateData: "#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",
+  goto: "!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",
+  nodeNames: "⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",
+  maxTerm: 25,
+  nodeProps: [
+    ["isolate", -2,6,11,""],
+    ["openedBy", 7,"{",12,"["],
+    ["closedBy", 8,"}",13,"]"]
+  ],
+  propSources: [jsonHighlighting],
+  skippedNodes: [0],
+  repeatNodeCount: 2,
+  tokenData: "(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",
+  tokenizers: [0],
+  topRules: {"JsonText":[0,1]},
+  tokenPrec: 0
+});
+
+/**
+Calls
+[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
+on the document and, if that throws an error, reports it as a
+single diagnostic.
+*/
+const jsonParseLinter = () => (view) => {
+    try {
+        JSON.parse(view.state.doc.toString());
+    }
+    catch (e) {
+        if (!(e instanceof SyntaxError))
+            throw e;
+        const pos = getErrorPosition(e, view.state.doc);
+        return [{
+                from: pos,
+                message: e.message,
+                severity: 'error',
+                to: pos
+            }];
+    }
+    return [];
+};
+function getErrorPosition(error, doc) {
+    let m;
+    if (m = error.message.match(/at position (\d+)/))
+        return Math.min(+m[1], doc.length);
+    if (m = error.message.match(/at line (\d+) column (\d+)/))
+        return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length);
+    return 0;
+}
+
+/**
+A language provider that provides JSON parsing.
+*/
+const jsonLanguage = /*@__PURE__*/LRLanguage.define({
+    name: "json",
+    parser: /*@__PURE__*/parser.configure({
+        props: [
+            /*@__PURE__*/indentNodeProp.add({
+                Object: /*@__PURE__*/continuedIndent({ except: /^\s*\}/ }),
+                Array: /*@__PURE__*/continuedIndent({ except: /^\s*\]/ })
+            }),
+            /*@__PURE__*/foldNodeProp.add({
+                "Object Array": foldInside
+            })
+        ]
+    }),
+    languageData: {
+        closeBrackets: { brackets: ["[", "{", '"'] },
+        indentOnInput: /^\s*[\}\]]$/
+    }
+});
+/**
+JSON language support.
+*/
+function json() {
+    return new LanguageSupport(jsonLanguage);
+}
+
+const ios = typeof navigator != "undefined" &&
+    !/*@__PURE__*//Edge\/(\d+)/.exec(navigator.userAgent) && /*@__PURE__*//Apple Computer/.test(navigator.vendor) &&
+    (/*@__PURE__*//Mobile\/\w+/.test(navigator.userAgent) || navigator.maxTouchPoints > 2);
+const Outside = "-10000px";
+class TooltipViewManager {
+    constructor(view, facet, createTooltipView) {
+        this.facet = facet;
+        this.createTooltipView = createTooltipView;
+        this.input = view.state.facet(facet);
+        this.tooltips = this.input.filter(t => t);
+        this.tooltipViews = this.tooltips.map(createTooltipView);
+    }
+    update(update) {
+        let input = update.state.facet(this.facet);
+        let tooltips = input.filter(x => x);
+        if (input === this.input) {
+            for (let t of this.tooltipViews)
+                if (t.update)
+                    t.update(update);
+            return false;
+        }
+        let tooltipViews = [];
+        for (let i = 0; i < tooltips.length; i++) {
+            let tip = tooltips[i], known = -1;
+            if (!tip)
+                continue;
+            for (let i = 0; i < this.tooltips.length; i++) {
+                let other = this.tooltips[i];
+                if (other && other.create == tip.create)
+                    known = i;
+            }
+            if (known < 0) {
+                tooltipViews[i] = this.createTooltipView(tip);
+            }
+            else {
+                let tooltipView = tooltipViews[i] = this.tooltipViews[known];
+                if (tooltipView.update)
+                    tooltipView.update(update);
+            }
+        }
+        for (let t of this.tooltipViews)
+            if (tooltipViews.indexOf(t) < 0)
+                t.dom.remove();
+        this.input = input;
+        this.tooltips = tooltips;
+        this.tooltipViews = tooltipViews;
+        return true;
+    }
+}
+function windowSpace() {
+    return { top: 0, left: 0, bottom: innerHeight, right: innerWidth };
 }
-const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
-/**
-Extension that will automatically insert JSX close tags when a `>` or
-`/` is typed.
-*/
-const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
-    if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
-        from != to || (text != ">" && text != "/") ||
-        !javascriptLanguage.isActiveAt(view.state, from, -1))
-        return false;
-    let base = defaultInsert(), { state } = base;
-    let closeTags = state.changeByRange(range => {
+const tooltipConfig = /*@__PURE__*/Facet.define({
+    combine: values => {
+        var _a, _b, _c;
+        return ({
+            position: ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
+            parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
+            tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,
+        });
+    }
+});
+const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
+    constructor(view) {
         var _a;
-        let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name;
-        if (around.name == "JSXStartTag")
-            around = around.parent;
-        if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
-        else if (text == ">" && around.name == "JSXFragmentTag") {
-            return { range, changes: { from: head, insert: `</>` } };
+        this.view = view;
+        this.inView = true;
+        this.lastTransaction = 0;
+        this.measureTimeout = -1;
+        let config = view.state.facet(tooltipConfig);
+        this.position = config.position;
+        this.parent = config.parent;
+        this.classes = view.themeClasses;
+        this.createContainer();
+        this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
+        this.manager = new TooltipViewManager(view, showTooltip, t => this.createTooltip(t));
+        this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
+            if (Date.now() > this.lastTransaction - 50 &&
+                entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
+                this.measureSoon();
+        }, { threshold: [1] }) : null;
+        this.observeIntersection();
+        (_a = view.dom.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
+        this.maybeMeasure();
+    }
+    createContainer() {
+        if (this.parent) {
+            this.container = document.createElement("div");
+            this.container.style.position = "relative";
+            this.container.className = this.view.themeClasses;
+            this.parent.appendChild(this.container);
         }
-        else if (text == "/" && around.name == "JSXStartCloseTag") {
-            let empty = around.parent, base = empty.parent;
-            if (base && empty.from == head - 2 &&
-                ((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
-                let insert = `${name}>`;
-                return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
+        else {
+            this.container = this.view.dom;
+        }
+    }
+    observeIntersection() {
+        if (this.intersectionObserver) {
+            this.intersectionObserver.disconnect();
+            for (let tooltip of this.manager.tooltipViews)
+                this.intersectionObserver.observe(tooltip.dom);
+        }
+    }
+    measureSoon() {
+        if (this.measureTimeout < 0)
+            this.measureTimeout = setTimeout(() => {
+                this.measureTimeout = -1;
+                this.maybeMeasure();
+            }, 50);
+    }
+    update(update) {
+        if (update.transactions.length)
+            this.lastTransaction = Date.now();
+        let updated = this.manager.update(update);
+        if (updated)
+            this.observeIntersection();
+        let shouldMeasure = updated || update.geometryChanged;
+        let newConfig = update.state.facet(tooltipConfig);
+        if (newConfig.position != this.position) {
+            this.position = newConfig.position;
+            for (let t of this.manager.tooltipViews)
+                t.dom.style.position = this.position;
+            shouldMeasure = true;
+        }
+        if (newConfig.parent != this.parent) {
+            if (this.parent)
+                this.container.remove();
+            this.parent = newConfig.parent;
+            this.createContainer();
+            for (let t of this.manager.tooltipViews)
+                this.container.appendChild(t.dom);
+            shouldMeasure = true;
+        }
+        else if (this.parent && this.view.themeClasses != this.classes) {
+            this.classes = this.container.className = this.view.themeClasses;
+        }
+        if (shouldMeasure)
+            this.maybeMeasure();
+    }
+    createTooltip(tooltip) {
+        let tooltipView = tooltip.create(this.view);
+        tooltipView.dom.classList.add("cm-tooltip");
+        if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
+            let arrow = document.createElement("div");
+            arrow.className = "cm-tooltip-arrow";
+            tooltipView.dom.appendChild(arrow);
+        }
+        tooltipView.dom.style.position = this.position;
+        tooltipView.dom.style.top = Outside;
+        this.container.appendChild(tooltipView.dom);
+        if (tooltipView.mount)
+            tooltipView.mount(this.view);
+        return tooltipView;
+    }
+    destroy() {
+        var _a, _b;
+        (_a = this.view.dom.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.removeEventListener("resize", this.measureSoon);
+        for (let { dom } of this.manager.tooltipViews)
+            dom.remove();
+        (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
+        clearTimeout(this.measureTimeout);
+    }
+    readMeasure() {
+        let editor = this.view.dom.getBoundingClientRect();
+        return {
+            editor,
+            parent: this.parent ? this.container.getBoundingClientRect() : editor,
+            pos: this.manager.tooltips.map((t, i) => {
+                let tv = this.manager.tooltipViews[i];
+                return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
+            }),
+            size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
+            space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
+        };
+    }
+    writeMeasure(measured) {
+        let { editor, space } = measured;
+        let others = [];
+        for (let i = 0; i < this.manager.tooltips.length; i++) {
+            let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
+            let pos = measured.pos[i], size = measured.size[i];
+            // Hide tooltips that are outside of the editor.
+            if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||
+                pos.top >= Math.min(editor.bottom, space.bottom) ||
+                pos.right < Math.max(editor.left, space.left) - .1 ||
+                pos.left > Math.min(editor.right, space.right) + .1) {
+                dom.style.top = Outside;
+                continue;
+            }
+            let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
+            let arrowHeight = arrow ? 7 /* Size */ : 0;
+            let width = size.right - size.left, height = size.bottom - size.top;
+            let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
+            let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
+                : ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
+                    : Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
+            let above = !!tooltip.above;
+            if (!tooltip.strictSide && (above
+                ? pos.top - (size.bottom - size.top) - offset.y < space.top
+                : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
+                above == (space.bottom - pos.bottom > pos.top - space.top))
+                above = !above;
+            let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
+            let right = left + width;
+            if (tView.overlap !== true)
+                for (let r of others)
+                    if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
+                        top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
+            if (this.position == "absolute") {
+                dom.style.top = (top - measured.parent.top) + "px";
+                dom.style.left = (left - measured.parent.left) + "px";
             }
+            else {
+                dom.style.top = top + "px";
+                dom.style.left = left + "px";
+            }
+            if (arrow)
+                arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
+            if (tView.overlap !== true)
+                others.push({ left, top, right, bottom: top + height });
+            dom.classList.toggle("cm-tooltip-above", above);
+            dom.classList.toggle("cm-tooltip-below", !above);
+            if (tView.positioned)
+                tView.positioned();
         }
-        else if (text == ">") {
-            let openTag = findOpenTag(around);
-            if (openTag && openTag.name == "JSXOpenTag" &&
-                !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
-                (name = elementName(state.doc, openTag, head)))
-                return { range, changes: { from: head, insert: `</${name}>` } };
+    }
+    maybeMeasure() {
+        if (this.manager.tooltips.length) {
+            if (this.view.inView)
+                this.view.requestMeasure(this.measureReq);
+            if (this.inView != this.view.inView) {
+                this.inView = this.view.inView;
+                if (!this.inView)
+                    for (let tv of this.manager.tooltipViews)
+                        tv.dom.style.top = Outside;
+            }
         }
-        return { range };
-    });
-    if (closeTags.changes.empty)
-        return false;
-    view.dispatch([
-        base,
-        state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
-    ]);
-    return true;
-});
-
-// Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
-const chalky = "#e5c07b", coral = "#e06c75", cyan = "#56b6c2", invalid = "#ffffff", ivory = "#abb2bf", stone = "#7d8799", // Brightened compared to original to increase contrast
-malibu = "#61afef", sage = "#98c379", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#2c313a", background = "#282c34", tooltipBackground = "#353a42", selection = "#3E4451", cursor = "#528bff";
-/**
-The editor theme styles for One Dark.
-*/
-const oneDarkTheme = /*@__PURE__*/EditorView.theme({
-    "&": {
-        color: ivory,
-        backgroundColor: background
-    },
-    ".cm-content": {
-        caretColor: cursor
-    },
-    ".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
-    "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
-    ".cm-panels": { backgroundColor: darkBackground, color: ivory },
-    ".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: background,
-        color: stone,
-        border: "none"
-    },
-    ".cm-activeLineGutter": {
-        backgroundColor: highlightBackground
+    }
+}, {
+    eventHandlers: {
+        scroll() { this.maybeMeasure(); }
+    }
+});
+const baseTheme = /*@__PURE__*/EditorView.baseTheme({
+    ".cm-tooltip": {
+        zIndex: 100
     },
-    ".cm-foldPlaceholder": {
-        backgroundColor: "transparent",
-        border: "none",
-        color: "#ddd"
+    "&light .cm-tooltip": {
+        border: "1px solid #bbb",
+        backgroundColor: "#f5f5f5"
     },
-    ".cm-tooltip": {
-        border: "none",
-        backgroundColor: tooltipBackground
+    "&light .cm-tooltip-section:not(:first-child)": {
+        borderTop: "1px solid #bbb",
     },
-    ".cm-tooltip .cm-tooltip-arrow:before": {
-        borderTopColor: "transparent",
-        borderBottomColor: "transparent"
+    "&dark .cm-tooltip": {
+        backgroundColor: "#333338",
+        color: "white"
     },
-    ".cm-tooltip .cm-tooltip-arrow:after": {
-        borderTopColor: tooltipBackground,
-        borderBottomColor: tooltipBackground
+    ".cm-tooltip-arrow": {
+        height: `${7 /* Size */}px`,
+        width: `${7 /* Size */ * 2}px`,
+        position: "absolute",
+        zIndex: -1,
+        overflow: "hidden",
+        "&:before, &:after": {
+            content: "''",
+            position: "absolute",
+            width: 0,
+            height: 0,
+            borderLeft: `${7 /* Size */}px solid transparent`,
+            borderRight: `${7 /* Size */}px solid transparent`,
+        },
+        ".cm-tooltip-above &": {
+            bottom: `-${7 /* Size */}px`,
+            "&:before": {
+                borderTop: `${7 /* Size */}px solid #bbb`,
+            },
+            "&:after": {
+                borderTop: `${7 /* Size */}px solid #f5f5f5`,
+                bottom: "1px"
+            }
+        },
+        ".cm-tooltip-below &": {
+            top: `-${7 /* Size */}px`,
+            "&:before": {
+                borderBottom: `${7 /* Size */}px solid #bbb`,
+            },
+            "&:after": {
+                borderBottom: `${7 /* Size */}px solid #f5f5f5`,
+                top: "1px"
+            }
+        },
     },
-    ".cm-tooltip-autocomplete": {
-        "& > ul > li[aria-selected]": {
-            backgroundColor: highlightBackground,
-            color: ivory
+    "&dark .cm-tooltip .cm-tooltip-arrow": {
+        "&:before": {
+            borderTopColor: "#333338",
+            borderBottomColor: "#333338"
+        },
+        "&:after": {
+            borderTopColor: "transparent",
+            borderBottomColor: "transparent"
         }
     }
-}, { dark: true });
+});
+const noOffset = { x: 0, y: 0 };
 /**
-The highlighting style for code in the One Dark theme.
+Behavior by which an extension can provide a tooltip to be shown.
 */
-const oneDarkHighlightStyle = /*@__PURE__*/HighlightStyle.define([
-    { tag: tags.keyword,
-        color: violet },
-    { tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
-        color: coral },
-    { tag: [/*@__PURE__*/tags.function(tags.variableName), tags.labelName],
-        color: malibu },
-    { tag: [tags.color, /*@__PURE__*/tags.constant(tags.name), /*@__PURE__*/tags.standard(tags.name)],
-        color: whiskey },
-    { tag: [/*@__PURE__*/tags.definition(tags.name), tags.separator],
-        color: ivory },
-    { tag: [tags.typeName, tags.className, tags.number, tags.changed, tags.annotation, tags.modifier, tags.self, tags.namespace],
-        color: chalky },
-    { tag: [tags.operator, tags.operatorKeyword, tags.url, tags.escape, tags.regexp, tags.link, /*@__PURE__*/tags.special(tags.string)],
-        color: cyan },
-    { tag: [tags.meta, tags.comment],
-        color: stone },
-    { tag: tags.strong,
-        fontWeight: "bold" },
-    { tag: tags.emphasis,
-        fontStyle: "italic" },
-    { tag: tags.strikethrough,
-        textDecoration: "line-through" },
-    { tag: tags.link,
-        color: stone,
-        textDecoration: "underline" },
-    { tag: tags.heading,
-        fontWeight: "bold",
-        color: coral },
-    { tag: [tags.atom, tags.bool, /*@__PURE__*/tags.special(tags.variableName)],
-        color: whiskey },
-    { tag: [tags.processingInstruction, tags.string, tags.inserted],
-        color: sage },
-    { tag: tags.invalid,
-        color: invalid },
-]);
+const showTooltip = /*@__PURE__*/Facet.define({
+    enables: [tooltipPlugin, baseTheme]
+});
+const showHoverTooltip = /*@__PURE__*/Facet.define();
+class HoverTooltipHost {
+    constructor(view) {
+        this.view = view;
+        this.mounted = false;
+        this.dom = document.createElement("div");
+        this.dom.classList.add("cm-tooltip-hover");
+        this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
+    }
+    // Needs to be static so that host tooltip instances always match
+    static create(view) {
+        return new HoverTooltipHost(view);
+    }
+    createHostedView(tooltip) {
+        let hostedView = tooltip.create(this.view);
+        hostedView.dom.classList.add("cm-tooltip-section");
+        this.dom.appendChild(hostedView.dom);
+        if (this.mounted && hostedView.mount)
+            hostedView.mount(this.view);
+        return hostedView;
+    }
+    mount(view) {
+        for (let hostedView of this.manager.tooltipViews) {
+            if (hostedView.mount)
+                hostedView.mount(view);
+        }
+        this.mounted = true;
+    }
+    positioned() {
+        for (let hostedView of this.manager.tooltipViews) {
+            if (hostedView.positioned)
+                hostedView.positioned();
+        }
+    }
+    update(update) {
+        this.manager.update(update);
+    }
+}
+const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
+    let tooltips = state.facet(showHoverTooltip).filter(t => t);
+    if (tooltips.length === 0)
+        return null;
+    return {
+        pos: Math.min(...tooltips.map(t => t.pos)),
+        end: Math.max(...tooltips.filter(t => t.end != null).map(t => t.end)),
+        create: HoverTooltipHost.create,
+        above: tooltips[0].above,
+        arrow: tooltips.some(t => t.arrow),
+    };
+});
+class HoverPlugin {
+    constructor(view, source, field, setHover, hoverTime) {
+        this.view = view;
+        this.source = source;
+        this.field = field;
+        this.setHover = setHover;
+        this.hoverTime = hoverTime;
+        this.hoverTimeout = -1;
+        this.restartTimeout = -1;
+        this.pending = null;
+        this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };
+        this.checkHover = this.checkHover.bind(this);
+        view.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this));
+        view.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
+    }
+    update() {
+        if (this.pending) {
+            this.pending = null;
+            clearTimeout(this.restartTimeout);
+            this.restartTimeout = setTimeout(() => this.startHover(), 20);
+        }
+    }
+    get active() {
+        return this.view.state.field(this.field);
+    }
+    checkHover() {
+        this.hoverTimeout = -1;
+        if (this.active)
+            return;
+        let hovered = Date.now() - this.lastMove.time;
+        if (hovered < this.hoverTime)
+            this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);
+        else
+            this.startHover();
+    }
+    startHover() {
+        var _a;
+        clearTimeout(this.restartTimeout);
+        let { lastMove } = this;
+        let pos = this.view.contentDOM.contains(lastMove.target) ? this.view.posAtCoords(lastMove) : null;
+        if (pos == null)
+            return;
+        let posCoords = this.view.coordsAtPos(pos);
+        if (posCoords == null || lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||
+            lastMove.x < posCoords.left - this.view.defaultCharacterWidth ||
+            lastMove.x > posCoords.right + this.view.defaultCharacterWidth)
+            return;
+        let bidi = this.view.bidiSpans(this.view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);
+        let rtl = bidi && bidi.dir == Direction.RTL ? -1 : 1;
+        let open = this.source(this.view, pos, (lastMove.x < posCoords.left ? -rtl : rtl));
+        if ((_a = open) === null || _a === void 0 ? void 0 : _a.then) {
+            let pending = this.pending = { pos };
+            open.then(result => {
+                if (this.pending == pending) {
+                    this.pending = null;
+                    if (result)
+                        this.view.dispatch({ effects: this.setHover.of(result) });
+                }
+            }, e => logException(this.view.state, e, "hover tooltip"));
+        }
+        else if (open) {
+            this.view.dispatch({ effects: this.setHover.of(open) });
+        }
+    }
+    mousemove(event) {
+        var _a;
+        this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };
+        if (this.hoverTimeout < 0)
+            this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
+        let tooltip = this.active;
+        if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
+            let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
+            if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
+                : !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
+                this.view.dispatch({ effects: this.setHover.of(null) });
+                this.pending = null;
+            }
+        }
+    }
+    mouseleave() {
+        clearTimeout(this.hoverTimeout);
+        this.hoverTimeout = -1;
+        if (this.active)
+            this.view.dispatch({ effects: this.setHover.of(null) });
+    }
+    destroy() {
+        clearTimeout(this.hoverTimeout);
+        this.view.dom.removeEventListener("mouseleave", this.mouseleave);
+        this.view.dom.removeEventListener("mousemove", this.mousemove);
+    }
+}
+function isInTooltip(elt) {
+    for (let cur = elt; cur; cur = cur.parentNode)
+        if (cur.nodeType == 1 && cur.classList.contains("cm-tooltip"))
+            return true;
+    return false;
+}
+function isOverRange(view, from, to, x, y, margin) {
+    let range = document.createRange();
+    let fromDOM = view.domAtPos(from), toDOM = view.domAtPos(to);
+    range.setEnd(toDOM.node, toDOM.offset);
+    range.setStart(fromDOM.node, fromDOM.offset);
+    let rects = range.getClientRects();
+    range.detach();
+    for (let i = 0; i < rects.length; i++) {
+        let rect = rects[i];
+        let dist = Math.max(rect.top - y, y - rect.bottom, rect.left - x, x - rect.right);
+        if (dist <= margin)
+            return true;
+    }
+    return false;
+}
 /**
-Extension to enable the One Dark theme (both the editor theme and
-the highlight style).
+Enable a hover tooltip, which shows up when the pointer hovers
+over ranges of text. The callback is called when the mouse hovers
+over the document text. It should, if there is a tooltip
+associated with position `pos` return the tooltip description
+(either directly or in a promise). The `side` argument indicates
+on which side of the position the pointer is—it will be -1 if the
+pointer is before the position, 1 if after the position.
+
+Note that all hover tooltips are hosted within a single tooltip
+container element. This allows multiple tooltips over the same
+range to be "merged" together without overlapping.
 */
-const oneDark = [oneDarkTheme, /*@__PURE__*/syntaxHighlighting(oneDarkHighlightStyle)];
+function hoverTooltip(source, options = {}) {
+    let setHover = StateEffect.define();
+    let hoverState = StateField.define({
+        create() { return null; },
+        update(value, tr) {
+            if (value && (options.hideOnChange && (tr.docChanged || tr.selection)))
+                return null;
+            for (let effect of tr.effects) {
+                if (effect.is(setHover))
+                    return effect.value;
+                if (effect.is(closeHoverTooltipEffect))
+                    return null;
+            }
+            if (value && tr.docChanged) {
+                let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);
+                if (newPos == null)
+                    return null;
+                let copy = Object.assign(Object.create(null), value);
+                copy.pos = newPos;
+                if (value.end != null)
+                    copy.end = tr.changes.mapPos(value.end);
+                return copy;
+            }
+            return value;
+        },
+        provide: f => showHoverTooltip.from(f)
+    });
+    return [
+        hoverState,
+        ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
+        showHoverTooltipHost
+    ];
+}
+const closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();
 
-export { EditorState, EditorView, autocompletion, basicSetup, javascript, language, lineNumbers, lintGutter, oneDark };
+export { Decoration, EditorState, EditorView, StateEffect, StateField, ViewPlugin, autocompletion, basicSetup, hoverTooltip, javascript, json, jsonParseLinter, language, lineNumbers, lintGutter, linter, oneDark, tooltips };
diff --git a/core/src/main/resources/static/codemirror-bundle.js b/core/src/main/resources/static/codemirror-bundle.js
deleted file mode 100644
index 53c90a02e..000000000
--- a/core/src/main/resources/static/codemirror-bundle.js
+++ /dev/null
@@ -1,67545 +0,0 @@
-(function () {
-   'use strict';
-
-   /**
-   The data structure for documents. @nonabstract
-   */
-   let Text$3 = class Text {
-       /**
-       @internal
-       */
-       constructor() {}
-       /**
-       Get the line description around the given position.
-       */
-       lineAt(pos) {
-           if (pos < 0 || pos > this.length)
-               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
-           return this.lineInner(pos, false, 1, 0);
-       }
-       /**
-       Get the description for the given (1-based) line number.
-       */
-       line(n) {
-           if (n < 1 || n > this.lines)
-               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
-           return this.lineInner(n, true, 1, 0);
-       }
-       /**
-       Replace a range of the text with the given content.
-       */
-       replace(from, to, text) {
-           let parts = [];
-           this.decompose(0, from, parts, 2 /* To */);
-           if (text.length)
-               text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
-           this.decompose(to, this.length, parts, 1 /* From */);
-           return TextNode$3.from(parts, this.length - (to - from) + text.length);
-       }
-       /**
-       Append another document to this one.
-       */
-       append(other) {
-           return this.replace(this.length, this.length, other);
-       }
-       /**
-       Retrieve the text between the given points.
-       */
-       slice(from, to = this.length) {
-           let parts = [];
-           this.decompose(from, to, parts, 0);
-           return TextNode$3.from(parts, to - from);
-       }
-       /**
-       Test whether this text is equal to another instance.
-       */
-       eq(other) {
-           if (other == this)
-               return true;
-           if (other.length != this.length || other.lines != this.lines)
-               return false;
-           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
-           let a = new RawTextCursor$3(this), b = new RawTextCursor$3(other);
-           for (let skip = start, pos = start;;) {
-               a.next(skip);
-               b.next(skip);
-               skip = 0;
-               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
-                   return false;
-               pos += a.value.length;
-               if (a.done || pos >= end)
-                   return true;
-           }
-       }
-       /**
-       Iterate over the text. When `dir` is `-1`, iteration happens
-       from end to start. This will return lines and the breaks between
-       them as separate strings.
-       */
-       iter(dir = 1) { return new RawTextCursor$3(this, dir); }
-       /**
-       Iterate over a range of the text. When `from` > `to`, the
-       iterator will run in reverse.
-       */
-       iterRange(from, to = this.length) { return new PartialTextCursor$3(this, from, to); }
-       /**
-       Return a cursor that iterates over the given range of lines,
-       _without_ returning the line breaks between, and yielding empty
-       strings for empty lines.
-       
-       When `from` and `to` are given, they should be 1-based line numbers.
-       */
-       iterLines(from, to) {
-           let inner;
-           if (from == null) {
-               inner = this.iter();
-           }
-           else {
-               if (to == null)
-                   to = this.lines + 1;
-               let start = this.line(from).from;
-               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
-           }
-           return new LineCursor$3(inner);
-       }
-       /**
-       @internal
-       */
-       toString() { return this.sliceString(0); }
-       /**
-       Convert the document to an array of lines (which can be
-       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
-       */
-       toJSON() {
-           let lines = [];
-           this.flatten(lines);
-           return lines;
-       }
-       /**
-       Create a `Text` instance for the given array of lines.
-       */
-       static of(text) {
-           if (text.length == 0)
-               throw new RangeError("A document must have at least one line");
-           if (text.length == 1 && !text[0])
-               return Text.empty;
-           return text.length <= 32 /* Branch */ ? new TextLeaf$3(text) : TextNode$3.from(TextLeaf$3.split(text, []));
-       }
-   };
-   // Leaves store an array of line strings. There are always line breaks
-   // between these strings. Leaves are limited in size and have to be
-   // contained in TextNode instances for bigger documents.
-   let TextLeaf$3 = class TextLeaf extends Text$3 {
-       constructor(text, length = textLength$3(text)) {
-           super();
-           this.text = text;
-           this.length = length;
-       }
-       get lines() { return this.text.length; }
-       get children() { return null; }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let string = this.text[i], end = offset + string.length;
-               if ((isLine ? line : end) >= target)
-                   return new Line$3(offset, end, line, string);
-               offset = end + 1;
-               line++;
-           }
-       }
-       decompose(from, to, target, open) {
-           let text = from <= 0 && to >= this.length ? this
-               : new TextLeaf(sliceText$3(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
-           if (open & 1 /* From */) {
-               let prev = target.pop();
-               let joined = appendText$3(text.text, prev.text.slice(), 0, text.length);
-               if (joined.length <= 32 /* Branch */) {
-                   target.push(new TextLeaf(joined, prev.length + text.length));
-               }
-               else {
-                   let mid = joined.length >> 1;
-                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
-               }
-           }
-           else {
-               target.push(text);
-           }
-       }
-       replace(from, to, text) {
-           if (!(text instanceof TextLeaf))
-               return super.replace(from, to, text);
-           let lines = appendText$3(this.text, appendText$3(text.text, sliceText$3(this.text, 0, from)), to);
-           let newLen = this.length + text.length - (to - from);
-           if (lines.length <= 32 /* Branch */)
-               return new TextLeaf(lines, newLen);
-           return TextNode$3.from(TextLeaf.split(lines, []), newLen);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           let result = "";
-           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
-               let line = this.text[i], end = pos + line.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += line.slice(Math.max(0, from - pos), to - pos);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let line of this.text)
-               target.push(line);
-       }
-       scanIdentical() { return 0; }
-       static split(text, target) {
-           let part = [], len = -1;
-           for (let line of text) {
-               part.push(line);
-               len += line.length + 1;
-               if (part.length == 32 /* Branch */) {
-                   target.push(new TextLeaf(part, len));
-                   part = [];
-                   len = -1;
-               }
-           }
-           if (len > -1)
-               target.push(new TextLeaf(part, len));
-           return target;
-       }
-   };
-   // Nodes provide the tree structure of the `Text` type. They store a
-   // number of other nodes or leaves, taking care to balance themselves
-   // on changes. There are implied line breaks _between_ the children of
-   // a node (but not before the first or after the last child).
-   let TextNode$3 = class TextNode extends Text$3 {
-       constructor(children, length) {
-           super();
-           this.children = children;
-           this.length = length;
-           this.lines = 0;
-           for (let child of children)
-               this.lines += child.lines;
-       }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
-               if ((isLine ? endLine : end) >= target)
-                   return child.lineInner(target, isLine, line, offset);
-               offset = end + 1;
-               line = endLine + 1;
-           }
-       }
-       decompose(from, to, target, open) {
-           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (from <= end && to >= pos) {
-                   let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
-                   if (pos >= from && end <= to && !childOpen)
-                       target.push(child);
-                   else
-                       child.decompose(from - pos, to - pos, target, childOpen);
-               }
-               pos = end + 1;
-           }
-       }
-       replace(from, to, text) {
-           if (text.lines < this.lines)
-               for (let i = 0, pos = 0; i < this.children.length; i++) {
-                   let child = this.children[i], end = pos + child.length;
-                   // Fast path: if the change only affects one child and the
-                   // child's size remains in the acceptable range, only update
-                   // that child
-                   if (from >= pos && to <= end) {
-                       let updated = child.replace(from - pos, to - pos, text);
-                       let totalLines = this.lines - child.lines + updated.lines;
-                       if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
-                           updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
-                           let copy = this.children.slice();
-                           copy[i] = updated;
-                           return new TextNode(copy, this.length - (to - from) + text.length);
-                       }
-                       return super.replace(pos, end, updated);
-                   }
-                   pos = end + 1;
-               }
-           return super.replace(from, to, text);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           let result = "";
-           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += child.sliceString(from - pos, to - pos, lineSep);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let child of this.children)
-               child.flatten(target);
-       }
-       scanIdentical(other, dir) {
-           if (!(other instanceof TextNode))
-               return 0;
-           let length = 0;
-           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
-               : [this.children.length - 1, other.children.length - 1, -1, -1];
-           for (;; iA += dir, iB += dir) {
-               if (iA == eA || iB == eB)
-                   return length;
-               let chA = this.children[iA], chB = other.children[iB];
-               if (chA != chB)
-                   return length + chA.scanIdentical(chB, dir);
-               length += chA.length + 1;
-           }
-       }
-       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
-           let lines = 0;
-           for (let ch of children)
-               lines += ch.lines;
-           if (lines < 32 /* Branch */) {
-               let flat = [];
-               for (let ch of children)
-                   ch.flatten(flat);
-               return new TextLeaf$3(flat, length);
-           }
-           let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
-           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
-           function add(child) {
-               let last;
-               if (child.lines > maxChunk && child instanceof TextNode) {
-                   for (let node of child.children)
-                       add(node);
-               }
-               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
-                   flush();
-                   chunked.push(child);
-               }
-               else if (child instanceof TextLeaf$3 && currentLines &&
-                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf$3 &&
-                   child.lines + last.lines <= 32 /* Branch */) {
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk[currentChunk.length - 1] = new TextLeaf$3(last.text.concat(child.text), last.length + 1 + child.length);
-               }
-               else {
-                   if (currentLines + child.lines > chunk)
-                       flush();
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk.push(child);
-               }
-           }
-           function flush() {
-               if (currentLines == 0)
-                   return;
-               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
-               currentLen = -1;
-               currentLines = currentChunk.length = 0;
-           }
-           for (let child of children)
-               add(child);
-           flush();
-           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
-       }
-   };
-   Text$3.empty = /*@__PURE__*/new TextLeaf$3([""], 0);
-   function textLength$3(text) {
-       let length = -1;
-       for (let line of text)
-           length += line.length + 1;
-       return length;
-   }
-   function appendText$3(text, target, from = 0, to = 1e9) {
-       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
-           let line = text[i], end = pos + line.length;
-           if (end >= from) {
-               if (end > to)
-                   line = line.slice(0, to - pos);
-               if (pos < from)
-                   line = line.slice(from - pos);
-               if (first) {
-                   target[target.length - 1] += line;
-                   first = false;
-               }
-               else
-                   target.push(line);
-           }
-           pos = end + 1;
-       }
-       return target;
-   }
-   function sliceText$3(text, from, to) {
-       return appendText$3(text, [""], from, to);
-   }
-   let RawTextCursor$3 = class RawTextCursor {
-       constructor(text, dir = 1) {
-           this.dir = dir;
-           this.done = false;
-           this.lineBreak = false;
-           this.value = "";
-           this.nodes = [text];
-           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf$3 ? text.text.length : text.children.length) << 1];
-       }
-       nextInner(skip, dir) {
-           this.done = this.lineBreak = false;
-           for (;;) {
-               let last = this.nodes.length - 1;
-               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
-               let size = top instanceof TextLeaf$3 ? top.text.length : top.children.length;
-               if (offset == (dir > 0 ? size : 0)) {
-                   if (last == 0) {
-                       this.done = true;
-                       this.value = "";
-                       return this;
-                   }
-                   if (dir > 0)
-                       this.offsets[last - 1]++;
-                   this.nodes.pop();
-                   this.offsets.pop();
-               }
-               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
-                   this.offsets[last] += dir;
-                   if (skip == 0) {
-                       this.lineBreak = true;
-                       this.value = "\n";
-                       return this;
-                   }
-                   skip--;
-               }
-               else if (top instanceof TextLeaf$3) {
-                   // Move to the next string
-                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
-                   this.offsets[last] += dir;
-                   if (next.length > Math.max(0, skip)) {
-                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
-                       return this;
-                   }
-                   skip -= next.length;
-               }
-               else {
-                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
-                   if (skip > next.length) {
-                       skip -= next.length;
-                       this.offsets[last] += dir;
-                   }
-                   else {
-                       if (dir < 0)
-                           this.offsets[last]--;
-                       this.nodes.push(next);
-                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf$3 ? next.text.length : next.children.length) << 1);
-                   }
-               }
-           }
-       }
-       next(skip = 0) {
-           if (skip < 0) {
-               this.nextInner(-skip, (-this.dir));
-               skip = this.value.length;
-           }
-           return this.nextInner(skip, this.dir);
-       }
-   };
-   let PartialTextCursor$3 = class PartialTextCursor {
-       constructor(text, start, end) {
-           this.value = "";
-           this.done = false;
-           this.cursor = new RawTextCursor$3(text, start > end ? -1 : 1);
-           this.pos = start > end ? text.length : 0;
-           this.from = Math.min(start, end);
-           this.to = Math.max(start, end);
-       }
-       nextInner(skip, dir) {
-           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
-               this.value = "";
-               this.done = true;
-               return this;
-           }
-           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
-           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
-           if (skip > limit)
-               skip = limit;
-           limit -= skip;
-           let { value } = this.cursor.next(skip);
-           this.pos += (value.length + skip) * dir;
-           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
-           this.done = !this.value;
-           return this;
-       }
-       next(skip = 0) {
-           if (skip < 0)
-               skip = Math.max(skip, this.from - this.pos);
-           else if (skip > 0)
-               skip = Math.min(skip, this.to - this.pos);
-           return this.nextInner(skip, this.cursor.dir);
-       }
-       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
-   };
-   let LineCursor$3 = class LineCursor {
-       constructor(inner) {
-           this.inner = inner;
-           this.afterBreak = true;
-           this.value = "";
-           this.done = false;
-       }
-       next(skip = 0) {
-           let { done, lineBreak, value } = this.inner.next(skip);
-           if (done) {
-               this.done = true;
-               this.value = "";
-           }
-           else if (lineBreak) {
-               if (this.afterBreak) {
-                   this.value = "";
-               }
-               else {
-                   this.afterBreak = true;
-                   this.next();
-               }
-           }
-           else {
-               this.value = value;
-               this.afterBreak = false;
-           }
-           return this;
-       }
-       get lineBreak() { return false; }
-   };
-   if (typeof Symbol != "undefined") {
-       Text$3.prototype[Symbol.iterator] = function () { return this.iter(); };
-       RawTextCursor$3.prototype[Symbol.iterator] = PartialTextCursor$3.prototype[Symbol.iterator] =
-           LineCursor$3.prototype[Symbol.iterator] = function () { return this; };
-   }
-   /**
-   This type describes a line in the document. It is created
-   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
-   */
-   let Line$3 = class Line {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The position of the start of the line.
-       */
-       from, 
-       /**
-       The position at the end of the line (_before_ the line break,
-       or at the end of document for the last line).
-       */
-       to, 
-       /**
-       This line's line number (1-based).
-       */
-       number, 
-       /**
-       The line's content.
-       */
-       text) {
-           this.from = from;
-           this.to = to;
-           this.number = number;
-           this.text = text;
-       }
-       /**
-       The length of the line (not including any line break after it).
-       */
-       get length() { return this.to - this.from; }
-   };
-
-   // Compressed representation of the Grapheme_Cluster_Break=Extend
-   // information from
-   // http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
-   // Each pair of elements represents a range, as an offet from the
-   // previous range and a length. Numbers are in base-36, with the empty
-   // string being a shorthand for 1.
-   let extend$2 = /*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
-   // Convert offsets into absolute values
-   for (let i = 1; i < extend$2.length; i++)
-       extend$2[i] += extend$2[i - 1];
-   function isExtendingChar$3(code) {
-       for (let i = 1; i < extend$2.length; i += 2)
-           if (extend$2[i] > code)
-               return extend$2[i - 1] <= code;
-       return false;
-   }
-   function isRegionalIndicator$3(code) {
-       return code >= 0x1F1E6 && code <= 0x1F1FF;
-   }
-   const ZWJ$3 = 0x200d;
-   /**
-   Returns a next grapheme cluster break _after_ (not equal to)
-   `pos`, if `forward` is true, or before otherwise. Returns `pos`
-   itself if no further cluster break is available in the string.
-   Moves across surrogate pairs, extending characters (when
-   `includeExtending` is true), characters joined with zero-width
-   joiners, and flag emoji.
-   */
-   function findClusterBreak$4(str, pos, forward = true, includeExtending = true) {
-       return (forward ? nextClusterBreak$3 : prevClusterBreak$3)(str, pos, includeExtending);
-   }
-   function nextClusterBreak$3(str, pos, includeExtending) {
-       if (pos == str.length)
-           return pos;
-       // If pos is in the middle of a surrogate pair, move to its start
-       if (pos && surrogateLow$4(str.charCodeAt(pos)) && surrogateHigh$4(str.charCodeAt(pos - 1)))
-           pos--;
-       let prev = codePointAt$4(str, pos);
-       pos += codePointSize$4(prev);
-       while (pos < str.length) {
-           let next = codePointAt$4(str, pos);
-           if (prev == ZWJ$3 || next == ZWJ$3 || includeExtending && isExtendingChar$3(next)) {
-               pos += codePointSize$4(next);
-               prev = next;
-           }
-           else if (isRegionalIndicator$3(next)) {
-               let countBefore = 0, i = pos - 2;
-               while (i >= 0 && isRegionalIndicator$3(codePointAt$4(str, i))) {
-                   countBefore++;
-                   i -= 2;
-               }
-               if (countBefore % 2 == 0)
-                   break;
-               else
-                   pos += 2;
-           }
-           else {
-               break;
-           }
-       }
-       return pos;
-   }
-   function prevClusterBreak$3(str, pos, includeExtending) {
-       while (pos > 0) {
-           let found = nextClusterBreak$3(str, pos - 2, includeExtending);
-           if (found < pos)
-               return found;
-           pos--;
-       }
-       return 0;
-   }
-   function surrogateLow$4(ch) { return ch >= 0xDC00 && ch < 0xE000; }
-   function surrogateHigh$4(ch) { return ch >= 0xD800 && ch < 0xDC00; }
-   /**
-   Find the code point at the given position in a string (like the
-   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
-   string method).
-   */
-   function codePointAt$4(str, pos) {
-       let code0 = str.charCodeAt(pos);
-       if (!surrogateHigh$4(code0) || pos + 1 == str.length)
-           return code0;
-       let code1 = str.charCodeAt(pos + 1);
-       if (!surrogateLow$4(code1))
-           return code0;
-       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
-   }
-   /**
-   Given a Unicode codepoint, return the JavaScript string that
-   respresents it (like
-   [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
-   */
-   function fromCodePoint$2(code) {
-       if (code <= 0xffff)
-           return String.fromCharCode(code);
-       code -= 0x10000;
-       return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
-   }
-   /**
-   The first character that takes up two positions in a JavaScript
-   string. It is often useful to compare with this after calling
-   `codePointAt`, to figure out whether your character takes up 1 or
-   2 index positions.
-   */
-   function codePointSize$4(code) { return code < 0x10000 ? 1 : 2; }
-
-   const DefaultSplit$3 = /\r\n?|\n/;
-   /**
-   Distinguishes different ways in which positions can be mapped.
-   */
-   var MapMode$3 = /*@__PURE__*/(function (MapMode) {
-       /**
-       Map a position to a valid new position, even when its context
-       was deleted.
-       */
-       MapMode[MapMode["Simple"] = 0] = "Simple";
-       /**
-       Return null if deletion happens across the position.
-       */
-       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
-       /**
-       Return null if the character _before_ the position is deleted.
-       */
-       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
-       /**
-       Return null if the character _after_ the position is deleted.
-       */
-       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
-   return MapMode})(MapMode$3 || (MapMode$3 = {}));
-   /**
-   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
-   that doesn't store the inserted text. As such, it can't be
-   applied, but is cheaper to store and manipulate.
-   */
-   let ChangeDesc$3 = class ChangeDesc {
-       // Sections are encoded as pairs of integers. The first is the
-       // length in the current document, and the second is -1 for
-       // unaffected sections, and the length of the replacement content
-       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
-       // 0), and a replacement two positive numbers.
-       constructor(
-       /**
-       @internal
-       */
-       sections) {
-           this.sections = sections;
-       }
-       /**
-       The length of the document before the change.
-       */
-       get length() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2)
-               result += this.sections[i];
-           return result;
-       }
-       /**
-       The length of the document after the change.
-       */
-       get newLength() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let ins = this.sections[i + 1];
-               result += ins < 0 ? this.sections[i] : ins;
-           }
-           return result;
-       }
-       /**
-       False when there are actual changes in this set.
-       */
-       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
-       /**
-       Iterate over the unchanged parts left by these changes. `posA`
-       provides the position of the range in the old document, `posB`
-       the new position in the changed document.
-       */
-       iterGaps(f) {
-           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0) {
-                   f(posA, posB, len);
-                   posB += len;
-               }
-               else {
-                   posB += ins;
-               }
-               posA += len;
-           }
-       }
-       /**
-       Iterate over the ranges changed by these changes. (See
-       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
-       variant that also provides you with the inserted text.)
-       `fromA`/`toA` provides the extent of the change in the starting
-       document, `fromB`/`toB` the extent of the replacement in the
-       changed document.
-       
-       When `individual` is true, adjacent changes (which are kept
-       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
-       reported separately.
-       */
-       iterChangedRanges(f, individual = false) {
-           iterChanges$3(this, f, individual);
-       }
-       /**
-       Get a description of the inverted form of these changes.
-       */
-       get invertedDesc() {
-           let sections = [];
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0)
-                   sections.push(len, ins);
-               else
-                   sections.push(ins, len);
-           }
-           return new ChangeDesc(sections);
-       }
-       /**
-       Compute the combined effect of applying another set of changes
-       after this one. The length of the document after this set should
-       match the length before `other`.
-       */
-       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets$3(this, other); }
-       /**
-       Map this description, which should start with the same document
-       as `other`, over another set of changes, so that it can be
-       applied after it. When `before` is true, map as if the changes
-       in `other` happened before the ones in `this`.
-       */
-       mapDesc(other, before = false) { return other.empty ? this : mapSet$3(this, other, before); }
-       mapPos(pos, assoc = -1, mode = MapMode$3.Simple) {
-           let posA = 0, posB = 0;
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
-               if (ins < 0) {
-                   if (endA > pos)
-                       return posB + (pos - posA);
-                   posB += len;
-               }
-               else {
-                   if (mode != MapMode$3.Simple && endA >= pos &&
-                       (mode == MapMode$3.TrackDel && posA < pos && endA > pos ||
-                           mode == MapMode$3.TrackBefore && posA < pos ||
-                           mode == MapMode$3.TrackAfter && endA > pos))
-                       return null;
-                   if (endA > pos || endA == pos && assoc < 0 && !len)
-                       return pos == posA || assoc < 0 ? posB : posB + ins;
-                   posB += ins;
-               }
-               posA = endA;
-           }
-           if (pos > posA)
-               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
-           return posB;
-       }
-       /**
-       Check whether these changes touch a given range. When one of the
-       changes entirely covers the range, the string `"cover"` is
-       returned.
-       */
-       touchesRange(from, to = from) {
-           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
-               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
-               if (ins >= 0 && pos <= to && end >= from)
-                   return pos < from && end > to ? "cover" : true;
-               pos = end;
-           }
-           return false;
-       }
-       /**
-       @internal
-       */
-       toString() {
-           let result = "";
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
-           }
-           return result;
-       }
-       /**
-       Serialize this change desc to a JSON-representable value.
-       */
-       toJSON() { return this.sections; }
-       /**
-       Create a change desc from its JSON representation (as produced
-       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
-               throw new RangeError("Invalid JSON representation of ChangeDesc");
-           return new ChangeDesc(json);
-       }
-       /**
-       @internal
-       */
-       static create(sections) { return new ChangeDesc(sections); }
-   };
-   /**
-   A change set represents a group of modifications to a document. It
-   stores the document length, and can only be applied to documents
-   with exactly that length.
-   */
-   let ChangeSet$3 = class ChangeSet extends ChangeDesc$3 {
-       constructor(sections, 
-       /**
-       @internal
-       */
-       inserted) {
-           super(sections);
-           this.inserted = inserted;
-       }
-       /**
-       Apply the changes to a document, returning the modified
-       document.
-       */
-       apply(doc) {
-           if (this.length != doc.length)
-               throw new RangeError("Applying change set to a document with the wrong length");
-           iterChanges$3(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
-           return doc;
-       }
-       mapDesc(other, before = false) { return mapSet$3(this, other, before, true); }
-       /**
-       Given the document as it existed _before_ the changes, return a
-       change set that represents the inverse of this set, which could
-       be used to go from the document created by the changes back to
-       the document as it existed before the changes.
-       */
-       invert(doc) {
-           let sections = this.sections.slice(), inserted = [];
-           for (let i = 0, pos = 0; i < sections.length; i += 2) {
-               let len = sections[i], ins = sections[i + 1];
-               if (ins >= 0) {
-                   sections[i] = ins;
-                   sections[i + 1] = len;
-                   let index = i >> 1;
-                   while (inserted.length < index)
-                       inserted.push(Text$3.empty);
-                   inserted.push(len ? doc.slice(pos, pos + len) : Text$3.empty);
-               }
-               pos += len;
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       Combine two subsequent change sets into a single set. `other`
-       must start in the document produced by `this`. If `this` goes
-       `docA` → `docB` and `other` represents `docB` → `docC`, the
-       returned value will represent the change `docA` → `docC`.
-       */
-       compose(other) { return this.empty ? other : other.empty ? this : composeSets$3(this, other, true); }
-       /**
-       Given another change set starting in the same document, maps this
-       change set over the other, producing a new change set that can be
-       applied to the document produced by applying `other`. When
-       `before` is `true`, order changes as if `this` comes before
-       `other`, otherwise (the default) treat `other` as coming first.
-       
-       Given two changes `A` and `B`, `A.compose(B.map(A))` and
-       `B.compose(A.map(B, true))` will produce the same document. This
-       provides a basic form of [operational
-       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
-       and can be used for collaborative editing.
-       */
-       map(other, before = false) { return other.empty ? this : mapSet$3(this, other, before, true); }
-       /**
-       Iterate over the changed ranges in the document, calling `f` for
-       each, with the range in the original document (`fromA`-`toA`)
-       and the range that replaces it in the new document
-       (`fromB`-`toB`).
-       
-       When `individual` is true, adjacent changes are reported
-       separately.
-       */
-       iterChanges(f, individual = false) {
-           iterChanges$3(this, f, individual);
-       }
-       /**
-       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
-       set.
-       */
-       get desc() { return ChangeDesc$3.create(this.sections); }
-       /**
-       @internal
-       */
-       filter(ranges) {
-           let resultSections = [], resultInserted = [], filteredSections = [];
-           let iter = new SectionIter$3(this);
-           done: for (let i = 0, pos = 0;;) {
-               let next = i == ranges.length ? 1e9 : ranges[i++];
-               while (pos < next || pos == next && iter.len == 0) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, next - pos);
-                   addSection$3(filteredSections, len, -1);
-                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
-                   addSection$3(resultSections, len, ins);
-                   if (ins > 0)
-                       addInsert$3(resultInserted, resultSections, iter.text);
-                   iter.forward(len);
-                   pos += len;
-               }
-               let end = ranges[i++];
-               while (pos < end) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, end - pos);
-                   addSection$3(resultSections, len, -1);
-                   addSection$3(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
-                   iter.forward(len);
-                   pos += len;
-               }
-           }
-           return { changes: new ChangeSet(resultSections, resultInserted),
-               filtered: ChangeDesc$3.create(filteredSections) };
-       }
-       /**
-       Serialize this change set to a JSON-representable value.
-       */
-       toJSON() {
-           let parts = [];
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let len = this.sections[i], ins = this.sections[i + 1];
-               if (ins < 0)
-                   parts.push(len);
-               else if (ins == 0)
-                   parts.push([len]);
-               else
-                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
-           }
-           return parts;
-       }
-       /**
-       Create a change set for the given changes, for a document of the
-       given length, using `lineSep` as line separator.
-       */
-       static of(changes, length, lineSep) {
-           let sections = [], inserted = [], pos = 0;
-           let total = null;
-           function flush(force = false) {
-               if (!force && !sections.length)
-                   return;
-               if (pos < length)
-                   addSection$3(sections, length - pos, -1);
-               let set = new ChangeSet(sections, inserted);
-               total = total ? total.compose(set.map(total)) : set;
-               sections = [];
-               inserted = [];
-               pos = 0;
-           }
-           function process(spec) {
-               if (Array.isArray(spec)) {
-                   for (let sub of spec)
-                       process(sub);
-               }
-               else if (spec instanceof ChangeSet) {
-                   if (spec.length != length)
-                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
-                   flush();
-                   total = total ? total.compose(spec.map(total)) : spec;
-               }
-               else {
-                   let { from, to = from, insert } = spec;
-                   if (from > to || from < 0 || to > length)
-                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
-                   let insText = !insert ? Text$3.empty : typeof insert == "string" ? Text$3.of(insert.split(lineSep || DefaultSplit$3)) : insert;
-                   let insLen = insText.length;
-                   if (from == to && insLen == 0)
-                       return;
-                   if (from < pos)
-                       flush();
-                   if (from > pos)
-                       addSection$3(sections, from - pos, -1);
-                   addSection$3(sections, to - from, insLen);
-                   addInsert$3(inserted, sections, insText);
-                   pos = to;
-               }
-           }
-           process(changes);
-           flush(!total);
-           return total;
-       }
-       /**
-       Create an empty changeset of the given length.
-       */
-       static empty(length) {
-           return new ChangeSet(length ? [length, -1] : [], []);
-       }
-       /**
-       Create a changeset from its JSON representation (as produced by
-       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json))
-               throw new RangeError("Invalid JSON representation of ChangeSet");
-           let sections = [], inserted = [];
-           for (let i = 0; i < json.length; i++) {
-               let part = json[i];
-               if (typeof part == "number") {
-                   sections.push(part, -1);
-               }
-               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
-                   throw new RangeError("Invalid JSON representation of ChangeSet");
-               }
-               else if (part.length == 1) {
-                   sections.push(part[0], 0);
-               }
-               else {
-                   while (inserted.length < i)
-                       inserted.push(Text$3.empty);
-                   inserted[i] = Text$3.of(part.slice(1));
-                   sections.push(part[0], inserted[i].length);
-               }
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       @internal
-       */
-       static createSet(sections, inserted) {
-           return new ChangeSet(sections, inserted);
-       }
-   };
-   function addSection$3(sections, len, ins, forceJoin = false) {
-       if (len == 0 && ins <= 0)
-           return;
-       let last = sections.length - 2;
-       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
-           sections[last] += len;
-       else if (len == 0 && sections[last] == 0)
-           sections[last + 1] += ins;
-       else if (forceJoin) {
-           sections[last] += len;
-           sections[last + 1] += ins;
-       }
-       else
-           sections.push(len, ins);
-   }
-   function addInsert$3(values, sections, value) {
-       if (value.length == 0)
-           return;
-       let index = (sections.length - 2) >> 1;
-       if (index < values.length) {
-           values[values.length - 1] = values[values.length - 1].append(value);
-       }
-       else {
-           while (values.length < index)
-               values.push(Text$3.empty);
-           values.push(value);
-       }
-   }
-   function iterChanges$3(desc, f, individual) {
-       let inserted = desc.inserted;
-       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
-           let len = desc.sections[i++], ins = desc.sections[i++];
-           if (ins < 0) {
-               posA += len;
-               posB += len;
-           }
-           else {
-               let endA = posA, endB = posB, text = Text$3.empty;
-               for (;;) {
-                   endA += len;
-                   endB += ins;
-                   if (ins && inserted)
-                       text = text.append(inserted[(i - 2) >> 1]);
-                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
-                       break;
-                   len = desc.sections[i++];
-                   ins = desc.sections[i++];
-               }
-               f(posA, endA, posB, endB, text);
-               posA = endA;
-               posB = endB;
-           }
-       }
-   }
-   function mapSet$3(setA, setB, before, mkSet = false) {
-       let sections = [], insert = mkSet ? [] : null;
-       let a = new SectionIter$3(setA), b = new SectionIter$3(setB);
-       for (let posA = 0, posB = 0;;) {
-           if (a.ins == -1) {
-               posA += a.len;
-               a.next();
-           }
-           else if (b.ins == -1 && posB < posA) {
-               let skip = Math.min(b.len, posA - posB);
-               b.forward(skip);
-               addSection$3(sections, skip, -1);
-               posB += skip;
-           }
-           else if (b.ins >= 0 && (a.done || posB < posA || posB == posA && (b.len < a.len || b.len == a.len && !before))) {
-               addSection$3(sections, b.ins, -1);
-               while (posA > posB && !a.done && posA + a.len < posB + b.len) {
-                   posA += a.len;
-                   a.next();
-               }
-               posB += b.len;
-               b.next();
-           }
-           else if (a.ins >= 0) {
-               let len = 0, end = posA + a.len;
-               for (;;) {
-                   if (b.ins >= 0 && posB > posA && posB + b.len < end) {
-                       len += b.ins;
-                       posB += b.len;
-                       b.next();
-                   }
-                   else if (b.ins == -1 && posB < end) {
-                       let skip = Math.min(b.len, end - posB);
-                       len += skip;
-                       b.forward(skip);
-                       posB += skip;
-                   }
-                   else {
-                       break;
-                   }
-               }
-               addSection$3(sections, len, a.ins);
-               if (insert)
-                   addInsert$3(insert, sections, a.text);
-               posA = end;
-               a.next();
-           }
-           else if (a.done && b.done) {
-               return insert ? ChangeSet$3.createSet(sections, insert) : ChangeDesc$3.create(sections);
-           }
-           else {
-               throw new Error("Mismatched change set lengths");
-           }
-       }
-   }
-   function composeSets$3(setA, setB, mkSet = false) {
-       let sections = [];
-       let insert = mkSet ? [] : null;
-       let a = new SectionIter$3(setA), b = new SectionIter$3(setB);
-       for (let open = false;;) {
-           if (a.done && b.done) {
-               return insert ? ChangeSet$3.createSet(sections, insert) : ChangeDesc$3.create(sections);
-           }
-           else if (a.ins == 0) { // Deletion in A
-               addSection$3(sections, a.len, 0, open);
-               a.next();
-           }
-           else if (b.len == 0 && !b.done) { // Insertion in B
-               addSection$3(sections, 0, b.ins, open);
-               if (insert)
-                   addInsert$3(insert, sections, b.text);
-               b.next();
-           }
-           else if (a.done || b.done) {
-               throw new Error("Mismatched change set lengths");
-           }
-           else {
-               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
-               if (a.ins == -1) {
-                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
-                   addSection$3(sections, len, insB, open);
-                   if (insert && insB)
-                       addInsert$3(insert, sections, b.text);
-               }
-               else if (b.ins == -1) {
-                   addSection$3(sections, a.off ? 0 : a.len, len, open);
-                   if (insert)
-                       addInsert$3(insert, sections, a.textBit(len));
-               }
-               else {
-                   addSection$3(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
-                   if (insert && !b.off)
-                       addInsert$3(insert, sections, b.text);
-               }
-               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
-               a.forward2(len);
-               b.forward(len);
-           }
-       }
-   }
-   let SectionIter$3 = class SectionIter {
-       constructor(set) {
-           this.set = set;
-           this.i = 0;
-           this.next();
-       }
-       next() {
-           let { sections } = this.set;
-           if (this.i < sections.length) {
-               this.len = sections[this.i++];
-               this.ins = sections[this.i++];
-           }
-           else {
-               this.len = 0;
-               this.ins = -2;
-           }
-           this.off = 0;
-       }
-       get done() { return this.ins == -2; }
-       get len2() { return this.ins < 0 ? this.len : this.ins; }
-       get text() {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length ? Text$3.empty : inserted[index];
-       }
-       textBit(len) {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length && !len ? Text$3.empty
-               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
-       }
-       forward(len) {
-           if (len == this.len)
-               this.next();
-           else {
-               this.len -= len;
-               this.off += len;
-           }
-       }
-       forward2(len) {
-           if (this.ins == -1)
-               this.forward(len);
-           else if (len == this.ins)
-               this.next();
-           else {
-               this.ins -= len;
-               this.off += len;
-           }
-       }
-   };
-
-   /**
-   A single selection range. When
-   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
-   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
-   multiple ranges. By default, selections hold exactly one range.
-   */
-   let SelectionRange$3 = class SelectionRange {
-       constructor(
-       /**
-       The lower boundary of the range.
-       */
-       from, 
-       /**
-       The upper boundary of the range.
-       */
-       to, flags) {
-           this.from = from;
-           this.to = to;
-           this.flags = flags;
-       }
-       /**
-       The anchor of the range—the side that doesn't move when you
-       extend it.
-       */
-       get anchor() { return this.flags & 16 /* Inverted */ ? 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 & 16 /* Inverted */ ? 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 & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
-       /**
-       The bidirectional text level associated with this cursor, if
-       any.
-       */
-       get bidiLevel() {
-           let level = this.flags & 3 /* BidiLevelMask */;
-           return level == 3 ? null : level;
-       }
-       /**
-       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 value = this.flags >> 5 /* GoalColumnOffset */;
-           return value == 33554431 /* NoGoalColumn */ ? undefined : value;
-       }
-       /**
-       Map this range through a change, producing a valid range in the
-       updated document.
-       */
-       map(change, assoc = -1) {
-           let from, to;
-           if (this.empty) {
-               from = to = change.mapPos(this.from, assoc);
-           }
-           else {
-               from = change.mapPos(this.from, 1);
-               to = change.mapPos(this.to, -1);
-           }
-           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
-       }
-       /**
-       Extend this range to cover at least `from` to `to`.
-       */
-       extend(from, to = from) {
-           if (from <= this.anchor && to >= this.anchor)
-               return EditorSelection$3.range(from, to);
-           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
-           return EditorSelection$3.range(this.anchor, head);
-       }
-       /**
-       Compare this range to another range.
-       */
-       eq(other) {
-           return this.anchor == other.anchor && this.head == other.head;
-       }
-       /**
-       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(json) {
-           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
-               throw new RangeError("Invalid JSON representation for SelectionRange");
-           return EditorSelection$3.range(json.anchor, json.head);
-       }
-       /**
-       @internal
-       */
-       static create(from, to, flags) {
-           return new SelectionRange(from, to, flags);
-       }
-   };
-   /**
-   An editor selection holds one or more selection ranges.
-   */
-   let EditorSelection$3 = class EditorSelection {
-       constructor(
-       /**
-       The ranges in the selection, sorted by position. Ranges cannot
-       overlap (but they may touch, if they aren't empty).
-       */
-       ranges, 
-       /**
-       The index of the _main_ range in the selection (which is
-       usually the range that was added last).
-       */
-       mainIndex) {
-           this.ranges = ranges;
-           this.mainIndex = mainIndex;
-       }
-       /**
-       Map a selection through a change. Used to adjust the selection
-       position for changes.
-       */
-       map(change, assoc = -1) {
-           if (change.empty)
-               return this;
-           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
-       }
-       /**
-       Compare this selection to another selection.
-       */
-       eq(other) {
-           if (this.ranges.length != other.ranges.length ||
-               this.mainIndex != other.mainIndex)
-               return false;
-           for (let i = 0; i < this.ranges.length; i++)
-               if (!this.ranges[i].eq(other.ranges[i]))
-                   return false;
-           return true;
-       }
-       /**
-       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 EditorSelection([this.main], 0);
-       }
-       /**
-       Extend this selection with an extra range.
-       */
-       addRange(range, main = true) {
-           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
-       }
-       /**
-       Replace a given range with another range, and then normalize the
-       selection to merge and sort ranges if necessary.
-       */
-       replaceRange(range, which = this.mainIndex) {
-           let ranges = this.ranges.slice();
-           ranges[which] = range;
-           return EditorSelection.create(ranges, this.mainIndex);
-       }
-       /**
-       Convert this selection to an object that can be serialized to
-       JSON.
-       */
-       toJSON() {
-           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
-       }
-       /**
-       Create a selection from a JSON representation.
-       */
-       static fromJSON(json) {
-           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
-               throw new RangeError("Invalid JSON representation for EditorSelection");
-           return new EditorSelection(json.ranges.map((r) => SelectionRange$3.fromJSON(r)), json.main);
-       }
-       /**
-       Create a selection holding a single range.
-       */
-       static single(anchor, head = anchor) {
-           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
-       }
-       /**
-       Sort and merge the given set of ranges, creating a valid
-       selection.
-       */
-       static create(ranges, mainIndex = 0) {
-           if (ranges.length == 0)
-               throw new RangeError("A selection needs at least one range");
-           for (let pos = 0, i = 0; i < ranges.length; i++) {
-               let range = ranges[i];
-               if (range.empty ? range.from <= pos : range.from < pos)
-                   return EditorSelection.normalized(ranges.slice(), mainIndex);
-               pos = range.to;
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-       /**
-       Create a cursor selection range at the given position. You can
-       safely ignore the optional arguments in most situations.
-       */
-       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
-           return SelectionRange$3.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
-               (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
-               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
-       }
-       /**
-       Create a selection range.
-       */
-       static range(anchor, head, goalColumn) {
-           let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
-           return head < anchor ? SelectionRange$3.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
-               : SelectionRange$3.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
-       }
-       /**
-       @internal
-       */
-       static normalized(ranges, mainIndex = 0) {
-           let main = ranges[mainIndex];
-           ranges.sort((a, b) => a.from - b.from);
-           mainIndex = ranges.indexOf(main);
-           for (let i = 1; i < ranges.length; i++) {
-               let range = ranges[i], prev = ranges[i - 1];
-               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
-                   let from = prev.from, to = Math.max(range.to, prev.to);
-                   if (i <= mainIndex)
-                       mainIndex--;
-                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
-               }
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-   };
-   function checkSelection$3(selection, docLength) {
-       for (let range of selection.ranges)
-           if (range.to > docLength)
-               throw new RangeError("Selection points outside of document");
-   }
-
-   let nextID$3 = 0;
-   /**
-   A facet is a labeled value that is associated with an editor
-   state. It takes inputs from any number of extensions, and combines
-   those into a single output value.
-
-   Examples of uses of facets are the [tab
-   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
-   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
-   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
-   */
-   let Facet$3 = class Facet {
-       constructor(
-       /**
-       @internal
-       */
-       combine, 
-       /**
-       @internal
-       */
-       compareInput, 
-       /**
-       @internal
-       */
-       compare, isStatic, 
-       /**
-       @internal
-       */
-       extensions) {
-           this.combine = combine;
-           this.compareInput = compareInput;
-           this.compare = compare;
-           this.isStatic = isStatic;
-           this.extensions = extensions;
-           /**
-           @internal
-           */
-           this.id = nextID$3++;
-           this.default = combine([]);
-       }
-       /**
-       Define a new facet.
-       */
-       static define(config = {}) {
-           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$6 : (a, b) => a === b), !!config.static, config.enables);
-       }
-       /**
-       Returns an extension that adds the given value to this facet.
-       */
-       of(value) {
-           return new FacetProvider$3([], this, 0 /* Static */, value);
-       }
-       /**
-       Create an extension that computes a value for the facet from a
-       state. You must take care to declare the parts of the state that
-       this value depends on, since your function is only called again
-       for a new state when one of those parts changed.
-       
-       In cases where your value depends only on a single field, you'll
-       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
-       */
-       compute(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider$3(deps, this, 1 /* Single */, get);
-       }
-       /**
-       Create an extension that computes zero or more values for this
-       facet from a state.
-       */
-       computeN(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider$3(deps, this, 2 /* Multi */, get);
-       }
-       from(field, get) {
-           if (!get)
-               get = x => x;
-           return this.compute([field], state => get(state.field(field)));
-       }
-   };
-   function sameArray$6(a, b) {
-       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
-   }
-   let FacetProvider$3 = class FacetProvider {
-       constructor(dependencies, facet, type, value) {
-           this.dependencies = dependencies;
-           this.facet = facet;
-           this.type = type;
-           this.value = value;
-           this.id = nextID$3++;
-       }
-       dynamicSlot(addresses) {
-           var _a;
-           let getter = this.value;
-           let compare = this.facet.compareInput;
-           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
-           let depDoc = false, depSel = false, depAddrs = [];
-           for (let dep of this.dependencies) {
-               if (dep == "doc")
-                   depDoc = true;
-               else if (dep == "selection")
-                   depSel = true;
-               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
-                   depAddrs.push(addresses[dep.id]);
-           }
-           return {
-               create(state) {
-                   state.values[idx] = getter(state);
-                   return 1 /* Changed */;
-               },
-               update(state, tr) {
-                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll$3(state, depAddrs)) {
-                       let newVal = getter(state);
-                       if (multi ? !compareArray$3(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
-                           state.values[idx] = newVal;
-                           return 1 /* Changed */;
-                       }
-                   }
-                   return 0;
-               },
-               reconfigure: (state, oldState) => {
-                   let newVal = getter(state);
-                   let oldAddr = oldState.config.address[id];
-                   if (oldAddr != null) {
-                       let oldVal = getAddr$3(oldState, oldAddr);
-                       if (this.dependencies.every(dep => {
-                           return dep instanceof Facet$3 ? oldState.facet(dep) === state.facet(dep) :
-                               dep instanceof StateField$3 ? oldState.field(dep, false) == state.field(dep, false) : true;
-                       }) || (multi ? compareArray$3(newVal, oldVal, compare) : compare(newVal, oldVal))) {
-                           state.values[idx] = oldVal;
-                           return 0;
-                       }
-                   }
-                   state.values[idx] = newVal;
-                   return 1 /* Changed */;
-               }
-           };
-       }
-   };
-   function compareArray$3(a, b, compare) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (!compare(a[i], b[i]))
-               return false;
-       return true;
-   }
-   function ensureAll$3(state, addrs) {
-       let changed = false;
-       for (let addr of addrs)
-           if (ensureAddr$3(state, addr) & 1 /* Changed */)
-               changed = true;
-       return changed;
-   }
-   function dynamicFacetSlot$3(addresses, facet, providers) {
-       let providerAddrs = providers.map(p => addresses[p.id]);
-       let providerTypes = providers.map(p => p.type);
-       let dynamic = providerAddrs.filter(p => !(p & 1));
-       let idx = addresses[facet.id] >> 1;
-       function get(state) {
-           let values = [];
-           for (let i = 0; i < providerAddrs.length; i++) {
-               let value = getAddr$3(state, providerAddrs[i]);
-               if (providerTypes[i] == 2 /* Multi */)
-                   for (let val of value)
-                       values.push(val);
-               else
-                   values.push(value);
-           }
-           return facet.combine(values);
-       }
-       return {
-           create(state) {
-               for (let addr of providerAddrs)
-                   ensureAddr$3(state, addr);
-               state.values[idx] = get(state);
-               return 1 /* Changed */;
-           },
-           update(state, tr) {
-               if (!ensureAll$3(state, dynamic))
-                   return 0;
-               let value = get(state);
-               if (facet.compare(value, state.values[idx]))
-                   return 0;
-               state.values[idx] = value;
-               return 1 /* Changed */;
-           },
-           reconfigure(state, oldState) {
-               let depChanged = ensureAll$3(state, providerAddrs);
-               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
-               if (oldProviders && !depChanged && sameArray$6(providers, oldProviders)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               let value = get(state);
-               if (facet.compare(value, oldValue)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               state.values[idx] = value;
-               return 1 /* Changed */;
-           }
-       };
-   }
-   const initField$3 = /*@__PURE__*/Facet$3.define({ static: true });
-   /**
-   Fields can store additional information in an editor state, and
-   keep it in sync with the rest of the state.
-   */
-   let StateField$3 = class StateField {
-       constructor(
-       /**
-       @internal
-       */
-       id, createF, updateF, compareF, 
-       /**
-       @internal
-       */
-       spec) {
-           this.id = id;
-           this.createF = createF;
-           this.updateF = updateF;
-           this.compareF = compareF;
-           this.spec = spec;
-           /**
-           @internal
-           */
-           this.provides = undefined;
-       }
-       /**
-       Define a state field.
-       */
-       static define(config) {
-           let field = new StateField(nextID$3++, config.create, config.update, config.compare || ((a, b) => a === b), config);
-           if (config.provide)
-               field.provides = config.provide(field);
-           return field;
-       }
-       create(state) {
-           let init = state.facet(initField$3).find(i => i.field == this);
-           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
-       }
-       /**
-       @internal
-       */
-       slot(addresses) {
-           let idx = addresses[this.id] >> 1;
-           return {
-               create: (state) => {
-                   state.values[idx] = this.create(state);
-                   return 1 /* Changed */;
-               },
-               update: (state, tr) => {
-                   let oldVal = state.values[idx];
-                   let value = this.updateF(oldVal, tr);
-                   if (this.compareF(oldVal, value))
-                       return 0;
-                   state.values[idx] = value;
-                   return 1 /* Changed */;
-               },
-               reconfigure: (state, oldState) => {
-                   if (oldState.config.address[this.id] != null) {
-                       state.values[idx] = oldState.field(this);
-                       return 0;
-                   }
-                   state.values[idx] = this.create(state);
-                   return 1 /* Changed */;
-               }
-           };
-       }
-       /**
-       Returns an extension that enables this field and overrides the
-       way it is initialized. Can be useful when you need to provide a
-       non-default starting value for the field.
-       */
-       init(create) {
-           return [this, initField$3.of({ field: this, create })];
-       }
-       /**
-       State field instances can be used as
-       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
-       given state.
-       */
-       get extension() { return this; }
-   };
-   const Prec_$3 = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
-   function prec$3(value) {
-       return (ext) => new PrecExtension$3(ext, value);
-   }
-   /**
-   By default extensions are registered in the order they are found
-   in the flattened form of nested array that was provided.
-   Individual extension values can be assigned a precedence to
-   override this. Extensions that do not have a precedence set get
-   the precedence of the nearest parent with a precedence, or
-   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
-   final ordering of extensions is determined by first sorting by
-   precedence and then by order within each precedence.
-   */
-   const Prec$3 = {
-       /**
-       The highest precedence level, for extensions that should end up
-       near the start of the precedence ordering.
-       */
-       highest: /*@__PURE__*/prec$3(Prec_$3.highest),
-       /**
-       A higher-than-default precedence, for extensions that should
-       come before those with default precedence.
-       */
-       high: /*@__PURE__*/prec$3(Prec_$3.high),
-       /**
-       The default precedence, which is also used for extensions
-       without an explicit precedence.
-       */
-       default: /*@__PURE__*/prec$3(Prec_$3.default),
-       /**
-       A lower-than-default precedence.
-       */
-       low: /*@__PURE__*/prec$3(Prec_$3.low),
-       /**
-       The lowest precedence level. Meant for things that should end up
-       near the end of the extension order.
-       */
-       lowest: /*@__PURE__*/prec$3(Prec_$3.lowest)
-   };
-   let PrecExtension$3 = class PrecExtension {
-       constructor(inner, prec) {
-           this.inner = inner;
-           this.prec = prec;
-       }
-   };
-   /**
-   Extension compartments can be used to make a configuration
-   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
-   configuration in a compartment, you can later
-   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
-   transaction.
-   */
-   let Compartment$3 = class Compartment {
-       /**
-       Create an instance of this compartment to add to your [state
-       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
-       */
-       of(ext) { return new CompartmentInstance$3(this, ext); }
-       /**
-       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
-       reconfigures this compartment.
-       */
-       reconfigure(content) {
-           return Compartment.reconfigure.of({ compartment: this, extension: content });
-       }
-       /**
-       Get the current content of the compartment in the state, or
-       `undefined` if it isn't present.
-       */
-       get(state) {
-           return state.config.compartments.get(this);
-       }
-   };
-   let CompartmentInstance$3 = class CompartmentInstance {
-       constructor(compartment, inner) {
-           this.compartment = compartment;
-           this.inner = inner;
-       }
-   };
-   let Configuration$3 = class Configuration {
-       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
-           this.base = base;
-           this.compartments = compartments;
-           this.dynamicSlots = dynamicSlots;
-           this.address = address;
-           this.staticValues = staticValues;
-           this.facets = facets;
-           this.statusTemplate = [];
-           while (this.statusTemplate.length < dynamicSlots.length)
-               this.statusTemplate.push(0 /* Unresolved */);
-       }
-       staticFacet(facet) {
-           let addr = this.address[facet.id];
-           return addr == null ? facet.default : this.staticValues[addr >> 1];
-       }
-       static resolve(base, compartments, oldState) {
-           let fields = [];
-           let facets = Object.create(null);
-           let newCompartments = new Map();
-           for (let ext of flatten$3(base, compartments, newCompartments)) {
-               if (ext instanceof StateField$3)
-                   fields.push(ext);
-               else
-                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
-           }
-           let address = Object.create(null);
-           let staticValues = [];
-           let dynamicSlots = [];
-           for (let field of fields) {
-               address[field.id] = dynamicSlots.length << 1;
-               dynamicSlots.push(a => field.slot(a));
-           }
-           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
-           for (let id in facets) {
-               let providers = facets[id], facet = providers[0].facet;
-               let oldProviders = oldFacets && oldFacets[id] || [];
-               if (providers.every(p => p.type == 0 /* Static */)) {
-                   address[facet.id] = (staticValues.length << 1) | 1;
-                   if (sameArray$6(oldProviders, providers)) {
-                       staticValues.push(oldState.facet(facet));
-                   }
-                   else {
-                       let value = facet.combine(providers.map(p => p.value));
-                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
-                   }
-               }
-               else {
-                   for (let p of providers) {
-                       if (p.type == 0 /* Static */) {
-                           address[p.id] = (staticValues.length << 1) | 1;
-                           staticValues.push(p.value);
-                       }
-                       else {
-                           address[p.id] = dynamicSlots.length << 1;
-                           dynamicSlots.push(a => p.dynamicSlot(a));
-                       }
-                   }
-                   address[facet.id] = dynamicSlots.length << 1;
-                   dynamicSlots.push(a => dynamicFacetSlot$3(a, facet, providers));
-               }
-           }
-           let dynamic = dynamicSlots.map(f => f(address));
-           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
-       }
-   };
-   function flatten$3(extension, compartments, newCompartments) {
-       let result = [[], [], [], [], []];
-       let seen = new Map();
-       function inner(ext, prec) {
-           let known = seen.get(ext);
-           if (known != null) {
-               if (known <= prec)
-                   return;
-               let found = result[known].indexOf(ext);
-               if (found > -1)
-                   result[known].splice(found, 1);
-               if (ext instanceof CompartmentInstance$3)
-                   newCompartments.delete(ext.compartment);
-           }
-           seen.set(ext, prec);
-           if (Array.isArray(ext)) {
-               for (let e of ext)
-                   inner(e, prec);
-           }
-           else if (ext instanceof CompartmentInstance$3) {
-               if (newCompartments.has(ext.compartment))
-                   throw new RangeError(`Duplicate use of compartment in extensions`);
-               let content = compartments.get(ext.compartment) || ext.inner;
-               newCompartments.set(ext.compartment, content);
-               inner(content, prec);
-           }
-           else if (ext instanceof PrecExtension$3) {
-               inner(ext.inner, ext.prec);
-           }
-           else if (ext instanceof StateField$3) {
-               result[prec].push(ext);
-               if (ext.provides)
-                   inner(ext.provides, prec);
-           }
-           else if (ext instanceof FacetProvider$3) {
-               result[prec].push(ext);
-               if (ext.facet.extensions)
-                   inner(ext.facet.extensions, prec);
-           }
-           else {
-               let content = ext.extension;
-               if (!content)
-                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
-               inner(content, prec);
-           }
-       }
-       inner(extension, Prec_$3.default);
-       return result.reduce((a, b) => a.concat(b));
-   }
-   function ensureAddr$3(state, addr) {
-       if (addr & 1)
-           return 2 /* Computed */;
-       let idx = addr >> 1;
-       let status = state.status[idx];
-       if (status == 4 /* Computing */)
-           throw new Error("Cyclic dependency between fields and/or facets");
-       if (status & 2 /* Computed */)
-           return status;
-       state.status[idx] = 4 /* Computing */;
-       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
-       return state.status[idx] = 2 /* Computed */ | changed;
-   }
-   function getAddr$3(state, addr) {
-       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
-   }
-
-   const languageData$3 = /*@__PURE__*/Facet$3.define();
-   const allowMultipleSelections$3 = /*@__PURE__*/Facet$3.define({
-       combine: values => values.some(v => v),
-       static: true
-   });
-   const lineSeparator$3 = /*@__PURE__*/Facet$3.define({
-       combine: values => values.length ? values[0] : undefined,
-       static: true
-   });
-   const changeFilter$3 = /*@__PURE__*/Facet$3.define();
-   const transactionFilter$3 = /*@__PURE__*/Facet$3.define();
-   const transactionExtender$3 = /*@__PURE__*/Facet$3.define();
-   const readOnly$3 = /*@__PURE__*/Facet$3.define({
-       combine: values => values.length ? values[0] : false
-   });
-
-   /**
-   Annotations are tagged values that are used to add metadata to
-   transactions in an extensible way. They should be used to model
-   things that effect the entire transaction (such as its [time
-   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
-   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
-   _alongside_ the other changes made by the transaction, [state
-   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
-   */
-   let Annotation$3 = class Annotation {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The annotation type.
-       */
-       type, 
-       /**
-       The value of this annotation.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Define a new type of annotation.
-       */
-       static define() { return new AnnotationType$3(); }
-   };
-   /**
-   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
-   */
-   let AnnotationType$3 = class AnnotationType {
-       /**
-       Create an instance of this annotation.
-       */
-       of(value) { return new Annotation$3(this, value); }
-   };
-   /**
-   Representation of a type of state effect. Defined with
-   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
-   */
-   let StateEffectType$3 = class StateEffectType {
-       /**
-       @internal
-       */
-       constructor(
-       // The `any` types in these function types are there to work
-       // around TypeScript issue #37631, where the type guard on
-       // `StateEffect.is` mysteriously stops working when these properly
-       // have type `Value`.
-       /**
-       @internal
-       */
-       map) {
-           this.map = map;
-       }
-       /**
-       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
-       type.
-       */
-       of(value) { return new StateEffect$3(this, value); }
-   };
-   /**
-   State effects can be used to represent additional effects
-   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
-   are often useful to model changes to custom [state
-   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
-   document or selection changes.
-   */
-   let StateEffect$3 = class StateEffect {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       @internal
-       */
-       type, 
-       /**
-       The value of this effect.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Map this effect through a position mapping. Will return
-       `undefined` when that ends up deleting the effect.
-       */
-       map(mapping) {
-           let mapped = this.type.map(this.value, mapping);
-           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
-       }
-       /**
-       Tells you whether this effect object is of a given
-       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
-       */
-       is(type) { return this.type == type; }
-       /**
-       Define a new effect type. The type parameter indicates the type
-       of values that his effect holds.
-       */
-       static define(spec = {}) {
-           return new StateEffectType$3(spec.map || (v => v));
-       }
-       /**
-       Map an array of effects through a change set.
-       */
-       static mapEffects(effects, mapping) {
-           if (!effects.length)
-               return effects;
-           let result = [];
-           for (let effect of effects) {
-               let mapped = effect.map(mapping);
-               if (mapped)
-                   result.push(mapped);
-           }
-           return result;
-       }
-   };
-   /**
-   This effect can be used to reconfigure the root extensions of
-   the editor. Doing this will discard any extensions
-   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
-   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
-   compartments.
-   */
-   StateEffect$3.reconfigure = /*@__PURE__*/StateEffect$3.define();
-   /**
-   Append extensions to the top-level configuration of the editor.
-   */
-   StateEffect$3.appendConfig = /*@__PURE__*/StateEffect$3.define();
-   /**
-   Changes to the editor state are grouped into transactions.
-   Typically, a user action creates a single transaction, which may
-   contain any number of document changes, may change the selection,
-   or have other effects. Create a transaction by calling
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
-   dispatch one by calling
-   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
-   */
-   let Transaction$3 = class Transaction {
-       constructor(
-       /**
-       The state from which the transaction starts.
-       */
-       startState, 
-       /**
-       The document changes made by this transaction.
-       */
-       changes, 
-       /**
-       The selection set by this transaction, or undefined if it
-       doesn't explicitly set a selection.
-       */
-       selection, 
-       /**
-       The effects added to the transaction.
-       */
-       effects, 
-       /**
-       @internal
-       */
-       annotations, 
-       /**
-       Whether the selection should be scrolled into view after this
-       transaction is dispatched.
-       */
-       scrollIntoView) {
-           this.startState = startState;
-           this.changes = changes;
-           this.selection = selection;
-           this.effects = effects;
-           this.annotations = annotations;
-           this.scrollIntoView = scrollIntoView;
-           /**
-           @internal
-           */
-           this._doc = null;
-           /**
-           @internal
-           */
-           this._state = null;
-           if (selection)
-               checkSelection$3(selection, changes.newLength);
-           if (!annotations.some((a) => a.type == Transaction.time))
-               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
-       }
-       /**
-       @internal
-       */
-       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
-           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
-       }
-       /**
-       The new document produced by the transaction. Contrary to
-       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
-       force the entire new state to be computed right away, so it is
-       recommended that [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
-       when they need to look at the new document.
-       */
-       get newDoc() {
-           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
-       }
-       /**
-       The new selection produced by the transaction. If
-       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
-       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
-       current selection through the changes made by the transaction.
-       */
-       get newSelection() {
-           return this.selection || this.startState.selection.map(this.changes);
-       }
-       /**
-       The new state created by the transaction. Computed on demand
-       (but retained for subsequent access), so it is recommended not to
-       access it in [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
-       */
-       get state() {
-           if (!this._state)
-               this.startState.applyTransaction(this);
-           return this._state;
-       }
-       /**
-       Get the value of the given annotation type, if any.
-       */
-       annotation(type) {
-           for (let ann of this.annotations)
-               if (ann.type == type)
-                   return ann.value;
-           return undefined;
-       }
-       /**
-       Indicates whether the transaction changed the document.
-       */
-       get docChanged() { return !this.changes.empty; }
-       /**
-       Indicates whether this transaction reconfigures the state
-       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
-       with a top-level configuration
-       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
-       */
-       get reconfigured() { return this.startState.config != this.state.config; }
-       /**
-       Returns true if the transaction has a [user
-       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
-       or more specific than `event`. For example, if the transaction
-       has `"select.pointer"` as user event, `"select"` and
-       `"select.pointer"` will match it.
-       */
-       isUserEvent(event) {
-           let e = this.annotation(Transaction.userEvent);
-           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
-       }
-   };
-   /**
-   Annotation used to store transaction timestamps. Automatically
-   added to every transaction, holding `Date.now()`.
-   */
-   Transaction$3.time = /*@__PURE__*/Annotation$3.define();
-   /**
-   Annotation used to associate a transaction with a user interface
-   event. Holds a string identifying the event, using a
-   dot-separated format to support attaching more specific
-   information. The events used by the core libraries are:
-
-    - `"input"` when content is entered
-      - `"input.type"` for typed input
-        - `"input.type.compose"` for composition
-      - `"input.paste"` for pasted input
-      - `"input.drop"` when adding content with drag-and-drop
-      - `"input.complete"` when autocompleting
-    - `"delete"` when the user deletes content
-      - `"delete.selection"` when deleting the selection
-      - `"delete.forward"` when deleting forward from the selection
-      - `"delete.backward"` when deleting backward from the selection
-      - `"delete.cut"` when cutting to the clipboard
-    - `"move"` when content is moved
-      - `"move.drop"` when content is moved within the editor through drag-and-drop
-    - `"select"` when explicitly changing the selection
-      - `"select.pointer"` when selecting with a mouse or other pointing device
-    - `"undo"` and `"redo"` for history actions
-
-   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
-   whether the annotation matches a given event.
-   */
-   Transaction$3.userEvent = /*@__PURE__*/Annotation$3.define();
-   /**
-   Annotation indicating whether a transaction should be added to
-   the undo history or not.
-   */
-   Transaction$3.addToHistory = /*@__PURE__*/Annotation$3.define();
-   /**
-   Annotation indicating (when present and true) that a transaction
-   represents a change made by some other actor, not the user. This
-   is used, for example, to tag other people's changes in
-   collaborative editing.
-   */
-   Transaction$3.remote = /*@__PURE__*/Annotation$3.define();
-   function joinRanges$3(a, b) {
-       let result = [];
-       for (let iA = 0, iB = 0;;) {
-           let from, to;
-           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
-               from = a[iA++];
-               to = a[iA++];
-           }
-           else if (iB < b.length) {
-               from = b[iB++];
-               to = b[iB++];
-           }
-           else
-               return result;
-           if (!result.length || result[result.length - 1] < from)
-               result.push(from, to);
-           else if (result[result.length - 1] < to)
-               result[result.length - 1] = to;
-       }
-   }
-   function mergeTransaction$3(a, b, sequential) {
-       var _a;
-       let mapForA, mapForB, changes;
-       if (sequential) {
-           mapForA = b.changes;
-           mapForB = ChangeSet$3.empty(b.changes.length);
-           changes = a.changes.compose(b.changes);
-       }
-       else {
-           mapForA = b.changes.map(a.changes);
-           mapForB = a.changes.mapDesc(b.changes, true);
-           changes = a.changes.compose(mapForA);
-       }
-       return {
-           changes,
-           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
-           effects: StateEffect$3.mapEffects(a.effects, mapForA).concat(StateEffect$3.mapEffects(b.effects, mapForB)),
-           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
-           scrollIntoView: a.scrollIntoView || b.scrollIntoView
-       };
-   }
-   function resolveTransactionInner$3(state, spec, docSize) {
-       let sel = spec.selection, annotations = asArray$5(spec.annotations);
-       if (spec.userEvent)
-           annotations = annotations.concat(Transaction$3.userEvent.of(spec.userEvent));
-       return {
-           changes: spec.changes instanceof ChangeSet$3 ? spec.changes
-               : ChangeSet$3.of(spec.changes || [], docSize, state.facet(lineSeparator$3)),
-           selection: sel && (sel instanceof EditorSelection$3 ? sel : EditorSelection$3.single(sel.anchor, sel.head)),
-           effects: asArray$5(spec.effects),
-           annotations,
-           scrollIntoView: !!spec.scrollIntoView
-       };
-   }
-   function resolveTransaction$3(state, specs, filter) {
-       let s = resolveTransactionInner$3(state, specs.length ? specs[0] : {}, state.doc.length);
-       if (specs.length && specs[0].filter === false)
-           filter = false;
-       for (let i = 1; i < specs.length; i++) {
-           if (specs[i].filter === false)
-               filter = false;
-           let seq = !!specs[i].sequential;
-           s = mergeTransaction$3(s, resolveTransactionInner$3(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
-       }
-       let tr = Transaction$3.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
-       return extendTransaction$3(filter ? filterTransaction$3(tr) : tr);
-   }
-   // Finish a transaction by applying filters if necessary.
-   function filterTransaction$3(tr) {
-       let state = tr.startState;
-       // Change filters
-       let result = true;
-       for (let filter of state.facet(changeFilter$3)) {
-           let value = filter(tr);
-           if (value === false) {
-               result = false;
-               break;
-           }
-           if (Array.isArray(value))
-               result = result === true ? value : joinRanges$3(result, value);
-       }
-       if (result !== true) {
-           let changes, back;
-           if (result === false) {
-               back = tr.changes.invertedDesc;
-               changes = ChangeSet$3.empty(state.doc.length);
-           }
-           else {
-               let filtered = tr.changes.filter(result);
-               changes = filtered.changes;
-               back = filtered.filtered.invertedDesc;
-           }
-           tr = Transaction$3.create(state, changes, tr.selection && tr.selection.map(back), StateEffect$3.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
-       }
-       // Transaction filters
-       let filters = state.facet(transactionFilter$3);
-       for (let i = filters.length - 1; i >= 0; i--) {
-           let filtered = filters[i](tr);
-           if (filtered instanceof Transaction$3)
-               tr = filtered;
-           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction$3)
-               tr = filtered[0];
-           else
-               tr = resolveTransaction$3(state, asArray$5(filtered), false);
-       }
-       return tr;
-   }
-   function extendTransaction$3(tr) {
-       let state = tr.startState, extenders = state.facet(transactionExtender$3), spec = tr;
-       for (let i = extenders.length - 1; i >= 0; i--) {
-           let extension = extenders[i](tr);
-           if (extension && Object.keys(extension).length)
-               spec = mergeTransaction$3(tr, resolveTransactionInner$3(state, extension, tr.changes.newLength), true);
-       }
-       return spec == tr ? tr : Transaction$3.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
-   }
-   const none$6 = [];
-   function asArray$5(value) {
-       return value == null ? none$6 : Array.isArray(value) ? value : [value];
-   }
-
-   /**
-   The categories produced by a [character
-   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
-   do things like selecting by word.
-   */
-   var CharCategory$3 = /*@__PURE__*/(function (CharCategory) {
-       /**
-       Word characters.
-       */
-       CharCategory[CharCategory["Word"] = 0] = "Word";
-       /**
-       Whitespace.
-       */
-       CharCategory[CharCategory["Space"] = 1] = "Space";
-       /**
-       Anything else.
-       */
-       CharCategory[CharCategory["Other"] = 2] = "Other";
-   return CharCategory})(CharCategory$3 || (CharCategory$3 = {}));
-   const nonASCIISingleCaseWordChar$3 = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
-   let wordChar$3;
-   try {
-       wordChar$3 = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
-   }
-   catch (_) { }
-   function hasWordChar$3(str) {
-       if (wordChar$3)
-           return wordChar$3.test(str);
-       for (let i = 0; i < str.length; i++) {
-           let ch = str[i];
-           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar$3.test(ch)))
-               return true;
-       }
-       return false;
-   }
-   function makeCategorizer$3(wordChars) {
-       return (char) => {
-           if (!/\S/.test(char))
-               return CharCategory$3.Space;
-           if (hasWordChar$3(char))
-               return CharCategory$3.Word;
-           for (let i = 0; i < wordChars.length; i++)
-               if (char.indexOf(wordChars[i]) > -1)
-                   return CharCategory$3.Word;
-           return CharCategory$3.Other;
-       };
-   }
-
-   /**
-   The editor state class is a persistent (immutable) data structure.
-   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
-   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
-   instance, without modifying the original object.
-
-   As such, _never_ mutate properties of a state directly. That'll
-   just break things.
-   */
-   let EditorState$3 = class EditorState {
-       constructor(
-       /**
-       @internal
-       */
-       config, 
-       /**
-       The current document.
-       */
-       doc, 
-       /**
-       The current selection.
-       */
-       selection, 
-       /**
-       @internal
-       */
-       values, computeSlot, tr) {
-           this.config = config;
-           this.doc = doc;
-           this.selection = selection;
-           this.values = values;
-           this.status = config.statusTemplate.slice();
-           this.computeSlot = computeSlot;
-           // Fill in the computed state immediately, so that further queries
-           // for it made during the update return this state
-           if (tr)
-               tr._state = this;
-           for (let i = 0; i < this.config.dynamicSlots.length; i++)
-               ensureAddr$3(this, i << 1);
-           this.computeSlot = null;
-       }
-       field(field, require = true) {
-           let addr = this.config.address[field.id];
-           if (addr == null) {
-               if (require)
-                   throw new RangeError("Field is not present in this state");
-               return undefined;
-           }
-           ensureAddr$3(this, addr);
-           return getAddr$3(this, addr);
-       }
-       /**
-       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
-       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
-       can be passed. Unless
-       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
-       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
-       are assumed to start in the _current_ document (not the document
-       produced by previous specs), and its
-       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
-       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
-       to the document created by its _own_ changes. The resulting
-       transaction contains the combined effect of all the different
-       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
-       specs take precedence over earlier ones.
-       */
-       update(...specs) {
-           return resolveTransaction$3(this, specs, true);
-       }
-       /**
-       @internal
-       */
-       applyTransaction(tr) {
-           let conf = this.config, { base, compartments } = conf;
-           for (let effect of tr.effects) {
-               if (effect.is(Compartment$3.reconfigure)) {
-                   if (conf) {
-                       compartments = new Map;
-                       conf.compartments.forEach((val, key) => compartments.set(key, val));
-                       conf = null;
-                   }
-                   compartments.set(effect.value.compartment, effect.value.extension);
-               }
-               else if (effect.is(StateEffect$3.reconfigure)) {
-                   conf = null;
-                   base = effect.value;
-               }
-               else if (effect.is(StateEffect$3.appendConfig)) {
-                   conf = null;
-                   base = asArray$5(base).concat(effect.value);
-               }
-           }
-           let startValues;
-           if (!conf) {
-               conf = Configuration$3.resolve(base, compartments, this);
-               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
-               startValues = intermediateState.values;
-           }
-           else {
-               startValues = tr.startState.values.slice();
-           }
-           new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
-       }
-       /**
-       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
-       replaces every selection range with the given content.
-       */
-       replaceSelection(text) {
-           if (typeof text == "string")
-               text = this.toText(text);
-           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
-               range: EditorSelection$3.cursor(range.from + text.length) }));
-       }
-       /**
-       Create a set of changes and a new selection by running the given
-       function for each range in the active selection. The function
-       can return an optional set of changes (in the coordinate space
-       of the start document), plus an updated range (in the coordinate
-       space of the document produced by the call's own changes). This
-       method will merge all the changes and ranges into a single
-       changeset and selection, and return it as a [transaction
-       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
-       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
-       */
-       changeByRange(f) {
-           let sel = this.selection;
-           let result1 = f(sel.ranges[0]);
-           let changes = this.changes(result1.changes), ranges = [result1.range];
-           let effects = asArray$5(result1.effects);
-           for (let i = 1; i < sel.ranges.length; i++) {
-               let result = f(sel.ranges[i]);
-               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
-               for (let j = 0; j < i; j++)
-                   ranges[j] = ranges[j].map(newMapped);
-               let mapBy = changes.mapDesc(newChanges, true);
-               ranges.push(result.range.map(mapBy));
-               changes = changes.compose(newMapped);
-               effects = StateEffect$3.mapEffects(effects, newMapped).concat(StateEffect$3.mapEffects(asArray$5(result.effects), mapBy));
-           }
-           return {
-               changes,
-               selection: EditorSelection$3.create(ranges, sel.mainIndex),
-               effects
-           };
-       }
-       /**
-       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
-       description, taking the state's document length and line
-       separator into account.
-       */
-       changes(spec = []) {
-           if (spec instanceof ChangeSet$3)
-               return spec;
-           return ChangeSet$3.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
-       }
-       /**
-       Using the state's [line
-       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
-       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
-       */
-       toText(string) {
-           return Text$3.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit$3));
-       }
-       /**
-       Return the given range of the document as a string.
-       */
-       sliceDoc(from = 0, to = this.doc.length) {
-           return this.doc.sliceString(from, to, this.lineBreak);
-       }
-       /**
-       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
-       */
-       facet(facet) {
-           let addr = this.config.address[facet.id];
-           if (addr == null)
-               return facet.default;
-           ensureAddr$3(this, addr);
-           return getAddr$3(this, addr);
-       }
-       /**
-       Convert this state to a JSON-serializable object. When custom
-       fields should be serialized, you can pass them in as an object
-       mapping property names (in the resulting object, which should
-       not use `doc` or `selection`) to fields.
-       */
-       toJSON(fields) {
-           let result = {
-               doc: this.sliceDoc(),
-               selection: this.selection.toJSON()
-           };
-           if (fields)
-               for (let prop in fields) {
-                   let value = fields[prop];
-                   if (value instanceof StateField$3)
-                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
-               }
-           return result;
-       }
-       /**
-       Deserialize a state from its JSON representation. When custom
-       fields should be deserialized, pass the same object you passed
-       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
-       third argument.
-       */
-       static fromJSON(json, config = {}, fields) {
-           if (!json || typeof json.doc != "string")
-               throw new RangeError("Invalid JSON representation for EditorState");
-           let fieldInit = [];
-           if (fields)
-               for (let prop in fields) {
-                   let field = fields[prop], value = json[prop];
-                   fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
-               }
-           return EditorState.create({
-               doc: json.doc,
-               selection: EditorSelection$3.fromJSON(json.selection),
-               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
-           });
-       }
-       /**
-       Create a new state. You'll usually only need this when
-       initializing an editor—updated states are created by applying
-       transactions.
-       */
-       static create(config = {}) {
-           let configuration = Configuration$3.resolve(config.extensions || [], new Map);
-           let doc = config.doc instanceof Text$3 ? config.doc
-               : Text$3.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit$3));
-           let selection = !config.selection ? EditorSelection$3.single(0)
-               : config.selection instanceof EditorSelection$3 ? config.selection
-                   : EditorSelection$3.single(config.selection.anchor, config.selection.head);
-           checkSelection$3(selection, doc.length);
-           if (!configuration.staticFacet(allowMultipleSelections$3))
-               selection = selection.asSingle();
-           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
-       }
-       /**
-       The size (in columns) of a tab in the document, determined by
-       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
-       */
-       get tabSize() { return this.facet(EditorState.tabSize); }
-       /**
-       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
-       string for this state.
-       */
-       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
-       /**
-       Returns true when the editor is
-       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
-       */
-       get readOnly() { return this.facet(readOnly$3); }
-       /**
-       Look up a translation for the given phrase (via the
-       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
-       original string if no translation is found.
-       
-       If additional arguments are passed, they will be inserted in
-       place of markers like `$1` (for the first value) and `$2`, etc.
-       A single `$` is equivalent to `$1`, and `$$` will produce a
-       literal dollar sign.
-       */
-       phrase(phrase, ...insert) {
-           for (let map of this.facet(EditorState.phrases))
-               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
-                   phrase = map[phrase];
-                   break;
-               }
-           if (insert.length)
-               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
-                   if (i == "$")
-                       return "$";
-                   let n = +(i || 1);
-                   return n > insert.length ? m : insert[n - 1];
-               });
-           return phrase;
-       }
-       /**
-       Find the values for a given language data field, provided by the
-       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
-       */
-       languageDataAt(name, pos, side = -1) {
-           let values = [];
-           for (let provider of this.facet(languageData$3)) {
-               for (let result of provider(this, pos, side)) {
-                   if (Object.prototype.hasOwnProperty.call(result, name))
-                       values.push(result[name]);
-               }
-           }
-           return values;
-       }
-       /**
-       Return a function that can categorize strings (expected to
-       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
-       into one of:
-       
-        - Word (contains an alphanumeric character or a character
-          explicitly listed in the local language's `"wordChars"`
-          language data, which should be a string)
-        - Space (contains only whitespace)
-        - Other (anything else)
-       */
-       charCategorizer(at) {
-           return makeCategorizer$3(this.languageDataAt("wordChars", at).join(""));
-       }
-       /**
-       Find the word at the given position, meaning the range
-       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
-       around it. If no word characters are adjacent to the position,
-       this returns null.
-       */
-       wordAt(pos) {
-           let { text, from, length } = this.doc.lineAt(pos);
-           let cat = this.charCategorizer(pos);
-           let start = pos - from, end = pos - from;
-           while (start > 0) {
-               let prev = findClusterBreak$4(text, start, false);
-               if (cat(text.slice(prev, start)) != CharCategory$3.Word)
-                   break;
-               start = prev;
-           }
-           while (end < length) {
-               let next = findClusterBreak$4(text, end);
-               if (cat(text.slice(end, next)) != CharCategory$3.Word)
-                   break;
-               end = next;
-           }
-           return start == end ? null : EditorSelection$3.range(start + from, end + from);
-       }
-   };
-   /**
-   A facet that, when enabled, causes the editor to allow multiple
-   ranges to be selected. Be careful though, because by default the
-   editor relies on the native DOM selection, which cannot handle
-   multiple selections. An extension like
-   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
-   secondary selections visible to the user.
-   */
-   EditorState$3.allowMultipleSelections = allowMultipleSelections$3;
-   /**
-   Configures the tab size to use in this state. The first
-   (highest-precedence) value of the facet is used. If no value is
-   given, this defaults to 4.
-   */
-   EditorState$3.tabSize = /*@__PURE__*/Facet$3.define({
-       combine: values => values.length ? values[0] : 4
-   });
-   /**
-   The line separator to use. By default, any of `"\n"`, `"\r\n"`
-   and `"\r"` is treated as a separator when splitting lines, and
-   lines are joined with `"\n"`.
-
-   When you configure a value here, only that precise separator
-   will be used, allowing you to round-trip documents through the
-   editor without normalizing line separators.
-   */
-   EditorState$3.lineSeparator = lineSeparator$3;
-   /**
-   This facet controls the value of the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
-   consulted by commands and extensions that implement editing
-   functionality to determine whether they should apply. It
-   defaults to false, but when its highest-precedence value is
-   `true`, such functionality disables itself.
-
-   Not to be confused with
-   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
-   controls whether the editor's DOM is set to be editable (and
-   thus focusable).
-   */
-   EditorState$3.readOnly = readOnly$3;
-   /**
-   Registers translation phrases. The
-   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
-   all objects registered with this facet to find translations for
-   its argument.
-   */
-   EditorState$3.phrases = /*@__PURE__*/Facet$3.define({
-       compare(a, b) {
-           let kA = Object.keys(a), kB = Object.keys(b);
-           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
-       }
-   });
-   /**
-   A facet used to register [language
-   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
-   */
-   EditorState$3.languageData = languageData$3;
-   /**
-   Facet used to register change filters, which are called for each
-   transaction (unless explicitly
-   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
-   part of the transaction's changes.
-
-   Such a function can return `true` to indicate that it doesn't
-   want to do anything, `false` to completely stop the changes in
-   the transaction, or a set of ranges in which changes should be
-   suppressed. Such ranges are represented as an array of numbers,
-   with each pair of two numbers indicating the start and end of a
-   range. So for example `[10, 20, 100, 110]` suppresses changes
-   between 10 and 20, and between 100 and 110.
-   */
-   EditorState$3.changeFilter = changeFilter$3;
-   /**
-   Facet used to register a hook that gets a chance to update or
-   replace transaction specs before they are applied. This will
-   only be applied for transactions that don't have
-   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
-   can either return a single transaction spec (possibly the input
-   transaction), or an array of specs (which will be combined in
-   the same way as the arguments to
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
-
-   When possible, it is recommended to avoid accessing
-   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
-   since it will force creation of a state that will then be
-   discarded again, if the transaction is actually filtered.
-
-   (This functionality should be used with care. Indiscriminately
-   modifying transaction is likely to break something or degrade
-   the user experience.)
-   */
-   EditorState$3.transactionFilter = transactionFilter$3;
-   /**
-   This is a more limited form of
-   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
-   which can only add
-   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
-   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
-   of filter runs even if the transaction has disabled regular
-   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
-   for effects that don't need to touch the changes or selection,
-   but do want to process every transaction.
-
-   Extenders run _after_ filters, when both are present.
-   */
-   EditorState$3.transactionExtender = transactionExtender$3;
-   Compartment$3.reconfigure = /*@__PURE__*/StateEffect$3.define();
-
-   /**
-   Utility function for combining behaviors to fill in a config
-   object from an array of provided configs. `defaults` should hold
-   default values for all optional fields in `Config`.
-
-   The function will, by default, error
-   when a field gets two values that aren't `===`-equal, but you can
-   provide combine functions per field to do something else.
-   */
-   function combineConfig$3(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
-   combine = {}) {
-       let result = {};
-       for (let config of configs)
-           for (let key of Object.keys(config)) {
-               let value = config[key], current = result[key];
-               if (current === undefined)
-                   result[key] = value;
-               else if (current === value || value === undefined) ; // No conflict
-               else if (Object.hasOwnProperty.call(combine, key))
-                   result[key] = combine[key](current, value);
-               else
-                   throw new Error("Config merge conflict for field " + key);
-           }
-       for (let key in defaults)
-           if (result[key] === undefined)
-               result[key] = defaults[key];
-       return result;
-   }
-
-   /**
-   Each range is associated with a value, which must inherit from
-   this class.
-   */
-   let RangeValue$3 = class RangeValue {
-       /**
-       Compare this value with another value. Used when comparing
-       rangesets. The default implementation compares by identity.
-       Unless you are only creating a fixed number of unique instances
-       of your value type, it is a good idea to implement this
-       properly.
-       */
-       eq(other) { return this == other; }
-       /**
-       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
-       */
-       range(from, to = from) { return Range$6.create(from, to, this); }
-   };
-   RangeValue$3.prototype.startSide = RangeValue$3.prototype.endSide = 0;
-   RangeValue$3.prototype.point = false;
-   RangeValue$3.prototype.mapMode = MapMode$3.TrackDel;
-   /**
-   A range associates a value with a range of positions.
-   */
-   let Range$6 = class Range {
-       constructor(
-       /**
-       The range's start position.
-       */
-       from, 
-       /**
-       Its end position.
-       */
-       to, 
-       /**
-       The value associated with this range.
-       */
-       value) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-       }
-       /**
-       @internal
-       */
-       static create(from, to, value) {
-           return new Range(from, to, value);
-       }
-   };
-   function cmpRange$3(a, b) {
-       return a.from - b.from || a.value.startSide - b.value.startSide;
-   }
-   let Chunk$3 = class Chunk {
-       constructor(from, to, value, 
-       // Chunks are marked with the largest point that occurs
-       // in them (or -1 for no points), so that scans that are
-       // only interested in points (such as the
-       // heightmap-related logic) can skip range-only chunks.
-       maxPoint) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-           this.maxPoint = maxPoint;
-       }
-       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(pos, side, end, startAt = 0) {
-           let arr = end ? this.to : this.from;
-           for (let lo = startAt, hi = arr.length;;) {
-               if (lo == hi)
-                   return lo;
-               let mid = (lo + hi) >> 1;
-               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
-               if (mid == lo)
-                   return diff >= 0 ? lo : hi;
-               if (diff >= 0)
-                   hi = mid;
-               else
-                   lo = mid + 1;
-           }
-       }
-       between(offset, from, to, f) {
-           for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
-               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
-                   return false;
-       }
-       map(offset, changes) {
-           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
-           for (let i = 0; i < this.value.length; i++) {
-               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
-               if (curFrom == curTo) {
-                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
-                   if (mapped == null)
-                       continue;
-                   newFrom = newTo = mapped;
-                   if (val.startSide != val.endSide) {
-                       newTo = changes.mapPos(curFrom, val.endSide);
-                       if (newTo < newFrom)
-                           continue;
-                   }
-               }
-               else {
-                   newFrom = changes.mapPos(curFrom, val.startSide);
-                   newTo = changes.mapPos(curTo, val.endSide);
-                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
-                       continue;
-               }
-               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
-                   continue;
-               if (newPos < 0)
-                   newPos = newFrom;
-               if (val.point)
-                   maxPoint = Math.max(maxPoint, newTo - newFrom);
-               value.push(val);
-               from.push(newFrom - newPos);
-               to.push(newTo - newPos);
-           }
-           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
-       }
-   };
-   /**
-   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
-   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
-   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
-   structure.
-   */
-   let RangeSet$3 = class RangeSet {
-       constructor(
-       /**
-       @internal
-       */
-       chunkPos, 
-       /**
-       @internal
-       */
-       chunk, 
-       /**
-       @internal
-       */
-       nextLayer, 
-       /**
-       @internal
-       */
-       maxPoint) {
-           this.chunkPos = chunkPos;
-           this.chunk = chunk;
-           this.nextLayer = nextLayer;
-           this.maxPoint = maxPoint;
-       }
-       /**
-       @internal
-       */
-       static create(chunkPos, chunk, nextLayer, maxPoint) {
-           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
-       }
-       /**
-       @internal
-       */
-       get length() {
-           let last = this.chunk.length - 1;
-           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
-       }
-       /**
-       The number of ranges in the set.
-       */
-       get size() {
-           if (this.isEmpty)
-               return 0;
-           let size = this.nextLayer.size;
-           for (let chunk of this.chunk)
-               size += chunk.value.length;
-           return size;
-       }
-       /**
-       @internal
-       */
-       chunkEnd(index) {
-           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
-           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
-           let filter = updateSpec.filter;
-           if (add.length == 0 && !filter)
-               return this;
-           if (sort)
-               add = add.slice().sort(cmpRange$3);
-           if (this.isEmpty)
-               return add.length ? RangeSet.of(add) : this;
-           let cur = new LayerCursor$3(this, null, -1).goto(0), i = 0, spill = [];
-           let builder = new RangeSetBuilder$3();
-           while (cur.value || i < add.length) {
-               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
-                   let range = add[i++];
-                   if (!builder.addInner(range.from, range.to, range.value))
-                       spill.push(range);
-               }
-               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
-                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
-                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
-                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
-                   cur.nextChunk();
-               }
-               else {
-                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
-                       if (!builder.addInner(cur.from, cur.to, cur.value))
-                           spill.push(Range$6.create(cur.from, cur.to, cur.value));
-                   }
-                   cur.next();
-               }
-           }
-           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
-               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
-       }
-       /**
-       Map this range set through a set of changes, return the new set.
-       */
-       map(changes) {
-           if (changes.empty || this.isEmpty)
-               return this;
-           let chunks = [], chunkPos = [], maxPoint = -1;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               let touch = changes.touchesRange(start, start + chunk.length);
-               if (touch === false) {
-                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
-                   chunks.push(chunk);
-                   chunkPos.push(changes.mapPos(start));
-               }
-               else if (touch === true) {
-                   let { mapped, pos } = chunk.map(start, changes);
-                   if (mapped) {
-                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
-                       chunks.push(mapped);
-                       chunkPos.push(pos);
-                   }
-               }
-           }
-           let next = this.nextLayer.map(changes);
-           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
-       }
-       /**
-       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(from, to, f) {
-           if (this.isEmpty)
-               return;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               if (to >= start && from <= start + chunk.length &&
-                   chunk.between(start, from - start, to - start, f) === false)
-                   return;
-           }
-           this.nextLayer.between(from, to, f);
-       }
-       /**
-       Iterate over the ranges in this set, in order, including all
-       ranges that end at or after `from`.
-       */
-       iter(from = 0) {
-           return HeapCursor$3.from([this]).goto(from);
-       }
-       /**
-       @internal
-       */
-       get isEmpty() { return this.nextLayer == this; }
-       /**
-       Iterate over the ranges in a collection of sets, in order,
-       starting from `from`.
-       */
-       static iter(sets, from = 0) {
-           return HeapCursor$3.from(sets).goto(from);
-       }
-       /**
-       Iterate over two groups of sets, calling methods on `comparator`
-       to notify it of possible differences.
-       */
-       static compare(oldSets, newSets, 
-       /**
-       This indicates how the underlying data changed between these
-       ranges, and is needed to synchronize the iteration. `from` and
-       `to` are coordinates in the _new_ space, after these changes.
-       */
-       textDiff, comparator, 
-       /**
-       Can be used to ignore all non-point ranges, and points below
-       the given size. When -1, all ranges are compared.
-       */
-       minPointSize = -1) {
-           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let sharedChunks = findSharedChunks$3(a, b, textDiff);
-           let sideA = new SpanCursor$3(a, sharedChunks, minPointSize);
-           let sideB = new SpanCursor$3(b, sharedChunks, minPointSize);
-           textDiff.iterGaps((fromA, fromB, length) => compare$3(sideA, fromA, sideB, fromB, length, comparator));
-           if (textDiff.empty && textDiff.length == 0)
-               compare$3(sideA, 0, sideB, 0, 0, comparator);
-       }
-       /**
-       Compare the contents of two groups of range sets, returning true
-       if they are equivalent in the given range.
-       */
-       static eq(oldSets, newSets, from = 0, to) {
-           if (to == null)
-               to = 1000000000 /* Far */;
-           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
-           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
-           if (a.length != b.length)
-               return false;
-           if (!a.length)
-               return true;
-           let sharedChunks = findSharedChunks$3(a, b);
-           let sideA = new SpanCursor$3(a, sharedChunks, 0).goto(from), sideB = new SpanCursor$3(b, sharedChunks, 0).goto(from);
-           for (;;) {
-               if (sideA.to != sideB.to ||
-                   !sameValues$3(sideA.active, sideB.active) ||
-                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
-                   return false;
-               if (sideA.to > to)
-                   return true;
-               sideA.next();
-               sideB.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(sets, from, to, iterator, 
-       /**
-       When given and greater than -1, only points of at least this
-       size are taken into account.
-       */
-       minPointSize = -1) {
-           let cursor = new SpanCursor$3(sets, null, minPointSize).goto(from), pos = from;
-           let open = cursor.openStart;
-           for (;;) {
-               let curTo = Math.min(cursor.to, to);
-               if (cursor.point) {
-                   iterator.point(pos, curTo, cursor.point, cursor.activeForPoint(cursor.to), open, cursor.pointRank);
-                   open = cursor.openEnd(curTo) + (cursor.to > curTo ? 1 : 0);
-               }
-               else if (curTo > pos) {
-                   iterator.span(pos, curTo, cursor.active, open);
-                   open = cursor.openEnd(curTo);
-               }
-               if (cursor.to > to)
-                   break;
-               pos = cursor.to;
-               cursor.next();
-           }
-           return open;
-       }
-       /**
-       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(ranges, sort = false) {
-           let build = new RangeSetBuilder$3();
-           for (let range of ranges instanceof Range$6 ? [ranges] : sort ? lazySort$3(ranges) : ranges)
-               build.add(range.from, range.to, range.value);
-           return build.finish();
-       }
-   };
-   /**
-   The empty set of ranges.
-   */
-   RangeSet$3.empty = /*@__PURE__*/new RangeSet$3([], [], null, -1);
-   function lazySort$3(ranges) {
-       if (ranges.length > 1)
-           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
-               let cur = ranges[i];
-               if (cmpRange$3(prev, cur) > 0)
-                   return ranges.slice().sort(cmpRange$3);
-               prev = cur;
-           }
-       return ranges;
-   }
-   RangeSet$3.empty.nextLayer = RangeSet$3.empty;
-   /**
-   A range set builder is a data structure that helps build up a
-   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
-   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
-   */
-   let RangeSetBuilder$3 = class RangeSetBuilder {
-       /**
-       Create an empty builder.
-       */
-       constructor() {
-           this.chunks = [];
-           this.chunkPos = [];
-           this.chunkStart = -1;
-           this.last = null;
-           this.lastFrom = -1000000000 /* Far */;
-           this.lastTo = -1000000000 /* Far */;
-           this.from = [];
-           this.to = [];
-           this.value = [];
-           this.maxPoint = -1;
-           this.setMaxPoint = -1;
-           this.nextLayer = null;
-       }
-       finishChunk(newArrays) {
-           this.chunks.push(new Chunk$3(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;
-           if (newArrays) {
-               this.from = [];
-               this.to = [];
-               this.value = [];
-           }
-       }
-       /**
-       Add a range. Ranges should be added in sorted (by `from` and
-       `value.startSide`) order.
-       */
-       add(from, to, value) {
-           if (!this.addInner(from, to, value))
-               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
-       }
-       /**
-       @internal
-       */
-       addInner(from, to, value) {
-           let diff = from - this.lastTo || value.startSide - this.last.endSide;
-           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
-               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
-           if (diff < 0)
-               return false;
-           if (this.from.length == 250 /* ChunkSize */)
-               this.finishChunk(true);
-           if (this.chunkStart < 0)
-               this.chunkStart = from;
-           this.from.push(from - this.chunkStart);
-           this.to.push(to - this.chunkStart);
-           this.last = value;
-           this.lastFrom = from;
-           this.lastTo = to;
-           this.value.push(value);
-           if (value.point)
-               this.maxPoint = Math.max(this.maxPoint, to - from);
-           return true;
-       }
-       /**
-       @internal
-       */
-       addChunk(from, chunk) {
-           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
-               return false;
-           if (this.from.length)
-               this.finishChunk(true);
-           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
-           this.chunks.push(chunk);
-           this.chunkPos.push(from);
-           let last = chunk.value.length - 1;
-           this.last = chunk.value[last];
-           this.lastFrom = chunk.from[last] + from;
-           this.lastTo = chunk.to[last] + from;
-           return true;
-       }
-       /**
-       Finish the range set. Returns the new set. The builder can't be
-       used anymore after this has been called.
-       */
-       finish() { return this.finishInner(RangeSet$3.empty); }
-       /**
-       @internal
-       */
-       finishInner(next) {
-           if (this.from.length)
-               this.finishChunk(false);
-           if (this.chunks.length == 0)
-               return next;
-           let result = RangeSet$3.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
-           this.from = null; // Make sure further `add` calls produce errors
-           return result;
-       }
-   };
-   function findSharedChunks$3(a, b, textDiff) {
-       let inA = new Map();
-       for (let set of a)
-           for (let i = 0; i < set.chunk.length; i++)
-               if (set.chunk[i].maxPoint <= 0)
-                   inA.set(set.chunk[i], set.chunkPos[i]);
-       let shared = new Set();
-       for (let set of b)
-           for (let i = 0; i < set.chunk.length; i++) {
-               let known = inA.get(set.chunk[i]);
-               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
-                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
-                   shared.add(set.chunk[i]);
-           }
-       return shared;
-   }
-   let LayerCursor$3 = class LayerCursor {
-       constructor(layer, skip, minPoint, rank = 0) {
-           this.layer = layer;
-           this.skip = skip;
-           this.minPoint = minPoint;
-           this.rank = rank;
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       get endSide() { return this.value ? this.value.endSide : 0; }
-       goto(pos, side = -1000000000 /* Far */) {
-           this.chunkIndex = this.rangeIndex = 0;
-           this.gotoInner(pos, side, false);
-           return this;
-       }
-       gotoInner(pos, side, forward) {
-           while (this.chunkIndex < this.layer.chunk.length) {
-               let next = this.layer.chunk[this.chunkIndex];
-               if (!(this.skip && this.skip.has(next) ||
-                   this.layer.chunkEnd(this.chunkIndex) < pos ||
-                   next.maxPoint < this.minPoint))
-                   break;
-               this.chunkIndex++;
-               forward = false;
-           }
-           if (this.chunkIndex < this.layer.chunk.length) {
-               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
-               if (!forward || this.rangeIndex < rangeIndex)
-                   this.setRangeIndex(rangeIndex);
-           }
-           this.next();
-       }
-       forward(pos, side) {
-           if ((this.to - pos || this.endSide - side) < 0)
-               this.gotoInner(pos, side, true);
-       }
-       next() {
-           for (;;) {
-               if (this.chunkIndex == this.layer.chunk.length) {
-                   this.from = this.to = 1000000000 /* Far */;
-                   this.value = null;
-                   break;
-               }
-               else {
-                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
-                   let from = chunkPos + chunk.from[this.rangeIndex];
-                   this.from = from;
-                   this.to = chunkPos + chunk.to[this.rangeIndex];
-                   this.value = chunk.value[this.rangeIndex];
-                   this.setRangeIndex(this.rangeIndex + 1);
-                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
-                       break;
-               }
-           }
-       }
-       setRangeIndex(index) {
-           if (index == this.layer.chunk[this.chunkIndex].value.length) {
-               this.chunkIndex++;
-               if (this.skip) {
-                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
-                       this.chunkIndex++;
-               }
-               this.rangeIndex = 0;
-           }
-           else {
-               this.rangeIndex = index;
-           }
-       }
-       nextChunk() {
-           this.chunkIndex++;
-           this.rangeIndex = 0;
-           this.next();
-       }
-       compare(other) {
-           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
-               this.to - other.to || this.endSide - other.endSide;
-       }
-   };
-   let HeapCursor$3 = class HeapCursor {
-       constructor(heap) {
-           this.heap = heap;
-       }
-       static from(sets, skip = null, minPoint = -1) {
-           let heap = [];
-           for (let i = 0; i < sets.length; i++) {
-               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
-                   if (cur.maxPoint >= minPoint)
-                       heap.push(new LayerCursor$3(cur, skip, minPoint, i));
-               }
-           }
-           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       goto(pos, side = -1000000000 /* Far */) {
-           for (let cur of this.heap)
-               cur.goto(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble$3(this.heap, i);
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           for (let cur of this.heap)
-               cur.forward(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble$3(this.heap, i);
-           if ((this.to - pos || this.value.endSide - side) < 0)
-               this.next();
-       }
-       next() {
-           if (this.heap.length == 0) {
-               this.from = this.to = 1000000000 /* Far */;
-               this.value = null;
-               this.rank = -1;
-           }
-           else {
-               let top = this.heap[0];
-               this.from = top.from;
-               this.to = top.to;
-               this.value = top.value;
-               this.rank = top.rank;
-               if (top.value)
-                   top.next();
-               heapBubble$3(this.heap, 0);
-           }
-       }
-   };
-   function heapBubble$3(heap, index) {
-       for (let cur = heap[index];;) {
-           let childIndex = (index << 1) + 1;
-           if (childIndex >= heap.length)
-               break;
-           let child = heap[childIndex];
-           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
-               child = heap[childIndex + 1];
-               childIndex++;
-           }
-           if (cur.compare(child) < 0)
-               break;
-           heap[childIndex] = cur;
-           heap[index] = child;
-           index = childIndex;
-       }
-   }
-   let SpanCursor$3 = class SpanCursor {
-       constructor(sets, skip, minPoint) {
-           this.minPoint = minPoint;
-           this.active = [];
-           this.activeTo = [];
-           this.activeRank = [];
-           this.minActive = -1;
-           // A currently active point range, if any
-           this.point = null;
-           this.pointFrom = 0;
-           this.pointRank = 0;
-           this.to = -1000000000 /* Far */;
-           this.endSide = 0;
-           this.openStart = -1;
-           this.cursor = HeapCursor$3.from(sets, skip, minPoint);
-       }
-       goto(pos, side = -1000000000 /* Far */) {
-           this.cursor.goto(pos, side);
-           this.active.length = this.activeTo.length = this.activeRank.length = 0;
-           this.minActive = -1;
-           this.to = pos;
-           this.endSide = side;
-           this.openStart = -1;
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
-               this.removeActive(this.minActive);
-           this.cursor.forward(pos, side);
-       }
-       removeActive(index) {
-           remove$3(this.active, index);
-           remove$3(this.activeTo, index);
-           remove$3(this.activeRank, index);
-           this.minActive = findMinIndex$3(this.active, this.activeTo);
-       }
-       addActive(trackOpen) {
-           let i = 0, { value, to, rank } = this.cursor;
-           while (i < this.activeRank.length && this.activeRank[i] <= rank)
-               i++;
-           insert$3(this.active, i, value);
-           insert$3(this.activeTo, i, to);
-           insert$3(this.activeRank, i, rank);
-           if (trackOpen)
-               insert$3(trackOpen, i, this.cursor.from);
-           this.minActive = findMinIndex$3(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 from = this.to, wasPoint = this.point;
-           this.point = null;
-           let trackOpen = this.openStart < 0 ? [] : null, trackExtra = 0;
-           for (;;) {
-               let a = this.minActive;
-               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
-                   if (this.activeTo[a] > from) {
-                       this.to = this.activeTo[a];
-                       this.endSide = this.active[a].endSide;
-                       break;
-                   }
-                   this.removeActive(a);
-                   if (trackOpen)
-                       remove$3(trackOpen, a);
-               }
-               else if (!this.cursor.value) {
-                   this.to = this.endSide = 1000000000 /* Far */;
-                   break;
-               }
-               else if (this.cursor.from > from) {
-                   this.to = this.cursor.from;
-                   this.endSide = this.cursor.startSide;
-                   break;
-               }
-               else {
-                   let nextVal = this.cursor.value;
-                   if (!nextVal.point) { // Opening a range
-                       this.addActive(trackOpen);
-                       this.cursor.next();
-                   }
-                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
-                       // Ignore any non-empty points that end precisely at the end of the prev point
-                       this.cursor.next();
-                   }
-                   else { // New point
-                       this.point = nextVal;
-                       this.pointFrom = this.cursor.from;
-                       this.pointRank = this.cursor.rank;
-                       this.to = this.cursor.to;
-                       this.endSide = nextVal.endSide;
-                       if (this.cursor.from < from)
-                           trackExtra = 1;
-                       this.cursor.next();
-                       this.forward(this.to, this.endSide);
-                       break;
-                   }
-               }
-           }
-           if (trackOpen) {
-               let openStart = 0;
-               while (openStart < trackOpen.length && trackOpen[openStart] < from)
-                   openStart++;
-               this.openStart = openStart + trackExtra;
-           }
-       }
-       activeForPoint(to) {
-           if (!this.active.length)
-               return this.active;
-           let active = [];
-           for (let i = this.active.length - 1; i >= 0; i--) {
-               if (this.activeRank[i] < this.pointRank)
-                   break;
-               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
-                   active.push(this.active[i]);
-           }
-           return active.reverse();
-       }
-       openEnd(to) {
-           let open = 0;
-           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
-               open++;
-           return open;
-       }
-   };
-   function compare$3(a, startA, b, startB, length, comparator) {
-       a.goto(startA);
-       b.goto(startB);
-       let endB = startB + length;
-       let pos = startB, dPos = startB - startA;
-       for (;;) {
-           let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;
-           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
-           if (a.point || b.point) {
-               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
-                   sameValues$3(a.activeForPoint(a.to + dPos), b.activeForPoint(b.to))))
-                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
-           }
-           else {
-               if (clipEnd > pos && !sameValues$3(a.active, b.active))
-                   comparator.compareRange(pos, clipEnd, a.active, b.active);
-           }
-           if (end > endB)
-               break;
-           pos = end;
-           if (diff <= 0)
-               a.next();
-           if (diff >= 0)
-               b.next();
-       }
-   }
-   function sameValues$3(a, b) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (a[i] != b[i] && !a[i].eq(b[i]))
-               return false;
-       return true;
-   }
-   function remove$3(array, index) {
-       for (let i = index, e = array.length - 1; i < e; i++)
-           array[i] = array[i + 1];
-       array.pop();
-   }
-   function insert$3(array, index, value) {
-       for (let i = array.length - 1; i >= index; i--)
-           array[i + 1] = array[i];
-       array[index] = value;
-   }
-   function findMinIndex$3(value, array) {
-       let found = -1, foundPos = 1000000000 /* Far */;
-       for (let i = 0; i < array.length; i++)
-           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
-               found = i;
-               foundPos = array[i];
-           }
-       return found;
-   }
-
-   /**
-   Count the column position at the given offset into the string,
-   taking extending characters and tab size into account.
-   */
-   function countColumn$1(string, tabSize, to = string.length) {
-       let n = 0;
-       for (let i = 0; i < to;) {
-           if (string.charCodeAt(i) == 9) {
-               n += tabSize - (n % tabSize);
-               i++;
-           }
-           else {
-               n++;
-               i = findClusterBreak$4(string, i);
-           }
-       }
-       return n;
-   }
-   /**
-   Find the offset that corresponds to the given column position in a
-   string, taking extending characters and tab size into account. By
-   default, the string length is returned when it is too short to
-   reach the column. Pass `strict` true to make it return -1 in that
-   situation.
-   */
-   function findColumn$3(string, col, tabSize, strict) {
-       for (let i = 0, n = 0;;) {
-           if (n >= col)
-               return i;
-           if (i == string.length)
-               break;
-           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
-           i = findClusterBreak$4(string, i);
-       }
-       return strict === true ? -1 : string.length;
-   }
-
-   const C = "\u037c";
-   const COUNT = typeof Symbol == "undefined" ? "__" + C : Symbol.for(C);
-   const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
-   const top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
-
-   // :: - Style modules encapsulate a set of CSS rules defined from
-   // JavaScript. Their definitions are only available in a given DOM
-   // root after it has been _mounted_ there with `StyleModule.mount`.
-   //
-   // Style modules should be created once and stored somewhere, as
-   // opposed to re-creating them every time you need them. The amount of
-   // CSS rules generated for a given DOM root is bounded by the amount
-   // of style modules that were used. So to avoid leaking rules, don't
-   // create these dynamically, but treat them as one-time allocations.
-   class StyleModule {
-     // :: (Object<Style>, ?{finish: ?(string) → string})
-     // Create a style module from the given spec.
-     //
-     // When `finish` is given, it is called on regular (non-`@`)
-     // selectors (after `&` expansion) to compute the final selector.
-     constructor(spec, options) {
-       this.rules = [];
-       let {finish} = options || {};
-
-       function splitSelector(selector) {
-         return /^@/.test(selector) ? [selector] : selector.split(/,\s*/)
-       }
-
-       function render(selectors, spec, target, isKeyframes) {
-         let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
-         if (isAt && spec == null) return target.push(selectors[0] + ";")
-         for (let prop in spec) {
-           let value = spec[prop];
-           if (/&/.test(prop)) {
-             render(prop.split(/,\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),
-                    value, target);
-           } else if (value && typeof value == "object") {
-             if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.")
-             render(splitSelector(prop), value, local, keyframes);
-           } else if (value != null) {
-             local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, l => "-" + l.toLowerCase()) + ": " + value + ";");
-           }
-         }
-         if (local.length || keyframes) {
-           target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") +
-                       " {" + local.join(" ") + "}");
-         }
-       }
-
-       for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
-     }
-
-     // :: () → string
-     // Returns a string containing the module's CSS rules.
-     getRules() { return this.rules.join("\n") }
-
-     // :: () → string
-     // Generate a new unique CSS class name.
-     static newName() {
-       let id = top[COUNT] || 1;
-       top[COUNT] = id + 1;
-       return C + id.toString(36)
-     }
-
-     // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
-     //
-     // Mount the given set of modules in the given DOM root, which ensures
-     // that the CSS rules defined by the module are available in that
-     // context.
-     //
-     // Rules are only added to the document once per root.
-     //
-     // Rule order will follow the order of the modules, so that rules from
-     // modules later in the array take precedence of those from earlier
-     // modules. If you call this function multiple times for the same root
-     // in a way that changes the order of already mounted modules, the old
-     // order will be changed.
-     //
-     // If a Content Security Policy nonce is provided, it is added to
-     // the `<style>` tag generated by the library.
-     static mount(root, modules, options) {
-       let set = root[SET], nonce = options && options.nonce;
-       if (!set) set = new StyleSet(root, nonce);
-       else if (nonce) set.setNonce(nonce);
-       set.mount(Array.isArray(modules) ? modules : [modules], root);
-     }
-   }
-
-   let adoptedSet = new Map; //<Document, StyleSet>
-
-   class StyleSet {
-     constructor(root, nonce) {
-       let doc = root.ownerDocument || root, win = doc.defaultView;
-       if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
-         let adopted = adoptedSet.get(doc);
-         if (adopted) return root[SET] = adopted
-         this.sheet = new win.CSSStyleSheet;
-         adoptedSet.set(doc, this);
-       } else {
-         this.styleTag = doc.createElement("style");
-         if (nonce) this.styleTag.setAttribute("nonce", nonce);
-       }
-       this.modules = [];
-       root[SET] = this;
-     }
-
-     mount(modules, root) {
-       let sheet = this.sheet;
-       let pos = 0 /* Current rule offset */, j = 0; /* Index into this.modules */
-       for (let i = 0; i < modules.length; i++) {
-         let mod = modules[i], index = this.modules.indexOf(mod);
-         if (index < j && index > -1) { // Ordering conflict
-           this.modules.splice(index, 1);
-           j--;
-           index = -1;
-         }
-         if (index == -1) {
-           this.modules.splice(j++, 0, mod);
-           if (sheet) for (let k = 0; k < mod.rules.length; k++)
-             sheet.insertRule(mod.rules[k], pos++);
-         } else {
-           while (j < index) pos += this.modules[j++].rules.length;
-           pos += mod.rules.length;
-           j++;
-         }
-       }
-
-       if (sheet) {
-         if (root.adoptedStyleSheets.indexOf(this.sheet) < 0)
-           root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
-       } else {
-         let text = "";
-         for (let i = 0; i < this.modules.length; i++)
-           text += this.modules[i].getRules() + "\n";
-         this.styleTag.textContent = text;
-         let target = root.head || root;
-         if (this.styleTag.parentNode != target)
-           target.insertBefore(this.styleTag, target.firstChild);
-       }
-     }
-
-     setNonce(nonce) {
-       if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce)
-         this.styleTag.setAttribute("nonce", nonce);
-     }
-   }
-
-   // Style::Object<union<Style,string>>
-   //
-   // A style is an object that, in the simple case, maps CSS property
-   // names to strings holding their values, as in `{color: "red",
-   // fontWeight: "bold"}`. The property names can be given in
-   // camel-case—the library will insert a dash before capital letters
-   // when converting them to CSS.
-   //
-   // If you include an underscore in a property name, it and everything
-   // after it will be removed from the output, which can be useful when
-   // providing a property multiple times, for browser compatibility
-   // reasons.
-   //
-   // A property in a style object can also be a sub-selector, which
-   // extends the current context to add a pseudo-selector or a child
-   // selector. Such a property should contain a `&` character, which
-   // will be replaced by the current selector. For example `{"&:before":
-   // {content: '"hi"'}}`. Sub-selectors and regular properties can
-   // freely be mixed in a given object. Any property containing a `&` is
-   // assumed to be a sub-selector.
-   //
-   // Finally, a property can specify an @-block to be wrapped around the
-   // styles defined inside the object that's the property's value. For
-   // example to create a media query you can do `{"@media screen and
-   // (min-width: 400px)": {...}}`.
-
-   var base = {
-     8: "Backspace",
-     9: "Tab",
-     10: "Enter",
-     12: "NumLock",
-     13: "Enter",
-     16: "Shift",
-     17: "Control",
-     18: "Alt",
-     20: "CapsLock",
-     27: "Escape",
-     32: " ",
-     33: "PageUp",
-     34: "PageDown",
-     35: "End",
-     36: "Home",
-     37: "ArrowLeft",
-     38: "ArrowUp",
-     39: "ArrowRight",
-     40: "ArrowDown",
-     44: "PrintScreen",
-     45: "Insert",
-     46: "Delete",
-     59: ";",
-     61: "=",
-     91: "Meta",
-     92: "Meta",
-     106: "*",
-     107: "+",
-     108: ",",
-     109: "-",
-     110: ".",
-     111: "/",
-     144: "NumLock",
-     145: "ScrollLock",
-     160: "Shift",
-     161: "Shift",
-     162: "Control",
-     163: "Control",
-     164: "Alt",
-     165: "Alt",
-     173: "-",
-     186: ";",
-     187: "=",
-     188: ",",
-     189: "-",
-     190: ".",
-     191: "/",
-     192: "`",
-     219: "[",
-     220: "\\",
-     221: "]",
-     222: "'"
-   };
-
-   var shift = {
-     48: ")",
-     49: "!",
-     50: "@",
-     51: "#",
-     52: "$",
-     53: "%",
-     54: "^",
-     55: "&",
-     56: "*",
-     57: "(",
-     59: ":",
-     61: "+",
-     173: "_",
-     186: ":",
-     187: "+",
-     188: "<",
-     189: "_",
-     190: ">",
-     191: "?",
-     192: "~",
-     219: "{",
-     220: "|",
-     221: "}",
-     222: "\""
-   };
-
-   var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
-   var ie$4 = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
-
-   // Fill in the digit keys
-   for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);
-
-   // The function keys
-   for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i;
-
-   // And the alphabetic keys
-   for (var i = 65; i <= 90; i++) {
-     base[i] = String.fromCharCode(i + 32);
-     shift[i] = String.fromCharCode(i);
-   }
-
-   // For each code that doesn't have a shift-equivalent, copy the base name
-   for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];
-
-   function keyName(event) {
-     // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.
-     // On IE, shift effect is never included in `.key`.
-     var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||
-         ie$4 && event.shiftKey && event.key && event.key.length == 1 ||
-         event.key == "Unidentified";
-     var name = (!ignoreKey && event.key) ||
-       (event.shiftKey ? shift : base)[event.keyCode] ||
-       event.key || "Unidentified";
-     // Edge sometimes produces wrong names (Issue #3)
-     if (name == "Esc") name = "Escape";
-     if (name == "Del") name = "Delete";
-     // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
-     if (name == "Left") name = "ArrowLeft";
-     if (name == "Up") name = "ArrowUp";
-     if (name == "Right") name = "ArrowRight";
-     if (name == "Down") name = "ArrowDown";
-     return name
-   }
-
-   function getSelection$3(root) {
-       let target;
-       // Browsers differ on whether shadow roots have a getSelection
-       // method. If it exists, use that, otherwise, call it on the
-       // document.
-       if (root.nodeType == 11) { // Shadow root
-           target = root.getSelection ? root : root.ownerDocument;
-       }
-       else {
-           target = root;
-       }
-       return target.getSelection();
-   }
-   function contains$3(dom, node) {
-       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
-   }
-   function deepActiveElement$2() {
-       let elt = document.activeElement;
-       while (elt && elt.shadowRoot)
-           elt = elt.shadowRoot.activeElement;
-       return elt;
-   }
-   function hasSelection$3(dom, selection) {
-       if (!selection.anchorNode)
-           return false;
-       try {
-           // Firefox will raise 'permission denied' errors when accessing
-           // properties of `sel.anchorNode` when it's in a generated CSS
-           // element.
-           return contains$3(dom, selection.anchorNode);
-       }
-       catch (_) {
-           return false;
-       }
-   }
-   function clientRectsFor$3(dom) {
-       if (dom.nodeType == 3)
-           return textRange$3(dom, 0, dom.nodeValue.length).getClientRects();
-       else if (dom.nodeType == 1)
-           return dom.getClientRects();
-       else
-           return [];
-   }
-   // Scans forward and backward through DOM positions equivalent to the
-   // given one to see if the two are in the same place (i.e. after a
-   // text node vs at the end of that text node)
-   function isEquivalentPosition$3(node, off, targetNode, targetOff) {
-       return targetNode ? (scanFor$3(node, off, targetNode, targetOff, -1) ||
-           scanFor$3(node, off, targetNode, targetOff, 1)) : false;
-   }
-   function domIndex$3(node) {
-       for (var index = 0;; index++) {
-           node = node.previousSibling;
-           if (!node)
-               return index;
-       }
-   }
-   function scanFor$3(node, off, targetNode, targetOff, dir) {
-       for (;;) {
-           if (node == targetNode && off == targetOff)
-               return true;
-           if (off == (dir < 0 ? 0 : maxOffset$3(node))) {
-               if (node.nodeName == "DIV")
-                   return false;
-               let parent = node.parentNode;
-               if (!parent || parent.nodeType != 1)
-                   return false;
-               off = domIndex$3(node) + (dir < 0 ? 0 : 1);
-               node = parent;
-           }
-           else if (node.nodeType == 1) {
-               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
-               if (node.nodeType == 1 && node.contentEditable == "false")
-                   return false;
-               off = dir < 0 ? maxOffset$3(node) : 0;
-           }
-           else {
-               return false;
-           }
-       }
-   }
-   function maxOffset$3(node) {
-       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
-   }
-   const Rect0$2 = { left: 0, right: 0, top: 0, bottom: 0 };
-   function flattenRect$3(rect, left) {
-       let x = left ? rect.left : rect.right;
-       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
-   }
-   function windowRect$3(win) {
-       return { left: 0, right: win.innerWidth,
-           top: 0, bottom: win.innerHeight };
-   }
-   function scrollRectIntoView$3(dom, rect, side, x, y, xMargin, yMargin, ltr) {
-       let doc = dom.ownerDocument, win = doc.defaultView;
-       for (let cur = dom; cur;) {
-           if (cur.nodeType == 1) { // Element
-               let bounding, top = cur == doc.body;
-               if (top) {
-                   bounding = windowRect$3(win);
-               }
-               else {
-                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
-                       cur = cur.parentNode;
-                       continue;
-                   }
-                   let rect = cur.getBoundingClientRect();
-                   // Make sure scrollbar width isn't included in the rectangle
-                   bounding = { left: rect.left, right: rect.left + cur.clientWidth,
-                       top: rect.top, bottom: rect.top + cur.clientHeight };
-               }
-               let moveX = 0, moveY = 0;
-               if (y == "nearest") {
-                   if (rect.top < bounding.top) {
-                       moveY = -(bounding.top - rect.top + yMargin);
-                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
-                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
-                   }
-                   else if (rect.bottom > bounding.bottom) {
-                       moveY = rect.bottom - bounding.bottom + yMargin;
-                       if (side < 0 && (rect.top - moveY) < bounding.top)
-                           moveY = -(bounding.top + moveY - rect.top + yMargin);
-                   }
-               }
-               else {
-                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
-                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
-                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
-                           rect.bottom - boundingHeight + yMargin;
-                   moveY = targetTop - bounding.top;
-               }
-               if (x == "nearest") {
-                   if (rect.left < bounding.left) {
-                       moveX = -(bounding.left - rect.left + xMargin);
-                       if (side > 0 && rect.right > bounding.right + moveX)
-                           moveX = rect.right - bounding.right + moveX + xMargin;
-                   }
-                   else if (rect.right > bounding.right) {
-                       moveX = rect.right - bounding.right + xMargin;
-                       if (side < 0 && rect.left < bounding.left + moveX)
-                           moveX = -(bounding.left + moveX - rect.left + xMargin);
-                   }
-               }
-               else {
-                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
-                       (x == "start") == ltr ? rect.left - xMargin :
-                           rect.right - (bounding.right - bounding.left) + xMargin;
-                   moveX = targetLeft - bounding.left;
-               }
-               if (moveX || moveY) {
-                   if (top) {
-                       win.scrollBy(moveX, moveY);
-                   }
-                   else {
-                       if (moveY) {
-                           let start = cur.scrollTop;
-                           cur.scrollTop += moveY;
-                           moveY = cur.scrollTop - start;
-                       }
-                       if (moveX) {
-                           let start = cur.scrollLeft;
-                           cur.scrollLeft += moveX;
-                           moveX = cur.scrollLeft - start;
-                       }
-                       rect = { left: rect.left - moveX, top: rect.top - moveY,
-                           right: rect.right - moveX, bottom: rect.bottom - moveY };
-                   }
-               }
-               if (top)
-                   break;
-               cur = cur.assignedSlot || cur.parentNode;
-               x = y = "nearest";
-           }
-           else if (cur.nodeType == 11) { // A shadow root
-               cur = cur.host;
-           }
-           else {
-               break;
-           }
-       }
-   }
-   let DOMSelectionState$3 = class DOMSelectionState {
-       constructor() {
-           this.anchorNode = null;
-           this.anchorOffset = 0;
-           this.focusNode = null;
-           this.focusOffset = 0;
-       }
-       eq(domSel) {
-           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
-               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
-       }
-       setRange(range) {
-           this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
-       }
-       set(anchorNode, anchorOffset, focusNode, focusOffset) {
-           this.anchorNode = anchorNode;
-           this.anchorOffset = anchorOffset;
-           this.focusNode = focusNode;
-           this.focusOffset = focusOffset;
-       }
-   };
-   let preventScrollSupported$3 = null;
-   // Feature-detects support for .focus({preventScroll: true}), and uses
-   // a fallback kludge when not supported.
-   function focusPreventScroll$3(dom) {
-       if (dom.setActive)
-           return dom.setActive(); // in IE
-       if (preventScrollSupported$3)
-           return dom.focus(preventScrollSupported$3);
-       let stack = [];
-       for (let cur = dom; cur; cur = cur.parentNode) {
-           stack.push(cur, cur.scrollTop, cur.scrollLeft);
-           if (cur == cur.ownerDocument)
-               break;
-       }
-       dom.focus(preventScrollSupported$3 == null ? {
-           get preventScroll() {
-               preventScrollSupported$3 = { preventScroll: true };
-               return true;
-           }
-       } : undefined);
-       if (!preventScrollSupported$3) {
-           preventScrollSupported$3 = false;
-           for (let i = 0; i < stack.length;) {
-               let elt = stack[i++], top = stack[i++], left = stack[i++];
-               if (elt.scrollTop != top)
-                   elt.scrollTop = top;
-               if (elt.scrollLeft != left)
-                   elt.scrollLeft = left;
-           }
-       }
-   }
-   let scratchRange$3;
-   function textRange$3(node, from, to = from) {
-       let range = scratchRange$3 || (scratchRange$3 = document.createRange());
-       range.setEnd(node, to);
-       range.setStart(node, from);
-       return range;
-   }
-   function dispatchKey$3(elt, name, code) {
-       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
-       let down = new KeyboardEvent("keydown", options);
-       down.synthetic = true;
-       elt.dispatchEvent(down);
-       let up = new KeyboardEvent("keyup", options);
-       up.synthetic = true;
-       elt.dispatchEvent(up);
-       return down.defaultPrevented || up.defaultPrevented;
-   }
-   function getRoot$3(node) {
-       while (node) {
-           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
-               return node;
-           node = node.assignedSlot || node.parentNode;
-       }
-       return null;
-   }
-   function clearAttributes$3(node) {
-       while (node.attributes.length)
-           node.removeAttributeNode(node.attributes[0]);
-   }
-
-   let DOMPos$3 = class DOMPos {
-       constructor(node, offset, precise = true) {
-           this.node = node;
-           this.offset = offset;
-           this.precise = precise;
-       }
-       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex$3(dom), precise); }
-       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex$3(dom) + 1, precise); }
-   };
-   const noChildren$3 = [];
-   let ContentView$3 = class ContentView {
-       constructor() {
-           this.parent = null;
-           this.dom = null;
-           this.dirty = 2 /* Node */;
-       }
-       get editorView() {
-           if (!this.parent)
-               throw new Error("Accessing view in orphan content view");
-           return this.parent.editorView;
-       }
-       get overrideDOMText() { return null; }
-       get posAtStart() {
-           return this.parent ? this.parent.posBefore(this) : 0;
-       }
-       get posAtEnd() {
-           return this.posAtStart + this.length;
-       }
-       posBefore(view) {
-           let pos = this.posAtStart;
-           for (let child of this.children) {
-               if (child == view)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-           throw new RangeError("Invalid child in posBefore");
-       }
-       posAfter(view) {
-           return this.posBefore(view) + view.length;
-       }
-       // Will return a rectangle directly before (when side < 0), after
-       // (side > 0) or directly on (when the browser supports it) the
-       // given position.
-       coordsAt(_pos, _side) { return null; }
-       sync(track) {
-           if (this.dirty & 2 /* Node */) {
-               let parent = this.dom;
-               let prev = null, next;
-               for (let child of this.children) {
-                   if (child.dirty) {
-                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
-                           let contentView = ContentView.get(next);
-                           if (!contentView || !contentView.parent && contentView.constructor == child.constructor)
-                               child.reuseDOM(next);
-                       }
-                       child.sync(track);
-                       child.dirty = 0 /* Not */;
-                   }
-                   next = prev ? prev.nextSibling : parent.firstChild;
-                   if (track && !track.written && track.node == parent && next != child.dom)
-                       track.written = true;
-                   if (child.dom.parentNode == parent) {
-                       while (next && next != child.dom)
-                           next = rm$1$3(next);
-                   }
-                   else {
-                       parent.insertBefore(child.dom, next);
-                   }
-                   prev = child.dom;
-               }
-               next = prev ? prev.nextSibling : parent.firstChild;
-               if (next && track && track.node == parent)
-                   track.written = true;
-               while (next)
-                   next = rm$1$3(next);
-           }
-           else if (this.dirty & 1 /* Child */) {
-               for (let child of this.children)
-                   if (child.dirty) {
-                       child.sync(track);
-                       child.dirty = 0 /* Not */;
-                   }
-           }
-       }
-       reuseDOM(_dom) { }
-       localPosFromDOM(node, offset) {
-           let after;
-           if (node == this.dom) {
-               after = this.dom.childNodes[offset];
-           }
-           else {
-               let bias = maxOffset$3(node) == 0 ? 0 : offset == 0 ? -1 : 1;
-               for (;;) {
-                   let parent = node.parentNode;
-                   if (parent == this.dom)
-                       break;
-                   if (bias == 0 && parent.firstChild != parent.lastChild) {
-                       if (node == parent.firstChild)
-                           bias = -1;
-                       else
-                           bias = 1;
-                   }
-                   node = parent;
-               }
-               if (bias < 0)
-                   after = node;
-               else
-                   after = node.nextSibling;
-           }
-           if (after == this.dom.firstChild)
-               return 0;
-           while (after && !ContentView.get(after))
-               after = after.nextSibling;
-           if (!after)
-               return this.length;
-           for (let i = 0, pos = 0;; i++) {
-               let child = this.children[i];
-               if (child.dom == after)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-       }
-       domBoundsAround(from, to, offset = 0) {
-           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
-           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos < from && end > to)
-                   return child.domBoundsAround(from, to, pos);
-               if (end >= from && fromI == -1) {
-                   fromI = i;
-                   fromStart = pos;
-               }
-               if (pos > to && child.dom.parentNode == this.dom) {
-                   toI = i;
-                   toEnd = prevEnd;
-                   break;
-               }
-               prevEnd = end;
-               pos = end + child.breakAfter;
-           }
-           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
-               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
-               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
-       }
-       markDirty(andParent = false) {
-           this.dirty |= 2 /* Node */;
-           this.markParentsDirty(andParent);
-       }
-       markParentsDirty(childList) {
-           for (let parent = this.parent; parent; parent = parent.parent) {
-               if (childList)
-                   parent.dirty |= 2 /* Node */;
-               if (parent.dirty & 1 /* Child */)
-                   return;
-               parent.dirty |= 1 /* Child */;
-               childList = false;
-           }
-       }
-       setParent(parent) {
-           if (this.parent != parent) {
-               this.parent = parent;
-               if (this.dirty)
-                   this.markParentsDirty(true);
-           }
-       }
-       setDOM(dom) {
-           if (this.dom)
-               this.dom.cmView = null;
-           this.dom = dom;
-           dom.cmView = this;
-       }
-       get rootView() {
-           for (let v = this;;) {
-               let parent = v.parent;
-               if (!parent)
-                   return v;
-               v = parent;
-           }
-       }
-       replaceChildren(from, to, children = noChildren$3) {
-           this.markDirty();
-           for (let i = from; i < to; i++) {
-               let child = this.children[i];
-               if (child.parent == this)
-                   child.destroy();
-           }
-           this.children.splice(from, to - from, ...children);
-           for (let i = 0; i < children.length; i++)
-               children[i].setParent(this);
-       }
-       ignoreMutation(_rec) { return false; }
-       ignoreEvent(_event) { return false; }
-       childCursor(pos = this.length) {
-           return new ChildCursor$3(this.children, pos, this.children.length);
-       }
-       childPos(pos, bias = 1) {
-           return this.childCursor().findPos(pos, bias);
-       }
-       toString() {
-           let name = this.constructor.name.replace("View", "");
-           return name + (this.children.length ? "(" + this.children.join() + ")" :
-               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
-               (this.breakAfter ? "#" : "");
-       }
-       static get(node) { return node.cmView; }
-       get isEditable() { return true; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           return false;
-       }
-       become(other) { return false; }
-       // When this is a zero-length view with a side, this should return a
-       // number <= 0 to indicate it is before its position, or a
-       // number > 0 when after its position.
-       getSide() { return 0; }
-       destroy() {
-           this.parent = null;
-       }
-   };
-   ContentView$3.prototype.breakAfter = 0;
-   // Remove a DOM node and return its next sibling.
-   function rm$1$3(dom) {
-       let next = dom.nextSibling;
-       dom.parentNode.removeChild(dom);
-       return next;
-   }
-   let ChildCursor$3 = class ChildCursor {
-       constructor(children, pos, i) {
-           this.children = children;
-           this.pos = pos;
-           this.i = i;
-           this.off = 0;
-       }
-       findPos(pos, bias = 1) {
-           for (;;) {
-               if (pos > this.pos || pos == this.pos &&
-                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
-                   this.off = pos - this.pos;
-                   return this;
-               }
-               let next = this.children[--this.i];
-               this.pos -= next.length + next.breakAfter;
-           }
-       }
-   };
-   function replaceRange$3(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
-       let { children } = parent;
-       let before = children.length ? children[fromI] : null;
-       let last = insert.length ? insert[insert.length - 1] : null;
-       let breakAtEnd = last ? last.breakAfter : breakAtStart;
-       // Change within a single child
-       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
-           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
-           return;
-       if (toI < children.length) {
-           let after = children[toI];
-           // Make sure the end of the child after the update is preserved in `after`
-           if (after && toOff < after.length) {
-               // If we're splitting a child, separate part of it to avoid that
-               // being mangled when updating the child before the update.
-               if (fromI == toI) {
-                   after = after.split(toOff);
-                   toOff = 0;
-               }
-               // If the element after the replacement should be merged with
-               // the last replacing element, update `content`
-               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
-                   insert[insert.length - 1] = after;
-               }
-               else {
-                   // Remove the start of the after element, if necessary, and
-                   // add it to `content`.
-                   if (toOff)
-                       after.merge(0, toOff, null, false, 0, openEnd);
-                   insert.push(after);
-               }
-           }
-           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
-               // The element at `toI` is entirely covered by this range.
-               // Preserve its line break, if any.
-               if (last)
-                   last.breakAfter = 1;
-               else
-                   breakAtStart = 1;
-           }
-           // Since we've handled the next element from the current elements
-           // now, make sure `toI` points after that.
-           toI++;
-       }
-       if (before) {
-           before.breakAfter = breakAtStart;
-           if (fromOff > 0) {
-               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
-                   before.breakAfter = insert.shift().breakAfter;
-               }
-               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
-                   before.merge(fromOff, before.length, null, false, openStart, 0);
-               }
-               fromI++;
-           }
-       }
-       // Try to merge widgets on the boundaries of the replacement
-       while (fromI < toI && insert.length) {
-           if (children[toI - 1].become(insert[insert.length - 1])) {
-               toI--;
-               insert.pop();
-               openEnd = insert.length ? 0 : openStart;
-           }
-           else if (children[fromI].become(insert[0])) {
-               fromI++;
-               insert.shift();
-               openStart = insert.length ? 0 : openEnd;
-           }
-           else {
-               break;
-           }
-       }
-       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
-           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
-           fromI--;
-       if (fromI < toI || insert.length)
-           parent.replaceChildren(fromI, toI, insert);
-   }
-   function mergeChildrenInto$3(parent, from, to, insert, openStart, openEnd) {
-       let cur = parent.childCursor();
-       let { i: toI, off: toOff } = cur.findPos(to, 1);
-       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
-       let dLen = from - to;
-       for (let view of insert)
-           dLen += view.length;
-       parent.length += dLen;
-       replaceRange$3(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
-   }
-
-   let nav$3 = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
-   let doc$3 = typeof document != "undefined" ? document : { documentElement: { style: {} } };
-   const ie_edge$3 = /*@__PURE__*//Edge\/(\d+)/.exec(nav$3.userAgent);
-   const ie_upto10$3 = /*@__PURE__*//MSIE \d/.test(nav$3.userAgent);
-   const ie_11up$3 = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav$3.userAgent);
-   const ie$3 = !!(ie_upto10$3 || ie_11up$3 || ie_edge$3);
-   const gecko$3 = !ie$3 && /*@__PURE__*//gecko\/(\d+)/i.test(nav$3.userAgent);
-   const chrome$3 = !ie$3 && /*@__PURE__*//Chrome\/(\d+)/.exec(nav$3.userAgent);
-   const webkit$3 = "webkitFontSmoothing" in doc$3.documentElement.style;
-   const safari$3 = !ie$3 && /*@__PURE__*//Apple Computer/.test(nav$3.vendor);
-   const ios$3 = safari$3 && (/*@__PURE__*//Mobile\/\w+/.test(nav$3.userAgent) || nav$3.maxTouchPoints > 2);
-   var browser$3 = {
-       mac: ios$3 || /*@__PURE__*//Mac/.test(nav$3.platform),
-       windows: /*@__PURE__*//Win/.test(nav$3.platform),
-       linux: /*@__PURE__*//Linux|X11/.test(nav$3.platform),
-       ie: ie$3,
-       ie_version: ie_upto10$3 ? doc$3.documentMode || 6 : ie_11up$3 ? +ie_11up$3[1] : ie_edge$3 ? +ie_edge$3[1] : 0,
-       gecko: gecko$3,
-       gecko_version: gecko$3 ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav$3.userAgent) || [0, 0])[1] : 0,
-       chrome: !!chrome$3,
-       chrome_version: chrome$3 ? +chrome$3[1] : 0,
-       ios: ios$3,
-       android: /*@__PURE__*//Android\b/.test(nav$3.userAgent),
-       webkit: webkit$3,
-       safari: safari$3,
-       webkit_version: webkit$3 ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
-       tabSize: doc$3.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
-   };
-
-   const MaxJoinLen$3 = 256;
-   let TextView$3 = class TextView extends ContentView$3 {
-       constructor(text) {
-           super();
-           this.text = text;
-       }
-       get length() { return this.text.length; }
-       createDOM(textDOM) {
-           this.setDOM(textDOM || document.createTextNode(this.text));
-       }
-       sync(track) {
-           if (!this.dom)
-               this.createDOM();
-           if (this.dom.nodeValue != this.text) {
-               if (track && track.node == this.dom)
-                   track.written = true;
-               this.dom.nodeValue = this.text;
-           }
-       }
-       reuseDOM(dom) {
-           if (dom.nodeType == 3)
-               this.createDOM(dom);
-       }
-       merge(from, to, source) {
-           if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen$3))
-               return false;
-           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = new TextView(this.text.slice(from));
-           this.text = this.text.slice(0, from);
-           this.markDirty();
-           return result;
-       }
-       localPosFromDOM(node, offset) {
-           return node == this.dom ? offset : offset ? this.text.length : 0;
-       }
-       domAtPos(pos) { return new DOMPos$3(this.dom, pos); }
-       domBoundsAround(_from, _to, offset) {
-           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
-       }
-       coordsAt(pos, side) {
-           return textCoords$3(this.dom, pos, side);
-       }
-   };
-   let MarkView$3 = class MarkView extends ContentView$3 {
-       constructor(mark, children = [], length = 0) {
-           super();
-           this.mark = mark;
-           this.children = children;
-           this.length = length;
-           for (let ch of children)
-               ch.setParent(this);
-       }
-       setAttrs(dom) {
-           clearAttributes$3(dom);
-           if (this.mark.class)
-               dom.className = this.mark.class;
-           if (this.mark.attrs)
-               for (let name in this.mark.attrs)
-                   dom.setAttribute(name, this.mark.attrs[name]);
-           return dom;
-       }
-       reuseDOM(node) {
-           if (node.nodeName == this.mark.tagName.toUpperCase()) {
-               this.setDOM(node);
-               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
-           }
-       }
-       sync(track) {
-           if (!this.dom)
-               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
-           else if (this.dirty & 4 /* Attrs */)
-               this.setAttrs(this.dom);
-           super.sync(track);
-       }
-       merge(from, to, source, _hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
-               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
-               return false;
-           mergeChildrenInto$3(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = [], off = 0, detachFrom = -1, i = 0;
-           for (let elt of this.children) {
-               let end = off + elt.length;
-               if (end > from)
-                   result.push(off < from ? elt.split(from - off) : elt);
-               if (detachFrom < 0 && off >= from)
-                   detachFrom = i;
-               off = end;
-               i++;
-           }
-           let length = this.length - from;
-           this.length = from;
-           if (detachFrom > -1) {
-               this.children.length = detachFrom;
-               this.markDirty();
-           }
-           return new MarkView(this.mark, result, length);
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos$3(this.dom, this.children, pos);
-       }
-       coordsAt(pos, side) {
-           return coordsInChildren$3(this, pos, side);
-       }
-   };
-   function textCoords$3(text, pos, side) {
-       let length = text.nodeValue.length;
-       if (pos > length)
-           pos = length;
-       let from = pos, to = pos, flatten = 0;
-       if (pos == 0 && side < 0 || pos == length && side >= 0) {
-           if (!(browser$3.chrome || browser$3.gecko)) { // These browsers reliably return valid rectangles for empty ranges
-               if (pos) {
-                   from--;
-                   flatten = 1;
-               } // FIXME this is wrong in RTL text
-               else if (to < length) {
-                   to++;
-                   flatten = -1;
-               }
-           }
-       }
-       else {
-           if (side < 0)
-               from--;
-           else if (to < length)
-               to++;
-       }
-       let rects = textRange$3(text, from, to).getClientRects();
-       if (!rects.length)
-           return Rect0$2;
-       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
-       if (browser$3.safari && !flatten && rect.width == 0)
-           rect = Array.prototype.find.call(rects, r => r.width) || rect;
-       return flatten ? flattenRect$3(rect, flatten < 0) : rect || null;
-   }
-   // Also used for collapsed ranges that don't have a placeholder widget!
-   let WidgetView$3 = class WidgetView extends ContentView$3 {
-       constructor(widget, length, side) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.side = side;
-           this.prevWidget = null;
-       }
-       static create(widget, length, side) {
-           return new (widget.customView || WidgetView)(widget, length, side);
-       }
-       split(from) {
-           let result = WidgetView.create(this.widget, this.length - from, this.side);
-           this.length -= from;
-           return result;
-       }
-       sync() {
-           if (!this.dom || !this.widget.updateDOM(this.dom)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(this.editorView));
-               this.dom.contentEditable = "false";
-           }
-       }
-       getSide() { return this.side; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       become(other) {
-           if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
-               if (this.widget.constructor == other.widget.constructor) {
-                   if (!this.widget.eq(other.widget))
-                       this.markDirty(true);
-                   if (this.dom && !this.prevWidget)
-                       this.prevWidget = this.widget;
-                   this.widget = other.widget;
-                   return true;
-               }
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       get overrideDOMText() {
-           if (this.length == 0)
-               return Text$3.empty;
-           let top = this;
-           while (top.parent)
-               top = top.parent;
-           let view = top.editorView, text = view && view.state.doc, start = this.posAtStart;
-           return text ? text.slice(start, start + this.length) : Text$3.empty;
-       }
-       domAtPos(pos) {
-           return pos == 0 ? DOMPos$3.before(this.dom) : DOMPos$3.after(this.dom, pos == this.length);
-       }
-       domBoundsAround() { return null; }
-       coordsAt(pos, side) {
-           let rects = this.dom.getClientRects(), rect = null;
-           if (!rects.length)
-               return Rect0$2;
-           for (let i = pos > 0 ? rects.length - 1 : 0;; i += (pos > 0 ? -1 : 1)) {
-               rect = rects[i];
-               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
-                   break;
-           }
-           return (pos == 0 && side > 0 || pos == this.length && side <= 0) ? rect : flattenRect$3(rect, pos == 0);
-       }
-       get isEditable() { return false; }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-   };
-   let CompositionView$2 = class CompositionView extends WidgetView$3 {
-       domAtPos(pos) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return new DOMPos$3(text, Math.min(pos, text.nodeValue.length));
-           return scanCompositionTree$2(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos$3(text, Math.min(p, text.nodeValue.length)));
-       }
-       sync() { this.setDOM(this.widget.toDOM()); }
-       localPosFromDOM(node, offset) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return Math.min(offset, this.length);
-           return posFromDOMInCompositionTree$2(node, offset, topView, text);
-       }
-       ignoreMutation() { return false; }
-       get overrideDOMText() { return null; }
-       coordsAt(pos, side) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return textCoords$3(text, pos, side);
-           return scanCompositionTree$2(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords$3(text, pos, side));
-       }
-       destroy() {
-           var _a;
-           super.destroy();
-           (_a = this.widget.topView) === null || _a === void 0 ? void 0 : _a.destroy();
-       }
-       get isEditable() { return true; }
-   };
-   // Uses the old structure of a chunk of content view frozen for
-   // composition to try and find a reasonable DOM location for the given
-   // offset.
-   function scanCompositionTree$2(pos, side, view, text, enterView, fromText) {
-       if (view instanceof MarkView$3) {
-           for (let child of view.children) {
-               let hasComp = contains$3(child.dom, text);
-               let len = hasComp ? text.nodeValue.length : child.length;
-               if (pos < len || pos == len && child.getSide() <= 0)
-                   return hasComp ? scanCompositionTree$2(pos, side, child, text, enterView, fromText) : enterView(child, pos, side);
-               pos -= len;
-           }
-           return enterView(view, view.length, -1);
-       }
-       else if (view.dom == text) {
-           return fromText(pos, side);
-       }
-       else {
-           return enterView(view, pos, side);
-       }
-   }
-   function posFromDOMInCompositionTree$2(node, offset, view, text) {
-       if (view instanceof MarkView$3) {
-           for (let child of view.children) {
-               let pos = 0, hasComp = contains$3(child.dom, text);
-               if (contains$3(child.dom, node))
-                   return pos + (hasComp ? posFromDOMInCompositionTree$2(node, offset, child, text) : child.localPosFromDOM(node, offset));
-               pos += hasComp ? text.nodeValue.length : child.length;
-           }
-       }
-       else if (view.dom == text) {
-           return Math.min(offset, text.nodeValue.length);
-       }
-       return view.localPosFromDOM(node, offset);
-   }
-   // These are drawn around uneditable widgets to avoid a number of
-   // browser bugs that show up when the cursor is directly next to
-   // uneditable inline content.
-   let WidgetBufferView$3 = class WidgetBufferView extends ContentView$3 {
-       constructor(side) {
-           super();
-           this.side = side;
-       }
-       get length() { return 0; }
-       merge() { return false; }
-       become(other) {
-           return other instanceof WidgetBufferView && other.side == this.side;
-       }
-       split() { return new WidgetBufferView(this.side); }
-       sync() {
-           if (!this.dom) {
-               let dom = document.createElement("img");
-               dom.className = "cm-widgetBuffer";
-               dom.setAttribute("aria-hidden", "true");
-               this.setDOM(dom);
-           }
-       }
-       getSide() { return this.side; }
-       domAtPos(pos) { return DOMPos$3.before(this.dom); }
-       localPosFromDOM() { return 0; }
-       domBoundsAround() { return null; }
-       coordsAt(pos) {
-           let imgRect = this.dom.getBoundingClientRect();
-           // Since the <img> height doesn't correspond to text height, try
-           // to borrow the height from some sibling node.
-           let siblingRect = inlineSiblingRect$2(this, this.side > 0 ? -1 : 1);
-           return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top
-               ? { left: imgRect.left, right: imgRect.right, top: siblingRect.top, bottom: siblingRect.bottom } : imgRect;
-       }
-       get overrideDOMText() {
-           return Text$3.empty;
-       }
-   };
-   TextView$3.prototype.children = WidgetView$3.prototype.children = WidgetBufferView$3.prototype.children = noChildren$3;
-   function inlineSiblingRect$2(view, side) {
-       let parent = view.parent, index = parent ? parent.children.indexOf(view) : -1;
-       while (parent && index >= 0) {
-           if (side < 0 ? index > 0 : index < parent.children.length) {
-               let next = parent.children[index + side];
-               if (next instanceof TextView$3) {
-                   let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
-                   if (nextRect)
-                       return nextRect;
-               }
-               index += side;
-           }
-           else if (parent instanceof MarkView$3 && parent.parent) {
-               index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
-               parent = parent.parent;
-           }
-           else {
-               let last = parent.dom.lastChild;
-               if (last && last.nodeName == "BR")
-                   return last.getClientRects()[0];
-               break;
-           }
-       }
-       return undefined;
-   }
-   function inlineDOMAtPos$3(dom, children, pos) {
-       let i = 0;
-       for (let off = 0; i < children.length; i++) {
-           let child = children[i], end = off + child.length;
-           if (end == off && child.getSide() <= 0)
-               continue;
-           if (pos > off && pos < end && child.dom.parentNode == dom)
-               return child.domAtPos(pos - off);
-           if (pos <= off)
-               break;
-           off = end;
-       }
-       for (; i > 0; i--) {
-           let before = children[i - 1].dom;
-           if (before.parentNode == dom)
-               return DOMPos$3.after(before);
-       }
-       return new DOMPos$3(dom, 0);
-   }
-   // Assumes `view`, if a mark view, has precisely 1 child.
-   function joinInlineInto$3(parent, view, open) {
-       let last, { children } = parent;
-       if (open > 0 && view instanceof MarkView$3 && children.length &&
-           (last = children[children.length - 1]) instanceof MarkView$3 && last.mark.eq(view.mark)) {
-           joinInlineInto$3(last, view.children[0], open - 1);
-       }
-       else {
-           children.push(view);
-           view.setParent(parent);
-       }
-       parent.length += view.length;
-   }
-   function coordsInChildren$3(view, pos, side) {
-       for (let off = 0, i = 0; i < view.children.length; i++) {
-           let child = view.children[i], end = off + child.length, next;
-           if ((side <= 0 || end == view.length || child.getSide() > 0 ? end >= pos : end > pos) &&
-               (pos < end || i + 1 == view.children.length || (next = view.children[i + 1]).length || next.getSide() > 0)) {
-               let flatten = 0;
-               if (end == off) {
-                   if (child.getSide() <= 0)
-                       continue;
-                   flatten = side = -child.getSide();
-               }
-               let rect = child.coordsAt(Math.max(0, pos - off), side);
-               return flatten && rect ? flattenRect$3(rect, side < 0) : rect;
-           }
-           off = end;
-       }
-       let last = view.dom.lastChild;
-       if (!last)
-           return view.dom.getBoundingClientRect();
-       let rects = clientRectsFor$3(last);
-       return rects[rects.length - 1] || null;
-   }
-
-   function combineAttrs$3(source, target) {
-       for (let name in source) {
-           if (name == "class" && target.class)
-               target.class += " " + source.class;
-           else if (name == "style" && target.style)
-               target.style += ";" + source.style;
-           else
-               target[name] = source[name];
-       }
-       return target;
-   }
-   function attrsEq$3(a, b) {
-       if (a == b)
-           return true;
-       if (!a || !b)
-           return false;
-       let keysA = Object.keys(a), keysB = Object.keys(b);
-       if (keysA.length != keysB.length)
-           return false;
-       for (let key of keysA) {
-           if (keysB.indexOf(key) == -1 || a[key] !== b[key])
-               return false;
-       }
-       return true;
-   }
-   function updateAttrs$3(dom, prev, attrs) {
-       let changed = null;
-       if (prev)
-           for (let name in prev)
-               if (!(attrs && name in attrs))
-                   dom.removeAttribute(changed = name);
-       if (attrs)
-           for (let name in attrs)
-               if (!(prev && prev[name] == attrs[name]))
-                   dom.setAttribute(changed = name, attrs[name]);
-       return !!changed;
-   }
-
-   /**
-   Widgets added to the content are described by subclasses of this
-   class. Using a description object like that makes it possible to
-   delay creating of the DOM structure for a widget until it is
-   needed, and to avoid redrawing widgets even if the decorations
-   that define them are recreated.
-   */
-   let WidgetType$3 = class WidgetType {
-       /**
-       Compare this instance to another instance of the same type.
-       (TypeScript can't express this, but only instances of the same
-       specific class will be passed to this method.) This is used to
-       avoid redrawing widgets when they are replaced by a new
-       decoration of the same type. The default implementation just
-       returns `false`, which will cause new instances of the widget to
-       always be redrawn.
-       */
-       eq(widget) { return false; }
-       /**
-       Update a DOM element created by a widget of the same type (but
-       different, non-`eq` content) to reflect this widget. May return
-       true to indicate that it could update, false to indicate it
-       couldn't (in which case the widget will be redrawn). The default
-       implementation just returns false.
-       */
-       updateDOM(dom) { return false; }
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       The estimated height this widget will have, to be used when
-       estimating the height of content that hasn't been drawn. May
-       return -1 to indicate you don't know. The default implementation
-       returns -1.
-       */
-       get estimatedHeight() { return -1; }
-       /**
-       Can be used to configure which kinds of events inside the widget
-       should be ignored by the editor. The default is to ignore all
-       events.
-       */
-       ignoreEvent(event) { return true; }
-       /**
-       @internal
-       */
-       get customView() { return null; }
-       /**
-       This is called when the an instance of the widget is removed
-       from the editor view.
-       */
-       destroy(dom) { }
-   };
-   /**
-   The different types of blocks that can occur in an editor view.
-   */
-   var BlockType$3 = /*@__PURE__*/(function (BlockType) {
-       /**
-       A line of text.
-       */
-       BlockType[BlockType["Text"] = 0] = "Text";
-       /**
-       A block widget associated with the position after it.
-       */
-       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
-       /**
-       A block widget associated with the position before it.
-       */
-       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
-       /**
-       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
-       */
-       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
-   return BlockType})(BlockType$3 || (BlockType$3 = {}));
-   /**
-   A decoration provides information on how to draw or style a piece
-   of content. You'll usually use it wrapped in a
-   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
-   @nonabstract
-   */
-   let Decoration$3 = class Decoration extends RangeValue$3 {
-       constructor(
-       /**
-       @internal
-       */
-       startSide, 
-       /**
-       @internal
-       */
-       endSide, 
-       /**
-       @internal
-       */
-       widget, 
-       /**
-       The config object used to create this decoration. You can
-       include additional properties in there to store metadata about
-       your decoration.
-       */
-       spec) {
-           super();
-           this.startSide = startSide;
-           this.endSide = endSide;
-           this.widget = widget;
-           this.spec = spec;
-       }
-       /**
-       @internal
-       */
-       get heightRelevant() { return false; }
-       /**
-       Create a mark decoration, which influences the styling of the
-       content in its range. Nested mark decorations will cause nested
-       DOM elements to be created. Nesting order is determined by
-       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
-       the higher-precedence decorations creating the inner DOM nodes.
-       Such elements are split on line boundaries and on the boundaries
-       of lower-precedence decorations.
-       */
-       static mark(spec) {
-           return new MarkDecoration$3(spec);
-       }
-       /**
-       Create a widget decoration, which displays a DOM element at the
-       given position.
-       */
-       static widget(spec) {
-           let side = spec.side || 0, block = !!spec.block;
-           side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
-           return new PointDecoration$3(spec, side, side, block, spec.widget || null, false);
-       }
-       /**
-       Create a replace decoration which replaces the given range with
-       a widget, or simply hides it.
-       */
-       static replace(spec) {
-           let block = !!spec.block, startSide, endSide;
-           if (spec.isBlockGap) {
-               startSide = -500000000 /* GapStart */;
-               endSide = 400000000 /* GapEnd */;
-           }
-           else {
-               let { start, end } = getInclusive$3(spec, block);
-               startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
-               endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
-           }
-           return new PointDecoration$3(spec, startSide, endSide, block, spec.widget || null, true);
-       }
-       /**
-       Create a line decoration, which can add DOM attributes to the
-       line starting at the given position.
-       */
-       static line(spec) {
-           return new LineDecoration$3(spec);
-       }
-       /**
-       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
-       decorated range or ranges. If the ranges aren't already sorted,
-       pass `true` for `sort` to make the library sort them for you.
-       */
-       static set(of, sort = false) {
-           return RangeSet$3.of(of, sort);
-       }
-       /**
-       @internal
-       */
-       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
-   };
-   /**
-   The empty set of decorations.
-   */
-   Decoration$3.none = RangeSet$3.empty;
-   let MarkDecoration$3 = class MarkDecoration extends Decoration$3 {
-       constructor(spec) {
-           let { start, end } = getInclusive$3(spec);
-           super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
-           this.tagName = spec.tagName || "span";
-           this.class = spec.class || "";
-           this.attrs = spec.attributes || null;
-       }
-       eq(other) {
-           return this == other ||
-               other instanceof MarkDecoration &&
-                   this.tagName == other.tagName &&
-                   this.class == other.class &&
-                   attrsEq$3(this.attrs, other.attrs);
-       }
-       range(from, to = from) {
-           if (from >= to)
-               throw new RangeError("Mark decorations may not be empty");
-           return super.range(from, to);
-       }
-   };
-   MarkDecoration$3.prototype.point = false;
-   let LineDecoration$3 = class LineDecoration extends Decoration$3 {
-       constructor(spec) {
-           super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
-       }
-       eq(other) {
-           return other instanceof LineDecoration && attrsEq$3(this.spec.attributes, other.spec.attributes);
-       }
-       range(from, to = from) {
-           if (to != from)
-               throw new RangeError("Line decoration ranges must be zero-length");
-           return super.range(from, to);
-       }
-   };
-   LineDecoration$3.prototype.mapMode = MapMode$3.TrackBefore;
-   LineDecoration$3.prototype.point = true;
-   let PointDecoration$3 = class PointDecoration extends Decoration$3 {
-       constructor(spec, startSide, endSide, block, widget, isReplace) {
-           super(startSide, endSide, widget, spec);
-           this.block = block;
-           this.isReplace = isReplace;
-           this.mapMode = !block ? MapMode$3.TrackDel : startSide <= 0 ? MapMode$3.TrackBefore : MapMode$3.TrackAfter;
-       }
-       // Only relevant when this.block == true
-       get type() {
-           return this.startSide < this.endSide ? BlockType$3.WidgetRange
-               : this.startSide <= 0 ? BlockType$3.WidgetBefore : BlockType$3.WidgetAfter;
-       }
-       get heightRelevant() { return this.block || !!this.widget && this.widget.estimatedHeight >= 5; }
-       eq(other) {
-           return other instanceof PointDecoration &&
-               widgetsEq$3(this.widget, other.widget) &&
-               this.block == other.block &&
-               this.startSide == other.startSide && this.endSide == other.endSide;
-       }
-       range(from, to = from) {
-           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
-               throw new RangeError("Invalid range for replacement decoration");
-           if (!this.isReplace && to != from)
-               throw new RangeError("Widget decorations can only have zero-length ranges");
-           return super.range(from, to);
-       }
-   };
-   PointDecoration$3.prototype.point = true;
-   function getInclusive$3(spec, block = false) {
-       let { inclusiveStart: start, inclusiveEnd: end } = spec;
-       if (start == null)
-           start = spec.inclusive;
-       if (end == null)
-           end = spec.inclusive;
-       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
-   }
-   function widgetsEq$3(a, b) {
-       return a == b || !!(a && b && a.compare(b));
-   }
-   function addRange$3(from, to, ranges, margin = 0) {
-       let last = ranges.length - 1;
-       if (last >= 0 && ranges[last] + margin >= from)
-           ranges[last] = Math.max(ranges[last], to);
-       else
-           ranges.push(from, to);
-   }
-
-   let LineView$3 = class LineView extends ContentView$3 {
-       constructor() {
-           super(...arguments);
-           this.children = [];
-           this.length = 0;
-           this.prevAttrs = undefined;
-           this.attrs = null;
-           this.breakAfter = 0;
-       }
-       // Consumes source
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source) {
-               if (!(source instanceof LineView))
-                   return false;
-               if (!this.dom)
-                   source.transferDOM(this); // Reuse source.dom when appropriate
-           }
-           if (hasStart)
-               this.setDeco(source ? source.attrs : null);
-           mergeChildrenInto$3(this, from, to, source ? source.children : [], openStart, openEnd);
-           return true;
-       }
-       split(at) {
-           let end = new LineView;
-           end.breakAfter = this.breakAfter;
-           if (this.length == 0)
-               return end;
-           let { i, off } = this.childPos(at);
-           if (off) {
-               end.append(this.children[i].split(off), 0);
-               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
-               i++;
-           }
-           for (let j = i; j < this.children.length; j++)
-               end.append(this.children[j], 0);
-           while (i > 0 && this.children[i - 1].length == 0)
-               this.children[--i].destroy();
-           this.children.length = i;
-           this.markDirty();
-           this.length = at;
-           return end;
-       }
-       transferDOM(other) {
-           if (!this.dom)
-               return;
-           this.markDirty();
-           other.setDOM(this.dom);
-           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
-           this.prevAttrs = undefined;
-           this.dom = null;
-       }
-       setDeco(attrs) {
-           if (!attrsEq$3(this.attrs, attrs)) {
-               if (this.dom) {
-                   this.prevAttrs = this.attrs;
-                   this.markDirty();
-               }
-               this.attrs = attrs;
-           }
-       }
-       append(child, openStart) {
-           joinInlineInto$3(this, child, openStart);
-       }
-       // Only called when building a line view in ContentBuilder
-       addLineDeco(deco) {
-           let attrs = deco.spec.attributes, cls = deco.spec.class;
-           if (attrs)
-               this.attrs = combineAttrs$3(attrs, this.attrs || {});
-           if (cls)
-               this.attrs = combineAttrs$3({ class: cls }, this.attrs || {});
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos$3(this.dom, this.children, pos);
-       }
-       reuseDOM(node) {
-           if (node.nodeName == "DIV") {
-               this.setDOM(node);
-               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
-           }
-       }
-       sync(track) {
-           var _a;
-           if (!this.dom) {
-               this.setDOM(document.createElement("div"));
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           else if (this.dirty & 4 /* Attrs */) {
-               clearAttributes$3(this.dom);
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           if (this.prevAttrs !== undefined) {
-               updateAttrs$3(this.dom, this.prevAttrs, this.attrs);
-               this.dom.classList.add("cm-line");
-               this.prevAttrs = undefined;
-           }
-           super.sync(track);
-           let last = this.dom.lastChild;
-           while (last && ContentView$3.get(last) instanceof MarkView$3)
-               last = last.lastChild;
-           if (!last || !this.length ||
-               last.nodeName != "BR" && ((_a = ContentView$3.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
-                   (!browser$3.ios || !this.children.some(ch => ch instanceof TextView$3))) {
-               let hack = document.createElement("BR");
-               hack.cmIgnore = true;
-               this.dom.appendChild(hack);
-           }
-       }
-       measureTextSize() {
-           if (this.children.length == 0 || this.length > 20)
-               return null;
-           let totalWidth = 0;
-           for (let child of this.children) {
-               if (!(child instanceof TextView$3))
-                   return null;
-               let rects = clientRectsFor$3(child.dom);
-               if (rects.length != 1)
-                   return null;
-               totalWidth += rects[0].width;
-           }
-           return { lineHeight: this.dom.getBoundingClientRect().height,
-               charWidth: totalWidth / this.length };
-       }
-       coordsAt(pos, side) {
-           return coordsInChildren$3(this, pos, side);
-       }
-       become(_other) { return false; }
-       get type() { return BlockType$3.Text; }
-       static find(docView, pos) {
-           for (let i = 0, off = 0; i < docView.children.length; i++) {
-               let block = docView.children[i], end = off + block.length;
-               if (end >= pos) {
-                   if (block instanceof LineView)
-                       return block;
-                   if (end > pos)
-                       break;
-               }
-               off = end + block.breakAfter;
-           }
-           return null;
-       }
-   };
-   let BlockWidgetView$3 = class BlockWidgetView extends ContentView$3 {
-       constructor(widget, length, type) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.type = type;
-           this.breakAfter = 0;
-           this.prevWidget = null;
-       }
-       merge(from, to, source, _takeDeco, openStart, openEnd) {
-           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       domAtPos(pos) {
-           return pos == 0 ? DOMPos$3.before(this.dom) : DOMPos$3.after(this.dom, pos == this.length);
-       }
-       split(at) {
-           let len = this.length - at;
-           this.length = at;
-           let end = new BlockWidgetView(this.widget, len, this.type);
-           end.breakAfter = this.breakAfter;
-           return end;
-       }
-       get children() { return noChildren$3; }
-       sync() {
-           if (!this.dom || !this.widget.updateDOM(this.dom)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(this.editorView));
-               this.dom.contentEditable = "false";
-           }
-       }
-       get overrideDOMText() {
-           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$3.empty;
-       }
-       domBoundsAround() { return null; }
-       become(other) {
-           if (other instanceof BlockWidgetView && other.type == this.type &&
-               other.widget.constructor == this.widget.constructor) {
-               if (!other.widget.eq(this.widget))
-                   this.markDirty(true);
-               if (this.dom && !this.prevWidget)
-                   this.prevWidget = this.widget;
-               this.widget = other.widget;
-               this.length = other.length;
-               this.breakAfter = other.breakAfter;
-               return true;
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-   };
-
-   let ContentBuilder$3 = class ContentBuilder {
-       constructor(doc, pos, end, disallowBlockEffectsFor) {
-           this.doc = doc;
-           this.pos = pos;
-           this.end = end;
-           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
-           this.content = [];
-           this.curLine = null;
-           this.breakAtStart = 0;
-           this.pendingBuffer = 0 /* No */;
-           // Set to false directly after a widget that covers the position after it
-           this.atCursorPos = true;
-           this.openStart = -1;
-           this.openEnd = -1;
-           this.text = "";
-           this.textOff = 0;
-           this.cursor = doc.iter();
-           this.skip = pos;
-       }
-       posCovered() {
-           if (this.content.length == 0)
-               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
-           let last = this.content[this.content.length - 1];
-           return !last.breakAfter && !(last instanceof BlockWidgetView$3 && last.type == BlockType$3.WidgetBefore);
-       }
-       getLine() {
-           if (!this.curLine) {
-               this.content.push(this.curLine = new LineView$3);
-               this.atCursorPos = true;
-           }
-           return this.curLine;
-       }
-       flushBuffer(active) {
-           if (this.pendingBuffer) {
-               this.curLine.append(wrapMarks$3(new WidgetBufferView$3(-1), active), active.length);
-               this.pendingBuffer = 0 /* No */;
-           }
-       }
-       addBlockWidget(view) {
-           this.flushBuffer([]);
-           this.curLine = null;
-           this.content.push(view);
-       }
-       finish(openEnd) {
-           if (!openEnd)
-               this.flushBuffer([]);
-           else
-               this.pendingBuffer = 0 /* No */;
-           if (!this.posCovered())
-               this.getLine();
-       }
-       buildText(length, active, openStart) {
-           while (length > 0) {
-               if (this.textOff == this.text.length) {
-                   let { value, lineBreak, done } = this.cursor.next(this.skip);
-                   this.skip = 0;
-                   if (done)
-                       throw new Error("Ran out of text content when drawing inline views");
-                   if (lineBreak) {
-                       if (!this.posCovered())
-                           this.getLine();
-                       if (this.content.length)
-                           this.content[this.content.length - 1].breakAfter = 1;
-                       else
-                           this.breakAtStart = 1;
-                       this.flushBuffer([]);
-                       this.curLine = null;
-                       length--;
-                       continue;
-                   }
-                   else {
-                       this.text = value;
-                       this.textOff = 0;
-                   }
-               }
-               let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
-               this.flushBuffer(active.slice(0, openStart));
-               this.getLine().append(wrapMarks$3(new TextView$3(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
-               this.atCursorPos = true;
-               this.textOff += take;
-               length -= take;
-               openStart = 0;
-           }
-       }
-       span(from, to, active, openStart) {
-           this.buildText(to - from, active, openStart);
-           this.pos = to;
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       point(from, to, deco, active, openStart, index) {
-           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration$3) {
-               if (deco.block)
-                   throw new RangeError("Block decorations may not be specified via plugins");
-               if (to > this.doc.lineAt(this.pos).to)
-                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
-           }
-           let len = to - from;
-           if (deco instanceof PointDecoration$3) {
-               if (deco.block) {
-                   let { type } = deco;
-                   if (type == BlockType$3.WidgetAfter && !this.posCovered())
-                       this.getLine();
-                   this.addBlockWidget(new BlockWidgetView$3(deco.widget || new NullWidget$3("div"), len, type));
-               }
-               else {
-                   let view = WidgetView$3.create(deco.widget || new NullWidget$3("span"), len, deco.startSide);
-                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
-                   let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
-                   let line = this.getLine();
-                   if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
-                       this.pendingBuffer = 0 /* No */;
-                   this.flushBuffer(active);
-                   if (cursorBefore) {
-                       line.append(wrapMarks$3(new WidgetBufferView$3(1), active), openStart);
-                       openStart = active.length + Math.max(0, openStart - active.length);
-                   }
-                   line.append(wrapMarks$3(view, active), openStart);
-                   this.atCursorPos = cursorAfter;
-                   this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
-               }
-           }
-           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
-               this.getLine().addLineDeco(deco);
-           }
-           if (len) {
-               // Advance the iterator past the replaced content
-               if (this.textOff + len <= this.text.length) {
-                   this.textOff += len;
-               }
-               else {
-                   this.skip += len - (this.text.length - this.textOff);
-                   this.text = "";
-                   this.textOff = 0;
-               }
-               this.pos = to;
-           }
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       static build(text, from, to, decorations, dynamicDecorationMap) {
-           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
-           builder.openEnd = RangeSet$3.spans(decorations, from, to, builder);
-           if (builder.openStart < 0)
-               builder.openStart = builder.openEnd;
-           builder.finish(builder.openEnd);
-           return builder;
-       }
-   };
-   function wrapMarks$3(view, active) {
-       for (let mark of active)
-           view = new MarkView$3(mark, [view], view.length);
-       return view;
-   }
-   let NullWidget$3 = class NullWidget extends WidgetType$3 {
-       constructor(tag) {
-           super();
-           this.tag = tag;
-       }
-       eq(other) { return other.tag == this.tag; }
-       toDOM() { return document.createElement(this.tag); }
-       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
-   };
-
-   const clickAddsSelectionRange$3 = /*@__PURE__*/Facet$3.define();
-   const dragMovesSelection$1$3 = /*@__PURE__*/Facet$3.define();
-   const mouseSelectionStyle$3 = /*@__PURE__*/Facet$3.define();
-   const exceptionSink$3 = /*@__PURE__*/Facet$3.define();
-   const updateListener$3 = /*@__PURE__*/Facet$3.define();
-   const inputHandler$4 = /*@__PURE__*/Facet$3.define();
-   const perLineTextDirection$3 = /*@__PURE__*/Facet$3.define({
-       combine: values => values.some(x => x)
-   });
-   let ScrollTarget$3 = class ScrollTarget {
-       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5) {
-           this.range = range;
-           this.y = y;
-           this.x = x;
-           this.yMargin = yMargin;
-           this.xMargin = xMargin;
-       }
-       map(changes) {
-           return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);
-       }
-   };
-   const scrollIntoView$5 = /*@__PURE__*/StateEffect$3.define({ map: (t, ch) => t.map(ch) });
-   /**
-   Log or report an unhandled exception in client code. Should
-   probably only be used by extension code that allows client code to
-   provide functions, and calls those functions in a context where an
-   exception can't be propagated to calling code in a reasonable way
-   (for example when in an event handler).
-
-   Either calls a handler registered with
-   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
-   `window.onerror`, if defined, or `console.error` (in which case
-   it'll pass `context`, when given, as first argument).
-   */
-   function logException$3(state, exception, context) {
-       let handler = state.facet(exceptionSink$3);
-       if (handler.length)
-           handler[0](exception);
-       else if (window.onerror)
-           window.onerror(String(exception), context, undefined, undefined, exception);
-       else if (context)
-           console.error(context + ":", exception);
-       else
-           console.error(exception);
-   }
-   const editable$3 = /*@__PURE__*/Facet$3.define({ combine: values => values.length ? values[0] : true });
-   let nextPluginID$3 = 0;
-   const viewPlugin$3 = /*@__PURE__*/Facet$3.define();
-   /**
-   View plugins associate stateful values with a view. They can
-   influence the way the content is drawn, and are notified of things
-   that happen in the view.
-   */
-   let ViewPlugin$3 = class ViewPlugin {
-       constructor(
-       /**
-       @internal
-       */
-       id, 
-       /**
-       @internal
-       */
-       create, 
-       /**
-       @internal
-       */
-       domEventHandlers, buildExtensions) {
-           this.id = id;
-           this.create = create;
-           this.domEventHandlers = domEventHandlers;
-           this.extension = buildExtensions(this);
-       }
-       /**
-       Define a plugin from a constructor function that creates the
-       plugin's value, given an editor view.
-       */
-       static define(create, spec) {
-           const { eventHandlers, provide, decorations: deco } = spec || {};
-           return new ViewPlugin(nextPluginID$3++, create, eventHandlers, plugin => {
-               let ext = [viewPlugin$3.of(plugin)];
-               if (deco)
-                   ext.push(decorations$3.of(view => {
-                       let pluginInst = view.plugin(plugin);
-                       return pluginInst ? deco(pluginInst) : Decoration$3.none;
-                   }));
-               if (provide)
-                   ext.push(provide(plugin));
-               return ext;
-           });
-       }
-       /**
-       Create a plugin for a class whose constructor takes a single
-       editor view as argument.
-       */
-       static fromClass(cls, spec) {
-           return ViewPlugin.define(view => new cls(view), spec);
-       }
-   };
-   let PluginInstance$3 = class PluginInstance {
-       constructor(spec) {
-           this.spec = spec;
-           // When starting an update, all plugins have this field set to the
-           // update object, indicating they need to be updated. When finished
-           // updating, it is set to `false`. Retrieving a plugin that needs to
-           // be updated with `view.plugin` forces an eager update.
-           this.mustUpdate = null;
-           // This is null when the plugin is initially created, but
-           // initialized on the first update.
-           this.value = null;
-       }
-       update(view) {
-           if (!this.value) {
-               if (this.spec) {
-                   try {
-                       this.value = this.spec.create(view);
-                   }
-                   catch (e) {
-                       logException$3(view.state, e, "CodeMirror plugin crashed");
-                       this.deactivate();
-                   }
-               }
-           }
-           else if (this.mustUpdate) {
-               let update = this.mustUpdate;
-               this.mustUpdate = null;
-               if (this.value.update) {
-                   try {
-                       this.value.update(update);
-                   }
-                   catch (e) {
-                       logException$3(update.state, e, "CodeMirror plugin crashed");
-                       if (this.value.destroy)
-                           try {
-                               this.value.destroy();
-                           }
-                           catch (_) { }
-                       this.deactivate();
-                   }
-               }
-           }
-           return this;
-       }
-       destroy(view) {
-           var _a;
-           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
-               try {
-                   this.value.destroy();
-               }
-               catch (e) {
-                   logException$3(view.state, e, "CodeMirror plugin crashed");
-               }
-           }
-       }
-       deactivate() {
-           this.spec = this.value = null;
-       }
-   };
-   const editorAttributes$3 = /*@__PURE__*/Facet$3.define();
-   const contentAttributes$3 = /*@__PURE__*/Facet$3.define();
-   // Provide decorations
-   const decorations$3 = /*@__PURE__*/Facet$3.define();
-   const atomicRanges$3 = /*@__PURE__*/Facet$3.define();
-   const scrollMargins$3 = /*@__PURE__*/Facet$3.define();
-   const styleModule$3 = /*@__PURE__*/Facet$3.define();
-   let ChangedRange$3 = class ChangedRange {
-       constructor(fromA, toA, fromB, toB) {
-           this.fromA = fromA;
-           this.toA = toA;
-           this.fromB = fromB;
-           this.toB = toB;
-       }
-       join(other) {
-           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
-       }
-       addToSet(set) {
-           let i = set.length, me = this;
-           for (; i > 0; i--) {
-               let range = set[i - 1];
-               if (range.fromA > me.toA)
-                   continue;
-               if (range.toA < me.fromA)
-                   break;
-               me = me.join(range);
-               set.splice(i - 1, 1);
-           }
-           set.splice(i, 0, me);
-           return set;
-       }
-       static extendWithRanges(diff, ranges) {
-           if (ranges.length == 0)
-               return diff;
-           let result = [];
-           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
-               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
-               let end = next ? next.fromB : 1e9;
-               while (rI < ranges.length && ranges[rI] < end) {
-                   let from = ranges[rI], to = ranges[rI + 1];
-                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
-                   if (fromB <= toB)
-                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
-                   if (to > end)
-                       break;
-                   else
-                       rI += 2;
-               }
-               if (!next)
-                   return result;
-               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
-               posA = next.toA;
-               posB = next.toB;
-           }
-       }
-   };
-   /**
-   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
-   class, which describe what happened, whenever the view is updated.
-   */
-   let ViewUpdate$3 = class ViewUpdate {
-       constructor(
-       /**
-       The editor view that the update is associated with.
-       */
-       view, 
-       /**
-       The new editor state.
-       */
-       state, 
-       /**
-       The transactions involved in the update. May be empty.
-       */
-       transactions) {
-           this.view = view;
-           this.state = state;
-           this.transactions = transactions;
-           /**
-           @internal
-           */
-           this.flags = 0;
-           this.startState = view.state;
-           this.changes = ChangeSet$3.empty(this.startState.doc.length);
-           for (let tr of transactions)
-               this.changes = this.changes.compose(tr.changes);
-           let changedRanges = [];
-           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange$3(fromA, toA, fromB, toB)));
-           this.changedRanges = changedRanges;
-           let focus = view.hasFocus;
-           if (focus != view.inputState.notifiedFocused) {
-               view.inputState.notifiedFocused = focus;
-               this.flags |= 1 /* Focus */;
-           }
-       }
-       /**
-       @internal
-       */
-       static create(view, state, transactions) {
-           return new ViewUpdate(view, state, transactions);
-       }
-       /**
-       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
-       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
-       update.
-       */
-       get viewportChanged() {
-           return (this.flags & 4 /* Viewport */) > 0;
-       }
-       /**
-       Indicates whether the height of a block element in the editor
-       changed in this update.
-       */
-       get heightChanged() {
-           return (this.flags & 2 /* Height */) > 0;
-       }
-       /**
-       Returns true when the document was modified or the size of the
-       editor, or elements within the editor, changed.
-       */
-       get geometryChanged() {
-           return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
-       }
-       /**
-       True when this update indicates a focus change.
-       */
-       get focusChanged() {
-           return (this.flags & 1 /* Focus */) > 0;
-       }
-       /**
-       Whether the document changed in this update.
-       */
-       get docChanged() {
-           return !this.changes.empty;
-       }
-       /**
-       Whether the selection was explicitly set in this update.
-       */
-       get selectionSet() {
-           return this.transactions.some(tr => tr.selection);
-       }
-       /**
-       @internal
-       */
-       get empty() { return this.flags == 0 && this.transactions.length == 0; }
-   };
-
-   /**
-   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-   */
-   var Direction$3 = /*@__PURE__*/(function (Direction) {
-       // (These are chosen to match the base levels, in bidi algorithm
-       // terms, of spans in that direction.)
-       /**
-       Left-to-right.
-       */
-       Direction[Direction["LTR"] = 0] = "LTR";
-       /**
-       Right-to-left.
-       */
-       Direction[Direction["RTL"] = 1] = "RTL";
-   return Direction})(Direction$3 || (Direction$3 = {}));
-   const LTR$3 = Direction$3.LTR, RTL$3 = Direction$3.RTL;
-   // Decode a string with each type encoded as log2(type)
-   function dec$3(str) {
-       let result = [];
-       for (let i = 0; i < str.length; i++)
-           result.push(1 << +str[i]);
-       return result;
-   }
-   // Character types for codepoints 0 to 0xf8
-   const LowTypes$3 = /*@__PURE__*/dec$3("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
-   // Character types for codepoints 0x600 to 0x6f9
-   const ArabicTypes$3 = /*@__PURE__*/dec$3("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
-   const Brackets$3 = /*@__PURE__*/Object.create(null), BracketStack$3 = [];
-   // There's a lot more in
-   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
-   // which are left out to keep code size down.
-   for (let p of ["()", "[]", "{}"]) {
-       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
-       Brackets$3[l] = r;
-       Brackets$3[r] = -l;
-   }
-   function charType$3(ch) {
-       return ch <= 0xf7 ? LowTypes$3[ch] :
-           0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
-               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes$3[ch - 0x600] :
-                   0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
-                       0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
-                           ch == 0x200c ? 256 /* NI */ : 1 /* L */;
-   }
-   const BidiRE$3 = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
-   /**
-   Represents a contiguous range of text that has a single direction
-   (as in left-to-right or right-to-left).
-   */
-   let BidiSpan$3 = class BidiSpan {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the span (relative to the start of the line).
-       */
-       from, 
-       /**
-       The end of the span.
-       */
-       to, 
-       /**
-       The ["bidi
-       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
-       of the span (in this context, 0 means
-       left-to-right, 1 means right-to-left, 2 means left-to-right
-       number inside right-to-left text).
-       */
-       level) {
-           this.from = from;
-           this.to = to;
-           this.level = level;
-       }
-       /**
-       The direction of this span.
-       */
-       get dir() { return this.level % 2 ? RTL$3 : LTR$3; }
-       /**
-       @internal
-       */
-       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
-       /**
-       @internal
-       */
-       static find(order, index, level, assoc) {
-           let maybe = -1;
-           for (let i = 0; i < order.length; i++) {
-               let span = order[i];
-               if (span.from <= index && span.to >= index) {
-                   if (span.level == level)
-                       return i;
-                   // When multiple spans match, if assoc != 0, take the one that
-                   // covers that side, otherwise take the one with the minimum
-                   // level.
-                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
-                       maybe = i;
-               }
-           }
-           if (maybe < 0)
-               throw new RangeError("Index out of range");
-           return maybe;
-       }
-   };
-   // Reused array of character types
-   const types$3 = [];
-   function computeOrder$3(line, direction) {
-       let len = line.length, outerType = direction == LTR$3 ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR$3 ? 2 /* R */ : 1 /* L */;
-       if (!line || outerType == 1 /* L */ && !BidiRE$3.test(line))
-           return trivialOrder$3(len);
-       // W1. Examine each non-spacing mark (NSM) in the level run, and
-       // change the type of the NSM to the type of the previous
-       // character. If the NSM is at the start of the level run, it will
-       // get the type of sor.
-       // W2. Search backwards from each instance of a European number
-       // until the first strong type (R, L, AL, or sor) is found. If an
-       // AL is found, change the type of the European number to Arabic
-       // number.
-       // W3. Change all ALs to R.
-       // (Left after this: L, R, EN, AN, ET, CS, NI)
-       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
-           let type = charType$3(line.charCodeAt(i));
-           if (type == 512 /* NSM */)
-               type = prev;
-           else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
-               type = 16 /* AN */;
-           types$3[i] = type == 4 /* AL */ ? 2 /* R */ : type;
-           if (type & 7 /* Strong */)
-               prevStrong = type;
-           prev = type;
-       }
-       // W5. A sequence of European terminators adjacent to European
-       // numbers changes to all European numbers.
-       // W6. Otherwise, separators and terminators change to Other
-       // Neutral.
-       // W7. Search backwards from each instance of a European number
-       // until the first strong type (R, L, or sor) is found. If an L is
-       // found, then change the type of the European number to L.
-       // (Left after this: L, R, EN+AN, NI)
-       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
-           let type = types$3[i];
-           if (type == 128 /* CS */) {
-               if (i < len - 1 && prev == types$3[i + 1] && (prev & 24 /* Num */))
-                   type = types$3[i] = prev;
-               else
-                   types$3[i] = 256 /* NI */;
-           }
-           else if (type == 64 /* ET */) {
-               let end = i + 1;
-               while (end < len && types$3[end] == 64 /* ET */)
-                   end++;
-               let replace = (i && prev == 8 /* EN */) || (end < len && types$3[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
-               for (let j = i; j < end; j++)
-                   types$3[j] = replace;
-               i = end - 1;
-           }
-           else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
-               types$3[i] = 1 /* L */;
-           }
-           prev = type;
-           if (type & 7 /* Strong */)
-               prevStrong = type;
-       }
-       // N0. Process bracket pairs in an isolating run sequence
-       // sequentially in the logical order of the text positions of the
-       // opening paired brackets using the logic given below. Within this
-       // scope, bidirectional types EN and AN are treated as R.
-       for (let i = 0, sI = 0, context = 0, ch, br, type; i < len; i++) {
-           // Keeps [startIndex, type, strongSeen] triples for each open
-           // bracket on BracketStack.
-           if (br = Brackets$3[ch = line.charCodeAt(i)]) {
-               if (br < 0) { // Closing bracket
-                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                       if (BracketStack$3[sJ + 1] == -br) {
-                           let flags = BracketStack$3[sJ + 2];
-                           let type = (flags & 2 /* EmbedInside */) ? outerType :
-                               !(flags & 4 /* OppositeInside */) ? 0 :
-                                   (flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
-                           if (type)
-                               types$3[i] = types$3[BracketStack$3[sJ]] = type;
-                           sI = sJ;
-                           break;
-                       }
-                   }
-               }
-               else if (BracketStack$3.length == 189 /* MaxDepth */) {
-                   break;
-               }
-               else {
-                   BracketStack$3[sI++] = i;
-                   BracketStack$3[sI++] = ch;
-                   BracketStack$3[sI++] = context;
-               }
-           }
-           else if ((type = types$3[i]) == 2 /* R */ || type == 1 /* L */) {
-               let embed = type == outerType;
-               context = embed ? 0 : 1 /* OppositeBefore */;
-               for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                   let cur = BracketStack$3[sJ + 2];
-                   if (cur & 2 /* EmbedInside */)
-                       break;
-                   if (embed) {
-                       BracketStack$3[sJ + 2] |= 2 /* EmbedInside */;
-                   }
-                   else {
-                       if (cur & 4 /* OppositeInside */)
-                           break;
-                       BracketStack$3[sJ + 2] |= 4 /* OppositeInside */;
-                   }
-               }
-           }
-       }
-       // N1. A sequence of neutrals takes the direction of the
-       // surrounding strong text if the text on both sides has the same
-       // direction. European and Arabic numbers act as if they were R in
-       // terms of their influence on neutrals. Start-of-level-run (sor)
-       // and end-of-level-run (eor) are used at level run boundaries.
-       // N2. Any remaining neutrals take the embedding direction.
-       // (Left after this: L, R, EN+AN)
-       for (let i = 0; i < len; i++) {
-           if (types$3[i] == 256 /* NI */) {
-               let end = i + 1;
-               while (end < len && types$3[end] == 256 /* NI */)
-                   end++;
-               let beforeL = (i ? types$3[i - 1] : outerType) == 1 /* L */;
-               let afterL = (end < len ? types$3[end] : outerType) == 1 /* L */;
-               let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
-               for (let j = i; j < end; j++)
-                   types$3[j] = replace;
-               i = end - 1;
-           }
-       }
-       // Here we depart from the documented algorithm, in order to avoid
-       // building up an actual levels array. Since there are only three
-       // levels (0, 1, 2) in an implementation that doesn't take
-       // explicit embedding into account, we can build up the order on
-       // the fly, without following the level-based algorithm.
-       let order = [];
-       if (outerType == 1 /* L */) {
-           for (let i = 0; i < len;) {
-               let start = i, rtl = types$3[i++] != 1 /* L */;
-               while (i < len && rtl == (types$3[i] != 1 /* L */))
-                   i++;
-               if (rtl) {
-                   for (let j = i; j > start;) {
-                       let end = j, l = types$3[--j] != 2 /* R */;
-                       while (j > start && l == (types$3[j - 1] != 2 /* R */))
-                           j--;
-                       order.push(new BidiSpan$3(j, end, l ? 2 : 1));
-                   }
-               }
-               else {
-                   order.push(new BidiSpan$3(start, i, 0));
-               }
-           }
-       }
-       else {
-           for (let i = 0; i < len;) {
-               let start = i, rtl = types$3[i++] == 2 /* R */;
-               while (i < len && rtl == (types$3[i] == 2 /* R */))
-                   i++;
-               order.push(new BidiSpan$3(start, i, rtl ? 1 : 2));
-           }
-       }
-       return order;
-   }
-   function trivialOrder$3(length) {
-       return [new BidiSpan$3(0, length, 0)];
-   }
-   let movedOver$3 = "";
-   function moveVisually$3(line, order, dir, start, forward) {
-       var _a;
-       let startIndex = start.head - line.from, spanI = -1;
-       if (startIndex == 0) {
-           if (!forward || !line.length)
-               return null;
-           if (order[0].level != dir) {
-               startIndex = order[0].side(false, dir);
-               spanI = 0;
-           }
-       }
-       else if (startIndex == line.length) {
-           if (forward)
-               return null;
-           let last = order[order.length - 1];
-           if (last.level != dir) {
-               startIndex = last.side(true, dir);
-               spanI = order.length - 1;
-           }
-       }
-       if (spanI < 0)
-           spanI = BidiSpan$3.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
-       let span = order[spanI];
-       // End of span. (But not end of line--that was checked for above.)
-       if (startIndex == span.side(forward, dir)) {
-           span = order[spanI += forward ? 1 : -1];
-           startIndex = span.side(!forward, dir);
-       }
-       let indexForward = forward == (span.dir == dir);
-       let nextIndex = findClusterBreak$4(line.text, startIndex, indexForward);
-       movedOver$3 = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
-       if (nextIndex != span.side(forward, dir))
-           return EditorSelection$3.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);
-       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
-       if (!nextSpan && span.level != dir)
-           return EditorSelection$3.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);
-       if (nextSpan && nextSpan.level < span.level)
-           return EditorSelection$3.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
-       return EditorSelection$3.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
-   }
-
-   const LineBreakPlaceholder$3 = "\uffff";
-   let DOMReader$3 = class DOMReader {
-       constructor(points, state) {
-           this.points = points;
-           this.text = "";
-           this.lineSeparator = state.facet(EditorState$3.lineSeparator);
-       }
-       append(text) {
-           this.text += text;
-       }
-       lineBreak() {
-           this.text += LineBreakPlaceholder$3;
-       }
-       readRange(start, end) {
-           if (!start)
-               return this;
-           let parent = start.parentNode;
-           for (let cur = start;;) {
-               this.findPointBefore(parent, cur);
-               this.readNode(cur);
-               let next = cur.nextSibling;
-               if (next == end)
-                   break;
-               let view = ContentView$3.get(cur), nextView = ContentView$3.get(next);
-               if (view && nextView ? view.breakAfter :
-                   (view ? view.breakAfter : isBlockElement$3(cur)) ||
-                       (isBlockElement$3(next) && (cur.nodeName != "BR" || cur.cmIgnore)))
-                   this.lineBreak();
-               cur = next;
-           }
-           this.findPointBefore(parent, end);
-           return this;
-       }
-       readTextNode(node) {
-           let text = node.nodeValue;
-           for (let point of this.points)
-               if (point.node == node)
-                   point.pos = this.text.length + Math.min(point.offset, text.length);
-           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
-               let nextBreak = -1, breakSize = 1, m;
-               if (this.lineSeparator) {
-                   nextBreak = text.indexOf(this.lineSeparator, off);
-                   breakSize = this.lineSeparator.length;
-               }
-               else if (m = re.exec(text)) {
-                   nextBreak = m.index;
-                   breakSize = m[0].length;
-               }
-               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
-               if (nextBreak < 0)
-                   break;
-               this.lineBreak();
-               if (breakSize > 1)
-                   for (let point of this.points)
-                       if (point.node == node && point.pos > this.text.length)
-                           point.pos -= breakSize - 1;
-               off = nextBreak + breakSize;
-           }
-       }
-       readNode(node) {
-           if (node.cmIgnore)
-               return;
-           let view = ContentView$3.get(node);
-           let fromView = view && view.overrideDOMText;
-           if (fromView != null) {
-               this.findPointInside(node, fromView.length);
-               for (let i = fromView.iter(); !i.next().done;) {
-                   if (i.lineBreak)
-                       this.lineBreak();
-                   else
-                       this.append(i.value);
-               }
-           }
-           else if (node.nodeType == 3) {
-               this.readTextNode(node);
-           }
-           else if (node.nodeName == "BR") {
-               if (node.nextSibling)
-                   this.lineBreak();
-           }
-           else if (node.nodeType == 1) {
-               this.readRange(node.firstChild, null);
-           }
-       }
-       findPointBefore(node, next) {
-           for (let point of this.points)
-               if (point.node == node && node.childNodes[point.offset] == next)
-                   point.pos = this.text.length;
-       }
-       findPointInside(node, maxLen) {
-           for (let point of this.points)
-               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
-                   point.pos = this.text.length + Math.min(maxLen, point.offset);
-       }
-   };
-   function isBlockElement$3(node) {
-       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
-   }
-   let DOMPoint$3 = class DOMPoint {
-       constructor(node, offset) {
-           this.node = node;
-           this.offset = offset;
-           this.pos = -1;
-       }
-   };
-
-   let DocView$3 = class DocView extends ContentView$3 {
-       constructor(view) {
-           super();
-           this.view = view;
-           this.compositionDeco = Decoration$3.none;
-           this.decorations = [];
-           this.dynamicDecorationMap = [];
-           // Track a minimum width for the editor. When measuring sizes in
-           // measureVisibleLineHeights, this is updated to point at the width
-           // of a given element and its extent in the document. When a change
-           // happens in that range, these are reset. That way, once we've seen
-           // a line/element of a given length, we keep the editor wide enough
-           // to fit at least that element, until it is changed, at which point
-           // we forget it again.
-           this.minWidth = 0;
-           this.minWidthFrom = 0;
-           this.minWidthTo = 0;
-           // Track whether the DOM selection was set in a lossy way, so that
-           // we don't mess it up when reading it back it
-           this.impreciseAnchor = null;
-           this.impreciseHead = null;
-           this.forceSelection = false;
-           // Used by the resize observer to ignore resizes that we caused
-           // ourselves
-           this.lastUpdate = Date.now();
-           this.setDOM(view.contentDOM);
-           this.children = [new LineView$3];
-           this.children[0].setParent(this);
-           this.updateDeco();
-           this.updateInner([new ChangedRange$3(0, 0, 0, view.state.doc.length)], 0);
-       }
-       get root() { return this.view.root; }
-       get editorView() { return this.view; }
-       get length() { return this.view.state.doc.length; }
-       // Update the document view to a given state. scrollIntoView can be
-       // used as a hint to compute a new viewport that includes that
-       // position, if we know the editor is going to scroll that position
-       // into view.
-       update(update) {
-           let changedRanges = update.changedRanges;
-           if (this.minWidth > 0 && changedRanges.length) {
-               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
-                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
-               }
-               else {
-                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
-                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
-               }
-           }
-           if (this.view.inputState.composing < 0)
-               this.compositionDeco = Decoration$3.none;
-           else if (update.transactions.length || this.dirty)
-               this.compositionDeco = computeCompositionDeco$2(this.view, update.changes);
-           // When the DOM nodes around the selection are moved to another
-           // parent, Chrome sometimes reports a different selection through
-           // getSelection than the one that it actually shows to the user.
-           // This forces a selection update when lines are joined to work
-           // around that. Issue #54
-           if ((browser$3.ie || browser$3.chrome) && !this.compositionDeco.size && update &&
-               update.state.doc.lines != update.startState.doc.lines)
-               this.forceSelection = true;
-           let prevDeco = this.decorations, deco = this.updateDeco();
-           let decoDiff = findChangedDeco$3(prevDeco, deco, update.changes);
-           changedRanges = ChangedRange$3.extendWithRanges(changedRanges, decoDiff);
-           if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
-               return false;
-           }
-           else {
-               this.updateInner(changedRanges, update.startState.doc.length);
-               if (update.transactions.length)
-                   this.lastUpdate = Date.now();
-               return true;
-           }
-       }
-       // Used by update and the constructor do perform the actual DOM
-       // update
-       updateInner(changes, oldLength) {
-           this.view.viewState.mustMeasureContent = true;
-           this.updateChildren(changes, oldLength);
-           let { observer } = this.view;
-           observer.ignore(() => {
-               // Lock the height during redrawing, since Chrome sometimes
-               // messes with the scroll position during DOM mutation (though
-               // no relayout is triggered and I cannot imagine how it can
-               // recompute the scroll position without a layout)
-               this.dom.style.height = this.view.viewState.contentHeight + "px";
-               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
-               // Chrome will sometimes, when DOM mutations occur directly
-               // around the selection, get confused and report a different
-               // selection from the one it displays (issue #218). This tries
-               // to detect that situation.
-               let track = browser$3.chrome || browser$3.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
-               this.sync(track);
-               this.dirty = 0 /* Not */;
-               if (track && (track.written || observer.selectionRange.focusNode != track.node))
-                   this.forceSelection = true;
-               this.dom.style.height = "";
-           });
-           let gaps = [];
-           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
-               for (let child of this.children)
-                   if (child instanceof BlockWidgetView$3 && child.widget instanceof BlockGapWidget$3)
-                       gaps.push(child.dom);
-           observer.updateGaps(gaps);
-       }
-       updateChildren(changes, oldLength) {
-           let cursor = this.childCursor(oldLength);
-           for (let i = changes.length - 1;; i--) {
-               let next = i >= 0 ? changes[i] : null;
-               if (!next)
-                   break;
-               let { fromA, toA, fromB, toB } = next;
-               let { content, breakAtStart, openStart, openEnd } = ContentBuilder$3.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap);
-               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
-               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
-               replaceRange$3(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
-           }
-       }
-       // Sync the DOM selection to this.state.selection
-       updateSelection(mustRead = false, fromPointer = false) {
-           if (mustRead)
-               this.view.observer.readSelectionRange();
-           if (!(fromPointer || this.mayControlSelection()) ||
-               browser$3.ios && this.view.inputState.rapidCompositionStart)
-               return;
-           let force = this.forceSelection;
-           this.forceSelection = false;
-           let main = this.view.state.selection.main;
-           // FIXME need to handle the case where the selection falls inside a block range
-           let anchor = this.domAtPos(main.anchor);
-           let head = main.empty ? anchor : this.domAtPos(main.head);
-           // Always reset on Firefox when next to an uneditable node to
-           // avoid invisible cursor bugs (#111)
-           if (browser$3.gecko && main.empty && betweenUneditable$3(anchor)) {
-               let dummy = document.createTextNode("");
-               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
-               anchor = head = new DOMPos$3(dummy, 0);
-               force = true;
-           }
-           let domSel = this.view.observer.selectionRange;
-           // If the selection is already here, or in an equivalent position, don't touch it
-           if (force || !domSel.focusNode ||
-               !isEquivalentPosition$3(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
-               !isEquivalentPosition$3(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
-               this.view.observer.ignore(() => {
-                   // Chrome Android will hide the virtual keyboard when tapping
-                   // inside an uneditable node, and not bring it back when we
-                   // move the cursor to its proper position. This tries to
-                   // restore the keyboard by cycling focus.
-                   if (browser$3.android && browser$3.chrome && this.dom.contains(domSel.focusNode) &&
-                       inUneditable$3(domSel.focusNode, this.dom)) {
-                       this.dom.blur();
-                       this.dom.focus({ preventScroll: true });
-                   }
-                   let rawSel = getSelection$3(this.root);
-                   if (main.empty) {
-                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
-                       if (browser$3.gecko) {
-                           let nextTo = nextToUneditable$3(anchor.node, anchor.offset);
-                           if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
-                               let text = nearbyTextNode$2(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
-                               if (text)
-                                   anchor = new DOMPos$3(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
-                           }
-                       }
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       if (main.bidiLevel != null && domSel.cursorBidiLevel != null)
-                           domSel.cursorBidiLevel = main.bidiLevel;
-                   }
-                   else if (rawSel.extend) {
-                       // Selection.extend can be used to create an 'inverted' selection
-                       // (one where the focus is before the anchor), but not all
-                       // browsers support it yet.
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       rawSel.extend(head.node, head.offset);
-                   }
-                   else {
-                       // Primitive (IE) way
-                       let range = document.createRange();
-                       if (main.anchor > main.head)
-                           [anchor, head] = [head, anchor];
-                       range.setEnd(head.node, head.offset);
-                       range.setStart(anchor.node, anchor.offset);
-                       rawSel.removeAllRanges();
-                       rawSel.addRange(range);
-                   }
-               });
-               this.view.observer.setSelectionRange(anchor, head);
-           }
-           this.impreciseAnchor = anchor.precise ? null : new DOMPos$3(domSel.anchorNode, domSel.anchorOffset);
-           this.impreciseHead = head.precise ? null : new DOMPos$3(domSel.focusNode, domSel.focusOffset);
-       }
-       enforceCursorAssoc() {
-           if (this.compositionDeco.size)
-               return;
-           let cursor = this.view.state.selection.main;
-           let sel = getSelection$3(this.root);
-           if (!cursor.empty || !cursor.assoc || !sel.modify)
-               return;
-           let line = LineView$3.find(this, cursor.head);
-           if (!line)
-               return;
-           let lineStart = line.posAtStart;
-           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
-               return;
-           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
-           if (!before || !after || before.bottom > after.top)
-               return;
-           let dom = this.domAtPos(cursor.head + cursor.assoc);
-           sel.collapse(dom.node, dom.offset);
-           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
-       }
-       mayControlSelection() {
-           return this.view.state.facet(editable$3) ? this.root.activeElement == this.dom
-               : hasSelection$3(this.dom, this.view.observer.selectionRange);
-       }
-       nearest(dom) {
-           for (let cur = dom; cur;) {
-               let domView = ContentView$3.get(cur);
-               if (domView && domView.rootView == this)
-                   return domView;
-               cur = cur.parentNode;
-           }
-           return null;
-       }
-       posFromDOM(node, offset) {
-           let view = this.nearest(node);
-           if (!view)
-               throw new RangeError("Trying to find position for a DOM position outside of the document");
-           return view.localPosFromDOM(node, offset) + view.posAtStart;
-       }
-       domAtPos(pos) {
-           let { i, off } = this.childCursor().findPos(pos, -1);
-           for (; i < this.children.length - 1;) {
-               let child = this.children[i];
-               if (off < child.length || child instanceof LineView$3)
-                   break;
-               i++;
-               off = 0;
-           }
-           return this.children[i].domAtPos(off);
-       }
-       coordsAt(pos, side) {
-           for (let off = this.length, i = this.children.length - 1;; i--) {
-               let child = this.children[i], start = off - child.breakAfter - child.length;
-               if (pos > start ||
-                   (pos == start && child.type != BlockType$3.WidgetBefore && child.type != BlockType$3.WidgetAfter &&
-                       (!i || side == 2 || this.children[i - 1].breakAfter ||
-                           (this.children[i - 1].type == BlockType$3.WidgetBefore && side > -2))))
-                   return child.coordsAt(pos - start, side);
-               off = start;
-           }
-       }
-       measureVisibleLineHeights(viewport) {
-           let result = [], { from, to } = viewport;
-           let contentWidth = this.view.contentDOM.clientWidth;
-           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
-           let widest = -1, ltr = this.view.textDirection == Direction$3.LTR;
-           for (let pos = 0, i = 0; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (end > to)
-                   break;
-               if (pos >= from) {
-                   let childRect = child.dom.getBoundingClientRect();
-                   result.push(childRect.height);
-                   if (isWider) {
-                       let last = child.dom.lastChild;
-                       let rects = last ? clientRectsFor$3(last) : [];
-                       if (rects.length) {
-                           let rect = rects[rects.length - 1];
-                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
-                           if (width > widest) {
-                               widest = width;
-                               this.minWidth = contentWidth;
-                               this.minWidthFrom = pos;
-                               this.minWidthTo = end;
-                           }
-                       }
-                   }
-               }
-               pos = end + child.breakAfter;
-           }
-           return result;
-       }
-       textDirectionAt(pos) {
-           let { i } = this.childPos(pos, 1);
-           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction$3.RTL : Direction$3.LTR;
-       }
-       measureTextSize() {
-           for (let child of this.children) {
-               if (child instanceof LineView$3) {
-                   let measure = child.measureTextSize();
-                   if (measure)
-                       return measure;
-               }
-           }
-           // If no workable line exists, force a layout of a measurable element
-           let dummy = document.createElement("div"), lineHeight, charWidth;
-           dummy.className = "cm-line";
-           dummy.textContent = "abc def ghi jkl mno pqr stu";
-           this.view.observer.ignore(() => {
-               this.dom.appendChild(dummy);
-               let rect = clientRectsFor$3(dummy.firstChild)[0];
-               lineHeight = dummy.getBoundingClientRect().height;
-               charWidth = rect ? rect.width / 27 : 7;
-               dummy.remove();
-           });
-           return { lineHeight, charWidth };
-       }
-       childCursor(pos = this.length) {
-           // Move back to start of last element when possible, so that
-           // `ChildCursor.findPos` doesn't have to deal with the edge case
-           // of being after the last element.
-           let i = this.children.length;
-           if (i)
-               pos -= this.children[--i].length;
-           return new ChildCursor$3(this.children, pos, i);
-       }
-       computeBlockGapDeco() {
-           let deco = [], vs = this.view.viewState;
-           for (let pos = 0, i = 0;; i++) {
-               let next = i == vs.viewports.length ? null : vs.viewports[i];
-               let end = next ? next.from - 1 : this.length;
-               if (end > pos) {
-                   let height = vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top;
-                   deco.push(Decoration$3.replace({
-                       widget: new BlockGapWidget$3(height),
-                       block: true,
-                       inclusive: true,
-                       isBlockGap: true,
-                   }).range(pos, end));
-               }
-               if (!next)
-                   break;
-               pos = next.to + 1;
-           }
-           return Decoration$3.set(deco);
-       }
-       updateDeco() {
-           let allDeco = this.view.state.facet(decorations$3).map((d, i) => {
-               let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
-               return dynamic ? d(this.view) : d;
-           });
-           for (let i = allDeco.length; i < allDeco.length + 3; i++)
-               this.dynamicDecorationMap[i] = false;
-           return this.decorations = [
-               ...allDeco,
-               this.compositionDeco,
-               this.computeBlockGapDeco(),
-               this.view.viewState.lineGapDeco
-           ];
-       }
-       scrollIntoView(target) {
-           let { range } = target;
-           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
-           if (!rect)
-               return;
-           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
-               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
-                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
-           let mLeft = 0, mRight = 0, mTop = 0, mBottom = 0;
-           for (let margins of this.view.state.facet(scrollMargins$3).map(f => f(this.view)))
-               if (margins) {
-                   let { left, right, top, bottom } = margins;
-                   if (left != null)
-                       mLeft = Math.max(mLeft, left);
-                   if (right != null)
-                       mRight = Math.max(mRight, right);
-                   if (top != null)
-                       mTop = Math.max(mTop, top);
-                   if (bottom != null)
-                       mBottom = Math.max(mBottom, bottom);
-               }
-           let targetRect = {
-               left: rect.left - mLeft, top: rect.top - mTop,
-               right: rect.right + mRight, bottom: rect.bottom + mBottom
-           };
-           scrollRectIntoView$3(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction$3.LTR);
-       }
-   };
-   function betweenUneditable$3(pos) {
-       return pos.node.nodeType == 1 && pos.node.firstChild &&
-           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
-           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
-   }
-   let BlockGapWidget$3 = class BlockGapWidget extends WidgetType$3 {
-       constructor(height) {
-           super();
-           this.height = height;
-       }
-       toDOM() {
-           let elt = document.createElement("div");
-           this.updateDOM(elt);
-           return elt;
-       }
-       eq(other) { return other.height == this.height; }
-       updateDOM(elt) {
-           elt.style.height = this.height + "px";
-           return true;
-       }
-       get estimatedHeight() { return this.height; }
-   };
-   function compositionSurroundingNode$2(view) {
-       let sel = view.observer.selectionRange;
-       let textNode = sel.focusNode && nearbyTextNode$2(sel.focusNode, sel.focusOffset, 0);
-       if (!textNode)
-           return null;
-       let cView = view.docView.nearest(textNode);
-       if (!cView)
-           return null;
-       if (cView instanceof LineView$3) {
-           let topNode = textNode;
-           while (topNode.parentNode != cView.dom)
-               topNode = topNode.parentNode;
-           let prev = topNode.previousSibling;
-           while (prev && !ContentView$3.get(prev))
-               prev = prev.previousSibling;
-           let pos = prev ? ContentView$3.get(prev).posAtEnd : cView.posAtStart;
-           return { from: pos, to: pos, node: topNode, text: textNode };
-       }
-       else {
-           for (;;) {
-               let { parent } = cView;
-               if (!parent)
-                   return null;
-               if (parent instanceof LineView$3)
-                   break;
-               cView = parent;
-           }
-           let from = cView.posAtStart;
-           return { from, to: from + cView.length, node: cView.dom, text: textNode };
-       }
-   }
-   function computeCompositionDeco$2(view, changes) {
-       let surrounding = compositionSurroundingNode$2(view);
-       if (!surrounding)
-           return Decoration$3.none;
-       let { from, to, node, text: textNode } = surrounding;
-       let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
-       let { state } = view, text = node.nodeType == 3 ? node.nodeValue :
-           new DOMReader$3([], state).readRange(node.firstChild, null).text;
-       if (newTo - newFrom < text.length) {
-           if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder$3) == text)
-               newTo = newFrom + text.length;
-           else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder$3) == text)
-               newFrom = newTo - text.length;
-           else
-               return Decoration$3.none;
-       }
-       else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder$3) != text) {
-           return Decoration$3.none;
-       }
-       let topView = ContentView$3.get(node);
-       if (topView instanceof CompositionView$2)
-           topView = topView.widget.topView;
-       else if (topView)
-           topView.parent = null;
-       return Decoration$3.set(Decoration$3.replace({ widget: new CompositionWidget$2(node, textNode, topView), inclusive: true })
-           .range(newFrom, newTo));
-   }
-   let CompositionWidget$2 = class CompositionWidget extends WidgetType$3 {
-       constructor(top, text, topView) {
-           super();
-           this.top = top;
-           this.text = text;
-           this.topView = topView;
-       }
-       eq(other) { return this.top == other.top && this.text == other.text; }
-       toDOM() { return this.top; }
-       ignoreEvent() { return false; }
-       get customView() { return CompositionView$2; }
-   };
-   function nearbyTextNode$2(node, offset, side) {
-       for (;;) {
-           if (node.nodeType == 3)
-               return node;
-           if (node.nodeType == 1 && offset > 0 && side <= 0) {
-               node = node.childNodes[offset - 1];
-               offset = maxOffset$3(node);
-           }
-           else if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {
-               node = node.childNodes[offset];
-               offset = 0;
-           }
-           else {
-               return null;
-           }
-       }
-   }
-   function nextToUneditable$3(node, offset) {
-       if (node.nodeType != 1)
-           return 0;
-       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
-           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
-   }
-   let DecorationComparator$1$3 = class DecorationComparator$1 {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange(from, to) { addRange$3(from, to, this.changes); }
-       comparePoint(from, to) { addRange$3(from, to, this.changes); }
-   };
-   function findChangedDeco$3(a, b, diff) {
-       let comp = new DecorationComparator$1$3;
-       RangeSet$3.compare(a, b, diff, comp);
-       return comp.changes;
-   }
-   function inUneditable$3(node, inside) {
-       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
-           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
-               return true;
-           }
-       }
-       return false;
-   }
-
-   function groupAt$3(state, pos, bias = 1) {
-       let categorize = state.charCategorizer(pos);
-       let line = state.doc.lineAt(pos), linePos = pos - line.from;
-       if (line.length == 0)
-           return EditorSelection$3.cursor(pos);
-       if (linePos == 0)
-           bias = 1;
-       else if (linePos == line.length)
-           bias = -1;
-       let from = linePos, to = linePos;
-       if (bias < 0)
-           from = findClusterBreak$4(line.text, linePos, false);
-       else
-           to = findClusterBreak$4(line.text, linePos);
-       let cat = categorize(line.text.slice(from, to));
-       while (from > 0) {
-           let prev = findClusterBreak$4(line.text, from, false);
-           if (categorize(line.text.slice(prev, from)) != cat)
-               break;
-           from = prev;
-       }
-       while (to < line.length) {
-           let next = findClusterBreak$4(line.text, to);
-           if (categorize(line.text.slice(to, next)) != cat)
-               break;
-           to = next;
-       }
-       return EditorSelection$3.range(from + line.from, to + line.from);
-   }
-   // Search the DOM for the {node, offset} position closest to the given
-   // coordinates. Very inefficient and crude, but can usually be avoided
-   // by calling caret(Position|Range)FromPoint instead.
-   function getdx$3(x, rect) {
-       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
-   }
-   function getdy$3(y, rect) {
-       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
-   }
-   function yOverlap$3(a, b) {
-       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
-   }
-   function upTop$3(rect, top) {
-       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
-   }
-   function upBot$3(rect, bottom) {
-       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
-   }
-   function domPosAtCoords$3(parent, x, y) {
-       let closest, closestRect, closestX, closestY;
-       let above, below, aboveRect, belowRect;
-       for (let child = parent.firstChild; child; child = child.nextSibling) {
-           let rects = clientRectsFor$3(child);
-           for (let i = 0; i < rects.length; i++) {
-               let rect = rects[i];
-               if (closestRect && yOverlap$3(closestRect, rect))
-                   rect = upTop$3(upBot$3(rect, closestRect.bottom), closestRect.top);
-               let dx = getdx$3(x, rect), dy = getdy$3(y, rect);
-               if (dx == 0 && dy == 0)
-                   return child.nodeType == 3 ? domPosInText$3(child, x, y) : domPosAtCoords$3(child, x, y);
-               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
-                   closest = child;
-                   closestRect = rect;
-                   closestX = dx;
-                   closestY = dy;
-               }
-               if (dx == 0) {
-                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
-                       above = child;
-                       aboveRect = rect;
-                   }
-                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
-                       below = child;
-                       belowRect = rect;
-                   }
-               }
-               else if (aboveRect && yOverlap$3(aboveRect, rect)) {
-                   aboveRect = upBot$3(aboveRect, rect.bottom);
-               }
-               else if (belowRect && yOverlap$3(belowRect, rect)) {
-                   belowRect = upTop$3(belowRect, rect.top);
-               }
-           }
-       }
-       if (aboveRect && aboveRect.bottom >= y) {
-           closest = above;
-           closestRect = aboveRect;
-       }
-       else if (belowRect && belowRect.top <= y) {
-           closest = below;
-           closestRect = belowRect;
-       }
-       if (!closest)
-           return { node: parent, offset: 0 };
-       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
-       if (closest.nodeType == 3)
-           return domPosInText$3(closest, clipX, y);
-       if (!closestX && closest.contentEditable == "true")
-           return domPosAtCoords$3(closest, clipX, y);
-       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
-           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
-       return { node: parent, offset };
-   }
-   function domPosInText$3(node, x, y) {
-       let len = node.nodeValue.length;
-       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
-       for (let i = 0; i < len; i++) {
-           let rects = textRange$3(node, i, i + 1).getClientRects();
-           for (let j = 0; j < rects.length; j++) {
-               let rect = rects[j];
-               if (rect.top == rect.bottom)
-                   continue;
-               if (!generalSide)
-                   generalSide = x - rect.left;
-               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
-               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
-                   let right = x >= (rect.left + rect.right) / 2, after = right;
-                   if (browser$3.chrome || browser$3.gecko) {
-                       // Check for RTL on browsers that support getting client
-                       // rects for empty ranges.
-                       let rectBefore = textRange$3(node, i).getBoundingClientRect();
-                       if (rectBefore.left == rect.right)
-                           after = !right;
-                   }
-                   if (dy <= 0)
-                       return { node, offset: i + (after ? 1 : 0) };
-                   closestOffset = i + (after ? 1 : 0);
-                   closestDY = dy;
-               }
-           }
-       }
-       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
-   }
-   function posAtCoords$3(view, { x, y }, precise, bias = -1) {
-       var _a;
-       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
-       let block, { docHeight } = view.viewState;
-       let yOffset = y - docTop;
-       if (yOffset < 0)
-           return 0;
-       if (yOffset > docHeight)
-           return view.state.doc.length;
-       // Scan for a text block near the queried y position
-       for (let halfLine = view.defaultLineHeight / 2, bounced = false;;) {
-           block = view.elementAtHeight(yOffset);
-           if (block.type == BlockType$3.Text)
-               break;
-           for (;;) {
-               // Move the y position out of this block
-               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
-               if (yOffset >= 0 && yOffset <= docHeight)
-                   break;
-               // If the document consists entirely of replaced widgets, we
-               // won't find a text block, so return 0
-               if (bounced)
-                   return precise ? null : 0;
-               bounced = true;
-               bias = -bias;
-           }
-       }
-       y = docTop + yOffset;
-       let lineStart = block.from;
-       // If this is outside of the rendered viewport, we can't determine a position
-       if (lineStart < view.viewport.from)
-           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise$3(view, content, block, x, y);
-       if (lineStart > view.viewport.to)
-           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
-               precise ? null : posAtCoordsImprecise$3(view, content, block, x, y);
-       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
-       let doc = view.dom.ownerDocument;
-       let root = view.root.elementFromPoint ? view.root : doc;
-       let element = root.elementFromPoint(x, y);
-       if (element && !view.contentDOM.contains(element))
-           element = null;
-       // If the element is unexpected, clip x at the sides of the content area and try again
-       if (!element) {
-           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
-           element = root.elementFromPoint(x, y);
-           if (element && !view.contentDOM.contains(element))
-               element = null;
-       }
-       // There's visible editor content under the point, so we can try
-       // using caret(Position|Range)FromPoint as a shortcut
-       let node, offset = -1;
-       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
-           if (doc.caretPositionFromPoint) {
-               let pos = doc.caretPositionFromPoint(x, y);
-               if (pos)
-                   ({ offsetNode: node, offset } = pos);
-           }
-           else if (doc.caretRangeFromPoint) {
-               let range = doc.caretRangeFromPoint(x, y);
-               if (range) {
-                   ({ startContainer: node, startOffset: offset } = range);
-                   if (browser$3.safari && isSuspiciousCaretResult$2(node, offset, x))
-                       node = undefined;
-               }
-           }
-       }
-       // No luck, do our own (potentially expensive) search
-       if (!node || !view.docView.dom.contains(node)) {
-           let line = LineView$3.find(view.docView, lineStart);
-           if (!line)
-               return yOffset > block.top + block.height / 2 ? block.to : block.from;
-           ({ node, offset } = domPosAtCoords$3(line.dom, x, y));
-       }
-       return view.docView.posFromDOM(node, offset);
-   }
-   function posAtCoordsImprecise$3(view, contentRect, block, x, y) {
-       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
-       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
-           let line = Math.floor((y - block.top) / view.defaultLineHeight);
-           into += line * view.viewState.heightOracle.lineLength;
-       }
-       let content = view.state.sliceDoc(block.from, block.to);
-       return block.from + findColumn$3(content, into, view.state.tabSize);
-   }
-   // In case of a high line height, Safari's caretRangeFromPoint treats
-   // the space between lines as belonging to the last character of the
-   // line before. This is used to detect such a result so that it can be
-   // ignored (issue #401).
-   function isSuspiciousCaretResult$2(node, offset, x) {
-       let len;
-       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
-           return false;
-       for (let next = node.nextSibling; next; next = next.nextSibling)
-           if (next.nodeType != 1 || next.nodeName != "BR")
-               return false;
-       return textRange$3(node, len - 1, len).getBoundingClientRect().left > x;
-   }
-   function moveToLineBoundary$3(view, start, forward, includeWrap) {
-       let line = view.state.doc.lineAt(start.head);
-       let coords = !includeWrap || !view.lineWrapping ? null
-           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
-       if (coords) {
-           let editorRect = view.dom.getBoundingClientRect();
-           let direction = view.textDirectionAt(line.from);
-           let pos = view.posAtCoords({ x: forward == (direction == Direction$3.LTR) ? editorRect.right - 1 : editorRect.left + 1,
-               y: (coords.top + coords.bottom) / 2 });
-           if (pos != null)
-               return EditorSelection$3.cursor(pos, forward ? -1 : 1);
-       }
-       let lineView = LineView$3.find(view.docView, start.head);
-       let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
-       return EditorSelection$3.cursor(end, forward ? -1 : 1);
-   }
-   function moveByChar$3(view, start, forward, by) {
-       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
-       let direction = view.textDirectionAt(line.from);
-       for (let cur = start, check = null;;) {
-           let next = moveVisually$3(line, spans, direction, cur, forward), char = movedOver$3;
-           if (!next) {
-               if (line.number == (forward ? view.state.doc.lines : 1))
-                   return cur;
-               char = "\n";
-               line = view.state.doc.line(line.number + (forward ? 1 : -1));
-               spans = view.bidiSpans(line);
-               next = EditorSelection$3.cursor(forward ? line.from : line.to);
-           }
-           if (!check) {
-               if (!by)
-                   return next;
-               check = by(char);
-           }
-           else if (!check(char)) {
-               return cur;
-           }
-           cur = next;
-       }
-   }
-   function byGroup$3(view, pos, start) {
-       let categorize = view.state.charCategorizer(pos);
-       let cat = categorize(start);
-       return (next) => {
-           let nextCat = categorize(next);
-           if (cat == CharCategory$3.Space)
-               cat = nextCat;
-           return cat == nextCat;
-       };
-   }
-   function moveVertically$3(view, start, forward, distance) {
-       let startPos = start.head, dir = forward ? 1 : -1;
-       if (startPos == (forward ? view.state.doc.length : 0))
-           return EditorSelection$3.cursor(startPos, start.assoc);
-       let goal = start.goalColumn, startY;
-       let rect = view.contentDOM.getBoundingClientRect();
-       let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;
-       if (startCoords) {
-           if (goal == null)
-               goal = startCoords.left - rect.left;
-           startY = dir < 0 ? startCoords.top : startCoords.bottom;
-       }
-       else {
-           let line = view.viewState.lineBlockAt(startPos);
-           if (goal == null)
-               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
-           startY = (dir < 0 ? line.top : line.bottom) + docTop;
-       }
-       let resolvedGoal = rect.left + goal;
-       let dist = distance !== null && distance !== void 0 ? distance : (view.defaultLineHeight >> 1);
-       for (let extra = 0;; extra += 10) {
-           let curY = startY + (dist + extra) * dir;
-           let pos = posAtCoords$3(view, { x: resolvedGoal, y: curY }, false, dir);
-           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))
-               return EditorSelection$3.cursor(pos, start.assoc, undefined, goal);
-       }
-   }
-   function skipAtoms$3(view, oldPos, pos) {
-       let atoms = view.state.facet(atomicRanges$3).map(f => f(view));
-       for (;;) {
-           let moved = false;
-           for (let set of atoms) {
-               set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
-                   if (pos.from > from && pos.from < to) {
-                       pos = oldPos.from > pos.from ? EditorSelection$3.cursor(from, 1) : EditorSelection$3.cursor(to, -1);
-                       moved = true;
-                   }
-               });
-           }
-           if (!moved)
-               return pos;
-       }
-   }
-
-   // This will also be where dragging info and such goes
-   let InputState$3 = class InputState {
-       constructor(view) {
-           this.lastKeyCode = 0;
-           this.lastKeyTime = 0;
-           this.chromeScrollHack = -1;
-           // On iOS, some keys need to have their default behavior happen
-           // (after which we retroactively handle them and reset the DOM) to
-           // avoid messing up the virtual keyboard state.
-           this.pendingIOSKey = undefined;
-           this.lastSelectionOrigin = null;
-           this.lastSelectionTime = 0;
-           this.lastEscPress = 0;
-           this.lastContextMenu = 0;
-           this.scrollHandlers = [];
-           this.registeredEvents = [];
-           this.customHandlers = [];
-           // -1 means not in a composition. Otherwise, this counts the number
-           // of changes made during the composition. The count is used to
-           // avoid treating the start state of the composition, before any
-           // changes have been made, as part of the composition.
-           this.composing = -1;
-           // Tracks whether the next change should be marked as starting the
-           // composition (null means no composition, true means next is the
-           // first, false means first has already been marked for this
-           // composition)
-           this.compositionFirstChange = null;
-           this.compositionEndedAt = 0;
-           this.rapidCompositionStart = false;
-           this.mouseSelection = null;
-           for (let type in handlers$3) {
-               let handler = handlers$3[type];
-               view.contentDOM.addEventListener(type, (event) => {
-                   if (!eventBelongsToEditor$3(view, event) || this.ignoreDuringComposition(event))
-                       return;
-                   if (type == "keydown" && this.keydown(view, event))
-                       return;
-                   if (this.mustFlushObserver(event))
-                       view.observer.forceFlush();
-                   if (this.runCustomHandlers(type, view, event))
-                       event.preventDefault();
-                   else
-                       handler(view, event);
-               });
-               this.registeredEvents.push(type);
-           }
-           if (browser$3.chrome && browser$3.chrome_version >= 102) {
-               // On Chrome 102, viewport updates somehow stop wheel-based
-               // scrolling. Turning off pointer events during the scroll seems
-               // to avoid the issue.
-               view.scrollDOM.addEventListener("wheel", () => {
-                   if (this.chromeScrollHack < 0)
-                       view.contentDOM.style.pointerEvents = "none";
-                   else
-                       window.clearTimeout(this.chromeScrollHack);
-                   this.chromeScrollHack = setTimeout(() => {
-                       this.chromeScrollHack = -1;
-                       view.contentDOM.style.pointerEvents = "";
-                   }, 100);
-               }, { passive: true });
-           }
-           this.notifiedFocused = view.hasFocus;
-           // On Safari adding an input event handler somehow prevents an
-           // issue where the composition vanishes when you press enter.
-           if (browser$3.safari)
-               view.contentDOM.addEventListener("input", () => null);
-       }
-       setSelectionOrigin(origin) {
-           this.lastSelectionOrigin = origin;
-           this.lastSelectionTime = Date.now();
-       }
-       ensureHandlers(view, plugins) {
-           var _a;
-           let handlers;
-           this.customHandlers = [];
-           for (let plugin of plugins)
-               if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {
-                   this.customHandlers.push({ plugin: plugin.value, handlers });
-                   for (let type in handlers)
-                       if (this.registeredEvents.indexOf(type) < 0 && type != "scroll") {
-                           this.registeredEvents.push(type);
-                           view.contentDOM.addEventListener(type, (event) => {
-                               if (!eventBelongsToEditor$3(view, event))
-                                   return;
-                               if (this.runCustomHandlers(type, view, event))
-                                   event.preventDefault();
-                           });
-                       }
-               }
-       }
-       runCustomHandlers(type, view, event) {
-           for (let set of this.customHandlers) {
-               let handler = set.handlers[type];
-               if (handler) {
-                   try {
-                       if (handler.call(set.plugin, event, view) || event.defaultPrevented)
-                           return true;
-                   }
-                   catch (e) {
-                       logException$3(view.state, e);
-                   }
-               }
-           }
-           return false;
-       }
-       runScrollHandlers(view, event) {
-           for (let set of this.customHandlers) {
-               let handler = set.handlers.scroll;
-               if (handler) {
-                   try {
-                       handler.call(set.plugin, event, view);
-                   }
-                   catch (e) {
-                       logException$3(view.state, e);
-                   }
-               }
-           }
-       }
-       keydown(view, event) {
-           // Must always run, even if a custom handler handled the event
-           this.lastKeyCode = event.keyCode;
-           this.lastKeyTime = Date.now();
-           if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
-               return true;
-           // Chrome for Android usually doesn't fire proper key events, but
-           // occasionally does, usually surrounded by a bunch of complicated
-           // composition changes. When an enter or backspace key event is
-           // seen, hold off on handling DOM events for a bit, and then
-           // dispatch it.
-           if (browser$3.android && browser$3.chrome && !event.synthetic &&
-               (event.keyCode == 13 || event.keyCode == 8)) {
-               view.observer.delayAndroidKey(event.key, event.keyCode);
-               return true;
-           }
-           // Prevent the default behavior of Enter on iOS makes the
-           // virtual keyboard get stuck in the wrong (lowercase)
-           // state. So we let it go through, and then, in
-           // applyDOMChange, notify key handlers of it and reset to
-           // the state they produce.
-           let pending;
-           if (browser$3.ios && (pending = PendingKeys$3.find(key => key.keyCode == event.keyCode)) &&
-               !(event.ctrlKey || event.altKey || event.metaKey) && !event.synthetic) {
-               this.pendingIOSKey = pending;
-               setTimeout(() => this.flushIOSKey(view), 250);
-               return true;
-           }
-           return false;
-       }
-       flushIOSKey(view) {
-           let key = this.pendingIOSKey;
-           if (!key)
-               return false;
-           this.pendingIOSKey = undefined;
-           return dispatchKey$3(view.contentDOM, key.key, key.keyCode);
-       }
-       ignoreDuringComposition(event) {
-           if (!/^key/.test(event.type))
-               return false;
-           if (this.composing > 0)
-               return true;
-           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
-           // On some input method editors (IMEs), the Enter key is used to
-           // confirm character selection. On Safari, when Enter is pressed,
-           // compositionend and keydown events are sometimes emitted in the
-           // wrong order. The key event should still be ignored, even when
-           // it happens after the compositionend event.
-           if (browser$3.safari && Date.now() - this.compositionEndedAt < 100) {
-               this.compositionEndedAt = 0;
-               return true;
-           }
-           return false;
-       }
-       mustFlushObserver(event) {
-           return (event.type == "keydown" && event.keyCode != 229) ||
-               event.type == "compositionend" && !browser$3.ios;
-       }
-       startMouseSelection(mouseSelection) {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-           this.mouseSelection = mouseSelection;
-       }
-       update(update) {
-           if (this.mouseSelection)
-               this.mouseSelection.update(update);
-           if (update.transactions.length)
-               this.lastKeyCode = this.lastSelectionTime = 0;
-       }
-       destroy() {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-       }
-   };
-   const PendingKeys$3 = [
-       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
-       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
-       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
-   ];
-   // Key codes for modifier keys
-   const modifierCodes$3 = [16, 17, 18, 20, 91, 92, 224, 225];
-   let MouseSelection$3 = class MouseSelection {
-       constructor(view, startEvent, style, mustSelect) {
-           this.view = view;
-           this.style = style;
-           this.mustSelect = mustSelect;
-           this.lastEvent = startEvent;
-           let doc = view.contentDOM.ownerDocument;
-           doc.addEventListener("mousemove", this.move = this.move.bind(this));
-           doc.addEventListener("mouseup", this.up = this.up.bind(this));
-           this.extend = startEvent.shiftKey;
-           this.multiple = view.state.facet(EditorState$3.allowMultipleSelections) && addsSelectionRange$3(view, startEvent);
-           this.dragMove = dragMovesSelection$4(view, startEvent);
-           this.dragging = isInPrimarySelection$3(view, startEvent) && getClickType$3(startEvent) == 1 ? null : false;
-           // When clicking outside of the selection, immediately apply the
-           // effect of starting the selection
-           if (this.dragging === false) {
-               startEvent.preventDefault();
-               this.select(startEvent);
-           }
-       }
-       move(event) {
-           if (event.buttons == 0)
-               return this.destroy();
-           if (this.dragging !== false)
-               return;
-           this.select(this.lastEvent = event);
-       }
-       up(event) {
-           if (this.dragging == null)
-               this.select(this.lastEvent);
-           if (!this.dragging)
-               event.preventDefault();
-           this.destroy();
-       }
-       destroy() {
-           let doc = this.view.contentDOM.ownerDocument;
-           doc.removeEventListener("mousemove", this.move);
-           doc.removeEventListener("mouseup", this.up);
-           this.view.inputState.mouseSelection = null;
-       }
-       select(event) {
-           let selection = this.style.get(event, this.extend, this.multiple);
-           if (this.mustSelect || !selection.eq(this.view.state.selection) ||
-               selection.main.assoc != this.view.state.selection.main.assoc)
-               this.view.dispatch({
-                   selection,
-                   userEvent: "select.pointer",
-                   scrollIntoView: true
-               });
-           this.mustSelect = false;
-       }
-       update(update) {
-           if (update.docChanged && this.dragging)
-               this.dragging = this.dragging.map(update.changes);
-           if (this.style.update(update))
-               setTimeout(() => this.select(this.lastEvent), 20);
-       }
-   };
-   function addsSelectionRange$3(view, event) {
-       let facet = view.state.facet(clickAddsSelectionRange$3);
-       return facet.length ? facet[0](event) : browser$3.mac ? event.metaKey : event.ctrlKey;
-   }
-   function dragMovesSelection$4(view, event) {
-       let facet = view.state.facet(dragMovesSelection$1$3);
-       return facet.length ? facet[0](event) : browser$3.mac ? !event.altKey : !event.ctrlKey;
-   }
-   function isInPrimarySelection$3(view, event) {
-       let { main } = view.state.selection;
-       if (main.empty)
-           return false;
-       // On boundary clicks, check whether the coordinates are inside the
-       // selection's client rectangles
-       let sel = getSelection$3(view.root);
-       if (sel.rangeCount == 0)
-           return true;
-       let rects = sel.getRangeAt(0).getClientRects();
-       for (let i = 0; i < rects.length; i++) {
-           let rect = rects[i];
-           if (rect.left <= event.clientX && rect.right >= event.clientX &&
-               rect.top <= event.clientY && rect.bottom >= event.clientY)
-               return true;
-       }
-       return false;
-   }
-   function eventBelongsToEditor$3(view, event) {
-       if (!event.bubbles)
-           return true;
-       if (event.defaultPrevented)
-           return false;
-       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
-           if (!node || node.nodeType == 11 || ((cView = ContentView$3.get(node)) && cView.ignoreEvent(event)))
-               return false;
-       return true;
-   }
-   const handlers$3 = /*@__PURE__*/Object.create(null);
-   // This is very crude, but unfortunately both these browsers _pretend_
-   // that they have a clipboard API—all the objects and methods are
-   // there, they just don't work, and they are hard to test.
-   const brokenClipboardAPI$3 = (browser$3.ie && browser$3.ie_version < 15) ||
-       (browser$3.ios && browser$3.webkit_version < 604);
-   function capturePaste$3(view) {
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.focus();
-       setTimeout(() => {
-           view.focus();
-           target.remove();
-           doPaste$3(view, target.value);
-       }, 50);
-   }
-   function doPaste$3(view, input) {
-       let { state } = view, changes, i = 1, text = state.toText(input);
-       let byLine = text.lines == state.selection.ranges.length;
-       let linewise = lastLinewiseCopy$3 != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy$3 == text.toString();
-       if (linewise) {
-           let lastLine = -1;
-           changes = state.changeByRange(range => {
-               let line = state.doc.lineAt(range.from);
-               if (line.from == lastLine)
-                   return { range };
-               lastLine = line.from;
-               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
-               return { changes: { from: line.from, insert },
-                   range: EditorSelection$3.cursor(range.from + insert.length) };
-           });
-       }
-       else if (byLine) {
-           changes = state.changeByRange(range => {
-               let line = text.line(i++);
-               return { changes: { from: range.from, to: range.to, insert: line.text },
-                   range: EditorSelection$3.cursor(range.from + line.length) };
-           });
-       }
-       else {
-           changes = state.replaceSelection(text);
-       }
-       view.dispatch(changes, {
-           userEvent: "input.paste",
-           scrollIntoView: true
-       });
-   }
-   handlers$3.keydown = (view, event) => {
-       view.inputState.setSelectionOrigin("select");
-       if (event.keyCode == 27)
-           view.inputState.lastEscPress = Date.now();
-       else if (modifierCodes$3.indexOf(event.keyCode) < 0)
-           view.inputState.lastEscPress = 0;
-   };
-   let lastTouch$2 = 0;
-   handlers$3.touchstart = (view, e) => {
-       lastTouch$2 = Date.now();
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   handlers$3.touchmove = view => {
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   handlers$3.mousedown = (view, event) => {
-       view.observer.flush();
-       if (lastTouch$2 > Date.now() - 2000 && getClickType$3(event) == 1)
-           return; // Ignore touch interaction
-       let style = null;
-       for (let makeStyle of view.state.facet(mouseSelectionStyle$3)) {
-           style = makeStyle(view, event);
-           if (style)
-               break;
-       }
-       if (!style && event.button == 0)
-           style = basicMouseSelection$3(view, event);
-       if (style) {
-           let mustFocus = view.root.activeElement != view.contentDOM;
-           if (mustFocus)
-               view.observer.ignore(() => focusPreventScroll$3(view.contentDOM));
-           view.inputState.startMouseSelection(new MouseSelection$3(view, event, style, mustFocus));
-       }
-   };
-   function rangeForClick$3(view, pos, bias, type) {
-       if (type == 1) { // Single click
-           return EditorSelection$3.cursor(pos, bias);
-       }
-       else if (type == 2) { // Double click
-           return groupAt$3(view.state, pos, bias);
-       }
-       else { // Triple click
-           let visual = LineView$3.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
-           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
-           if (to < view.state.doc.length && to == line.to)
-               to++;
-           return EditorSelection$3.range(from, to);
-       }
-   }
-   let insideY$2 = (y, rect) => y >= rect.top && y <= rect.bottom;
-   let inside$3 = (x, y, rect) => insideY$2(y, rect) && x >= rect.left && x <= rect.right;
-   // Try to determine, for the given coordinates, associated with the
-   // given position, whether they are related to the element before or
-   // the element after the position.
-   function findPositionSide$3(view, pos, x, y) {
-       let line = LineView$3.find(view.docView, pos);
-       if (!line)
-           return 1;
-       let off = pos - line.posAtStart;
-       // Line boundaries point into the line
-       if (off == 0)
-           return 1;
-       if (off == line.length)
-           return -1;
-       // Positions on top of an element point at that element
-       let before = line.coordsAt(off, -1);
-       if (before && inside$3(x, y, before))
-           return -1;
-       let after = line.coordsAt(off, 1);
-       if (after && inside$3(x, y, after))
-           return 1;
-       // This is probably a line wrap point. Pick before if the point is
-       // beside it.
-       return before && insideY$2(y, before) ? -1 : 1;
-   }
-   function queryPos$3(view, event) {
-       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       return { pos, bias: findPositionSide$3(view, pos, event.clientX, event.clientY) };
-   }
-   const BadMouseDetail$3 = browser$3.ie && browser$3.ie_version <= 11;
-   let lastMouseDown$3 = null, lastMouseDownCount$3 = 0, lastMouseDownTime$3 = 0;
-   function getClickType$3(event) {
-       if (!BadMouseDetail$3)
-           return event.detail;
-       let last = lastMouseDown$3, lastTime = lastMouseDownTime$3;
-       lastMouseDown$3 = event;
-       lastMouseDownTime$3 = Date.now();
-       return lastMouseDownCount$3 = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
-           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount$3 + 1) % 3 : 1;
-   }
-   function basicMouseSelection$3(view, event) {
-       let start = queryPos$3(view, event), type = getClickType$3(event);
-       let startSel = view.state.selection;
-       let last = start, lastEvent = event;
-       return {
-           update(update) {
-               if (update.docChanged) {
-                   if (start)
-                       start.pos = update.changes.mapPos(start.pos);
-                   startSel = startSel.map(update.changes);
-                   lastEvent = null;
-               }
-           },
-           get(event, extend, multiple) {
-               let cur;
-               if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
-                   cur = last;
-               else {
-                   cur = last = queryPos$3(view, event);
-                   lastEvent = event;
-               }
-               if (!cur || !start)
-                   return startSel;
-               let range = rangeForClick$3(view, cur.pos, cur.bias, type);
-               if (start.pos != cur.pos && !extend) {
-                   let startRange = rangeForClick$3(view, start.pos, start.bias, type);
-                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
-                   range = from < range.from ? EditorSelection$3.range(from, to) : EditorSelection$3.range(to, from);
-               }
-               if (extend)
-                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
-               else if (multiple)
-                   return startSel.addRange(range);
-               else
-                   return EditorSelection$3.create([range]);
-           }
-       };
-   }
-   handlers$3.dragstart = (view, event) => {
-       let { selection: { main } } = view.state;
-       let { mouseSelection } = view.inputState;
-       if (mouseSelection)
-           mouseSelection.dragging = main;
-       if (event.dataTransfer) {
-           event.dataTransfer.setData("Text", view.state.sliceDoc(main.from, main.to));
-           event.dataTransfer.effectAllowed = "copyMove";
-       }
-   };
-   function dropText$3(view, event, text, direct) {
-       if (!text)
-           return;
-       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       event.preventDefault();
-       let { mouseSelection } = view.inputState;
-       let del = direct && mouseSelection && mouseSelection.dragging && mouseSelection.dragMove ?
-           { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;
-       let ins = { from: dropPos, insert: text };
-       let changes = view.state.changes(del ? [del, ins] : ins);
-       view.focus();
-       view.dispatch({
-           changes,
-           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
-           userEvent: del ? "move.drop" : "input.drop"
-       });
-   }
-   handlers$3.drop = (view, event) => {
-       if (!event.dataTransfer)
-           return;
-       if (view.state.readOnly)
-           return event.preventDefault();
-       let files = event.dataTransfer.files;
-       if (files && files.length) { // For a file drop, read the file's text.
-           event.preventDefault();
-           let text = Array(files.length), read = 0;
-           let finishFile = () => {
-               if (++read == files.length)
-                   dropText$3(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
-           };
-           for (let i = 0; i < files.length; i++) {
-               let reader = new FileReader;
-               reader.onerror = finishFile;
-               reader.onload = () => {
-                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
-                       text[i] = reader.result;
-                   finishFile();
-               };
-               reader.readAsText(files[i]);
-           }
-       }
-       else {
-           dropText$3(view, event, event.dataTransfer.getData("Text"), true);
-       }
-   };
-   handlers$3.paste = (view, event) => {
-       if (view.state.readOnly)
-           return event.preventDefault();
-       view.observer.flush();
-       let data = brokenClipboardAPI$3 ? null : event.clipboardData;
-       if (data) {
-           doPaste$3(view, data.getData("text/plain"));
-           event.preventDefault();
-       }
-       else {
-           capturePaste$3(view);
-       }
-   };
-   function captureCopy$3(view, text) {
-       // The extra wrapper is somehow necessary on IE/Edge to prevent the
-       // content from being mangled when it is put onto the clipboard
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.value = text;
-       target.focus();
-       target.selectionEnd = text.length;
-       target.selectionStart = 0;
-       setTimeout(() => {
-           target.remove();
-           view.focus();
-       }, 50);
-   }
-   function copiedRange$3(state) {
-       let content = [], ranges = [], linewise = false;
-       for (let range of state.selection.ranges)
-           if (!range.empty) {
-               content.push(state.sliceDoc(range.from, range.to));
-               ranges.push(range);
-           }
-       if (!content.length) {
-           // Nothing selected, do a line-wise copy
-           let upto = -1;
-           for (let { from } of state.selection.ranges) {
-               let line = state.doc.lineAt(from);
-               if (line.number > upto) {
-                   content.push(line.text);
-                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
-               }
-               upto = line.number;
-           }
-           linewise = true;
-       }
-       return { text: content.join(state.lineBreak), ranges, linewise };
-   }
-   let lastLinewiseCopy$3 = null;
-   handlers$3.copy = handlers$3.cut = (view, event) => {
-       let { text, ranges, linewise } = copiedRange$3(view.state);
-       if (!text && !linewise)
-           return;
-       lastLinewiseCopy$3 = linewise ? text : null;
-       let data = brokenClipboardAPI$3 ? null : event.clipboardData;
-       if (data) {
-           event.preventDefault();
-           data.clearData();
-           data.setData("text/plain", text);
-       }
-       else {
-           captureCopy$3(view, text);
-       }
-       if (event.type == "cut" && !view.state.readOnly)
-           view.dispatch({
-               changes: ranges,
-               scrollIntoView: true,
-               userEvent: "delete.cut"
-           });
-   };
-   function updateForFocusChange$3(view) {
-       setTimeout(() => {
-           if (view.hasFocus != view.inputState.notifiedFocused)
-               view.update([]);
-       }, 10);
-   }
-   handlers$3.focus = updateForFocusChange$3;
-   handlers$3.blur = view => {
-       view.observer.clearSelectionRange();
-       updateForFocusChange$3(view);
-   };
-   function forceClearComposition$2(view, rapid) {
-       if (view.docView.compositionDeco.size) {
-           view.inputState.rapidCompositionStart = rapid;
-           try {
-               view.update([]);
-           }
-           finally {
-               view.inputState.rapidCompositionStart = false;
-           }
-       }
-   }
-   handlers$3.compositionstart = handlers$3.compositionupdate = view => {
-       if (view.inputState.compositionFirstChange == null)
-           view.inputState.compositionFirstChange = true;
-       if (view.inputState.composing < 0) {
-           // FIXME possibly set a timeout to clear it again on Android
-           view.inputState.composing = 0;
-           if (view.docView.compositionDeco.size) {
-               view.observer.flush();
-               forceClearComposition$2(view, true);
-           }
-       }
-   };
-   handlers$3.compositionend = view => {
-       view.inputState.composing = -1;
-       view.inputState.compositionEndedAt = Date.now();
-       view.inputState.compositionFirstChange = null;
-       setTimeout(() => {
-           if (view.inputState.composing < 0)
-               forceClearComposition$2(view, false);
-       }, 50);
-   };
-   handlers$3.contextmenu = view => {
-       view.inputState.lastContextMenu = Date.now();
-   };
-   handlers$3.beforeinput = (view, event) => {
-       var _a;
-       // Because Chrome Android doesn't fire useful key events, use
-       // beforeinput to detect backspace (and possibly enter and delete,
-       // but those usually don't even seem to fire beforeinput events at
-       // the moment) and fake a key event for it.
-       //
-       // (preventDefault on beforeinput, though supported in the spec,
-       // seems to do nothing at all on Chrome).
-       let pending;
-       if (browser$3.chrome && browser$3.android && (pending = PendingKeys$3.find(key => key.inputType == event.inputType))) {
-           view.observer.delayAndroidKey(pending.key, pending.keyCode);
-           if (pending.key == "Backspace" || pending.key == "Delete") {
-               let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
-               setTimeout(() => {
-                   var _a;
-                   // Backspacing near uneditable nodes on Chrome Android sometimes
-                   // closes the virtual keyboard. This tries to crudely detect
-                   // that and refocus to get it back.
-                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
-                       view.contentDOM.blur();
-                       view.focus();
-                   }
-               }, 100);
-           }
-       }
-   };
-
-   const wrappingWhiteSpace$3 = ["pre-wrap", "normal", "pre-line", "break-spaces"];
-   let HeightOracle$3 = class HeightOracle {
-       constructor() {
-           this.doc = Text$3.empty;
-           this.lineWrapping = false;
-           this.heightSamples = {};
-           this.lineHeight = 14;
-           this.charWidth = 7;
-           this.lineLength = 30;
-           // Used to track, during updateHeight, if any actual heights changed
-           this.heightChanged = false;
-       }
-       heightForGap(from, to) {
-           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
-           if (this.lineWrapping)
-               lines += Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength);
-           return this.lineHeight * lines;
-       }
-       heightForLine(length) {
-           if (!this.lineWrapping)
-               return this.lineHeight;
-           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
-           return lines * this.lineHeight;
-       }
-       setDoc(doc) { this.doc = doc; return this; }
-       mustRefreshForWrapping(whiteSpace) {
-           return (wrappingWhiteSpace$3.indexOf(whiteSpace) > -1) != this.lineWrapping;
-       }
-       mustRefreshForHeights(lineHeights) {
-           let newHeight = false;
-           for (let i = 0; i < lineHeights.length; i++) {
-               let h = lineHeights[i];
-               if (h < 0) {
-                   i++;
-               }
-               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
-                   newHeight = true;
-                   this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return newHeight;
-       }
-       refresh(whiteSpace, lineHeight, charWidth, lineLength, knownHeights) {
-           let lineWrapping = wrappingWhiteSpace$3.indexOf(whiteSpace) > -1;
-           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
-           this.lineWrapping = lineWrapping;
-           this.lineHeight = lineHeight;
-           this.charWidth = charWidth;
-           this.lineLength = lineLength;
-           if (changed) {
-               this.heightSamples = {};
-               for (let i = 0; i < knownHeights.length; i++) {
-                   let h = knownHeights[i];
-                   if (h < 0)
-                       i++;
-                   else
-                       this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return changed;
-       }
-   };
-   // This object is used by `updateHeight` to make DOM measurements
-   // arrive at the right nides. The `heights` array is a sequence of
-   // block heights, starting from position `from`.
-   let MeasuredHeights$3 = class MeasuredHeights {
-       constructor(from, heights) {
-           this.from = from;
-           this.heights = heights;
-           this.index = 0;
-       }
-       get more() { return this.index < this.heights.length; }
-   };
-   /**
-   Record used to represent information about a block-level element
-   in the editor view.
-   */
-   let BlockInfo$3 = class BlockInfo {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the element in the document.
-       */
-       from, 
-       /**
-       The length of the element.
-       */
-       length, 
-       /**
-       The top position of the element (relative to the top of the
-       document).
-       */
-       top, 
-       /**
-       Its height.
-       */
-       height, 
-       /**
-       The type of element this is. When querying lines, this may be
-       an array of all the blocks that make up the line.
-       */
-       type) {
-           this.from = from;
-           this.length = length;
-           this.top = top;
-           this.height = height;
-           this.type = type;
-       }
-       /**
-       The end of the element as a document position.
-       */
-       get to() { return this.from + this.length; }
-       /**
-       The bottom position of the element.
-       */
-       get bottom() { return this.top + this.height; }
-       /**
-       @internal
-       */
-       join(other) {
-           let detail = (Array.isArray(this.type) ? this.type : [this])
-               .concat(Array.isArray(other.type) ? other.type : [other]);
-           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
-       }
-   };
-   var QueryType$4 = /*@__PURE__*/(function (QueryType) {
-       QueryType[QueryType["ByPos"] = 0] = "ByPos";
-       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
-       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
-   return QueryType})(QueryType$4 || (QueryType$4 = {}));
-   const Epsilon$3 = 1e-3;
-   let HeightMap$3 = class HeightMap {
-       constructor(length, // The number of characters covered
-       height, // Height of this part of the document
-       flags = 2 /* Outdated */) {
-           this.length = length;
-           this.height = height;
-           this.flags = flags;
-       }
-       get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
-       set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
-       setHeight(oracle, height) {
-           if (this.height != height) {
-               if (Math.abs(this.height - height) > Epsilon$3)
-                   oracle.heightChanged = true;
-               this.height = height;
-           }
-       }
-       // Base case is to replace a leaf node, which simply builds a tree
-       // from the new nodes and returns that (HeightMapBranch and
-       // HeightMapGap override this to actually use from/to)
-       replace(_from, _to, nodes) {
-           return HeightMap.of(nodes);
-       }
-       // Again, these are base cases, and are overridden for branch and gap nodes.
-       decomposeLeft(_to, result) { result.push(this); }
-       decomposeRight(_from, result) { result.push(this); }
-       applyChanges(decorations, oldDoc, oracle, changes) {
-           let me = this;
-           for (let i = changes.length - 1; i >= 0; i--) {
-               let { fromA, toA, fromB, toB } = changes[i];
-               let start = me.lineAt(fromA, QueryType$4.ByPosNoHeight, oldDoc, 0, 0);
-               let end = start.to >= toA ? start : me.lineAt(toA, QueryType$4.ByPosNoHeight, oldDoc, 0, 0);
-               toB += end.to - toA;
-               toA = end.to;
-               while (i > 0 && start.from <= changes[i - 1].toA) {
-                   fromA = changes[i - 1].fromA;
-                   fromB = changes[i - 1].fromB;
-                   i--;
-                   if (fromA < start.from)
-                       start = me.lineAt(fromA, QueryType$4.ByPosNoHeight, oldDoc, 0, 0);
-               }
-               fromB += start.from - fromA;
-               fromA = start.from;
-               let nodes = NodeBuilder$3.build(oracle, decorations, fromB, toB);
-               me = me.replace(fromA, toA, nodes);
-           }
-           return me.updateHeight(oracle, 0);
-       }
-       static empty() { return new HeightMapText$3(0, 0); }
-       // nodes uses null values to indicate the position of line breaks.
-       // There are never line breaks at the start or end of the array, or
-       // two line breaks next to each other, and the array isn't allowed
-       // to be empty (same restrictions as return value from the builder).
-       static of(nodes) {
-           if (nodes.length == 1)
-               return nodes[0];
-           let i = 0, j = nodes.length, before = 0, after = 0;
-           for (;;) {
-               if (i == j) {
-                   if (before > after * 2) {
-                       let split = nodes[i - 1];
-                       if (split.break)
-                           nodes.splice(--i, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(--i, 1, split.left, split.right);
-                       j += 1 + split.break;
-                       before -= split.size;
-                   }
-                   else if (after > before * 2) {
-                       let split = nodes[j];
-                       if (split.break)
-                           nodes.splice(j, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(j, 1, split.left, split.right);
-                       j += 2 + split.break;
-                       after -= split.size;
-                   }
-                   else {
-                       break;
-                   }
-               }
-               else if (before < after) {
-                   let next = nodes[i++];
-                   if (next)
-                       before += next.size;
-               }
-               else {
-                   let next = nodes[--j];
-                   if (next)
-                       after += next.size;
-               }
-           }
-           let brk = 0;
-           if (nodes[i - 1] == null) {
-               brk = 1;
-               i--;
-           }
-           else if (nodes[i] == null) {
-               brk = 1;
-               j++;
-           }
-           return new HeightMapBranch$3(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
-       }
-   };
-   HeightMap$3.prototype.size = 1;
-   let HeightMapBlock$3 = class HeightMapBlock extends HeightMap$3 {
-       constructor(length, height, type) {
-           super(length, height);
-           this.type = type;
-       }
-       blockAt(_height, _doc, top, offset) {
-           return new BlockInfo$3(offset, this.length, top, this.height, this.type);
-       }
-       lineAt(_value, _type, doc, top, offset) {
-           return this.blockAt(0, doc, top, offset);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           if (from <= offset + this.length && to >= offset)
-               f(this.blockAt(0, doc, top, offset));
-       }
-       updateHeight(oracle, offset = 0, _force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(oracle, measured.heights[measured.index++]);
-           this.outdated = false;
-           return this;
-       }
-       toString() { return `block(${this.length})`; }
-   };
-   let HeightMapText$3 = class HeightMapText extends HeightMapBlock$3 {
-       constructor(length, height) {
-           super(length, height, BlockType$3.Text);
-           this.collapsed = 0; // Amount of collapsed content in the line
-           this.widgetHeight = 0; // Maximum inline widget height
-       }
-       replace(_from, _to, nodes) {
-           let node = nodes[0];
-           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap$3 && (node.flags & 4 /* SingleLine */)) &&
-               Math.abs(this.length - node.length) < 10) {
-               if (node instanceof HeightMapGap$3)
-                   node = new HeightMapText(node.length, this.height);
-               else
-                   node.height = this.height;
-               if (!this.outdated)
-                   node.outdated = false;
-               return node;
-           }
-           else {
-               return HeightMap$3.of(nodes);
-           }
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(oracle, measured.heights[measured.index++]);
-           else if (force || this.outdated)
-               this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)));
-           this.outdated = false;
-           return this;
-       }
-       toString() {
-           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
-       }
-   };
-   let HeightMapGap$3 = class HeightMapGap extends HeightMap$3 {
-       constructor(length) { super(length, 0); }
-       lines(doc, offset) {
-           let firstLine = doc.lineAt(offset).number, lastLine = doc.lineAt(offset + this.length).number;
-           return { firstLine, lastLine, lineHeight: this.height / (lastLine - firstLine + 1) };
-       }
-       blockAt(height, doc, top, offset) {
-           let { firstLine, lastLine, lineHeight } = this.lines(doc, offset);
-           let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / lineHeight)));
-           let { from, length } = doc.line(firstLine + line);
-           return new BlockInfo$3(from, length, top + lineHeight * line, lineHeight, BlockType$3.Text);
-       }
-       lineAt(value, type, doc, top, offset) {
-           if (type == QueryType$4.ByHeight)
-               return this.blockAt(value, doc, top, offset);
-           if (type == QueryType$4.ByPosNoHeight) {
-               let { from, to } = doc.lineAt(value);
-               return new BlockInfo$3(from, to - from, 0, 0, BlockType$3.Text);
-           }
-           let { firstLine, lineHeight } = this.lines(doc, offset);
-           let { from, length, number } = doc.lineAt(value);
-           return new BlockInfo$3(from, length, top + lineHeight * (number - firstLine), lineHeight, BlockType$3.Text);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           let { firstLine, lineHeight } = this.lines(doc, offset);
-           for (let pos = Math.max(from, offset), end = Math.min(offset + this.length, to); pos <= end;) {
-               let line = doc.lineAt(pos);
-               if (pos == from)
-                   top += lineHeight * (line.number - firstLine);
-               f(new BlockInfo$3(line.from, line.length, top, lineHeight, BlockType$3.Text));
-               top += lineHeight;
-               pos = line.to + 1;
-           }
-       }
-       replace(from, to, nodes) {
-           let after = this.length - to;
-           if (after > 0) {
-               let last = nodes[nodes.length - 1];
-               if (last instanceof HeightMapGap)
-                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
-               else
-                   nodes.push(null, new HeightMapGap(after - 1));
-           }
-           if (from > 0) {
-               let first = nodes[0];
-               if (first instanceof HeightMapGap)
-                   nodes[0] = new HeightMapGap(from + first.length);
-               else
-                   nodes.unshift(new HeightMapGap(from - 1), null);
-           }
-           return HeightMap$3.of(nodes);
-       }
-       decomposeLeft(to, result) {
-           result.push(new HeightMapGap(to - 1), null);
-       }
-       decomposeRight(from, result) {
-           result.push(null, new HeightMapGap(this.length - from - 1));
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let end = offset + this.length;
-           if (measured && measured.from <= offset + this.length && measured.more) {
-               // Fill in part of this gap with measured lines. We know there
-               // can't be widgets or collapsed ranges in those lines, because
-               // they would already have been added to the heightmap (gaps
-               // only contain plain text).
-               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
-               let wasChanged = oracle.heightChanged;
-               if (measured.from > offset)
-                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
-               while (pos <= end && measured.more) {
-                   let len = oracle.doc.lineAt(pos).length;
-                   if (nodes.length)
-                       nodes.push(null);
-                   let height = measured.heights[measured.index++];
-                   if (singleHeight == -1)
-                       singleHeight = height;
-                   else if (Math.abs(height - singleHeight) >= Epsilon$3)
-                       singleHeight = -2;
-                   let line = new HeightMapText$3(len, height);
-                   line.outdated = false;
-                   nodes.push(line);
-                   pos += len + 1;
-               }
-               if (pos <= end)
-                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
-               let result = HeightMap$3.of(nodes);
-               oracle.heightChanged = wasChanged || singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon$3 ||
-                   Math.abs(singleHeight - this.lines(oracle.doc, offset).lineHeight) >= Epsilon$3;
-               return result;
-           }
-           else if (force || this.outdated) {
-               this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));
-               this.outdated = false;
-           }
-           return this;
-       }
-       toString() { return `gap(${this.length})`; }
-   };
-   let HeightMapBranch$3 = class HeightMapBranch extends HeightMap$3 {
-       constructor(left, brk, right) {
-           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
-           this.left = left;
-           this.right = right;
-           this.size = left.size + right.size;
-       }
-       get break() { return this.flags & 1 /* Break */; }
-       blockAt(height, doc, top, offset) {
-           let mid = top + this.left.height;
-           return height < mid ? this.left.blockAt(height, doc, top, offset)
-               : this.right.blockAt(height, doc, mid, offset + this.left.length + this.break);
-       }
-       lineAt(value, type, doc, top, offset) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           let left = type == QueryType$4.ByHeight ? value < rightTop : value < rightOffset;
-           let base = left ? this.left.lineAt(value, type, doc, top, offset)
-               : this.right.lineAt(value, type, doc, rightTop, rightOffset);
-           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
-               return base;
-           let subQuery = type == QueryType$4.ByPosNoHeight ? QueryType$4.ByPosNoHeight : QueryType$4.ByPos;
-           if (left)
-               return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));
-           else
-               return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           if (this.break) {
-               if (from < rightOffset)
-                   this.left.forEachLine(from, to, doc, top, offset, f);
-               if (to >= rightOffset)
-                   this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
-           }
-           else {
-               let mid = this.lineAt(rightOffset, QueryType$4.ByPos, doc, top, offset);
-               if (from < mid.from)
-                   this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
-               if (mid.to >= from && mid.from <= to)
-                   f(mid);
-               if (to > mid.to)
-                   this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
-           }
-       }
-       replace(from, to, nodes) {
-           let rightStart = this.left.length + this.break;
-           if (to < rightStart)
-               return this.balanced(this.left.replace(from, to, nodes), this.right);
-           if (from > this.left.length)
-               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
-           let result = [];
-           if (from > 0)
-               this.decomposeLeft(from, result);
-           let left = result.length;
-           for (let node of nodes)
-               result.push(node);
-           if (from > 0)
-               mergeGaps$3(result, left - 1);
-           if (to < this.length) {
-               let right = result.length;
-               this.decomposeRight(to, result);
-               mergeGaps$3(result, right);
-           }
-           return HeightMap$3.of(result);
-       }
-       decomposeLeft(to, result) {
-           let left = this.left.length;
-           if (to <= left)
-               return this.left.decomposeLeft(to, result);
-           result.push(this.left);
-           if (this.break) {
-               left++;
-               if (to >= left)
-                   result.push(null);
-           }
-           if (to > left)
-               this.right.decomposeLeft(to - left, result);
-       }
-       decomposeRight(from, result) {
-           let left = this.left.length, right = left + this.break;
-           if (from >= right)
-               return this.right.decomposeRight(from - right, result);
-           if (from < left)
-               this.left.decomposeRight(from, result);
-           if (this.break && from < right)
-               result.push(null);
-           result.push(this.right);
-       }
-       balanced(left, right) {
-           if (left.size > 2 * right.size || right.size > 2 * left.size)
-               return HeightMap$3.of(this.break ? [left, null, right] : [left, right]);
-           this.left = left;
-           this.right = right;
-           this.height = left.height + right.height;
-           this.outdated = left.outdated || right.outdated;
-           this.size = left.size + right.size;
-           this.length = left.length + this.break + right.length;
-           return this;
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
-           if (measured && measured.from <= offset + left.length && measured.more)
-               rebalance = left = left.updateHeight(oracle, offset, force, measured);
-           else
-               left.updateHeight(oracle, offset, force);
-           if (measured && measured.from <= rightStart + right.length && measured.more)
-               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
-           else
-               right.updateHeight(oracle, rightStart, force);
-           if (rebalance)
-               return this.balanced(left, right);
-           this.height = this.left.height + this.right.height;
-           this.outdated = false;
-           return this;
-       }
-       toString() { return this.left + (this.break ? " " : "-") + this.right; }
-   };
-   function mergeGaps$3(nodes, around) {
-       let before, after;
-       if (nodes[around] == null &&
-           (before = nodes[around - 1]) instanceof HeightMapGap$3 &&
-           (after = nodes[around + 1]) instanceof HeightMapGap$3)
-           nodes.splice(around - 1, 3, new HeightMapGap$3(before.length + 1 + after.length));
-   }
-   const relevantWidgetHeight$3 = 5;
-   let NodeBuilder$3 = class NodeBuilder {
-       constructor(pos, oracle) {
-           this.pos = pos;
-           this.oracle = oracle;
-           this.nodes = [];
-           this.lineStart = -1;
-           this.lineEnd = -1;
-           this.covering = null;
-           this.writtenTo = pos;
-       }
-       get isCovered() {
-           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
-       }
-       span(_from, to) {
-           if (this.lineStart > -1) {
-               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
-               if (last instanceof HeightMapText$3)
-                   last.length += end - this.pos;
-               else if (end > this.pos || !this.isCovered)
-                   this.nodes.push(new HeightMapText$3(end - this.pos, -1));
-               this.writtenTo = end;
-               if (to > end) {
-                   this.nodes.push(null);
-                   this.writtenTo++;
-                   this.lineStart = -1;
-               }
-           }
-           this.pos = to;
-       }
-       point(from, to, deco) {
-           if (from < to || deco.heightRelevant) {
-               let height = deco.widget ? deco.widget.estimatedHeight : 0;
-               if (height < 0)
-                   height = this.oracle.lineHeight;
-               let len = to - from;
-               if (deco.block) {
-                   this.addBlock(new HeightMapBlock$3(len, height, deco.type));
-               }
-               else if (len || height >= relevantWidgetHeight$3) {
-                   this.addLineDeco(height, len);
-               }
-           }
-           else if (to > from) {
-               this.span(from, to);
-           }
-           if (this.lineEnd > -1 && this.lineEnd < this.pos)
-               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
-       }
-       enterLine() {
-           if (this.lineStart > -1)
-               return;
-           let { from, to } = this.oracle.doc.lineAt(this.pos);
-           this.lineStart = from;
-           this.lineEnd = to;
-           if (this.writtenTo < from) {
-               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
-                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
-               this.nodes.push(null);
-           }
-           if (this.pos > from)
-               this.nodes.push(new HeightMapText$3(this.pos - from, -1));
-           this.writtenTo = this.pos;
-       }
-       blankContent(from, to) {
-           let gap = new HeightMapGap$3(to - from);
-           if (this.oracle.doc.lineAt(from).to == to)
-               gap.flags |= 4 /* SingleLine */;
-           return gap;
-       }
-       ensureLine() {
-           this.enterLine();
-           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
-           if (last instanceof HeightMapText$3)
-               return last;
-           let line = new HeightMapText$3(0, -1);
-           this.nodes.push(line);
-           return line;
-       }
-       addBlock(block) {
-           this.enterLine();
-           if (block.type == BlockType$3.WidgetAfter && !this.isCovered)
-               this.ensureLine();
-           this.nodes.push(block);
-           this.writtenTo = this.pos = this.pos + block.length;
-           if (block.type != BlockType$3.WidgetBefore)
-               this.covering = block;
-       }
-       addLineDeco(height, length) {
-           let line = this.ensureLine();
-           line.length += length;
-           line.collapsed += length;
-           line.widgetHeight = Math.max(line.widgetHeight, height);
-           this.writtenTo = this.pos = this.pos + length;
-       }
-       finish(from) {
-           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
-           if (this.lineStart > -1 && !(last instanceof HeightMapText$3) && !this.isCovered)
-               this.nodes.push(new HeightMapText$3(0, -1));
-           else if (this.writtenTo < this.pos || last == null)
-               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
-           let pos = from;
-           for (let node of this.nodes) {
-               if (node instanceof HeightMapText$3)
-                   node.updateHeight(this.oracle, pos);
-               pos += node ? node.length : 1;
-           }
-           return this.nodes;
-       }
-       // Always called with a region that on both sides either stretches
-       // to a line break or the end of the document.
-       // The returned array uses null to indicate line breaks, but never
-       // starts or ends in a line break, or has multiple line breaks next
-       // to each other.
-       static build(oracle, decorations, from, to) {
-           let builder = new NodeBuilder(from, oracle);
-           RangeSet$3.spans(decorations, from, to, builder, 0);
-           return builder.finish(from);
-       }
-   };
-   function heightRelevantDecoChanges$3(a, b, diff) {
-       let comp = new DecorationComparator$4;
-       RangeSet$3.compare(a, b, diff, comp, 0);
-       return comp.changes;
-   }
-   let DecorationComparator$4 = class DecorationComparator {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange() { }
-       comparePoint(from, to, a, b) {
-           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
-               addRange$3(from, to, this.changes, 5);
-       }
-   };
-
-   function visiblePixelRange$3(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       let left = Math.max(0, rect.left), right = Math.min(innerWidth, rect.right);
-       let top = Math.max(0, rect.top), bottom = Math.min(innerHeight, rect.bottom);
-       let body = dom.ownerDocument.body;
-       for (let parent = dom.parentNode; parent && parent != body;) {
-           if (parent.nodeType == 1) {
-               let elt = parent;
-               let style = window.getComputedStyle(elt);
-               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
-                   style.overflow != "visible") {
-                   let parentRect = elt.getBoundingClientRect();
-                   left = Math.max(left, parentRect.left);
-                   right = Math.min(right, parentRect.right);
-                   top = Math.max(top, parentRect.top);
-                   bottom = Math.min(bottom, parentRect.bottom);
-               }
-               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
-           }
-           else if (parent.nodeType == 11) { // Shadow root
-               parent = parent.host;
-           }
-           else {
-               break;
-           }
-       }
-       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
-           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
-   }
-   function fullPixelRange$3(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       return { left: 0, right: rect.right - rect.left,
-           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
-   }
-   // Line gaps are placeholder widgets used to hide pieces of overlong
-   // lines within the viewport, as a kludge to keep the editor
-   // responsive when a ridiculously long line is loaded into it.
-   let LineGap$3 = class LineGap {
-       constructor(from, to, size) {
-           this.from = from;
-           this.to = to;
-           this.size = size;
-       }
-       static same(a, b) {
-           if (a.length != b.length)
-               return false;
-           for (let i = 0; i < a.length; i++) {
-               let gA = a[i], gB = b[i];
-               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
-                   return false;
-           }
-           return true;
-       }
-       draw(wrapping) {
-           return Decoration$3.replace({ widget: new LineGapWidget$3(this.size, wrapping) }).range(this.from, this.to);
-       }
-   };
-   let LineGapWidget$3 = class LineGapWidget extends WidgetType$3 {
-       constructor(size, vertical) {
-           super();
-           this.size = size;
-           this.vertical = vertical;
-       }
-       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
-       toDOM() {
-           let elt = document.createElement("div");
-           if (this.vertical) {
-               elt.style.height = this.size + "px";
-           }
-           else {
-               elt.style.width = this.size + "px";
-               elt.style.height = "2px";
-               elt.style.display = "inline-block";
-           }
-           return elt;
-       }
-       get estimatedHeight() { return this.vertical ? this.size : -1; }
-   };
-   let ViewState$3 = class ViewState {
-       constructor(state) {
-           this.state = state;
-           // These are contentDOM-local coordinates
-           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
-           this.inView = true;
-           this.paddingTop = 0;
-           this.paddingBottom = 0;
-           this.contentDOMWidth = 0;
-           this.contentDOMHeight = 0;
-           this.editorHeight = 0;
-           this.editorWidth = 0;
-           this.heightOracle = new HeightOracle$3;
-           // See VP.MaxDOMHeight
-           this.scaler = IdScaler$3;
-           this.scrollTarget = null;
-           // Briefly set to true when printing, to disable viewport limiting
-           this.printing = false;
-           // Flag set when editor content was redrawn, so that the next
-           // measure stage knows it must read DOM layout
-           this.mustMeasureContent = true;
-           this.defaultTextDirection = Direction$3.RTL;
-           this.visibleRanges = [];
-           // Cursor 'assoc' is only significant when the cursor is on a line
-           // wrap point, where it must stick to the character that it is
-           // associated with. Since browsers don't provide a reasonable
-           // interface to set or query this, when a selection is set that
-           // might cause this to be significant, this flag is set. The next
-           // measure phase will check whether the cursor is on a line-wrapping
-           // boundary and, if so, reset it to make sure it is positioned in
-           // the right place.
-           this.mustEnforceCursorAssoc = false;
-           this.stateDeco = state.facet(decorations$3).filter(d => typeof d != "function");
-           this.heightMap = HeightMap$3.empty().applyChanges(this.stateDeco, Text$3.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange$3(0, 0, 0, state.doc.length)]);
-           this.viewport = this.getViewport(0, null);
-           this.updateViewportLines();
-           this.updateForViewport();
-           this.lineGaps = this.ensureLineGaps([]);
-           this.lineGapDeco = Decoration$3.set(this.lineGaps.map(gap => gap.draw(false)));
-           this.computeVisibleRanges();
-       }
-       updateForViewport() {
-           let viewports = [this.viewport], { main } = this.state.selection;
-           for (let i = 0; i <= 1; i++) {
-               let pos = i ? main.head : main.anchor;
-               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
-                   let { from, to } = this.lineBlockAt(pos);
-                   viewports.push(new Viewport$3(from, to));
-               }
-           }
-           this.viewports = viewports.sort((a, b) => a.from - b.from);
-           this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler$3 :
-               new BigScaler$3(this.heightOracle.doc, this.heightMap, this.viewports);
-       }
-       updateViewportLines() {
-           this.viewportLines = [];
-           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, block => {
-               this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock$3(block, this.scaler));
-           });
-       }
-       update(update, scrollTarget = null) {
-           this.state = update.state;
-           let prevDeco = this.stateDeco;
-           this.stateDeco = this.state.facet(decorations$3).filter(d => typeof d != "function");
-           let contentChanges = update.changedRanges;
-           let heightChanges = ChangedRange$3.extendWithRanges(contentChanges, heightRelevantDecoChanges$3(prevDeco, this.stateDeco, update ? update.changes : ChangeSet$3.empty(this.state.doc.length)));
-           let prevHeight = this.heightMap.height;
-           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
-           if (this.heightMap.height != prevHeight)
-               update.flags |= 2 /* Height */;
-           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
-           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
-               !this.viewportIsAppropriate(viewport))
-               viewport = this.getViewport(0, scrollTarget);
-           let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
-               viewport.from != this.viewport.from || viewport.to != this.viewport.to;
-           this.viewport = viewport;
-           this.updateForViewport();
-           if (updateLines)
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
-               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
-           update.flags |= this.computeVisibleRanges();
-           if (scrollTarget)
-               this.scrollTarget = scrollTarget;
-           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
-               update.state.selection.main.empty && update.state.selection.main.assoc)
-               this.mustEnforceCursorAssoc = true;
-       }
-       measure(view) {
-           let dom = view.contentDOM, style = window.getComputedStyle(dom);
-           let oracle = this.heightOracle;
-           let whiteSpace = style.whiteSpace;
-           this.defaultTextDirection = style.direction == "rtl" ? Direction$3.RTL : Direction$3.LTR;
-           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
-           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
-           this.contentDOMHeight = dom.clientHeight;
-           this.mustMeasureContent = false;
-           let result = 0, bias = 0;
-           // Vertical padding
-           let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
-           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
-               this.paddingTop = paddingTop;
-               this.paddingBottom = paddingBottom;
-               result |= 8 /* Geometry */ | 2 /* Height */;
-           }
-           if (this.editorWidth != view.scrollDOM.clientWidth) {
-               if (oracle.lineWrapping)
-                   measureContent = true;
-               this.editorWidth = view.scrollDOM.clientWidth;
-               result |= 8 /* Geometry */;
-           }
-           // Pixel viewport
-           let pixelViewport = (this.printing ? fullPixelRange$3 : visiblePixelRange$3)(dom, this.paddingTop);
-           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
-           this.pixelViewport = pixelViewport;
-           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
-           if (inView != this.inView) {
-               this.inView = inView;
-               if (inView)
-                   measureContent = true;
-           }
-           if (!this.inView)
-               return 0;
-           let contentWidth = dom.clientWidth;
-           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
-               this.contentDOMWidth = contentWidth;
-               this.editorHeight = view.scrollDOM.clientHeight;
-               result |= 8 /* Geometry */;
-           }
-           if (measureContent) {
-               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
-               if (oracle.mustRefreshForHeights(lineHeights))
-                   refresh = true;
-               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
-                   let { lineHeight, charWidth } = view.docView.measureTextSize();
-                   refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
-                   if (refresh) {
-                       view.docView.minWidth = 0;
-                       result |= 8 /* Geometry */;
-                   }
-               }
-               if (dTop > 0 && dBottom > 0)
-                   bias = Math.max(dTop, dBottom);
-               else if (dTop < 0 && dBottom < 0)
-                   bias = Math.min(dTop, dBottom);
-               oracle.heightChanged = false;
-               for (let vp of this.viewports) {
-                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
-                   this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights$3(vp.from, heights));
-               }
-               if (oracle.heightChanged)
-                   result |= 2 /* Height */;
-           }
-           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
-               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
-           if (viewportChange)
-               this.viewport = this.getViewport(bias, this.scrollTarget);
-           this.updateForViewport();
-           if ((result & 2 /* Height */) || viewportChange)
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
-               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
-           result |= this.computeVisibleRanges();
-           if (this.mustEnforceCursorAssoc) {
-               this.mustEnforceCursorAssoc = false;
-               // This is done in the read stage, because moving the selection
-               // to a line end is going to trigger a layout anyway, so it
-               // can't be a pure write. It should be rare that it does any
-               // writing.
-               view.docView.enforceCursorAssoc();
-           }
-           return result;
-       }
-       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
-       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
-       getViewport(bias, scrollTarget) {
-           // This will divide VP.Margin between the top and the
-           // bottom, depending on the bias (the change in viewport position
-           // since the last update). It'll hold a number between 0 and 1
-           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
-           let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
-           let viewport = new Viewport$3(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType$4.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType$4.ByHeight, doc, 0, 0).to);
-           // If scrollTarget is given, make sure the viewport includes that position
-           if (scrollTarget) {
-               let { head } = scrollTarget.range;
-               if (head < viewport.from || head > viewport.to) {
-                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
-                   let block = map.lineAt(head, QueryType$4.ByPos, doc, 0, 0), topPos;
-                   if (scrollTarget.y == "center")
-                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
-                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
-                       topPos = block.top;
-                   else
-                       topPos = block.bottom - viewHeight;
-                   viewport = new Viewport$3(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType$4.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType$4.ByHeight, doc, 0, 0).to);
-               }
-           }
-           return viewport;
-       }
-       mapViewport(viewport, changes) {
-           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
-           return new Viewport$3(this.heightMap.lineAt(from, QueryType$4.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType$4.ByPos, this.state.doc, 0, 0).to);
-       }
-       // Checks if a given viewport covers the visible part of the
-       // document and not too much beyond that.
-       viewportIsAppropriate({ from, to }, bias = 0) {
-           if (!this.inView)
-               return true;
-           let { top } = this.heightMap.lineAt(from, QueryType$4.ByPos, this.state.doc, 0, 0);
-           let { bottom } = this.heightMap.lineAt(to, QueryType$4.ByPos, this.state.doc, 0, 0);
-           let { visibleTop, visibleBottom } = this;
-           return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
-               (to == this.state.doc.length ||
-                   bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
-               (top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
-       }
-       mapLineGaps(gaps, changes) {
-           if (!gaps.length || changes.empty)
-               return gaps;
-           let mapped = [];
-           for (let gap of gaps)
-               if (!changes.touchesRange(gap.from, gap.to))
-                   mapped.push(new LineGap$3(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));
-           return mapped;
-       }
-       // Computes positions in the viewport where the start or end of a
-       // line should be hidden, trying to reuse existing line gaps when
-       // appropriate to avoid unneccesary redraws.
-       // Uses crude character-counting for the positioning and sizing,
-       // since actual DOM coordinates aren't always available and
-       // predictable. Relies on generous margins (see LG.Margin) to hide
-       // the artifacts this might produce from the user.
-       ensureLineGaps(current) {
-           let gaps = [];
-           // This won't work at all in predominantly right-to-left text.
-           if (this.defaultTextDirection != Direction$3.LTR)
-               return gaps;
-           for (let line of this.viewportLines) {
-               if (line.length < 4000 /* DoubleMargin */)
-                   continue;
-               let structure = lineStructure$3(line.from, line.to, this.stateDeco);
-               if (structure.total < 4000 /* DoubleMargin */)
-                   continue;
-               let viewFrom, viewTo;
-               if (this.heightOracle.lineWrapping) {
-                   let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
-                   viewFrom = findPosition$3(structure, (this.visibleTop - line.top - marginHeight) / line.height);
-                   viewTo = findPosition$3(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
-               }
-               else {
-                   let totalWidth = structure.total * this.heightOracle.charWidth;
-                   let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
-                   viewFrom = findPosition$3(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
-                   viewTo = findPosition$3(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
-               }
-               let outside = [];
-               if (viewFrom > line.from)
-                   outside.push({ from: line.from, to: viewFrom });
-               if (viewTo < line.to)
-                   outside.push({ from: viewTo, to: line.to });
-               let sel = this.state.selection.main;
-               // Make sure the gaps don't cover a selection end
-               if (sel.from >= line.from && sel.from <= line.to)
-                   cutRange$2(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
-               if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
-                   cutRange$2(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
-               for (let { from, to } of outside)
-                   if (to - from > 1000 /* HalfMargin */) {
-                       gaps.push(find$3(current, gap => gap.from >= line.from && gap.to <= line.to &&
-                           Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
-                           new LineGap$3(from, to, this.gapSize(line, from, to, structure)));
-                   }
-           }
-           return gaps;
-       }
-       gapSize(line, from, to, structure) {
-           let fraction = findFraction$3(structure, to) - findFraction$3(structure, from);
-           if (this.heightOracle.lineWrapping) {
-               return line.height * fraction;
-           }
-           else {
-               return structure.total * this.heightOracle.charWidth * fraction;
-           }
-       }
-       updateLineGaps(gaps) {
-           if (!LineGap$3.same(gaps, this.lineGaps)) {
-               this.lineGaps = gaps;
-               this.lineGapDeco = Decoration$3.set(gaps.map(gap => gap.draw(this.heightOracle.lineWrapping)));
-           }
-       }
-       computeVisibleRanges() {
-           let deco = this.stateDeco;
-           if (this.lineGaps.length)
-               deco = deco.concat(this.lineGapDeco);
-           let ranges = [];
-           RangeSet$3.spans(deco, this.viewport.from, this.viewport.to, {
-               span(from, to) { ranges.push({ from, to }); },
-               point() { }
-           }, 20);
-           let changed = ranges.length != this.visibleRanges.length ||
-               this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
-           this.visibleRanges = ranges;
-           return changed ? 4 /* Viewport */ : 0;
-       }
-       lineBlockAt(pos) {
-           return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
-               scaleBlock$3(this.heightMap.lineAt(pos, QueryType$4.ByPos, this.state.doc, 0, 0), this.scaler);
-       }
-       lineBlockAtHeight(height) {
-           return scaleBlock$3(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$4.ByHeight, this.state.doc, 0, 0), this.scaler);
-       }
-       elementAtHeight(height) {
-           return scaleBlock$3(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
-       }
-       get docHeight() {
-           return this.scaler.toDOM(this.heightMap.height);
-       }
-       get contentHeight() {
-           return this.docHeight + this.paddingTop + this.paddingBottom;
-       }
-   };
-   let Viewport$3 = class Viewport {
-       constructor(from, to) {
-           this.from = from;
-           this.to = to;
-       }
-   };
-   function lineStructure$3(from, to, stateDeco) {
-       let ranges = [], pos = from, total = 0;
-       RangeSet$3.spans(stateDeco, from, to, {
-           span() { },
-           point(from, to) {
-               if (from > pos) {
-                   ranges.push({ from: pos, to: from });
-                   total += from - pos;
-               }
-               pos = to;
-           }
-       }, 20); // We're only interested in collapsed ranges of a significant size
-       if (pos < to) {
-           ranges.push({ from: pos, to });
-           total += to - pos;
-       }
-       return { total, ranges };
-   }
-   function findPosition$3({ total, ranges }, ratio) {
-       if (ratio <= 0)
-           return ranges[0].from;
-       if (ratio >= 1)
-           return ranges[ranges.length - 1].to;
-       let dist = Math.floor(total * ratio);
-       for (let i = 0;; i++) {
-           let { from, to } = ranges[i], size = to - from;
-           if (dist <= size)
-               return from + dist;
-           dist -= size;
-       }
-   }
-   function findFraction$3(structure, pos) {
-       let counted = 0;
-       for (let { from, to } of structure.ranges) {
-           if (pos <= to) {
-               counted += pos - from;
-               break;
-           }
-           counted += to - from;
-       }
-       return counted / structure.total;
-   }
-   function cutRange$2(ranges, from, to) {
-       for (let i = 0; i < ranges.length; i++) {
-           let r = ranges[i];
-           if (r.from < to && r.to > from) {
-               let pieces = [];
-               if (r.from < from)
-                   pieces.push({ from: r.from, to: from });
-               if (r.to > to)
-                   pieces.push({ from: to, to: r.to });
-               ranges.splice(i, 1, ...pieces);
-               i += pieces.length - 1;
-           }
-       }
-   }
-   function find$3(array, f) {
-       for (let val of array)
-           if (f(val))
-               return val;
-       return undefined;
-   }
-   // Don't scale when the document height is within the range of what
-   // the DOM can handle.
-   const IdScaler$3 = {
-       toDOM(n) { return n; },
-       fromDOM(n) { return n; },
-       scale: 1
-   };
-   // When the height is too big (> VP.MaxDOMHeight), scale down the
-   // regions outside the viewports so that the total height is
-   // VP.MaxDOMHeight.
-   let BigScaler$3 = class BigScaler {
-       constructor(doc, heightMap, viewports) {
-           let vpHeight = 0, base = 0, domBase = 0;
-           this.viewports = viewports.map(({ from, to }) => {
-               let top = heightMap.lineAt(from, QueryType$4.ByPos, doc, 0, 0).top;
-               let bottom = heightMap.lineAt(to, QueryType$4.ByPos, doc, 0, 0).bottom;
-               vpHeight += bottom - top;
-               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
-           });
-           this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
-           for (let obj of this.viewports) {
-               obj.domTop = domBase + (obj.top - base) * this.scale;
-               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
-               base = obj.bottom;
-           }
-       }
-       toDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.top)
-                   return domBase + (n - base) * this.scale;
-               if (n <= vp.bottom)
-                   return vp.domTop + (n - vp.top);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-       fromDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.domTop)
-                   return base + (n - domBase) / this.scale;
-               if (n <= vp.domBottom)
-                   return vp.top + (n - vp.domTop);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-   };
-   function scaleBlock$3(block, scaler) {
-       if (scaler.scale == 1)
-           return block;
-       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
-       return new BlockInfo$3(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock$3(b, scaler)) : block.type);
-   }
-
-   const theme$3 = /*@__PURE__*/Facet$3.define({ combine: strs => strs.join(" ") });
-   const darkTheme$3 = /*@__PURE__*/Facet$3.define({ combine: values => values.indexOf(true) > -1 });
-   const baseThemeID$3 = /*@__PURE__*/StyleModule.newName(), baseLightID$3 = /*@__PURE__*/StyleModule.newName(), baseDarkID$3 = /*@__PURE__*/StyleModule.newName();
-   const lightDarkIDs$3 = { "&light": "." + baseLightID$3, "&dark": "." + baseDarkID$3 };
-   function buildTheme$3(main, spec, scopes) {
-       return new StyleModule(spec, {
-           finish(sel) {
-               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
-                   if (m == "&")
-                       return main;
-                   if (!scopes || !scopes[m])
-                       throw new RangeError(`Unsupported selector: ${m}`);
-                   return scopes[m];
-               }) : main + " " + sel;
-           }
-       });
-   }
-   const baseTheme$1$5 = /*@__PURE__*/buildTheme$3("." + baseThemeID$3, {
-       "&.cm-editor": {
-           position: "relative !important",
-           boxSizing: "border-box",
-           "&.cm-focused": {
-               // Provide a simple default outline to make sure a focused
-               // editor is visually distinct. Can't leave the default behavior
-               // because that will apply to the content element, which is
-               // inside the scrollable container and doesn't include the
-               // gutters. We also can't use an 'auto' outline, since those
-               // are, for some reason, drawn behind the element content, which
-               // will cause things like the active line background to cover
-               // the outline (#297).
-               outline: "1px dotted #212121"
-           },
-           display: "flex !important",
-           flexDirection: "column"
-       },
-       ".cm-scroller": {
-           display: "flex !important",
-           alignItems: "flex-start !important",
-           fontFamily: "monospace",
-           lineHeight: 1.4,
-           height: "100%",
-           overflowX: "auto",
-           position: "relative",
-           zIndex: 0
-       },
-       ".cm-content": {
-           margin: 0,
-           flexGrow: 2,
-           minHeight: "100%",
-           display: "block",
-           whiteSpace: "pre",
-           wordWrap: "normal",
-           boxSizing: "border-box",
-           padding: "4px 0",
-           outline: "none",
-           "&[contenteditable=true]": {
-               WebkitUserModify: "read-write-plaintext-only",
-           }
-       },
-       ".cm-lineWrapping": {
-           whiteSpace_fallback: "pre-wrap",
-           whiteSpace: "break-spaces",
-           wordBreak: "break-word",
-           overflowWrap: "anywhere"
-       },
-       "&light .cm-content": { caretColor: "black" },
-       "&dark .cm-content": { caretColor: "white" },
-       ".cm-line": {
-           display: "block",
-           padding: "0 2px 0 4px"
-       },
-       ".cm-selectionLayer": {
-           zIndex: -1,
-           contain: "size style"
-       },
-       ".cm-selectionBackground": {
-           position: "absolute",
-       },
-       "&light .cm-selectionBackground": {
-           background: "#d9d9d9"
-       },
-       "&dark .cm-selectionBackground": {
-           background: "#222"
-       },
-       "&light.cm-focused .cm-selectionBackground": {
-           background: "#d7d4f0"
-       },
-       "&dark.cm-focused .cm-selectionBackground": {
-           background: "#233"
-       },
-       ".cm-cursorLayer": {
-           zIndex: 100,
-           contain: "size style",
-           pointerEvents: "none"
-       },
-       "&.cm-focused .cm-cursorLayer": {
-           animation: "steps(1) cm-blink 1.2s infinite"
-       },
-       // Two animations defined so that we can switch between them to
-       // restart the animation without forcing another style
-       // recomputation.
-       "@keyframes cm-blink": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
-       "@keyframes cm-blink2": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
-       ".cm-cursor, .cm-dropCursor": {
-           position: "absolute",
-           borderLeft: "1.2px solid black",
-           marginLeft: "-0.6px",
-           pointerEvents: "none",
-       },
-       ".cm-cursor": {
-           display: "none"
-       },
-       "&dark .cm-cursor": {
-           borderLeftColor: "#444"
-       },
-       "&.cm-focused .cm-cursor": {
-           display: "block"
-       },
-       "&light .cm-activeLine": { backgroundColor: "#f3f9ff" },
-       "&dark .cm-activeLine": { backgroundColor: "#223039" },
-       "&light .cm-specialChar": { color: "red" },
-       "&dark .cm-specialChar": { color: "#f78" },
-       ".cm-gutters": {
-           display: "flex",
-           height: "100%",
-           boxSizing: "border-box",
-           left: 0,
-           zIndex: 200
-       },
-       "&light .cm-gutters": {
-           backgroundColor: "#f5f5f5",
-           color: "#6c6c6c",
-           borderRight: "1px solid #ddd"
-       },
-       "&dark .cm-gutters": {
-           backgroundColor: "#333338",
-           color: "#ccc"
-       },
-       ".cm-gutter": {
-           display: "flex !important",
-           flexDirection: "column",
-           flexShrink: 0,
-           boxSizing: "border-box",
-           minHeight: "100%",
-           overflow: "hidden"
-       },
-       ".cm-gutterElement": {
-           boxSizing: "border-box"
-       },
-       ".cm-lineNumbers .cm-gutterElement": {
-           padding: "0 3px 0 5px",
-           minWidth: "20px",
-           textAlign: "right",
-           whiteSpace: "nowrap"
-       },
-       "&light .cm-activeLineGutter": {
-           backgroundColor: "#e2f2ff"
-       },
-       "&dark .cm-activeLineGutter": {
-           backgroundColor: "#222227"
-       },
-       ".cm-panels": {
-           boxSizing: "border-box",
-           position: "sticky",
-           left: 0,
-           right: 0
-       },
-       "&light .cm-panels": {
-           backgroundColor: "#f5f5f5",
-           color: "black"
-       },
-       "&light .cm-panels-top": {
-           borderBottom: "1px solid #ddd"
-       },
-       "&light .cm-panels-bottom": {
-           borderTop: "1px solid #ddd"
-       },
-       "&dark .cm-panels": {
-           backgroundColor: "#333338",
-           color: "white"
-       },
-       ".cm-tab": {
-           display: "inline-block",
-           overflow: "hidden",
-           verticalAlign: "bottom"
-       },
-       ".cm-widgetBuffer": {
-           verticalAlign: "text-top",
-           height: "1em",
-           display: "inline"
-       },
-       ".cm-placeholder": {
-           color: "#888",
-           display: "inline-block",
-           verticalAlign: "top",
-       },
-       ".cm-button": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           padding: ".2em 1em",
-           borderRadius: "1px"
-       },
-       "&light .cm-button": {
-           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
-           }
-       },
-       "&dark .cm-button": {
-           backgroundImage: "linear-gradient(#393939, #111)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#111, #333)"
-           }
-       },
-       ".cm-textfield": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           border: "1px solid silver",
-           padding: ".2em .5em"
-       },
-       "&light .cm-textfield": {
-           backgroundColor: "white"
-       },
-       "&dark .cm-textfield": {
-           border: "1px solid #555",
-           backgroundColor: "inherit"
-       }
-   }, lightDarkIDs$3);
-
-   const observeOptions$3 = {
-       childList: true,
-       characterData: true,
-       subtree: true,
-       attributes: true,
-       characterDataOldValue: true
-   };
-   // IE11 has very broken mutation observers, so we also listen to
-   // DOMCharacterDataModified there
-   const useCharData$3 = browser$3.ie && browser$3.ie_version <= 11;
-   let DOMObserver$3 = class DOMObserver {
-       constructor(view, onChange, onScrollChanged) {
-           this.view = view;
-           this.onChange = onChange;
-           this.onScrollChanged = onScrollChanged;
-           this.active = false;
-           // The known selection. Kept in our own object, as opposed to just
-           // directly accessing the selection because:
-           //  - Safari doesn't report the right selection in shadow DOM
-           //  - Reading from the selection forces a DOM layout
-           //  - This way, we can ignore selectionchange events if we have
-           //    already seen the 'new' selection
-           this.selectionRange = new DOMSelectionState$3;
-           // Set when a selection change is detected, cleared on flush
-           this.selectionChanged = false;
-           this.delayedFlush = -1;
-           this.resizeTimeout = -1;
-           this.queue = [];
-           this.delayedAndroidKey = null;
-           this.scrollTargets = [];
-           this.intersection = null;
-           this.resize = null;
-           this.intersecting = false;
-           this.gapIntersection = null;
-           this.gaps = [];
-           // Timeout for scheduling check of the parents that need scroll handlers
-           this.parentCheck = -1;
-           this.dom = view.contentDOM;
-           this.observer = new MutationObserver(mutations => {
-               for (let mut of mutations)
-                   this.queue.push(mut);
-               // IE11 will sometimes (on typing over a selection or
-               // backspacing out a single character text node) call the
-               // observer callback before actually updating the DOM.
-               //
-               // Unrelatedly, iOS Safari will, when ending a composition,
-               // sometimes first clear it, deliver the mutations, and then
-               // reinsert the finished text. CodeMirror's handling of the
-               // deletion will prevent the reinsertion from happening,
-               // breaking composition.
-               if ((browser$3.ie && browser$3.ie_version <= 11 || browser$3.ios && view.composing) &&
-                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
-                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
-                   this.flushSoon();
-               else
-                   this.flush();
-           });
-           if (useCharData$3)
-               this.onCharData = (event) => {
-                   this.queue.push({ target: event.target,
-                       type: "characterData",
-                       oldValue: event.prevValue });
-                   this.flushSoon();
-               };
-           this.onSelectionChange = this.onSelectionChange.bind(this);
-           window.addEventListener("resize", this.onResize = this.onResize.bind(this));
-           if (typeof ResizeObserver == "function") {
-               this.resize = new ResizeObserver(() => {
-                   if (this.view.docView.lastUpdate < Date.now() - 75)
-                       this.onResize();
-               });
-               this.resize.observe(view.scrollDOM);
-           }
-           window.addEventListener("beforeprint", this.onPrint = this.onPrint.bind(this));
-           this.start();
-           window.addEventListener("scroll", this.onScroll = this.onScroll.bind(this));
-           if (typeof IntersectionObserver == "function") {
-               this.intersection = new IntersectionObserver(entries => {
-                   if (this.parentCheck < 0)
-                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
-                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
-                       this.intersecting = !this.intersecting;
-                       if (this.intersecting != this.view.inView)
-                           this.onScrollChanged(document.createEvent("Event"));
-                   }
-               }, {});
-               this.intersection.observe(this.dom);
-               this.gapIntersection = new IntersectionObserver(entries => {
-                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
-                       this.onScrollChanged(document.createEvent("Event"));
-               }, {});
-           }
-           this.listenForScroll();
-           this.readSelectionRange();
-           this.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
-       }
-       onScroll(e) {
-           if (this.intersecting)
-               this.flush(false);
-           this.onScrollChanged(e);
-       }
-       onResize() {
-           if (this.resizeTimeout < 0)
-               this.resizeTimeout = setTimeout(() => {
-                   this.resizeTimeout = -1;
-                   this.view.requestMeasure();
-               }, 50);
-       }
-       onPrint() {
-           this.view.viewState.printing = true;
-           this.view.measure();
-           setTimeout(() => {
-               this.view.viewState.printing = false;
-               this.view.requestMeasure();
-           }, 500);
-       }
-       updateGaps(gaps) {
-           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
-               this.gapIntersection.disconnect();
-               for (let gap of gaps)
-                   this.gapIntersection.observe(gap);
-               this.gaps = gaps;
-           }
-       }
-       onSelectionChange(event) {
-           if (!this.readSelectionRange() || this.delayedAndroidKey)
-               return;
-           let { view } = this, sel = this.selectionRange;
-           if (view.state.facet(editable$3) ? view.root.activeElement != this.dom : !hasSelection$3(view.dom, sel))
-               return;
-           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
-           if (context && context.ignoreEvent(event))
-               return;
-           // Deletions on IE11 fire their events in the wrong order, giving
-           // us a selection change event before the DOM changes are
-           // reported.
-           // Chrome Android has a similar issue when backspacing out a
-           // selection (#645).
-           if ((browser$3.ie && browser$3.ie_version <= 11 || browser$3.android && browser$3.chrome) && !view.state.selection.main.empty &&
-               // (Selection.isCollapsed isn't reliable on IE)
-               sel.focusNode && isEquivalentPosition$3(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
-               this.flushSoon();
-           else
-               this.flush(false);
-       }
-       readSelectionRange() {
-           let { root } = this.view, domSel = getSelection$3(root);
-           // The Selection object is broken in shadow roots in Safari. See
-           // https://github.com/codemirror/codemirror.next/issues/414
-           let range = browser$3.safari && root.nodeType == 11 && deepActiveElement$2() == this.view.contentDOM &&
-               safariSelectionRangeHack$3(this.view) || domSel;
-           if (this.selectionRange.eq(range))
-               return false;
-           this.selectionRange.setRange(range);
-           return this.selectionChanged = true;
-       }
-       setSelectionRange(anchor, head) {
-           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
-           this.selectionChanged = false;
-       }
-       clearSelectionRange() {
-           this.selectionRange.set(null, 0, null, 0);
-       }
-       listenForScroll() {
-           this.parentCheck = -1;
-           let i = 0, changed = null;
-           for (let dom = this.dom; dom;) {
-               if (dom.nodeType == 1) {
-                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
-                       i++;
-                   else if (!changed)
-                       changed = this.scrollTargets.slice(0, i);
-                   if (changed)
-                       changed.push(dom);
-                   dom = dom.assignedSlot || dom.parentNode;
-               }
-               else if (dom.nodeType == 11) { // Shadow root
-                   dom = dom.host;
-               }
-               else {
-                   break;
-               }
-           }
-           if (i < this.scrollTargets.length && !changed)
-               changed = this.scrollTargets.slice(0, i);
-           if (changed) {
-               for (let dom of this.scrollTargets)
-                   dom.removeEventListener("scroll", this.onScroll);
-               for (let dom of this.scrollTargets = changed)
-                   dom.addEventListener("scroll", this.onScroll);
-           }
-       }
-       ignore(f) {
-           if (!this.active)
-               return f();
-           try {
-               this.stop();
-               return f();
-           }
-           finally {
-               this.start();
-               this.clear();
-           }
-       }
-       start() {
-           if (this.active)
-               return;
-           this.observer.observe(this.dom, observeOptions$3);
-           if (useCharData$3)
-               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
-           this.active = true;
-       }
-       stop() {
-           if (!this.active)
-               return;
-           this.active = false;
-           this.observer.disconnect();
-           if (useCharData$3)
-               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
-       }
-       // Throw away any pending changes
-       clear() {
-           this.processRecords();
-           this.queue.length = 0;
-           this.selectionChanged = false;
-       }
-       // Chrome Android, especially in combination with GBoard, not only
-       // doesn't reliably fire regular key events, but also often
-       // surrounds the effect of enter or backspace with a bunch of
-       // composition events that, when interrupted, cause text duplication
-       // or other kinds of corruption. This hack makes the editor back off
-       // from handling DOM changes for a moment when such a key is
-       // detected (via beforeinput or keydown), and then tries to flush
-       // them or, if that has no effect, dispatches the given key.
-       delayAndroidKey(key, keyCode) {
-           if (!this.delayedAndroidKey)
-               requestAnimationFrame(() => {
-                   let key = this.delayedAndroidKey;
-                   this.delayedAndroidKey = null;
-                   this.delayedFlush = -1;
-                   if (!this.flush())
-                       dispatchKey$3(this.view.contentDOM, key.key, key.keyCode);
-               });
-           // Since backspace beforeinput is sometimes signalled spuriously,
-           // Enter always takes precedence.
-           if (!this.delayedAndroidKey || key == "Enter")
-               this.delayedAndroidKey = { key, keyCode };
-       }
-       flushSoon() {
-           if (this.delayedFlush < 0)
-               this.delayedFlush = window.setTimeout(() => { this.delayedFlush = -1; this.flush(); }, 20);
-       }
-       forceFlush() {
-           if (this.delayedFlush >= 0) {
-               window.clearTimeout(this.delayedFlush);
-               this.delayedFlush = -1;
-               this.flush();
-           }
-       }
-       processRecords() {
-           let records = this.queue;
-           for (let mut of this.observer.takeRecords())
-               records.push(mut);
-           if (records.length)
-               this.queue = [];
-           let from = -1, to = -1, typeOver = false;
-           for (let record of records) {
-               let range = this.readMutation(record);
-               if (!range)
-                   continue;
-               if (range.typeOver)
-                   typeOver = true;
-               if (from == -1) {
-                   ({ from, to } = range);
-               }
-               else {
-                   from = Math.min(range.from, from);
-                   to = Math.max(range.to, to);
-               }
-           }
-           return { from, to, typeOver };
-       }
-       // Apply pending changes, if any
-       flush(readSelection = true) {
-           // Completely hold off flushing when pending keys are set—the code
-           // managing those will make sure processRecords is called and the
-           // view is resynchronized after
-           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
-               return;
-           if (readSelection)
-               this.readSelectionRange();
-           let { from, to, typeOver } = this.processRecords();
-           let newSel = this.selectionChanged && hasSelection$3(this.dom, this.selectionRange);
-           if (from < 0 && !newSel)
-               return;
-           this.selectionChanged = false;
-           let startState = this.view.state;
-           let handled = this.onChange(from, to, typeOver);
-           // The view wasn't updated
-           if (this.view.state == startState)
-               this.view.update([]);
-           return handled;
-       }
-       readMutation(rec) {
-           let cView = this.view.docView.nearest(rec.target);
-           if (!cView || cView.ignoreMutation(rec))
-               return null;
-           cView.markDirty(rec.type == "attributes");
-           if (rec.type == "attributes")
-               cView.dirty |= 4 /* Attrs */;
-           if (rec.type == "childList") {
-               let childBefore = findChild$3(cView, rec.previousSibling || rec.target.previousSibling, -1);
-               let childAfter = findChild$3(cView, rec.nextSibling || rec.target.nextSibling, 1);
-               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
-                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
-           }
-           else if (rec.type == "characterData") {
-               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
-           }
-           else {
-               return null;
-           }
-       }
-       destroy() {
-           var _a, _b, _c;
-           this.stop();
-           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
-           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
-           (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
-           for (let dom of this.scrollTargets)
-               dom.removeEventListener("scroll", this.onScroll);
-           window.removeEventListener("scroll", this.onScroll);
-           window.removeEventListener("resize", this.onResize);
-           window.removeEventListener("beforeprint", this.onPrint);
-           this.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
-           clearTimeout(this.parentCheck);
-           clearTimeout(this.resizeTimeout);
-       }
-   };
-   function findChild$3(cView, dom, dir) {
-       while (dom) {
-           let curView = ContentView$3.get(dom);
-           if (curView && curView.parent == cView)
-               return curView;
-           let parent = dom.parentNode;
-           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
-       }
-       return null;
-   }
-   // Used to work around a Safari Selection/shadow DOM bug (#414)
-   function safariSelectionRangeHack$3(view) {
-       let found = null;
-       // Because Safari (at least in 2018-2021) doesn't provide regular
-       // access to the selection inside a shadowroot, we have to perform a
-       // ridiculous hack to get at it—using `execCommand` to trigger a
-       // `beforeInput` event so that we can read the target range from the
-       // event.
-       function read(event) {
-           event.preventDefault();
-           event.stopImmediatePropagation();
-           found = event.getTargetRanges()[0];
-       }
-       view.contentDOM.addEventListener("beforeinput", read, true);
-       document.execCommand("indent");
-       view.contentDOM.removeEventListener("beforeinput", read, true);
-       if (!found)
-           return null;
-       let anchorNode = found.startContainer, anchorOffset = found.startOffset;
-       let focusNode = found.endContainer, focusOffset = found.endOffset;
-       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
-       // Since such a range doesn't distinguish between anchor and head,
-       // use a heuristic that flips it around if its end matches the
-       // current anchor.
-       if (isEquivalentPosition$3(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
-           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
-       return { anchorNode, anchorOffset, focusNode, focusOffset };
-   }
-
-   function applyDOMChange$3(view, start, end, typeOver) {
-       let change, newSel;
-       let sel = view.state.selection.main;
-       if (start > -1) {
-           let bounds = view.docView.domBoundsAround(start, end, 0);
-           if (!bounds || view.state.readOnly)
-               return false;
-           let { from, to } = bounds;
-           let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints$3(view);
-           let reader = new DOMReader$3(selPoints, view.state);
-           reader.readRange(bounds.startDOM, bounds.endDOM);
-           let preferredPos = sel.from, preferredSide = null;
-           // Prefer anchoring to end when Backspace is pressed (or, on
-           // Android, when something was deleted)
-           if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 ||
-               browser$3.android && reader.text.length < to - from) {
-               preferredPos = sel.to;
-               preferredSide = "end";
-           }
-           let diff = findDiff$3(view.state.doc.sliceString(from, to, LineBreakPlaceholder$3), reader.text, preferredPos - from, preferredSide);
-           if (diff) {
-               // Chrome inserts two newlines when pressing shift-enter at the
-               // end of a line. This drops one of those.
-               if (browser$3.chrome && view.inputState.lastKeyCode == 13 &&
-                   diff.toB == diff.from + 2 && reader.text.slice(diff.from, diff.toB) == LineBreakPlaceholder$3 + LineBreakPlaceholder$3)
-                   diff.toB--;
-               change = { from: from + diff.from, to: from + diff.toA,
-                   insert: Text$3.of(reader.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder$3)) };
-           }
-           newSel = selectionFromPoints$3(selPoints, from);
-       }
-       else if (view.hasFocus || !view.state.facet(editable$3)) {
-           let domSel = view.observer.selectionRange;
-           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
-           let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
-               !contains$3(view.contentDOM, domSel.focusNode)
-               ? view.state.selection.main.head
-               : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
-           let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
-               !contains$3(view.contentDOM, domSel.anchorNode)
-               ? view.state.selection.main.anchor
-               : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
-           if (head != sel.head || anchor != sel.anchor)
-               newSel = EditorSelection$3.single(anchor, head);
-       }
-       if (!change && !newSel)
-           return false;
-       // Heuristic to notice typing over a selected character
-       if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
-           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
-       // If the change is inside the selection and covers most of it,
-       // assume it is a selection replace (with identical characters at
-       // the start/end not included in the diff)
-       else if (change && change.from >= sel.from && change.to <= sel.to &&
-           (change.from != sel.from || change.to != sel.to) &&
-           (sel.to - sel.from) - (change.to - change.from) <= 4)
-           change = {
-               from: sel.from, to: sel.to,
-               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
-           };
-       // Detect insert-period-on-double-space Mac behavior, and transform
-       // it into a regular space insert.
-       else if ((browser$3.mac || browser$3.android) && change && change.from == change.to && change.from == sel.head - 1 &&
-           change.insert.toString() == ".")
-           change = { from: sel.from, to: sel.to, insert: Text$3.of([" "]) };
-       if (change) {
-           let startState = view.state;
-           if (browser$3.ios && view.inputState.flushIOSKey(view))
-               return true;
-           // Android browsers don't fire reasonable key events for enter,
-           // backspace, or delete. So this detects changes that look like
-           // they're caused by those keys, and reinterprets them as key
-           // events. (Some of these keys are also handled by beforeinput
-           // events and the pendingAndroidKey mechanism, but that's not
-           // reliable in all situations.)
-           if (browser$3.android &&
-               ((change.from == sel.from && change.to == sel.to &&
-                   change.insert.length == 1 && change.insert.lines == 2 &&
-                   dispatchKey$3(view.contentDOM, "Enter", 13)) ||
-                   (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 &&
-                       dispatchKey$3(view.contentDOM, "Backspace", 8)) ||
-                   (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
-                       dispatchKey$3(view.contentDOM, "Delete", 46))))
-               return true;
-           let text = change.insert.toString();
-           if (view.state.facet(inputHandler$4).some(h => h(view, change.from, change.to, text)))
-               return true;
-           if (view.inputState.composing >= 0)
-               view.inputState.composing++;
-           let tr;
-           if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
-               (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
-               view.inputState.composing < 0) {
-               let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
-               let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
-               tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
-           }
-           else {
-               let changes = startState.changes(change);
-               let mainSel = newSel && !startState.selection.main.eq(newSel.main) && newSel.main.to <= changes.newLength
-                   ? newSel.main : undefined;
-               // Try to apply a composition change to all cursors
-               if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
-                   change.to <= sel.to && change.to >= sel.to - 10) {
-                   let replaced = view.state.sliceDoc(change.from, change.to);
-                   let compositionRange = compositionSurroundingNode$2(view) || view.state.doc.lineAt(sel.head);
-                   let offset = sel.to - change.to, size = sel.to - sel.from;
-                   tr = startState.changeByRange(range => {
-                       if (range.from == sel.from && range.to == sel.to)
-                           return { changes, range: mainSel || range.map(changes) };
-                       let to = range.to - offset, from = to - replaced.length;
-                       if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
-                           // Unfortunately, there's no way to make multiple
-                           // changes in the same node work without aborting
-                           // composition, so cursors in the composition range are
-                           // ignored.
-                           compositionRange && range.to >= compositionRange.from && range.from <= compositionRange.to)
-                           return { range };
-                       let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
-                       return {
-                           changes: rangeChanges,
-                           range: !mainSel ? range.map(rangeChanges) :
-                               EditorSelection$3.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
-                       };
-                   });
-               }
-               else {
-                   tr = {
-                       changes,
-                       selection: mainSel && startState.selection.replaceRange(mainSel)
-                   };
-               }
-           }
-           let userEvent = "input.type";
-           if (view.composing) {
-               userEvent += ".compose";
-               if (view.inputState.compositionFirstChange) {
-                   userEvent += ".start";
-                   view.inputState.compositionFirstChange = false;
-               }
-           }
-           view.dispatch(tr, { scrollIntoView: true, userEvent });
-           return true;
-       }
-       else if (newSel && !newSel.main.eq(sel)) {
-           let scrollIntoView = false, userEvent = "select";
-           if (view.inputState.lastSelectionTime > Date.now() - 50) {
-               if (view.inputState.lastSelectionOrigin == "select")
-                   scrollIntoView = true;
-               userEvent = view.inputState.lastSelectionOrigin;
-           }
-           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
-           return true;
-       }
-       else {
-           return false;
-       }
-   }
-   function findDiff$3(a, b, preferredPos, preferredSide) {
-       let minLen = Math.min(a.length, b.length);
-       let from = 0;
-       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
-           from++;
-       if (from == minLen && a.length == b.length)
-           return null;
-       let toA = a.length, toB = b.length;
-       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
-           toA--;
-           toB--;
-       }
-       if (preferredSide == "end") {
-           let adjust = Math.max(0, from - Math.min(toA, toB));
-           preferredPos -= toA + adjust - from;
-       }
-       if (toA < from && a.length < b.length) {
-           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
-           from -= move;
-           toB = from + (toB - toA);
-           toA = from;
-       }
-       else if (toB < from) {
-           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
-           from -= move;
-           toA = from + (toA - toB);
-           toB = from;
-       }
-       return { from, toA, toB };
-   }
-   function selectionPoints$3(view) {
-       let result = [];
-       if (view.root.activeElement != view.contentDOM)
-           return result;
-       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
-       if (anchorNode) {
-           result.push(new DOMPoint$3(anchorNode, anchorOffset));
-           if (focusNode != anchorNode || focusOffset != anchorOffset)
-               result.push(new DOMPoint$3(focusNode, focusOffset));
-       }
-       return result;
-   }
-   function selectionFromPoints$3(points, base) {
-       if (points.length == 0)
-           return null;
-       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
-       return anchor > -1 && head > -1 ? EditorSelection$3.single(anchor + base, head + base) : null;
-   }
-
-   // The editor's update state machine looks something like this:
-   //
-   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
-   //                                         ↑      ↓
-   //                                         Updating (measure)
-   //
-   // The difference between 'Idle' and 'Idle (unchecked)' lies in
-   // whether a layout check has been scheduled. A regular update through
-   // the `update` method updates the DOM in a write-only fashion, and
-   // relies on a check (scheduled with `requestAnimationFrame`) to make
-   // sure everything is where it should be and the viewport covers the
-   // visible code. That check continues to measure and then optionally
-   // update until it reaches a coherent state.
-   /**
-   An editor view represents the editor's user interface. It holds
-   the editable DOM surface, and possibly other elements such as the
-   line number gutter. It handles events and dispatches state
-   transactions for editing actions.
-   */
-   let EditorView$3 = class EditorView {
-       /**
-       Construct a new view. You'll want to either provide a `parent`
-       option, or put `view.dom` into your document after creating a
-       view, so that the user can see the editor.
-       */
-       constructor(
-       /**
-       Initialization options.
-       */
-       config = {}) {
-           this.plugins = [];
-           this.pluginMap = new Map;
-           this.editorAttrs = {};
-           this.contentAttrs = {};
-           this.bidiCache = [];
-           this.destroyed = false;
-           /**
-           @internal
-           */
-           this.updateState = 2 /* Updating */;
-           /**
-           @internal
-           */
-           this.measureScheduled = -1;
-           /**
-           @internal
-           */
-           this.measureRequests = [];
-           this.contentDOM = document.createElement("div");
-           this.scrollDOM = document.createElement("div");
-           this.scrollDOM.tabIndex = -1;
-           this.scrollDOM.className = "cm-scroller";
-           this.scrollDOM.appendChild(this.contentDOM);
-           this.announceDOM = document.createElement("div");
-           this.announceDOM.style.cssText = "position: absolute; top: -10000px";
-           this.announceDOM.setAttribute("aria-live", "polite");
-           this.dom = document.createElement("div");
-           this.dom.appendChild(this.announceDOM);
-           this.dom.appendChild(this.scrollDOM);
-           this._dispatch = config.dispatch || ((tr) => this.update([tr]));
-           this.dispatch = this.dispatch.bind(this);
-           this.root = (config.root || getRoot$3(config.parent) || document);
-           this.viewState = new ViewState$3(config.state || EditorState$3.create());
-           this.plugins = this.state.facet(viewPlugin$3).map(spec => new PluginInstance$3(spec));
-           for (let plugin of this.plugins)
-               plugin.update(this);
-           this.observer = new DOMObserver$3(this, (from, to, typeOver) => {
-               return applyDOMChange$3(this, from, to, typeOver);
-           }, event => {
-               this.inputState.runScrollHandlers(this, event);
-               if (this.observer.intersecting)
-                   this.measure();
-           });
-           this.inputState = new InputState$3(this);
-           this.inputState.ensureHandlers(this, this.plugins);
-           this.docView = new DocView$3(this);
-           this.mountStyles();
-           this.updateAttrs();
-           this.updateState = 0 /* Idle */;
-           this.requestMeasure();
-           if (config.parent)
-               config.parent.appendChild(this.dom);
-       }
-       /**
-       The current editor state.
-       */
-       get state() { return this.viewState.state; }
-       /**
-       To be able to display large documents without consuming too much
-       memory or overloading the browser, CodeMirror only draws the
-       code that is visible (plus a margin around it) to the DOM. This
-       property tells you the extent of the current drawn viewport, in
-       document positions.
-       */
-       get viewport() { return this.viewState.viewport; }
-       /**
-       When there are, for example, large collapsed ranges in the
-       viewport, its size can be a lot bigger than the actual visible
-       content. Thus, if you are doing something like styling the
-       content in the viewport, it is preferable to only do so for
-       these ranges, which are the subset of the viewport that is
-       actually drawn.
-       */
-       get visibleRanges() { return this.viewState.visibleRanges; }
-       /**
-       Returns false when the editor is entirely scrolled out of view
-       or otherwise hidden.
-       */
-       get inView() { return this.viewState.inView; }
-       /**
-       Indicates whether the user is currently composing text via
-       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
-       one change has been made in the current composition.
-       */
-       get composing() { return this.inputState.composing > 0; }
-       /**
-       Indicates whether the user is currently in composing state. Note
-       that on some platforms, like Android, this will be the case a
-       lot, since just putting the cursor on a word starts a
-       composition there.
-       */
-       get compositionStarted() { return this.inputState.composing >= 0; }
-       dispatch(...input) {
-           this._dispatch(input.length == 1 && input[0] instanceof Transaction$3 ? input[0]
-               : this.state.update(...input));
-       }
-       /**
-       Update the view for the given array of transactions. This will
-       update the visible document and selection to match the state
-       produced by the transactions, and notify view plugins of the
-       change. You should usually call
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
-       as a primitive.
-       */
-       update(transactions) {
-           if (this.updateState != 0 /* Idle */)
-               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
-           let redrawn = false, attrsChanged = false, update;
-           let state = this.state;
-           for (let tr of transactions) {
-               if (tr.startState != state)
-                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
-               state = tr.state;
-           }
-           if (this.destroyed) {
-               this.viewState.state = state;
-               return;
-           }
-           this.observer.clear();
-           // When the phrases change, redraw the editor
-           if (state.facet(EditorState$3.phrases) != this.state.facet(EditorState$3.phrases))
-               return this.setState(state);
-           update = ViewUpdate$3.create(this, state, transactions);
-           let scrollTarget = this.viewState.scrollTarget;
-           try {
-               this.updateState = 2 /* Updating */;
-               for (let tr of transactions) {
-                   if (scrollTarget)
-                       scrollTarget = scrollTarget.map(tr.changes);
-                   if (tr.scrollIntoView) {
-                       let { main } = tr.state.selection;
-                       scrollTarget = new ScrollTarget$3(main.empty ? main : EditorSelection$3.cursor(main.head, main.head > main.anchor ? -1 : 1));
-                   }
-                   for (let e of tr.effects)
-                       if (e.is(scrollIntoView$5))
-                           scrollTarget = e.value;
-               }
-               this.viewState.update(update, scrollTarget);
-               this.bidiCache = CachedOrder$3.update(this.bidiCache, update.changes);
-               if (!update.empty) {
-                   this.updatePlugins(update);
-                   this.inputState.update(update);
-               }
-               redrawn = this.docView.update(update);
-               if (this.state.facet(styleModule$3) != this.styleModules)
-                   this.mountStyles();
-               attrsChanged = this.updateAttrs();
-               this.showAnnouncements(transactions);
-               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-           }
-           if (update.startState.facet(theme$3) != update.state.facet(theme$3))
-               this.viewState.mustMeasureContent = true;
-           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
-               this.requestMeasure();
-           if (!update.empty)
-               for (let listener of this.state.facet(updateListener$3))
-                   listener(update);
-       }
-       /**
-       Reset the view to the given state. (This will cause the entire
-       document to be redrawn and all view plugins to be reinitialized,
-       so you should probably only use it when the new state isn't
-       derived from the old state. Otherwise, use
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
-       */
-       setState(newState) {
-           if (this.updateState != 0 /* Idle */)
-               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
-           if (this.destroyed) {
-               this.viewState.state = newState;
-               return;
-           }
-           this.updateState = 2 /* Updating */;
-           let hadFocus = this.hasFocus;
-           try {
-               for (let plugin of this.plugins)
-                   plugin.destroy(this);
-               this.viewState = new ViewState$3(newState);
-               this.plugins = newState.facet(viewPlugin$3).map(spec => new PluginInstance$3(spec));
-               this.pluginMap.clear();
-               for (let plugin of this.plugins)
-                   plugin.update(this);
-               this.docView = new DocView$3(this);
-               this.inputState.ensureHandlers(this, this.plugins);
-               this.mountStyles();
-               this.updateAttrs();
-               this.bidiCache = [];
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-           }
-           if (hadFocus)
-               this.focus();
-           this.requestMeasure();
-       }
-       updatePlugins(update) {
-           let prevSpecs = update.startState.facet(viewPlugin$3), specs = update.state.facet(viewPlugin$3);
-           if (prevSpecs != specs) {
-               let newPlugins = [];
-               for (let spec of specs) {
-                   let found = prevSpecs.indexOf(spec);
-                   if (found < 0) {
-                       newPlugins.push(new PluginInstance$3(spec));
-                   }
-                   else {
-                       let plugin = this.plugins[found];
-                       plugin.mustUpdate = update;
-                       newPlugins.push(plugin);
-                   }
-               }
-               for (let plugin of this.plugins)
-                   if (plugin.mustUpdate != update)
-                       plugin.destroy(this);
-               this.plugins = newPlugins;
-               this.pluginMap.clear();
-               this.inputState.ensureHandlers(this, this.plugins);
-           }
-           else {
-               for (let p of this.plugins)
-                   p.mustUpdate = update;
-           }
-           for (let i = 0; i < this.plugins.length; i++)
-               this.plugins[i].update(this);
-       }
-       /**
-       @internal
-       */
-       measure(flush = true) {
-           if (this.destroyed)
-               return;
-           if (this.measureScheduled > -1)
-               cancelAnimationFrame(this.measureScheduled);
-           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
-           if (flush)
-               this.observer.flush();
-           let updated = null;
-           try {
-               for (let i = 0;; i++) {
-                   this.updateState = 1 /* Measuring */;
-                   let oldViewport = this.viewport;
-                   let changed = this.viewState.measure(this);
-                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
-                       break;
-                   if (i > 5) {
-                       console.warn(this.measureRequests.length
-                           ? "Measure loop restarted more than 5 times"
-                           : "Viewport failed to stabilize");
-                       break;
-                   }
-                   let measuring = [];
-                   // Only run measure requests in this cycle when the viewport didn't change
-                   if (!(changed & 4 /* Viewport */))
-                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
-                   let measured = measuring.map(m => {
-                       try {
-                           return m.read(this);
-                       }
-                       catch (e) {
-                           logException$3(this.state, e);
-                           return BadMeasure$3;
-                       }
-                   });
-                   let update = ViewUpdate$3.create(this, this.state, []), redrawn = false, scrolled = false;
-                   update.flags |= changed;
-                   if (!updated)
-                       updated = update;
-                   else
-                       updated.flags |= changed;
-                   this.updateState = 2 /* Updating */;
-                   if (!update.empty) {
-                       this.updatePlugins(update);
-                       this.inputState.update(update);
-                       this.updateAttrs();
-                       redrawn = this.docView.update(update);
-                   }
-                   for (let i = 0; i < measuring.length; i++)
-                       if (measured[i] != BadMeasure$3) {
-                           try {
-                               let m = measuring[i];
-                               if (m.write)
-                                   m.write(measured[i], this);
-                           }
-                           catch (e) {
-                               logException$3(this.state, e);
-                           }
-                       }
-                   if (this.viewState.scrollTarget) {
-                       this.docView.scrollIntoView(this.viewState.scrollTarget);
-                       this.viewState.scrollTarget = null;
-                       scrolled = true;
-                   }
-                   if (redrawn)
-                       this.docView.updateSelection(true);
-                   if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
-                       !scrolled && this.measureRequests.length == 0)
-                       break;
-               }
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-               this.measureScheduled = -1;
-           }
-           if (updated && !updated.empty)
-               for (let listener of this.state.facet(updateListener$3))
-                   listener(updated);
-       }
-       /**
-       Get the CSS classes for the currently active editor themes.
-       */
-       get themeClasses() {
-           return baseThemeID$3 + " " +
-               (this.state.facet(darkTheme$3) ? baseDarkID$3 : baseLightID$3) + " " +
-               this.state.facet(theme$3);
-       }
-       updateAttrs() {
-           let editorAttrs = attrsFromFacet$3(this, editorAttributes$3, {
-               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
-           });
-           let contentAttrs = {
-               spellcheck: "false",
-               autocorrect: "off",
-               autocapitalize: "off",
-               translate: "no",
-               contenteditable: !this.state.facet(editable$3) ? "false" : "true",
-               class: "cm-content",
-               style: `${browser$3.tabSize}: ${this.state.tabSize}`,
-               role: "textbox",
-               "aria-multiline": "true"
-           };
-           if (this.state.readOnly)
-               contentAttrs["aria-readonly"] = "true";
-           attrsFromFacet$3(this, contentAttributes$3, contentAttrs);
-           let changed = this.observer.ignore(() => {
-               let changedContent = updateAttrs$3(this.contentDOM, this.contentAttrs, contentAttrs);
-               let changedEditor = updateAttrs$3(this.dom, this.editorAttrs, editorAttrs);
-               return changedContent || changedEditor;
-           });
-           this.editorAttrs = editorAttrs;
-           this.contentAttrs = contentAttrs;
-           return changed;
-       }
-       showAnnouncements(trs) {
-           let first = true;
-           for (let tr of trs)
-               for (let effect of tr.effects)
-                   if (effect.is(EditorView.announce)) {
-                       if (first)
-                           this.announceDOM.textContent = "";
-                       first = false;
-                       let div = this.announceDOM.appendChild(document.createElement("div"));
-                       div.textContent = effect.value;
-                   }
-       }
-       mountStyles() {
-           this.styleModules = this.state.facet(styleModule$3);
-           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$5).reverse());
-       }
-       readMeasured() {
-           if (this.updateState == 2 /* Updating */)
-               throw new Error("Reading the editor layout isn't allowed during an update");
-           if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
-               this.measure(false);
-       }
-       /**
-       Schedule a layout measurement, optionally providing callbacks to
-       do custom DOM measuring followed by a DOM write phase. Using
-       this is preferable reading DOM layout directly from, for
-       example, an event handler, because it'll make sure measuring and
-       drawing done by other components is synchronized, avoiding
-       unnecessary DOM layout computations.
-       */
-       requestMeasure(request) {
-           if (this.measureScheduled < 0)
-               this.measureScheduled = requestAnimationFrame(() => this.measure());
-           if (request) {
-               if (request.key != null)
-                   for (let i = 0; i < this.measureRequests.length; i++) {
-                       if (this.measureRequests[i].key === request.key) {
-                           this.measureRequests[i] = request;
-                           return;
-                       }
-                   }
-               this.measureRequests.push(request);
-           }
-       }
-       /**
-       Get the value of a specific plugin, if present. Note that
-       plugins that crash can be dropped from a view, so even when you
-       know you registered a given plugin, it is recommended to check
-       the return value of this method.
-       */
-       plugin(plugin) {
-           let known = this.pluginMap.get(plugin);
-           if (known === undefined || known && known.spec != plugin)
-               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
-           return known && known.update(this).value;
-       }
-       /**
-       The top position of the document, in screen coordinates. This
-       may be negative when the editor is scrolled down. Points
-       directly to the top of the first line, not above the padding.
-       */
-       get documentTop() {
-           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
-       }
-       /**
-       Reports the padding above and below the document.
-       */
-       get documentPadding() {
-           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
-       }
-       /**
-       Find the text line or block widget at the given vertical
-       position (which is interpreted as relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
-       */
-       elementAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.elementAtHeight(height);
-       }
-       /**
-       Find the line block (see
-       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
-       height.
-       */
-       lineBlockAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.lineBlockAtHeight(height);
-       }
-       /**
-       Get the extent and vertical position of all [line
-       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
-       are relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
-       */
-       get viewportLineBlocks() {
-           return this.viewState.viewportLines;
-       }
-       /**
-       Find the line block around the given document position. A line
-       block is a range delimited on both sides by either a
-       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
-       start/end of the document. It will usually just hold a line of
-       text, but may be broken into multiple textblocks by block
-       widgets.
-       */
-       lineBlockAt(pos) {
-           return this.viewState.lineBlockAt(pos);
-       }
-       /**
-       The editor's total content height.
-       */
-       get contentHeight() {
-           return this.viewState.contentHeight;
-       }
-       /**
-       Move a cursor position by [grapheme
-       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
-       the motion is away from the line start, or towards it. In
-       bidirectional text, the line is traversed in visual order, using
-       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-       When the start position was the last one on the line, the
-       returned position will be across the line break. If there is no
-       further line, the original position is returned.
-       
-       By default, this method moves over a single cluster. The
-       optional `by` argument can be used to move across more. It will
-       be called with the first cluster as argument, and should return
-       a predicate that determines, for each subsequent cluster,
-       whether it should also be moved over.
-       */
-       moveByChar(start, forward, by) {
-           return skipAtoms$3(this, start, moveByChar$3(this, start, forward, by));
-       }
-       /**
-       Move a cursor position across the next group of either
-       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
-       non-whitespace characters.
-       */
-       moveByGroup(start, forward) {
-           return skipAtoms$3(this, start, moveByChar$3(this, start, forward, initial => byGroup$3(this, start.head, initial)));
-       }
-       /**
-       Move to the next line boundary in the given direction. If
-       `includeWrap` is true, line wrapping is on, and there is a
-       further wrap point on the current line, the wrap point will be
-       returned. Otherwise this function will return the start or end
-       of the line.
-       */
-       moveToLineBoundary(start, forward, includeWrap = true) {
-           return moveToLineBoundary$3(this, start, forward, includeWrap);
-       }
-       /**
-       Move a cursor position vertically. When `distance` isn't given,
-       it defaults to moving to the next line (including wrapped
-       lines). Otherwise, `distance` should provide a positive distance
-       in pixels.
-       
-       When `start` has a
-       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
-       motion will use that as a target horizontal position. Otherwise,
-       the cursor's own horizontal position is used. The returned
-       cursor will have its goal column set to whichever column was
-       used.
-       */
-       moveVertically(start, forward, distance) {
-           return skipAtoms$3(this, start, moveVertically$3(this, start, forward, distance));
-       }
-       /**
-       Find the DOM parent node and offset (child offset if `node` is
-       an element, character offset when it is a text node) at the
-       given document position.
-       
-       Note that for positions that aren't currently in
-       `visibleRanges`, the resulting DOM position isn't necessarily
-       meaningful (it may just point before or after a placeholder
-       element).
-       */
-       domAtPos(pos) {
-           return this.docView.domAtPos(pos);
-       }
-       /**
-       Find the document position at the given DOM node. Can be useful
-       for associating positions with DOM events. Will raise an error
-       when `node` isn't part of the editor content.
-       */
-       posAtDOM(node, offset = 0) {
-           return this.docView.posFromDOM(node, offset);
-       }
-       posAtCoords(coords, precise = true) {
-           this.readMeasured();
-           return posAtCoords$3(this, coords, precise);
-       }
-       /**
-       Get the screen coordinates at the given document position.
-       `side` determines whether the coordinates are based on the
-       element before (-1) or after (1) the position (if no element is
-       available on the given side, the method will transparently use
-       another strategy to get reasonable coordinates).
-       */
-       coordsAtPos(pos, side = 1) {
-           this.readMeasured();
-           let rect = this.docView.coordsAt(pos, side);
-           if (!rect || rect.left == rect.right)
-               return rect;
-           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
-           let span = order[BidiSpan$3.find(order, pos - line.from, -1, side)];
-           return flattenRect$3(rect, (span.dir == Direction$3.LTR) == (side > 0));
-       }
-       /**
-       The default width of a character in the editor. May not
-       accurately reflect the width of all characters (given variable
-       width fonts or styling of invididual ranges).
-       */
-       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
-       /**
-       The default height of a line in the editor. May not be accurate
-       for all lines.
-       */
-       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
-       /**
-       The text direction
-       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
-       CSS property) of the editor's content element.
-       */
-       get textDirection() { return this.viewState.defaultTextDirection; }
-       /**
-       Find the text direction of the block at the given position, as
-       assigned by CSS. If
-       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
-       isn't enabled, or the given position is outside of the viewport,
-       this will always return the same as
-       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
-       this may trigger a DOM layout.
-       */
-       textDirectionAt(pos) {
-           let perLine = this.state.facet(perLineTextDirection$3);
-           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
-               return this.textDirection;
-           this.readMeasured();
-           return this.docView.textDirectionAt(pos);
-       }
-       /**
-       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
-       (as determined by the
-       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
-       CSS property of its content element).
-       */
-       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
-       /**
-       Returns the bidirectional text structure of the given line
-       (which should be in the current document) as an array of span
-       objects. The order of these spans matches the [text
-       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
-       left-to-right, the leftmost spans come first, otherwise the
-       rightmost spans come first.
-       */
-       bidiSpans(line) {
-           if (line.length > MaxBidiLine$3)
-               return trivialOrder$3(line.length);
-           let dir = this.textDirectionAt(line.from);
-           for (let entry of this.bidiCache)
-               if (entry.from == line.from && entry.dir == dir)
-                   return entry.order;
-           let order = computeOrder$3(line.text, dir);
-           this.bidiCache.push(new CachedOrder$3(line.from, line.to, dir, order));
-           return order;
-       }
-       /**
-       Check whether the editor has focus.
-       */
-       get hasFocus() {
-           var _a;
-           // Safari return false for hasFocus when the context menu is open
-           // or closing, which leads us to ignore selection changes from the
-           // context menu because it looks like the editor isn't focused.
-           // This kludges around that.
-           return (document.hasFocus() || browser$3.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
-               this.root.activeElement == this.contentDOM;
-       }
-       /**
-       Put focus on the editor.
-       */
-       focus() {
-           this.observer.ignore(() => {
-               focusPreventScroll$3(this.contentDOM);
-               this.docView.updateSelection();
-           });
-       }
-       /**
-       Clean up this editor view, removing its element from the
-       document, unregistering event handlers, and notifying
-       plugins. The view instance can no longer be used after
-       calling this.
-       */
-       destroy() {
-           for (let plugin of this.plugins)
-               plugin.destroy(this);
-           this.plugins = [];
-           this.inputState.destroy();
-           this.dom.remove();
-           this.observer.destroy();
-           if (this.measureScheduled > -1)
-               cancelAnimationFrame(this.measureScheduled);
-           this.destroyed = true;
-       }
-       /**
-       Returns an effect that can be
-       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
-       cause it to scroll the given position or range into view.
-       */
-       static scrollIntoView(pos, options = {}) {
-           return scrollIntoView$5.of(new ScrollTarget$3(typeof pos == "number" ? EditorSelection$3.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
-       }
-       /**
-       Returns an extension that can be used to add DOM event handlers.
-       The value should be an object mapping event names to handler
-       functions. For any given event, such functions are ordered by
-       extension precedence, and the first handler to return true will
-       be assumed to have handled that event, and no other handlers or
-       built-in behavior will be activated for it. These are registered
-       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
-       for `scroll` handlers, which will be called any time the
-       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
-       its parent nodes is scrolled.
-       */
-       static domEventHandlers(handlers) {
-           return ViewPlugin$3.define(() => ({}), { eventHandlers: handlers });
-       }
-       /**
-       Create a theme extension. The first argument can be a
-       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
-       style spec providing the styles for the theme. These will be
-       prefixed with a generated class for the style.
-       
-       Because the selectors will be prefixed with a scope class, rule
-       that directly match the editor's [wrapper
-       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
-       added—need to be explicitly differentiated by adding an `&` to
-       the selector for that element—for example
-       `&.cm-focused`.
-       
-       When `dark` is set to true, the theme will be marked as dark,
-       which will cause the `&dark` rules from [base
-       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
-       `&light` when a light theme is active).
-       */
-       static theme(spec, options) {
-           let prefix = StyleModule.newName();
-           let result = [theme$3.of(prefix), styleModule$3.of(buildTheme$3(`.${prefix}`, spec))];
-           if (options && options.dark)
-               result.push(darkTheme$3.of(true));
-           return result;
-       }
-       /**
-       Create an extension that adds styles to the base theme. Like
-       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
-       place of the editor wrapper element when directly targeting
-       that. You can also use `&dark` or `&light` instead to only
-       target editors with a dark or light theme.
-       */
-       static baseTheme(spec) {
-           return Prec$3.lowest(styleModule$3.of(buildTheme$3("." + baseThemeID$3, spec, lightDarkIDs$3)));
-       }
-   };
-   /**
-   Facet to add a [style
-   module](https://github.com/marijnh/style-mod#documentation) to
-   an editor view. The view will ensure that the module is
-   mounted in its [document
-   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
-   */
-   EditorView$3.styleModule = styleModule$3;
-   /**
-   An input handler can override the way changes to the editable
-   DOM content are handled. Handlers are passed the document
-   positions between which the change was found, and the new
-   content. When one returns true, no further input handlers are
-   called and the default behavior is prevented.
-   */
-   EditorView$3.inputHandler = inputHandler$4;
-   /**
-   By default, the editor assumes all its content has the same
-   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
-   value to make it read the text direction of every (rendered)
-   line separately.
-   */
-   EditorView$3.perLineTextDirection = perLineTextDirection$3;
-   /**
-   Allows you to provide a function that should be called when the
-   library catches an exception from an extension (mostly from view
-   plugins, but may be used by other extensions to route exceptions
-   from user-code-provided callbacks). This is mostly useful for
-   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
-   */
-   EditorView$3.exceptionSink = exceptionSink$3;
-   /**
-   A facet that can be used to register a function to be called
-   every time the view updates.
-   */
-   EditorView$3.updateListener = updateListener$3;
-   /**
-   Facet that controls whether the editor content DOM is editable.
-   When its highest-precedence value is `false`, the element will
-   not have its `contenteditable` attribute set. (Note that this
-   doesn't affect API calls that change the editor content, even
-   when those are bound to keys or buttons. See the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
-   */
-   EditorView$3.editable = editable$3;
-   /**
-   Allows you to influence the way mouse selection happens. The
-   functions in this facet will be called for a `mousedown` event
-   on the editor, and can return an object that overrides the way a
-   selection is computed from that mouse click or drag.
-   */
-   EditorView$3.mouseSelectionStyle = mouseSelectionStyle$3;
-   /**
-   Facet used to configure whether a given selection drag event
-   should move or copy the selection. The given predicate will be
-   called with the `mousedown` event, and can return `true` when
-   the drag should move the content.
-   */
-   EditorView$3.dragMovesSelection = dragMovesSelection$1$3;
-   /**
-   Facet used to configure whether a given selecting click adds a
-   new range to the existing selection or replaces it entirely. The
-   default behavior is to check `event.metaKey` on macOS, and
-   `event.ctrlKey` elsewhere.
-   */
-   EditorView$3.clickAddsSelectionRange = clickAddsSelectionRange$3;
-   /**
-   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
-   are shown in the view. Decorations can be provided in two
-   ways—directly, or via a function that takes an editor view.
-
-   Only decoration sets provided directly are allowed to influence
-   the editor's vertical layout structure. The ones provided as
-   functions are called _after_ the new viewport has been computed,
-   and thus **must not** introduce block widgets or replacing
-   decorations that cover line breaks.
-   */
-   EditorView$3.decorations = decorations$3;
-   /**
-   Used to provide ranges that should be treated as atoms as far as
-   cursor motion is concerned. This causes methods like
-   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
-   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
-   commands built on top of them) to skip across such regions when
-   a selection endpoint would enter them. This does _not_ prevent
-   direct programmatic [selection
-   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
-   regions.
-   */
-   EditorView$3.atomicRanges = atomicRanges$3;
-   /**
-   Facet that allows extensions to provide additional scroll
-   margins (space around the sides of the scrolling element that
-   should be considered invisible). This can be useful when the
-   plugin introduces elements that cover part of that element (for
-   example a horizontally fixed gutter).
-   */
-   EditorView$3.scrollMargins = scrollMargins$3;
-   /**
-   This facet records whether a dark theme is active. The extension
-   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
-   includes an instance of this when the `dark` option is set to
-   true.
-   */
-   EditorView$3.darkTheme = darkTheme$3;
-   /**
-   Facet that provides additional DOM attributes for the editor's
-   editable DOM element.
-   */
-   EditorView$3.contentAttributes = contentAttributes$3;
-   /**
-   Facet that provides DOM attributes for the editor's outer
-   element.
-   */
-   EditorView$3.editorAttributes = editorAttributes$3;
-   /**
-   An extension that enables line wrapping in the editor (by
-   setting CSS `white-space` to `pre-wrap` in the content).
-   */
-   EditorView$3.lineWrapping = /*@__PURE__*/EditorView$3.contentAttributes.of({ "class": "cm-lineWrapping" });
-   /**
-   State effect used to include screen reader announcements in a
-   transaction. These will be added to the DOM in a visually hidden
-   element with `aria-live="polite"` set, and should be used to
-   describe effects that are visually obvious but may not be
-   noticed by screen reader users (such as moving to the next
-   search match).
-   */
-   EditorView$3.announce = /*@__PURE__*/StateEffect$3.define();
-   // Maximum line length for which we compute accurate bidi info
-   const MaxBidiLine$3 = 4096;
-   const BadMeasure$3 = {};
-   let CachedOrder$3 = class CachedOrder {
-       constructor(from, to, dir, order) {
-           this.from = from;
-           this.to = to;
-           this.dir = dir;
-           this.order = order;
-       }
-       static update(cache, changes) {
-           if (changes.empty)
-               return cache;
-           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction$3.LTR;
-           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
-               let entry = cache[i];
-               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
-                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.order));
-           }
-           return result;
-       }
-   };
-   function attrsFromFacet$3(view, facet, base) {
-       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
-           let source = sources[i], value = typeof source == "function" ? source(view) : source;
-           if (value)
-               combineAttrs$3(value, base);
-       }
-       return base;
-   }
-
-   const currentPlatform$2 = browser$3.mac ? "mac" : browser$3.windows ? "win" : browser$3.linux ? "linux" : "key";
-   function normalizeKeyName$2(name, platform) {
-       const parts = name.split(/-(?!$)/);
-       let result = parts[parts.length - 1];
-       if (result == "Space")
-           result = " ";
-       let alt, ctrl, shift, meta;
-       for (let i = 0; i < parts.length - 1; ++i) {
-           const mod = parts[i];
-           if (/^(cmd|meta|m)$/i.test(mod))
-               meta = true;
-           else if (/^a(lt)?$/i.test(mod))
-               alt = true;
-           else if (/^(c|ctrl|control)$/i.test(mod))
-               ctrl = true;
-           else if (/^s(hift)?$/i.test(mod))
-               shift = true;
-           else if (/^mod$/i.test(mod)) {
-               if (platform == "mac")
-                   meta = true;
-               else
-                   ctrl = true;
-           }
-           else
-               throw new Error("Unrecognized modifier name: " + mod);
-       }
-       if (alt)
-           result = "Alt-" + result;
-       if (ctrl)
-           result = "Ctrl-" + result;
-       if (meta)
-           result = "Meta-" + result;
-       if (shift)
-           result = "Shift-" + result;
-       return result;
-   }
-   function modifiers$2(name, event, shift) {
-       if (event.altKey)
-           name = "Alt-" + name;
-       if (event.ctrlKey)
-           name = "Ctrl-" + name;
-       if (event.metaKey)
-           name = "Meta-" + name;
-       if (shift !== false && event.shiftKey)
-           name = "Shift-" + name;
-       return name;
-   }
-   const handleKeyEvents$2 = /*@__PURE__*/EditorView$3.domEventHandlers({
-       keydown(event, view) {
-           return runHandlers$2(getKeymap$2(view.state), event, view, "editor");
-       }
-   });
-   /**
-   Facet used for registering keymaps.
-
-   You can add multiple keymaps to an editor. Their priorities
-   determine their precedence (the ones specified early or with high
-   priority get checked first). When a handler has returned `true`
-   for a given key, no further handlers are called.
-   */
-   const keymap$2 = /*@__PURE__*/Facet$3.define({ enables: handleKeyEvents$2 });
-   const Keymaps$2 = /*@__PURE__*/new WeakMap();
-   // This is hidden behind an indirection, rather than directly computed
-   // by the facet, to keep internal types out of the facet's type.
-   function getKeymap$2(state) {
-       let bindings = state.facet(keymap$2);
-       let map = Keymaps$2.get(bindings);
-       if (!map)
-           Keymaps$2.set(bindings, map = buildKeymap$2(bindings.reduce((a, b) => a.concat(b), [])));
-       return map;
-   }
-   let storedPrefix$2 = null;
-   const PrefixTimeout$2 = 4000;
-   function buildKeymap$2(bindings, platform = currentPlatform$2) {
-       let bound = Object.create(null);
-       let isPrefix = Object.create(null);
-       let checkPrefix = (name, is) => {
-           let current = isPrefix[name];
-           if (current == null)
-               isPrefix[name] = is;
-           else if (current != is)
-               throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
-       };
-       let add = (scope, key, command, preventDefault) => {
-           let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
-           let parts = key.split(/ (?!$)/).map(k => normalizeKeyName$2(k, platform));
-           for (let i = 1; i < parts.length; i++) {
-               let prefix = parts.slice(0, i).join(" ");
-               checkPrefix(prefix, true);
-               if (!scopeObj[prefix])
-                   scopeObj[prefix] = {
-                       preventDefault: true,
-                       commands: [(view) => {
-                               let ourObj = storedPrefix$2 = { view, prefix, scope };
-                               setTimeout(() => { if (storedPrefix$2 == ourObj)
-                                   storedPrefix$2 = null; }, PrefixTimeout$2);
-                               return true;
-                           }]
-                   };
-           }
-           let full = parts.join(" ");
-           checkPrefix(full, false);
-           let binding = scopeObj[full] || (scopeObj[full] = { preventDefault: false, commands: [] });
-           binding.commands.push(command);
-           if (preventDefault)
-               binding.preventDefault = true;
-       };
-       for (let b of bindings) {
-           let name = b[platform] || b.key;
-           if (!name)
-               continue;
-           for (let scope of b.scope ? b.scope.split(" ") : ["editor"]) {
-               add(scope, name, b.run, b.preventDefault);
-               if (b.shift)
-                   add(scope, "Shift-" + name, b.shift, b.preventDefault);
-           }
-       }
-       return bound;
-   }
-   function runHandlers$2(map, event, view, scope) {
-       let name = keyName(event), isChar = name.length == 1 && name != " ";
-       let prefix = "", fallthrough = false;
-       if (storedPrefix$2 && storedPrefix$2.view == view && storedPrefix$2.scope == scope) {
-           prefix = storedPrefix$2.prefix + " ";
-           if (fallthrough = modifierCodes$3.indexOf(event.keyCode) < 0)
-               storedPrefix$2 = null;
-       }
-       let runFor = (binding) => {
-           if (binding) {
-               for (let cmd of binding.commands)
-                   if (cmd(view))
-                       return true;
-               if (binding.preventDefault)
-                   fallthrough = true;
-           }
-           return false;
-       };
-       let scopeObj = map[scope], baseName;
-       if (scopeObj) {
-           if (runFor(scopeObj[prefix + modifiers$2(name, event, !isChar)]))
-               return true;
-           if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
-               (baseName = base[event.keyCode]) && baseName != name) {
-               if (runFor(scopeObj[prefix + modifiers$2(baseName, event, true)]))
-                   return true;
-           }
-           else if (isChar && event.shiftKey) {
-               if (runFor(scopeObj[prefix + modifiers$2(name, event, true)]))
-                   return true;
-           }
-       }
-       return fallthrough;
-   }
-
-   const CanHidePrimary$3 = !browser$3.ios; // FIXME test IE
-   const selectionConfig = /*@__PURE__*/Facet$3.define({
-       combine(configs) {
-           return combineConfig$3(configs, {
-               cursorBlinkRate: 1200,
-               drawRangeCursor: true
-           }, {
-               cursorBlinkRate: (a, b) => Math.min(a, b),
-               drawRangeCursor: (a, b) => a || b
-           });
-       }
-   });
-   /**
-   Returns an extension that hides the browser's native selection and
-   cursor, replacing the selection with a background behind the text
-   (with the `cm-selectionBackground` class), and the
-   cursors with elements overlaid over the code (using
-   `cm-cursor-primary` and `cm-cursor-secondary`).
-
-   This allows the editor to display secondary selection ranges, and
-   tends to produce a type of selection more in line with that users
-   expect in a text editor (the native selection styling will often
-   leave gaps between lines and won't fill the horizontal space after
-   a line when the selection continues past it).
-
-   It does have a performance cost, in that it requires an extra DOM
-   layout cycle for many updates (the selection is drawn based on DOM
-   layout information that's only available after laying out the
-   content).
-   */
-   function drawSelection(config = {}) {
-       return [
-           selectionConfig.of(config),
-           drawSelectionPlugin,
-           hideNativeSelection
-       ];
-   }
-   class Piece {
-       constructor(left, top, width, height, className) {
-           this.left = left;
-           this.top = top;
-           this.width = width;
-           this.height = height;
-           this.className = className;
-       }
-       draw() {
-           let elt = document.createElement("div");
-           elt.className = this.className;
-           this.adjust(elt);
-           return elt;
-       }
-       adjust(elt) {
-           elt.style.left = this.left + "px";
-           elt.style.top = this.top + "px";
-           if (this.width >= 0)
-               elt.style.width = this.width + "px";
-           elt.style.height = this.height + "px";
-       }
-       eq(p) {
-           return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&
-               this.className == p.className;
-       }
-   }
-   const drawSelectionPlugin = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.rangePieces = [];
-           this.cursors = [];
-           this.measureReq = { read: this.readPos.bind(this), write: this.drawSel.bind(this) };
-           this.selectionLayer = view.scrollDOM.appendChild(document.createElement("div"));
-           this.selectionLayer.className = "cm-selectionLayer";
-           this.selectionLayer.setAttribute("aria-hidden", "true");
-           this.cursorLayer = view.scrollDOM.appendChild(document.createElement("div"));
-           this.cursorLayer.className = "cm-cursorLayer";
-           this.cursorLayer.setAttribute("aria-hidden", "true");
-           view.requestMeasure(this.measureReq);
-           this.setBlinkRate();
-       }
-       setBlinkRate() {
-           this.cursorLayer.style.animationDuration = this.view.state.facet(selectionConfig).cursorBlinkRate + "ms";
-       }
-       update(update) {
-           let confChanged = update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
-           if (confChanged || update.selectionSet || update.geometryChanged || update.viewportChanged)
-               this.view.requestMeasure(this.measureReq);
-           if (update.transactions.some(tr => tr.scrollIntoView))
-               this.cursorLayer.style.animationName = this.cursorLayer.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
-           if (confChanged)
-               this.setBlinkRate();
-       }
-       readPos() {
-           let { state } = this.view, conf = state.facet(selectionConfig);
-           let rangePieces = state.selection.ranges.map(r => r.empty ? [] : measureRange(this.view, r)).reduce((a, b) => a.concat(b));
-           let cursors = [];
-           for (let r of state.selection.ranges) {
-               let prim = r == state.selection.main;
-               if (r.empty ? !prim || CanHidePrimary$3 : conf.drawRangeCursor) {
-                   let piece = measureCursor(this.view, r, prim);
-                   if (piece)
-                       cursors.push(piece);
-               }
-           }
-           return { rangePieces, cursors };
-       }
-       drawSel({ rangePieces, cursors }) {
-           if (rangePieces.length != this.rangePieces.length || rangePieces.some((p, i) => !p.eq(this.rangePieces[i]))) {
-               this.selectionLayer.textContent = "";
-               for (let p of rangePieces)
-                   this.selectionLayer.appendChild(p.draw());
-               this.rangePieces = rangePieces;
-           }
-           if (cursors.length != this.cursors.length || cursors.some((c, i) => !c.eq(this.cursors[i]))) {
-               let oldCursors = this.cursorLayer.children;
-               if (oldCursors.length !== cursors.length) {
-                   this.cursorLayer.textContent = "";
-                   for (const c of cursors)
-                       this.cursorLayer.appendChild(c.draw());
-               }
-               else {
-                   cursors.forEach((c, idx) => c.adjust(oldCursors[idx]));
-               }
-               this.cursors = cursors;
-           }
-       }
-       destroy() {
-           this.selectionLayer.remove();
-           this.cursorLayer.remove();
-       }
-   });
-   const themeSpec$3 = {
-       ".cm-line": {
-           "& ::selection": { backgroundColor: "transparent !important" },
-           "&::selection": { backgroundColor: "transparent !important" }
-       }
-   };
-   if (CanHidePrimary$3)
-       themeSpec$3[".cm-line"].caretColor = "transparent !important";
-   const hideNativeSelection = /*@__PURE__*/Prec$3.highest(/*@__PURE__*/EditorView$3.theme(themeSpec$3));
-   function getBase(view) {
-       let rect = view.scrollDOM.getBoundingClientRect();
-       let left = view.textDirection == Direction$3.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth;
-       return { left: left - view.scrollDOM.scrollLeft, top: rect.top - view.scrollDOM.scrollTop };
-   }
-   function wrappedLine(view, pos, inside) {
-       let range = EditorSelection$3.cursor(pos);
-       return { from: Math.max(inside.from, view.moveToLineBoundary(range, false, true).from),
-           to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),
-           type: BlockType$3.Text };
-   }
-   function blockAt$1(view, pos) {
-       let line = view.lineBlockAt(pos);
-       if (Array.isArray(line.type))
-           for (let l of line.type) {
-               if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType$3.Text))
-                   return l;
-           }
-       return line;
-   }
-   function measureRange(view, range) {
-       if (range.to <= view.viewport.from || range.from >= view.viewport.to)
-           return [];
-       let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);
-       let ltr = view.textDirection == Direction$3.LTR;
-       let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);
-       let lineStyle = window.getComputedStyle(content.firstChild);
-       let leftSide = contentRect.left + parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent));
-       let rightSide = contentRect.right - parseInt(lineStyle.paddingRight);
-       let startBlock = blockAt$1(view, from), endBlock = blockAt$1(view, to);
-       let visualStart = startBlock.type == BlockType$3.Text ? startBlock : null;
-       let visualEnd = endBlock.type == BlockType$3.Text ? endBlock : null;
-       if (view.lineWrapping) {
-           if (visualStart)
-               visualStart = wrappedLine(view, from, visualStart);
-           if (visualEnd)
-               visualEnd = wrappedLine(view, to, visualEnd);
-       }
-       if (visualStart && visualEnd && visualStart.from == visualEnd.from) {
-           return pieces(drawForLine(range.from, range.to, visualStart));
-       }
-       else {
-           let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
-           let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
-           let between = [];
-           if ((visualStart || startBlock).to < (visualEnd || endBlock).from - 1)
-               between.push(piece(leftSide, top.bottom, rightSide, bottom.top));
-           else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType$3.Text)
-               top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
-           return pieces(top).concat(between).concat(pieces(bottom));
-       }
-       function piece(left, top, right, bottom) {
-           return new Piece(left - base.left, top - base.top - 0.01 /* Epsilon */, right - left, bottom - top + 0.01 /* Epsilon */, "cm-selectionBackground");
-       }
-       function pieces({ top, bottom, horizontal }) {
-           let pieces = [];
-           for (let i = 0; i < horizontal.length; i += 2)
-               pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));
-           return pieces;
-       }
-       // Gets passed from/to in line-local positions
-       function drawForLine(from, to, line) {
-           let top = 1e9, bottom = -1e9, horizontal = [];
-           function addSpan(from, fromOpen, to, toOpen, dir) {
-               // Passing 2/-2 is a kludge to force the view to return
-               // coordinates on the proper side of block widgets, since
-               // normalizing the side there, though appropriate for most
-               // coordsAtPos queries, would break selection drawing.
-               let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));
-               let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));
-               top = Math.min(fromCoords.top, toCoords.top, top);
-               bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);
-               if (dir == Direction$3.LTR)
-                   horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);
-               else
-                   horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);
-           }
-           let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;
-           // Split the range by visible range and document line
-           for (let r of view.visibleRanges)
-               if (r.to > start && r.from < end) {
-                   for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {
-                       let docLine = view.state.doc.lineAt(pos);
-                       for (let span of view.bidiSpans(docLine)) {
-                           let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;
-                           if (spanFrom >= endPos)
-                               break;
-                           if (spanTo > pos)
-                               addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);
-                       }
-                       pos = docLine.to + 1;
-                       if (pos >= endPos)
-                           break;
-                   }
-               }
-           if (horizontal.length == 0)
-               addSpan(start, from == null, end, to == null, view.textDirection);
-           return { top, bottom, horizontal };
-       }
-       function drawForWidget(block, top) {
-           let y = contentRect.top + (top ? block.top : block.bottom);
-           return { top: y, bottom: y, horizontal: [] };
-       }
-   }
-   function measureCursor(view, cursor, primary) {
-       let pos = view.coordsAtPos(cursor.head, cursor.assoc || 1);
-       if (!pos)
-           return null;
-       let base = getBase(view);
-       return new Piece(pos.left - base.left, pos.top - base.top, -1, pos.bottom - pos.top, primary ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary");
-   }
-
-   const setDropCursorPos = /*@__PURE__*/StateEffect$3.define({
-       map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
-   });
-   const dropCursorPos = /*@__PURE__*/StateField$3.define({
-       create() { return null; },
-       update(pos, tr) {
-           if (pos != null)
-               pos = tr.changes.mapPos(pos);
-           return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);
-       }
-   });
-   const drawDropCursor = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.cursor = null;
-           this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };
-       }
-       update(update) {
-           var _a;
-           let cursorPos = update.state.field(dropCursorPos);
-           if (cursorPos == null) {
-               if (this.cursor != null) {
-                   (_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();
-                   this.cursor = null;
-               }
-           }
-           else {
-               if (!this.cursor) {
-                   this.cursor = this.view.scrollDOM.appendChild(document.createElement("div"));
-                   this.cursor.className = "cm-dropCursor";
-               }
-               if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)
-                   this.view.requestMeasure(this.measureReq);
-           }
-       }
-       readPos() {
-           let pos = this.view.state.field(dropCursorPos);
-           let rect = pos != null && this.view.coordsAtPos(pos);
-           if (!rect)
-               return null;
-           let outer = this.view.scrollDOM.getBoundingClientRect();
-           return {
-               left: rect.left - outer.left + this.view.scrollDOM.scrollLeft,
-               top: rect.top - outer.top + this.view.scrollDOM.scrollTop,
-               height: rect.bottom - rect.top
-           };
-       }
-       drawCursor(pos) {
-           if (this.cursor) {
-               if (pos) {
-                   this.cursor.style.left = pos.left + "px";
-                   this.cursor.style.top = pos.top + "px";
-                   this.cursor.style.height = pos.height + "px";
-               }
-               else {
-                   this.cursor.style.left = "-100000px";
-               }
-           }
-       }
-       destroy() {
-           if (this.cursor)
-               this.cursor.remove();
-       }
-       setDropPos(pos) {
-           if (this.view.state.field(dropCursorPos) != pos)
-               this.view.dispatch({ effects: setDropCursorPos.of(pos) });
-       }
-   }, {
-       eventHandlers: {
-           dragover(event) {
-               this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));
-           },
-           dragleave(event) {
-               if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))
-                   this.setDropPos(null);
-           },
-           dragend() {
-               this.setDropPos(null);
-           },
-           drop() {
-               this.setDropPos(null);
-           }
-       }
-   });
-   /**
-   Draws a cursor at the current drop position when something is
-   dragged over the editor.
-   */
-   function dropCursor() {
-       return [dropCursorPos, drawDropCursor];
-   }
-
-   function iterMatches(doc, re, from, to, f) {
-       re.lastIndex = 0;
-       for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {
-           if (!cursor.lineBreak)
-               while (m = re.exec(cursor.value))
-                   f(pos + m.index, pos + m.index + m[0].length, m);
-       }
-   }
-   function matchRanges(view, maxLength) {
-       let visible = view.visibleRanges;
-       if (visible.length == 1 && visible[0].from == view.viewport.from &&
-           visible[0].to == view.viewport.to)
-           return visible;
-       let result = [];
-       for (let { from, to } of visible) {
-           from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);
-           to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);
-           if (result.length && result[result.length - 1].to >= from)
-               result[result.length - 1].to = to;
-           else
-               result.push({ from, to });
-       }
-       return result;
-   }
-   /**
-   Helper class used to make it easier to maintain decorations on
-   visible code that matches a given regular expression. To be used
-   in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
-   represent a matching configuration.
-   */
-   class MatchDecorator {
-       /**
-       Create a decorator.
-       */
-       constructor(config) {
-           let { regexp, decoration, boundary, maxLength = 1000 } = config;
-           if (!regexp.global)
-               throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
-           this.regexp = regexp;
-           this.getDeco = typeof decoration == "function" ? decoration : () => decoration;
-           this.boundary = boundary;
-           this.maxLength = maxLength;
-       }
-       /**
-       Compute the full set of decorations for matches in the given
-       view's viewport. You'll want to call this when initializing your
-       plugin.
-       */
-       createDeco(view) {
-           let build = new RangeSetBuilder$3();
-           for (let { from, to } of matchRanges(view, this.maxLength))
-               iterMatches(view.state.doc, this.regexp, from, to, (a, b, m) => build.add(a, b, this.getDeco(m, view, a)));
-           return build.finish();
-       }
-       /**
-       Update a set of decorations for a view update. `deco` _must_ be
-       the set of decorations produced by _this_ `MatchDecorator` for
-       the view state before the update.
-       */
-       updateDeco(update, deco) {
-           let changeFrom = 1e9, changeTo = -1;
-           if (update.docChanged)
-               update.changes.iterChanges((_f, _t, from, to) => {
-                   if (to > update.view.viewport.from && from < update.view.viewport.to) {
-                       changeFrom = Math.min(from, changeFrom);
-                       changeTo = Math.max(to, changeTo);
-                   }
-               });
-           if (update.viewportChanged || changeTo - changeFrom > 1000)
-               return this.createDeco(update.view);
-           if (changeTo > -1)
-               return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);
-           return deco;
-       }
-       updateRange(view, deco, updateFrom, updateTo) {
-           for (let r of view.visibleRanges) {
-               let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);
-               if (to > from) {
-                   let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;
-                   let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);
-                   if (this.boundary) {
-                       for (; from > fromLine.from; from--)
-                           if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {
-                               start = from;
-                               break;
-                           }
-                       for (; to < toLine.to; to++)
-                           if (this.boundary.test(toLine.text[to - toLine.from])) {
-                               end = to;
-                               break;
-                           }
-                   }
-                   let ranges = [], m;
-                   if (fromLine == toLine) {
-                       this.regexp.lastIndex = start - fromLine.from;
-                       while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from) {
-                           let pos = m.index + fromLine.from;
-                           ranges.push(this.getDeco(m, view, pos).range(pos, pos + m[0].length));
-                       }
-                   }
-                   else {
-                       iterMatches(view.state.doc, this.regexp, start, end, (from, to, m) => ranges.push(this.getDeco(m, view, from).range(from, to)));
-                   }
-                   deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });
-               }
-           }
-           return deco;
-       }
-   }
-
-   const UnicodeRegexpSupport = /x/.unicode != null ? "gu" : "g";
-   const Specials = /*@__PURE__*/new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\ufeff\ufff9-\ufffc]", UnicodeRegexpSupport);
-   const Names = {
-       0: "null",
-       7: "bell",
-       8: "backspace",
-       10: "newline",
-       11: "vertical tab",
-       13: "carriage return",
-       27: "escape",
-       8203: "zero width space",
-       8204: "zero width non-joiner",
-       8205: "zero width joiner",
-       8206: "left-to-right mark",
-       8207: "right-to-left mark",
-       8232: "line separator",
-       8237: "left-to-right override",
-       8238: "right-to-left override",
-       8233: "paragraph separator",
-       65279: "zero width no-break space",
-       65532: "object replacement"
-   };
-   let _supportsTabSize = null;
-   function supportsTabSize() {
-       var _a;
-       if (_supportsTabSize == null && typeof document != "undefined" && document.body) {
-           let styles = document.body.style;
-           _supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;
-       }
-       return _supportsTabSize || false;
-   }
-   const specialCharConfig = /*@__PURE__*/Facet$3.define({
-       combine(configs) {
-           let config = combineConfig$3(configs, {
-               render: null,
-               specialChars: Specials,
-               addSpecialChars: null
-           });
-           if (config.replaceTabs = !supportsTabSize())
-               config.specialChars = new RegExp("\t|" + config.specialChars.source, UnicodeRegexpSupport);
-           if (config.addSpecialChars)
-               config.specialChars = new RegExp(config.specialChars.source + "|" + config.addSpecialChars.source, UnicodeRegexpSupport);
-           return config;
-       }
-   });
-   /**
-   Returns an extension that installs highlighting of special
-   characters.
-   */
-   function highlightSpecialChars(
-   /**
-   Configuration options.
-   */
-   config = {}) {
-       return [specialCharConfig.of(config), specialCharPlugin()];
-   }
-   let _plugin = null;
-   function specialCharPlugin() {
-       return _plugin || (_plugin = ViewPlugin$3.fromClass(class {
-           constructor(view) {
-               this.view = view;
-               this.decorations = Decoration$3.none;
-               this.decorationCache = Object.create(null);
-               this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));
-               this.decorations = this.decorator.createDeco(view);
-           }
-           makeDecorator(conf) {
-               return new MatchDecorator({
-                   regexp: conf.specialChars,
-                   decoration: (m, view, pos) => {
-                       let { doc } = view.state;
-                       let code = codePointAt$4(m[0], 0);
-                       if (code == 9) {
-                           let line = doc.lineAt(pos);
-                           let size = view.state.tabSize, col = countColumn$1(line.text, size, pos - line.from);
-                           return Decoration$3.replace({ widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth) });
-                       }
-                       return this.decorationCache[code] ||
-                           (this.decorationCache[code] = Decoration$3.replace({ widget: new SpecialCharWidget(conf, code) }));
-                   },
-                   boundary: conf.replaceTabs ? undefined : /[^]/
-               });
-           }
-           update(update) {
-               let conf = update.state.facet(specialCharConfig);
-               if (update.startState.facet(specialCharConfig) != conf) {
-                   this.decorator = this.makeDecorator(conf);
-                   this.decorations = this.decorator.createDeco(update.view);
-               }
-               else {
-                   this.decorations = this.decorator.updateDeco(update, this.decorations);
-               }
-           }
-       }, {
-           decorations: v => v.decorations
-       }));
-   }
-   const DefaultPlaceholder = "\u2022";
-   // Assigns placeholder characters from the Control Pictures block to
-   // ASCII control characters
-   function placeholder$1(code) {
-       if (code >= 32)
-           return DefaultPlaceholder;
-       if (code == 10)
-           return "\u2424";
-       return String.fromCharCode(9216 + code);
-   }
-   class SpecialCharWidget extends WidgetType$3 {
-       constructor(options, code) {
-           super();
-           this.options = options;
-           this.code = code;
-       }
-       eq(other) { return other.code == this.code; }
-       toDOM(view) {
-           let ph = placeholder$1(this.code);
-           let desc = view.state.phrase("Control character") + " " + (Names[this.code] || "0x" + this.code.toString(16));
-           let custom = this.options.render && this.options.render(this.code, desc, ph);
-           if (custom)
-               return custom;
-           let span = document.createElement("span");
-           span.textContent = ph;
-           span.title = desc;
-           span.setAttribute("aria-label", desc);
-           span.className = "cm-specialChar";
-           return span;
-       }
-       ignoreEvent() { return false; }
-   }
-   class TabWidget extends WidgetType$3 {
-       constructor(width) {
-           super();
-           this.width = width;
-       }
-       eq(other) { return other.width == this.width; }
-       toDOM() {
-           let span = document.createElement("span");
-           span.textContent = "\t";
-           span.className = "cm-tab";
-           span.style.width = this.width + "px";
-           return span;
-       }
-       ignoreEvent() { return false; }
-   }
-
-   /**
-   Mark lines that have a cursor on them with the `"cm-activeLine"`
-   DOM class.
-   */
-   function highlightActiveLine() {
-       return activeLineHighlighter;
-   }
-   const lineDeco = /*@__PURE__*/Decoration$3.line({ class: "cm-activeLine" });
-   const activeLineHighlighter = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           this.decorations = this.getDeco(view);
-       }
-       update(update) {
-           if (update.docChanged || update.selectionSet)
-               this.decorations = this.getDeco(update.view);
-       }
-       getDeco(view) {
-           let lastLineStart = -1, deco = [];
-           for (let r of view.state.selection.ranges) {
-               if (!r.empty)
-                   return Decoration$3.none;
-               let line = view.lineBlockAt(r.head);
-               if (line.from > lastLineStart) {
-                   deco.push(lineDeco.range(line.from));
-                   lastLineStart = line.from;
-               }
-           }
-           return Decoration$3.set(deco);
-       }
-   }, {
-       decorations: v => v.decorations
-   });
-
-   // Don't compute precise column positions for line offsets above this
-   // (since it could get expensive). Assume offset==column for them.
-   const MaxOff = 2000;
-   function rectangleFor(state, a, b) {
-       let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);
-       let ranges = [];
-       if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {
-           let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);
-           for (let i = startLine; i <= endLine; i++) {
-               let line = state.doc.line(i);
-               if (line.length <= endOff)
-                   ranges.push(EditorSelection$3.range(line.from + startOff, line.to + endOff));
-           }
-       }
-       else {
-           let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);
-           for (let i = startLine; i <= endLine; i++) {
-               let line = state.doc.line(i);
-               let start = findColumn$3(line.text, startCol, state.tabSize, true);
-               if (start > -1) {
-                   let end = findColumn$3(line.text, endCol, state.tabSize);
-                   ranges.push(EditorSelection$3.range(line.from + start, line.from + end));
-               }
-           }
-       }
-       return ranges;
-   }
-   function absoluteColumn(view, x) {
-       let ref = view.coordsAtPos(view.viewport.from);
-       return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;
-   }
-   function getPos(view, event) {
-       let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       let line = view.state.doc.lineAt(offset), off = offset - line.from;
-       let col = off > MaxOff ? -1
-           : off == line.length ? absoluteColumn(view, event.clientX)
-               : countColumn$1(line.text, view.state.tabSize, offset - line.from);
-       return { line: line.number, col, off };
-   }
-   function rectangleSelectionStyle(view, event) {
-       let start = getPos(view, event), startSel = view.state.selection;
-       if (!start)
-           return null;
-       return {
-           update(update) {
-               if (update.docChanged) {
-                   let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);
-                   let newLine = update.state.doc.lineAt(newStart);
-                   start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };
-                   startSel = startSel.map(update.changes);
-               }
-           },
-           get(event, _extend, multiple) {
-               let cur = getPos(view, event);
-               if (!cur)
-                   return startSel;
-               let ranges = rectangleFor(view.state, start, cur);
-               if (!ranges.length)
-                   return startSel;
-               if (multiple)
-                   return EditorSelection$3.create(ranges.concat(startSel.ranges));
-               else
-                   return EditorSelection$3.create(ranges);
-           }
-       };
-   }
-   /**
-   Create an extension that enables rectangular selections. By
-   default, it will react to left mouse drag with the Alt key held
-   down. When such a selection occurs, the text within the rectangle
-   that was dragged over will be selected, as one selection
-   [range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.
-   */
-   function rectangularSelection(options) {
-       let filter = (e => e.altKey && e.button == 0);
-       return EditorView$3.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
-   }
-   const keys = {
-       Alt: [18, e => e.altKey],
-       Control: [17, e => e.ctrlKey],
-       Shift: [16, e => e.shiftKey],
-       Meta: [91, e => e.metaKey]
-   };
-   const showCrosshair = { style: "cursor: crosshair" };
-   /**
-   Returns an extension that turns the pointer cursor into a
-   crosshair when a given modifier key, defaulting to Alt, is held
-   down. Can serve as a visual hint that rectangular selection is
-   going to happen when paired with
-   [`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).
-   */
-   function crosshairCursor(options = {}) {
-       let [code, getter] = keys[options.key || "Alt"];
-       let plugin = ViewPlugin$3.fromClass(class {
-           constructor(view) {
-               this.view = view;
-               this.isDown = false;
-           }
-           set(isDown) {
-               if (this.isDown != isDown) {
-                   this.isDown = isDown;
-                   this.view.update([]);
-               }
-           }
-       }, {
-           eventHandlers: {
-               keydown(e) {
-                   this.set(e.keyCode == code || getter(e));
-               },
-               keyup(e) {
-                   if (e.keyCode == code || !getter(e))
-                       this.set(false);
-               }
-           }
-       });
-       return [
-           plugin,
-           EditorView$3.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })
-       ];
-   }
-
-   const Outside$1 = "-10000px";
-   let TooltipViewManager$1 = class TooltipViewManager {
-       constructor(view, facet, createTooltipView) {
-           this.facet = facet;
-           this.createTooltipView = createTooltipView;
-           this.input = view.state.facet(facet);
-           this.tooltips = this.input.filter(t => t);
-           this.tooltipViews = this.tooltips.map(createTooltipView);
-       }
-       update(update) {
-           let input = update.state.facet(this.facet);
-           let tooltips = input.filter(x => x);
-           if (input === this.input) {
-               for (let t of this.tooltipViews)
-                   if (t.update)
-                       t.update(update);
-               return false;
-           }
-           let tooltipViews = [];
-           for (let i = 0; i < tooltips.length; i++) {
-               let tip = tooltips[i], known = -1;
-               if (!tip)
-                   continue;
-               for (let i = 0; i < this.tooltips.length; i++) {
-                   let other = this.tooltips[i];
-                   if (other && other.create == tip.create)
-                       known = i;
-               }
-               if (known < 0) {
-                   tooltipViews[i] = this.createTooltipView(tip);
-               }
-               else {
-                   let tooltipView = tooltipViews[i] = this.tooltipViews[known];
-                   if (tooltipView.update)
-                       tooltipView.update(update);
-               }
-           }
-           for (let t of this.tooltipViews)
-               if (tooltipViews.indexOf(t) < 0)
-                   t.dom.remove();
-           this.input = input;
-           this.tooltips = tooltips;
-           this.tooltipViews = tooltipViews;
-           return true;
-       }
-   };
-   function windowSpace$1() {
-       return { top: 0, left: 0, bottom: innerHeight, right: innerWidth };
-   }
-   const tooltipConfig$1 = /*@__PURE__*/Facet$3.define({
-       combine: values => {
-           var _a, _b, _c;
-           return ({
-               position: browser$3.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
-               parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
-               tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace$1,
-           });
-       }
-   });
-   const tooltipPlugin$1 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           var _a;
-           this.view = view;
-           this.inView = true;
-           this.lastTransaction = 0;
-           this.measureTimeout = -1;
-           let config = view.state.facet(tooltipConfig$1);
-           this.position = config.position;
-           this.parent = config.parent;
-           this.classes = view.themeClasses;
-           this.createContainer();
-           this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
-           this.manager = new TooltipViewManager$1(view, showTooltip$1, t => this.createTooltip(t));
-           this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
-               if (Date.now() > this.lastTransaction - 50 &&
-                   entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
-                   this.measureSoon();
-           }, { threshold: [1] }) : null;
-           this.observeIntersection();
-           (_a = view.dom.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
-           this.maybeMeasure();
-       }
-       createContainer() {
-           if (this.parent) {
-               this.container = document.createElement("div");
-               this.container.style.position = "relative";
-               this.container.className = this.view.themeClasses;
-               this.parent.appendChild(this.container);
-           }
-           else {
-               this.container = this.view.dom;
-           }
-       }
-       observeIntersection() {
-           if (this.intersectionObserver) {
-               this.intersectionObserver.disconnect();
-               for (let tooltip of this.manager.tooltipViews)
-                   this.intersectionObserver.observe(tooltip.dom);
-           }
-       }
-       measureSoon() {
-           if (this.measureTimeout < 0)
-               this.measureTimeout = setTimeout(() => {
-                   this.measureTimeout = -1;
-                   this.maybeMeasure();
-               }, 50);
-       }
-       update(update) {
-           if (update.transactions.length)
-               this.lastTransaction = Date.now();
-           let updated = this.manager.update(update);
-           if (updated)
-               this.observeIntersection();
-           let shouldMeasure = updated || update.geometryChanged;
-           let newConfig = update.state.facet(tooltipConfig$1);
-           if (newConfig.position != this.position) {
-               this.position = newConfig.position;
-               for (let t of this.manager.tooltipViews)
-                   t.dom.style.position = this.position;
-               shouldMeasure = true;
-           }
-           if (newConfig.parent != this.parent) {
-               if (this.parent)
-                   this.container.remove();
-               this.parent = newConfig.parent;
-               this.createContainer();
-               for (let t of this.manager.tooltipViews)
-                   this.container.appendChild(t.dom);
-               shouldMeasure = true;
-           }
-           else if (this.parent && this.view.themeClasses != this.classes) {
-               this.classes = this.container.className = this.view.themeClasses;
-           }
-           if (shouldMeasure)
-               this.maybeMeasure();
-       }
-       createTooltip(tooltip) {
-           let tooltipView = tooltip.create(this.view);
-           tooltipView.dom.classList.add("cm-tooltip");
-           if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
-               let arrow = document.createElement("div");
-               arrow.className = "cm-tooltip-arrow";
-               tooltipView.dom.appendChild(arrow);
-           }
-           tooltipView.dom.style.position = this.position;
-           tooltipView.dom.style.top = Outside$1;
-           this.container.appendChild(tooltipView.dom);
-           if (tooltipView.mount)
-               tooltipView.mount(this.view);
-           return tooltipView;
-       }
-       destroy() {
-           var _a, _b;
-           (_a = this.view.dom.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.removeEventListener("resize", this.measureSoon);
-           for (let { dom } of this.manager.tooltipViews)
-               dom.remove();
-           (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
-           clearTimeout(this.measureTimeout);
-       }
-       readMeasure() {
-           let editor = this.view.dom.getBoundingClientRect();
-           return {
-               editor,
-               parent: this.parent ? this.container.getBoundingClientRect() : editor,
-               pos: this.manager.tooltips.map((t, i) => {
-                   let tv = this.manager.tooltipViews[i];
-                   return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
-               }),
-               size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
-               space: this.view.state.facet(tooltipConfig$1).tooltipSpace(this.view),
-           };
-       }
-       writeMeasure(measured) {
-           let { editor, space } = measured;
-           let others = [];
-           for (let i = 0; i < this.manager.tooltips.length; i++) {
-               let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
-               let pos = measured.pos[i], size = measured.size[i];
-               // Hide tooltips that are outside of the editor.
-               if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||
-                   pos.top >= Math.min(editor.bottom, space.bottom) ||
-                   pos.right < Math.max(editor.left, space.left) - .1 ||
-                   pos.left > Math.min(editor.right, space.right) + .1) {
-                   dom.style.top = Outside$1;
-                   continue;
-               }
-               let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
-               let arrowHeight = arrow ? 7 /* Size */ : 0;
-               let width = size.right - size.left, height = size.bottom - size.top;
-               let offset = tView.offset || noOffset$1, ltr = this.view.textDirection == Direction$3.LTR;
-               let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
-                   : ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
-                       : Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
-               let above = !!tooltip.above;
-               if (!tooltip.strictSide && (above
-                   ? pos.top - (size.bottom - size.top) - offset.y < space.top
-                   : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
-                   above == (space.bottom - pos.bottom > pos.top - space.top))
-                   above = !above;
-               let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
-               let right = left + width;
-               if (tView.overlap !== true)
-                   for (let r of others)
-                       if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
-                           top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
-               if (this.position == "absolute") {
-                   dom.style.top = (top - measured.parent.top) + "px";
-                   dom.style.left = (left - measured.parent.left) + "px";
-               }
-               else {
-                   dom.style.top = top + "px";
-                   dom.style.left = left + "px";
-               }
-               if (arrow)
-                   arrow.style.left = `${pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Offset */ - 7 /* Size */)}px`;
-               if (tView.overlap !== true)
-                   others.push({ left, top, right, bottom: top + height });
-               dom.classList.toggle("cm-tooltip-above", above);
-               dom.classList.toggle("cm-tooltip-below", !above);
-               if (tView.positioned)
-                   tView.positioned();
-           }
-       }
-       maybeMeasure() {
-           if (this.manager.tooltips.length) {
-               if (this.view.inView)
-                   this.view.requestMeasure(this.measureReq);
-               if (this.inView != this.view.inView) {
-                   this.inView = this.view.inView;
-                   if (!this.inView)
-                       for (let tv of this.manager.tooltipViews)
-                           tv.dom.style.top = Outside$1;
-               }
-           }
-       }
-   }, {
-       eventHandlers: {
-           scroll() { this.maybeMeasure(); }
-       }
-   });
-   const baseTheme$7 = /*@__PURE__*/EditorView$3.baseTheme({
-       ".cm-tooltip": {
-           zIndex: 100
-       },
-       "&light .cm-tooltip": {
-           border: "1px solid #bbb",
-           backgroundColor: "#f5f5f5"
-       },
-       "&light .cm-tooltip-section:not(:first-child)": {
-           borderTop: "1px solid #bbb",
-       },
-       "&dark .cm-tooltip": {
-           backgroundColor: "#333338",
-           color: "white"
-       },
-       ".cm-tooltip-arrow": {
-           height: `${7 /* Size */}px`,
-           width: `${7 /* Size */ * 2}px`,
-           position: "absolute",
-           zIndex: -1,
-           overflow: "hidden",
-           "&:before, &:after": {
-               content: "''",
-               position: "absolute",
-               width: 0,
-               height: 0,
-               borderLeft: `${7 /* Size */}px solid transparent`,
-               borderRight: `${7 /* Size */}px solid transparent`,
-           },
-           ".cm-tooltip-above &": {
-               bottom: `-${7 /* Size */}px`,
-               "&:before": {
-                   borderTop: `${7 /* Size */}px solid #bbb`,
-               },
-               "&:after": {
-                   borderTop: `${7 /* Size */}px solid #f5f5f5`,
-                   bottom: "1px"
-               }
-           },
-           ".cm-tooltip-below &": {
-               top: `-${7 /* Size */}px`,
-               "&:before": {
-                   borderBottom: `${7 /* Size */}px solid #bbb`,
-               },
-               "&:after": {
-                   borderBottom: `${7 /* Size */}px solid #f5f5f5`,
-                   top: "1px"
-               }
-           },
-       },
-       "&dark .cm-tooltip .cm-tooltip-arrow": {
-           "&:before": {
-               borderTopColor: "#333338",
-               borderBottomColor: "#333338"
-           },
-           "&:after": {
-               borderTopColor: "transparent",
-               borderBottomColor: "transparent"
-           }
-       }
-   });
-   const noOffset$1 = { x: 0, y: 0 };
-   /**
-   Facet to which an extension can add a value to show a tooltip.
-   */
-   const showTooltip$1 = /*@__PURE__*/Facet$3.define({
-       enables: [tooltipPlugin$1, baseTheme$7]
-   });
-   const showHoverTooltip = /*@__PURE__*/Facet$3.define();
-   class HoverTooltipHost {
-       constructor(view) {
-           this.view = view;
-           this.mounted = false;
-           this.dom = document.createElement("div");
-           this.dom.classList.add("cm-tooltip-hover");
-           this.manager = new TooltipViewManager$1(view, showHoverTooltip, t => this.createHostedView(t));
-       }
-       // Needs to be static so that host tooltip instances always match
-       static create(view) {
-           return new HoverTooltipHost(view);
-       }
-       createHostedView(tooltip) {
-           let hostedView = tooltip.create(this.view);
-           hostedView.dom.classList.add("cm-tooltip-section");
-           this.dom.appendChild(hostedView.dom);
-           if (this.mounted && hostedView.mount)
-               hostedView.mount(this.view);
-           return hostedView;
-       }
-       mount(view) {
-           for (let hostedView of this.manager.tooltipViews) {
-               if (hostedView.mount)
-                   hostedView.mount(view);
-           }
-           this.mounted = true;
-       }
-       positioned() {
-           for (let hostedView of this.manager.tooltipViews) {
-               if (hostedView.positioned)
-                   hostedView.positioned();
-           }
-       }
-       update(update) {
-           this.manager.update(update);
-       }
-   }
-   const showHoverTooltipHost = /*@__PURE__*/showTooltip$1.compute([showHoverTooltip], state => {
-       let tooltips = state.facet(showHoverTooltip).filter(t => t);
-       if (tooltips.length === 0)
-           return null;
-       return {
-           pos: Math.min(...tooltips.map(t => t.pos)),
-           end: Math.max(...tooltips.filter(t => t.end != null).map(t => t.end)),
-           create: HoverTooltipHost.create,
-           above: tooltips[0].above,
-           arrow: tooltips.some(t => t.arrow),
-       };
-   });
-   class HoverPlugin {
-       constructor(view, source, field, setHover, hoverTime) {
-           this.view = view;
-           this.source = source;
-           this.field = field;
-           this.setHover = setHover;
-           this.hoverTime = hoverTime;
-           this.hoverTimeout = -1;
-           this.restartTimeout = -1;
-           this.pending = null;
-           this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };
-           this.checkHover = this.checkHover.bind(this);
-           view.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this));
-           view.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
-       }
-       update() {
-           if (this.pending) {
-               this.pending = null;
-               clearTimeout(this.restartTimeout);
-               this.restartTimeout = setTimeout(() => this.startHover(), 20);
-           }
-       }
-       get active() {
-           return this.view.state.field(this.field);
-       }
-       checkHover() {
-           this.hoverTimeout = -1;
-           if (this.active)
-               return;
-           let hovered = Date.now() - this.lastMove.time;
-           if (hovered < this.hoverTime)
-               this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);
-           else
-               this.startHover();
-       }
-       startHover() {
-           clearTimeout(this.restartTimeout);
-           let { lastMove } = this;
-           let pos = this.view.contentDOM.contains(lastMove.target) ? this.view.posAtCoords(lastMove) : null;
-           if (pos == null)
-               return;
-           let posCoords = this.view.coordsAtPos(pos);
-           if (posCoords == null || lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||
-               lastMove.x < posCoords.left - this.view.defaultCharacterWidth ||
-               lastMove.x > posCoords.right + this.view.defaultCharacterWidth)
-               return;
-           let bidi = this.view.bidiSpans(this.view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);
-           let rtl = bidi && bidi.dir == Direction$3.RTL ? -1 : 1;
-           let open = this.source(this.view, pos, (lastMove.x < posCoords.left ? -rtl : rtl));
-           if (open === null || open === void 0 ? void 0 : open.then) {
-               let pending = this.pending = { pos };
-               open.then(result => {
-                   if (this.pending == pending) {
-                       this.pending = null;
-                       if (result)
-                           this.view.dispatch({ effects: this.setHover.of(result) });
-                   }
-               }, e => logException$3(this.view.state, e, "hover tooltip"));
-           }
-           else if (open) {
-               this.view.dispatch({ effects: this.setHover.of(open) });
-           }
-       }
-       mousemove(event) {
-           var _a;
-           this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };
-           if (this.hoverTimeout < 0)
-               this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
-           let tooltip = this.active;
-           if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {
-               let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;
-               if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
-                   : !isOverRange(this.view, pos, end, event.clientX, event.clientY, 6 /* MaxDist */))) {
-                   this.view.dispatch({ effects: this.setHover.of(null) });
-                   this.pending = null;
-               }
-           }
-       }
-       mouseleave() {
-           clearTimeout(this.hoverTimeout);
-           this.hoverTimeout = -1;
-           if (this.active)
-               this.view.dispatch({ effects: this.setHover.of(null) });
-       }
-       destroy() {
-           clearTimeout(this.hoverTimeout);
-           this.view.dom.removeEventListener("mouseleave", this.mouseleave);
-           this.view.dom.removeEventListener("mousemove", this.mousemove);
-       }
-   }
-   function isInTooltip(elt) {
-       for (let cur = elt; cur; cur = cur.parentNode)
-           if (cur.nodeType == 1 && cur.classList.contains("cm-tooltip"))
-               return true;
-       return false;
-   }
-   function isOverRange(view, from, to, x, y, margin) {
-       let range = document.createRange();
-       let fromDOM = view.domAtPos(from), toDOM = view.domAtPos(to);
-       range.setEnd(toDOM.node, toDOM.offset);
-       range.setStart(fromDOM.node, fromDOM.offset);
-       let rects = range.getClientRects();
-       range.detach();
-       for (let i = 0; i < rects.length; i++) {
-           let rect = rects[i];
-           let dist = Math.max(rect.top - y, y - rect.bottom, rect.left - x, x - rect.right);
-           if (dist <= margin)
-               return true;
-       }
-       return false;
-   }
-   /**
-   Set up a hover tooltip, which shows up when the pointer hovers
-   over ranges of text. The callback is called when the mouse hovers
-   over the document text. It should, if there is a tooltip
-   associated with position `pos`, return the tooltip description
-   (either directly or in a promise). The `side` argument indicates
-   on which side of the position the pointer is—it will be -1 if the
-   pointer is before the position, 1 if after the position.
-
-   Note that all hover tooltips are hosted within a single tooltip
-   container element. This allows multiple tooltips over the same
-   range to be "merged" together without overlapping.
-   */
-   function hoverTooltip(source, options = {}) {
-       let setHover = StateEffect$3.define();
-       let hoverState = StateField$3.define({
-           create() { return null; },
-           update(value, tr) {
-               if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
-                   options.hideOn && options.hideOn(tr, value)))
-                   return null;
-               if (value && tr.docChanged) {
-                   let newPos = tr.changes.mapPos(value.pos, -1, MapMode$3.TrackDel);
-                   if (newPos == null)
-                       return null;
-                   let copy = Object.assign(Object.create(null), value);
-                   copy.pos = newPos;
-                   if (value.end != null)
-                       copy.end = tr.changes.mapPos(value.end);
-                   value = copy;
-               }
-               for (let effect of tr.effects) {
-                   if (effect.is(setHover))
-                       value = effect.value;
-                   if (effect.is(closeHoverTooltipEffect))
-                       value = null;
-               }
-               return value;
-           },
-           provide: f => showHoverTooltip.from(f)
-       });
-       return [
-           hoverState,
-           ViewPlugin$3.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Time */)),
-           showHoverTooltipHost
-       ];
-   }
-   /**
-   Get the active tooltip view for a given tooltip, if available.
-   */
-   function getTooltip$1(view, tooltip) {
-       let plugin = view.plugin(tooltipPlugin$1);
-       if (!plugin)
-           return null;
-       let found = plugin.manager.tooltips.indexOf(tooltip);
-       return found < 0 ? null : plugin.manager.tooltipViews[found];
-   }
-   const closeHoverTooltipEffect = /*@__PURE__*/StateEffect$3.define();
-
-   const panelConfig$2 = /*@__PURE__*/Facet$3.define({
-       combine(configs) {
-           let topContainer, bottomContainer;
-           for (let c of configs) {
-               topContainer = topContainer || c.topContainer;
-               bottomContainer = bottomContainer || c.bottomContainer;
-           }
-           return { topContainer, bottomContainer };
-       }
-   });
-   /**
-   Get the active panel created by the given constructor, if any.
-   This can be useful when you need access to your panels' DOM
-   structure.
-   */
-   function getPanel$1(view, panel) {
-       let plugin = view.plugin(panelPlugin$2);
-       let index = plugin ? plugin.specs.indexOf(panel) : -1;
-       return index > -1 ? plugin.panels[index] : null;
-   }
-   const panelPlugin$2 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           this.input = view.state.facet(showPanel$2);
-           this.specs = this.input.filter(s => s);
-           this.panels = this.specs.map(spec => spec(view));
-           let conf = view.state.facet(panelConfig$2);
-           this.top = new PanelGroup$2(view, true, conf.topContainer);
-           this.bottom = new PanelGroup$2(view, false, conf.bottomContainer);
-           this.top.sync(this.panels.filter(p => p.top));
-           this.bottom.sync(this.panels.filter(p => !p.top));
-           for (let p of this.panels) {
-               p.dom.classList.add("cm-panel");
-               if (p.mount)
-                   p.mount();
-           }
-       }
-       update(update) {
-           let conf = update.state.facet(panelConfig$2);
-           if (this.top.container != conf.topContainer) {
-               this.top.sync([]);
-               this.top = new PanelGroup$2(update.view, true, conf.topContainer);
-           }
-           if (this.bottom.container != conf.bottomContainer) {
-               this.bottom.sync([]);
-               this.bottom = new PanelGroup$2(update.view, false, conf.bottomContainer);
-           }
-           this.top.syncClasses();
-           this.bottom.syncClasses();
-           let input = update.state.facet(showPanel$2);
-           if (input != this.input) {
-               let specs = input.filter(x => x);
-               let panels = [], top = [], bottom = [], mount = [];
-               for (let spec of specs) {
-                   let known = this.specs.indexOf(spec), panel;
-                   if (known < 0) {
-                       panel = spec(update.view);
-                       mount.push(panel);
-                   }
-                   else {
-                       panel = this.panels[known];
-                       if (panel.update)
-                           panel.update(update);
-                   }
-                   panels.push(panel);
-                   (panel.top ? top : bottom).push(panel);
-               }
-               this.specs = specs;
-               this.panels = panels;
-               this.top.sync(top);
-               this.bottom.sync(bottom);
-               for (let p of mount) {
-                   p.dom.classList.add("cm-panel");
-                   if (p.mount)
-                       p.mount();
-               }
-           }
-           else {
-               for (let p of this.panels)
-                   if (p.update)
-                       p.update(update);
-           }
-       }
-       destroy() {
-           this.top.sync([]);
-           this.bottom.sync([]);
-       }
-   }, {
-       provide: plugin => EditorView$3.scrollMargins.of(view => {
-           let value = view.plugin(plugin);
-           return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
-       })
-   });
-   let PanelGroup$2 = class PanelGroup {
-       constructor(view, top, container) {
-           this.view = view;
-           this.top = top;
-           this.container = container;
-           this.dom = undefined;
-           this.classes = "";
-           this.panels = [];
-           this.syncClasses();
-       }
-       sync(panels) {
-           for (let p of this.panels)
-               if (p.destroy && panels.indexOf(p) < 0)
-                   p.destroy();
-           this.panels = panels;
-           this.syncDOM();
-       }
-       syncDOM() {
-           if (this.panels.length == 0) {
-               if (this.dom) {
-                   this.dom.remove();
-                   this.dom = undefined;
-               }
-               return;
-           }
-           if (!this.dom) {
-               this.dom = document.createElement("div");
-               this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
-               this.dom.style[this.top ? "top" : "bottom"] = "0";
-               let parent = this.container || this.view.dom;
-               parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
-           }
-           let curDOM = this.dom.firstChild;
-           for (let panel of this.panels) {
-               if (panel.dom.parentNode == this.dom) {
-                   while (curDOM != panel.dom)
-                       curDOM = rm$3(curDOM);
-                   curDOM = curDOM.nextSibling;
-               }
-               else {
-                   this.dom.insertBefore(panel.dom, curDOM);
-               }
-           }
-           while (curDOM)
-               curDOM = rm$3(curDOM);
-       }
-       scrollMargin() {
-           return !this.dom || this.container ? 0
-               : Math.max(0, this.top ?
-                   this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
-                   Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
-       }
-       syncClasses() {
-           if (!this.container || this.classes == this.view.themeClasses)
-               return;
-           for (let cls of this.classes.split(" "))
-               if (cls)
-                   this.container.classList.remove(cls);
-           for (let cls of (this.classes = this.view.themeClasses).split(" "))
-               if (cls)
-                   this.container.classList.add(cls);
-       }
-   };
-   function rm$3(node) {
-       let next = node.nextSibling;
-       node.remove();
-       return next;
-   }
-   /**
-   Opening a panel is done by providing a constructor function for
-   the panel through this facet. (The panel is closed again when its
-   constructor is no longer provided.) Values of `null` are ignored.
-   */
-   const showPanel$2 = /*@__PURE__*/Facet$3.define({
-       enables: panelPlugin$2
-   });
-
-   /**
-   A gutter marker represents a bit of information attached to a line
-   in a specific gutter. Your own custom markers have to extend this
-   class.
-   */
-   let GutterMarker$3 = class GutterMarker extends RangeValue$3 {
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       Compare this marker to another marker of the same type.
-       */
-       eq(other) { return false; }
-       /**
-       Called if the marker has a `toDOM` method and its representation
-       was removed from a gutter.
-       */
-       destroy(dom) { }
-   };
-   GutterMarker$3.prototype.elementClass = "";
-   GutterMarker$3.prototype.toDOM = undefined;
-   GutterMarker$3.prototype.mapMode = MapMode$3.TrackBefore;
-   GutterMarker$3.prototype.startSide = GutterMarker$3.prototype.endSide = -1;
-   GutterMarker$3.prototype.point = true;
-   /**
-   Facet used to add a class to all gutter elements for a given line.
-   Markers given to this facet should _only_ define an
-   [`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a
-   [`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear
-   in all gutters for the line).
-   */
-   const gutterLineClass$1 = /*@__PURE__*/Facet$3.define();
-   const defaults$2 = {
-       class: "",
-       renderEmptyElements: false,
-       elementStyle: "",
-       markers: () => RangeSet$3.empty,
-       lineMarker: () => null,
-       lineMarkerChange: null,
-       initialSpacer: null,
-       updateSpacer: null,
-       domEventHandlers: {}
-   };
-   const activeGutters$1 = /*@__PURE__*/Facet$3.define();
-   /**
-   Define an editor gutter. The order in which the gutters appear is
-   determined by their extension priority.
-   */
-   function gutter$1(config) {
-       return [gutters$1(), activeGutters$1.of(Object.assign(Object.assign({}, defaults$2), config))];
-   }
-   const unfixGutters$1 = /*@__PURE__*/Facet$3.define({
-       combine: values => values.some(x => x)
-   });
-   /**
-   The gutter-drawing plugin is automatically enabled when you add a
-   gutter, but you can use this function to explicitly configure it.
-
-   Unless `fixed` is explicitly set to `false`, the gutters are
-   fixed, meaning they don't scroll along with the content
-   horizontally (except on Internet Explorer, which doesn't support
-   CSS [`position:
-   sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
-   */
-   function gutters$1(config) {
-       let result = [
-           gutterView$1,
-       ];
-       return result;
-   }
-   const gutterView$1 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.prevViewport = view.viewport;
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-gutters";
-           this.dom.setAttribute("aria-hidden", "true");
-           this.dom.style.minHeight = this.view.contentHeight + "px";
-           this.gutters = view.state.facet(activeGutters$1).map(conf => new SingleGutterView$1(view, conf));
-           for (let gutter of this.gutters)
-               this.dom.appendChild(gutter.dom);
-           this.fixed = !view.state.facet(unfixGutters$1);
-           if (this.fixed) {
-               // FIXME IE11 fallback, which doesn't support position: sticky,
-               // by using position: relative + event handlers that realign the
-               // gutter (or just force fixed=false on IE11?)
-               this.dom.style.position = "sticky";
-           }
-           this.syncGutters(false);
-           view.scrollDOM.insertBefore(this.dom, view.contentDOM);
-       }
-       update(update) {
-           if (this.updateGutters(update)) {
-               // Detach during sync when the viewport changed significantly
-               // (such as during scrolling), since for large updates that is
-               // faster.
-               let vpA = this.prevViewport, vpB = update.view.viewport;
-               let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);
-               this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);
-           }
-           if (update.geometryChanged)
-               this.dom.style.minHeight = this.view.contentHeight + "px";
-           if (this.view.state.facet(unfixGutters$1) != !this.fixed) {
-               this.fixed = !this.fixed;
-               this.dom.style.position = this.fixed ? "sticky" : "";
-           }
-           this.prevViewport = update.view.viewport;
-       }
-       syncGutters(detach) {
-           let after = this.dom.nextSibling;
-           if (detach)
-               this.dom.remove();
-           let lineClasses = RangeSet$3.iter(this.view.state.facet(gutterLineClass$1), this.view.viewport.from);
-           let classSet = [];
-           let contexts = this.gutters.map(gutter => new UpdateContext$1(gutter, this.view.viewport, -this.view.documentPadding.top));
-           for (let line of this.view.viewportLineBlocks) {
-               let text;
-               if (Array.isArray(line.type)) {
-                   for (let b of line.type)
-                       if (b.type == BlockType$3.Text) {
-                           text = b;
-                           break;
-                       }
-               }
-               else {
-                   text = line.type == BlockType$3.Text ? line : undefined;
-               }
-               if (!text)
-                   continue;
-               if (classSet.length)
-                   classSet = [];
-               advanceCursor$1(lineClasses, classSet, line.from);
-               for (let cx of contexts)
-                   cx.line(this.view, text, classSet);
-           }
-           for (let cx of contexts)
-               cx.finish();
-           if (detach)
-               this.view.scrollDOM.insertBefore(this.dom, after);
-       }
-       updateGutters(update) {
-           let prev = update.startState.facet(activeGutters$1), cur = update.state.facet(activeGutters$1);
-           let change = update.docChanged || update.heightChanged || update.viewportChanged ||
-               !RangeSet$3.eq(update.startState.facet(gutterLineClass$1), update.state.facet(gutterLineClass$1), update.view.viewport.from, update.view.viewport.to);
-           if (prev == cur) {
-               for (let gutter of this.gutters)
-                   if (gutter.update(update))
-                       change = true;
-           }
-           else {
-               change = true;
-               let gutters = [];
-               for (let conf of cur) {
-                   let known = prev.indexOf(conf);
-                   if (known < 0) {
-                       gutters.push(new SingleGutterView$1(this.view, conf));
-                   }
-                   else {
-                       this.gutters[known].update(update);
-                       gutters.push(this.gutters[known]);
-                   }
-               }
-               for (let g of this.gutters) {
-                   g.dom.remove();
-                   if (gutters.indexOf(g) < 0)
-                       g.destroy();
-               }
-               for (let g of gutters)
-                   this.dom.appendChild(g.dom);
-               this.gutters = gutters;
-           }
-           return change;
-       }
-       destroy() {
-           for (let view of this.gutters)
-               view.destroy();
-           this.dom.remove();
-       }
-   }, {
-       provide: plugin => EditorView$3.scrollMargins.of(view => {
-           let value = view.plugin(plugin);
-           if (!value || value.gutters.length == 0 || !value.fixed)
-               return null;
-           return view.textDirection == Direction$3.LTR ? { left: value.dom.offsetWidth } : { right: value.dom.offsetWidth };
-       })
-   });
-   function asArray$4(val) { return (Array.isArray(val) ? val : [val]); }
-   function advanceCursor$1(cursor, collect, pos) {
-       while (cursor.value && cursor.from <= pos) {
-           if (cursor.from == pos)
-               collect.push(cursor.value);
-           cursor.next();
-       }
-   }
-   let UpdateContext$1 = class UpdateContext {
-       constructor(gutter, viewport, height) {
-           this.gutter = gutter;
-           this.height = height;
-           this.localMarkers = [];
-           this.i = 0;
-           this.cursor = RangeSet$3.iter(gutter.markers, viewport.from);
-       }
-       line(view, line, extraMarkers) {
-           if (this.localMarkers.length)
-               this.localMarkers = [];
-           advanceCursor$1(this.cursor, this.localMarkers, line.from);
-           let localMarkers = extraMarkers.length ? this.localMarkers.concat(extraMarkers) : this.localMarkers;
-           let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
-           if (forLine)
-               localMarkers.unshift(forLine);
-           let gutter = this.gutter;
-           if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
-               return;
-           let above = line.top - this.height;
-           if (this.i == gutter.elements.length) {
-               let newElt = new GutterElement$1(view, line.height, above, localMarkers);
-               gutter.elements.push(newElt);
-               gutter.dom.appendChild(newElt.dom);
-           }
-           else {
-               gutter.elements[this.i].update(view, line.height, above, localMarkers);
-           }
-           this.height = line.bottom;
-           this.i++;
-       }
-       finish() {
-           let gutter = this.gutter;
-           while (gutter.elements.length > this.i) {
-               let last = gutter.elements.pop();
-               gutter.dom.removeChild(last.dom);
-               last.destroy();
-           }
-       }
-   };
-   let SingleGutterView$1 = class SingleGutterView {
-       constructor(view, config) {
-           this.view = view;
-           this.config = config;
-           this.elements = [];
-           this.spacer = null;
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
-           for (let prop in config.domEventHandlers) {
-               this.dom.addEventListener(prop, (event) => {
-                   let line = view.lineBlockAtHeight(event.clientY - view.documentTop);
-                   if (config.domEventHandlers[prop](view, line, event))
-                       event.preventDefault();
-               });
-           }
-           this.markers = asArray$4(config.markers(view));
-           if (config.initialSpacer) {
-               this.spacer = new GutterElement$1(view, 0, 0, [config.initialSpacer(view)]);
-               this.dom.appendChild(this.spacer.dom);
-               this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none";
-           }
-       }
-       update(update) {
-           let prevMarkers = this.markers;
-           this.markers = asArray$4(this.config.markers(update.view));
-           if (this.spacer && this.config.updateSpacer) {
-               let updated = this.config.updateSpacer(this.spacer.markers[0], update);
-               if (updated != this.spacer.markers[0])
-                   this.spacer.update(update.view, 0, 0, [updated]);
-           }
-           let vp = update.view.viewport;
-           return !RangeSet$3.eq(this.markers, prevMarkers, vp.from, vp.to) ||
-               (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);
-       }
-       destroy() {
-           for (let elt of this.elements)
-               elt.destroy();
-       }
-   };
-   let GutterElement$1 = class GutterElement {
-       constructor(view, height, above, markers) {
-           this.height = -1;
-           this.above = 0;
-           this.markers = [];
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-gutterElement";
-           this.update(view, height, above, markers);
-       }
-       update(view, height, above, markers) {
-           if (this.height != height)
-               this.dom.style.height = (this.height = height) + "px";
-           if (this.above != above)
-               this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
-           if (!sameMarkers$1(this.markers, markers))
-               this.setMarkers(view, markers);
-       }
-       setMarkers(view, markers) {
-           let cls = "cm-gutterElement", domPos = this.dom.firstChild;
-           for (let iNew = 0, iOld = 0;;) {
-               let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;
-               if (marker) {
-                   let c = marker.elementClass;
-                   if (c)
-                       cls += " " + c;
-                   for (let i = iOld; i < this.markers.length; i++)
-                       if (this.markers[i].compare(marker)) {
-                           skipTo = i;
-                           matched = true;
-                           break;
-                       }
-               }
-               else {
-                   skipTo = this.markers.length;
-               }
-               while (iOld < skipTo) {
-                   let next = this.markers[iOld++];
-                   if (next.toDOM) {
-                       next.destroy(domPos);
-                       let after = domPos.nextSibling;
-                       domPos.remove();
-                       domPos = after;
-                   }
-               }
-               if (!marker)
-                   break;
-               if (marker.toDOM) {
-                   if (matched)
-                       domPos = domPos.nextSibling;
-                   else
-                       this.dom.insertBefore(marker.toDOM(view), domPos);
-               }
-               if (matched)
-                   iOld++;
-           }
-           this.dom.className = cls;
-           this.markers = markers;
-       }
-       destroy() {
-           this.setMarkers(null, []); // First argument not used unless creating markers
-       }
-   };
-   function sameMarkers$1(a, b) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (!a[i].compare(b[i]))
-               return false;
-       return true;
-   }
-   /**
-   Facet used to provide markers to the line number gutter.
-   */
-   const lineNumberMarkers$1 = /*@__PURE__*/Facet$3.define();
-   const lineNumberConfig$1 = /*@__PURE__*/Facet$3.define({
-       combine(values) {
-           return combineConfig$3(values, { formatNumber: String, domEventHandlers: {} }, {
-               domEventHandlers(a, b) {
-                   let result = Object.assign({}, a);
-                   for (let event in b) {
-                       let exists = result[event], add = b[event];
-                       result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;
-                   }
-                   return result;
-               }
-           });
-       }
-   });
-   let NumberMarker$1 = class NumberMarker extends GutterMarker$3 {
-       constructor(number) {
-           super();
-           this.number = number;
-       }
-       eq(other) { return this.number == other.number; }
-       toDOM() { return document.createTextNode(this.number); }
-   };
-   function formatNumber$1(view, number) {
-       return view.state.facet(lineNumberConfig$1).formatNumber(number, view.state);
-   }
-   const lineNumberGutter$1 = /*@__PURE__*/activeGutters$1.compute([lineNumberConfig$1], state => ({
-       class: "cm-lineNumbers",
-       renderEmptyElements: false,
-       markers(view) { return view.state.facet(lineNumberMarkers$1); },
-       lineMarker(view, line, others) {
-           if (others.some(m => m.toDOM))
-               return null;
-           return new NumberMarker$1(formatNumber$1(view, view.state.doc.lineAt(line.from).number));
-       },
-       lineMarkerChange: update => update.startState.facet(lineNumberConfig$1) != update.state.facet(lineNumberConfig$1),
-       initialSpacer(view) {
-           return new NumberMarker$1(formatNumber$1(view, maxLineNumber$1(view.state.doc.lines)));
-       },
-       updateSpacer(spacer, update) {
-           let max = formatNumber$1(update.view, maxLineNumber$1(update.view.state.doc.lines));
-           return max == spacer.number ? spacer : new NumberMarker$1(max);
-       },
-       domEventHandlers: state.facet(lineNumberConfig$1).domEventHandlers
-   }));
-   /**
-   Create a line number gutter extension.
-   */
-   function lineNumbers$1(config = {}) {
-       return [
-           lineNumberConfig$1.of(config),
-           gutters$1(),
-           lineNumberGutter$1
-       ];
-   }
-   function maxLineNumber$1(lines) {
-       let last = 9;
-       while (last < lines)
-           last = last * 10 + 9;
-       return last;
-   }
-   const activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker$3 {
-       constructor() {
-           super(...arguments);
-           this.elementClass = "cm-activeLineGutter";
-       }
-   };
-   const activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass$1.compute(["selection"], state => {
-       let marks = [], last = -1;
-       for (let range of state.selection.ranges)
-           if (range.empty) {
-               let linePos = state.doc.lineAt(range.head).from;
-               if (linePos > last) {
-                   last = linePos;
-                   marks.push(activeLineGutterMarker.range(linePos));
-               }
-           }
-       return RangeSet$3.of(marks);
-   });
-   /**
-   Returns an extension that adds a `cm-activeLineGutter` class to
-   all gutter elements on the [active
-   line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
-   */
-   function highlightActiveLineGutter() {
-       return activeLineGutterHighlighter;
-   }
-
-   // FIXME profile adding a per-Tree TreeNode cache, validating it by
-   // parent pointer
-   /// The default maximum length of a `TreeBuffer` node (1024).
-   const DefaultBufferLength$2 = 1024;
-   let nextPropID$2 = 0;
-   let Range$5 = class Range {
-       constructor(from, to) {
-           this.from = from;
-           this.to = to;
-       }
-   };
-   /// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
-   /// can have metadata associated with it in props. Instances of this
-   /// class represent prop names.
-   let NodeProp$2 = class NodeProp {
-       /// Create a new node prop type.
-       constructor(config = {}) {
-           this.id = nextPropID$2++;
-           this.perNode = !!config.perNode;
-           this.deserialize = config.deserialize || (() => {
-               throw new Error("This node type doesn't define a deserialize function");
-           });
-       }
-       /// This is meant to be used with
-       /// [`NodeSet.extend`](#common.NodeSet.extend) or
-       /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
-       /// prop values for each node type in the set. Takes a [match
-       /// object](#common.NodeType^match) or function that returns undefined
-       /// if the node type doesn't get this prop, and the prop's value if
-       /// it does.
-       add(match) {
-           if (this.perNode)
-               throw new RangeError("Can't add per-node props to node types");
-           if (typeof match != "function")
-               match = NodeType$2.match(match);
-           return (type) => {
-               let result = match(type);
-               return result === undefined ? null : [this, result];
-           };
-       }
-   };
-   /// Prop that is used to describe matching delimiters. For opening
-   /// delimiters, this holds an array of node names (written as a
-   /// space-separated string when declaring this prop in a grammar)
-   /// for the node types of closing delimiters that match it.
-   NodeProp$2.closedBy = new NodeProp$2({ deserialize: str => str.split(" ") });
-   /// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
-   /// attached to closing delimiters, holding an array of node names
-   /// of types of matching opening delimiters.
-   NodeProp$2.openedBy = new NodeProp$2({ deserialize: str => str.split(" ") });
-   /// Used to assign node types to groups (for example, all node
-   /// types that represent an expression could be tagged with an
-   /// `"Expression"` group).
-   NodeProp$2.group = new NodeProp$2({ deserialize: str => str.split(" ") });
-   /// The hash of the [context](#lr.ContextTracker.constructor)
-   /// that the node was parsed in, if any. Used to limit reuse of
-   /// contextual nodes.
-   NodeProp$2.contextHash = new NodeProp$2({ perNode: true });
-   /// The distance beyond the end of the node that the tokenizer
-   /// looked ahead for any of the tokens inside the node. (The LR
-   /// parser only stores this when it is larger than 25, for
-   /// efficiency reasons.)
-   NodeProp$2.lookAhead = new NodeProp$2({ perNode: true });
-   /// This per-node prop is used to replace a given node, or part of a
-   /// node, with another tree. This is useful to include trees from
-   /// different languages.
-   NodeProp$2.mounted = new NodeProp$2({ perNode: true });
-   const noProps$2 = Object.create(null);
-   /// Each node in a syntax tree has a node type associated with it.
-   let NodeType$2 = class NodeType {
-       /// @internal
-       constructor(
-       /// The name of the node type. Not necessarily unique, but if the
-       /// grammar was written properly, different node types with the
-       /// same name within a node set should play the same semantic
-       /// role.
-       name, 
-       /// @internal
-       props, 
-       /// The id of this node in its set. Corresponds to the term ids
-       /// used in the parser.
-       id, 
-       /// @internal
-       flags = 0) {
-           this.name = name;
-           this.props = props;
-           this.id = id;
-           this.flags = flags;
-       }
-       static define(spec) {
-           let props = spec.props && spec.props.length ? Object.create(null) : noProps$2;
-           let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
-               (spec.error ? 4 /* Error */ : 0) | (spec.name == null ? 8 /* Anonymous */ : 0);
-           let type = new NodeType(spec.name || "", props, spec.id, flags);
-           if (spec.props)
-               for (let src of spec.props) {
-                   if (!Array.isArray(src))
-                       src = src(type);
-                   if (src) {
-                       if (src[0].perNode)
-                           throw new RangeError("Can't store a per-node prop on a node type");
-                       props[src[0].id] = src[1];
-                   }
-               }
-           return type;
-       }
-       /// Retrieves a node prop for this type. Will return `undefined` if
-       /// the prop isn't present on this node.
-       prop(prop) { return this.props[prop.id]; }
-       /// True when this is the top node of a grammar.
-       get isTop() { return (this.flags & 1 /* Top */) > 0; }
-       /// True when this node is produced by a skip rule.
-       get isSkipped() { return (this.flags & 2 /* Skipped */) > 0; }
-       /// Indicates whether this is an error node.
-       get isError() { return (this.flags & 4 /* Error */) > 0; }
-       /// When true, this node type doesn't correspond to a user-declared
-       /// named node, for example because it is used to cache repetition.
-       get isAnonymous() { return (this.flags & 8 /* Anonymous */) > 0; }
-       /// Returns true when this node's name or one of its
-       /// [groups](#common.NodeProp^group) matches the given string.
-       is(name) {
-           if (typeof name == 'string') {
-               if (this.name == name)
-                   return true;
-               let group = this.prop(NodeProp$2.group);
-               return group ? group.indexOf(name) > -1 : false;
-           }
-           return this.id == name;
-       }
-       /// Create a function from node types to arbitrary values by
-       /// specifying an object whose property names are node or
-       /// [group](#common.NodeProp^group) names. Often useful with
-       /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
-       /// names, separated by spaces, in a single property name to map
-       /// multiple node names to a single value.
-       static match(map) {
-           let direct = Object.create(null);
-           for (let prop in map)
-               for (let name of prop.split(" "))
-                   direct[name] = map[prop];
-           return (node) => {
-               for (let groups = node.prop(NodeProp$2.group), i = -1; i < (groups ? groups.length : 0); i++) {
-                   let found = direct[i < 0 ? node.name : groups[i]];
-                   if (found)
-                       return found;
-               }
-           };
-       }
-   };
-   /// An empty dummy node type to use when no actual type is available.
-   NodeType$2.none = new NodeType$2("", Object.create(null), 0, 8 /* Anonymous */);
-   const CachedNode$2 = new WeakMap(), CachedInnerNode$2 = new WeakMap();
-   /// Options that control iteration. Can be combined with the `|`
-   /// operator to enable multiple ones.
-   var IterMode$2;
-   (function (IterMode) {
-       /// When enabled, iteration will only visit [`Tree`](#common.Tree)
-       /// objects, not nodes packed into
-       /// [`TreeBuffer`](#common.TreeBuffer)s.
-       IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
-       /// Enable this to make iteration include anonymous nodes (such as
-       /// the nodes that wrap repeated grammar constructs into a balanced
-       /// tree).
-       IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
-       /// By default, regular [mounted](#common.NodeProp^mounted) nodes
-       /// replace their base node in iteration. Enable this to ignore them
-       /// instead.
-       IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
-       /// This option only applies in
-       /// [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
-       /// library to not enter mounted overlays if one covers the given
-       /// position.
-       IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
-   })(IterMode$2 || (IterMode$2 = {}));
-   /// A piece of syntax tree. There are two ways to approach these
-   /// trees: the way they are actually stored in memory, and the
-   /// convenient way.
-   ///
-   /// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
-   /// objects. By packing detail information into `TreeBuffer` leaf
-   /// nodes, the representation is made a lot more memory-efficient.
-   ///
-   /// However, when you want to actually work with tree nodes, this
-   /// representation is very awkward, so most client code will want to
-   /// use the [`TreeCursor`](#common.TreeCursor) or
-   /// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
-   /// a view on some part of this data structure, and can be used to
-   /// move around to adjacent nodes.
-   let Tree$2 = class Tree {
-       /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
-       constructor(
-       /// The type of the top node.
-       type, 
-       /// This node's child nodes.
-       children, 
-       /// The positions (offsets relative to the start of this tree) of
-       /// the children.
-       positions, 
-       /// The total length of this tree
-       length, 
-       /// Per-node [node props](#common.NodeProp) to associate with this node.
-       props) {
-           this.type = type;
-           this.children = children;
-           this.positions = positions;
-           this.length = length;
-           /// @internal
-           this.props = null;
-           if (props && props.length) {
-               this.props = Object.create(null);
-               for (let [prop, value] of props)
-                   this.props[typeof prop == "number" ? prop : prop.id] = value;
-           }
-       }
-       /// @internal
-       toString() {
-           let mounted = this.prop(NodeProp$2.mounted);
-           if (mounted && !mounted.overlay)
-               return mounted.tree.toString();
-           let children = "";
-           for (let ch of this.children) {
-               let str = ch.toString();
-               if (str) {
-                   if (children)
-                       children += ",";
-                   children += str;
-               }
-           }
-           return !this.type.name ? children :
-               (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
-                   (children.length ? "(" + children + ")" : "");
-       }
-       /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
-       /// the tree. Mode can be used to [control](#common.IterMode) which
-       /// nodes the cursor visits.
-       cursor(mode = 0) {
-           return new TreeCursor$2(this.topNode, mode);
-       }
-       /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
-       /// at the given position and side (see
-       /// [`moveTo`](#common.TreeCursor.moveTo).
-       cursorAt(pos, side = 0, mode = 0) {
-           let scope = CachedNode$2.get(this) || this.topNode;
-           let cursor = new TreeCursor$2(scope);
-           cursor.moveTo(pos, side);
-           CachedNode$2.set(this, cursor._tree);
-           return cursor;
-       }
-       /// Get a [syntax node](#common.SyntaxNode) object for the top of the
-       /// tree.
-       get topNode() {
-           return new TreeNode$2(this, 0, 0, null);
-       }
-       /// Get the [syntax node](#common.SyntaxNode) at the given position.
-       /// If `side` is -1, this will move into nodes that end at the
-       /// position. If 1, it'll move into nodes that start at the
-       /// position. With 0, it'll only enter nodes that cover the position
-       /// from both sides.
-       resolve(pos, side = 0) {
-           let node = resolveNode$2(CachedNode$2.get(this) || this.topNode, pos, side, false);
-           CachedNode$2.set(this, node);
-           return node;
-       }
-       /// Like [`resolve`](#common.Tree.resolve), but will enter
-       /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
-       /// pointing into the innermost overlaid tree at the given position
-       /// (with parent links going through all parent structure, including
-       /// the host trees).
-       resolveInner(pos, side = 0) {
-           let node = resolveNode$2(CachedInnerNode$2.get(this) || this.topNode, pos, side, true);
-           CachedInnerNode$2.set(this, node);
-           return node;
-       }
-       /// Iterate over the tree and its children, calling `enter` for any
-       /// node that touches the `from`/`to` region (if given) before
-       /// running over such a node's children, and `leave` (if given) when
-       /// leaving the node. When `enter` returns `false`, that node will
-       /// not have its children iterated over (or `leave` called).
-       iterate(spec) {
-           let { enter, leave, from = 0, to = this.length } = spec;
-           for (let c = this.cursor((spec.mode || 0) | IterMode$2.IncludeAnonymous);;) {
-               let entered = false;
-               if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
-                   if (c.firstChild())
-                       continue;
-                   entered = true;
-               }
-               for (;;) {
-                   if (entered && leave && !c.type.isAnonymous)
-                       leave(c);
-                   if (c.nextSibling())
-                       break;
-                   if (!c.parent())
-                       return;
-                   entered = true;
-               }
-           }
-       }
-       /// Get the value of the given [node prop](#common.NodeProp) for this
-       /// node. Works with both per-node and per-type props.
-       prop(prop) {
-           return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
-       }
-       /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
-       /// format that can be passed to the [`Tree`](#common.Tree)
-       /// constructor.
-       get propValues() {
-           let result = [];
-           if (this.props)
-               for (let id in this.props)
-                   result.push([+id, this.props[id]]);
-           return result;
-       }
-       /// Balance the direct children of this tree, producing a copy of
-       /// which may have children grouped into subtrees with type
-       /// [`NodeType.none`](#common.NodeType^none).
-       balance(config = {}) {
-           return this.children.length <= 8 /* BranchFactor */ ? this :
-               balanceRange$2(NodeType$2.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType$2.none, children, positions, length)));
-       }
-       /// Build a tree from a postfix-ordered buffer of node information,
-       /// or a cursor over such a buffer.
-       static build(data) { return buildTree$2(data); }
-   };
-   /// The empty tree
-   Tree$2.empty = new Tree$2(NodeType$2.none, [], [], 0);
-   let FlatBufferCursor$2 = class FlatBufferCursor {
-       constructor(buffer, index) {
-           this.buffer = buffer;
-           this.index = index;
-       }
-       get id() { return this.buffer[this.index - 4]; }
-       get start() { return this.buffer[this.index - 3]; }
-       get end() { return this.buffer[this.index - 2]; }
-       get size() { return this.buffer[this.index - 1]; }
-       get pos() { return this.index; }
-       next() { this.index -= 4; }
-       fork() { return new FlatBufferCursor(this.buffer, this.index); }
-   };
-   /// Tree buffers contain (type, start, end, endIndex) quads for each
-   /// node. In such a buffer, nodes are stored in prefix order (parents
-   /// before children, with the endIndex of the parent indicating which
-   /// children belong to it)
-   let TreeBuffer$2 = class TreeBuffer {
-       /// Create a tree buffer.
-       constructor(
-       /// The buffer's content.
-       buffer, 
-       /// The total length of the group of nodes in the buffer.
-       length, 
-       /// The node set used in this buffer.
-       set) {
-           this.buffer = buffer;
-           this.length = length;
-           this.set = set;
-       }
-       /// @internal
-       get type() { return NodeType$2.none; }
-       /// @internal
-       toString() {
-           let result = [];
-           for (let index = 0; index < this.buffer.length;) {
-               result.push(this.childString(index));
-               index = this.buffer[index + 3];
-           }
-           return result.join(",");
-       }
-       /// @internal
-       childString(index) {
-           let id = this.buffer[index], endIndex = this.buffer[index + 3];
-           let type = this.set.types[id], result = type.name;
-           if (/\W/.test(result) && !type.isError)
-               result = JSON.stringify(result);
-           index += 4;
-           if (endIndex == index)
-               return result;
-           let children = [];
-           while (index < endIndex) {
-               children.push(this.childString(index));
-               index = this.buffer[index + 3];
-           }
-           return result + "(" + children.join(",") + ")";
-       }
-       /// @internal
-       findChild(startIndex, endIndex, dir, pos, side) {
-           let { buffer } = this, pick = -1;
-           for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
-               if (checkSide$2(side, pos, buffer[i + 1], buffer[i + 2])) {
-                   pick = i;
-                   if (dir > 0)
-                       break;
-               }
-           }
-           return pick;
-       }
-       /// @internal
-       slice(startI, endI, from, to) {
-           let b = this.buffer;
-           let copy = new Uint16Array(endI - startI);
-           for (let i = startI, j = 0; i < endI;) {
-               copy[j++] = b[i++];
-               copy[j++] = b[i++] - from;
-               copy[j++] = b[i++] - from;
-               copy[j++] = b[i++] - startI;
-           }
-           return new TreeBuffer(copy, to - from, this.set);
-       }
-   };
-   function checkSide$2(side, pos, from, to) {
-       switch (side) {
-           case -2 /* Before */: return from < pos;
-           case -1 /* AtOrBefore */: return to >= pos && from < pos;
-           case 0 /* Around */: return from < pos && to > pos;
-           case 1 /* AtOrAfter */: return from <= pos && to > pos;
-           case 2 /* After */: return to > pos;
-           case 4 /* DontCare */: return true;
-       }
-   }
-   function enterUnfinishedNodesBefore$1(node, pos) {
-       let scan = node.childBefore(pos);
-       while (scan) {
-           let last = scan.lastChild;
-           if (!last || last.to != scan.to)
-               break;
-           if (last.type.isError && last.from == last.to) {
-               node = scan;
-               scan = last.prevSibling;
-           }
-           else {
-               scan = last;
-           }
-       }
-       return node;
-   }
-   function resolveNode$2(node, pos, side, overlays) {
-       var _a;
-       // Move up to a node that actually holds the position, if possible
-       while (node.from == node.to ||
-           (side < 1 ? node.from >= pos : node.from > pos) ||
-           (side > -1 ? node.to <= pos : node.to < pos)) {
-           let parent = !overlays && node instanceof TreeNode$2 && node.index < 0 ? null : node.parent;
-           if (!parent)
-               return node;
-           node = parent;
-       }
-       let mode = overlays ? 0 : IterMode$2.IgnoreOverlays;
-       // Must go up out of overlays when those do not overlap with pos
-       if (overlays)
-           for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
-               if (scan instanceof TreeNode$2 && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
-                   node = parent;
-           }
-       for (;;) {
-           let inner = node.enter(pos, side, mode);
-           if (!inner)
-               return node;
-           node = inner;
-       }
-   }
-   let TreeNode$2 = class TreeNode {
-       constructor(_tree, from, 
-       // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
-       index, _parent) {
-           this._tree = _tree;
-           this.from = from;
-           this.index = index;
-           this._parent = _parent;
-       }
-       get type() { return this._tree.type; }
-       get name() { return this._tree.type.name; }
-       get to() { return this.from + this._tree.length; }
-       nextChild(i, dir, pos, side, mode = 0) {
-           for (let parent = this;;) {
-               for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
-                   let next = children[i], start = positions[i] + parent.from;
-                   if (!checkSide$2(side, pos, start, start + next.length))
-                       continue;
-                   if (next instanceof TreeBuffer$2) {
-                       if (mode & IterMode$2.ExcludeBuffers)
-                           continue;
-                       let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
-                       if (index > -1)
-                           return new BufferNode$2(new BufferContext$2(parent, next, i, start), null, index);
-                   }
-                   else if ((mode & IterMode$2.IncludeAnonymous) || (!next.type.isAnonymous || hasChild$2(next))) {
-                       let mounted;
-                       if (!(mode & IterMode$2.IgnoreMounts) &&
-                           next.props && (mounted = next.prop(NodeProp$2.mounted)) && !mounted.overlay)
-                           return new TreeNode(mounted.tree, start, i, parent);
-                       let inner = new TreeNode(next, start, i, parent);
-                       return (mode & IterMode$2.IncludeAnonymous) || !inner.type.isAnonymous ? inner
-                           : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
-                   }
-               }
-               if ((mode & IterMode$2.IncludeAnonymous) || !parent.type.isAnonymous)
-                   return null;
-               if (parent.index >= 0)
-                   i = parent.index + dir;
-               else
-                   i = dir < 0 ? -1 : parent._parent._tree.children.length;
-               parent = parent._parent;
-               if (!parent)
-                   return null;
-           }
-       }
-       get firstChild() { return this.nextChild(0, 1, 0, 4 /* DontCare */); }
-       get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* DontCare */); }
-       childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* After */); }
-       childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Before */); }
-       enter(pos, side, mode = 0) {
-           let mounted;
-           if (!(mode & IterMode$2.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp$2.mounted)) && mounted.overlay) {
-               let rPos = pos - this.from;
-               for (let { from, to } of mounted.overlay) {
-                   if ((side > 0 ? from <= rPos : from < rPos) &&
-                       (side < 0 ? to >= rPos : to > rPos))
-                       return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
-               }
-           }
-           return this.nextChild(0, 1, pos, side, mode);
-       }
-       nextSignificantParent() {
-           let val = this;
-           while (val.type.isAnonymous && val._parent)
-               val = val._parent;
-           return val;
-       }
-       get parent() {
-           return this._parent ? this._parent.nextSignificantParent() : null;
-       }
-       get nextSibling() {
-           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* DontCare */) : null;
-       }
-       get prevSibling() {
-           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* DontCare */) : null;
-       }
-       cursor(mode = 0) { return new TreeCursor$2(this, mode); }
-       get tree() { return this._tree; }
-       toTree() { return this._tree; }
-       resolve(pos, side = 0) {
-           return resolveNode$2(this, pos, side, false);
-       }
-       resolveInner(pos, side = 0) {
-           return resolveNode$2(this, pos, side, true);
-       }
-       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore$1(this, pos); }
-       getChild(type, before = null, after = null) {
-           let r = getChildren$2(this, type, before, after);
-           return r.length ? r[0] : null;
-       }
-       getChildren(type, before = null, after = null) {
-           return getChildren$2(this, type, before, after);
-       }
-       /// @internal
-       toString() { return this._tree.toString(); }
-       get node() { return this; }
-       matchContext(context) { return matchNodeContext$2(this, context); }
-   };
-   function getChildren$2(node, type, before, after) {
-       let cur = node.cursor(), result = [];
-       if (!cur.firstChild())
-           return result;
-       if (before != null)
-           while (!cur.type.is(before))
-               if (!cur.nextSibling())
-                   return result;
-       for (;;) {
-           if (after != null && cur.type.is(after))
-               return result;
-           if (cur.type.is(type))
-               result.push(cur.node);
-           if (!cur.nextSibling())
-               return after == null ? result : [];
-       }
-   }
-   function matchNodeContext$2(node, context, i = context.length - 1) {
-       for (let p = node.parent; i >= 0; p = p.parent) {
-           if (!p)
-               return false;
-           if (!p.type.isAnonymous) {
-               if (context[i] && context[i] != p.name)
-                   return false;
-               i--;
-           }
-       }
-       return true;
-   }
-   let BufferContext$2 = class BufferContext {
-       constructor(parent, buffer, index, start) {
-           this.parent = parent;
-           this.buffer = buffer;
-           this.index = index;
-           this.start = start;
-       }
-   };
-   let BufferNode$2 = class BufferNode {
-       constructor(context, _parent, index) {
-           this.context = context;
-           this._parent = _parent;
-           this.index = index;
-           this.type = context.buffer.set.types[context.buffer.buffer[index]];
-       }
-       get name() { return this.type.name; }
-       get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
-       get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
-       child(dir, pos, side) {
-           let { buffer } = this.context;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
-           return index < 0 ? null : new BufferNode(this.context, this, index);
-       }
-       get firstChild() { return this.child(1, 0, 4 /* DontCare */); }
-       get lastChild() { return this.child(-1, 0, 4 /* DontCare */); }
-       childAfter(pos) { return this.child(1, pos, 2 /* After */); }
-       childBefore(pos) { return this.child(-1, pos, -2 /* Before */); }
-       enter(pos, side, mode = 0) {
-           if (mode & IterMode$2.ExcludeBuffers)
-               return null;
-           let { buffer } = this.context;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
-           return index < 0 ? null : new BufferNode(this.context, this, index);
-       }
-       get parent() {
-           return this._parent || this.context.parent.nextSignificantParent();
-       }
-       externalSibling(dir) {
-           return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* DontCare */);
-       }
-       get nextSibling() {
-           let { buffer } = this.context;
-           let after = buffer.buffer[this.index + 3];
-           if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
-               return new BufferNode(this.context, this._parent, after);
-           return this.externalSibling(1);
-       }
-       get prevSibling() {
-           let { buffer } = this.context;
-           let parentStart = this._parent ? this._parent.index + 4 : 0;
-           if (this.index == parentStart)
-               return this.externalSibling(-1);
-           return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
-       }
-       cursor(mode = 0) { return new TreeCursor$2(this, mode); }
-       get tree() { return null; }
-       toTree() {
-           let children = [], positions = [];
-           let { buffer } = this.context;
-           let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
-           if (endI > startI) {
-               let from = buffer.buffer[this.index + 1], to = buffer.buffer[this.index + 2];
-               children.push(buffer.slice(startI, endI, from, to));
-               positions.push(0);
-           }
-           return new Tree$2(this.type, children, positions, this.to - this.from);
-       }
-       resolve(pos, side = 0) {
-           return resolveNode$2(this, pos, side, false);
-       }
-       resolveInner(pos, side = 0) {
-           return resolveNode$2(this, pos, side, true);
-       }
-       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore$1(this, pos); }
-       /// @internal
-       toString() { return this.context.buffer.childString(this.index); }
-       getChild(type, before = null, after = null) {
-           let r = getChildren$2(this, type, before, after);
-           return r.length ? r[0] : null;
-       }
-       getChildren(type, before = null, after = null) {
-           return getChildren$2(this, type, before, after);
-       }
-       get node() { return this; }
-       matchContext(context) { return matchNodeContext$2(this, context); }
-   };
-   /// A tree cursor object focuses on a given node in a syntax tree, and
-   /// allows you to move to adjacent nodes.
-   let TreeCursor$2 = class TreeCursor {
-       /// @internal
-       constructor(node, 
-       /// @internal
-       mode = 0) {
-           this.mode = mode;
-           /// @internal
-           this.buffer = null;
-           this.stack = [];
-           /// @internal
-           this.index = 0;
-           this.bufferNode = null;
-           if (node instanceof TreeNode$2) {
-               this.yieldNode(node);
-           }
-           else {
-               this._tree = node.context.parent;
-               this.buffer = node.context;
-               for (let n = node._parent; n; n = n._parent)
-                   this.stack.unshift(n.index);
-               this.bufferNode = node;
-               this.yieldBuf(node.index);
-           }
-       }
-       /// Shorthand for `.type.name`.
-       get name() { return this.type.name; }
-       yieldNode(node) {
-           if (!node)
-               return false;
-           this._tree = node;
-           this.type = node.type;
-           this.from = node.from;
-           this.to = node.to;
-           return true;
-       }
-       yieldBuf(index, type) {
-           this.index = index;
-           let { start, buffer } = this.buffer;
-           this.type = type || buffer.set.types[buffer.buffer[index]];
-           this.from = start + buffer.buffer[index + 1];
-           this.to = start + buffer.buffer[index + 2];
-           return true;
-       }
-       yield(node) {
-           if (!node)
-               return false;
-           if (node instanceof TreeNode$2) {
-               this.buffer = null;
-               return this.yieldNode(node);
-           }
-           this.buffer = node.context;
-           return this.yieldBuf(node.index, node.type);
-       }
-       /// @internal
-       toString() {
-           return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
-       }
-       /// @internal
-       enterChild(dir, pos, side) {
-           if (!this.buffer)
-               return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
-           let { buffer } = this.buffer;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
-           if (index < 0)
-               return false;
-           this.stack.push(this.index);
-           return this.yieldBuf(index);
-       }
-       /// Move the cursor to this node's first child. When this returns
-       /// false, the node has no child, and the cursor has not been moved.
-       firstChild() { return this.enterChild(1, 0, 4 /* DontCare */); }
-       /// Move the cursor to this node's last child.
-       lastChild() { return this.enterChild(-1, 0, 4 /* DontCare */); }
-       /// Move the cursor to the first child that ends after `pos`.
-       childAfter(pos) { return this.enterChild(1, pos, 2 /* After */); }
-       /// Move to the last child that starts before `pos`.
-       childBefore(pos) { return this.enterChild(-1, pos, -2 /* Before */); }
-       /// Move the cursor to the child around `pos`. If side is -1 the
-       /// child may end at that position, when 1 it may start there. This
-       /// will also enter [overlaid](#common.MountedTree.overlay)
-       /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
-       /// set to false.
-       enter(pos, side, mode = this.mode) {
-           if (!this.buffer)
-               return this.yield(this._tree.enter(pos, side, mode));
-           return mode & IterMode$2.ExcludeBuffers ? false : this.enterChild(1, pos, side);
-       }
-       /// Move to the node's parent node, if this isn't the top node.
-       parent() {
-           if (!this.buffer)
-               return this.yieldNode((this.mode & IterMode$2.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
-           if (this.stack.length)
-               return this.yieldBuf(this.stack.pop());
-           let parent = (this.mode & IterMode$2.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
-           this.buffer = null;
-           return this.yieldNode(parent);
-       }
-       /// @internal
-       sibling(dir) {
-           if (!this.buffer)
-               return !this._tree._parent ? false
-                   : this.yield(this._tree.index < 0 ? null
-                       : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* DontCare */, this.mode));
-           let { buffer } = this.buffer, d = this.stack.length - 1;
-           if (dir < 0) {
-               let parentStart = d < 0 ? 0 : this.stack[d] + 4;
-               if (this.index != parentStart)
-                   return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
-           }
-           else {
-               let after = buffer.buffer[this.index + 3];
-               if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
-                   return this.yieldBuf(after);
-           }
-           return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* DontCare */, this.mode)) : false;
-       }
-       /// Move to this node's next sibling, if any.
-       nextSibling() { return this.sibling(1); }
-       /// Move to this node's previous sibling, if any.
-       prevSibling() { return this.sibling(-1); }
-       atLastNode(dir) {
-           let index, parent, { buffer } = this;
-           if (buffer) {
-               if (dir > 0) {
-                   if (this.index < buffer.buffer.buffer.length)
-                       return false;
-               }
-               else {
-                   for (let i = 0; i < this.index; i++)
-                       if (buffer.buffer.buffer[i + 3] < this.index)
-                           return false;
-               }
-               ({ index, parent } = buffer);
-           }
-           else {
-               ({ index, _parent: parent } = this._tree);
-           }
-           for (; parent; { index, _parent: parent } = parent) {
-               if (index > -1)
-                   for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
-                       let child = parent._tree.children[i];
-                       if ((this.mode & IterMode$2.IncludeAnonymous) ||
-                           child instanceof TreeBuffer$2 ||
-                           !child.type.isAnonymous ||
-                           hasChild$2(child))
-                           return false;
-                   }
-           }
-           return true;
-       }
-       move(dir, enter) {
-           if (enter && this.enterChild(dir, 0, 4 /* DontCare */))
-               return true;
-           for (;;) {
-               if (this.sibling(dir))
-                   return true;
-               if (this.atLastNode(dir) || !this.parent())
-                   return false;
-           }
-       }
-       /// Move to the next node in a
-       /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
-       /// traversal, going from a node to its first child or, if the
-       /// current node is empty or `enter` is false, its next sibling or
-       /// the next sibling of the first parent node that has one.
-       next(enter = true) { return this.move(1, enter); }
-       /// Move to the next node in a last-to-first pre-order traveral. A
-       /// node is followed by its last child or, if it has none, its
-       /// previous sibling or the previous sibling of the first parent
-       /// node that has one.
-       prev(enter = true) { return this.move(-1, enter); }
-       /// Move the cursor to the innermost node that covers `pos`. If
-       /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
-       /// it will enter nodes that start at `pos`.
-       moveTo(pos, side = 0) {
-           // Move up to a node that actually holds the position, if possible
-           while (this.from == this.to ||
-               (side < 1 ? this.from >= pos : this.from > pos) ||
-               (side > -1 ? this.to <= pos : this.to < pos))
-               if (!this.parent())
-                   break;
-           // Then scan down into child nodes as far as possible
-           while (this.enterChild(1, pos, side)) { }
-           return this;
-       }
-       /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
-       /// position.
-       get node() {
-           if (!this.buffer)
-               return this._tree;
-           let cache = this.bufferNode, result = null, depth = 0;
-           if (cache && cache.context == this.buffer) {
-               scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
-                   for (let c = cache; c; c = c._parent)
-                       if (c.index == index) {
-                           if (index == this.index)
-                               return c;
-                           result = c;
-                           depth = d + 1;
-                           break scan;
-                       }
-                   index = this.stack[--d];
-               }
-           }
-           for (let i = depth; i < this.stack.length; i++)
-               result = new BufferNode$2(this.buffer, result, this.stack[i]);
-           return this.bufferNode = new BufferNode$2(this.buffer, result, this.index);
-       }
-       /// Get the [tree](#common.Tree) that represents the current node, if
-       /// any. Will return null when the node is in a [tree
-       /// buffer](#common.TreeBuffer).
-       get tree() {
-           return this.buffer ? null : this._tree._tree;
-       }
-       /// Iterate over the current node and all its descendants, calling
-       /// `enter` when entering a node and `leave`, if given, when leaving
-       /// one. When `enter` returns `false`, any children of that node are
-       /// skipped, and `leave` isn't called for it.
-       iterate(enter, leave) {
-           for (let depth = 0;;) {
-               let mustLeave = false;
-               if (this.type.isAnonymous || enter(this) !== false) {
-                   if (this.firstChild()) {
-                       depth++;
-                       continue;
-                   }
-                   if (!this.type.isAnonymous)
-                       mustLeave = true;
-               }
-               for (;;) {
-                   if (mustLeave && leave)
-                       leave(this);
-                   mustLeave = this.type.isAnonymous;
-                   if (this.nextSibling())
-                       break;
-                   if (!depth)
-                       return;
-                   this.parent();
-                   depth--;
-                   mustLeave = true;
-               }
-           }
-       }
-       /// Test whether the current node matches a given context—a sequence
-       /// of direct parent node names. Empty strings in the context array
-       /// are treated as wildcards.
-       matchContext(context) {
-           if (!this.buffer)
-               return matchNodeContext$2(this.node, context);
-           let { buffer } = this.buffer, { types } = buffer.set;
-           for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
-               if (d < 0)
-                   return matchNodeContext$2(this.node, context, i);
-               let type = types[buffer.buffer[this.stack[d]]];
-               if (!type.isAnonymous) {
-                   if (context[i] && context[i] != type.name)
-                       return false;
-                   i--;
-               }
-           }
-           return true;
-       }
-   };
-   function hasChild$2(tree) {
-       return tree.children.some(ch => ch instanceof TreeBuffer$2 || !ch.type.isAnonymous || hasChild$2(ch));
-   }
-   function buildTree$2(data) {
-       var _a;
-       let { buffer, nodeSet, maxBufferLength = DefaultBufferLength$2, reused = [], minRepeatType = nodeSet.types.length } = data;
-       let cursor = Array.isArray(buffer) ? new FlatBufferCursor$2(buffer, buffer.length) : buffer;
-       let types = nodeSet.types;
-       let contextHash = 0, lookAhead = 0;
-       function takeNode(parentStart, minPos, children, positions, inRepeat) {
-           let { id, start, end, size } = cursor;
-           let lookAheadAtStart = lookAhead;
-           while (size < 0) {
-               cursor.next();
-               if (size == -1 /* Reuse */) {
-                   let node = reused[id];
-                   children.push(node);
-                   positions.push(start - parentStart);
-                   return;
-               }
-               else if (size == -3 /* ContextChange */) { // Context change
-                   contextHash = id;
-                   return;
-               }
-               else if (size == -4 /* LookAhead */) {
-                   lookAhead = id;
-                   return;
-               }
-               else {
-                   throw new RangeError(`Unrecognized record size: ${size}`);
-               }
-           }
-           let type = types[id], node, buffer;
-           let startPos = start - parentStart;
-           if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
-               // Small enough for a buffer, and no reused nodes inside
-               let data = new Uint16Array(buffer.size - buffer.skip);
-               let endPos = cursor.pos - buffer.size, index = data.length;
-               while (cursor.pos > endPos)
-                   index = copyToBuffer(buffer.start, data, index);
-               node = new TreeBuffer$2(data, end - buffer.start, nodeSet);
-               startPos = buffer.start - parentStart;
-           }
-           else { // Make it a node
-               let endPos = cursor.pos - size;
-               cursor.next();
-               let localChildren = [], localPositions = [];
-               let localInRepeat = id >= minRepeatType ? id : -1;
-               let lastGroup = 0, lastEnd = end;
-               while (cursor.pos > endPos) {
-                   if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
-                       if (cursor.end <= lastEnd - maxBufferLength) {
-                           makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
-                           lastGroup = localChildren.length;
-                           lastEnd = cursor.end;
-                       }
-                       cursor.next();
-                   }
-                   else {
-                       takeNode(start, endPos, localChildren, localPositions, localInRepeat);
-                   }
-               }
-               if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
-                   makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
-               localChildren.reverse();
-               localPositions.reverse();
-               if (localInRepeat > -1 && lastGroup > 0) {
-                   let make = makeBalanced(type);
-                   node = balanceRange$2(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
-               }
-               else {
-                   node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
-               }
-           }
-           children.push(node);
-           positions.push(startPos);
-       }
-       function makeBalanced(type) {
-           return (children, positions, length) => {
-               let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
-               if (lastI >= 0 && (last = children[lastI]) instanceof Tree$2) {
-                   if (!lastI && last.type == type && last.length == length)
-                       return last;
-                   if (lookAheadProp = last.prop(NodeProp$2.lookAhead))
-                       lookAhead = positions[lastI] + last.length + lookAheadProp;
-               }
-               return makeTree(type, children, positions, length, lookAhead);
-           };
-       }
-       function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {
-           let localChildren = [], localPositions = [];
-           while (children.length > i) {
-               localChildren.push(children.pop());
-               localPositions.push(positions.pop() + base - from);
-           }
-           children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));
-           positions.push(from - base);
-       }
-       function makeTree(type, children, positions, length, lookAhead = 0, props) {
-           if (contextHash) {
-               let pair = [NodeProp$2.contextHash, contextHash];
-               props = props ? [pair].concat(props) : [pair];
-           }
-           if (lookAhead > 25) {
-               let pair = [NodeProp$2.lookAhead, lookAhead];
-               props = props ? [pair].concat(props) : [pair];
-           }
-           return new Tree$2(type, children, positions, length, props);
-       }
-       function findBufferSize(maxSize, inRepeat) {
-           // Scan through the buffer to find previous siblings that fit
-           // together in a TreeBuffer, and don't contain any reused nodes
-           // (which can't be stored in a buffer).
-           // If `inRepeat` is > -1, ignore node boundaries of that type for
-           // nesting, but make sure the end falls either at the start
-           // (`maxSize`) or before such a node.
-           let fork = cursor.fork();
-           let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
-           let result = { size: 0, start: 0, skip: 0 };
-           scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
-               let nodeSize = fork.size;
-               // Pretend nested repeat nodes of the same type don't exist
-               if (fork.id == inRepeat && nodeSize >= 0) {
-                   // Except that we store the current state as a valid return
-                   // value.
-                   result.size = size;
-                   result.start = start;
-                   result.skip = skip;
-                   skip += 4;
-                   size += 4;
-                   fork.next();
-                   continue;
-               }
-               let startPos = fork.pos - nodeSize;
-               if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
-                   break;
-               let localSkipped = fork.id >= minRepeatType ? 4 : 0;
-               let nodeStart = fork.start;
-               fork.next();
-               while (fork.pos > startPos) {
-                   if (fork.size < 0) {
-                       if (fork.size == -3 /* ContextChange */)
-                           localSkipped += 4;
-                       else
-                           break scan;
-                   }
-                   else if (fork.id >= minRepeatType) {
-                       localSkipped += 4;
-                   }
-                   fork.next();
-               }
-               start = nodeStart;
-               size += nodeSize;
-               skip += localSkipped;
-           }
-           if (inRepeat < 0 || size == maxSize) {
-               result.size = size;
-               result.start = start;
-               result.skip = skip;
-           }
-           return result.size > 4 ? result : undefined;
-       }
-       function copyToBuffer(bufferStart, buffer, index) {
-           let { id, start, end, size } = cursor;
-           cursor.next();
-           if (size >= 0 && id < minRepeatType) {
-               let startIndex = index;
-               if (size > 4) {
-                   let endPos = cursor.pos - (size - 4);
-                   while (cursor.pos > endPos)
-                       index = copyToBuffer(bufferStart, buffer, index);
-               }
-               buffer[--index] = startIndex;
-               buffer[--index] = end - bufferStart;
-               buffer[--index] = start - bufferStart;
-               buffer[--index] = id;
-           }
-           else if (size == -3 /* ContextChange */) {
-               contextHash = id;
-           }
-           else if (size == -4 /* LookAhead */) {
-               lookAhead = id;
-           }
-           return index;
-       }
-       let children = [], positions = [];
-       while (cursor.pos > 0)
-           takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
-       let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
-       return new Tree$2(types[data.topID], children.reverse(), positions.reverse(), length);
-   }
-   const nodeSizeCache$2 = new WeakMap;
-   function nodeSize$2(balanceType, node) {
-       if (!balanceType.isAnonymous || node instanceof TreeBuffer$2 || node.type != balanceType)
-           return 1;
-       let size = nodeSizeCache$2.get(node);
-       if (size == null) {
-           size = 1;
-           for (let child of node.children) {
-               if (child.type != balanceType || !(child instanceof Tree$2)) {
-                   size = 1;
-                   break;
-               }
-               size += nodeSize$2(balanceType, child);
-           }
-           nodeSizeCache$2.set(node, size);
-       }
-       return size;
-   }
-   function balanceRange$2(
-   // The type the balanced tree's inner nodes.
-   balanceType, 
-   // The direct children and their positions
-   children, positions, 
-   // The index range in children/positions to use
-   from, to, 
-   // The start position of the nodes, relative to their parent.
-   start, 
-   // Length of the outer node
-   length, 
-   // Function to build the top node of the balanced tree
-   mkTop, 
-   // Function to build internal nodes for the balanced tree
-   mkTree) {
-       let total = 0;
-       for (let i = from; i < to; i++)
-           total += nodeSize$2(balanceType, children[i]);
-       let maxChild = Math.ceil((total * 1.5) / 8 /* BranchFactor */);
-       let localChildren = [], localPositions = [];
-       function divide(children, positions, from, to, offset) {
-           for (let i = from; i < to;) {
-               let groupFrom = i, groupStart = positions[i], groupSize = nodeSize$2(balanceType, children[i]);
-               i++;
-               for (; i < to; i++) {
-                   let nextSize = nodeSize$2(balanceType, children[i]);
-                   if (groupSize + nextSize >= maxChild)
-                       break;
-                   groupSize += nextSize;
-               }
-               if (i == groupFrom + 1) {
-                   if (groupSize > maxChild) {
-                       let only = children[groupFrom]; // Only trees can have a size > 1
-                       divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
-                       continue;
-                   }
-                   localChildren.push(children[groupFrom]);
-               }
-               else {
-                   let length = positions[i - 1] + children[i - 1].length - groupStart;
-                   localChildren.push(balanceRange$2(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
-               }
-               localPositions.push(groupStart + offset - start);
-           }
-       }
-       divide(children, positions, from, to, 0);
-       return (mkTop || mkTree)(localChildren, localPositions, length);
-   }
-
-   /// Tree fragments are used during [incremental
-   /// parsing](#common.Parser.startParse) to track parts of old trees
-   /// that can be reused in a new parse. An array of fragments is used
-   /// to track regions of an old tree whose nodes might be reused in new
-   /// parses. Use the static
-   /// [`applyChanges`](#common.TreeFragment^applyChanges) method to
-   /// update fragments for document changes.
-   let TreeFragment$2 = class TreeFragment {
-       /// Construct a tree fragment.
-       constructor(
-       /// The start of the unchanged range pointed to by this fragment.
-       /// This refers to an offset in the _updated_ document (as opposed
-       /// to the original tree).
-       from, 
-       /// The end of the unchanged range.
-       to, 
-       /// The tree that this fragment is based on.
-       tree, 
-       /// The offset between the fragment's tree and the document that
-       /// this fragment can be used against. Add this when going from
-       /// document to tree positions, subtract it to go from tree to
-       /// document positions.
-       offset, openStart = false, openEnd = false) {
-           this.from = from;
-           this.to = to;
-           this.tree = tree;
-           this.offset = offset;
-           this.open = (openStart ? 1 /* Start */ : 0) | (openEnd ? 2 /* End */ : 0);
-       }
-       /// Whether the start of the fragment represents the start of a
-       /// parse, or the end of a change. (In the second case, it may not
-       /// be safe to reuse some nodes at the start, depending on the
-       /// parsing algorithm.)
-       get openStart() { return (this.open & 1 /* Start */) > 0; }
-       /// Whether the end of the fragment represents the end of a
-       /// full-document parse, or the start of a change.
-       get openEnd() { return (this.open & 2 /* End */) > 0; }
-       /// Create a set of fragments from a freshly parsed tree, or update
-       /// an existing set of fragments by replacing the ones that overlap
-       /// with a tree with content from the new tree. When `partial` is
-       /// true, the parse is treated as incomplete, and the resulting
-       /// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
-       /// true.
-       static addTree(tree, fragments = [], partial = false) {
-           let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
-           for (let f of fragments)
-               if (f.to > tree.length)
-                   result.push(f);
-           return result;
-       }
-       /// Apply a set of edits to an array of fragments, removing or
-       /// splitting fragments as necessary to remove edited ranges, and
-       /// adjusting offsets for fragments that moved.
-       static applyChanges(fragments, changes, minGap = 128) {
-           if (!changes.length)
-               return fragments;
-           let result = [];
-           let fI = 1, nextF = fragments.length ? fragments[0] : null;
-           for (let cI = 0, pos = 0, off = 0;; cI++) {
-               let nextC = cI < changes.length ? changes[cI] : null;
-               let nextPos = nextC ? nextC.fromA : 1e9;
-               if (nextPos - pos >= minGap)
-                   while (nextF && nextF.from < nextPos) {
-                       let cut = nextF;
-                       if (pos >= cut.from || nextPos <= cut.to || off) {
-                           let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
-                           cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
-                       }
-                       if (cut)
-                           result.push(cut);
-                       if (nextF.to > nextPos)
-                           break;
-                       nextF = fI < fragments.length ? fragments[fI++] : null;
-                   }
-               if (!nextC)
-                   break;
-               pos = nextC.toA;
-               off = nextC.toA - nextC.toB;
-           }
-           return result;
-       }
-   };
-   /// A superclass that parsers should extend.
-   let Parser$2 = class Parser {
-       /// Start a parse, returning a [partial parse](#common.PartialParse)
-       /// object. [`fragments`](#common.TreeFragment) can be passed in to
-       /// make the parse incremental.
-       ///
-       /// By default, the entire input is parsed. You can pass `ranges`,
-       /// which should be a sorted array of non-empty, non-overlapping
-       /// ranges, to parse only those ranges. The tree returned in that
-       /// case will start at `ranges[0].from`.
-       startParse(input, fragments, ranges) {
-           if (typeof input == "string")
-               input = new StringInput$2(input);
-           ranges = !ranges ? [new Range$5(0, input.length)] : ranges.length ? ranges.map(r => new Range$5(r.from, r.to)) : [new Range$5(0, 0)];
-           return this.createParse(input, fragments || [], ranges);
-       }
-       /// Run a full parse, returning the resulting tree.
-       parse(input, fragments, ranges) {
-           let parse = this.startParse(input, fragments, ranges);
-           for (;;) {
-               let done = parse.advance();
-               if (done)
-                   return done;
-           }
-       }
-   };
-   let StringInput$2 = class StringInput {
-       constructor(string) {
-           this.string = string;
-       }
-       get length() { return this.string.length; }
-       chunk(from) { return this.string.slice(from); }
-       get lineChunks() { return false; }
-       read(from, to) { return this.string.slice(from, to); }
-   };
-   new NodeProp$2({ perNode: true });
-
-   let nextTagID$2 = 0;
-   /// Highlighting tags are markers that denote a highlighting category.
-   /// They are [associated](#highlight.styleTags) with parts of a syntax
-   /// tree by a language mode, and then mapped to an actual CSS style by
-   /// a [highlighter](#highlight.Highlighter).
-   ///
-   /// Because syntax tree node types and highlight styles have to be
-   /// able to talk the same language, CodeMirror uses a mostly _closed_
-   /// [vocabulary](#highlight.tags) of syntax tags (as opposed to
-   /// traditional open string-based systems, which make it hard for
-   /// highlighting themes to cover all the tokens produced by the
-   /// various languages).
-   ///
-   /// It _is_ possible to [define](#highlight.Tag^define) your own
-   /// highlighting tags for system-internal use (where you control both
-   /// the language package and the highlighter), but such tags will not
-   /// be picked up by regular highlighters (though you can derive them
-   /// from standard tags to allow highlighters to fall back to those).
-   let Tag$2 = class Tag {
-       /// @internal
-       constructor(
-       /// The set of this tag and all its parent tags, starting with
-       /// this one itself and sorted in order of decreasing specificity.
-       set, 
-       /// The base unmodified tag that this one is based on, if it's
-       /// modified @internal
-       base, 
-       /// The modifiers applied to this.base @internal
-       modified) {
-           this.set = set;
-           this.base = base;
-           this.modified = modified;
-           /// @internal
-           this.id = nextTagID$2++;
-       }
-       /// Define a new tag. If `parent` is given, the tag is treated as a
-       /// sub-tag of that parent, and
-       /// [highlighters](#highlight.tagHighlighter) that don't mention
-       /// this tag will try to fall back to the parent tag (or grandparent
-       /// tag, etc).
-       static define(parent) {
-           if (parent === null || parent === void 0 ? void 0 : parent.base)
-               throw new Error("Can not derive from a modified tag");
-           let tag = new Tag([], null, []);
-           tag.set.push(tag);
-           if (parent)
-               for (let t of parent.set)
-                   tag.set.push(t);
-           return tag;
-       }
-       /// Define a tag _modifier_, which is a function that, given a tag,
-       /// will return a tag that is a subtag of the original. Applying the
-       /// same modifier to a twice tag will return the same value (`m1(t1)
-       /// == m1(t1)`) and applying multiple modifiers will, regardless or
-       /// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
-       ///
-       /// When multiple modifiers are applied to a given base tag, each
-       /// smaller set of modifiers is registered as a parent, so that for
-       /// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
-       /// `m1(m3(t1)`, and so on.
-       static defineModifier() {
-           let mod = new Modifier$2;
-           return (tag) => {
-               if (tag.modified.indexOf(mod) > -1)
-                   return tag;
-               return Modifier$2.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
-           };
-       }
-   };
-   let nextModifierID$2 = 0;
-   let Modifier$2 = class Modifier {
-       constructor() {
-           this.instances = [];
-           this.id = nextModifierID$2++;
-       }
-       static get(base, mods) {
-           if (!mods.length)
-               return base;
-           let exists = mods[0].instances.find(t => t.base == base && sameArray$5(mods, t.modified));
-           if (exists)
-               return exists;
-           let set = [], tag = new Tag$2(set, base, mods);
-           for (let m of mods)
-               m.instances.push(tag);
-           let configs = permute$1(mods);
-           for (let parent of base.set)
-               for (let config of configs)
-                   set.push(Modifier.get(parent, config));
-           return tag;
-       }
-   };
-   function sameArray$5(a, b) {
-       return a.length == b.length && a.every((x, i) => x == b[i]);
-   }
-   function permute$1(array) {
-       let result = [array];
-       for (let i = 0; i < array.length; i++) {
-           for (let a of permute$1(array.slice(0, i).concat(array.slice(i + 1))))
-               result.push(a);
-       }
-       return result;
-   }
-   /// This function is used to add a set of tags to a language syntax
-   /// via [`NodeSet.extend`](#common.NodeSet.extend) or
-   /// [`LRParser.configure`](#lr.LRParser.configure).
-   ///
-   /// The argument object maps node selectors to [highlighting
-   /// tags](#highlight.Tag) or arrays of tags.
-   ///
-   /// Node selectors may hold one or more (space-separated) node paths.
-   /// Such a path can be a [node name](#common.NodeType.name), or
-   /// multiple node names (or `*` wildcards) separated by slash
-   /// characters, as in `"Block/Declaration/VariableName"`. Such a path
-   /// matches the final node but only if its direct parent nodes are the
-   /// other nodes mentioned. A `*` in such a path matches any parent,
-   /// but only a single level—wildcards that match multiple parents
-   /// aren't supported, both for efficiency reasons and because Lezer
-   /// trees make it rather hard to reason about what they would match.)
-   ///
-   /// A path can be ended with `/...` to indicate that the tag assigned
-   /// to the node should also apply to all child nodes, even if they
-   /// match their own style (by default, only the innermost style is
-   /// used).
-   ///
-   /// When a path ends in `!`, as in `Attribute!`, no further matching
-   /// happens for the node's child nodes, and the entire node gets the
-   /// given style.
-   ///
-   /// In this notation, node names that contain `/`, `!`, `*`, or `...`
-   /// must be quoted as JSON strings.
-   ///
-   /// For example:
-   ///
-   /// ```javascript
-   /// parser.withProps(
-   ///   styleTags({
-   ///     // Style Number and BigNumber nodes
-   ///     "Number BigNumber": tags.number,
-   ///     // Style Escape nodes whose parent is String
-   ///     "String/Escape": tags.escape,
-   ///     // Style anything inside Attributes nodes
-   ///     "Attributes!": tags.meta,
-   ///     // Add a style to all content inside Italic nodes
-   ///     "Italic/...": tags.emphasis,
-   ///     // Style InvalidString nodes as both `string` and `invalid`
-   ///     "InvalidString": [tags.string, tags.invalid],
-   ///     // Style the node named "/" as punctuation
-   ///     '"/"': tags.punctuation
-   ///   })
-   /// )
-   /// ```
-   function styleTags$2(spec) {
-       let byName = Object.create(null);
-       for (let prop in spec) {
-           let tags = spec[prop];
-           if (!Array.isArray(tags))
-               tags = [tags];
-           for (let part of prop.split(" "))
-               if (part) {
-                   let pieces = [], mode = 2 /* Normal */, rest = part;
-                   for (let pos = 0;;) {
-                       if (rest == "..." && pos > 0 && pos + 3 == part.length) {
-                           mode = 1 /* Inherit */;
-                           break;
-                       }
-                       let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
-                       if (!m)
-                           throw new RangeError("Invalid path: " + part);
-                       pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
-                       pos += m[0].length;
-                       if (pos == part.length)
-                           break;
-                       let next = part[pos++];
-                       if (pos == part.length && next == "!") {
-                           mode = 0 /* Opaque */;
-                           break;
-                       }
-                       if (next != "/")
-                           throw new RangeError("Invalid path: " + part);
-                       rest = part.slice(pos);
-                   }
-                   let last = pieces.length - 1, inner = pieces[last];
-                   if (!inner)
-                       throw new RangeError("Invalid path: " + part);
-                   let rule = new Rule$2(tags, mode, last > 0 ? pieces.slice(0, last) : null);
-                   byName[inner] = rule.sort(byName[inner]);
-               }
-       }
-       return ruleNodeProp$2.add(byName);
-   }
-   const ruleNodeProp$2 = new NodeProp$2();
-   let Rule$2 = class Rule {
-       constructor(tags, mode, context, next) {
-           this.tags = tags;
-           this.mode = mode;
-           this.context = context;
-           this.next = next;
-       }
-       sort(other) {
-           if (!other || other.depth < this.depth) {
-               this.next = other;
-               return this;
-           }
-           other.next = this.sort(other.next);
-           return other;
-       }
-       get depth() { return this.context ? this.context.length : 0; }
-   };
-   /// Define a [highlighter](#highlight.Highlighter) from an array of
-   /// tag/class pairs. Classes associated with more specific tags will
-   /// take precedence.
-   function tagHighlighter$2(tags, options) {
-       let map = Object.create(null);
-       for (let style of tags) {
-           if (!Array.isArray(style.tag))
-               map[style.tag.id] = style.class;
-           else
-               for (let tag of style.tag)
-                   map[tag.id] = style.class;
-       }
-       let { scope, all = null } = options || {};
-       return {
-           style: (tags) => {
-               let cls = all;
-               for (let tag of tags) {
-                   for (let sub of tag.set) {
-                       let tagClass = map[sub.id];
-                       if (tagClass) {
-                           cls = cls ? cls + " " + tagClass : tagClass;
-                           break;
-                       }
-                   }
-               }
-               return cls;
-           },
-           scope: scope
-       };
-   }
-   function highlightTags$1(highlighters, tags) {
-       let result = null;
-       for (let highlighter of highlighters) {
-           let value = highlighter.style(tags);
-           if (value)
-               result = result ? result + " " + value : value;
-       }
-       return result;
-   }
-   /// Highlight the given [tree](#common.Tree) with the given
-   /// [highlighter](#highlight.Highlighter).
-   function highlightTree$1(tree, highlighter, 
-   /// Assign styling to a region of the text. Will be called, in order
-   /// of position, for any ranges where more than zero classes apply.
-   /// `classes` is a space separated string of CSS classes.
-   putStyle, 
-   /// The start of the range to highlight.
-   from = 0, 
-   /// The end of the range.
-   to = tree.length) {
-       let builder = new HighlightBuilder$1(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
-       builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
-       builder.flush(to);
-   }
-   let HighlightBuilder$1 = class HighlightBuilder {
-       constructor(at, highlighters, span) {
-           this.at = at;
-           this.highlighters = highlighters;
-           this.span = span;
-           this.class = "";
-       }
-       startSpan(at, cls) {
-           if (cls != this.class) {
-               this.flush(at);
-               if (at > this.at)
-                   this.at = at;
-               this.class = cls;
-           }
-       }
-       flush(to) {
-           if (to > this.at && this.class)
-               this.span(this.at, to, this.class);
-       }
-       highlightRange(cursor, from, to, inheritedClass, highlighters) {
-           let { type, from: start, to: end } = cursor;
-           if (start >= to || end <= from)
-               return;
-           if (type.isTop)
-               highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
-           let cls = inheritedClass;
-           let rule = type.prop(ruleNodeProp$2), opaque = false;
-           while (rule) {
-               if (!rule.context || cursor.matchContext(rule.context)) {
-                   let tagCls = highlightTags$1(highlighters, rule.tags);
-                   if (tagCls) {
-                       if (cls)
-                           cls += " ";
-                       cls += tagCls;
-                       if (rule.mode == 1 /* Inherit */)
-                           inheritedClass += (inheritedClass ? " " : "") + tagCls;
-                       else if (rule.mode == 0 /* Opaque */)
-                           opaque = true;
-                   }
-                   break;
-               }
-               rule = rule.next;
-           }
-           this.startSpan(cursor.from, cls);
-           if (opaque)
-               return;
-           let mounted = cursor.tree && cursor.tree.prop(NodeProp$2.mounted);
-           if (mounted && mounted.overlay) {
-               let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
-               let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
-               let hasChild = cursor.firstChild();
-               for (let i = 0, pos = start;; i++) {
-                   let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
-                   let nextPos = next ? next.from + start : end;
-                   let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
-                   if (rangeFrom < rangeTo && hasChild) {
-                       while (cursor.from < rangeTo) {
-                           this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
-                           this.startSpan(Math.min(to, cursor.to), cls);
-                           if (cursor.to >= nextPos || !cursor.nextSibling())
-                               break;
-                       }
-                   }
-                   if (!next || nextPos > to)
-                       break;
-                   pos = next.to + start;
-                   if (pos > from) {
-                       this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), inheritedClass, innerHighlighters);
-                       this.startSpan(pos, cls);
-                   }
-               }
-               if (hasChild)
-                   cursor.parent();
-           }
-           else if (cursor.firstChild()) {
-               do {
-                   if (cursor.to <= from)
-                       continue;
-                   if (cursor.from >= to)
-                       break;
-                   this.highlightRange(cursor, from, to, inheritedClass, highlighters);
-                   this.startSpan(Math.min(to, cursor.to), cls);
-               } while (cursor.nextSibling());
-               cursor.parent();
-           }
-       }
-   };
-   const t$2 = Tag$2.define;
-   const comment$2 = t$2(), name$2 = t$2(), typeName$2 = t$2(name$2), propertyName$2 = t$2(name$2), literal$2 = t$2(), string$2 = t$2(literal$2), number$2 = t$2(literal$2), content$2 = t$2(), heading$2 = t$2(content$2), keyword$2 = t$2(), operator$2 = t$2(), punctuation$2 = t$2(), bracket$2 = t$2(punctuation$2), meta$2 = t$2();
-   /// The default set of highlighting [tags](#highlight.Tag).
-   ///
-   /// This collection is heavily biased towards programming languages,
-   /// and necessarily incomplete. A full ontology of syntactic
-   /// constructs would fill a stack of books, and be impractical to
-   /// write themes for. So try to make do with this set. If all else
-   /// fails, [open an
-   /// issue](https://github.com/codemirror/codemirror.next) to propose a
-   /// new tag, or [define](#highlight.Tag^define) a local custom tag for
-   /// your use case.
-   ///
-   /// Note that it is not obligatory to always attach the most specific
-   /// tag possible to an element—if your grammar can't easily
-   /// distinguish a certain type of element (such as a local variable),
-   /// it is okay to style it as its more general variant (a variable).
-   /// 
-   /// For tags that extend some parent tag, the documentation links to
-   /// the parent.
-   const tags$2 = {
-       /// A comment.
-       comment: comment$2,
-       /// A line [comment](#highlight.tags.comment).
-       lineComment: t$2(comment$2),
-       /// A block [comment](#highlight.tags.comment).
-       blockComment: t$2(comment$2),
-       /// A documentation [comment](#highlight.tags.comment).
-       docComment: t$2(comment$2),
-       /// Any kind of identifier.
-       name: name$2,
-       /// The [name](#highlight.tags.name) of a variable.
-       variableName: t$2(name$2),
-       /// A type [name](#highlight.tags.name).
-       typeName: typeName$2,
-       /// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
-       tagName: t$2(typeName$2),
-       /// A property or field [name](#highlight.tags.name).
-       propertyName: propertyName$2,
-       /// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
-       attributeName: t$2(propertyName$2),
-       /// The [name](#highlight.tags.name) of a class.
-       className: t$2(name$2),
-       /// A label [name](#highlight.tags.name).
-       labelName: t$2(name$2),
-       /// A namespace [name](#highlight.tags.name).
-       namespace: t$2(name$2),
-       /// The [name](#highlight.tags.name) of a macro.
-       macroName: t$2(name$2),
-       /// A literal value.
-       literal: literal$2,
-       /// A string [literal](#highlight.tags.literal).
-       string: string$2,
-       /// A documentation [string](#highlight.tags.string).
-       docString: t$2(string$2),
-       /// A character literal (subtag of [string](#highlight.tags.string)).
-       character: t$2(string$2),
-       /// An attribute value (subtag of [string](#highlight.tags.string)).
-       attributeValue: t$2(string$2),
-       /// A number [literal](#highlight.tags.literal).
-       number: number$2,
-       /// An integer [number](#highlight.tags.number) literal.
-       integer: t$2(number$2),
-       /// A floating-point [number](#highlight.tags.number) literal.
-       float: t$2(number$2),
-       /// A boolean [literal](#highlight.tags.literal).
-       bool: t$2(literal$2),
-       /// Regular expression [literal](#highlight.tags.literal).
-       regexp: t$2(literal$2),
-       /// An escape [literal](#highlight.tags.literal), for example a
-       /// backslash escape in a string.
-       escape: t$2(literal$2),
-       /// A color [literal](#highlight.tags.literal).
-       color: t$2(literal$2),
-       /// A URL [literal](#highlight.tags.literal).
-       url: t$2(literal$2),
-       /// A language keyword.
-       keyword: keyword$2,
-       /// The [keyword](#highlight.tags.keyword) for the self or this
-       /// object.
-       self: t$2(keyword$2),
-       /// The [keyword](#highlight.tags.keyword) for null.
-       null: t$2(keyword$2),
-       /// A [keyword](#highlight.tags.keyword) denoting some atomic value.
-       atom: t$2(keyword$2),
-       /// A [keyword](#highlight.tags.keyword) that represents a unit.
-       unit: t$2(keyword$2),
-       /// A modifier [keyword](#highlight.tags.keyword).
-       modifier: t$2(keyword$2),
-       /// A [keyword](#highlight.tags.keyword) that acts as an operator.
-       operatorKeyword: t$2(keyword$2),
-       /// A control-flow related [keyword](#highlight.tags.keyword).
-       controlKeyword: t$2(keyword$2),
-       /// A [keyword](#highlight.tags.keyword) that defines something.
-       definitionKeyword: t$2(keyword$2),
-       /// A [keyword](#highlight.tags.keyword) related to defining or
-       /// interfacing with modules.
-       moduleKeyword: t$2(keyword$2),
-       /// An operator.
-       operator: operator$2,
-       /// An [operator](#highlight.tags.operator) that defines something.
-       derefOperator: t$2(operator$2),
-       /// Arithmetic-related [operator](#highlight.tags.operator).
-       arithmeticOperator: t$2(operator$2),
-       /// Logical [operator](#highlight.tags.operator).
-       logicOperator: t$2(operator$2),
-       /// Bit [operator](#highlight.tags.operator).
-       bitwiseOperator: t$2(operator$2),
-       /// Comparison [operator](#highlight.tags.operator).
-       compareOperator: t$2(operator$2),
-       /// [Operator](#highlight.tags.operator) that updates its operand.
-       updateOperator: t$2(operator$2),
-       /// [Operator](#highlight.tags.operator) that defines something.
-       definitionOperator: t$2(operator$2),
-       /// Type-related [operator](#highlight.tags.operator).
-       typeOperator: t$2(operator$2),
-       /// Control-flow [operator](#highlight.tags.operator).
-       controlOperator: t$2(operator$2),
-       /// Program or markup punctuation.
-       punctuation: punctuation$2,
-       /// [Punctuation](#highlight.tags.punctuation) that separates
-       /// things.
-       separator: t$2(punctuation$2),
-       /// Bracket-style [punctuation](#highlight.tags.punctuation).
-       bracket: bracket$2,
-       /// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
-       /// tokens).
-       angleBracket: t$2(bracket$2),
-       /// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
-       /// tokens).
-       squareBracket: t$2(bracket$2),
-       /// Parentheses (usually `(` and `)` tokens). Subtag of
-       /// [bracket](#highlight.tags.bracket).
-       paren: t$2(bracket$2),
-       /// Braces (usually `{` and `}` tokens). Subtag of
-       /// [bracket](#highlight.tags.bracket).
-       brace: t$2(bracket$2),
-       /// Content, for example plain text in XML or markup documents.
-       content: content$2,
-       /// [Content](#highlight.tags.content) that represents a heading.
-       heading: heading$2,
-       /// A level 1 [heading](#highlight.tags.heading).
-       heading1: t$2(heading$2),
-       /// A level 2 [heading](#highlight.tags.heading).
-       heading2: t$2(heading$2),
-       /// A level 3 [heading](#highlight.tags.heading).
-       heading3: t$2(heading$2),
-       /// A level 4 [heading](#highlight.tags.heading).
-       heading4: t$2(heading$2),
-       /// A level 5 [heading](#highlight.tags.heading).
-       heading5: t$2(heading$2),
-       /// A level 6 [heading](#highlight.tags.heading).
-       heading6: t$2(heading$2),
-       /// A prose separator (such as a horizontal rule).
-       contentSeparator: t$2(content$2),
-       /// [Content](#highlight.tags.content) that represents a list.
-       list: t$2(content$2),
-       /// [Content](#highlight.tags.content) that represents a quote.
-       quote: t$2(content$2),
-       /// [Content](#highlight.tags.content) that is emphasized.
-       emphasis: t$2(content$2),
-       /// [Content](#highlight.tags.content) that is styled strong.
-       strong: t$2(content$2),
-       /// [Content](#highlight.tags.content) that is part of a link.
-       link: t$2(content$2),
-       /// [Content](#highlight.tags.content) that is styled as code or
-       /// monospace.
-       monospace: t$2(content$2),
-       /// [Content](#highlight.tags.content) that has a strike-through
-       /// style.
-       strikethrough: t$2(content$2),
-       /// Inserted text in a change-tracking format.
-       inserted: t$2(),
-       /// Deleted text.
-       deleted: t$2(),
-       /// Changed text.
-       changed: t$2(),
-       /// An invalid or unsyntactic element.
-       invalid: t$2(),
-       /// Metadata or meta-instruction.
-       meta: meta$2,
-       /// [Metadata](#highlight.tags.meta) that applies to the entire
-       /// document.
-       documentMeta: t$2(meta$2),
-       /// [Metadata](#highlight.tags.meta) that annotates or adds
-       /// attributes to a given syntactic element.
-       annotation: t$2(meta$2),
-       /// Processing instruction or preprocessor directive. Subtag of
-       /// [meta](#highlight.tags.meta).
-       processingInstruction: t$2(meta$2),
-       /// [Modifier](#highlight.Tag^defineModifier) that indicates that a
-       /// given element is being defined. Expected to be used with the
-       /// various [name](#highlight.tags.name) tags.
-       definition: Tag$2.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) that indicates that
-       /// something is constant. Mostly expected to be used with
-       /// [variable names](#highlight.tags.variableName).
-       constant: Tag$2.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) used to indicate that
-       /// a [variable](#highlight.tags.variableName) or [property
-       /// name](#highlight.tags.propertyName) is being called or defined
-       /// as a function.
-       function: Tag$2.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) that can be applied to
-       /// [names](#highlight.tags.name) to indicate that they belong to
-       /// the language's standard environment.
-       standard: Tag$2.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) that indicates a given
-       /// [names](#highlight.tags.name) is local to some scope.
-       local: Tag$2.defineModifier(),
-       /// A generic variant [modifier](#highlight.Tag^defineModifier) that
-       /// can be used to tag language-specific alternative variants of
-       /// some common tag. It is recommended for themes to define special
-       /// forms of at least the [string](#highlight.tags.string) and
-       /// [variable name](#highlight.tags.variableName) tags, since those
-       /// come up a lot.
-       special: Tag$2.defineModifier()
-   };
-   /// This is a highlighter that adds stable, predictable classes to
-   /// tokens, for styling with external CSS.
-   ///
-   /// The following tags are mapped to their name prefixed with `"tok-"`
-   /// (for example `"tok-comment"`):
-   ///
-   /// * [`link`](#highlight.tags.link)
-   /// * [`heading`](#highlight.tags.heading)
-   /// * [`emphasis`](#highlight.tags.emphasis)
-   /// * [`strong`](#highlight.tags.strong)
-   /// * [`keyword`](#highlight.tags.keyword)
-   /// * [`atom`](#highlight.tags.atom) [`bool`](#highlight.tags.bool)
-   /// * [`url`](#highlight.tags.url)
-   /// * [`labelName`](#highlight.tags.labelName)
-   /// * [`inserted`](#highlight.tags.inserted)
-   /// * [`deleted`](#highlight.tags.deleted)
-   /// * [`literal`](#highlight.tags.literal)
-   /// * [`string`](#highlight.tags.string)
-   /// * [`number`](#highlight.tags.number)
-   /// * [`variableName`](#highlight.tags.variableName)
-   /// * [`typeName`](#highlight.tags.typeName)
-   /// * [`namespace`](#highlight.tags.namespace)
-   /// * [`className`](#highlight.tags.className)
-   /// * [`macroName`](#highlight.tags.macroName)
-   /// * [`propertyName`](#highlight.tags.propertyName)
-   /// * [`operator`](#highlight.tags.operator)
-   /// * [`comment`](#highlight.tags.comment)
-   /// * [`meta`](#highlight.tags.meta)
-   /// * [`punctuation`](#highlight.tags.punctuation)
-   /// * [`invalid`](#highlight.tags.invalid)
-   ///
-   /// In addition, these mappings are provided:
-   ///
-   /// * [`regexp`](#highlight.tags.regexp),
-   ///   [`escape`](#highlight.tags.escape), and
-   ///   [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
-   ///   are mapped to `"tok-string2"`
-   /// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
-   ///   to `"tok-variableName2"`
-   /// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
-   ///   to `"tok-variableName tok-local"`
-   /// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
-   ///   to `"tok-variableName tok-definition"`
-   /// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
-   ///   to `"tok-propertyName tok-definition"`
-   tagHighlighter$2([
-       { tag: tags$2.link, class: "tok-link" },
-       { tag: tags$2.heading, class: "tok-heading" },
-       { tag: tags$2.emphasis, class: "tok-emphasis" },
-       { tag: tags$2.strong, class: "tok-strong" },
-       { tag: tags$2.keyword, class: "tok-keyword" },
-       { tag: tags$2.atom, class: "tok-atom" },
-       { tag: tags$2.bool, class: "tok-bool" },
-       { tag: tags$2.url, class: "tok-url" },
-       { tag: tags$2.labelName, class: "tok-labelName" },
-       { tag: tags$2.inserted, class: "tok-inserted" },
-       { tag: tags$2.deleted, class: "tok-deleted" },
-       { tag: tags$2.literal, class: "tok-literal" },
-       { tag: tags$2.string, class: "tok-string" },
-       { tag: tags$2.number, class: "tok-number" },
-       { tag: [tags$2.regexp, tags$2.escape, tags$2.special(tags$2.string)], class: "tok-string2" },
-       { tag: tags$2.variableName, class: "tok-variableName" },
-       { tag: tags$2.local(tags$2.variableName), class: "tok-variableName tok-local" },
-       { tag: tags$2.definition(tags$2.variableName), class: "tok-variableName tok-definition" },
-       { tag: tags$2.special(tags$2.variableName), class: "tok-variableName2" },
-       { tag: tags$2.definition(tags$2.propertyName), class: "tok-propertyName tok-definition" },
-       { tag: tags$2.typeName, class: "tok-typeName" },
-       { tag: tags$2.namespace, class: "tok-namespace" },
-       { tag: tags$2.className, class: "tok-className" },
-       { tag: tags$2.macroName, class: "tok-macroName" },
-       { tag: tags$2.propertyName, class: "tok-propertyName" },
-       { tag: tags$2.operator, class: "tok-operator" },
-       { tag: tags$2.comment, class: "tok-comment" },
-       { tag: tags$2.meta, class: "tok-meta" },
-       { tag: tags$2.invalid, class: "tok-invalid" },
-       { tag: tags$2.punctuation, class: "tok-punctuation" }
-   ]);
-
-   var _a$2;
-   /**
-   Node prop stored in a parser's top syntax node to provide the
-   facet that stores language-specific data for that language.
-   */
-   const languageDataProp$2 = /*@__PURE__*/new NodeProp$2();
-   /**
-   A language object manages parsing and per-language
-   [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
-   managed as a [Lezer](https://lezer.codemirror.net) tree. The class
-   can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
-   subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
-   via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
-   for stream parsers.
-   */
-   let Language$2 = class Language {
-       /**
-       Construct a language object. If you need to invoke this
-       directly, first define a data facet with
-       [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
-       configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
-       to the language's outer syntax node.
-       */
-       constructor(
-       /**
-       The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
-       used for this language.
-       */
-       data, parser, extraExtensions = []) {
-           this.data = data;
-           // Kludge to define EditorState.tree as a debugging helper,
-           // without the EditorState package actually knowing about
-           // languages and lezer trees.
-           if (!EditorState$3.prototype.hasOwnProperty("tree"))
-               Object.defineProperty(EditorState$3.prototype, "tree", { get() { return syntaxTree$2(this); } });
-           this.parser = parser;
-           this.extension = [
-               language$2.of(this),
-               EditorState$3.languageData.of((state, pos, side) => state.facet(languageDataFacetAt$1(state, pos, side)))
-           ].concat(extraExtensions);
-       }
-       /**
-       Query whether this language is active at the given position.
-       */
-       isActiveAt(state, pos, side = -1) {
-           return languageDataFacetAt$1(state, pos, side) == this.data;
-       }
-       /**
-       Find the document regions that were parsed using this language.
-       The returned regions will _include_ any nested languages rooted
-       in this language, when those exist.
-       */
-       findRegions(state) {
-           let lang = state.facet(language$2);
-           if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
-               return [{ from: 0, to: state.doc.length }];
-           if (!lang || !lang.allowsNesting)
-               return [];
-           let result = [];
-           let explore = (tree, from) => {
-               if (tree.prop(languageDataProp$2) == this.data) {
-                   result.push({ from, to: from + tree.length });
-                   return;
-               }
-               let mount = tree.prop(NodeProp$2.mounted);
-               if (mount) {
-                   if (mount.tree.prop(languageDataProp$2) == this.data) {
-                       if (mount.overlay)
-                           for (let r of mount.overlay)
-                               result.push({ from: r.from + from, to: r.to + from });
-                       else
-                           result.push({ from: from, to: from + tree.length });
-                       return;
-                   }
-                   else if (mount.overlay) {
-                       let size = result.length;
-                       explore(mount.tree, mount.overlay[0].from + from);
-                       if (result.length > size)
-                           return;
-                   }
-               }
-               for (let i = 0; i < tree.children.length; i++) {
-                   let ch = tree.children[i];
-                   if (ch instanceof Tree$2)
-                       explore(ch, tree.positions[i] + from);
-               }
-           };
-           explore(syntaxTree$2(state), 0);
-           return result;
-       }
-       /**
-       Indicates whether this language allows nested languages. The
-       default implementation returns true.
-       */
-       get allowsNesting() { return true; }
-   };
-   /**
-   @internal
-   */
-   Language$2.setState = /*@__PURE__*/StateEffect$3.define();
-   function languageDataFacetAt$1(state, pos, side) {
-       let topLang = state.facet(language$2);
-       if (!topLang)
-           return null;
-       let facet = topLang.data;
-       if (topLang.allowsNesting) {
-           for (let node = syntaxTree$2(state).topNode; node; node = node.enter(pos, side, IterMode$2.ExcludeBuffers))
-               facet = node.type.prop(languageDataProp$2) || facet;
-       }
-       return facet;
-   }
-   /**
-   Get the syntax tree for a state, which is the current (possibly
-   incomplete) parse tree of the active
-   [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
-   language available.
-   */
-   function syntaxTree$2(state) {
-       let field = state.field(Language$2.state, false);
-       return field ? field.tree : Tree$2.empty;
-   }
-   // Lezer-style Input object for a Text document.
-   let DocInput$2 = class DocInput {
-       constructor(doc, length = doc.length) {
-           this.doc = doc;
-           this.length = length;
-           this.cursorPos = 0;
-           this.string = "";
-           this.cursor = doc.iter();
-       }
-       syncTo(pos) {
-           this.string = this.cursor.next(pos - this.cursorPos).value;
-           this.cursorPos = pos + this.string.length;
-           return this.cursorPos - this.string.length;
-       }
-       chunk(pos) {
-           this.syncTo(pos);
-           return this.string;
-       }
-       get lineChunks() { return true; }
-       read(from, to) {
-           let stringStart = this.cursorPos - this.string.length;
-           if (from < stringStart || to >= this.cursorPos)
-               return this.doc.sliceString(from, to);
-           else
-               return this.string.slice(from - stringStart, to - stringStart);
-       }
-   };
-   let currentContext$2 = null;
-   /**
-   A parse context provided to parsers working on the editor content.
-   */
-   let ParseContext$2 = class ParseContext {
-       constructor(parser, 
-       /**
-       The current editor state.
-       */
-       state, 
-       /**
-       Tree fragments that can be reused by incremental re-parses.
-       */
-       fragments = [], 
-       /**
-       @internal
-       */
-       tree, 
-       /**
-       @internal
-       */
-       treeLen, 
-       /**
-       The current editor viewport (or some overapproximation
-       thereof). Intended to be used for opportunistically avoiding
-       work (in which case
-       [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
-       should be called to make sure the parser is restarted when the
-       skipped region becomes visible).
-       */
-       viewport, 
-       /**
-       @internal
-       */
-       skipped, 
-       /**
-       This is where skipping parsers can register a promise that,
-       when resolved, will schedule a new parse. It is cleared when
-       the parse worker picks up the promise. @internal
-       */
-       scheduleOn) {
-           this.parser = parser;
-           this.state = state;
-           this.fragments = fragments;
-           this.tree = tree;
-           this.treeLen = treeLen;
-           this.viewport = viewport;
-           this.skipped = skipped;
-           this.scheduleOn = scheduleOn;
-           this.parse = null;
-           /**
-           @internal
-           */
-           this.tempSkipped = [];
-       }
-       /**
-       @internal
-       */
-       static create(parser, state, viewport) {
-           return new ParseContext(parser, state, [], Tree$2.empty, 0, viewport, [], null);
-       }
-       startParse() {
-           return this.parser.startParse(new DocInput$2(this.state.doc), this.fragments);
-       }
-       /**
-       @internal
-       */
-       work(until, upto) {
-           if (upto != null && upto >= this.state.doc.length)
-               upto = undefined;
-           if (this.tree != Tree$2.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
-               this.takeTree();
-               return true;
-           }
-           return this.withContext(() => {
-               var _a;
-               if (typeof until == "number") {
-                   let endTime = Date.now() + until;
-                   until = () => Date.now() > endTime;
-               }
-               if (!this.parse)
-                   this.parse = this.startParse();
-               if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
-                   upto < this.state.doc.length)
-                   this.parse.stopAt(upto);
-               for (;;) {
-                   let done = this.parse.advance();
-                   if (done) {
-                       this.fragments = this.withoutTempSkipped(TreeFragment$2.addTree(done, this.fragments, this.parse.stoppedAt != null));
-                       this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
-                       this.tree = done;
-                       this.parse = null;
-                       if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
-                           this.parse = this.startParse();
-                       else
-                           return true;
-                   }
-                   if (until())
-                       return false;
-               }
-           });
-       }
-       /**
-       @internal
-       */
-       takeTree() {
-           let pos, tree;
-           if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
-               if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
-                   this.parse.stopAt(pos);
-               this.withContext(() => { while (!(tree = this.parse.advance())) { } });
-               this.treeLen = pos;
-               this.tree = tree;
-               this.fragments = this.withoutTempSkipped(TreeFragment$2.addTree(this.tree, this.fragments, true));
-               this.parse = null;
-           }
-       }
-       withContext(f) {
-           let prev = currentContext$2;
-           currentContext$2 = this;
-           try {
-               return f();
-           }
-           finally {
-               currentContext$2 = prev;
-           }
-       }
-       withoutTempSkipped(fragments) {
-           for (let r; r = this.tempSkipped.pop();)
-               fragments = cutFragments$2(fragments, r.from, r.to);
-           return fragments;
-       }
-       /**
-       @internal
-       */
-       changes(changes, newState) {
-           let { fragments, tree, treeLen, viewport, skipped } = this;
-           this.takeTree();
-           if (!changes.empty) {
-               let ranges = [];
-               changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
-               fragments = TreeFragment$2.applyChanges(fragments, ranges);
-               tree = Tree$2.empty;
-               treeLen = 0;
-               viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
-               if (this.skipped.length) {
-                   skipped = [];
-                   for (let r of this.skipped) {
-                       let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
-                       if (from < to)
-                           skipped.push({ from, to });
-                   }
-               }
-           }
-           return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
-       }
-       /**
-       @internal
-       */
-       updateViewport(viewport) {
-           if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
-               return false;
-           this.viewport = viewport;
-           let startLen = this.skipped.length;
-           for (let i = 0; i < this.skipped.length; i++) {
-               let { from, to } = this.skipped[i];
-               if (from < viewport.to && to > viewport.from) {
-                   this.fragments = cutFragments$2(this.fragments, from, to);
-                   this.skipped.splice(i--, 1);
-               }
-           }
-           if (this.skipped.length >= startLen)
-               return false;
-           this.reset();
-           return true;
-       }
-       /**
-       @internal
-       */
-       reset() {
-           if (this.parse) {
-               this.takeTree();
-               this.parse = null;
-           }
-       }
-       /**
-       Notify the parse scheduler that the given region was skipped
-       because it wasn't in view, and the parse should be restarted
-       when it comes into view.
-       */
-       skipUntilInView(from, to) {
-           this.skipped.push({ from, to });
-       }
-       /**
-       Returns a parser intended to be used as placeholder when
-       asynchronously loading a nested parser. It'll skip its input and
-       mark it as not-really-parsed, so that the next update will parse
-       it again.
-       
-       When `until` is given, a reparse will be scheduled when that
-       promise resolves.
-       */
-       static getSkippingParser(until) {
-           return new class extends Parser$2 {
-               createParse(input, fragments, ranges) {
-                   let from = ranges[0].from, to = ranges[ranges.length - 1].to;
-                   let parser = {
-                       parsedPos: from,
-                       advance() {
-                           let cx = currentContext$2;
-                           if (cx) {
-                               for (let r of ranges)
-                                   cx.tempSkipped.push(r);
-                               if (until)
-                                   cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
-                           }
-                           this.parsedPos = to;
-                           return new Tree$2(NodeType$2.none, [], [], to - from);
-                       },
-                       stoppedAt: null,
-                       stopAt() { }
-                   };
-                   return parser;
-               }
-           };
-       }
-       /**
-       @internal
-       */
-       isDone(upto) {
-           upto = Math.min(upto, this.state.doc.length);
-           let frags = this.fragments;
-           return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
-       }
-       /**
-       Get the context for the current parse, or `null` if no editor
-       parse is in progress.
-       */
-       static get() { return currentContext$2; }
-   };
-   function cutFragments$2(fragments, from, to) {
-       return TreeFragment$2.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
-   }
-   let LanguageState$2 = class LanguageState {
-       constructor(
-       // A mutable parse state that is used to preserve work done during
-       // the lifetime of a state when moving to the next state.
-       context) {
-           this.context = context;
-           this.tree = context.tree;
-       }
-       apply(tr) {
-           if (!tr.docChanged && this.tree == this.context.tree)
-               return this;
-           let newCx = this.context.changes(tr.changes, tr.state);
-           // If the previous parse wasn't done, go forward only up to its
-           // end position or the end of the viewport, to avoid slowing down
-           // state updates with parse work beyond the viewport.
-           let upto = this.context.treeLen == tr.startState.doc.length ? undefined
-               : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
-           if (!newCx.work(20 /* Apply */, upto))
-               newCx.takeTree();
-           return new LanguageState(newCx);
-       }
-       static init(state) {
-           let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
-           let parseState = ParseContext$2.create(state.facet(language$2).parser, state, { from: 0, to: vpTo });
-           if (!parseState.work(20 /* Apply */, vpTo))
-               parseState.takeTree();
-           return new LanguageState(parseState);
-       }
-   };
-   Language$2.state = /*@__PURE__*/StateField$3.define({
-       create: LanguageState$2.init,
-       update(value, tr) {
-           for (let e of tr.effects)
-               if (e.is(Language$2.setState))
-                   return e.value;
-           if (tr.startState.facet(language$2) != tr.state.facet(language$2))
-               return LanguageState$2.init(tr.state);
-           return value.apply(tr);
-       }
-   });
-   let requestIdle$2 = (callback) => {
-       let timeout = setTimeout(() => callback(), 500 /* MaxPause */);
-       return () => clearTimeout(timeout);
-   };
-   if (typeof requestIdleCallback != "undefined")
-       requestIdle$2 = (callback) => {
-           let idle = -1, timeout = setTimeout(() => {
-               idle = requestIdleCallback(callback, { timeout: 500 /* MaxPause */ - 100 /* MinPause */ });
-           }, 100 /* MinPause */);
-           return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
-       };
-   const isInputPending$2 = typeof navigator != "undefined" && ((_a$2 = navigator.scheduling) === null || _a$2 === void 0 ? void 0 : _a$2.isInputPending)
-       ? () => navigator.scheduling.isInputPending() : null;
-   const parseWorker$2 = /*@__PURE__*/ViewPlugin$3.fromClass(class ParseWorker {
-       constructor(view) {
-           this.view = view;
-           this.working = null;
-           this.workScheduled = 0;
-           // End of the current time chunk
-           this.chunkEnd = -1;
-           // Milliseconds of budget left for this chunk
-           this.chunkBudget = -1;
-           this.work = this.work.bind(this);
-           this.scheduleWork();
-       }
-       update(update) {
-           let cx = this.view.state.field(Language$2.state).context;
-           if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
-               this.scheduleWork();
-           if (update.docChanged) {
-               if (this.view.hasFocus)
-                   this.chunkBudget += 50 /* ChangeBonus */;
-               this.scheduleWork();
-           }
-           this.checkAsyncSchedule(cx);
-       }
-       scheduleWork() {
-           if (this.working)
-               return;
-           let { state } = this.view, field = state.field(Language$2.state);
-           if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
-               this.working = requestIdle$2(this.work);
-       }
-       work(deadline) {
-           this.working = null;
-           let now = Date.now();
-           if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
-               this.chunkEnd = now + 30000 /* ChunkTime */;
-               this.chunkBudget = 3000 /* ChunkBudget */;
-           }
-           if (this.chunkBudget <= 0)
-               return; // No more budget
-           let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language$2.state);
-           if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* MaxParseAhead */))
-               return;
-           let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Slice */, deadline && !isInputPending$2 ? Math.max(25 /* MinSlice */, deadline.timeRemaining() - 5) : 1e9);
-           let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
-           let done = field.context.work(() => {
-               return isInputPending$2 && isInputPending$2() || Date.now() > endTime;
-           }, vpTo + (viewportFirst ? 0 : 100000 /* MaxParseAhead */));
-           this.chunkBudget -= Date.now() - now;
-           if (done || this.chunkBudget <= 0) {
-               field.context.takeTree();
-               this.view.dispatch({ effects: Language$2.setState.of(new LanguageState$2(field.context)) });
-           }
-           if (this.chunkBudget > 0 && !(done && !viewportFirst))
-               this.scheduleWork();
-           this.checkAsyncSchedule(field.context);
-       }
-       checkAsyncSchedule(cx) {
-           if (cx.scheduleOn) {
-               this.workScheduled++;
-               cx.scheduleOn
-                   .then(() => this.scheduleWork())
-                   .catch(err => logException$3(this.view.state, err))
-                   .then(() => this.workScheduled--);
-               cx.scheduleOn = null;
-           }
-       }
-       destroy() {
-           if (this.working)
-               this.working();
-       }
-       isWorking() {
-           return !!(this.working || this.workScheduled > 0);
-       }
-   }, {
-       eventHandlers: { focus() { this.scheduleWork(); } }
-   });
-   /**
-   The facet used to associate a language with an editor state.
-   */
-   const language$2 = /*@__PURE__*/Facet$3.define({
-       combine(languages) { return languages.length ? languages[0] : null; },
-       enables: [Language$2.state, parseWorker$2]
-   });
-
-   /**
-   Facet that defines a way to provide a function that computes the
-   appropriate indentation depth at the start of a given line, or
-   `null` to indicate no appropriate indentation could be determined.
-   */
-   const indentService$1 = /*@__PURE__*/Facet$3.define();
-   /**
-   Facet for overriding the unit by which indentation happens.
-   Should be a string consisting either entirely of spaces or
-   entirely of tabs. When not set, this defaults to 2 spaces.
-   */
-   const indentUnit$2 = /*@__PURE__*/Facet$3.define({
-       combine: values => {
-           if (!values.length)
-               return "  ";
-           if (!/^(?: +|\t+)$/.test(values[0]))
-               throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
-           return values[0];
-       }
-   });
-   /**
-   Return the _column width_ of an indent unit in the state.
-   Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
-   facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
-   contains tabs.
-   */
-   function getIndentUnit$1(state) {
-       let unit = state.facet(indentUnit$2);
-       return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
-   }
-   /**
-   Create an indentation string that covers columns 0 to `cols`.
-   Will use tabs for as much of the columns as possible when the
-   [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
-   tabs.
-   */
-   function indentString$1(state, cols) {
-       let result = "", ts = state.tabSize;
-       if (state.facet(indentUnit$2).charCodeAt(0) == 9)
-           while (cols >= ts) {
-               result += "\t";
-               cols -= ts;
-           }
-       for (let i = 0; i < cols; i++)
-           result += " ";
-       return result;
-   }
-   /**
-   Get the indentation at the given position. Will first consult any
-   [indent services](https://codemirror.net/6/docs/ref/#language.indentService) that are registered,
-   and if none of those return an indentation, this will check the
-   syntax tree for the [indent node prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp)
-   and use that if found. Returns a number when an indentation could
-   be determined, and null otherwise.
-   */
-   function getIndentation$1(context, pos) {
-       if (context instanceof EditorState$3)
-           context = new IndentContext$1(context);
-       for (let service of context.state.facet(indentService$1)) {
-           let result = service(context, pos);
-           if (result != null)
-               return result;
-       }
-       let tree = syntaxTree$2(context.state);
-       return tree ? syntaxIndentation$1(context, tree, pos) : null;
-   }
-   /**
-   Indentation contexts are used when calling [indentation
-   services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
-   useful in indentation logic, and can selectively override the
-   indentation reported for some lines.
-   */
-   let IndentContext$1 = class IndentContext {
-       /**
-       Create an indent context.
-       */
-       constructor(
-       /**
-       The editor state.
-       */
-       state, 
-       /**
-       @internal
-       */
-       options = {}) {
-           this.state = state;
-           this.options = options;
-           this.unit = getIndentUnit$1(state);
-       }
-       /**
-       Get a description of the line at the given position, taking
-       [simulated line
-       breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
-       into account. If there is such a break at `pos`, the `bias`
-       argument determines whether the part of the line line before or
-       after the break is used.
-       */
-       lineAt(pos, bias = 1) {
-           let line = this.state.doc.lineAt(pos);
-           let { simulateBreak, simulateDoubleBreak } = this.options;
-           if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
-               if (simulateDoubleBreak && simulateBreak == pos)
-                   return { text: "", from: pos };
-               else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
-                   return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
-               else
-                   return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
-           }
-           return line;
-       }
-       /**
-       Get the text directly after `pos`, either the entire line
-       or the next 100 characters, whichever is shorter.
-       */
-       textAfterPos(pos, bias = 1) {
-           if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
-               return "";
-           let { text, from } = this.lineAt(pos, bias);
-           return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
-       }
-       /**
-       Find the column for the given position.
-       */
-       column(pos, bias = 1) {
-           let { text, from } = this.lineAt(pos, bias);
-           let result = this.countColumn(text, pos - from);
-           let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
-           if (override > -1)
-               result += override - this.countColumn(text, text.search(/\S|$/));
-           return result;
-       }
-       /**
-       Find the column position (taking tabs into account) of the given
-       position in the given string.
-       */
-       countColumn(line, pos = line.length) {
-           return countColumn$1(line, this.state.tabSize, pos);
-       }
-       /**
-       Find the indentation column of the line at the given point.
-       */
-       lineIndent(pos, bias = 1) {
-           let { text, from } = this.lineAt(pos, bias);
-           let override = this.options.overrideIndentation;
-           if (override) {
-               let overriden = override(from);
-               if (overriden > -1)
-                   return overriden;
-           }
-           return this.countColumn(text, text.search(/\S|$/));
-       }
-       /**
-       Returns the [simulated line
-       break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
-       for this context, if any.
-       */
-       get simulatedBreak() {
-           return this.options.simulateBreak || null;
-       }
-   };
-   /**
-   A syntax tree node prop used to associate indentation strategies
-   with node types. Such a strategy is a function from an indentation
-   context to a column number or null, where null indicates that no
-   definitive indentation can be determined.
-   */
-   const indentNodeProp$2 = /*@__PURE__*/new NodeProp$2();
-   // Compute the indentation for a given position from the syntax tree.
-   function syntaxIndentation$1(cx, ast, pos) {
-       return indentFrom$1(ast.resolveInner(pos).enterUnfinishedNodesBefore(pos), pos, cx);
-   }
-   function ignoreClosed$1(cx) {
-       return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
-   }
-   function indentStrategy$1(tree) {
-       let strategy = tree.type.prop(indentNodeProp$2);
-       if (strategy)
-           return strategy;
-       let first = tree.firstChild, close;
-       if (first && (close = first.type.prop(NodeProp$2.closedBy))) {
-           let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
-           return cx => delimitedStrategy$2(cx, true, 1, undefined, closed && !ignoreClosed$1(cx) ? last.from : undefined);
-       }
-       return tree.parent == null ? topIndent$1 : null;
-   }
-   function indentFrom$1(node, pos, base) {
-       for (; node; node = node.parent) {
-           let strategy = indentStrategy$1(node);
-           if (strategy)
-               return strategy(TreeIndentContext$1.create(base, pos, node));
-       }
-       return null;
-   }
-   function topIndent$1() { return 0; }
-   /**
-   Objects of this type provide context information and helper
-   methods to indentation functions registered on syntax nodes.
-   */
-   let TreeIndentContext$1 = class TreeIndentContext extends IndentContext$1 {
-       constructor(base, 
-       /**
-       The position at which indentation is being computed.
-       */
-       pos, 
-       /**
-       The syntax tree node to which the indentation strategy
-       applies.
-       */
-       node) {
-           super(base.state, base.options);
-           this.base = base;
-           this.pos = pos;
-           this.node = node;
-       }
-       /**
-       @internal
-       */
-       static create(base, pos, node) {
-           return new TreeIndentContext(base, pos, node);
-       }
-       /**
-       Get the text directly after `this.pos`, either the entire line
-       or the next 100 characters, whichever is shorter.
-       */
-       get textAfter() {
-           return this.textAfterPos(this.pos);
-       }
-       /**
-       Get the indentation at the reference line for `this.node`, which
-       is the line on which it starts, unless there is a node that is
-       _not_ a parent of this node covering the start of that line. If
-       so, the line at the start of that node is tried, again skipping
-       on if it is covered by another such node.
-       */
-       get baseIndent() {
-           let line = this.state.doc.lineAt(this.node.from);
-           // Skip line starts that are covered by a sibling (or cousin, etc)
-           for (;;) {
-               let atBreak = this.node.resolve(line.from);
-               while (atBreak.parent && atBreak.parent.from == atBreak.from)
-                   atBreak = atBreak.parent;
-               if (isParent$1(atBreak, this.node))
-                   break;
-               line = this.state.doc.lineAt(atBreak.from);
-           }
-           return this.lineIndent(line.from);
-       }
-       /**
-       Continue looking for indentations in the node's parent nodes,
-       and return the result of that.
-       */
-       continue() {
-           let parent = this.node.parent;
-           return parent ? indentFrom$1(parent, this.pos, this.base) : 0;
-       }
-   };
-   function isParent$1(parent, of) {
-       for (let cur = of; cur; cur = cur.parent)
-           if (parent == cur)
-               return true;
-       return false;
-   }
-   // Check whether a delimited node is aligned (meaning there are
-   // non-skipped nodes on the same line as the opening delimiter). And
-   // if so, return the opening token.
-   function bracketedAligned$2(context) {
-       let tree = context.node;
-       let openToken = tree.childAfter(tree.from), last = tree.lastChild;
-       if (!openToken)
-           return null;
-       let sim = context.options.simulateBreak;
-       let openLine = context.state.doc.lineAt(openToken.from);
-       let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
-       for (let pos = openToken.to;;) {
-           let next = tree.childAfter(pos);
-           if (!next || next == last)
-               return null;
-           if (!next.type.isSkipped)
-               return next.from < lineEnd ? openToken : null;
-           pos = next.to;
-       }
-   }
-   function delimitedStrategy$2(context, align, units, closing, closedAt) {
-       let after = context.textAfter, space = after.match(/^\s*/)[0].length;
-       let closed = closedAt == context.pos + space;
-       let aligned = bracketedAligned$2(context) ;
-       if (aligned)
-           return closed ? context.column(aligned.from) : context.column(aligned.to);
-       return context.baseIndent + (closed ? 0 : context.unit * units);
-   }
-   const DontIndentBeyond = 200;
-   /**
-   Enables reindentation on input. When a language defines an
-   `indentOnInput` field in its [language
-   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular
-   expression, the line at the cursor will be reindented whenever new
-   text is typed and the input from the start of the line up to the
-   cursor matches that regexp.
-
-   To avoid unneccesary reindents, it is recommended to start the
-   regexp with `^` (usually followed by `\s*`), and end it with `$`.
-   For example, `/^\s*\}$/` will reindent when a closing brace is
-   added at the start of a line.
-   */
-   function indentOnInput() {
-       return EditorState$3.transactionFilter.of(tr => {
-           if (!tr.docChanged || !tr.isUserEvent("input.type") && !tr.isUserEvent("input.complete"))
-               return tr;
-           let rules = tr.startState.languageDataAt("indentOnInput", tr.startState.selection.main.head);
-           if (!rules.length)
-               return tr;
-           let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);
-           if (head > line.from + DontIndentBeyond)
-               return tr;
-           let lineStart = doc.sliceString(line.from, head);
-           if (!rules.some(r => r.test(lineStart)))
-               return tr;
-           let { state } = tr, last = -1, changes = [];
-           for (let { head } of state.selection.ranges) {
-               let line = state.doc.lineAt(head);
-               if (line.from == last)
-                   continue;
-               last = line.from;
-               let indent = getIndentation$1(state, line.from);
-               if (indent == null)
-                   continue;
-               let cur = /^\s*/.exec(line.text)[0];
-               let norm = indentString$1(state, indent);
-               if (cur != norm)
-                   changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
-           }
-           return changes.length ? [tr, { changes, sequential: true }] : tr;
-       });
-   }
-
-   /**
-   A facet that registers a code folding service. When called with
-   the extent of a line, such a function should return a foldable
-   range that starts on that line (but continues beyond it), if one
-   can be found.
-   */
-   const foldService = /*@__PURE__*/Facet$3.define();
-   /**
-   This node prop is used to associate folding information with
-   syntax node types. Given a syntax node, it should check whether
-   that tree is foldable and return the range that can be collapsed
-   when it is.
-   */
-   const foldNodeProp$1 = /*@__PURE__*/new NodeProp$2();
-   function syntaxFolding(state, start, end) {
-       let tree = syntaxTree$2(state);
-       if (tree.length < end)
-           return null;
-       let inner = tree.resolveInner(end);
-       let found = null;
-       for (let cur = inner; cur; cur = cur.parent) {
-           if (cur.to <= end || cur.from > end)
-               continue;
-           if (found && cur.from < start)
-               break;
-           let prop = cur.type.prop(foldNodeProp$1);
-           if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {
-               let value = prop(cur, state);
-               if (value && value.from <= end && value.from >= start && value.to > end)
-                   found = value;
-           }
-       }
-       return found;
-   }
-   function isUnfinished(node) {
-       let ch = node.lastChild;
-       return ch && ch.to == node.to && ch.type.isError;
-   }
-   /**
-   Check whether the given line is foldable. First asks any fold
-   services registered through
-   [`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return
-   a result, tries to query the [fold node
-   prop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end
-   of the line.
-   */
-   function foldable(state, lineStart, lineEnd) {
-       for (let service of state.facet(foldService)) {
-           let result = service(state, lineStart, lineEnd);
-           if (result)
-               return result;
-       }
-       return syntaxFolding(state, lineStart, lineEnd);
-   }
-   function mapRange(range, mapping) {
-       let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);
-       return from >= to ? undefined : { from, to };
-   }
-   /**
-   State effect that can be attached to a transaction to fold the
-   given range. (You probably only need this in exceptional
-   circumstances—usually you'll just want to let
-   [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold
-   gutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)
-   */
-   const foldEffect = /*@__PURE__*/StateEffect$3.define({ map: mapRange });
-   /**
-   State effect that unfolds the given range (if it was folded).
-   */
-   const unfoldEffect = /*@__PURE__*/StateEffect$3.define({ map: mapRange });
-   function selectedLines(view) {
-       let lines = [];
-       for (let { head } of view.state.selection.ranges) {
-           if (lines.some(l => l.from <= head && l.to >= head))
-               continue;
-           lines.push(view.lineBlockAt(head));
-       }
-       return lines;
-   }
-   const foldState = /*@__PURE__*/StateField$3.define({
-       create() {
-           return Decoration$3.none;
-       },
-       update(folded, tr) {
-           folded = folded.map(tr.changes);
-           for (let e of tr.effects) {
-               if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to))
-                   folded = folded.update({ add: [foldWidget.range(e.value.from, e.value.to)] });
-               else if (e.is(unfoldEffect))
-                   folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,
-                       filterFrom: e.value.from, filterTo: e.value.to });
-           }
-           // Clear folded ranges that cover the selection head
-           if (tr.selection) {
-               let onSelection = false, { head } = tr.selection.main;
-               folded.between(head, head, (a, b) => { if (a < head && b > head)
-                   onSelection = true; });
-               if (onSelection)
-                   folded = folded.update({
-                       filterFrom: head,
-                       filterTo: head,
-                       filter: (a, b) => b <= head || a >= head
-                   });
-           }
-           return folded;
-       },
-       provide: f => EditorView$3.decorations.from(f)
-   });
-   function findFold(state, from, to) {
-       var _a;
-       let found = null;
-       (_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {
-           if (!found || found.from > from)
-               found = { from, to };
-       });
-       return found;
-   }
-   function foldExists(folded, from, to) {
-       let found = false;
-       folded.between(from, from, (a, b) => { if (a == from && b == to)
-           found = true; });
-       return found;
-   }
-   function maybeEnable(state, other) {
-       return state.field(foldState, false) ? other : other.concat(StateEffect$3.appendConfig.of(codeFolding()));
-   }
-   /**
-   Fold the lines that are selected, if possible.
-   */
-   const foldCode = view => {
-       for (let line of selectedLines(view)) {
-           let range = foldable(view.state, line.from, line.to);
-           if (range) {
-               view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });
-               return true;
-           }
-       }
-       return false;
-   };
-   /**
-   Unfold folded ranges on selected lines.
-   */
-   const unfoldCode = view => {
-       if (!view.state.field(foldState, false))
-           return false;
-       let effects = [];
-       for (let line of selectedLines(view)) {
-           let folded = findFold(view.state, line.from, line.to);
-           if (folded)
-               effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));
-       }
-       if (effects.length)
-           view.dispatch({ effects });
-       return effects.length > 0;
-   };
-   function announceFold(view, range, fold = true) {
-       let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;
-       return EditorView$3.announce.of(`${view.state.phrase(fold ? "Folded lines" : "Unfolded lines")} ${lineFrom} ${view.state.phrase("to")} ${lineTo}.`);
-   }
-   /**
-   Fold all top-level foldable ranges. Note that, in most cases,
-   folding information will depend on the [syntax
-   tree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work
-   reliably when the document hasn't been fully parsed (either
-   because the editor state was only just initialized, or because the
-   document is so big that the parser decided not to parse it
-   entirely).
-   */
-   const foldAll = view => {
-       let { state } = view, effects = [];
-       for (let pos = 0; pos < state.doc.length;) {
-           let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);
-           if (range)
-               effects.push(foldEffect.of(range));
-           pos = (range ? view.lineBlockAt(range.to) : line).to + 1;
-       }
-       if (effects.length)
-           view.dispatch({ effects: maybeEnable(view.state, effects) });
-       return !!effects.length;
-   };
-   /**
-   Unfold all folded code.
-   */
-   const unfoldAll = view => {
-       let field = view.state.field(foldState, false);
-       if (!field || !field.size)
-           return false;
-       let effects = [];
-       field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });
-       view.dispatch({ effects });
-       return true;
-   };
-   /**
-   Default fold-related key bindings.
-
-    - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).
-    - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).
-    - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).
-    - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).
-   */
-   const foldKeymap = [
-       { key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: foldCode },
-       { key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: unfoldCode },
-       { key: "Ctrl-Alt-[", run: foldAll },
-       { key: "Ctrl-Alt-]", run: unfoldAll }
-   ];
-   const defaultConfig = {
-       placeholderDOM: null,
-       placeholderText: "…"
-   };
-   const foldConfig = /*@__PURE__*/Facet$3.define({
-       combine(values) { return combineConfig$3(values, defaultConfig); }
-   });
-   /**
-   Create an extension that configures code folding.
-   */
-   function codeFolding(config) {
-       let result = [foldState, baseTheme$1$4];
-       return result;
-   }
-   const foldWidget = /*@__PURE__*/Decoration$3.replace({ widget: /*@__PURE__*/new class extends WidgetType$3 {
-           toDOM(view) {
-               let { state } = view, conf = state.facet(foldConfig);
-               let onclick = (event) => {
-                   let line = view.lineBlockAt(view.posAtDOM(event.target));
-                   let folded = findFold(view.state, line.from, line.to);
-                   if (folded)
-                       view.dispatch({ effects: unfoldEffect.of(folded) });
-                   event.preventDefault();
-               };
-               if (conf.placeholderDOM)
-                   return conf.placeholderDOM(view, onclick);
-               let element = document.createElement("span");
-               element.textContent = conf.placeholderText;
-               element.setAttribute("aria-label", state.phrase("folded code"));
-               element.title = state.phrase("unfold");
-               element.className = "cm-foldPlaceholder";
-               element.onclick = onclick;
-               return element;
-           }
-       } });
-   const foldGutterDefaults = {
-       openText: "⌄",
-       closedText: "›",
-       markerDOM: null,
-       domEventHandlers: {},
-   };
-   class FoldMarker extends GutterMarker$3 {
-       constructor(config, open) {
-           super();
-           this.config = config;
-           this.open = open;
-       }
-       eq(other) { return this.config == other.config && this.open == other.open; }
-       toDOM(view) {
-           if (this.config.markerDOM)
-               return this.config.markerDOM(this.open);
-           let span = document.createElement("span");
-           span.textContent = this.open ? this.config.openText : this.config.closedText;
-           span.title = view.state.phrase(this.open ? "Fold line" : "Unfold line");
-           return span;
-       }
-   }
-   /**
-   Create an extension that registers a fold gutter, which shows a
-   fold status indicator before foldable lines (which can be clicked
-   to fold or unfold the line).
-   */
-   function foldGutter(config = {}) {
-       let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);
-       let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);
-       let markers = ViewPlugin$3.fromClass(class {
-           constructor(view) {
-               this.from = view.viewport.from;
-               this.markers = this.buildMarkers(view);
-           }
-           update(update) {
-               if (update.docChanged || update.viewportChanged ||
-                   update.startState.facet(language$2) != update.state.facet(language$2) ||
-                   update.startState.field(foldState, false) != update.state.field(foldState, false) ||
-                   syntaxTree$2(update.startState) != syntaxTree$2(update.state))
-                   this.markers = this.buildMarkers(update.view);
-           }
-           buildMarkers(view) {
-               let builder = new RangeSetBuilder$3();
-               for (let line of view.viewportLineBlocks) {
-                   let mark = findFold(view.state, line.from, line.to) ? canUnfold
-                       : foldable(view.state, line.from, line.to) ? canFold : null;
-                   if (mark)
-                       builder.add(line.from, line.from, mark);
-               }
-               return builder.finish();
-           }
-       });
-       let { domEventHandlers } = fullConfig;
-       return [
-           markers,
-           gutter$1({
-               class: "cm-foldGutter",
-               markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet$3.empty; },
-               initialSpacer() {
-                   return new FoldMarker(fullConfig, false);
-               },
-               domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {
-                       if (domEventHandlers.click && domEventHandlers.click(view, line, event))
-                           return true;
-                       let folded = findFold(view.state, line.from, line.to);
-                       if (folded) {
-                           view.dispatch({ effects: unfoldEffect.of(folded) });
-                           return true;
-                       }
-                       let range = foldable(view.state, line.from, line.to);
-                       if (range) {
-                           view.dispatch({ effects: foldEffect.of(range) });
-                           return true;
-                       }
-                       return false;
-                   } })
-           }),
-           codeFolding()
-       ];
-   }
-   const baseTheme$1$4 = /*@__PURE__*/EditorView$3.baseTheme({
-       ".cm-foldPlaceholder": {
-           backgroundColor: "#eee",
-           border: "1px solid #ddd",
-           color: "#888",
-           borderRadius: ".2em",
-           margin: "0 1px",
-           padding: "0 1px",
-           cursor: "pointer"
-       },
-       ".cm-foldGutter span": {
-           padding: "0 1px",
-           cursor: "pointer"
-       }
-   });
-
-   /**
-   A highlight style associates CSS styles with higlighting
-   [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
-   */
-   let HighlightStyle$1 = class HighlightStyle {
-       constructor(spec, options) {
-           let modSpec;
-           function def(spec) {
-               let cls = StyleModule.newName();
-               (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
-               return cls;
-           }
-           const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
-           const scopeOpt = options.scope;
-           this.scope = scopeOpt instanceof Language$2 ? (type) => type.prop(languageDataProp$2) == scopeOpt.data
-               : scopeOpt ? (type) => type == scopeOpt : undefined;
-           this.style = tagHighlighter$2(spec.map(style => ({
-               tag: style.tag,
-               class: style.class || def(Object.assign({}, style, { tag: null }))
-           })), {
-               all,
-           }).style;
-           this.module = modSpec ? new StyleModule(modSpec) : null;
-           this.themeType = options.themeType;
-       }
-       /**
-       Create a highlighter style that associates the given styles to
-       the given tags. The specs must be objects that hold a style tag
-       or array of tags in their `tag` property, and either a single
-       `class` property providing a static CSS class (for highlighter
-       that rely on external styling), or a
-       [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
-       set of CSS properties (which define the styling for those tags).
-       
-       The CSS rules created for a highlighter will be emitted in the
-       order of the spec's properties. That means that for elements that
-       have multiple tags associated with them, styles defined further
-       down in the list will have a higher CSS precedence than styles
-       defined earlier.
-       */
-       static define(specs, options) {
-           return new HighlightStyle(specs, options || {});
-       }
-   };
-   const highlighterFacet$1 = /*@__PURE__*/Facet$3.define();
-   const fallbackHighlighter$1 = /*@__PURE__*/Facet$3.define({
-       combine(values) { return values.length ? [values[0]] : null; }
-   });
-   function getHighlighters$1(state) {
-       let main = state.facet(highlighterFacet$1);
-       return main.length ? main : state.facet(fallbackHighlighter$1);
-   }
-   /**
-   Wrap a highlighter in an editor extension that uses it to apply
-   syntax highlighting to the editor content.
-
-   When multiple (non-fallback) styles are provided, the styling
-   applied is the union of the classes they emit.
-   */
-   function syntaxHighlighting$1(highlighter, options) {
-       let ext = [treeHighlighter$1], themeType;
-       if (highlighter instanceof HighlightStyle$1) {
-           if (highlighter.module)
-               ext.push(EditorView$3.styleModule.of(highlighter.module));
-           themeType = highlighter.themeType;
-       }
-       if (options === null || options === void 0 ? void 0 : options.fallback)
-           ext.push(fallbackHighlighter$1.of(highlighter));
-       else if (themeType)
-           ext.push(highlighterFacet$1.computeN([EditorView$3.darkTheme], state => {
-               return state.facet(EditorView$3.darkTheme) == (themeType == "dark") ? [highlighter] : [];
-           }));
-       else
-           ext.push(highlighterFacet$1.of(highlighter));
-       return ext;
-   }
-   let TreeHighlighter$1 = class TreeHighlighter {
-       constructor(view) {
-           this.markCache = Object.create(null);
-           this.tree = syntaxTree$2(view.state);
-           this.decorations = this.buildDeco(view, getHighlighters$1(view.state));
-       }
-       update(update) {
-           let tree = syntaxTree$2(update.state), highlighters = getHighlighters$1(update.state);
-           let styleChange = highlighters != getHighlighters$1(update.startState);
-           if (tree.length < update.view.viewport.to && !styleChange && tree.type == this.tree.type) {
-               this.decorations = this.decorations.map(update.changes);
-           }
-           else if (tree != this.tree || update.viewportChanged || styleChange) {
-               this.tree = tree;
-               this.decorations = this.buildDeco(update.view, highlighters);
-           }
-       }
-       buildDeco(view, highlighters) {
-           if (!highlighters || !this.tree.length)
-               return Decoration$3.none;
-           let builder = new RangeSetBuilder$3();
-           for (let { from, to } of view.visibleRanges) {
-               highlightTree$1(this.tree, highlighters, (from, to, style) => {
-                   builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration$3.mark({ class: style })));
-               }, from, to);
-           }
-           return builder.finish();
-       }
-   };
-   const treeHighlighter$1 = /*@__PURE__*/Prec$3.high(/*@__PURE__*/ViewPlugin$3.fromClass(TreeHighlighter$1, {
-       decorations: v => v.decorations
-   }));
-   /**
-   A default highlight style (works well with light themes).
-   */
-   const defaultHighlightStyle = /*@__PURE__*/HighlightStyle$1.define([
-       { tag: tags$2.meta,
-           color: "#7a757a" },
-       { tag: tags$2.link,
-           textDecoration: "underline" },
-       { tag: tags$2.heading,
-           textDecoration: "underline",
-           fontWeight: "bold" },
-       { tag: tags$2.emphasis,
-           fontStyle: "italic" },
-       { tag: tags$2.strong,
-           fontWeight: "bold" },
-       { tag: tags$2.strikethrough,
-           textDecoration: "line-through" },
-       { tag: tags$2.keyword,
-           color: "#708" },
-       { tag: [tags$2.atom, tags$2.bool, tags$2.url, tags$2.contentSeparator, tags$2.labelName],
-           color: "#219" },
-       { tag: [tags$2.literal, tags$2.inserted],
-           color: "#164" },
-       { tag: [tags$2.string, tags$2.deleted],
-           color: "#a11" },
-       { tag: [tags$2.regexp, tags$2.escape, /*@__PURE__*/tags$2.special(tags$2.string)],
-           color: "#e40" },
-       { tag: /*@__PURE__*/tags$2.definition(tags$2.variableName),
-           color: "#00f" },
-       { tag: /*@__PURE__*/tags$2.local(tags$2.variableName),
-           color: "#30a" },
-       { tag: [tags$2.typeName, tags$2.namespace],
-           color: "#085" },
-       { tag: tags$2.className,
-           color: "#167" },
-       { tag: [/*@__PURE__*/tags$2.special(tags$2.variableName), tags$2.macroName],
-           color: "#256" },
-       { tag: /*@__PURE__*/tags$2.definition(tags$2.propertyName),
-           color: "#00c" },
-       { tag: tags$2.comment,
-           color: "#940" },
-       { tag: tags$2.invalid,
-           color: "#f00" }
-   ]);
-
-   const baseTheme$6 = /*@__PURE__*/EditorView$3.baseTheme({
-       "&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
-       "&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
-   });
-   const DefaultScanDist$1 = 10000, DefaultBrackets$1 = "()[]{}";
-   const bracketMatchingConfig = /*@__PURE__*/Facet$3.define({
-       combine(configs) {
-           return combineConfig$3(configs, {
-               afterCursor: true,
-               brackets: DefaultBrackets$1,
-               maxScanDistance: DefaultScanDist$1,
-               renderMatch: defaultRenderMatch
-           });
-       }
-   });
-   const matchingMark = /*@__PURE__*/Decoration$3.mark({ class: "cm-matchingBracket" }), nonmatchingMark = /*@__PURE__*/Decoration$3.mark({ class: "cm-nonmatchingBracket" });
-   function defaultRenderMatch(match) {
-       let decorations = [];
-       let mark = match.matched ? matchingMark : nonmatchingMark;
-       decorations.push(mark.range(match.start.from, match.start.to));
-       if (match.end)
-           decorations.push(mark.range(match.end.from, match.end.to));
-       return decorations;
-   }
-   const bracketMatchingState = /*@__PURE__*/StateField$3.define({
-       create() { return Decoration$3.none; },
-       update(deco, tr) {
-           if (!tr.docChanged && !tr.selection)
-               return deco;
-           let decorations = [];
-           let config = tr.state.facet(bracketMatchingConfig);
-           for (let range of tr.state.selection.ranges) {
-               if (!range.empty)
-                   continue;
-               let match = matchBrackets$1(tr.state, range.head, -1, config)
-                   || (range.head > 0 && matchBrackets$1(tr.state, range.head - 1, 1, config))
-                   || (config.afterCursor &&
-                       (matchBrackets$1(tr.state, range.head, 1, config) ||
-                           (range.head < tr.state.doc.length && matchBrackets$1(tr.state, range.head + 1, -1, config))));
-               if (match)
-                   decorations = decorations.concat(config.renderMatch(match, tr.state));
-           }
-           return Decoration$3.set(decorations, true);
-       },
-       provide: f => EditorView$3.decorations.from(f)
-   });
-   const bracketMatchingUnique = [
-       bracketMatchingState,
-       baseTheme$6
-   ];
-   /**
-   Create an extension that enables bracket matching. Whenever the
-   cursor is next to a bracket, that bracket and the one it matches
-   are highlighted. Or, when no matching bracket is found, another
-   highlighting style is used to indicate this.
-   */
-   function bracketMatching(config = {}) {
-       return [bracketMatchingConfig.of(config), bracketMatchingUnique];
-   }
-   function matchingNodes$1(node, dir, brackets) {
-       let byProp = node.prop(dir < 0 ? NodeProp$2.openedBy : NodeProp$2.closedBy);
-       if (byProp)
-           return byProp;
-       if (node.name.length == 1) {
-           let index = brackets.indexOf(node.name);
-           if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
-               return [brackets[index + dir]];
-       }
-       return null;
-   }
-   /**
-   Find the matching bracket for the token at `pos`, scanning
-   direction `dir`. Only the `brackets` and `maxScanDistance`
-   properties are used from `config`, if given. Returns null if no
-   bracket was found at `pos`, or a match result otherwise.
-   */
-   function matchBrackets$1(state, pos, dir, config = {}) {
-       let maxScanDistance = config.maxScanDistance || DefaultScanDist$1, brackets = config.brackets || DefaultBrackets$1;
-       let tree = syntaxTree$2(state), node = tree.resolveInner(pos, dir);
-       for (let cur = node; cur; cur = cur.parent) {
-           let matches = matchingNodes$1(cur.type, dir, brackets);
-           if (matches && cur.from < cur.to)
-               return matchMarkedBrackets$1(state, pos, dir, cur, matches, brackets);
-       }
-       return matchPlainBrackets$1(state, pos, dir, tree, node.type, maxScanDistance, brackets);
-   }
-   function matchMarkedBrackets$1(_state, _pos, dir, token, matching, brackets) {
-       let parent = token.parent, firstToken = { from: token.from, to: token.to };
-       let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
-       if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
-           do {
-               if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
-                   if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
-                       return { start: firstToken, end: { from: cursor.from, to: cursor.to }, matched: true };
-                   }
-                   else if (matchingNodes$1(cursor.type, dir, brackets)) {
-                       depth++;
-                   }
-                   else if (matchingNodes$1(cursor.type, -dir, brackets)) {
-                       depth--;
-                       if (depth == 0)
-                           return {
-                               start: firstToken,
-                               end: cursor.from == cursor.to ? undefined : { from: cursor.from, to: cursor.to },
-                               matched: false
-                           };
-                   }
-               }
-           } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
-       return { start: firstToken, matched: false };
-   }
-   function matchPlainBrackets$1(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
-       let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
-       let bracket = brackets.indexOf(startCh);
-       if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
-           return null;
-       let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
-       let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
-       for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
-           let text = iter.value;
-           if (dir < 0)
-               distance += text.length;
-           let basePos = pos + distance * dir;
-           for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
-               let found = brackets.indexOf(text[pos]);
-               if (found < 0 || tree.resolve(basePos + pos, 1).type != tokenType)
-                   continue;
-               if ((found % 2 == 0) == (dir > 0)) {
-                   depth++;
-               }
-               else if (depth == 1) { // Closing
-                   return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
-               }
-               else {
-                   depth--;
-               }
-           }
-           if (dir > 0)
-               distance += text.length;
-       }
-       return iter.done ? { start: startToken, matched: false } : null;
-   }
-   const noTokens$2 = /*@__PURE__*/Object.create(null);
-   const typeArray$2 = [NodeType$2.none];
-   const warned$2 = [];
-   const defaultTable$2 = /*@__PURE__*/Object.create(null);
-   for (let [legacyName, name] of [
-       ["variable", "variableName"],
-       ["variable-2", "variableName.special"],
-       ["string-2", "string.special"],
-       ["def", "variableName.definition"],
-       ["tag", "typeName"],
-       ["attribute", "propertyName"],
-       ["type", "typeName"],
-       ["builtin", "variableName.standard"],
-       ["qualifier", "modifier"],
-       ["error", "invalid"],
-       ["header", "heading"],
-       ["property", "propertyName"]
-   ])
-       defaultTable$2[legacyName] = /*@__PURE__*/createTokenType$2(noTokens$2, name);
-   function warnForPart$2(part, msg) {
-       if (warned$2.indexOf(part) > -1)
-           return;
-       warned$2.push(part);
-       console.warn(msg);
-   }
-   function createTokenType$2(extra, tagStr) {
-       let tag = null;
-       for (let part of tagStr.split(".")) {
-           let value = (extra[part] || tags$2[part]);
-           if (!value) {
-               warnForPart$2(part, `Unknown highlighting tag ${part}`);
-           }
-           else if (typeof value == "function") {
-               if (!tag)
-                   warnForPart$2(part, `Modifier ${part} used at start of tag`);
-               else
-                   tag = value(tag);
-           }
-           else {
-               if (tag)
-                   warnForPart$2(part, `Tag ${part} used as modifier`);
-               else
-                   tag = value;
-           }
-       }
-       if (!tag)
-           return 0;
-       let name = tagStr.replace(/ /g, "_"), type = NodeType$2.define({
-           id: typeArray$2.length,
-           name,
-           props: [styleTags$2({ [name]: tag })]
-       });
-       typeArray$2.push(type);
-       return type.id;
-   }
-
-   /**
-   The data structure for documents. @nonabstract
-   */
-   let Text$2 = class Text {
-       /**
-       @internal
-       */
-       constructor() { }
-       /**
-       Get the line description around the given position.
-       */
-       lineAt(pos) {
-           if (pos < 0 || pos > this.length)
-               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
-           return this.lineInner(pos, false, 1, 0);
-       }
-       /**
-       Get the description for the given (1-based) line number.
-       */
-       line(n) {
-           if (n < 1 || n > this.lines)
-               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
-           return this.lineInner(n, true, 1, 0);
-       }
-       /**
-       Replace a range of the text with the given content.
-       */
-       replace(from, to, text) {
-           let parts = [];
-           this.decompose(0, from, parts, 2 /* To */);
-           if (text.length)
-               text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
-           this.decompose(to, this.length, parts, 1 /* From */);
-           return TextNode$2.from(parts, this.length - (to - from) + text.length);
-       }
-       /**
-       Append another document to this one.
-       */
-       append(other) {
-           return this.replace(this.length, this.length, other);
-       }
-       /**
-       Retrieve the text between the given points.
-       */
-       slice(from, to = this.length) {
-           let parts = [];
-           this.decompose(from, to, parts, 0);
-           return TextNode$2.from(parts, to - from);
-       }
-       /**
-       Test whether this text is equal to another instance.
-       */
-       eq(other) {
-           if (other == this)
-               return true;
-           if (other.length != this.length || other.lines != this.lines)
-               return false;
-           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
-           let a = new RawTextCursor$2(this), b = new RawTextCursor$2(other);
-           for (let skip = start, pos = start;;) {
-               a.next(skip);
-               b.next(skip);
-               skip = 0;
-               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
-                   return false;
-               pos += a.value.length;
-               if (a.done || pos >= end)
-                   return true;
-           }
-       }
-       /**
-       Iterate over the text. When `dir` is `-1`, iteration happens
-       from end to start. This will return lines and the breaks between
-       them as separate strings.
-       */
-       iter(dir = 1) { return new RawTextCursor$2(this, dir); }
-       /**
-       Iterate over a range of the text. When `from` > `to`, the
-       iterator will run in reverse.
-       */
-       iterRange(from, to = this.length) { return new PartialTextCursor$2(this, from, to); }
-       /**
-       Return a cursor that iterates over the given range of lines,
-       _without_ returning the line breaks between, and yielding empty
-       strings for empty lines.
-       
-       When `from` and `to` are given, they should be 1-based line numbers.
-       */
-       iterLines(from, to) {
-           let inner;
-           if (from == null) {
-               inner = this.iter();
-           }
-           else {
-               if (to == null)
-                   to = this.lines + 1;
-               let start = this.line(from).from;
-               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
-           }
-           return new LineCursor$2(inner);
-       }
-       /**
-       @internal
-       */
-       toString() { return this.sliceString(0); }
-       /**
-       Convert the document to an array of lines (which can be
-       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
-       */
-       toJSON() {
-           let lines = [];
-           this.flatten(lines);
-           return lines;
-       }
-       /**
-       Create a `Text` instance for the given array of lines.
-       */
-       static of(text) {
-           if (text.length == 0)
-               throw new RangeError("A document must have at least one line");
-           if (text.length == 1 && !text[0])
-               return Text.empty;
-           return text.length <= 32 /* Branch */ ? new TextLeaf$2(text) : TextNode$2.from(TextLeaf$2.split(text, []));
-       }
-   };
-   // Leaves store an array of line strings. There are always line breaks
-   // between these strings. Leaves are limited in size and have to be
-   // contained in TextNode instances for bigger documents.
-   let TextLeaf$2 = class TextLeaf extends Text$2 {
-       constructor(text, length = textLength$2(text)) {
-           super();
-           this.text = text;
-           this.length = length;
-       }
-       get lines() { return this.text.length; }
-       get children() { return null; }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let string = this.text[i], end = offset + string.length;
-               if ((isLine ? line : end) >= target)
-                   return new Line$2(offset, end, line, string);
-               offset = end + 1;
-               line++;
-           }
-       }
-       decompose(from, to, target, open) {
-           let text = from <= 0 && to >= this.length ? this
-               : new TextLeaf(sliceText$2(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
-           if (open & 1 /* From */) {
-               let prev = target.pop();
-               let joined = appendText$2(text.text, prev.text.slice(), 0, text.length);
-               if (joined.length <= 32 /* Branch */) {
-                   target.push(new TextLeaf(joined, prev.length + text.length));
-               }
-               else {
-                   let mid = joined.length >> 1;
-                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
-               }
-           }
-           else {
-               target.push(text);
-           }
-       }
-       replace(from, to, text) {
-           if (!(text instanceof TextLeaf))
-               return super.replace(from, to, text);
-           let lines = appendText$2(this.text, appendText$2(text.text, sliceText$2(this.text, 0, from)), to);
-           let newLen = this.length + text.length - (to - from);
-           if (lines.length <= 32 /* Branch */)
-               return new TextLeaf(lines, newLen);
-           return TextNode$2.from(TextLeaf.split(lines, []), newLen);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           let result = "";
-           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
-               let line = this.text[i], end = pos + line.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += line.slice(Math.max(0, from - pos), to - pos);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let line of this.text)
-               target.push(line);
-       }
-       scanIdentical() { return 0; }
-       static split(text, target) {
-           let part = [], len = -1;
-           for (let line of text) {
-               part.push(line);
-               len += line.length + 1;
-               if (part.length == 32 /* Branch */) {
-                   target.push(new TextLeaf(part, len));
-                   part = [];
-                   len = -1;
-               }
-           }
-           if (len > -1)
-               target.push(new TextLeaf(part, len));
-           return target;
-       }
-   };
-   // Nodes provide the tree structure of the `Text` type. They store a
-   // number of other nodes or leaves, taking care to balance themselves
-   // on changes. There are implied line breaks _between_ the children of
-   // a node (but not before the first or after the last child).
-   let TextNode$2 = class TextNode extends Text$2 {
-       constructor(children, length) {
-           super();
-           this.children = children;
-           this.length = length;
-           this.lines = 0;
-           for (let child of children)
-               this.lines += child.lines;
-       }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
-               if ((isLine ? endLine : end) >= target)
-                   return child.lineInner(target, isLine, line, offset);
-               offset = end + 1;
-               line = endLine + 1;
-           }
-       }
-       decompose(from, to, target, open) {
-           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (from <= end && to >= pos) {
-                   let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
-                   if (pos >= from && end <= to && !childOpen)
-                       target.push(child);
-                   else
-                       child.decompose(from - pos, to - pos, target, childOpen);
-               }
-               pos = end + 1;
-           }
-       }
-       replace(from, to, text) {
-           if (text.lines < this.lines)
-               for (let i = 0, pos = 0; i < this.children.length; i++) {
-                   let child = this.children[i], end = pos + child.length;
-                   // Fast path: if the change only affects one child and the
-                   // child's size remains in the acceptable range, only update
-                   // that child
-                   if (from >= pos && to <= end) {
-                       let updated = child.replace(from - pos, to - pos, text);
-                       let totalLines = this.lines - child.lines + updated.lines;
-                       if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
-                           updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
-                           let copy = this.children.slice();
-                           copy[i] = updated;
-                           return new TextNode(copy, this.length - (to - from) + text.length);
-                       }
-                       return super.replace(pos, end, updated);
-                   }
-                   pos = end + 1;
-               }
-           return super.replace(from, to, text);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           let result = "";
-           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += child.sliceString(from - pos, to - pos, lineSep);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let child of this.children)
-               child.flatten(target);
-       }
-       scanIdentical(other, dir) {
-           if (!(other instanceof TextNode))
-               return 0;
-           let length = 0;
-           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
-               : [this.children.length - 1, other.children.length - 1, -1, -1];
-           for (;; iA += dir, iB += dir) {
-               if (iA == eA || iB == eB)
-                   return length;
-               let chA = this.children[iA], chB = other.children[iB];
-               if (chA != chB)
-                   return length + chA.scanIdentical(chB, dir);
-               length += chA.length + 1;
-           }
-       }
-       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
-           let lines = 0;
-           for (let ch of children)
-               lines += ch.lines;
-           if (lines < 32 /* Branch */) {
-               let flat = [];
-               for (let ch of children)
-                   ch.flatten(flat);
-               return new TextLeaf$2(flat, length);
-           }
-           let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
-           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
-           function add(child) {
-               let last;
-               if (child.lines > maxChunk && child instanceof TextNode) {
-                   for (let node of child.children)
-                       add(node);
-               }
-               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
-                   flush();
-                   chunked.push(child);
-               }
-               else if (child instanceof TextLeaf$2 && currentLines &&
-                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf$2 &&
-                   child.lines + last.lines <= 32 /* Branch */) {
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk[currentChunk.length - 1] = new TextLeaf$2(last.text.concat(child.text), last.length + 1 + child.length);
-               }
-               else {
-                   if (currentLines + child.lines > chunk)
-                       flush();
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk.push(child);
-               }
-           }
-           function flush() {
-               if (currentLines == 0)
-                   return;
-               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
-               currentLen = -1;
-               currentLines = currentChunk.length = 0;
-           }
-           for (let child of children)
-               add(child);
-           flush();
-           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
-       }
-   };
-   Text$2.empty = /*@__PURE__*/new TextLeaf$2([""], 0);
-   function textLength$2(text) {
-       let length = -1;
-       for (let line of text)
-           length += line.length + 1;
-       return length;
-   }
-   function appendText$2(text, target, from = 0, to = 1e9) {
-       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
-           let line = text[i], end = pos + line.length;
-           if (end >= from) {
-               if (end > to)
-                   line = line.slice(0, to - pos);
-               if (pos < from)
-                   line = line.slice(from - pos);
-               if (first) {
-                   target[target.length - 1] += line;
-                   first = false;
-               }
-               else
-                   target.push(line);
-           }
-           pos = end + 1;
-       }
-       return target;
-   }
-   function sliceText$2(text, from, to) {
-       return appendText$2(text, [""], from, to);
-   }
-   let RawTextCursor$2 = class RawTextCursor {
-       constructor(text, dir = 1) {
-           this.dir = dir;
-           this.done = false;
-           this.lineBreak = false;
-           this.value = "";
-           this.nodes = [text];
-           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf$2 ? text.text.length : text.children.length) << 1];
-       }
-       nextInner(skip, dir) {
-           this.done = this.lineBreak = false;
-           for (;;) {
-               let last = this.nodes.length - 1;
-               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
-               let size = top instanceof TextLeaf$2 ? top.text.length : top.children.length;
-               if (offset == (dir > 0 ? size : 0)) {
-                   if (last == 0) {
-                       this.done = true;
-                       this.value = "";
-                       return this;
-                   }
-                   if (dir > 0)
-                       this.offsets[last - 1]++;
-                   this.nodes.pop();
-                   this.offsets.pop();
-               }
-               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
-                   this.offsets[last] += dir;
-                   if (skip == 0) {
-                       this.lineBreak = true;
-                       this.value = "\n";
-                       return this;
-                   }
-                   skip--;
-               }
-               else if (top instanceof TextLeaf$2) {
-                   // Move to the next string
-                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
-                   this.offsets[last] += dir;
-                   if (next.length > Math.max(0, skip)) {
-                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
-                       return this;
-                   }
-                   skip -= next.length;
-               }
-               else {
-                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
-                   if (skip > next.length) {
-                       skip -= next.length;
-                       this.offsets[last] += dir;
-                   }
-                   else {
-                       if (dir < 0)
-                           this.offsets[last]--;
-                       this.nodes.push(next);
-                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf$2 ? next.text.length : next.children.length) << 1);
-                   }
-               }
-           }
-       }
-       next(skip = 0) {
-           if (skip < 0) {
-               this.nextInner(-skip, (-this.dir));
-               skip = this.value.length;
-           }
-           return this.nextInner(skip, this.dir);
-       }
-   };
-   let PartialTextCursor$2 = class PartialTextCursor {
-       constructor(text, start, end) {
-           this.value = "";
-           this.done = false;
-           this.cursor = new RawTextCursor$2(text, start > end ? -1 : 1);
-           this.pos = start > end ? text.length : 0;
-           this.from = Math.min(start, end);
-           this.to = Math.max(start, end);
-       }
-       nextInner(skip, dir) {
-           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
-               this.value = "";
-               this.done = true;
-               return this;
-           }
-           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
-           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
-           if (skip > limit)
-               skip = limit;
-           limit -= skip;
-           let { value } = this.cursor.next(skip);
-           this.pos += (value.length + skip) * dir;
-           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
-           this.done = !this.value;
-           return this;
-       }
-       next(skip = 0) {
-           if (skip < 0)
-               skip = Math.max(skip, this.from - this.pos);
-           else if (skip > 0)
-               skip = Math.min(skip, this.to - this.pos);
-           return this.nextInner(skip, this.cursor.dir);
-       }
-       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
-   };
-   let LineCursor$2 = class LineCursor {
-       constructor(inner) {
-           this.inner = inner;
-           this.afterBreak = true;
-           this.value = "";
-           this.done = false;
-       }
-       next(skip = 0) {
-           let { done, lineBreak, value } = this.inner.next(skip);
-           if (done) {
-               this.done = true;
-               this.value = "";
-           }
-           else if (lineBreak) {
-               if (this.afterBreak) {
-                   this.value = "";
-               }
-               else {
-                   this.afterBreak = true;
-                   this.next();
-               }
-           }
-           else {
-               this.value = value;
-               this.afterBreak = false;
-           }
-           return this;
-       }
-       get lineBreak() { return false; }
-   };
-   if (typeof Symbol != "undefined") {
-       Text$2.prototype[Symbol.iterator] = function () { return this.iter(); };
-       RawTextCursor$2.prototype[Symbol.iterator] = PartialTextCursor$2.prototype[Symbol.iterator] =
-           LineCursor$2.prototype[Symbol.iterator] = function () { return this; };
-   }
-   /**
-   This type describes a line in the document. It is created
-   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
-   */
-   let Line$2 = class Line {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The position of the start of the line.
-       */
-       from, 
-       /**
-       The position at the end of the line (_before_ the line break,
-       or at the end of document for the last line).
-       */
-       to, 
-       /**
-       This line's line number (1-based).
-       */
-       number, 
-       /**
-       The line's content.
-       */
-       text) {
-           this.from = from;
-           this.to = to;
-           this.number = number;
-           this.text = text;
-       }
-       /**
-       The length of the line (not including any line break after it).
-       */
-       get length() { return this.to - this.from; }
-   };
-
-   // Compressed representation of the Grapheme_Cluster_Break=Extend
-   // information from
-   // http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
-   // Each pair of elements represents a range, as an offet from the
-   // previous range and a length. Numbers are in base-36, with the empty
-   // string being a shorthand for 1.
-   let extend$1 = /*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
-   // Convert offsets into absolute values
-   for (let i = 1; i < extend$1.length; i++)
-       extend$1[i] += extend$1[i - 1];
-   function isExtendingChar$2(code) {
-       for (let i = 1; i < extend$1.length; i += 2)
-           if (extend$1[i] > code)
-               return extend$1[i - 1] <= code;
-       return false;
-   }
-   function isRegionalIndicator$2(code) {
-       return code >= 0x1F1E6 && code <= 0x1F1FF;
-   }
-   const ZWJ$2 = 0x200d;
-   /**
-   Returns a next grapheme cluster break _after_ (not equal to)
-   `pos`, if `forward` is true, or before otherwise. Returns `pos`
-   itself if no further cluster break is available in the string.
-   Moves across surrogate pairs, extending characters (when
-   `includeExtending` is true), characters joined with zero-width
-   joiners, and flag emoji.
-   */
-   function findClusterBreak$3(str, pos, forward = true, includeExtending = true) {
-       return (forward ? nextClusterBreak$2 : prevClusterBreak$2)(str, pos, includeExtending);
-   }
-   function nextClusterBreak$2(str, pos, includeExtending) {
-       if (pos == str.length)
-           return pos;
-       // If pos is in the middle of a surrogate pair, move to its start
-       if (pos && surrogateLow$3(str.charCodeAt(pos)) && surrogateHigh$3(str.charCodeAt(pos - 1)))
-           pos--;
-       let prev = codePointAt$3(str, pos);
-       pos += codePointSize$3(prev);
-       while (pos < str.length) {
-           let next = codePointAt$3(str, pos);
-           if (prev == ZWJ$2 || next == ZWJ$2 || includeExtending && isExtendingChar$2(next)) {
-               pos += codePointSize$3(next);
-               prev = next;
-           }
-           else if (isRegionalIndicator$2(next)) {
-               let countBefore = 0, i = pos - 2;
-               while (i >= 0 && isRegionalIndicator$2(codePointAt$3(str, i))) {
-                   countBefore++;
-                   i -= 2;
-               }
-               if (countBefore % 2 == 0)
-                   break;
-               else
-                   pos += 2;
-           }
-           else {
-               break;
-           }
-       }
-       return pos;
-   }
-   function prevClusterBreak$2(str, pos, includeExtending) {
-       while (pos > 0) {
-           let found = nextClusterBreak$2(str, pos - 2, includeExtending);
-           if (found < pos)
-               return found;
-           pos--;
-       }
-       return 0;
-   }
-   function surrogateLow$3(ch) { return ch >= 0xDC00 && ch < 0xE000; }
-   function surrogateHigh$3(ch) { return ch >= 0xD800 && ch < 0xDC00; }
-   /**
-   Find the code point at the given position in a string (like the
-   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
-   string method).
-   */
-   function codePointAt$3(str, pos) {
-       let code0 = str.charCodeAt(pos);
-       if (!surrogateHigh$3(code0) || pos + 1 == str.length)
-           return code0;
-       let code1 = str.charCodeAt(pos + 1);
-       if (!surrogateLow$3(code1))
-           return code0;
-       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
-   }
-   /**
-   The first character that takes up two positions in a JavaScript
-   string. It is often useful to compare with this after calling
-   `codePointAt`, to figure out whether your character takes up 1 or
-   2 index positions.
-   */
-   function codePointSize$3(code) { return code < 0x10000 ? 1 : 2; }
-
-   const DefaultSplit$2 = /\r\n?|\n/;
-   /**
-   Distinguishes different ways in which positions can be mapped.
-   */
-   var MapMode$2 = /*@__PURE__*/(function (MapMode) {
-       /**
-       Map a position to a valid new position, even when its context
-       was deleted.
-       */
-       MapMode[MapMode["Simple"] = 0] = "Simple";
-       /**
-       Return null if deletion happens across the position.
-       */
-       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
-       /**
-       Return null if the character _before_ the position is deleted.
-       */
-       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
-       /**
-       Return null if the character _after_ the position is deleted.
-       */
-       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
-   return MapMode})(MapMode$2 || (MapMode$2 = {}));
-   /**
-   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
-   that doesn't store the inserted text. As such, it can't be
-   applied, but is cheaper to store and manipulate.
-   */
-   let ChangeDesc$2 = class ChangeDesc {
-       // Sections are encoded as pairs of integers. The first is the
-       // length in the current document, and the second is -1 for
-       // unaffected sections, and the length of the replacement content
-       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
-       // 0), and a replacement two positive numbers.
-       constructor(
-       /**
-       @internal
-       */
-       sections) {
-           this.sections = sections;
-       }
-       /**
-       The length of the document before the change.
-       */
-       get length() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2)
-               result += this.sections[i];
-           return result;
-       }
-       /**
-       The length of the document after the change.
-       */
-       get newLength() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let ins = this.sections[i + 1];
-               result += ins < 0 ? this.sections[i] : ins;
-           }
-           return result;
-       }
-       /**
-       False when there are actual changes in this set.
-       */
-       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
-       /**
-       Iterate over the unchanged parts left by these changes. `posA`
-       provides the position of the range in the old document, `posB`
-       the new position in the changed document.
-       */
-       iterGaps(f) {
-           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0) {
-                   f(posA, posB, len);
-                   posB += len;
-               }
-               else {
-                   posB += ins;
-               }
-               posA += len;
-           }
-       }
-       /**
-       Iterate over the ranges changed by these changes. (See
-       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
-       variant that also provides you with the inserted text.)
-       `fromA`/`toA` provides the extent of the change in the starting
-       document, `fromB`/`toB` the extent of the replacement in the
-       changed document.
-       
-       When `individual` is true, adjacent changes (which are kept
-       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
-       reported separately.
-       */
-       iterChangedRanges(f, individual = false) {
-           iterChanges$2(this, f, individual);
-       }
-       /**
-       Get a description of the inverted form of these changes.
-       */
-       get invertedDesc() {
-           let sections = [];
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0)
-                   sections.push(len, ins);
-               else
-                   sections.push(ins, len);
-           }
-           return new ChangeDesc(sections);
-       }
-       /**
-       Compute the combined effect of applying another set of changes
-       after this one. The length of the document after this set should
-       match the length before `other`.
-       */
-       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets$2(this, other); }
-       /**
-       Map this description, which should start with the same document
-       as `other`, over another set of changes, so that it can be
-       applied after it. When `before` is true, map as if the changes
-       in `other` happened before the ones in `this`.
-       */
-       mapDesc(other, before = false) { return other.empty ? this : mapSet$2(this, other, before); }
-       mapPos(pos, assoc = -1, mode = MapMode$2.Simple) {
-           let posA = 0, posB = 0;
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
-               if (ins < 0) {
-                   if (endA > pos)
-                       return posB + (pos - posA);
-                   posB += len;
-               }
-               else {
-                   if (mode != MapMode$2.Simple && endA >= pos &&
-                       (mode == MapMode$2.TrackDel && posA < pos && endA > pos ||
-                           mode == MapMode$2.TrackBefore && posA < pos ||
-                           mode == MapMode$2.TrackAfter && endA > pos))
-                       return null;
-                   if (endA > pos || endA == pos && assoc < 0 && !len)
-                       return pos == posA || assoc < 0 ? posB : posB + ins;
-                   posB += ins;
-               }
-               posA = endA;
-           }
-           if (pos > posA)
-               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
-           return posB;
-       }
-       /**
-       Check whether these changes touch a given range. When one of the
-       changes entirely covers the range, the string `"cover"` is
-       returned.
-       */
-       touchesRange(from, to = from) {
-           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
-               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
-               if (ins >= 0 && pos <= to && end >= from)
-                   return pos < from && end > to ? "cover" : true;
-               pos = end;
-           }
-           return false;
-       }
-       /**
-       @internal
-       */
-       toString() {
-           let result = "";
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
-           }
-           return result;
-       }
-       /**
-       Serialize this change desc to a JSON-representable value.
-       */
-       toJSON() { return this.sections; }
-       /**
-       Create a change desc from its JSON representation (as produced
-       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
-               throw new RangeError("Invalid JSON representation of ChangeDesc");
-           return new ChangeDesc(json);
-       }
-       /**
-       @internal
-       */
-       static create(sections) { return new ChangeDesc(sections); }
-   };
-   /**
-   A change set represents a group of modifications to a document. It
-   stores the document length, and can only be applied to documents
-   with exactly that length.
-   */
-   let ChangeSet$2 = class ChangeSet extends ChangeDesc$2 {
-       constructor(sections, 
-       /**
-       @internal
-       */
-       inserted) {
-           super(sections);
-           this.inserted = inserted;
-       }
-       /**
-       Apply the changes to a document, returning the modified
-       document.
-       */
-       apply(doc) {
-           if (this.length != doc.length)
-               throw new RangeError("Applying change set to a document with the wrong length");
-           iterChanges$2(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
-           return doc;
-       }
-       mapDesc(other, before = false) { return mapSet$2(this, other, before, true); }
-       /**
-       Given the document as it existed _before_ the changes, return a
-       change set that represents the inverse of this set, which could
-       be used to go from the document created by the changes back to
-       the document as it existed before the changes.
-       */
-       invert(doc) {
-           let sections = this.sections.slice(), inserted = [];
-           for (let i = 0, pos = 0; i < sections.length; i += 2) {
-               let len = sections[i], ins = sections[i + 1];
-               if (ins >= 0) {
-                   sections[i] = ins;
-                   sections[i + 1] = len;
-                   let index = i >> 1;
-                   while (inserted.length < index)
-                       inserted.push(Text$2.empty);
-                   inserted.push(len ? doc.slice(pos, pos + len) : Text$2.empty);
-               }
-               pos += len;
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       Combine two subsequent change sets into a single set. `other`
-       must start in the document produced by `this`. If `this` goes
-       `docA` → `docB` and `other` represents `docB` → `docC`, the
-       returned value will represent the change `docA` → `docC`.
-       */
-       compose(other) { return this.empty ? other : other.empty ? this : composeSets$2(this, other, true); }
-       /**
-       Given another change set starting in the same document, maps this
-       change set over the other, producing a new change set that can be
-       applied to the document produced by applying `other`. When
-       `before` is `true`, order changes as if `this` comes before
-       `other`, otherwise (the default) treat `other` as coming first.
-       
-       Given two changes `A` and `B`, `A.compose(B.map(A))` and
-       `B.compose(A.map(B, true))` will produce the same document. This
-       provides a basic form of [operational
-       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
-       and can be used for collaborative editing.
-       */
-       map(other, before = false) { return other.empty ? this : mapSet$2(this, other, before, true); }
-       /**
-       Iterate over the changed ranges in the document, calling `f` for
-       each, with the range in the original document (`fromA`-`toA`)
-       and the range that replaces it in the new document
-       (`fromB`-`toB`).
-       
-       When `individual` is true, adjacent changes are reported
-       separately.
-       */
-       iterChanges(f, individual = false) {
-           iterChanges$2(this, f, individual);
-       }
-       /**
-       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
-       set.
-       */
-       get desc() { return ChangeDesc$2.create(this.sections); }
-       /**
-       @internal
-       */
-       filter(ranges) {
-           let resultSections = [], resultInserted = [], filteredSections = [];
-           let iter = new SectionIter$2(this);
-           done: for (let i = 0, pos = 0;;) {
-               let next = i == ranges.length ? 1e9 : ranges[i++];
-               while (pos < next || pos == next && iter.len == 0) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, next - pos);
-                   addSection$2(filteredSections, len, -1);
-                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
-                   addSection$2(resultSections, len, ins);
-                   if (ins > 0)
-                       addInsert$2(resultInserted, resultSections, iter.text);
-                   iter.forward(len);
-                   pos += len;
-               }
-               let end = ranges[i++];
-               while (pos < end) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, end - pos);
-                   addSection$2(resultSections, len, -1);
-                   addSection$2(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
-                   iter.forward(len);
-                   pos += len;
-               }
-           }
-           return { changes: new ChangeSet(resultSections, resultInserted),
-               filtered: ChangeDesc$2.create(filteredSections) };
-       }
-       /**
-       Serialize this change set to a JSON-representable value.
-       */
-       toJSON() {
-           let parts = [];
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let len = this.sections[i], ins = this.sections[i + 1];
-               if (ins < 0)
-                   parts.push(len);
-               else if (ins == 0)
-                   parts.push([len]);
-               else
-                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
-           }
-           return parts;
-       }
-       /**
-       Create a change set for the given changes, for a document of the
-       given length, using `lineSep` as line separator.
-       */
-       static of(changes, length, lineSep) {
-           let sections = [], inserted = [], pos = 0;
-           let total = null;
-           function flush(force = false) {
-               if (!force && !sections.length)
-                   return;
-               if (pos < length)
-                   addSection$2(sections, length - pos, -1);
-               let set = new ChangeSet(sections, inserted);
-               total = total ? total.compose(set.map(total)) : set;
-               sections = [];
-               inserted = [];
-               pos = 0;
-           }
-           function process(spec) {
-               if (Array.isArray(spec)) {
-                   for (let sub of spec)
-                       process(sub);
-               }
-               else if (spec instanceof ChangeSet) {
-                   if (spec.length != length)
-                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
-                   flush();
-                   total = total ? total.compose(spec.map(total)) : spec;
-               }
-               else {
-                   let { from, to = from, insert } = spec;
-                   if (from > to || from < 0 || to > length)
-                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
-                   let insText = !insert ? Text$2.empty : typeof insert == "string" ? Text$2.of(insert.split(lineSep || DefaultSplit$2)) : insert;
-                   let insLen = insText.length;
-                   if (from == to && insLen == 0)
-                       return;
-                   if (from < pos)
-                       flush();
-                   if (from > pos)
-                       addSection$2(sections, from - pos, -1);
-                   addSection$2(sections, to - from, insLen);
-                   addInsert$2(inserted, sections, insText);
-                   pos = to;
-               }
-           }
-           process(changes);
-           flush(!total);
-           return total;
-       }
-       /**
-       Create an empty changeset of the given length.
-       */
-       static empty(length) {
-           return new ChangeSet(length ? [length, -1] : [], []);
-       }
-       /**
-       Create a changeset from its JSON representation (as produced by
-       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json))
-               throw new RangeError("Invalid JSON representation of ChangeSet");
-           let sections = [], inserted = [];
-           for (let i = 0; i < json.length; i++) {
-               let part = json[i];
-               if (typeof part == "number") {
-                   sections.push(part, -1);
-               }
-               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
-                   throw new RangeError("Invalid JSON representation of ChangeSet");
-               }
-               else if (part.length == 1) {
-                   sections.push(part[0], 0);
-               }
-               else {
-                   while (inserted.length < i)
-                       inserted.push(Text$2.empty);
-                   inserted[i] = Text$2.of(part.slice(1));
-                   sections.push(part[0], inserted[i].length);
-               }
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       @internal
-       */
-       static createSet(sections, inserted) {
-           return new ChangeSet(sections, inserted);
-       }
-   };
-   function addSection$2(sections, len, ins, forceJoin = false) {
-       if (len == 0 && ins <= 0)
-           return;
-       let last = sections.length - 2;
-       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
-           sections[last] += len;
-       else if (len == 0 && sections[last] == 0)
-           sections[last + 1] += ins;
-       else if (forceJoin) {
-           sections[last] += len;
-           sections[last + 1] += ins;
-       }
-       else
-           sections.push(len, ins);
-   }
-   function addInsert$2(values, sections, value) {
-       if (value.length == 0)
-           return;
-       let index = (sections.length - 2) >> 1;
-       if (index < values.length) {
-           values[values.length - 1] = values[values.length - 1].append(value);
-       }
-       else {
-           while (values.length < index)
-               values.push(Text$2.empty);
-           values.push(value);
-       }
-   }
-   function iterChanges$2(desc, f, individual) {
-       let inserted = desc.inserted;
-       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
-           let len = desc.sections[i++], ins = desc.sections[i++];
-           if (ins < 0) {
-               posA += len;
-               posB += len;
-           }
-           else {
-               let endA = posA, endB = posB, text = Text$2.empty;
-               for (;;) {
-                   endA += len;
-                   endB += ins;
-                   if (ins && inserted)
-                       text = text.append(inserted[(i - 2) >> 1]);
-                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
-                       break;
-                   len = desc.sections[i++];
-                   ins = desc.sections[i++];
-               }
-               f(posA, endA, posB, endB, text);
-               posA = endA;
-               posB = endB;
-           }
-       }
-   }
-   function mapSet$2(setA, setB, before, mkSet = false) {
-       let sections = [], insert = mkSet ? [] : null;
-       let a = new SectionIter$2(setA), b = new SectionIter$2(setB);
-       for (let posA = 0, posB = 0;;) {
-           if (a.ins == -1) {
-               posA += a.len;
-               a.next();
-           }
-           else if (b.ins == -1 && posB < posA) {
-               let skip = Math.min(b.len, posA - posB);
-               b.forward(skip);
-               addSection$2(sections, skip, -1);
-               posB += skip;
-           }
-           else if (b.ins >= 0 && (a.done || posB < posA || posB == posA && (b.len < a.len || b.len == a.len && !before))) {
-               addSection$2(sections, b.ins, -1);
-               while (posA > posB && !a.done && posA + a.len < posB + b.len) {
-                   posA += a.len;
-                   a.next();
-               }
-               posB += b.len;
-               b.next();
-           }
-           else if (a.ins >= 0) {
-               let len = 0, end = posA + a.len;
-               for (;;) {
-                   if (b.ins >= 0 && posB > posA && posB + b.len < end) {
-                       len += b.ins;
-                       posB += b.len;
-                       b.next();
-                   }
-                   else if (b.ins == -1 && posB < end) {
-                       let skip = Math.min(b.len, end - posB);
-                       len += skip;
-                       b.forward(skip);
-                       posB += skip;
-                   }
-                   else {
-                       break;
-                   }
-               }
-               addSection$2(sections, len, a.ins);
-               if (insert)
-                   addInsert$2(insert, sections, a.text);
-               posA = end;
-               a.next();
-           }
-           else if (a.done && b.done) {
-               return insert ? ChangeSet$2.createSet(sections, insert) : ChangeDesc$2.create(sections);
-           }
-           else {
-               throw new Error("Mismatched change set lengths");
-           }
-       }
-   }
-   function composeSets$2(setA, setB, mkSet = false) {
-       let sections = [];
-       let insert = mkSet ? [] : null;
-       let a = new SectionIter$2(setA), b = new SectionIter$2(setB);
-       for (let open = false;;) {
-           if (a.done && b.done) {
-               return insert ? ChangeSet$2.createSet(sections, insert) : ChangeDesc$2.create(sections);
-           }
-           else if (a.ins == 0) { // Deletion in A
-               addSection$2(sections, a.len, 0, open);
-               a.next();
-           }
-           else if (b.len == 0 && !b.done) { // Insertion in B
-               addSection$2(sections, 0, b.ins, open);
-               if (insert)
-                   addInsert$2(insert, sections, b.text);
-               b.next();
-           }
-           else if (a.done || b.done) {
-               throw new Error("Mismatched change set lengths");
-           }
-           else {
-               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
-               if (a.ins == -1) {
-                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
-                   addSection$2(sections, len, insB, open);
-                   if (insert && insB)
-                       addInsert$2(insert, sections, b.text);
-               }
-               else if (b.ins == -1) {
-                   addSection$2(sections, a.off ? 0 : a.len, len, open);
-                   if (insert)
-                       addInsert$2(insert, sections, a.textBit(len));
-               }
-               else {
-                   addSection$2(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
-                   if (insert && !b.off)
-                       addInsert$2(insert, sections, b.text);
-               }
-               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
-               a.forward2(len);
-               b.forward(len);
-           }
-       }
-   }
-   let SectionIter$2 = class SectionIter {
-       constructor(set) {
-           this.set = set;
-           this.i = 0;
-           this.next();
-       }
-       next() {
-           let { sections } = this.set;
-           if (this.i < sections.length) {
-               this.len = sections[this.i++];
-               this.ins = sections[this.i++];
-           }
-           else {
-               this.len = 0;
-               this.ins = -2;
-           }
-           this.off = 0;
-       }
-       get done() { return this.ins == -2; }
-       get len2() { return this.ins < 0 ? this.len : this.ins; }
-       get text() {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length ? Text$2.empty : inserted[index];
-       }
-       textBit(len) {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length && !len ? Text$2.empty
-               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
-       }
-       forward(len) {
-           if (len == this.len)
-               this.next();
-           else {
-               this.len -= len;
-               this.off += len;
-           }
-       }
-       forward2(len) {
-           if (this.ins == -1)
-               this.forward(len);
-           else if (len == this.ins)
-               this.next();
-           else {
-               this.ins -= len;
-               this.off += len;
-           }
-       }
-   };
-
-   /**
-   A single selection range. When
-   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
-   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
-   multiple ranges. By default, selections hold exactly one range.
-   */
-   let SelectionRange$2 = class SelectionRange {
-       constructor(
-       /**
-       The lower boundary of the range.
-       */
-       from, 
-       /**
-       The upper boundary of the range.
-       */
-       to, flags) {
-           this.from = from;
-           this.to = to;
-           this.flags = flags;
-       }
-       /**
-       The anchor of the range—the side that doesn't move when you
-       extend it.
-       */
-       get anchor() { return this.flags & 16 /* Inverted */ ? 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 & 16 /* Inverted */ ? 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 & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
-       /**
-       The bidirectional text level associated with this cursor, if
-       any.
-       */
-       get bidiLevel() {
-           let level = this.flags & 3 /* BidiLevelMask */;
-           return level == 3 ? null : level;
-       }
-       /**
-       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 value = this.flags >> 5 /* GoalColumnOffset */;
-           return value == 33554431 /* NoGoalColumn */ ? undefined : value;
-       }
-       /**
-       Map this range through a change, producing a valid range in the
-       updated document.
-       */
-       map(change, assoc = -1) {
-           let from, to;
-           if (this.empty) {
-               from = to = change.mapPos(this.from, assoc);
-           }
-           else {
-               from = change.mapPos(this.from, 1);
-               to = change.mapPos(this.to, -1);
-           }
-           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
-       }
-       /**
-       Extend this range to cover at least `from` to `to`.
-       */
-       extend(from, to = from) {
-           if (from <= this.anchor && to >= this.anchor)
-               return EditorSelection$2.range(from, to);
-           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
-           return EditorSelection$2.range(this.anchor, head);
-       }
-       /**
-       Compare this range to another range.
-       */
-       eq(other) {
-           return this.anchor == other.anchor && this.head == other.head;
-       }
-       /**
-       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(json) {
-           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
-               throw new RangeError("Invalid JSON representation for SelectionRange");
-           return EditorSelection$2.range(json.anchor, json.head);
-       }
-       /**
-       @internal
-       */
-       static create(from, to, flags) {
-           return new SelectionRange(from, to, flags);
-       }
-   };
-   /**
-   An editor selection holds one or more selection ranges.
-   */
-   let EditorSelection$2 = class EditorSelection {
-       constructor(
-       /**
-       The ranges in the selection, sorted by position. Ranges cannot
-       overlap (but they may touch, if they aren't empty).
-       */
-       ranges, 
-       /**
-       The index of the _main_ range in the selection (which is
-       usually the range that was added last).
-       */
-       mainIndex) {
-           this.ranges = ranges;
-           this.mainIndex = mainIndex;
-       }
-       /**
-       Map a selection through a change. Used to adjust the selection
-       position for changes.
-       */
-       map(change, assoc = -1) {
-           if (change.empty)
-               return this;
-           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
-       }
-       /**
-       Compare this selection to another selection.
-       */
-       eq(other) {
-           if (this.ranges.length != other.ranges.length ||
-               this.mainIndex != other.mainIndex)
-               return false;
-           for (let i = 0; i < this.ranges.length; i++)
-               if (!this.ranges[i].eq(other.ranges[i]))
-                   return false;
-           return true;
-       }
-       /**
-       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 EditorSelection([this.main], 0);
-       }
-       /**
-       Extend this selection with an extra range.
-       */
-       addRange(range, main = true) {
-           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
-       }
-       /**
-       Replace a given range with another range, and then normalize the
-       selection to merge and sort ranges if necessary.
-       */
-       replaceRange(range, which = this.mainIndex) {
-           let ranges = this.ranges.slice();
-           ranges[which] = range;
-           return EditorSelection.create(ranges, this.mainIndex);
-       }
-       /**
-       Convert this selection to an object that can be serialized to
-       JSON.
-       */
-       toJSON() {
-           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
-       }
-       /**
-       Create a selection from a JSON representation.
-       */
-       static fromJSON(json) {
-           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
-               throw new RangeError("Invalid JSON representation for EditorSelection");
-           return new EditorSelection(json.ranges.map((r) => SelectionRange$2.fromJSON(r)), json.main);
-       }
-       /**
-       Create a selection holding a single range.
-       */
-       static single(anchor, head = anchor) {
-           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
-       }
-       /**
-       Sort and merge the given set of ranges, creating a valid
-       selection.
-       */
-       static create(ranges, mainIndex = 0) {
-           if (ranges.length == 0)
-               throw new RangeError("A selection needs at least one range");
-           for (let pos = 0, i = 0; i < ranges.length; i++) {
-               let range = ranges[i];
-               if (range.empty ? range.from <= pos : range.from < pos)
-                   return EditorSelection.normalized(ranges.slice(), mainIndex);
-               pos = range.to;
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-       /**
-       Create a cursor selection range at the given position. You can
-       safely ignore the optional arguments in most situations.
-       */
-       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
-           return SelectionRange$2.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
-               (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
-               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
-       }
-       /**
-       Create a selection range.
-       */
-       static range(anchor, head, goalColumn) {
-           let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
-           return head < anchor ? SelectionRange$2.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
-               : SelectionRange$2.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
-       }
-       /**
-       @internal
-       */
-       static normalized(ranges, mainIndex = 0) {
-           let main = ranges[mainIndex];
-           ranges.sort((a, b) => a.from - b.from);
-           mainIndex = ranges.indexOf(main);
-           for (let i = 1; i < ranges.length; i++) {
-               let range = ranges[i], prev = ranges[i - 1];
-               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
-                   let from = prev.from, to = Math.max(range.to, prev.to);
-                   if (i <= mainIndex)
-                       mainIndex--;
-                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
-               }
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-   };
-   function checkSelection$2(selection, docLength) {
-       for (let range of selection.ranges)
-           if (range.to > docLength)
-               throw new RangeError("Selection points outside of document");
-   }
-
-   let nextID$2 = 0;
-   /**
-   A facet is a labeled value that is associated with an editor
-   state. It takes inputs from any number of extensions, and combines
-   those into a single output value.
-
-   Examples of uses of facets are the [tab
-   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
-   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
-   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
-   */
-   let Facet$2 = class Facet {
-       constructor(
-       /**
-       @internal
-       */
-       combine, 
-       /**
-       @internal
-       */
-       compareInput, 
-       /**
-       @internal
-       */
-       compare, isStatic, 
-       /**
-       @internal
-       */
-       extensions) {
-           this.combine = combine;
-           this.compareInput = compareInput;
-           this.compare = compare;
-           this.isStatic = isStatic;
-           this.extensions = extensions;
-           /**
-           @internal
-           */
-           this.id = nextID$2++;
-           this.default = combine([]);
-       }
-       /**
-       Define a new facet.
-       */
-       static define(config = {}) {
-           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$4 : (a, b) => a === b), !!config.static, config.enables);
-       }
-       /**
-       Returns an extension that adds the given value to this facet.
-       */
-       of(value) {
-           return new FacetProvider$2([], this, 0 /* Static */, value);
-       }
-       /**
-       Create an extension that computes a value for the facet from a
-       state. You must take care to declare the parts of the state that
-       this value depends on, since your function is only called again
-       for a new state when one of those parts changed.
-       
-       In cases where your value depends only on a single field, you'll
-       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
-       */
-       compute(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider$2(deps, this, 1 /* Single */, get);
-       }
-       /**
-       Create an extension that computes zero or more values for this
-       facet from a state.
-       */
-       computeN(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider$2(deps, this, 2 /* Multi */, get);
-       }
-       from(field, get) {
-           if (!get)
-               get = x => x;
-           return this.compute([field], state => get(state.field(field)));
-       }
-   };
-   function sameArray$4(a, b) {
-       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
-   }
-   let FacetProvider$2 = class FacetProvider {
-       constructor(dependencies, facet, type, value) {
-           this.dependencies = dependencies;
-           this.facet = facet;
-           this.type = type;
-           this.value = value;
-           this.id = nextID$2++;
-       }
-       dynamicSlot(addresses) {
-           var _a;
-           let getter = this.value;
-           let compare = this.facet.compareInput;
-           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
-           let depDoc = false, depSel = false, depAddrs = [];
-           for (let dep of this.dependencies) {
-               if (dep == "doc")
-                   depDoc = true;
-               else if (dep == "selection")
-                   depSel = true;
-               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
-                   depAddrs.push(addresses[dep.id]);
-           }
-           return {
-               create(state) {
-                   state.values[idx] = getter(state);
-                   return 1 /* Changed */;
-               },
-               update(state, tr) {
-                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll$2(state, depAddrs)) {
-                       let newVal = getter(state);
-                       if (multi ? !compareArray$2(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
-                           state.values[idx] = newVal;
-                           return 1 /* Changed */;
-                       }
-                   }
-                   return 0;
-               },
-               reconfigure: (state, oldState) => {
-                   let newVal = getter(state);
-                   let oldAddr = oldState.config.address[id];
-                   if (oldAddr != null) {
-                       let oldVal = getAddr$2(oldState, oldAddr);
-                       if (this.dependencies.every(dep => {
-                           return dep instanceof Facet$2 ? oldState.facet(dep) === state.facet(dep) :
-                               dep instanceof StateField$2 ? oldState.field(dep, false) == state.field(dep, false) : true;
-                       }) || (multi ? compareArray$2(newVal, oldVal, compare) : compare(newVal, oldVal))) {
-                           state.values[idx] = oldVal;
-                           return 0;
-                       }
-                   }
-                   state.values[idx] = newVal;
-                   return 1 /* Changed */;
-               }
-           };
-       }
-   };
-   function compareArray$2(a, b, compare) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (!compare(a[i], b[i]))
-               return false;
-       return true;
-   }
-   function ensureAll$2(state, addrs) {
-       let changed = false;
-       for (let addr of addrs)
-           if (ensureAddr$2(state, addr) & 1 /* Changed */)
-               changed = true;
-       return changed;
-   }
-   function dynamicFacetSlot$2(addresses, facet, providers) {
-       let providerAddrs = providers.map(p => addresses[p.id]);
-       let providerTypes = providers.map(p => p.type);
-       let dynamic = providerAddrs.filter(p => !(p & 1));
-       let idx = addresses[facet.id] >> 1;
-       function get(state) {
-           let values = [];
-           for (let i = 0; i < providerAddrs.length; i++) {
-               let value = getAddr$2(state, providerAddrs[i]);
-               if (providerTypes[i] == 2 /* Multi */)
-                   for (let val of value)
-                       values.push(val);
-               else
-                   values.push(value);
-           }
-           return facet.combine(values);
-       }
-       return {
-           create(state) {
-               for (let addr of providerAddrs)
-                   ensureAddr$2(state, addr);
-               state.values[idx] = get(state);
-               return 1 /* Changed */;
-           },
-           update(state, tr) {
-               if (!ensureAll$2(state, dynamic))
-                   return 0;
-               let value = get(state);
-               if (facet.compare(value, state.values[idx]))
-                   return 0;
-               state.values[idx] = value;
-               return 1 /* Changed */;
-           },
-           reconfigure(state, oldState) {
-               let depChanged = ensureAll$2(state, providerAddrs);
-               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
-               if (oldProviders && !depChanged && sameArray$4(providers, oldProviders)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               let value = get(state);
-               if (facet.compare(value, oldValue)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               state.values[idx] = value;
-               return 1 /* Changed */;
-           }
-       };
-   }
-   const initField$2 = /*@__PURE__*/Facet$2.define({ static: true });
-   /**
-   Fields can store additional information in an editor state, and
-   keep it in sync with the rest of the state.
-   */
-   let StateField$2 = class StateField {
-       constructor(
-       /**
-       @internal
-       */
-       id, createF, updateF, compareF, 
-       /**
-       @internal
-       */
-       spec) {
-           this.id = id;
-           this.createF = createF;
-           this.updateF = updateF;
-           this.compareF = compareF;
-           this.spec = spec;
-           /**
-           @internal
-           */
-           this.provides = undefined;
-       }
-       /**
-       Define a state field.
-       */
-       static define(config) {
-           let field = new StateField(nextID$2++, config.create, config.update, config.compare || ((a, b) => a === b), config);
-           if (config.provide)
-               field.provides = config.provide(field);
-           return field;
-       }
-       create(state) {
-           let init = state.facet(initField$2).find(i => i.field == this);
-           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
-       }
-       /**
-       @internal
-       */
-       slot(addresses) {
-           let idx = addresses[this.id] >> 1;
-           return {
-               create: (state) => {
-                   state.values[idx] = this.create(state);
-                   return 1 /* Changed */;
-               },
-               update: (state, tr) => {
-                   let oldVal = state.values[idx];
-                   let value = this.updateF(oldVal, tr);
-                   if (this.compareF(oldVal, value))
-                       return 0;
-                   state.values[idx] = value;
-                   return 1 /* Changed */;
-               },
-               reconfigure: (state, oldState) => {
-                   if (oldState.config.address[this.id] != null) {
-                       state.values[idx] = oldState.field(this);
-                       return 0;
-                   }
-                   state.values[idx] = this.create(state);
-                   return 1 /* Changed */;
-               }
-           };
-       }
-       /**
-       Returns an extension that enables this field and overrides the
-       way it is initialized. Can be useful when you need to provide a
-       non-default starting value for the field.
-       */
-       init(create) {
-           return [this, initField$2.of({ field: this, create })];
-       }
-       /**
-       State field instances can be used as
-       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
-       given state.
-       */
-       get extension() { return this; }
-   };
-   const Prec_$2 = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
-   function prec$2(value) {
-       return (ext) => new PrecExtension$2(ext, value);
-   }
-   /**
-   By default extensions are registered in the order they are found
-   in the flattened form of nested array that was provided.
-   Individual extension values can be assigned a precedence to
-   override this. Extensions that do not have a precedence set get
-   the precedence of the nearest parent with a precedence, or
-   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
-   final ordering of extensions is determined by first sorting by
-   precedence and then by order within each precedence.
-   */
-   const Prec$2 = {
-       /**
-       The highest precedence level, for extensions that should end up
-       near the start of the precedence ordering.
-       */
-       highest: /*@__PURE__*/prec$2(Prec_$2.highest),
-       /**
-       A higher-than-default precedence, for extensions that should
-       come before those with default precedence.
-       */
-       high: /*@__PURE__*/prec$2(Prec_$2.high),
-       /**
-       The default precedence, which is also used for extensions
-       without an explicit precedence.
-       */
-       default: /*@__PURE__*/prec$2(Prec_$2.default),
-       /**
-       A lower-than-default precedence.
-       */
-       low: /*@__PURE__*/prec$2(Prec_$2.low),
-       /**
-       The lowest precedence level. Meant for things that should end up
-       near the end of the extension order.
-       */
-       lowest: /*@__PURE__*/prec$2(Prec_$2.lowest)
-   };
-   let PrecExtension$2 = class PrecExtension {
-       constructor(inner, prec) {
-           this.inner = inner;
-           this.prec = prec;
-       }
-   };
-   /**
-   Extension compartments can be used to make a configuration
-   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
-   configuration in a compartment, you can later
-   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
-   transaction.
-   */
-   let Compartment$2 = class Compartment {
-       /**
-       Create an instance of this compartment to add to your [state
-       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
-       */
-       of(ext) { return new CompartmentInstance$2(this, ext); }
-       /**
-       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
-       reconfigures this compartment.
-       */
-       reconfigure(content) {
-           return Compartment.reconfigure.of({ compartment: this, extension: content });
-       }
-       /**
-       Get the current content of the compartment in the state, or
-       `undefined` if it isn't present.
-       */
-       get(state) {
-           return state.config.compartments.get(this);
-       }
-   };
-   let CompartmentInstance$2 = class CompartmentInstance {
-       constructor(compartment, inner) {
-           this.compartment = compartment;
-           this.inner = inner;
-       }
-   };
-   let Configuration$2 = class Configuration {
-       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
-           this.base = base;
-           this.compartments = compartments;
-           this.dynamicSlots = dynamicSlots;
-           this.address = address;
-           this.staticValues = staticValues;
-           this.facets = facets;
-           this.statusTemplate = [];
-           while (this.statusTemplate.length < dynamicSlots.length)
-               this.statusTemplate.push(0 /* Unresolved */);
-       }
-       staticFacet(facet) {
-           let addr = this.address[facet.id];
-           return addr == null ? facet.default : this.staticValues[addr >> 1];
-       }
-       static resolve(base, compartments, oldState) {
-           let fields = [];
-           let facets = Object.create(null);
-           let newCompartments = new Map();
-           for (let ext of flatten$2(base, compartments, newCompartments)) {
-               if (ext instanceof StateField$2)
-                   fields.push(ext);
-               else
-                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
-           }
-           let address = Object.create(null);
-           let staticValues = [];
-           let dynamicSlots = [];
-           for (let field of fields) {
-               address[field.id] = dynamicSlots.length << 1;
-               dynamicSlots.push(a => field.slot(a));
-           }
-           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
-           for (let id in facets) {
-               let providers = facets[id], facet = providers[0].facet;
-               let oldProviders = oldFacets && oldFacets[id] || [];
-               if (providers.every(p => p.type == 0 /* Static */)) {
-                   address[facet.id] = (staticValues.length << 1) | 1;
-                   if (sameArray$4(oldProviders, providers)) {
-                       staticValues.push(oldState.facet(facet));
-                   }
-                   else {
-                       let value = facet.combine(providers.map(p => p.value));
-                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
-                   }
-               }
-               else {
-                   for (let p of providers) {
-                       if (p.type == 0 /* Static */) {
-                           address[p.id] = (staticValues.length << 1) | 1;
-                           staticValues.push(p.value);
-                       }
-                       else {
-                           address[p.id] = dynamicSlots.length << 1;
-                           dynamicSlots.push(a => p.dynamicSlot(a));
-                       }
-                   }
-                   address[facet.id] = dynamicSlots.length << 1;
-                   dynamicSlots.push(a => dynamicFacetSlot$2(a, facet, providers));
-               }
-           }
-           let dynamic = dynamicSlots.map(f => f(address));
-           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
-       }
-   };
-   function flatten$2(extension, compartments, newCompartments) {
-       let result = [[], [], [], [], []];
-       let seen = new Map();
-       function inner(ext, prec) {
-           let known = seen.get(ext);
-           if (known != null) {
-               if (known <= prec)
-                   return;
-               let found = result[known].indexOf(ext);
-               if (found > -1)
-                   result[known].splice(found, 1);
-               if (ext instanceof CompartmentInstance$2)
-                   newCompartments.delete(ext.compartment);
-           }
-           seen.set(ext, prec);
-           if (Array.isArray(ext)) {
-               for (let e of ext)
-                   inner(e, prec);
-           }
-           else if (ext instanceof CompartmentInstance$2) {
-               if (newCompartments.has(ext.compartment))
-                   throw new RangeError(`Duplicate use of compartment in extensions`);
-               let content = compartments.get(ext.compartment) || ext.inner;
-               newCompartments.set(ext.compartment, content);
-               inner(content, prec);
-           }
-           else if (ext instanceof PrecExtension$2) {
-               inner(ext.inner, ext.prec);
-           }
-           else if (ext instanceof StateField$2) {
-               result[prec].push(ext);
-               if (ext.provides)
-                   inner(ext.provides, prec);
-           }
-           else if (ext instanceof FacetProvider$2) {
-               result[prec].push(ext);
-               if (ext.facet.extensions)
-                   inner(ext.facet.extensions, prec);
-           }
-           else {
-               let content = ext.extension;
-               if (!content)
-                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
-               inner(content, prec);
-           }
-       }
-       inner(extension, Prec_$2.default);
-       return result.reduce((a, b) => a.concat(b));
-   }
-   function ensureAddr$2(state, addr) {
-       if (addr & 1)
-           return 2 /* Computed */;
-       let idx = addr >> 1;
-       let status = state.status[idx];
-       if (status == 4 /* Computing */)
-           throw new Error("Cyclic dependency between fields and/or facets");
-       if (status & 2 /* Computed */)
-           return status;
-       state.status[idx] = 4 /* Computing */;
-       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
-       return state.status[idx] = 2 /* Computed */ | changed;
-   }
-   function getAddr$2(state, addr) {
-       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
-   }
-
-   const languageData$2 = /*@__PURE__*/Facet$2.define();
-   const allowMultipleSelections$2 = /*@__PURE__*/Facet$2.define({
-       combine: values => values.some(v => v),
-       static: true
-   });
-   const lineSeparator$2 = /*@__PURE__*/Facet$2.define({
-       combine: values => values.length ? values[0] : undefined,
-       static: true
-   });
-   const changeFilter$2 = /*@__PURE__*/Facet$2.define();
-   const transactionFilter$2 = /*@__PURE__*/Facet$2.define();
-   const transactionExtender$2 = /*@__PURE__*/Facet$2.define();
-   const readOnly$2 = /*@__PURE__*/Facet$2.define({
-       combine: values => values.length ? values[0] : false
-   });
-
-   /**
-   Annotations are tagged values that are used to add metadata to
-   transactions in an extensible way. They should be used to model
-   things that effect the entire transaction (such as its [time
-   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
-   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
-   _alongside_ the other changes made by the transaction, [state
-   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
-   */
-   let Annotation$2 = class Annotation {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The annotation type.
-       */
-       type, 
-       /**
-       The value of this annotation.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Define a new type of annotation.
-       */
-       static define() { return new AnnotationType$2(); }
-   };
-   /**
-   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
-   */
-   let AnnotationType$2 = class AnnotationType {
-       /**
-       Create an instance of this annotation.
-       */
-       of(value) { return new Annotation$2(this, value); }
-   };
-   /**
-   Representation of a type of state effect. Defined with
-   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
-   */
-   let StateEffectType$2 = class StateEffectType {
-       /**
-       @internal
-       */
-       constructor(
-       // The `any` types in these function types are there to work
-       // around TypeScript issue #37631, where the type guard on
-       // `StateEffect.is` mysteriously stops working when these properly
-       // have type `Value`.
-       /**
-       @internal
-       */
-       map) {
-           this.map = map;
-       }
-       /**
-       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
-       type.
-       */
-       of(value) { return new StateEffect$2(this, value); }
-   };
-   /**
-   State effects can be used to represent additional effects
-   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
-   are often useful to model changes to custom [state
-   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
-   document or selection changes.
-   */
-   let StateEffect$2 = class StateEffect {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       @internal
-       */
-       type, 
-       /**
-       The value of this effect.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Map this effect through a position mapping. Will return
-       `undefined` when that ends up deleting the effect.
-       */
-       map(mapping) {
-           let mapped = this.type.map(this.value, mapping);
-           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
-       }
-       /**
-       Tells you whether this effect object is of a given
-       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
-       */
-       is(type) { return this.type == type; }
-       /**
-       Define a new effect type. The type parameter indicates the type
-       of values that his effect holds.
-       */
-       static define(spec = {}) {
-           return new StateEffectType$2(spec.map || (v => v));
-       }
-       /**
-       Map an array of effects through a change set.
-       */
-       static mapEffects(effects, mapping) {
-           if (!effects.length)
-               return effects;
-           let result = [];
-           for (let effect of effects) {
-               let mapped = effect.map(mapping);
-               if (mapped)
-                   result.push(mapped);
-           }
-           return result;
-       }
-   };
-   /**
-   This effect can be used to reconfigure the root extensions of
-   the editor. Doing this will discard any extensions
-   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
-   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
-   compartments.
-   */
-   StateEffect$2.reconfigure = /*@__PURE__*/StateEffect$2.define();
-   /**
-   Append extensions to the top-level configuration of the editor.
-   */
-   StateEffect$2.appendConfig = /*@__PURE__*/StateEffect$2.define();
-   /**
-   Changes to the editor state are grouped into transactions.
-   Typically, a user action creates a single transaction, which may
-   contain any number of document changes, may change the selection,
-   or have other effects. Create a transaction by calling
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
-   dispatch one by calling
-   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
-   */
-   let Transaction$2 = class Transaction {
-       constructor(
-       /**
-       The state from which the transaction starts.
-       */
-       startState, 
-       /**
-       The document changes made by this transaction.
-       */
-       changes, 
-       /**
-       The selection set by this transaction, or undefined if it
-       doesn't explicitly set a selection.
-       */
-       selection, 
-       /**
-       The effects added to the transaction.
-       */
-       effects, 
-       /**
-       @internal
-       */
-       annotations, 
-       /**
-       Whether the selection should be scrolled into view after this
-       transaction is dispatched.
-       */
-       scrollIntoView) {
-           this.startState = startState;
-           this.changes = changes;
-           this.selection = selection;
-           this.effects = effects;
-           this.annotations = annotations;
-           this.scrollIntoView = scrollIntoView;
-           /**
-           @internal
-           */
-           this._doc = null;
-           /**
-           @internal
-           */
-           this._state = null;
-           if (selection)
-               checkSelection$2(selection, changes.newLength);
-           if (!annotations.some((a) => a.type == Transaction.time))
-               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
-       }
-       /**
-       @internal
-       */
-       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
-           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
-       }
-       /**
-       The new document produced by the transaction. Contrary to
-       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
-       force the entire new state to be computed right away, so it is
-       recommended that [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
-       when they need to look at the new document.
-       */
-       get newDoc() {
-           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
-       }
-       /**
-       The new selection produced by the transaction. If
-       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
-       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
-       current selection through the changes made by the transaction.
-       */
-       get newSelection() {
-           return this.selection || this.startState.selection.map(this.changes);
-       }
-       /**
-       The new state created by the transaction. Computed on demand
-       (but retained for subsequent access), so it is recommended not to
-       access it in [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
-       */
-       get state() {
-           if (!this._state)
-               this.startState.applyTransaction(this);
-           return this._state;
-       }
-       /**
-       Get the value of the given annotation type, if any.
-       */
-       annotation(type) {
-           for (let ann of this.annotations)
-               if (ann.type == type)
-                   return ann.value;
-           return undefined;
-       }
-       /**
-       Indicates whether the transaction changed the document.
-       */
-       get docChanged() { return !this.changes.empty; }
-       /**
-       Indicates whether this transaction reconfigures the state
-       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
-       with a top-level configuration
-       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
-       */
-       get reconfigured() { return this.startState.config != this.state.config; }
-       /**
-       Returns true if the transaction has a [user
-       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
-       or more specific than `event`. For example, if the transaction
-       has `"select.pointer"` as user event, `"select"` and
-       `"select.pointer"` will match it.
-       */
-       isUserEvent(event) {
-           let e = this.annotation(Transaction.userEvent);
-           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
-       }
-   };
-   /**
-   Annotation used to store transaction timestamps. Automatically
-   added to every transaction, holding `Date.now()`.
-   */
-   Transaction$2.time = /*@__PURE__*/Annotation$2.define();
-   /**
-   Annotation used to associate a transaction with a user interface
-   event. Holds a string identifying the event, using a
-   dot-separated format to support attaching more specific
-   information. The events used by the core libraries are:
-
-    - `"input"` when content is entered
-      - `"input.type"` for typed input
-        - `"input.type.compose"` for composition
-      - `"input.paste"` for pasted input
-      - `"input.drop"` when adding content with drag-and-drop
-      - `"input.complete"` when autocompleting
-    - `"delete"` when the user deletes content
-      - `"delete.selection"` when deleting the selection
-      - `"delete.forward"` when deleting forward from the selection
-      - `"delete.backward"` when deleting backward from the selection
-      - `"delete.cut"` when cutting to the clipboard
-    - `"move"` when content is moved
-      - `"move.drop"` when content is moved within the editor through drag-and-drop
-    - `"select"` when explicitly changing the selection
-      - `"select.pointer"` when selecting with a mouse or other pointing device
-    - `"undo"` and `"redo"` for history actions
-
-   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
-   whether the annotation matches a given event.
-   */
-   Transaction$2.userEvent = /*@__PURE__*/Annotation$2.define();
-   /**
-   Annotation indicating whether a transaction should be added to
-   the undo history or not.
-   */
-   Transaction$2.addToHistory = /*@__PURE__*/Annotation$2.define();
-   /**
-   Annotation indicating (when present and true) that a transaction
-   represents a change made by some other actor, not the user. This
-   is used, for example, to tag other people's changes in
-   collaborative editing.
-   */
-   Transaction$2.remote = /*@__PURE__*/Annotation$2.define();
-   function joinRanges$2(a, b) {
-       let result = [];
-       for (let iA = 0, iB = 0;;) {
-           let from, to;
-           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
-               from = a[iA++];
-               to = a[iA++];
-           }
-           else if (iB < b.length) {
-               from = b[iB++];
-               to = b[iB++];
-           }
-           else
-               return result;
-           if (!result.length || result[result.length - 1] < from)
-               result.push(from, to);
-           else if (result[result.length - 1] < to)
-               result[result.length - 1] = to;
-       }
-   }
-   function mergeTransaction$2(a, b, sequential) {
-       var _a;
-       let mapForA, mapForB, changes;
-       if (sequential) {
-           mapForA = b.changes;
-           mapForB = ChangeSet$2.empty(b.changes.length);
-           changes = a.changes.compose(b.changes);
-       }
-       else {
-           mapForA = b.changes.map(a.changes);
-           mapForB = a.changes.mapDesc(b.changes, true);
-           changes = a.changes.compose(mapForA);
-       }
-       return {
-           changes,
-           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
-           effects: StateEffect$2.mapEffects(a.effects, mapForA).concat(StateEffect$2.mapEffects(b.effects, mapForB)),
-           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
-           scrollIntoView: a.scrollIntoView || b.scrollIntoView
-       };
-   }
-   function resolveTransactionInner$2(state, spec, docSize) {
-       let sel = spec.selection, annotations = asArray$3(spec.annotations);
-       if (spec.userEvent)
-           annotations = annotations.concat(Transaction$2.userEvent.of(spec.userEvent));
-       return {
-           changes: spec.changes instanceof ChangeSet$2 ? spec.changes
-               : ChangeSet$2.of(spec.changes || [], docSize, state.facet(lineSeparator$2)),
-           selection: sel && (sel instanceof EditorSelection$2 ? sel : EditorSelection$2.single(sel.anchor, sel.head)),
-           effects: asArray$3(spec.effects),
-           annotations,
-           scrollIntoView: !!spec.scrollIntoView
-       };
-   }
-   function resolveTransaction$2(state, specs, filter) {
-       let s = resolveTransactionInner$2(state, specs.length ? specs[0] : {}, state.doc.length);
-       if (specs.length && specs[0].filter === false)
-           filter = false;
-       for (let i = 1; i < specs.length; i++) {
-           if (specs[i].filter === false)
-               filter = false;
-           let seq = !!specs[i].sequential;
-           s = mergeTransaction$2(s, resolveTransactionInner$2(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
-       }
-       let tr = Transaction$2.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
-       return extendTransaction$2(filter ? filterTransaction$2(tr) : tr);
-   }
-   // Finish a transaction by applying filters if necessary.
-   function filterTransaction$2(tr) {
-       let state = tr.startState;
-       // Change filters
-       let result = true;
-       for (let filter of state.facet(changeFilter$2)) {
-           let value = filter(tr);
-           if (value === false) {
-               result = false;
-               break;
-           }
-           if (Array.isArray(value))
-               result = result === true ? value : joinRanges$2(result, value);
-       }
-       if (result !== true) {
-           let changes, back;
-           if (result === false) {
-               back = tr.changes.invertedDesc;
-               changes = ChangeSet$2.empty(state.doc.length);
-           }
-           else {
-               let filtered = tr.changes.filter(result);
-               changes = filtered.changes;
-               back = filtered.filtered.invertedDesc;
-           }
-           tr = Transaction$2.create(state, changes, tr.selection && tr.selection.map(back), StateEffect$2.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
-       }
-       // Transaction filters
-       let filters = state.facet(transactionFilter$2);
-       for (let i = filters.length - 1; i >= 0; i--) {
-           let filtered = filters[i](tr);
-           if (filtered instanceof Transaction$2)
-               tr = filtered;
-           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction$2)
-               tr = filtered[0];
-           else
-               tr = resolveTransaction$2(state, asArray$3(filtered), false);
-       }
-       return tr;
-   }
-   function extendTransaction$2(tr) {
-       let state = tr.startState, extenders = state.facet(transactionExtender$2), spec = tr;
-       for (let i = extenders.length - 1; i >= 0; i--) {
-           let extension = extenders[i](tr);
-           if (extension && Object.keys(extension).length)
-               spec = mergeTransaction$2(tr, resolveTransactionInner$2(state, extension, tr.changes.newLength), true);
-       }
-       return spec == tr ? tr : Transaction$2.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
-   }
-   const none$5 = [];
-   function asArray$3(value) {
-       return value == null ? none$5 : Array.isArray(value) ? value : [value];
-   }
-
-   /**
-   The categories produced by a [character
-   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
-   do things like selecting by word.
-   */
-   var CharCategory$2 = /*@__PURE__*/(function (CharCategory) {
-       /**
-       Word characters.
-       */
-       CharCategory[CharCategory["Word"] = 0] = "Word";
-       /**
-       Whitespace.
-       */
-       CharCategory[CharCategory["Space"] = 1] = "Space";
-       /**
-       Anything else.
-       */
-       CharCategory[CharCategory["Other"] = 2] = "Other";
-   return CharCategory})(CharCategory$2 || (CharCategory$2 = {}));
-   const nonASCIISingleCaseWordChar$2 = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
-   let wordChar$2;
-   try {
-       wordChar$2 = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
-   }
-   catch (_) { }
-   function hasWordChar$2(str) {
-       if (wordChar$2)
-           return wordChar$2.test(str);
-       for (let i = 0; i < str.length; i++) {
-           let ch = str[i];
-           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar$2.test(ch)))
-               return true;
-       }
-       return false;
-   }
-   function makeCategorizer$2(wordChars) {
-       return (char) => {
-           if (!/\S/.test(char))
-               return CharCategory$2.Space;
-           if (hasWordChar$2(char))
-               return CharCategory$2.Word;
-           for (let i = 0; i < wordChars.length; i++)
-               if (char.indexOf(wordChars[i]) > -1)
-                   return CharCategory$2.Word;
-           return CharCategory$2.Other;
-       };
-   }
-
-   /**
-   The editor state class is a persistent (immutable) data structure.
-   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
-   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
-   instance, without modifying the original object.
-
-   As such, _never_ mutate properties of a state directly. That'll
-   just break things.
-   */
-   let EditorState$2 = class EditorState {
-       constructor(
-       /**
-       @internal
-       */
-       config, 
-       /**
-       The current document.
-       */
-       doc, 
-       /**
-       The current selection.
-       */
-       selection, 
-       /**
-       @internal
-       */
-       values, computeSlot, tr) {
-           this.config = config;
-           this.doc = doc;
-           this.selection = selection;
-           this.values = values;
-           this.status = config.statusTemplate.slice();
-           this.computeSlot = computeSlot;
-           // Fill in the computed state immediately, so that further queries
-           // for it made during the update return this state
-           if (tr)
-               tr._state = this;
-           for (let i = 0; i < this.config.dynamicSlots.length; i++)
-               ensureAddr$2(this, i << 1);
-           this.computeSlot = null;
-       }
-       field(field, require = true) {
-           let addr = this.config.address[field.id];
-           if (addr == null) {
-               if (require)
-                   throw new RangeError("Field is not present in this state");
-               return undefined;
-           }
-           ensureAddr$2(this, addr);
-           return getAddr$2(this, addr);
-       }
-       /**
-       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
-       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
-       can be passed. Unless
-       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
-       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
-       are assumed to start in the _current_ document (not the document
-       produced by previous specs), and its
-       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
-       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
-       to the document created by its _own_ changes. The resulting
-       transaction contains the combined effect of all the different
-       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
-       specs take precedence over earlier ones.
-       */
-       update(...specs) {
-           return resolveTransaction$2(this, specs, true);
-       }
-       /**
-       @internal
-       */
-       applyTransaction(tr) {
-           let conf = this.config, { base, compartments } = conf;
-           for (let effect of tr.effects) {
-               if (effect.is(Compartment$2.reconfigure)) {
-                   if (conf) {
-                       compartments = new Map;
-                       conf.compartments.forEach((val, key) => compartments.set(key, val));
-                       conf = null;
-                   }
-                   compartments.set(effect.value.compartment, effect.value.extension);
-               }
-               else if (effect.is(StateEffect$2.reconfigure)) {
-                   conf = null;
-                   base = effect.value;
-               }
-               else if (effect.is(StateEffect$2.appendConfig)) {
-                   conf = null;
-                   base = asArray$3(base).concat(effect.value);
-               }
-           }
-           let startValues;
-           if (!conf) {
-               conf = Configuration$2.resolve(base, compartments, this);
-               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
-               startValues = intermediateState.values;
-           }
-           else {
-               startValues = tr.startState.values.slice();
-           }
-           new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
-       }
-       /**
-       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
-       replaces every selection range with the given content.
-       */
-       replaceSelection(text) {
-           if (typeof text == "string")
-               text = this.toText(text);
-           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
-               range: EditorSelection$2.cursor(range.from + text.length) }));
-       }
-       /**
-       Create a set of changes and a new selection by running the given
-       function for each range in the active selection. The function
-       can return an optional set of changes (in the coordinate space
-       of the start document), plus an updated range (in the coordinate
-       space of the document produced by the call's own changes). This
-       method will merge all the changes and ranges into a single
-       changeset and selection, and return it as a [transaction
-       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
-       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
-       */
-       changeByRange(f) {
-           let sel = this.selection;
-           let result1 = f(sel.ranges[0]);
-           let changes = this.changes(result1.changes), ranges = [result1.range];
-           let effects = asArray$3(result1.effects);
-           for (let i = 1; i < sel.ranges.length; i++) {
-               let result = f(sel.ranges[i]);
-               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
-               for (let j = 0; j < i; j++)
-                   ranges[j] = ranges[j].map(newMapped);
-               let mapBy = changes.mapDesc(newChanges, true);
-               ranges.push(result.range.map(mapBy));
-               changes = changes.compose(newMapped);
-               effects = StateEffect$2.mapEffects(effects, newMapped).concat(StateEffect$2.mapEffects(asArray$3(result.effects), mapBy));
-           }
-           return {
-               changes,
-               selection: EditorSelection$2.create(ranges, sel.mainIndex),
-               effects
-           };
-       }
-       /**
-       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
-       description, taking the state's document length and line
-       separator into account.
-       */
-       changes(spec = []) {
-           if (spec instanceof ChangeSet$2)
-               return spec;
-           return ChangeSet$2.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
-       }
-       /**
-       Using the state's [line
-       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
-       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
-       */
-       toText(string) {
-           return Text$2.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit$2));
-       }
-       /**
-       Return the given range of the document as a string.
-       */
-       sliceDoc(from = 0, to = this.doc.length) {
-           return this.doc.sliceString(from, to, this.lineBreak);
-       }
-       /**
-       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
-       */
-       facet(facet) {
-           let addr = this.config.address[facet.id];
-           if (addr == null)
-               return facet.default;
-           ensureAddr$2(this, addr);
-           return getAddr$2(this, addr);
-       }
-       /**
-       Convert this state to a JSON-serializable object. When custom
-       fields should be serialized, you can pass them in as an object
-       mapping property names (in the resulting object, which should
-       not use `doc` or `selection`) to fields.
-       */
-       toJSON(fields) {
-           let result = {
-               doc: this.sliceDoc(),
-               selection: this.selection.toJSON()
-           };
-           if (fields)
-               for (let prop in fields) {
-                   let value = fields[prop];
-                   if (value instanceof StateField$2)
-                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
-               }
-           return result;
-       }
-       /**
-       Deserialize a state from its JSON representation. When custom
-       fields should be deserialized, pass the same object you passed
-       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
-       third argument.
-       */
-       static fromJSON(json, config = {}, fields) {
-           if (!json || typeof json.doc != "string")
-               throw new RangeError("Invalid JSON representation for EditorState");
-           let fieldInit = [];
-           if (fields)
-               for (let prop in fields) {
-                   let field = fields[prop], value = json[prop];
-                   fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
-               }
-           return EditorState.create({
-               doc: json.doc,
-               selection: EditorSelection$2.fromJSON(json.selection),
-               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
-           });
-       }
-       /**
-       Create a new state. You'll usually only need this when
-       initializing an editor—updated states are created by applying
-       transactions.
-       */
-       static create(config = {}) {
-           let configuration = Configuration$2.resolve(config.extensions || [], new Map);
-           let doc = config.doc instanceof Text$2 ? config.doc
-               : Text$2.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit$2));
-           let selection = !config.selection ? EditorSelection$2.single(0)
-               : config.selection instanceof EditorSelection$2 ? config.selection
-                   : EditorSelection$2.single(config.selection.anchor, config.selection.head);
-           checkSelection$2(selection, doc.length);
-           if (!configuration.staticFacet(allowMultipleSelections$2))
-               selection = selection.asSingle();
-           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
-       }
-       /**
-       The size (in columns) of a tab in the document, determined by
-       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
-       */
-       get tabSize() { return this.facet(EditorState.tabSize); }
-       /**
-       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
-       string for this state.
-       */
-       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
-       /**
-       Returns true when the editor is
-       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
-       */
-       get readOnly() { return this.facet(readOnly$2); }
-       /**
-       Look up a translation for the given phrase (via the
-       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
-       original string if no translation is found.
-       
-       If additional arguments are passed, they will be inserted in
-       place of markers like `$1` (for the first value) and `$2`, etc.
-       A single `$` is equivalent to `$1`, and `$$` will produce a
-       literal dollar sign.
-       */
-       phrase(phrase, ...insert) {
-           for (let map of this.facet(EditorState.phrases))
-               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
-                   phrase = map[phrase];
-                   break;
-               }
-           if (insert.length)
-               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
-                   if (i == "$")
-                       return "$";
-                   let n = +(i || 1);
-                   return n > insert.length ? m : insert[n - 1];
-               });
-           return phrase;
-       }
-       /**
-       Find the values for a given language data field, provided by the
-       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
-       */
-       languageDataAt(name, pos, side = -1) {
-           let values = [];
-           for (let provider of this.facet(languageData$2)) {
-               for (let result of provider(this, pos, side)) {
-                   if (Object.prototype.hasOwnProperty.call(result, name))
-                       values.push(result[name]);
-               }
-           }
-           return values;
-       }
-       /**
-       Return a function that can categorize strings (expected to
-       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
-       into one of:
-       
-        - Word (contains an alphanumeric character or a character
-          explicitly listed in the local language's `"wordChars"`
-          language data, which should be a string)
-        - Space (contains only whitespace)
-        - Other (anything else)
-       */
-       charCategorizer(at) {
-           return makeCategorizer$2(this.languageDataAt("wordChars", at).join(""));
-       }
-       /**
-       Find the word at the given position, meaning the range
-       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
-       around it. If no word characters are adjacent to the position,
-       this returns null.
-       */
-       wordAt(pos) {
-           let { text, from, length } = this.doc.lineAt(pos);
-           let cat = this.charCategorizer(pos);
-           let start = pos - from, end = pos - from;
-           while (start > 0) {
-               let prev = findClusterBreak$3(text, start, false);
-               if (cat(text.slice(prev, start)) != CharCategory$2.Word)
-                   break;
-               start = prev;
-           }
-           while (end < length) {
-               let next = findClusterBreak$3(text, end);
-               if (cat(text.slice(end, next)) != CharCategory$2.Word)
-                   break;
-               end = next;
-           }
-           return start == end ? null : EditorSelection$2.range(start + from, end + from);
-       }
-   };
-   /**
-   A facet that, when enabled, causes the editor to allow multiple
-   ranges to be selected. Be careful though, because by default the
-   editor relies on the native DOM selection, which cannot handle
-   multiple selections. An extension like
-   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
-   secondary selections visible to the user.
-   */
-   EditorState$2.allowMultipleSelections = allowMultipleSelections$2;
-   /**
-   Configures the tab size to use in this state. The first
-   (highest-precedence) value of the facet is used. If no value is
-   given, this defaults to 4.
-   */
-   EditorState$2.tabSize = /*@__PURE__*/Facet$2.define({
-       combine: values => values.length ? values[0] : 4
-   });
-   /**
-   The line separator to use. By default, any of `"\n"`, `"\r\n"`
-   and `"\r"` is treated as a separator when splitting lines, and
-   lines are joined with `"\n"`.
-
-   When you configure a value here, only that precise separator
-   will be used, allowing you to round-trip documents through the
-   editor without normalizing line separators.
-   */
-   EditorState$2.lineSeparator = lineSeparator$2;
-   /**
-   This facet controls the value of the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
-   consulted by commands and extensions that implement editing
-   functionality to determine whether they should apply. It
-   defaults to false, but when its highest-precedence value is
-   `true`, such functionality disables itself.
-
-   Not to be confused with
-   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
-   controls whether the editor's DOM is set to be editable (and
-   thus focusable).
-   */
-   EditorState$2.readOnly = readOnly$2;
-   /**
-   Registers translation phrases. The
-   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
-   all objects registered with this facet to find translations for
-   its argument.
-   */
-   EditorState$2.phrases = /*@__PURE__*/Facet$2.define({
-       compare(a, b) {
-           let kA = Object.keys(a), kB = Object.keys(b);
-           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
-       }
-   });
-   /**
-   A facet used to register [language
-   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
-   */
-   EditorState$2.languageData = languageData$2;
-   /**
-   Facet used to register change filters, which are called for each
-   transaction (unless explicitly
-   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
-   part of the transaction's changes.
-
-   Such a function can return `true` to indicate that it doesn't
-   want to do anything, `false` to completely stop the changes in
-   the transaction, or a set of ranges in which changes should be
-   suppressed. Such ranges are represented as an array of numbers,
-   with each pair of two numbers indicating the start and end of a
-   range. So for example `[10, 20, 100, 110]` suppresses changes
-   between 10 and 20, and between 100 and 110.
-   */
-   EditorState$2.changeFilter = changeFilter$2;
-   /**
-   Facet used to register a hook that gets a chance to update or
-   replace transaction specs before they are applied. This will
-   only be applied for transactions that don't have
-   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
-   can either return a single transaction spec (possibly the input
-   transaction), or an array of specs (which will be combined in
-   the same way as the arguments to
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
-
-   When possible, it is recommended to avoid accessing
-   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
-   since it will force creation of a state that will then be
-   discarded again, if the transaction is actually filtered.
-
-   (This functionality should be used with care. Indiscriminately
-   modifying transaction is likely to break something or degrade
-   the user experience.)
-   */
-   EditorState$2.transactionFilter = transactionFilter$2;
-   /**
-   This is a more limited form of
-   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
-   which can only add
-   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
-   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
-   of filter runs even if the transaction has disabled regular
-   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
-   for effects that don't need to touch the changes or selection,
-   but do want to process every transaction.
-
-   Extenders run _after_ filters, when both are present.
-   */
-   EditorState$2.transactionExtender = transactionExtender$2;
-   Compartment$2.reconfigure = /*@__PURE__*/StateEffect$2.define();
-
-   /**
-   Utility function for combining behaviors to fill in a config
-   object from an array of provided configs. `defaults` should hold
-   default values for all optional fields in `Config`.
-
-   The function will, by default, error
-   when a field gets two values that aren't `===`-equal, but you can
-   provide combine functions per field to do something else.
-   */
-   function combineConfig$2(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
-   combine = {}) {
-       let result = {};
-       for (let config of configs)
-           for (let key of Object.keys(config)) {
-               let value = config[key], current = result[key];
-               if (current === undefined)
-                   result[key] = value;
-               else if (current === value || value === undefined) ; // No conflict
-               else if (Object.hasOwnProperty.call(combine, key))
-                   result[key] = combine[key](current, value);
-               else
-                   throw new Error("Config merge conflict for field " + key);
-           }
-       for (let key in defaults)
-           if (result[key] === undefined)
-               result[key] = defaults[key];
-       return result;
-   }
-
-   /**
-   Each range is associated with a value, which must inherit from
-   this class.
-   */
-   let RangeValue$2 = class RangeValue {
-       /**
-       Compare this value with another value. Used when comparing
-       rangesets. The default implementation compares by identity.
-       Unless you are only creating a fixed number of unique instances
-       of your value type, it is a good idea to implement this
-       properly.
-       */
-       eq(other) { return this == other; }
-       /**
-       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
-       */
-       range(from, to = from) { return Range$4.create(from, to, this); }
-   };
-   RangeValue$2.prototype.startSide = RangeValue$2.prototype.endSide = 0;
-   RangeValue$2.prototype.point = false;
-   RangeValue$2.prototype.mapMode = MapMode$2.TrackDel;
-   /**
-   A range associates a value with a range of positions.
-   */
-   let Range$4 = class Range {
-       constructor(
-       /**
-       The range's start position.
-       */
-       from, 
-       /**
-       Its end position.
-       */
-       to, 
-       /**
-       The value associated with this range.
-       */
-       value) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-       }
-       /**
-       @internal
-       */
-       static create(from, to, value) {
-           return new Range(from, to, value);
-       }
-   };
-   function cmpRange$2(a, b) {
-       return a.from - b.from || a.value.startSide - b.value.startSide;
-   }
-   let Chunk$2 = class Chunk {
-       constructor(from, to, value, 
-       // Chunks are marked with the largest point that occurs
-       // in them (or -1 for no points), so that scans that are
-       // only interested in points (such as the
-       // heightmap-related logic) can skip range-only chunks.
-       maxPoint) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-           this.maxPoint = maxPoint;
-       }
-       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(pos, side, end, startAt = 0) {
-           let arr = end ? this.to : this.from;
-           for (let lo = startAt, hi = arr.length;;) {
-               if (lo == hi)
-                   return lo;
-               let mid = (lo + hi) >> 1;
-               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
-               if (mid == lo)
-                   return diff >= 0 ? lo : hi;
-               if (diff >= 0)
-                   hi = mid;
-               else
-                   lo = mid + 1;
-           }
-       }
-       between(offset, from, to, f) {
-           for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
-               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
-                   return false;
-       }
-       map(offset, changes) {
-           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
-           for (let i = 0; i < this.value.length; i++) {
-               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
-               if (curFrom == curTo) {
-                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
-                   if (mapped == null)
-                       continue;
-                   newFrom = newTo = mapped;
-                   if (val.startSide != val.endSide) {
-                       newTo = changes.mapPos(curFrom, val.endSide);
-                       if (newTo < newFrom)
-                           continue;
-                   }
-               }
-               else {
-                   newFrom = changes.mapPos(curFrom, val.startSide);
-                   newTo = changes.mapPos(curTo, val.endSide);
-                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
-                       continue;
-               }
-               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
-                   continue;
-               if (newPos < 0)
-                   newPos = newFrom;
-               if (val.point)
-                   maxPoint = Math.max(maxPoint, newTo - newFrom);
-               value.push(val);
-               from.push(newFrom - newPos);
-               to.push(newTo - newPos);
-           }
-           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
-       }
-   };
-   /**
-   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
-   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
-   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
-   structure.
-   */
-   let RangeSet$2 = class RangeSet {
-       constructor(
-       /**
-       @internal
-       */
-       chunkPos, 
-       /**
-       @internal
-       */
-       chunk, 
-       /**
-       @internal
-       */
-       nextLayer, 
-       /**
-       @internal
-       */
-       maxPoint) {
-           this.chunkPos = chunkPos;
-           this.chunk = chunk;
-           this.nextLayer = nextLayer;
-           this.maxPoint = maxPoint;
-       }
-       /**
-       @internal
-       */
-       static create(chunkPos, chunk, nextLayer, maxPoint) {
-           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
-       }
-       /**
-       @internal
-       */
-       get length() {
-           let last = this.chunk.length - 1;
-           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
-       }
-       /**
-       The number of ranges in the set.
-       */
-       get size() {
-           if (this.isEmpty)
-               return 0;
-           let size = this.nextLayer.size;
-           for (let chunk of this.chunk)
-               size += chunk.value.length;
-           return size;
-       }
-       /**
-       @internal
-       */
-       chunkEnd(index) {
-           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
-           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
-           let filter = updateSpec.filter;
-           if (add.length == 0 && !filter)
-               return this;
-           if (sort)
-               add = add.slice().sort(cmpRange$2);
-           if (this.isEmpty)
-               return add.length ? RangeSet.of(add) : this;
-           let cur = new LayerCursor$2(this, null, -1).goto(0), i = 0, spill = [];
-           let builder = new RangeSetBuilder$2();
-           while (cur.value || i < add.length) {
-               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
-                   let range = add[i++];
-                   if (!builder.addInner(range.from, range.to, range.value))
-                       spill.push(range);
-               }
-               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
-                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
-                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
-                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
-                   cur.nextChunk();
-               }
-               else {
-                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
-                       if (!builder.addInner(cur.from, cur.to, cur.value))
-                           spill.push(Range$4.create(cur.from, cur.to, cur.value));
-                   }
-                   cur.next();
-               }
-           }
-           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
-               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
-       }
-       /**
-       Map this range set through a set of changes, return the new set.
-       */
-       map(changes) {
-           if (changes.empty || this.isEmpty)
-               return this;
-           let chunks = [], chunkPos = [], maxPoint = -1;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               let touch = changes.touchesRange(start, start + chunk.length);
-               if (touch === false) {
-                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
-                   chunks.push(chunk);
-                   chunkPos.push(changes.mapPos(start));
-               }
-               else if (touch === true) {
-                   let { mapped, pos } = chunk.map(start, changes);
-                   if (mapped) {
-                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
-                       chunks.push(mapped);
-                       chunkPos.push(pos);
-                   }
-               }
-           }
-           let next = this.nextLayer.map(changes);
-           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
-       }
-       /**
-       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(from, to, f) {
-           if (this.isEmpty)
-               return;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               if (to >= start && from <= start + chunk.length &&
-                   chunk.between(start, from - start, to - start, f) === false)
-                   return;
-           }
-           this.nextLayer.between(from, to, f);
-       }
-       /**
-       Iterate over the ranges in this set, in order, including all
-       ranges that end at or after `from`.
-       */
-       iter(from = 0) {
-           return HeapCursor$2.from([this]).goto(from);
-       }
-       /**
-       @internal
-       */
-       get isEmpty() { return this.nextLayer == this; }
-       /**
-       Iterate over the ranges in a collection of sets, in order,
-       starting from `from`.
-       */
-       static iter(sets, from = 0) {
-           return HeapCursor$2.from(sets).goto(from);
-       }
-       /**
-       Iterate over two groups of sets, calling methods on `comparator`
-       to notify it of possible differences.
-       */
-       static compare(oldSets, newSets, 
-       /**
-       This indicates how the underlying data changed between these
-       ranges, and is needed to synchronize the iteration. `from` and
-       `to` are coordinates in the _new_ space, after these changes.
-       */
-       textDiff, comparator, 
-       /**
-       Can be used to ignore all non-point ranges, and points below
-       the given size. When -1, all ranges are compared.
-       */
-       minPointSize = -1) {
-           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let sharedChunks = findSharedChunks$2(a, b, textDiff);
-           let sideA = new SpanCursor$2(a, sharedChunks, minPointSize);
-           let sideB = new SpanCursor$2(b, sharedChunks, minPointSize);
-           textDiff.iterGaps((fromA, fromB, length) => compare$2(sideA, fromA, sideB, fromB, length, comparator));
-           if (textDiff.empty && textDiff.length == 0)
-               compare$2(sideA, 0, sideB, 0, 0, comparator);
-       }
-       /**
-       Compare the contents of two groups of range sets, returning true
-       if they are equivalent in the given range.
-       */
-       static eq(oldSets, newSets, from = 0, to) {
-           if (to == null)
-               to = 1000000000 /* Far */;
-           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
-           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
-           if (a.length != b.length)
-               return false;
-           if (!a.length)
-               return true;
-           let sharedChunks = findSharedChunks$2(a, b);
-           let sideA = new SpanCursor$2(a, sharedChunks, 0).goto(from), sideB = new SpanCursor$2(b, sharedChunks, 0).goto(from);
-           for (;;) {
-               if (sideA.to != sideB.to ||
-                   !sameValues$2(sideA.active, sideB.active) ||
-                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
-                   return false;
-               if (sideA.to > to)
-                   return true;
-               sideA.next();
-               sideB.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(sets, from, to, iterator, 
-       /**
-       When given and greater than -1, only points of at least this
-       size are taken into account.
-       */
-       minPointSize = -1) {
-           let cursor = new SpanCursor$2(sets, null, minPointSize).goto(from), pos = from;
-           let open = cursor.openStart;
-           for (;;) {
-               let curTo = Math.min(cursor.to, to);
-               if (cursor.point) {
-                   iterator.point(pos, curTo, cursor.point, cursor.activeForPoint(cursor.to), open, cursor.pointRank);
-                   open = cursor.openEnd(curTo) + (cursor.to > curTo ? 1 : 0);
-               }
-               else if (curTo > pos) {
-                   iterator.span(pos, curTo, cursor.active, open);
-                   open = cursor.openEnd(curTo);
-               }
-               if (cursor.to > to)
-                   break;
-               pos = cursor.to;
-               cursor.next();
-           }
-           return open;
-       }
-       /**
-       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(ranges, sort = false) {
-           let build = new RangeSetBuilder$2();
-           for (let range of ranges instanceof Range$4 ? [ranges] : sort ? lazySort$2(ranges) : ranges)
-               build.add(range.from, range.to, range.value);
-           return build.finish();
-       }
-   };
-   /**
-   The empty set of ranges.
-   */
-   RangeSet$2.empty = /*@__PURE__*/new RangeSet$2([], [], null, -1);
-   function lazySort$2(ranges) {
-       if (ranges.length > 1)
-           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
-               let cur = ranges[i];
-               if (cmpRange$2(prev, cur) > 0)
-                   return ranges.slice().sort(cmpRange$2);
-               prev = cur;
-           }
-       return ranges;
-   }
-   RangeSet$2.empty.nextLayer = RangeSet$2.empty;
-   /**
-   A range set builder is a data structure that helps build up a
-   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
-   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
-   */
-   let RangeSetBuilder$2 = class RangeSetBuilder {
-       /**
-       Create an empty builder.
-       */
-       constructor() {
-           this.chunks = [];
-           this.chunkPos = [];
-           this.chunkStart = -1;
-           this.last = null;
-           this.lastFrom = -1000000000 /* Far */;
-           this.lastTo = -1000000000 /* Far */;
-           this.from = [];
-           this.to = [];
-           this.value = [];
-           this.maxPoint = -1;
-           this.setMaxPoint = -1;
-           this.nextLayer = null;
-       }
-       finishChunk(newArrays) {
-           this.chunks.push(new Chunk$2(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;
-           if (newArrays) {
-               this.from = [];
-               this.to = [];
-               this.value = [];
-           }
-       }
-       /**
-       Add a range. Ranges should be added in sorted (by `from` and
-       `value.startSide`) order.
-       */
-       add(from, to, value) {
-           if (!this.addInner(from, to, value))
-               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
-       }
-       /**
-       @internal
-       */
-       addInner(from, to, value) {
-           let diff = from - this.lastTo || value.startSide - this.last.endSide;
-           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
-               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
-           if (diff < 0)
-               return false;
-           if (this.from.length == 250 /* ChunkSize */)
-               this.finishChunk(true);
-           if (this.chunkStart < 0)
-               this.chunkStart = from;
-           this.from.push(from - this.chunkStart);
-           this.to.push(to - this.chunkStart);
-           this.last = value;
-           this.lastFrom = from;
-           this.lastTo = to;
-           this.value.push(value);
-           if (value.point)
-               this.maxPoint = Math.max(this.maxPoint, to - from);
-           return true;
-       }
-       /**
-       @internal
-       */
-       addChunk(from, chunk) {
-           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
-               return false;
-           if (this.from.length)
-               this.finishChunk(true);
-           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
-           this.chunks.push(chunk);
-           this.chunkPos.push(from);
-           let last = chunk.value.length - 1;
-           this.last = chunk.value[last];
-           this.lastFrom = chunk.from[last] + from;
-           this.lastTo = chunk.to[last] + from;
-           return true;
-       }
-       /**
-       Finish the range set. Returns the new set. The builder can't be
-       used anymore after this has been called.
-       */
-       finish() { return this.finishInner(RangeSet$2.empty); }
-       /**
-       @internal
-       */
-       finishInner(next) {
-           if (this.from.length)
-               this.finishChunk(false);
-           if (this.chunks.length == 0)
-               return next;
-           let result = RangeSet$2.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
-           this.from = null; // Make sure further `add` calls produce errors
-           return result;
-       }
-   };
-   function findSharedChunks$2(a, b, textDiff) {
-       let inA = new Map();
-       for (let set of a)
-           for (let i = 0; i < set.chunk.length; i++)
-               if (set.chunk[i].maxPoint <= 0)
-                   inA.set(set.chunk[i], set.chunkPos[i]);
-       let shared = new Set();
-       for (let set of b)
-           for (let i = 0; i < set.chunk.length; i++) {
-               let known = inA.get(set.chunk[i]);
-               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
-                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
-                   shared.add(set.chunk[i]);
-           }
-       return shared;
-   }
-   let LayerCursor$2 = class LayerCursor {
-       constructor(layer, skip, minPoint, rank = 0) {
-           this.layer = layer;
-           this.skip = skip;
-           this.minPoint = minPoint;
-           this.rank = rank;
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       get endSide() { return this.value ? this.value.endSide : 0; }
-       goto(pos, side = -1000000000 /* Far */) {
-           this.chunkIndex = this.rangeIndex = 0;
-           this.gotoInner(pos, side, false);
-           return this;
-       }
-       gotoInner(pos, side, forward) {
-           while (this.chunkIndex < this.layer.chunk.length) {
-               let next = this.layer.chunk[this.chunkIndex];
-               if (!(this.skip && this.skip.has(next) ||
-                   this.layer.chunkEnd(this.chunkIndex) < pos ||
-                   next.maxPoint < this.minPoint))
-                   break;
-               this.chunkIndex++;
-               forward = false;
-           }
-           if (this.chunkIndex < this.layer.chunk.length) {
-               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
-               if (!forward || this.rangeIndex < rangeIndex)
-                   this.setRangeIndex(rangeIndex);
-           }
-           this.next();
-       }
-       forward(pos, side) {
-           if ((this.to - pos || this.endSide - side) < 0)
-               this.gotoInner(pos, side, true);
-       }
-       next() {
-           for (;;) {
-               if (this.chunkIndex == this.layer.chunk.length) {
-                   this.from = this.to = 1000000000 /* Far */;
-                   this.value = null;
-                   break;
-               }
-               else {
-                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
-                   let from = chunkPos + chunk.from[this.rangeIndex];
-                   this.from = from;
-                   this.to = chunkPos + chunk.to[this.rangeIndex];
-                   this.value = chunk.value[this.rangeIndex];
-                   this.setRangeIndex(this.rangeIndex + 1);
-                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
-                       break;
-               }
-           }
-       }
-       setRangeIndex(index) {
-           if (index == this.layer.chunk[this.chunkIndex].value.length) {
-               this.chunkIndex++;
-               if (this.skip) {
-                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
-                       this.chunkIndex++;
-               }
-               this.rangeIndex = 0;
-           }
-           else {
-               this.rangeIndex = index;
-           }
-       }
-       nextChunk() {
-           this.chunkIndex++;
-           this.rangeIndex = 0;
-           this.next();
-       }
-       compare(other) {
-           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
-               this.to - other.to || this.endSide - other.endSide;
-       }
-   };
-   let HeapCursor$2 = class HeapCursor {
-       constructor(heap) {
-           this.heap = heap;
-       }
-       static from(sets, skip = null, minPoint = -1) {
-           let heap = [];
-           for (let i = 0; i < sets.length; i++) {
-               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
-                   if (cur.maxPoint >= minPoint)
-                       heap.push(new LayerCursor$2(cur, skip, minPoint, i));
-               }
-           }
-           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       goto(pos, side = -1000000000 /* Far */) {
-           for (let cur of this.heap)
-               cur.goto(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble$2(this.heap, i);
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           for (let cur of this.heap)
-               cur.forward(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble$2(this.heap, i);
-           if ((this.to - pos || this.value.endSide - side) < 0)
-               this.next();
-       }
-       next() {
-           if (this.heap.length == 0) {
-               this.from = this.to = 1000000000 /* Far */;
-               this.value = null;
-               this.rank = -1;
-           }
-           else {
-               let top = this.heap[0];
-               this.from = top.from;
-               this.to = top.to;
-               this.value = top.value;
-               this.rank = top.rank;
-               if (top.value)
-                   top.next();
-               heapBubble$2(this.heap, 0);
-           }
-       }
-   };
-   function heapBubble$2(heap, index) {
-       for (let cur = heap[index];;) {
-           let childIndex = (index << 1) + 1;
-           if (childIndex >= heap.length)
-               break;
-           let child = heap[childIndex];
-           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
-               child = heap[childIndex + 1];
-               childIndex++;
-           }
-           if (cur.compare(child) < 0)
-               break;
-           heap[childIndex] = cur;
-           heap[index] = child;
-           index = childIndex;
-       }
-   }
-   let SpanCursor$2 = class SpanCursor {
-       constructor(sets, skip, minPoint) {
-           this.minPoint = minPoint;
-           this.active = [];
-           this.activeTo = [];
-           this.activeRank = [];
-           this.minActive = -1;
-           // A currently active point range, if any
-           this.point = null;
-           this.pointFrom = 0;
-           this.pointRank = 0;
-           this.to = -1000000000 /* Far */;
-           this.endSide = 0;
-           this.openStart = -1;
-           this.cursor = HeapCursor$2.from(sets, skip, minPoint);
-       }
-       goto(pos, side = -1000000000 /* Far */) {
-           this.cursor.goto(pos, side);
-           this.active.length = this.activeTo.length = this.activeRank.length = 0;
-           this.minActive = -1;
-           this.to = pos;
-           this.endSide = side;
-           this.openStart = -1;
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
-               this.removeActive(this.minActive);
-           this.cursor.forward(pos, side);
-       }
-       removeActive(index) {
-           remove$2(this.active, index);
-           remove$2(this.activeTo, index);
-           remove$2(this.activeRank, index);
-           this.minActive = findMinIndex$2(this.active, this.activeTo);
-       }
-       addActive(trackOpen) {
-           let i = 0, { value, to, rank } = this.cursor;
-           while (i < this.activeRank.length && this.activeRank[i] <= rank)
-               i++;
-           insert$2(this.active, i, value);
-           insert$2(this.activeTo, i, to);
-           insert$2(this.activeRank, i, rank);
-           if (trackOpen)
-               insert$2(trackOpen, i, this.cursor.from);
-           this.minActive = findMinIndex$2(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 from = this.to, wasPoint = this.point;
-           this.point = null;
-           let trackOpen = this.openStart < 0 ? [] : null, trackExtra = 0;
-           for (;;) {
-               let a = this.minActive;
-               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
-                   if (this.activeTo[a] > from) {
-                       this.to = this.activeTo[a];
-                       this.endSide = this.active[a].endSide;
-                       break;
-                   }
-                   this.removeActive(a);
-                   if (trackOpen)
-                       remove$2(trackOpen, a);
-               }
-               else if (!this.cursor.value) {
-                   this.to = this.endSide = 1000000000 /* Far */;
-                   break;
-               }
-               else if (this.cursor.from > from) {
-                   this.to = this.cursor.from;
-                   this.endSide = this.cursor.startSide;
-                   break;
-               }
-               else {
-                   let nextVal = this.cursor.value;
-                   if (!nextVal.point) { // Opening a range
-                       this.addActive(trackOpen);
-                       this.cursor.next();
-                   }
-                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
-                       // Ignore any non-empty points that end precisely at the end of the prev point
-                       this.cursor.next();
-                   }
-                   else { // New point
-                       this.point = nextVal;
-                       this.pointFrom = this.cursor.from;
-                       this.pointRank = this.cursor.rank;
-                       this.to = this.cursor.to;
-                       this.endSide = nextVal.endSide;
-                       if (this.cursor.from < from)
-                           trackExtra = 1;
-                       this.cursor.next();
-                       this.forward(this.to, this.endSide);
-                       break;
-                   }
-               }
-           }
-           if (trackOpen) {
-               let openStart = 0;
-               while (openStart < trackOpen.length && trackOpen[openStart] < from)
-                   openStart++;
-               this.openStart = openStart + trackExtra;
-           }
-       }
-       activeForPoint(to) {
-           if (!this.active.length)
-               return this.active;
-           let active = [];
-           for (let i = this.active.length - 1; i >= 0; i--) {
-               if (this.activeRank[i] < this.pointRank)
-                   break;
-               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
-                   active.push(this.active[i]);
-           }
-           return active.reverse();
-       }
-       openEnd(to) {
-           let open = 0;
-           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
-               open++;
-           return open;
-       }
-   };
-   function compare$2(a, startA, b, startB, length, comparator) {
-       a.goto(startA);
-       b.goto(startB);
-       let endB = startB + length;
-       let pos = startB, dPos = startB - startA;
-       for (;;) {
-           let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;
-           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
-           if (a.point || b.point) {
-               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
-                   sameValues$2(a.activeForPoint(a.to + dPos), b.activeForPoint(b.to))))
-                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
-           }
-           else {
-               if (clipEnd > pos && !sameValues$2(a.active, b.active))
-                   comparator.compareRange(pos, clipEnd, a.active, b.active);
-           }
-           if (end > endB)
-               break;
-           pos = end;
-           if (diff <= 0)
-               a.next();
-           if (diff >= 0)
-               b.next();
-       }
-   }
-   function sameValues$2(a, b) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (a[i] != b[i] && !a[i].eq(b[i]))
-               return false;
-       return true;
-   }
-   function remove$2(array, index) {
-       for (let i = index, e = array.length - 1; i < e; i++)
-           array[i] = array[i + 1];
-       array.pop();
-   }
-   function insert$2(array, index, value) {
-       for (let i = array.length - 1; i >= index; i--)
-           array[i + 1] = array[i];
-       array[index] = value;
-   }
-   function findMinIndex$2(value, array) {
-       let found = -1, foundPos = 1000000000 /* Far */;
-       for (let i = 0; i < array.length; i++)
-           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
-               found = i;
-               foundPos = array[i];
-           }
-       return found;
-   }
-
-   /**
-   Count the column position at the given offset into the string,
-   taking extending characters and tab size into account.
-   */
-   function countColumn(string, tabSize, to = string.length) {
-       let n = 0;
-       for (let i = 0; i < to;) {
-           if (string.charCodeAt(i) == 9) {
-               n += tabSize - (n % tabSize);
-               i++;
-           }
-           else {
-               n++;
-               i = findClusterBreak$3(string, i);
-           }
-       }
-       return n;
-   }
-   /**
-   Find the offset that corresponds to the given column position in a
-   string, taking extending characters and tab size into account. By
-   default, the string length is returned when it is too short to
-   reach the column. Pass `strict` true to make it return -1 in that
-   situation.
-   */
-   function findColumn$2(string, col, tabSize, strict) {
-       for (let i = 0, n = 0;;) {
-           if (n >= col)
-               return i;
-           if (i == string.length)
-               break;
-           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
-           i = findClusterBreak$3(string, i);
-       }
-       return strict === true ? -1 : string.length;
-   }
-
-   function getSelection$2(root) {
-       let target;
-       // Browsers differ on whether shadow roots have a getSelection
-       // method. If it exists, use that, otherwise, call it on the
-       // document.
-       if (root.nodeType == 11) { // Shadow root
-           target = root.getSelection ? root : root.ownerDocument;
-       }
-       else {
-           target = root;
-       }
-       return target.getSelection();
-   }
-   function contains$2(dom, node) {
-       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
-   }
-   function deepActiveElement$1() {
-       let elt = document.activeElement;
-       while (elt && elt.shadowRoot)
-           elt = elt.shadowRoot.activeElement;
-       return elt;
-   }
-   function hasSelection$2(dom, selection) {
-       if (!selection.anchorNode)
-           return false;
-       try {
-           // Firefox will raise 'permission denied' errors when accessing
-           // properties of `sel.anchorNode` when it's in a generated CSS
-           // element.
-           return contains$2(dom, selection.anchorNode);
-       }
-       catch (_) {
-           return false;
-       }
-   }
-   function clientRectsFor$2(dom) {
-       if (dom.nodeType == 3)
-           return textRange$2(dom, 0, dom.nodeValue.length).getClientRects();
-       else if (dom.nodeType == 1)
-           return dom.getClientRects();
-       else
-           return [];
-   }
-   // Scans forward and backward through DOM positions equivalent to the
-   // given one to see if the two are in the same place (i.e. after a
-   // text node vs at the end of that text node)
-   function isEquivalentPosition$2(node, off, targetNode, targetOff) {
-       return targetNode ? (scanFor$2(node, off, targetNode, targetOff, -1) ||
-           scanFor$2(node, off, targetNode, targetOff, 1)) : false;
-   }
-   function domIndex$2(node) {
-       for (var index = 0;; index++) {
-           node = node.previousSibling;
-           if (!node)
-               return index;
-       }
-   }
-   function scanFor$2(node, off, targetNode, targetOff, dir) {
-       for (;;) {
-           if (node == targetNode && off == targetOff)
-               return true;
-           if (off == (dir < 0 ? 0 : maxOffset$2(node))) {
-               if (node.nodeName == "DIV")
-                   return false;
-               let parent = node.parentNode;
-               if (!parent || parent.nodeType != 1)
-                   return false;
-               off = domIndex$2(node) + (dir < 0 ? 0 : 1);
-               node = parent;
-           }
-           else if (node.nodeType == 1) {
-               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
-               if (node.nodeType == 1 && node.contentEditable == "false")
-                   return false;
-               off = dir < 0 ? maxOffset$2(node) : 0;
-           }
-           else {
-               return false;
-           }
-       }
-   }
-   function maxOffset$2(node) {
-       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
-   }
-   const Rect0$1 = { left: 0, right: 0, top: 0, bottom: 0 };
-   function flattenRect$2(rect, left) {
-       let x = left ? rect.left : rect.right;
-       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
-   }
-   function windowRect$2(win) {
-       return { left: 0, right: win.innerWidth,
-           top: 0, bottom: win.innerHeight };
-   }
-   function scrollRectIntoView$2(dom, rect, side, x, y, xMargin, yMargin, ltr) {
-       let doc = dom.ownerDocument, win = doc.defaultView;
-       for (let cur = dom; cur;) {
-           if (cur.nodeType == 1) { // Element
-               let bounding, top = cur == doc.body;
-               if (top) {
-                   bounding = windowRect$2(win);
-               }
-               else {
-                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
-                       cur = cur.parentNode;
-                       continue;
-                   }
-                   let rect = cur.getBoundingClientRect();
-                   // Make sure scrollbar width isn't included in the rectangle
-                   bounding = { left: rect.left, right: rect.left + cur.clientWidth,
-                       top: rect.top, bottom: rect.top + cur.clientHeight };
-               }
-               let moveX = 0, moveY = 0;
-               if (y == "nearest") {
-                   if (rect.top < bounding.top) {
-                       moveY = -(bounding.top - rect.top + yMargin);
-                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
-                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
-                   }
-                   else if (rect.bottom > bounding.bottom) {
-                       moveY = rect.bottom - bounding.bottom + yMargin;
-                       if (side < 0 && (rect.top - moveY) < bounding.top)
-                           moveY = -(bounding.top + moveY - rect.top + yMargin);
-                   }
-               }
-               else {
-                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
-                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
-                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
-                           rect.bottom - boundingHeight + yMargin;
-                   moveY = targetTop - bounding.top;
-               }
-               if (x == "nearest") {
-                   if (rect.left < bounding.left) {
-                       moveX = -(bounding.left - rect.left + xMargin);
-                       if (side > 0 && rect.right > bounding.right + moveX)
-                           moveX = rect.right - bounding.right + moveX + xMargin;
-                   }
-                   else if (rect.right > bounding.right) {
-                       moveX = rect.right - bounding.right + xMargin;
-                       if (side < 0 && rect.left < bounding.left + moveX)
-                           moveX = -(bounding.left + moveX - rect.left + xMargin);
-                   }
-               }
-               else {
-                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
-                       (x == "start") == ltr ? rect.left - xMargin :
-                           rect.right - (bounding.right - bounding.left) + xMargin;
-                   moveX = targetLeft - bounding.left;
-               }
-               if (moveX || moveY) {
-                   if (top) {
-                       win.scrollBy(moveX, moveY);
-                   }
-                   else {
-                       if (moveY) {
-                           let start = cur.scrollTop;
-                           cur.scrollTop += moveY;
-                           moveY = cur.scrollTop - start;
-                       }
-                       if (moveX) {
-                           let start = cur.scrollLeft;
-                           cur.scrollLeft += moveX;
-                           moveX = cur.scrollLeft - start;
-                       }
-                       rect = { left: rect.left - moveX, top: rect.top - moveY,
-                           right: rect.right - moveX, bottom: rect.bottom - moveY };
-                   }
-               }
-               if (top)
-                   break;
-               cur = cur.assignedSlot || cur.parentNode;
-               x = y = "nearest";
-           }
-           else if (cur.nodeType == 11) { // A shadow root
-               cur = cur.host;
-           }
-           else {
-               break;
-           }
-       }
-   }
-   let DOMSelectionState$2 = class DOMSelectionState {
-       constructor() {
-           this.anchorNode = null;
-           this.anchorOffset = 0;
-           this.focusNode = null;
-           this.focusOffset = 0;
-       }
-       eq(domSel) {
-           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
-               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
-       }
-       setRange(range) {
-           this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
-       }
-       set(anchorNode, anchorOffset, focusNode, focusOffset) {
-           this.anchorNode = anchorNode;
-           this.anchorOffset = anchorOffset;
-           this.focusNode = focusNode;
-           this.focusOffset = focusOffset;
-       }
-   };
-   let preventScrollSupported$2 = null;
-   // Feature-detects support for .focus({preventScroll: true}), and uses
-   // a fallback kludge when not supported.
-   function focusPreventScroll$2(dom) {
-       if (dom.setActive)
-           return dom.setActive(); // in IE
-       if (preventScrollSupported$2)
-           return dom.focus(preventScrollSupported$2);
-       let stack = [];
-       for (let cur = dom; cur; cur = cur.parentNode) {
-           stack.push(cur, cur.scrollTop, cur.scrollLeft);
-           if (cur == cur.ownerDocument)
-               break;
-       }
-       dom.focus(preventScrollSupported$2 == null ? {
-           get preventScroll() {
-               preventScrollSupported$2 = { preventScroll: true };
-               return true;
-           }
-       } : undefined);
-       if (!preventScrollSupported$2) {
-           preventScrollSupported$2 = false;
-           for (let i = 0; i < stack.length;) {
-               let elt = stack[i++], top = stack[i++], left = stack[i++];
-               if (elt.scrollTop != top)
-                   elt.scrollTop = top;
-               if (elt.scrollLeft != left)
-                   elt.scrollLeft = left;
-           }
-       }
-   }
-   let scratchRange$2;
-   function textRange$2(node, from, to = from) {
-       let range = scratchRange$2 || (scratchRange$2 = document.createRange());
-       range.setEnd(node, to);
-       range.setStart(node, from);
-       return range;
-   }
-   function dispatchKey$2(elt, name, code) {
-       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
-       let down = new KeyboardEvent("keydown", options);
-       down.synthetic = true;
-       elt.dispatchEvent(down);
-       let up = new KeyboardEvent("keyup", options);
-       up.synthetic = true;
-       elt.dispatchEvent(up);
-       return down.defaultPrevented || up.defaultPrevented;
-   }
-   function getRoot$2(node) {
-       while (node) {
-           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
-               return node;
-           node = node.assignedSlot || node.parentNode;
-       }
-       return null;
-   }
-   function clearAttributes$2(node) {
-       while (node.attributes.length)
-           node.removeAttributeNode(node.attributes[0]);
-   }
-
-   let DOMPos$2 = class DOMPos {
-       constructor(node, offset, precise = true) {
-           this.node = node;
-           this.offset = offset;
-           this.precise = precise;
-       }
-       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex$2(dom), precise); }
-       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex$2(dom) + 1, precise); }
-   };
-   const noChildren$2 = [];
-   let ContentView$2 = class ContentView {
-       constructor() {
-           this.parent = null;
-           this.dom = null;
-           this.dirty = 2 /* Node */;
-       }
-       get editorView() {
-           if (!this.parent)
-               throw new Error("Accessing view in orphan content view");
-           return this.parent.editorView;
-       }
-       get overrideDOMText() { return null; }
-       get posAtStart() {
-           return this.parent ? this.parent.posBefore(this) : 0;
-       }
-       get posAtEnd() {
-           return this.posAtStart + this.length;
-       }
-       posBefore(view) {
-           let pos = this.posAtStart;
-           for (let child of this.children) {
-               if (child == view)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-           throw new RangeError("Invalid child in posBefore");
-       }
-       posAfter(view) {
-           return this.posBefore(view) + view.length;
-       }
-       // Will return a rectangle directly before (when side < 0), after
-       // (side > 0) or directly on (when the browser supports it) the
-       // given position.
-       coordsAt(_pos, _side) { return null; }
-       sync(track) {
-           if (this.dirty & 2 /* Node */) {
-               let parent = this.dom;
-               let prev = null, next;
-               for (let child of this.children) {
-                   if (child.dirty) {
-                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
-                           let contentView = ContentView.get(next);
-                           if (!contentView || !contentView.parent && contentView.constructor == child.constructor)
-                               child.reuseDOM(next);
-                       }
-                       child.sync(track);
-                       child.dirty = 0 /* Not */;
-                   }
-                   next = prev ? prev.nextSibling : parent.firstChild;
-                   if (track && !track.written && track.node == parent && next != child.dom)
-                       track.written = true;
-                   if (child.dom.parentNode == parent) {
-                       while (next && next != child.dom)
-                           next = rm$1$2(next);
-                   }
-                   else {
-                       parent.insertBefore(child.dom, next);
-                   }
-                   prev = child.dom;
-               }
-               next = prev ? prev.nextSibling : parent.firstChild;
-               if (next && track && track.node == parent)
-                   track.written = true;
-               while (next)
-                   next = rm$1$2(next);
-           }
-           else if (this.dirty & 1 /* Child */) {
-               for (let child of this.children)
-                   if (child.dirty) {
-                       child.sync(track);
-                       child.dirty = 0 /* Not */;
-                   }
-           }
-       }
-       reuseDOM(_dom) { }
-       localPosFromDOM(node, offset) {
-           let after;
-           if (node == this.dom) {
-               after = this.dom.childNodes[offset];
-           }
-           else {
-               let bias = maxOffset$2(node) == 0 ? 0 : offset == 0 ? -1 : 1;
-               for (;;) {
-                   let parent = node.parentNode;
-                   if (parent == this.dom)
-                       break;
-                   if (bias == 0 && parent.firstChild != parent.lastChild) {
-                       if (node == parent.firstChild)
-                           bias = -1;
-                       else
-                           bias = 1;
-                   }
-                   node = parent;
-               }
-               if (bias < 0)
-                   after = node;
-               else
-                   after = node.nextSibling;
-           }
-           if (after == this.dom.firstChild)
-               return 0;
-           while (after && !ContentView.get(after))
-               after = after.nextSibling;
-           if (!after)
-               return this.length;
-           for (let i = 0, pos = 0;; i++) {
-               let child = this.children[i];
-               if (child.dom == after)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-       }
-       domBoundsAround(from, to, offset = 0) {
-           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
-           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos < from && end > to)
-                   return child.domBoundsAround(from, to, pos);
-               if (end >= from && fromI == -1) {
-                   fromI = i;
-                   fromStart = pos;
-               }
-               if (pos > to && child.dom.parentNode == this.dom) {
-                   toI = i;
-                   toEnd = prevEnd;
-                   break;
-               }
-               prevEnd = end;
-               pos = end + child.breakAfter;
-           }
-           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
-               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
-               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
-       }
-       markDirty(andParent = false) {
-           this.dirty |= 2 /* Node */;
-           this.markParentsDirty(andParent);
-       }
-       markParentsDirty(childList) {
-           for (let parent = this.parent; parent; parent = parent.parent) {
-               if (childList)
-                   parent.dirty |= 2 /* Node */;
-               if (parent.dirty & 1 /* Child */)
-                   return;
-               parent.dirty |= 1 /* Child */;
-               childList = false;
-           }
-       }
-       setParent(parent) {
-           if (this.parent != parent) {
-               this.parent = parent;
-               if (this.dirty)
-                   this.markParentsDirty(true);
-           }
-       }
-       setDOM(dom) {
-           if (this.dom)
-               this.dom.cmView = null;
-           this.dom = dom;
-           dom.cmView = this;
-       }
-       get rootView() {
-           for (let v = this;;) {
-               let parent = v.parent;
-               if (!parent)
-                   return v;
-               v = parent;
-           }
-       }
-       replaceChildren(from, to, children = noChildren$2) {
-           this.markDirty();
-           for (let i = from; i < to; i++) {
-               let child = this.children[i];
-               if (child.parent == this)
-                   child.destroy();
-           }
-           this.children.splice(from, to - from, ...children);
-           for (let i = 0; i < children.length; i++)
-               children[i].setParent(this);
-       }
-       ignoreMutation(_rec) { return false; }
-       ignoreEvent(_event) { return false; }
-       childCursor(pos = this.length) {
-           return new ChildCursor$2(this.children, pos, this.children.length);
-       }
-       childPos(pos, bias = 1) {
-           return this.childCursor().findPos(pos, bias);
-       }
-       toString() {
-           let name = this.constructor.name.replace("View", "");
-           return name + (this.children.length ? "(" + this.children.join() + ")" :
-               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
-               (this.breakAfter ? "#" : "");
-       }
-       static get(node) { return node.cmView; }
-       get isEditable() { return true; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           return false;
-       }
-       become(other) { return false; }
-       // When this is a zero-length view with a side, this should return a
-       // number <= 0 to indicate it is before its position, or a
-       // number > 0 when after its position.
-       getSide() { return 0; }
-       destroy() {
-           this.parent = null;
-       }
-   };
-   ContentView$2.prototype.breakAfter = 0;
-   // Remove a DOM node and return its next sibling.
-   function rm$1$2(dom) {
-       let next = dom.nextSibling;
-       dom.parentNode.removeChild(dom);
-       return next;
-   }
-   let ChildCursor$2 = class ChildCursor {
-       constructor(children, pos, i) {
-           this.children = children;
-           this.pos = pos;
-           this.i = i;
-           this.off = 0;
-       }
-       findPos(pos, bias = 1) {
-           for (;;) {
-               if (pos > this.pos || pos == this.pos &&
-                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
-                   this.off = pos - this.pos;
-                   return this;
-               }
-               let next = this.children[--this.i];
-               this.pos -= next.length + next.breakAfter;
-           }
-       }
-   };
-   function replaceRange$2(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
-       let { children } = parent;
-       let before = children.length ? children[fromI] : null;
-       let last = insert.length ? insert[insert.length - 1] : null;
-       let breakAtEnd = last ? last.breakAfter : breakAtStart;
-       // Change within a single child
-       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
-           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
-           return;
-       if (toI < children.length) {
-           let after = children[toI];
-           // Make sure the end of the child after the update is preserved in `after`
-           if (after && toOff < after.length) {
-               // If we're splitting a child, separate part of it to avoid that
-               // being mangled when updating the child before the update.
-               if (fromI == toI) {
-                   after = after.split(toOff);
-                   toOff = 0;
-               }
-               // If the element after the replacement should be merged with
-               // the last replacing element, update `content`
-               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
-                   insert[insert.length - 1] = after;
-               }
-               else {
-                   // Remove the start of the after element, if necessary, and
-                   // add it to `content`.
-                   if (toOff)
-                       after.merge(0, toOff, null, false, 0, openEnd);
-                   insert.push(after);
-               }
-           }
-           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
-               // The element at `toI` is entirely covered by this range.
-               // Preserve its line break, if any.
-               if (last)
-                   last.breakAfter = 1;
-               else
-                   breakAtStart = 1;
-           }
-           // Since we've handled the next element from the current elements
-           // now, make sure `toI` points after that.
-           toI++;
-       }
-       if (before) {
-           before.breakAfter = breakAtStart;
-           if (fromOff > 0) {
-               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
-                   before.breakAfter = insert.shift().breakAfter;
-               }
-               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
-                   before.merge(fromOff, before.length, null, false, openStart, 0);
-               }
-               fromI++;
-           }
-       }
-       // Try to merge widgets on the boundaries of the replacement
-       while (fromI < toI && insert.length) {
-           if (children[toI - 1].become(insert[insert.length - 1])) {
-               toI--;
-               insert.pop();
-               openEnd = insert.length ? 0 : openStart;
-           }
-           else if (children[fromI].become(insert[0])) {
-               fromI++;
-               insert.shift();
-               openStart = insert.length ? 0 : openEnd;
-           }
-           else {
-               break;
-           }
-       }
-       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
-           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
-           fromI--;
-       if (fromI < toI || insert.length)
-           parent.replaceChildren(fromI, toI, insert);
-   }
-   function mergeChildrenInto$2(parent, from, to, insert, openStart, openEnd) {
-       let cur = parent.childCursor();
-       let { i: toI, off: toOff } = cur.findPos(to, 1);
-       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
-       let dLen = from - to;
-       for (let view of insert)
-           dLen += view.length;
-       parent.length += dLen;
-       replaceRange$2(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
-   }
-
-   let nav$2 = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
-   let doc$2 = typeof document != "undefined" ? document : { documentElement: { style: {} } };
-   const ie_edge$2 = /*@__PURE__*//Edge\/(\d+)/.exec(nav$2.userAgent);
-   const ie_upto10$2 = /*@__PURE__*//MSIE \d/.test(nav$2.userAgent);
-   const ie_11up$2 = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav$2.userAgent);
-   const ie$2 = !!(ie_upto10$2 || ie_11up$2 || ie_edge$2);
-   const gecko$2 = !ie$2 && /*@__PURE__*//gecko\/(\d+)/i.test(nav$2.userAgent);
-   const chrome$2 = !ie$2 && /*@__PURE__*//Chrome\/(\d+)/.exec(nav$2.userAgent);
-   const webkit$2 = "webkitFontSmoothing" in doc$2.documentElement.style;
-   const safari$2 = !ie$2 && /*@__PURE__*//Apple Computer/.test(nav$2.vendor);
-   const ios$2 = safari$2 && (/*@__PURE__*//Mobile\/\w+/.test(nav$2.userAgent) || nav$2.maxTouchPoints > 2);
-   var browser$2 = {
-       mac: ios$2 || /*@__PURE__*//Mac/.test(nav$2.platform),
-       windows: /*@__PURE__*//Win/.test(nav$2.platform),
-       linux: /*@__PURE__*//Linux|X11/.test(nav$2.platform),
-       ie: ie$2,
-       ie_version: ie_upto10$2 ? doc$2.documentMode || 6 : ie_11up$2 ? +ie_11up$2[1] : ie_edge$2 ? +ie_edge$2[1] : 0,
-       gecko: gecko$2,
-       gecko_version: gecko$2 ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav$2.userAgent) || [0, 0])[1] : 0,
-       chrome: !!chrome$2,
-       chrome_version: chrome$2 ? +chrome$2[1] : 0,
-       ios: ios$2,
-       android: /*@__PURE__*//Android\b/.test(nav$2.userAgent),
-       webkit: webkit$2,
-       safari: safari$2,
-       webkit_version: webkit$2 ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
-       tabSize: doc$2.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
-   };
-
-   const MaxJoinLen$2 = 256;
-   let TextView$2 = class TextView extends ContentView$2 {
-       constructor(text) {
-           super();
-           this.text = text;
-       }
-       get length() { return this.text.length; }
-       createDOM(textDOM) {
-           this.setDOM(textDOM || document.createTextNode(this.text));
-       }
-       sync(track) {
-           if (!this.dom)
-               this.createDOM();
-           if (this.dom.nodeValue != this.text) {
-               if (track && track.node == this.dom)
-                   track.written = true;
-               this.dom.nodeValue = this.text;
-           }
-       }
-       reuseDOM(dom) {
-           if (dom.nodeType == 3)
-               this.createDOM(dom);
-       }
-       merge(from, to, source) {
-           if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen$2))
-               return false;
-           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = new TextView(this.text.slice(from));
-           this.text = this.text.slice(0, from);
-           this.markDirty();
-           return result;
-       }
-       localPosFromDOM(node, offset) {
-           return node == this.dom ? offset : offset ? this.text.length : 0;
-       }
-       domAtPos(pos) { return new DOMPos$2(this.dom, pos); }
-       domBoundsAround(_from, _to, offset) {
-           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
-       }
-       coordsAt(pos, side) {
-           return textCoords$2(this.dom, pos, side);
-       }
-   };
-   let MarkView$2 = class MarkView extends ContentView$2 {
-       constructor(mark, children = [], length = 0) {
-           super();
-           this.mark = mark;
-           this.children = children;
-           this.length = length;
-           for (let ch of children)
-               ch.setParent(this);
-       }
-       setAttrs(dom) {
-           clearAttributes$2(dom);
-           if (this.mark.class)
-               dom.className = this.mark.class;
-           if (this.mark.attrs)
-               for (let name in this.mark.attrs)
-                   dom.setAttribute(name, this.mark.attrs[name]);
-           return dom;
-       }
-       reuseDOM(node) {
-           if (node.nodeName == this.mark.tagName.toUpperCase()) {
-               this.setDOM(node);
-               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
-           }
-       }
-       sync(track) {
-           if (!this.dom)
-               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
-           else if (this.dirty & 4 /* Attrs */)
-               this.setAttrs(this.dom);
-           super.sync(track);
-       }
-       merge(from, to, source, _hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
-               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
-               return false;
-           mergeChildrenInto$2(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = [], off = 0, detachFrom = -1, i = 0;
-           for (let elt of this.children) {
-               let end = off + elt.length;
-               if (end > from)
-                   result.push(off < from ? elt.split(from - off) : elt);
-               if (detachFrom < 0 && off >= from)
-                   detachFrom = i;
-               off = end;
-               i++;
-           }
-           let length = this.length - from;
-           this.length = from;
-           if (detachFrom > -1) {
-               this.children.length = detachFrom;
-               this.markDirty();
-           }
-           return new MarkView(this.mark, result, length);
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos$2(this.dom, this.children, pos);
-       }
-       coordsAt(pos, side) {
-           return coordsInChildren$2(this, pos, side);
-       }
-   };
-   function textCoords$2(text, pos, side) {
-       let length = text.nodeValue.length;
-       if (pos > length)
-           pos = length;
-       let from = pos, to = pos, flatten = 0;
-       if (pos == 0 && side < 0 || pos == length && side >= 0) {
-           if (!(browser$2.chrome || browser$2.gecko)) { // These browsers reliably return valid rectangles for empty ranges
-               if (pos) {
-                   from--;
-                   flatten = 1;
-               } // FIXME this is wrong in RTL text
-               else if (to < length) {
-                   to++;
-                   flatten = -1;
-               }
-           }
-       }
-       else {
-           if (side < 0)
-               from--;
-           else if (to < length)
-               to++;
-       }
-       let rects = textRange$2(text, from, to).getClientRects();
-       if (!rects.length)
-           return Rect0$1;
-       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
-       if (browser$2.safari && !flatten && rect.width == 0)
-           rect = Array.prototype.find.call(rects, r => r.width) || rect;
-       return flatten ? flattenRect$2(rect, flatten < 0) : rect || null;
-   }
-   // Also used for collapsed ranges that don't have a placeholder widget!
-   let WidgetView$2 = class WidgetView extends ContentView$2 {
-       constructor(widget, length, side) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.side = side;
-           this.prevWidget = null;
-       }
-       static create(widget, length, side) {
-           return new (widget.customView || WidgetView)(widget, length, side);
-       }
-       split(from) {
-           let result = WidgetView.create(this.widget, this.length - from, this.side);
-           this.length -= from;
-           return result;
-       }
-       sync() {
-           if (!this.dom || !this.widget.updateDOM(this.dom)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(this.editorView));
-               this.dom.contentEditable = "false";
-           }
-       }
-       getSide() { return this.side; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       become(other) {
-           if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
-               if (this.widget.constructor == other.widget.constructor) {
-                   if (!this.widget.eq(other.widget))
-                       this.markDirty(true);
-                   if (this.dom && !this.prevWidget)
-                       this.prevWidget = this.widget;
-                   this.widget = other.widget;
-                   return true;
-               }
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       get overrideDOMText() {
-           if (this.length == 0)
-               return Text$2.empty;
-           let top = this;
-           while (top.parent)
-               top = top.parent;
-           let view = top.editorView, text = view && view.state.doc, start = this.posAtStart;
-           return text ? text.slice(start, start + this.length) : Text$2.empty;
-       }
-       domAtPos(pos) {
-           return pos == 0 ? DOMPos$2.before(this.dom) : DOMPos$2.after(this.dom, pos == this.length);
-       }
-       domBoundsAround() { return null; }
-       coordsAt(pos, side) {
-           let rects = this.dom.getClientRects(), rect = null;
-           if (!rects.length)
-               return Rect0$1;
-           for (let i = pos > 0 ? rects.length - 1 : 0;; i += (pos > 0 ? -1 : 1)) {
-               rect = rects[i];
-               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
-                   break;
-           }
-           return (pos == 0 && side > 0 || pos == this.length && side <= 0) ? rect : flattenRect$2(rect, pos == 0);
-       }
-       get isEditable() { return false; }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-   };
-   let CompositionView$1 = class CompositionView extends WidgetView$2 {
-       domAtPos(pos) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return new DOMPos$2(text, Math.min(pos, text.nodeValue.length));
-           return scanCompositionTree$1(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos$2(text, Math.min(p, text.nodeValue.length)));
-       }
-       sync() { this.setDOM(this.widget.toDOM()); }
-       localPosFromDOM(node, offset) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return Math.min(offset, this.length);
-           return posFromDOMInCompositionTree$1(node, offset, topView, text);
-       }
-       ignoreMutation() { return false; }
-       get overrideDOMText() { return null; }
-       coordsAt(pos, side) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return textCoords$2(text, pos, side);
-           return scanCompositionTree$1(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords$2(text, pos, side));
-       }
-       destroy() {
-           var _a;
-           super.destroy();
-           (_a = this.widget.topView) === null || _a === void 0 ? void 0 : _a.destroy();
-       }
-       get isEditable() { return true; }
-   };
-   // Uses the old structure of a chunk of content view frozen for
-   // composition to try and find a reasonable DOM location for the given
-   // offset.
-   function scanCompositionTree$1(pos, side, view, text, enterView, fromText) {
-       if (view instanceof MarkView$2) {
-           for (let child of view.children) {
-               let hasComp = contains$2(child.dom, text);
-               let len = hasComp ? text.nodeValue.length : child.length;
-               if (pos < len || pos == len && child.getSide() <= 0)
-                   return hasComp ? scanCompositionTree$1(pos, side, child, text, enterView, fromText) : enterView(child, pos, side);
-               pos -= len;
-           }
-           return enterView(view, view.length, -1);
-       }
-       else if (view.dom == text) {
-           return fromText(pos, side);
-       }
-       else {
-           return enterView(view, pos, side);
-       }
-   }
-   function posFromDOMInCompositionTree$1(node, offset, view, text) {
-       if (view instanceof MarkView$2) {
-           for (let child of view.children) {
-               let pos = 0, hasComp = contains$2(child.dom, text);
-               if (contains$2(child.dom, node))
-                   return pos + (hasComp ? posFromDOMInCompositionTree$1(node, offset, child, text) : child.localPosFromDOM(node, offset));
-               pos += hasComp ? text.nodeValue.length : child.length;
-           }
-       }
-       else if (view.dom == text) {
-           return Math.min(offset, text.nodeValue.length);
-       }
-       return view.localPosFromDOM(node, offset);
-   }
-   // These are drawn around uneditable widgets to avoid a number of
-   // browser bugs that show up when the cursor is directly next to
-   // uneditable inline content.
-   let WidgetBufferView$2 = class WidgetBufferView extends ContentView$2 {
-       constructor(side) {
-           super();
-           this.side = side;
-       }
-       get length() { return 0; }
-       merge() { return false; }
-       become(other) {
-           return other instanceof WidgetBufferView && other.side == this.side;
-       }
-       split() { return new WidgetBufferView(this.side); }
-       sync() {
-           if (!this.dom) {
-               let dom = document.createElement("img");
-               dom.className = "cm-widgetBuffer";
-               dom.setAttribute("aria-hidden", "true");
-               this.setDOM(dom);
-           }
-       }
-       getSide() { return this.side; }
-       domAtPos(pos) { return DOMPos$2.before(this.dom); }
-       localPosFromDOM() { return 0; }
-       domBoundsAround() { return null; }
-       coordsAt(pos) {
-           let imgRect = this.dom.getBoundingClientRect();
-           // Since the <img> height doesn't correspond to text height, try
-           // to borrow the height from some sibling node.
-           let siblingRect = inlineSiblingRect$1(this, this.side > 0 ? -1 : 1);
-           return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top
-               ? { left: imgRect.left, right: imgRect.right, top: siblingRect.top, bottom: siblingRect.bottom } : imgRect;
-       }
-       get overrideDOMText() {
-           return Text$2.empty;
-       }
-   };
-   TextView$2.prototype.children = WidgetView$2.prototype.children = WidgetBufferView$2.prototype.children = noChildren$2;
-   function inlineSiblingRect$1(view, side) {
-       let parent = view.parent, index = parent ? parent.children.indexOf(view) : -1;
-       while (parent && index >= 0) {
-           if (side < 0 ? index > 0 : index < parent.children.length) {
-               let next = parent.children[index + side];
-               if (next instanceof TextView$2) {
-                   let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
-                   if (nextRect)
-                       return nextRect;
-               }
-               index += side;
-           }
-           else if (parent instanceof MarkView$2 && parent.parent) {
-               index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
-               parent = parent.parent;
-           }
-           else {
-               let last = parent.dom.lastChild;
-               if (last && last.nodeName == "BR")
-                   return last.getClientRects()[0];
-               break;
-           }
-       }
-       return undefined;
-   }
-   function inlineDOMAtPos$2(dom, children, pos) {
-       let i = 0;
-       for (let off = 0; i < children.length; i++) {
-           let child = children[i], end = off + child.length;
-           if (end == off && child.getSide() <= 0)
-               continue;
-           if (pos > off && pos < end && child.dom.parentNode == dom)
-               return child.domAtPos(pos - off);
-           if (pos <= off)
-               break;
-           off = end;
-       }
-       for (; i > 0; i--) {
-           let before = children[i - 1].dom;
-           if (before.parentNode == dom)
-               return DOMPos$2.after(before);
-       }
-       return new DOMPos$2(dom, 0);
-   }
-   // Assumes `view`, if a mark view, has precisely 1 child.
-   function joinInlineInto$2(parent, view, open) {
-       let last, { children } = parent;
-       if (open > 0 && view instanceof MarkView$2 && children.length &&
-           (last = children[children.length - 1]) instanceof MarkView$2 && last.mark.eq(view.mark)) {
-           joinInlineInto$2(last, view.children[0], open - 1);
-       }
-       else {
-           children.push(view);
-           view.setParent(parent);
-       }
-       parent.length += view.length;
-   }
-   function coordsInChildren$2(view, pos, side) {
-       for (let off = 0, i = 0; i < view.children.length; i++) {
-           let child = view.children[i], end = off + child.length, next;
-           if ((side <= 0 || end == view.length || child.getSide() > 0 ? end >= pos : end > pos) &&
-               (pos < end || i + 1 == view.children.length || (next = view.children[i + 1]).length || next.getSide() > 0)) {
-               let flatten = 0;
-               if (end == off) {
-                   if (child.getSide() <= 0)
-                       continue;
-                   flatten = side = -child.getSide();
-               }
-               let rect = child.coordsAt(Math.max(0, pos - off), side);
-               return flatten && rect ? flattenRect$2(rect, side < 0) : rect;
-           }
-           off = end;
-       }
-       let last = view.dom.lastChild;
-       if (!last)
-           return view.dom.getBoundingClientRect();
-       let rects = clientRectsFor$2(last);
-       return rects[rects.length - 1] || null;
-   }
-
-   function combineAttrs$2(source, target) {
-       for (let name in source) {
-           if (name == "class" && target.class)
-               target.class += " " + source.class;
-           else if (name == "style" && target.style)
-               target.style += ";" + source.style;
-           else
-               target[name] = source[name];
-       }
-       return target;
-   }
-   function attrsEq$2(a, b) {
-       if (a == b)
-           return true;
-       if (!a || !b)
-           return false;
-       let keysA = Object.keys(a), keysB = Object.keys(b);
-       if (keysA.length != keysB.length)
-           return false;
-       for (let key of keysA) {
-           if (keysB.indexOf(key) == -1 || a[key] !== b[key])
-               return false;
-       }
-       return true;
-   }
-   function updateAttrs$2(dom, prev, attrs) {
-       let changed = null;
-       if (prev)
-           for (let name in prev)
-               if (!(attrs && name in attrs))
-                   dom.removeAttribute(changed = name);
-       if (attrs)
-           for (let name in attrs)
-               if (!(prev && prev[name] == attrs[name]))
-                   dom.setAttribute(changed = name, attrs[name]);
-       return !!changed;
-   }
-
-   /**
-   Widgets added to the content are described by subclasses of this
-   class. Using a description object like that makes it possible to
-   delay creating of the DOM structure for a widget until it is
-   needed, and to avoid redrawing widgets even if the decorations
-   that define them are recreated.
-   */
-   let WidgetType$2 = class WidgetType {
-       /**
-       Compare this instance to another instance of the same type.
-       (TypeScript can't express this, but only instances of the same
-       specific class will be passed to this method.) This is used to
-       avoid redrawing widgets when they are replaced by a new
-       decoration of the same type. The default implementation just
-       returns `false`, which will cause new instances of the widget to
-       always be redrawn.
-       */
-       eq(widget) { return false; }
-       /**
-       Update a DOM element created by a widget of the same type (but
-       different, non-`eq` content) to reflect this widget. May return
-       true to indicate that it could update, false to indicate it
-       couldn't (in which case the widget will be redrawn). The default
-       implementation just returns false.
-       */
-       updateDOM(dom) { return false; }
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       The estimated height this widget will have, to be used when
-       estimating the height of content that hasn't been drawn. May
-       return -1 to indicate you don't know. The default implementation
-       returns -1.
-       */
-       get estimatedHeight() { return -1; }
-       /**
-       Can be used to configure which kinds of events inside the widget
-       should be ignored by the editor. The default is to ignore all
-       events.
-       */
-       ignoreEvent(event) { return true; }
-       /**
-       @internal
-       */
-       get customView() { return null; }
-       /**
-       This is called when the an instance of the widget is removed
-       from the editor view.
-       */
-       destroy(dom) { }
-   };
-   /**
-   The different types of blocks that can occur in an editor view.
-   */
-   var BlockType$2 = /*@__PURE__*/(function (BlockType) {
-       /**
-       A line of text.
-       */
-       BlockType[BlockType["Text"] = 0] = "Text";
-       /**
-       A block widget associated with the position after it.
-       */
-       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
-       /**
-       A block widget associated with the position before it.
-       */
-       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
-       /**
-       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
-       */
-       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
-   return BlockType})(BlockType$2 || (BlockType$2 = {}));
-   /**
-   A decoration provides information on how to draw or style a piece
-   of content. You'll usually use it wrapped in a
-   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
-   @nonabstract
-   */
-   let Decoration$2 = class Decoration extends RangeValue$2 {
-       constructor(
-       /**
-       @internal
-       */
-       startSide, 
-       /**
-       @internal
-       */
-       endSide, 
-       /**
-       @internal
-       */
-       widget, 
-       /**
-       The config object used to create this decoration. You can
-       include additional properties in there to store metadata about
-       your decoration.
-       */
-       spec) {
-           super();
-           this.startSide = startSide;
-           this.endSide = endSide;
-           this.widget = widget;
-           this.spec = spec;
-       }
-       /**
-       @internal
-       */
-       get heightRelevant() { return false; }
-       /**
-       Create a mark decoration, which influences the styling of the
-       content in its range. Nested mark decorations will cause nested
-       DOM elements to be created. Nesting order is determined by
-       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
-       the higher-precedence decorations creating the inner DOM nodes.
-       Such elements are split on line boundaries and on the boundaries
-       of lower-precedence decorations.
-       */
-       static mark(spec) {
-           return new MarkDecoration$2(spec);
-       }
-       /**
-       Create a widget decoration, which displays a DOM element at the
-       given position.
-       */
-       static widget(spec) {
-           let side = spec.side || 0, block = !!spec.block;
-           side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
-           return new PointDecoration$2(spec, side, side, block, spec.widget || null, false);
-       }
-       /**
-       Create a replace decoration which replaces the given range with
-       a widget, or simply hides it.
-       */
-       static replace(spec) {
-           let block = !!spec.block, startSide, endSide;
-           if (spec.isBlockGap) {
-               startSide = -500000000 /* GapStart */;
-               endSide = 400000000 /* GapEnd */;
-           }
-           else {
-               let { start, end } = getInclusive$2(spec, block);
-               startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
-               endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
-           }
-           return new PointDecoration$2(spec, startSide, endSide, block, spec.widget || null, true);
-       }
-       /**
-       Create a line decoration, which can add DOM attributes to the
-       line starting at the given position.
-       */
-       static line(spec) {
-           return new LineDecoration$2(spec);
-       }
-       /**
-       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
-       decorated range or ranges. If the ranges aren't already sorted,
-       pass `true` for `sort` to make the library sort them for you.
-       */
-       static set(of, sort = false) {
-           return RangeSet$2.of(of, sort);
-       }
-       /**
-       @internal
-       */
-       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
-   };
-   /**
-   The empty set of decorations.
-   */
-   Decoration$2.none = RangeSet$2.empty;
-   let MarkDecoration$2 = class MarkDecoration extends Decoration$2 {
-       constructor(spec) {
-           let { start, end } = getInclusive$2(spec);
-           super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
-           this.tagName = spec.tagName || "span";
-           this.class = spec.class || "";
-           this.attrs = spec.attributes || null;
-       }
-       eq(other) {
-           return this == other ||
-               other instanceof MarkDecoration &&
-                   this.tagName == other.tagName &&
-                   this.class == other.class &&
-                   attrsEq$2(this.attrs, other.attrs);
-       }
-       range(from, to = from) {
-           if (from >= to)
-               throw new RangeError("Mark decorations may not be empty");
-           return super.range(from, to);
-       }
-   };
-   MarkDecoration$2.prototype.point = false;
-   let LineDecoration$2 = class LineDecoration extends Decoration$2 {
-       constructor(spec) {
-           super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
-       }
-       eq(other) {
-           return other instanceof LineDecoration && attrsEq$2(this.spec.attributes, other.spec.attributes);
-       }
-       range(from, to = from) {
-           if (to != from)
-               throw new RangeError("Line decoration ranges must be zero-length");
-           return super.range(from, to);
-       }
-   };
-   LineDecoration$2.prototype.mapMode = MapMode$2.TrackBefore;
-   LineDecoration$2.prototype.point = true;
-   let PointDecoration$2 = class PointDecoration extends Decoration$2 {
-       constructor(spec, startSide, endSide, block, widget, isReplace) {
-           super(startSide, endSide, widget, spec);
-           this.block = block;
-           this.isReplace = isReplace;
-           this.mapMode = !block ? MapMode$2.TrackDel : startSide <= 0 ? MapMode$2.TrackBefore : MapMode$2.TrackAfter;
-       }
-       // Only relevant when this.block == true
-       get type() {
-           return this.startSide < this.endSide ? BlockType$2.WidgetRange
-               : this.startSide <= 0 ? BlockType$2.WidgetBefore : BlockType$2.WidgetAfter;
-       }
-       get heightRelevant() { return this.block || !!this.widget && this.widget.estimatedHeight >= 5; }
-       eq(other) {
-           return other instanceof PointDecoration &&
-               widgetsEq$2(this.widget, other.widget) &&
-               this.block == other.block &&
-               this.startSide == other.startSide && this.endSide == other.endSide;
-       }
-       range(from, to = from) {
-           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
-               throw new RangeError("Invalid range for replacement decoration");
-           if (!this.isReplace && to != from)
-               throw new RangeError("Widget decorations can only have zero-length ranges");
-           return super.range(from, to);
-       }
-   };
-   PointDecoration$2.prototype.point = true;
-   function getInclusive$2(spec, block = false) {
-       let { inclusiveStart: start, inclusiveEnd: end } = spec;
-       if (start == null)
-           start = spec.inclusive;
-       if (end == null)
-           end = spec.inclusive;
-       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
-   }
-   function widgetsEq$2(a, b) {
-       return a == b || !!(a && b && a.compare(b));
-   }
-   function addRange$2(from, to, ranges, margin = 0) {
-       let last = ranges.length - 1;
-       if (last >= 0 && ranges[last] + margin >= from)
-           ranges[last] = Math.max(ranges[last], to);
-       else
-           ranges.push(from, to);
-   }
-
-   let LineView$2 = class LineView extends ContentView$2 {
-       constructor() {
-           super(...arguments);
-           this.children = [];
-           this.length = 0;
-           this.prevAttrs = undefined;
-           this.attrs = null;
-           this.breakAfter = 0;
-       }
-       // Consumes source
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source) {
-               if (!(source instanceof LineView))
-                   return false;
-               if (!this.dom)
-                   source.transferDOM(this); // Reuse source.dom when appropriate
-           }
-           if (hasStart)
-               this.setDeco(source ? source.attrs : null);
-           mergeChildrenInto$2(this, from, to, source ? source.children : [], openStart, openEnd);
-           return true;
-       }
-       split(at) {
-           let end = new LineView;
-           end.breakAfter = this.breakAfter;
-           if (this.length == 0)
-               return end;
-           let { i, off } = this.childPos(at);
-           if (off) {
-               end.append(this.children[i].split(off), 0);
-               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
-               i++;
-           }
-           for (let j = i; j < this.children.length; j++)
-               end.append(this.children[j], 0);
-           while (i > 0 && this.children[i - 1].length == 0)
-               this.children[--i].destroy();
-           this.children.length = i;
-           this.markDirty();
-           this.length = at;
-           return end;
-       }
-       transferDOM(other) {
-           if (!this.dom)
-               return;
-           this.markDirty();
-           other.setDOM(this.dom);
-           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
-           this.prevAttrs = undefined;
-           this.dom = null;
-       }
-       setDeco(attrs) {
-           if (!attrsEq$2(this.attrs, attrs)) {
-               if (this.dom) {
-                   this.prevAttrs = this.attrs;
-                   this.markDirty();
-               }
-               this.attrs = attrs;
-           }
-       }
-       append(child, openStart) {
-           joinInlineInto$2(this, child, openStart);
-       }
-       // Only called when building a line view in ContentBuilder
-       addLineDeco(deco) {
-           let attrs = deco.spec.attributes, cls = deco.spec.class;
-           if (attrs)
-               this.attrs = combineAttrs$2(attrs, this.attrs || {});
-           if (cls)
-               this.attrs = combineAttrs$2({ class: cls }, this.attrs || {});
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos$2(this.dom, this.children, pos);
-       }
-       reuseDOM(node) {
-           if (node.nodeName == "DIV") {
-               this.setDOM(node);
-               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
-           }
-       }
-       sync(track) {
-           var _a;
-           if (!this.dom) {
-               this.setDOM(document.createElement("div"));
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           else if (this.dirty & 4 /* Attrs */) {
-               clearAttributes$2(this.dom);
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           if (this.prevAttrs !== undefined) {
-               updateAttrs$2(this.dom, this.prevAttrs, this.attrs);
-               this.dom.classList.add("cm-line");
-               this.prevAttrs = undefined;
-           }
-           super.sync(track);
-           let last = this.dom.lastChild;
-           while (last && ContentView$2.get(last) instanceof MarkView$2)
-               last = last.lastChild;
-           if (!last || !this.length ||
-               last.nodeName != "BR" && ((_a = ContentView$2.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
-                   (!browser$2.ios || !this.children.some(ch => ch instanceof TextView$2))) {
-               let hack = document.createElement("BR");
-               hack.cmIgnore = true;
-               this.dom.appendChild(hack);
-           }
-       }
-       measureTextSize() {
-           if (this.children.length == 0 || this.length > 20)
-               return null;
-           let totalWidth = 0;
-           for (let child of this.children) {
-               if (!(child instanceof TextView$2))
-                   return null;
-               let rects = clientRectsFor$2(child.dom);
-               if (rects.length != 1)
-                   return null;
-               totalWidth += rects[0].width;
-           }
-           return { lineHeight: this.dom.getBoundingClientRect().height,
-               charWidth: totalWidth / this.length };
-       }
-       coordsAt(pos, side) {
-           return coordsInChildren$2(this, pos, side);
-       }
-       become(_other) { return false; }
-       get type() { return BlockType$2.Text; }
-       static find(docView, pos) {
-           for (let i = 0, off = 0; i < docView.children.length; i++) {
-               let block = docView.children[i], end = off + block.length;
-               if (end >= pos) {
-                   if (block instanceof LineView)
-                       return block;
-                   if (end > pos)
-                       break;
-               }
-               off = end + block.breakAfter;
-           }
-           return null;
-       }
-   };
-   let BlockWidgetView$2 = class BlockWidgetView extends ContentView$2 {
-       constructor(widget, length, type) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.type = type;
-           this.breakAfter = 0;
-           this.prevWidget = null;
-       }
-       merge(from, to, source, _takeDeco, openStart, openEnd) {
-           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       domAtPos(pos) {
-           return pos == 0 ? DOMPos$2.before(this.dom) : DOMPos$2.after(this.dom, pos == this.length);
-       }
-       split(at) {
-           let len = this.length - at;
-           this.length = at;
-           let end = new BlockWidgetView(this.widget, len, this.type);
-           end.breakAfter = this.breakAfter;
-           return end;
-       }
-       get children() { return noChildren$2; }
-       sync() {
-           if (!this.dom || !this.widget.updateDOM(this.dom)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(this.editorView));
-               this.dom.contentEditable = "false";
-           }
-       }
-       get overrideDOMText() {
-           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$2.empty;
-       }
-       domBoundsAround() { return null; }
-       become(other) {
-           if (other instanceof BlockWidgetView && other.type == this.type &&
-               other.widget.constructor == this.widget.constructor) {
-               if (!other.widget.eq(this.widget))
-                   this.markDirty(true);
-               if (this.dom && !this.prevWidget)
-                   this.prevWidget = this.widget;
-               this.widget = other.widget;
-               this.length = other.length;
-               this.breakAfter = other.breakAfter;
-               return true;
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-   };
-
-   let ContentBuilder$2 = class ContentBuilder {
-       constructor(doc, pos, end, disallowBlockEffectsFor) {
-           this.doc = doc;
-           this.pos = pos;
-           this.end = end;
-           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
-           this.content = [];
-           this.curLine = null;
-           this.breakAtStart = 0;
-           this.pendingBuffer = 0 /* No */;
-           // Set to false directly after a widget that covers the position after it
-           this.atCursorPos = true;
-           this.openStart = -1;
-           this.openEnd = -1;
-           this.text = "";
-           this.textOff = 0;
-           this.cursor = doc.iter();
-           this.skip = pos;
-       }
-       posCovered() {
-           if (this.content.length == 0)
-               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
-           let last = this.content[this.content.length - 1];
-           return !last.breakAfter && !(last instanceof BlockWidgetView$2 && last.type == BlockType$2.WidgetBefore);
-       }
-       getLine() {
-           if (!this.curLine) {
-               this.content.push(this.curLine = new LineView$2);
-               this.atCursorPos = true;
-           }
-           return this.curLine;
-       }
-       flushBuffer(active) {
-           if (this.pendingBuffer) {
-               this.curLine.append(wrapMarks$2(new WidgetBufferView$2(-1), active), active.length);
-               this.pendingBuffer = 0 /* No */;
-           }
-       }
-       addBlockWidget(view) {
-           this.flushBuffer([]);
-           this.curLine = null;
-           this.content.push(view);
-       }
-       finish(openEnd) {
-           if (!openEnd)
-               this.flushBuffer([]);
-           else
-               this.pendingBuffer = 0 /* No */;
-           if (!this.posCovered())
-               this.getLine();
-       }
-       buildText(length, active, openStart) {
-           while (length > 0) {
-               if (this.textOff == this.text.length) {
-                   let { value, lineBreak, done } = this.cursor.next(this.skip);
-                   this.skip = 0;
-                   if (done)
-                       throw new Error("Ran out of text content when drawing inline views");
-                   if (lineBreak) {
-                       if (!this.posCovered())
-                           this.getLine();
-                       if (this.content.length)
-                           this.content[this.content.length - 1].breakAfter = 1;
-                       else
-                           this.breakAtStart = 1;
-                       this.flushBuffer([]);
-                       this.curLine = null;
-                       length--;
-                       continue;
-                   }
-                   else {
-                       this.text = value;
-                       this.textOff = 0;
-                   }
-               }
-               let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
-               this.flushBuffer(active.slice(0, openStart));
-               this.getLine().append(wrapMarks$2(new TextView$2(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
-               this.atCursorPos = true;
-               this.textOff += take;
-               length -= take;
-               openStart = 0;
-           }
-       }
-       span(from, to, active, openStart) {
-           this.buildText(to - from, active, openStart);
-           this.pos = to;
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       point(from, to, deco, active, openStart, index) {
-           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration$2) {
-               if (deco.block)
-                   throw new RangeError("Block decorations may not be specified via plugins");
-               if (to > this.doc.lineAt(this.pos).to)
-                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
-           }
-           let len = to - from;
-           if (deco instanceof PointDecoration$2) {
-               if (deco.block) {
-                   let { type } = deco;
-                   if (type == BlockType$2.WidgetAfter && !this.posCovered())
-                       this.getLine();
-                   this.addBlockWidget(new BlockWidgetView$2(deco.widget || new NullWidget$2("div"), len, type));
-               }
-               else {
-                   let view = WidgetView$2.create(deco.widget || new NullWidget$2("span"), len, deco.startSide);
-                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
-                   let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
-                   let line = this.getLine();
-                   if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
-                       this.pendingBuffer = 0 /* No */;
-                   this.flushBuffer(active);
-                   if (cursorBefore) {
-                       line.append(wrapMarks$2(new WidgetBufferView$2(1), active), openStart);
-                       openStart = active.length + Math.max(0, openStart - active.length);
-                   }
-                   line.append(wrapMarks$2(view, active), openStart);
-                   this.atCursorPos = cursorAfter;
-                   this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
-               }
-           }
-           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
-               this.getLine().addLineDeco(deco);
-           }
-           if (len) {
-               // Advance the iterator past the replaced content
-               if (this.textOff + len <= this.text.length) {
-                   this.textOff += len;
-               }
-               else {
-                   this.skip += len - (this.text.length - this.textOff);
-                   this.text = "";
-                   this.textOff = 0;
-               }
-               this.pos = to;
-           }
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       static build(text, from, to, decorations, dynamicDecorationMap) {
-           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
-           builder.openEnd = RangeSet$2.spans(decorations, from, to, builder);
-           if (builder.openStart < 0)
-               builder.openStart = builder.openEnd;
-           builder.finish(builder.openEnd);
-           return builder;
-       }
-   };
-   function wrapMarks$2(view, active) {
-       for (let mark of active)
-           view = new MarkView$2(mark, [view], view.length);
-       return view;
-   }
-   let NullWidget$2 = class NullWidget extends WidgetType$2 {
-       constructor(tag) {
-           super();
-           this.tag = tag;
-       }
-       eq(other) { return other.tag == this.tag; }
-       toDOM() { return document.createElement(this.tag); }
-       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
-   };
-
-   const clickAddsSelectionRange$2 = /*@__PURE__*/Facet$2.define();
-   const dragMovesSelection$1$2 = /*@__PURE__*/Facet$2.define();
-   const mouseSelectionStyle$2 = /*@__PURE__*/Facet$2.define();
-   const exceptionSink$2 = /*@__PURE__*/Facet$2.define();
-   const updateListener$2 = /*@__PURE__*/Facet$2.define();
-   const inputHandler$3 = /*@__PURE__*/Facet$2.define();
-   const perLineTextDirection$2 = /*@__PURE__*/Facet$2.define({
-       combine: values => values.some(x => x)
-   });
-   let ScrollTarget$2 = class ScrollTarget {
-       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5) {
-           this.range = range;
-           this.y = y;
-           this.x = x;
-           this.yMargin = yMargin;
-           this.xMargin = xMargin;
-       }
-       map(changes) {
-           return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);
-       }
-   };
-   const scrollIntoView$4 = /*@__PURE__*/StateEffect$2.define({ map: (t, ch) => t.map(ch) });
-   /**
-   Log or report an unhandled exception in client code. Should
-   probably only be used by extension code that allows client code to
-   provide functions, and calls those functions in a context where an
-   exception can't be propagated to calling code in a reasonable way
-   (for example when in an event handler).
-
-   Either calls a handler registered with
-   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
-   `window.onerror`, if defined, or `console.error` (in which case
-   it'll pass `context`, when given, as first argument).
-   */
-   function logException$2(state, exception, context) {
-       let handler = state.facet(exceptionSink$2);
-       if (handler.length)
-           handler[0](exception);
-       else if (window.onerror)
-           window.onerror(String(exception), context, undefined, undefined, exception);
-       else if (context)
-           console.error(context + ":", exception);
-       else
-           console.error(exception);
-   }
-   const editable$2 = /*@__PURE__*/Facet$2.define({ combine: values => values.length ? values[0] : true });
-   let nextPluginID$2 = 0;
-   const viewPlugin$2 = /*@__PURE__*/Facet$2.define();
-   /**
-   View plugins associate stateful values with a view. They can
-   influence the way the content is drawn, and are notified of things
-   that happen in the view.
-   */
-   let ViewPlugin$2 = class ViewPlugin {
-       constructor(
-       /**
-       @internal
-       */
-       id, 
-       /**
-       @internal
-       */
-       create, 
-       /**
-       @internal
-       */
-       domEventHandlers, buildExtensions) {
-           this.id = id;
-           this.create = create;
-           this.domEventHandlers = domEventHandlers;
-           this.extension = buildExtensions(this);
-       }
-       /**
-       Define a plugin from a constructor function that creates the
-       plugin's value, given an editor view.
-       */
-       static define(create, spec) {
-           const { eventHandlers, provide, decorations: deco } = spec || {};
-           return new ViewPlugin(nextPluginID$2++, create, eventHandlers, plugin => {
-               let ext = [viewPlugin$2.of(plugin)];
-               if (deco)
-                   ext.push(decorations$2.of(view => {
-                       let pluginInst = view.plugin(plugin);
-                       return pluginInst ? deco(pluginInst) : Decoration$2.none;
-                   }));
-               if (provide)
-                   ext.push(provide(plugin));
-               return ext;
-           });
-       }
-       /**
-       Create a plugin for a class whose constructor takes a single
-       editor view as argument.
-       */
-       static fromClass(cls, spec) {
-           return ViewPlugin.define(view => new cls(view), spec);
-       }
-   };
-   let PluginInstance$2 = class PluginInstance {
-       constructor(spec) {
-           this.spec = spec;
-           // When starting an update, all plugins have this field set to the
-           // update object, indicating they need to be updated. When finished
-           // updating, it is set to `false`. Retrieving a plugin that needs to
-           // be updated with `view.plugin` forces an eager update.
-           this.mustUpdate = null;
-           // This is null when the plugin is initially created, but
-           // initialized on the first update.
-           this.value = null;
-       }
-       update(view) {
-           if (!this.value) {
-               if (this.spec) {
-                   try {
-                       this.value = this.spec.create(view);
-                   }
-                   catch (e) {
-                       logException$2(view.state, e, "CodeMirror plugin crashed");
-                       this.deactivate();
-                   }
-               }
-           }
-           else if (this.mustUpdate) {
-               let update = this.mustUpdate;
-               this.mustUpdate = null;
-               if (this.value.update) {
-                   try {
-                       this.value.update(update);
-                   }
-                   catch (e) {
-                       logException$2(update.state, e, "CodeMirror plugin crashed");
-                       if (this.value.destroy)
-                           try {
-                               this.value.destroy();
-                           }
-                           catch (_) { }
-                       this.deactivate();
-                   }
-               }
-           }
-           return this;
-       }
-       destroy(view) {
-           var _a;
-           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
-               try {
-                   this.value.destroy();
-               }
-               catch (e) {
-                   logException$2(view.state, e, "CodeMirror plugin crashed");
-               }
-           }
-       }
-       deactivate() {
-           this.spec = this.value = null;
-       }
-   };
-   const editorAttributes$2 = /*@__PURE__*/Facet$2.define();
-   const contentAttributes$2 = /*@__PURE__*/Facet$2.define();
-   // Provide decorations
-   const decorations$2 = /*@__PURE__*/Facet$2.define();
-   const atomicRanges$2 = /*@__PURE__*/Facet$2.define();
-   const scrollMargins$2 = /*@__PURE__*/Facet$2.define();
-   const styleModule$2 = /*@__PURE__*/Facet$2.define();
-   let ChangedRange$2 = class ChangedRange {
-       constructor(fromA, toA, fromB, toB) {
-           this.fromA = fromA;
-           this.toA = toA;
-           this.fromB = fromB;
-           this.toB = toB;
-       }
-       join(other) {
-           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
-       }
-       addToSet(set) {
-           let i = set.length, me = this;
-           for (; i > 0; i--) {
-               let range = set[i - 1];
-               if (range.fromA > me.toA)
-                   continue;
-               if (range.toA < me.fromA)
-                   break;
-               me = me.join(range);
-               set.splice(i - 1, 1);
-           }
-           set.splice(i, 0, me);
-           return set;
-       }
-       static extendWithRanges(diff, ranges) {
-           if (ranges.length == 0)
-               return diff;
-           let result = [];
-           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
-               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
-               let end = next ? next.fromB : 1e9;
-               while (rI < ranges.length && ranges[rI] < end) {
-                   let from = ranges[rI], to = ranges[rI + 1];
-                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
-                   if (fromB <= toB)
-                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
-                   if (to > end)
-                       break;
-                   else
-                       rI += 2;
-               }
-               if (!next)
-                   return result;
-               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
-               posA = next.toA;
-               posB = next.toB;
-           }
-       }
-   };
-   /**
-   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
-   class, which describe what happened, whenever the view is updated.
-   */
-   let ViewUpdate$2 = class ViewUpdate {
-       constructor(
-       /**
-       The editor view that the update is associated with.
-       */
-       view, 
-       /**
-       The new editor state.
-       */
-       state, 
-       /**
-       The transactions involved in the update. May be empty.
-       */
-       transactions) {
-           this.view = view;
-           this.state = state;
-           this.transactions = transactions;
-           /**
-           @internal
-           */
-           this.flags = 0;
-           this.startState = view.state;
-           this.changes = ChangeSet$2.empty(this.startState.doc.length);
-           for (let tr of transactions)
-               this.changes = this.changes.compose(tr.changes);
-           let changedRanges = [];
-           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange$2(fromA, toA, fromB, toB)));
-           this.changedRanges = changedRanges;
-           let focus = view.hasFocus;
-           if (focus != view.inputState.notifiedFocused) {
-               view.inputState.notifiedFocused = focus;
-               this.flags |= 1 /* Focus */;
-           }
-       }
-       /**
-       @internal
-       */
-       static create(view, state, transactions) {
-           return new ViewUpdate(view, state, transactions);
-       }
-       /**
-       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
-       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
-       update.
-       */
-       get viewportChanged() {
-           return (this.flags & 4 /* Viewport */) > 0;
-       }
-       /**
-       Indicates whether the height of a block element in the editor
-       changed in this update.
-       */
-       get heightChanged() {
-           return (this.flags & 2 /* Height */) > 0;
-       }
-       /**
-       Returns true when the document was modified or the size of the
-       editor, or elements within the editor, changed.
-       */
-       get geometryChanged() {
-           return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
-       }
-       /**
-       True when this update indicates a focus change.
-       */
-       get focusChanged() {
-           return (this.flags & 1 /* Focus */) > 0;
-       }
-       /**
-       Whether the document changed in this update.
-       */
-       get docChanged() {
-           return !this.changes.empty;
-       }
-       /**
-       Whether the selection was explicitly set in this update.
-       */
-       get selectionSet() {
-           return this.transactions.some(tr => tr.selection);
-       }
-       /**
-       @internal
-       */
-       get empty() { return this.flags == 0 && this.transactions.length == 0; }
-   };
-
-   /**
-   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-   */
-   var Direction$2 = /*@__PURE__*/(function (Direction) {
-       // (These are chosen to match the base levels, in bidi algorithm
-       // terms, of spans in that direction.)
-       /**
-       Left-to-right.
-       */
-       Direction[Direction["LTR"] = 0] = "LTR";
-       /**
-       Right-to-left.
-       */
-       Direction[Direction["RTL"] = 1] = "RTL";
-   return Direction})(Direction$2 || (Direction$2 = {}));
-   const LTR$2 = Direction$2.LTR, RTL$2 = Direction$2.RTL;
-   // Decode a string with each type encoded as log2(type)
-   function dec$2(str) {
-       let result = [];
-       for (let i = 0; i < str.length; i++)
-           result.push(1 << +str[i]);
-       return result;
-   }
-   // Character types for codepoints 0 to 0xf8
-   const LowTypes$2 = /*@__PURE__*/dec$2("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
-   // Character types for codepoints 0x600 to 0x6f9
-   const ArabicTypes$2 = /*@__PURE__*/dec$2("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
-   const Brackets$2 = /*@__PURE__*/Object.create(null), BracketStack$2 = [];
-   // There's a lot more in
-   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
-   // which are left out to keep code size down.
-   for (let p of ["()", "[]", "{}"]) {
-       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
-       Brackets$2[l] = r;
-       Brackets$2[r] = -l;
-   }
-   function charType$2(ch) {
-       return ch <= 0xf7 ? LowTypes$2[ch] :
-           0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
-               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes$2[ch - 0x600] :
-                   0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
-                       0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
-                           ch == 0x200c ? 256 /* NI */ : 1 /* L */;
-   }
-   const BidiRE$2 = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
-   /**
-   Represents a contiguous range of text that has a single direction
-   (as in left-to-right or right-to-left).
-   */
-   let BidiSpan$2 = class BidiSpan {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the span (relative to the start of the line).
-       */
-       from, 
-       /**
-       The end of the span.
-       */
-       to, 
-       /**
-       The ["bidi
-       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
-       of the span (in this context, 0 means
-       left-to-right, 1 means right-to-left, 2 means left-to-right
-       number inside right-to-left text).
-       */
-       level) {
-           this.from = from;
-           this.to = to;
-           this.level = level;
-       }
-       /**
-       The direction of this span.
-       */
-       get dir() { return this.level % 2 ? RTL$2 : LTR$2; }
-       /**
-       @internal
-       */
-       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
-       /**
-       @internal
-       */
-       static find(order, index, level, assoc) {
-           let maybe = -1;
-           for (let i = 0; i < order.length; i++) {
-               let span = order[i];
-               if (span.from <= index && span.to >= index) {
-                   if (span.level == level)
-                       return i;
-                   // When multiple spans match, if assoc != 0, take the one that
-                   // covers that side, otherwise take the one with the minimum
-                   // level.
-                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
-                       maybe = i;
-               }
-           }
-           if (maybe < 0)
-               throw new RangeError("Index out of range");
-           return maybe;
-       }
-   };
-   // Reused array of character types
-   const types$2 = [];
-   function computeOrder$2(line, direction) {
-       let len = line.length, outerType = direction == LTR$2 ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR$2 ? 2 /* R */ : 1 /* L */;
-       if (!line || outerType == 1 /* L */ && !BidiRE$2.test(line))
-           return trivialOrder$2(len);
-       // W1. Examine each non-spacing mark (NSM) in the level run, and
-       // change the type of the NSM to the type of the previous
-       // character. If the NSM is at the start of the level run, it will
-       // get the type of sor.
-       // W2. Search backwards from each instance of a European number
-       // until the first strong type (R, L, AL, or sor) is found. If an
-       // AL is found, change the type of the European number to Arabic
-       // number.
-       // W3. Change all ALs to R.
-       // (Left after this: L, R, EN, AN, ET, CS, NI)
-       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
-           let type = charType$2(line.charCodeAt(i));
-           if (type == 512 /* NSM */)
-               type = prev;
-           else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
-               type = 16 /* AN */;
-           types$2[i] = type == 4 /* AL */ ? 2 /* R */ : type;
-           if (type & 7 /* Strong */)
-               prevStrong = type;
-           prev = type;
-       }
-       // W5. A sequence of European terminators adjacent to European
-       // numbers changes to all European numbers.
-       // W6. Otherwise, separators and terminators change to Other
-       // Neutral.
-       // W7. Search backwards from each instance of a European number
-       // until the first strong type (R, L, or sor) is found. If an L is
-       // found, then change the type of the European number to L.
-       // (Left after this: L, R, EN+AN, NI)
-       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
-           let type = types$2[i];
-           if (type == 128 /* CS */) {
-               if (i < len - 1 && prev == types$2[i + 1] && (prev & 24 /* Num */))
-                   type = types$2[i] = prev;
-               else
-                   types$2[i] = 256 /* NI */;
-           }
-           else if (type == 64 /* ET */) {
-               let end = i + 1;
-               while (end < len && types$2[end] == 64 /* ET */)
-                   end++;
-               let replace = (i && prev == 8 /* EN */) || (end < len && types$2[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
-               for (let j = i; j < end; j++)
-                   types$2[j] = replace;
-               i = end - 1;
-           }
-           else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
-               types$2[i] = 1 /* L */;
-           }
-           prev = type;
-           if (type & 7 /* Strong */)
-               prevStrong = type;
-       }
-       // N0. Process bracket pairs in an isolating run sequence
-       // sequentially in the logical order of the text positions of the
-       // opening paired brackets using the logic given below. Within this
-       // scope, bidirectional types EN and AN are treated as R.
-       for (let i = 0, sI = 0, context = 0, ch, br, type; i < len; i++) {
-           // Keeps [startIndex, type, strongSeen] triples for each open
-           // bracket on BracketStack.
-           if (br = Brackets$2[ch = line.charCodeAt(i)]) {
-               if (br < 0) { // Closing bracket
-                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                       if (BracketStack$2[sJ + 1] == -br) {
-                           let flags = BracketStack$2[sJ + 2];
-                           let type = (flags & 2 /* EmbedInside */) ? outerType :
-                               !(flags & 4 /* OppositeInside */) ? 0 :
-                                   (flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
-                           if (type)
-                               types$2[i] = types$2[BracketStack$2[sJ]] = type;
-                           sI = sJ;
-                           break;
-                       }
-                   }
-               }
-               else if (BracketStack$2.length == 189 /* MaxDepth */) {
-                   break;
-               }
-               else {
-                   BracketStack$2[sI++] = i;
-                   BracketStack$2[sI++] = ch;
-                   BracketStack$2[sI++] = context;
-               }
-           }
-           else if ((type = types$2[i]) == 2 /* R */ || type == 1 /* L */) {
-               let embed = type == outerType;
-               context = embed ? 0 : 1 /* OppositeBefore */;
-               for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                   let cur = BracketStack$2[sJ + 2];
-                   if (cur & 2 /* EmbedInside */)
-                       break;
-                   if (embed) {
-                       BracketStack$2[sJ + 2] |= 2 /* EmbedInside */;
-                   }
-                   else {
-                       if (cur & 4 /* OppositeInside */)
-                           break;
-                       BracketStack$2[sJ + 2] |= 4 /* OppositeInside */;
-                   }
-               }
-           }
-       }
-       // N1. A sequence of neutrals takes the direction of the
-       // surrounding strong text if the text on both sides has the same
-       // direction. European and Arabic numbers act as if they were R in
-       // terms of their influence on neutrals. Start-of-level-run (sor)
-       // and end-of-level-run (eor) are used at level run boundaries.
-       // N2. Any remaining neutrals take the embedding direction.
-       // (Left after this: L, R, EN+AN)
-       for (let i = 0; i < len; i++) {
-           if (types$2[i] == 256 /* NI */) {
-               let end = i + 1;
-               while (end < len && types$2[end] == 256 /* NI */)
-                   end++;
-               let beforeL = (i ? types$2[i - 1] : outerType) == 1 /* L */;
-               let afterL = (end < len ? types$2[end] : outerType) == 1 /* L */;
-               let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
-               for (let j = i; j < end; j++)
-                   types$2[j] = replace;
-               i = end - 1;
-           }
-       }
-       // Here we depart from the documented algorithm, in order to avoid
-       // building up an actual levels array. Since there are only three
-       // levels (0, 1, 2) in an implementation that doesn't take
-       // explicit embedding into account, we can build up the order on
-       // the fly, without following the level-based algorithm.
-       let order = [];
-       if (outerType == 1 /* L */) {
-           for (let i = 0; i < len;) {
-               let start = i, rtl = types$2[i++] != 1 /* L */;
-               while (i < len && rtl == (types$2[i] != 1 /* L */))
-                   i++;
-               if (rtl) {
-                   for (let j = i; j > start;) {
-                       let end = j, l = types$2[--j] != 2 /* R */;
-                       while (j > start && l == (types$2[j - 1] != 2 /* R */))
-                           j--;
-                       order.push(new BidiSpan$2(j, end, l ? 2 : 1));
-                   }
-               }
-               else {
-                   order.push(new BidiSpan$2(start, i, 0));
-               }
-           }
-       }
-       else {
-           for (let i = 0; i < len;) {
-               let start = i, rtl = types$2[i++] == 2 /* R */;
-               while (i < len && rtl == (types$2[i] == 2 /* R */))
-                   i++;
-               order.push(new BidiSpan$2(start, i, rtl ? 1 : 2));
-           }
-       }
-       return order;
-   }
-   function trivialOrder$2(length) {
-       return [new BidiSpan$2(0, length, 0)];
-   }
-   let movedOver$2 = "";
-   function moveVisually$2(line, order, dir, start, forward) {
-       var _a;
-       let startIndex = start.head - line.from, spanI = -1;
-       if (startIndex == 0) {
-           if (!forward || !line.length)
-               return null;
-           if (order[0].level != dir) {
-               startIndex = order[0].side(false, dir);
-               spanI = 0;
-           }
-       }
-       else if (startIndex == line.length) {
-           if (forward)
-               return null;
-           let last = order[order.length - 1];
-           if (last.level != dir) {
-               startIndex = last.side(true, dir);
-               spanI = order.length - 1;
-           }
-       }
-       if (spanI < 0)
-           spanI = BidiSpan$2.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
-       let span = order[spanI];
-       // End of span. (But not end of line--that was checked for above.)
-       if (startIndex == span.side(forward, dir)) {
-           span = order[spanI += forward ? 1 : -1];
-           startIndex = span.side(!forward, dir);
-       }
-       let indexForward = forward == (span.dir == dir);
-       let nextIndex = findClusterBreak$3(line.text, startIndex, indexForward);
-       movedOver$2 = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
-       if (nextIndex != span.side(forward, dir))
-           return EditorSelection$2.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);
-       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
-       if (!nextSpan && span.level != dir)
-           return EditorSelection$2.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);
-       if (nextSpan && nextSpan.level < span.level)
-           return EditorSelection$2.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
-       return EditorSelection$2.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
-   }
-
-   const LineBreakPlaceholder$2 = "\uffff";
-   let DOMReader$2 = class DOMReader {
-       constructor(points, state) {
-           this.points = points;
-           this.text = "";
-           this.lineSeparator = state.facet(EditorState$2.lineSeparator);
-       }
-       append(text) {
-           this.text += text;
-       }
-       lineBreak() {
-           this.text += LineBreakPlaceholder$2;
-       }
-       readRange(start, end) {
-           if (!start)
-               return this;
-           let parent = start.parentNode;
-           for (let cur = start;;) {
-               this.findPointBefore(parent, cur);
-               this.readNode(cur);
-               let next = cur.nextSibling;
-               if (next == end)
-                   break;
-               let view = ContentView$2.get(cur), nextView = ContentView$2.get(next);
-               if (view && nextView ? view.breakAfter :
-                   (view ? view.breakAfter : isBlockElement$2(cur)) ||
-                       (isBlockElement$2(next) && (cur.nodeName != "BR" || cur.cmIgnore)))
-                   this.lineBreak();
-               cur = next;
-           }
-           this.findPointBefore(parent, end);
-           return this;
-       }
-       readTextNode(node) {
-           let text = node.nodeValue;
-           for (let point of this.points)
-               if (point.node == node)
-                   point.pos = this.text.length + Math.min(point.offset, text.length);
-           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
-               let nextBreak = -1, breakSize = 1, m;
-               if (this.lineSeparator) {
-                   nextBreak = text.indexOf(this.lineSeparator, off);
-                   breakSize = this.lineSeparator.length;
-               }
-               else if (m = re.exec(text)) {
-                   nextBreak = m.index;
-                   breakSize = m[0].length;
-               }
-               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
-               if (nextBreak < 0)
-                   break;
-               this.lineBreak();
-               if (breakSize > 1)
-                   for (let point of this.points)
-                       if (point.node == node && point.pos > this.text.length)
-                           point.pos -= breakSize - 1;
-               off = nextBreak + breakSize;
-           }
-       }
-       readNode(node) {
-           if (node.cmIgnore)
-               return;
-           let view = ContentView$2.get(node);
-           let fromView = view && view.overrideDOMText;
-           if (fromView != null) {
-               this.findPointInside(node, fromView.length);
-               for (let i = fromView.iter(); !i.next().done;) {
-                   if (i.lineBreak)
-                       this.lineBreak();
-                   else
-                       this.append(i.value);
-               }
-           }
-           else if (node.nodeType == 3) {
-               this.readTextNode(node);
-           }
-           else if (node.nodeName == "BR") {
-               if (node.nextSibling)
-                   this.lineBreak();
-           }
-           else if (node.nodeType == 1) {
-               this.readRange(node.firstChild, null);
-           }
-       }
-       findPointBefore(node, next) {
-           for (let point of this.points)
-               if (point.node == node && node.childNodes[point.offset] == next)
-                   point.pos = this.text.length;
-       }
-       findPointInside(node, maxLen) {
-           for (let point of this.points)
-               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
-                   point.pos = this.text.length + Math.min(maxLen, point.offset);
-       }
-   };
-   function isBlockElement$2(node) {
-       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
-   }
-   let DOMPoint$2 = class DOMPoint {
-       constructor(node, offset) {
-           this.node = node;
-           this.offset = offset;
-           this.pos = -1;
-       }
-   };
-
-   let DocView$2 = class DocView extends ContentView$2 {
-       constructor(view) {
-           super();
-           this.view = view;
-           this.compositionDeco = Decoration$2.none;
-           this.decorations = [];
-           this.dynamicDecorationMap = [];
-           // Track a minimum width for the editor. When measuring sizes in
-           // measureVisibleLineHeights, this is updated to point at the width
-           // of a given element and its extent in the document. When a change
-           // happens in that range, these are reset. That way, once we've seen
-           // a line/element of a given length, we keep the editor wide enough
-           // to fit at least that element, until it is changed, at which point
-           // we forget it again.
-           this.minWidth = 0;
-           this.minWidthFrom = 0;
-           this.minWidthTo = 0;
-           // Track whether the DOM selection was set in a lossy way, so that
-           // we don't mess it up when reading it back it
-           this.impreciseAnchor = null;
-           this.impreciseHead = null;
-           this.forceSelection = false;
-           // Used by the resize observer to ignore resizes that we caused
-           // ourselves
-           this.lastUpdate = Date.now();
-           this.setDOM(view.contentDOM);
-           this.children = [new LineView$2];
-           this.children[0].setParent(this);
-           this.updateDeco();
-           this.updateInner([new ChangedRange$2(0, 0, 0, view.state.doc.length)], 0);
-       }
-       get root() { return this.view.root; }
-       get editorView() { return this.view; }
-       get length() { return this.view.state.doc.length; }
-       // Update the document view to a given state. scrollIntoView can be
-       // used as a hint to compute a new viewport that includes that
-       // position, if we know the editor is going to scroll that position
-       // into view.
-       update(update) {
-           let changedRanges = update.changedRanges;
-           if (this.minWidth > 0 && changedRanges.length) {
-               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
-                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
-               }
-               else {
-                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
-                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
-               }
-           }
-           if (this.view.inputState.composing < 0)
-               this.compositionDeco = Decoration$2.none;
-           else if (update.transactions.length || this.dirty)
-               this.compositionDeco = computeCompositionDeco$1(this.view, update.changes);
-           // When the DOM nodes around the selection are moved to another
-           // parent, Chrome sometimes reports a different selection through
-           // getSelection than the one that it actually shows to the user.
-           // This forces a selection update when lines are joined to work
-           // around that. Issue #54
-           if ((browser$2.ie || browser$2.chrome) && !this.compositionDeco.size && update &&
-               update.state.doc.lines != update.startState.doc.lines)
-               this.forceSelection = true;
-           let prevDeco = this.decorations, deco = this.updateDeco();
-           let decoDiff = findChangedDeco$2(prevDeco, deco, update.changes);
-           changedRanges = ChangedRange$2.extendWithRanges(changedRanges, decoDiff);
-           if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
-               return false;
-           }
-           else {
-               this.updateInner(changedRanges, update.startState.doc.length);
-               if (update.transactions.length)
-                   this.lastUpdate = Date.now();
-               return true;
-           }
-       }
-       // Used by update and the constructor do perform the actual DOM
-       // update
-       updateInner(changes, oldLength) {
-           this.view.viewState.mustMeasureContent = true;
-           this.updateChildren(changes, oldLength);
-           let { observer } = this.view;
-           observer.ignore(() => {
-               // Lock the height during redrawing, since Chrome sometimes
-               // messes with the scroll position during DOM mutation (though
-               // no relayout is triggered and I cannot imagine how it can
-               // recompute the scroll position without a layout)
-               this.dom.style.height = this.view.viewState.contentHeight + "px";
-               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
-               // Chrome will sometimes, when DOM mutations occur directly
-               // around the selection, get confused and report a different
-               // selection from the one it displays (issue #218). This tries
-               // to detect that situation.
-               let track = browser$2.chrome || browser$2.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
-               this.sync(track);
-               this.dirty = 0 /* Not */;
-               if (track && (track.written || observer.selectionRange.focusNode != track.node))
-                   this.forceSelection = true;
-               this.dom.style.height = "";
-           });
-           let gaps = [];
-           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
-               for (let child of this.children)
-                   if (child instanceof BlockWidgetView$2 && child.widget instanceof BlockGapWidget$2)
-                       gaps.push(child.dom);
-           observer.updateGaps(gaps);
-       }
-       updateChildren(changes, oldLength) {
-           let cursor = this.childCursor(oldLength);
-           for (let i = changes.length - 1;; i--) {
-               let next = i >= 0 ? changes[i] : null;
-               if (!next)
-                   break;
-               let { fromA, toA, fromB, toB } = next;
-               let { content, breakAtStart, openStart, openEnd } = ContentBuilder$2.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap);
-               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
-               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
-               replaceRange$2(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
-           }
-       }
-       // Sync the DOM selection to this.state.selection
-       updateSelection(mustRead = false, fromPointer = false) {
-           if (mustRead)
-               this.view.observer.readSelectionRange();
-           if (!(fromPointer || this.mayControlSelection()) ||
-               browser$2.ios && this.view.inputState.rapidCompositionStart)
-               return;
-           let force = this.forceSelection;
-           this.forceSelection = false;
-           let main = this.view.state.selection.main;
-           // FIXME need to handle the case where the selection falls inside a block range
-           let anchor = this.domAtPos(main.anchor);
-           let head = main.empty ? anchor : this.domAtPos(main.head);
-           // Always reset on Firefox when next to an uneditable node to
-           // avoid invisible cursor bugs (#111)
-           if (browser$2.gecko && main.empty && betweenUneditable$2(anchor)) {
-               let dummy = document.createTextNode("");
-               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
-               anchor = head = new DOMPos$2(dummy, 0);
-               force = true;
-           }
-           let domSel = this.view.observer.selectionRange;
-           // If the selection is already here, or in an equivalent position, don't touch it
-           if (force || !domSel.focusNode ||
-               !isEquivalentPosition$2(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
-               !isEquivalentPosition$2(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
-               this.view.observer.ignore(() => {
-                   // Chrome Android will hide the virtual keyboard when tapping
-                   // inside an uneditable node, and not bring it back when we
-                   // move the cursor to its proper position. This tries to
-                   // restore the keyboard by cycling focus.
-                   if (browser$2.android && browser$2.chrome && this.dom.contains(domSel.focusNode) &&
-                       inUneditable$2(domSel.focusNode, this.dom)) {
-                       this.dom.blur();
-                       this.dom.focus({ preventScroll: true });
-                   }
-                   let rawSel = getSelection$2(this.root);
-                   if (main.empty) {
-                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
-                       if (browser$2.gecko) {
-                           let nextTo = nextToUneditable$2(anchor.node, anchor.offset);
-                           if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
-                               let text = nearbyTextNode$1(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
-                               if (text)
-                                   anchor = new DOMPos$2(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
-                           }
-                       }
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       if (main.bidiLevel != null && domSel.cursorBidiLevel != null)
-                           domSel.cursorBidiLevel = main.bidiLevel;
-                   }
-                   else if (rawSel.extend) {
-                       // Selection.extend can be used to create an 'inverted' selection
-                       // (one where the focus is before the anchor), but not all
-                       // browsers support it yet.
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       rawSel.extend(head.node, head.offset);
-                   }
-                   else {
-                       // Primitive (IE) way
-                       let range = document.createRange();
-                       if (main.anchor > main.head)
-                           [anchor, head] = [head, anchor];
-                       range.setEnd(head.node, head.offset);
-                       range.setStart(anchor.node, anchor.offset);
-                       rawSel.removeAllRanges();
-                       rawSel.addRange(range);
-                   }
-               });
-               this.view.observer.setSelectionRange(anchor, head);
-           }
-           this.impreciseAnchor = anchor.precise ? null : new DOMPos$2(domSel.anchorNode, domSel.anchorOffset);
-           this.impreciseHead = head.precise ? null : new DOMPos$2(domSel.focusNode, domSel.focusOffset);
-       }
-       enforceCursorAssoc() {
-           if (this.compositionDeco.size)
-               return;
-           let cursor = this.view.state.selection.main;
-           let sel = getSelection$2(this.root);
-           if (!cursor.empty || !cursor.assoc || !sel.modify)
-               return;
-           let line = LineView$2.find(this, cursor.head);
-           if (!line)
-               return;
-           let lineStart = line.posAtStart;
-           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
-               return;
-           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
-           if (!before || !after || before.bottom > after.top)
-               return;
-           let dom = this.domAtPos(cursor.head + cursor.assoc);
-           sel.collapse(dom.node, dom.offset);
-           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
-       }
-       mayControlSelection() {
-           return this.view.state.facet(editable$2) ? this.root.activeElement == this.dom
-               : hasSelection$2(this.dom, this.view.observer.selectionRange);
-       }
-       nearest(dom) {
-           for (let cur = dom; cur;) {
-               let domView = ContentView$2.get(cur);
-               if (domView && domView.rootView == this)
-                   return domView;
-               cur = cur.parentNode;
-           }
-           return null;
-       }
-       posFromDOM(node, offset) {
-           let view = this.nearest(node);
-           if (!view)
-               throw new RangeError("Trying to find position for a DOM position outside of the document");
-           return view.localPosFromDOM(node, offset) + view.posAtStart;
-       }
-       domAtPos(pos) {
-           let { i, off } = this.childCursor().findPos(pos, -1);
-           for (; i < this.children.length - 1;) {
-               let child = this.children[i];
-               if (off < child.length || child instanceof LineView$2)
-                   break;
-               i++;
-               off = 0;
-           }
-           return this.children[i].domAtPos(off);
-       }
-       coordsAt(pos, side) {
-           for (let off = this.length, i = this.children.length - 1;; i--) {
-               let child = this.children[i], start = off - child.breakAfter - child.length;
-               if (pos > start ||
-                   (pos == start && child.type != BlockType$2.WidgetBefore && child.type != BlockType$2.WidgetAfter &&
-                       (!i || side == 2 || this.children[i - 1].breakAfter ||
-                           (this.children[i - 1].type == BlockType$2.WidgetBefore && side > -2))))
-                   return child.coordsAt(pos - start, side);
-               off = start;
-           }
-       }
-       measureVisibleLineHeights(viewport) {
-           let result = [], { from, to } = viewport;
-           let contentWidth = this.view.contentDOM.clientWidth;
-           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
-           let widest = -1, ltr = this.view.textDirection == Direction$2.LTR;
-           for (let pos = 0, i = 0; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (end > to)
-                   break;
-               if (pos >= from) {
-                   let childRect = child.dom.getBoundingClientRect();
-                   result.push(childRect.height);
-                   if (isWider) {
-                       let last = child.dom.lastChild;
-                       let rects = last ? clientRectsFor$2(last) : [];
-                       if (rects.length) {
-                           let rect = rects[rects.length - 1];
-                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
-                           if (width > widest) {
-                               widest = width;
-                               this.minWidth = contentWidth;
-                               this.minWidthFrom = pos;
-                               this.minWidthTo = end;
-                           }
-                       }
-                   }
-               }
-               pos = end + child.breakAfter;
-           }
-           return result;
-       }
-       textDirectionAt(pos) {
-           let { i } = this.childPos(pos, 1);
-           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction$2.RTL : Direction$2.LTR;
-       }
-       measureTextSize() {
-           for (let child of this.children) {
-               if (child instanceof LineView$2) {
-                   let measure = child.measureTextSize();
-                   if (measure)
-                       return measure;
-               }
-           }
-           // If no workable line exists, force a layout of a measurable element
-           let dummy = document.createElement("div"), lineHeight, charWidth;
-           dummy.className = "cm-line";
-           dummy.textContent = "abc def ghi jkl mno pqr stu";
-           this.view.observer.ignore(() => {
-               this.dom.appendChild(dummy);
-               let rect = clientRectsFor$2(dummy.firstChild)[0];
-               lineHeight = dummy.getBoundingClientRect().height;
-               charWidth = rect ? rect.width / 27 : 7;
-               dummy.remove();
-           });
-           return { lineHeight, charWidth };
-       }
-       childCursor(pos = this.length) {
-           // Move back to start of last element when possible, so that
-           // `ChildCursor.findPos` doesn't have to deal with the edge case
-           // of being after the last element.
-           let i = this.children.length;
-           if (i)
-               pos -= this.children[--i].length;
-           return new ChildCursor$2(this.children, pos, i);
-       }
-       computeBlockGapDeco() {
-           let deco = [], vs = this.view.viewState;
-           for (let pos = 0, i = 0;; i++) {
-               let next = i == vs.viewports.length ? null : vs.viewports[i];
-               let end = next ? next.from - 1 : this.length;
-               if (end > pos) {
-                   let height = vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top;
-                   deco.push(Decoration$2.replace({
-                       widget: new BlockGapWidget$2(height),
-                       block: true,
-                       inclusive: true,
-                       isBlockGap: true,
-                   }).range(pos, end));
-               }
-               if (!next)
-                   break;
-               pos = next.to + 1;
-           }
-           return Decoration$2.set(deco);
-       }
-       updateDeco() {
-           let allDeco = this.view.state.facet(decorations$2).map((d, i) => {
-               let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
-               return dynamic ? d(this.view) : d;
-           });
-           for (let i = allDeco.length; i < allDeco.length + 3; i++)
-               this.dynamicDecorationMap[i] = false;
-           return this.decorations = [
-               ...allDeco,
-               this.compositionDeco,
-               this.computeBlockGapDeco(),
-               this.view.viewState.lineGapDeco
-           ];
-       }
-       scrollIntoView(target) {
-           let { range } = target;
-           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
-           if (!rect)
-               return;
-           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
-               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
-                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
-           let mLeft = 0, mRight = 0, mTop = 0, mBottom = 0;
-           for (let margins of this.view.state.facet(scrollMargins$2).map(f => f(this.view)))
-               if (margins) {
-                   let { left, right, top, bottom } = margins;
-                   if (left != null)
-                       mLeft = Math.max(mLeft, left);
-                   if (right != null)
-                       mRight = Math.max(mRight, right);
-                   if (top != null)
-                       mTop = Math.max(mTop, top);
-                   if (bottom != null)
-                       mBottom = Math.max(mBottom, bottom);
-               }
-           let targetRect = {
-               left: rect.left - mLeft, top: rect.top - mTop,
-               right: rect.right + mRight, bottom: rect.bottom + mBottom
-           };
-           scrollRectIntoView$2(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction$2.LTR);
-       }
-   };
-   function betweenUneditable$2(pos) {
-       return pos.node.nodeType == 1 && pos.node.firstChild &&
-           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
-           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
-   }
-   let BlockGapWidget$2 = class BlockGapWidget extends WidgetType$2 {
-       constructor(height) {
-           super();
-           this.height = height;
-       }
-       toDOM() {
-           let elt = document.createElement("div");
-           this.updateDOM(elt);
-           return elt;
-       }
-       eq(other) { return other.height == this.height; }
-       updateDOM(elt) {
-           elt.style.height = this.height + "px";
-           return true;
-       }
-       get estimatedHeight() { return this.height; }
-   };
-   function compositionSurroundingNode$1(view) {
-       let sel = view.observer.selectionRange;
-       let textNode = sel.focusNode && nearbyTextNode$1(sel.focusNode, sel.focusOffset, 0);
-       if (!textNode)
-           return null;
-       let cView = view.docView.nearest(textNode);
-       if (!cView)
-           return null;
-       if (cView instanceof LineView$2) {
-           let topNode = textNode;
-           while (topNode.parentNode != cView.dom)
-               topNode = topNode.parentNode;
-           let prev = topNode.previousSibling;
-           while (prev && !ContentView$2.get(prev))
-               prev = prev.previousSibling;
-           let pos = prev ? ContentView$2.get(prev).posAtEnd : cView.posAtStart;
-           return { from: pos, to: pos, node: topNode, text: textNode };
-       }
-       else {
-           for (;;) {
-               let { parent } = cView;
-               if (!parent)
-                   return null;
-               if (parent instanceof LineView$2)
-                   break;
-               cView = parent;
-           }
-           let from = cView.posAtStart;
-           return { from, to: from + cView.length, node: cView.dom, text: textNode };
-       }
-   }
-   function computeCompositionDeco$1(view, changes) {
-       let surrounding = compositionSurroundingNode$1(view);
-       if (!surrounding)
-           return Decoration$2.none;
-       let { from, to, node, text: textNode } = surrounding;
-       let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
-       let { state } = view, text = node.nodeType == 3 ? node.nodeValue :
-           new DOMReader$2([], state).readRange(node.firstChild, null).text;
-       if (newTo - newFrom < text.length) {
-           if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder$2) == text)
-               newTo = newFrom + text.length;
-           else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder$2) == text)
-               newFrom = newTo - text.length;
-           else
-               return Decoration$2.none;
-       }
-       else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder$2) != text) {
-           return Decoration$2.none;
-       }
-       let topView = ContentView$2.get(node);
-       if (topView instanceof CompositionView$1)
-           topView = topView.widget.topView;
-       else if (topView)
-           topView.parent = null;
-       return Decoration$2.set(Decoration$2.replace({ widget: new CompositionWidget$1(node, textNode, topView), inclusive: true })
-           .range(newFrom, newTo));
-   }
-   let CompositionWidget$1 = class CompositionWidget extends WidgetType$2 {
-       constructor(top, text, topView) {
-           super();
-           this.top = top;
-           this.text = text;
-           this.topView = topView;
-       }
-       eq(other) { return this.top == other.top && this.text == other.text; }
-       toDOM() { return this.top; }
-       ignoreEvent() { return false; }
-       get customView() { return CompositionView$1; }
-   };
-   function nearbyTextNode$1(node, offset, side) {
-       for (;;) {
-           if (node.nodeType == 3)
-               return node;
-           if (node.nodeType == 1 && offset > 0 && side <= 0) {
-               node = node.childNodes[offset - 1];
-               offset = maxOffset$2(node);
-           }
-           else if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {
-               node = node.childNodes[offset];
-               offset = 0;
-           }
-           else {
-               return null;
-           }
-       }
-   }
-   function nextToUneditable$2(node, offset) {
-       if (node.nodeType != 1)
-           return 0;
-       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
-           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
-   }
-   let DecorationComparator$1$2 = class DecorationComparator$1 {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange(from, to) { addRange$2(from, to, this.changes); }
-       comparePoint(from, to) { addRange$2(from, to, this.changes); }
-   };
-   function findChangedDeco$2(a, b, diff) {
-       let comp = new DecorationComparator$1$2;
-       RangeSet$2.compare(a, b, diff, comp);
-       return comp.changes;
-   }
-   function inUneditable$2(node, inside) {
-       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
-           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
-               return true;
-           }
-       }
-       return false;
-   }
-
-   function groupAt$2(state, pos, bias = 1) {
-       let categorize = state.charCategorizer(pos);
-       let line = state.doc.lineAt(pos), linePos = pos - line.from;
-       if (line.length == 0)
-           return EditorSelection$2.cursor(pos);
-       if (linePos == 0)
-           bias = 1;
-       else if (linePos == line.length)
-           bias = -1;
-       let from = linePos, to = linePos;
-       if (bias < 0)
-           from = findClusterBreak$3(line.text, linePos, false);
-       else
-           to = findClusterBreak$3(line.text, linePos);
-       let cat = categorize(line.text.slice(from, to));
-       while (from > 0) {
-           let prev = findClusterBreak$3(line.text, from, false);
-           if (categorize(line.text.slice(prev, from)) != cat)
-               break;
-           from = prev;
-       }
-       while (to < line.length) {
-           let next = findClusterBreak$3(line.text, to);
-           if (categorize(line.text.slice(to, next)) != cat)
-               break;
-           to = next;
-       }
-       return EditorSelection$2.range(from + line.from, to + line.from);
-   }
-   // Search the DOM for the {node, offset} position closest to the given
-   // coordinates. Very inefficient and crude, but can usually be avoided
-   // by calling caret(Position|Range)FromPoint instead.
-   function getdx$2(x, rect) {
-       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
-   }
-   function getdy$2(y, rect) {
-       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
-   }
-   function yOverlap$2(a, b) {
-       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
-   }
-   function upTop$2(rect, top) {
-       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
-   }
-   function upBot$2(rect, bottom) {
-       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
-   }
-   function domPosAtCoords$2(parent, x, y) {
-       let closest, closestRect, closestX, closestY;
-       let above, below, aboveRect, belowRect;
-       for (let child = parent.firstChild; child; child = child.nextSibling) {
-           let rects = clientRectsFor$2(child);
-           for (let i = 0; i < rects.length; i++) {
-               let rect = rects[i];
-               if (closestRect && yOverlap$2(closestRect, rect))
-                   rect = upTop$2(upBot$2(rect, closestRect.bottom), closestRect.top);
-               let dx = getdx$2(x, rect), dy = getdy$2(y, rect);
-               if (dx == 0 && dy == 0)
-                   return child.nodeType == 3 ? domPosInText$2(child, x, y) : domPosAtCoords$2(child, x, y);
-               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
-                   closest = child;
-                   closestRect = rect;
-                   closestX = dx;
-                   closestY = dy;
-               }
-               if (dx == 0) {
-                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
-                       above = child;
-                       aboveRect = rect;
-                   }
-                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
-                       below = child;
-                       belowRect = rect;
-                   }
-               }
-               else if (aboveRect && yOverlap$2(aboveRect, rect)) {
-                   aboveRect = upBot$2(aboveRect, rect.bottom);
-               }
-               else if (belowRect && yOverlap$2(belowRect, rect)) {
-                   belowRect = upTop$2(belowRect, rect.top);
-               }
-           }
-       }
-       if (aboveRect && aboveRect.bottom >= y) {
-           closest = above;
-           closestRect = aboveRect;
-       }
-       else if (belowRect && belowRect.top <= y) {
-           closest = below;
-           closestRect = belowRect;
-       }
-       if (!closest)
-           return { node: parent, offset: 0 };
-       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
-       if (closest.nodeType == 3)
-           return domPosInText$2(closest, clipX, y);
-       if (!closestX && closest.contentEditable == "true")
-           return domPosAtCoords$2(closest, clipX, y);
-       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
-           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
-       return { node: parent, offset };
-   }
-   function domPosInText$2(node, x, y) {
-       let len = node.nodeValue.length;
-       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
-       for (let i = 0; i < len; i++) {
-           let rects = textRange$2(node, i, i + 1).getClientRects();
-           for (let j = 0; j < rects.length; j++) {
-               let rect = rects[j];
-               if (rect.top == rect.bottom)
-                   continue;
-               if (!generalSide)
-                   generalSide = x - rect.left;
-               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
-               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
-                   let right = x >= (rect.left + rect.right) / 2, after = right;
-                   if (browser$2.chrome || browser$2.gecko) {
-                       // Check for RTL on browsers that support getting client
-                       // rects for empty ranges.
-                       let rectBefore = textRange$2(node, i).getBoundingClientRect();
-                       if (rectBefore.left == rect.right)
-                           after = !right;
-                   }
-                   if (dy <= 0)
-                       return { node, offset: i + (after ? 1 : 0) };
-                   closestOffset = i + (after ? 1 : 0);
-                   closestDY = dy;
-               }
-           }
-       }
-       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
-   }
-   function posAtCoords$2(view, { x, y }, precise, bias = -1) {
-       var _a;
-       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
-       let block, { docHeight } = view.viewState;
-       let yOffset = y - docTop;
-       if (yOffset < 0)
-           return 0;
-       if (yOffset > docHeight)
-           return view.state.doc.length;
-       // Scan for a text block near the queried y position
-       for (let halfLine = view.defaultLineHeight / 2, bounced = false;;) {
-           block = view.elementAtHeight(yOffset);
-           if (block.type == BlockType$2.Text)
-               break;
-           for (;;) {
-               // Move the y position out of this block
-               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
-               if (yOffset >= 0 && yOffset <= docHeight)
-                   break;
-               // If the document consists entirely of replaced widgets, we
-               // won't find a text block, so return 0
-               if (bounced)
-                   return precise ? null : 0;
-               bounced = true;
-               bias = -bias;
-           }
-       }
-       y = docTop + yOffset;
-       let lineStart = block.from;
-       // If this is outside of the rendered viewport, we can't determine a position
-       if (lineStart < view.viewport.from)
-           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise$2(view, content, block, x, y);
-       if (lineStart > view.viewport.to)
-           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
-               precise ? null : posAtCoordsImprecise$2(view, content, block, x, y);
-       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
-       let doc = view.dom.ownerDocument;
-       let root = view.root.elementFromPoint ? view.root : doc;
-       let element = root.elementFromPoint(x, y);
-       if (element && !view.contentDOM.contains(element))
-           element = null;
-       // If the element is unexpected, clip x at the sides of the content area and try again
-       if (!element) {
-           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
-           element = root.elementFromPoint(x, y);
-           if (element && !view.contentDOM.contains(element))
-               element = null;
-       }
-       // There's visible editor content under the point, so we can try
-       // using caret(Position|Range)FromPoint as a shortcut
-       let node, offset = -1;
-       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
-           if (doc.caretPositionFromPoint) {
-               let pos = doc.caretPositionFromPoint(x, y);
-               if (pos)
-                   ({ offsetNode: node, offset } = pos);
-           }
-           else if (doc.caretRangeFromPoint) {
-               let range = doc.caretRangeFromPoint(x, y);
-               if (range) {
-                   ({ startContainer: node, startOffset: offset } = range);
-                   if (browser$2.safari && isSuspiciousCaretResult$1(node, offset, x))
-                       node = undefined;
-               }
-           }
-       }
-       // No luck, do our own (potentially expensive) search
-       if (!node || !view.docView.dom.contains(node)) {
-           let line = LineView$2.find(view.docView, lineStart);
-           if (!line)
-               return yOffset > block.top + block.height / 2 ? block.to : block.from;
-           ({ node, offset } = domPosAtCoords$2(line.dom, x, y));
-       }
-       return view.docView.posFromDOM(node, offset);
-   }
-   function posAtCoordsImprecise$2(view, contentRect, block, x, y) {
-       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
-       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
-           let line = Math.floor((y - block.top) / view.defaultLineHeight);
-           into += line * view.viewState.heightOracle.lineLength;
-       }
-       let content = view.state.sliceDoc(block.from, block.to);
-       return block.from + findColumn$2(content, into, view.state.tabSize);
-   }
-   // In case of a high line height, Safari's caretRangeFromPoint treats
-   // the space between lines as belonging to the last character of the
-   // line before. This is used to detect such a result so that it can be
-   // ignored (issue #401).
-   function isSuspiciousCaretResult$1(node, offset, x) {
-       let len;
-       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
-           return false;
-       for (let next = node.nextSibling; next; next = next.nextSibling)
-           if (next.nodeType != 1 || next.nodeName != "BR")
-               return false;
-       return textRange$2(node, len - 1, len).getBoundingClientRect().left > x;
-   }
-   function moveToLineBoundary$2(view, start, forward, includeWrap) {
-       let line = view.state.doc.lineAt(start.head);
-       let coords = !includeWrap || !view.lineWrapping ? null
-           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
-       if (coords) {
-           let editorRect = view.dom.getBoundingClientRect();
-           let direction = view.textDirectionAt(line.from);
-           let pos = view.posAtCoords({ x: forward == (direction == Direction$2.LTR) ? editorRect.right - 1 : editorRect.left + 1,
-               y: (coords.top + coords.bottom) / 2 });
-           if (pos != null)
-               return EditorSelection$2.cursor(pos, forward ? -1 : 1);
-       }
-       let lineView = LineView$2.find(view.docView, start.head);
-       let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
-       return EditorSelection$2.cursor(end, forward ? -1 : 1);
-   }
-   function moveByChar$2(view, start, forward, by) {
-       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
-       let direction = view.textDirectionAt(line.from);
-       for (let cur = start, check = null;;) {
-           let next = moveVisually$2(line, spans, direction, cur, forward), char = movedOver$2;
-           if (!next) {
-               if (line.number == (forward ? view.state.doc.lines : 1))
-                   return cur;
-               char = "\n";
-               line = view.state.doc.line(line.number + (forward ? 1 : -1));
-               spans = view.bidiSpans(line);
-               next = EditorSelection$2.cursor(forward ? line.from : line.to);
-           }
-           if (!check) {
-               if (!by)
-                   return next;
-               check = by(char);
-           }
-           else if (!check(char)) {
-               return cur;
-           }
-           cur = next;
-       }
-   }
-   function byGroup$2(view, pos, start) {
-       let categorize = view.state.charCategorizer(pos);
-       let cat = categorize(start);
-       return (next) => {
-           let nextCat = categorize(next);
-           if (cat == CharCategory$2.Space)
-               cat = nextCat;
-           return cat == nextCat;
-       };
-   }
-   function moveVertically$2(view, start, forward, distance) {
-       let startPos = start.head, dir = forward ? 1 : -1;
-       if (startPos == (forward ? view.state.doc.length : 0))
-           return EditorSelection$2.cursor(startPos, start.assoc);
-       let goal = start.goalColumn, startY;
-       let rect = view.contentDOM.getBoundingClientRect();
-       let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;
-       if (startCoords) {
-           if (goal == null)
-               goal = startCoords.left - rect.left;
-           startY = dir < 0 ? startCoords.top : startCoords.bottom;
-       }
-       else {
-           let line = view.viewState.lineBlockAt(startPos);
-           if (goal == null)
-               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
-           startY = (dir < 0 ? line.top : line.bottom) + docTop;
-       }
-       let resolvedGoal = rect.left + goal;
-       let dist = distance !== null && distance !== void 0 ? distance : (view.defaultLineHeight >> 1);
-       for (let extra = 0;; extra += 10) {
-           let curY = startY + (dist + extra) * dir;
-           let pos = posAtCoords$2(view, { x: resolvedGoal, y: curY }, false, dir);
-           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))
-               return EditorSelection$2.cursor(pos, start.assoc, undefined, goal);
-       }
-   }
-   function skipAtoms$2(view, oldPos, pos) {
-       let atoms = view.state.facet(atomicRanges$2).map(f => f(view));
-       for (;;) {
-           let moved = false;
-           for (let set of atoms) {
-               set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
-                   if (pos.from > from && pos.from < to) {
-                       pos = oldPos.from > pos.from ? EditorSelection$2.cursor(from, 1) : EditorSelection$2.cursor(to, -1);
-                       moved = true;
-                   }
-               });
-           }
-           if (!moved)
-               return pos;
-       }
-   }
-
-   // This will also be where dragging info and such goes
-   let InputState$2 = class InputState {
-       constructor(view) {
-           this.lastKeyCode = 0;
-           this.lastKeyTime = 0;
-           this.chromeScrollHack = -1;
-           // On iOS, some keys need to have their default behavior happen
-           // (after which we retroactively handle them and reset the DOM) to
-           // avoid messing up the virtual keyboard state.
-           this.pendingIOSKey = undefined;
-           this.lastSelectionOrigin = null;
-           this.lastSelectionTime = 0;
-           this.lastEscPress = 0;
-           this.lastContextMenu = 0;
-           this.scrollHandlers = [];
-           this.registeredEvents = [];
-           this.customHandlers = [];
-           // -1 means not in a composition. Otherwise, this counts the number
-           // of changes made during the composition. The count is used to
-           // avoid treating the start state of the composition, before any
-           // changes have been made, as part of the composition.
-           this.composing = -1;
-           // Tracks whether the next change should be marked as starting the
-           // composition (null means no composition, true means next is the
-           // first, false means first has already been marked for this
-           // composition)
-           this.compositionFirstChange = null;
-           this.compositionEndedAt = 0;
-           this.rapidCompositionStart = false;
-           this.mouseSelection = null;
-           for (let type in handlers$2) {
-               let handler = handlers$2[type];
-               view.contentDOM.addEventListener(type, (event) => {
-                   if (!eventBelongsToEditor$2(view, event) || this.ignoreDuringComposition(event))
-                       return;
-                   if (type == "keydown" && this.keydown(view, event))
-                       return;
-                   if (this.mustFlushObserver(event))
-                       view.observer.forceFlush();
-                   if (this.runCustomHandlers(type, view, event))
-                       event.preventDefault();
-                   else
-                       handler(view, event);
-               });
-               this.registeredEvents.push(type);
-           }
-           if (browser$2.chrome && browser$2.chrome_version >= 102) {
-               // On Chrome 102, viewport updates somehow stop wheel-based
-               // scrolling. Turning off pointer events during the scroll seems
-               // to avoid the issue.
-               view.scrollDOM.addEventListener("wheel", () => {
-                   if (this.chromeScrollHack < 0)
-                       view.contentDOM.style.pointerEvents = "none";
-                   else
-                       window.clearTimeout(this.chromeScrollHack);
-                   this.chromeScrollHack = setTimeout(() => {
-                       this.chromeScrollHack = -1;
-                       view.contentDOM.style.pointerEvents = "";
-                   }, 100);
-               }, { passive: true });
-           }
-           this.notifiedFocused = view.hasFocus;
-           // On Safari adding an input event handler somehow prevents an
-           // issue where the composition vanishes when you press enter.
-           if (browser$2.safari)
-               view.contentDOM.addEventListener("input", () => null);
-       }
-       setSelectionOrigin(origin) {
-           this.lastSelectionOrigin = origin;
-           this.lastSelectionTime = Date.now();
-       }
-       ensureHandlers(view, plugins) {
-           var _a;
-           let handlers;
-           this.customHandlers = [];
-           for (let plugin of plugins)
-               if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {
-                   this.customHandlers.push({ plugin: plugin.value, handlers });
-                   for (let type in handlers)
-                       if (this.registeredEvents.indexOf(type) < 0 && type != "scroll") {
-                           this.registeredEvents.push(type);
-                           view.contentDOM.addEventListener(type, (event) => {
-                               if (!eventBelongsToEditor$2(view, event))
-                                   return;
-                               if (this.runCustomHandlers(type, view, event))
-                                   event.preventDefault();
-                           });
-                       }
-               }
-       }
-       runCustomHandlers(type, view, event) {
-           for (let set of this.customHandlers) {
-               let handler = set.handlers[type];
-               if (handler) {
-                   try {
-                       if (handler.call(set.plugin, event, view) || event.defaultPrevented)
-                           return true;
-                   }
-                   catch (e) {
-                       logException$2(view.state, e);
-                   }
-               }
-           }
-           return false;
-       }
-       runScrollHandlers(view, event) {
-           for (let set of this.customHandlers) {
-               let handler = set.handlers.scroll;
-               if (handler) {
-                   try {
-                       handler.call(set.plugin, event, view);
-                   }
-                   catch (e) {
-                       logException$2(view.state, e);
-                   }
-               }
-           }
-       }
-       keydown(view, event) {
-           // Must always run, even if a custom handler handled the event
-           this.lastKeyCode = event.keyCode;
-           this.lastKeyTime = Date.now();
-           if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
-               return true;
-           // Chrome for Android usually doesn't fire proper key events, but
-           // occasionally does, usually surrounded by a bunch of complicated
-           // composition changes. When an enter or backspace key event is
-           // seen, hold off on handling DOM events for a bit, and then
-           // dispatch it.
-           if (browser$2.android && browser$2.chrome && !event.synthetic &&
-               (event.keyCode == 13 || event.keyCode == 8)) {
-               view.observer.delayAndroidKey(event.key, event.keyCode);
-               return true;
-           }
-           // Prevent the default behavior of Enter on iOS makes the
-           // virtual keyboard get stuck in the wrong (lowercase)
-           // state. So we let it go through, and then, in
-           // applyDOMChange, notify key handlers of it and reset to
-           // the state they produce.
-           let pending;
-           if (browser$2.ios && (pending = PendingKeys$2.find(key => key.keyCode == event.keyCode)) &&
-               !(event.ctrlKey || event.altKey || event.metaKey) && !event.synthetic) {
-               this.pendingIOSKey = pending;
-               setTimeout(() => this.flushIOSKey(view), 250);
-               return true;
-           }
-           return false;
-       }
-       flushIOSKey(view) {
-           let key = this.pendingIOSKey;
-           if (!key)
-               return false;
-           this.pendingIOSKey = undefined;
-           return dispatchKey$2(view.contentDOM, key.key, key.keyCode);
-       }
-       ignoreDuringComposition(event) {
-           if (!/^key/.test(event.type))
-               return false;
-           if (this.composing > 0)
-               return true;
-           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
-           // On some input method editors (IMEs), the Enter key is used to
-           // confirm character selection. On Safari, when Enter is pressed,
-           // compositionend and keydown events are sometimes emitted in the
-           // wrong order. The key event should still be ignored, even when
-           // it happens after the compositionend event.
-           if (browser$2.safari && Date.now() - this.compositionEndedAt < 100) {
-               this.compositionEndedAt = 0;
-               return true;
-           }
-           return false;
-       }
-       mustFlushObserver(event) {
-           return (event.type == "keydown" && event.keyCode != 229) ||
-               event.type == "compositionend" && !browser$2.ios;
-       }
-       startMouseSelection(mouseSelection) {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-           this.mouseSelection = mouseSelection;
-       }
-       update(update) {
-           if (this.mouseSelection)
-               this.mouseSelection.update(update);
-           if (update.transactions.length)
-               this.lastKeyCode = this.lastSelectionTime = 0;
-       }
-       destroy() {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-       }
-   };
-   const PendingKeys$2 = [
-       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
-       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
-       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
-   ];
-   // Key codes for modifier keys
-   const modifierCodes$2 = [16, 17, 18, 20, 91, 92, 224, 225];
-   let MouseSelection$2 = class MouseSelection {
-       constructor(view, startEvent, style, mustSelect) {
-           this.view = view;
-           this.style = style;
-           this.mustSelect = mustSelect;
-           this.lastEvent = startEvent;
-           let doc = view.contentDOM.ownerDocument;
-           doc.addEventListener("mousemove", this.move = this.move.bind(this));
-           doc.addEventListener("mouseup", this.up = this.up.bind(this));
-           this.extend = startEvent.shiftKey;
-           this.multiple = view.state.facet(EditorState$2.allowMultipleSelections) && addsSelectionRange$2(view, startEvent);
-           this.dragMove = dragMovesSelection$3(view, startEvent);
-           this.dragging = isInPrimarySelection$2(view, startEvent) && getClickType$2(startEvent) == 1 ? null : false;
-           // When clicking outside of the selection, immediately apply the
-           // effect of starting the selection
-           if (this.dragging === false) {
-               startEvent.preventDefault();
-               this.select(startEvent);
-           }
-       }
-       move(event) {
-           if (event.buttons == 0)
-               return this.destroy();
-           if (this.dragging !== false)
-               return;
-           this.select(this.lastEvent = event);
-       }
-       up(event) {
-           if (this.dragging == null)
-               this.select(this.lastEvent);
-           if (!this.dragging)
-               event.preventDefault();
-           this.destroy();
-       }
-       destroy() {
-           let doc = this.view.contentDOM.ownerDocument;
-           doc.removeEventListener("mousemove", this.move);
-           doc.removeEventListener("mouseup", this.up);
-           this.view.inputState.mouseSelection = null;
-       }
-       select(event) {
-           let selection = this.style.get(event, this.extend, this.multiple);
-           if (this.mustSelect || !selection.eq(this.view.state.selection) ||
-               selection.main.assoc != this.view.state.selection.main.assoc)
-               this.view.dispatch({
-                   selection,
-                   userEvent: "select.pointer",
-                   scrollIntoView: true
-               });
-           this.mustSelect = false;
-       }
-       update(update) {
-           if (update.docChanged && this.dragging)
-               this.dragging = this.dragging.map(update.changes);
-           if (this.style.update(update))
-               setTimeout(() => this.select(this.lastEvent), 20);
-       }
-   };
-   function addsSelectionRange$2(view, event) {
-       let facet = view.state.facet(clickAddsSelectionRange$2);
-       return facet.length ? facet[0](event) : browser$2.mac ? event.metaKey : event.ctrlKey;
-   }
-   function dragMovesSelection$3(view, event) {
-       let facet = view.state.facet(dragMovesSelection$1$2);
-       return facet.length ? facet[0](event) : browser$2.mac ? !event.altKey : !event.ctrlKey;
-   }
-   function isInPrimarySelection$2(view, event) {
-       let { main } = view.state.selection;
-       if (main.empty)
-           return false;
-       // On boundary clicks, check whether the coordinates are inside the
-       // selection's client rectangles
-       let sel = getSelection$2(view.root);
-       if (sel.rangeCount == 0)
-           return true;
-       let rects = sel.getRangeAt(0).getClientRects();
-       for (let i = 0; i < rects.length; i++) {
-           let rect = rects[i];
-           if (rect.left <= event.clientX && rect.right >= event.clientX &&
-               rect.top <= event.clientY && rect.bottom >= event.clientY)
-               return true;
-       }
-       return false;
-   }
-   function eventBelongsToEditor$2(view, event) {
-       if (!event.bubbles)
-           return true;
-       if (event.defaultPrevented)
-           return false;
-       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
-           if (!node || node.nodeType == 11 || ((cView = ContentView$2.get(node)) && cView.ignoreEvent(event)))
-               return false;
-       return true;
-   }
-   const handlers$2 = /*@__PURE__*/Object.create(null);
-   // This is very crude, but unfortunately both these browsers _pretend_
-   // that they have a clipboard API—all the objects and methods are
-   // there, they just don't work, and they are hard to test.
-   const brokenClipboardAPI$2 = (browser$2.ie && browser$2.ie_version < 15) ||
-       (browser$2.ios && browser$2.webkit_version < 604);
-   function capturePaste$2(view) {
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.focus();
-       setTimeout(() => {
-           view.focus();
-           target.remove();
-           doPaste$2(view, target.value);
-       }, 50);
-   }
-   function doPaste$2(view, input) {
-       let { state } = view, changes, i = 1, text = state.toText(input);
-       let byLine = text.lines == state.selection.ranges.length;
-       let linewise = lastLinewiseCopy$2 != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy$2 == text.toString();
-       if (linewise) {
-           let lastLine = -1;
-           changes = state.changeByRange(range => {
-               let line = state.doc.lineAt(range.from);
-               if (line.from == lastLine)
-                   return { range };
-               lastLine = line.from;
-               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
-               return { changes: { from: line.from, insert },
-                   range: EditorSelection$2.cursor(range.from + insert.length) };
-           });
-       }
-       else if (byLine) {
-           changes = state.changeByRange(range => {
-               let line = text.line(i++);
-               return { changes: { from: range.from, to: range.to, insert: line.text },
-                   range: EditorSelection$2.cursor(range.from + line.length) };
-           });
-       }
-       else {
-           changes = state.replaceSelection(text);
-       }
-       view.dispatch(changes, {
-           userEvent: "input.paste",
-           scrollIntoView: true
-       });
-   }
-   handlers$2.keydown = (view, event) => {
-       view.inputState.setSelectionOrigin("select");
-       if (event.keyCode == 27)
-           view.inputState.lastEscPress = Date.now();
-       else if (modifierCodes$2.indexOf(event.keyCode) < 0)
-           view.inputState.lastEscPress = 0;
-   };
-   let lastTouch$1 = 0;
-   handlers$2.touchstart = (view, e) => {
-       lastTouch$1 = Date.now();
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   handlers$2.touchmove = view => {
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   handlers$2.mousedown = (view, event) => {
-       view.observer.flush();
-       if (lastTouch$1 > Date.now() - 2000 && getClickType$2(event) == 1)
-           return; // Ignore touch interaction
-       let style = null;
-       for (let makeStyle of view.state.facet(mouseSelectionStyle$2)) {
-           style = makeStyle(view, event);
-           if (style)
-               break;
-       }
-       if (!style && event.button == 0)
-           style = basicMouseSelection$2(view, event);
-       if (style) {
-           let mustFocus = view.root.activeElement != view.contentDOM;
-           if (mustFocus)
-               view.observer.ignore(() => focusPreventScroll$2(view.contentDOM));
-           view.inputState.startMouseSelection(new MouseSelection$2(view, event, style, mustFocus));
-       }
-   };
-   function rangeForClick$2(view, pos, bias, type) {
-       if (type == 1) { // Single click
-           return EditorSelection$2.cursor(pos, bias);
-       }
-       else if (type == 2) { // Double click
-           return groupAt$2(view.state, pos, bias);
-       }
-       else { // Triple click
-           let visual = LineView$2.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
-           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
-           if (to < view.state.doc.length && to == line.to)
-               to++;
-           return EditorSelection$2.range(from, to);
-       }
-   }
-   let insideY$1 = (y, rect) => y >= rect.top && y <= rect.bottom;
-   let inside$2 = (x, y, rect) => insideY$1(y, rect) && x >= rect.left && x <= rect.right;
-   // Try to determine, for the given coordinates, associated with the
-   // given position, whether they are related to the element before or
-   // the element after the position.
-   function findPositionSide$2(view, pos, x, y) {
-       let line = LineView$2.find(view.docView, pos);
-       if (!line)
-           return 1;
-       let off = pos - line.posAtStart;
-       // Line boundaries point into the line
-       if (off == 0)
-           return 1;
-       if (off == line.length)
-           return -1;
-       // Positions on top of an element point at that element
-       let before = line.coordsAt(off, -1);
-       if (before && inside$2(x, y, before))
-           return -1;
-       let after = line.coordsAt(off, 1);
-       if (after && inside$2(x, y, after))
-           return 1;
-       // This is probably a line wrap point. Pick before if the point is
-       // beside it.
-       return before && insideY$1(y, before) ? -1 : 1;
-   }
-   function queryPos$2(view, event) {
-       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       return { pos, bias: findPositionSide$2(view, pos, event.clientX, event.clientY) };
-   }
-   const BadMouseDetail$2 = browser$2.ie && browser$2.ie_version <= 11;
-   let lastMouseDown$2 = null, lastMouseDownCount$2 = 0, lastMouseDownTime$2 = 0;
-   function getClickType$2(event) {
-       if (!BadMouseDetail$2)
-           return event.detail;
-       let last = lastMouseDown$2, lastTime = lastMouseDownTime$2;
-       lastMouseDown$2 = event;
-       lastMouseDownTime$2 = Date.now();
-       return lastMouseDownCount$2 = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
-           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount$2 + 1) % 3 : 1;
-   }
-   function basicMouseSelection$2(view, event) {
-       let start = queryPos$2(view, event), type = getClickType$2(event);
-       let startSel = view.state.selection;
-       let last = start, lastEvent = event;
-       return {
-           update(update) {
-               if (update.docChanged) {
-                   if (start)
-                       start.pos = update.changes.mapPos(start.pos);
-                   startSel = startSel.map(update.changes);
-                   lastEvent = null;
-               }
-           },
-           get(event, extend, multiple) {
-               let cur;
-               if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
-                   cur = last;
-               else {
-                   cur = last = queryPos$2(view, event);
-                   lastEvent = event;
-               }
-               if (!cur || !start)
-                   return startSel;
-               let range = rangeForClick$2(view, cur.pos, cur.bias, type);
-               if (start.pos != cur.pos && !extend) {
-                   let startRange = rangeForClick$2(view, start.pos, start.bias, type);
-                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
-                   range = from < range.from ? EditorSelection$2.range(from, to) : EditorSelection$2.range(to, from);
-               }
-               if (extend)
-                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
-               else if (multiple)
-                   return startSel.addRange(range);
-               else
-                   return EditorSelection$2.create([range]);
-           }
-       };
-   }
-   handlers$2.dragstart = (view, event) => {
-       let { selection: { main } } = view.state;
-       let { mouseSelection } = view.inputState;
-       if (mouseSelection)
-           mouseSelection.dragging = main;
-       if (event.dataTransfer) {
-           event.dataTransfer.setData("Text", view.state.sliceDoc(main.from, main.to));
-           event.dataTransfer.effectAllowed = "copyMove";
-       }
-   };
-   function dropText$2(view, event, text, direct) {
-       if (!text)
-           return;
-       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       event.preventDefault();
-       let { mouseSelection } = view.inputState;
-       let del = direct && mouseSelection && mouseSelection.dragging && mouseSelection.dragMove ?
-           { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;
-       let ins = { from: dropPos, insert: text };
-       let changes = view.state.changes(del ? [del, ins] : ins);
-       view.focus();
-       view.dispatch({
-           changes,
-           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
-           userEvent: del ? "move.drop" : "input.drop"
-       });
-   }
-   handlers$2.drop = (view, event) => {
-       if (!event.dataTransfer)
-           return;
-       if (view.state.readOnly)
-           return event.preventDefault();
-       let files = event.dataTransfer.files;
-       if (files && files.length) { // For a file drop, read the file's text.
-           event.preventDefault();
-           let text = Array(files.length), read = 0;
-           let finishFile = () => {
-               if (++read == files.length)
-                   dropText$2(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
-           };
-           for (let i = 0; i < files.length; i++) {
-               let reader = new FileReader;
-               reader.onerror = finishFile;
-               reader.onload = () => {
-                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
-                       text[i] = reader.result;
-                   finishFile();
-               };
-               reader.readAsText(files[i]);
-           }
-       }
-       else {
-           dropText$2(view, event, event.dataTransfer.getData("Text"), true);
-       }
-   };
-   handlers$2.paste = (view, event) => {
-       if (view.state.readOnly)
-           return event.preventDefault();
-       view.observer.flush();
-       let data = brokenClipboardAPI$2 ? null : event.clipboardData;
-       if (data) {
-           doPaste$2(view, data.getData("text/plain"));
-           event.preventDefault();
-       }
-       else {
-           capturePaste$2(view);
-       }
-   };
-   function captureCopy$2(view, text) {
-       // The extra wrapper is somehow necessary on IE/Edge to prevent the
-       // content from being mangled when it is put onto the clipboard
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.value = text;
-       target.focus();
-       target.selectionEnd = text.length;
-       target.selectionStart = 0;
-       setTimeout(() => {
-           target.remove();
-           view.focus();
-       }, 50);
-   }
-   function copiedRange$2(state) {
-       let content = [], ranges = [], linewise = false;
-       for (let range of state.selection.ranges)
-           if (!range.empty) {
-               content.push(state.sliceDoc(range.from, range.to));
-               ranges.push(range);
-           }
-       if (!content.length) {
-           // Nothing selected, do a line-wise copy
-           let upto = -1;
-           for (let { from } of state.selection.ranges) {
-               let line = state.doc.lineAt(from);
-               if (line.number > upto) {
-                   content.push(line.text);
-                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
-               }
-               upto = line.number;
-           }
-           linewise = true;
-       }
-       return { text: content.join(state.lineBreak), ranges, linewise };
-   }
-   let lastLinewiseCopy$2 = null;
-   handlers$2.copy = handlers$2.cut = (view, event) => {
-       let { text, ranges, linewise } = copiedRange$2(view.state);
-       if (!text && !linewise)
-           return;
-       lastLinewiseCopy$2 = linewise ? text : null;
-       let data = brokenClipboardAPI$2 ? null : event.clipboardData;
-       if (data) {
-           event.preventDefault();
-           data.clearData();
-           data.setData("text/plain", text);
-       }
-       else {
-           captureCopy$2(view, text);
-       }
-       if (event.type == "cut" && !view.state.readOnly)
-           view.dispatch({
-               changes: ranges,
-               scrollIntoView: true,
-               userEvent: "delete.cut"
-           });
-   };
-   function updateForFocusChange$2(view) {
-       setTimeout(() => {
-           if (view.hasFocus != view.inputState.notifiedFocused)
-               view.update([]);
-       }, 10);
-   }
-   handlers$2.focus = updateForFocusChange$2;
-   handlers$2.blur = view => {
-       view.observer.clearSelectionRange();
-       updateForFocusChange$2(view);
-   };
-   function forceClearComposition$1(view, rapid) {
-       if (view.docView.compositionDeco.size) {
-           view.inputState.rapidCompositionStart = rapid;
-           try {
-               view.update([]);
-           }
-           finally {
-               view.inputState.rapidCompositionStart = false;
-           }
-       }
-   }
-   handlers$2.compositionstart = handlers$2.compositionupdate = view => {
-       if (view.inputState.compositionFirstChange == null)
-           view.inputState.compositionFirstChange = true;
-       if (view.inputState.composing < 0) {
-           // FIXME possibly set a timeout to clear it again on Android
-           view.inputState.composing = 0;
-           if (view.docView.compositionDeco.size) {
-               view.observer.flush();
-               forceClearComposition$1(view, true);
-           }
-       }
-   };
-   handlers$2.compositionend = view => {
-       view.inputState.composing = -1;
-       view.inputState.compositionEndedAt = Date.now();
-       view.inputState.compositionFirstChange = null;
-       setTimeout(() => {
-           if (view.inputState.composing < 0)
-               forceClearComposition$1(view, false);
-       }, 50);
-   };
-   handlers$2.contextmenu = view => {
-       view.inputState.lastContextMenu = Date.now();
-   };
-   handlers$2.beforeinput = (view, event) => {
-       var _a;
-       // Because Chrome Android doesn't fire useful key events, use
-       // beforeinput to detect backspace (and possibly enter and delete,
-       // but those usually don't even seem to fire beforeinput events at
-       // the moment) and fake a key event for it.
-       //
-       // (preventDefault on beforeinput, though supported in the spec,
-       // seems to do nothing at all on Chrome).
-       let pending;
-       if (browser$2.chrome && browser$2.android && (pending = PendingKeys$2.find(key => key.inputType == event.inputType))) {
-           view.observer.delayAndroidKey(pending.key, pending.keyCode);
-           if (pending.key == "Backspace" || pending.key == "Delete") {
-               let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
-               setTimeout(() => {
-                   var _a;
-                   // Backspacing near uneditable nodes on Chrome Android sometimes
-                   // closes the virtual keyboard. This tries to crudely detect
-                   // that and refocus to get it back.
-                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
-                       view.contentDOM.blur();
-                       view.focus();
-                   }
-               }, 100);
-           }
-       }
-   };
-
-   const wrappingWhiteSpace$2 = ["pre-wrap", "normal", "pre-line", "break-spaces"];
-   let HeightOracle$2 = class HeightOracle {
-       constructor() {
-           this.doc = Text$2.empty;
-           this.lineWrapping = false;
-           this.heightSamples = {};
-           this.lineHeight = 14;
-           this.charWidth = 7;
-           this.lineLength = 30;
-           // Used to track, during updateHeight, if any actual heights changed
-           this.heightChanged = false;
-       }
-       heightForGap(from, to) {
-           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
-           if (this.lineWrapping)
-               lines += Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength);
-           return this.lineHeight * lines;
-       }
-       heightForLine(length) {
-           if (!this.lineWrapping)
-               return this.lineHeight;
-           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
-           return lines * this.lineHeight;
-       }
-       setDoc(doc) { this.doc = doc; return this; }
-       mustRefreshForWrapping(whiteSpace) {
-           return (wrappingWhiteSpace$2.indexOf(whiteSpace) > -1) != this.lineWrapping;
-       }
-       mustRefreshForHeights(lineHeights) {
-           let newHeight = false;
-           for (let i = 0; i < lineHeights.length; i++) {
-               let h = lineHeights[i];
-               if (h < 0) {
-                   i++;
-               }
-               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
-                   newHeight = true;
-                   this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return newHeight;
-       }
-       refresh(whiteSpace, lineHeight, charWidth, lineLength, knownHeights) {
-           let lineWrapping = wrappingWhiteSpace$2.indexOf(whiteSpace) > -1;
-           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
-           this.lineWrapping = lineWrapping;
-           this.lineHeight = lineHeight;
-           this.charWidth = charWidth;
-           this.lineLength = lineLength;
-           if (changed) {
-               this.heightSamples = {};
-               for (let i = 0; i < knownHeights.length; i++) {
-                   let h = knownHeights[i];
-                   if (h < 0)
-                       i++;
-                   else
-                       this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return changed;
-       }
-   };
-   // This object is used by `updateHeight` to make DOM measurements
-   // arrive at the right nides. The `heights` array is a sequence of
-   // block heights, starting from position `from`.
-   let MeasuredHeights$2 = class MeasuredHeights {
-       constructor(from, heights) {
-           this.from = from;
-           this.heights = heights;
-           this.index = 0;
-       }
-       get more() { return this.index < this.heights.length; }
-   };
-   /**
-   Record used to represent information about a block-level element
-   in the editor view.
-   */
-   let BlockInfo$2 = class BlockInfo {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the element in the document.
-       */
-       from, 
-       /**
-       The length of the element.
-       */
-       length, 
-       /**
-       The top position of the element (relative to the top of the
-       document).
-       */
-       top, 
-       /**
-       Its height.
-       */
-       height, 
-       /**
-       The type of element this is. When querying lines, this may be
-       an array of all the blocks that make up the line.
-       */
-       type) {
-           this.from = from;
-           this.length = length;
-           this.top = top;
-           this.height = height;
-           this.type = type;
-       }
-       /**
-       The end of the element as a document position.
-       */
-       get to() { return this.from + this.length; }
-       /**
-       The bottom position of the element.
-       */
-       get bottom() { return this.top + this.height; }
-       /**
-       @internal
-       */
-       join(other) {
-           let detail = (Array.isArray(this.type) ? this.type : [this])
-               .concat(Array.isArray(other.type) ? other.type : [other]);
-           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
-       }
-   };
-   var QueryType$3 = /*@__PURE__*/(function (QueryType) {
-       QueryType[QueryType["ByPos"] = 0] = "ByPos";
-       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
-       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
-   return QueryType})(QueryType$3 || (QueryType$3 = {}));
-   const Epsilon$2 = 1e-3;
-   let HeightMap$2 = class HeightMap {
-       constructor(length, // The number of characters covered
-       height, // Height of this part of the document
-       flags = 2 /* Outdated */) {
-           this.length = length;
-           this.height = height;
-           this.flags = flags;
-       }
-       get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
-       set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
-       setHeight(oracle, height) {
-           if (this.height != height) {
-               if (Math.abs(this.height - height) > Epsilon$2)
-                   oracle.heightChanged = true;
-               this.height = height;
-           }
-       }
-       // Base case is to replace a leaf node, which simply builds a tree
-       // from the new nodes and returns that (HeightMapBranch and
-       // HeightMapGap override this to actually use from/to)
-       replace(_from, _to, nodes) {
-           return HeightMap.of(nodes);
-       }
-       // Again, these are base cases, and are overridden for branch and gap nodes.
-       decomposeLeft(_to, result) { result.push(this); }
-       decomposeRight(_from, result) { result.push(this); }
-       applyChanges(decorations, oldDoc, oracle, changes) {
-           let me = this;
-           for (let i = changes.length - 1; i >= 0; i--) {
-               let { fromA, toA, fromB, toB } = changes[i];
-               let start = me.lineAt(fromA, QueryType$3.ByPosNoHeight, oldDoc, 0, 0);
-               let end = start.to >= toA ? start : me.lineAt(toA, QueryType$3.ByPosNoHeight, oldDoc, 0, 0);
-               toB += end.to - toA;
-               toA = end.to;
-               while (i > 0 && start.from <= changes[i - 1].toA) {
-                   fromA = changes[i - 1].fromA;
-                   fromB = changes[i - 1].fromB;
-                   i--;
-                   if (fromA < start.from)
-                       start = me.lineAt(fromA, QueryType$3.ByPosNoHeight, oldDoc, 0, 0);
-               }
-               fromB += start.from - fromA;
-               fromA = start.from;
-               let nodes = NodeBuilder$2.build(oracle, decorations, fromB, toB);
-               me = me.replace(fromA, toA, nodes);
-           }
-           return me.updateHeight(oracle, 0);
-       }
-       static empty() { return new HeightMapText$2(0, 0); }
-       // nodes uses null values to indicate the position of line breaks.
-       // There are never line breaks at the start or end of the array, or
-       // two line breaks next to each other, and the array isn't allowed
-       // to be empty (same restrictions as return value from the builder).
-       static of(nodes) {
-           if (nodes.length == 1)
-               return nodes[0];
-           let i = 0, j = nodes.length, before = 0, after = 0;
-           for (;;) {
-               if (i == j) {
-                   if (before > after * 2) {
-                       let split = nodes[i - 1];
-                       if (split.break)
-                           nodes.splice(--i, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(--i, 1, split.left, split.right);
-                       j += 1 + split.break;
-                       before -= split.size;
-                   }
-                   else if (after > before * 2) {
-                       let split = nodes[j];
-                       if (split.break)
-                           nodes.splice(j, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(j, 1, split.left, split.right);
-                       j += 2 + split.break;
-                       after -= split.size;
-                   }
-                   else {
-                       break;
-                   }
-               }
-               else if (before < after) {
-                   let next = nodes[i++];
-                   if (next)
-                       before += next.size;
-               }
-               else {
-                   let next = nodes[--j];
-                   if (next)
-                       after += next.size;
-               }
-           }
-           let brk = 0;
-           if (nodes[i - 1] == null) {
-               brk = 1;
-               i--;
-           }
-           else if (nodes[i] == null) {
-               brk = 1;
-               j++;
-           }
-           return new HeightMapBranch$2(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
-       }
-   };
-   HeightMap$2.prototype.size = 1;
-   let HeightMapBlock$2 = class HeightMapBlock extends HeightMap$2 {
-       constructor(length, height, type) {
-           super(length, height);
-           this.type = type;
-       }
-       blockAt(_height, _doc, top, offset) {
-           return new BlockInfo$2(offset, this.length, top, this.height, this.type);
-       }
-       lineAt(_value, _type, doc, top, offset) {
-           return this.blockAt(0, doc, top, offset);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           if (from <= offset + this.length && to >= offset)
-               f(this.blockAt(0, doc, top, offset));
-       }
-       updateHeight(oracle, offset = 0, _force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(oracle, measured.heights[measured.index++]);
-           this.outdated = false;
-           return this;
-       }
-       toString() { return `block(${this.length})`; }
-   };
-   let HeightMapText$2 = class HeightMapText extends HeightMapBlock$2 {
-       constructor(length, height) {
-           super(length, height, BlockType$2.Text);
-           this.collapsed = 0; // Amount of collapsed content in the line
-           this.widgetHeight = 0; // Maximum inline widget height
-       }
-       replace(_from, _to, nodes) {
-           let node = nodes[0];
-           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap$2 && (node.flags & 4 /* SingleLine */)) &&
-               Math.abs(this.length - node.length) < 10) {
-               if (node instanceof HeightMapGap$2)
-                   node = new HeightMapText(node.length, this.height);
-               else
-                   node.height = this.height;
-               if (!this.outdated)
-                   node.outdated = false;
-               return node;
-           }
-           else {
-               return HeightMap$2.of(nodes);
-           }
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(oracle, measured.heights[measured.index++]);
-           else if (force || this.outdated)
-               this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)));
-           this.outdated = false;
-           return this;
-       }
-       toString() {
-           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
-       }
-   };
-   let HeightMapGap$2 = class HeightMapGap extends HeightMap$2 {
-       constructor(length) { super(length, 0); }
-       lines(doc, offset) {
-           let firstLine = doc.lineAt(offset).number, lastLine = doc.lineAt(offset + this.length).number;
-           return { firstLine, lastLine, lineHeight: this.height / (lastLine - firstLine + 1) };
-       }
-       blockAt(height, doc, top, offset) {
-           let { firstLine, lastLine, lineHeight } = this.lines(doc, offset);
-           let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / lineHeight)));
-           let { from, length } = doc.line(firstLine + line);
-           return new BlockInfo$2(from, length, top + lineHeight * line, lineHeight, BlockType$2.Text);
-       }
-       lineAt(value, type, doc, top, offset) {
-           if (type == QueryType$3.ByHeight)
-               return this.blockAt(value, doc, top, offset);
-           if (type == QueryType$3.ByPosNoHeight) {
-               let { from, to } = doc.lineAt(value);
-               return new BlockInfo$2(from, to - from, 0, 0, BlockType$2.Text);
-           }
-           let { firstLine, lineHeight } = this.lines(doc, offset);
-           let { from, length, number } = doc.lineAt(value);
-           return new BlockInfo$2(from, length, top + lineHeight * (number - firstLine), lineHeight, BlockType$2.Text);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           let { firstLine, lineHeight } = this.lines(doc, offset);
-           for (let pos = Math.max(from, offset), end = Math.min(offset + this.length, to); pos <= end;) {
-               let line = doc.lineAt(pos);
-               if (pos == from)
-                   top += lineHeight * (line.number - firstLine);
-               f(new BlockInfo$2(line.from, line.length, top, lineHeight, BlockType$2.Text));
-               top += lineHeight;
-               pos = line.to + 1;
-           }
-       }
-       replace(from, to, nodes) {
-           let after = this.length - to;
-           if (after > 0) {
-               let last = nodes[nodes.length - 1];
-               if (last instanceof HeightMapGap)
-                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
-               else
-                   nodes.push(null, new HeightMapGap(after - 1));
-           }
-           if (from > 0) {
-               let first = nodes[0];
-               if (first instanceof HeightMapGap)
-                   nodes[0] = new HeightMapGap(from + first.length);
-               else
-                   nodes.unshift(new HeightMapGap(from - 1), null);
-           }
-           return HeightMap$2.of(nodes);
-       }
-       decomposeLeft(to, result) {
-           result.push(new HeightMapGap(to - 1), null);
-       }
-       decomposeRight(from, result) {
-           result.push(null, new HeightMapGap(this.length - from - 1));
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let end = offset + this.length;
-           if (measured && measured.from <= offset + this.length && measured.more) {
-               // Fill in part of this gap with measured lines. We know there
-               // can't be widgets or collapsed ranges in those lines, because
-               // they would already have been added to the heightmap (gaps
-               // only contain plain text).
-               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
-               let wasChanged = oracle.heightChanged;
-               if (measured.from > offset)
-                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
-               while (pos <= end && measured.more) {
-                   let len = oracle.doc.lineAt(pos).length;
-                   if (nodes.length)
-                       nodes.push(null);
-                   let height = measured.heights[measured.index++];
-                   if (singleHeight == -1)
-                       singleHeight = height;
-                   else if (Math.abs(height - singleHeight) >= Epsilon$2)
-                       singleHeight = -2;
-                   let line = new HeightMapText$2(len, height);
-                   line.outdated = false;
-                   nodes.push(line);
-                   pos += len + 1;
-               }
-               if (pos <= end)
-                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
-               let result = HeightMap$2.of(nodes);
-               oracle.heightChanged = wasChanged || singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon$2 ||
-                   Math.abs(singleHeight - this.lines(oracle.doc, offset).lineHeight) >= Epsilon$2;
-               return result;
-           }
-           else if (force || this.outdated) {
-               this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));
-               this.outdated = false;
-           }
-           return this;
-       }
-       toString() { return `gap(${this.length})`; }
-   };
-   let HeightMapBranch$2 = class HeightMapBranch extends HeightMap$2 {
-       constructor(left, brk, right) {
-           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
-           this.left = left;
-           this.right = right;
-           this.size = left.size + right.size;
-       }
-       get break() { return this.flags & 1 /* Break */; }
-       blockAt(height, doc, top, offset) {
-           let mid = top + this.left.height;
-           return height < mid ? this.left.blockAt(height, doc, top, offset)
-               : this.right.blockAt(height, doc, mid, offset + this.left.length + this.break);
-       }
-       lineAt(value, type, doc, top, offset) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           let left = type == QueryType$3.ByHeight ? value < rightTop : value < rightOffset;
-           let base = left ? this.left.lineAt(value, type, doc, top, offset)
-               : this.right.lineAt(value, type, doc, rightTop, rightOffset);
-           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
-               return base;
-           let subQuery = type == QueryType$3.ByPosNoHeight ? QueryType$3.ByPosNoHeight : QueryType$3.ByPos;
-           if (left)
-               return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));
-           else
-               return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           if (this.break) {
-               if (from < rightOffset)
-                   this.left.forEachLine(from, to, doc, top, offset, f);
-               if (to >= rightOffset)
-                   this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
-           }
-           else {
-               let mid = this.lineAt(rightOffset, QueryType$3.ByPos, doc, top, offset);
-               if (from < mid.from)
-                   this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
-               if (mid.to >= from && mid.from <= to)
-                   f(mid);
-               if (to > mid.to)
-                   this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
-           }
-       }
-       replace(from, to, nodes) {
-           let rightStart = this.left.length + this.break;
-           if (to < rightStart)
-               return this.balanced(this.left.replace(from, to, nodes), this.right);
-           if (from > this.left.length)
-               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
-           let result = [];
-           if (from > 0)
-               this.decomposeLeft(from, result);
-           let left = result.length;
-           for (let node of nodes)
-               result.push(node);
-           if (from > 0)
-               mergeGaps$2(result, left - 1);
-           if (to < this.length) {
-               let right = result.length;
-               this.decomposeRight(to, result);
-               mergeGaps$2(result, right);
-           }
-           return HeightMap$2.of(result);
-       }
-       decomposeLeft(to, result) {
-           let left = this.left.length;
-           if (to <= left)
-               return this.left.decomposeLeft(to, result);
-           result.push(this.left);
-           if (this.break) {
-               left++;
-               if (to >= left)
-                   result.push(null);
-           }
-           if (to > left)
-               this.right.decomposeLeft(to - left, result);
-       }
-       decomposeRight(from, result) {
-           let left = this.left.length, right = left + this.break;
-           if (from >= right)
-               return this.right.decomposeRight(from - right, result);
-           if (from < left)
-               this.left.decomposeRight(from, result);
-           if (this.break && from < right)
-               result.push(null);
-           result.push(this.right);
-       }
-       balanced(left, right) {
-           if (left.size > 2 * right.size || right.size > 2 * left.size)
-               return HeightMap$2.of(this.break ? [left, null, right] : [left, right]);
-           this.left = left;
-           this.right = right;
-           this.height = left.height + right.height;
-           this.outdated = left.outdated || right.outdated;
-           this.size = left.size + right.size;
-           this.length = left.length + this.break + right.length;
-           return this;
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
-           if (measured && measured.from <= offset + left.length && measured.more)
-               rebalance = left = left.updateHeight(oracle, offset, force, measured);
-           else
-               left.updateHeight(oracle, offset, force);
-           if (measured && measured.from <= rightStart + right.length && measured.more)
-               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
-           else
-               right.updateHeight(oracle, rightStart, force);
-           if (rebalance)
-               return this.balanced(left, right);
-           this.height = this.left.height + this.right.height;
-           this.outdated = false;
-           return this;
-       }
-       toString() { return this.left + (this.break ? " " : "-") + this.right; }
-   };
-   function mergeGaps$2(nodes, around) {
-       let before, after;
-       if (nodes[around] == null &&
-           (before = nodes[around - 1]) instanceof HeightMapGap$2 &&
-           (after = nodes[around + 1]) instanceof HeightMapGap$2)
-           nodes.splice(around - 1, 3, new HeightMapGap$2(before.length + 1 + after.length));
-   }
-   const relevantWidgetHeight$2 = 5;
-   let NodeBuilder$2 = class NodeBuilder {
-       constructor(pos, oracle) {
-           this.pos = pos;
-           this.oracle = oracle;
-           this.nodes = [];
-           this.lineStart = -1;
-           this.lineEnd = -1;
-           this.covering = null;
-           this.writtenTo = pos;
-       }
-       get isCovered() {
-           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
-       }
-       span(_from, to) {
-           if (this.lineStart > -1) {
-               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
-               if (last instanceof HeightMapText$2)
-                   last.length += end - this.pos;
-               else if (end > this.pos || !this.isCovered)
-                   this.nodes.push(new HeightMapText$2(end - this.pos, -1));
-               this.writtenTo = end;
-               if (to > end) {
-                   this.nodes.push(null);
-                   this.writtenTo++;
-                   this.lineStart = -1;
-               }
-           }
-           this.pos = to;
-       }
-       point(from, to, deco) {
-           if (from < to || deco.heightRelevant) {
-               let height = deco.widget ? deco.widget.estimatedHeight : 0;
-               if (height < 0)
-                   height = this.oracle.lineHeight;
-               let len = to - from;
-               if (deco.block) {
-                   this.addBlock(new HeightMapBlock$2(len, height, deco.type));
-               }
-               else if (len || height >= relevantWidgetHeight$2) {
-                   this.addLineDeco(height, len);
-               }
-           }
-           else if (to > from) {
-               this.span(from, to);
-           }
-           if (this.lineEnd > -1 && this.lineEnd < this.pos)
-               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
-       }
-       enterLine() {
-           if (this.lineStart > -1)
-               return;
-           let { from, to } = this.oracle.doc.lineAt(this.pos);
-           this.lineStart = from;
-           this.lineEnd = to;
-           if (this.writtenTo < from) {
-               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
-                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
-               this.nodes.push(null);
-           }
-           if (this.pos > from)
-               this.nodes.push(new HeightMapText$2(this.pos - from, -1));
-           this.writtenTo = this.pos;
-       }
-       blankContent(from, to) {
-           let gap = new HeightMapGap$2(to - from);
-           if (this.oracle.doc.lineAt(from).to == to)
-               gap.flags |= 4 /* SingleLine */;
-           return gap;
-       }
-       ensureLine() {
-           this.enterLine();
-           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
-           if (last instanceof HeightMapText$2)
-               return last;
-           let line = new HeightMapText$2(0, -1);
-           this.nodes.push(line);
-           return line;
-       }
-       addBlock(block) {
-           this.enterLine();
-           if (block.type == BlockType$2.WidgetAfter && !this.isCovered)
-               this.ensureLine();
-           this.nodes.push(block);
-           this.writtenTo = this.pos = this.pos + block.length;
-           if (block.type != BlockType$2.WidgetBefore)
-               this.covering = block;
-       }
-       addLineDeco(height, length) {
-           let line = this.ensureLine();
-           line.length += length;
-           line.collapsed += length;
-           line.widgetHeight = Math.max(line.widgetHeight, height);
-           this.writtenTo = this.pos = this.pos + length;
-       }
-       finish(from) {
-           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
-           if (this.lineStart > -1 && !(last instanceof HeightMapText$2) && !this.isCovered)
-               this.nodes.push(new HeightMapText$2(0, -1));
-           else if (this.writtenTo < this.pos || last == null)
-               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
-           let pos = from;
-           for (let node of this.nodes) {
-               if (node instanceof HeightMapText$2)
-                   node.updateHeight(this.oracle, pos);
-               pos += node ? node.length : 1;
-           }
-           return this.nodes;
-       }
-       // Always called with a region that on both sides either stretches
-       // to a line break or the end of the document.
-       // The returned array uses null to indicate line breaks, but never
-       // starts or ends in a line break, or has multiple line breaks next
-       // to each other.
-       static build(oracle, decorations, from, to) {
-           let builder = new NodeBuilder(from, oracle);
-           RangeSet$2.spans(decorations, from, to, builder, 0);
-           return builder.finish(from);
-       }
-   };
-   function heightRelevantDecoChanges$2(a, b, diff) {
-       let comp = new DecorationComparator$3;
-       RangeSet$2.compare(a, b, diff, comp, 0);
-       return comp.changes;
-   }
-   let DecorationComparator$3 = class DecorationComparator {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange() { }
-       comparePoint(from, to, a, b) {
-           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
-               addRange$2(from, to, this.changes, 5);
-       }
-   };
-
-   function visiblePixelRange$2(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       let left = Math.max(0, rect.left), right = Math.min(innerWidth, rect.right);
-       let top = Math.max(0, rect.top), bottom = Math.min(innerHeight, rect.bottom);
-       let body = dom.ownerDocument.body;
-       for (let parent = dom.parentNode; parent && parent != body;) {
-           if (parent.nodeType == 1) {
-               let elt = parent;
-               let style = window.getComputedStyle(elt);
-               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
-                   style.overflow != "visible") {
-                   let parentRect = elt.getBoundingClientRect();
-                   left = Math.max(left, parentRect.left);
-                   right = Math.min(right, parentRect.right);
-                   top = Math.max(top, parentRect.top);
-                   bottom = Math.min(bottom, parentRect.bottom);
-               }
-               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
-           }
-           else if (parent.nodeType == 11) { // Shadow root
-               parent = parent.host;
-           }
-           else {
-               break;
-           }
-       }
-       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
-           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
-   }
-   function fullPixelRange$2(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       return { left: 0, right: rect.right - rect.left,
-           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
-   }
-   // Line gaps are placeholder widgets used to hide pieces of overlong
-   // lines within the viewport, as a kludge to keep the editor
-   // responsive when a ridiculously long line is loaded into it.
-   let LineGap$2 = class LineGap {
-       constructor(from, to, size) {
-           this.from = from;
-           this.to = to;
-           this.size = size;
-       }
-       static same(a, b) {
-           if (a.length != b.length)
-               return false;
-           for (let i = 0; i < a.length; i++) {
-               let gA = a[i], gB = b[i];
-               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
-                   return false;
-           }
-           return true;
-       }
-       draw(wrapping) {
-           return Decoration$2.replace({ widget: new LineGapWidget$2(this.size, wrapping) }).range(this.from, this.to);
-       }
-   };
-   let LineGapWidget$2 = class LineGapWidget extends WidgetType$2 {
-       constructor(size, vertical) {
-           super();
-           this.size = size;
-           this.vertical = vertical;
-       }
-       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
-       toDOM() {
-           let elt = document.createElement("div");
-           if (this.vertical) {
-               elt.style.height = this.size + "px";
-           }
-           else {
-               elt.style.width = this.size + "px";
-               elt.style.height = "2px";
-               elt.style.display = "inline-block";
-           }
-           return elt;
-       }
-       get estimatedHeight() { return this.vertical ? this.size : -1; }
-   };
-   let ViewState$2 = class ViewState {
-       constructor(state) {
-           this.state = state;
-           // These are contentDOM-local coordinates
-           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
-           this.inView = true;
-           this.paddingTop = 0;
-           this.paddingBottom = 0;
-           this.contentDOMWidth = 0;
-           this.contentDOMHeight = 0;
-           this.editorHeight = 0;
-           this.editorWidth = 0;
-           this.heightOracle = new HeightOracle$2;
-           // See VP.MaxDOMHeight
-           this.scaler = IdScaler$2;
-           this.scrollTarget = null;
-           // Briefly set to true when printing, to disable viewport limiting
-           this.printing = false;
-           // Flag set when editor content was redrawn, so that the next
-           // measure stage knows it must read DOM layout
-           this.mustMeasureContent = true;
-           this.defaultTextDirection = Direction$2.RTL;
-           this.visibleRanges = [];
-           // Cursor 'assoc' is only significant when the cursor is on a line
-           // wrap point, where it must stick to the character that it is
-           // associated with. Since browsers don't provide a reasonable
-           // interface to set or query this, when a selection is set that
-           // might cause this to be significant, this flag is set. The next
-           // measure phase will check whether the cursor is on a line-wrapping
-           // boundary and, if so, reset it to make sure it is positioned in
-           // the right place.
-           this.mustEnforceCursorAssoc = false;
-           this.stateDeco = state.facet(decorations$2).filter(d => typeof d != "function");
-           this.heightMap = HeightMap$2.empty().applyChanges(this.stateDeco, Text$2.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange$2(0, 0, 0, state.doc.length)]);
-           this.viewport = this.getViewport(0, null);
-           this.updateViewportLines();
-           this.updateForViewport();
-           this.lineGaps = this.ensureLineGaps([]);
-           this.lineGapDeco = Decoration$2.set(this.lineGaps.map(gap => gap.draw(false)));
-           this.computeVisibleRanges();
-       }
-       updateForViewport() {
-           let viewports = [this.viewport], { main } = this.state.selection;
-           for (let i = 0; i <= 1; i++) {
-               let pos = i ? main.head : main.anchor;
-               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
-                   let { from, to } = this.lineBlockAt(pos);
-                   viewports.push(new Viewport$2(from, to));
-               }
-           }
-           this.viewports = viewports.sort((a, b) => a.from - b.from);
-           this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler$2 :
-               new BigScaler$2(this.heightOracle.doc, this.heightMap, this.viewports);
-       }
-       updateViewportLines() {
-           this.viewportLines = [];
-           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, block => {
-               this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock$2(block, this.scaler));
-           });
-       }
-       update(update, scrollTarget = null) {
-           this.state = update.state;
-           let prevDeco = this.stateDeco;
-           this.stateDeco = this.state.facet(decorations$2).filter(d => typeof d != "function");
-           let contentChanges = update.changedRanges;
-           let heightChanges = ChangedRange$2.extendWithRanges(contentChanges, heightRelevantDecoChanges$2(prevDeco, this.stateDeco, update ? update.changes : ChangeSet$2.empty(this.state.doc.length)));
-           let prevHeight = this.heightMap.height;
-           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
-           if (this.heightMap.height != prevHeight)
-               update.flags |= 2 /* Height */;
-           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
-           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
-               !this.viewportIsAppropriate(viewport))
-               viewport = this.getViewport(0, scrollTarget);
-           let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
-               viewport.from != this.viewport.from || viewport.to != this.viewport.to;
-           this.viewport = viewport;
-           this.updateForViewport();
-           if (updateLines)
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
-               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
-           update.flags |= this.computeVisibleRanges();
-           if (scrollTarget)
-               this.scrollTarget = scrollTarget;
-           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
-               update.state.selection.main.empty && update.state.selection.main.assoc)
-               this.mustEnforceCursorAssoc = true;
-       }
-       measure(view) {
-           let dom = view.contentDOM, style = window.getComputedStyle(dom);
-           let oracle = this.heightOracle;
-           let whiteSpace = style.whiteSpace;
-           this.defaultTextDirection = style.direction == "rtl" ? Direction$2.RTL : Direction$2.LTR;
-           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
-           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
-           this.contentDOMHeight = dom.clientHeight;
-           this.mustMeasureContent = false;
-           let result = 0, bias = 0;
-           // Vertical padding
-           let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
-           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
-               this.paddingTop = paddingTop;
-               this.paddingBottom = paddingBottom;
-               result |= 8 /* Geometry */ | 2 /* Height */;
-           }
-           if (this.editorWidth != view.scrollDOM.clientWidth) {
-               if (oracle.lineWrapping)
-                   measureContent = true;
-               this.editorWidth = view.scrollDOM.clientWidth;
-               result |= 8 /* Geometry */;
-           }
-           // Pixel viewport
-           let pixelViewport = (this.printing ? fullPixelRange$2 : visiblePixelRange$2)(dom, this.paddingTop);
-           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
-           this.pixelViewport = pixelViewport;
-           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
-           if (inView != this.inView) {
-               this.inView = inView;
-               if (inView)
-                   measureContent = true;
-           }
-           if (!this.inView)
-               return 0;
-           let contentWidth = dom.clientWidth;
-           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
-               this.contentDOMWidth = contentWidth;
-               this.editorHeight = view.scrollDOM.clientHeight;
-               result |= 8 /* Geometry */;
-           }
-           if (measureContent) {
-               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
-               if (oracle.mustRefreshForHeights(lineHeights))
-                   refresh = true;
-               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
-                   let { lineHeight, charWidth } = view.docView.measureTextSize();
-                   refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
-                   if (refresh) {
-                       view.docView.minWidth = 0;
-                       result |= 8 /* Geometry */;
-                   }
-               }
-               if (dTop > 0 && dBottom > 0)
-                   bias = Math.max(dTop, dBottom);
-               else if (dTop < 0 && dBottom < 0)
-                   bias = Math.min(dTop, dBottom);
-               oracle.heightChanged = false;
-               for (let vp of this.viewports) {
-                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
-                   this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights$2(vp.from, heights));
-               }
-               if (oracle.heightChanged)
-                   result |= 2 /* Height */;
-           }
-           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
-               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
-           if (viewportChange)
-               this.viewport = this.getViewport(bias, this.scrollTarget);
-           this.updateForViewport();
-           if ((result & 2 /* Height */) || viewportChange)
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
-               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
-           result |= this.computeVisibleRanges();
-           if (this.mustEnforceCursorAssoc) {
-               this.mustEnforceCursorAssoc = false;
-               // This is done in the read stage, because moving the selection
-               // to a line end is going to trigger a layout anyway, so it
-               // can't be a pure write. It should be rare that it does any
-               // writing.
-               view.docView.enforceCursorAssoc();
-           }
-           return result;
-       }
-       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
-       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
-       getViewport(bias, scrollTarget) {
-           // This will divide VP.Margin between the top and the
-           // bottom, depending on the bias (the change in viewport position
-           // since the last update). It'll hold a number between 0 and 1
-           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
-           let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
-           let viewport = new Viewport$2(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType$3.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType$3.ByHeight, doc, 0, 0).to);
-           // If scrollTarget is given, make sure the viewport includes that position
-           if (scrollTarget) {
-               let { head } = scrollTarget.range;
-               if (head < viewport.from || head > viewport.to) {
-                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
-                   let block = map.lineAt(head, QueryType$3.ByPos, doc, 0, 0), topPos;
-                   if (scrollTarget.y == "center")
-                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
-                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
-                       topPos = block.top;
-                   else
-                       topPos = block.bottom - viewHeight;
-                   viewport = new Viewport$2(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType$3.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType$3.ByHeight, doc, 0, 0).to);
-               }
-           }
-           return viewport;
-       }
-       mapViewport(viewport, changes) {
-           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
-           return new Viewport$2(this.heightMap.lineAt(from, QueryType$3.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType$3.ByPos, this.state.doc, 0, 0).to);
-       }
-       // Checks if a given viewport covers the visible part of the
-       // document and not too much beyond that.
-       viewportIsAppropriate({ from, to }, bias = 0) {
-           if (!this.inView)
-               return true;
-           let { top } = this.heightMap.lineAt(from, QueryType$3.ByPos, this.state.doc, 0, 0);
-           let { bottom } = this.heightMap.lineAt(to, QueryType$3.ByPos, this.state.doc, 0, 0);
-           let { visibleTop, visibleBottom } = this;
-           return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
-               (to == this.state.doc.length ||
-                   bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
-               (top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
-       }
-       mapLineGaps(gaps, changes) {
-           if (!gaps.length || changes.empty)
-               return gaps;
-           let mapped = [];
-           for (let gap of gaps)
-               if (!changes.touchesRange(gap.from, gap.to))
-                   mapped.push(new LineGap$2(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));
-           return mapped;
-       }
-       // Computes positions in the viewport where the start or end of a
-       // line should be hidden, trying to reuse existing line gaps when
-       // appropriate to avoid unneccesary redraws.
-       // Uses crude character-counting for the positioning and sizing,
-       // since actual DOM coordinates aren't always available and
-       // predictable. Relies on generous margins (see LG.Margin) to hide
-       // the artifacts this might produce from the user.
-       ensureLineGaps(current) {
-           let gaps = [];
-           // This won't work at all in predominantly right-to-left text.
-           if (this.defaultTextDirection != Direction$2.LTR)
-               return gaps;
-           for (let line of this.viewportLines) {
-               if (line.length < 4000 /* DoubleMargin */)
-                   continue;
-               let structure = lineStructure$2(line.from, line.to, this.stateDeco);
-               if (structure.total < 4000 /* DoubleMargin */)
-                   continue;
-               let viewFrom, viewTo;
-               if (this.heightOracle.lineWrapping) {
-                   let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
-                   viewFrom = findPosition$2(structure, (this.visibleTop - line.top - marginHeight) / line.height);
-                   viewTo = findPosition$2(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
-               }
-               else {
-                   let totalWidth = structure.total * this.heightOracle.charWidth;
-                   let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
-                   viewFrom = findPosition$2(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
-                   viewTo = findPosition$2(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
-               }
-               let outside = [];
-               if (viewFrom > line.from)
-                   outside.push({ from: line.from, to: viewFrom });
-               if (viewTo < line.to)
-                   outside.push({ from: viewTo, to: line.to });
-               let sel = this.state.selection.main;
-               // Make sure the gaps don't cover a selection end
-               if (sel.from >= line.from && sel.from <= line.to)
-                   cutRange$1(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
-               if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
-                   cutRange$1(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
-               for (let { from, to } of outside)
-                   if (to - from > 1000 /* HalfMargin */) {
-                       gaps.push(find$2(current, gap => gap.from >= line.from && gap.to <= line.to &&
-                           Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
-                           new LineGap$2(from, to, this.gapSize(line, from, to, structure)));
-                   }
-           }
-           return gaps;
-       }
-       gapSize(line, from, to, structure) {
-           let fraction = findFraction$2(structure, to) - findFraction$2(structure, from);
-           if (this.heightOracle.lineWrapping) {
-               return line.height * fraction;
-           }
-           else {
-               return structure.total * this.heightOracle.charWidth * fraction;
-           }
-       }
-       updateLineGaps(gaps) {
-           if (!LineGap$2.same(gaps, this.lineGaps)) {
-               this.lineGaps = gaps;
-               this.lineGapDeco = Decoration$2.set(gaps.map(gap => gap.draw(this.heightOracle.lineWrapping)));
-           }
-       }
-       computeVisibleRanges() {
-           let deco = this.stateDeco;
-           if (this.lineGaps.length)
-               deco = deco.concat(this.lineGapDeco);
-           let ranges = [];
-           RangeSet$2.spans(deco, this.viewport.from, this.viewport.to, {
-               span(from, to) { ranges.push({ from, to }); },
-               point() { }
-           }, 20);
-           let changed = ranges.length != this.visibleRanges.length ||
-               this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
-           this.visibleRanges = ranges;
-           return changed ? 4 /* Viewport */ : 0;
-       }
-       lineBlockAt(pos) {
-           return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
-               scaleBlock$2(this.heightMap.lineAt(pos, QueryType$3.ByPos, this.state.doc, 0, 0), this.scaler);
-       }
-       lineBlockAtHeight(height) {
-           return scaleBlock$2(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$3.ByHeight, this.state.doc, 0, 0), this.scaler);
-       }
-       elementAtHeight(height) {
-           return scaleBlock$2(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
-       }
-       get docHeight() {
-           return this.scaler.toDOM(this.heightMap.height);
-       }
-       get contentHeight() {
-           return this.docHeight + this.paddingTop + this.paddingBottom;
-       }
-   };
-   let Viewport$2 = class Viewport {
-       constructor(from, to) {
-           this.from = from;
-           this.to = to;
-       }
-   };
-   function lineStructure$2(from, to, stateDeco) {
-       let ranges = [], pos = from, total = 0;
-       RangeSet$2.spans(stateDeco, from, to, {
-           span() { },
-           point(from, to) {
-               if (from > pos) {
-                   ranges.push({ from: pos, to: from });
-                   total += from - pos;
-               }
-               pos = to;
-           }
-       }, 20); // We're only interested in collapsed ranges of a significant size
-       if (pos < to) {
-           ranges.push({ from: pos, to });
-           total += to - pos;
-       }
-       return { total, ranges };
-   }
-   function findPosition$2({ total, ranges }, ratio) {
-       if (ratio <= 0)
-           return ranges[0].from;
-       if (ratio >= 1)
-           return ranges[ranges.length - 1].to;
-       let dist = Math.floor(total * ratio);
-       for (let i = 0;; i++) {
-           let { from, to } = ranges[i], size = to - from;
-           if (dist <= size)
-               return from + dist;
-           dist -= size;
-       }
-   }
-   function findFraction$2(structure, pos) {
-       let counted = 0;
-       for (let { from, to } of structure.ranges) {
-           if (pos <= to) {
-               counted += pos - from;
-               break;
-           }
-           counted += to - from;
-       }
-       return counted / structure.total;
-   }
-   function cutRange$1(ranges, from, to) {
-       for (let i = 0; i < ranges.length; i++) {
-           let r = ranges[i];
-           if (r.from < to && r.to > from) {
-               let pieces = [];
-               if (r.from < from)
-                   pieces.push({ from: r.from, to: from });
-               if (r.to > to)
-                   pieces.push({ from: to, to: r.to });
-               ranges.splice(i, 1, ...pieces);
-               i += pieces.length - 1;
-           }
-       }
-   }
-   function find$2(array, f) {
-       for (let val of array)
-           if (f(val))
-               return val;
-       return undefined;
-   }
-   // Don't scale when the document height is within the range of what
-   // the DOM can handle.
-   const IdScaler$2 = {
-       toDOM(n) { return n; },
-       fromDOM(n) { return n; },
-       scale: 1
-   };
-   // When the height is too big (> VP.MaxDOMHeight), scale down the
-   // regions outside the viewports so that the total height is
-   // VP.MaxDOMHeight.
-   let BigScaler$2 = class BigScaler {
-       constructor(doc, heightMap, viewports) {
-           let vpHeight = 0, base = 0, domBase = 0;
-           this.viewports = viewports.map(({ from, to }) => {
-               let top = heightMap.lineAt(from, QueryType$3.ByPos, doc, 0, 0).top;
-               let bottom = heightMap.lineAt(to, QueryType$3.ByPos, doc, 0, 0).bottom;
-               vpHeight += bottom - top;
-               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
-           });
-           this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
-           for (let obj of this.viewports) {
-               obj.domTop = domBase + (obj.top - base) * this.scale;
-               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
-               base = obj.bottom;
-           }
-       }
-       toDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.top)
-                   return domBase + (n - base) * this.scale;
-               if (n <= vp.bottom)
-                   return vp.domTop + (n - vp.top);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-       fromDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.domTop)
-                   return base + (n - domBase) / this.scale;
-               if (n <= vp.domBottom)
-                   return vp.top + (n - vp.domTop);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-   };
-   function scaleBlock$2(block, scaler) {
-       if (scaler.scale == 1)
-           return block;
-       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
-       return new BlockInfo$2(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock$2(b, scaler)) : block.type);
-   }
-
-   const theme$2 = /*@__PURE__*/Facet$2.define({ combine: strs => strs.join(" ") });
-   const darkTheme$2 = /*@__PURE__*/Facet$2.define({ combine: values => values.indexOf(true) > -1 });
-   const baseThemeID$2 = /*@__PURE__*/StyleModule.newName(), baseLightID$2 = /*@__PURE__*/StyleModule.newName(), baseDarkID$2 = /*@__PURE__*/StyleModule.newName();
-   const lightDarkIDs$2 = { "&light": "." + baseLightID$2, "&dark": "." + baseDarkID$2 };
-   function buildTheme$2(main, spec, scopes) {
-       return new StyleModule(spec, {
-           finish(sel) {
-               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
-                   if (m == "&")
-                       return main;
-                   if (!scopes || !scopes[m])
-                       throw new RangeError(`Unsupported selector: ${m}`);
-                   return scopes[m];
-               }) : main + " " + sel;
-           }
-       });
-   }
-   const baseTheme$1$3 = /*@__PURE__*/buildTheme$2("." + baseThemeID$2, {
-       "&.cm-editor": {
-           position: "relative !important",
-           boxSizing: "border-box",
-           "&.cm-focused": {
-               // Provide a simple default outline to make sure a focused
-               // editor is visually distinct. Can't leave the default behavior
-               // because that will apply to the content element, which is
-               // inside the scrollable container and doesn't include the
-               // gutters. We also can't use an 'auto' outline, since those
-               // are, for some reason, drawn behind the element content, which
-               // will cause things like the active line background to cover
-               // the outline (#297).
-               outline: "1px dotted #212121"
-           },
-           display: "flex !important",
-           flexDirection: "column"
-       },
-       ".cm-scroller": {
-           display: "flex !important",
-           alignItems: "flex-start !important",
-           fontFamily: "monospace",
-           lineHeight: 1.4,
-           height: "100%",
-           overflowX: "auto",
-           position: "relative",
-           zIndex: 0
-       },
-       ".cm-content": {
-           margin: 0,
-           flexGrow: 2,
-           minHeight: "100%",
-           display: "block",
-           whiteSpace: "pre",
-           wordWrap: "normal",
-           boxSizing: "border-box",
-           padding: "4px 0",
-           outline: "none",
-           "&[contenteditable=true]": {
-               WebkitUserModify: "read-write-plaintext-only",
-           }
-       },
-       ".cm-lineWrapping": {
-           whiteSpace_fallback: "pre-wrap",
-           whiteSpace: "break-spaces",
-           wordBreak: "break-word",
-           overflowWrap: "anywhere"
-       },
-       "&light .cm-content": { caretColor: "black" },
-       "&dark .cm-content": { caretColor: "white" },
-       ".cm-line": {
-           display: "block",
-           padding: "0 2px 0 4px"
-       },
-       ".cm-selectionLayer": {
-           zIndex: -1,
-           contain: "size style"
-       },
-       ".cm-selectionBackground": {
-           position: "absolute",
-       },
-       "&light .cm-selectionBackground": {
-           background: "#d9d9d9"
-       },
-       "&dark .cm-selectionBackground": {
-           background: "#222"
-       },
-       "&light.cm-focused .cm-selectionBackground": {
-           background: "#d7d4f0"
-       },
-       "&dark.cm-focused .cm-selectionBackground": {
-           background: "#233"
-       },
-       ".cm-cursorLayer": {
-           zIndex: 100,
-           contain: "size style",
-           pointerEvents: "none"
-       },
-       "&.cm-focused .cm-cursorLayer": {
-           animation: "steps(1) cm-blink 1.2s infinite"
-       },
-       // Two animations defined so that we can switch between them to
-       // restart the animation without forcing another style
-       // recomputation.
-       "@keyframes cm-blink": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
-       "@keyframes cm-blink2": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
-       ".cm-cursor, .cm-dropCursor": {
-           position: "absolute",
-           borderLeft: "1.2px solid black",
-           marginLeft: "-0.6px",
-           pointerEvents: "none",
-       },
-       ".cm-cursor": {
-           display: "none"
-       },
-       "&dark .cm-cursor": {
-           borderLeftColor: "#444"
-       },
-       "&.cm-focused .cm-cursor": {
-           display: "block"
-       },
-       "&light .cm-activeLine": { backgroundColor: "#f3f9ff" },
-       "&dark .cm-activeLine": { backgroundColor: "#223039" },
-       "&light .cm-specialChar": { color: "red" },
-       "&dark .cm-specialChar": { color: "#f78" },
-       ".cm-gutters": {
-           display: "flex",
-           height: "100%",
-           boxSizing: "border-box",
-           left: 0,
-           zIndex: 200
-       },
-       "&light .cm-gutters": {
-           backgroundColor: "#f5f5f5",
-           color: "#6c6c6c",
-           borderRight: "1px solid #ddd"
-       },
-       "&dark .cm-gutters": {
-           backgroundColor: "#333338",
-           color: "#ccc"
-       },
-       ".cm-gutter": {
-           display: "flex !important",
-           flexDirection: "column",
-           flexShrink: 0,
-           boxSizing: "border-box",
-           minHeight: "100%",
-           overflow: "hidden"
-       },
-       ".cm-gutterElement": {
-           boxSizing: "border-box"
-       },
-       ".cm-lineNumbers .cm-gutterElement": {
-           padding: "0 3px 0 5px",
-           minWidth: "20px",
-           textAlign: "right",
-           whiteSpace: "nowrap"
-       },
-       "&light .cm-activeLineGutter": {
-           backgroundColor: "#e2f2ff"
-       },
-       "&dark .cm-activeLineGutter": {
-           backgroundColor: "#222227"
-       },
-       ".cm-panels": {
-           boxSizing: "border-box",
-           position: "sticky",
-           left: 0,
-           right: 0
-       },
-       "&light .cm-panels": {
-           backgroundColor: "#f5f5f5",
-           color: "black"
-       },
-       "&light .cm-panels-top": {
-           borderBottom: "1px solid #ddd"
-       },
-       "&light .cm-panels-bottom": {
-           borderTop: "1px solid #ddd"
-       },
-       "&dark .cm-panels": {
-           backgroundColor: "#333338",
-           color: "white"
-       },
-       ".cm-tab": {
-           display: "inline-block",
-           overflow: "hidden",
-           verticalAlign: "bottom"
-       },
-       ".cm-widgetBuffer": {
-           verticalAlign: "text-top",
-           height: "1em",
-           display: "inline"
-       },
-       ".cm-placeholder": {
-           color: "#888",
-           display: "inline-block",
-           verticalAlign: "top",
-       },
-       ".cm-button": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           padding: ".2em 1em",
-           borderRadius: "1px"
-       },
-       "&light .cm-button": {
-           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
-           }
-       },
-       "&dark .cm-button": {
-           backgroundImage: "linear-gradient(#393939, #111)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#111, #333)"
-           }
-       },
-       ".cm-textfield": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           border: "1px solid silver",
-           padding: ".2em .5em"
-       },
-       "&light .cm-textfield": {
-           backgroundColor: "white"
-       },
-       "&dark .cm-textfield": {
-           border: "1px solid #555",
-           backgroundColor: "inherit"
-       }
-   }, lightDarkIDs$2);
-
-   const observeOptions$2 = {
-       childList: true,
-       characterData: true,
-       subtree: true,
-       attributes: true,
-       characterDataOldValue: true
-   };
-   // IE11 has very broken mutation observers, so we also listen to
-   // DOMCharacterDataModified there
-   const useCharData$2 = browser$2.ie && browser$2.ie_version <= 11;
-   let DOMObserver$2 = class DOMObserver {
-       constructor(view, onChange, onScrollChanged) {
-           this.view = view;
-           this.onChange = onChange;
-           this.onScrollChanged = onScrollChanged;
-           this.active = false;
-           // The known selection. Kept in our own object, as opposed to just
-           // directly accessing the selection because:
-           //  - Safari doesn't report the right selection in shadow DOM
-           //  - Reading from the selection forces a DOM layout
-           //  - This way, we can ignore selectionchange events if we have
-           //    already seen the 'new' selection
-           this.selectionRange = new DOMSelectionState$2;
-           // Set when a selection change is detected, cleared on flush
-           this.selectionChanged = false;
-           this.delayedFlush = -1;
-           this.resizeTimeout = -1;
-           this.queue = [];
-           this.delayedAndroidKey = null;
-           this.scrollTargets = [];
-           this.intersection = null;
-           this.resize = null;
-           this.intersecting = false;
-           this.gapIntersection = null;
-           this.gaps = [];
-           // Timeout for scheduling check of the parents that need scroll handlers
-           this.parentCheck = -1;
-           this.dom = view.contentDOM;
-           this.observer = new MutationObserver(mutations => {
-               for (let mut of mutations)
-                   this.queue.push(mut);
-               // IE11 will sometimes (on typing over a selection or
-               // backspacing out a single character text node) call the
-               // observer callback before actually updating the DOM.
-               //
-               // Unrelatedly, iOS Safari will, when ending a composition,
-               // sometimes first clear it, deliver the mutations, and then
-               // reinsert the finished text. CodeMirror's handling of the
-               // deletion will prevent the reinsertion from happening,
-               // breaking composition.
-               if ((browser$2.ie && browser$2.ie_version <= 11 || browser$2.ios && view.composing) &&
-                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
-                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
-                   this.flushSoon();
-               else
-                   this.flush();
-           });
-           if (useCharData$2)
-               this.onCharData = (event) => {
-                   this.queue.push({ target: event.target,
-                       type: "characterData",
-                       oldValue: event.prevValue });
-                   this.flushSoon();
-               };
-           this.onSelectionChange = this.onSelectionChange.bind(this);
-           window.addEventListener("resize", this.onResize = this.onResize.bind(this));
-           if (typeof ResizeObserver == "function") {
-               this.resize = new ResizeObserver(() => {
-                   if (this.view.docView.lastUpdate < Date.now() - 75)
-                       this.onResize();
-               });
-               this.resize.observe(view.scrollDOM);
-           }
-           window.addEventListener("beforeprint", this.onPrint = this.onPrint.bind(this));
-           this.start();
-           window.addEventListener("scroll", this.onScroll = this.onScroll.bind(this));
-           if (typeof IntersectionObserver == "function") {
-               this.intersection = new IntersectionObserver(entries => {
-                   if (this.parentCheck < 0)
-                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
-                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
-                       this.intersecting = !this.intersecting;
-                       if (this.intersecting != this.view.inView)
-                           this.onScrollChanged(document.createEvent("Event"));
-                   }
-               }, {});
-               this.intersection.observe(this.dom);
-               this.gapIntersection = new IntersectionObserver(entries => {
-                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
-                       this.onScrollChanged(document.createEvent("Event"));
-               }, {});
-           }
-           this.listenForScroll();
-           this.readSelectionRange();
-           this.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
-       }
-       onScroll(e) {
-           if (this.intersecting)
-               this.flush(false);
-           this.onScrollChanged(e);
-       }
-       onResize() {
-           if (this.resizeTimeout < 0)
-               this.resizeTimeout = setTimeout(() => {
-                   this.resizeTimeout = -1;
-                   this.view.requestMeasure();
-               }, 50);
-       }
-       onPrint() {
-           this.view.viewState.printing = true;
-           this.view.measure();
-           setTimeout(() => {
-               this.view.viewState.printing = false;
-               this.view.requestMeasure();
-           }, 500);
-       }
-       updateGaps(gaps) {
-           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
-               this.gapIntersection.disconnect();
-               for (let gap of gaps)
-                   this.gapIntersection.observe(gap);
-               this.gaps = gaps;
-           }
-       }
-       onSelectionChange(event) {
-           if (!this.readSelectionRange() || this.delayedAndroidKey)
-               return;
-           let { view } = this, sel = this.selectionRange;
-           if (view.state.facet(editable$2) ? view.root.activeElement != this.dom : !hasSelection$2(view.dom, sel))
-               return;
-           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
-           if (context && context.ignoreEvent(event))
-               return;
-           // Deletions on IE11 fire their events in the wrong order, giving
-           // us a selection change event before the DOM changes are
-           // reported.
-           // Chrome Android has a similar issue when backspacing out a
-           // selection (#645).
-           if ((browser$2.ie && browser$2.ie_version <= 11 || browser$2.android && browser$2.chrome) && !view.state.selection.main.empty &&
-               // (Selection.isCollapsed isn't reliable on IE)
-               sel.focusNode && isEquivalentPosition$2(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
-               this.flushSoon();
-           else
-               this.flush(false);
-       }
-       readSelectionRange() {
-           let { root } = this.view, domSel = getSelection$2(root);
-           // The Selection object is broken in shadow roots in Safari. See
-           // https://github.com/codemirror/codemirror.next/issues/414
-           let range = browser$2.safari && root.nodeType == 11 && deepActiveElement$1() == this.view.contentDOM &&
-               safariSelectionRangeHack$2(this.view) || domSel;
-           if (this.selectionRange.eq(range))
-               return false;
-           this.selectionRange.setRange(range);
-           return this.selectionChanged = true;
-       }
-       setSelectionRange(anchor, head) {
-           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
-           this.selectionChanged = false;
-       }
-       clearSelectionRange() {
-           this.selectionRange.set(null, 0, null, 0);
-       }
-       listenForScroll() {
-           this.parentCheck = -1;
-           let i = 0, changed = null;
-           for (let dom = this.dom; dom;) {
-               if (dom.nodeType == 1) {
-                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
-                       i++;
-                   else if (!changed)
-                       changed = this.scrollTargets.slice(0, i);
-                   if (changed)
-                       changed.push(dom);
-                   dom = dom.assignedSlot || dom.parentNode;
-               }
-               else if (dom.nodeType == 11) { // Shadow root
-                   dom = dom.host;
-               }
-               else {
-                   break;
-               }
-           }
-           if (i < this.scrollTargets.length && !changed)
-               changed = this.scrollTargets.slice(0, i);
-           if (changed) {
-               for (let dom of this.scrollTargets)
-                   dom.removeEventListener("scroll", this.onScroll);
-               for (let dom of this.scrollTargets = changed)
-                   dom.addEventListener("scroll", this.onScroll);
-           }
-       }
-       ignore(f) {
-           if (!this.active)
-               return f();
-           try {
-               this.stop();
-               return f();
-           }
-           finally {
-               this.start();
-               this.clear();
-           }
-       }
-       start() {
-           if (this.active)
-               return;
-           this.observer.observe(this.dom, observeOptions$2);
-           if (useCharData$2)
-               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
-           this.active = true;
-       }
-       stop() {
-           if (!this.active)
-               return;
-           this.active = false;
-           this.observer.disconnect();
-           if (useCharData$2)
-               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
-       }
-       // Throw away any pending changes
-       clear() {
-           this.processRecords();
-           this.queue.length = 0;
-           this.selectionChanged = false;
-       }
-       // Chrome Android, especially in combination with GBoard, not only
-       // doesn't reliably fire regular key events, but also often
-       // surrounds the effect of enter or backspace with a bunch of
-       // composition events that, when interrupted, cause text duplication
-       // or other kinds of corruption. This hack makes the editor back off
-       // from handling DOM changes for a moment when such a key is
-       // detected (via beforeinput or keydown), and then tries to flush
-       // them or, if that has no effect, dispatches the given key.
-       delayAndroidKey(key, keyCode) {
-           if (!this.delayedAndroidKey)
-               requestAnimationFrame(() => {
-                   let key = this.delayedAndroidKey;
-                   this.delayedAndroidKey = null;
-                   this.delayedFlush = -1;
-                   if (!this.flush())
-                       dispatchKey$2(this.view.contentDOM, key.key, key.keyCode);
-               });
-           // Since backspace beforeinput is sometimes signalled spuriously,
-           // Enter always takes precedence.
-           if (!this.delayedAndroidKey || key == "Enter")
-               this.delayedAndroidKey = { key, keyCode };
-       }
-       flushSoon() {
-           if (this.delayedFlush < 0)
-               this.delayedFlush = window.setTimeout(() => { this.delayedFlush = -1; this.flush(); }, 20);
-       }
-       forceFlush() {
-           if (this.delayedFlush >= 0) {
-               window.clearTimeout(this.delayedFlush);
-               this.delayedFlush = -1;
-               this.flush();
-           }
-       }
-       processRecords() {
-           let records = this.queue;
-           for (let mut of this.observer.takeRecords())
-               records.push(mut);
-           if (records.length)
-               this.queue = [];
-           let from = -1, to = -1, typeOver = false;
-           for (let record of records) {
-               let range = this.readMutation(record);
-               if (!range)
-                   continue;
-               if (range.typeOver)
-                   typeOver = true;
-               if (from == -1) {
-                   ({ from, to } = range);
-               }
-               else {
-                   from = Math.min(range.from, from);
-                   to = Math.max(range.to, to);
-               }
-           }
-           return { from, to, typeOver };
-       }
-       // Apply pending changes, if any
-       flush(readSelection = true) {
-           // Completely hold off flushing when pending keys are set—the code
-           // managing those will make sure processRecords is called and the
-           // view is resynchronized after
-           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
-               return;
-           if (readSelection)
-               this.readSelectionRange();
-           let { from, to, typeOver } = this.processRecords();
-           let newSel = this.selectionChanged && hasSelection$2(this.dom, this.selectionRange);
-           if (from < 0 && !newSel)
-               return;
-           this.selectionChanged = false;
-           let startState = this.view.state;
-           let handled = this.onChange(from, to, typeOver);
-           // The view wasn't updated
-           if (this.view.state == startState)
-               this.view.update([]);
-           return handled;
-       }
-       readMutation(rec) {
-           let cView = this.view.docView.nearest(rec.target);
-           if (!cView || cView.ignoreMutation(rec))
-               return null;
-           cView.markDirty(rec.type == "attributes");
-           if (rec.type == "attributes")
-               cView.dirty |= 4 /* Attrs */;
-           if (rec.type == "childList") {
-               let childBefore = findChild$2(cView, rec.previousSibling || rec.target.previousSibling, -1);
-               let childAfter = findChild$2(cView, rec.nextSibling || rec.target.nextSibling, 1);
-               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
-                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
-           }
-           else if (rec.type == "characterData") {
-               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
-           }
-           else {
-               return null;
-           }
-       }
-       destroy() {
-           var _a, _b, _c;
-           this.stop();
-           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
-           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
-           (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
-           for (let dom of this.scrollTargets)
-               dom.removeEventListener("scroll", this.onScroll);
-           window.removeEventListener("scroll", this.onScroll);
-           window.removeEventListener("resize", this.onResize);
-           window.removeEventListener("beforeprint", this.onPrint);
-           this.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
-           clearTimeout(this.parentCheck);
-           clearTimeout(this.resizeTimeout);
-       }
-   };
-   function findChild$2(cView, dom, dir) {
-       while (dom) {
-           let curView = ContentView$2.get(dom);
-           if (curView && curView.parent == cView)
-               return curView;
-           let parent = dom.parentNode;
-           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
-       }
-       return null;
-   }
-   // Used to work around a Safari Selection/shadow DOM bug (#414)
-   function safariSelectionRangeHack$2(view) {
-       let found = null;
-       // Because Safari (at least in 2018-2021) doesn't provide regular
-       // access to the selection inside a shadowroot, we have to perform a
-       // ridiculous hack to get at it—using `execCommand` to trigger a
-       // `beforeInput` event so that we can read the target range from the
-       // event.
-       function read(event) {
-           event.preventDefault();
-           event.stopImmediatePropagation();
-           found = event.getTargetRanges()[0];
-       }
-       view.contentDOM.addEventListener("beforeinput", read, true);
-       document.execCommand("indent");
-       view.contentDOM.removeEventListener("beforeinput", read, true);
-       if (!found)
-           return null;
-       let anchorNode = found.startContainer, anchorOffset = found.startOffset;
-       let focusNode = found.endContainer, focusOffset = found.endOffset;
-       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
-       // Since such a range doesn't distinguish between anchor and head,
-       // use a heuristic that flips it around if its end matches the
-       // current anchor.
-       if (isEquivalentPosition$2(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
-           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
-       return { anchorNode, anchorOffset, focusNode, focusOffset };
-   }
-
-   function applyDOMChange$2(view, start, end, typeOver) {
-       let change, newSel;
-       let sel = view.state.selection.main;
-       if (start > -1) {
-           let bounds = view.docView.domBoundsAround(start, end, 0);
-           if (!bounds || view.state.readOnly)
-               return false;
-           let { from, to } = bounds;
-           let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints$2(view);
-           let reader = new DOMReader$2(selPoints, view.state);
-           reader.readRange(bounds.startDOM, bounds.endDOM);
-           let preferredPos = sel.from, preferredSide = null;
-           // Prefer anchoring to end when Backspace is pressed (or, on
-           // Android, when something was deleted)
-           if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 ||
-               browser$2.android && reader.text.length < to - from) {
-               preferredPos = sel.to;
-               preferredSide = "end";
-           }
-           let diff = findDiff$2(view.state.doc.sliceString(from, to, LineBreakPlaceholder$2), reader.text, preferredPos - from, preferredSide);
-           if (diff) {
-               // Chrome inserts two newlines when pressing shift-enter at the
-               // end of a line. This drops one of those.
-               if (browser$2.chrome && view.inputState.lastKeyCode == 13 &&
-                   diff.toB == diff.from + 2 && reader.text.slice(diff.from, diff.toB) == LineBreakPlaceholder$2 + LineBreakPlaceholder$2)
-                   diff.toB--;
-               change = { from: from + diff.from, to: from + diff.toA,
-                   insert: Text$2.of(reader.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder$2)) };
-           }
-           newSel = selectionFromPoints$2(selPoints, from);
-       }
-       else if (view.hasFocus || !view.state.facet(editable$2)) {
-           let domSel = view.observer.selectionRange;
-           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
-           let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
-               !contains$2(view.contentDOM, domSel.focusNode)
-               ? view.state.selection.main.head
-               : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
-           let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
-               !contains$2(view.contentDOM, domSel.anchorNode)
-               ? view.state.selection.main.anchor
-               : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
-           if (head != sel.head || anchor != sel.anchor)
-               newSel = EditorSelection$2.single(anchor, head);
-       }
-       if (!change && !newSel)
-           return false;
-       // Heuristic to notice typing over a selected character
-       if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
-           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
-       // If the change is inside the selection and covers most of it,
-       // assume it is a selection replace (with identical characters at
-       // the start/end not included in the diff)
-       else if (change && change.from >= sel.from && change.to <= sel.to &&
-           (change.from != sel.from || change.to != sel.to) &&
-           (sel.to - sel.from) - (change.to - change.from) <= 4)
-           change = {
-               from: sel.from, to: sel.to,
-               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
-           };
-       // Detect insert-period-on-double-space Mac behavior, and transform
-       // it into a regular space insert.
-       else if ((browser$2.mac || browser$2.android) && change && change.from == change.to && change.from == sel.head - 1 &&
-           change.insert.toString() == ".")
-           change = { from: sel.from, to: sel.to, insert: Text$2.of([" "]) };
-       if (change) {
-           let startState = view.state;
-           if (browser$2.ios && view.inputState.flushIOSKey(view))
-               return true;
-           // Android browsers don't fire reasonable key events for enter,
-           // backspace, or delete. So this detects changes that look like
-           // they're caused by those keys, and reinterprets them as key
-           // events. (Some of these keys are also handled by beforeinput
-           // events and the pendingAndroidKey mechanism, but that's not
-           // reliable in all situations.)
-           if (browser$2.android &&
-               ((change.from == sel.from && change.to == sel.to &&
-                   change.insert.length == 1 && change.insert.lines == 2 &&
-                   dispatchKey$2(view.contentDOM, "Enter", 13)) ||
-                   (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 &&
-                       dispatchKey$2(view.contentDOM, "Backspace", 8)) ||
-                   (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
-                       dispatchKey$2(view.contentDOM, "Delete", 46))))
-               return true;
-           let text = change.insert.toString();
-           if (view.state.facet(inputHandler$3).some(h => h(view, change.from, change.to, text)))
-               return true;
-           if (view.inputState.composing >= 0)
-               view.inputState.composing++;
-           let tr;
-           if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
-               (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
-               view.inputState.composing < 0) {
-               let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
-               let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
-               tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
-           }
-           else {
-               let changes = startState.changes(change);
-               let mainSel = newSel && !startState.selection.main.eq(newSel.main) && newSel.main.to <= changes.newLength
-                   ? newSel.main : undefined;
-               // Try to apply a composition change to all cursors
-               if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
-                   change.to <= sel.to && change.to >= sel.to - 10) {
-                   let replaced = view.state.sliceDoc(change.from, change.to);
-                   let compositionRange = compositionSurroundingNode$1(view) || view.state.doc.lineAt(sel.head);
-                   let offset = sel.to - change.to, size = sel.to - sel.from;
-                   tr = startState.changeByRange(range => {
-                       if (range.from == sel.from && range.to == sel.to)
-                           return { changes, range: mainSel || range.map(changes) };
-                       let to = range.to - offset, from = to - replaced.length;
-                       if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
-                           // Unfortunately, there's no way to make multiple
-                           // changes in the same node work without aborting
-                           // composition, so cursors in the composition range are
-                           // ignored.
-                           compositionRange && range.to >= compositionRange.from && range.from <= compositionRange.to)
-                           return { range };
-                       let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
-                       return {
-                           changes: rangeChanges,
-                           range: !mainSel ? range.map(rangeChanges) :
-                               EditorSelection$2.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
-                       };
-                   });
-               }
-               else {
-                   tr = {
-                       changes,
-                       selection: mainSel && startState.selection.replaceRange(mainSel)
-                   };
-               }
-           }
-           let userEvent = "input.type";
-           if (view.composing) {
-               userEvent += ".compose";
-               if (view.inputState.compositionFirstChange) {
-                   userEvent += ".start";
-                   view.inputState.compositionFirstChange = false;
-               }
-           }
-           view.dispatch(tr, { scrollIntoView: true, userEvent });
-           return true;
-       }
-       else if (newSel && !newSel.main.eq(sel)) {
-           let scrollIntoView = false, userEvent = "select";
-           if (view.inputState.lastSelectionTime > Date.now() - 50) {
-               if (view.inputState.lastSelectionOrigin == "select")
-                   scrollIntoView = true;
-               userEvent = view.inputState.lastSelectionOrigin;
-           }
-           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
-           return true;
-       }
-       else {
-           return false;
-       }
-   }
-   function findDiff$2(a, b, preferredPos, preferredSide) {
-       let minLen = Math.min(a.length, b.length);
-       let from = 0;
-       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
-           from++;
-       if (from == minLen && a.length == b.length)
-           return null;
-       let toA = a.length, toB = b.length;
-       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
-           toA--;
-           toB--;
-       }
-       if (preferredSide == "end") {
-           let adjust = Math.max(0, from - Math.min(toA, toB));
-           preferredPos -= toA + adjust - from;
-       }
-       if (toA < from && a.length < b.length) {
-           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
-           from -= move;
-           toB = from + (toB - toA);
-           toA = from;
-       }
-       else if (toB < from) {
-           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
-           from -= move;
-           toA = from + (toA - toB);
-           toB = from;
-       }
-       return { from, toA, toB };
-   }
-   function selectionPoints$2(view) {
-       let result = [];
-       if (view.root.activeElement != view.contentDOM)
-           return result;
-       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
-       if (anchorNode) {
-           result.push(new DOMPoint$2(anchorNode, anchorOffset));
-           if (focusNode != anchorNode || focusOffset != anchorOffset)
-               result.push(new DOMPoint$2(focusNode, focusOffset));
-       }
-       return result;
-   }
-   function selectionFromPoints$2(points, base) {
-       if (points.length == 0)
-           return null;
-       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
-       return anchor > -1 && head > -1 ? EditorSelection$2.single(anchor + base, head + base) : null;
-   }
-
-   // The editor's update state machine looks something like this:
-   //
-   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
-   //                                         ↑      ↓
-   //                                         Updating (measure)
-   //
-   // The difference between 'Idle' and 'Idle (unchecked)' lies in
-   // whether a layout check has been scheduled. A regular update through
-   // the `update` method updates the DOM in a write-only fashion, and
-   // relies on a check (scheduled with `requestAnimationFrame`) to make
-   // sure everything is where it should be and the viewport covers the
-   // visible code. That check continues to measure and then optionally
-   // update until it reaches a coherent state.
-   /**
-   An editor view represents the editor's user interface. It holds
-   the editable DOM surface, and possibly other elements such as the
-   line number gutter. It handles events and dispatches state
-   transactions for editing actions.
-   */
-   let EditorView$2 = class EditorView {
-       /**
-       Construct a new view. You'll want to either provide a `parent`
-       option, or put `view.dom` into your document after creating a
-       view, so that the user can see the editor.
-       */
-       constructor(
-       /**
-       Initialization options.
-       */
-       config = {}) {
-           this.plugins = [];
-           this.pluginMap = new Map;
-           this.editorAttrs = {};
-           this.contentAttrs = {};
-           this.bidiCache = [];
-           this.destroyed = false;
-           /**
-           @internal
-           */
-           this.updateState = 2 /* Updating */;
-           /**
-           @internal
-           */
-           this.measureScheduled = -1;
-           /**
-           @internal
-           */
-           this.measureRequests = [];
-           this.contentDOM = document.createElement("div");
-           this.scrollDOM = document.createElement("div");
-           this.scrollDOM.tabIndex = -1;
-           this.scrollDOM.className = "cm-scroller";
-           this.scrollDOM.appendChild(this.contentDOM);
-           this.announceDOM = document.createElement("div");
-           this.announceDOM.style.cssText = "position: absolute; top: -10000px";
-           this.announceDOM.setAttribute("aria-live", "polite");
-           this.dom = document.createElement("div");
-           this.dom.appendChild(this.announceDOM);
-           this.dom.appendChild(this.scrollDOM);
-           this._dispatch = config.dispatch || ((tr) => this.update([tr]));
-           this.dispatch = this.dispatch.bind(this);
-           this.root = (config.root || getRoot$2(config.parent) || document);
-           this.viewState = new ViewState$2(config.state || EditorState$2.create());
-           this.plugins = this.state.facet(viewPlugin$2).map(spec => new PluginInstance$2(spec));
-           for (let plugin of this.plugins)
-               plugin.update(this);
-           this.observer = new DOMObserver$2(this, (from, to, typeOver) => {
-               return applyDOMChange$2(this, from, to, typeOver);
-           }, event => {
-               this.inputState.runScrollHandlers(this, event);
-               if (this.observer.intersecting)
-                   this.measure();
-           });
-           this.inputState = new InputState$2(this);
-           this.inputState.ensureHandlers(this, this.plugins);
-           this.docView = new DocView$2(this);
-           this.mountStyles();
-           this.updateAttrs();
-           this.updateState = 0 /* Idle */;
-           this.requestMeasure();
-           if (config.parent)
-               config.parent.appendChild(this.dom);
-       }
-       /**
-       The current editor state.
-       */
-       get state() { return this.viewState.state; }
-       /**
-       To be able to display large documents without consuming too much
-       memory or overloading the browser, CodeMirror only draws the
-       code that is visible (plus a margin around it) to the DOM. This
-       property tells you the extent of the current drawn viewport, in
-       document positions.
-       */
-       get viewport() { return this.viewState.viewport; }
-       /**
-       When there are, for example, large collapsed ranges in the
-       viewport, its size can be a lot bigger than the actual visible
-       content. Thus, if you are doing something like styling the
-       content in the viewport, it is preferable to only do so for
-       these ranges, which are the subset of the viewport that is
-       actually drawn.
-       */
-       get visibleRanges() { return this.viewState.visibleRanges; }
-       /**
-       Returns false when the editor is entirely scrolled out of view
-       or otherwise hidden.
-       */
-       get inView() { return this.viewState.inView; }
-       /**
-       Indicates whether the user is currently composing text via
-       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
-       one change has been made in the current composition.
-       */
-       get composing() { return this.inputState.composing > 0; }
-       /**
-       Indicates whether the user is currently in composing state. Note
-       that on some platforms, like Android, this will be the case a
-       lot, since just putting the cursor on a word starts a
-       composition there.
-       */
-       get compositionStarted() { return this.inputState.composing >= 0; }
-       dispatch(...input) {
-           this._dispatch(input.length == 1 && input[0] instanceof Transaction$2 ? input[0]
-               : this.state.update(...input));
-       }
-       /**
-       Update the view for the given array of transactions. This will
-       update the visible document and selection to match the state
-       produced by the transactions, and notify view plugins of the
-       change. You should usually call
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
-       as a primitive.
-       */
-       update(transactions) {
-           if (this.updateState != 0 /* Idle */)
-               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
-           let redrawn = false, attrsChanged = false, update;
-           let state = this.state;
-           for (let tr of transactions) {
-               if (tr.startState != state)
-                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
-               state = tr.state;
-           }
-           if (this.destroyed) {
-               this.viewState.state = state;
-               return;
-           }
-           this.observer.clear();
-           // When the phrases change, redraw the editor
-           if (state.facet(EditorState$2.phrases) != this.state.facet(EditorState$2.phrases))
-               return this.setState(state);
-           update = ViewUpdate$2.create(this, state, transactions);
-           let scrollTarget = this.viewState.scrollTarget;
-           try {
-               this.updateState = 2 /* Updating */;
-               for (let tr of transactions) {
-                   if (scrollTarget)
-                       scrollTarget = scrollTarget.map(tr.changes);
-                   if (tr.scrollIntoView) {
-                       let { main } = tr.state.selection;
-                       scrollTarget = new ScrollTarget$2(main.empty ? main : EditorSelection$2.cursor(main.head, main.head > main.anchor ? -1 : 1));
-                   }
-                   for (let e of tr.effects)
-                       if (e.is(scrollIntoView$4))
-                           scrollTarget = e.value;
-               }
-               this.viewState.update(update, scrollTarget);
-               this.bidiCache = CachedOrder$2.update(this.bidiCache, update.changes);
-               if (!update.empty) {
-                   this.updatePlugins(update);
-                   this.inputState.update(update);
-               }
-               redrawn = this.docView.update(update);
-               if (this.state.facet(styleModule$2) != this.styleModules)
-                   this.mountStyles();
-               attrsChanged = this.updateAttrs();
-               this.showAnnouncements(transactions);
-               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-           }
-           if (update.startState.facet(theme$2) != update.state.facet(theme$2))
-               this.viewState.mustMeasureContent = true;
-           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
-               this.requestMeasure();
-           if (!update.empty)
-               for (let listener of this.state.facet(updateListener$2))
-                   listener(update);
-       }
-       /**
-       Reset the view to the given state. (This will cause the entire
-       document to be redrawn and all view plugins to be reinitialized,
-       so you should probably only use it when the new state isn't
-       derived from the old state. Otherwise, use
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
-       */
-       setState(newState) {
-           if (this.updateState != 0 /* Idle */)
-               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
-           if (this.destroyed) {
-               this.viewState.state = newState;
-               return;
-           }
-           this.updateState = 2 /* Updating */;
-           let hadFocus = this.hasFocus;
-           try {
-               for (let plugin of this.plugins)
-                   plugin.destroy(this);
-               this.viewState = new ViewState$2(newState);
-               this.plugins = newState.facet(viewPlugin$2).map(spec => new PluginInstance$2(spec));
-               this.pluginMap.clear();
-               for (let plugin of this.plugins)
-                   plugin.update(this);
-               this.docView = new DocView$2(this);
-               this.inputState.ensureHandlers(this, this.plugins);
-               this.mountStyles();
-               this.updateAttrs();
-               this.bidiCache = [];
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-           }
-           if (hadFocus)
-               this.focus();
-           this.requestMeasure();
-       }
-       updatePlugins(update) {
-           let prevSpecs = update.startState.facet(viewPlugin$2), specs = update.state.facet(viewPlugin$2);
-           if (prevSpecs != specs) {
-               let newPlugins = [];
-               for (let spec of specs) {
-                   let found = prevSpecs.indexOf(spec);
-                   if (found < 0) {
-                       newPlugins.push(new PluginInstance$2(spec));
-                   }
-                   else {
-                       let plugin = this.plugins[found];
-                       plugin.mustUpdate = update;
-                       newPlugins.push(plugin);
-                   }
-               }
-               for (let plugin of this.plugins)
-                   if (plugin.mustUpdate != update)
-                       plugin.destroy(this);
-               this.plugins = newPlugins;
-               this.pluginMap.clear();
-               this.inputState.ensureHandlers(this, this.plugins);
-           }
-           else {
-               for (let p of this.plugins)
-                   p.mustUpdate = update;
-           }
-           for (let i = 0; i < this.plugins.length; i++)
-               this.plugins[i].update(this);
-       }
-       /**
-       @internal
-       */
-       measure(flush = true) {
-           if (this.destroyed)
-               return;
-           if (this.measureScheduled > -1)
-               cancelAnimationFrame(this.measureScheduled);
-           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
-           if (flush)
-               this.observer.flush();
-           let updated = null;
-           try {
-               for (let i = 0;; i++) {
-                   this.updateState = 1 /* Measuring */;
-                   let oldViewport = this.viewport;
-                   let changed = this.viewState.measure(this);
-                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
-                       break;
-                   if (i > 5) {
-                       console.warn(this.measureRequests.length
-                           ? "Measure loop restarted more than 5 times"
-                           : "Viewport failed to stabilize");
-                       break;
-                   }
-                   let measuring = [];
-                   // Only run measure requests in this cycle when the viewport didn't change
-                   if (!(changed & 4 /* Viewport */))
-                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
-                   let measured = measuring.map(m => {
-                       try {
-                           return m.read(this);
-                       }
-                       catch (e) {
-                           logException$2(this.state, e);
-                           return BadMeasure$2;
-                       }
-                   });
-                   let update = ViewUpdate$2.create(this, this.state, []), redrawn = false, scrolled = false;
-                   update.flags |= changed;
-                   if (!updated)
-                       updated = update;
-                   else
-                       updated.flags |= changed;
-                   this.updateState = 2 /* Updating */;
-                   if (!update.empty) {
-                       this.updatePlugins(update);
-                       this.inputState.update(update);
-                       this.updateAttrs();
-                       redrawn = this.docView.update(update);
-                   }
-                   for (let i = 0; i < measuring.length; i++)
-                       if (measured[i] != BadMeasure$2) {
-                           try {
-                               let m = measuring[i];
-                               if (m.write)
-                                   m.write(measured[i], this);
-                           }
-                           catch (e) {
-                               logException$2(this.state, e);
-                           }
-                       }
-                   if (this.viewState.scrollTarget) {
-                       this.docView.scrollIntoView(this.viewState.scrollTarget);
-                       this.viewState.scrollTarget = null;
-                       scrolled = true;
-                   }
-                   if (redrawn)
-                       this.docView.updateSelection(true);
-                   if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
-                       !scrolled && this.measureRequests.length == 0)
-                       break;
-               }
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-               this.measureScheduled = -1;
-           }
-           if (updated && !updated.empty)
-               for (let listener of this.state.facet(updateListener$2))
-                   listener(updated);
-       }
-       /**
-       Get the CSS classes for the currently active editor themes.
-       */
-       get themeClasses() {
-           return baseThemeID$2 + " " +
-               (this.state.facet(darkTheme$2) ? baseDarkID$2 : baseLightID$2) + " " +
-               this.state.facet(theme$2);
-       }
-       updateAttrs() {
-           let editorAttrs = attrsFromFacet$2(this, editorAttributes$2, {
-               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
-           });
-           let contentAttrs = {
-               spellcheck: "false",
-               autocorrect: "off",
-               autocapitalize: "off",
-               translate: "no",
-               contenteditable: !this.state.facet(editable$2) ? "false" : "true",
-               class: "cm-content",
-               style: `${browser$2.tabSize}: ${this.state.tabSize}`,
-               role: "textbox",
-               "aria-multiline": "true"
-           };
-           if (this.state.readOnly)
-               contentAttrs["aria-readonly"] = "true";
-           attrsFromFacet$2(this, contentAttributes$2, contentAttrs);
-           let changed = this.observer.ignore(() => {
-               let changedContent = updateAttrs$2(this.contentDOM, this.contentAttrs, contentAttrs);
-               let changedEditor = updateAttrs$2(this.dom, this.editorAttrs, editorAttrs);
-               return changedContent || changedEditor;
-           });
-           this.editorAttrs = editorAttrs;
-           this.contentAttrs = contentAttrs;
-           return changed;
-       }
-       showAnnouncements(trs) {
-           let first = true;
-           for (let tr of trs)
-               for (let effect of tr.effects)
-                   if (effect.is(EditorView.announce)) {
-                       if (first)
-                           this.announceDOM.textContent = "";
-                       first = false;
-                       let div = this.announceDOM.appendChild(document.createElement("div"));
-                       div.textContent = effect.value;
-                   }
-       }
-       mountStyles() {
-           this.styleModules = this.state.facet(styleModule$2);
-           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$3).reverse());
-       }
-       readMeasured() {
-           if (this.updateState == 2 /* Updating */)
-               throw new Error("Reading the editor layout isn't allowed during an update");
-           if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
-               this.measure(false);
-       }
-       /**
-       Schedule a layout measurement, optionally providing callbacks to
-       do custom DOM measuring followed by a DOM write phase. Using
-       this is preferable reading DOM layout directly from, for
-       example, an event handler, because it'll make sure measuring and
-       drawing done by other components is synchronized, avoiding
-       unnecessary DOM layout computations.
-       */
-       requestMeasure(request) {
-           if (this.measureScheduled < 0)
-               this.measureScheduled = requestAnimationFrame(() => this.measure());
-           if (request) {
-               if (request.key != null)
-                   for (let i = 0; i < this.measureRequests.length; i++) {
-                       if (this.measureRequests[i].key === request.key) {
-                           this.measureRequests[i] = request;
-                           return;
-                       }
-                   }
-               this.measureRequests.push(request);
-           }
-       }
-       /**
-       Get the value of a specific plugin, if present. Note that
-       plugins that crash can be dropped from a view, so even when you
-       know you registered a given plugin, it is recommended to check
-       the return value of this method.
-       */
-       plugin(plugin) {
-           let known = this.pluginMap.get(plugin);
-           if (known === undefined || known && known.spec != plugin)
-               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
-           return known && known.update(this).value;
-       }
-       /**
-       The top position of the document, in screen coordinates. This
-       may be negative when the editor is scrolled down. Points
-       directly to the top of the first line, not above the padding.
-       */
-       get documentTop() {
-           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
-       }
-       /**
-       Reports the padding above and below the document.
-       */
-       get documentPadding() {
-           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
-       }
-       /**
-       Find the text line or block widget at the given vertical
-       position (which is interpreted as relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
-       */
-       elementAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.elementAtHeight(height);
-       }
-       /**
-       Find the line block (see
-       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
-       height.
-       */
-       lineBlockAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.lineBlockAtHeight(height);
-       }
-       /**
-       Get the extent and vertical position of all [line
-       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
-       are relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
-       */
-       get viewportLineBlocks() {
-           return this.viewState.viewportLines;
-       }
-       /**
-       Find the line block around the given document position. A line
-       block is a range delimited on both sides by either a
-       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
-       start/end of the document. It will usually just hold a line of
-       text, but may be broken into multiple textblocks by block
-       widgets.
-       */
-       lineBlockAt(pos) {
-           return this.viewState.lineBlockAt(pos);
-       }
-       /**
-       The editor's total content height.
-       */
-       get contentHeight() {
-           return this.viewState.contentHeight;
-       }
-       /**
-       Move a cursor position by [grapheme
-       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
-       the motion is away from the line start, or towards it. In
-       bidirectional text, the line is traversed in visual order, using
-       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-       When the start position was the last one on the line, the
-       returned position will be across the line break. If there is no
-       further line, the original position is returned.
-       
-       By default, this method moves over a single cluster. The
-       optional `by` argument can be used to move across more. It will
-       be called with the first cluster as argument, and should return
-       a predicate that determines, for each subsequent cluster,
-       whether it should also be moved over.
-       */
-       moveByChar(start, forward, by) {
-           return skipAtoms$2(this, start, moveByChar$2(this, start, forward, by));
-       }
-       /**
-       Move a cursor position across the next group of either
-       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
-       non-whitespace characters.
-       */
-       moveByGroup(start, forward) {
-           return skipAtoms$2(this, start, moveByChar$2(this, start, forward, initial => byGroup$2(this, start.head, initial)));
-       }
-       /**
-       Move to the next line boundary in the given direction. If
-       `includeWrap` is true, line wrapping is on, and there is a
-       further wrap point on the current line, the wrap point will be
-       returned. Otherwise this function will return the start or end
-       of the line.
-       */
-       moveToLineBoundary(start, forward, includeWrap = true) {
-           return moveToLineBoundary$2(this, start, forward, includeWrap);
-       }
-       /**
-       Move a cursor position vertically. When `distance` isn't given,
-       it defaults to moving to the next line (including wrapped
-       lines). Otherwise, `distance` should provide a positive distance
-       in pixels.
-       
-       When `start` has a
-       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
-       motion will use that as a target horizontal position. Otherwise,
-       the cursor's own horizontal position is used. The returned
-       cursor will have its goal column set to whichever column was
-       used.
-       */
-       moveVertically(start, forward, distance) {
-           return skipAtoms$2(this, start, moveVertically$2(this, start, forward, distance));
-       }
-       /**
-       Find the DOM parent node and offset (child offset if `node` is
-       an element, character offset when it is a text node) at the
-       given document position.
-       
-       Note that for positions that aren't currently in
-       `visibleRanges`, the resulting DOM position isn't necessarily
-       meaningful (it may just point before or after a placeholder
-       element).
-       */
-       domAtPos(pos) {
-           return this.docView.domAtPos(pos);
-       }
-       /**
-       Find the document position at the given DOM node. Can be useful
-       for associating positions with DOM events. Will raise an error
-       when `node` isn't part of the editor content.
-       */
-       posAtDOM(node, offset = 0) {
-           return this.docView.posFromDOM(node, offset);
-       }
-       posAtCoords(coords, precise = true) {
-           this.readMeasured();
-           return posAtCoords$2(this, coords, precise);
-       }
-       /**
-       Get the screen coordinates at the given document position.
-       `side` determines whether the coordinates are based on the
-       element before (-1) or after (1) the position (if no element is
-       available on the given side, the method will transparently use
-       another strategy to get reasonable coordinates).
-       */
-       coordsAtPos(pos, side = 1) {
-           this.readMeasured();
-           let rect = this.docView.coordsAt(pos, side);
-           if (!rect || rect.left == rect.right)
-               return rect;
-           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
-           let span = order[BidiSpan$2.find(order, pos - line.from, -1, side)];
-           return flattenRect$2(rect, (span.dir == Direction$2.LTR) == (side > 0));
-       }
-       /**
-       The default width of a character in the editor. May not
-       accurately reflect the width of all characters (given variable
-       width fonts or styling of invididual ranges).
-       */
-       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
-       /**
-       The default height of a line in the editor. May not be accurate
-       for all lines.
-       */
-       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
-       /**
-       The text direction
-       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
-       CSS property) of the editor's content element.
-       */
-       get textDirection() { return this.viewState.defaultTextDirection; }
-       /**
-       Find the text direction of the block at the given position, as
-       assigned by CSS. If
-       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
-       isn't enabled, or the given position is outside of the viewport,
-       this will always return the same as
-       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
-       this may trigger a DOM layout.
-       */
-       textDirectionAt(pos) {
-           let perLine = this.state.facet(perLineTextDirection$2);
-           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
-               return this.textDirection;
-           this.readMeasured();
-           return this.docView.textDirectionAt(pos);
-       }
-       /**
-       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
-       (as determined by the
-       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
-       CSS property of its content element).
-       */
-       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
-       /**
-       Returns the bidirectional text structure of the given line
-       (which should be in the current document) as an array of span
-       objects. The order of these spans matches the [text
-       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
-       left-to-right, the leftmost spans come first, otherwise the
-       rightmost spans come first.
-       */
-       bidiSpans(line) {
-           if (line.length > MaxBidiLine$2)
-               return trivialOrder$2(line.length);
-           let dir = this.textDirectionAt(line.from);
-           for (let entry of this.bidiCache)
-               if (entry.from == line.from && entry.dir == dir)
-                   return entry.order;
-           let order = computeOrder$2(line.text, dir);
-           this.bidiCache.push(new CachedOrder$2(line.from, line.to, dir, order));
-           return order;
-       }
-       /**
-       Check whether the editor has focus.
-       */
-       get hasFocus() {
-           var _a;
-           // Safari return false for hasFocus when the context menu is open
-           // or closing, which leads us to ignore selection changes from the
-           // context menu because it looks like the editor isn't focused.
-           // This kludges around that.
-           return (document.hasFocus() || browser$2.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
-               this.root.activeElement == this.contentDOM;
-       }
-       /**
-       Put focus on the editor.
-       */
-       focus() {
-           this.observer.ignore(() => {
-               focusPreventScroll$2(this.contentDOM);
-               this.docView.updateSelection();
-           });
-       }
-       /**
-       Clean up this editor view, removing its element from the
-       document, unregistering event handlers, and notifying
-       plugins. The view instance can no longer be used after
-       calling this.
-       */
-       destroy() {
-           for (let plugin of this.plugins)
-               plugin.destroy(this);
-           this.plugins = [];
-           this.inputState.destroy();
-           this.dom.remove();
-           this.observer.destroy();
-           if (this.measureScheduled > -1)
-               cancelAnimationFrame(this.measureScheduled);
-           this.destroyed = true;
-       }
-       /**
-       Returns an effect that can be
-       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
-       cause it to scroll the given position or range into view.
-       */
-       static scrollIntoView(pos, options = {}) {
-           return scrollIntoView$4.of(new ScrollTarget$2(typeof pos == "number" ? EditorSelection$2.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
-       }
-       /**
-       Returns an extension that can be used to add DOM event handlers.
-       The value should be an object mapping event names to handler
-       functions. For any given event, such functions are ordered by
-       extension precedence, and the first handler to return true will
-       be assumed to have handled that event, and no other handlers or
-       built-in behavior will be activated for it. These are registered
-       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
-       for `scroll` handlers, which will be called any time the
-       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
-       its parent nodes is scrolled.
-       */
-       static domEventHandlers(handlers) {
-           return ViewPlugin$2.define(() => ({}), { eventHandlers: handlers });
-       }
-       /**
-       Create a theme extension. The first argument can be a
-       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
-       style spec providing the styles for the theme. These will be
-       prefixed with a generated class for the style.
-       
-       Because the selectors will be prefixed with a scope class, rule
-       that directly match the editor's [wrapper
-       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
-       added—need to be explicitly differentiated by adding an `&` to
-       the selector for that element—for example
-       `&.cm-focused`.
-       
-       When `dark` is set to true, the theme will be marked as dark,
-       which will cause the `&dark` rules from [base
-       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
-       `&light` when a light theme is active).
-       */
-       static theme(spec, options) {
-           let prefix = StyleModule.newName();
-           let result = [theme$2.of(prefix), styleModule$2.of(buildTheme$2(`.${prefix}`, spec))];
-           if (options && options.dark)
-               result.push(darkTheme$2.of(true));
-           return result;
-       }
-       /**
-       Create an extension that adds styles to the base theme. Like
-       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
-       place of the editor wrapper element when directly targeting
-       that. You can also use `&dark` or `&light` instead to only
-       target editors with a dark or light theme.
-       */
-       static baseTheme(spec) {
-           return Prec$2.lowest(styleModule$2.of(buildTheme$2("." + baseThemeID$2, spec, lightDarkIDs$2)));
-       }
-   };
-   /**
-   Facet to add a [style
-   module](https://github.com/marijnh/style-mod#documentation) to
-   an editor view. The view will ensure that the module is
-   mounted in its [document
-   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
-   */
-   EditorView$2.styleModule = styleModule$2;
-   /**
-   An input handler can override the way changes to the editable
-   DOM content are handled. Handlers are passed the document
-   positions between which the change was found, and the new
-   content. When one returns true, no further input handlers are
-   called and the default behavior is prevented.
-   */
-   EditorView$2.inputHandler = inputHandler$3;
-   /**
-   By default, the editor assumes all its content has the same
-   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
-   value to make it read the text direction of every (rendered)
-   line separately.
-   */
-   EditorView$2.perLineTextDirection = perLineTextDirection$2;
-   /**
-   Allows you to provide a function that should be called when the
-   library catches an exception from an extension (mostly from view
-   plugins, but may be used by other extensions to route exceptions
-   from user-code-provided callbacks). This is mostly useful for
-   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
-   */
-   EditorView$2.exceptionSink = exceptionSink$2;
-   /**
-   A facet that can be used to register a function to be called
-   every time the view updates.
-   */
-   EditorView$2.updateListener = updateListener$2;
-   /**
-   Facet that controls whether the editor content DOM is editable.
-   When its highest-precedence value is `false`, the element will
-   not have its `contenteditable` attribute set. (Note that this
-   doesn't affect API calls that change the editor content, even
-   when those are bound to keys or buttons. See the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
-   */
-   EditorView$2.editable = editable$2;
-   /**
-   Allows you to influence the way mouse selection happens. The
-   functions in this facet will be called for a `mousedown` event
-   on the editor, and can return an object that overrides the way a
-   selection is computed from that mouse click or drag.
-   */
-   EditorView$2.mouseSelectionStyle = mouseSelectionStyle$2;
-   /**
-   Facet used to configure whether a given selection drag event
-   should move or copy the selection. The given predicate will be
-   called with the `mousedown` event, and can return `true` when
-   the drag should move the content.
-   */
-   EditorView$2.dragMovesSelection = dragMovesSelection$1$2;
-   /**
-   Facet used to configure whether a given selecting click adds a
-   new range to the existing selection or replaces it entirely. The
-   default behavior is to check `event.metaKey` on macOS, and
-   `event.ctrlKey` elsewhere.
-   */
-   EditorView$2.clickAddsSelectionRange = clickAddsSelectionRange$2;
-   /**
-   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
-   are shown in the view. Decorations can be provided in two
-   ways—directly, or via a function that takes an editor view.
-
-   Only decoration sets provided directly are allowed to influence
-   the editor's vertical layout structure. The ones provided as
-   functions are called _after_ the new viewport has been computed,
-   and thus **must not** introduce block widgets or replacing
-   decorations that cover line breaks.
-   */
-   EditorView$2.decorations = decorations$2;
-   /**
-   Used to provide ranges that should be treated as atoms as far as
-   cursor motion is concerned. This causes methods like
-   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
-   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
-   commands built on top of them) to skip across such regions when
-   a selection endpoint would enter them. This does _not_ prevent
-   direct programmatic [selection
-   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
-   regions.
-   */
-   EditorView$2.atomicRanges = atomicRanges$2;
-   /**
-   Facet that allows extensions to provide additional scroll
-   margins (space around the sides of the scrolling element that
-   should be considered invisible). This can be useful when the
-   plugin introduces elements that cover part of that element (for
-   example a horizontally fixed gutter).
-   */
-   EditorView$2.scrollMargins = scrollMargins$2;
-   /**
-   This facet records whether a dark theme is active. The extension
-   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
-   includes an instance of this when the `dark` option is set to
-   true.
-   */
-   EditorView$2.darkTheme = darkTheme$2;
-   /**
-   Facet that provides additional DOM attributes for the editor's
-   editable DOM element.
-   */
-   EditorView$2.contentAttributes = contentAttributes$2;
-   /**
-   Facet that provides DOM attributes for the editor's outer
-   element.
-   */
-   EditorView$2.editorAttributes = editorAttributes$2;
-   /**
-   An extension that enables line wrapping in the editor (by
-   setting CSS `white-space` to `pre-wrap` in the content).
-   */
-   EditorView$2.lineWrapping = /*@__PURE__*/EditorView$2.contentAttributes.of({ "class": "cm-lineWrapping" });
-   /**
-   State effect used to include screen reader announcements in a
-   transaction. These will be added to the DOM in a visually hidden
-   element with `aria-live="polite"` set, and should be used to
-   describe effects that are visually obvious but may not be
-   noticed by screen reader users (such as moving to the next
-   search match).
-   */
-   EditorView$2.announce = /*@__PURE__*/StateEffect$2.define();
-   // Maximum line length for which we compute accurate bidi info
-   const MaxBidiLine$2 = 4096;
-   const BadMeasure$2 = {};
-   let CachedOrder$2 = class CachedOrder {
-       constructor(from, to, dir, order) {
-           this.from = from;
-           this.to = to;
-           this.dir = dir;
-           this.order = order;
-       }
-       static update(cache, changes) {
-           if (changes.empty)
-               return cache;
-           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction$2.LTR;
-           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
-               let entry = cache[i];
-               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
-                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.order));
-           }
-           return result;
-       }
-   };
-   function attrsFromFacet$2(view, facet, base) {
-       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
-           let source = sources[i], value = typeof source == "function" ? source(view) : source;
-           if (value)
-               combineAttrs$2(value, base);
-       }
-       return base;
-   }
-
-   const CanHidePrimary$2 = !browser$2.ios; // FIXME test IE
-   const themeSpec$2 = {
-       ".cm-line": {
-           "& ::selection": { backgroundColor: "transparent !important" },
-           "&::selection": { backgroundColor: "transparent !important" }
-       }
-   };
-   if (CanHidePrimary$2)
-       themeSpec$2[".cm-line"].caretColor = "transparent !important";
-
-   /**
-   A gutter marker represents a bit of information attached to a line
-   in a specific gutter. Your own custom markers have to extend this
-   class.
-   */
-   let GutterMarker$2 = class GutterMarker extends RangeValue$2 {
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       Compare this marker to another marker of the same type.
-       */
-       eq(other) { return false; }
-       /**
-       Called if the marker has a `toDOM` method and its representation
-       was removed from a gutter.
-       */
-       destroy(dom) { }
-   };
-   GutterMarker$2.prototype.elementClass = "";
-   GutterMarker$2.prototype.toDOM = undefined;
-   GutterMarker$2.prototype.mapMode = MapMode$2.TrackBefore;
-   GutterMarker$2.prototype.startSide = GutterMarker$2.prototype.endSide = -1;
-   GutterMarker$2.prototype.point = true;
-
-   // FIXME profile adding a per-Tree TreeNode cache, validating it by
-   // parent pointer
-   /// The default maximum length of a `TreeBuffer` node (1024).
-   const DefaultBufferLength$1 = 1024;
-   let nextPropID$1 = 0;
-   let Range$3 = class Range {
-       constructor(from, to) {
-           this.from = from;
-           this.to = to;
-       }
-   };
-   /// Each [node type](#common.NodeType) or [individual tree](#common.Tree)
-   /// can have metadata associated with it in props. Instances of this
-   /// class represent prop names.
-   let NodeProp$1 = class NodeProp {
-       /// Create a new node prop type.
-       constructor(config = {}) {
-           this.id = nextPropID$1++;
-           this.perNode = !!config.perNode;
-           this.deserialize = config.deserialize || (() => {
-               throw new Error("This node type doesn't define a deserialize function");
-           });
-       }
-       /// This is meant to be used with
-       /// [`NodeSet.extend`](#common.NodeSet.extend) or
-       /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
-       /// prop values for each node type in the set. Takes a [match
-       /// object](#common.NodeType^match) or function that returns undefined
-       /// if the node type doesn't get this prop, and the prop's value if
-       /// it does.
-       add(match) {
-           if (this.perNode)
-               throw new RangeError("Can't add per-node props to node types");
-           if (typeof match != "function")
-               match = NodeType$1.match(match);
-           return (type) => {
-               let result = match(type);
-               return result === undefined ? null : [this, result];
-           };
-       }
-   };
-   /// Prop that is used to describe matching delimiters. For opening
-   /// delimiters, this holds an array of node names (written as a
-   /// space-separated string when declaring this prop in a grammar)
-   /// for the node types of closing delimiters that match it.
-   NodeProp$1.closedBy = new NodeProp$1({ deserialize: str => str.split(" ") });
-   /// The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
-   /// attached to closing delimiters, holding an array of node names
-   /// of types of matching opening delimiters.
-   NodeProp$1.openedBy = new NodeProp$1({ deserialize: str => str.split(" ") });
-   /// Used to assign node types to groups (for example, all node
-   /// types that represent an expression could be tagged with an
-   /// `"Expression"` group).
-   NodeProp$1.group = new NodeProp$1({ deserialize: str => str.split(" ") });
-   /// The hash of the [context](#lr.ContextTracker.constructor)
-   /// that the node was parsed in, if any. Used to limit reuse of
-   /// contextual nodes.
-   NodeProp$1.contextHash = new NodeProp$1({ perNode: true });
-   /// The distance beyond the end of the node that the tokenizer
-   /// looked ahead for any of the tokens inside the node. (The LR
-   /// parser only stores this when it is larger than 25, for
-   /// efficiency reasons.)
-   NodeProp$1.lookAhead = new NodeProp$1({ perNode: true });
-   /// This per-node prop is used to replace a given node, or part of a
-   /// node, with another tree. This is useful to include trees from
-   /// different languages.
-   NodeProp$1.mounted = new NodeProp$1({ perNode: true });
-   const noProps$1 = Object.create(null);
-   /// Each node in a syntax tree has a node type associated with it.
-   let NodeType$1 = class NodeType {
-       /// @internal
-       constructor(
-       /// The name of the node type. Not necessarily unique, but if the
-       /// grammar was written properly, different node types with the
-       /// same name within a node set should play the same semantic
-       /// role.
-       name, 
-       /// @internal
-       props, 
-       /// The id of this node in its set. Corresponds to the term ids
-       /// used in the parser.
-       id, 
-       /// @internal
-       flags = 0) {
-           this.name = name;
-           this.props = props;
-           this.id = id;
-           this.flags = flags;
-       }
-       static define(spec) {
-           let props = spec.props && spec.props.length ? Object.create(null) : noProps$1;
-           let flags = (spec.top ? 1 /* Top */ : 0) | (spec.skipped ? 2 /* Skipped */ : 0) |
-               (spec.error ? 4 /* Error */ : 0) | (spec.name == null ? 8 /* Anonymous */ : 0);
-           let type = new NodeType(spec.name || "", props, spec.id, flags);
-           if (spec.props)
-               for (let src of spec.props) {
-                   if (!Array.isArray(src))
-                       src = src(type);
-                   if (src) {
-                       if (src[0].perNode)
-                           throw new RangeError("Can't store a per-node prop on a node type");
-                       props[src[0].id] = src[1];
-                   }
-               }
-           return type;
-       }
-       /// Retrieves a node prop for this type. Will return `undefined` if
-       /// the prop isn't present on this node.
-       prop(prop) { return this.props[prop.id]; }
-       /// True when this is the top node of a grammar.
-       get isTop() { return (this.flags & 1 /* Top */) > 0; }
-       /// True when this node is produced by a skip rule.
-       get isSkipped() { return (this.flags & 2 /* Skipped */) > 0; }
-       /// Indicates whether this is an error node.
-       get isError() { return (this.flags & 4 /* Error */) > 0; }
-       /// When true, this node type doesn't correspond to a user-declared
-       /// named node, for example because it is used to cache repetition.
-       get isAnonymous() { return (this.flags & 8 /* Anonymous */) > 0; }
-       /// Returns true when this node's name or one of its
-       /// [groups](#common.NodeProp^group) matches the given string.
-       is(name) {
-           if (typeof name == 'string') {
-               if (this.name == name)
-                   return true;
-               let group = this.prop(NodeProp$1.group);
-               return group ? group.indexOf(name) > -1 : false;
-           }
-           return this.id == name;
-       }
-       /// Create a function from node types to arbitrary values by
-       /// specifying an object whose property names are node or
-       /// [group](#common.NodeProp^group) names. Often useful with
-       /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
-       /// names, separated by spaces, in a single property name to map
-       /// multiple node names to a single value.
-       static match(map) {
-           let direct = Object.create(null);
-           for (let prop in map)
-               for (let name of prop.split(" "))
-                   direct[name] = map[prop];
-           return (node) => {
-               for (let groups = node.prop(NodeProp$1.group), i = -1; i < (groups ? groups.length : 0); i++) {
-                   let found = direct[i < 0 ? node.name : groups[i]];
-                   if (found)
-                       return found;
-               }
-           };
-       }
-   };
-   /// An empty dummy node type to use when no actual type is available.
-   NodeType$1.none = new NodeType$1("", Object.create(null), 0, 8 /* Anonymous */);
-   const CachedNode$1 = new WeakMap(), CachedInnerNode$1 = new WeakMap();
-   /// Options that control iteration. Can be combined with the `|`
-   /// operator to enable multiple ones.
-   var IterMode$1;
-   (function (IterMode) {
-       /// When enabled, iteration will only visit [`Tree`](#common.Tree)
-       /// objects, not nodes packed into
-       /// [`TreeBuffer`](#common.TreeBuffer)s.
-       IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
-       /// Enable this to make iteration include anonymous nodes (such as
-       /// the nodes that wrap repeated grammar constructs into a balanced
-       /// tree).
-       IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
-       /// By default, regular [mounted](#common.NodeProp^mounted) nodes
-       /// replace their base node in iteration. Enable this to ignore them
-       /// instead.
-       IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
-       /// This option only applies in
-       /// [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
-       /// library to not enter mounted overlays if one covers the given
-       /// position.
-       IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
-   })(IterMode$1 || (IterMode$1 = {}));
-   /// A piece of syntax tree. There are two ways to approach these
-   /// trees: the way they are actually stored in memory, and the
-   /// convenient way.
-   ///
-   /// Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
-   /// objects. By packing detail information into `TreeBuffer` leaf
-   /// nodes, the representation is made a lot more memory-efficient.
-   ///
-   /// However, when you want to actually work with tree nodes, this
-   /// representation is very awkward, so most client code will want to
-   /// use the [`TreeCursor`](#common.TreeCursor) or
-   /// [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
-   /// a view on some part of this data structure, and can be used to
-   /// move around to adjacent nodes.
-   let Tree$1 = class Tree {
-       /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
-       constructor(
-       /// The type of the top node.
-       type, 
-       /// This node's child nodes.
-       children, 
-       /// The positions (offsets relative to the start of this tree) of
-       /// the children.
-       positions, 
-       /// The total length of this tree
-       length, 
-       /// Per-node [node props](#common.NodeProp) to associate with this node.
-       props) {
-           this.type = type;
-           this.children = children;
-           this.positions = positions;
-           this.length = length;
-           /// @internal
-           this.props = null;
-           if (props && props.length) {
-               this.props = Object.create(null);
-               for (let [prop, value] of props)
-                   this.props[typeof prop == "number" ? prop : prop.id] = value;
-           }
-       }
-       /// @internal
-       toString() {
-           let mounted = this.prop(NodeProp$1.mounted);
-           if (mounted && !mounted.overlay)
-               return mounted.tree.toString();
-           let children = "";
-           for (let ch of this.children) {
-               let str = ch.toString();
-               if (str) {
-                   if (children)
-                       children += ",";
-                   children += str;
-               }
-           }
-           return !this.type.name ? children :
-               (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
-                   (children.length ? "(" + children + ")" : "");
-       }
-       /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
-       /// the tree. Mode can be used to [control](#common.IterMode) which
-       /// nodes the cursor visits.
-       cursor(mode = 0) {
-           return new TreeCursor$1(this.topNode, mode);
-       }
-       /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
-       /// at the given position and side (see
-       /// [`moveTo`](#common.TreeCursor.moveTo).
-       cursorAt(pos, side = 0, mode = 0) {
-           let scope = CachedNode$1.get(this) || this.topNode;
-           let cursor = new TreeCursor$1(scope);
-           cursor.moveTo(pos, side);
-           CachedNode$1.set(this, cursor._tree);
-           return cursor;
-       }
-       /// Get a [syntax node](#common.SyntaxNode) object for the top of the
-       /// tree.
-       get topNode() {
-           return new TreeNode$1(this, 0, 0, null);
-       }
-       /// Get the [syntax node](#common.SyntaxNode) at the given position.
-       /// If `side` is -1, this will move into nodes that end at the
-       /// position. If 1, it'll move into nodes that start at the
-       /// position. With 0, it'll only enter nodes that cover the position
-       /// from both sides.
-       resolve(pos, side = 0) {
-           let node = resolveNode$1(CachedNode$1.get(this) || this.topNode, pos, side, false);
-           CachedNode$1.set(this, node);
-           return node;
-       }
-       /// Like [`resolve`](#common.Tree.resolve), but will enter
-       /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
-       /// pointing into the innermost overlaid tree at the given position
-       /// (with parent links going through all parent structure, including
-       /// the host trees).
-       resolveInner(pos, side = 0) {
-           let node = resolveNode$1(CachedInnerNode$1.get(this) || this.topNode, pos, side, true);
-           CachedInnerNode$1.set(this, node);
-           return node;
-       }
-       /// Iterate over the tree and its children, calling `enter` for any
-       /// node that touches the `from`/`to` region (if given) before
-       /// running over such a node's children, and `leave` (if given) when
-       /// leaving the node. When `enter` returns `false`, that node will
-       /// not have its children iterated over (or `leave` called).
-       iterate(spec) {
-           let { enter, leave, from = 0, to = this.length } = spec;
-           for (let c = this.cursor((spec.mode || 0) | IterMode$1.IncludeAnonymous);;) {
-               let entered = false;
-               if (c.from <= to && c.to >= from && (c.type.isAnonymous || enter(c) !== false)) {
-                   if (c.firstChild())
-                       continue;
-                   entered = true;
-               }
-               for (;;) {
-                   if (entered && leave && !c.type.isAnonymous)
-                       leave(c);
-                   if (c.nextSibling())
-                       break;
-                   if (!c.parent())
-                       return;
-                   entered = true;
-               }
-           }
-       }
-       /// Get the value of the given [node prop](#common.NodeProp) for this
-       /// node. Works with both per-node and per-type props.
-       prop(prop) {
-           return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
-       }
-       /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
-       /// format that can be passed to the [`Tree`](#common.Tree)
-       /// constructor.
-       get propValues() {
-           let result = [];
-           if (this.props)
-               for (let id in this.props)
-                   result.push([+id, this.props[id]]);
-           return result;
-       }
-       /// Balance the direct children of this tree, producing a copy of
-       /// which may have children grouped into subtrees with type
-       /// [`NodeType.none`](#common.NodeType^none).
-       balance(config = {}) {
-           return this.children.length <= 8 /* BranchFactor */ ? this :
-               balanceRange$1(NodeType$1.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType$1.none, children, positions, length)));
-       }
-       /// Build a tree from a postfix-ordered buffer of node information,
-       /// or a cursor over such a buffer.
-       static build(data) { return buildTree$1(data); }
-   };
-   /// The empty tree
-   Tree$1.empty = new Tree$1(NodeType$1.none, [], [], 0);
-   let FlatBufferCursor$1 = class FlatBufferCursor {
-       constructor(buffer, index) {
-           this.buffer = buffer;
-           this.index = index;
-       }
-       get id() { return this.buffer[this.index - 4]; }
-       get start() { return this.buffer[this.index - 3]; }
-       get end() { return this.buffer[this.index - 2]; }
-       get size() { return this.buffer[this.index - 1]; }
-       get pos() { return this.index; }
-       next() { this.index -= 4; }
-       fork() { return new FlatBufferCursor(this.buffer, this.index); }
-   };
-   /// Tree buffers contain (type, start, end, endIndex) quads for each
-   /// node. In such a buffer, nodes are stored in prefix order (parents
-   /// before children, with the endIndex of the parent indicating which
-   /// children belong to it)
-   let TreeBuffer$1 = class TreeBuffer {
-       /// Create a tree buffer.
-       constructor(
-       /// The buffer's content.
-       buffer, 
-       /// The total length of the group of nodes in the buffer.
-       length, 
-       /// The node set used in this buffer.
-       set) {
-           this.buffer = buffer;
-           this.length = length;
-           this.set = set;
-       }
-       /// @internal
-       get type() { return NodeType$1.none; }
-       /// @internal
-       toString() {
-           let result = [];
-           for (let index = 0; index < this.buffer.length;) {
-               result.push(this.childString(index));
-               index = this.buffer[index + 3];
-           }
-           return result.join(",");
-       }
-       /// @internal
-       childString(index) {
-           let id = this.buffer[index], endIndex = this.buffer[index + 3];
-           let type = this.set.types[id], result = type.name;
-           if (/\W/.test(result) && !type.isError)
-               result = JSON.stringify(result);
-           index += 4;
-           if (endIndex == index)
-               return result;
-           let children = [];
-           while (index < endIndex) {
-               children.push(this.childString(index));
-               index = this.buffer[index + 3];
-           }
-           return result + "(" + children.join(",") + ")";
-       }
-       /// @internal
-       findChild(startIndex, endIndex, dir, pos, side) {
-           let { buffer } = this, pick = -1;
-           for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
-               if (checkSide$1(side, pos, buffer[i + 1], buffer[i + 2])) {
-                   pick = i;
-                   if (dir > 0)
-                       break;
-               }
-           }
-           return pick;
-       }
-       /// @internal
-       slice(startI, endI, from, to) {
-           let b = this.buffer;
-           let copy = new Uint16Array(endI - startI);
-           for (let i = startI, j = 0; i < endI;) {
-               copy[j++] = b[i++];
-               copy[j++] = b[i++] - from;
-               copy[j++] = b[i++] - from;
-               copy[j++] = b[i++] - startI;
-           }
-           return new TreeBuffer(copy, to - from, this.set);
-       }
-   };
-   function checkSide$1(side, pos, from, to) {
-       switch (side) {
-           case -2 /* Before */: return from < pos;
-           case -1 /* AtOrBefore */: return to >= pos && from < pos;
-           case 0 /* Around */: return from < pos && to > pos;
-           case 1 /* AtOrAfter */: return from <= pos && to > pos;
-           case 2 /* After */: return to > pos;
-           case 4 /* DontCare */: return true;
-       }
-   }
-   function enterUnfinishedNodesBefore(node, pos) {
-       let scan = node.childBefore(pos);
-       while (scan) {
-           let last = scan.lastChild;
-           if (!last || last.to != scan.to)
-               break;
-           if (last.type.isError && last.from == last.to) {
-               node = scan;
-               scan = last.prevSibling;
-           }
-           else {
-               scan = last;
-           }
-       }
-       return node;
-   }
-   function resolveNode$1(node, pos, side, overlays) {
-       var _a;
-       // Move up to a node that actually holds the position, if possible
-       while (node.from == node.to ||
-           (side < 1 ? node.from >= pos : node.from > pos) ||
-           (side > -1 ? node.to <= pos : node.to < pos)) {
-           let parent = !overlays && node instanceof TreeNode$1 && node.index < 0 ? null : node.parent;
-           if (!parent)
-               return node;
-           node = parent;
-       }
-       let mode = overlays ? 0 : IterMode$1.IgnoreOverlays;
-       // Must go up out of overlays when those do not overlap with pos
-       if (overlays)
-           for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
-               if (scan instanceof TreeNode$1 && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
-                   node = parent;
-           }
-       for (;;) {
-           let inner = node.enter(pos, side, mode);
-           if (!inner)
-               return node;
-           node = inner;
-       }
-   }
-   let TreeNode$1 = class TreeNode {
-       constructor(_tree, from, 
-       // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
-       index, _parent) {
-           this._tree = _tree;
-           this.from = from;
-           this.index = index;
-           this._parent = _parent;
-       }
-       get type() { return this._tree.type; }
-       get name() { return this._tree.type.name; }
-       get to() { return this.from + this._tree.length; }
-       nextChild(i, dir, pos, side, mode = 0) {
-           for (let parent = this;;) {
-               for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
-                   let next = children[i], start = positions[i] + parent.from;
-                   if (!checkSide$1(side, pos, start, start + next.length))
-                       continue;
-                   if (next instanceof TreeBuffer$1) {
-                       if (mode & IterMode$1.ExcludeBuffers)
-                           continue;
-                       let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
-                       if (index > -1)
-                           return new BufferNode$1(new BufferContext$1(parent, next, i, start), null, index);
-                   }
-                   else if ((mode & IterMode$1.IncludeAnonymous) || (!next.type.isAnonymous || hasChild$1(next))) {
-                       let mounted;
-                       if (!(mode & IterMode$1.IgnoreMounts) &&
-                           next.props && (mounted = next.prop(NodeProp$1.mounted)) && !mounted.overlay)
-                           return new TreeNode(mounted.tree, start, i, parent);
-                       let inner = new TreeNode(next, start, i, parent);
-                       return (mode & IterMode$1.IncludeAnonymous) || !inner.type.isAnonymous ? inner
-                           : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
-                   }
-               }
-               if ((mode & IterMode$1.IncludeAnonymous) || !parent.type.isAnonymous)
-                   return null;
-               if (parent.index >= 0)
-                   i = parent.index + dir;
-               else
-                   i = dir < 0 ? -1 : parent._parent._tree.children.length;
-               parent = parent._parent;
-               if (!parent)
-                   return null;
-           }
-       }
-       get firstChild() { return this.nextChild(0, 1, 0, 4 /* DontCare */); }
-       get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* DontCare */); }
-       childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* After */); }
-       childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Before */); }
-       enter(pos, side, mode = 0) {
-           let mounted;
-           if (!(mode & IterMode$1.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp$1.mounted)) && mounted.overlay) {
-               let rPos = pos - this.from;
-               for (let { from, to } of mounted.overlay) {
-                   if ((side > 0 ? from <= rPos : from < rPos) &&
-                       (side < 0 ? to >= rPos : to > rPos))
-                       return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
-               }
-           }
-           return this.nextChild(0, 1, pos, side, mode);
-       }
-       nextSignificantParent() {
-           let val = this;
-           while (val.type.isAnonymous && val._parent)
-               val = val._parent;
-           return val;
-       }
-       get parent() {
-           return this._parent ? this._parent.nextSignificantParent() : null;
-       }
-       get nextSibling() {
-           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* DontCare */) : null;
-       }
-       get prevSibling() {
-           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* DontCare */) : null;
-       }
-       cursor(mode = 0) { return new TreeCursor$1(this, mode); }
-       get tree() { return this._tree; }
-       toTree() { return this._tree; }
-       resolve(pos, side = 0) {
-           return resolveNode$1(this, pos, side, false);
-       }
-       resolveInner(pos, side = 0) {
-           return resolveNode$1(this, pos, side, true);
-       }
-       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore(this, pos); }
-       getChild(type, before = null, after = null) {
-           let r = getChildren$1(this, type, before, after);
-           return r.length ? r[0] : null;
-       }
-       getChildren(type, before = null, after = null) {
-           return getChildren$1(this, type, before, after);
-       }
-       /// @internal
-       toString() { return this._tree.toString(); }
-       get node() { return this; }
-       matchContext(context) { return matchNodeContext$1(this, context); }
-   };
-   function getChildren$1(node, type, before, after) {
-       let cur = node.cursor(), result = [];
-       if (!cur.firstChild())
-           return result;
-       if (before != null)
-           while (!cur.type.is(before))
-               if (!cur.nextSibling())
-                   return result;
-       for (;;) {
-           if (after != null && cur.type.is(after))
-               return result;
-           if (cur.type.is(type))
-               result.push(cur.node);
-           if (!cur.nextSibling())
-               return after == null ? result : [];
-       }
-   }
-   function matchNodeContext$1(node, context, i = context.length - 1) {
-       for (let p = node.parent; i >= 0; p = p.parent) {
-           if (!p)
-               return false;
-           if (!p.type.isAnonymous) {
-               if (context[i] && context[i] != p.name)
-                   return false;
-               i--;
-           }
-       }
-       return true;
-   }
-   let BufferContext$1 = class BufferContext {
-       constructor(parent, buffer, index, start) {
-           this.parent = parent;
-           this.buffer = buffer;
-           this.index = index;
-           this.start = start;
-       }
-   };
-   let BufferNode$1 = class BufferNode {
-       constructor(context, _parent, index) {
-           this.context = context;
-           this._parent = _parent;
-           this.index = index;
-           this.type = context.buffer.set.types[context.buffer.buffer[index]];
-       }
-       get name() { return this.type.name; }
-       get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
-       get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
-       child(dir, pos, side) {
-           let { buffer } = this.context;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
-           return index < 0 ? null : new BufferNode(this.context, this, index);
-       }
-       get firstChild() { return this.child(1, 0, 4 /* DontCare */); }
-       get lastChild() { return this.child(-1, 0, 4 /* DontCare */); }
-       childAfter(pos) { return this.child(1, pos, 2 /* After */); }
-       childBefore(pos) { return this.child(-1, pos, -2 /* Before */); }
-       enter(pos, side, mode = 0) {
-           if (mode & IterMode$1.ExcludeBuffers)
-               return null;
-           let { buffer } = this.context;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
-           return index < 0 ? null : new BufferNode(this.context, this, index);
-       }
-       get parent() {
-           return this._parent || this.context.parent.nextSignificantParent();
-       }
-       externalSibling(dir) {
-           return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* DontCare */);
-       }
-       get nextSibling() {
-           let { buffer } = this.context;
-           let after = buffer.buffer[this.index + 3];
-           if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
-               return new BufferNode(this.context, this._parent, after);
-           return this.externalSibling(1);
-       }
-       get prevSibling() {
-           let { buffer } = this.context;
-           let parentStart = this._parent ? this._parent.index + 4 : 0;
-           if (this.index == parentStart)
-               return this.externalSibling(-1);
-           return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
-       }
-       cursor(mode = 0) { return new TreeCursor$1(this, mode); }
-       get tree() { return null; }
-       toTree() {
-           let children = [], positions = [];
-           let { buffer } = this.context;
-           let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
-           if (endI > startI) {
-               let from = buffer.buffer[this.index + 1], to = buffer.buffer[this.index + 2];
-               children.push(buffer.slice(startI, endI, from, to));
-               positions.push(0);
-           }
-           return new Tree$1(this.type, children, positions, this.to - this.from);
-       }
-       resolve(pos, side = 0) {
-           return resolveNode$1(this, pos, side, false);
-       }
-       resolveInner(pos, side = 0) {
-           return resolveNode$1(this, pos, side, true);
-       }
-       enterUnfinishedNodesBefore(pos) { return enterUnfinishedNodesBefore(this, pos); }
-       /// @internal
-       toString() { return this.context.buffer.childString(this.index); }
-       getChild(type, before = null, after = null) {
-           let r = getChildren$1(this, type, before, after);
-           return r.length ? r[0] : null;
-       }
-       getChildren(type, before = null, after = null) {
-           return getChildren$1(this, type, before, after);
-       }
-       get node() { return this; }
-       matchContext(context) { return matchNodeContext$1(this, context); }
-   };
-   /// A tree cursor object focuses on a given node in a syntax tree, and
-   /// allows you to move to adjacent nodes.
-   let TreeCursor$1 = class TreeCursor {
-       /// @internal
-       constructor(node, 
-       /// @internal
-       mode = 0) {
-           this.mode = mode;
-           /// @internal
-           this.buffer = null;
-           this.stack = [];
-           /// @internal
-           this.index = 0;
-           this.bufferNode = null;
-           if (node instanceof TreeNode$1) {
-               this.yieldNode(node);
-           }
-           else {
-               this._tree = node.context.parent;
-               this.buffer = node.context;
-               for (let n = node._parent; n; n = n._parent)
-                   this.stack.unshift(n.index);
-               this.bufferNode = node;
-               this.yieldBuf(node.index);
-           }
-       }
-       /// Shorthand for `.type.name`.
-       get name() { return this.type.name; }
-       yieldNode(node) {
-           if (!node)
-               return false;
-           this._tree = node;
-           this.type = node.type;
-           this.from = node.from;
-           this.to = node.to;
-           return true;
-       }
-       yieldBuf(index, type) {
-           this.index = index;
-           let { start, buffer } = this.buffer;
-           this.type = type || buffer.set.types[buffer.buffer[index]];
-           this.from = start + buffer.buffer[index + 1];
-           this.to = start + buffer.buffer[index + 2];
-           return true;
-       }
-       yield(node) {
-           if (!node)
-               return false;
-           if (node instanceof TreeNode$1) {
-               this.buffer = null;
-               return this.yieldNode(node);
-           }
-           this.buffer = node.context;
-           return this.yieldBuf(node.index, node.type);
-       }
-       /// @internal
-       toString() {
-           return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
-       }
-       /// @internal
-       enterChild(dir, pos, side) {
-           if (!this.buffer)
-               return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
-           let { buffer } = this.buffer;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
-           if (index < 0)
-               return false;
-           this.stack.push(this.index);
-           return this.yieldBuf(index);
-       }
-       /// Move the cursor to this node's first child. When this returns
-       /// false, the node has no child, and the cursor has not been moved.
-       firstChild() { return this.enterChild(1, 0, 4 /* DontCare */); }
-       /// Move the cursor to this node's last child.
-       lastChild() { return this.enterChild(-1, 0, 4 /* DontCare */); }
-       /// Move the cursor to the first child that ends after `pos`.
-       childAfter(pos) { return this.enterChild(1, pos, 2 /* After */); }
-       /// Move to the last child that starts before `pos`.
-       childBefore(pos) { return this.enterChild(-1, pos, -2 /* Before */); }
-       /// Move the cursor to the child around `pos`. If side is -1 the
-       /// child may end at that position, when 1 it may start there. This
-       /// will also enter [overlaid](#common.MountedTree.overlay)
-       /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
-       /// set to false.
-       enter(pos, side, mode = this.mode) {
-           if (!this.buffer)
-               return this.yield(this._tree.enter(pos, side, mode));
-           return mode & IterMode$1.ExcludeBuffers ? false : this.enterChild(1, pos, side);
-       }
-       /// Move to the node's parent node, if this isn't the top node.
-       parent() {
-           if (!this.buffer)
-               return this.yieldNode((this.mode & IterMode$1.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
-           if (this.stack.length)
-               return this.yieldBuf(this.stack.pop());
-           let parent = (this.mode & IterMode$1.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
-           this.buffer = null;
-           return this.yieldNode(parent);
-       }
-       /// @internal
-       sibling(dir) {
-           if (!this.buffer)
-               return !this._tree._parent ? false
-                   : this.yield(this._tree.index < 0 ? null
-                       : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* DontCare */, this.mode));
-           let { buffer } = this.buffer, d = this.stack.length - 1;
-           if (dir < 0) {
-               let parentStart = d < 0 ? 0 : this.stack[d] + 4;
-               if (this.index != parentStart)
-                   return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* DontCare */));
-           }
-           else {
-               let after = buffer.buffer[this.index + 3];
-               if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
-                   return this.yieldBuf(after);
-           }
-           return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* DontCare */, this.mode)) : false;
-       }
-       /// Move to this node's next sibling, if any.
-       nextSibling() { return this.sibling(1); }
-       /// Move to this node's previous sibling, if any.
-       prevSibling() { return this.sibling(-1); }
-       atLastNode(dir) {
-           let index, parent, { buffer } = this;
-           if (buffer) {
-               if (dir > 0) {
-                   if (this.index < buffer.buffer.buffer.length)
-                       return false;
-               }
-               else {
-                   for (let i = 0; i < this.index; i++)
-                       if (buffer.buffer.buffer[i + 3] < this.index)
-                           return false;
-               }
-               ({ index, parent } = buffer);
-           }
-           else {
-               ({ index, _parent: parent } = this._tree);
-           }
-           for (; parent; { index, _parent: parent } = parent) {
-               if (index > -1)
-                   for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
-                       let child = parent._tree.children[i];
-                       if ((this.mode & IterMode$1.IncludeAnonymous) ||
-                           child instanceof TreeBuffer$1 ||
-                           !child.type.isAnonymous ||
-                           hasChild$1(child))
-                           return false;
-                   }
-           }
-           return true;
-       }
-       move(dir, enter) {
-           if (enter && this.enterChild(dir, 0, 4 /* DontCare */))
-               return true;
-           for (;;) {
-               if (this.sibling(dir))
-                   return true;
-               if (this.atLastNode(dir) || !this.parent())
-                   return false;
-           }
-       }
-       /// Move to the next node in a
-       /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR))
-       /// traversal, going from a node to its first child or, if the
-       /// current node is empty or `enter` is false, its next sibling or
-       /// the next sibling of the first parent node that has one.
-       next(enter = true) { return this.move(1, enter); }
-       /// Move to the next node in a last-to-first pre-order traveral. A
-       /// node is followed by its last child or, if it has none, its
-       /// previous sibling or the previous sibling of the first parent
-       /// node that has one.
-       prev(enter = true) { return this.move(-1, enter); }
-       /// Move the cursor to the innermost node that covers `pos`. If
-       /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
-       /// it will enter nodes that start at `pos`.
-       moveTo(pos, side = 0) {
-           // Move up to a node that actually holds the position, if possible
-           while (this.from == this.to ||
-               (side < 1 ? this.from >= pos : this.from > pos) ||
-               (side > -1 ? this.to <= pos : this.to < pos))
-               if (!this.parent())
-                   break;
-           // Then scan down into child nodes as far as possible
-           while (this.enterChild(1, pos, side)) { }
-           return this;
-       }
-       /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
-       /// position.
-       get node() {
-           if (!this.buffer)
-               return this._tree;
-           let cache = this.bufferNode, result = null, depth = 0;
-           if (cache && cache.context == this.buffer) {
-               scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
-                   for (let c = cache; c; c = c._parent)
-                       if (c.index == index) {
-                           if (index == this.index)
-                               return c;
-                           result = c;
-                           depth = d + 1;
-                           break scan;
-                       }
-                   index = this.stack[--d];
-               }
-           }
-           for (let i = depth; i < this.stack.length; i++)
-               result = new BufferNode$1(this.buffer, result, this.stack[i]);
-           return this.bufferNode = new BufferNode$1(this.buffer, result, this.index);
-       }
-       /// Get the [tree](#common.Tree) that represents the current node, if
-       /// any. Will return null when the node is in a [tree
-       /// buffer](#common.TreeBuffer).
-       get tree() {
-           return this.buffer ? null : this._tree._tree;
-       }
-       /// Iterate over the current node and all its descendants, calling
-       /// `enter` when entering a node and `leave`, if given, when leaving
-       /// one. When `enter` returns `false`, any children of that node are
-       /// skipped, and `leave` isn't called for it.
-       iterate(enter, leave) {
-           for (let depth = 0;;) {
-               let mustLeave = false;
-               if (this.type.isAnonymous || enter(this) !== false) {
-                   if (this.firstChild()) {
-                       depth++;
-                       continue;
-                   }
-                   if (!this.type.isAnonymous)
-                       mustLeave = true;
-               }
-               for (;;) {
-                   if (mustLeave && leave)
-                       leave(this);
-                   mustLeave = this.type.isAnonymous;
-                   if (this.nextSibling())
-                       break;
-                   if (!depth)
-                       return;
-                   this.parent();
-                   depth--;
-                   mustLeave = true;
-               }
-           }
-       }
-       /// Test whether the current node matches a given context—a sequence
-       /// of direct parent node names. Empty strings in the context array
-       /// are treated as wildcards.
-       matchContext(context) {
-           if (!this.buffer)
-               return matchNodeContext$1(this.node, context);
-           let { buffer } = this.buffer, { types } = buffer.set;
-           for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
-               if (d < 0)
-                   return matchNodeContext$1(this.node, context, i);
-               let type = types[buffer.buffer[this.stack[d]]];
-               if (!type.isAnonymous) {
-                   if (context[i] && context[i] != type.name)
-                       return false;
-                   i--;
-               }
-           }
-           return true;
-       }
-   };
-   function hasChild$1(tree) {
-       return tree.children.some(ch => ch instanceof TreeBuffer$1 || !ch.type.isAnonymous || hasChild$1(ch));
-   }
-   function buildTree$1(data) {
-       var _a;
-       let { buffer, nodeSet, maxBufferLength = DefaultBufferLength$1, reused = [], minRepeatType = nodeSet.types.length } = data;
-       let cursor = Array.isArray(buffer) ? new FlatBufferCursor$1(buffer, buffer.length) : buffer;
-       let types = nodeSet.types;
-       let contextHash = 0, lookAhead = 0;
-       function takeNode(parentStart, minPos, children, positions, inRepeat) {
-           let { id, start, end, size } = cursor;
-           let lookAheadAtStart = lookAhead;
-           while (size < 0) {
-               cursor.next();
-               if (size == -1 /* Reuse */) {
-                   let node = reused[id];
-                   children.push(node);
-                   positions.push(start - parentStart);
-                   return;
-               }
-               else if (size == -3 /* ContextChange */) { // Context change
-                   contextHash = id;
-                   return;
-               }
-               else if (size == -4 /* LookAhead */) {
-                   lookAhead = id;
-                   return;
-               }
-               else {
-                   throw new RangeError(`Unrecognized record size: ${size}`);
-               }
-           }
-           let type = types[id], node, buffer;
-           let startPos = start - parentStart;
-           if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
-               // Small enough for a buffer, and no reused nodes inside
-               let data = new Uint16Array(buffer.size - buffer.skip);
-               let endPos = cursor.pos - buffer.size, index = data.length;
-               while (cursor.pos > endPos)
-                   index = copyToBuffer(buffer.start, data, index);
-               node = new TreeBuffer$1(data, end - buffer.start, nodeSet);
-               startPos = buffer.start - parentStart;
-           }
-           else { // Make it a node
-               let endPos = cursor.pos - size;
-               cursor.next();
-               let localChildren = [], localPositions = [];
-               let localInRepeat = id >= minRepeatType ? id : -1;
-               let lastGroup = 0, lastEnd = end;
-               while (cursor.pos > endPos) {
-                   if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
-                       if (cursor.end <= lastEnd - maxBufferLength) {
-                           makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
-                           lastGroup = localChildren.length;
-                           lastEnd = cursor.end;
-                       }
-                       cursor.next();
-                   }
-                   else {
-                       takeNode(start, endPos, localChildren, localPositions, localInRepeat);
-                   }
-               }
-               if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
-                   makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
-               localChildren.reverse();
-               localPositions.reverse();
-               if (localInRepeat > -1 && lastGroup > 0) {
-                   let make = makeBalanced(type);
-                   node = balanceRange$1(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
-               }
-               else {
-                   node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
-               }
-           }
-           children.push(node);
-           positions.push(startPos);
-       }
-       function makeBalanced(type) {
-           return (children, positions, length) => {
-               let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
-               if (lastI >= 0 && (last = children[lastI]) instanceof Tree$1) {
-                   if (!lastI && last.type == type && last.length == length)
-                       return last;
-                   if (lookAheadProp = last.prop(NodeProp$1.lookAhead))
-                       lookAhead = positions[lastI] + last.length + lookAheadProp;
-               }
-               return makeTree(type, children, positions, length, lookAhead);
-           };
-       }
-       function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {
-           let localChildren = [], localPositions = [];
-           while (children.length > i) {
-               localChildren.push(children.pop());
-               localPositions.push(positions.pop() + base - from);
-           }
-           children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));
-           positions.push(from - base);
-       }
-       function makeTree(type, children, positions, length, lookAhead = 0, props) {
-           if (contextHash) {
-               let pair = [NodeProp$1.contextHash, contextHash];
-               props = props ? [pair].concat(props) : [pair];
-           }
-           if (lookAhead > 25) {
-               let pair = [NodeProp$1.lookAhead, lookAhead];
-               props = props ? [pair].concat(props) : [pair];
-           }
-           return new Tree$1(type, children, positions, length, props);
-       }
-       function findBufferSize(maxSize, inRepeat) {
-           // Scan through the buffer to find previous siblings that fit
-           // together in a TreeBuffer, and don't contain any reused nodes
-           // (which can't be stored in a buffer).
-           // If `inRepeat` is > -1, ignore node boundaries of that type for
-           // nesting, but make sure the end falls either at the start
-           // (`maxSize`) or before such a node.
-           let fork = cursor.fork();
-           let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
-           let result = { size: 0, start: 0, skip: 0 };
-           scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
-               let nodeSize = fork.size;
-               // Pretend nested repeat nodes of the same type don't exist
-               if (fork.id == inRepeat && nodeSize >= 0) {
-                   // Except that we store the current state as a valid return
-                   // value.
-                   result.size = size;
-                   result.start = start;
-                   result.skip = skip;
-                   skip += 4;
-                   size += 4;
-                   fork.next();
-                   continue;
-               }
-               let startPos = fork.pos - nodeSize;
-               if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
-                   break;
-               let localSkipped = fork.id >= minRepeatType ? 4 : 0;
-               let nodeStart = fork.start;
-               fork.next();
-               while (fork.pos > startPos) {
-                   if (fork.size < 0) {
-                       if (fork.size == -3 /* ContextChange */)
-                           localSkipped += 4;
-                       else
-                           break scan;
-                   }
-                   else if (fork.id >= minRepeatType) {
-                       localSkipped += 4;
-                   }
-                   fork.next();
-               }
-               start = nodeStart;
-               size += nodeSize;
-               skip += localSkipped;
-           }
-           if (inRepeat < 0 || size == maxSize) {
-               result.size = size;
-               result.start = start;
-               result.skip = skip;
-           }
-           return result.size > 4 ? result : undefined;
-       }
-       function copyToBuffer(bufferStart, buffer, index) {
-           let { id, start, end, size } = cursor;
-           cursor.next();
-           if (size >= 0 && id < minRepeatType) {
-               let startIndex = index;
-               if (size > 4) {
-                   let endPos = cursor.pos - (size - 4);
-                   while (cursor.pos > endPos)
-                       index = copyToBuffer(bufferStart, buffer, index);
-               }
-               buffer[--index] = startIndex;
-               buffer[--index] = end - bufferStart;
-               buffer[--index] = start - bufferStart;
-               buffer[--index] = id;
-           }
-           else if (size == -3 /* ContextChange */) {
-               contextHash = id;
-           }
-           else if (size == -4 /* LookAhead */) {
-               lookAhead = id;
-           }
-           return index;
-       }
-       let children = [], positions = [];
-       while (cursor.pos > 0)
-           takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
-       let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
-       return new Tree$1(types[data.topID], children.reverse(), positions.reverse(), length);
-   }
-   const nodeSizeCache$1 = new WeakMap;
-   function nodeSize$1(balanceType, node) {
-       if (!balanceType.isAnonymous || node instanceof TreeBuffer$1 || node.type != balanceType)
-           return 1;
-       let size = nodeSizeCache$1.get(node);
-       if (size == null) {
-           size = 1;
-           for (let child of node.children) {
-               if (child.type != balanceType || !(child instanceof Tree$1)) {
-                   size = 1;
-                   break;
-               }
-               size += nodeSize$1(balanceType, child);
-           }
-           nodeSizeCache$1.set(node, size);
-       }
-       return size;
-   }
-   function balanceRange$1(
-   // The type the balanced tree's inner nodes.
-   balanceType, 
-   // The direct children and their positions
-   children, positions, 
-   // The index range in children/positions to use
-   from, to, 
-   // The start position of the nodes, relative to their parent.
-   start, 
-   // Length of the outer node
-   length, 
-   // Function to build the top node of the balanced tree
-   mkTop, 
-   // Function to build internal nodes for the balanced tree
-   mkTree) {
-       let total = 0;
-       for (let i = from; i < to; i++)
-           total += nodeSize$1(balanceType, children[i]);
-       let maxChild = Math.ceil((total * 1.5) / 8 /* BranchFactor */);
-       let localChildren = [], localPositions = [];
-       function divide(children, positions, from, to, offset) {
-           for (let i = from; i < to;) {
-               let groupFrom = i, groupStart = positions[i], groupSize = nodeSize$1(balanceType, children[i]);
-               i++;
-               for (; i < to; i++) {
-                   let nextSize = nodeSize$1(balanceType, children[i]);
-                   if (groupSize + nextSize >= maxChild)
-                       break;
-                   groupSize += nextSize;
-               }
-               if (i == groupFrom + 1) {
-                   if (groupSize > maxChild) {
-                       let only = children[groupFrom]; // Only trees can have a size > 1
-                       divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
-                       continue;
-                   }
-                   localChildren.push(children[groupFrom]);
-               }
-               else {
-                   let length = positions[i - 1] + children[i - 1].length - groupStart;
-                   localChildren.push(balanceRange$1(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
-               }
-               localPositions.push(groupStart + offset - start);
-           }
-       }
-       divide(children, positions, from, to, 0);
-       return (mkTop || mkTree)(localChildren, localPositions, length);
-   }
-
-   /// Tree fragments are used during [incremental
-   /// parsing](#common.Parser.startParse) to track parts of old trees
-   /// that can be reused in a new parse. An array of fragments is used
-   /// to track regions of an old tree whose nodes might be reused in new
-   /// parses. Use the static
-   /// [`applyChanges`](#common.TreeFragment^applyChanges) method to
-   /// update fragments for document changes.
-   let TreeFragment$1 = class TreeFragment {
-       /// Construct a tree fragment.
-       constructor(
-       /// The start of the unchanged range pointed to by this fragment.
-       /// This refers to an offset in the _updated_ document (as opposed
-       /// to the original tree).
-       from, 
-       /// The end of the unchanged range.
-       to, 
-       /// The tree that this fragment is based on.
-       tree, 
-       /// The offset between the fragment's tree and the document that
-       /// this fragment can be used against. Add this when going from
-       /// document to tree positions, subtract it to go from tree to
-       /// document positions.
-       offset, openStart = false, openEnd = false) {
-           this.from = from;
-           this.to = to;
-           this.tree = tree;
-           this.offset = offset;
-           this.open = (openStart ? 1 /* Start */ : 0) | (openEnd ? 2 /* End */ : 0);
-       }
-       /// Whether the start of the fragment represents the start of a
-       /// parse, or the end of a change. (In the second case, it may not
-       /// be safe to reuse some nodes at the start, depending on the
-       /// parsing algorithm.)
-       get openStart() { return (this.open & 1 /* Start */) > 0; }
-       /// Whether the end of the fragment represents the end of a
-       /// full-document parse, or the start of a change.
-       get openEnd() { return (this.open & 2 /* End */) > 0; }
-       /// Create a set of fragments from a freshly parsed tree, or update
-       /// an existing set of fragments by replacing the ones that overlap
-       /// with a tree with content from the new tree. When `partial` is
-       /// true, the parse is treated as incomplete, and the resulting
-       /// fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
-       /// true.
-       static addTree(tree, fragments = [], partial = false) {
-           let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
-           for (let f of fragments)
-               if (f.to > tree.length)
-                   result.push(f);
-           return result;
-       }
-       /// Apply a set of edits to an array of fragments, removing or
-       /// splitting fragments as necessary to remove edited ranges, and
-       /// adjusting offsets for fragments that moved.
-       static applyChanges(fragments, changes, minGap = 128) {
-           if (!changes.length)
-               return fragments;
-           let result = [];
-           let fI = 1, nextF = fragments.length ? fragments[0] : null;
-           for (let cI = 0, pos = 0, off = 0;; cI++) {
-               let nextC = cI < changes.length ? changes[cI] : null;
-               let nextPos = nextC ? nextC.fromA : 1e9;
-               if (nextPos - pos >= minGap)
-                   while (nextF && nextF.from < nextPos) {
-                       let cut = nextF;
-                       if (pos >= cut.from || nextPos <= cut.to || off) {
-                           let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
-                           cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
-                       }
-                       if (cut)
-                           result.push(cut);
-                       if (nextF.to > nextPos)
-                           break;
-                       nextF = fI < fragments.length ? fragments[fI++] : null;
-                   }
-               if (!nextC)
-                   break;
-               pos = nextC.toA;
-               off = nextC.toA - nextC.toB;
-           }
-           return result;
-       }
-   };
-   /// A superclass that parsers should extend.
-   let Parser$1 = class Parser {
-       /// Start a parse, returning a [partial parse](#common.PartialParse)
-       /// object. [`fragments`](#common.TreeFragment) can be passed in to
-       /// make the parse incremental.
-       ///
-       /// By default, the entire input is parsed. You can pass `ranges`,
-       /// which should be a sorted array of non-empty, non-overlapping
-       /// ranges, to parse only those ranges. The tree returned in that
-       /// case will start at `ranges[0].from`.
-       startParse(input, fragments, ranges) {
-           if (typeof input == "string")
-               input = new StringInput$1(input);
-           ranges = !ranges ? [new Range$3(0, input.length)] : ranges.length ? ranges.map(r => new Range$3(r.from, r.to)) : [new Range$3(0, 0)];
-           return this.createParse(input, fragments || [], ranges);
-       }
-       /// Run a full parse, returning the resulting tree.
-       parse(input, fragments, ranges) {
-           let parse = this.startParse(input, fragments, ranges);
-           for (;;) {
-               let done = parse.advance();
-               if (done)
-                   return done;
-           }
-       }
-   };
-   let StringInput$1 = class StringInput {
-       constructor(string) {
-           this.string = string;
-       }
-       get length() { return this.string.length; }
-       chunk(from) { return this.string.slice(from); }
-       get lineChunks() { return false; }
-       read(from, to) { return this.string.slice(from, to); }
-   };
-   new NodeProp$1({ perNode: true });
-
-   let nextTagID$1 = 0;
-   /// Highlighting tags are markers that denote a highlighting category.
-   /// They are [associated](#highlight.styleTags) with parts of a syntax
-   /// tree by a language mode, and then mapped to an actual CSS style by
-   /// a [highlighter](#highlight.Highlighter).
-   ///
-   /// Because syntax tree node types and highlight styles have to be
-   /// able to talk the same language, CodeMirror uses a mostly _closed_
-   /// [vocabulary](#highlight.tags) of syntax tags (as opposed to
-   /// traditional open string-based systems, which make it hard for
-   /// highlighting themes to cover all the tokens produced by the
-   /// various languages).
-   ///
-   /// It _is_ possible to [define](#highlight.Tag^define) your own
-   /// highlighting tags for system-internal use (where you control both
-   /// the language package and the highlighter), but such tags will not
-   /// be picked up by regular highlighters (though you can derive them
-   /// from standard tags to allow highlighters to fall back to those).
-   let Tag$1 = class Tag {
-       /// @internal
-       constructor(
-       /// The set of this tag and all its parent tags, starting with
-       /// this one itself and sorted in order of decreasing specificity.
-       set, 
-       /// The base unmodified tag that this one is based on, if it's
-       /// modified @internal
-       base, 
-       /// The modifiers applied to this.base @internal
-       modified) {
-           this.set = set;
-           this.base = base;
-           this.modified = modified;
-           /// @internal
-           this.id = nextTagID$1++;
-       }
-       /// Define a new tag. If `parent` is given, the tag is treated as a
-       /// sub-tag of that parent, and
-       /// [highlighters](#highlight.tagHighlighter) that don't mention
-       /// this tag will try to fall back to the parent tag (or grandparent
-       /// tag, etc).
-       static define(parent) {
-           if (parent === null || parent === void 0 ? void 0 : parent.base)
-               throw new Error("Can not derive from a modified tag");
-           let tag = new Tag([], null, []);
-           tag.set.push(tag);
-           if (parent)
-               for (let t of parent.set)
-                   tag.set.push(t);
-           return tag;
-       }
-       /// Define a tag _modifier_, which is a function that, given a tag,
-       /// will return a tag that is a subtag of the original. Applying the
-       /// same modifier to a twice tag will return the same value (`m1(t1)
-       /// == m1(t1)`) and applying multiple modifiers will, regardless or
-       /// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
-       ///
-       /// When multiple modifiers are applied to a given base tag, each
-       /// smaller set of modifiers is registered as a parent, so that for
-       /// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
-       /// `m1(m3(t1)`, and so on.
-       static defineModifier() {
-           let mod = new Modifier$1;
-           return (tag) => {
-               if (tag.modified.indexOf(mod) > -1)
-                   return tag;
-               return Modifier$1.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
-           };
-       }
-   };
-   let nextModifierID$1 = 0;
-   let Modifier$1 = class Modifier {
-       constructor() {
-           this.instances = [];
-           this.id = nextModifierID$1++;
-       }
-       static get(base, mods) {
-           if (!mods.length)
-               return base;
-           let exists = mods[0].instances.find(t => t.base == base && sameArray$3(mods, t.modified));
-           if (exists)
-               return exists;
-           let set = [], tag = new Tag$1(set, base, mods);
-           for (let m of mods)
-               m.instances.push(tag);
-           let configs = permute(mods);
-           for (let parent of base.set)
-               for (let config of configs)
-                   set.push(Modifier.get(parent, config));
-           return tag;
-       }
-   };
-   function sameArray$3(a, b) {
-       return a.length == b.length && a.every((x, i) => x == b[i]);
-   }
-   function permute(array) {
-       let result = [array];
-       for (let i = 0; i < array.length; i++) {
-           for (let a of permute(array.slice(0, i).concat(array.slice(i + 1))))
-               result.push(a);
-       }
-       return result;
-   }
-   /// This function is used to add a set of tags to a language syntax
-   /// via [`NodeSet.extend`](#common.NodeSet.extend) or
-   /// [`LRParser.configure`](#lr.LRParser.configure).
-   ///
-   /// The argument object maps node selectors to [highlighting
-   /// tags](#highlight.Tag) or arrays of tags.
-   ///
-   /// Node selectors may hold one or more (space-separated) node paths.
-   /// Such a path can be a [node name](#common.NodeType.name), or
-   /// multiple node names (or `*` wildcards) separated by slash
-   /// characters, as in `"Block/Declaration/VariableName"`. Such a path
-   /// matches the final node but only if its direct parent nodes are the
-   /// other nodes mentioned. A `*` in such a path matches any parent,
-   /// but only a single level—wildcards that match multiple parents
-   /// aren't supported, both for efficiency reasons and because Lezer
-   /// trees make it rather hard to reason about what they would match.)
-   ///
-   /// A path can be ended with `/...` to indicate that the tag assigned
-   /// to the node should also apply to all child nodes, even if they
-   /// match their own style (by default, only the innermost style is
-   /// used).
-   ///
-   /// When a path ends in `!`, as in `Attribute!`, no further matching
-   /// happens for the node's child nodes, and the entire node gets the
-   /// given style.
-   ///
-   /// In this notation, node names that contain `/`, `!`, `*`, or `...`
-   /// must be quoted as JSON strings.
-   ///
-   /// For example:
-   ///
-   /// ```javascript
-   /// parser.withProps(
-   ///   styleTags({
-   ///     // Style Number and BigNumber nodes
-   ///     "Number BigNumber": tags.number,
-   ///     // Style Escape nodes whose parent is String
-   ///     "String/Escape": tags.escape,
-   ///     // Style anything inside Attributes nodes
-   ///     "Attributes!": tags.meta,
-   ///     // Add a style to all content inside Italic nodes
-   ///     "Italic/...": tags.emphasis,
-   ///     // Style InvalidString nodes as both `string` and `invalid`
-   ///     "InvalidString": [tags.string, tags.invalid],
-   ///     // Style the node named "/" as punctuation
-   ///     '"/"': tags.punctuation
-   ///   })
-   /// )
-   /// ```
-   function styleTags$1(spec) {
-       let byName = Object.create(null);
-       for (let prop in spec) {
-           let tags = spec[prop];
-           if (!Array.isArray(tags))
-               tags = [tags];
-           for (let part of prop.split(" "))
-               if (part) {
-                   let pieces = [], mode = 2 /* Normal */, rest = part;
-                   for (let pos = 0;;) {
-                       if (rest == "..." && pos > 0 && pos + 3 == part.length) {
-                           mode = 1 /* Inherit */;
-                           break;
-                       }
-                       let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
-                       if (!m)
-                           throw new RangeError("Invalid path: " + part);
-                       pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
-                       pos += m[0].length;
-                       if (pos == part.length)
-                           break;
-                       let next = part[pos++];
-                       if (pos == part.length && next == "!") {
-                           mode = 0 /* Opaque */;
-                           break;
-                       }
-                       if (next != "/")
-                           throw new RangeError("Invalid path: " + part);
-                       rest = part.slice(pos);
-                   }
-                   let last = pieces.length - 1, inner = pieces[last];
-                   if (!inner)
-                       throw new RangeError("Invalid path: " + part);
-                   let rule = new Rule$1(tags, mode, last > 0 ? pieces.slice(0, last) : null);
-                   byName[inner] = rule.sort(byName[inner]);
-               }
-       }
-       return ruleNodeProp$1.add(byName);
-   }
-   const ruleNodeProp$1 = new NodeProp$1();
-   let Rule$1 = class Rule {
-       constructor(tags, mode, context, next) {
-           this.tags = tags;
-           this.mode = mode;
-           this.context = context;
-           this.next = next;
-       }
-       sort(other) {
-           if (!other || other.depth < this.depth) {
-               this.next = other;
-               return this;
-           }
-           other.next = this.sort(other.next);
-           return other;
-       }
-       get depth() { return this.context ? this.context.length : 0; }
-   };
-   /// Define a [highlighter](#highlight.Highlighter) from an array of
-   /// tag/class pairs. Classes associated with more specific tags will
-   /// take precedence.
-   function tagHighlighter$1(tags, options) {
-       let map = Object.create(null);
-       for (let style of tags) {
-           if (!Array.isArray(style.tag))
-               map[style.tag.id] = style.class;
-           else
-               for (let tag of style.tag)
-                   map[tag.id] = style.class;
-       }
-       let { scope, all = null } = {};
-       return {
-           style: (tags) => {
-               let cls = all;
-               for (let tag of tags) {
-                   for (let sub of tag.set) {
-                       let tagClass = map[sub.id];
-                       if (tagClass) {
-                           cls = cls ? cls + " " + tagClass : tagClass;
-                           break;
-                       }
-                   }
-               }
-               return cls;
-           },
-           scope: scope
-       };
-   }
-   const t$1 = Tag$1.define;
-   const comment$1 = t$1(), name$1 = t$1(), typeName$1 = t$1(name$1), propertyName$1 = t$1(name$1), literal$1 = t$1(), string$1 = t$1(literal$1), number$1 = t$1(literal$1), content$1 = t$1(), heading$1 = t$1(content$1), keyword$1 = t$1(), operator$1 = t$1(), punctuation$1 = t$1(), bracket$1 = t$1(punctuation$1), meta$1 = t$1();
-   /// The default set of highlighting [tags](#highlight.Tag).
-   ///
-   /// This collection is heavily biased towards programming languages,
-   /// and necessarily incomplete. A full ontology of syntactic
-   /// constructs would fill a stack of books, and be impractical to
-   /// write themes for. So try to make do with this set. If all else
-   /// fails, [open an
-   /// issue](https://github.com/codemirror/codemirror.next) to propose a
-   /// new tag, or [define](#highlight.Tag^define) a local custom tag for
-   /// your use case.
-   ///
-   /// Note that it is not obligatory to always attach the most specific
-   /// tag possible to an element—if your grammar can't easily
-   /// distinguish a certain type of element (such as a local variable),
-   /// it is okay to style it as its more general variant (a variable).
-   /// 
-   /// For tags that extend some parent tag, the documentation links to
-   /// the parent.
-   const tags$1 = {
-       /// A comment.
-       comment: comment$1,
-       /// A line [comment](#highlight.tags.comment).
-       lineComment: t$1(comment$1),
-       /// A block [comment](#highlight.tags.comment).
-       blockComment: t$1(comment$1),
-       /// A documentation [comment](#highlight.tags.comment).
-       docComment: t$1(comment$1),
-       /// Any kind of identifier.
-       name: name$1,
-       /// The [name](#highlight.tags.name) of a variable.
-       variableName: t$1(name$1),
-       /// A type [name](#highlight.tags.name).
-       typeName: typeName$1,
-       /// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
-       tagName: t$1(typeName$1),
-       /// A property or field [name](#highlight.tags.name).
-       propertyName: propertyName$1,
-       /// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
-       attributeName: t$1(propertyName$1),
-       /// The [name](#highlight.tags.name) of a class.
-       className: t$1(name$1),
-       /// A label [name](#highlight.tags.name).
-       labelName: t$1(name$1),
-       /// A namespace [name](#highlight.tags.name).
-       namespace: t$1(name$1),
-       /// The [name](#highlight.tags.name) of a macro.
-       macroName: t$1(name$1),
-       /// A literal value.
-       literal: literal$1,
-       /// A string [literal](#highlight.tags.literal).
-       string: string$1,
-       /// A documentation [string](#highlight.tags.string).
-       docString: t$1(string$1),
-       /// A character literal (subtag of [string](#highlight.tags.string)).
-       character: t$1(string$1),
-       /// An attribute value (subtag of [string](#highlight.tags.string)).
-       attributeValue: t$1(string$1),
-       /// A number [literal](#highlight.tags.literal).
-       number: number$1,
-       /// An integer [number](#highlight.tags.number) literal.
-       integer: t$1(number$1),
-       /// A floating-point [number](#highlight.tags.number) literal.
-       float: t$1(number$1),
-       /// A boolean [literal](#highlight.tags.literal).
-       bool: t$1(literal$1),
-       /// Regular expression [literal](#highlight.tags.literal).
-       regexp: t$1(literal$1),
-       /// An escape [literal](#highlight.tags.literal), for example a
-       /// backslash escape in a string.
-       escape: t$1(literal$1),
-       /// A color [literal](#highlight.tags.literal).
-       color: t$1(literal$1),
-       /// A URL [literal](#highlight.tags.literal).
-       url: t$1(literal$1),
-       /// A language keyword.
-       keyword: keyword$1,
-       /// The [keyword](#highlight.tags.keyword) for the self or this
-       /// object.
-       self: t$1(keyword$1),
-       /// The [keyword](#highlight.tags.keyword) for null.
-       null: t$1(keyword$1),
-       /// A [keyword](#highlight.tags.keyword) denoting some atomic value.
-       atom: t$1(keyword$1),
-       /// A [keyword](#highlight.tags.keyword) that represents a unit.
-       unit: t$1(keyword$1),
-       /// A modifier [keyword](#highlight.tags.keyword).
-       modifier: t$1(keyword$1),
-       /// A [keyword](#highlight.tags.keyword) that acts as an operator.
-       operatorKeyword: t$1(keyword$1),
-       /// A control-flow related [keyword](#highlight.tags.keyword).
-       controlKeyword: t$1(keyword$1),
-       /// A [keyword](#highlight.tags.keyword) that defines something.
-       definitionKeyword: t$1(keyword$1),
-       /// A [keyword](#highlight.tags.keyword) related to defining or
-       /// interfacing with modules.
-       moduleKeyword: t$1(keyword$1),
-       /// An operator.
-       operator: operator$1,
-       /// An [operator](#highlight.tags.operator) that defines something.
-       derefOperator: t$1(operator$1),
-       /// Arithmetic-related [operator](#highlight.tags.operator).
-       arithmeticOperator: t$1(operator$1),
-       /// Logical [operator](#highlight.tags.operator).
-       logicOperator: t$1(operator$1),
-       /// Bit [operator](#highlight.tags.operator).
-       bitwiseOperator: t$1(operator$1),
-       /// Comparison [operator](#highlight.tags.operator).
-       compareOperator: t$1(operator$1),
-       /// [Operator](#highlight.tags.operator) that updates its operand.
-       updateOperator: t$1(operator$1),
-       /// [Operator](#highlight.tags.operator) that defines something.
-       definitionOperator: t$1(operator$1),
-       /// Type-related [operator](#highlight.tags.operator).
-       typeOperator: t$1(operator$1),
-       /// Control-flow [operator](#highlight.tags.operator).
-       controlOperator: t$1(operator$1),
-       /// Program or markup punctuation.
-       punctuation: punctuation$1,
-       /// [Punctuation](#highlight.tags.punctuation) that separates
-       /// things.
-       separator: t$1(punctuation$1),
-       /// Bracket-style [punctuation](#highlight.tags.punctuation).
-       bracket: bracket$1,
-       /// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
-       /// tokens).
-       angleBracket: t$1(bracket$1),
-       /// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
-       /// tokens).
-       squareBracket: t$1(bracket$1),
-       /// Parentheses (usually `(` and `)` tokens). Subtag of
-       /// [bracket](#highlight.tags.bracket).
-       paren: t$1(bracket$1),
-       /// Braces (usually `{` and `}` tokens). Subtag of
-       /// [bracket](#highlight.tags.bracket).
-       brace: t$1(bracket$1),
-       /// Content, for example plain text in XML or markup documents.
-       content: content$1,
-       /// [Content](#highlight.tags.content) that represents a heading.
-       heading: heading$1,
-       /// A level 1 [heading](#highlight.tags.heading).
-       heading1: t$1(heading$1),
-       /// A level 2 [heading](#highlight.tags.heading).
-       heading2: t$1(heading$1),
-       /// A level 3 [heading](#highlight.tags.heading).
-       heading3: t$1(heading$1),
-       /// A level 4 [heading](#highlight.tags.heading).
-       heading4: t$1(heading$1),
-       /// A level 5 [heading](#highlight.tags.heading).
-       heading5: t$1(heading$1),
-       /// A level 6 [heading](#highlight.tags.heading).
-       heading6: t$1(heading$1),
-       /// A prose separator (such as a horizontal rule).
-       contentSeparator: t$1(content$1),
-       /// [Content](#highlight.tags.content) that represents a list.
-       list: t$1(content$1),
-       /// [Content](#highlight.tags.content) that represents a quote.
-       quote: t$1(content$1),
-       /// [Content](#highlight.tags.content) that is emphasized.
-       emphasis: t$1(content$1),
-       /// [Content](#highlight.tags.content) that is styled strong.
-       strong: t$1(content$1),
-       /// [Content](#highlight.tags.content) that is part of a link.
-       link: t$1(content$1),
-       /// [Content](#highlight.tags.content) that is styled as code or
-       /// monospace.
-       monospace: t$1(content$1),
-       /// [Content](#highlight.tags.content) that has a strike-through
-       /// style.
-       strikethrough: t$1(content$1),
-       /// Inserted text in a change-tracking format.
-       inserted: t$1(),
-       /// Deleted text.
-       deleted: t$1(),
-       /// Changed text.
-       changed: t$1(),
-       /// An invalid or unsyntactic element.
-       invalid: t$1(),
-       /// Metadata or meta-instruction.
-       meta: meta$1,
-       /// [Metadata](#highlight.tags.meta) that applies to the entire
-       /// document.
-       documentMeta: t$1(meta$1),
-       /// [Metadata](#highlight.tags.meta) that annotates or adds
-       /// attributes to a given syntactic element.
-       annotation: t$1(meta$1),
-       /// Processing instruction or preprocessor directive. Subtag of
-       /// [meta](#highlight.tags.meta).
-       processingInstruction: t$1(meta$1),
-       /// [Modifier](#highlight.Tag^defineModifier) that indicates that a
-       /// given element is being defined. Expected to be used with the
-       /// various [name](#highlight.tags.name) tags.
-       definition: Tag$1.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) that indicates that
-       /// something is constant. Mostly expected to be used with
-       /// [variable names](#highlight.tags.variableName).
-       constant: Tag$1.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) used to indicate that
-       /// a [variable](#highlight.tags.variableName) or [property
-       /// name](#highlight.tags.propertyName) is being called or defined
-       /// as a function.
-       function: Tag$1.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) that can be applied to
-       /// [names](#highlight.tags.name) to indicate that they belong to
-       /// the language's standard environment.
-       standard: Tag$1.defineModifier(),
-       /// [Modifier](#highlight.Tag^defineModifier) that indicates a given
-       /// [names](#highlight.tags.name) is local to some scope.
-       local: Tag$1.defineModifier(),
-       /// A generic variant [modifier](#highlight.Tag^defineModifier) that
-       /// can be used to tag language-specific alternative variants of
-       /// some common tag. It is recommended for themes to define special
-       /// forms of at least the [string](#highlight.tags.string) and
-       /// [variable name](#highlight.tags.variableName) tags, since those
-       /// come up a lot.
-       special: Tag$1.defineModifier()
-   };
-   /// This is a highlighter that adds stable, predictable classes to
-   /// tokens, for styling with external CSS.
-   ///
-   /// The following tags are mapped to their name prefixed with `"tok-"`
-   /// (for example `"tok-comment"`):
-   ///
-   /// * [`link`](#highlight.tags.link)
-   /// * [`heading`](#highlight.tags.heading)
-   /// * [`emphasis`](#highlight.tags.emphasis)
-   /// * [`strong`](#highlight.tags.strong)
-   /// * [`keyword`](#highlight.tags.keyword)
-   /// * [`atom`](#highlight.tags.atom) [`bool`](#highlight.tags.bool)
-   /// * [`url`](#highlight.tags.url)
-   /// * [`labelName`](#highlight.tags.labelName)
-   /// * [`inserted`](#highlight.tags.inserted)
-   /// * [`deleted`](#highlight.tags.deleted)
-   /// * [`literal`](#highlight.tags.literal)
-   /// * [`string`](#highlight.tags.string)
-   /// * [`number`](#highlight.tags.number)
-   /// * [`variableName`](#highlight.tags.variableName)
-   /// * [`typeName`](#highlight.tags.typeName)
-   /// * [`namespace`](#highlight.tags.namespace)
-   /// * [`className`](#highlight.tags.className)
-   /// * [`macroName`](#highlight.tags.macroName)
-   /// * [`propertyName`](#highlight.tags.propertyName)
-   /// * [`operator`](#highlight.tags.operator)
-   /// * [`comment`](#highlight.tags.comment)
-   /// * [`meta`](#highlight.tags.meta)
-   /// * [`punctuation`](#highlight.tags.punctuation)
-   /// * [`invalid`](#highlight.tags.invalid)
-   ///
-   /// In addition, these mappings are provided:
-   ///
-   /// * [`regexp`](#highlight.tags.regexp),
-   ///   [`escape`](#highlight.tags.escape), and
-   ///   [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
-   ///   are mapped to `"tok-string2"`
-   /// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
-   ///   to `"tok-variableName2"`
-   /// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
-   ///   to `"tok-variableName tok-local"`
-   /// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
-   ///   to `"tok-variableName tok-definition"`
-   /// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
-   ///   to `"tok-propertyName tok-definition"`
-   tagHighlighter$1([
-       { tag: tags$1.link, class: "tok-link" },
-       { tag: tags$1.heading, class: "tok-heading" },
-       { tag: tags$1.emphasis, class: "tok-emphasis" },
-       { tag: tags$1.strong, class: "tok-strong" },
-       { tag: tags$1.keyword, class: "tok-keyword" },
-       { tag: tags$1.atom, class: "tok-atom" },
-       { tag: tags$1.bool, class: "tok-bool" },
-       { tag: tags$1.url, class: "tok-url" },
-       { tag: tags$1.labelName, class: "tok-labelName" },
-       { tag: tags$1.inserted, class: "tok-inserted" },
-       { tag: tags$1.deleted, class: "tok-deleted" },
-       { tag: tags$1.literal, class: "tok-literal" },
-       { tag: tags$1.string, class: "tok-string" },
-       { tag: tags$1.number, class: "tok-number" },
-       { tag: [tags$1.regexp, tags$1.escape, tags$1.special(tags$1.string)], class: "tok-string2" },
-       { tag: tags$1.variableName, class: "tok-variableName" },
-       { tag: tags$1.local(tags$1.variableName), class: "tok-variableName tok-local" },
-       { tag: tags$1.definition(tags$1.variableName), class: "tok-variableName tok-definition" },
-       { tag: tags$1.special(tags$1.variableName), class: "tok-variableName2" },
-       { tag: tags$1.definition(tags$1.propertyName), class: "tok-propertyName tok-definition" },
-       { tag: tags$1.typeName, class: "tok-typeName" },
-       { tag: tags$1.namespace, class: "tok-namespace" },
-       { tag: tags$1.className, class: "tok-className" },
-       { tag: tags$1.macroName, class: "tok-macroName" },
-       { tag: tags$1.propertyName, class: "tok-propertyName" },
-       { tag: tags$1.operator, class: "tok-operator" },
-       { tag: tags$1.comment, class: "tok-comment" },
-       { tag: tags$1.meta, class: "tok-meta" },
-       { tag: tags$1.invalid, class: "tok-invalid" },
-       { tag: tags$1.punctuation, class: "tok-punctuation" }
-   ]);
-
-   var _a$1;
-   /**
-   Node prop stored in a parser's top syntax node to provide the
-   facet that stores language-specific data for that language.
-   */
-   const languageDataProp$1 = /*@__PURE__*/new NodeProp$1();
-   /**
-   A language object manages parsing and per-language
-   [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
-   managed as a [Lezer](https://lezer.codemirror.net) tree. The class
-   can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
-   subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
-   via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
-   for stream parsers.
-   */
-   let Language$1 = class Language {
-       /**
-       Construct a language object. If you need to invoke this
-       directly, first define a data facet with
-       [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
-       configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
-       to the language's outer syntax node.
-       */
-       constructor(
-       /**
-       The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
-       used for this language.
-       */
-       data, parser, extraExtensions = []) {
-           this.data = data;
-           // Kludge to define EditorState.tree as a debugging helper,
-           // without the EditorState package actually knowing about
-           // languages and lezer trees.
-           if (!EditorState$2.prototype.hasOwnProperty("tree"))
-               Object.defineProperty(EditorState$2.prototype, "tree", { get() { return syntaxTree$1(this); } });
-           this.parser = parser;
-           this.extension = [
-               language$1.of(this),
-               EditorState$2.languageData.of((state, pos, side) => state.facet(languageDataFacetAt(state, pos, side)))
-           ].concat(extraExtensions);
-       }
-       /**
-       Query whether this language is active at the given position.
-       */
-       isActiveAt(state, pos, side = -1) {
-           return languageDataFacetAt(state, pos, side) == this.data;
-       }
-       /**
-       Find the document regions that were parsed using this language.
-       The returned regions will _include_ any nested languages rooted
-       in this language, when those exist.
-       */
-       findRegions(state) {
-           let lang = state.facet(language$1);
-           if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
-               return [{ from: 0, to: state.doc.length }];
-           if (!lang || !lang.allowsNesting)
-               return [];
-           let result = [];
-           let explore = (tree, from) => {
-               if (tree.prop(languageDataProp$1) == this.data) {
-                   result.push({ from, to: from + tree.length });
-                   return;
-               }
-               let mount = tree.prop(NodeProp$1.mounted);
-               if (mount) {
-                   if (mount.tree.prop(languageDataProp$1) == this.data) {
-                       if (mount.overlay)
-                           for (let r of mount.overlay)
-                               result.push({ from: r.from + from, to: r.to + from });
-                       else
-                           result.push({ from: from, to: from + tree.length });
-                       return;
-                   }
-                   else if (mount.overlay) {
-                       let size = result.length;
-                       explore(mount.tree, mount.overlay[0].from + from);
-                       if (result.length > size)
-                           return;
-                   }
-               }
-               for (let i = 0; i < tree.children.length; i++) {
-                   let ch = tree.children[i];
-                   if (ch instanceof Tree$1)
-                       explore(ch, tree.positions[i] + from);
-               }
-           };
-           explore(syntaxTree$1(state), 0);
-           return result;
-       }
-       /**
-       Indicates whether this language allows nested languages. The
-       default implementation returns true.
-       */
-       get allowsNesting() { return true; }
-   };
-   /**
-   @internal
-   */
-   Language$1.setState = /*@__PURE__*/StateEffect$2.define();
-   function languageDataFacetAt(state, pos, side) {
-       let topLang = state.facet(language$1);
-       if (!topLang)
-           return null;
-       let facet = topLang.data;
-       if (topLang.allowsNesting) {
-           for (let node = syntaxTree$1(state).topNode; node; node = node.enter(pos, side, IterMode$1.ExcludeBuffers))
-               facet = node.type.prop(languageDataProp$1) || facet;
-       }
-       return facet;
-   }
-   /**
-   Get the syntax tree for a state, which is the current (possibly
-   incomplete) parse tree of the active
-   [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
-   language available.
-   */
-   function syntaxTree$1(state) {
-       let field = state.field(Language$1.state, false);
-       return field ? field.tree : Tree$1.empty;
-   }
-   // Lezer-style Input object for a Text document.
-   let DocInput$1 = class DocInput {
-       constructor(doc, length = doc.length) {
-           this.doc = doc;
-           this.length = length;
-           this.cursorPos = 0;
-           this.string = "";
-           this.cursor = doc.iter();
-       }
-       syncTo(pos) {
-           this.string = this.cursor.next(pos - this.cursorPos).value;
-           this.cursorPos = pos + this.string.length;
-           return this.cursorPos - this.string.length;
-       }
-       chunk(pos) {
-           this.syncTo(pos);
-           return this.string;
-       }
-       get lineChunks() { return true; }
-       read(from, to) {
-           let stringStart = this.cursorPos - this.string.length;
-           if (from < stringStart || to >= this.cursorPos)
-               return this.doc.sliceString(from, to);
-           else
-               return this.string.slice(from - stringStart, to - stringStart);
-       }
-   };
-   let currentContext$1 = null;
-   /**
-   A parse context provided to parsers working on the editor content.
-   */
-   let ParseContext$1 = class ParseContext {
-       constructor(parser, 
-       /**
-       The current editor state.
-       */
-       state, 
-       /**
-       Tree fragments that can be reused by incremental re-parses.
-       */
-       fragments = [], 
-       /**
-       @internal
-       */
-       tree, 
-       /**
-       @internal
-       */
-       treeLen, 
-       /**
-       The current editor viewport (or some overapproximation
-       thereof). Intended to be used for opportunistically avoiding
-       work (in which case
-       [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
-       should be called to make sure the parser is restarted when the
-       skipped region becomes visible).
-       */
-       viewport, 
-       /**
-       @internal
-       */
-       skipped, 
-       /**
-       This is where skipping parsers can register a promise that,
-       when resolved, will schedule a new parse. It is cleared when
-       the parse worker picks up the promise. @internal
-       */
-       scheduleOn) {
-           this.parser = parser;
-           this.state = state;
-           this.fragments = fragments;
-           this.tree = tree;
-           this.treeLen = treeLen;
-           this.viewport = viewport;
-           this.skipped = skipped;
-           this.scheduleOn = scheduleOn;
-           this.parse = null;
-           /**
-           @internal
-           */
-           this.tempSkipped = [];
-       }
-       /**
-       @internal
-       */
-       static create(parser, state, viewport) {
-           return new ParseContext(parser, state, [], Tree$1.empty, 0, viewport, [], null);
-       }
-       startParse() {
-           return this.parser.startParse(new DocInput$1(this.state.doc), this.fragments);
-       }
-       /**
-       @internal
-       */
-       work(until, upto) {
-           if (upto != null && upto >= this.state.doc.length)
-               upto = undefined;
-           if (this.tree != Tree$1.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
-               this.takeTree();
-               return true;
-           }
-           return this.withContext(() => {
-               var _a;
-               if (typeof until == "number") {
-                   let endTime = Date.now() + until;
-                   until = () => Date.now() > endTime;
-               }
-               if (!this.parse)
-                   this.parse = this.startParse();
-               if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
-                   upto < this.state.doc.length)
-                   this.parse.stopAt(upto);
-               for (;;) {
-                   let done = this.parse.advance();
-                   if (done) {
-                       this.fragments = this.withoutTempSkipped(TreeFragment$1.addTree(done, this.fragments, this.parse.stoppedAt != null));
-                       this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
-                       this.tree = done;
-                       this.parse = null;
-                       if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
-                           this.parse = this.startParse();
-                       else
-                           return true;
-                   }
-                   if (until())
-                       return false;
-               }
-           });
-       }
-       /**
-       @internal
-       */
-       takeTree() {
-           let pos, tree;
-           if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
-               if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
-                   this.parse.stopAt(pos);
-               this.withContext(() => { while (!(tree = this.parse.advance())) { } });
-               this.treeLen = pos;
-               this.tree = tree;
-               this.fragments = this.withoutTempSkipped(TreeFragment$1.addTree(this.tree, this.fragments, true));
-               this.parse = null;
-           }
-       }
-       withContext(f) {
-           let prev = currentContext$1;
-           currentContext$1 = this;
-           try {
-               return f();
-           }
-           finally {
-               currentContext$1 = prev;
-           }
-       }
-       withoutTempSkipped(fragments) {
-           for (let r; r = this.tempSkipped.pop();)
-               fragments = cutFragments$1(fragments, r.from, r.to);
-           return fragments;
-       }
-       /**
-       @internal
-       */
-       changes(changes, newState) {
-           let { fragments, tree, treeLen, viewport, skipped } = this;
-           this.takeTree();
-           if (!changes.empty) {
-               let ranges = [];
-               changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
-               fragments = TreeFragment$1.applyChanges(fragments, ranges);
-               tree = Tree$1.empty;
-               treeLen = 0;
-               viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
-               if (this.skipped.length) {
-                   skipped = [];
-                   for (let r of this.skipped) {
-                       let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
-                       if (from < to)
-                           skipped.push({ from, to });
-                   }
-               }
-           }
-           return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
-       }
-       /**
-       @internal
-       */
-       updateViewport(viewport) {
-           if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
-               return false;
-           this.viewport = viewport;
-           let startLen = this.skipped.length;
-           for (let i = 0; i < this.skipped.length; i++) {
-               let { from, to } = this.skipped[i];
-               if (from < viewport.to && to > viewport.from) {
-                   this.fragments = cutFragments$1(this.fragments, from, to);
-                   this.skipped.splice(i--, 1);
-               }
-           }
-           if (this.skipped.length >= startLen)
-               return false;
-           this.reset();
-           return true;
-       }
-       /**
-       @internal
-       */
-       reset() {
-           if (this.parse) {
-               this.takeTree();
-               this.parse = null;
-           }
-       }
-       /**
-       Notify the parse scheduler that the given region was skipped
-       because it wasn't in view, and the parse should be restarted
-       when it comes into view.
-       */
-       skipUntilInView(from, to) {
-           this.skipped.push({ from, to });
-       }
-       /**
-       Returns a parser intended to be used as placeholder when
-       asynchronously loading a nested parser. It'll skip its input and
-       mark it as not-really-parsed, so that the next update will parse
-       it again.
-       
-       When `until` is given, a reparse will be scheduled when that
-       promise resolves.
-       */
-       static getSkippingParser(until) {
-           return new class extends Parser$1 {
-               createParse(input, fragments, ranges) {
-                   let from = ranges[0].from, to = ranges[ranges.length - 1].to;
-                   let parser = {
-                       parsedPos: from,
-                       advance() {
-                           let cx = currentContext$1;
-                           if (cx) {
-                               for (let r of ranges)
-                                   cx.tempSkipped.push(r);
-                               if (until)
-                                   cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
-                           }
-                           this.parsedPos = to;
-                           return new Tree$1(NodeType$1.none, [], [], to - from);
-                       },
-                       stoppedAt: null,
-                       stopAt() { }
-                   };
-                   return parser;
-               }
-           };
-       }
-       /**
-       @internal
-       */
-       isDone(upto) {
-           upto = Math.min(upto, this.state.doc.length);
-           let frags = this.fragments;
-           return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
-       }
-       /**
-       Get the context for the current parse, or `null` if no editor
-       parse is in progress.
-       */
-       static get() { return currentContext$1; }
-   };
-   function cutFragments$1(fragments, from, to) {
-       return TreeFragment$1.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
-   }
-   let LanguageState$1 = class LanguageState {
-       constructor(
-       // A mutable parse state that is used to preserve work done during
-       // the lifetime of a state when moving to the next state.
-       context) {
-           this.context = context;
-           this.tree = context.tree;
-       }
-       apply(tr) {
-           if (!tr.docChanged && this.tree == this.context.tree)
-               return this;
-           let newCx = this.context.changes(tr.changes, tr.state);
-           // If the previous parse wasn't done, go forward only up to its
-           // end position or the end of the viewport, to avoid slowing down
-           // state updates with parse work beyond the viewport.
-           let upto = this.context.treeLen == tr.startState.doc.length ? undefined
-               : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
-           if (!newCx.work(20 /* Apply */, upto))
-               newCx.takeTree();
-           return new LanguageState(newCx);
-       }
-       static init(state) {
-           let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
-           let parseState = ParseContext$1.create(state.facet(language$1).parser, state, { from: 0, to: vpTo });
-           if (!parseState.work(20 /* Apply */, vpTo))
-               parseState.takeTree();
-           return new LanguageState(parseState);
-       }
-   };
-   Language$1.state = /*@__PURE__*/StateField$2.define({
-       create: LanguageState$1.init,
-       update(value, tr) {
-           for (let e of tr.effects)
-               if (e.is(Language$1.setState))
-                   return e.value;
-           if (tr.startState.facet(language$1) != tr.state.facet(language$1))
-               return LanguageState$1.init(tr.state);
-           return value.apply(tr);
-       }
-   });
-   let requestIdle$1 = (callback) => {
-       let timeout = setTimeout(() => callback(), 500 /* MaxPause */);
-       return () => clearTimeout(timeout);
-   };
-   if (typeof requestIdleCallback != "undefined")
-       requestIdle$1 = (callback) => {
-           let idle = -1, timeout = setTimeout(() => {
-               idle = requestIdleCallback(callback, { timeout: 500 /* MaxPause */ - 100 /* MinPause */ });
-           }, 100 /* MinPause */);
-           return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
-       };
-   const isInputPending$1 = typeof navigator != "undefined" && ((_a$1 = navigator.scheduling) === null || _a$1 === void 0 ? void 0 : _a$1.isInputPending)
-       ? () => navigator.scheduling.isInputPending() : null;
-   const parseWorker$1 = /*@__PURE__*/ViewPlugin$2.fromClass(class ParseWorker {
-       constructor(view) {
-           this.view = view;
-           this.working = null;
-           this.workScheduled = 0;
-           // End of the current time chunk
-           this.chunkEnd = -1;
-           // Milliseconds of budget left for this chunk
-           this.chunkBudget = -1;
-           this.work = this.work.bind(this);
-           this.scheduleWork();
-       }
-       update(update) {
-           let cx = this.view.state.field(Language$1.state).context;
-           if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
-               this.scheduleWork();
-           if (update.docChanged) {
-               if (this.view.hasFocus)
-                   this.chunkBudget += 50 /* ChangeBonus */;
-               this.scheduleWork();
-           }
-           this.checkAsyncSchedule(cx);
-       }
-       scheduleWork() {
-           if (this.working)
-               return;
-           let { state } = this.view, field = state.field(Language$1.state);
-           if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
-               this.working = requestIdle$1(this.work);
-       }
-       work(deadline) {
-           this.working = null;
-           let now = Date.now();
-           if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
-               this.chunkEnd = now + 30000 /* ChunkTime */;
-               this.chunkBudget = 3000 /* ChunkBudget */;
-           }
-           if (this.chunkBudget <= 0)
-               return; // No more budget
-           let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language$1.state);
-           if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* MaxParseAhead */))
-               return;
-           let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Slice */, deadline && !isInputPending$1 ? Math.max(25 /* MinSlice */, deadline.timeRemaining() - 5) : 1e9);
-           let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
-           let done = field.context.work(() => {
-               return isInputPending$1 && isInputPending$1() || Date.now() > endTime;
-           }, vpTo + (viewportFirst ? 0 : 100000 /* MaxParseAhead */));
-           this.chunkBudget -= Date.now() - now;
-           if (done || this.chunkBudget <= 0) {
-               field.context.takeTree();
-               this.view.dispatch({ effects: Language$1.setState.of(new LanguageState$1(field.context)) });
-           }
-           if (this.chunkBudget > 0 && !(done && !viewportFirst))
-               this.scheduleWork();
-           this.checkAsyncSchedule(field.context);
-       }
-       checkAsyncSchedule(cx) {
-           if (cx.scheduleOn) {
-               this.workScheduled++;
-               cx.scheduleOn
-                   .then(() => this.scheduleWork())
-                   .catch(err => logException$2(this.view.state, err))
-                   .then(() => this.workScheduled--);
-               cx.scheduleOn = null;
-           }
-       }
-       destroy() {
-           if (this.working)
-               this.working();
-       }
-       isWorking() {
-           return !!(this.working || this.workScheduled > 0);
-       }
-   }, {
-       eventHandlers: { focus() { this.scheduleWork(); } }
-   });
-   /**
-   The facet used to associate a language with an editor state.
-   */
-   const language$1 = /*@__PURE__*/Facet$2.define({
-       combine(languages) { return languages.length ? languages[0] : null; },
-       enables: [Language$1.state, parseWorker$1]
-   });
-
-   /**
-   Facet that defines a way to provide a function that computes the
-   appropriate indentation depth at the start of a given line, or
-   `null` to indicate no appropriate indentation could be determined.
-   */
-   const indentService = /*@__PURE__*/Facet$2.define();
-   /**
-   Facet for overriding the unit by which indentation happens.
-   Should be a string consisting either entirely of spaces or
-   entirely of tabs. When not set, this defaults to 2 spaces.
-   */
-   const indentUnit$1 = /*@__PURE__*/Facet$2.define({
-       combine: values => {
-           if (!values.length)
-               return "  ";
-           if (!/^(?: +|\t+)$/.test(values[0]))
-               throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
-           return values[0];
-       }
-   });
-   /**
-   Return the _column width_ of an indent unit in the state.
-   Determined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)
-   facet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that
-   contains tabs.
-   */
-   function getIndentUnit(state) {
-       let unit = state.facet(indentUnit$1);
-       return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;
-   }
-   /**
-   Create an indentation string that covers columns 0 to `cols`.
-   Will use tabs for as much of the columns as possible when the
-   [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains
-   tabs.
-   */
-   function indentString(state, cols) {
-       let result = "", ts = state.tabSize;
-       if (state.facet(indentUnit$1).charCodeAt(0) == 9)
-           while (cols >= ts) {
-               result += "\t";
-               cols -= ts;
-           }
-       for (let i = 0; i < cols; i++)
-           result += " ";
-       return result;
-   }
-   /**
-   Get the indentation at the given position. Will first consult any
-   [indent services](https://codemirror.net/6/docs/ref/#language.indentService) that are registered,
-   and if none of those return an indentation, this will check the
-   syntax tree for the [indent node prop](https://codemirror.net/6/docs/ref/#language.indentNodeProp)
-   and use that if found. Returns a number when an indentation could
-   be determined, and null otherwise.
-   */
-   function getIndentation(context, pos) {
-       if (context instanceof EditorState$2)
-           context = new IndentContext(context);
-       for (let service of context.state.facet(indentService)) {
-           let result = service(context, pos);
-           if (result != null)
-               return result;
-       }
-       let tree = syntaxTree$1(context.state);
-       return tree ? syntaxIndentation(context, tree, pos) : null;
-   }
-   /**
-   Indentation contexts are used when calling [indentation
-   services](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities
-   useful in indentation logic, and can selectively override the
-   indentation reported for some lines.
-   */
-   class IndentContext {
-       /**
-       Create an indent context.
-       */
-       constructor(
-       /**
-       The editor state.
-       */
-       state, 
-       /**
-       @internal
-       */
-       options = {}) {
-           this.state = state;
-           this.options = options;
-           this.unit = getIndentUnit(state);
-       }
-       /**
-       Get a description of the line at the given position, taking
-       [simulated line
-       breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
-       into account. If there is such a break at `pos`, the `bias`
-       argument determines whether the part of the line line before or
-       after the break is used.
-       */
-       lineAt(pos, bias = 1) {
-           let line = this.state.doc.lineAt(pos);
-           let { simulateBreak, simulateDoubleBreak } = this.options;
-           if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {
-               if (simulateDoubleBreak && simulateBreak == pos)
-                   return { text: "", from: pos };
-               else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)
-                   return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };
-               else
-                   return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };
-           }
-           return line;
-       }
-       /**
-       Get the text directly after `pos`, either the entire line
-       or the next 100 characters, whichever is shorter.
-       */
-       textAfterPos(pos, bias = 1) {
-           if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)
-               return "";
-           let { text, from } = this.lineAt(pos, bias);
-           return text.slice(pos - from, Math.min(text.length, pos + 100 - from));
-       }
-       /**
-       Find the column for the given position.
-       */
-       column(pos, bias = 1) {
-           let { text, from } = this.lineAt(pos, bias);
-           let result = this.countColumn(text, pos - from);
-           let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;
-           if (override > -1)
-               result += override - this.countColumn(text, text.search(/\S|$/));
-           return result;
-       }
-       /**
-       Find the column position (taking tabs into account) of the given
-       position in the given string.
-       */
-       countColumn(line, pos = line.length) {
-           return countColumn(line, this.state.tabSize, pos);
-       }
-       /**
-       Find the indentation column of the line at the given point.
-       */
-       lineIndent(pos, bias = 1) {
-           let { text, from } = this.lineAt(pos, bias);
-           let override = this.options.overrideIndentation;
-           if (override) {
-               let overriden = override(from);
-               if (overriden > -1)
-                   return overriden;
-           }
-           return this.countColumn(text, text.search(/\S|$/));
-       }
-       /**
-       Returns the [simulated line
-       break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
-       for this context, if any.
-       */
-       get simulatedBreak() {
-           return this.options.simulateBreak || null;
-       }
-   }
-   /**
-   A syntax tree node prop used to associate indentation strategies
-   with node types. Such a strategy is a function from an indentation
-   context to a column number or null, where null indicates that no
-   definitive indentation can be determined.
-   */
-   const indentNodeProp$1 = /*@__PURE__*/new NodeProp$1();
-   // Compute the indentation for a given position from the syntax tree.
-   function syntaxIndentation(cx, ast, pos) {
-       return indentFrom(ast.resolveInner(pos).enterUnfinishedNodesBefore(pos), pos, cx);
-   }
-   function ignoreClosed(cx) {
-       return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;
-   }
-   function indentStrategy(tree) {
-       let strategy = tree.type.prop(indentNodeProp$1);
-       if (strategy)
-           return strategy;
-       let first = tree.firstChild, close;
-       if (first && (close = first.type.prop(NodeProp$1.closedBy))) {
-           let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;
-           return cx => delimitedStrategy$1(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);
-       }
-       return tree.parent == null ? topIndent : null;
-   }
-   function indentFrom(node, pos, base) {
-       for (; node; node = node.parent) {
-           let strategy = indentStrategy(node);
-           if (strategy)
-               return strategy(TreeIndentContext.create(base, pos, node));
-       }
-       return null;
-   }
-   function topIndent() { return 0; }
-   /**
-   Objects of this type provide context information and helper
-   methods to indentation functions registered on syntax nodes.
-   */
-   class TreeIndentContext extends IndentContext {
-       constructor(base, 
-       /**
-       The position at which indentation is being computed.
-       */
-       pos, 
-       /**
-       The syntax tree node to which the indentation strategy
-       applies.
-       */
-       node) {
-           super(base.state, base.options);
-           this.base = base;
-           this.pos = pos;
-           this.node = node;
-       }
-       /**
-       @internal
-       */
-       static create(base, pos, node) {
-           return new TreeIndentContext(base, pos, node);
-       }
-       /**
-       Get the text directly after `this.pos`, either the entire line
-       or the next 100 characters, whichever is shorter.
-       */
-       get textAfter() {
-           return this.textAfterPos(this.pos);
-       }
-       /**
-       Get the indentation at the reference line for `this.node`, which
-       is the line on which it starts, unless there is a node that is
-       _not_ a parent of this node covering the start of that line. If
-       so, the line at the start of that node is tried, again skipping
-       on if it is covered by another such node.
-       */
-       get baseIndent() {
-           let line = this.state.doc.lineAt(this.node.from);
-           // Skip line starts that are covered by a sibling (or cousin, etc)
-           for (;;) {
-               let atBreak = this.node.resolve(line.from);
-               while (atBreak.parent && atBreak.parent.from == atBreak.from)
-                   atBreak = atBreak.parent;
-               if (isParent(atBreak, this.node))
-                   break;
-               line = this.state.doc.lineAt(atBreak.from);
-           }
-           return this.lineIndent(line.from);
-       }
-       /**
-       Continue looking for indentations in the node's parent nodes,
-       and return the result of that.
-       */
-       continue() {
-           let parent = this.node.parent;
-           return parent ? indentFrom(parent, this.pos, this.base) : 0;
-       }
-   }
-   function isParent(parent, of) {
-       for (let cur = of; cur; cur = cur.parent)
-           if (parent == cur)
-               return true;
-       return false;
-   }
-   // Check whether a delimited node is aligned (meaning there are
-   // non-skipped nodes on the same line as the opening delimiter). And
-   // if so, return the opening token.
-   function bracketedAligned$1(context) {
-       let tree = context.node;
-       let openToken = tree.childAfter(tree.from), last = tree.lastChild;
-       if (!openToken)
-           return null;
-       let sim = context.options.simulateBreak;
-       let openLine = context.state.doc.lineAt(openToken.from);
-       let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
-       for (let pos = openToken.to;;) {
-           let next = tree.childAfter(pos);
-           if (!next || next == last)
-               return null;
-           if (!next.type.isSkipped)
-               return next.from < lineEnd ? openToken : null;
-           pos = next.to;
-       }
-   }
-   function delimitedStrategy$1(context, align, units, closing, closedAt) {
-       let after = context.textAfter, space = after.match(/^\s*/)[0].length;
-       let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
-       let aligned = bracketedAligned$1(context) ;
-       if (aligned)
-           return closed ? context.column(aligned.from) : context.column(aligned.to);
-       return context.baseIndent + (closed ? 0 : context.unit * units);
-   }
-   const DefaultScanDist = 10000, DefaultBrackets = "()[]{}";
-   function matchingNodes(node, dir, brackets) {
-       let byProp = node.prop(dir < 0 ? NodeProp$1.openedBy : NodeProp$1.closedBy);
-       if (byProp)
-           return byProp;
-       if (node.name.length == 1) {
-           let index = brackets.indexOf(node.name);
-           if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))
-               return [brackets[index + dir]];
-       }
-       return null;
-   }
-   /**
-   Find the matching bracket for the token at `pos`, scanning
-   direction `dir`. Only the `brackets` and `maxScanDistance`
-   properties are used from `config`, if given. Returns null if no
-   bracket was found at `pos`, or a match result otherwise.
-   */
-   function matchBrackets(state, pos, dir, config = {}) {
-       let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;
-       let tree = syntaxTree$1(state), node = tree.resolveInner(pos, dir);
-       for (let cur = node; cur; cur = cur.parent) {
-           let matches = matchingNodes(cur.type, dir, brackets);
-           if (matches && cur.from < cur.to)
-               return matchMarkedBrackets(state, pos, dir, cur, matches, brackets);
-       }
-       return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);
-   }
-   function matchMarkedBrackets(_state, _pos, dir, token, matching, brackets) {
-       let parent = token.parent, firstToken = { from: token.from, to: token.to };
-       let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();
-       if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))
-           do {
-               if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {
-                   if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {
-                       return { start: firstToken, end: { from: cursor.from, to: cursor.to }, matched: true };
-                   }
-                   else if (matchingNodes(cursor.type, dir, brackets)) {
-                       depth++;
-                   }
-                   else if (matchingNodes(cursor.type, -dir, brackets)) {
-                       depth--;
-                       if (depth == 0)
-                           return {
-                               start: firstToken,
-                               end: cursor.from == cursor.to ? undefined : { from: cursor.from, to: cursor.to },
-                               matched: false
-                           };
-                   }
-               }
-           } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());
-       return { start: firstToken, matched: false };
-   }
-   function matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {
-       let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);
-       let bracket = brackets.indexOf(startCh);
-       if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))
-           return null;
-       let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };
-       let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;
-       for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {
-           let text = iter.value;
-           if (dir < 0)
-               distance += text.length;
-           let basePos = pos + distance * dir;
-           for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {
-               let found = brackets.indexOf(text[pos]);
-               if (found < 0 || tree.resolve(basePos + pos, 1).type != tokenType)
-                   continue;
-               if ((found % 2 == 0) == (dir > 0)) {
-                   depth++;
-               }
-               else if (depth == 1) { // Closing
-                   return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };
-               }
-               else {
-                   depth--;
-               }
-           }
-           if (dir > 0)
-               distance += text.length;
-       }
-       return iter.done ? { start: startToken, matched: false } : null;
-   }
-   const noTokens$1 = /*@__PURE__*/Object.create(null);
-   const typeArray$1 = [NodeType$1.none];
-   const warned$1 = [];
-   const defaultTable$1 = /*@__PURE__*/Object.create(null);
-   for (let [legacyName, name] of [
-       ["variable", "variableName"],
-       ["variable-2", "variableName.special"],
-       ["string-2", "string.special"],
-       ["def", "variableName.definition"],
-       ["tag", "typeName"],
-       ["attribute", "propertyName"],
-       ["type", "typeName"],
-       ["builtin", "variableName.standard"],
-       ["qualifier", "modifier"],
-       ["error", "invalid"],
-       ["header", "heading"],
-       ["property", "propertyName"]
-   ])
-       defaultTable$1[legacyName] = /*@__PURE__*/createTokenType$1(noTokens$1, name);
-   function warnForPart$1(part, msg) {
-       if (warned$1.indexOf(part) > -1)
-           return;
-       warned$1.push(part);
-       console.warn(msg);
-   }
-   function createTokenType$1(extra, tagStr) {
-       let tag = null;
-       for (let part of tagStr.split(".")) {
-           let value = (extra[part] || tags$1[part]);
-           if (!value) {
-               warnForPart$1(part, `Unknown highlighting tag ${part}`);
-           }
-           else if (typeof value == "function") {
-               if (!tag)
-                   warnForPart$1(part, `Modifier ${part} used at start of tag`);
-               else
-                   tag = value(tag);
-           }
-           else {
-               if (tag)
-                   warnForPart$1(part, `Tag ${part} used as modifier`);
-               else
-                   tag = value;
-           }
-       }
-       if (!tag)
-           return 0;
-       let name = tagStr.replace(/ /g, "_"), type = NodeType$1.define({
-           id: typeArray$1.length,
-           name,
-           props: [styleTags$1({ [name]: tag })]
-       });
-       typeArray$1.push(type);
-       return type.id;
-   }
-
-   /**
-   Comment or uncomment the current selection. Will use line comments
-   if available, otherwise falling back to block comments.
-   */
-   const toggleComment = target => {
-       let config = getConfig(target.state);
-       return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;
-   };
-   function command(f, option) {
-       return ({ state, dispatch }) => {
-           if (state.readOnly)
-               return false;
-           let tr = f(option, state);
-           if (!tr)
-               return false;
-           dispatch(state.update(tr));
-           return true;
-       };
-   }
-   /**
-   Comment or uncomment the current selection using line comments.
-   The line comment syntax is taken from the
-   [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
-   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
-   */
-   const toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* Toggle */);
-   /**
-   Comment or uncomment the current selection using block comments.
-   The block comment syntax is taken from the
-   [`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
-   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
-   */
-   const toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* Toggle */);
-   /**
-   Comment or uncomment the lines around the current selection using
-   block comments.
-   */
-   const toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* Toggle */);
-   function getConfig(state, pos = state.selection.main.head) {
-       let data = state.languageDataAt("commentTokens", pos);
-       return data.length ? data[0] : {};
-   }
-   const SearchMargin = 50;
-   /**
-   Determines if the given range is block-commented in the given
-   state.
-   */
-   function findBlockComment(state, { open, close }, from, to) {
-       let textBefore = state.sliceDoc(from - SearchMargin, from);
-       let textAfter = state.sliceDoc(to, to + SearchMargin);
-       let spaceBefore = /\s*$/.exec(textBefore)[0].length, spaceAfter = /^\s*/.exec(textAfter)[0].length;
-       let beforeOff = textBefore.length - spaceBefore;
-       if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&
-           textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {
-           return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },
-               close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };
-       }
-       let startText, endText;
-       if (to - from <= 2 * SearchMargin) {
-           startText = endText = state.sliceDoc(from, to);
-       }
-       else {
-           startText = state.sliceDoc(from, from + SearchMargin);
-           endText = state.sliceDoc(to - SearchMargin, to);
-       }
-       let startSpace = /^\s*/.exec(startText)[0].length, endSpace = /\s*$/.exec(endText)[0].length;
-       let endOff = endText.length - endSpace - close.length;
-       if (startText.slice(startSpace, startSpace + open.length) == open &&
-           endText.slice(endOff, endOff + close.length) == close) {
-           return { open: { pos: from + startSpace + open.length,
-                   margin: /\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },
-               close: { pos: to - endSpace - close.length,
-                   margin: /\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };
-       }
-       return null;
-   }
-   function selectedLineRanges(state) {
-       let ranges = [];
-       for (let r of state.selection.ranges) {
-           let fromLine = state.doc.lineAt(r.from);
-           let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);
-           let last = ranges.length - 1;
-           if (last >= 0 && ranges[last].to > fromLine.from)
-               ranges[last].to = toLine.to;
-           else
-               ranges.push({ from: fromLine.from, to: toLine.to });
-       }
-       return ranges;
-   }
-   // Performs toggle, comment and uncomment of block comments in
-   // languages that support them.
-   function changeBlockComment(option, state, ranges = state.selection.ranges) {
-       let tokens = ranges.map(r => getConfig(state, r.from).block);
-       if (!tokens.every(c => c))
-           return null;
-       let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));
-       if (option != 2 /* Uncomment */ && !comments.every(c => c)) {
-           return { changes: state.changes(ranges.map((range, i) => {
-                   if (comments[i])
-                       return [];
-                   return [{ from: range.from, insert: tokens[i].open + " " }, { from: range.to, insert: " " + tokens[i].close }];
-               })) };
-       }
-       else if (option != 1 /* Comment */ && comments.some(c => c)) {
-           let changes = [];
-           for (let i = 0, comment; i < comments.length; i++)
-               if (comment = comments[i]) {
-                   let token = tokens[i], { open, close } = comment;
-                   changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });
-               }
-           return { changes };
-       }
-       return null;
-   }
-   // Performs toggle, comment and uncomment of line comments.
-   function changeLineComment(option, state, ranges = state.selection.ranges) {
-       let lines = [];
-       let prevLine = -1;
-       for (let { from, to } of ranges) {
-           let startI = lines.length, minIndent = 1e9;
-           for (let pos = from; pos <= to;) {
-               let line = state.doc.lineAt(pos);
-               if (line.from > prevLine && (from == to || to > line.from)) {
-                   prevLine = line.from;
-                   let token = getConfig(state, pos).line;
-                   if (!token)
-                       continue;
-                   let indent = /^\s*/.exec(line.text)[0].length;
-                   let empty = indent == line.length;
-                   let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;
-                   if (indent < line.text.length && indent < minIndent)
-                       minIndent = indent;
-                   lines.push({ line, comment, token, indent, empty, single: false });
-               }
-               pos = line.to + 1;
-           }
-           if (minIndent < 1e9)
-               for (let i = startI; i < lines.length; i++)
-                   if (lines[i].indent < lines[i].line.text.length)
-                       lines[i].indent = minIndent;
-           if (lines.length == startI + 1)
-               lines[startI].single = true;
-       }
-       if (option != 2 /* Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {
-           let changes = [];
-           for (let { line, token, indent, empty, single } of lines)
-               if (single || !empty)
-                   changes.push({ from: line.from + indent, insert: token + " " });
-           let changeSet = state.changes(changes);
-           return { changes: changeSet, selection: state.selection.map(changeSet, 1) };
-       }
-       else if (option != 1 /* Comment */ && lines.some(l => l.comment >= 0)) {
-           let changes = [];
-           for (let { line, comment, token } of lines)
-               if (comment >= 0) {
-                   let from = line.from + comment, to = from + token.length;
-                   if (line.text[to - line.from] == " ")
-                       to++;
-                   changes.push({ from, to });
-               }
-           return { changes };
-       }
-       return null;
-   }
-
-   const fromHistory = /*@__PURE__*/Annotation$2.define();
-   /**
-   Transaction annotation that will prevent that transaction from
-   being combined with other transactions in the undo history. Given
-   `"before"`, it'll prevent merging with previous transactions. With
-   `"after"`, subsequent transactions won't be combined with this
-   one. With `"full"`, the transaction is isolated on both sides.
-   */
-   const isolateHistory = /*@__PURE__*/Annotation$2.define();
-   /**
-   This facet provides a way to register functions that, given a
-   transaction, provide a set of effects that the history should
-   store when inverting the transaction. This can be used to
-   integrate some kinds of effects in the history, so that they can
-   be undone (and redone again).
-   */
-   const invertedEffects = /*@__PURE__*/Facet$2.define();
-   const historyConfig = /*@__PURE__*/Facet$2.define({
-       combine(configs) {
-           return combineConfig$2(configs, {
-               minDepth: 100,
-               newGroupDelay: 500
-           }, { minDepth: Math.max, newGroupDelay: Math.min });
-       }
-   });
-   function changeEnd(changes) {
-       let end = 0;
-       changes.iterChangedRanges((_, to) => end = to);
-       return end;
-   }
-   const historyField_ = /*@__PURE__*/StateField$2.define({
-       create() {
-           return HistoryState.empty;
-       },
-       update(state, tr) {
-           let config = tr.state.facet(historyConfig);
-           let fromHist = tr.annotation(fromHistory);
-           if (fromHist) {
-               let selection = tr.docChanged ? EditorSelection$2.single(changeEnd(tr.changes)) : undefined;
-               let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;
-               let other = from == 0 /* Done */ ? state.undone : state.done;
-               if (item)
-                   other = updateBranch(other, other.length, config.minDepth, item);
-               else
-                   other = addSelection(other, tr.startState.selection);
-               return new HistoryState(from == 0 /* Done */ ? fromHist.rest : other, from == 0 /* Done */ ? other : fromHist.rest);
-           }
-           let isolate = tr.annotation(isolateHistory);
-           if (isolate == "full" || isolate == "before")
-               state = state.isolate();
-           if (tr.annotation(Transaction$2.addToHistory) === false)
-               return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;
-           let event = HistEvent.fromTransaction(tr);
-           let time = tr.annotation(Transaction$2.time), userEvent = tr.annotation(Transaction$2.userEvent);
-           if (event)
-               state = state.addChanges(event, time, userEvent, config.newGroupDelay, config.minDepth);
-           else if (tr.selection)
-               state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);
-           if (isolate == "full" || isolate == "after")
-               state = state.isolate();
-           return state;
-       },
-       toJSON(value) {
-           return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };
-       },
-       fromJSON(json) {
-           return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));
-       }
-   });
-   /**
-   Create a history extension with the given configuration.
-   */
-   function history(config = {}) {
-       return [
-           historyField_,
-           historyConfig.of(config),
-           EditorView$2.domEventHandlers({
-               beforeinput(e, view) {
-                   let command = e.inputType == "historyUndo" ? undo : e.inputType == "historyRedo" ? redo : null;
-                   if (!command)
-                       return false;
-                   e.preventDefault();
-                   return command(view);
-               }
-           })
-       ];
-   }
-   function cmd(side, selection) {
-       return function ({ state, dispatch }) {
-           if (!selection && state.readOnly)
-               return false;
-           let historyState = state.field(historyField_, false);
-           if (!historyState)
-               return false;
-           let tr = historyState.pop(side, state, selection);
-           if (!tr)
-               return false;
-           dispatch(tr);
-           return true;
-       };
-   }
-   /**
-   Undo a single group of history events. Returns false if no group
-   was available.
-   */
-   const undo = /*@__PURE__*/cmd(0 /* Done */, false);
-   /**
-   Redo a group of history events. Returns false if no group was
-   available.
-   */
-   const redo = /*@__PURE__*/cmd(1 /* Undone */, false);
-   /**
-   Undo a change or selection change.
-   */
-   const undoSelection = /*@__PURE__*/cmd(0 /* Done */, true);
-   /**
-   Redo a change or selection change.
-   */
-   const redoSelection = /*@__PURE__*/cmd(1 /* Undone */, true);
-   // History events store groups of changes or effects that need to be
-   // undone/redone together.
-   class HistEvent {
-       constructor(
-       // The changes in this event. Normal events hold at least one
-       // change or effect. But it may be necessary to store selection
-       // events before the first change, in which case a special type of
-       // instance is created which doesn't hold any changes, with
-       // changes == startSelection == undefined
-       changes, 
-       // The effects associated with this event
-       effects, mapped, 
-       // The selection before this event
-       startSelection, 
-       // Stores selection changes after this event, to be used for
-       // selection undo/redo.
-       selectionsAfter) {
-           this.changes = changes;
-           this.effects = effects;
-           this.mapped = mapped;
-           this.startSelection = startSelection;
-           this.selectionsAfter = selectionsAfter;
-       }
-       setSelAfter(after) {
-           return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);
-       }
-       toJSON() {
-           var _a, _b, _c;
-           return {
-               changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),
-               mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),
-               startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),
-               selectionsAfter: this.selectionsAfter.map(s => s.toJSON())
-           };
-       }
-       static fromJSON(json) {
-           return new HistEvent(json.changes && ChangeSet$2.fromJSON(json.changes), [], json.mapped && ChangeDesc$2.fromJSON(json.mapped), json.startSelection && EditorSelection$2.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection$2.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(tr, selection) {
-           let effects = none$4;
-           for (let invert of tr.startState.facet(invertedEffects)) {
-               let result = invert(tr);
-               if (result.length)
-                   effects = effects.concat(result);
-           }
-           if (!effects.length && tr.changes.empty)
-               return null;
-           return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none$4);
-       }
-       static selection(selections) {
-           return new HistEvent(undefined, none$4, undefined, undefined, selections);
-       }
-   }
-   function updateBranch(branch, to, maxLen, newEvent) {
-       let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;
-       let newBranch = branch.slice(start, to);
-       newBranch.push(newEvent);
-       return newBranch;
-   }
-   function isAdjacent(a, b) {
-       let ranges = [], isAdjacent = false;
-       a.iterChangedRanges((f, t) => ranges.push(f, t));
-       b.iterChangedRanges((_f, _t, f, t) => {
-           for (let i = 0; i < ranges.length;) {
-               let from = ranges[i++], to = ranges[i++];
-               if (t >= from && f <= to)
-                   isAdjacent = true;
-           }
-       });
-       return isAdjacent;
-   }
-   function eqSelectionShape(a, b) {
-       return a.ranges.length == b.ranges.length &&
-           a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;
-   }
-   function conc(a, b) {
-       return !a.length ? b : !b.length ? a : a.concat(b);
-   }
-   const none$4 = [];
-   const MaxSelectionsPerEvent = 200;
-   function addSelection(branch, selection) {
-       if (!branch.length) {
-           return [HistEvent.selection([selection])];
-       }
-       else {
-           let lastEvent = branch[branch.length - 1];
-           let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));
-           if (sels.length && sels[sels.length - 1].eq(selection))
-               return branch;
-           sels.push(selection);
-           return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));
-       }
-   }
-   // Assumes the top item has one or more selectionAfter values
-   function popSelection(branch) {
-       let last = branch[branch.length - 1];
-       let newBranch = branch.slice();
-       newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));
-       return newBranch;
-   }
-   // Add a mapping to the top event in the given branch. If this maps
-   // away all the changes and effects in that item, drop it and
-   // propagate the mapping to the next item.
-   function addMappingToBranch(branch, mapping) {
-       if (!branch.length)
-           return branch;
-       let length = branch.length, selections = none$4;
-       while (length) {
-           let event = mapEvent(branch[length - 1], mapping, selections);
-           if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping
-               let result = branch.slice(0, length);
-               result[length - 1] = event;
-               return result;
-           }
-           else { // Drop this event, since there's no changes or effects left
-               mapping = event.mapped;
-               length--;
-               selections = event.selectionsAfter;
-           }
-       }
-       return selections.length ? [HistEvent.selection(selections)] : none$4;
-   }
-   function mapEvent(event, mapping, extraSelections) {
-       let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none$4, extraSelections);
-       // Change-less events don't store mappings (they are always the last event in a branch)
-       if (!event.changes)
-           return HistEvent.selection(selections);
-       let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);
-       let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;
-       return new HistEvent(mappedChanges, StateEffect$2.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);
-   }
-   const joinableUserEvent = /^(input\.type|delete)($|\.)/;
-   class HistoryState {
-       constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {
-           this.done = done;
-           this.undone = undone;
-           this.prevTime = prevTime;
-           this.prevUserEvent = prevUserEvent;
-       }
-       isolate() {
-           return this.prevTime ? new HistoryState(this.done, this.undone) : this;
-       }
-       addChanges(event, time, userEvent, newGroupDelay, maxLen) {
-           let done = this.done, lastEvent = done[done.length - 1];
-           if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&
-               (!userEvent || joinableUserEvent.test(userEvent)) &&
-               ((!lastEvent.selectionsAfter.length &&
-                   time - this.prevTime < newGroupDelay &&
-                   isAdjacent(lastEvent.changes, event.changes)) ||
-                   // For compose (but not compose.start) events, always join with previous event
-                   userEvent == "input.type.compose")) {
-               done = updateBranch(done, done.length - 1, maxLen, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none$4));
-           }
-           else {
-               done = updateBranch(done, done.length, maxLen, event);
-           }
-           return new HistoryState(done, none$4, time, userEvent);
-       }
-       addSelection(selection, time, userEvent, newGroupDelay) {
-           let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none$4;
-           if (last.length > 0 &&
-               time - this.prevTime < newGroupDelay &&
-               userEvent == this.prevUserEvent && userEvent && /^select($|\.)/.test(userEvent) &&
-               eqSelectionShape(last[last.length - 1], selection))
-               return this;
-           return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);
-       }
-       addMapping(mapping) {
-           return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);
-       }
-       pop(side, state, selection) {
-           let branch = side == 0 /* Done */ ? this.done : this.undone;
-           if (branch.length == 0)
-               return null;
-           let event = branch[branch.length - 1];
-           if (selection && event.selectionsAfter.length) {
-               return state.update({
-                   selection: event.selectionsAfter[event.selectionsAfter.length - 1],
-                   annotations: fromHistory.of({ side, rest: popSelection(branch) }),
-                   userEvent: side == 0 /* Done */ ? "select.undo" : "select.redo",
-                   scrollIntoView: true
-               });
-           }
-           else if (!event.changes) {
-               return null;
-           }
-           else {
-               let rest = branch.length == 1 ? none$4 : branch.slice(0, branch.length - 1);
-               if (event.mapped)
-                   rest = addMappingToBranch(rest, event.mapped);
-               return state.update({
-                   changes: event.changes,
-                   selection: event.startSelection,
-                   effects: event.effects,
-                   annotations: fromHistory.of({ side, rest }),
-                   filter: false,
-                   userEvent: side == 0 /* Done */ ? "undo" : "redo",
-                   scrollIntoView: true
-               });
-           }
-       }
-   }
-   HistoryState.empty = /*@__PURE__*/new HistoryState(none$4, none$4);
-   /**
-   Default key bindings for the undo history.
-
-   - Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
-   - Mod-y (Mod-Shift-z on macOS): [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
-   - Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
-   - Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
-   */
-   const historyKeymap = [
-       { key: "Mod-z", run: undo, preventDefault: true },
-       { key: "Mod-y", mac: "Mod-Shift-z", run: redo, preventDefault: true },
-       { key: "Mod-u", run: undoSelection, preventDefault: true },
-       { key: "Alt-u", mac: "Mod-Shift-u", run: redoSelection, preventDefault: true }
-   ];
-
-   function updateSel(sel, by) {
-       return EditorSelection$2.create(sel.ranges.map(by), sel.mainIndex);
-   }
-   function setSel(state, selection) {
-       return state.update({ selection, scrollIntoView: true, userEvent: "select" });
-   }
-   function moveSel({ state, dispatch }, how) {
-       let selection = updateSel(state.selection, how);
-       if (selection.eq(state.selection))
-           return false;
-       dispatch(setSel(state, selection));
-       return true;
-   }
-   function rangeEnd(range, forward) {
-       return EditorSelection$2.cursor(forward ? range.to : range.from);
-   }
-   function cursorByChar(view, forward) {
-       return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));
-   }
-   function ltrAtCursor(view) {
-       return view.textDirectionAt(view.state.selection.main.head) == Direction$2.LTR;
-   }
-   /**
-   Move the selection one character to the left (which is backward in
-   left-to-right text, forward in right-to-left text).
-   */
-   const cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));
-   /**
-   Move the selection one character to the right.
-   */
-   const cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));
-   function cursorByGroup(view, forward) {
-       return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));
-   }
-   /**
-   Move the selection to the left across one group of word or
-   non-word (but also non-space) characters.
-   */
-   const cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));
-   /**
-   Move the selection one group to the right.
-   */
-   const cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));
-   function interestingNode(state, node, bracketProp) {
-       if (node.type.prop(bracketProp))
-           return true;
-       let len = node.to - node.from;
-       return len && (len > 2 || /[^\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;
-   }
-   function moveBySyntax(state, start, forward) {
-       let pos = syntaxTree$1(state).resolveInner(start.head);
-       let bracketProp = forward ? NodeProp$1.closedBy : NodeProp$1.openedBy;
-       // Scan forward through child nodes to see if there's an interesting
-       // node ahead.
-       for (let at = start.head;;) {
-           let next = forward ? pos.childAfter(at) : pos.childBefore(at);
-           if (!next)
-               break;
-           if (interestingNode(state, next, bracketProp))
-               pos = next;
-           else
-               at = forward ? next.to : next.from;
-       }
-       let bracket = pos.type.prop(bracketProp), match, newPos;
-       if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched)
-           newPos = forward ? match.end.to : match.end.from;
-       else
-           newPos = forward ? pos.to : pos.from;
-       return EditorSelection$2.cursor(newPos, forward ? -1 : 1);
-   }
-   /**
-   Move the cursor over the next syntactic element to the left.
-   */
-   const cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
-   /**
-   Move the cursor over the next syntactic element to the right.
-   */
-   const cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
-   function cursorByLine(view, forward) {
-       return moveSel(view, range => {
-           if (!range.empty)
-               return rangeEnd(range, forward);
-           let moved = view.moveVertically(range, forward);
-           return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);
-       });
-   }
-   /**
-   Move the selection one line up.
-   */
-   const cursorLineUp = view => cursorByLine(view, false);
-   /**
-   Move the selection one line down.
-   */
-   const cursorLineDown = view => cursorByLine(view, true);
-   function cursorByPage(view, forward) {
-       let { state } = view, selection = updateSel(state.selection, range => {
-           return range.empty ? view.moveVertically(range, forward, Math.min(view.dom.clientHeight, innerHeight))
-               : rangeEnd(range, forward);
-       });
-       if (selection.eq(state.selection))
-           return false;
-       let startPos = view.coordsAtPos(state.selection.main.head);
-       let scrollRect = view.scrollDOM.getBoundingClientRect();
-       let effect;
-       if (startPos && startPos.top > scrollRect.top && startPos.bottom < scrollRect.bottom &&
-           startPos.top - scrollRect.top <= view.scrollDOM.scrollHeight - view.scrollDOM.scrollTop - view.scrollDOM.clientHeight)
-           effect = EditorView$2.scrollIntoView(selection.main.head, { y: "start", yMargin: startPos.top - scrollRect.top });
-       view.dispatch(setSel(state, selection), { effects: effect });
-       return true;
-   }
-   /**
-   Move the selection one page up.
-   */
-   const cursorPageUp = view => cursorByPage(view, false);
-   /**
-   Move the selection one page down.
-   */
-   const cursorPageDown = view => cursorByPage(view, true);
-   function moveByLineBoundary(view, start, forward) {
-       let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward);
-       if (moved.head == start.head && moved.head != (forward ? line.to : line.from))
-           moved = view.moveToLineBoundary(start, forward, false);
-       if (!forward && moved.head == line.from && line.length) {
-           let space = /^\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;
-           if (space && start.head != line.from + space)
-               moved = EditorSelection$2.cursor(line.from + space);
-       }
-       return moved;
-   }
-   /**
-   Move the selection to the next line wrap point, or to the end of
-   the line if there isn't one left on this line.
-   */
-   const cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));
-   /**
-   Move the selection to previous line wrap point, or failing that to
-   the start of the line. If the line is indented, and the cursor
-   isn't already at the end of the indentation, this will move to the
-   end of the indentation instead of the start of the line.
-   */
-   const cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));
-   /**
-   Move the selection to the start of the line.
-   */
-   const cursorLineStart = view => moveSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).from, 1));
-   /**
-   Move the selection to the end of the line.
-   */
-   const cursorLineEnd = view => moveSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).to, -1));
-   function toMatchingBracket(state, dispatch, extend) {
-       let found = false, selection = updateSel(state.selection, range => {
-           let matching = matchBrackets(state, range.head, -1)
-               || matchBrackets(state, range.head, 1)
-               || (range.head > 0 && matchBrackets(state, range.head - 1, 1))
-               || (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1));
-           if (!matching || !matching.end)
-               return range;
-           found = true;
-           let head = matching.start.from == range.head ? matching.end.to : matching.end.from;
-           return EditorSelection$2.cursor(head);
-       });
-       if (!found)
-           return false;
-       dispatch(setSel(state, selection));
-       return true;
-   }
-   /**
-   Move the selection to the bracket matching the one it is currently
-   on, if any.
-   */
-   const cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch);
-   function extendSel(view, how) {
-       let selection = updateSel(view.state.selection, range => {
-           let head = how(range);
-           return EditorSelection$2.range(range.anchor, head.head, head.goalColumn);
-       });
-       if (selection.eq(view.state.selection))
-           return false;
-       view.dispatch(setSel(view.state, selection));
-       return true;
-   }
-   function selectByChar(view, forward) {
-       return extendSel(view, range => view.moveByChar(range, forward));
-   }
-   /**
-   Move the selection head one character to the left, while leaving
-   the anchor in place.
-   */
-   const selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));
-   /**
-   Move the selection head one character to the right.
-   */
-   const selectCharRight = view => selectByChar(view, ltrAtCursor(view));
-   function selectByGroup(view, forward) {
-       return extendSel(view, range => view.moveByGroup(range, forward));
-   }
-   /**
-   Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
-   the left.
-   */
-   const selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));
-   /**
-   Move the selection head one group to the right.
-   */
-   const selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));
-   /**
-   Move the selection head over the next syntactic element to the left.
-   */
-   const selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));
-   /**
-   Move the selection head over the next syntactic element to the right.
-   */
-   const selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));
-   function selectByLine(view, forward) {
-       return extendSel(view, range => view.moveVertically(range, forward));
-   }
-   /**
-   Move the selection head one line up.
-   */
-   const selectLineUp = view => selectByLine(view, false);
-   /**
-   Move the selection head one line down.
-   */
-   const selectLineDown = view => selectByLine(view, true);
-   function selectByPage(view, forward) {
-       return extendSel(view, range => view.moveVertically(range, forward, Math.min(view.dom.clientHeight, innerHeight)));
-   }
-   /**
-   Move the selection head one page up.
-   */
-   const selectPageUp = view => selectByPage(view, false);
-   /**
-   Move the selection head one page down.
-   */
-   const selectPageDown = view => selectByPage(view, true);
-   /**
-   Move the selection head to the next line boundary.
-   */
-   const selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));
-   /**
-   Move the selection head to the previous line boundary.
-   */
-   const selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));
-   /**
-   Move the selection head to the start of the line.
-   */
-   const selectLineStart = view => extendSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).from));
-   /**
-   Move the selection head to the end of the line.
-   */
-   const selectLineEnd = view => extendSel(view, range => EditorSelection$2.cursor(view.lineBlockAt(range.head).to));
-   /**
-   Move the selection to the start of the document.
-   */
-   const cursorDocStart = ({ state, dispatch }) => {
-       dispatch(setSel(state, { anchor: 0 }));
-       return true;
-   };
-   /**
-   Move the selection to the end of the document.
-   */
-   const cursorDocEnd = ({ state, dispatch }) => {
-       dispatch(setSel(state, { anchor: state.doc.length }));
-       return true;
-   };
-   /**
-   Move the selection head to the start of the document.
-   */
-   const selectDocStart = ({ state, dispatch }) => {
-       dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 }));
-       return true;
-   };
-   /**
-   Move the selection head to the end of the document.
-   */
-   const selectDocEnd = ({ state, dispatch }) => {
-       dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length }));
-       return true;
-   };
-   /**
-   Select the entire document.
-   */
-   const selectAll = ({ state, dispatch }) => {
-       dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: "select" }));
-       return true;
-   };
-   /**
-   Expand the selection to cover entire lines.
-   */
-   const selectLine = ({ state, dispatch }) => {
-       let ranges = selectedLineBlocks(state).map(({ from, to }) => EditorSelection$2.range(from, Math.min(to + 1, state.doc.length)));
-       dispatch(state.update({ selection: EditorSelection$2.create(ranges), userEvent: "select" }));
-       return true;
-   };
-   /**
-   Select the next syntactic construct that is larger than the
-   selection. Note that this will only work insofar as the language
-   [provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
-   syntax tree.
-   */
-   const selectParentSyntax = ({ state, dispatch }) => {
-       let selection = updateSel(state.selection, range => {
-           var _a;
-           let context = syntaxTree$1(state).resolveInner(range.head, 1);
-           while (!((context.from < range.from && context.to >= range.to) ||
-               (context.to > range.to && context.from <= range.from) ||
-               !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent)))
-               context = context.parent;
-           return EditorSelection$2.range(context.to, context.from);
-       });
-       dispatch(setSel(state, selection));
-       return true;
-   };
-   /**
-   Simplify the current selection. When multiple ranges are selected,
-   reduce it to its main range. Otherwise, if the selection is
-   non-empty, convert it to a cursor selection.
-   */
-   const simplifySelection = ({ state, dispatch }) => {
-       let cur = state.selection, selection = null;
-       if (cur.ranges.length > 1)
-           selection = EditorSelection$2.create([cur.main]);
-       else if (!cur.main.empty)
-           selection = EditorSelection$2.create([EditorSelection$2.cursor(cur.main.head)]);
-       if (!selection)
-           return false;
-       dispatch(setSel(state, selection));
-       return true;
-   };
-   function deleteBy({ state, dispatch }, by) {
-       if (state.readOnly)
-           return false;
-       let event = "delete.selection";
-       let changes = state.changeByRange(range => {
-           let { from, to } = range;
-           if (from == to) {
-               let towards = by(from);
-               if (towards < from)
-                   event = "delete.backward";
-               else if (towards > from)
-                   event = "delete.forward";
-               from = Math.min(from, towards);
-               to = Math.max(to, towards);
-           }
-           return from == to ? { range } : { changes: { from, to }, range: EditorSelection$2.cursor(from) };
-       });
-       if (changes.changes.empty)
-           return false;
-       dispatch(state.update(changes, { scrollIntoView: true, userEvent: event }));
-       return true;
-   }
-   function skipAtomic(target, pos, forward) {
-       if (target instanceof EditorView$2)
-           for (let ranges of target.state.facet(EditorView$2.atomicRanges).map(f => f(target)))
-               ranges.between(pos, pos, (from, to) => {
-                   if (from < pos && to > pos)
-                       pos = forward ? to : from;
-               });
-       return pos;
-   }
-   const deleteByChar = (target, forward) => deleteBy(target, pos => {
-       let { state } = target, line = state.doc.lineAt(pos), before, targetPos;
-       if (!forward && pos > line.from && pos < line.from + 200 &&
-           !/[^ \t]/.test(before = line.text.slice(0, pos - line.from))) {
-           if (before[before.length - 1] == "\t")
-               return pos - 1;
-           let col = countColumn(before, state.tabSize), drop = col % getIndentUnit(state) || getIndentUnit(state);
-           for (let i = 0; i < drop && before[before.length - 1 - i] == " "; i++)
-               pos--;
-           targetPos = pos;
-       }
-       else {
-           targetPos = findClusterBreak$3(line.text, pos - line.from, forward, forward) + line.from;
-           if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))
-               targetPos += forward ? 1 : -1;
-       }
-       return skipAtomic(target, targetPos, forward);
-   });
-   /**
-   Delete the selection, or, for cursor selections, the character
-   before the cursor.
-   */
-   const deleteCharBackward = view => deleteByChar(view, false);
-   /**
-   Delete the selection or the character after the cursor.
-   */
-   const deleteCharForward = view => deleteByChar(view, true);
-   const deleteByGroup = (target, forward) => deleteBy(target, start => {
-       let pos = start, { state } = target, line = state.doc.lineAt(pos);
-       let categorize = state.charCategorizer(pos);
-       for (let cat = null;;) {
-           if (pos == (forward ? line.to : line.from)) {
-               if (pos == start && line.number != (forward ? state.doc.lines : 1))
-                   pos += forward ? 1 : -1;
-               break;
-           }
-           let next = findClusterBreak$3(line.text, pos - line.from, forward) + line.from;
-           let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);
-           let nextCat = categorize(nextChar);
-           if (cat != null && nextCat != cat)
-               break;
-           if (nextChar != " " || pos != start)
-               cat = nextCat;
-           pos = next;
-       }
-       return skipAtomic(target, pos, forward);
-   });
-   /**
-   Delete the selection or backward until the end of the next
-   [group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
-   whitespace when they consist of a single space.
-   */
-   const deleteGroupBackward = target => deleteByGroup(target, false);
-   /**
-   Delete the selection or forward until the end of the next group.
-   */
-   const deleteGroupForward = target => deleteByGroup(target, true);
-   /**
-   Delete the selection, or, if it is a cursor selection, delete to
-   the end of the line. If the cursor is directly at the end of the
-   line, delete the line break after it.
-   */
-   const deleteToLineEnd = view => deleteBy(view, pos => {
-       let lineEnd = view.lineBlockAt(pos).to;
-       return skipAtomic(view, pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1), true);
-   });
-   /**
-   Delete the selection, or, if it is a cursor selection, delete to
-   the start of the line. If the cursor is directly at the start of the
-   line, delete the line break before it.
-   */
-   const deleteToLineStart = view => deleteBy(view, pos => {
-       let lineStart = view.lineBlockAt(pos).from;
-       return skipAtomic(view, pos > lineStart ? lineStart : Math.max(0, pos - 1), false);
-   });
-   /**
-   Replace each selection range with a line break, leaving the cursor
-   on the line before the break.
-   */
-   const splitLine = ({ state, dispatch }) => {
-       if (state.readOnly)
-           return false;
-       let changes = state.changeByRange(range => {
-           return { changes: { from: range.from, to: range.to, insert: Text$2.of(["", ""]) },
-               range: EditorSelection$2.cursor(range.from) };
-       });
-       dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
-       return true;
-   };
-   /**
-   Flip the characters before and after the cursor(s).
-   */
-   const transposeChars = ({ state, dispatch }) => {
-       if (state.readOnly)
-           return false;
-       let changes = state.changeByRange(range => {
-           if (!range.empty || range.from == 0 || range.from == state.doc.length)
-               return { range };
-           let pos = range.from, line = state.doc.lineAt(pos);
-           let from = pos == line.from ? pos - 1 : findClusterBreak$3(line.text, pos - line.from, false) + line.from;
-           let to = pos == line.to ? pos + 1 : findClusterBreak$3(line.text, pos - line.from, true) + line.from;
-           return { changes: { from, to, insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos)) },
-               range: EditorSelection$2.cursor(to) };
-       });
-       if (changes.changes.empty)
-           return false;
-       dispatch(state.update(changes, { scrollIntoView: true, userEvent: "move.character" }));
-       return true;
-   };
-   function selectedLineBlocks(state) {
-       let blocks = [], upto = -1;
-       for (let range of state.selection.ranges) {
-           let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to);
-           if (!range.empty && range.to == endLine.from)
-               endLine = state.doc.lineAt(range.to - 1);
-           if (upto >= startLine.number) {
-               let prev = blocks[blocks.length - 1];
-               prev.to = endLine.to;
-               prev.ranges.push(range);
-           }
-           else {
-               blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] });
-           }
-           upto = endLine.number + 1;
-       }
-       return blocks;
-   }
-   function moveLine(state, dispatch, forward) {
-       if (state.readOnly)
-           return false;
-       let changes = [], ranges = [];
-       for (let block of selectedLineBlocks(state)) {
-           if (forward ? block.to == state.doc.length : block.from == 0)
-               continue;
-           let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);
-           let size = nextLine.length + 1;
-           if (forward) {
-               changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state.lineBreak });
-               for (let r of block.ranges)
-                   ranges.push(EditorSelection$2.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));
-           }
-           else {
-               changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text });
-               for (let r of block.ranges)
-                   ranges.push(EditorSelection$2.range(r.anchor - size, r.head - size));
-           }
-       }
-       if (!changes.length)
-           return false;
-       dispatch(state.update({
-           changes,
-           scrollIntoView: true,
-           selection: EditorSelection$2.create(ranges, state.selection.mainIndex),
-           userEvent: "move.line"
-       }));
-       return true;
-   }
-   /**
-   Move the selected lines up one line.
-   */
-   const moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false);
-   /**
-   Move the selected lines down one line.
-   */
-   const moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true);
-   function copyLine(state, dispatch, forward) {
-       if (state.readOnly)
-           return false;
-       let changes = [];
-       for (let block of selectedLineBlocks(state)) {
-           if (forward)
-               changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak });
-           else
-               changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) });
-       }
-       dispatch(state.update({ changes, scrollIntoView: true, userEvent: "input.copyline" }));
-       return true;
-   }
-   /**
-   Create a copy of the selected lines. Keep the selection in the top copy.
-   */
-   const copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false);
-   /**
-   Create a copy of the selected lines. Keep the selection in the bottom copy.
-   */
-   const copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true);
-   /**
-   Delete selected lines.
-   */
-   const deleteLine = view => {
-       if (view.state.readOnly)
-           return false;
-       let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => {
-           if (from > 0)
-               from--;
-           else if (to < state.doc.length)
-               to++;
-           return { from, to };
-       }));
-       let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);
-       view.dispatch({ changes, selection, scrollIntoView: true, userEvent: "delete.line" });
-       return true;
-   };
-   function isBetweenBrackets(state, pos) {
-       if (/\(\)|\[\]|\{\}/.test(state.sliceDoc(pos - 1, pos + 1)))
-           return { from: pos, to: pos };
-       let context = syntaxTree$1(state).resolveInner(pos);
-       let before = context.childBefore(pos), after = context.childAfter(pos), closedBy;
-       if (before && after && before.to <= pos && after.from >= pos &&
-           (closedBy = before.type.prop(NodeProp$1.closedBy)) && closedBy.indexOf(after.name) > -1 &&
-           state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from)
-           return { from: before.to, to: after.from };
-       return null;
-   }
-   /**
-   Replace the selection with a newline and indent the newly created
-   line(s). If the current line consists only of whitespace, this
-   will also delete that whitespace. When the cursor is between
-   matching brackets, an additional newline will be inserted after
-   the cursor.
-   */
-   const insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);
-   /**
-   Create a blank, indented line below the current line.
-   */
-   const insertBlankLine = /*@__PURE__*/newlineAndIndent(true);
-   function newlineAndIndent(atEof) {
-       return ({ state, dispatch }) => {
-           if (state.readOnly)
-               return false;
-           let changes = state.changeByRange(range => {
-               let { from, to } = range, line = state.doc.lineAt(from);
-               let explode = !atEof && from == to && isBetweenBrackets(state, from);
-               if (atEof)
-                   from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;
-               let cx = new IndentContext(state, { simulateBreak: from, simulateDoubleBreak: !!explode });
-               let indent = getIndentation(cx, from);
-               if (indent == null)
-                   indent = /^\s*/.exec(state.doc.lineAt(from).text)[0].length;
-               while (to < line.to && /\s/.test(line.text[to - line.from]))
-                   to++;
-               if (explode)
-                   ({ from, to } = explode);
-               else if (from > line.from && from < line.from + 100 && !/\S/.test(line.text.slice(0, from)))
-                   from = line.from;
-               let insert = ["", indentString(state, indent)];
-               if (explode)
-                   insert.push(indentString(state, cx.lineIndent(line.from, -1)));
-               return { changes: { from, to, insert: Text$2.of(insert) },
-                   range: EditorSelection$2.cursor(from + 1 + insert[1].length) };
-           });
-           dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
-           return true;
-       };
-   }
-   function changeBySelectedLine(state, f) {
-       let atLine = -1;
-       return state.changeByRange(range => {
-           let changes = [];
-           for (let pos = range.from; pos <= range.to;) {
-               let line = state.doc.lineAt(pos);
-               if (line.number > atLine && (range.empty || range.to > line.from)) {
-                   f(line, changes, range);
-                   atLine = line.number;
-               }
-               pos = line.to + 1;
-           }
-           let changeSet = state.changes(changes);
-           return { changes,
-               range: EditorSelection$2.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) };
-       });
-   }
-   /**
-   Auto-indent the selected lines. This uses the [indentation service
-   facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
-   information.
-   */
-   const indentSelection = ({ state, dispatch }) => {
-       if (state.readOnly)
-           return false;
-       let updated = Object.create(null);
-       let context = new IndentContext(state, { overrideIndentation: start => {
-               let found = updated[start];
-               return found == null ? -1 : found;
-           } });
-       let changes = changeBySelectedLine(state, (line, changes, range) => {
-           let indent = getIndentation(context, line.from);
-           if (indent == null)
-               return;
-           if (!/\S/.test(line.text))
-               indent = 0;
-           let cur = /^\s*/.exec(line.text)[0];
-           let norm = indentString(state, indent);
-           if (cur != norm || range.from < line.from + cur.length) {
-               updated[line.from] = indent;
-               changes.push({ from: line.from, to: line.from + cur.length, insert: norm });
-           }
-       });
-       if (!changes.changes.empty)
-           dispatch(state.update(changes, { userEvent: "indent" }));
-       return true;
-   };
-   /**
-   Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
-   lines.
-   */
-   const indentMore = ({ state, dispatch }) => {
-       if (state.readOnly)
-           return false;
-       dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
-           changes.push({ from: line.from, insert: state.facet(indentUnit$1) });
-       }), { userEvent: "input.indent" }));
-       return true;
-   };
-   /**
-   Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
-   selected lines.
-   */
-   const indentLess = ({ state, dispatch }) => {
-       if (state.readOnly)
-           return false;
-       dispatch(state.update(changeBySelectedLine(state, (line, changes) => {
-           let space = /^\s*/.exec(line.text)[0];
-           if (!space)
-               return;
-           let col = countColumn(space, state.tabSize), keep = 0;
-           let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));
-           while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep))
-               keep++;
-           changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) });
-       }), { userEvent: "delete.dedent" }));
-       return true;
-   };
-   /**
-   Array of key bindings containing the Emacs-style bindings that are
-   available on macOS by default.
-
-    - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
-    - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
-    - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
-    - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
-    - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
-    - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
-    - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
-    - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
-    - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
-    - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
-    - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
-    - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
-    - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
-    - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
-   */
-   const emacsStyleKeymap = [
-       { key: "Ctrl-b", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
-       { key: "Ctrl-f", run: cursorCharRight, shift: selectCharRight },
-       { key: "Ctrl-p", run: cursorLineUp, shift: selectLineUp },
-       { key: "Ctrl-n", run: cursorLineDown, shift: selectLineDown },
-       { key: "Ctrl-a", run: cursorLineStart, shift: selectLineStart },
-       { key: "Ctrl-e", run: cursorLineEnd, shift: selectLineEnd },
-       { key: "Ctrl-d", run: deleteCharForward },
-       { key: "Ctrl-h", run: deleteCharBackward },
-       { key: "Ctrl-k", run: deleteToLineEnd },
-       { key: "Ctrl-Alt-h", run: deleteGroupBackward },
-       { key: "Ctrl-o", run: splitLine },
-       { key: "Ctrl-t", run: transposeChars },
-       { key: "Ctrl-v", run: cursorPageDown },
-   ];
-   /**
-   An array of key bindings closely sticking to platform-standard or
-   widely used bindings. (This includes the bindings from
-   [`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
-   property changed to `mac`.)
-
-    - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
-    - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
-    - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
-    - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
-    - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
-    - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
-    - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
-    - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
-    - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
-    - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
-    - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
-    - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
-    - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
-    - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
-    - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
-    - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
-    - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
-    - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
-    - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
-    - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
-    - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
-    - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
-    - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
-    - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
-    - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
-    - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
-   */
-   const standardKeymap = /*@__PURE__*/[
-       { key: "ArrowLeft", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },
-       { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: cursorGroupLeft, shift: selectGroupLeft },
-       { mac: "Cmd-ArrowLeft", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward },
-       { key: "ArrowRight", run: cursorCharRight, shift: selectCharRight, preventDefault: true },
-       { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: cursorGroupRight, shift: selectGroupRight },
-       { mac: "Cmd-ArrowRight", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward },
-       { key: "ArrowUp", run: cursorLineUp, shift: selectLineUp, preventDefault: true },
-       { mac: "Cmd-ArrowUp", run: cursorDocStart, shift: selectDocStart },
-       { mac: "Ctrl-ArrowUp", run: cursorPageUp, shift: selectPageUp },
-       { key: "ArrowDown", run: cursorLineDown, shift: selectLineDown, preventDefault: true },
-       { mac: "Cmd-ArrowDown", run: cursorDocEnd, shift: selectDocEnd },
-       { mac: "Ctrl-ArrowDown", run: cursorPageDown, shift: selectPageDown },
-       { key: "PageUp", run: cursorPageUp, shift: selectPageUp },
-       { key: "PageDown", run: cursorPageDown, shift: selectPageDown },
-       { key: "Home", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true },
-       { key: "Mod-Home", run: cursorDocStart, shift: selectDocStart },
-       { key: "End", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true },
-       { key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd },
-       { key: "Enter", run: insertNewlineAndIndent },
-       { key: "Mod-a", run: selectAll },
-       { key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward },
-       { key: "Delete", run: deleteCharForward },
-       { key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward },
-       { key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward },
-       { mac: "Mod-Backspace", run: deleteToLineStart },
-       { mac: "Mod-Delete", run: deleteToLineEnd }
-   ].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));
-   /**
-   The default keymap. Includes all bindings from
-   [`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
-
-   - Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
-   - Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
-   - Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
-   - Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
-   - Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
-   - Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
-   - Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
-   - Ctrl-Enter (Comd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
-   - Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
-   - Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
-   - Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
-   - Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
-   - Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
-   - Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
-   - Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
-   - Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
-   - Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
-   */
-   const defaultKeymap = /*@__PURE__*/[
-       { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: cursorSyntaxLeft, shift: selectSyntaxLeft },
-       { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: cursorSyntaxRight, shift: selectSyntaxRight },
-       { key: "Alt-ArrowUp", run: moveLineUp },
-       { key: "Shift-Alt-ArrowUp", run: copyLineUp },
-       { key: "Alt-ArrowDown", run: moveLineDown },
-       { key: "Shift-Alt-ArrowDown", run: copyLineDown },
-       { key: "Escape", run: simplifySelection },
-       { key: "Mod-Enter", run: insertBlankLine },
-       { key: "Alt-l", mac: "Ctrl-l", run: selectLine },
-       { key: "Mod-i", run: selectParentSyntax, preventDefault: true },
-       { key: "Mod-[", run: indentLess },
-       { key: "Mod-]", run: indentMore },
-       { key: "Mod-Alt-\\", run: indentSelection },
-       { key: "Shift-Mod-k", run: deleteLine },
-       { key: "Shift-Mod-\\", run: cursorMatchingBracket },
-       { key: "Mod-/", run: toggleComment },
-       { key: "Alt-A", run: toggleBlockComment }
-   ].concat(standardKeymap);
-
-   /**
-   The data structure for documents. @nonabstract
-   */
-   let Text$1 = class Text {
-       /**
-       @internal
-       */
-       constructor() { }
-       /**
-       Get the line description around the given position.
-       */
-       lineAt(pos) {
-           if (pos < 0 || pos > this.length)
-               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
-           return this.lineInner(pos, false, 1, 0);
-       }
-       /**
-       Get the description for the given (1-based) line number.
-       */
-       line(n) {
-           if (n < 1 || n > this.lines)
-               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
-           return this.lineInner(n, true, 1, 0);
-       }
-       /**
-       Replace a range of the text with the given content.
-       */
-       replace(from, to, text) {
-           let parts = [];
-           this.decompose(0, from, parts, 2 /* To */);
-           if (text.length)
-               text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
-           this.decompose(to, this.length, parts, 1 /* From */);
-           return TextNode$1.from(parts, this.length - (to - from) + text.length);
-       }
-       /**
-       Append another document to this one.
-       */
-       append(other) {
-           return this.replace(this.length, this.length, other);
-       }
-       /**
-       Retrieve the text between the given points.
-       */
-       slice(from, to = this.length) {
-           let parts = [];
-           this.decompose(from, to, parts, 0);
-           return TextNode$1.from(parts, to - from);
-       }
-       /**
-       Test whether this text is equal to another instance.
-       */
-       eq(other) {
-           if (other == this)
-               return true;
-           if (other.length != this.length || other.lines != this.lines)
-               return false;
-           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
-           let a = new RawTextCursor$1(this), b = new RawTextCursor$1(other);
-           for (let skip = start, pos = start;;) {
-               a.next(skip);
-               b.next(skip);
-               skip = 0;
-               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
-                   return false;
-               pos += a.value.length;
-               if (a.done || pos >= end)
-                   return true;
-           }
-       }
-       /**
-       Iterate over the text. When `dir` is `-1`, iteration happens
-       from end to start. This will return lines and the breaks between
-       them as separate strings.
-       */
-       iter(dir = 1) { return new RawTextCursor$1(this, dir); }
-       /**
-       Iterate over a range of the text. When `from` > `to`, the
-       iterator will run in reverse.
-       */
-       iterRange(from, to = this.length) { return new PartialTextCursor$1(this, from, to); }
-       /**
-       Return a cursor that iterates over the given range of lines,
-       _without_ returning the line breaks between, and yielding empty
-       strings for empty lines.
-       
-       When `from` and `to` are given, they should be 1-based line numbers.
-       */
-       iterLines(from, to) {
-           let inner;
-           if (from == null) {
-               inner = this.iter();
-           }
-           else {
-               if (to == null)
-                   to = this.lines + 1;
-               let start = this.line(from).from;
-               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
-           }
-           return new LineCursor$1(inner);
-       }
-       /**
-       @internal
-       */
-       toString() { return this.sliceString(0); }
-       /**
-       Convert the document to an array of lines (which can be
-       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
-       */
-       toJSON() {
-           let lines = [];
-           this.flatten(lines);
-           return lines;
-       }
-       /**
-       Create a `Text` instance for the given array of lines.
-       */
-       static of(text) {
-           if (text.length == 0)
-               throw new RangeError("A document must have at least one line");
-           if (text.length == 1 && !text[0])
-               return Text.empty;
-           return text.length <= 32 /* Branch */ ? new TextLeaf$1(text) : TextNode$1.from(TextLeaf$1.split(text, []));
-       }
-   };
-   // Leaves store an array of line strings. There are always line breaks
-   // between these strings. Leaves are limited in size and have to be
-   // contained in TextNode instances for bigger documents.
-   let TextLeaf$1 = class TextLeaf extends Text$1 {
-       constructor(text, length = textLength$1(text)) {
-           super();
-           this.text = text;
-           this.length = length;
-       }
-       get lines() { return this.text.length; }
-       get children() { return null; }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let string = this.text[i], end = offset + string.length;
-               if ((isLine ? line : end) >= target)
-                   return new Line$1(offset, end, line, string);
-               offset = end + 1;
-               line++;
-           }
-       }
-       decompose(from, to, target, open) {
-           let text = from <= 0 && to >= this.length ? this
-               : new TextLeaf(sliceText$1(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
-           if (open & 1 /* From */) {
-               let prev = target.pop();
-               let joined = appendText$1(text.text, prev.text.slice(), 0, text.length);
-               if (joined.length <= 32 /* Branch */) {
-                   target.push(new TextLeaf(joined, prev.length + text.length));
-               }
-               else {
-                   let mid = joined.length >> 1;
-                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
-               }
-           }
-           else {
-               target.push(text);
-           }
-       }
-       replace(from, to, text) {
-           if (!(text instanceof TextLeaf))
-               return super.replace(from, to, text);
-           let lines = appendText$1(this.text, appendText$1(text.text, sliceText$1(this.text, 0, from)), to);
-           let newLen = this.length + text.length - (to - from);
-           if (lines.length <= 32 /* Branch */)
-               return new TextLeaf(lines, newLen);
-           return TextNode$1.from(TextLeaf.split(lines, []), newLen);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           let result = "";
-           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
-               let line = this.text[i], end = pos + line.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += line.slice(Math.max(0, from - pos), to - pos);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let line of this.text)
-               target.push(line);
-       }
-       scanIdentical() { return 0; }
-       static split(text, target) {
-           let part = [], len = -1;
-           for (let line of text) {
-               part.push(line);
-               len += line.length + 1;
-               if (part.length == 32 /* Branch */) {
-                   target.push(new TextLeaf(part, len));
-                   part = [];
-                   len = -1;
-               }
-           }
-           if (len > -1)
-               target.push(new TextLeaf(part, len));
-           return target;
-       }
-   };
-   // Nodes provide the tree structure of the `Text` type. They store a
-   // number of other nodes or leaves, taking care to balance themselves
-   // on changes. There are implied line breaks _between_ the children of
-   // a node (but not before the first or after the last child).
-   let TextNode$1 = class TextNode extends Text$1 {
-       constructor(children, length) {
-           super();
-           this.children = children;
-           this.length = length;
-           this.lines = 0;
-           for (let child of children)
-               this.lines += child.lines;
-       }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
-               if ((isLine ? endLine : end) >= target)
-                   return child.lineInner(target, isLine, line, offset);
-               offset = end + 1;
-               line = endLine + 1;
-           }
-       }
-       decompose(from, to, target, open) {
-           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (from <= end && to >= pos) {
-                   let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
-                   if (pos >= from && end <= to && !childOpen)
-                       target.push(child);
-                   else
-                       child.decompose(from - pos, to - pos, target, childOpen);
-               }
-               pos = end + 1;
-           }
-       }
-       replace(from, to, text) {
-           if (text.lines < this.lines)
-               for (let i = 0, pos = 0; i < this.children.length; i++) {
-                   let child = this.children[i], end = pos + child.length;
-                   // Fast path: if the change only affects one child and the
-                   // child's size remains in the acceptable range, only update
-                   // that child
-                   if (from >= pos && to <= end) {
-                       let updated = child.replace(from - pos, to - pos, text);
-                       let totalLines = this.lines - child.lines + updated.lines;
-                       if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
-                           updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
-                           let copy = this.children.slice();
-                           copy[i] = updated;
-                           return new TextNode(copy, this.length - (to - from) + text.length);
-                       }
-                       return super.replace(pos, end, updated);
-                   }
-                   pos = end + 1;
-               }
-           return super.replace(from, to, text);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           let result = "";
-           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += child.sliceString(from - pos, to - pos, lineSep);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let child of this.children)
-               child.flatten(target);
-       }
-       scanIdentical(other, dir) {
-           if (!(other instanceof TextNode))
-               return 0;
-           let length = 0;
-           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
-               : [this.children.length - 1, other.children.length - 1, -1, -1];
-           for (;; iA += dir, iB += dir) {
-               if (iA == eA || iB == eB)
-                   return length;
-               let chA = this.children[iA], chB = other.children[iB];
-               if (chA != chB)
-                   return length + chA.scanIdentical(chB, dir);
-               length += chA.length + 1;
-           }
-       }
-       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
-           let lines = 0;
-           for (let ch of children)
-               lines += ch.lines;
-           if (lines < 32 /* Branch */) {
-               let flat = [];
-               for (let ch of children)
-                   ch.flatten(flat);
-               return new TextLeaf$1(flat, length);
-           }
-           let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
-           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
-           function add(child) {
-               let last;
-               if (child.lines > maxChunk && child instanceof TextNode) {
-                   for (let node of child.children)
-                       add(node);
-               }
-               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
-                   flush();
-                   chunked.push(child);
-               }
-               else if (child instanceof TextLeaf$1 && currentLines &&
-                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf$1 &&
-                   child.lines + last.lines <= 32 /* Branch */) {
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk[currentChunk.length - 1] = new TextLeaf$1(last.text.concat(child.text), last.length + 1 + child.length);
-               }
-               else {
-                   if (currentLines + child.lines > chunk)
-                       flush();
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk.push(child);
-               }
-           }
-           function flush() {
-               if (currentLines == 0)
-                   return;
-               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
-               currentLen = -1;
-               currentLines = currentChunk.length = 0;
-           }
-           for (let child of children)
-               add(child);
-           flush();
-           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
-       }
-   };
-   Text$1.empty = /*@__PURE__*/new TextLeaf$1([""], 0);
-   function textLength$1(text) {
-       let length = -1;
-       for (let line of text)
-           length += line.length + 1;
-       return length;
-   }
-   function appendText$1(text, target, from = 0, to = 1e9) {
-       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
-           let line = text[i], end = pos + line.length;
-           if (end >= from) {
-               if (end > to)
-                   line = line.slice(0, to - pos);
-               if (pos < from)
-                   line = line.slice(from - pos);
-               if (first) {
-                   target[target.length - 1] += line;
-                   first = false;
-               }
-               else
-                   target.push(line);
-           }
-           pos = end + 1;
-       }
-       return target;
-   }
-   function sliceText$1(text, from, to) {
-       return appendText$1(text, [""], from, to);
-   }
-   let RawTextCursor$1 = class RawTextCursor {
-       constructor(text, dir = 1) {
-           this.dir = dir;
-           this.done = false;
-           this.lineBreak = false;
-           this.value = "";
-           this.nodes = [text];
-           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf$1 ? text.text.length : text.children.length) << 1];
-       }
-       nextInner(skip, dir) {
-           this.done = this.lineBreak = false;
-           for (;;) {
-               let last = this.nodes.length - 1;
-               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
-               let size = top instanceof TextLeaf$1 ? top.text.length : top.children.length;
-               if (offset == (dir > 0 ? size : 0)) {
-                   if (last == 0) {
-                       this.done = true;
-                       this.value = "";
-                       return this;
-                   }
-                   if (dir > 0)
-                       this.offsets[last - 1]++;
-                   this.nodes.pop();
-                   this.offsets.pop();
-               }
-               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
-                   this.offsets[last] += dir;
-                   if (skip == 0) {
-                       this.lineBreak = true;
-                       this.value = "\n";
-                       return this;
-                   }
-                   skip--;
-               }
-               else if (top instanceof TextLeaf$1) {
-                   // Move to the next string
-                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
-                   this.offsets[last] += dir;
-                   if (next.length > Math.max(0, skip)) {
-                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
-                       return this;
-                   }
-                   skip -= next.length;
-               }
-               else {
-                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
-                   if (skip > next.length) {
-                       skip -= next.length;
-                       this.offsets[last] += dir;
-                   }
-                   else {
-                       if (dir < 0)
-                           this.offsets[last]--;
-                       this.nodes.push(next);
-                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf$1 ? next.text.length : next.children.length) << 1);
-                   }
-               }
-           }
-       }
-       next(skip = 0) {
-           if (skip < 0) {
-               this.nextInner(-skip, (-this.dir));
-               skip = this.value.length;
-           }
-           return this.nextInner(skip, this.dir);
-       }
-   };
-   let PartialTextCursor$1 = class PartialTextCursor {
-       constructor(text, start, end) {
-           this.value = "";
-           this.done = false;
-           this.cursor = new RawTextCursor$1(text, start > end ? -1 : 1);
-           this.pos = start > end ? text.length : 0;
-           this.from = Math.min(start, end);
-           this.to = Math.max(start, end);
-       }
-       nextInner(skip, dir) {
-           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
-               this.value = "";
-               this.done = true;
-               return this;
-           }
-           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
-           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
-           if (skip > limit)
-               skip = limit;
-           limit -= skip;
-           let { value } = this.cursor.next(skip);
-           this.pos += (value.length + skip) * dir;
-           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
-           this.done = !this.value;
-           return this;
-       }
-       next(skip = 0) {
-           if (skip < 0)
-               skip = Math.max(skip, this.from - this.pos);
-           else if (skip > 0)
-               skip = Math.min(skip, this.to - this.pos);
-           return this.nextInner(skip, this.cursor.dir);
-       }
-       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
-   };
-   let LineCursor$1 = class LineCursor {
-       constructor(inner) {
-           this.inner = inner;
-           this.afterBreak = true;
-           this.value = "";
-           this.done = false;
-       }
-       next(skip = 0) {
-           let { done, lineBreak, value } = this.inner.next(skip);
-           if (done) {
-               this.done = true;
-               this.value = "";
-           }
-           else if (lineBreak) {
-               if (this.afterBreak) {
-                   this.value = "";
-               }
-               else {
-                   this.afterBreak = true;
-                   this.next();
-               }
-           }
-           else {
-               this.value = value;
-               this.afterBreak = false;
-           }
-           return this;
-       }
-       get lineBreak() { return false; }
-   };
-   if (typeof Symbol != "undefined") {
-       Text$1.prototype[Symbol.iterator] = function () { return this.iter(); };
-       RawTextCursor$1.prototype[Symbol.iterator] = PartialTextCursor$1.prototype[Symbol.iterator] =
-           LineCursor$1.prototype[Symbol.iterator] = function () { return this; };
-   }
-   /**
-   This type describes a line in the document. It is created
-   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
-   */
-   let Line$1 = class Line {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The position of the start of the line.
-       */
-       from, 
-       /**
-       The position at the end of the line (_before_ the line break,
-       or at the end of document for the last line).
-       */
-       to, 
-       /**
-       This line's line number (1-based).
-       */
-       number, 
-       /**
-       The line's content.
-       */
-       text) {
-           this.from = from;
-           this.to = to;
-           this.number = number;
-           this.text = text;
-       }
-       /**
-       The length of the line (not including any line break after it).
-       */
-       get length() { return this.to - this.from; }
-   };
-
-   // Compressed representation of the Grapheme_Cluster_Break=Extend
-   // information from
-   // http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
-   // Each pair of elements represents a range, as an offet from the
-   // previous range and a length. Numbers are in base-36, with the empty
-   // string being a shorthand for 1.
-   let extend = /*@__PURE__*/"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
-   // Convert offsets into absolute values
-   for (let i = 1; i < extend.length; i++)
-       extend[i] += extend[i - 1];
-   function isExtendingChar$1(code) {
-       for (let i = 1; i < extend.length; i += 2)
-           if (extend[i] > code)
-               return extend[i - 1] <= code;
-       return false;
-   }
-   function isRegionalIndicator$1(code) {
-       return code >= 0x1F1E6 && code <= 0x1F1FF;
-   }
-   const ZWJ$1 = 0x200d;
-   /**
-   Returns a next grapheme cluster break _after_ (not equal to)
-   `pos`, if `forward` is true, or before otherwise. Returns `pos`
-   itself if no further cluster break is available in the string.
-   Moves across surrogate pairs, extending characters (when
-   `includeExtending` is true), characters joined with zero-width
-   joiners, and flag emoji.
-   */
-   function findClusterBreak$2(str, pos, forward = true, includeExtending = true) {
-       return (forward ? nextClusterBreak$1 : prevClusterBreak$1)(str, pos, includeExtending);
-   }
-   function nextClusterBreak$1(str, pos, includeExtending) {
-       if (pos == str.length)
-           return pos;
-       // If pos is in the middle of a surrogate pair, move to its start
-       if (pos && surrogateLow$2(str.charCodeAt(pos)) && surrogateHigh$2(str.charCodeAt(pos - 1)))
-           pos--;
-       let prev = codePointAt$2(str, pos);
-       pos += codePointSize$2(prev);
-       while (pos < str.length) {
-           let next = codePointAt$2(str, pos);
-           if (prev == ZWJ$1 || next == ZWJ$1 || includeExtending && isExtendingChar$1(next)) {
-               pos += codePointSize$2(next);
-               prev = next;
-           }
-           else if (isRegionalIndicator$1(next)) {
-               let countBefore = 0, i = pos - 2;
-               while (i >= 0 && isRegionalIndicator$1(codePointAt$2(str, i))) {
-                   countBefore++;
-                   i -= 2;
-               }
-               if (countBefore % 2 == 0)
-                   break;
-               else
-                   pos += 2;
-           }
-           else {
-               break;
-           }
-       }
-       return pos;
-   }
-   function prevClusterBreak$1(str, pos, includeExtending) {
-       while (pos > 0) {
-           let found = nextClusterBreak$1(str, pos - 2, includeExtending);
-           if (found < pos)
-               return found;
-           pos--;
-       }
-       return 0;
-   }
-   function surrogateLow$2(ch) { return ch >= 0xDC00 && ch < 0xE000; }
-   function surrogateHigh$2(ch) { return ch >= 0xD800 && ch < 0xDC00; }
-   /**
-   Find the code point at the given position in a string (like the
-   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
-   string method).
-   */
-   function codePointAt$2(str, pos) {
-       let code0 = str.charCodeAt(pos);
-       if (!surrogateHigh$2(code0) || pos + 1 == str.length)
-           return code0;
-       let code1 = str.charCodeAt(pos + 1);
-       if (!surrogateLow$2(code1))
-           return code0;
-       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
-   }
-   /**
-   Given a Unicode codepoint, return the JavaScript string that
-   respresents it (like
-   [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
-   */
-   function fromCodePoint$1(code) {
-       if (code <= 0xffff)
-           return String.fromCharCode(code);
-       code -= 0x10000;
-       return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
-   }
-   /**
-   The first character that takes up two positions in a JavaScript
-   string. It is often useful to compare with this after calling
-   `codePointAt`, to figure out whether your character takes up 1 or
-   2 index positions.
-   */
-   function codePointSize$2(code) { return code < 0x10000 ? 1 : 2; }
-
-   const DefaultSplit$1 = /\r\n?|\n/;
-   /**
-   Distinguishes different ways in which positions can be mapped.
-   */
-   var MapMode$1 = /*@__PURE__*/(function (MapMode) {
-       /**
-       Map a position to a valid new position, even when its context
-       was deleted.
-       */
-       MapMode[MapMode["Simple"] = 0] = "Simple";
-       /**
-       Return null if deletion happens across the position.
-       */
-       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
-       /**
-       Return null if the character _before_ the position is deleted.
-       */
-       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
-       /**
-       Return null if the character _after_ the position is deleted.
-       */
-       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
-   return MapMode})(MapMode$1 || (MapMode$1 = {}));
-   /**
-   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
-   that doesn't store the inserted text. As such, it can't be
-   applied, but is cheaper to store and manipulate.
-   */
-   let ChangeDesc$1 = class ChangeDesc {
-       // Sections are encoded as pairs of integers. The first is the
-       // length in the current document, and the second is -1 for
-       // unaffected sections, and the length of the replacement content
-       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
-       // 0), and a replacement two positive numbers.
-       constructor(
-       /**
-       @internal
-       */
-       sections) {
-           this.sections = sections;
-       }
-       /**
-       The length of the document before the change.
-       */
-       get length() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2)
-               result += this.sections[i];
-           return result;
-       }
-       /**
-       The length of the document after the change.
-       */
-       get newLength() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let ins = this.sections[i + 1];
-               result += ins < 0 ? this.sections[i] : ins;
-           }
-           return result;
-       }
-       /**
-       False when there are actual changes in this set.
-       */
-       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
-       /**
-       Iterate over the unchanged parts left by these changes. `posA`
-       provides the position of the range in the old document, `posB`
-       the new position in the changed document.
-       */
-       iterGaps(f) {
-           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0) {
-                   f(posA, posB, len);
-                   posB += len;
-               }
-               else {
-                   posB += ins;
-               }
-               posA += len;
-           }
-       }
-       /**
-       Iterate over the ranges changed by these changes. (See
-       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
-       variant that also provides you with the inserted text.)
-       `fromA`/`toA` provides the extent of the change in the starting
-       document, `fromB`/`toB` the extent of the replacement in the
-       changed document.
-       
-       When `individual` is true, adjacent changes (which are kept
-       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
-       reported separately.
-       */
-       iterChangedRanges(f, individual = false) {
-           iterChanges$1(this, f, individual);
-       }
-       /**
-       Get a description of the inverted form of these changes.
-       */
-       get invertedDesc() {
-           let sections = [];
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0)
-                   sections.push(len, ins);
-               else
-                   sections.push(ins, len);
-           }
-           return new ChangeDesc(sections);
-       }
-       /**
-       Compute the combined effect of applying another set of changes
-       after this one. The length of the document after this set should
-       match the length before `other`.
-       */
-       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets$1(this, other); }
-       /**
-       Map this description, which should start with the same document
-       as `other`, over another set of changes, so that it can be
-       applied after it. When `before` is true, map as if the changes
-       in `other` happened before the ones in `this`.
-       */
-       mapDesc(other, before = false) { return other.empty ? this : mapSet$1(this, other, before); }
-       mapPos(pos, assoc = -1, mode = MapMode$1.Simple) {
-           let posA = 0, posB = 0;
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
-               if (ins < 0) {
-                   if (endA > pos)
-                       return posB + (pos - posA);
-                   posB += len;
-               }
-               else {
-                   if (mode != MapMode$1.Simple && endA >= pos &&
-                       (mode == MapMode$1.TrackDel && posA < pos && endA > pos ||
-                           mode == MapMode$1.TrackBefore && posA < pos ||
-                           mode == MapMode$1.TrackAfter && endA > pos))
-                       return null;
-                   if (endA > pos || endA == pos && assoc < 0 && !len)
-                       return pos == posA || assoc < 0 ? posB : posB + ins;
-                   posB += ins;
-               }
-               posA = endA;
-           }
-           if (pos > posA)
-               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
-           return posB;
-       }
-       /**
-       Check whether these changes touch a given range. When one of the
-       changes entirely covers the range, the string `"cover"` is
-       returned.
-       */
-       touchesRange(from, to = from) {
-           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
-               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
-               if (ins >= 0 && pos <= to && end >= from)
-                   return pos < from && end > to ? "cover" : true;
-               pos = end;
-           }
-           return false;
-       }
-       /**
-       @internal
-       */
-       toString() {
-           let result = "";
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
-           }
-           return result;
-       }
-       /**
-       Serialize this change desc to a JSON-representable value.
-       */
-       toJSON() { return this.sections; }
-       /**
-       Create a change desc from its JSON representation (as produced
-       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
-               throw new RangeError("Invalid JSON representation of ChangeDesc");
-           return new ChangeDesc(json);
-       }
-       /**
-       @internal
-       */
-       static create(sections) { return new ChangeDesc(sections); }
-   };
-   /**
-   A change set represents a group of modifications to a document. It
-   stores the document length, and can only be applied to documents
-   with exactly that length.
-   */
-   let ChangeSet$1 = class ChangeSet extends ChangeDesc$1 {
-       constructor(sections, 
-       /**
-       @internal
-       */
-       inserted) {
-           super(sections);
-           this.inserted = inserted;
-       }
-       /**
-       Apply the changes to a document, returning the modified
-       document.
-       */
-       apply(doc) {
-           if (this.length != doc.length)
-               throw new RangeError("Applying change set to a document with the wrong length");
-           iterChanges$1(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
-           return doc;
-       }
-       mapDesc(other, before = false) { return mapSet$1(this, other, before, true); }
-       /**
-       Given the document as it existed _before_ the changes, return a
-       change set that represents the inverse of this set, which could
-       be used to go from the document created by the changes back to
-       the document as it existed before the changes.
-       */
-       invert(doc) {
-           let sections = this.sections.slice(), inserted = [];
-           for (let i = 0, pos = 0; i < sections.length; i += 2) {
-               let len = sections[i], ins = sections[i + 1];
-               if (ins >= 0) {
-                   sections[i] = ins;
-                   sections[i + 1] = len;
-                   let index = i >> 1;
-                   while (inserted.length < index)
-                       inserted.push(Text$1.empty);
-                   inserted.push(len ? doc.slice(pos, pos + len) : Text$1.empty);
-               }
-               pos += len;
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       Combine two subsequent change sets into a single set. `other`
-       must start in the document produced by `this`. If `this` goes
-       `docA` → `docB` and `other` represents `docB` → `docC`, the
-       returned value will represent the change `docA` → `docC`.
-       */
-       compose(other) { return this.empty ? other : other.empty ? this : composeSets$1(this, other, true); }
-       /**
-       Given another change set starting in the same document, maps this
-       change set over the other, producing a new change set that can be
-       applied to the document produced by applying `other`. When
-       `before` is `true`, order changes as if `this` comes before
-       `other`, otherwise (the default) treat `other` as coming first.
-       
-       Given two changes `A` and `B`, `A.compose(B.map(A))` and
-       `B.compose(A.map(B, true))` will produce the same document. This
-       provides a basic form of [operational
-       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
-       and can be used for collaborative editing.
-       */
-       map(other, before = false) { return other.empty ? this : mapSet$1(this, other, before, true); }
-       /**
-       Iterate over the changed ranges in the document, calling `f` for
-       each, with the range in the original document (`fromA`-`toA`)
-       and the range that replaces it in the new document
-       (`fromB`-`toB`).
-       
-       When `individual` is true, adjacent changes are reported
-       separately.
-       */
-       iterChanges(f, individual = false) {
-           iterChanges$1(this, f, individual);
-       }
-       /**
-       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
-       set.
-       */
-       get desc() { return ChangeDesc$1.create(this.sections); }
-       /**
-       @internal
-       */
-       filter(ranges) {
-           let resultSections = [], resultInserted = [], filteredSections = [];
-           let iter = new SectionIter$1(this);
-           done: for (let i = 0, pos = 0;;) {
-               let next = i == ranges.length ? 1e9 : ranges[i++];
-               while (pos < next || pos == next && iter.len == 0) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, next - pos);
-                   addSection$1(filteredSections, len, -1);
-                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
-                   addSection$1(resultSections, len, ins);
-                   if (ins > 0)
-                       addInsert$1(resultInserted, resultSections, iter.text);
-                   iter.forward(len);
-                   pos += len;
-               }
-               let end = ranges[i++];
-               while (pos < end) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, end - pos);
-                   addSection$1(resultSections, len, -1);
-                   addSection$1(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
-                   iter.forward(len);
-                   pos += len;
-               }
-           }
-           return { changes: new ChangeSet(resultSections, resultInserted),
-               filtered: ChangeDesc$1.create(filteredSections) };
-       }
-       /**
-       Serialize this change set to a JSON-representable value.
-       */
-       toJSON() {
-           let parts = [];
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let len = this.sections[i], ins = this.sections[i + 1];
-               if (ins < 0)
-                   parts.push(len);
-               else if (ins == 0)
-                   parts.push([len]);
-               else
-                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
-           }
-           return parts;
-       }
-       /**
-       Create a change set for the given changes, for a document of the
-       given length, using `lineSep` as line separator.
-       */
-       static of(changes, length, lineSep) {
-           let sections = [], inserted = [], pos = 0;
-           let total = null;
-           function flush(force = false) {
-               if (!force && !sections.length)
-                   return;
-               if (pos < length)
-                   addSection$1(sections, length - pos, -1);
-               let set = new ChangeSet(sections, inserted);
-               total = total ? total.compose(set.map(total)) : set;
-               sections = [];
-               inserted = [];
-               pos = 0;
-           }
-           function process(spec) {
-               if (Array.isArray(spec)) {
-                   for (let sub of spec)
-                       process(sub);
-               }
-               else if (spec instanceof ChangeSet) {
-                   if (spec.length != length)
-                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
-                   flush();
-                   total = total ? total.compose(spec.map(total)) : spec;
-               }
-               else {
-                   let { from, to = from, insert } = spec;
-                   if (from > to || from < 0 || to > length)
-                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
-                   let insText = !insert ? Text$1.empty : typeof insert == "string" ? Text$1.of(insert.split(lineSep || DefaultSplit$1)) : insert;
-                   let insLen = insText.length;
-                   if (from == to && insLen == 0)
-                       return;
-                   if (from < pos)
-                       flush();
-                   if (from > pos)
-                       addSection$1(sections, from - pos, -1);
-                   addSection$1(sections, to - from, insLen);
-                   addInsert$1(inserted, sections, insText);
-                   pos = to;
-               }
-           }
-           process(changes);
-           flush(!total);
-           return total;
-       }
-       /**
-       Create an empty changeset of the given length.
-       */
-       static empty(length) {
-           return new ChangeSet(length ? [length, -1] : [], []);
-       }
-       /**
-       Create a changeset from its JSON representation (as produced by
-       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json))
-               throw new RangeError("Invalid JSON representation of ChangeSet");
-           let sections = [], inserted = [];
-           for (let i = 0; i < json.length; i++) {
-               let part = json[i];
-               if (typeof part == "number") {
-                   sections.push(part, -1);
-               }
-               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
-                   throw new RangeError("Invalid JSON representation of ChangeSet");
-               }
-               else if (part.length == 1) {
-                   sections.push(part[0], 0);
-               }
-               else {
-                   while (inserted.length < i)
-                       inserted.push(Text$1.empty);
-                   inserted[i] = Text$1.of(part.slice(1));
-                   sections.push(part[0], inserted[i].length);
-               }
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       @internal
-       */
-       static createSet(sections, inserted) {
-           return new ChangeSet(sections, inserted);
-       }
-   };
-   function addSection$1(sections, len, ins, forceJoin = false) {
-       if (len == 0 && ins <= 0)
-           return;
-       let last = sections.length - 2;
-       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
-           sections[last] += len;
-       else if (len == 0 && sections[last] == 0)
-           sections[last + 1] += ins;
-       else if (forceJoin) {
-           sections[last] += len;
-           sections[last + 1] += ins;
-       }
-       else
-           sections.push(len, ins);
-   }
-   function addInsert$1(values, sections, value) {
-       if (value.length == 0)
-           return;
-       let index = (sections.length - 2) >> 1;
-       if (index < values.length) {
-           values[values.length - 1] = values[values.length - 1].append(value);
-       }
-       else {
-           while (values.length < index)
-               values.push(Text$1.empty);
-           values.push(value);
-       }
-   }
-   function iterChanges$1(desc, f, individual) {
-       let inserted = desc.inserted;
-       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
-           let len = desc.sections[i++], ins = desc.sections[i++];
-           if (ins < 0) {
-               posA += len;
-               posB += len;
-           }
-           else {
-               let endA = posA, endB = posB, text = Text$1.empty;
-               for (;;) {
-                   endA += len;
-                   endB += ins;
-                   if (ins && inserted)
-                       text = text.append(inserted[(i - 2) >> 1]);
-                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
-                       break;
-                   len = desc.sections[i++];
-                   ins = desc.sections[i++];
-               }
-               f(posA, endA, posB, endB, text);
-               posA = endA;
-               posB = endB;
-           }
-       }
-   }
-   function mapSet$1(setA, setB, before, mkSet = false) {
-       let sections = [], insert = mkSet ? [] : null;
-       let a = new SectionIter$1(setA), b = new SectionIter$1(setB);
-       for (let posA = 0, posB = 0;;) {
-           if (a.ins == -1) {
-               posA += a.len;
-               a.next();
-           }
-           else if (b.ins == -1 && posB < posA) {
-               let skip = Math.min(b.len, posA - posB);
-               b.forward(skip);
-               addSection$1(sections, skip, -1);
-               posB += skip;
-           }
-           else if (b.ins >= 0 && (a.done || posB < posA || posB == posA && (b.len < a.len || b.len == a.len && !before))) {
-               addSection$1(sections, b.ins, -1);
-               while (posA > posB && !a.done && posA + a.len < posB + b.len) {
-                   posA += a.len;
-                   a.next();
-               }
-               posB += b.len;
-               b.next();
-           }
-           else if (a.ins >= 0) {
-               let len = 0, end = posA + a.len;
-               for (;;) {
-                   if (b.ins >= 0 && posB > posA && posB + b.len < end) {
-                       len += b.ins;
-                       posB += b.len;
-                       b.next();
-                   }
-                   else if (b.ins == -1 && posB < end) {
-                       let skip = Math.min(b.len, end - posB);
-                       len += skip;
-                       b.forward(skip);
-                       posB += skip;
-                   }
-                   else {
-                       break;
-                   }
-               }
-               addSection$1(sections, len, a.ins);
-               if (insert)
-                   addInsert$1(insert, sections, a.text);
-               posA = end;
-               a.next();
-           }
-           else if (a.done && b.done) {
-               return insert ? ChangeSet$1.createSet(sections, insert) : ChangeDesc$1.create(sections);
-           }
-           else {
-               throw new Error("Mismatched change set lengths");
-           }
-       }
-   }
-   function composeSets$1(setA, setB, mkSet = false) {
-       let sections = [];
-       let insert = mkSet ? [] : null;
-       let a = new SectionIter$1(setA), b = new SectionIter$1(setB);
-       for (let open = false;;) {
-           if (a.done && b.done) {
-               return insert ? ChangeSet$1.createSet(sections, insert) : ChangeDesc$1.create(sections);
-           }
-           else if (a.ins == 0) { // Deletion in A
-               addSection$1(sections, a.len, 0, open);
-               a.next();
-           }
-           else if (b.len == 0 && !b.done) { // Insertion in B
-               addSection$1(sections, 0, b.ins, open);
-               if (insert)
-                   addInsert$1(insert, sections, b.text);
-               b.next();
-           }
-           else if (a.done || b.done) {
-               throw new Error("Mismatched change set lengths");
-           }
-           else {
-               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
-               if (a.ins == -1) {
-                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
-                   addSection$1(sections, len, insB, open);
-                   if (insert && insB)
-                       addInsert$1(insert, sections, b.text);
-               }
-               else if (b.ins == -1) {
-                   addSection$1(sections, a.off ? 0 : a.len, len, open);
-                   if (insert)
-                       addInsert$1(insert, sections, a.textBit(len));
-               }
-               else {
-                   addSection$1(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
-                   if (insert && !b.off)
-                       addInsert$1(insert, sections, b.text);
-               }
-               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
-               a.forward2(len);
-               b.forward(len);
-           }
-       }
-   }
-   let SectionIter$1 = class SectionIter {
-       constructor(set) {
-           this.set = set;
-           this.i = 0;
-           this.next();
-       }
-       next() {
-           let { sections } = this.set;
-           if (this.i < sections.length) {
-               this.len = sections[this.i++];
-               this.ins = sections[this.i++];
-           }
-           else {
-               this.len = 0;
-               this.ins = -2;
-           }
-           this.off = 0;
-       }
-       get done() { return this.ins == -2; }
-       get len2() { return this.ins < 0 ? this.len : this.ins; }
-       get text() {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length ? Text$1.empty : inserted[index];
-       }
-       textBit(len) {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length && !len ? Text$1.empty
-               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
-       }
-       forward(len) {
-           if (len == this.len)
-               this.next();
-           else {
-               this.len -= len;
-               this.off += len;
-           }
-       }
-       forward2(len) {
-           if (this.ins == -1)
-               this.forward(len);
-           else if (len == this.ins)
-               this.next();
-           else {
-               this.ins -= len;
-               this.off += len;
-           }
-       }
-   };
-
-   /**
-   A single selection range. When
-   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
-   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
-   multiple ranges. By default, selections hold exactly one range.
-   */
-   let SelectionRange$1 = class SelectionRange {
-       constructor(
-       /**
-       The lower boundary of the range.
-       */
-       from, 
-       /**
-       The upper boundary of the range.
-       */
-       to, flags) {
-           this.from = from;
-           this.to = to;
-           this.flags = flags;
-       }
-       /**
-       The anchor of the range—the side that doesn't move when you
-       extend it.
-       */
-       get anchor() { return this.flags & 16 /* Inverted */ ? 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 & 16 /* Inverted */ ? 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 & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
-       /**
-       The bidirectional text level associated with this cursor, if
-       any.
-       */
-       get bidiLevel() {
-           let level = this.flags & 3 /* BidiLevelMask */;
-           return level == 3 ? null : level;
-       }
-       /**
-       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 value = this.flags >> 5 /* GoalColumnOffset */;
-           return value == 33554431 /* NoGoalColumn */ ? undefined : value;
-       }
-       /**
-       Map this range through a change, producing a valid range in the
-       updated document.
-       */
-       map(change, assoc = -1) {
-           let from, to;
-           if (this.empty) {
-               from = to = change.mapPos(this.from, assoc);
-           }
-           else {
-               from = change.mapPos(this.from, 1);
-               to = change.mapPos(this.to, -1);
-           }
-           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
-       }
-       /**
-       Extend this range to cover at least `from` to `to`.
-       */
-       extend(from, to = from) {
-           if (from <= this.anchor && to >= this.anchor)
-               return EditorSelection$1.range(from, to);
-           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
-           return EditorSelection$1.range(this.anchor, head);
-       }
-       /**
-       Compare this range to another range.
-       */
-       eq(other) {
-           return this.anchor == other.anchor && this.head == other.head;
-       }
-       /**
-       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(json) {
-           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
-               throw new RangeError("Invalid JSON representation for SelectionRange");
-           return EditorSelection$1.range(json.anchor, json.head);
-       }
-       /**
-       @internal
-       */
-       static create(from, to, flags) {
-           return new SelectionRange(from, to, flags);
-       }
-   };
-   /**
-   An editor selection holds one or more selection ranges.
-   */
-   let EditorSelection$1 = class EditorSelection {
-       constructor(
-       /**
-       The ranges in the selection, sorted by position. Ranges cannot
-       overlap (but they may touch, if they aren't empty).
-       */
-       ranges, 
-       /**
-       The index of the _main_ range in the selection (which is
-       usually the range that was added last).
-       */
-       mainIndex) {
-           this.ranges = ranges;
-           this.mainIndex = mainIndex;
-       }
-       /**
-       Map a selection through a change. Used to adjust the selection
-       position for changes.
-       */
-       map(change, assoc = -1) {
-           if (change.empty)
-               return this;
-           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);
-       }
-       /**
-       Compare this selection to another selection.
-       */
-       eq(other) {
-           if (this.ranges.length != other.ranges.length ||
-               this.mainIndex != other.mainIndex)
-               return false;
-           for (let i = 0; i < this.ranges.length; i++)
-               if (!this.ranges[i].eq(other.ranges[i]))
-                   return false;
-           return true;
-       }
-       /**
-       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 EditorSelection([this.main], 0);
-       }
-       /**
-       Extend this selection with an extra range.
-       */
-       addRange(range, main = true) {
-           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
-       }
-       /**
-       Replace a given range with another range, and then normalize the
-       selection to merge and sort ranges if necessary.
-       */
-       replaceRange(range, which = this.mainIndex) {
-           let ranges = this.ranges.slice();
-           ranges[which] = range;
-           return EditorSelection.create(ranges, this.mainIndex);
-       }
-       /**
-       Convert this selection to an object that can be serialized to
-       JSON.
-       */
-       toJSON() {
-           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
-       }
-       /**
-       Create a selection from a JSON representation.
-       */
-       static fromJSON(json) {
-           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
-               throw new RangeError("Invalid JSON representation for EditorSelection");
-           return new EditorSelection(json.ranges.map((r) => SelectionRange$1.fromJSON(r)), json.main);
-       }
-       /**
-       Create a selection holding a single range.
-       */
-       static single(anchor, head = anchor) {
-           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
-       }
-       /**
-       Sort and merge the given set of ranges, creating a valid
-       selection.
-       */
-       static create(ranges, mainIndex = 0) {
-           if (ranges.length == 0)
-               throw new RangeError("A selection needs at least one range");
-           for (let pos = 0, i = 0; i < ranges.length; i++) {
-               let range = ranges[i];
-               if (range.empty ? range.from <= pos : range.from < pos)
-                   return EditorSelection.normalized(ranges.slice(), mainIndex);
-               pos = range.to;
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-       /**
-       Create a cursor selection range at the given position. You can
-       safely ignore the optional arguments in most situations.
-       */
-       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
-           return SelectionRange$1.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
-               (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
-               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
-       }
-       /**
-       Create a selection range.
-       */
-       static range(anchor, head, goalColumn) {
-           let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
-           return head < anchor ? SelectionRange$1.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
-               : SelectionRange$1.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
-       }
-       /**
-       @internal
-       */
-       static normalized(ranges, mainIndex = 0) {
-           let main = ranges[mainIndex];
-           ranges.sort((a, b) => a.from - b.from);
-           mainIndex = ranges.indexOf(main);
-           for (let i = 1; i < ranges.length; i++) {
-               let range = ranges[i], prev = ranges[i - 1];
-               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
-                   let from = prev.from, to = Math.max(range.to, prev.to);
-                   if (i <= mainIndex)
-                       mainIndex--;
-                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
-               }
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-   };
-   function checkSelection$1(selection, docLength) {
-       for (let range of selection.ranges)
-           if (range.to > docLength)
-               throw new RangeError("Selection points outside of document");
-   }
-
-   let nextID$1 = 0;
-   /**
-   A facet is a labeled value that is associated with an editor
-   state. It takes inputs from any number of extensions, and combines
-   those into a single output value.
-
-   Examples of uses of facets are the [tab
-   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
-   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
-   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
-   */
-   let Facet$1 = class Facet {
-       constructor(
-       /**
-       @internal
-       */
-       combine, 
-       /**
-       @internal
-       */
-       compareInput, 
-       /**
-       @internal
-       */
-       compare, isStatic, 
-       /**
-       @internal
-       */
-       extensions) {
-           this.combine = combine;
-           this.compareInput = compareInput;
-           this.compare = compare;
-           this.isStatic = isStatic;
-           this.extensions = extensions;
-           /**
-           @internal
-           */
-           this.id = nextID$1++;
-           this.default = combine([]);
-       }
-       /**
-       Define a new facet.
-       */
-       static define(config = {}) {
-           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$2 : (a, b) => a === b), !!config.static, config.enables);
-       }
-       /**
-       Returns an extension that adds the given value to this facet.
-       */
-       of(value) {
-           return new FacetProvider$1([], this, 0 /* Static */, value);
-       }
-       /**
-       Create an extension that computes a value for the facet from a
-       state. You must take care to declare the parts of the state that
-       this value depends on, since your function is only called again
-       for a new state when one of those parts changed.
-       
-       In cases where your value depends only on a single field, you'll
-       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
-       */
-       compute(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider$1(deps, this, 1 /* Single */, get);
-       }
-       /**
-       Create an extension that computes zero or more values for this
-       facet from a state.
-       */
-       computeN(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider$1(deps, this, 2 /* Multi */, get);
-       }
-       from(field, get) {
-           if (!get)
-               get = x => x;
-           return this.compute([field], state => get(state.field(field)));
-       }
-   };
-   function sameArray$2(a, b) {
-       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
-   }
-   let FacetProvider$1 = class FacetProvider {
-       constructor(dependencies, facet, type, value) {
-           this.dependencies = dependencies;
-           this.facet = facet;
-           this.type = type;
-           this.value = value;
-           this.id = nextID$1++;
-       }
-       dynamicSlot(addresses) {
-           var _a;
-           let getter = this.value;
-           let compare = this.facet.compareInput;
-           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
-           let depDoc = false, depSel = false, depAddrs = [];
-           for (let dep of this.dependencies) {
-               if (dep == "doc")
-                   depDoc = true;
-               else if (dep == "selection")
-                   depSel = true;
-               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
-                   depAddrs.push(addresses[dep.id]);
-           }
-           return {
-               create(state) {
-                   state.values[idx] = getter(state);
-                   return 1 /* Changed */;
-               },
-               update(state, tr) {
-                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll$1(state, depAddrs)) {
-                       let newVal = getter(state);
-                       if (multi ? !compareArray$1(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
-                           state.values[idx] = newVal;
-                           return 1 /* Changed */;
-                       }
-                   }
-                   return 0;
-               },
-               reconfigure: (state, oldState) => {
-                   let newVal = getter(state);
-                   let oldAddr = oldState.config.address[id];
-                   if (oldAddr != null) {
-                       let oldVal = getAddr$1(oldState, oldAddr);
-                       if (this.dependencies.every(dep => {
-                           return dep instanceof Facet$1 ? oldState.facet(dep) === state.facet(dep) :
-                               dep instanceof StateField$1 ? oldState.field(dep, false) == state.field(dep, false) : true;
-                       }) || (multi ? compareArray$1(newVal, oldVal, compare) : compare(newVal, oldVal))) {
-                           state.values[idx] = oldVal;
-                           return 0;
-                       }
-                   }
-                   state.values[idx] = newVal;
-                   return 1 /* Changed */;
-               }
-           };
-       }
-   };
-   function compareArray$1(a, b, compare) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (!compare(a[i], b[i]))
-               return false;
-       return true;
-   }
-   function ensureAll$1(state, addrs) {
-       let changed = false;
-       for (let addr of addrs)
-           if (ensureAddr$1(state, addr) & 1 /* Changed */)
-               changed = true;
-       return changed;
-   }
-   function dynamicFacetSlot$1(addresses, facet, providers) {
-       let providerAddrs = providers.map(p => addresses[p.id]);
-       let providerTypes = providers.map(p => p.type);
-       let dynamic = providerAddrs.filter(p => !(p & 1));
-       let idx = addresses[facet.id] >> 1;
-       function get(state) {
-           let values = [];
-           for (let i = 0; i < providerAddrs.length; i++) {
-               let value = getAddr$1(state, providerAddrs[i]);
-               if (providerTypes[i] == 2 /* Multi */)
-                   for (let val of value)
-                       values.push(val);
-               else
-                   values.push(value);
-           }
-           return facet.combine(values);
-       }
-       return {
-           create(state) {
-               for (let addr of providerAddrs)
-                   ensureAddr$1(state, addr);
-               state.values[idx] = get(state);
-               return 1 /* Changed */;
-           },
-           update(state, tr) {
-               if (!ensureAll$1(state, dynamic))
-                   return 0;
-               let value = get(state);
-               if (facet.compare(value, state.values[idx]))
-                   return 0;
-               state.values[idx] = value;
-               return 1 /* Changed */;
-           },
-           reconfigure(state, oldState) {
-               let depChanged = ensureAll$1(state, providerAddrs);
-               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
-               if (oldProviders && !depChanged && sameArray$2(providers, oldProviders)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               let value = get(state);
-               if (facet.compare(value, oldValue)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               state.values[idx] = value;
-               return 1 /* Changed */;
-           }
-       };
-   }
-   const initField$1 = /*@__PURE__*/Facet$1.define({ static: true });
-   /**
-   Fields can store additional information in an editor state, and
-   keep it in sync with the rest of the state.
-   */
-   let StateField$1 = class StateField {
-       constructor(
-       /**
-       @internal
-       */
-       id, createF, updateF, compareF, 
-       /**
-       @internal
-       */
-       spec) {
-           this.id = id;
-           this.createF = createF;
-           this.updateF = updateF;
-           this.compareF = compareF;
-           this.spec = spec;
-           /**
-           @internal
-           */
-           this.provides = undefined;
-       }
-       /**
-       Define a state field.
-       */
-       static define(config) {
-           let field = new StateField(nextID$1++, config.create, config.update, config.compare || ((a, b) => a === b), config);
-           if (config.provide)
-               field.provides = config.provide(field);
-           return field;
-       }
-       create(state) {
-           let init = state.facet(initField$1).find(i => i.field == this);
-           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
-       }
-       /**
-       @internal
-       */
-       slot(addresses) {
-           let idx = addresses[this.id] >> 1;
-           return {
-               create: (state) => {
-                   state.values[idx] = this.create(state);
-                   return 1 /* Changed */;
-               },
-               update: (state, tr) => {
-                   let oldVal = state.values[idx];
-                   let value = this.updateF(oldVal, tr);
-                   if (this.compareF(oldVal, value))
-                       return 0;
-                   state.values[idx] = value;
-                   return 1 /* Changed */;
-               },
-               reconfigure: (state, oldState) => {
-                   if (oldState.config.address[this.id] != null) {
-                       state.values[idx] = oldState.field(this);
-                       return 0;
-                   }
-                   state.values[idx] = this.create(state);
-                   return 1 /* Changed */;
-               }
-           };
-       }
-       /**
-       Returns an extension that enables this field and overrides the
-       way it is initialized. Can be useful when you need to provide a
-       non-default starting value for the field.
-       */
-       init(create) {
-           return [this, initField$1.of({ field: this, create })];
-       }
-       /**
-       State field instances can be used as
-       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
-       given state.
-       */
-       get extension() { return this; }
-   };
-   const Prec_$1 = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
-   function prec$1(value) {
-       return (ext) => new PrecExtension$1(ext, value);
-   }
-   /**
-   By default extensions are registered in the order they are found
-   in the flattened form of nested array that was provided.
-   Individual extension values can be assigned a precedence to
-   override this. Extensions that do not have a precedence set get
-   the precedence of the nearest parent with a precedence, or
-   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
-   final ordering of extensions is determined by first sorting by
-   precedence and then by order within each precedence.
-   */
-   const Prec$1 = {
-       /**
-       The highest precedence level, for extensions that should end up
-       near the start of the precedence ordering.
-       */
-       highest: /*@__PURE__*/prec$1(Prec_$1.highest),
-       /**
-       A higher-than-default precedence, for extensions that should
-       come before those with default precedence.
-       */
-       high: /*@__PURE__*/prec$1(Prec_$1.high),
-       /**
-       The default precedence, which is also used for extensions
-       without an explicit precedence.
-       */
-       default: /*@__PURE__*/prec$1(Prec_$1.default),
-       /**
-       A lower-than-default precedence.
-       */
-       low: /*@__PURE__*/prec$1(Prec_$1.low),
-       /**
-       The lowest precedence level. Meant for things that should end up
-       near the end of the extension order.
-       */
-       lowest: /*@__PURE__*/prec$1(Prec_$1.lowest)
-   };
-   let PrecExtension$1 = class PrecExtension {
-       constructor(inner, prec) {
-           this.inner = inner;
-           this.prec = prec;
-       }
-   };
-   /**
-   Extension compartments can be used to make a configuration
-   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
-   configuration in a compartment, you can later
-   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
-   transaction.
-   */
-   let Compartment$1 = class Compartment {
-       /**
-       Create an instance of this compartment to add to your [state
-       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
-       */
-       of(ext) { return new CompartmentInstance$1(this, ext); }
-       /**
-       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
-       reconfigures this compartment.
-       */
-       reconfigure(content) {
-           return Compartment.reconfigure.of({ compartment: this, extension: content });
-       }
-       /**
-       Get the current content of the compartment in the state, or
-       `undefined` if it isn't present.
-       */
-       get(state) {
-           return state.config.compartments.get(this);
-       }
-   };
-   let CompartmentInstance$1 = class CompartmentInstance {
-       constructor(compartment, inner) {
-           this.compartment = compartment;
-           this.inner = inner;
-       }
-   };
-   let Configuration$1 = class Configuration {
-       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
-           this.base = base;
-           this.compartments = compartments;
-           this.dynamicSlots = dynamicSlots;
-           this.address = address;
-           this.staticValues = staticValues;
-           this.facets = facets;
-           this.statusTemplate = [];
-           while (this.statusTemplate.length < dynamicSlots.length)
-               this.statusTemplate.push(0 /* Unresolved */);
-       }
-       staticFacet(facet) {
-           let addr = this.address[facet.id];
-           return addr == null ? facet.default : this.staticValues[addr >> 1];
-       }
-       static resolve(base, compartments, oldState) {
-           let fields = [];
-           let facets = Object.create(null);
-           let newCompartments = new Map();
-           for (let ext of flatten$1(base, compartments, newCompartments)) {
-               if (ext instanceof StateField$1)
-                   fields.push(ext);
-               else
-                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
-           }
-           let address = Object.create(null);
-           let staticValues = [];
-           let dynamicSlots = [];
-           for (let field of fields) {
-               address[field.id] = dynamicSlots.length << 1;
-               dynamicSlots.push(a => field.slot(a));
-           }
-           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
-           for (let id in facets) {
-               let providers = facets[id], facet = providers[0].facet;
-               let oldProviders = oldFacets && oldFacets[id] || [];
-               if (providers.every(p => p.type == 0 /* Static */)) {
-                   address[facet.id] = (staticValues.length << 1) | 1;
-                   if (sameArray$2(oldProviders, providers)) {
-                       staticValues.push(oldState.facet(facet));
-                   }
-                   else {
-                       let value = facet.combine(providers.map(p => p.value));
-                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
-                   }
-               }
-               else {
-                   for (let p of providers) {
-                       if (p.type == 0 /* Static */) {
-                           address[p.id] = (staticValues.length << 1) | 1;
-                           staticValues.push(p.value);
-                       }
-                       else {
-                           address[p.id] = dynamicSlots.length << 1;
-                           dynamicSlots.push(a => p.dynamicSlot(a));
-                       }
-                   }
-                   address[facet.id] = dynamicSlots.length << 1;
-                   dynamicSlots.push(a => dynamicFacetSlot$1(a, facet, providers));
-               }
-           }
-           let dynamic = dynamicSlots.map(f => f(address));
-           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
-       }
-   };
-   function flatten$1(extension, compartments, newCompartments) {
-       let result = [[], [], [], [], []];
-       let seen = new Map();
-       function inner(ext, prec) {
-           let known = seen.get(ext);
-           if (known != null) {
-               if (known <= prec)
-                   return;
-               let found = result[known].indexOf(ext);
-               if (found > -1)
-                   result[known].splice(found, 1);
-               if (ext instanceof CompartmentInstance$1)
-                   newCompartments.delete(ext.compartment);
-           }
-           seen.set(ext, prec);
-           if (Array.isArray(ext)) {
-               for (let e of ext)
-                   inner(e, prec);
-           }
-           else if (ext instanceof CompartmentInstance$1) {
-               if (newCompartments.has(ext.compartment))
-                   throw new RangeError(`Duplicate use of compartment in extensions`);
-               let content = compartments.get(ext.compartment) || ext.inner;
-               newCompartments.set(ext.compartment, content);
-               inner(content, prec);
-           }
-           else if (ext instanceof PrecExtension$1) {
-               inner(ext.inner, ext.prec);
-           }
-           else if (ext instanceof StateField$1) {
-               result[prec].push(ext);
-               if (ext.provides)
-                   inner(ext.provides, prec);
-           }
-           else if (ext instanceof FacetProvider$1) {
-               result[prec].push(ext);
-               if (ext.facet.extensions)
-                   inner(ext.facet.extensions, prec);
-           }
-           else {
-               let content = ext.extension;
-               if (!content)
-                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
-               inner(content, prec);
-           }
-       }
-       inner(extension, Prec_$1.default);
-       return result.reduce((a, b) => a.concat(b));
-   }
-   function ensureAddr$1(state, addr) {
-       if (addr & 1)
-           return 2 /* Computed */;
-       let idx = addr >> 1;
-       let status = state.status[idx];
-       if (status == 4 /* Computing */)
-           throw new Error("Cyclic dependency between fields and/or facets");
-       if (status & 2 /* Computed */)
-           return status;
-       state.status[idx] = 4 /* Computing */;
-       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
-       return state.status[idx] = 2 /* Computed */ | changed;
-   }
-   function getAddr$1(state, addr) {
-       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
-   }
-
-   const languageData$1 = /*@__PURE__*/Facet$1.define();
-   const allowMultipleSelections$1 = /*@__PURE__*/Facet$1.define({
-       combine: values => values.some(v => v),
-       static: true
-   });
-   const lineSeparator$1 = /*@__PURE__*/Facet$1.define({
-       combine: values => values.length ? values[0] : undefined,
-       static: true
-   });
-   const changeFilter$1 = /*@__PURE__*/Facet$1.define();
-   const transactionFilter$1 = /*@__PURE__*/Facet$1.define();
-   const transactionExtender$1 = /*@__PURE__*/Facet$1.define();
-   const readOnly$1 = /*@__PURE__*/Facet$1.define({
-       combine: values => values.length ? values[0] : false
-   });
-
-   /**
-   Annotations are tagged values that are used to add metadata to
-   transactions in an extensible way. They should be used to model
-   things that effect the entire transaction (such as its [time
-   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
-   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
-   _alongside_ the other changes made by the transaction, [state
-   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
-   */
-   let Annotation$1 = class Annotation {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The annotation type.
-       */
-       type, 
-       /**
-       The value of this annotation.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Define a new type of annotation.
-       */
-       static define() { return new AnnotationType$1(); }
-   };
-   /**
-   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
-   */
-   let AnnotationType$1 = class AnnotationType {
-       /**
-       Create an instance of this annotation.
-       */
-       of(value) { return new Annotation$1(this, value); }
-   };
-   /**
-   Representation of a type of state effect. Defined with
-   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
-   */
-   let StateEffectType$1 = class StateEffectType {
-       /**
-       @internal
-       */
-       constructor(
-       // The `any` types in these function types are there to work
-       // around TypeScript issue #37631, where the type guard on
-       // `StateEffect.is` mysteriously stops working when these properly
-       // have type `Value`.
-       /**
-       @internal
-       */
-       map) {
-           this.map = map;
-       }
-       /**
-       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
-       type.
-       */
-       of(value) { return new StateEffect$1(this, value); }
-   };
-   /**
-   State effects can be used to represent additional effects
-   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
-   are often useful to model changes to custom [state
-   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
-   document or selection changes.
-   */
-   let StateEffect$1 = class StateEffect {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       @internal
-       */
-       type, 
-       /**
-       The value of this effect.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Map this effect through a position mapping. Will return
-       `undefined` when that ends up deleting the effect.
-       */
-       map(mapping) {
-           let mapped = this.type.map(this.value, mapping);
-           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
-       }
-       /**
-       Tells you whether this effect object is of a given
-       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
-       */
-       is(type) { return this.type == type; }
-       /**
-       Define a new effect type. The type parameter indicates the type
-       of values that his effect holds.
-       */
-       static define(spec = {}) {
-           return new StateEffectType$1(spec.map || (v => v));
-       }
-       /**
-       Map an array of effects through a change set.
-       */
-       static mapEffects(effects, mapping) {
-           if (!effects.length)
-               return effects;
-           let result = [];
-           for (let effect of effects) {
-               let mapped = effect.map(mapping);
-               if (mapped)
-                   result.push(mapped);
-           }
-           return result;
-       }
-   };
-   /**
-   This effect can be used to reconfigure the root extensions of
-   the editor. Doing this will discard any extensions
-   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
-   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
-   compartments.
-   */
-   StateEffect$1.reconfigure = /*@__PURE__*/StateEffect$1.define();
-   /**
-   Append extensions to the top-level configuration of the editor.
-   */
-   StateEffect$1.appendConfig = /*@__PURE__*/StateEffect$1.define();
-   /**
-   Changes to the editor state are grouped into transactions.
-   Typically, a user action creates a single transaction, which may
-   contain any number of document changes, may change the selection,
-   or have other effects. Create a transaction by calling
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
-   dispatch one by calling
-   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
-   */
-   let Transaction$1 = class Transaction {
-       constructor(
-       /**
-       The state from which the transaction starts.
-       */
-       startState, 
-       /**
-       The document changes made by this transaction.
-       */
-       changes, 
-       /**
-       The selection set by this transaction, or undefined if it
-       doesn't explicitly set a selection.
-       */
-       selection, 
-       /**
-       The effects added to the transaction.
-       */
-       effects, 
-       /**
-       @internal
-       */
-       annotations, 
-       /**
-       Whether the selection should be scrolled into view after this
-       transaction is dispatched.
-       */
-       scrollIntoView) {
-           this.startState = startState;
-           this.changes = changes;
-           this.selection = selection;
-           this.effects = effects;
-           this.annotations = annotations;
-           this.scrollIntoView = scrollIntoView;
-           /**
-           @internal
-           */
-           this._doc = null;
-           /**
-           @internal
-           */
-           this._state = null;
-           if (selection)
-               checkSelection$1(selection, changes.newLength);
-           if (!annotations.some((a) => a.type == Transaction.time))
-               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
-       }
-       /**
-       @internal
-       */
-       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
-           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
-       }
-       /**
-       The new document produced by the transaction. Contrary to
-       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
-       force the entire new state to be computed right away, so it is
-       recommended that [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
-       when they need to look at the new document.
-       */
-       get newDoc() {
-           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
-       }
-       /**
-       The new selection produced by the transaction. If
-       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
-       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
-       current selection through the changes made by the transaction.
-       */
-       get newSelection() {
-           return this.selection || this.startState.selection.map(this.changes);
-       }
-       /**
-       The new state created by the transaction. Computed on demand
-       (but retained for subsequent access), so it is recommended not to
-       access it in [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
-       */
-       get state() {
-           if (!this._state)
-               this.startState.applyTransaction(this);
-           return this._state;
-       }
-       /**
-       Get the value of the given annotation type, if any.
-       */
-       annotation(type) {
-           for (let ann of this.annotations)
-               if (ann.type == type)
-                   return ann.value;
-           return undefined;
-       }
-       /**
-       Indicates whether the transaction changed the document.
-       */
-       get docChanged() { return !this.changes.empty; }
-       /**
-       Indicates whether this transaction reconfigures the state
-       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
-       with a top-level configuration
-       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
-       */
-       get reconfigured() { return this.startState.config != this.state.config; }
-       /**
-       Returns true if the transaction has a [user
-       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
-       or more specific than `event`. For example, if the transaction
-       has `"select.pointer"` as user event, `"select"` and
-       `"select.pointer"` will match it.
-       */
-       isUserEvent(event) {
-           let e = this.annotation(Transaction.userEvent);
-           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
-       }
-   };
-   /**
-   Annotation used to store transaction timestamps. Automatically
-   added to every transaction, holding `Date.now()`.
-   */
-   Transaction$1.time = /*@__PURE__*/Annotation$1.define();
-   /**
-   Annotation used to associate a transaction with a user interface
-   event. Holds a string identifying the event, using a
-   dot-separated format to support attaching more specific
-   information. The events used by the core libraries are:
-
-    - `"input"` when content is entered
-      - `"input.type"` for typed input
-        - `"input.type.compose"` for composition
-      - `"input.paste"` for pasted input
-      - `"input.drop"` when adding content with drag-and-drop
-      - `"input.complete"` when autocompleting
-    - `"delete"` when the user deletes content
-      - `"delete.selection"` when deleting the selection
-      - `"delete.forward"` when deleting forward from the selection
-      - `"delete.backward"` when deleting backward from the selection
-      - `"delete.cut"` when cutting to the clipboard
-    - `"move"` when content is moved
-      - `"move.drop"` when content is moved within the editor through drag-and-drop
-    - `"select"` when explicitly changing the selection
-      - `"select.pointer"` when selecting with a mouse or other pointing device
-    - `"undo"` and `"redo"` for history actions
-
-   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
-   whether the annotation matches a given event.
-   */
-   Transaction$1.userEvent = /*@__PURE__*/Annotation$1.define();
-   /**
-   Annotation indicating whether a transaction should be added to
-   the undo history or not.
-   */
-   Transaction$1.addToHistory = /*@__PURE__*/Annotation$1.define();
-   /**
-   Annotation indicating (when present and true) that a transaction
-   represents a change made by some other actor, not the user. This
-   is used, for example, to tag other people's changes in
-   collaborative editing.
-   */
-   Transaction$1.remote = /*@__PURE__*/Annotation$1.define();
-   function joinRanges$1(a, b) {
-       let result = [];
-       for (let iA = 0, iB = 0;;) {
-           let from, to;
-           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
-               from = a[iA++];
-               to = a[iA++];
-           }
-           else if (iB < b.length) {
-               from = b[iB++];
-               to = b[iB++];
-           }
-           else
-               return result;
-           if (!result.length || result[result.length - 1] < from)
-               result.push(from, to);
-           else if (result[result.length - 1] < to)
-               result[result.length - 1] = to;
-       }
-   }
-   function mergeTransaction$1(a, b, sequential) {
-       var _a;
-       let mapForA, mapForB, changes;
-       if (sequential) {
-           mapForA = b.changes;
-           mapForB = ChangeSet$1.empty(b.changes.length);
-           changes = a.changes.compose(b.changes);
-       }
-       else {
-           mapForA = b.changes.map(a.changes);
-           mapForB = a.changes.mapDesc(b.changes, true);
-           changes = a.changes.compose(mapForA);
-       }
-       return {
-           changes,
-           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
-           effects: StateEffect$1.mapEffects(a.effects, mapForA).concat(StateEffect$1.mapEffects(b.effects, mapForB)),
-           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
-           scrollIntoView: a.scrollIntoView || b.scrollIntoView
-       };
-   }
-   function resolveTransactionInner$1(state, spec, docSize) {
-       let sel = spec.selection, annotations = asArray$2(spec.annotations);
-       if (spec.userEvent)
-           annotations = annotations.concat(Transaction$1.userEvent.of(spec.userEvent));
-       return {
-           changes: spec.changes instanceof ChangeSet$1 ? spec.changes
-               : ChangeSet$1.of(spec.changes || [], docSize, state.facet(lineSeparator$1)),
-           selection: sel && (sel instanceof EditorSelection$1 ? sel : EditorSelection$1.single(sel.anchor, sel.head)),
-           effects: asArray$2(spec.effects),
-           annotations,
-           scrollIntoView: !!spec.scrollIntoView
-       };
-   }
-   function resolveTransaction$1(state, specs, filter) {
-       let s = resolveTransactionInner$1(state, specs.length ? specs[0] : {}, state.doc.length);
-       if (specs.length && specs[0].filter === false)
-           filter = false;
-       for (let i = 1; i < specs.length; i++) {
-           if (specs[i].filter === false)
-               filter = false;
-           let seq = !!specs[i].sequential;
-           s = mergeTransaction$1(s, resolveTransactionInner$1(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
-       }
-       let tr = Transaction$1.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
-       return extendTransaction$1(filter ? filterTransaction$1(tr) : tr);
-   }
-   // Finish a transaction by applying filters if necessary.
-   function filterTransaction$1(tr) {
-       let state = tr.startState;
-       // Change filters
-       let result = true;
-       for (let filter of state.facet(changeFilter$1)) {
-           let value = filter(tr);
-           if (value === false) {
-               result = false;
-               break;
-           }
-           if (Array.isArray(value))
-               result = result === true ? value : joinRanges$1(result, value);
-       }
-       if (result !== true) {
-           let changes, back;
-           if (result === false) {
-               back = tr.changes.invertedDesc;
-               changes = ChangeSet$1.empty(state.doc.length);
-           }
-           else {
-               let filtered = tr.changes.filter(result);
-               changes = filtered.changes;
-               back = filtered.filtered.invertedDesc;
-           }
-           tr = Transaction$1.create(state, changes, tr.selection && tr.selection.map(back), StateEffect$1.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
-       }
-       // Transaction filters
-       let filters = state.facet(transactionFilter$1);
-       for (let i = filters.length - 1; i >= 0; i--) {
-           let filtered = filters[i](tr);
-           if (filtered instanceof Transaction$1)
-               tr = filtered;
-           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction$1)
-               tr = filtered[0];
-           else
-               tr = resolveTransaction$1(state, asArray$2(filtered), false);
-       }
-       return tr;
-   }
-   function extendTransaction$1(tr) {
-       let state = tr.startState, extenders = state.facet(transactionExtender$1), spec = tr;
-       for (let i = extenders.length - 1; i >= 0; i--) {
-           let extension = extenders[i](tr);
-           if (extension && Object.keys(extension).length)
-               spec = mergeTransaction$1(tr, resolveTransactionInner$1(state, extension, tr.changes.newLength), true);
-       }
-       return spec == tr ? tr : Transaction$1.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
-   }
-   const none$3 = [];
-   function asArray$2(value) {
-       return value == null ? none$3 : Array.isArray(value) ? value : [value];
-   }
-
-   /**
-   The categories produced by a [character
-   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
-   do things like selecting by word.
-   */
-   var CharCategory$1 = /*@__PURE__*/(function (CharCategory) {
-       /**
-       Word characters.
-       */
-       CharCategory[CharCategory["Word"] = 0] = "Word";
-       /**
-       Whitespace.
-       */
-       CharCategory[CharCategory["Space"] = 1] = "Space";
-       /**
-       Anything else.
-       */
-       CharCategory[CharCategory["Other"] = 2] = "Other";
-   return CharCategory})(CharCategory$1 || (CharCategory$1 = {}));
-   const nonASCIISingleCaseWordChar$1 = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
-   let wordChar$1;
-   try {
-       wordChar$1 = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
-   }
-   catch (_) { }
-   function hasWordChar$1(str) {
-       if (wordChar$1)
-           return wordChar$1.test(str);
-       for (let i = 0; i < str.length; i++) {
-           let ch = str[i];
-           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar$1.test(ch)))
-               return true;
-       }
-       return false;
-   }
-   function makeCategorizer$1(wordChars) {
-       return (char) => {
-           if (!/\S/.test(char))
-               return CharCategory$1.Space;
-           if (hasWordChar$1(char))
-               return CharCategory$1.Word;
-           for (let i = 0; i < wordChars.length; i++)
-               if (char.indexOf(wordChars[i]) > -1)
-                   return CharCategory$1.Word;
-           return CharCategory$1.Other;
-       };
-   }
-
-   /**
-   The editor state class is a persistent (immutable) data structure.
-   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
-   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
-   instance, without modifying the original object.
-
-   As such, _never_ mutate properties of a state directly. That'll
-   just break things.
-   */
-   let EditorState$1 = class EditorState {
-       constructor(
-       /**
-       @internal
-       */
-       config, 
-       /**
-       The current document.
-       */
-       doc, 
-       /**
-       The current selection.
-       */
-       selection, 
-       /**
-       @internal
-       */
-       values, computeSlot, tr) {
-           this.config = config;
-           this.doc = doc;
-           this.selection = selection;
-           this.values = values;
-           this.status = config.statusTemplate.slice();
-           this.computeSlot = computeSlot;
-           // Fill in the computed state immediately, so that further queries
-           // for it made during the update return this state
-           if (tr)
-               tr._state = this;
-           for (let i = 0; i < this.config.dynamicSlots.length; i++)
-               ensureAddr$1(this, i << 1);
-           this.computeSlot = null;
-       }
-       field(field, require = true) {
-           let addr = this.config.address[field.id];
-           if (addr == null) {
-               if (require)
-                   throw new RangeError("Field is not present in this state");
-               return undefined;
-           }
-           ensureAddr$1(this, addr);
-           return getAddr$1(this, addr);
-       }
-       /**
-       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
-       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
-       can be passed. Unless
-       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
-       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
-       are assumed to start in the _current_ document (not the document
-       produced by previous specs), and its
-       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
-       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
-       to the document created by its _own_ changes. The resulting
-       transaction contains the combined effect of all the different
-       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
-       specs take precedence over earlier ones.
-       */
-       update(...specs) {
-           return resolveTransaction$1(this, specs, true);
-       }
-       /**
-       @internal
-       */
-       applyTransaction(tr) {
-           let conf = this.config, { base, compartments } = conf;
-           for (let effect of tr.effects) {
-               if (effect.is(Compartment$1.reconfigure)) {
-                   if (conf) {
-                       compartments = new Map;
-                       conf.compartments.forEach((val, key) => compartments.set(key, val));
-                       conf = null;
-                   }
-                   compartments.set(effect.value.compartment, effect.value.extension);
-               }
-               else if (effect.is(StateEffect$1.reconfigure)) {
-                   conf = null;
-                   base = effect.value;
-               }
-               else if (effect.is(StateEffect$1.appendConfig)) {
-                   conf = null;
-                   base = asArray$2(base).concat(effect.value);
-               }
-           }
-           let startValues;
-           if (!conf) {
-               conf = Configuration$1.resolve(base, compartments, this);
-               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
-               startValues = intermediateState.values;
-           }
-           else {
-               startValues = tr.startState.values.slice();
-           }
-           new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);
-       }
-       /**
-       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
-       replaces every selection range with the given content.
-       */
-       replaceSelection(text) {
-           if (typeof text == "string")
-               text = this.toText(text);
-           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
-               range: EditorSelection$1.cursor(range.from + text.length) }));
-       }
-       /**
-       Create a set of changes and a new selection by running the given
-       function for each range in the active selection. The function
-       can return an optional set of changes (in the coordinate space
-       of the start document), plus an updated range (in the coordinate
-       space of the document produced by the call's own changes). This
-       method will merge all the changes and ranges into a single
-       changeset and selection, and return it as a [transaction
-       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
-       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
-       */
-       changeByRange(f) {
-           let sel = this.selection;
-           let result1 = f(sel.ranges[0]);
-           let changes = this.changes(result1.changes), ranges = [result1.range];
-           let effects = asArray$2(result1.effects);
-           for (let i = 1; i < sel.ranges.length; i++) {
-               let result = f(sel.ranges[i]);
-               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
-               for (let j = 0; j < i; j++)
-                   ranges[j] = ranges[j].map(newMapped);
-               let mapBy = changes.mapDesc(newChanges, true);
-               ranges.push(result.range.map(mapBy));
-               changes = changes.compose(newMapped);
-               effects = StateEffect$1.mapEffects(effects, newMapped).concat(StateEffect$1.mapEffects(asArray$2(result.effects), mapBy));
-           }
-           return {
-               changes,
-               selection: EditorSelection$1.create(ranges, sel.mainIndex),
-               effects
-           };
-       }
-       /**
-       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
-       description, taking the state's document length and line
-       separator into account.
-       */
-       changes(spec = []) {
-           if (spec instanceof ChangeSet$1)
-               return spec;
-           return ChangeSet$1.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
-       }
-       /**
-       Using the state's [line
-       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
-       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
-       */
-       toText(string) {
-           return Text$1.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit$1));
-       }
-       /**
-       Return the given range of the document as a string.
-       */
-       sliceDoc(from = 0, to = this.doc.length) {
-           return this.doc.sliceString(from, to, this.lineBreak);
-       }
-       /**
-       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
-       */
-       facet(facet) {
-           let addr = this.config.address[facet.id];
-           if (addr == null)
-               return facet.default;
-           ensureAddr$1(this, addr);
-           return getAddr$1(this, addr);
-       }
-       /**
-       Convert this state to a JSON-serializable object. When custom
-       fields should be serialized, you can pass them in as an object
-       mapping property names (in the resulting object, which should
-       not use `doc` or `selection`) to fields.
-       */
-       toJSON(fields) {
-           let result = {
-               doc: this.sliceDoc(),
-               selection: this.selection.toJSON()
-           };
-           if (fields)
-               for (let prop in fields) {
-                   let value = fields[prop];
-                   if (value instanceof StateField$1)
-                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
-               }
-           return result;
-       }
-       /**
-       Deserialize a state from its JSON representation. When custom
-       fields should be deserialized, pass the same object you passed
-       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
-       third argument.
-       */
-       static fromJSON(json, config = {}, fields) {
-           if (!json || typeof json.doc != "string")
-               throw new RangeError("Invalid JSON representation for EditorState");
-           let fieldInit = [];
-           if (fields)
-               for (let prop in fields) {
-                   let field = fields[prop], value = json[prop];
-                   fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
-               }
-           return EditorState.create({
-               doc: json.doc,
-               selection: EditorSelection$1.fromJSON(json.selection),
-               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
-           });
-       }
-       /**
-       Create a new state. You'll usually only need this when
-       initializing an editor—updated states are created by applying
-       transactions.
-       */
-       static create(config = {}) {
-           let configuration = Configuration$1.resolve(config.extensions || [], new Map);
-           let doc = config.doc instanceof Text$1 ? config.doc
-               : Text$1.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit$1));
-           let selection = !config.selection ? EditorSelection$1.single(0)
-               : config.selection instanceof EditorSelection$1 ? config.selection
-                   : EditorSelection$1.single(config.selection.anchor, config.selection.head);
-           checkSelection$1(selection, doc.length);
-           if (!configuration.staticFacet(allowMultipleSelections$1))
-               selection = selection.asSingle();
-           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
-       }
-       /**
-       The size (in columns) of a tab in the document, determined by
-       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
-       */
-       get tabSize() { return this.facet(EditorState.tabSize); }
-       /**
-       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
-       string for this state.
-       */
-       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
-       /**
-       Returns true when the editor is
-       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
-       */
-       get readOnly() { return this.facet(readOnly$1); }
-       /**
-       Look up a translation for the given phrase (via the
-       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
-       original string if no translation is found.
-       
-       If additional arguments are passed, they will be inserted in
-       place of markers like `$1` (for the first value) and `$2`, etc.
-       A single `$` is equivalent to `$1`, and `$$` will produce a
-       literal dollar sign.
-       */
-       phrase(phrase, ...insert) {
-           for (let map of this.facet(EditorState.phrases))
-               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
-                   phrase = map[phrase];
-                   break;
-               }
-           if (insert.length)
-               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
-                   if (i == "$")
-                       return "$";
-                   let n = +(i || 1);
-                   return n > insert.length ? m : insert[n - 1];
-               });
-           return phrase;
-       }
-       /**
-       Find the values for a given language data field, provided by the
-       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
-       */
-       languageDataAt(name, pos, side = -1) {
-           let values = [];
-           for (let provider of this.facet(languageData$1)) {
-               for (let result of provider(this, pos, side)) {
-                   if (Object.prototype.hasOwnProperty.call(result, name))
-                       values.push(result[name]);
-               }
-           }
-           return values;
-       }
-       /**
-       Return a function that can categorize strings (expected to
-       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
-       into one of:
-       
-        - Word (contains an alphanumeric character or a character
-          explicitly listed in the local language's `"wordChars"`
-          language data, which should be a string)
-        - Space (contains only whitespace)
-        - Other (anything else)
-       */
-       charCategorizer(at) {
-           return makeCategorizer$1(this.languageDataAt("wordChars", at).join(""));
-       }
-       /**
-       Find the word at the given position, meaning the range
-       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
-       around it. If no word characters are adjacent to the position,
-       this returns null.
-       */
-       wordAt(pos) {
-           let { text, from, length } = this.doc.lineAt(pos);
-           let cat = this.charCategorizer(pos);
-           let start = pos - from, end = pos - from;
-           while (start > 0) {
-               let prev = findClusterBreak$2(text, start, false);
-               if (cat(text.slice(prev, start)) != CharCategory$1.Word)
-                   break;
-               start = prev;
-           }
-           while (end < length) {
-               let next = findClusterBreak$2(text, end);
-               if (cat(text.slice(end, next)) != CharCategory$1.Word)
-                   break;
-               end = next;
-           }
-           return start == end ? null : EditorSelection$1.range(start + from, end + from);
-       }
-   };
-   /**
-   A facet that, when enabled, causes the editor to allow multiple
-   ranges to be selected. Be careful though, because by default the
-   editor relies on the native DOM selection, which cannot handle
-   multiple selections. An extension like
-   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
-   secondary selections visible to the user.
-   */
-   EditorState$1.allowMultipleSelections = allowMultipleSelections$1;
-   /**
-   Configures the tab size to use in this state. The first
-   (highest-precedence) value of the facet is used. If no value is
-   given, this defaults to 4.
-   */
-   EditorState$1.tabSize = /*@__PURE__*/Facet$1.define({
-       combine: values => values.length ? values[0] : 4
-   });
-   /**
-   The line separator to use. By default, any of `"\n"`, `"\r\n"`
-   and `"\r"` is treated as a separator when splitting lines, and
-   lines are joined with `"\n"`.
-
-   When you configure a value here, only that precise separator
-   will be used, allowing you to round-trip documents through the
-   editor without normalizing line separators.
-   */
-   EditorState$1.lineSeparator = lineSeparator$1;
-   /**
-   This facet controls the value of the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
-   consulted by commands and extensions that implement editing
-   functionality to determine whether they should apply. It
-   defaults to false, but when its highest-precedence value is
-   `true`, such functionality disables itself.
-
-   Not to be confused with
-   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
-   controls whether the editor's DOM is set to be editable (and
-   thus focusable).
-   */
-   EditorState$1.readOnly = readOnly$1;
-   /**
-   Registers translation phrases. The
-   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
-   all objects registered with this facet to find translations for
-   its argument.
-   */
-   EditorState$1.phrases = /*@__PURE__*/Facet$1.define({
-       compare(a, b) {
-           let kA = Object.keys(a), kB = Object.keys(b);
-           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
-       }
-   });
-   /**
-   A facet used to register [language
-   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
-   */
-   EditorState$1.languageData = languageData$1;
-   /**
-   Facet used to register change filters, which are called for each
-   transaction (unless explicitly
-   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
-   part of the transaction's changes.
-
-   Such a function can return `true` to indicate that it doesn't
-   want to do anything, `false` to completely stop the changes in
-   the transaction, or a set of ranges in which changes should be
-   suppressed. Such ranges are represented as an array of numbers,
-   with each pair of two numbers indicating the start and end of a
-   range. So for example `[10, 20, 100, 110]` suppresses changes
-   between 10 and 20, and between 100 and 110.
-   */
-   EditorState$1.changeFilter = changeFilter$1;
-   /**
-   Facet used to register a hook that gets a chance to update or
-   replace transaction specs before they are applied. This will
-   only be applied for transactions that don't have
-   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
-   can either return a single transaction spec (possibly the input
-   transaction), or an array of specs (which will be combined in
-   the same way as the arguments to
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
-
-   When possible, it is recommended to avoid accessing
-   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
-   since it will force creation of a state that will then be
-   discarded again, if the transaction is actually filtered.
-
-   (This functionality should be used with care. Indiscriminately
-   modifying transaction is likely to break something or degrade
-   the user experience.)
-   */
-   EditorState$1.transactionFilter = transactionFilter$1;
-   /**
-   This is a more limited form of
-   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
-   which can only add
-   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
-   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
-   of filter runs even if the transaction has disabled regular
-   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
-   for effects that don't need to touch the changes or selection,
-   but do want to process every transaction.
-
-   Extenders run _after_ filters, when both are present.
-   */
-   EditorState$1.transactionExtender = transactionExtender$1;
-   Compartment$1.reconfigure = /*@__PURE__*/StateEffect$1.define();
-
-   /**
-   Utility function for combining behaviors to fill in a config
-   object from an array of provided configs. `defaults` should hold
-   default values for all optional fields in `Config`.
-
-   The function will, by default, error
-   when a field gets two values that aren't `===`-equal, but you can
-   provide combine functions per field to do something else.
-   */
-   function combineConfig$1(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
-   combine = {}) {
-       let result = {};
-       for (let config of configs)
-           for (let key of Object.keys(config)) {
-               let value = config[key], current = result[key];
-               if (current === undefined)
-                   result[key] = value;
-               else if (current === value || value === undefined) ; // No conflict
-               else if (Object.hasOwnProperty.call(combine, key))
-                   result[key] = combine[key](current, value);
-               else
-                   throw new Error("Config merge conflict for field " + key);
-           }
-       for (let key in defaults)
-           if (result[key] === undefined)
-               result[key] = defaults[key];
-       return result;
-   }
-
-   /**
-   Each range is associated with a value, which must inherit from
-   this class.
-   */
-   let RangeValue$1 = class RangeValue {
-       /**
-       Compare this value with another value. Used when comparing
-       rangesets. The default implementation compares by identity.
-       Unless you are only creating a fixed number of unique instances
-       of your value type, it is a good idea to implement this
-       properly.
-       */
-       eq(other) { return this == other; }
-       /**
-       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
-       */
-       range(from, to = from) { return Range$2.create(from, to, this); }
-   };
-   RangeValue$1.prototype.startSide = RangeValue$1.prototype.endSide = 0;
-   RangeValue$1.prototype.point = false;
-   RangeValue$1.prototype.mapMode = MapMode$1.TrackDel;
-   /**
-   A range associates a value with a range of positions.
-   */
-   let Range$2 = class Range {
-       constructor(
-       /**
-       The range's start position.
-       */
-       from, 
-       /**
-       Its end position.
-       */
-       to, 
-       /**
-       The value associated with this range.
-       */
-       value) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-       }
-       /**
-       @internal
-       */
-       static create(from, to, value) {
-           return new Range(from, to, value);
-       }
-   };
-   function cmpRange$1(a, b) {
-       return a.from - b.from || a.value.startSide - b.value.startSide;
-   }
-   let Chunk$1 = class Chunk {
-       constructor(from, to, value, 
-       // Chunks are marked with the largest point that occurs
-       // in them (or -1 for no points), so that scans that are
-       // only interested in points (such as the
-       // heightmap-related logic) can skip range-only chunks.
-       maxPoint) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-           this.maxPoint = maxPoint;
-       }
-       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(pos, side, end, startAt = 0) {
-           let arr = end ? this.to : this.from;
-           for (let lo = startAt, hi = arr.length;;) {
-               if (lo == hi)
-                   return lo;
-               let mid = (lo + hi) >> 1;
-               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
-               if (mid == lo)
-                   return diff >= 0 ? lo : hi;
-               if (diff >= 0)
-                   hi = mid;
-               else
-                   lo = mid + 1;
-           }
-       }
-       between(offset, from, to, f) {
-           for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
-               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
-                   return false;
-       }
-       map(offset, changes) {
-           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
-           for (let i = 0; i < this.value.length; i++) {
-               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
-               if (curFrom == curTo) {
-                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
-                   if (mapped == null)
-                       continue;
-                   newFrom = newTo = mapped;
-                   if (val.startSide != val.endSide) {
-                       newTo = changes.mapPos(curFrom, val.endSide);
-                       if (newTo < newFrom)
-                           continue;
-                   }
-               }
-               else {
-                   newFrom = changes.mapPos(curFrom, val.startSide);
-                   newTo = changes.mapPos(curTo, val.endSide);
-                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
-                       continue;
-               }
-               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
-                   continue;
-               if (newPos < 0)
-                   newPos = newFrom;
-               if (val.point)
-                   maxPoint = Math.max(maxPoint, newTo - newFrom);
-               value.push(val);
-               from.push(newFrom - newPos);
-               to.push(newTo - newPos);
-           }
-           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
-       }
-   };
-   /**
-   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
-   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
-   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
-   structure.
-   */
-   let RangeSet$1 = class RangeSet {
-       constructor(
-       /**
-       @internal
-       */
-       chunkPos, 
-       /**
-       @internal
-       */
-       chunk, 
-       /**
-       @internal
-       */
-       nextLayer, 
-       /**
-       @internal
-       */
-       maxPoint) {
-           this.chunkPos = chunkPos;
-           this.chunk = chunk;
-           this.nextLayer = nextLayer;
-           this.maxPoint = maxPoint;
-       }
-       /**
-       @internal
-       */
-       static create(chunkPos, chunk, nextLayer, maxPoint) {
-           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
-       }
-       /**
-       @internal
-       */
-       get length() {
-           let last = this.chunk.length - 1;
-           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
-       }
-       /**
-       The number of ranges in the set.
-       */
-       get size() {
-           if (this.isEmpty)
-               return 0;
-           let size = this.nextLayer.size;
-           for (let chunk of this.chunk)
-               size += chunk.value.length;
-           return size;
-       }
-       /**
-       @internal
-       */
-       chunkEnd(index) {
-           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
-           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
-           let filter = updateSpec.filter;
-           if (add.length == 0 && !filter)
-               return this;
-           if (sort)
-               add = add.slice().sort(cmpRange$1);
-           if (this.isEmpty)
-               return add.length ? RangeSet.of(add) : this;
-           let cur = new LayerCursor$1(this, null, -1).goto(0), i = 0, spill = [];
-           let builder = new RangeSetBuilder$1();
-           while (cur.value || i < add.length) {
-               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
-                   let range = add[i++];
-                   if (!builder.addInner(range.from, range.to, range.value))
-                       spill.push(range);
-               }
-               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
-                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
-                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
-                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
-                   cur.nextChunk();
-               }
-               else {
-                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
-                       if (!builder.addInner(cur.from, cur.to, cur.value))
-                           spill.push(Range$2.create(cur.from, cur.to, cur.value));
-                   }
-                   cur.next();
-               }
-           }
-           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
-               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
-       }
-       /**
-       Map this range set through a set of changes, return the new set.
-       */
-       map(changes) {
-           if (changes.empty || this.isEmpty)
-               return this;
-           let chunks = [], chunkPos = [], maxPoint = -1;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               let touch = changes.touchesRange(start, start + chunk.length);
-               if (touch === false) {
-                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
-                   chunks.push(chunk);
-                   chunkPos.push(changes.mapPos(start));
-               }
-               else if (touch === true) {
-                   let { mapped, pos } = chunk.map(start, changes);
-                   if (mapped) {
-                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
-                       chunks.push(mapped);
-                       chunkPos.push(pos);
-                   }
-               }
-           }
-           let next = this.nextLayer.map(changes);
-           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
-       }
-       /**
-       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(from, to, f) {
-           if (this.isEmpty)
-               return;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               if (to >= start && from <= start + chunk.length &&
-                   chunk.between(start, from - start, to - start, f) === false)
-                   return;
-           }
-           this.nextLayer.between(from, to, f);
-       }
-       /**
-       Iterate over the ranges in this set, in order, including all
-       ranges that end at or after `from`.
-       */
-       iter(from = 0) {
-           return HeapCursor$1.from([this]).goto(from);
-       }
-       /**
-       @internal
-       */
-       get isEmpty() { return this.nextLayer == this; }
-       /**
-       Iterate over the ranges in a collection of sets, in order,
-       starting from `from`.
-       */
-       static iter(sets, from = 0) {
-           return HeapCursor$1.from(sets).goto(from);
-       }
-       /**
-       Iterate over two groups of sets, calling methods on `comparator`
-       to notify it of possible differences.
-       */
-       static compare(oldSets, newSets, 
-       /**
-       This indicates how the underlying data changed between these
-       ranges, and is needed to synchronize the iteration. `from` and
-       `to` are coordinates in the _new_ space, after these changes.
-       */
-       textDiff, comparator, 
-       /**
-       Can be used to ignore all non-point ranges, and points below
-       the given size. When -1, all ranges are compared.
-       */
-       minPointSize = -1) {
-           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let sharedChunks = findSharedChunks$1(a, b, textDiff);
-           let sideA = new SpanCursor$1(a, sharedChunks, minPointSize);
-           let sideB = new SpanCursor$1(b, sharedChunks, minPointSize);
-           textDiff.iterGaps((fromA, fromB, length) => compare$1(sideA, fromA, sideB, fromB, length, comparator));
-           if (textDiff.empty && textDiff.length == 0)
-               compare$1(sideA, 0, sideB, 0, 0, comparator);
-       }
-       /**
-       Compare the contents of two groups of range sets, returning true
-       if they are equivalent in the given range.
-       */
-       static eq(oldSets, newSets, from = 0, to) {
-           if (to == null)
-               to = 1000000000 /* Far */;
-           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
-           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
-           if (a.length != b.length)
-               return false;
-           if (!a.length)
-               return true;
-           let sharedChunks = findSharedChunks$1(a, b);
-           let sideA = new SpanCursor$1(a, sharedChunks, 0).goto(from), sideB = new SpanCursor$1(b, sharedChunks, 0).goto(from);
-           for (;;) {
-               if (sideA.to != sideB.to ||
-                   !sameValues$1(sideA.active, sideB.active) ||
-                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
-                   return false;
-               if (sideA.to > to)
-                   return true;
-               sideA.next();
-               sideB.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(sets, from, to, iterator, 
-       /**
-       When given and greater than -1, only points of at least this
-       size are taken into account.
-       */
-       minPointSize = -1) {
-           let cursor = new SpanCursor$1(sets, null, minPointSize).goto(from), pos = from;
-           let open = cursor.openStart;
-           for (;;) {
-               let curTo = Math.min(cursor.to, to);
-               if (cursor.point) {
-                   iterator.point(pos, curTo, cursor.point, cursor.activeForPoint(cursor.to), open, cursor.pointRank);
-                   open = cursor.openEnd(curTo) + (cursor.to > curTo ? 1 : 0);
-               }
-               else if (curTo > pos) {
-                   iterator.span(pos, curTo, cursor.active, open);
-                   open = cursor.openEnd(curTo);
-               }
-               if (cursor.to > to)
-                   break;
-               pos = cursor.to;
-               cursor.next();
-           }
-           return open;
-       }
-       /**
-       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(ranges, sort = false) {
-           let build = new RangeSetBuilder$1();
-           for (let range of ranges instanceof Range$2 ? [ranges] : sort ? lazySort$1(ranges) : ranges)
-               build.add(range.from, range.to, range.value);
-           return build.finish();
-       }
-   };
-   /**
-   The empty set of ranges.
-   */
-   RangeSet$1.empty = /*@__PURE__*/new RangeSet$1([], [], null, -1);
-   function lazySort$1(ranges) {
-       if (ranges.length > 1)
-           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
-               let cur = ranges[i];
-               if (cmpRange$1(prev, cur) > 0)
-                   return ranges.slice().sort(cmpRange$1);
-               prev = cur;
-           }
-       return ranges;
-   }
-   RangeSet$1.empty.nextLayer = RangeSet$1.empty;
-   /**
-   A range set builder is a data structure that helps build up a
-   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
-   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
-   */
-   let RangeSetBuilder$1 = class RangeSetBuilder {
-       /**
-       Create an empty builder.
-       */
-       constructor() {
-           this.chunks = [];
-           this.chunkPos = [];
-           this.chunkStart = -1;
-           this.last = null;
-           this.lastFrom = -1000000000 /* Far */;
-           this.lastTo = -1000000000 /* Far */;
-           this.from = [];
-           this.to = [];
-           this.value = [];
-           this.maxPoint = -1;
-           this.setMaxPoint = -1;
-           this.nextLayer = null;
-       }
-       finishChunk(newArrays) {
-           this.chunks.push(new Chunk$1(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;
-           if (newArrays) {
-               this.from = [];
-               this.to = [];
-               this.value = [];
-           }
-       }
-       /**
-       Add a range. Ranges should be added in sorted (by `from` and
-       `value.startSide`) order.
-       */
-       add(from, to, value) {
-           if (!this.addInner(from, to, value))
-               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
-       }
-       /**
-       @internal
-       */
-       addInner(from, to, value) {
-           let diff = from - this.lastTo || value.startSide - this.last.endSide;
-           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
-               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
-           if (diff < 0)
-               return false;
-           if (this.from.length == 250 /* ChunkSize */)
-               this.finishChunk(true);
-           if (this.chunkStart < 0)
-               this.chunkStart = from;
-           this.from.push(from - this.chunkStart);
-           this.to.push(to - this.chunkStart);
-           this.last = value;
-           this.lastFrom = from;
-           this.lastTo = to;
-           this.value.push(value);
-           if (value.point)
-               this.maxPoint = Math.max(this.maxPoint, to - from);
-           return true;
-       }
-       /**
-       @internal
-       */
-       addChunk(from, chunk) {
-           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
-               return false;
-           if (this.from.length)
-               this.finishChunk(true);
-           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
-           this.chunks.push(chunk);
-           this.chunkPos.push(from);
-           let last = chunk.value.length - 1;
-           this.last = chunk.value[last];
-           this.lastFrom = chunk.from[last] + from;
-           this.lastTo = chunk.to[last] + from;
-           return true;
-       }
-       /**
-       Finish the range set. Returns the new set. The builder can't be
-       used anymore after this has been called.
-       */
-       finish() { return this.finishInner(RangeSet$1.empty); }
-       /**
-       @internal
-       */
-       finishInner(next) {
-           if (this.from.length)
-               this.finishChunk(false);
-           if (this.chunks.length == 0)
-               return next;
-           let result = RangeSet$1.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
-           this.from = null; // Make sure further `add` calls produce errors
-           return result;
-       }
-   };
-   function findSharedChunks$1(a, b, textDiff) {
-       let inA = new Map();
-       for (let set of a)
-           for (let i = 0; i < set.chunk.length; i++)
-               if (set.chunk[i].maxPoint <= 0)
-                   inA.set(set.chunk[i], set.chunkPos[i]);
-       let shared = new Set();
-       for (let set of b)
-           for (let i = 0; i < set.chunk.length; i++) {
-               let known = inA.get(set.chunk[i]);
-               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
-                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
-                   shared.add(set.chunk[i]);
-           }
-       return shared;
-   }
-   let LayerCursor$1 = class LayerCursor {
-       constructor(layer, skip, minPoint, rank = 0) {
-           this.layer = layer;
-           this.skip = skip;
-           this.minPoint = minPoint;
-           this.rank = rank;
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       get endSide() { return this.value ? this.value.endSide : 0; }
-       goto(pos, side = -1000000000 /* Far */) {
-           this.chunkIndex = this.rangeIndex = 0;
-           this.gotoInner(pos, side, false);
-           return this;
-       }
-       gotoInner(pos, side, forward) {
-           while (this.chunkIndex < this.layer.chunk.length) {
-               let next = this.layer.chunk[this.chunkIndex];
-               if (!(this.skip && this.skip.has(next) ||
-                   this.layer.chunkEnd(this.chunkIndex) < pos ||
-                   next.maxPoint < this.minPoint))
-                   break;
-               this.chunkIndex++;
-               forward = false;
-           }
-           if (this.chunkIndex < this.layer.chunk.length) {
-               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
-               if (!forward || this.rangeIndex < rangeIndex)
-                   this.setRangeIndex(rangeIndex);
-           }
-           this.next();
-       }
-       forward(pos, side) {
-           if ((this.to - pos || this.endSide - side) < 0)
-               this.gotoInner(pos, side, true);
-       }
-       next() {
-           for (;;) {
-               if (this.chunkIndex == this.layer.chunk.length) {
-                   this.from = this.to = 1000000000 /* Far */;
-                   this.value = null;
-                   break;
-               }
-               else {
-                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
-                   let from = chunkPos + chunk.from[this.rangeIndex];
-                   this.from = from;
-                   this.to = chunkPos + chunk.to[this.rangeIndex];
-                   this.value = chunk.value[this.rangeIndex];
-                   this.setRangeIndex(this.rangeIndex + 1);
-                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
-                       break;
-               }
-           }
-       }
-       setRangeIndex(index) {
-           if (index == this.layer.chunk[this.chunkIndex].value.length) {
-               this.chunkIndex++;
-               if (this.skip) {
-                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
-                       this.chunkIndex++;
-               }
-               this.rangeIndex = 0;
-           }
-           else {
-               this.rangeIndex = index;
-           }
-       }
-       nextChunk() {
-           this.chunkIndex++;
-           this.rangeIndex = 0;
-           this.next();
-       }
-       compare(other) {
-           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
-               this.to - other.to || this.endSide - other.endSide;
-       }
-   };
-   let HeapCursor$1 = class HeapCursor {
-       constructor(heap) {
-           this.heap = heap;
-       }
-       static from(sets, skip = null, minPoint = -1) {
-           let heap = [];
-           for (let i = 0; i < sets.length; i++) {
-               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
-                   if (cur.maxPoint >= minPoint)
-                       heap.push(new LayerCursor$1(cur, skip, minPoint, i));
-               }
-           }
-           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       goto(pos, side = -1000000000 /* Far */) {
-           for (let cur of this.heap)
-               cur.goto(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble$1(this.heap, i);
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           for (let cur of this.heap)
-               cur.forward(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble$1(this.heap, i);
-           if ((this.to - pos || this.value.endSide - side) < 0)
-               this.next();
-       }
-       next() {
-           if (this.heap.length == 0) {
-               this.from = this.to = 1000000000 /* Far */;
-               this.value = null;
-               this.rank = -1;
-           }
-           else {
-               let top = this.heap[0];
-               this.from = top.from;
-               this.to = top.to;
-               this.value = top.value;
-               this.rank = top.rank;
-               if (top.value)
-                   top.next();
-               heapBubble$1(this.heap, 0);
-           }
-       }
-   };
-   function heapBubble$1(heap, index) {
-       for (let cur = heap[index];;) {
-           let childIndex = (index << 1) + 1;
-           if (childIndex >= heap.length)
-               break;
-           let child = heap[childIndex];
-           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
-               child = heap[childIndex + 1];
-               childIndex++;
-           }
-           if (cur.compare(child) < 0)
-               break;
-           heap[childIndex] = cur;
-           heap[index] = child;
-           index = childIndex;
-       }
-   }
-   let SpanCursor$1 = class SpanCursor {
-       constructor(sets, skip, minPoint) {
-           this.minPoint = minPoint;
-           this.active = [];
-           this.activeTo = [];
-           this.activeRank = [];
-           this.minActive = -1;
-           // A currently active point range, if any
-           this.point = null;
-           this.pointFrom = 0;
-           this.pointRank = 0;
-           this.to = -1000000000 /* Far */;
-           this.endSide = 0;
-           this.openStart = -1;
-           this.cursor = HeapCursor$1.from(sets, skip, minPoint);
-       }
-       goto(pos, side = -1000000000 /* Far */) {
-           this.cursor.goto(pos, side);
-           this.active.length = this.activeTo.length = this.activeRank.length = 0;
-           this.minActive = -1;
-           this.to = pos;
-           this.endSide = side;
-           this.openStart = -1;
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
-               this.removeActive(this.minActive);
-           this.cursor.forward(pos, side);
-       }
-       removeActive(index) {
-           remove$1(this.active, index);
-           remove$1(this.activeTo, index);
-           remove$1(this.activeRank, index);
-           this.minActive = findMinIndex$1(this.active, this.activeTo);
-       }
-       addActive(trackOpen) {
-           let i = 0, { value, to, rank } = this.cursor;
-           while (i < this.activeRank.length && this.activeRank[i] <= rank)
-               i++;
-           insert$1(this.active, i, value);
-           insert$1(this.activeTo, i, to);
-           insert$1(this.activeRank, i, rank);
-           if (trackOpen)
-               insert$1(trackOpen, i, this.cursor.from);
-           this.minActive = findMinIndex$1(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 from = this.to, wasPoint = this.point;
-           this.point = null;
-           let trackOpen = this.openStart < 0 ? [] : null, trackExtra = 0;
-           for (;;) {
-               let a = this.minActive;
-               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
-                   if (this.activeTo[a] > from) {
-                       this.to = this.activeTo[a];
-                       this.endSide = this.active[a].endSide;
-                       break;
-                   }
-                   this.removeActive(a);
-                   if (trackOpen)
-                       remove$1(trackOpen, a);
-               }
-               else if (!this.cursor.value) {
-                   this.to = this.endSide = 1000000000 /* Far */;
-                   break;
-               }
-               else if (this.cursor.from > from) {
-                   this.to = this.cursor.from;
-                   this.endSide = this.cursor.startSide;
-                   break;
-               }
-               else {
-                   let nextVal = this.cursor.value;
-                   if (!nextVal.point) { // Opening a range
-                       this.addActive(trackOpen);
-                       this.cursor.next();
-                   }
-                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
-                       // Ignore any non-empty points that end precisely at the end of the prev point
-                       this.cursor.next();
-                   }
-                   else { // New point
-                       this.point = nextVal;
-                       this.pointFrom = this.cursor.from;
-                       this.pointRank = this.cursor.rank;
-                       this.to = this.cursor.to;
-                       this.endSide = nextVal.endSide;
-                       if (this.cursor.from < from)
-                           trackExtra = 1;
-                       this.cursor.next();
-                       this.forward(this.to, this.endSide);
-                       break;
-                   }
-               }
-           }
-           if (trackOpen) {
-               let openStart = 0;
-               while (openStart < trackOpen.length && trackOpen[openStart] < from)
-                   openStart++;
-               this.openStart = openStart + trackExtra;
-           }
-       }
-       activeForPoint(to) {
-           if (!this.active.length)
-               return this.active;
-           let active = [];
-           for (let i = this.active.length - 1; i >= 0; i--) {
-               if (this.activeRank[i] < this.pointRank)
-                   break;
-               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
-                   active.push(this.active[i]);
-           }
-           return active.reverse();
-       }
-       openEnd(to) {
-           let open = 0;
-           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
-               open++;
-           return open;
-       }
-   };
-   function compare$1(a, startA, b, startB, length, comparator) {
-       a.goto(startA);
-       b.goto(startB);
-       let endB = startB + length;
-       let pos = startB, dPos = startB - startA;
-       for (;;) {
-           let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;
-           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
-           if (a.point || b.point) {
-               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
-                   sameValues$1(a.activeForPoint(a.to + dPos), b.activeForPoint(b.to))))
-                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
-           }
-           else {
-               if (clipEnd > pos && !sameValues$1(a.active, b.active))
-                   comparator.compareRange(pos, clipEnd, a.active, b.active);
-           }
-           if (end > endB)
-               break;
-           pos = end;
-           if (diff <= 0)
-               a.next();
-           if (diff >= 0)
-               b.next();
-       }
-   }
-   function sameValues$1(a, b) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (a[i] != b[i] && !a[i].eq(b[i]))
-               return false;
-       return true;
-   }
-   function remove$1(array, index) {
-       for (let i = index, e = array.length - 1; i < e; i++)
-           array[i] = array[i + 1];
-       array.pop();
-   }
-   function insert$1(array, index, value) {
-       for (let i = array.length - 1; i >= index; i--)
-           array[i + 1] = array[i];
-       array[index] = value;
-   }
-   function findMinIndex$1(value, array) {
-       let found = -1, foundPos = 1000000000 /* Far */;
-       for (let i = 0; i < array.length; i++)
-           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
-               found = i;
-               foundPos = array[i];
-           }
-       return found;
-   }
-   /**
-   Find the offset that corresponds to the given column position in a
-   string, taking extending characters and tab size into account. By
-   default, the string length is returned when it is too short to
-   reach the column. Pass `strict` true to make it return -1 in that
-   situation.
-   */
-   function findColumn$1(string, col, tabSize, strict) {
-       for (let i = 0, n = 0;;) {
-           if (n >= col)
-               return i;
-           if (i == string.length)
-               break;
-           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
-           i = findClusterBreak$2(string, i);
-       }
-       return strict === true ? -1 : string.length;
-   }
-
-   function getSelection$1(root) {
-       let target;
-       // Browsers differ on whether shadow roots have a getSelection
-       // method. If it exists, use that, otherwise, call it on the
-       // document.
-       if (root.nodeType == 11) { // Shadow root
-           target = root.getSelection ? root : root.ownerDocument;
-       }
-       else {
-           target = root;
-       }
-       return target.getSelection();
-   }
-   function contains$1(dom, node) {
-       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
-   }
-   function deepActiveElement() {
-       let elt = document.activeElement;
-       while (elt && elt.shadowRoot)
-           elt = elt.shadowRoot.activeElement;
-       return elt;
-   }
-   function hasSelection$1(dom, selection) {
-       if (!selection.anchorNode)
-           return false;
-       try {
-           // Firefox will raise 'permission denied' errors when accessing
-           // properties of `sel.anchorNode` when it's in a generated CSS
-           // element.
-           return contains$1(dom, selection.anchorNode);
-       }
-       catch (_) {
-           return false;
-       }
-   }
-   function clientRectsFor$1(dom) {
-       if (dom.nodeType == 3)
-           return textRange$1(dom, 0, dom.nodeValue.length).getClientRects();
-       else if (dom.nodeType == 1)
-           return dom.getClientRects();
-       else
-           return [];
-   }
-   // Scans forward and backward through DOM positions equivalent to the
-   // given one to see if the two are in the same place (i.e. after a
-   // text node vs at the end of that text node)
-   function isEquivalentPosition$1(node, off, targetNode, targetOff) {
-       return targetNode ? (scanFor$1(node, off, targetNode, targetOff, -1) ||
-           scanFor$1(node, off, targetNode, targetOff, 1)) : false;
-   }
-   function domIndex$1(node) {
-       for (var index = 0;; index++) {
-           node = node.previousSibling;
-           if (!node)
-               return index;
-       }
-   }
-   function scanFor$1(node, off, targetNode, targetOff, dir) {
-       for (;;) {
-           if (node == targetNode && off == targetOff)
-               return true;
-           if (off == (dir < 0 ? 0 : maxOffset$1(node))) {
-               if (node.nodeName == "DIV")
-                   return false;
-               let parent = node.parentNode;
-               if (!parent || parent.nodeType != 1)
-                   return false;
-               off = domIndex$1(node) + (dir < 0 ? 0 : 1);
-               node = parent;
-           }
-           else if (node.nodeType == 1) {
-               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
-               if (node.nodeType == 1 && node.contentEditable == "false")
-                   return false;
-               off = dir < 0 ? maxOffset$1(node) : 0;
-           }
-           else {
-               return false;
-           }
-       }
-   }
-   function maxOffset$1(node) {
-       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
-   }
-   const Rect0 = { left: 0, right: 0, top: 0, bottom: 0 };
-   function flattenRect$1(rect, left) {
-       let x = left ? rect.left : rect.right;
-       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
-   }
-   function windowRect$1(win) {
-       return { left: 0, right: win.innerWidth,
-           top: 0, bottom: win.innerHeight };
-   }
-   function scrollRectIntoView$1(dom, rect, side, x, y, xMargin, yMargin, ltr) {
-       let doc = dom.ownerDocument, win = doc.defaultView;
-       for (let cur = dom; cur;) {
-           if (cur.nodeType == 1) { // Element
-               let bounding, top = cur == doc.body;
-               if (top) {
-                   bounding = windowRect$1(win);
-               }
-               else {
-                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
-                       cur = cur.parentNode;
-                       continue;
-                   }
-                   let rect = cur.getBoundingClientRect();
-                   // Make sure scrollbar width isn't included in the rectangle
-                   bounding = { left: rect.left, right: rect.left + cur.clientWidth,
-                       top: rect.top, bottom: rect.top + cur.clientHeight };
-               }
-               let moveX = 0, moveY = 0;
-               if (y == "nearest") {
-                   if (rect.top < bounding.top) {
-                       moveY = -(bounding.top - rect.top + yMargin);
-                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
-                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
-                   }
-                   else if (rect.bottom > bounding.bottom) {
-                       moveY = rect.bottom - bounding.bottom + yMargin;
-                       if (side < 0 && (rect.top - moveY) < bounding.top)
-                           moveY = -(bounding.top + moveY - rect.top + yMargin);
-                   }
-               }
-               else {
-                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
-                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
-                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
-                           rect.bottom - boundingHeight + yMargin;
-                   moveY = targetTop - bounding.top;
-               }
-               if (x == "nearest") {
-                   if (rect.left < bounding.left) {
-                       moveX = -(bounding.left - rect.left + xMargin);
-                       if (side > 0 && rect.right > bounding.right + moveX)
-                           moveX = rect.right - bounding.right + moveX + xMargin;
-                   }
-                   else if (rect.right > bounding.right) {
-                       moveX = rect.right - bounding.right + xMargin;
-                       if (side < 0 && rect.left < bounding.left + moveX)
-                           moveX = -(bounding.left + moveX - rect.left + xMargin);
-                   }
-               }
-               else {
-                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
-                       (x == "start") == ltr ? rect.left - xMargin :
-                           rect.right - (bounding.right - bounding.left) + xMargin;
-                   moveX = targetLeft - bounding.left;
-               }
-               if (moveX || moveY) {
-                   if (top) {
-                       win.scrollBy(moveX, moveY);
-                   }
-                   else {
-                       if (moveY) {
-                           let start = cur.scrollTop;
-                           cur.scrollTop += moveY;
-                           moveY = cur.scrollTop - start;
-                       }
-                       if (moveX) {
-                           let start = cur.scrollLeft;
-                           cur.scrollLeft += moveX;
-                           moveX = cur.scrollLeft - start;
-                       }
-                       rect = { left: rect.left - moveX, top: rect.top - moveY,
-                           right: rect.right - moveX, bottom: rect.bottom - moveY };
-                   }
-               }
-               if (top)
-                   break;
-               cur = cur.assignedSlot || cur.parentNode;
-               x = y = "nearest";
-           }
-           else if (cur.nodeType == 11) { // A shadow root
-               cur = cur.host;
-           }
-           else {
-               break;
-           }
-       }
-   }
-   let DOMSelectionState$1 = class DOMSelectionState {
-       constructor() {
-           this.anchorNode = null;
-           this.anchorOffset = 0;
-           this.focusNode = null;
-           this.focusOffset = 0;
-       }
-       eq(domSel) {
-           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
-               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
-       }
-       setRange(range) {
-           this.set(range.anchorNode, range.anchorOffset, range.focusNode, range.focusOffset);
-       }
-       set(anchorNode, anchorOffset, focusNode, focusOffset) {
-           this.anchorNode = anchorNode;
-           this.anchorOffset = anchorOffset;
-           this.focusNode = focusNode;
-           this.focusOffset = focusOffset;
-       }
-   };
-   let preventScrollSupported$1 = null;
-   // Feature-detects support for .focus({preventScroll: true}), and uses
-   // a fallback kludge when not supported.
-   function focusPreventScroll$1(dom) {
-       if (dom.setActive)
-           return dom.setActive(); // in IE
-       if (preventScrollSupported$1)
-           return dom.focus(preventScrollSupported$1);
-       let stack = [];
-       for (let cur = dom; cur; cur = cur.parentNode) {
-           stack.push(cur, cur.scrollTop, cur.scrollLeft);
-           if (cur == cur.ownerDocument)
-               break;
-       }
-       dom.focus(preventScrollSupported$1 == null ? {
-           get preventScroll() {
-               preventScrollSupported$1 = { preventScroll: true };
-               return true;
-           }
-       } : undefined);
-       if (!preventScrollSupported$1) {
-           preventScrollSupported$1 = false;
-           for (let i = 0; i < stack.length;) {
-               let elt = stack[i++], top = stack[i++], left = stack[i++];
-               if (elt.scrollTop != top)
-                   elt.scrollTop = top;
-               if (elt.scrollLeft != left)
-                   elt.scrollLeft = left;
-           }
-       }
-   }
-   let scratchRange$1;
-   function textRange$1(node, from, to = from) {
-       let range = scratchRange$1 || (scratchRange$1 = document.createRange());
-       range.setEnd(node, to);
-       range.setStart(node, from);
-       return range;
-   }
-   function dispatchKey$1(elt, name, code) {
-       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
-       let down = new KeyboardEvent("keydown", options);
-       down.synthetic = true;
-       elt.dispatchEvent(down);
-       let up = new KeyboardEvent("keyup", options);
-       up.synthetic = true;
-       elt.dispatchEvent(up);
-       return down.defaultPrevented || up.defaultPrevented;
-   }
-   function getRoot$1(node) {
-       while (node) {
-           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
-               return node;
-           node = node.assignedSlot || node.parentNode;
-       }
-       return null;
-   }
-   function clearAttributes$1(node) {
-       while (node.attributes.length)
-           node.removeAttributeNode(node.attributes[0]);
-   }
-
-   let DOMPos$1 = class DOMPos {
-       constructor(node, offset, precise = true) {
-           this.node = node;
-           this.offset = offset;
-           this.precise = precise;
-       }
-       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex$1(dom), precise); }
-       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex$1(dom) + 1, precise); }
-   };
-   const noChildren$1 = [];
-   let ContentView$1 = class ContentView {
-       constructor() {
-           this.parent = null;
-           this.dom = null;
-           this.dirty = 2 /* Node */;
-       }
-       get editorView() {
-           if (!this.parent)
-               throw new Error("Accessing view in orphan content view");
-           return this.parent.editorView;
-       }
-       get overrideDOMText() { return null; }
-       get posAtStart() {
-           return this.parent ? this.parent.posBefore(this) : 0;
-       }
-       get posAtEnd() {
-           return this.posAtStart + this.length;
-       }
-       posBefore(view) {
-           let pos = this.posAtStart;
-           for (let child of this.children) {
-               if (child == view)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-           throw new RangeError("Invalid child in posBefore");
-       }
-       posAfter(view) {
-           return this.posBefore(view) + view.length;
-       }
-       // Will return a rectangle directly before (when side < 0), after
-       // (side > 0) or directly on (when the browser supports it) the
-       // given position.
-       coordsAt(_pos, _side) { return null; }
-       sync(track) {
-           if (this.dirty & 2 /* Node */) {
-               let parent = this.dom;
-               let prev = null, next;
-               for (let child of this.children) {
-                   if (child.dirty) {
-                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
-                           let contentView = ContentView.get(next);
-                           if (!contentView || !contentView.parent && contentView.constructor == child.constructor)
-                               child.reuseDOM(next);
-                       }
-                       child.sync(track);
-                       child.dirty = 0 /* Not */;
-                   }
-                   next = prev ? prev.nextSibling : parent.firstChild;
-                   if (track && !track.written && track.node == parent && next != child.dom)
-                       track.written = true;
-                   if (child.dom.parentNode == parent) {
-                       while (next && next != child.dom)
-                           next = rm$1$1(next);
-                   }
-                   else {
-                       parent.insertBefore(child.dom, next);
-                   }
-                   prev = child.dom;
-               }
-               next = prev ? prev.nextSibling : parent.firstChild;
-               if (next && track && track.node == parent)
-                   track.written = true;
-               while (next)
-                   next = rm$1$1(next);
-           }
-           else if (this.dirty & 1 /* Child */) {
-               for (let child of this.children)
-                   if (child.dirty) {
-                       child.sync(track);
-                       child.dirty = 0 /* Not */;
-                   }
-           }
-       }
-       reuseDOM(_dom) { }
-       localPosFromDOM(node, offset) {
-           let after;
-           if (node == this.dom) {
-               after = this.dom.childNodes[offset];
-           }
-           else {
-               let bias = maxOffset$1(node) == 0 ? 0 : offset == 0 ? -1 : 1;
-               for (;;) {
-                   let parent = node.parentNode;
-                   if (parent == this.dom)
-                       break;
-                   if (bias == 0 && parent.firstChild != parent.lastChild) {
-                       if (node == parent.firstChild)
-                           bias = -1;
-                       else
-                           bias = 1;
-                   }
-                   node = parent;
-               }
-               if (bias < 0)
-                   after = node;
-               else
-                   after = node.nextSibling;
-           }
-           if (after == this.dom.firstChild)
-               return 0;
-           while (after && !ContentView.get(after))
-               after = after.nextSibling;
-           if (!after)
-               return this.length;
-           for (let i = 0, pos = 0;; i++) {
-               let child = this.children[i];
-               if (child.dom == after)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-       }
-       domBoundsAround(from, to, offset = 0) {
-           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
-           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos < from && end > to)
-                   return child.domBoundsAround(from, to, pos);
-               if (end >= from && fromI == -1) {
-                   fromI = i;
-                   fromStart = pos;
-               }
-               if (pos > to && child.dom.parentNode == this.dom) {
-                   toI = i;
-                   toEnd = prevEnd;
-                   break;
-               }
-               prevEnd = end;
-               pos = end + child.breakAfter;
-           }
-           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
-               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
-               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
-       }
-       markDirty(andParent = false) {
-           this.dirty |= 2 /* Node */;
-           this.markParentsDirty(andParent);
-       }
-       markParentsDirty(childList) {
-           for (let parent = this.parent; parent; parent = parent.parent) {
-               if (childList)
-                   parent.dirty |= 2 /* Node */;
-               if (parent.dirty & 1 /* Child */)
-                   return;
-               parent.dirty |= 1 /* Child */;
-               childList = false;
-           }
-       }
-       setParent(parent) {
-           if (this.parent != parent) {
-               this.parent = parent;
-               if (this.dirty)
-                   this.markParentsDirty(true);
-           }
-       }
-       setDOM(dom) {
-           if (this.dom)
-               this.dom.cmView = null;
-           this.dom = dom;
-           dom.cmView = this;
-       }
-       get rootView() {
-           for (let v = this;;) {
-               let parent = v.parent;
-               if (!parent)
-                   return v;
-               v = parent;
-           }
-       }
-       replaceChildren(from, to, children = noChildren$1) {
-           this.markDirty();
-           for (let i = from; i < to; i++) {
-               let child = this.children[i];
-               if (child.parent == this)
-                   child.destroy();
-           }
-           this.children.splice(from, to - from, ...children);
-           for (let i = 0; i < children.length; i++)
-               children[i].setParent(this);
-       }
-       ignoreMutation(_rec) { return false; }
-       ignoreEvent(_event) { return false; }
-       childCursor(pos = this.length) {
-           return new ChildCursor$1(this.children, pos, this.children.length);
-       }
-       childPos(pos, bias = 1) {
-           return this.childCursor().findPos(pos, bias);
-       }
-       toString() {
-           let name = this.constructor.name.replace("View", "");
-           return name + (this.children.length ? "(" + this.children.join() + ")" :
-               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
-               (this.breakAfter ? "#" : "");
-       }
-       static get(node) { return node.cmView; }
-       get isEditable() { return true; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           return false;
-       }
-       become(other) { return false; }
-       // When this is a zero-length view with a side, this should return a
-       // number <= 0 to indicate it is before its position, or a
-       // number > 0 when after its position.
-       getSide() { return 0; }
-       destroy() {
-           this.parent = null;
-       }
-   };
-   ContentView$1.prototype.breakAfter = 0;
-   // Remove a DOM node and return its next sibling.
-   function rm$1$1(dom) {
-       let next = dom.nextSibling;
-       dom.parentNode.removeChild(dom);
-       return next;
-   }
-   let ChildCursor$1 = class ChildCursor {
-       constructor(children, pos, i) {
-           this.children = children;
-           this.pos = pos;
-           this.i = i;
-           this.off = 0;
-       }
-       findPos(pos, bias = 1) {
-           for (;;) {
-               if (pos > this.pos || pos == this.pos &&
-                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
-                   this.off = pos - this.pos;
-                   return this;
-               }
-               let next = this.children[--this.i];
-               this.pos -= next.length + next.breakAfter;
-           }
-       }
-   };
-   function replaceRange$1(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
-       let { children } = parent;
-       let before = children.length ? children[fromI] : null;
-       let last = insert.length ? insert[insert.length - 1] : null;
-       let breakAtEnd = last ? last.breakAfter : breakAtStart;
-       // Change within a single child
-       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
-           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
-           return;
-       if (toI < children.length) {
-           let after = children[toI];
-           // Make sure the end of the child after the update is preserved in `after`
-           if (after && toOff < after.length) {
-               // If we're splitting a child, separate part of it to avoid that
-               // being mangled when updating the child before the update.
-               if (fromI == toI) {
-                   after = after.split(toOff);
-                   toOff = 0;
-               }
-               // If the element after the replacement should be merged with
-               // the last replacing element, update `content`
-               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
-                   insert[insert.length - 1] = after;
-               }
-               else {
-                   // Remove the start of the after element, if necessary, and
-                   // add it to `content`.
-                   if (toOff)
-                       after.merge(0, toOff, null, false, 0, openEnd);
-                   insert.push(after);
-               }
-           }
-           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
-               // The element at `toI` is entirely covered by this range.
-               // Preserve its line break, if any.
-               if (last)
-                   last.breakAfter = 1;
-               else
-                   breakAtStart = 1;
-           }
-           // Since we've handled the next element from the current elements
-           // now, make sure `toI` points after that.
-           toI++;
-       }
-       if (before) {
-           before.breakAfter = breakAtStart;
-           if (fromOff > 0) {
-               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
-                   before.breakAfter = insert.shift().breakAfter;
-               }
-               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
-                   before.merge(fromOff, before.length, null, false, openStart, 0);
-               }
-               fromI++;
-           }
-       }
-       // Try to merge widgets on the boundaries of the replacement
-       while (fromI < toI && insert.length) {
-           if (children[toI - 1].become(insert[insert.length - 1])) {
-               toI--;
-               insert.pop();
-               openEnd = insert.length ? 0 : openStart;
-           }
-           else if (children[fromI].become(insert[0])) {
-               fromI++;
-               insert.shift();
-               openStart = insert.length ? 0 : openEnd;
-           }
-           else {
-               break;
-           }
-       }
-       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
-           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
-           fromI--;
-       if (fromI < toI || insert.length)
-           parent.replaceChildren(fromI, toI, insert);
-   }
-   function mergeChildrenInto$1(parent, from, to, insert, openStart, openEnd) {
-       let cur = parent.childCursor();
-       let { i: toI, off: toOff } = cur.findPos(to, 1);
-       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
-       let dLen = from - to;
-       for (let view of insert)
-           dLen += view.length;
-       parent.length += dLen;
-       replaceRange$1(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
-   }
-
-   let nav$1 = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
-   let doc$1 = typeof document != "undefined" ? document : { documentElement: { style: {} } };
-   const ie_edge$1 = /*@__PURE__*//Edge\/(\d+)/.exec(nav$1.userAgent);
-   const ie_upto10$1 = /*@__PURE__*//MSIE \d/.test(nav$1.userAgent);
-   const ie_11up$1 = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav$1.userAgent);
-   const ie$1 = !!(ie_upto10$1 || ie_11up$1 || ie_edge$1);
-   const gecko$1 = !ie$1 && /*@__PURE__*//gecko\/(\d+)/i.test(nav$1.userAgent);
-   const chrome$1 = !ie$1 && /*@__PURE__*//Chrome\/(\d+)/.exec(nav$1.userAgent);
-   const webkit$1 = "webkitFontSmoothing" in doc$1.documentElement.style;
-   const safari$1 = !ie$1 && /*@__PURE__*//Apple Computer/.test(nav$1.vendor);
-   const ios$1 = safari$1 && (/*@__PURE__*//Mobile\/\w+/.test(nav$1.userAgent) || nav$1.maxTouchPoints > 2);
-   var browser$1 = {
-       mac: ios$1 || /*@__PURE__*//Mac/.test(nav$1.platform),
-       windows: /*@__PURE__*//Win/.test(nav$1.platform),
-       linux: /*@__PURE__*//Linux|X11/.test(nav$1.platform),
-       ie: ie$1,
-       ie_version: ie_upto10$1 ? doc$1.documentMode || 6 : ie_11up$1 ? +ie_11up$1[1] : ie_edge$1 ? +ie_edge$1[1] : 0,
-       gecko: gecko$1,
-       gecko_version: gecko$1 ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav$1.userAgent) || [0, 0])[1] : 0,
-       chrome: !!chrome$1,
-       chrome_version: chrome$1 ? +chrome$1[1] : 0,
-       ios: ios$1,
-       android: /*@__PURE__*//Android\b/.test(nav$1.userAgent),
-       webkit: webkit$1,
-       safari: safari$1,
-       webkit_version: webkit$1 ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
-       tabSize: doc$1.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
-   };
-
-   const MaxJoinLen$1 = 256;
-   let TextView$1 = class TextView extends ContentView$1 {
-       constructor(text) {
-           super();
-           this.text = text;
-       }
-       get length() { return this.text.length; }
-       createDOM(textDOM) {
-           this.setDOM(textDOM || document.createTextNode(this.text));
-       }
-       sync(track) {
-           if (!this.dom)
-               this.createDOM();
-           if (this.dom.nodeValue != this.text) {
-               if (track && track.node == this.dom)
-                   track.written = true;
-               this.dom.nodeValue = this.text;
-           }
-       }
-       reuseDOM(dom) {
-           if (dom.nodeType == 3)
-               this.createDOM(dom);
-       }
-       merge(from, to, source) {
-           if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen$1))
-               return false;
-           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = new TextView(this.text.slice(from));
-           this.text = this.text.slice(0, from);
-           this.markDirty();
-           return result;
-       }
-       localPosFromDOM(node, offset) {
-           return node == this.dom ? offset : offset ? this.text.length : 0;
-       }
-       domAtPos(pos) { return new DOMPos$1(this.dom, pos); }
-       domBoundsAround(_from, _to, offset) {
-           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
-       }
-       coordsAt(pos, side) {
-           return textCoords$1(this.dom, pos, side);
-       }
-   };
-   let MarkView$1 = class MarkView extends ContentView$1 {
-       constructor(mark, children = [], length = 0) {
-           super();
-           this.mark = mark;
-           this.children = children;
-           this.length = length;
-           for (let ch of children)
-               ch.setParent(this);
-       }
-       setAttrs(dom) {
-           clearAttributes$1(dom);
-           if (this.mark.class)
-               dom.className = this.mark.class;
-           if (this.mark.attrs)
-               for (let name in this.mark.attrs)
-                   dom.setAttribute(name, this.mark.attrs[name]);
-           return dom;
-       }
-       reuseDOM(node) {
-           if (node.nodeName == this.mark.tagName.toUpperCase()) {
-               this.setDOM(node);
-               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
-           }
-       }
-       sync(track) {
-           if (!this.dom)
-               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
-           else if (this.dirty & 4 /* Attrs */)
-               this.setAttrs(this.dom);
-           super.sync(track);
-       }
-       merge(from, to, source, _hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
-               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
-               return false;
-           mergeChildrenInto$1(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = [], off = 0, detachFrom = -1, i = 0;
-           for (let elt of this.children) {
-               let end = off + elt.length;
-               if (end > from)
-                   result.push(off < from ? elt.split(from - off) : elt);
-               if (detachFrom < 0 && off >= from)
-                   detachFrom = i;
-               off = end;
-               i++;
-           }
-           let length = this.length - from;
-           this.length = from;
-           if (detachFrom > -1) {
-               this.children.length = detachFrom;
-               this.markDirty();
-           }
-           return new MarkView(this.mark, result, length);
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos$1(this.dom, this.children, pos);
-       }
-       coordsAt(pos, side) {
-           return coordsInChildren$1(this, pos, side);
-       }
-   };
-   function textCoords$1(text, pos, side) {
-       let length = text.nodeValue.length;
-       if (pos > length)
-           pos = length;
-       let from = pos, to = pos, flatten = 0;
-       if (pos == 0 && side < 0 || pos == length && side >= 0) {
-           if (!(browser$1.chrome || browser$1.gecko)) { // These browsers reliably return valid rectangles for empty ranges
-               if (pos) {
-                   from--;
-                   flatten = 1;
-               } // FIXME this is wrong in RTL text
-               else if (to < length) {
-                   to++;
-                   flatten = -1;
-               }
-           }
-       }
-       else {
-           if (side < 0)
-               from--;
-           else if (to < length)
-               to++;
-       }
-       let rects = textRange$1(text, from, to).getClientRects();
-       if (!rects.length)
-           return Rect0;
-       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
-       if (browser$1.safari && !flatten && rect.width == 0)
-           rect = Array.prototype.find.call(rects, r => r.width) || rect;
-       return flatten ? flattenRect$1(rect, flatten < 0) : rect || null;
-   }
-   // Also used for collapsed ranges that don't have a placeholder widget!
-   let WidgetView$1 = class WidgetView extends ContentView$1 {
-       constructor(widget, length, side) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.side = side;
-           this.prevWidget = null;
-       }
-       static create(widget, length, side) {
-           return new (widget.customView || WidgetView)(widget, length, side);
-       }
-       split(from) {
-           let result = WidgetView.create(this.widget, this.length - from, this.side);
-           this.length -= from;
-           return result;
-       }
-       sync() {
-           if (!this.dom || !this.widget.updateDOM(this.dom)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(this.editorView));
-               this.dom.contentEditable = "false";
-           }
-       }
-       getSide() { return this.side; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       become(other) {
-           if (other.length == this.length && other instanceof WidgetView && other.side == this.side) {
-               if (this.widget.constructor == other.widget.constructor) {
-                   if (!this.widget.eq(other.widget))
-                       this.markDirty(true);
-                   if (this.dom && !this.prevWidget)
-                       this.prevWidget = this.widget;
-                   this.widget = other.widget;
-                   return true;
-               }
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       get overrideDOMText() {
-           if (this.length == 0)
-               return Text$1.empty;
-           let top = this;
-           while (top.parent)
-               top = top.parent;
-           let view = top.editorView, text = view && view.state.doc, start = this.posAtStart;
-           return text ? text.slice(start, start + this.length) : Text$1.empty;
-       }
-       domAtPos(pos) {
-           return pos == 0 ? DOMPos$1.before(this.dom) : DOMPos$1.after(this.dom, pos == this.length);
-       }
-       domBoundsAround() { return null; }
-       coordsAt(pos, side) {
-           let rects = this.dom.getClientRects(), rect = null;
-           if (!rects.length)
-               return Rect0;
-           for (let i = pos > 0 ? rects.length - 1 : 0;; i += (pos > 0 ? -1 : 1)) {
-               rect = rects[i];
-               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
-                   break;
-           }
-           return (pos == 0 && side > 0 || pos == this.length && side <= 0) ? rect : flattenRect$1(rect, pos == 0);
-       }
-       get isEditable() { return false; }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-   };
-   class CompositionView extends WidgetView$1 {
-       domAtPos(pos) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return new DOMPos$1(text, Math.min(pos, text.nodeValue.length));
-           return scanCompositionTree(pos, 0, topView, text, (v, p) => v.domAtPos(p), p => new DOMPos$1(text, Math.min(p, text.nodeValue.length)));
-       }
-       sync() { this.setDOM(this.widget.toDOM()); }
-       localPosFromDOM(node, offset) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return Math.min(offset, this.length);
-           return posFromDOMInCompositionTree(node, offset, topView, text);
-       }
-       ignoreMutation() { return false; }
-       get overrideDOMText() { return null; }
-       coordsAt(pos, side) {
-           let { topView, text } = this.widget;
-           if (!topView)
-               return textCoords$1(text, pos, side);
-           return scanCompositionTree(pos, side, topView, text, (v, pos, side) => v.coordsAt(pos, side), (pos, side) => textCoords$1(text, pos, side));
-       }
-       destroy() {
-           var _a;
-           super.destroy();
-           (_a = this.widget.topView) === null || _a === void 0 ? void 0 : _a.destroy();
-       }
-       get isEditable() { return true; }
-   }
-   // Uses the old structure of a chunk of content view frozen for
-   // composition to try and find a reasonable DOM location for the given
-   // offset.
-   function scanCompositionTree(pos, side, view, text, enterView, fromText) {
-       if (view instanceof MarkView$1) {
-           for (let child of view.children) {
-               let hasComp = contains$1(child.dom, text);
-               let len = hasComp ? text.nodeValue.length : child.length;
-               if (pos < len || pos == len && child.getSide() <= 0)
-                   return hasComp ? scanCompositionTree(pos, side, child, text, enterView, fromText) : enterView(child, pos, side);
-               pos -= len;
-           }
-           return enterView(view, view.length, -1);
-       }
-       else if (view.dom == text) {
-           return fromText(pos, side);
-       }
-       else {
-           return enterView(view, pos, side);
-       }
-   }
-   function posFromDOMInCompositionTree(node, offset, view, text) {
-       if (view instanceof MarkView$1) {
-           for (let child of view.children) {
-               let pos = 0, hasComp = contains$1(child.dom, text);
-               if (contains$1(child.dom, node))
-                   return pos + (hasComp ? posFromDOMInCompositionTree(node, offset, child, text) : child.localPosFromDOM(node, offset));
-               pos += hasComp ? text.nodeValue.length : child.length;
-           }
-       }
-       else if (view.dom == text) {
-           return Math.min(offset, text.nodeValue.length);
-       }
-       return view.localPosFromDOM(node, offset);
-   }
-   // These are drawn around uneditable widgets to avoid a number of
-   // browser bugs that show up when the cursor is directly next to
-   // uneditable inline content.
-   let WidgetBufferView$1 = class WidgetBufferView extends ContentView$1 {
-       constructor(side) {
-           super();
-           this.side = side;
-       }
-       get length() { return 0; }
-       merge() { return false; }
-       become(other) {
-           return other instanceof WidgetBufferView && other.side == this.side;
-       }
-       split() { return new WidgetBufferView(this.side); }
-       sync() {
-           if (!this.dom) {
-               let dom = document.createElement("img");
-               dom.className = "cm-widgetBuffer";
-               dom.setAttribute("aria-hidden", "true");
-               this.setDOM(dom);
-           }
-       }
-       getSide() { return this.side; }
-       domAtPos(pos) { return DOMPos$1.before(this.dom); }
-       localPosFromDOM() { return 0; }
-       domBoundsAround() { return null; }
-       coordsAt(pos) {
-           let imgRect = this.dom.getBoundingClientRect();
-           // Since the <img> height doesn't correspond to text height, try
-           // to borrow the height from some sibling node.
-           let siblingRect = inlineSiblingRect(this, this.side > 0 ? -1 : 1);
-           return siblingRect && siblingRect.top < imgRect.bottom && siblingRect.bottom > imgRect.top
-               ? { left: imgRect.left, right: imgRect.right, top: siblingRect.top, bottom: siblingRect.bottom } : imgRect;
-       }
-       get overrideDOMText() {
-           return Text$1.empty;
-       }
-   };
-   TextView$1.prototype.children = WidgetView$1.prototype.children = WidgetBufferView$1.prototype.children = noChildren$1;
-   function inlineSiblingRect(view, side) {
-       let parent = view.parent, index = parent ? parent.children.indexOf(view) : -1;
-       while (parent && index >= 0) {
-           if (side < 0 ? index > 0 : index < parent.children.length) {
-               let next = parent.children[index + side];
-               if (next instanceof TextView$1) {
-                   let nextRect = next.coordsAt(side < 0 ? next.length : 0, side);
-                   if (nextRect)
-                       return nextRect;
-               }
-               index += side;
-           }
-           else if (parent instanceof MarkView$1 && parent.parent) {
-               index = parent.parent.children.indexOf(parent) + (side < 0 ? 0 : 1);
-               parent = parent.parent;
-           }
-           else {
-               let last = parent.dom.lastChild;
-               if (last && last.nodeName == "BR")
-                   return last.getClientRects()[0];
-               break;
-           }
-       }
-       return undefined;
-   }
-   function inlineDOMAtPos$1(dom, children, pos) {
-       let i = 0;
-       for (let off = 0; i < children.length; i++) {
-           let child = children[i], end = off + child.length;
-           if (end == off && child.getSide() <= 0)
-               continue;
-           if (pos > off && pos < end && child.dom.parentNode == dom)
-               return child.domAtPos(pos - off);
-           if (pos <= off)
-               break;
-           off = end;
-       }
-       for (; i > 0; i--) {
-           let before = children[i - 1].dom;
-           if (before.parentNode == dom)
-               return DOMPos$1.after(before);
-       }
-       return new DOMPos$1(dom, 0);
-   }
-   // Assumes `view`, if a mark view, has precisely 1 child.
-   function joinInlineInto$1(parent, view, open) {
-       let last, { children } = parent;
-       if (open > 0 && view instanceof MarkView$1 && children.length &&
-           (last = children[children.length - 1]) instanceof MarkView$1 && last.mark.eq(view.mark)) {
-           joinInlineInto$1(last, view.children[0], open - 1);
-       }
-       else {
-           children.push(view);
-           view.setParent(parent);
-       }
-       parent.length += view.length;
-   }
-   function coordsInChildren$1(view, pos, side) {
-       for (let off = 0, i = 0; i < view.children.length; i++) {
-           let child = view.children[i], end = off + child.length, next;
-           if ((side <= 0 || end == view.length || child.getSide() > 0 ? end >= pos : end > pos) &&
-               (pos < end || i + 1 == view.children.length || (next = view.children[i + 1]).length || next.getSide() > 0)) {
-               let flatten = 0;
-               if (end == off) {
-                   if (child.getSide() <= 0)
-                       continue;
-                   flatten = side = -child.getSide();
-               }
-               let rect = child.coordsAt(Math.max(0, pos - off), side);
-               return flatten && rect ? flattenRect$1(rect, side < 0) : rect;
-           }
-           off = end;
-       }
-       let last = view.dom.lastChild;
-       if (!last)
-           return view.dom.getBoundingClientRect();
-       let rects = clientRectsFor$1(last);
-       return rects[rects.length - 1] || null;
-   }
-
-   function combineAttrs$1(source, target) {
-       for (let name in source) {
-           if (name == "class" && target.class)
-               target.class += " " + source.class;
-           else if (name == "style" && target.style)
-               target.style += ";" + source.style;
-           else
-               target[name] = source[name];
-       }
-       return target;
-   }
-   function attrsEq$1(a, b) {
-       if (a == b)
-           return true;
-       if (!a || !b)
-           return false;
-       let keysA = Object.keys(a), keysB = Object.keys(b);
-       if (keysA.length != keysB.length)
-           return false;
-       for (let key of keysA) {
-           if (keysB.indexOf(key) == -1 || a[key] !== b[key])
-               return false;
-       }
-       return true;
-   }
-   function updateAttrs$1(dom, prev, attrs) {
-       let changed = null;
-       if (prev)
-           for (let name in prev)
-               if (!(attrs && name in attrs))
-                   dom.removeAttribute(changed = name);
-       if (attrs)
-           for (let name in attrs)
-               if (!(prev && prev[name] == attrs[name]))
-                   dom.setAttribute(changed = name, attrs[name]);
-       return !!changed;
-   }
-
-   /**
-   Widgets added to the content are described by subclasses of this
-   class. Using a description object like that makes it possible to
-   delay creating of the DOM structure for a widget until it is
-   needed, and to avoid redrawing widgets even if the decorations
-   that define them are recreated.
-   */
-   let WidgetType$1 = class WidgetType {
-       /**
-       Compare this instance to another instance of the same type.
-       (TypeScript can't express this, but only instances of the same
-       specific class will be passed to this method.) This is used to
-       avoid redrawing widgets when they are replaced by a new
-       decoration of the same type. The default implementation just
-       returns `false`, which will cause new instances of the widget to
-       always be redrawn.
-       */
-       eq(widget) { return false; }
-       /**
-       Update a DOM element created by a widget of the same type (but
-       different, non-`eq` content) to reflect this widget. May return
-       true to indicate that it could update, false to indicate it
-       couldn't (in which case the widget will be redrawn). The default
-       implementation just returns false.
-       */
-       updateDOM(dom) { return false; }
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       The estimated height this widget will have, to be used when
-       estimating the height of content that hasn't been drawn. May
-       return -1 to indicate you don't know. The default implementation
-       returns -1.
-       */
-       get estimatedHeight() { return -1; }
-       /**
-       Can be used to configure which kinds of events inside the widget
-       should be ignored by the editor. The default is to ignore all
-       events.
-       */
-       ignoreEvent(event) { return true; }
-       /**
-       @internal
-       */
-       get customView() { return null; }
-       /**
-       This is called when the an instance of the widget is removed
-       from the editor view.
-       */
-       destroy(dom) { }
-   };
-   /**
-   The different types of blocks that can occur in an editor view.
-   */
-   var BlockType$1 = /*@__PURE__*/(function (BlockType) {
-       /**
-       A line of text.
-       */
-       BlockType[BlockType["Text"] = 0] = "Text";
-       /**
-       A block widget associated with the position after it.
-       */
-       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
-       /**
-       A block widget associated with the position before it.
-       */
-       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
-       /**
-       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
-       */
-       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
-   return BlockType})(BlockType$1 || (BlockType$1 = {}));
-   /**
-   A decoration provides information on how to draw or style a piece
-   of content. You'll usually use it wrapped in a
-   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
-   @nonabstract
-   */
-   let Decoration$1 = class Decoration extends RangeValue$1 {
-       constructor(
-       /**
-       @internal
-       */
-       startSide, 
-       /**
-       @internal
-       */
-       endSide, 
-       /**
-       @internal
-       */
-       widget, 
-       /**
-       The config object used to create this decoration. You can
-       include additional properties in there to store metadata about
-       your decoration.
-       */
-       spec) {
-           super();
-           this.startSide = startSide;
-           this.endSide = endSide;
-           this.widget = widget;
-           this.spec = spec;
-       }
-       /**
-       @internal
-       */
-       get heightRelevant() { return false; }
-       /**
-       Create a mark decoration, which influences the styling of the
-       content in its range. Nested mark decorations will cause nested
-       DOM elements to be created. Nesting order is determined by
-       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
-       the higher-precedence decorations creating the inner DOM nodes.
-       Such elements are split on line boundaries and on the boundaries
-       of lower-precedence decorations.
-       */
-       static mark(spec) {
-           return new MarkDecoration$1(spec);
-       }
-       /**
-       Create a widget decoration, which displays a DOM element at the
-       given position.
-       */
-       static widget(spec) {
-           let side = spec.side || 0, block = !!spec.block;
-           side += block ? (side > 0 ? 300000000 /* BlockAfter */ : -400000000 /* BlockBefore */) : (side > 0 ? 100000000 /* InlineAfter */ : -100000000 /* InlineBefore */);
-           return new PointDecoration$1(spec, side, side, block, spec.widget || null, false);
-       }
-       /**
-       Create a replace decoration which replaces the given range with
-       a widget, or simply hides it.
-       */
-       static replace(spec) {
-           let block = !!spec.block, startSide, endSide;
-           if (spec.isBlockGap) {
-               startSide = -500000000 /* GapStart */;
-               endSide = 400000000 /* GapEnd */;
-           }
-           else {
-               let { start, end } = getInclusive$1(spec, block);
-               startSide = (start ? (block ? -300000000 /* BlockIncStart */ : -1 /* InlineIncStart */) : 500000000 /* NonIncStart */) - 1;
-               endSide = (end ? (block ? 200000000 /* BlockIncEnd */ : 1 /* InlineIncEnd */) : -600000000 /* NonIncEnd */) + 1;
-           }
-           return new PointDecoration$1(spec, startSide, endSide, block, spec.widget || null, true);
-       }
-       /**
-       Create a line decoration, which can add DOM attributes to the
-       line starting at the given position.
-       */
-       static line(spec) {
-           return new LineDecoration$1(spec);
-       }
-       /**
-       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
-       decorated range or ranges. If the ranges aren't already sorted,
-       pass `true` for `sort` to make the library sort them for you.
-       */
-       static set(of, sort = false) {
-           return RangeSet$1.of(of, sort);
-       }
-       /**
-       @internal
-       */
-       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
-   };
-   /**
-   The empty set of decorations.
-   */
-   Decoration$1.none = RangeSet$1.empty;
-   let MarkDecoration$1 = class MarkDecoration extends Decoration$1 {
-       constructor(spec) {
-           let { start, end } = getInclusive$1(spec);
-           super(start ? -1 /* InlineIncStart */ : 500000000 /* NonIncStart */, end ? 1 /* InlineIncEnd */ : -600000000 /* NonIncEnd */, null, spec);
-           this.tagName = spec.tagName || "span";
-           this.class = spec.class || "";
-           this.attrs = spec.attributes || null;
-       }
-       eq(other) {
-           return this == other ||
-               other instanceof MarkDecoration &&
-                   this.tagName == other.tagName &&
-                   this.class == other.class &&
-                   attrsEq$1(this.attrs, other.attrs);
-       }
-       range(from, to = from) {
-           if (from >= to)
-               throw new RangeError("Mark decorations may not be empty");
-           return super.range(from, to);
-       }
-   };
-   MarkDecoration$1.prototype.point = false;
-   let LineDecoration$1 = class LineDecoration extends Decoration$1 {
-       constructor(spec) {
-           super(-200000000 /* Line */, -200000000 /* Line */, null, spec);
-       }
-       eq(other) {
-           return other instanceof LineDecoration && attrsEq$1(this.spec.attributes, other.spec.attributes);
-       }
-       range(from, to = from) {
-           if (to != from)
-               throw new RangeError("Line decoration ranges must be zero-length");
-           return super.range(from, to);
-       }
-   };
-   LineDecoration$1.prototype.mapMode = MapMode$1.TrackBefore;
-   LineDecoration$1.prototype.point = true;
-   let PointDecoration$1 = class PointDecoration extends Decoration$1 {
-       constructor(spec, startSide, endSide, block, widget, isReplace) {
-           super(startSide, endSide, widget, spec);
-           this.block = block;
-           this.isReplace = isReplace;
-           this.mapMode = !block ? MapMode$1.TrackDel : startSide <= 0 ? MapMode$1.TrackBefore : MapMode$1.TrackAfter;
-       }
-       // Only relevant when this.block == true
-       get type() {
-           return this.startSide < this.endSide ? BlockType$1.WidgetRange
-               : this.startSide <= 0 ? BlockType$1.WidgetBefore : BlockType$1.WidgetAfter;
-       }
-       get heightRelevant() { return this.block || !!this.widget && this.widget.estimatedHeight >= 5; }
-       eq(other) {
-           return other instanceof PointDecoration &&
-               widgetsEq$1(this.widget, other.widget) &&
-               this.block == other.block &&
-               this.startSide == other.startSide && this.endSide == other.endSide;
-       }
-       range(from, to = from) {
-           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
-               throw new RangeError("Invalid range for replacement decoration");
-           if (!this.isReplace && to != from)
-               throw new RangeError("Widget decorations can only have zero-length ranges");
-           return super.range(from, to);
-       }
-   };
-   PointDecoration$1.prototype.point = true;
-   function getInclusive$1(spec, block = false) {
-       let { inclusiveStart: start, inclusiveEnd: end } = spec;
-       if (start == null)
-           start = spec.inclusive;
-       if (end == null)
-           end = spec.inclusive;
-       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
-   }
-   function widgetsEq$1(a, b) {
-       return a == b || !!(a && b && a.compare(b));
-   }
-   function addRange$1(from, to, ranges, margin = 0) {
-       let last = ranges.length - 1;
-       if (last >= 0 && ranges[last] + margin >= from)
-           ranges[last] = Math.max(ranges[last], to);
-       else
-           ranges.push(from, to);
-   }
-
-   let LineView$1 = class LineView extends ContentView$1 {
-       constructor() {
-           super(...arguments);
-           this.children = [];
-           this.length = 0;
-           this.prevAttrs = undefined;
-           this.attrs = null;
-           this.breakAfter = 0;
-       }
-       // Consumes source
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source) {
-               if (!(source instanceof LineView))
-                   return false;
-               if (!this.dom)
-                   source.transferDOM(this); // Reuse source.dom when appropriate
-           }
-           if (hasStart)
-               this.setDeco(source ? source.attrs : null);
-           mergeChildrenInto$1(this, from, to, source ? source.children : [], openStart, openEnd);
-           return true;
-       }
-       split(at) {
-           let end = new LineView;
-           end.breakAfter = this.breakAfter;
-           if (this.length == 0)
-               return end;
-           let { i, off } = this.childPos(at);
-           if (off) {
-               end.append(this.children[i].split(off), 0);
-               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
-               i++;
-           }
-           for (let j = i; j < this.children.length; j++)
-               end.append(this.children[j], 0);
-           while (i > 0 && this.children[i - 1].length == 0)
-               this.children[--i].destroy();
-           this.children.length = i;
-           this.markDirty();
-           this.length = at;
-           return end;
-       }
-       transferDOM(other) {
-           if (!this.dom)
-               return;
-           this.markDirty();
-           other.setDOM(this.dom);
-           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
-           this.prevAttrs = undefined;
-           this.dom = null;
-       }
-       setDeco(attrs) {
-           if (!attrsEq$1(this.attrs, attrs)) {
-               if (this.dom) {
-                   this.prevAttrs = this.attrs;
-                   this.markDirty();
-               }
-               this.attrs = attrs;
-           }
-       }
-       append(child, openStart) {
-           joinInlineInto$1(this, child, openStart);
-       }
-       // Only called when building a line view in ContentBuilder
-       addLineDeco(deco) {
-           let attrs = deco.spec.attributes, cls = deco.spec.class;
-           if (attrs)
-               this.attrs = combineAttrs$1(attrs, this.attrs || {});
-           if (cls)
-               this.attrs = combineAttrs$1({ class: cls }, this.attrs || {});
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos$1(this.dom, this.children, pos);
-       }
-       reuseDOM(node) {
-           if (node.nodeName == "DIV") {
-               this.setDOM(node);
-               this.dirty |= 4 /* Attrs */ | 2 /* Node */;
-           }
-       }
-       sync(track) {
-           var _a;
-           if (!this.dom) {
-               this.setDOM(document.createElement("div"));
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           else if (this.dirty & 4 /* Attrs */) {
-               clearAttributes$1(this.dom);
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           if (this.prevAttrs !== undefined) {
-               updateAttrs$1(this.dom, this.prevAttrs, this.attrs);
-               this.dom.classList.add("cm-line");
-               this.prevAttrs = undefined;
-           }
-           super.sync(track);
-           let last = this.dom.lastChild;
-           while (last && ContentView$1.get(last) instanceof MarkView$1)
-               last = last.lastChild;
-           if (!last || !this.length ||
-               last.nodeName != "BR" && ((_a = ContentView$1.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
-                   (!browser$1.ios || !this.children.some(ch => ch instanceof TextView$1))) {
-               let hack = document.createElement("BR");
-               hack.cmIgnore = true;
-               this.dom.appendChild(hack);
-           }
-       }
-       measureTextSize() {
-           if (this.children.length == 0 || this.length > 20)
-               return null;
-           let totalWidth = 0;
-           for (let child of this.children) {
-               if (!(child instanceof TextView$1))
-                   return null;
-               let rects = clientRectsFor$1(child.dom);
-               if (rects.length != 1)
-                   return null;
-               totalWidth += rects[0].width;
-           }
-           return { lineHeight: this.dom.getBoundingClientRect().height,
-               charWidth: totalWidth / this.length };
-       }
-       coordsAt(pos, side) {
-           return coordsInChildren$1(this, pos, side);
-       }
-       become(_other) { return false; }
-       get type() { return BlockType$1.Text; }
-       static find(docView, pos) {
-           for (let i = 0, off = 0; i < docView.children.length; i++) {
-               let block = docView.children[i], end = off + block.length;
-               if (end >= pos) {
-                   if (block instanceof LineView)
-                       return block;
-                   if (end > pos)
-                       break;
-               }
-               off = end + block.breakAfter;
-           }
-           return null;
-       }
-   };
-   let BlockWidgetView$1 = class BlockWidgetView extends ContentView$1 {
-       constructor(widget, length, type) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.type = type;
-           this.breakAfter = 0;
-           this.prevWidget = null;
-       }
-       merge(from, to, source, _takeDeco, openStart, openEnd) {
-           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       domAtPos(pos) {
-           return pos == 0 ? DOMPos$1.before(this.dom) : DOMPos$1.after(this.dom, pos == this.length);
-       }
-       split(at) {
-           let len = this.length - at;
-           this.length = at;
-           let end = new BlockWidgetView(this.widget, len, this.type);
-           end.breakAfter = this.breakAfter;
-           return end;
-       }
-       get children() { return noChildren$1; }
-       sync() {
-           if (!this.dom || !this.widget.updateDOM(this.dom)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(this.editorView));
-               this.dom.contentEditable = "false";
-           }
-       }
-       get overrideDOMText() {
-           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$1.empty;
-       }
-       domBoundsAround() { return null; }
-       become(other) {
-           if (other instanceof BlockWidgetView && other.type == this.type &&
-               other.widget.constructor == this.widget.constructor) {
-               if (!other.widget.eq(this.widget))
-                   this.markDirty(true);
-               if (this.dom && !this.prevWidget)
-                   this.prevWidget = this.widget;
-               this.widget = other.widget;
-               this.length = other.length;
-               this.breakAfter = other.breakAfter;
-               return true;
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-   };
-
-   let ContentBuilder$1 = class ContentBuilder {
-       constructor(doc, pos, end, disallowBlockEffectsFor) {
-           this.doc = doc;
-           this.pos = pos;
-           this.end = end;
-           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
-           this.content = [];
-           this.curLine = null;
-           this.breakAtStart = 0;
-           this.pendingBuffer = 0 /* No */;
-           // Set to false directly after a widget that covers the position after it
-           this.atCursorPos = true;
-           this.openStart = -1;
-           this.openEnd = -1;
-           this.text = "";
-           this.textOff = 0;
-           this.cursor = doc.iter();
-           this.skip = pos;
-       }
-       posCovered() {
-           if (this.content.length == 0)
-               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
-           let last = this.content[this.content.length - 1];
-           return !last.breakAfter && !(last instanceof BlockWidgetView$1 && last.type == BlockType$1.WidgetBefore);
-       }
-       getLine() {
-           if (!this.curLine) {
-               this.content.push(this.curLine = new LineView$1);
-               this.atCursorPos = true;
-           }
-           return this.curLine;
-       }
-       flushBuffer(active) {
-           if (this.pendingBuffer) {
-               this.curLine.append(wrapMarks$1(new WidgetBufferView$1(-1), active), active.length);
-               this.pendingBuffer = 0 /* No */;
-           }
-       }
-       addBlockWidget(view) {
-           this.flushBuffer([]);
-           this.curLine = null;
-           this.content.push(view);
-       }
-       finish(openEnd) {
-           if (!openEnd)
-               this.flushBuffer([]);
-           else
-               this.pendingBuffer = 0 /* No */;
-           if (!this.posCovered())
-               this.getLine();
-       }
-       buildText(length, active, openStart) {
-           while (length > 0) {
-               if (this.textOff == this.text.length) {
-                   let { value, lineBreak, done } = this.cursor.next(this.skip);
-                   this.skip = 0;
-                   if (done)
-                       throw new Error("Ran out of text content when drawing inline views");
-                   if (lineBreak) {
-                       if (!this.posCovered())
-                           this.getLine();
-                       if (this.content.length)
-                           this.content[this.content.length - 1].breakAfter = 1;
-                       else
-                           this.breakAtStart = 1;
-                       this.flushBuffer([]);
-                       this.curLine = null;
-                       length--;
-                       continue;
-                   }
-                   else {
-                       this.text = value;
-                       this.textOff = 0;
-                   }
-               }
-               let take = Math.min(this.text.length - this.textOff, length, 512 /* Chunk */);
-               this.flushBuffer(active.slice(0, openStart));
-               this.getLine().append(wrapMarks$1(new TextView$1(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
-               this.atCursorPos = true;
-               this.textOff += take;
-               length -= take;
-               openStart = 0;
-           }
-       }
-       span(from, to, active, openStart) {
-           this.buildText(to - from, active, openStart);
-           this.pos = to;
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       point(from, to, deco, active, openStart, index) {
-           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration$1) {
-               if (deco.block)
-                   throw new RangeError("Block decorations may not be specified via plugins");
-               if (to > this.doc.lineAt(this.pos).to)
-                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
-           }
-           let len = to - from;
-           if (deco instanceof PointDecoration$1) {
-               if (deco.block) {
-                   let { type } = deco;
-                   if (type == BlockType$1.WidgetAfter && !this.posCovered())
-                       this.getLine();
-                   this.addBlockWidget(new BlockWidgetView$1(deco.widget || new NullWidget$1("div"), len, type));
-               }
-               else {
-                   let view = WidgetView$1.create(deco.widget || new NullWidget$1("span"), len, deco.startSide);
-                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length && (from < to || deco.startSide > 0);
-                   let cursorAfter = !view.isEditable && (from < to || deco.startSide <= 0);
-                   let line = this.getLine();
-                   if (this.pendingBuffer == 2 /* IfCursor */ && !cursorBefore)
-                       this.pendingBuffer = 0 /* No */;
-                   this.flushBuffer(active);
-                   if (cursorBefore) {
-                       line.append(wrapMarks$1(new WidgetBufferView$1(1), active), openStart);
-                       openStart = active.length + Math.max(0, openStart - active.length);
-                   }
-                   line.append(wrapMarks$1(view, active), openStart);
-                   this.atCursorPos = cursorAfter;
-                   this.pendingBuffer = !cursorAfter ? 0 /* No */ : from < to ? 1 /* Yes */ : 2 /* IfCursor */;
-               }
-           }
-           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
-               this.getLine().addLineDeco(deco);
-           }
-           if (len) {
-               // Advance the iterator past the replaced content
-               if (this.textOff + len <= this.text.length) {
-                   this.textOff += len;
-               }
-               else {
-                   this.skip += len - (this.text.length - this.textOff);
-                   this.text = "";
-                   this.textOff = 0;
-               }
-               this.pos = to;
-           }
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       static build(text, from, to, decorations, dynamicDecorationMap) {
-           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
-           builder.openEnd = RangeSet$1.spans(decorations, from, to, builder);
-           if (builder.openStart < 0)
-               builder.openStart = builder.openEnd;
-           builder.finish(builder.openEnd);
-           return builder;
-       }
-   };
-   function wrapMarks$1(view, active) {
-       for (let mark of active)
-           view = new MarkView$1(mark, [view], view.length);
-       return view;
-   }
-   let NullWidget$1 = class NullWidget extends WidgetType$1 {
-       constructor(tag) {
-           super();
-           this.tag = tag;
-       }
-       eq(other) { return other.tag == this.tag; }
-       toDOM() { return document.createElement(this.tag); }
-       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
-   };
-
-   const clickAddsSelectionRange$1 = /*@__PURE__*/Facet$1.define();
-   const dragMovesSelection$1$1 = /*@__PURE__*/Facet$1.define();
-   const mouseSelectionStyle$1 = /*@__PURE__*/Facet$1.define();
-   const exceptionSink$1 = /*@__PURE__*/Facet$1.define();
-   const updateListener$1 = /*@__PURE__*/Facet$1.define();
-   const inputHandler$2 = /*@__PURE__*/Facet$1.define();
-   const perLineTextDirection$1 = /*@__PURE__*/Facet$1.define({
-       combine: values => values.some(x => x)
-   });
-   let ScrollTarget$1 = class ScrollTarget {
-       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5) {
-           this.range = range;
-           this.y = y;
-           this.x = x;
-           this.yMargin = yMargin;
-           this.xMargin = xMargin;
-       }
-       map(changes) {
-           return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);
-       }
-   };
-   const scrollIntoView$3 = /*@__PURE__*/StateEffect$1.define({ map: (t, ch) => t.map(ch) });
-   /**
-   Log or report an unhandled exception in client code. Should
-   probably only be used by extension code that allows client code to
-   provide functions, and calls those functions in a context where an
-   exception can't be propagated to calling code in a reasonable way
-   (for example when in an event handler).
-
-   Either calls a handler registered with
-   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
-   `window.onerror`, if defined, or `console.error` (in which case
-   it'll pass `context`, when given, as first argument).
-   */
-   function logException$1(state, exception, context) {
-       let handler = state.facet(exceptionSink$1);
-       if (handler.length)
-           handler[0](exception);
-       else if (window.onerror)
-           window.onerror(String(exception), context, undefined, undefined, exception);
-       else if (context)
-           console.error(context + ":", exception);
-       else
-           console.error(exception);
-   }
-   const editable$1 = /*@__PURE__*/Facet$1.define({ combine: values => values.length ? values[0] : true });
-   let nextPluginID$1 = 0;
-   const viewPlugin$1 = /*@__PURE__*/Facet$1.define();
-   /**
-   View plugins associate stateful values with a view. They can
-   influence the way the content is drawn, and are notified of things
-   that happen in the view.
-   */
-   let ViewPlugin$1 = class ViewPlugin {
-       constructor(
-       /**
-       @internal
-       */
-       id, 
-       /**
-       @internal
-       */
-       create, 
-       /**
-       @internal
-       */
-       domEventHandlers, buildExtensions) {
-           this.id = id;
-           this.create = create;
-           this.domEventHandlers = domEventHandlers;
-           this.extension = buildExtensions(this);
-       }
-       /**
-       Define a plugin from a constructor function that creates the
-       plugin's value, given an editor view.
-       */
-       static define(create, spec) {
-           const { eventHandlers, provide, decorations: deco } = spec || {};
-           return new ViewPlugin(nextPluginID$1++, create, eventHandlers, plugin => {
-               let ext = [viewPlugin$1.of(plugin)];
-               if (deco)
-                   ext.push(decorations$1.of(view => {
-                       let pluginInst = view.plugin(plugin);
-                       return pluginInst ? deco(pluginInst) : Decoration$1.none;
-                   }));
-               if (provide)
-                   ext.push(provide(plugin));
-               return ext;
-           });
-       }
-       /**
-       Create a plugin for a class whose constructor takes a single
-       editor view as argument.
-       */
-       static fromClass(cls, spec) {
-           return ViewPlugin.define(view => new cls(view), spec);
-       }
-   };
-   let PluginInstance$1 = class PluginInstance {
-       constructor(spec) {
-           this.spec = spec;
-           // When starting an update, all plugins have this field set to the
-           // update object, indicating they need to be updated. When finished
-           // updating, it is set to `false`. Retrieving a plugin that needs to
-           // be updated with `view.plugin` forces an eager update.
-           this.mustUpdate = null;
-           // This is null when the plugin is initially created, but
-           // initialized on the first update.
-           this.value = null;
-       }
-       update(view) {
-           if (!this.value) {
-               if (this.spec) {
-                   try {
-                       this.value = this.spec.create(view);
-                   }
-                   catch (e) {
-                       logException$1(view.state, e, "CodeMirror plugin crashed");
-                       this.deactivate();
-                   }
-               }
-           }
-           else if (this.mustUpdate) {
-               let update = this.mustUpdate;
-               this.mustUpdate = null;
-               if (this.value.update) {
-                   try {
-                       this.value.update(update);
-                   }
-                   catch (e) {
-                       logException$1(update.state, e, "CodeMirror plugin crashed");
-                       if (this.value.destroy)
-                           try {
-                               this.value.destroy();
-                           }
-                           catch (_) { }
-                       this.deactivate();
-                   }
-               }
-           }
-           return this;
-       }
-       destroy(view) {
-           var _a;
-           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
-               try {
-                   this.value.destroy();
-               }
-               catch (e) {
-                   logException$1(view.state, e, "CodeMirror plugin crashed");
-               }
-           }
-       }
-       deactivate() {
-           this.spec = this.value = null;
-       }
-   };
-   const editorAttributes$1 = /*@__PURE__*/Facet$1.define();
-   const contentAttributes$1 = /*@__PURE__*/Facet$1.define();
-   // Provide decorations
-   const decorations$1 = /*@__PURE__*/Facet$1.define();
-   const atomicRanges$1 = /*@__PURE__*/Facet$1.define();
-   const scrollMargins$1 = /*@__PURE__*/Facet$1.define();
-   const styleModule$1 = /*@__PURE__*/Facet$1.define();
-   let ChangedRange$1 = class ChangedRange {
-       constructor(fromA, toA, fromB, toB) {
-           this.fromA = fromA;
-           this.toA = toA;
-           this.fromB = fromB;
-           this.toB = toB;
-       }
-       join(other) {
-           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
-       }
-       addToSet(set) {
-           let i = set.length, me = this;
-           for (; i > 0; i--) {
-               let range = set[i - 1];
-               if (range.fromA > me.toA)
-                   continue;
-               if (range.toA < me.fromA)
-                   break;
-               me = me.join(range);
-               set.splice(i - 1, 1);
-           }
-           set.splice(i, 0, me);
-           return set;
-       }
-       static extendWithRanges(diff, ranges) {
-           if (ranges.length == 0)
-               return diff;
-           let result = [];
-           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
-               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
-               let end = next ? next.fromB : 1e9;
-               while (rI < ranges.length && ranges[rI] < end) {
-                   let from = ranges[rI], to = ranges[rI + 1];
-                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
-                   if (fromB <= toB)
-                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
-                   if (to > end)
-                       break;
-                   else
-                       rI += 2;
-               }
-               if (!next)
-                   return result;
-               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
-               posA = next.toA;
-               posB = next.toB;
-           }
-       }
-   };
-   /**
-   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
-   class, which describe what happened, whenever the view is updated.
-   */
-   let ViewUpdate$1 = class ViewUpdate {
-       constructor(
-       /**
-       The editor view that the update is associated with.
-       */
-       view, 
-       /**
-       The new editor state.
-       */
-       state, 
-       /**
-       The transactions involved in the update. May be empty.
-       */
-       transactions) {
-           this.view = view;
-           this.state = state;
-           this.transactions = transactions;
-           /**
-           @internal
-           */
-           this.flags = 0;
-           this.startState = view.state;
-           this.changes = ChangeSet$1.empty(this.startState.doc.length);
-           for (let tr of transactions)
-               this.changes = this.changes.compose(tr.changes);
-           let changedRanges = [];
-           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange$1(fromA, toA, fromB, toB)));
-           this.changedRanges = changedRanges;
-           let focus = view.hasFocus;
-           if (focus != view.inputState.notifiedFocused) {
-               view.inputState.notifiedFocused = focus;
-               this.flags |= 1 /* Focus */;
-           }
-       }
-       /**
-       @internal
-       */
-       static create(view, state, transactions) {
-           return new ViewUpdate(view, state, transactions);
-       }
-       /**
-       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
-       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
-       update.
-       */
-       get viewportChanged() {
-           return (this.flags & 4 /* Viewport */) > 0;
-       }
-       /**
-       Indicates whether the height of a block element in the editor
-       changed in this update.
-       */
-       get heightChanged() {
-           return (this.flags & 2 /* Height */) > 0;
-       }
-       /**
-       Returns true when the document was modified or the size of the
-       editor, or elements within the editor, changed.
-       */
-       get geometryChanged() {
-           return this.docChanged || (this.flags & (8 /* Geometry */ | 2 /* Height */)) > 0;
-       }
-       /**
-       True when this update indicates a focus change.
-       */
-       get focusChanged() {
-           return (this.flags & 1 /* Focus */) > 0;
-       }
-       /**
-       Whether the document changed in this update.
-       */
-       get docChanged() {
-           return !this.changes.empty;
-       }
-       /**
-       Whether the selection was explicitly set in this update.
-       */
-       get selectionSet() {
-           return this.transactions.some(tr => tr.selection);
-       }
-       /**
-       @internal
-       */
-       get empty() { return this.flags == 0 && this.transactions.length == 0; }
-   };
-
-   /**
-   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-   */
-   var Direction$1 = /*@__PURE__*/(function (Direction) {
-       // (These are chosen to match the base levels, in bidi algorithm
-       // terms, of spans in that direction.)
-       /**
-       Left-to-right.
-       */
-       Direction[Direction["LTR"] = 0] = "LTR";
-       /**
-       Right-to-left.
-       */
-       Direction[Direction["RTL"] = 1] = "RTL";
-   return Direction})(Direction$1 || (Direction$1 = {}));
-   const LTR$1 = Direction$1.LTR, RTL$1 = Direction$1.RTL;
-   // Decode a string with each type encoded as log2(type)
-   function dec$1(str) {
-       let result = [];
-       for (let i = 0; i < str.length; i++)
-           result.push(1 << +str[i]);
-       return result;
-   }
-   // Character types for codepoints 0 to 0xf8
-   const LowTypes$1 = /*@__PURE__*/dec$1("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
-   // Character types for codepoints 0x600 to 0x6f9
-   const ArabicTypes$1 = /*@__PURE__*/dec$1("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
-   const Brackets$1 = /*@__PURE__*/Object.create(null), BracketStack$1 = [];
-   // There's a lot more in
-   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
-   // which are left out to keep code size down.
-   for (let p of ["()", "[]", "{}"]) {
-       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
-       Brackets$1[l] = r;
-       Brackets$1[r] = -l;
-   }
-   function charType$1(ch) {
-       return ch <= 0xf7 ? LowTypes$1[ch] :
-           0x590 <= ch && ch <= 0x5f4 ? 2 /* R */ :
-               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes$1[ch - 0x600] :
-                   0x6ee <= ch && ch <= 0x8ac ? 4 /* AL */ :
-                       0x2000 <= ch && ch <= 0x200b ? 256 /* NI */ :
-                           ch == 0x200c ? 256 /* NI */ : 1 /* L */;
-   }
-   const BidiRE$1 = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
-   /**
-   Represents a contiguous range of text that has a single direction
-   (as in left-to-right or right-to-left).
-   */
-   let BidiSpan$1 = class BidiSpan {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the span (relative to the start of the line).
-       */
-       from, 
-       /**
-       The end of the span.
-       */
-       to, 
-       /**
-       The ["bidi
-       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
-       of the span (in this context, 0 means
-       left-to-right, 1 means right-to-left, 2 means left-to-right
-       number inside right-to-left text).
-       */
-       level) {
-           this.from = from;
-           this.to = to;
-           this.level = level;
-       }
-       /**
-       The direction of this span.
-       */
-       get dir() { return this.level % 2 ? RTL$1 : LTR$1; }
-       /**
-       @internal
-       */
-       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
-       /**
-       @internal
-       */
-       static find(order, index, level, assoc) {
-           let maybe = -1;
-           for (let i = 0; i < order.length; i++) {
-               let span = order[i];
-               if (span.from <= index && span.to >= index) {
-                   if (span.level == level)
-                       return i;
-                   // When multiple spans match, if assoc != 0, take the one that
-                   // covers that side, otherwise take the one with the minimum
-                   // level.
-                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
-                       maybe = i;
-               }
-           }
-           if (maybe < 0)
-               throw new RangeError("Index out of range");
-           return maybe;
-       }
-   };
-   // Reused array of character types
-   const types$1 = [];
-   function computeOrder$1(line, direction) {
-       let len = line.length, outerType = direction == LTR$1 ? 1 /* L */ : 2 /* R */, oppositeType = direction == LTR$1 ? 2 /* R */ : 1 /* L */;
-       if (!line || outerType == 1 /* L */ && !BidiRE$1.test(line))
-           return trivialOrder$1(len);
-       // W1. Examine each non-spacing mark (NSM) in the level run, and
-       // change the type of the NSM to the type of the previous
-       // character. If the NSM is at the start of the level run, it will
-       // get the type of sor.
-       // W2. Search backwards from each instance of a European number
-       // until the first strong type (R, L, AL, or sor) is found. If an
-       // AL is found, change the type of the European number to Arabic
-       // number.
-       // W3. Change all ALs to R.
-       // (Left after this: L, R, EN, AN, ET, CS, NI)
-       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
-           let type = charType$1(line.charCodeAt(i));
-           if (type == 512 /* NSM */)
-               type = prev;
-           else if (type == 8 /* EN */ && prevStrong == 4 /* AL */)
-               type = 16 /* AN */;
-           types$1[i] = type == 4 /* AL */ ? 2 /* R */ : type;
-           if (type & 7 /* Strong */)
-               prevStrong = type;
-           prev = type;
-       }
-       // W5. A sequence of European terminators adjacent to European
-       // numbers changes to all European numbers.
-       // W6. Otherwise, separators and terminators change to Other
-       // Neutral.
-       // W7. Search backwards from each instance of a European number
-       // until the first strong type (R, L, or sor) is found. If an L is
-       // found, then change the type of the European number to L.
-       // (Left after this: L, R, EN+AN, NI)
-       for (let i = 0, prev = outerType, prevStrong = outerType; i < len; i++) {
-           let type = types$1[i];
-           if (type == 128 /* CS */) {
-               if (i < len - 1 && prev == types$1[i + 1] && (prev & 24 /* Num */))
-                   type = types$1[i] = prev;
-               else
-                   types$1[i] = 256 /* NI */;
-           }
-           else if (type == 64 /* ET */) {
-               let end = i + 1;
-               while (end < len && types$1[end] == 64 /* ET */)
-                   end++;
-               let replace = (i && prev == 8 /* EN */) || (end < len && types$1[end] == 8 /* EN */) ? (prevStrong == 1 /* L */ ? 1 /* L */ : 8 /* EN */) : 256 /* NI */;
-               for (let j = i; j < end; j++)
-                   types$1[j] = replace;
-               i = end - 1;
-           }
-           else if (type == 8 /* EN */ && prevStrong == 1 /* L */) {
-               types$1[i] = 1 /* L */;
-           }
-           prev = type;
-           if (type & 7 /* Strong */)
-               prevStrong = type;
-       }
-       // N0. Process bracket pairs in an isolating run sequence
-       // sequentially in the logical order of the text positions of the
-       // opening paired brackets using the logic given below. Within this
-       // scope, bidirectional types EN and AN are treated as R.
-       for (let i = 0, sI = 0, context = 0, ch, br, type; i < len; i++) {
-           // Keeps [startIndex, type, strongSeen] triples for each open
-           // bracket on BracketStack.
-           if (br = Brackets$1[ch = line.charCodeAt(i)]) {
-               if (br < 0) { // Closing bracket
-                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                       if (BracketStack$1[sJ + 1] == -br) {
-                           let flags = BracketStack$1[sJ + 2];
-                           let type = (flags & 2 /* EmbedInside */) ? outerType :
-                               !(flags & 4 /* OppositeInside */) ? 0 :
-                                   (flags & 1 /* OppositeBefore */) ? oppositeType : outerType;
-                           if (type)
-                               types$1[i] = types$1[BracketStack$1[sJ]] = type;
-                           sI = sJ;
-                           break;
-                       }
-                   }
-               }
-               else if (BracketStack$1.length == 189 /* MaxDepth */) {
-                   break;
-               }
-               else {
-                   BracketStack$1[sI++] = i;
-                   BracketStack$1[sI++] = ch;
-                   BracketStack$1[sI++] = context;
-               }
-           }
-           else if ((type = types$1[i]) == 2 /* R */ || type == 1 /* L */) {
-               let embed = type == outerType;
-               context = embed ? 0 : 1 /* OppositeBefore */;
-               for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                   let cur = BracketStack$1[sJ + 2];
-                   if (cur & 2 /* EmbedInside */)
-                       break;
-                   if (embed) {
-                       BracketStack$1[sJ + 2] |= 2 /* EmbedInside */;
-                   }
-                   else {
-                       if (cur & 4 /* OppositeInside */)
-                           break;
-                       BracketStack$1[sJ + 2] |= 4 /* OppositeInside */;
-                   }
-               }
-           }
-       }
-       // N1. A sequence of neutrals takes the direction of the
-       // surrounding strong text if the text on both sides has the same
-       // direction. European and Arabic numbers act as if they were R in
-       // terms of their influence on neutrals. Start-of-level-run (sor)
-       // and end-of-level-run (eor) are used at level run boundaries.
-       // N2. Any remaining neutrals take the embedding direction.
-       // (Left after this: L, R, EN+AN)
-       for (let i = 0; i < len; i++) {
-           if (types$1[i] == 256 /* NI */) {
-               let end = i + 1;
-               while (end < len && types$1[end] == 256 /* NI */)
-                   end++;
-               let beforeL = (i ? types$1[i - 1] : outerType) == 1 /* L */;
-               let afterL = (end < len ? types$1[end] : outerType) == 1 /* L */;
-               let replace = beforeL == afterL ? (beforeL ? 1 /* L */ : 2 /* R */) : outerType;
-               for (let j = i; j < end; j++)
-                   types$1[j] = replace;
-               i = end - 1;
-           }
-       }
-       // Here we depart from the documented algorithm, in order to avoid
-       // building up an actual levels array. Since there are only three
-       // levels (0, 1, 2) in an implementation that doesn't take
-       // explicit embedding into account, we can build up the order on
-       // the fly, without following the level-based algorithm.
-       let order = [];
-       if (outerType == 1 /* L */) {
-           for (let i = 0; i < len;) {
-               let start = i, rtl = types$1[i++] != 1 /* L */;
-               while (i < len && rtl == (types$1[i] != 1 /* L */))
-                   i++;
-               if (rtl) {
-                   for (let j = i; j > start;) {
-                       let end = j, l = types$1[--j] != 2 /* R */;
-                       while (j > start && l == (types$1[j - 1] != 2 /* R */))
-                           j--;
-                       order.push(new BidiSpan$1(j, end, l ? 2 : 1));
-                   }
-               }
-               else {
-                   order.push(new BidiSpan$1(start, i, 0));
-               }
-           }
-       }
-       else {
-           for (let i = 0; i < len;) {
-               let start = i, rtl = types$1[i++] == 2 /* R */;
-               while (i < len && rtl == (types$1[i] == 2 /* R */))
-                   i++;
-               order.push(new BidiSpan$1(start, i, rtl ? 1 : 2));
-           }
-       }
-       return order;
-   }
-   function trivialOrder$1(length) {
-       return [new BidiSpan$1(0, length, 0)];
-   }
-   let movedOver$1 = "";
-   function moveVisually$1(line, order, dir, start, forward) {
-       var _a;
-       let startIndex = start.head - line.from, spanI = -1;
-       if (startIndex == 0) {
-           if (!forward || !line.length)
-               return null;
-           if (order[0].level != dir) {
-               startIndex = order[0].side(false, dir);
-               spanI = 0;
-           }
-       }
-       else if (startIndex == line.length) {
-           if (forward)
-               return null;
-           let last = order[order.length - 1];
-           if (last.level != dir) {
-               startIndex = last.side(true, dir);
-               spanI = order.length - 1;
-           }
-       }
-       if (spanI < 0)
-           spanI = BidiSpan$1.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
-       let span = order[spanI];
-       // End of span. (But not end of line--that was checked for above.)
-       if (startIndex == span.side(forward, dir)) {
-           span = order[spanI += forward ? 1 : -1];
-           startIndex = span.side(!forward, dir);
-       }
-       let indexForward = forward == (span.dir == dir);
-       let nextIndex = findClusterBreak$2(line.text, startIndex, indexForward);
-       movedOver$1 = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
-       if (nextIndex != span.side(forward, dir))
-           return EditorSelection$1.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);
-       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
-       if (!nextSpan && span.level != dir)
-           return EditorSelection$1.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);
-       if (nextSpan && nextSpan.level < span.level)
-           return EditorSelection$1.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
-       return EditorSelection$1.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
-   }
-
-   const LineBreakPlaceholder$1 = "\uffff";
-   let DOMReader$1 = class DOMReader {
-       constructor(points, state) {
-           this.points = points;
-           this.text = "";
-           this.lineSeparator = state.facet(EditorState$1.lineSeparator);
-       }
-       append(text) {
-           this.text += text;
-       }
-       lineBreak() {
-           this.text += LineBreakPlaceholder$1;
-       }
-       readRange(start, end) {
-           if (!start)
-               return this;
-           let parent = start.parentNode;
-           for (let cur = start;;) {
-               this.findPointBefore(parent, cur);
-               this.readNode(cur);
-               let next = cur.nextSibling;
-               if (next == end)
-                   break;
-               let view = ContentView$1.get(cur), nextView = ContentView$1.get(next);
-               if (view && nextView ? view.breakAfter :
-                   (view ? view.breakAfter : isBlockElement$1(cur)) ||
-                       (isBlockElement$1(next) && (cur.nodeName != "BR" || cur.cmIgnore)))
-                   this.lineBreak();
-               cur = next;
-           }
-           this.findPointBefore(parent, end);
-           return this;
-       }
-       readTextNode(node) {
-           let text = node.nodeValue;
-           for (let point of this.points)
-               if (point.node == node)
-                   point.pos = this.text.length + Math.min(point.offset, text.length);
-           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
-               let nextBreak = -1, breakSize = 1, m;
-               if (this.lineSeparator) {
-                   nextBreak = text.indexOf(this.lineSeparator, off);
-                   breakSize = this.lineSeparator.length;
-               }
-               else if (m = re.exec(text)) {
-                   nextBreak = m.index;
-                   breakSize = m[0].length;
-               }
-               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
-               if (nextBreak < 0)
-                   break;
-               this.lineBreak();
-               if (breakSize > 1)
-                   for (let point of this.points)
-                       if (point.node == node && point.pos > this.text.length)
-                           point.pos -= breakSize - 1;
-               off = nextBreak + breakSize;
-           }
-       }
-       readNode(node) {
-           if (node.cmIgnore)
-               return;
-           let view = ContentView$1.get(node);
-           let fromView = view && view.overrideDOMText;
-           if (fromView != null) {
-               this.findPointInside(node, fromView.length);
-               for (let i = fromView.iter(); !i.next().done;) {
-                   if (i.lineBreak)
-                       this.lineBreak();
-                   else
-                       this.append(i.value);
-               }
-           }
-           else if (node.nodeType == 3) {
-               this.readTextNode(node);
-           }
-           else if (node.nodeName == "BR") {
-               if (node.nextSibling)
-                   this.lineBreak();
-           }
-           else if (node.nodeType == 1) {
-               this.readRange(node.firstChild, null);
-           }
-       }
-       findPointBefore(node, next) {
-           for (let point of this.points)
-               if (point.node == node && node.childNodes[point.offset] == next)
-                   point.pos = this.text.length;
-       }
-       findPointInside(node, maxLen) {
-           for (let point of this.points)
-               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
-                   point.pos = this.text.length + Math.min(maxLen, point.offset);
-       }
-   };
-   function isBlockElement$1(node) {
-       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
-   }
-   let DOMPoint$1 = class DOMPoint {
-       constructor(node, offset) {
-           this.node = node;
-           this.offset = offset;
-           this.pos = -1;
-       }
-   };
-
-   let DocView$1 = class DocView extends ContentView$1 {
-       constructor(view) {
-           super();
-           this.view = view;
-           this.compositionDeco = Decoration$1.none;
-           this.decorations = [];
-           this.dynamicDecorationMap = [];
-           // Track a minimum width for the editor. When measuring sizes in
-           // measureVisibleLineHeights, this is updated to point at the width
-           // of a given element and its extent in the document. When a change
-           // happens in that range, these are reset. That way, once we've seen
-           // a line/element of a given length, we keep the editor wide enough
-           // to fit at least that element, until it is changed, at which point
-           // we forget it again.
-           this.minWidth = 0;
-           this.minWidthFrom = 0;
-           this.minWidthTo = 0;
-           // Track whether the DOM selection was set in a lossy way, so that
-           // we don't mess it up when reading it back it
-           this.impreciseAnchor = null;
-           this.impreciseHead = null;
-           this.forceSelection = false;
-           // Used by the resize observer to ignore resizes that we caused
-           // ourselves
-           this.lastUpdate = Date.now();
-           this.setDOM(view.contentDOM);
-           this.children = [new LineView$1];
-           this.children[0].setParent(this);
-           this.updateDeco();
-           this.updateInner([new ChangedRange$1(0, 0, 0, view.state.doc.length)], 0);
-       }
-       get root() { return this.view.root; }
-       get editorView() { return this.view; }
-       get length() { return this.view.state.doc.length; }
-       // Update the document view to a given state. scrollIntoView can be
-       // used as a hint to compute a new viewport that includes that
-       // position, if we know the editor is going to scroll that position
-       // into view.
-       update(update) {
-           let changedRanges = update.changedRanges;
-           if (this.minWidth > 0 && changedRanges.length) {
-               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
-                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
-               }
-               else {
-                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
-                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
-               }
-           }
-           if (this.view.inputState.composing < 0)
-               this.compositionDeco = Decoration$1.none;
-           else if (update.transactions.length || this.dirty)
-               this.compositionDeco = computeCompositionDeco(this.view, update.changes);
-           // When the DOM nodes around the selection are moved to another
-           // parent, Chrome sometimes reports a different selection through
-           // getSelection than the one that it actually shows to the user.
-           // This forces a selection update when lines are joined to work
-           // around that. Issue #54
-           if ((browser$1.ie || browser$1.chrome) && !this.compositionDeco.size && update &&
-               update.state.doc.lines != update.startState.doc.lines)
-               this.forceSelection = true;
-           let prevDeco = this.decorations, deco = this.updateDeco();
-           let decoDiff = findChangedDeco$1(prevDeco, deco, update.changes);
-           changedRanges = ChangedRange$1.extendWithRanges(changedRanges, decoDiff);
-           if (this.dirty == 0 /* Not */ && changedRanges.length == 0) {
-               return false;
-           }
-           else {
-               this.updateInner(changedRanges, update.startState.doc.length);
-               if (update.transactions.length)
-                   this.lastUpdate = Date.now();
-               return true;
-           }
-       }
-       // Used by update and the constructor do perform the actual DOM
-       // update
-       updateInner(changes, oldLength) {
-           this.view.viewState.mustMeasureContent = true;
-           this.updateChildren(changes, oldLength);
-           let { observer } = this.view;
-           observer.ignore(() => {
-               // Lock the height during redrawing, since Chrome sometimes
-               // messes with the scroll position during DOM mutation (though
-               // no relayout is triggered and I cannot imagine how it can
-               // recompute the scroll position without a layout)
-               this.dom.style.height = this.view.viewState.contentHeight + "px";
-               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
-               // Chrome will sometimes, when DOM mutations occur directly
-               // around the selection, get confused and report a different
-               // selection from the one it displays (issue #218). This tries
-               // to detect that situation.
-               let track = browser$1.chrome || browser$1.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
-               this.sync(track);
-               this.dirty = 0 /* Not */;
-               if (track && (track.written || observer.selectionRange.focusNode != track.node))
-                   this.forceSelection = true;
-               this.dom.style.height = "";
-           });
-           let gaps = [];
-           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
-               for (let child of this.children)
-                   if (child instanceof BlockWidgetView$1 && child.widget instanceof BlockGapWidget$1)
-                       gaps.push(child.dom);
-           observer.updateGaps(gaps);
-       }
-       updateChildren(changes, oldLength) {
-           let cursor = this.childCursor(oldLength);
-           for (let i = changes.length - 1;; i--) {
-               let next = i >= 0 ? changes[i] : null;
-               if (!next)
-                   break;
-               let { fromA, toA, fromB, toB } = next;
-               let { content, breakAtStart, openStart, openEnd } = ContentBuilder$1.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap);
-               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
-               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
-               replaceRange$1(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
-           }
-       }
-       // Sync the DOM selection to this.state.selection
-       updateSelection(mustRead = false, fromPointer = false) {
-           if (mustRead)
-               this.view.observer.readSelectionRange();
-           if (!(fromPointer || this.mayControlSelection()) ||
-               browser$1.ios && this.view.inputState.rapidCompositionStart)
-               return;
-           let force = this.forceSelection;
-           this.forceSelection = false;
-           let main = this.view.state.selection.main;
-           // FIXME need to handle the case where the selection falls inside a block range
-           let anchor = this.domAtPos(main.anchor);
-           let head = main.empty ? anchor : this.domAtPos(main.head);
-           // Always reset on Firefox when next to an uneditable node to
-           // avoid invisible cursor bugs (#111)
-           if (browser$1.gecko && main.empty && betweenUneditable$1(anchor)) {
-               let dummy = document.createTextNode("");
-               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
-               anchor = head = new DOMPos$1(dummy, 0);
-               force = true;
-           }
-           let domSel = this.view.observer.selectionRange;
-           // If the selection is already here, or in an equivalent position, don't touch it
-           if (force || !domSel.focusNode ||
-               !isEquivalentPosition$1(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
-               !isEquivalentPosition$1(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {
-               this.view.observer.ignore(() => {
-                   // Chrome Android will hide the virtual keyboard when tapping
-                   // inside an uneditable node, and not bring it back when we
-                   // move the cursor to its proper position. This tries to
-                   // restore the keyboard by cycling focus.
-                   if (browser$1.android && browser$1.chrome && this.dom.contains(domSel.focusNode) &&
-                       inUneditable$1(domSel.focusNode, this.dom)) {
-                       this.dom.blur();
-                       this.dom.focus({ preventScroll: true });
-                   }
-                   let rawSel = getSelection$1(this.root);
-                   if (main.empty) {
-                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
-                       if (browser$1.gecko) {
-                           let nextTo = nextToUneditable$1(anchor.node, anchor.offset);
-                           if (nextTo && nextTo != (1 /* Before */ | 2 /* After */)) {
-                               let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* Before */ ? 1 : -1);
-                               if (text)
-                                   anchor = new DOMPos$1(text, nextTo == 1 /* Before */ ? 0 : text.nodeValue.length);
-                           }
-                       }
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       if (main.bidiLevel != null && domSel.cursorBidiLevel != null)
-                           domSel.cursorBidiLevel = main.bidiLevel;
-                   }
-                   else if (rawSel.extend) {
-                       // Selection.extend can be used to create an 'inverted' selection
-                       // (one where the focus is before the anchor), but not all
-                       // browsers support it yet.
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       rawSel.extend(head.node, head.offset);
-                   }
-                   else {
-                       // Primitive (IE) way
-                       let range = document.createRange();
-                       if (main.anchor > main.head)
-                           [anchor, head] = [head, anchor];
-                       range.setEnd(head.node, head.offset);
-                       range.setStart(anchor.node, anchor.offset);
-                       rawSel.removeAllRanges();
-                       rawSel.addRange(range);
-                   }
-               });
-               this.view.observer.setSelectionRange(anchor, head);
-           }
-           this.impreciseAnchor = anchor.precise ? null : new DOMPos$1(domSel.anchorNode, domSel.anchorOffset);
-           this.impreciseHead = head.precise ? null : new DOMPos$1(domSel.focusNode, domSel.focusOffset);
-       }
-       enforceCursorAssoc() {
-           if (this.compositionDeco.size)
-               return;
-           let cursor = this.view.state.selection.main;
-           let sel = getSelection$1(this.root);
-           if (!cursor.empty || !cursor.assoc || !sel.modify)
-               return;
-           let line = LineView$1.find(this, cursor.head);
-           if (!line)
-               return;
-           let lineStart = line.posAtStart;
-           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
-               return;
-           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
-           if (!before || !after || before.bottom > after.top)
-               return;
-           let dom = this.domAtPos(cursor.head + cursor.assoc);
-           sel.collapse(dom.node, dom.offset);
-           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
-       }
-       mayControlSelection() {
-           return this.view.state.facet(editable$1) ? this.root.activeElement == this.dom
-               : hasSelection$1(this.dom, this.view.observer.selectionRange);
-       }
-       nearest(dom) {
-           for (let cur = dom; cur;) {
-               let domView = ContentView$1.get(cur);
-               if (domView && domView.rootView == this)
-                   return domView;
-               cur = cur.parentNode;
-           }
-           return null;
-       }
-       posFromDOM(node, offset) {
-           let view = this.nearest(node);
-           if (!view)
-               throw new RangeError("Trying to find position for a DOM position outside of the document");
-           return view.localPosFromDOM(node, offset) + view.posAtStart;
-       }
-       domAtPos(pos) {
-           let { i, off } = this.childCursor().findPos(pos, -1);
-           for (; i < this.children.length - 1;) {
-               let child = this.children[i];
-               if (off < child.length || child instanceof LineView$1)
-                   break;
-               i++;
-               off = 0;
-           }
-           return this.children[i].domAtPos(off);
-       }
-       coordsAt(pos, side) {
-           for (let off = this.length, i = this.children.length - 1;; i--) {
-               let child = this.children[i], start = off - child.breakAfter - child.length;
-               if (pos > start ||
-                   (pos == start && child.type != BlockType$1.WidgetBefore && child.type != BlockType$1.WidgetAfter &&
-                       (!i || side == 2 || this.children[i - 1].breakAfter ||
-                           (this.children[i - 1].type == BlockType$1.WidgetBefore && side > -2))))
-                   return child.coordsAt(pos - start, side);
-               off = start;
-           }
-       }
-       measureVisibleLineHeights(viewport) {
-           let result = [], { from, to } = viewport;
-           let contentWidth = this.view.contentDOM.clientWidth;
-           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
-           let widest = -1, ltr = this.view.textDirection == Direction$1.LTR;
-           for (let pos = 0, i = 0; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (end > to)
-                   break;
-               if (pos >= from) {
-                   let childRect = child.dom.getBoundingClientRect();
-                   result.push(childRect.height);
-                   if (isWider) {
-                       let last = child.dom.lastChild;
-                       let rects = last ? clientRectsFor$1(last) : [];
-                       if (rects.length) {
-                           let rect = rects[rects.length - 1];
-                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
-                           if (width > widest) {
-                               widest = width;
-                               this.minWidth = contentWidth;
-                               this.minWidthFrom = pos;
-                               this.minWidthTo = end;
-                           }
-                       }
-                   }
-               }
-               pos = end + child.breakAfter;
-           }
-           return result;
-       }
-       textDirectionAt(pos) {
-           let { i } = this.childPos(pos, 1);
-           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction$1.RTL : Direction$1.LTR;
-       }
-       measureTextSize() {
-           for (let child of this.children) {
-               if (child instanceof LineView$1) {
-                   let measure = child.measureTextSize();
-                   if (measure)
-                       return measure;
-               }
-           }
-           // If no workable line exists, force a layout of a measurable element
-           let dummy = document.createElement("div"), lineHeight, charWidth;
-           dummy.className = "cm-line";
-           dummy.textContent = "abc def ghi jkl mno pqr stu";
-           this.view.observer.ignore(() => {
-               this.dom.appendChild(dummy);
-               let rect = clientRectsFor$1(dummy.firstChild)[0];
-               lineHeight = dummy.getBoundingClientRect().height;
-               charWidth = rect ? rect.width / 27 : 7;
-               dummy.remove();
-           });
-           return { lineHeight, charWidth };
-       }
-       childCursor(pos = this.length) {
-           // Move back to start of last element when possible, so that
-           // `ChildCursor.findPos` doesn't have to deal with the edge case
-           // of being after the last element.
-           let i = this.children.length;
-           if (i)
-               pos -= this.children[--i].length;
-           return new ChildCursor$1(this.children, pos, i);
-       }
-       computeBlockGapDeco() {
-           let deco = [], vs = this.view.viewState;
-           for (let pos = 0, i = 0;; i++) {
-               let next = i == vs.viewports.length ? null : vs.viewports[i];
-               let end = next ? next.from - 1 : this.length;
-               if (end > pos) {
-                   let height = vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top;
-                   deco.push(Decoration$1.replace({
-                       widget: new BlockGapWidget$1(height),
-                       block: true,
-                       inclusive: true,
-                       isBlockGap: true,
-                   }).range(pos, end));
-               }
-               if (!next)
-                   break;
-               pos = next.to + 1;
-           }
-           return Decoration$1.set(deco);
-       }
-       updateDeco() {
-           let allDeco = this.view.state.facet(decorations$1).map((d, i) => {
-               let dynamic = this.dynamicDecorationMap[i] = typeof d == "function";
-               return dynamic ? d(this.view) : d;
-           });
-           for (let i = allDeco.length; i < allDeco.length + 3; i++)
-               this.dynamicDecorationMap[i] = false;
-           return this.decorations = [
-               ...allDeco,
-               this.compositionDeco,
-               this.computeBlockGapDeco(),
-               this.view.viewState.lineGapDeco
-           ];
-       }
-       scrollIntoView(target) {
-           let { range } = target;
-           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
-           if (!rect)
-               return;
-           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
-               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
-                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
-           let mLeft = 0, mRight = 0, mTop = 0, mBottom = 0;
-           for (let margins of this.view.state.facet(scrollMargins$1).map(f => f(this.view)))
-               if (margins) {
-                   let { left, right, top, bottom } = margins;
-                   if (left != null)
-                       mLeft = Math.max(mLeft, left);
-                   if (right != null)
-                       mRight = Math.max(mRight, right);
-                   if (top != null)
-                       mTop = Math.max(mTop, top);
-                   if (bottom != null)
-                       mBottom = Math.max(mBottom, bottom);
-               }
-           let targetRect = {
-               left: rect.left - mLeft, top: rect.top - mTop,
-               right: rect.right + mRight, bottom: rect.bottom + mBottom
-           };
-           scrollRectIntoView$1(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction$1.LTR);
-       }
-   };
-   function betweenUneditable$1(pos) {
-       return pos.node.nodeType == 1 && pos.node.firstChild &&
-           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
-           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
-   }
-   let BlockGapWidget$1 = class BlockGapWidget extends WidgetType$1 {
-       constructor(height) {
-           super();
-           this.height = height;
-       }
-       toDOM() {
-           let elt = document.createElement("div");
-           this.updateDOM(elt);
-           return elt;
-       }
-       eq(other) { return other.height == this.height; }
-       updateDOM(elt) {
-           elt.style.height = this.height + "px";
-           return true;
-       }
-       get estimatedHeight() { return this.height; }
-   };
-   function compositionSurroundingNode(view) {
-       let sel = view.observer.selectionRange;
-       let textNode = sel.focusNode && nearbyTextNode(sel.focusNode, sel.focusOffset, 0);
-       if (!textNode)
-           return null;
-       let cView = view.docView.nearest(textNode);
-       if (!cView)
-           return null;
-       if (cView instanceof LineView$1) {
-           let topNode = textNode;
-           while (topNode.parentNode != cView.dom)
-               topNode = topNode.parentNode;
-           let prev = topNode.previousSibling;
-           while (prev && !ContentView$1.get(prev))
-               prev = prev.previousSibling;
-           let pos = prev ? ContentView$1.get(prev).posAtEnd : cView.posAtStart;
-           return { from: pos, to: pos, node: topNode, text: textNode };
-       }
-       else {
-           for (;;) {
-               let { parent } = cView;
-               if (!parent)
-                   return null;
-               if (parent instanceof LineView$1)
-                   break;
-               cView = parent;
-           }
-           let from = cView.posAtStart;
-           return { from, to: from + cView.length, node: cView.dom, text: textNode };
-       }
-   }
-   function computeCompositionDeco(view, changes) {
-       let surrounding = compositionSurroundingNode(view);
-       if (!surrounding)
-           return Decoration$1.none;
-       let { from, to, node, text: textNode } = surrounding;
-       let newFrom = changes.mapPos(from, 1), newTo = Math.max(newFrom, changes.mapPos(to, -1));
-       let { state } = view, text = node.nodeType == 3 ? node.nodeValue :
-           new DOMReader$1([], state).readRange(node.firstChild, null).text;
-       if (newTo - newFrom < text.length) {
-           if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length), LineBreakPlaceholder$1) == text)
-               newTo = newFrom + text.length;
-           else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo, LineBreakPlaceholder$1) == text)
-               newFrom = newTo - text.length;
-           else
-               return Decoration$1.none;
-       }
-       else if (state.doc.sliceString(newFrom, newTo, LineBreakPlaceholder$1) != text) {
-           return Decoration$1.none;
-       }
-       let topView = ContentView$1.get(node);
-       if (topView instanceof CompositionView)
-           topView = topView.widget.topView;
-       else if (topView)
-           topView.parent = null;
-       return Decoration$1.set(Decoration$1.replace({ widget: new CompositionWidget(node, textNode, topView), inclusive: true })
-           .range(newFrom, newTo));
-   }
-   class CompositionWidget extends WidgetType$1 {
-       constructor(top, text, topView) {
-           super();
-           this.top = top;
-           this.text = text;
-           this.topView = topView;
-       }
-       eq(other) { return this.top == other.top && this.text == other.text; }
-       toDOM() { return this.top; }
-       ignoreEvent() { return false; }
-       get customView() { return CompositionView; }
-   }
-   function nearbyTextNode(node, offset, side) {
-       for (;;) {
-           if (node.nodeType == 3)
-               return node;
-           if (node.nodeType == 1 && offset > 0 && side <= 0) {
-               node = node.childNodes[offset - 1];
-               offset = maxOffset$1(node);
-           }
-           else if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {
-               node = node.childNodes[offset];
-               offset = 0;
-           }
-           else {
-               return null;
-           }
-       }
-   }
-   function nextToUneditable$1(node, offset) {
-       if (node.nodeType != 1)
-           return 0;
-       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* Before */ : 0) |
-           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* After */ : 0);
-   }
-   let DecorationComparator$1$1 = class DecorationComparator$1 {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange(from, to) { addRange$1(from, to, this.changes); }
-       comparePoint(from, to) { addRange$1(from, to, this.changes); }
-   };
-   function findChangedDeco$1(a, b, diff) {
-       let comp = new DecorationComparator$1$1;
-       RangeSet$1.compare(a, b, diff, comp);
-       return comp.changes;
-   }
-   function inUneditable$1(node, inside) {
-       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
-           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
-               return true;
-           }
-       }
-       return false;
-   }
-
-   function groupAt$1(state, pos, bias = 1) {
-       let categorize = state.charCategorizer(pos);
-       let line = state.doc.lineAt(pos), linePos = pos - line.from;
-       if (line.length == 0)
-           return EditorSelection$1.cursor(pos);
-       if (linePos == 0)
-           bias = 1;
-       else if (linePos == line.length)
-           bias = -1;
-       let from = linePos, to = linePos;
-       if (bias < 0)
-           from = findClusterBreak$2(line.text, linePos, false);
-       else
-           to = findClusterBreak$2(line.text, linePos);
-       let cat = categorize(line.text.slice(from, to));
-       while (from > 0) {
-           let prev = findClusterBreak$2(line.text, from, false);
-           if (categorize(line.text.slice(prev, from)) != cat)
-               break;
-           from = prev;
-       }
-       while (to < line.length) {
-           let next = findClusterBreak$2(line.text, to);
-           if (categorize(line.text.slice(to, next)) != cat)
-               break;
-           to = next;
-       }
-       return EditorSelection$1.range(from + line.from, to + line.from);
-   }
-   // Search the DOM for the {node, offset} position closest to the given
-   // coordinates. Very inefficient and crude, but can usually be avoided
-   // by calling caret(Position|Range)FromPoint instead.
-   function getdx$1(x, rect) {
-       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
-   }
-   function getdy$1(y, rect) {
-       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
-   }
-   function yOverlap$1(a, b) {
-       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
-   }
-   function upTop$1(rect, top) {
-       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
-   }
-   function upBot$1(rect, bottom) {
-       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
-   }
-   function domPosAtCoords$1(parent, x, y) {
-       let closest, closestRect, closestX, closestY;
-       let above, below, aboveRect, belowRect;
-       for (let child = parent.firstChild; child; child = child.nextSibling) {
-           let rects = clientRectsFor$1(child);
-           for (let i = 0; i < rects.length; i++) {
-               let rect = rects[i];
-               if (closestRect && yOverlap$1(closestRect, rect))
-                   rect = upTop$1(upBot$1(rect, closestRect.bottom), closestRect.top);
-               let dx = getdx$1(x, rect), dy = getdy$1(y, rect);
-               if (dx == 0 && dy == 0)
-                   return child.nodeType == 3 ? domPosInText$1(child, x, y) : domPosAtCoords$1(child, x, y);
-               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
-                   closest = child;
-                   closestRect = rect;
-                   closestX = dx;
-                   closestY = dy;
-               }
-               if (dx == 0) {
-                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
-                       above = child;
-                       aboveRect = rect;
-                   }
-                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
-                       below = child;
-                       belowRect = rect;
-                   }
-               }
-               else if (aboveRect && yOverlap$1(aboveRect, rect)) {
-                   aboveRect = upBot$1(aboveRect, rect.bottom);
-               }
-               else if (belowRect && yOverlap$1(belowRect, rect)) {
-                   belowRect = upTop$1(belowRect, rect.top);
-               }
-           }
-       }
-       if (aboveRect && aboveRect.bottom >= y) {
-           closest = above;
-           closestRect = aboveRect;
-       }
-       else if (belowRect && belowRect.top <= y) {
-           closest = below;
-           closestRect = belowRect;
-       }
-       if (!closest)
-           return { node: parent, offset: 0 };
-       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
-       if (closest.nodeType == 3)
-           return domPosInText$1(closest, clipX, y);
-       if (!closestX && closest.contentEditable == "true")
-           return domPosAtCoords$1(closest, clipX, y);
-       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
-           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
-       return { node: parent, offset };
-   }
-   function domPosInText$1(node, x, y) {
-       let len = node.nodeValue.length;
-       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
-       for (let i = 0; i < len; i++) {
-           let rects = textRange$1(node, i, i + 1).getClientRects();
-           for (let j = 0; j < rects.length; j++) {
-               let rect = rects[j];
-               if (rect.top == rect.bottom)
-                   continue;
-               if (!generalSide)
-                   generalSide = x - rect.left;
-               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
-               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
-                   let right = x >= (rect.left + rect.right) / 2, after = right;
-                   if (browser$1.chrome || browser$1.gecko) {
-                       // Check for RTL on browsers that support getting client
-                       // rects for empty ranges.
-                       let rectBefore = textRange$1(node, i).getBoundingClientRect();
-                       if (rectBefore.left == rect.right)
-                           after = !right;
-                   }
-                   if (dy <= 0)
-                       return { node, offset: i + (after ? 1 : 0) };
-                   closestOffset = i + (after ? 1 : 0);
-                   closestDY = dy;
-               }
-           }
-       }
-       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
-   }
-   function posAtCoords$1(view, { x, y }, precise, bias = -1) {
-       var _a;
-       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
-       let block, { docHeight } = view.viewState;
-       let yOffset = y - docTop;
-       if (yOffset < 0)
-           return 0;
-       if (yOffset > docHeight)
-           return view.state.doc.length;
-       // Scan for a text block near the queried y position
-       for (let halfLine = view.defaultLineHeight / 2, bounced = false;;) {
-           block = view.elementAtHeight(yOffset);
-           if (block.type == BlockType$1.Text)
-               break;
-           for (;;) {
-               // Move the y position out of this block
-               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
-               if (yOffset >= 0 && yOffset <= docHeight)
-                   break;
-               // If the document consists entirely of replaced widgets, we
-               // won't find a text block, so return 0
-               if (bounced)
-                   return precise ? null : 0;
-               bounced = true;
-               bias = -bias;
-           }
-       }
-       y = docTop + yOffset;
-       let lineStart = block.from;
-       // If this is outside of the rendered viewport, we can't determine a position
-       if (lineStart < view.viewport.from)
-           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise$1(view, content, block, x, y);
-       if (lineStart > view.viewport.to)
-           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
-               precise ? null : posAtCoordsImprecise$1(view, content, block, x, y);
-       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
-       let doc = view.dom.ownerDocument;
-       let root = view.root.elementFromPoint ? view.root : doc;
-       let element = root.elementFromPoint(x, y);
-       if (element && !view.contentDOM.contains(element))
-           element = null;
-       // If the element is unexpected, clip x at the sides of the content area and try again
-       if (!element) {
-           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
-           element = root.elementFromPoint(x, y);
-           if (element && !view.contentDOM.contains(element))
-               element = null;
-       }
-       // There's visible editor content under the point, so we can try
-       // using caret(Position|Range)FromPoint as a shortcut
-       let node, offset = -1;
-       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
-           if (doc.caretPositionFromPoint) {
-               let pos = doc.caretPositionFromPoint(x, y);
-               if (pos)
-                   ({ offsetNode: node, offset } = pos);
-           }
-           else if (doc.caretRangeFromPoint) {
-               let range = doc.caretRangeFromPoint(x, y);
-               if (range) {
-                   ({ startContainer: node, startOffset: offset } = range);
-                   if (browser$1.safari && isSuspiciousCaretResult(node, offset, x))
-                       node = undefined;
-               }
-           }
-       }
-       // No luck, do our own (potentially expensive) search
-       if (!node || !view.docView.dom.contains(node)) {
-           let line = LineView$1.find(view.docView, lineStart);
-           if (!line)
-               return yOffset > block.top + block.height / 2 ? block.to : block.from;
-           ({ node, offset } = domPosAtCoords$1(line.dom, x, y));
-       }
-       return view.docView.posFromDOM(node, offset);
-   }
-   function posAtCoordsImprecise$1(view, contentRect, block, x, y) {
-       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
-       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
-           let line = Math.floor((y - block.top) / view.defaultLineHeight);
-           into += line * view.viewState.heightOracle.lineLength;
-       }
-       let content = view.state.sliceDoc(block.from, block.to);
-       return block.from + findColumn$1(content, into, view.state.tabSize);
-   }
-   // In case of a high line height, Safari's caretRangeFromPoint treats
-   // the space between lines as belonging to the last character of the
-   // line before. This is used to detect such a result so that it can be
-   // ignored (issue #401).
-   function isSuspiciousCaretResult(node, offset, x) {
-       let len;
-       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
-           return false;
-       for (let next = node.nextSibling; next; next = next.nextSibling)
-           if (next.nodeType != 1 || next.nodeName != "BR")
-               return false;
-       return textRange$1(node, len - 1, len).getBoundingClientRect().left > x;
-   }
-   function moveToLineBoundary$1(view, start, forward, includeWrap) {
-       let line = view.state.doc.lineAt(start.head);
-       let coords = !includeWrap || !view.lineWrapping ? null
-           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
-       if (coords) {
-           let editorRect = view.dom.getBoundingClientRect();
-           let direction = view.textDirectionAt(line.from);
-           let pos = view.posAtCoords({ x: forward == (direction == Direction$1.LTR) ? editorRect.right - 1 : editorRect.left + 1,
-               y: (coords.top + coords.bottom) / 2 });
-           if (pos != null)
-               return EditorSelection$1.cursor(pos, forward ? -1 : 1);
-       }
-       let lineView = LineView$1.find(view.docView, start.head);
-       let end = lineView ? (forward ? lineView.posAtEnd : lineView.posAtStart) : (forward ? line.to : line.from);
-       return EditorSelection$1.cursor(end, forward ? -1 : 1);
-   }
-   function moveByChar$1(view, start, forward, by) {
-       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
-       let direction = view.textDirectionAt(line.from);
-       for (let cur = start, check = null;;) {
-           let next = moveVisually$1(line, spans, direction, cur, forward), char = movedOver$1;
-           if (!next) {
-               if (line.number == (forward ? view.state.doc.lines : 1))
-                   return cur;
-               char = "\n";
-               line = view.state.doc.line(line.number + (forward ? 1 : -1));
-               spans = view.bidiSpans(line);
-               next = EditorSelection$1.cursor(forward ? line.from : line.to);
-           }
-           if (!check) {
-               if (!by)
-                   return next;
-               check = by(char);
-           }
-           else if (!check(char)) {
-               return cur;
-           }
-           cur = next;
-       }
-   }
-   function byGroup$1(view, pos, start) {
-       let categorize = view.state.charCategorizer(pos);
-       let cat = categorize(start);
-       return (next) => {
-           let nextCat = categorize(next);
-           if (cat == CharCategory$1.Space)
-               cat = nextCat;
-           return cat == nextCat;
-       };
-   }
-   function moveVertically$1(view, start, forward, distance) {
-       let startPos = start.head, dir = forward ? 1 : -1;
-       if (startPos == (forward ? view.state.doc.length : 0))
-           return EditorSelection$1.cursor(startPos, start.assoc);
-       let goal = start.goalColumn, startY;
-       let rect = view.contentDOM.getBoundingClientRect();
-       let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;
-       if (startCoords) {
-           if (goal == null)
-               goal = startCoords.left - rect.left;
-           startY = dir < 0 ? startCoords.top : startCoords.bottom;
-       }
-       else {
-           let line = view.viewState.lineBlockAt(startPos);
-           if (goal == null)
-               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
-           startY = (dir < 0 ? line.top : line.bottom) + docTop;
-       }
-       let resolvedGoal = rect.left + goal;
-       let dist = distance !== null && distance !== void 0 ? distance : (view.defaultLineHeight >> 1);
-       for (let extra = 0;; extra += 10) {
-           let curY = startY + (dist + extra) * dir;
-           let pos = posAtCoords$1(view, { x: resolvedGoal, y: curY }, false, dir);
-           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))
-               return EditorSelection$1.cursor(pos, start.assoc, undefined, goal);
-       }
-   }
-   function skipAtoms$1(view, oldPos, pos) {
-       let atoms = view.state.facet(atomicRanges$1).map(f => f(view));
-       for (;;) {
-           let moved = false;
-           for (let set of atoms) {
-               set.between(pos.from - 1, pos.from + 1, (from, to, value) => {
-                   if (pos.from > from && pos.from < to) {
-                       pos = oldPos.from > pos.from ? EditorSelection$1.cursor(from, 1) : EditorSelection$1.cursor(to, -1);
-                       moved = true;
-                   }
-               });
-           }
-           if (!moved)
-               return pos;
-       }
-   }
-
-   // This will also be where dragging info and such goes
-   let InputState$1 = class InputState {
-       constructor(view) {
-           this.lastKeyCode = 0;
-           this.lastKeyTime = 0;
-           this.chromeScrollHack = -1;
-           // On iOS, some keys need to have their default behavior happen
-           // (after which we retroactively handle them and reset the DOM) to
-           // avoid messing up the virtual keyboard state.
-           this.pendingIOSKey = undefined;
-           this.lastSelectionOrigin = null;
-           this.lastSelectionTime = 0;
-           this.lastEscPress = 0;
-           this.lastContextMenu = 0;
-           this.scrollHandlers = [];
-           this.registeredEvents = [];
-           this.customHandlers = [];
-           // -1 means not in a composition. Otherwise, this counts the number
-           // of changes made during the composition. The count is used to
-           // avoid treating the start state of the composition, before any
-           // changes have been made, as part of the composition.
-           this.composing = -1;
-           // Tracks whether the next change should be marked as starting the
-           // composition (null means no composition, true means next is the
-           // first, false means first has already been marked for this
-           // composition)
-           this.compositionFirstChange = null;
-           this.compositionEndedAt = 0;
-           this.rapidCompositionStart = false;
-           this.mouseSelection = null;
-           for (let type in handlers$1) {
-               let handler = handlers$1[type];
-               view.contentDOM.addEventListener(type, (event) => {
-                   if (!eventBelongsToEditor$1(view, event) || this.ignoreDuringComposition(event))
-                       return;
-                   if (type == "keydown" && this.keydown(view, event))
-                       return;
-                   if (this.mustFlushObserver(event))
-                       view.observer.forceFlush();
-                   if (this.runCustomHandlers(type, view, event))
-                       event.preventDefault();
-                   else
-                       handler(view, event);
-               });
-               this.registeredEvents.push(type);
-           }
-           if (browser$1.chrome && browser$1.chrome_version >= 102) {
-               // On Chrome 102, viewport updates somehow stop wheel-based
-               // scrolling. Turning off pointer events during the scroll seems
-               // to avoid the issue.
-               view.scrollDOM.addEventListener("wheel", () => {
-                   if (this.chromeScrollHack < 0)
-                       view.contentDOM.style.pointerEvents = "none";
-                   else
-                       window.clearTimeout(this.chromeScrollHack);
-                   this.chromeScrollHack = setTimeout(() => {
-                       this.chromeScrollHack = -1;
-                       view.contentDOM.style.pointerEvents = "";
-                   }, 100);
-               }, { passive: true });
-           }
-           this.notifiedFocused = view.hasFocus;
-           // On Safari adding an input event handler somehow prevents an
-           // issue where the composition vanishes when you press enter.
-           if (browser$1.safari)
-               view.contentDOM.addEventListener("input", () => null);
-       }
-       setSelectionOrigin(origin) {
-           this.lastSelectionOrigin = origin;
-           this.lastSelectionTime = Date.now();
-       }
-       ensureHandlers(view, plugins) {
-           var _a;
-           let handlers;
-           this.customHandlers = [];
-           for (let plugin of plugins)
-               if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {
-                   this.customHandlers.push({ plugin: plugin.value, handlers });
-                   for (let type in handlers)
-                       if (this.registeredEvents.indexOf(type) < 0 && type != "scroll") {
-                           this.registeredEvents.push(type);
-                           view.contentDOM.addEventListener(type, (event) => {
-                               if (!eventBelongsToEditor$1(view, event))
-                                   return;
-                               if (this.runCustomHandlers(type, view, event))
-                                   event.preventDefault();
-                           });
-                       }
-               }
-       }
-       runCustomHandlers(type, view, event) {
-           for (let set of this.customHandlers) {
-               let handler = set.handlers[type];
-               if (handler) {
-                   try {
-                       if (handler.call(set.plugin, event, view) || event.defaultPrevented)
-                           return true;
-                   }
-                   catch (e) {
-                       logException$1(view.state, e);
-                   }
-               }
-           }
-           return false;
-       }
-       runScrollHandlers(view, event) {
-           for (let set of this.customHandlers) {
-               let handler = set.handlers.scroll;
-               if (handler) {
-                   try {
-                       handler.call(set.plugin, event, view);
-                   }
-                   catch (e) {
-                       logException$1(view.state, e);
-                   }
-               }
-           }
-       }
-       keydown(view, event) {
-           // Must always run, even if a custom handler handled the event
-           this.lastKeyCode = event.keyCode;
-           this.lastKeyTime = Date.now();
-           if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)
-               return true;
-           // Chrome for Android usually doesn't fire proper key events, but
-           // occasionally does, usually surrounded by a bunch of complicated
-           // composition changes. When an enter or backspace key event is
-           // seen, hold off on handling DOM events for a bit, and then
-           // dispatch it.
-           if (browser$1.android && browser$1.chrome && !event.synthetic &&
-               (event.keyCode == 13 || event.keyCode == 8)) {
-               view.observer.delayAndroidKey(event.key, event.keyCode);
-               return true;
-           }
-           // Prevent the default behavior of Enter on iOS makes the
-           // virtual keyboard get stuck in the wrong (lowercase)
-           // state. So we let it go through, and then, in
-           // applyDOMChange, notify key handlers of it and reset to
-           // the state they produce.
-           let pending;
-           if (browser$1.ios && (pending = PendingKeys$1.find(key => key.keyCode == event.keyCode)) &&
-               !(event.ctrlKey || event.altKey || event.metaKey) && !event.synthetic) {
-               this.pendingIOSKey = pending;
-               setTimeout(() => this.flushIOSKey(view), 250);
-               return true;
-           }
-           return false;
-       }
-       flushIOSKey(view) {
-           let key = this.pendingIOSKey;
-           if (!key)
-               return false;
-           this.pendingIOSKey = undefined;
-           return dispatchKey$1(view.contentDOM, key.key, key.keyCode);
-       }
-       ignoreDuringComposition(event) {
-           if (!/^key/.test(event.type))
-               return false;
-           if (this.composing > 0)
-               return true;
-           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
-           // On some input method editors (IMEs), the Enter key is used to
-           // confirm character selection. On Safari, when Enter is pressed,
-           // compositionend and keydown events are sometimes emitted in the
-           // wrong order. The key event should still be ignored, even when
-           // it happens after the compositionend event.
-           if (browser$1.safari && Date.now() - this.compositionEndedAt < 100) {
-               this.compositionEndedAt = 0;
-               return true;
-           }
-           return false;
-       }
-       mustFlushObserver(event) {
-           return (event.type == "keydown" && event.keyCode != 229) ||
-               event.type == "compositionend" && !browser$1.ios;
-       }
-       startMouseSelection(mouseSelection) {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-           this.mouseSelection = mouseSelection;
-       }
-       update(update) {
-           if (this.mouseSelection)
-               this.mouseSelection.update(update);
-           if (update.transactions.length)
-               this.lastKeyCode = this.lastSelectionTime = 0;
-       }
-       destroy() {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-       }
-   };
-   const PendingKeys$1 = [
-       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
-       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
-       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
-   ];
-   // Key codes for modifier keys
-   const modifierCodes$1 = [16, 17, 18, 20, 91, 92, 224, 225];
-   let MouseSelection$1 = class MouseSelection {
-       constructor(view, startEvent, style, mustSelect) {
-           this.view = view;
-           this.style = style;
-           this.mustSelect = mustSelect;
-           this.lastEvent = startEvent;
-           let doc = view.contentDOM.ownerDocument;
-           doc.addEventListener("mousemove", this.move = this.move.bind(this));
-           doc.addEventListener("mouseup", this.up = this.up.bind(this));
-           this.extend = startEvent.shiftKey;
-           this.multiple = view.state.facet(EditorState$1.allowMultipleSelections) && addsSelectionRange$1(view, startEvent);
-           this.dragMove = dragMovesSelection$2(view, startEvent);
-           this.dragging = isInPrimarySelection$1(view, startEvent) && getClickType$1(startEvent) == 1 ? null : false;
-           // When clicking outside of the selection, immediately apply the
-           // effect of starting the selection
-           if (this.dragging === false) {
-               startEvent.preventDefault();
-               this.select(startEvent);
-           }
-       }
-       move(event) {
-           if (event.buttons == 0)
-               return this.destroy();
-           if (this.dragging !== false)
-               return;
-           this.select(this.lastEvent = event);
-       }
-       up(event) {
-           if (this.dragging == null)
-               this.select(this.lastEvent);
-           if (!this.dragging)
-               event.preventDefault();
-           this.destroy();
-       }
-       destroy() {
-           let doc = this.view.contentDOM.ownerDocument;
-           doc.removeEventListener("mousemove", this.move);
-           doc.removeEventListener("mouseup", this.up);
-           this.view.inputState.mouseSelection = null;
-       }
-       select(event) {
-           let selection = this.style.get(event, this.extend, this.multiple);
-           if (this.mustSelect || !selection.eq(this.view.state.selection) ||
-               selection.main.assoc != this.view.state.selection.main.assoc)
-               this.view.dispatch({
-                   selection,
-                   userEvent: "select.pointer",
-                   scrollIntoView: true
-               });
-           this.mustSelect = false;
-       }
-       update(update) {
-           if (update.docChanged && this.dragging)
-               this.dragging = this.dragging.map(update.changes);
-           if (this.style.update(update))
-               setTimeout(() => this.select(this.lastEvent), 20);
-       }
-   };
-   function addsSelectionRange$1(view, event) {
-       let facet = view.state.facet(clickAddsSelectionRange$1);
-       return facet.length ? facet[0](event) : browser$1.mac ? event.metaKey : event.ctrlKey;
-   }
-   function dragMovesSelection$2(view, event) {
-       let facet = view.state.facet(dragMovesSelection$1$1);
-       return facet.length ? facet[0](event) : browser$1.mac ? !event.altKey : !event.ctrlKey;
-   }
-   function isInPrimarySelection$1(view, event) {
-       let { main } = view.state.selection;
-       if (main.empty)
-           return false;
-       // On boundary clicks, check whether the coordinates are inside the
-       // selection's client rectangles
-       let sel = getSelection$1(view.root);
-       if (sel.rangeCount == 0)
-           return true;
-       let rects = sel.getRangeAt(0).getClientRects();
-       for (let i = 0; i < rects.length; i++) {
-           let rect = rects[i];
-           if (rect.left <= event.clientX && rect.right >= event.clientX &&
-               rect.top <= event.clientY && rect.bottom >= event.clientY)
-               return true;
-       }
-       return false;
-   }
-   function eventBelongsToEditor$1(view, event) {
-       if (!event.bubbles)
-           return true;
-       if (event.defaultPrevented)
-           return false;
-       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
-           if (!node || node.nodeType == 11 || ((cView = ContentView$1.get(node)) && cView.ignoreEvent(event)))
-               return false;
-       return true;
-   }
-   const handlers$1 = /*@__PURE__*/Object.create(null);
-   // This is very crude, but unfortunately both these browsers _pretend_
-   // that they have a clipboard API—all the objects and methods are
-   // there, they just don't work, and they are hard to test.
-   const brokenClipboardAPI$1 = (browser$1.ie && browser$1.ie_version < 15) ||
-       (browser$1.ios && browser$1.webkit_version < 604);
-   function capturePaste$1(view) {
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.focus();
-       setTimeout(() => {
-           view.focus();
-           target.remove();
-           doPaste$1(view, target.value);
-       }, 50);
-   }
-   function doPaste$1(view, input) {
-       let { state } = view, changes, i = 1, text = state.toText(input);
-       let byLine = text.lines == state.selection.ranges.length;
-       let linewise = lastLinewiseCopy$1 != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy$1 == text.toString();
-       if (linewise) {
-           let lastLine = -1;
-           changes = state.changeByRange(range => {
-               let line = state.doc.lineAt(range.from);
-               if (line.from == lastLine)
-                   return { range };
-               lastLine = line.from;
-               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
-               return { changes: { from: line.from, insert },
-                   range: EditorSelection$1.cursor(range.from + insert.length) };
-           });
-       }
-       else if (byLine) {
-           changes = state.changeByRange(range => {
-               let line = text.line(i++);
-               return { changes: { from: range.from, to: range.to, insert: line.text },
-                   range: EditorSelection$1.cursor(range.from + line.length) };
-           });
-       }
-       else {
-           changes = state.replaceSelection(text);
-       }
-       view.dispatch(changes, {
-           userEvent: "input.paste",
-           scrollIntoView: true
-       });
-   }
-   handlers$1.keydown = (view, event) => {
-       view.inputState.setSelectionOrigin("select");
-       if (event.keyCode == 27)
-           view.inputState.lastEscPress = Date.now();
-       else if (modifierCodes$1.indexOf(event.keyCode) < 0)
-           view.inputState.lastEscPress = 0;
-   };
-   let lastTouch = 0;
-   handlers$1.touchstart = (view, e) => {
-       lastTouch = Date.now();
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   handlers$1.touchmove = view => {
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   handlers$1.mousedown = (view, event) => {
-       view.observer.flush();
-       if (lastTouch > Date.now() - 2000 && getClickType$1(event) == 1)
-           return; // Ignore touch interaction
-       let style = null;
-       for (let makeStyle of view.state.facet(mouseSelectionStyle$1)) {
-           style = makeStyle(view, event);
-           if (style)
-               break;
-       }
-       if (!style && event.button == 0)
-           style = basicMouseSelection$1(view, event);
-       if (style) {
-           let mustFocus = view.root.activeElement != view.contentDOM;
-           if (mustFocus)
-               view.observer.ignore(() => focusPreventScroll$1(view.contentDOM));
-           view.inputState.startMouseSelection(new MouseSelection$1(view, event, style, mustFocus));
-       }
-   };
-   function rangeForClick$1(view, pos, bias, type) {
-       if (type == 1) { // Single click
-           return EditorSelection$1.cursor(pos, bias);
-       }
-       else if (type == 2) { // Double click
-           return groupAt$1(view.state, pos, bias);
-       }
-       else { // Triple click
-           let visual = LineView$1.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
-           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
-           if (to < view.state.doc.length && to == line.to)
-               to++;
-           return EditorSelection$1.range(from, to);
-       }
-   }
-   let insideY = (y, rect) => y >= rect.top && y <= rect.bottom;
-   let inside$1 = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right;
-   // Try to determine, for the given coordinates, associated with the
-   // given position, whether they are related to the element before or
-   // the element after the position.
-   function findPositionSide$1(view, pos, x, y) {
-       let line = LineView$1.find(view.docView, pos);
-       if (!line)
-           return 1;
-       let off = pos - line.posAtStart;
-       // Line boundaries point into the line
-       if (off == 0)
-           return 1;
-       if (off == line.length)
-           return -1;
-       // Positions on top of an element point at that element
-       let before = line.coordsAt(off, -1);
-       if (before && inside$1(x, y, before))
-           return -1;
-       let after = line.coordsAt(off, 1);
-       if (after && inside$1(x, y, after))
-           return 1;
-       // This is probably a line wrap point. Pick before if the point is
-       // beside it.
-       return before && insideY(y, before) ? -1 : 1;
-   }
-   function queryPos$1(view, event) {
-       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       return { pos, bias: findPositionSide$1(view, pos, event.clientX, event.clientY) };
-   }
-   const BadMouseDetail$1 = browser$1.ie && browser$1.ie_version <= 11;
-   let lastMouseDown$1 = null, lastMouseDownCount$1 = 0, lastMouseDownTime$1 = 0;
-   function getClickType$1(event) {
-       if (!BadMouseDetail$1)
-           return event.detail;
-       let last = lastMouseDown$1, lastTime = lastMouseDownTime$1;
-       lastMouseDown$1 = event;
-       lastMouseDownTime$1 = Date.now();
-       return lastMouseDownCount$1 = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
-           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount$1 + 1) % 3 : 1;
-   }
-   function basicMouseSelection$1(view, event) {
-       let start = queryPos$1(view, event), type = getClickType$1(event);
-       let startSel = view.state.selection;
-       let last = start, lastEvent = event;
-       return {
-           update(update) {
-               if (update.docChanged) {
-                   if (start)
-                       start.pos = update.changes.mapPos(start.pos);
-                   startSel = startSel.map(update.changes);
-                   lastEvent = null;
-               }
-           },
-           get(event, extend, multiple) {
-               let cur;
-               if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
-                   cur = last;
-               else {
-                   cur = last = queryPos$1(view, event);
-                   lastEvent = event;
-               }
-               if (!cur || !start)
-                   return startSel;
-               let range = rangeForClick$1(view, cur.pos, cur.bias, type);
-               if (start.pos != cur.pos && !extend) {
-                   let startRange = rangeForClick$1(view, start.pos, start.bias, type);
-                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
-                   range = from < range.from ? EditorSelection$1.range(from, to) : EditorSelection$1.range(to, from);
-               }
-               if (extend)
-                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
-               else if (multiple)
-                   return startSel.addRange(range);
-               else
-                   return EditorSelection$1.create([range]);
-           }
-       };
-   }
-   handlers$1.dragstart = (view, event) => {
-       let { selection: { main } } = view.state;
-       let { mouseSelection } = view.inputState;
-       if (mouseSelection)
-           mouseSelection.dragging = main;
-       if (event.dataTransfer) {
-           event.dataTransfer.setData("Text", view.state.sliceDoc(main.from, main.to));
-           event.dataTransfer.effectAllowed = "copyMove";
-       }
-   };
-   function dropText$1(view, event, text, direct) {
-       if (!text)
-           return;
-       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       event.preventDefault();
-       let { mouseSelection } = view.inputState;
-       let del = direct && mouseSelection && mouseSelection.dragging && mouseSelection.dragMove ?
-           { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;
-       let ins = { from: dropPos, insert: text };
-       let changes = view.state.changes(del ? [del, ins] : ins);
-       view.focus();
-       view.dispatch({
-           changes,
-           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
-           userEvent: del ? "move.drop" : "input.drop"
-       });
-   }
-   handlers$1.drop = (view, event) => {
-       if (!event.dataTransfer)
-           return;
-       if (view.state.readOnly)
-           return event.preventDefault();
-       let files = event.dataTransfer.files;
-       if (files && files.length) { // For a file drop, read the file's text.
-           event.preventDefault();
-           let text = Array(files.length), read = 0;
-           let finishFile = () => {
-               if (++read == files.length)
-                   dropText$1(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
-           };
-           for (let i = 0; i < files.length; i++) {
-               let reader = new FileReader;
-               reader.onerror = finishFile;
-               reader.onload = () => {
-                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
-                       text[i] = reader.result;
-                   finishFile();
-               };
-               reader.readAsText(files[i]);
-           }
-       }
-       else {
-           dropText$1(view, event, event.dataTransfer.getData("Text"), true);
-       }
-   };
-   handlers$1.paste = (view, event) => {
-       if (view.state.readOnly)
-           return event.preventDefault();
-       view.observer.flush();
-       let data = brokenClipboardAPI$1 ? null : event.clipboardData;
-       if (data) {
-           doPaste$1(view, data.getData("text/plain"));
-           event.preventDefault();
-       }
-       else {
-           capturePaste$1(view);
-       }
-   };
-   function captureCopy$1(view, text) {
-       // The extra wrapper is somehow necessary on IE/Edge to prevent the
-       // content from being mangled when it is put onto the clipboard
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.value = text;
-       target.focus();
-       target.selectionEnd = text.length;
-       target.selectionStart = 0;
-       setTimeout(() => {
-           target.remove();
-           view.focus();
-       }, 50);
-   }
-   function copiedRange$1(state) {
-       let content = [], ranges = [], linewise = false;
-       for (let range of state.selection.ranges)
-           if (!range.empty) {
-               content.push(state.sliceDoc(range.from, range.to));
-               ranges.push(range);
-           }
-       if (!content.length) {
-           // Nothing selected, do a line-wise copy
-           let upto = -1;
-           for (let { from } of state.selection.ranges) {
-               let line = state.doc.lineAt(from);
-               if (line.number > upto) {
-                   content.push(line.text);
-                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
-               }
-               upto = line.number;
-           }
-           linewise = true;
-       }
-       return { text: content.join(state.lineBreak), ranges, linewise };
-   }
-   let lastLinewiseCopy$1 = null;
-   handlers$1.copy = handlers$1.cut = (view, event) => {
-       let { text, ranges, linewise } = copiedRange$1(view.state);
-       if (!text && !linewise)
-           return;
-       lastLinewiseCopy$1 = linewise ? text : null;
-       let data = brokenClipboardAPI$1 ? null : event.clipboardData;
-       if (data) {
-           event.preventDefault();
-           data.clearData();
-           data.setData("text/plain", text);
-       }
-       else {
-           captureCopy$1(view, text);
-       }
-       if (event.type == "cut" && !view.state.readOnly)
-           view.dispatch({
-               changes: ranges,
-               scrollIntoView: true,
-               userEvent: "delete.cut"
-           });
-   };
-   function updateForFocusChange$1(view) {
-       setTimeout(() => {
-           if (view.hasFocus != view.inputState.notifiedFocused)
-               view.update([]);
-       }, 10);
-   }
-   handlers$1.focus = updateForFocusChange$1;
-   handlers$1.blur = view => {
-       view.observer.clearSelectionRange();
-       updateForFocusChange$1(view);
-   };
-   function forceClearComposition(view, rapid) {
-       if (view.docView.compositionDeco.size) {
-           view.inputState.rapidCompositionStart = rapid;
-           try {
-               view.update([]);
-           }
-           finally {
-               view.inputState.rapidCompositionStart = false;
-           }
-       }
-   }
-   handlers$1.compositionstart = handlers$1.compositionupdate = view => {
-       if (view.inputState.compositionFirstChange == null)
-           view.inputState.compositionFirstChange = true;
-       if (view.inputState.composing < 0) {
-           // FIXME possibly set a timeout to clear it again on Android
-           view.inputState.composing = 0;
-           if (view.docView.compositionDeco.size) {
-               view.observer.flush();
-               forceClearComposition(view, true);
-           }
-       }
-   };
-   handlers$1.compositionend = view => {
-       view.inputState.composing = -1;
-       view.inputState.compositionEndedAt = Date.now();
-       view.inputState.compositionFirstChange = null;
-       setTimeout(() => {
-           if (view.inputState.composing < 0)
-               forceClearComposition(view, false);
-       }, 50);
-   };
-   handlers$1.contextmenu = view => {
-       view.inputState.lastContextMenu = Date.now();
-   };
-   handlers$1.beforeinput = (view, event) => {
-       var _a;
-       // Because Chrome Android doesn't fire useful key events, use
-       // beforeinput to detect backspace (and possibly enter and delete,
-       // but those usually don't even seem to fire beforeinput events at
-       // the moment) and fake a key event for it.
-       //
-       // (preventDefault on beforeinput, though supported in the spec,
-       // seems to do nothing at all on Chrome).
-       let pending;
-       if (browser$1.chrome && browser$1.android && (pending = PendingKeys$1.find(key => key.inputType == event.inputType))) {
-           view.observer.delayAndroidKey(pending.key, pending.keyCode);
-           if (pending.key == "Backspace" || pending.key == "Delete") {
-               let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
-               setTimeout(() => {
-                   var _a;
-                   // Backspacing near uneditable nodes on Chrome Android sometimes
-                   // closes the virtual keyboard. This tries to crudely detect
-                   // that and refocus to get it back.
-                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
-                       view.contentDOM.blur();
-                       view.focus();
-                   }
-               }, 100);
-           }
-       }
-   };
-
-   const wrappingWhiteSpace$1 = ["pre-wrap", "normal", "pre-line", "break-spaces"];
-   let HeightOracle$1 = class HeightOracle {
-       constructor() {
-           this.doc = Text$1.empty;
-           this.lineWrapping = false;
-           this.heightSamples = {};
-           this.lineHeight = 14;
-           this.charWidth = 7;
-           this.lineLength = 30;
-           // Used to track, during updateHeight, if any actual heights changed
-           this.heightChanged = false;
-       }
-       heightForGap(from, to) {
-           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
-           if (this.lineWrapping)
-               lines += Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength);
-           return this.lineHeight * lines;
-       }
-       heightForLine(length) {
-           if (!this.lineWrapping)
-               return this.lineHeight;
-           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
-           return lines * this.lineHeight;
-       }
-       setDoc(doc) { this.doc = doc; return this; }
-       mustRefreshForWrapping(whiteSpace) {
-           return (wrappingWhiteSpace$1.indexOf(whiteSpace) > -1) != this.lineWrapping;
-       }
-       mustRefreshForHeights(lineHeights) {
-           let newHeight = false;
-           for (let i = 0; i < lineHeights.length; i++) {
-               let h = lineHeights[i];
-               if (h < 0) {
-                   i++;
-               }
-               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
-                   newHeight = true;
-                   this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return newHeight;
-       }
-       refresh(whiteSpace, lineHeight, charWidth, lineLength, knownHeights) {
-           let lineWrapping = wrappingWhiteSpace$1.indexOf(whiteSpace) > -1;
-           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
-           this.lineWrapping = lineWrapping;
-           this.lineHeight = lineHeight;
-           this.charWidth = charWidth;
-           this.lineLength = lineLength;
-           if (changed) {
-               this.heightSamples = {};
-               for (let i = 0; i < knownHeights.length; i++) {
-                   let h = knownHeights[i];
-                   if (h < 0)
-                       i++;
-                   else
-                       this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return changed;
-       }
-   };
-   // This object is used by `updateHeight` to make DOM measurements
-   // arrive at the right nides. The `heights` array is a sequence of
-   // block heights, starting from position `from`.
-   let MeasuredHeights$1 = class MeasuredHeights {
-       constructor(from, heights) {
-           this.from = from;
-           this.heights = heights;
-           this.index = 0;
-       }
-       get more() { return this.index < this.heights.length; }
-   };
-   /**
-   Record used to represent information about a block-level element
-   in the editor view.
-   */
-   let BlockInfo$1 = class BlockInfo {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the element in the document.
-       */
-       from, 
-       /**
-       The length of the element.
-       */
-       length, 
-       /**
-       The top position of the element (relative to the top of the
-       document).
-       */
-       top, 
-       /**
-       Its height.
-       */
-       height, 
-       /**
-       The type of element this is. When querying lines, this may be
-       an array of all the blocks that make up the line.
-       */
-       type) {
-           this.from = from;
-           this.length = length;
-           this.top = top;
-           this.height = height;
-           this.type = type;
-       }
-       /**
-       The end of the element as a document position.
-       */
-       get to() { return this.from + this.length; }
-       /**
-       The bottom position of the element.
-       */
-       get bottom() { return this.top + this.height; }
-       /**
-       @internal
-       */
-       join(other) {
-           let detail = (Array.isArray(this.type) ? this.type : [this])
-               .concat(Array.isArray(other.type) ? other.type : [other]);
-           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
-       }
-   };
-   var QueryType$2 = /*@__PURE__*/(function (QueryType) {
-       QueryType[QueryType["ByPos"] = 0] = "ByPos";
-       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
-       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
-   return QueryType})(QueryType$2 || (QueryType$2 = {}));
-   const Epsilon$1 = 1e-3;
-   let HeightMap$1 = class HeightMap {
-       constructor(length, // The number of characters covered
-       height, // Height of this part of the document
-       flags = 2 /* Outdated */) {
-           this.length = length;
-           this.height = height;
-           this.flags = flags;
-       }
-       get outdated() { return (this.flags & 2 /* Outdated */) > 0; }
-       set outdated(value) { this.flags = (value ? 2 /* Outdated */ : 0) | (this.flags & ~2 /* Outdated */); }
-       setHeight(oracle, height) {
-           if (this.height != height) {
-               if (Math.abs(this.height - height) > Epsilon$1)
-                   oracle.heightChanged = true;
-               this.height = height;
-           }
-       }
-       // Base case is to replace a leaf node, which simply builds a tree
-       // from the new nodes and returns that (HeightMapBranch and
-       // HeightMapGap override this to actually use from/to)
-       replace(_from, _to, nodes) {
-           return HeightMap.of(nodes);
-       }
-       // Again, these are base cases, and are overridden for branch and gap nodes.
-       decomposeLeft(_to, result) { result.push(this); }
-       decomposeRight(_from, result) { result.push(this); }
-       applyChanges(decorations, oldDoc, oracle, changes) {
-           let me = this;
-           for (let i = changes.length - 1; i >= 0; i--) {
-               let { fromA, toA, fromB, toB } = changes[i];
-               let start = me.lineAt(fromA, QueryType$2.ByPosNoHeight, oldDoc, 0, 0);
-               let end = start.to >= toA ? start : me.lineAt(toA, QueryType$2.ByPosNoHeight, oldDoc, 0, 0);
-               toB += end.to - toA;
-               toA = end.to;
-               while (i > 0 && start.from <= changes[i - 1].toA) {
-                   fromA = changes[i - 1].fromA;
-                   fromB = changes[i - 1].fromB;
-                   i--;
-                   if (fromA < start.from)
-                       start = me.lineAt(fromA, QueryType$2.ByPosNoHeight, oldDoc, 0, 0);
-               }
-               fromB += start.from - fromA;
-               fromA = start.from;
-               let nodes = NodeBuilder$1.build(oracle, decorations, fromB, toB);
-               me = me.replace(fromA, toA, nodes);
-           }
-           return me.updateHeight(oracle, 0);
-       }
-       static empty() { return new HeightMapText$1(0, 0); }
-       // nodes uses null values to indicate the position of line breaks.
-       // There are never line breaks at the start or end of the array, or
-       // two line breaks next to each other, and the array isn't allowed
-       // to be empty (same restrictions as return value from the builder).
-       static of(nodes) {
-           if (nodes.length == 1)
-               return nodes[0];
-           let i = 0, j = nodes.length, before = 0, after = 0;
-           for (;;) {
-               if (i == j) {
-                   if (before > after * 2) {
-                       let split = nodes[i - 1];
-                       if (split.break)
-                           nodes.splice(--i, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(--i, 1, split.left, split.right);
-                       j += 1 + split.break;
-                       before -= split.size;
-                   }
-                   else if (after > before * 2) {
-                       let split = nodes[j];
-                       if (split.break)
-                           nodes.splice(j, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(j, 1, split.left, split.right);
-                       j += 2 + split.break;
-                       after -= split.size;
-                   }
-                   else {
-                       break;
-                   }
-               }
-               else if (before < after) {
-                   let next = nodes[i++];
-                   if (next)
-                       before += next.size;
-               }
-               else {
-                   let next = nodes[--j];
-                   if (next)
-                       after += next.size;
-               }
-           }
-           let brk = 0;
-           if (nodes[i - 1] == null) {
-               brk = 1;
-               i--;
-           }
-           else if (nodes[i] == null) {
-               brk = 1;
-               j++;
-           }
-           return new HeightMapBranch$1(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
-       }
-   };
-   HeightMap$1.prototype.size = 1;
-   let HeightMapBlock$1 = class HeightMapBlock extends HeightMap$1 {
-       constructor(length, height, type) {
-           super(length, height);
-           this.type = type;
-       }
-       blockAt(_height, _doc, top, offset) {
-           return new BlockInfo$1(offset, this.length, top, this.height, this.type);
-       }
-       lineAt(_value, _type, doc, top, offset) {
-           return this.blockAt(0, doc, top, offset);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           if (from <= offset + this.length && to >= offset)
-               f(this.blockAt(0, doc, top, offset));
-       }
-       updateHeight(oracle, offset = 0, _force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(oracle, measured.heights[measured.index++]);
-           this.outdated = false;
-           return this;
-       }
-       toString() { return `block(${this.length})`; }
-   };
-   let HeightMapText$1 = class HeightMapText extends HeightMapBlock$1 {
-       constructor(length, height) {
-           super(length, height, BlockType$1.Text);
-           this.collapsed = 0; // Amount of collapsed content in the line
-           this.widgetHeight = 0; // Maximum inline widget height
-       }
-       replace(_from, _to, nodes) {
-           let node = nodes[0];
-           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap$1 && (node.flags & 4 /* SingleLine */)) &&
-               Math.abs(this.length - node.length) < 10) {
-               if (node instanceof HeightMapGap$1)
-                   node = new HeightMapText(node.length, this.height);
-               else
-                   node.height = this.height;
-               if (!this.outdated)
-                   node.outdated = false;
-               return node;
-           }
-           else {
-               return HeightMap$1.of(nodes);
-           }
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(oracle, measured.heights[measured.index++]);
-           else if (force || this.outdated)
-               this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)));
-           this.outdated = false;
-           return this;
-       }
-       toString() {
-           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
-       }
-   };
-   let HeightMapGap$1 = class HeightMapGap extends HeightMap$1 {
-       constructor(length) { super(length, 0); }
-       lines(doc, offset) {
-           let firstLine = doc.lineAt(offset).number, lastLine = doc.lineAt(offset + this.length).number;
-           return { firstLine, lastLine, lineHeight: this.height / (lastLine - firstLine + 1) };
-       }
-       blockAt(height, doc, top, offset) {
-           let { firstLine, lastLine, lineHeight } = this.lines(doc, offset);
-           let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / lineHeight)));
-           let { from, length } = doc.line(firstLine + line);
-           return new BlockInfo$1(from, length, top + lineHeight * line, lineHeight, BlockType$1.Text);
-       }
-       lineAt(value, type, doc, top, offset) {
-           if (type == QueryType$2.ByHeight)
-               return this.blockAt(value, doc, top, offset);
-           if (type == QueryType$2.ByPosNoHeight) {
-               let { from, to } = doc.lineAt(value);
-               return new BlockInfo$1(from, to - from, 0, 0, BlockType$1.Text);
-           }
-           let { firstLine, lineHeight } = this.lines(doc, offset);
-           let { from, length, number } = doc.lineAt(value);
-           return new BlockInfo$1(from, length, top + lineHeight * (number - firstLine), lineHeight, BlockType$1.Text);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           let { firstLine, lineHeight } = this.lines(doc, offset);
-           for (let pos = Math.max(from, offset), end = Math.min(offset + this.length, to); pos <= end;) {
-               let line = doc.lineAt(pos);
-               if (pos == from)
-                   top += lineHeight * (line.number - firstLine);
-               f(new BlockInfo$1(line.from, line.length, top, lineHeight, BlockType$1.Text));
-               top += lineHeight;
-               pos = line.to + 1;
-           }
-       }
-       replace(from, to, nodes) {
-           let after = this.length - to;
-           if (after > 0) {
-               let last = nodes[nodes.length - 1];
-               if (last instanceof HeightMapGap)
-                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
-               else
-                   nodes.push(null, new HeightMapGap(after - 1));
-           }
-           if (from > 0) {
-               let first = nodes[0];
-               if (first instanceof HeightMapGap)
-                   nodes[0] = new HeightMapGap(from + first.length);
-               else
-                   nodes.unshift(new HeightMapGap(from - 1), null);
-           }
-           return HeightMap$1.of(nodes);
-       }
-       decomposeLeft(to, result) {
-           result.push(new HeightMapGap(to - 1), null);
-       }
-       decomposeRight(from, result) {
-           result.push(null, new HeightMapGap(this.length - from - 1));
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let end = offset + this.length;
-           if (measured && measured.from <= offset + this.length && measured.more) {
-               // Fill in part of this gap with measured lines. We know there
-               // can't be widgets or collapsed ranges in those lines, because
-               // they would already have been added to the heightmap (gaps
-               // only contain plain text).
-               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
-               let wasChanged = oracle.heightChanged;
-               if (measured.from > offset)
-                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
-               while (pos <= end && measured.more) {
-                   let len = oracle.doc.lineAt(pos).length;
-                   if (nodes.length)
-                       nodes.push(null);
-                   let height = measured.heights[measured.index++];
-                   if (singleHeight == -1)
-                       singleHeight = height;
-                   else if (Math.abs(height - singleHeight) >= Epsilon$1)
-                       singleHeight = -2;
-                   let line = new HeightMapText$1(len, height);
-                   line.outdated = false;
-                   nodes.push(line);
-                   pos += len + 1;
-               }
-               if (pos <= end)
-                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
-               let result = HeightMap$1.of(nodes);
-               oracle.heightChanged = wasChanged || singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon$1 ||
-                   Math.abs(singleHeight - this.lines(oracle.doc, offset).lineHeight) >= Epsilon$1;
-               return result;
-           }
-           else if (force || this.outdated) {
-               this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));
-               this.outdated = false;
-           }
-           return this;
-       }
-       toString() { return `gap(${this.length})`; }
-   };
-   let HeightMapBranch$1 = class HeightMapBranch extends HeightMap$1 {
-       constructor(left, brk, right) {
-           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Outdated */ : 0));
-           this.left = left;
-           this.right = right;
-           this.size = left.size + right.size;
-       }
-       get break() { return this.flags & 1 /* Break */; }
-       blockAt(height, doc, top, offset) {
-           let mid = top + this.left.height;
-           return height < mid ? this.left.blockAt(height, doc, top, offset)
-               : this.right.blockAt(height, doc, mid, offset + this.left.length + this.break);
-       }
-       lineAt(value, type, doc, top, offset) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           let left = type == QueryType$2.ByHeight ? value < rightTop : value < rightOffset;
-           let base = left ? this.left.lineAt(value, type, doc, top, offset)
-               : this.right.lineAt(value, type, doc, rightTop, rightOffset);
-           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
-               return base;
-           let subQuery = type == QueryType$2.ByPosNoHeight ? QueryType$2.ByPosNoHeight : QueryType$2.ByPos;
-           if (left)
-               return base.join(this.right.lineAt(rightOffset, subQuery, doc, rightTop, rightOffset));
-           else
-               return this.left.lineAt(rightOffset, subQuery, doc, top, offset).join(base);
-       }
-       forEachLine(from, to, doc, top, offset, f) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           if (this.break) {
-               if (from < rightOffset)
-                   this.left.forEachLine(from, to, doc, top, offset, f);
-               if (to >= rightOffset)
-                   this.right.forEachLine(from, to, doc, rightTop, rightOffset, f);
-           }
-           else {
-               let mid = this.lineAt(rightOffset, QueryType$2.ByPos, doc, top, offset);
-               if (from < mid.from)
-                   this.left.forEachLine(from, mid.from - 1, doc, top, offset, f);
-               if (mid.to >= from && mid.from <= to)
-                   f(mid);
-               if (to > mid.to)
-                   this.right.forEachLine(mid.to + 1, to, doc, rightTop, rightOffset, f);
-           }
-       }
-       replace(from, to, nodes) {
-           let rightStart = this.left.length + this.break;
-           if (to < rightStart)
-               return this.balanced(this.left.replace(from, to, nodes), this.right);
-           if (from > this.left.length)
-               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
-           let result = [];
-           if (from > 0)
-               this.decomposeLeft(from, result);
-           let left = result.length;
-           for (let node of nodes)
-               result.push(node);
-           if (from > 0)
-               mergeGaps$1(result, left - 1);
-           if (to < this.length) {
-               let right = result.length;
-               this.decomposeRight(to, result);
-               mergeGaps$1(result, right);
-           }
-           return HeightMap$1.of(result);
-       }
-       decomposeLeft(to, result) {
-           let left = this.left.length;
-           if (to <= left)
-               return this.left.decomposeLeft(to, result);
-           result.push(this.left);
-           if (this.break) {
-               left++;
-               if (to >= left)
-                   result.push(null);
-           }
-           if (to > left)
-               this.right.decomposeLeft(to - left, result);
-       }
-       decomposeRight(from, result) {
-           let left = this.left.length, right = left + this.break;
-           if (from >= right)
-               return this.right.decomposeRight(from - right, result);
-           if (from < left)
-               this.left.decomposeRight(from, result);
-           if (this.break && from < right)
-               result.push(null);
-           result.push(this.right);
-       }
-       balanced(left, right) {
-           if (left.size > 2 * right.size || right.size > 2 * left.size)
-               return HeightMap$1.of(this.break ? [left, null, right] : [left, right]);
-           this.left = left;
-           this.right = right;
-           this.height = left.height + right.height;
-           this.outdated = left.outdated || right.outdated;
-           this.size = left.size + right.size;
-           this.length = left.length + this.break + right.length;
-           return this;
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
-           if (measured && measured.from <= offset + left.length && measured.more)
-               rebalance = left = left.updateHeight(oracle, offset, force, measured);
-           else
-               left.updateHeight(oracle, offset, force);
-           if (measured && measured.from <= rightStart + right.length && measured.more)
-               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
-           else
-               right.updateHeight(oracle, rightStart, force);
-           if (rebalance)
-               return this.balanced(left, right);
-           this.height = this.left.height + this.right.height;
-           this.outdated = false;
-           return this;
-       }
-       toString() { return this.left + (this.break ? " " : "-") + this.right; }
-   };
-   function mergeGaps$1(nodes, around) {
-       let before, after;
-       if (nodes[around] == null &&
-           (before = nodes[around - 1]) instanceof HeightMapGap$1 &&
-           (after = nodes[around + 1]) instanceof HeightMapGap$1)
-           nodes.splice(around - 1, 3, new HeightMapGap$1(before.length + 1 + after.length));
-   }
-   const relevantWidgetHeight$1 = 5;
-   let NodeBuilder$1 = class NodeBuilder {
-       constructor(pos, oracle) {
-           this.pos = pos;
-           this.oracle = oracle;
-           this.nodes = [];
-           this.lineStart = -1;
-           this.lineEnd = -1;
-           this.covering = null;
-           this.writtenTo = pos;
-       }
-       get isCovered() {
-           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
-       }
-       span(_from, to) {
-           if (this.lineStart > -1) {
-               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
-               if (last instanceof HeightMapText$1)
-                   last.length += end - this.pos;
-               else if (end > this.pos || !this.isCovered)
-                   this.nodes.push(new HeightMapText$1(end - this.pos, -1));
-               this.writtenTo = end;
-               if (to > end) {
-                   this.nodes.push(null);
-                   this.writtenTo++;
-                   this.lineStart = -1;
-               }
-           }
-           this.pos = to;
-       }
-       point(from, to, deco) {
-           if (from < to || deco.heightRelevant) {
-               let height = deco.widget ? deco.widget.estimatedHeight : 0;
-               if (height < 0)
-                   height = this.oracle.lineHeight;
-               let len = to - from;
-               if (deco.block) {
-                   this.addBlock(new HeightMapBlock$1(len, height, deco.type));
-               }
-               else if (len || height >= relevantWidgetHeight$1) {
-                   this.addLineDeco(height, len);
-               }
-           }
-           else if (to > from) {
-               this.span(from, to);
-           }
-           if (this.lineEnd > -1 && this.lineEnd < this.pos)
-               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
-       }
-       enterLine() {
-           if (this.lineStart > -1)
-               return;
-           let { from, to } = this.oracle.doc.lineAt(this.pos);
-           this.lineStart = from;
-           this.lineEnd = to;
-           if (this.writtenTo < from) {
-               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
-                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
-               this.nodes.push(null);
-           }
-           if (this.pos > from)
-               this.nodes.push(new HeightMapText$1(this.pos - from, -1));
-           this.writtenTo = this.pos;
-       }
-       blankContent(from, to) {
-           let gap = new HeightMapGap$1(to - from);
-           if (this.oracle.doc.lineAt(from).to == to)
-               gap.flags |= 4 /* SingleLine */;
-           return gap;
-       }
-       ensureLine() {
-           this.enterLine();
-           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
-           if (last instanceof HeightMapText$1)
-               return last;
-           let line = new HeightMapText$1(0, -1);
-           this.nodes.push(line);
-           return line;
-       }
-       addBlock(block) {
-           this.enterLine();
-           if (block.type == BlockType$1.WidgetAfter && !this.isCovered)
-               this.ensureLine();
-           this.nodes.push(block);
-           this.writtenTo = this.pos = this.pos + block.length;
-           if (block.type != BlockType$1.WidgetBefore)
-               this.covering = block;
-       }
-       addLineDeco(height, length) {
-           let line = this.ensureLine();
-           line.length += length;
-           line.collapsed += length;
-           line.widgetHeight = Math.max(line.widgetHeight, height);
-           this.writtenTo = this.pos = this.pos + length;
-       }
-       finish(from) {
-           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
-           if (this.lineStart > -1 && !(last instanceof HeightMapText$1) && !this.isCovered)
-               this.nodes.push(new HeightMapText$1(0, -1));
-           else if (this.writtenTo < this.pos || last == null)
-               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
-           let pos = from;
-           for (let node of this.nodes) {
-               if (node instanceof HeightMapText$1)
-                   node.updateHeight(this.oracle, pos);
-               pos += node ? node.length : 1;
-           }
-           return this.nodes;
-       }
-       // Always called with a region that on both sides either stretches
-       // to a line break or the end of the document.
-       // The returned array uses null to indicate line breaks, but never
-       // starts or ends in a line break, or has multiple line breaks next
-       // to each other.
-       static build(oracle, decorations, from, to) {
-           let builder = new NodeBuilder(from, oracle);
-           RangeSet$1.spans(decorations, from, to, builder, 0);
-           return builder.finish(from);
-       }
-   };
-   function heightRelevantDecoChanges$1(a, b, diff) {
-       let comp = new DecorationComparator$2;
-       RangeSet$1.compare(a, b, diff, comp, 0);
-       return comp.changes;
-   }
-   let DecorationComparator$2 = class DecorationComparator {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange() { }
-       comparePoint(from, to, a, b) {
-           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
-               addRange$1(from, to, this.changes, 5);
-       }
-   };
-
-   function visiblePixelRange$1(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       let left = Math.max(0, rect.left), right = Math.min(innerWidth, rect.right);
-       let top = Math.max(0, rect.top), bottom = Math.min(innerHeight, rect.bottom);
-       let body = dom.ownerDocument.body;
-       for (let parent = dom.parentNode; parent && parent != body;) {
-           if (parent.nodeType == 1) {
-               let elt = parent;
-               let style = window.getComputedStyle(elt);
-               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
-                   style.overflow != "visible") {
-                   let parentRect = elt.getBoundingClientRect();
-                   left = Math.max(left, parentRect.left);
-                   right = Math.min(right, parentRect.right);
-                   top = Math.max(top, parentRect.top);
-                   bottom = Math.min(bottom, parentRect.bottom);
-               }
-               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
-           }
-           else if (parent.nodeType == 11) { // Shadow root
-               parent = parent.host;
-           }
-           else {
-               break;
-           }
-       }
-       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
-           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
-   }
-   function fullPixelRange$1(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       return { left: 0, right: rect.right - rect.left,
-           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
-   }
-   // Line gaps are placeholder widgets used to hide pieces of overlong
-   // lines within the viewport, as a kludge to keep the editor
-   // responsive when a ridiculously long line is loaded into it.
-   let LineGap$1 = class LineGap {
-       constructor(from, to, size) {
-           this.from = from;
-           this.to = to;
-           this.size = size;
-       }
-       static same(a, b) {
-           if (a.length != b.length)
-               return false;
-           for (let i = 0; i < a.length; i++) {
-               let gA = a[i], gB = b[i];
-               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
-                   return false;
-           }
-           return true;
-       }
-       draw(wrapping) {
-           return Decoration$1.replace({ widget: new LineGapWidget$1(this.size, wrapping) }).range(this.from, this.to);
-       }
-   };
-   let LineGapWidget$1 = class LineGapWidget extends WidgetType$1 {
-       constructor(size, vertical) {
-           super();
-           this.size = size;
-           this.vertical = vertical;
-       }
-       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
-       toDOM() {
-           let elt = document.createElement("div");
-           if (this.vertical) {
-               elt.style.height = this.size + "px";
-           }
-           else {
-               elt.style.width = this.size + "px";
-               elt.style.height = "2px";
-               elt.style.display = "inline-block";
-           }
-           return elt;
-       }
-       get estimatedHeight() { return this.vertical ? this.size : -1; }
-   };
-   let ViewState$1 = class ViewState {
-       constructor(state) {
-           this.state = state;
-           // These are contentDOM-local coordinates
-           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
-           this.inView = true;
-           this.paddingTop = 0;
-           this.paddingBottom = 0;
-           this.contentDOMWidth = 0;
-           this.contentDOMHeight = 0;
-           this.editorHeight = 0;
-           this.editorWidth = 0;
-           this.heightOracle = new HeightOracle$1;
-           // See VP.MaxDOMHeight
-           this.scaler = IdScaler$1;
-           this.scrollTarget = null;
-           // Briefly set to true when printing, to disable viewport limiting
-           this.printing = false;
-           // Flag set when editor content was redrawn, so that the next
-           // measure stage knows it must read DOM layout
-           this.mustMeasureContent = true;
-           this.defaultTextDirection = Direction$1.RTL;
-           this.visibleRanges = [];
-           // Cursor 'assoc' is only significant when the cursor is on a line
-           // wrap point, where it must stick to the character that it is
-           // associated with. Since browsers don't provide a reasonable
-           // interface to set or query this, when a selection is set that
-           // might cause this to be significant, this flag is set. The next
-           // measure phase will check whether the cursor is on a line-wrapping
-           // boundary and, if so, reset it to make sure it is positioned in
-           // the right place.
-           this.mustEnforceCursorAssoc = false;
-           this.stateDeco = state.facet(decorations$1).filter(d => typeof d != "function");
-           this.heightMap = HeightMap$1.empty().applyChanges(this.stateDeco, Text$1.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange$1(0, 0, 0, state.doc.length)]);
-           this.viewport = this.getViewport(0, null);
-           this.updateViewportLines();
-           this.updateForViewport();
-           this.lineGaps = this.ensureLineGaps([]);
-           this.lineGapDeco = Decoration$1.set(this.lineGaps.map(gap => gap.draw(false)));
-           this.computeVisibleRanges();
-       }
-       updateForViewport() {
-           let viewports = [this.viewport], { main } = this.state.selection;
-           for (let i = 0; i <= 1; i++) {
-               let pos = i ? main.head : main.anchor;
-               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
-                   let { from, to } = this.lineBlockAt(pos);
-                   viewports.push(new Viewport$1(from, to));
-               }
-           }
-           this.viewports = viewports.sort((a, b) => a.from - b.from);
-           this.scaler = this.heightMap.height <= 7000000 /* MaxDOMHeight */ ? IdScaler$1 :
-               new BigScaler$1(this.heightOracle.doc, this.heightMap, this.viewports);
-       }
-       updateViewportLines() {
-           this.viewportLines = [];
-           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, block => {
-               this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock$1(block, this.scaler));
-           });
-       }
-       update(update, scrollTarget = null) {
-           this.state = update.state;
-           let prevDeco = this.stateDeco;
-           this.stateDeco = this.state.facet(decorations$1).filter(d => typeof d != "function");
-           let contentChanges = update.changedRanges;
-           let heightChanges = ChangedRange$1.extendWithRanges(contentChanges, heightRelevantDecoChanges$1(prevDeco, this.stateDeco, update ? update.changes : ChangeSet$1.empty(this.state.doc.length)));
-           let prevHeight = this.heightMap.height;
-           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
-           if (this.heightMap.height != prevHeight)
-               update.flags |= 2 /* Height */;
-           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
-           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
-               !this.viewportIsAppropriate(viewport))
-               viewport = this.getViewport(0, scrollTarget);
-           let updateLines = !update.changes.empty || (update.flags & 2 /* Height */) ||
-               viewport.from != this.viewport.from || viewport.to != this.viewport.to;
-           this.viewport = viewport;
-           this.updateForViewport();
-           if (updateLines)
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
-               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
-           update.flags |= this.computeVisibleRanges();
-           if (scrollTarget)
-               this.scrollTarget = scrollTarget;
-           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
-               update.state.selection.main.empty && update.state.selection.main.assoc)
-               this.mustEnforceCursorAssoc = true;
-       }
-       measure(view) {
-           let dom = view.contentDOM, style = window.getComputedStyle(dom);
-           let oracle = this.heightOracle;
-           let whiteSpace = style.whiteSpace;
-           this.defaultTextDirection = style.direction == "rtl" ? Direction$1.RTL : Direction$1.LTR;
-           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
-           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != dom.clientHeight;
-           this.contentDOMHeight = dom.clientHeight;
-           this.mustMeasureContent = false;
-           let result = 0, bias = 0;
-           // Vertical padding
-           let paddingTop = parseInt(style.paddingTop) || 0, paddingBottom = parseInt(style.paddingBottom) || 0;
-           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
-               this.paddingTop = paddingTop;
-               this.paddingBottom = paddingBottom;
-               result |= 8 /* Geometry */ | 2 /* Height */;
-           }
-           if (this.editorWidth != view.scrollDOM.clientWidth) {
-               if (oracle.lineWrapping)
-                   measureContent = true;
-               this.editorWidth = view.scrollDOM.clientWidth;
-               result |= 8 /* Geometry */;
-           }
-           // Pixel viewport
-           let pixelViewport = (this.printing ? fullPixelRange$1 : visiblePixelRange$1)(dom, this.paddingTop);
-           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
-           this.pixelViewport = pixelViewport;
-           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
-           if (inView != this.inView) {
-               this.inView = inView;
-               if (inView)
-                   measureContent = true;
-           }
-           if (!this.inView)
-               return 0;
-           let contentWidth = dom.clientWidth;
-           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
-               this.contentDOMWidth = contentWidth;
-               this.editorHeight = view.scrollDOM.clientHeight;
-               result |= 8 /* Geometry */;
-           }
-           if (measureContent) {
-               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
-               if (oracle.mustRefreshForHeights(lineHeights))
-                   refresh = true;
-               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
-                   let { lineHeight, charWidth } = view.docView.measureTextSize();
-                   refresh = oracle.refresh(whiteSpace, lineHeight, charWidth, contentWidth / charWidth, lineHeights);
-                   if (refresh) {
-                       view.docView.minWidth = 0;
-                       result |= 8 /* Geometry */;
-                   }
-               }
-               if (dTop > 0 && dBottom > 0)
-                   bias = Math.max(dTop, dBottom);
-               else if (dTop < 0 && dBottom < 0)
-                   bias = Math.min(dTop, dBottom);
-               oracle.heightChanged = false;
-               for (let vp of this.viewports) {
-                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
-                   this.heightMap = this.heightMap.updateHeight(oracle, 0, refresh, new MeasuredHeights$1(vp.from, heights));
-               }
-               if (oracle.heightChanged)
-                   result |= 2 /* Height */;
-           }
-           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
-               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
-           if (viewportChange)
-               this.viewport = this.getViewport(bias, this.scrollTarget);
-           this.updateForViewport();
-           if ((result & 2 /* Height */) || viewportChange)
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
-               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
-           result |= this.computeVisibleRanges();
-           if (this.mustEnforceCursorAssoc) {
-               this.mustEnforceCursorAssoc = false;
-               // This is done in the read stage, because moving the selection
-               // to a line end is going to trigger a layout anyway, so it
-               // can't be a pure write. It should be rare that it does any
-               // writing.
-               view.docView.enforceCursorAssoc();
-           }
-           return result;
-       }
-       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
-       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
-       getViewport(bias, scrollTarget) {
-           // This will divide VP.Margin between the top and the
-           // bottom, depending on the bias (the change in viewport position
-           // since the last update). It'll hold a number between 0 and 1
-           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* Margin */ / 2));
-           let map = this.heightMap, doc = this.state.doc, { visibleTop, visibleBottom } = this;
-           let viewport = new Viewport$1(map.lineAt(visibleTop - marginTop * 1000 /* Margin */, QueryType$2.ByHeight, doc, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* Margin */, QueryType$2.ByHeight, doc, 0, 0).to);
-           // If scrollTarget is given, make sure the viewport includes that position
-           if (scrollTarget) {
-               let { head } = scrollTarget.range;
-               if (head < viewport.from || head > viewport.to) {
-                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
-                   let block = map.lineAt(head, QueryType$2.ByPos, doc, 0, 0), topPos;
-                   if (scrollTarget.y == "center")
-                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
-                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
-                       topPos = block.top;
-                   else
-                       topPos = block.bottom - viewHeight;
-                   viewport = new Viewport$1(map.lineAt(topPos - 1000 /* Margin */ / 2, QueryType$2.ByHeight, doc, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* Margin */ / 2, QueryType$2.ByHeight, doc, 0, 0).to);
-               }
-           }
-           return viewport;
-       }
-       mapViewport(viewport, changes) {
-           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
-           return new Viewport$1(this.heightMap.lineAt(from, QueryType$2.ByPos, this.state.doc, 0, 0).from, this.heightMap.lineAt(to, QueryType$2.ByPos, this.state.doc, 0, 0).to);
-       }
-       // Checks if a given viewport covers the visible part of the
-       // document and not too much beyond that.
-       viewportIsAppropriate({ from, to }, bias = 0) {
-           if (!this.inView)
-               return true;
-           let { top } = this.heightMap.lineAt(from, QueryType$2.ByPos, this.state.doc, 0, 0);
-           let { bottom } = this.heightMap.lineAt(to, QueryType$2.ByPos, this.state.doc, 0, 0);
-           let { visibleTop, visibleBottom } = this;
-           return (from == 0 || top <= visibleTop - Math.max(10 /* MinCoverMargin */, Math.min(-bias, 250 /* MaxCoverMargin */))) &&
-               (to == this.state.doc.length ||
-                   bottom >= visibleBottom + Math.max(10 /* MinCoverMargin */, Math.min(bias, 250 /* MaxCoverMargin */))) &&
-               (top > visibleTop - 2 * 1000 /* Margin */ && bottom < visibleBottom + 2 * 1000 /* Margin */);
-       }
-       mapLineGaps(gaps, changes) {
-           if (!gaps.length || changes.empty)
-               return gaps;
-           let mapped = [];
-           for (let gap of gaps)
-               if (!changes.touchesRange(gap.from, gap.to))
-                   mapped.push(new LineGap$1(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));
-           return mapped;
-       }
-       // Computes positions in the viewport where the start or end of a
-       // line should be hidden, trying to reuse existing line gaps when
-       // appropriate to avoid unneccesary redraws.
-       // Uses crude character-counting for the positioning and sizing,
-       // since actual DOM coordinates aren't always available and
-       // predictable. Relies on generous margins (see LG.Margin) to hide
-       // the artifacts this might produce from the user.
-       ensureLineGaps(current) {
-           let gaps = [];
-           // This won't work at all in predominantly right-to-left text.
-           if (this.defaultTextDirection != Direction$1.LTR)
-               return gaps;
-           for (let line of this.viewportLines) {
-               if (line.length < 4000 /* DoubleMargin */)
-                   continue;
-               let structure = lineStructure$1(line.from, line.to, this.stateDeco);
-               if (structure.total < 4000 /* DoubleMargin */)
-                   continue;
-               let viewFrom, viewTo;
-               if (this.heightOracle.lineWrapping) {
-                   let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
-                   viewFrom = findPosition$1(structure, (this.visibleTop - line.top - marginHeight) / line.height);
-                   viewTo = findPosition$1(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
-               }
-               else {
-                   let totalWidth = structure.total * this.heightOracle.charWidth;
-                   let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
-                   viewFrom = findPosition$1(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
-                   viewTo = findPosition$1(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
-               }
-               let outside = [];
-               if (viewFrom > line.from)
-                   outside.push({ from: line.from, to: viewFrom });
-               if (viewTo < line.to)
-                   outside.push({ from: viewTo, to: line.to });
-               let sel = this.state.selection.main;
-               // Make sure the gaps don't cover a selection end
-               if (sel.from >= line.from && sel.from <= line.to)
-                   cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
-               if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
-                   cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
-               for (let { from, to } of outside)
-                   if (to - from > 1000 /* HalfMargin */) {
-                       gaps.push(find$1(current, gap => gap.from >= line.from && gap.to <= line.to &&
-                           Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
-                           new LineGap$1(from, to, this.gapSize(line, from, to, structure)));
-                   }
-           }
-           return gaps;
-       }
-       gapSize(line, from, to, structure) {
-           let fraction = findFraction$1(structure, to) - findFraction$1(structure, from);
-           if (this.heightOracle.lineWrapping) {
-               return line.height * fraction;
-           }
-           else {
-               return structure.total * this.heightOracle.charWidth * fraction;
-           }
-       }
-       updateLineGaps(gaps) {
-           if (!LineGap$1.same(gaps, this.lineGaps)) {
-               this.lineGaps = gaps;
-               this.lineGapDeco = Decoration$1.set(gaps.map(gap => gap.draw(this.heightOracle.lineWrapping)));
-           }
-       }
-       computeVisibleRanges() {
-           let deco = this.stateDeco;
-           if (this.lineGaps.length)
-               deco = deco.concat(this.lineGapDeco);
-           let ranges = [];
-           RangeSet$1.spans(deco, this.viewport.from, this.viewport.to, {
-               span(from, to) { ranges.push({ from, to }); },
-               point() { }
-           }, 20);
-           let changed = ranges.length != this.visibleRanges.length ||
-               this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);
-           this.visibleRanges = ranges;
-           return changed ? 4 /* Viewport */ : 0;
-       }
-       lineBlockAt(pos) {
-           return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
-               scaleBlock$1(this.heightMap.lineAt(pos, QueryType$2.ByPos, this.state.doc, 0, 0), this.scaler);
-       }
-       lineBlockAtHeight(height) {
-           return scaleBlock$1(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType$2.ByHeight, this.state.doc, 0, 0), this.scaler);
-       }
-       elementAtHeight(height) {
-           return scaleBlock$1(this.heightMap.blockAt(this.scaler.fromDOM(height), this.state.doc, 0, 0), this.scaler);
-       }
-       get docHeight() {
-           return this.scaler.toDOM(this.heightMap.height);
-       }
-       get contentHeight() {
-           return this.docHeight + this.paddingTop + this.paddingBottom;
-       }
-   };
-   let Viewport$1 = class Viewport {
-       constructor(from, to) {
-           this.from = from;
-           this.to = to;
-       }
-   };
-   function lineStructure$1(from, to, stateDeco) {
-       let ranges = [], pos = from, total = 0;
-       RangeSet$1.spans(stateDeco, from, to, {
-           span() { },
-           point(from, to) {
-               if (from > pos) {
-                   ranges.push({ from: pos, to: from });
-                   total += from - pos;
-               }
-               pos = to;
-           }
-       }, 20); // We're only interested in collapsed ranges of a significant size
-       if (pos < to) {
-           ranges.push({ from: pos, to });
-           total += to - pos;
-       }
-       return { total, ranges };
-   }
-   function findPosition$1({ total, ranges }, ratio) {
-       if (ratio <= 0)
-           return ranges[0].from;
-       if (ratio >= 1)
-           return ranges[ranges.length - 1].to;
-       let dist = Math.floor(total * ratio);
-       for (let i = 0;; i++) {
-           let { from, to } = ranges[i], size = to - from;
-           if (dist <= size)
-               return from + dist;
-           dist -= size;
-       }
-   }
-   function findFraction$1(structure, pos) {
-       let counted = 0;
-       for (let { from, to } of structure.ranges) {
-           if (pos <= to) {
-               counted += pos - from;
-               break;
-           }
-           counted += to - from;
-       }
-       return counted / structure.total;
-   }
-   function cutRange(ranges, from, to) {
-       for (let i = 0; i < ranges.length; i++) {
-           let r = ranges[i];
-           if (r.from < to && r.to > from) {
-               let pieces = [];
-               if (r.from < from)
-                   pieces.push({ from: r.from, to: from });
-               if (r.to > to)
-                   pieces.push({ from: to, to: r.to });
-               ranges.splice(i, 1, ...pieces);
-               i += pieces.length - 1;
-           }
-       }
-   }
-   function find$1(array, f) {
-       for (let val of array)
-           if (f(val))
-               return val;
-       return undefined;
-   }
-   // Don't scale when the document height is within the range of what
-   // the DOM can handle.
-   const IdScaler$1 = {
-       toDOM(n) { return n; },
-       fromDOM(n) { return n; },
-       scale: 1
-   };
-   // When the height is too big (> VP.MaxDOMHeight), scale down the
-   // regions outside the viewports so that the total height is
-   // VP.MaxDOMHeight.
-   let BigScaler$1 = class BigScaler {
-       constructor(doc, heightMap, viewports) {
-           let vpHeight = 0, base = 0, domBase = 0;
-           this.viewports = viewports.map(({ from, to }) => {
-               let top = heightMap.lineAt(from, QueryType$2.ByPos, doc, 0, 0).top;
-               let bottom = heightMap.lineAt(to, QueryType$2.ByPos, doc, 0, 0).bottom;
-               vpHeight += bottom - top;
-               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
-           });
-           this.scale = (7000000 /* MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
-           for (let obj of this.viewports) {
-               obj.domTop = domBase + (obj.top - base) * this.scale;
-               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
-               base = obj.bottom;
-           }
-       }
-       toDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.top)
-                   return domBase + (n - base) * this.scale;
-               if (n <= vp.bottom)
-                   return vp.domTop + (n - vp.top);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-       fromDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.domTop)
-                   return base + (n - domBase) / this.scale;
-               if (n <= vp.domBottom)
-                   return vp.top + (n - vp.domTop);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-   };
-   function scaleBlock$1(block, scaler) {
-       if (scaler.scale == 1)
-           return block;
-       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
-       return new BlockInfo$1(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block.type) ? block.type.map(b => scaleBlock$1(b, scaler)) : block.type);
-   }
-
-   const theme$1 = /*@__PURE__*/Facet$1.define({ combine: strs => strs.join(" ") });
-   const darkTheme$1 = /*@__PURE__*/Facet$1.define({ combine: values => values.indexOf(true) > -1 });
-   const baseThemeID$1 = /*@__PURE__*/StyleModule.newName(), baseLightID$1 = /*@__PURE__*/StyleModule.newName(), baseDarkID$1 = /*@__PURE__*/StyleModule.newName();
-   const lightDarkIDs$1 = { "&light": "." + baseLightID$1, "&dark": "." + baseDarkID$1 };
-   function buildTheme$1(main, spec, scopes) {
-       return new StyleModule(spec, {
-           finish(sel) {
-               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
-                   if (m == "&")
-                       return main;
-                   if (!scopes || !scopes[m])
-                       throw new RangeError(`Unsupported selector: ${m}`);
-                   return scopes[m];
-               }) : main + " " + sel;
-           }
-       });
-   }
-   const baseTheme$1$2 = /*@__PURE__*/buildTheme$1("." + baseThemeID$1, {
-       "&.cm-editor": {
-           position: "relative !important",
-           boxSizing: "border-box",
-           "&.cm-focused": {
-               // Provide a simple default outline to make sure a focused
-               // editor is visually distinct. Can't leave the default behavior
-               // because that will apply to the content element, which is
-               // inside the scrollable container and doesn't include the
-               // gutters. We also can't use an 'auto' outline, since those
-               // are, for some reason, drawn behind the element content, which
-               // will cause things like the active line background to cover
-               // the outline (#297).
-               outline: "1px dotted #212121"
-           },
-           display: "flex !important",
-           flexDirection: "column"
-       },
-       ".cm-scroller": {
-           display: "flex !important",
-           alignItems: "flex-start !important",
-           fontFamily: "monospace",
-           lineHeight: 1.4,
-           height: "100%",
-           overflowX: "auto",
-           position: "relative",
-           zIndex: 0
-       },
-       ".cm-content": {
-           margin: 0,
-           flexGrow: 2,
-           minHeight: "100%",
-           display: "block",
-           whiteSpace: "pre",
-           wordWrap: "normal",
-           boxSizing: "border-box",
-           padding: "4px 0",
-           outline: "none",
-           "&[contenteditable=true]": {
-               WebkitUserModify: "read-write-plaintext-only",
-           }
-       },
-       ".cm-lineWrapping": {
-           whiteSpace_fallback: "pre-wrap",
-           whiteSpace: "break-spaces",
-           wordBreak: "break-word",
-           overflowWrap: "anywhere"
-       },
-       "&light .cm-content": { caretColor: "black" },
-       "&dark .cm-content": { caretColor: "white" },
-       ".cm-line": {
-           display: "block",
-           padding: "0 2px 0 4px"
-       },
-       ".cm-selectionLayer": {
-           zIndex: -1,
-           contain: "size style"
-       },
-       ".cm-selectionBackground": {
-           position: "absolute",
-       },
-       "&light .cm-selectionBackground": {
-           background: "#d9d9d9"
-       },
-       "&dark .cm-selectionBackground": {
-           background: "#222"
-       },
-       "&light.cm-focused .cm-selectionBackground": {
-           background: "#d7d4f0"
-       },
-       "&dark.cm-focused .cm-selectionBackground": {
-           background: "#233"
-       },
-       ".cm-cursorLayer": {
-           zIndex: 100,
-           contain: "size style",
-           pointerEvents: "none"
-       },
-       "&.cm-focused .cm-cursorLayer": {
-           animation: "steps(1) cm-blink 1.2s infinite"
-       },
-       // Two animations defined so that we can switch between them to
-       // restart the animation without forcing another style
-       // recomputation.
-       "@keyframes cm-blink": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
-       "@keyframes cm-blink2": { "0%": {}, "50%": { visibility: "hidden" }, "100%": {} },
-       ".cm-cursor, .cm-dropCursor": {
-           position: "absolute",
-           borderLeft: "1.2px solid black",
-           marginLeft: "-0.6px",
-           pointerEvents: "none",
-       },
-       ".cm-cursor": {
-           display: "none"
-       },
-       "&dark .cm-cursor": {
-           borderLeftColor: "#444"
-       },
-       "&.cm-focused .cm-cursor": {
-           display: "block"
-       },
-       "&light .cm-activeLine": { backgroundColor: "#f3f9ff" },
-       "&dark .cm-activeLine": { backgroundColor: "#223039" },
-       "&light .cm-specialChar": { color: "red" },
-       "&dark .cm-specialChar": { color: "#f78" },
-       ".cm-gutters": {
-           display: "flex",
-           height: "100%",
-           boxSizing: "border-box",
-           left: 0,
-           zIndex: 200
-       },
-       "&light .cm-gutters": {
-           backgroundColor: "#f5f5f5",
-           color: "#6c6c6c",
-           borderRight: "1px solid #ddd"
-       },
-       "&dark .cm-gutters": {
-           backgroundColor: "#333338",
-           color: "#ccc"
-       },
-       ".cm-gutter": {
-           display: "flex !important",
-           flexDirection: "column",
-           flexShrink: 0,
-           boxSizing: "border-box",
-           minHeight: "100%",
-           overflow: "hidden"
-       },
-       ".cm-gutterElement": {
-           boxSizing: "border-box"
-       },
-       ".cm-lineNumbers .cm-gutterElement": {
-           padding: "0 3px 0 5px",
-           minWidth: "20px",
-           textAlign: "right",
-           whiteSpace: "nowrap"
-       },
-       "&light .cm-activeLineGutter": {
-           backgroundColor: "#e2f2ff"
-       },
-       "&dark .cm-activeLineGutter": {
-           backgroundColor: "#222227"
-       },
-       ".cm-panels": {
-           boxSizing: "border-box",
-           position: "sticky",
-           left: 0,
-           right: 0
-       },
-       "&light .cm-panels": {
-           backgroundColor: "#f5f5f5",
-           color: "black"
-       },
-       "&light .cm-panels-top": {
-           borderBottom: "1px solid #ddd"
-       },
-       "&light .cm-panels-bottom": {
-           borderTop: "1px solid #ddd"
-       },
-       "&dark .cm-panels": {
-           backgroundColor: "#333338",
-           color: "white"
-       },
-       ".cm-tab": {
-           display: "inline-block",
-           overflow: "hidden",
-           verticalAlign: "bottom"
-       },
-       ".cm-widgetBuffer": {
-           verticalAlign: "text-top",
-           height: "1em",
-           display: "inline"
-       },
-       ".cm-placeholder": {
-           color: "#888",
-           display: "inline-block",
-           verticalAlign: "top",
-       },
-       ".cm-button": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           padding: ".2em 1em",
-           borderRadius: "1px"
-       },
-       "&light .cm-button": {
-           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
-           }
-       },
-       "&dark .cm-button": {
-           backgroundImage: "linear-gradient(#393939, #111)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#111, #333)"
-           }
-       },
-       ".cm-textfield": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           border: "1px solid silver",
-           padding: ".2em .5em"
-       },
-       "&light .cm-textfield": {
-           backgroundColor: "white"
-       },
-       "&dark .cm-textfield": {
-           border: "1px solid #555",
-           backgroundColor: "inherit"
-       }
-   }, lightDarkIDs$1);
-
-   const observeOptions$1 = {
-       childList: true,
-       characterData: true,
-       subtree: true,
-       attributes: true,
-       characterDataOldValue: true
-   };
-   // IE11 has very broken mutation observers, so we also listen to
-   // DOMCharacterDataModified there
-   const useCharData$1 = browser$1.ie && browser$1.ie_version <= 11;
-   let DOMObserver$1 = class DOMObserver {
-       constructor(view, onChange, onScrollChanged) {
-           this.view = view;
-           this.onChange = onChange;
-           this.onScrollChanged = onScrollChanged;
-           this.active = false;
-           // The known selection. Kept in our own object, as opposed to just
-           // directly accessing the selection because:
-           //  - Safari doesn't report the right selection in shadow DOM
-           //  - Reading from the selection forces a DOM layout
-           //  - This way, we can ignore selectionchange events if we have
-           //    already seen the 'new' selection
-           this.selectionRange = new DOMSelectionState$1;
-           // Set when a selection change is detected, cleared on flush
-           this.selectionChanged = false;
-           this.delayedFlush = -1;
-           this.resizeTimeout = -1;
-           this.queue = [];
-           this.delayedAndroidKey = null;
-           this.scrollTargets = [];
-           this.intersection = null;
-           this.resize = null;
-           this.intersecting = false;
-           this.gapIntersection = null;
-           this.gaps = [];
-           // Timeout for scheduling check of the parents that need scroll handlers
-           this.parentCheck = -1;
-           this.dom = view.contentDOM;
-           this.observer = new MutationObserver(mutations => {
-               for (let mut of mutations)
-                   this.queue.push(mut);
-               // IE11 will sometimes (on typing over a selection or
-               // backspacing out a single character text node) call the
-               // observer callback before actually updating the DOM.
-               //
-               // Unrelatedly, iOS Safari will, when ending a composition,
-               // sometimes first clear it, deliver the mutations, and then
-               // reinsert the finished text. CodeMirror's handling of the
-               // deletion will prevent the reinsertion from happening,
-               // breaking composition.
-               if ((browser$1.ie && browser$1.ie_version <= 11 || browser$1.ios && view.composing) &&
-                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
-                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
-                   this.flushSoon();
-               else
-                   this.flush();
-           });
-           if (useCharData$1)
-               this.onCharData = (event) => {
-                   this.queue.push({ target: event.target,
-                       type: "characterData",
-                       oldValue: event.prevValue });
-                   this.flushSoon();
-               };
-           this.onSelectionChange = this.onSelectionChange.bind(this);
-           window.addEventListener("resize", this.onResize = this.onResize.bind(this));
-           if (typeof ResizeObserver == "function") {
-               this.resize = new ResizeObserver(() => {
-                   if (this.view.docView.lastUpdate < Date.now() - 75)
-                       this.onResize();
-               });
-               this.resize.observe(view.scrollDOM);
-           }
-           window.addEventListener("beforeprint", this.onPrint = this.onPrint.bind(this));
-           this.start();
-           window.addEventListener("scroll", this.onScroll = this.onScroll.bind(this));
-           if (typeof IntersectionObserver == "function") {
-               this.intersection = new IntersectionObserver(entries => {
-                   if (this.parentCheck < 0)
-                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
-                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
-                       this.intersecting = !this.intersecting;
-                       if (this.intersecting != this.view.inView)
-                           this.onScrollChanged(document.createEvent("Event"));
-                   }
-               }, {});
-               this.intersection.observe(this.dom);
-               this.gapIntersection = new IntersectionObserver(entries => {
-                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
-                       this.onScrollChanged(document.createEvent("Event"));
-               }, {});
-           }
-           this.listenForScroll();
-           this.readSelectionRange();
-           this.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
-       }
-       onScroll(e) {
-           if (this.intersecting)
-               this.flush(false);
-           this.onScrollChanged(e);
-       }
-       onResize() {
-           if (this.resizeTimeout < 0)
-               this.resizeTimeout = setTimeout(() => {
-                   this.resizeTimeout = -1;
-                   this.view.requestMeasure();
-               }, 50);
-       }
-       onPrint() {
-           this.view.viewState.printing = true;
-           this.view.measure();
-           setTimeout(() => {
-               this.view.viewState.printing = false;
-               this.view.requestMeasure();
-           }, 500);
-       }
-       updateGaps(gaps) {
-           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
-               this.gapIntersection.disconnect();
-               for (let gap of gaps)
-                   this.gapIntersection.observe(gap);
-               this.gaps = gaps;
-           }
-       }
-       onSelectionChange(event) {
-           if (!this.readSelectionRange() || this.delayedAndroidKey)
-               return;
-           let { view } = this, sel = this.selectionRange;
-           if (view.state.facet(editable$1) ? view.root.activeElement != this.dom : !hasSelection$1(view.dom, sel))
-               return;
-           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
-           if (context && context.ignoreEvent(event))
-               return;
-           // Deletions on IE11 fire their events in the wrong order, giving
-           // us a selection change event before the DOM changes are
-           // reported.
-           // Chrome Android has a similar issue when backspacing out a
-           // selection (#645).
-           if ((browser$1.ie && browser$1.ie_version <= 11 || browser$1.android && browser$1.chrome) && !view.state.selection.main.empty &&
-               // (Selection.isCollapsed isn't reliable on IE)
-               sel.focusNode && isEquivalentPosition$1(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
-               this.flushSoon();
-           else
-               this.flush(false);
-       }
-       readSelectionRange() {
-           let { root } = this.view, domSel = getSelection$1(root);
-           // The Selection object is broken in shadow roots in Safari. See
-           // https://github.com/codemirror/codemirror.next/issues/414
-           let range = browser$1.safari && root.nodeType == 11 && deepActiveElement() == this.view.contentDOM &&
-               safariSelectionRangeHack$1(this.view) || domSel;
-           if (this.selectionRange.eq(range))
-               return false;
-           this.selectionRange.setRange(range);
-           return this.selectionChanged = true;
-       }
-       setSelectionRange(anchor, head) {
-           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
-           this.selectionChanged = false;
-       }
-       clearSelectionRange() {
-           this.selectionRange.set(null, 0, null, 0);
-       }
-       listenForScroll() {
-           this.parentCheck = -1;
-           let i = 0, changed = null;
-           for (let dom = this.dom; dom;) {
-               if (dom.nodeType == 1) {
-                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
-                       i++;
-                   else if (!changed)
-                       changed = this.scrollTargets.slice(0, i);
-                   if (changed)
-                       changed.push(dom);
-                   dom = dom.assignedSlot || dom.parentNode;
-               }
-               else if (dom.nodeType == 11) { // Shadow root
-                   dom = dom.host;
-               }
-               else {
-                   break;
-               }
-           }
-           if (i < this.scrollTargets.length && !changed)
-               changed = this.scrollTargets.slice(0, i);
-           if (changed) {
-               for (let dom of this.scrollTargets)
-                   dom.removeEventListener("scroll", this.onScroll);
-               for (let dom of this.scrollTargets = changed)
-                   dom.addEventListener("scroll", this.onScroll);
-           }
-       }
-       ignore(f) {
-           if (!this.active)
-               return f();
-           try {
-               this.stop();
-               return f();
-           }
-           finally {
-               this.start();
-               this.clear();
-           }
-       }
-       start() {
-           if (this.active)
-               return;
-           this.observer.observe(this.dom, observeOptions$1);
-           if (useCharData$1)
-               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
-           this.active = true;
-       }
-       stop() {
-           if (!this.active)
-               return;
-           this.active = false;
-           this.observer.disconnect();
-           if (useCharData$1)
-               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
-       }
-       // Throw away any pending changes
-       clear() {
-           this.processRecords();
-           this.queue.length = 0;
-           this.selectionChanged = false;
-       }
-       // Chrome Android, especially in combination with GBoard, not only
-       // doesn't reliably fire regular key events, but also often
-       // surrounds the effect of enter or backspace with a bunch of
-       // composition events that, when interrupted, cause text duplication
-       // or other kinds of corruption. This hack makes the editor back off
-       // from handling DOM changes for a moment when such a key is
-       // detected (via beforeinput or keydown), and then tries to flush
-       // them or, if that has no effect, dispatches the given key.
-       delayAndroidKey(key, keyCode) {
-           if (!this.delayedAndroidKey)
-               requestAnimationFrame(() => {
-                   let key = this.delayedAndroidKey;
-                   this.delayedAndroidKey = null;
-                   this.delayedFlush = -1;
-                   if (!this.flush())
-                       dispatchKey$1(this.view.contentDOM, key.key, key.keyCode);
-               });
-           // Since backspace beforeinput is sometimes signalled spuriously,
-           // Enter always takes precedence.
-           if (!this.delayedAndroidKey || key == "Enter")
-               this.delayedAndroidKey = { key, keyCode };
-       }
-       flushSoon() {
-           if (this.delayedFlush < 0)
-               this.delayedFlush = window.setTimeout(() => { this.delayedFlush = -1; this.flush(); }, 20);
-       }
-       forceFlush() {
-           if (this.delayedFlush >= 0) {
-               window.clearTimeout(this.delayedFlush);
-               this.delayedFlush = -1;
-               this.flush();
-           }
-       }
-       processRecords() {
-           let records = this.queue;
-           for (let mut of this.observer.takeRecords())
-               records.push(mut);
-           if (records.length)
-               this.queue = [];
-           let from = -1, to = -1, typeOver = false;
-           for (let record of records) {
-               let range = this.readMutation(record);
-               if (!range)
-                   continue;
-               if (range.typeOver)
-                   typeOver = true;
-               if (from == -1) {
-                   ({ from, to } = range);
-               }
-               else {
-                   from = Math.min(range.from, from);
-                   to = Math.max(range.to, to);
-               }
-           }
-           return { from, to, typeOver };
-       }
-       // Apply pending changes, if any
-       flush(readSelection = true) {
-           // Completely hold off flushing when pending keys are set—the code
-           // managing those will make sure processRecords is called and the
-           // view is resynchronized after
-           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
-               return;
-           if (readSelection)
-               this.readSelectionRange();
-           let { from, to, typeOver } = this.processRecords();
-           let newSel = this.selectionChanged && hasSelection$1(this.dom, this.selectionRange);
-           if (from < 0 && !newSel)
-               return;
-           this.selectionChanged = false;
-           let startState = this.view.state;
-           let handled = this.onChange(from, to, typeOver);
-           // The view wasn't updated
-           if (this.view.state == startState)
-               this.view.update([]);
-           return handled;
-       }
-       readMutation(rec) {
-           let cView = this.view.docView.nearest(rec.target);
-           if (!cView || cView.ignoreMutation(rec))
-               return null;
-           cView.markDirty(rec.type == "attributes");
-           if (rec.type == "attributes")
-               cView.dirty |= 4 /* Attrs */;
-           if (rec.type == "childList") {
-               let childBefore = findChild$1(cView, rec.previousSibling || rec.target.previousSibling, -1);
-               let childAfter = findChild$1(cView, rec.nextSibling || rec.target.nextSibling, 1);
-               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
-                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
-           }
-           else if (rec.type == "characterData") {
-               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
-           }
-           else {
-               return null;
-           }
-       }
-       destroy() {
-           var _a, _b, _c;
-           this.stop();
-           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
-           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
-           (_c = this.resize) === null || _c === void 0 ? void 0 : _c.disconnect();
-           for (let dom of this.scrollTargets)
-               dom.removeEventListener("scroll", this.onScroll);
-           window.removeEventListener("scroll", this.onScroll);
-           window.removeEventListener("resize", this.onResize);
-           window.removeEventListener("beforeprint", this.onPrint);
-           this.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
-           clearTimeout(this.parentCheck);
-           clearTimeout(this.resizeTimeout);
-       }
-   };
-   function findChild$1(cView, dom, dir) {
-       while (dom) {
-           let curView = ContentView$1.get(dom);
-           if (curView && curView.parent == cView)
-               return curView;
-           let parent = dom.parentNode;
-           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
-       }
-       return null;
-   }
-   // Used to work around a Safari Selection/shadow DOM bug (#414)
-   function safariSelectionRangeHack$1(view) {
-       let found = null;
-       // Because Safari (at least in 2018-2021) doesn't provide regular
-       // access to the selection inside a shadowroot, we have to perform a
-       // ridiculous hack to get at it—using `execCommand` to trigger a
-       // `beforeInput` event so that we can read the target range from the
-       // event.
-       function read(event) {
-           event.preventDefault();
-           event.stopImmediatePropagation();
-           found = event.getTargetRanges()[0];
-       }
-       view.contentDOM.addEventListener("beforeinput", read, true);
-       document.execCommand("indent");
-       view.contentDOM.removeEventListener("beforeinput", read, true);
-       if (!found)
-           return null;
-       let anchorNode = found.startContainer, anchorOffset = found.startOffset;
-       let focusNode = found.endContainer, focusOffset = found.endOffset;
-       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
-       // Since such a range doesn't distinguish between anchor and head,
-       // use a heuristic that flips it around if its end matches the
-       // current anchor.
-       if (isEquivalentPosition$1(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
-           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
-       return { anchorNode, anchorOffset, focusNode, focusOffset };
-   }
-
-   function applyDOMChange$1(view, start, end, typeOver) {
-       let change, newSel;
-       let sel = view.state.selection.main;
-       if (start > -1) {
-           let bounds = view.docView.domBoundsAround(start, end, 0);
-           if (!bounds || view.state.readOnly)
-               return false;
-           let { from, to } = bounds;
-           let selPoints = view.docView.impreciseHead || view.docView.impreciseAnchor ? [] : selectionPoints$1(view);
-           let reader = new DOMReader$1(selPoints, view.state);
-           reader.readRange(bounds.startDOM, bounds.endDOM);
-           let preferredPos = sel.from, preferredSide = null;
-           // Prefer anchoring to end when Backspace is pressed (or, on
-           // Android, when something was deleted)
-           if (view.inputState.lastKeyCode === 8 && view.inputState.lastKeyTime > Date.now() - 100 ||
-               browser$1.android && reader.text.length < to - from) {
-               preferredPos = sel.to;
-               preferredSide = "end";
-           }
-           let diff = findDiff$1(view.state.doc.sliceString(from, to, LineBreakPlaceholder$1), reader.text, preferredPos - from, preferredSide);
-           if (diff) {
-               // Chrome inserts two newlines when pressing shift-enter at the
-               // end of a line. This drops one of those.
-               if (browser$1.chrome && view.inputState.lastKeyCode == 13 &&
-                   diff.toB == diff.from + 2 && reader.text.slice(diff.from, diff.toB) == LineBreakPlaceholder$1 + LineBreakPlaceholder$1)
-                   diff.toB--;
-               change = { from: from + diff.from, to: from + diff.toA,
-                   insert: Text$1.of(reader.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder$1)) };
-           }
-           newSel = selectionFromPoints$1(selPoints, from);
-       }
-       else if (view.hasFocus || !view.state.facet(editable$1)) {
-           let domSel = view.observer.selectionRange;
-           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
-           let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
-               !contains$1(view.contentDOM, domSel.focusNode)
-               ? view.state.selection.main.head
-               : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
-           let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
-               !contains$1(view.contentDOM, domSel.anchorNode)
-               ? view.state.selection.main.anchor
-               : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
-           if (head != sel.head || anchor != sel.anchor)
-               newSel = EditorSelection$1.single(anchor, head);
-       }
-       if (!change && !newSel)
-           return false;
-       // Heuristic to notice typing over a selected character
-       if (!change && typeOver && !sel.empty && newSel && newSel.main.empty)
-           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
-       // If the change is inside the selection and covers most of it,
-       // assume it is a selection replace (with identical characters at
-       // the start/end not included in the diff)
-       else if (change && change.from >= sel.from && change.to <= sel.to &&
-           (change.from != sel.from || change.to != sel.to) &&
-           (sel.to - sel.from) - (change.to - change.from) <= 4)
-           change = {
-               from: sel.from, to: sel.to,
-               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
-           };
-       // Detect insert-period-on-double-space Mac behavior, and transform
-       // it into a regular space insert.
-       else if ((browser$1.mac || browser$1.android) && change && change.from == change.to && change.from == sel.head - 1 &&
-           change.insert.toString() == ".")
-           change = { from: sel.from, to: sel.to, insert: Text$1.of([" "]) };
-       if (change) {
-           let startState = view.state;
-           if (browser$1.ios && view.inputState.flushIOSKey(view))
-               return true;
-           // Android browsers don't fire reasonable key events for enter,
-           // backspace, or delete. So this detects changes that look like
-           // they're caused by those keys, and reinterprets them as key
-           // events. (Some of these keys are also handled by beforeinput
-           // events and the pendingAndroidKey mechanism, but that's not
-           // reliable in all situations.)
-           if (browser$1.android &&
-               ((change.from == sel.from && change.to == sel.to &&
-                   change.insert.length == 1 && change.insert.lines == 2 &&
-                   dispatchKey$1(view.contentDOM, "Enter", 13)) ||
-                   (change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 &&
-                       dispatchKey$1(view.contentDOM, "Backspace", 8)) ||
-                   (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
-                       dispatchKey$1(view.contentDOM, "Delete", 46))))
-               return true;
-           let text = change.insert.toString();
-           if (view.state.facet(inputHandler$2).some(h => h(view, change.from, change.to, text)))
-               return true;
-           if (view.inputState.composing >= 0)
-               view.inputState.composing++;
-           let tr;
-           if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
-               (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
-               view.inputState.composing < 0) {
-               let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
-               let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
-               tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
-           }
-           else {
-               let changes = startState.changes(change);
-               let mainSel = newSel && !startState.selection.main.eq(newSel.main) && newSel.main.to <= changes.newLength
-                   ? newSel.main : undefined;
-               // Try to apply a composition change to all cursors
-               if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
-                   change.to <= sel.to && change.to >= sel.to - 10) {
-                   let replaced = view.state.sliceDoc(change.from, change.to);
-                   let compositionRange = compositionSurroundingNode(view) || view.state.doc.lineAt(sel.head);
-                   let offset = sel.to - change.to, size = sel.to - sel.from;
-                   tr = startState.changeByRange(range => {
-                       if (range.from == sel.from && range.to == sel.to)
-                           return { changes, range: mainSel || range.map(changes) };
-                       let to = range.to - offset, from = to - replaced.length;
-                       if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
-                           // Unfortunately, there's no way to make multiple
-                           // changes in the same node work without aborting
-                           // composition, so cursors in the composition range are
-                           // ignored.
-                           compositionRange && range.to >= compositionRange.from && range.from <= compositionRange.to)
-                           return { range };
-                       let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
-                       return {
-                           changes: rangeChanges,
-                           range: !mainSel ? range.map(rangeChanges) :
-                               EditorSelection$1.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
-                       };
-                   });
-               }
-               else {
-                   tr = {
-                       changes,
-                       selection: mainSel && startState.selection.replaceRange(mainSel)
-                   };
-               }
-           }
-           let userEvent = "input.type";
-           if (view.composing) {
-               userEvent += ".compose";
-               if (view.inputState.compositionFirstChange) {
-                   userEvent += ".start";
-                   view.inputState.compositionFirstChange = false;
-               }
-           }
-           view.dispatch(tr, { scrollIntoView: true, userEvent });
-           return true;
-       }
-       else if (newSel && !newSel.main.eq(sel)) {
-           let scrollIntoView = false, userEvent = "select";
-           if (view.inputState.lastSelectionTime > Date.now() - 50) {
-               if (view.inputState.lastSelectionOrigin == "select")
-                   scrollIntoView = true;
-               userEvent = view.inputState.lastSelectionOrigin;
-           }
-           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
-           return true;
-       }
-       else {
-           return false;
-       }
-   }
-   function findDiff$1(a, b, preferredPos, preferredSide) {
-       let minLen = Math.min(a.length, b.length);
-       let from = 0;
-       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
-           from++;
-       if (from == minLen && a.length == b.length)
-           return null;
-       let toA = a.length, toB = b.length;
-       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
-           toA--;
-           toB--;
-       }
-       if (preferredSide == "end") {
-           let adjust = Math.max(0, from - Math.min(toA, toB));
-           preferredPos -= toA + adjust - from;
-       }
-       if (toA < from && a.length < b.length) {
-           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
-           from -= move;
-           toB = from + (toB - toA);
-           toA = from;
-       }
-       else if (toB < from) {
-           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
-           from -= move;
-           toA = from + (toA - toB);
-           toB = from;
-       }
-       return { from, toA, toB };
-   }
-   function selectionPoints$1(view) {
-       let result = [];
-       if (view.root.activeElement != view.contentDOM)
-           return result;
-       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
-       if (anchorNode) {
-           result.push(new DOMPoint$1(anchorNode, anchorOffset));
-           if (focusNode != anchorNode || focusOffset != anchorOffset)
-               result.push(new DOMPoint$1(focusNode, focusOffset));
-       }
-       return result;
-   }
-   function selectionFromPoints$1(points, base) {
-       if (points.length == 0)
-           return null;
-       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
-       return anchor > -1 && head > -1 ? EditorSelection$1.single(anchor + base, head + base) : null;
-   }
-
-   // The editor's update state machine looks something like this:
-   //
-   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
-   //                                         ↑      ↓
-   //                                         Updating (measure)
-   //
-   // The difference between 'Idle' and 'Idle (unchecked)' lies in
-   // whether a layout check has been scheduled. A regular update through
-   // the `update` method updates the DOM in a write-only fashion, and
-   // relies on a check (scheduled with `requestAnimationFrame`) to make
-   // sure everything is where it should be and the viewport covers the
-   // visible code. That check continues to measure and then optionally
-   // update until it reaches a coherent state.
-   /**
-   An editor view represents the editor's user interface. It holds
-   the editable DOM surface, and possibly other elements such as the
-   line number gutter. It handles events and dispatches state
-   transactions for editing actions.
-   */
-   let EditorView$1 = class EditorView {
-       /**
-       Construct a new view. You'll want to either provide a `parent`
-       option, or put `view.dom` into your document after creating a
-       view, so that the user can see the editor.
-       */
-       constructor(
-       /**
-       Initialization options.
-       */
-       config = {}) {
-           this.plugins = [];
-           this.pluginMap = new Map;
-           this.editorAttrs = {};
-           this.contentAttrs = {};
-           this.bidiCache = [];
-           this.destroyed = false;
-           /**
-           @internal
-           */
-           this.updateState = 2 /* Updating */;
-           /**
-           @internal
-           */
-           this.measureScheduled = -1;
-           /**
-           @internal
-           */
-           this.measureRequests = [];
-           this.contentDOM = document.createElement("div");
-           this.scrollDOM = document.createElement("div");
-           this.scrollDOM.tabIndex = -1;
-           this.scrollDOM.className = "cm-scroller";
-           this.scrollDOM.appendChild(this.contentDOM);
-           this.announceDOM = document.createElement("div");
-           this.announceDOM.style.cssText = "position: absolute; top: -10000px";
-           this.announceDOM.setAttribute("aria-live", "polite");
-           this.dom = document.createElement("div");
-           this.dom.appendChild(this.announceDOM);
-           this.dom.appendChild(this.scrollDOM);
-           this._dispatch = config.dispatch || ((tr) => this.update([tr]));
-           this.dispatch = this.dispatch.bind(this);
-           this.root = (config.root || getRoot$1(config.parent) || document);
-           this.viewState = new ViewState$1(config.state || EditorState$1.create());
-           this.plugins = this.state.facet(viewPlugin$1).map(spec => new PluginInstance$1(spec));
-           for (let plugin of this.plugins)
-               plugin.update(this);
-           this.observer = new DOMObserver$1(this, (from, to, typeOver) => {
-               return applyDOMChange$1(this, from, to, typeOver);
-           }, event => {
-               this.inputState.runScrollHandlers(this, event);
-               if (this.observer.intersecting)
-                   this.measure();
-           });
-           this.inputState = new InputState$1(this);
-           this.inputState.ensureHandlers(this, this.plugins);
-           this.docView = new DocView$1(this);
-           this.mountStyles();
-           this.updateAttrs();
-           this.updateState = 0 /* Idle */;
-           this.requestMeasure();
-           if (config.parent)
-               config.parent.appendChild(this.dom);
-       }
-       /**
-       The current editor state.
-       */
-       get state() { return this.viewState.state; }
-       /**
-       To be able to display large documents without consuming too much
-       memory or overloading the browser, CodeMirror only draws the
-       code that is visible (plus a margin around it) to the DOM. This
-       property tells you the extent of the current drawn viewport, in
-       document positions.
-       */
-       get viewport() { return this.viewState.viewport; }
-       /**
-       When there are, for example, large collapsed ranges in the
-       viewport, its size can be a lot bigger than the actual visible
-       content. Thus, if you are doing something like styling the
-       content in the viewport, it is preferable to only do so for
-       these ranges, which are the subset of the viewport that is
-       actually drawn.
-       */
-       get visibleRanges() { return this.viewState.visibleRanges; }
-       /**
-       Returns false when the editor is entirely scrolled out of view
-       or otherwise hidden.
-       */
-       get inView() { return this.viewState.inView; }
-       /**
-       Indicates whether the user is currently composing text via
-       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
-       one change has been made in the current composition.
-       */
-       get composing() { return this.inputState.composing > 0; }
-       /**
-       Indicates whether the user is currently in composing state. Note
-       that on some platforms, like Android, this will be the case a
-       lot, since just putting the cursor on a word starts a
-       composition there.
-       */
-       get compositionStarted() { return this.inputState.composing >= 0; }
-       dispatch(...input) {
-           this._dispatch(input.length == 1 && input[0] instanceof Transaction$1 ? input[0]
-               : this.state.update(...input));
-       }
-       /**
-       Update the view for the given array of transactions. This will
-       update the visible document and selection to match the state
-       produced by the transactions, and notify view plugins of the
-       change. You should usually call
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
-       as a primitive.
-       */
-       update(transactions) {
-           if (this.updateState != 0 /* Idle */)
-               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
-           let redrawn = false, attrsChanged = false, update;
-           let state = this.state;
-           for (let tr of transactions) {
-               if (tr.startState != state)
-                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
-               state = tr.state;
-           }
-           if (this.destroyed) {
-               this.viewState.state = state;
-               return;
-           }
-           this.observer.clear();
-           // When the phrases change, redraw the editor
-           if (state.facet(EditorState$1.phrases) != this.state.facet(EditorState$1.phrases))
-               return this.setState(state);
-           update = ViewUpdate$1.create(this, state, transactions);
-           let scrollTarget = this.viewState.scrollTarget;
-           try {
-               this.updateState = 2 /* Updating */;
-               for (let tr of transactions) {
-                   if (scrollTarget)
-                       scrollTarget = scrollTarget.map(tr.changes);
-                   if (tr.scrollIntoView) {
-                       let { main } = tr.state.selection;
-                       scrollTarget = new ScrollTarget$1(main.empty ? main : EditorSelection$1.cursor(main.head, main.head > main.anchor ? -1 : 1));
-                   }
-                   for (let e of tr.effects)
-                       if (e.is(scrollIntoView$3))
-                           scrollTarget = e.value;
-               }
-               this.viewState.update(update, scrollTarget);
-               this.bidiCache = CachedOrder$1.update(this.bidiCache, update.changes);
-               if (!update.empty) {
-                   this.updatePlugins(update);
-                   this.inputState.update(update);
-               }
-               redrawn = this.docView.update(update);
-               if (this.state.facet(styleModule$1) != this.styleModules)
-                   this.mountStyles();
-               attrsChanged = this.updateAttrs();
-               this.showAnnouncements(transactions);
-               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-           }
-           if (update.startState.facet(theme$1) != update.state.facet(theme$1))
-               this.viewState.mustMeasureContent = true;
-           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
-               this.requestMeasure();
-           if (!update.empty)
-               for (let listener of this.state.facet(updateListener$1))
-                   listener(update);
-       }
-       /**
-       Reset the view to the given state. (This will cause the entire
-       document to be redrawn and all view plugins to be reinitialized,
-       so you should probably only use it when the new state isn't
-       derived from the old state. Otherwise, use
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
-       */
-       setState(newState) {
-           if (this.updateState != 0 /* Idle */)
-               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
-           if (this.destroyed) {
-               this.viewState.state = newState;
-               return;
-           }
-           this.updateState = 2 /* Updating */;
-           let hadFocus = this.hasFocus;
-           try {
-               for (let plugin of this.plugins)
-                   plugin.destroy(this);
-               this.viewState = new ViewState$1(newState);
-               this.plugins = newState.facet(viewPlugin$1).map(spec => new PluginInstance$1(spec));
-               this.pluginMap.clear();
-               for (let plugin of this.plugins)
-                   plugin.update(this);
-               this.docView = new DocView$1(this);
-               this.inputState.ensureHandlers(this, this.plugins);
-               this.mountStyles();
-               this.updateAttrs();
-               this.bidiCache = [];
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-           }
-           if (hadFocus)
-               this.focus();
-           this.requestMeasure();
-       }
-       updatePlugins(update) {
-           let prevSpecs = update.startState.facet(viewPlugin$1), specs = update.state.facet(viewPlugin$1);
-           if (prevSpecs != specs) {
-               let newPlugins = [];
-               for (let spec of specs) {
-                   let found = prevSpecs.indexOf(spec);
-                   if (found < 0) {
-                       newPlugins.push(new PluginInstance$1(spec));
-                   }
-                   else {
-                       let plugin = this.plugins[found];
-                       plugin.mustUpdate = update;
-                       newPlugins.push(plugin);
-                   }
-               }
-               for (let plugin of this.plugins)
-                   if (plugin.mustUpdate != update)
-                       plugin.destroy(this);
-               this.plugins = newPlugins;
-               this.pluginMap.clear();
-               this.inputState.ensureHandlers(this, this.plugins);
-           }
-           else {
-               for (let p of this.plugins)
-                   p.mustUpdate = update;
-           }
-           for (let i = 0; i < this.plugins.length; i++)
-               this.plugins[i].update(this);
-       }
-       /**
-       @internal
-       */
-       measure(flush = true) {
-           if (this.destroyed)
-               return;
-           if (this.measureScheduled > -1)
-               cancelAnimationFrame(this.measureScheduled);
-           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
-           if (flush)
-               this.observer.flush();
-           let updated = null;
-           try {
-               for (let i = 0;; i++) {
-                   this.updateState = 1 /* Measuring */;
-                   let oldViewport = this.viewport;
-                   let changed = this.viewState.measure(this);
-                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
-                       break;
-                   if (i > 5) {
-                       console.warn(this.measureRequests.length
-                           ? "Measure loop restarted more than 5 times"
-                           : "Viewport failed to stabilize");
-                       break;
-                   }
-                   let measuring = [];
-                   // Only run measure requests in this cycle when the viewport didn't change
-                   if (!(changed & 4 /* Viewport */))
-                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
-                   let measured = measuring.map(m => {
-                       try {
-                           return m.read(this);
-                       }
-                       catch (e) {
-                           logException$1(this.state, e);
-                           return BadMeasure$1;
-                       }
-                   });
-                   let update = ViewUpdate$1.create(this, this.state, []), redrawn = false, scrolled = false;
-                   update.flags |= changed;
-                   if (!updated)
-                       updated = update;
-                   else
-                       updated.flags |= changed;
-                   this.updateState = 2 /* Updating */;
-                   if (!update.empty) {
-                       this.updatePlugins(update);
-                       this.inputState.update(update);
-                       this.updateAttrs();
-                       redrawn = this.docView.update(update);
-                   }
-                   for (let i = 0; i < measuring.length; i++)
-                       if (measured[i] != BadMeasure$1) {
-                           try {
-                               let m = measuring[i];
-                               if (m.write)
-                                   m.write(measured[i], this);
-                           }
-                           catch (e) {
-                               logException$1(this.state, e);
-                           }
-                       }
-                   if (this.viewState.scrollTarget) {
-                       this.docView.scrollIntoView(this.viewState.scrollTarget);
-                       this.viewState.scrollTarget = null;
-                       scrolled = true;
-                   }
-                   if (redrawn)
-                       this.docView.updateSelection(true);
-                   if (this.viewport.from == oldViewport.from && this.viewport.to == oldViewport.to &&
-                       !scrolled && this.measureRequests.length == 0)
-                       break;
-               }
-           }
-           finally {
-               this.updateState = 0 /* Idle */;
-               this.measureScheduled = -1;
-           }
-           if (updated && !updated.empty)
-               for (let listener of this.state.facet(updateListener$1))
-                   listener(updated);
-       }
-       /**
-       Get the CSS classes for the currently active editor themes.
-       */
-       get themeClasses() {
-           return baseThemeID$1 + " " +
-               (this.state.facet(darkTheme$1) ? baseDarkID$1 : baseLightID$1) + " " +
-               this.state.facet(theme$1);
-       }
-       updateAttrs() {
-           let editorAttrs = attrsFromFacet$1(this, editorAttributes$1, {
-               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
-           });
-           let contentAttrs = {
-               spellcheck: "false",
-               autocorrect: "off",
-               autocapitalize: "off",
-               translate: "no",
-               contenteditable: !this.state.facet(editable$1) ? "false" : "true",
-               class: "cm-content",
-               style: `${browser$1.tabSize}: ${this.state.tabSize}`,
-               role: "textbox",
-               "aria-multiline": "true"
-           };
-           if (this.state.readOnly)
-               contentAttrs["aria-readonly"] = "true";
-           attrsFromFacet$1(this, contentAttributes$1, contentAttrs);
-           let changed = this.observer.ignore(() => {
-               let changedContent = updateAttrs$1(this.contentDOM, this.contentAttrs, contentAttrs);
-               let changedEditor = updateAttrs$1(this.dom, this.editorAttrs, editorAttrs);
-               return changedContent || changedEditor;
-           });
-           this.editorAttrs = editorAttrs;
-           this.contentAttrs = contentAttrs;
-           return changed;
-       }
-       showAnnouncements(trs) {
-           let first = true;
-           for (let tr of trs)
-               for (let effect of tr.effects)
-                   if (effect.is(EditorView.announce)) {
-                       if (first)
-                           this.announceDOM.textContent = "";
-                       first = false;
-                       let div = this.announceDOM.appendChild(document.createElement("div"));
-                       div.textContent = effect.value;
-                   }
-       }
-       mountStyles() {
-           this.styleModules = this.state.facet(styleModule$1);
-           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1$2).reverse());
-       }
-       readMeasured() {
-           if (this.updateState == 2 /* Updating */)
-               throw new Error("Reading the editor layout isn't allowed during an update");
-           if (this.updateState == 0 /* Idle */ && this.measureScheduled > -1)
-               this.measure(false);
-       }
-       /**
-       Schedule a layout measurement, optionally providing callbacks to
-       do custom DOM measuring followed by a DOM write phase. Using
-       this is preferable reading DOM layout directly from, for
-       example, an event handler, because it'll make sure measuring and
-       drawing done by other components is synchronized, avoiding
-       unnecessary DOM layout computations.
-       */
-       requestMeasure(request) {
-           if (this.measureScheduled < 0)
-               this.measureScheduled = requestAnimationFrame(() => this.measure());
-           if (request) {
-               if (request.key != null)
-                   for (let i = 0; i < this.measureRequests.length; i++) {
-                       if (this.measureRequests[i].key === request.key) {
-                           this.measureRequests[i] = request;
-                           return;
-                       }
-                   }
-               this.measureRequests.push(request);
-           }
-       }
-       /**
-       Get the value of a specific plugin, if present. Note that
-       plugins that crash can be dropped from a view, so even when you
-       know you registered a given plugin, it is recommended to check
-       the return value of this method.
-       */
-       plugin(plugin) {
-           let known = this.pluginMap.get(plugin);
-           if (known === undefined || known && known.spec != plugin)
-               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
-           return known && known.update(this).value;
-       }
-       /**
-       The top position of the document, in screen coordinates. This
-       may be negative when the editor is scrolled down. Points
-       directly to the top of the first line, not above the padding.
-       */
-       get documentTop() {
-           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
-       }
-       /**
-       Reports the padding above and below the document.
-       */
-       get documentPadding() {
-           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
-       }
-       /**
-       Find the text line or block widget at the given vertical
-       position (which is interpreted as relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)
-       */
-       elementAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.elementAtHeight(height);
-       }
-       /**
-       Find the line block (see
-       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
-       height.
-       */
-       lineBlockAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.lineBlockAtHeight(height);
-       }
-       /**
-       Get the extent and vertical position of all [line
-       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
-       are relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
-       */
-       get viewportLineBlocks() {
-           return this.viewState.viewportLines;
-       }
-       /**
-       Find the line block around the given document position. A line
-       block is a range delimited on both sides by either a
-       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
-       start/end of the document. It will usually just hold a line of
-       text, but may be broken into multiple textblocks by block
-       widgets.
-       */
-       lineBlockAt(pos) {
-           return this.viewState.lineBlockAt(pos);
-       }
-       /**
-       The editor's total content height.
-       */
-       get contentHeight() {
-           return this.viewState.contentHeight;
-       }
-       /**
-       Move a cursor position by [grapheme
-       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
-       the motion is away from the line start, or towards it. In
-       bidirectional text, the line is traversed in visual order, using
-       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-       When the start position was the last one on the line, the
-       returned position will be across the line break. If there is no
-       further line, the original position is returned.
-       
-       By default, this method moves over a single cluster. The
-       optional `by` argument can be used to move across more. It will
-       be called with the first cluster as argument, and should return
-       a predicate that determines, for each subsequent cluster,
-       whether it should also be moved over.
-       */
-       moveByChar(start, forward, by) {
-           return skipAtoms$1(this, start, moveByChar$1(this, start, forward, by));
-       }
-       /**
-       Move a cursor position across the next group of either
-       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
-       non-whitespace characters.
-       */
-       moveByGroup(start, forward) {
-           return skipAtoms$1(this, start, moveByChar$1(this, start, forward, initial => byGroup$1(this, start.head, initial)));
-       }
-       /**
-       Move to the next line boundary in the given direction. If
-       `includeWrap` is true, line wrapping is on, and there is a
-       further wrap point on the current line, the wrap point will be
-       returned. Otherwise this function will return the start or end
-       of the line.
-       */
-       moveToLineBoundary(start, forward, includeWrap = true) {
-           return moveToLineBoundary$1(this, start, forward, includeWrap);
-       }
-       /**
-       Move a cursor position vertically. When `distance` isn't given,
-       it defaults to moving to the next line (including wrapped
-       lines). Otherwise, `distance` should provide a positive distance
-       in pixels.
-       
-       When `start` has a
-       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
-       motion will use that as a target horizontal position. Otherwise,
-       the cursor's own horizontal position is used. The returned
-       cursor will have its goal column set to whichever column was
-       used.
-       */
-       moveVertically(start, forward, distance) {
-           return skipAtoms$1(this, start, moveVertically$1(this, start, forward, distance));
-       }
-       /**
-       Find the DOM parent node and offset (child offset if `node` is
-       an element, character offset when it is a text node) at the
-       given document position.
-       
-       Note that for positions that aren't currently in
-       `visibleRanges`, the resulting DOM position isn't necessarily
-       meaningful (it may just point before or after a placeholder
-       element).
-       */
-       domAtPos(pos) {
-           return this.docView.domAtPos(pos);
-       }
-       /**
-       Find the document position at the given DOM node. Can be useful
-       for associating positions with DOM events. Will raise an error
-       when `node` isn't part of the editor content.
-       */
-       posAtDOM(node, offset = 0) {
-           return this.docView.posFromDOM(node, offset);
-       }
-       posAtCoords(coords, precise = true) {
-           this.readMeasured();
-           return posAtCoords$1(this, coords, precise);
-       }
-       /**
-       Get the screen coordinates at the given document position.
-       `side` determines whether the coordinates are based on the
-       element before (-1) or after (1) the position (if no element is
-       available on the given side, the method will transparently use
-       another strategy to get reasonable coordinates).
-       */
-       coordsAtPos(pos, side = 1) {
-           this.readMeasured();
-           let rect = this.docView.coordsAt(pos, side);
-           if (!rect || rect.left == rect.right)
-               return rect;
-           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
-           let span = order[BidiSpan$1.find(order, pos - line.from, -1, side)];
-           return flattenRect$1(rect, (span.dir == Direction$1.LTR) == (side > 0));
-       }
-       /**
-       The default width of a character in the editor. May not
-       accurately reflect the width of all characters (given variable
-       width fonts or styling of invididual ranges).
-       */
-       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
-       /**
-       The default height of a line in the editor. May not be accurate
-       for all lines.
-       */
-       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
-       /**
-       The text direction
-       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
-       CSS property) of the editor's content element.
-       */
-       get textDirection() { return this.viewState.defaultTextDirection; }
-       /**
-       Find the text direction of the block at the given position, as
-       assigned by CSS. If
-       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
-       isn't enabled, or the given position is outside of the viewport,
-       this will always return the same as
-       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
-       this may trigger a DOM layout.
-       */
-       textDirectionAt(pos) {
-           let perLine = this.state.facet(perLineTextDirection$1);
-           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
-               return this.textDirection;
-           this.readMeasured();
-           return this.docView.textDirectionAt(pos);
-       }
-       /**
-       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
-       (as determined by the
-       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
-       CSS property of its content element).
-       */
-       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
-       /**
-       Returns the bidirectional text structure of the given line
-       (which should be in the current document) as an array of span
-       objects. The order of these spans matches the [text
-       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
-       left-to-right, the leftmost spans come first, otherwise the
-       rightmost spans come first.
-       */
-       bidiSpans(line) {
-           if (line.length > MaxBidiLine$1)
-               return trivialOrder$1(line.length);
-           let dir = this.textDirectionAt(line.from);
-           for (let entry of this.bidiCache)
-               if (entry.from == line.from && entry.dir == dir)
-                   return entry.order;
-           let order = computeOrder$1(line.text, dir);
-           this.bidiCache.push(new CachedOrder$1(line.from, line.to, dir, order));
-           return order;
-       }
-       /**
-       Check whether the editor has focus.
-       */
-       get hasFocus() {
-           var _a;
-           // Safari return false for hasFocus when the context menu is open
-           // or closing, which leads us to ignore selection changes from the
-           // context menu because it looks like the editor isn't focused.
-           // This kludges around that.
-           return (document.hasFocus() || browser$1.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
-               this.root.activeElement == this.contentDOM;
-       }
-       /**
-       Put focus on the editor.
-       */
-       focus() {
-           this.observer.ignore(() => {
-               focusPreventScroll$1(this.contentDOM);
-               this.docView.updateSelection();
-           });
-       }
-       /**
-       Clean up this editor view, removing its element from the
-       document, unregistering event handlers, and notifying
-       plugins. The view instance can no longer be used after
-       calling this.
-       */
-       destroy() {
-           for (let plugin of this.plugins)
-               plugin.destroy(this);
-           this.plugins = [];
-           this.inputState.destroy();
-           this.dom.remove();
-           this.observer.destroy();
-           if (this.measureScheduled > -1)
-               cancelAnimationFrame(this.measureScheduled);
-           this.destroyed = true;
-       }
-       /**
-       Returns an effect that can be
-       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
-       cause it to scroll the given position or range into view.
-       */
-       static scrollIntoView(pos, options = {}) {
-           return scrollIntoView$3.of(new ScrollTarget$1(typeof pos == "number" ? EditorSelection$1.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
-       }
-       /**
-       Returns an extension that can be used to add DOM event handlers.
-       The value should be an object mapping event names to handler
-       functions. For any given event, such functions are ordered by
-       extension precedence, and the first handler to return true will
-       be assumed to have handled that event, and no other handlers or
-       built-in behavior will be activated for it. These are registered
-       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
-       for `scroll` handlers, which will be called any time the
-       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
-       its parent nodes is scrolled.
-       */
-       static domEventHandlers(handlers) {
-           return ViewPlugin$1.define(() => ({}), { eventHandlers: handlers });
-       }
-       /**
-       Create a theme extension. The first argument can be a
-       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
-       style spec providing the styles for the theme. These will be
-       prefixed with a generated class for the style.
-       
-       Because the selectors will be prefixed with a scope class, rule
-       that directly match the editor's [wrapper
-       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
-       added—need to be explicitly differentiated by adding an `&` to
-       the selector for that element—for example
-       `&.cm-focused`.
-       
-       When `dark` is set to true, the theme will be marked as dark,
-       which will cause the `&dark` rules from [base
-       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
-       `&light` when a light theme is active).
-       */
-       static theme(spec, options) {
-           let prefix = StyleModule.newName();
-           let result = [theme$1.of(prefix), styleModule$1.of(buildTheme$1(`.${prefix}`, spec))];
-           if (options && options.dark)
-               result.push(darkTheme$1.of(true));
-           return result;
-       }
-       /**
-       Create an extension that adds styles to the base theme. Like
-       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
-       place of the editor wrapper element when directly targeting
-       that. You can also use `&dark` or `&light` instead to only
-       target editors with a dark or light theme.
-       */
-       static baseTheme(spec) {
-           return Prec$1.lowest(styleModule$1.of(buildTheme$1("." + baseThemeID$1, spec, lightDarkIDs$1)));
-       }
-   };
-   /**
-   Facet to add a [style
-   module](https://github.com/marijnh/style-mod#documentation) to
-   an editor view. The view will ensure that the module is
-   mounted in its [document
-   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
-   */
-   EditorView$1.styleModule = styleModule$1;
-   /**
-   An input handler can override the way changes to the editable
-   DOM content are handled. Handlers are passed the document
-   positions between which the change was found, and the new
-   content. When one returns true, no further input handlers are
-   called and the default behavior is prevented.
-   */
-   EditorView$1.inputHandler = inputHandler$2;
-   /**
-   By default, the editor assumes all its content has the same
-   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
-   value to make it read the text direction of every (rendered)
-   line separately.
-   */
-   EditorView$1.perLineTextDirection = perLineTextDirection$1;
-   /**
-   Allows you to provide a function that should be called when the
-   library catches an exception from an extension (mostly from view
-   plugins, but may be used by other extensions to route exceptions
-   from user-code-provided callbacks). This is mostly useful for
-   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
-   */
-   EditorView$1.exceptionSink = exceptionSink$1;
-   /**
-   A facet that can be used to register a function to be called
-   every time the view updates.
-   */
-   EditorView$1.updateListener = updateListener$1;
-   /**
-   Facet that controls whether the editor content DOM is editable.
-   When its highest-precedence value is `false`, the element will
-   not have its `contenteditable` attribute set. (Note that this
-   doesn't affect API calls that change the editor content, even
-   when those are bound to keys or buttons. See the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
-   */
-   EditorView$1.editable = editable$1;
-   /**
-   Allows you to influence the way mouse selection happens. The
-   functions in this facet will be called for a `mousedown` event
-   on the editor, and can return an object that overrides the way a
-   selection is computed from that mouse click or drag.
-   */
-   EditorView$1.mouseSelectionStyle = mouseSelectionStyle$1;
-   /**
-   Facet used to configure whether a given selection drag event
-   should move or copy the selection. The given predicate will be
-   called with the `mousedown` event, and can return `true` when
-   the drag should move the content.
-   */
-   EditorView$1.dragMovesSelection = dragMovesSelection$1$1;
-   /**
-   Facet used to configure whether a given selecting click adds a
-   new range to the existing selection or replaces it entirely. The
-   default behavior is to check `event.metaKey` on macOS, and
-   `event.ctrlKey` elsewhere.
-   */
-   EditorView$1.clickAddsSelectionRange = clickAddsSelectionRange$1;
-   /**
-   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
-   are shown in the view. Decorations can be provided in two
-   ways—directly, or via a function that takes an editor view.
-
-   Only decoration sets provided directly are allowed to influence
-   the editor's vertical layout structure. The ones provided as
-   functions are called _after_ the new viewport has been computed,
-   and thus **must not** introduce block widgets or replacing
-   decorations that cover line breaks.
-   */
-   EditorView$1.decorations = decorations$1;
-   /**
-   Used to provide ranges that should be treated as atoms as far as
-   cursor motion is concerned. This causes methods like
-   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
-   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
-   commands built on top of them) to skip across such regions when
-   a selection endpoint would enter them. This does _not_ prevent
-   direct programmatic [selection
-   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
-   regions.
-   */
-   EditorView$1.atomicRanges = atomicRanges$1;
-   /**
-   Facet that allows extensions to provide additional scroll
-   margins (space around the sides of the scrolling element that
-   should be considered invisible). This can be useful when the
-   plugin introduces elements that cover part of that element (for
-   example a horizontally fixed gutter).
-   */
-   EditorView$1.scrollMargins = scrollMargins$1;
-   /**
-   This facet records whether a dark theme is active. The extension
-   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
-   includes an instance of this when the `dark` option is set to
-   true.
-   */
-   EditorView$1.darkTheme = darkTheme$1;
-   /**
-   Facet that provides additional DOM attributes for the editor's
-   editable DOM element.
-   */
-   EditorView$1.contentAttributes = contentAttributes$1;
-   /**
-   Facet that provides DOM attributes for the editor's outer
-   element.
-   */
-   EditorView$1.editorAttributes = editorAttributes$1;
-   /**
-   An extension that enables line wrapping in the editor (by
-   setting CSS `white-space` to `pre-wrap` in the content).
-   */
-   EditorView$1.lineWrapping = /*@__PURE__*/EditorView$1.contentAttributes.of({ "class": "cm-lineWrapping" });
-   /**
-   State effect used to include screen reader announcements in a
-   transaction. These will be added to the DOM in a visually hidden
-   element with `aria-live="polite"` set, and should be used to
-   describe effects that are visually obvious but may not be
-   noticed by screen reader users (such as moving to the next
-   search match).
-   */
-   EditorView$1.announce = /*@__PURE__*/StateEffect$1.define();
-   // Maximum line length for which we compute accurate bidi info
-   const MaxBidiLine$1 = 4096;
-   const BadMeasure$1 = {};
-   let CachedOrder$1 = class CachedOrder {
-       constructor(from, to, dir, order) {
-           this.from = from;
-           this.to = to;
-           this.dir = dir;
-           this.order = order;
-       }
-       static update(cache, changes) {
-           if (changes.empty)
-               return cache;
-           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction$1.LTR;
-           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
-               let entry = cache[i];
-               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
-                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.order));
-           }
-           return result;
-       }
-   };
-   function attrsFromFacet$1(view, facet, base) {
-       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
-           let source = sources[i], value = typeof source == "function" ? source(view) : source;
-           if (value)
-               combineAttrs$1(value, base);
-       }
-       return base;
-   }
-
-   const currentPlatform$1 = browser$1.mac ? "mac" : browser$1.windows ? "win" : browser$1.linux ? "linux" : "key";
-   function normalizeKeyName$1(name, platform) {
-       const parts = name.split(/-(?!$)/);
-       let result = parts[parts.length - 1];
-       if (result == "Space")
-           result = " ";
-       let alt, ctrl, shift, meta;
-       for (let i = 0; i < parts.length - 1; ++i) {
-           const mod = parts[i];
-           if (/^(cmd|meta|m)$/i.test(mod))
-               meta = true;
-           else if (/^a(lt)?$/i.test(mod))
-               alt = true;
-           else if (/^(c|ctrl|control)$/i.test(mod))
-               ctrl = true;
-           else if (/^s(hift)?$/i.test(mod))
-               shift = true;
-           else if (/^mod$/i.test(mod)) {
-               if (platform == "mac")
-                   meta = true;
-               else
-                   ctrl = true;
-           }
-           else
-               throw new Error("Unrecognized modifier name: " + mod);
-       }
-       if (alt)
-           result = "Alt-" + result;
-       if (ctrl)
-           result = "Ctrl-" + result;
-       if (meta)
-           result = "Meta-" + result;
-       if (shift)
-           result = "Shift-" + result;
-       return result;
-   }
-   function modifiers$1(name, event, shift) {
-       if (event.altKey)
-           name = "Alt-" + name;
-       if (event.ctrlKey)
-           name = "Ctrl-" + name;
-       if (event.metaKey)
-           name = "Meta-" + name;
-       if (shift !== false && event.shiftKey)
-           name = "Shift-" + name;
-       return name;
-   }
-   const handleKeyEvents$1 = /*@__PURE__*/EditorView$1.domEventHandlers({
-       keydown(event, view) {
-           return runHandlers$1(getKeymap$1(view.state), event, view, "editor");
-       }
-   });
-   /**
-   Facet used for registering keymaps.
-
-   You can add multiple keymaps to an editor. Their priorities
-   determine their precedence (the ones specified early or with high
-   priority get checked first). When a handler has returned `true`
-   for a given key, no further handlers are called.
-   */
-   const keymap$1 = /*@__PURE__*/Facet$1.define({ enables: handleKeyEvents$1 });
-   const Keymaps$1 = /*@__PURE__*/new WeakMap();
-   // This is hidden behind an indirection, rather than directly computed
-   // by the facet, to keep internal types out of the facet's type.
-   function getKeymap$1(state) {
-       let bindings = state.facet(keymap$1);
-       let map = Keymaps$1.get(bindings);
-       if (!map)
-           Keymaps$1.set(bindings, map = buildKeymap$1(bindings.reduce((a, b) => a.concat(b), [])));
-       return map;
-   }
-   /**
-   Run the key handlers registered for a given scope. The event
-   object should be a `"keydown"` event. Returns true if any of the
-   handlers handled it.
-   */
-   function runScopeHandlers(view, event, scope) {
-       return runHandlers$1(getKeymap$1(view.state), event, view, scope);
-   }
-   let storedPrefix$1 = null;
-   const PrefixTimeout$1 = 4000;
-   function buildKeymap$1(bindings, platform = currentPlatform$1) {
-       let bound = Object.create(null);
-       let isPrefix = Object.create(null);
-       let checkPrefix = (name, is) => {
-           let current = isPrefix[name];
-           if (current == null)
-               isPrefix[name] = is;
-           else if (current != is)
-               throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
-       };
-       let add = (scope, key, command, preventDefault) => {
-           let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
-           let parts = key.split(/ (?!$)/).map(k => normalizeKeyName$1(k, platform));
-           for (let i = 1; i < parts.length; i++) {
-               let prefix = parts.slice(0, i).join(" ");
-               checkPrefix(prefix, true);
-               if (!scopeObj[prefix])
-                   scopeObj[prefix] = {
-                       preventDefault: true,
-                       commands: [(view) => {
-                               let ourObj = storedPrefix$1 = { view, prefix, scope };
-                               setTimeout(() => { if (storedPrefix$1 == ourObj)
-                                   storedPrefix$1 = null; }, PrefixTimeout$1);
-                               return true;
-                           }]
-                   };
-           }
-           let full = parts.join(" ");
-           checkPrefix(full, false);
-           let binding = scopeObj[full] || (scopeObj[full] = { preventDefault: false, commands: [] });
-           binding.commands.push(command);
-           if (preventDefault)
-               binding.preventDefault = true;
-       };
-       for (let b of bindings) {
-           let name = b[platform] || b.key;
-           if (!name)
-               continue;
-           for (let scope of b.scope ? b.scope.split(" ") : ["editor"]) {
-               add(scope, name, b.run, b.preventDefault);
-               if (b.shift)
-                   add(scope, "Shift-" + name, b.shift, b.preventDefault);
-           }
-       }
-       return bound;
-   }
-   function runHandlers$1(map, event, view, scope) {
-       let name = keyName(event), isChar = name.length == 1 && name != " ";
-       let prefix = "", fallthrough = false;
-       if (storedPrefix$1 && storedPrefix$1.view == view && storedPrefix$1.scope == scope) {
-           prefix = storedPrefix$1.prefix + " ";
-           if (fallthrough = modifierCodes$1.indexOf(event.keyCode) < 0)
-               storedPrefix$1 = null;
-       }
-       let runFor = (binding) => {
-           if (binding) {
-               for (let cmd of binding.commands)
-                   if (cmd(view))
-                       return true;
-               if (binding.preventDefault)
-                   fallthrough = true;
-           }
-           return false;
-       };
-       let scopeObj = map[scope], baseName;
-       if (scopeObj) {
-           if (runFor(scopeObj[prefix + modifiers$1(name, event, !isChar)]))
-               return true;
-           if (isChar && (event.shiftKey || event.altKey || event.metaKey) &&
-               (baseName = base[event.keyCode]) && baseName != name) {
-               if (runFor(scopeObj[prefix + modifiers$1(baseName, event, true)]))
-                   return true;
-           }
-           else if (isChar && event.shiftKey) {
-               if (runFor(scopeObj[prefix + modifiers$1(name, event, true)]))
-                   return true;
-           }
-       }
-       return fallthrough;
-   }
-
-   const CanHidePrimary$1 = !browser$1.ios; // FIXME test IE
-   const themeSpec$1 = {
-       ".cm-line": {
-           "& ::selection": { backgroundColor: "transparent !important" },
-           "&::selection": { backgroundColor: "transparent !important" }
-       }
-   };
-   if (CanHidePrimary$1)
-       themeSpec$1[".cm-line"].caretColor = "transparent !important";
-
-   const panelConfig$1 = /*@__PURE__*/Facet$1.define({
-       combine(configs) {
-           let topContainer, bottomContainer;
-           for (let c of configs) {
-               topContainer = topContainer || c.topContainer;
-               bottomContainer = bottomContainer || c.bottomContainer;
-           }
-           return { topContainer, bottomContainer };
-       }
-   });
-   /**
-   Get the active panel created by the given constructor, if any.
-   This can be useful when you need access to your panels' DOM
-   structure.
-   */
-   function getPanel(view, panel) {
-       let plugin = view.plugin(panelPlugin$1);
-       let index = plugin ? plugin.specs.indexOf(panel) : -1;
-       return index > -1 ? plugin.panels[index] : null;
-   }
-   const panelPlugin$1 = /*@__PURE__*/ViewPlugin$1.fromClass(class {
-       constructor(view) {
-           this.input = view.state.facet(showPanel$1);
-           this.specs = this.input.filter(s => s);
-           this.panels = this.specs.map(spec => spec(view));
-           let conf = view.state.facet(panelConfig$1);
-           this.top = new PanelGroup$1(view, true, conf.topContainer);
-           this.bottom = new PanelGroup$1(view, false, conf.bottomContainer);
-           this.top.sync(this.panels.filter(p => p.top));
-           this.bottom.sync(this.panels.filter(p => !p.top));
-           for (let p of this.panels) {
-               p.dom.classList.add("cm-panel");
-               if (p.mount)
-                   p.mount();
-           }
-       }
-       update(update) {
-           let conf = update.state.facet(panelConfig$1);
-           if (this.top.container != conf.topContainer) {
-               this.top.sync([]);
-               this.top = new PanelGroup$1(update.view, true, conf.topContainer);
-           }
-           if (this.bottom.container != conf.bottomContainer) {
-               this.bottom.sync([]);
-               this.bottom = new PanelGroup$1(update.view, false, conf.bottomContainer);
-           }
-           this.top.syncClasses();
-           this.bottom.syncClasses();
-           let input = update.state.facet(showPanel$1);
-           if (input != this.input) {
-               let specs = input.filter(x => x);
-               let panels = [], top = [], bottom = [], mount = [];
-               for (let spec of specs) {
-                   let known = this.specs.indexOf(spec), panel;
-                   if (known < 0) {
-                       panel = spec(update.view);
-                       mount.push(panel);
-                   }
-                   else {
-                       panel = this.panels[known];
-                       if (panel.update)
-                           panel.update(update);
-                   }
-                   panels.push(panel);
-                   (panel.top ? top : bottom).push(panel);
-               }
-               this.specs = specs;
-               this.panels = panels;
-               this.top.sync(top);
-               this.bottom.sync(bottom);
-               for (let p of mount) {
-                   p.dom.classList.add("cm-panel");
-                   if (p.mount)
-                       p.mount();
-               }
-           }
-           else {
-               for (let p of this.panels)
-                   if (p.update)
-                       p.update(update);
-           }
-       }
-       destroy() {
-           this.top.sync([]);
-           this.bottom.sync([]);
-       }
-   }, {
-       provide: plugin => EditorView$1.scrollMargins.of(view => {
-           let value = view.plugin(plugin);
-           return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
-       })
-   });
-   let PanelGroup$1 = class PanelGroup {
-       constructor(view, top, container) {
-           this.view = view;
-           this.top = top;
-           this.container = container;
-           this.dom = undefined;
-           this.classes = "";
-           this.panels = [];
-           this.syncClasses();
-       }
-       sync(panels) {
-           for (let p of this.panels)
-               if (p.destroy && panels.indexOf(p) < 0)
-                   p.destroy();
-           this.panels = panels;
-           this.syncDOM();
-       }
-       syncDOM() {
-           if (this.panels.length == 0) {
-               if (this.dom) {
-                   this.dom.remove();
-                   this.dom = undefined;
-               }
-               return;
-           }
-           if (!this.dom) {
-               this.dom = document.createElement("div");
-               this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
-               this.dom.style[this.top ? "top" : "bottom"] = "0";
-               let parent = this.container || this.view.dom;
-               parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
-           }
-           let curDOM = this.dom.firstChild;
-           for (let panel of this.panels) {
-               if (panel.dom.parentNode == this.dom) {
-                   while (curDOM != panel.dom)
-                       curDOM = rm$2(curDOM);
-                   curDOM = curDOM.nextSibling;
-               }
-               else {
-                   this.dom.insertBefore(panel.dom, curDOM);
-               }
-           }
-           while (curDOM)
-               curDOM = rm$2(curDOM);
-       }
-       scrollMargin() {
-           return !this.dom || this.container ? 0
-               : Math.max(0, this.top ?
-                   this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
-                   Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
-       }
-       syncClasses() {
-           if (!this.container || this.classes == this.view.themeClasses)
-               return;
-           for (let cls of this.classes.split(" "))
-               if (cls)
-                   this.container.classList.remove(cls);
-           for (let cls of (this.classes = this.view.themeClasses).split(" "))
-               if (cls)
-                   this.container.classList.add(cls);
-       }
-   };
-   function rm$2(node) {
-       let next = node.nextSibling;
-       node.remove();
-       return next;
-   }
-   /**
-   Opening a panel is done by providing a constructor function for
-   the panel through this facet. (The panel is closed again when its
-   constructor is no longer provided.) Values of `null` are ignored.
-   */
-   const showPanel$1 = /*@__PURE__*/Facet$1.define({
-       enables: panelPlugin$1
-   });
-
-   /**
-   A gutter marker represents a bit of information attached to a line
-   in a specific gutter. Your own custom markers have to extend this
-   class.
-   */
-   let GutterMarker$1 = class GutterMarker extends RangeValue$1 {
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       Compare this marker to another marker of the same type.
-       */
-       eq(other) { return false; }
-       /**
-       Called if the marker has a `toDOM` method and its representation
-       was removed from a gutter.
-       */
-       destroy(dom) { }
-   };
-   GutterMarker$1.prototype.elementClass = "";
-   GutterMarker$1.prototype.toDOM = undefined;
-   GutterMarker$1.prototype.mapMode = MapMode$1.TrackBefore;
-   GutterMarker$1.prototype.startSide = GutterMarker$1.prototype.endSide = -1;
-   GutterMarker$1.prototype.point = true;
-
-   function crelt() {
-     var elt = arguments[0];
-     if (typeof elt == "string") elt = document.createElement(elt);
-     var i = 1, next = arguments[1];
-     if (next && typeof next == "object" && next.nodeType == null && !Array.isArray(next)) {
-       for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {
-         var value = next[name];
-         if (typeof value == "string") elt.setAttribute(name, value);
-         else if (value != null) elt[name] = value;
-       }
-       i++;
-     }
-     for (; i < arguments.length; i++) add(elt, arguments[i]);
-     return elt
-   }
-
-   function add(elt, child) {
-     if (typeof child == "string") {
-       elt.appendChild(document.createTextNode(child));
-     } else if (child == null) ; else if (child.nodeType != null) {
-       elt.appendChild(child);
-     } else if (Array.isArray(child)) {
-       for (var i = 0; i < child.length; i++) add(elt, child[i]);
-     } else {
-       throw new RangeError("Unsupported child node: " + child)
-     }
-   }
-
-   const basicNormalize = typeof String.prototype.normalize == "function"
-       ? x => x.normalize("NFKD") : x => x;
-   /**
-   A search cursor provides an iterator over text matches in a
-   document.
-   */
-   class SearchCursor {
-       /**
-       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(text, query, from = 0, to = text.length, normalize) {
-           /**
-           The current match (only holds a meaningful value after
-           [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
-           `done` is false).
-           */
-           this.value = { from: 0, to: 0 };
-           /**
-           Whether the end of the iterated region has been reached.
-           */
-           this.done = false;
-           this.matches = [];
-           this.buffer = "";
-           this.bufferPos = 0;
-           this.iter = text.iterRange(from, to);
-           this.bufferStart = from;
-           this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;
-           this.query = this.normalize(query);
-       }
-       peek() {
-           if (this.bufferPos == this.buffer.length) {
-               this.bufferStart += this.buffer.length;
-               this.iter.next();
-               if (this.iter.done)
-                   return -1;
-               this.bufferPos = 0;
-               this.buffer = this.iter.value;
-           }
-           return codePointAt$2(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() {
-           while (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 next = this.peek();
-               if (next < 0) {
-                   this.done = true;
-                   return this;
-               }
-               let str = fromCodePoint$1(next), start = this.bufferStart + this.bufferPos;
-               this.bufferPos += codePointSize$2(next);
-               let norm = this.normalize(str);
-               for (let i = 0, pos = start;; i++) {
-                   let code = norm.charCodeAt(i);
-                   let match = this.match(code, pos);
-                   if (match) {
-                       this.value = match;
-                       return this;
-                   }
-                   if (i == norm.length - 1)
-                       break;
-                   if (pos == start && i < str.length && str.charCodeAt(i) == code)
-                       pos++;
-               }
-           }
-       }
-       match(code, pos) {
-           let match = null;
-           for (let i = 0; i < this.matches.length; i += 2) {
-               let index = this.matches[i], keep = false;
-               if (this.query.charCodeAt(index) == code) {
-                   if (index == this.query.length - 1) {
-                       match = { from: this.matches[i + 1], to: pos + 1 };
-                   }
-                   else {
-                       this.matches[i]++;
-                       keep = true;
-                   }
-               }
-               if (!keep) {
-                   this.matches.splice(i, 2);
-                   i -= 2;
-               }
-           }
-           if (this.query.charCodeAt(0) == code) {
-               if (this.query.length == 1)
-                   match = { from: pos, to: pos + 1 };
-               else
-                   this.matches.push(1, pos);
-           }
-           return match;
-       }
-   }
-   if (typeof Symbol != "undefined")
-       SearchCursor.prototype[Symbol.iterator] = function () { return this; };
-
-   const empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec("") };
-   const baseFlags = "gm" + (/x/.unicode == null ? "" : "u");
-   /**
-   This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
-   but searches for a regular expression pattern instead of a plain
-   string.
-   */
-   class RegExpCursor {
-       /**
-       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(text, query, options, from = 0, to = text.length) {
-           this.to = to;
-           this.curLine = "";
-           /**
-           Set to `true` when the cursor has reached the end of the search
-           range.
-           */
-           this.done = false;
-           /**
-           Will contain an object with the extent of the match and the
-           match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
-           sucessfully finds a match.
-           */
-           this.value = empty;
-           if (/\\[sWDnr]|\n|\r|\[\^/.test(query))
-               return new MultilineRegExpCursor(text, query, options, from, to);
-           this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
-           this.iter = text.iter();
-           let startLine = text.lineAt(from);
-           this.curLineStart = startLine.from;
-           this.matchPos = from;
-           this.getLine(this.curLineStart);
-       }
-       getLine(skip) {
-           this.iter.next(skip);
-           if (this.iter.lineBreak) {
-               this.curLine = "";
-           }
-           else {
-               this.curLine = this.iter.value;
-               if (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;
-           if (this.curLineStart > this.to)
-               this.curLine = "";
-           else
-               this.getLine(0);
-       }
-       /**
-       Move to the next match, if there is one.
-       */
-       next() {
-           for (let off = this.matchPos - this.curLineStart;;) {
-               this.re.lastIndex = off;
-               let match = this.matchPos <= this.to && this.re.exec(this.curLine);
-               if (match) {
-                   let from = this.curLineStart + match.index, to = from + match[0].length;
-                   this.matchPos = to + (from == to ? 1 : 0);
-                   if (from == this.curLine.length)
-                       this.nextLine();
-                   if (from < to || from > this.value.to) {
-                       this.value = { from, to, match };
-                       return this;
-                   }
-                   off = this.matchPos - this.curLineStart;
-               }
-               else if (this.curLineStart + this.curLine.length < this.to) {
-                   this.nextLine();
-                   off = 0;
-               }
-               else {
-                   this.done = true;
-                   return this;
-               }
-           }
-       }
-   }
-   const flattened = /*@__PURE__*/new WeakMap();
-   // Reusable (partially) flattened document strings
-   class FlattenedDoc {
-       constructor(from, text) {
-           this.from = from;
-           this.text = text;
-       }
-       get to() { return this.from + this.text.length; }
-       static get(doc, from, to) {
-           let cached = flattened.get(doc);
-           if (!cached || cached.from >= to || cached.to <= from) {
-               let flat = new FlattenedDoc(from, doc.sliceString(from, to));
-               flattened.set(doc, flat);
-               return flat;
-           }
-           if (cached.from == from && cached.to == to)
-               return cached;
-           let { text, from: cachedFrom } = cached;
-           if (cachedFrom > from) {
-               text = doc.sliceString(from, cachedFrom) + text;
-               cachedFrom = from;
-           }
-           if (cached.to < to)
-               text += doc.sliceString(cached.to, to);
-           flattened.set(doc, new FlattenedDoc(cachedFrom, text));
-           return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));
-       }
-   }
-   class MultilineRegExpCursor {
-       constructor(text, query, options, from, to) {
-           this.text = text;
-           this.to = to;
-           this.done = false;
-           this.value = empty;
-           this.matchPos = from;
-           this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? "i" : ""));
-           this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Base */));
-       }
-       chunkEnd(pos) {
-           return pos >= this.to ? this.to : this.text.lineAt(pos).to;
-       }
-       next() {
-           for (;;) {
-               let off = this.re.lastIndex = this.matchPos - this.flat.from;
-               let match = this.re.exec(this.flat.text);
-               // Skip empty matches directly after the last match
-               if (match && !match[0] && match.index == off) {
-                   this.re.lastIndex = off + 1;
-                   match = this.re.exec(this.flat.text);
-               }
-               // If a match goes almost to the end of a noncomplete chunk, try
-               // again, since it'll likely be able to match more
-               if (match && this.flat.to < this.to && match.index + match[0].length > this.flat.text.length - 10)
-                   match = null;
-               if (match) {
-                   let from = this.flat.from + match.index, to = from + match[0].length;
-                   this.value = { from, to, match };
-                   this.matchPos = to + (from == to ? 1 : 0);
-                   return this;
-               }
-               else {
-                   if (this.flat.to == this.to) {
-                       this.done = true;
-                       return this;
-                   }
-                   // Grow the flattened doc
-                   this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
-               }
-           }
-       }
-   }
-   if (typeof Symbol != "undefined") {
-       RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] =
-           function () { return this; };
-   }
-   function validRegExp(source) {
-       try {
-           new RegExp(source, baseFlags);
-           return true;
-       }
-       catch (_a) {
-           return false;
-       }
-   }
-
-   function createLineDialog(view) {
-       let input = crelt("input", { class: "cm-textfield", name: "line" });
-       let dom = crelt("form", {
-           class: "cm-gotoLine",
-           onkeydown: (event) => {
-               if (event.keyCode == 27) { // Escape
-                   event.preventDefault();
-                   view.dispatch({ effects: dialogEffect.of(false) });
-                   view.focus();
-               }
-               else if (event.keyCode == 13) { // Enter
-                   event.preventDefault();
-                   go();
-               }
-           },
-           onsubmit: (event) => {
-               event.preventDefault();
-               go();
-           }
-       }, crelt("label", view.state.phrase("Go to line"), ": ", input), " ", crelt("button", { class: "cm-button", type: "submit" }, view.state.phrase("go")));
-       function go() {
-           let match = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);
-           if (!match)
-               return;
-           let { state } = view, startLine = state.doc.lineAt(state.selection.main.head);
-           let [, sign, ln, cl, percent] = match;
-           let col = cl ? +cl.slice(1) : 0;
-           let line = ln ? +ln : startLine.number;
-           if (ln && percent) {
-               let pc = line / 100;
-               if (sign)
-                   pc = pc * (sign == "-" ? -1 : 1) + (startLine.number / state.doc.lines);
-               line = Math.round(state.doc.lines * pc);
-           }
-           else if (ln && sign) {
-               line = line * (sign == "-" ? -1 : 1) + startLine.number;
-           }
-           let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));
-           view.dispatch({
-               effects: dialogEffect.of(false),
-               selection: EditorSelection$1.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length))),
-               scrollIntoView: true
-           });
-           view.focus();
-       }
-       return { dom };
-   }
-   const dialogEffect = /*@__PURE__*/StateEffect$1.define();
-   const dialogField = /*@__PURE__*/StateField$1.define({
-       create() { return true; },
-       update(value, tr) {
-           for (let e of tr.effects)
-               if (e.is(dialogEffect))
-                   value = e.value;
-           return value;
-       },
-       provide: f => showPanel$1.from(f, val => val ? createLineDialog : null)
-   });
-   /**
-   Command that shows a dialog asking the user for a line number, and
-   when a valid position is provided, moves the cursor to that line.
-
-   Supports line numbers, relative line offsets prefixed with `+` or
-   `-`, document percentages suffixed with `%`, and an optional
-   column position by adding `:` and a second number after the line
-   number.
-
-   The dialog can be styled with the `panel.gotoLine` theme
-   selector.
-   */
-   const gotoLine = view => {
-       let panel = getPanel(view, createLineDialog);
-       if (!panel) {
-           let effects = [dialogEffect.of(true)];
-           if (view.state.field(dialogField, false) == null)
-               effects.push(StateEffect$1.appendConfig.of([dialogField, baseTheme$1$1]));
-           view.dispatch({ effects });
-           panel = getPanel(view, createLineDialog);
-       }
-       if (panel)
-           panel.dom.querySelector("input").focus();
-       return true;
-   };
-   const baseTheme$1$1 = /*@__PURE__*/EditorView$1.baseTheme({
-       ".cm-panel.cm-gotoLine": {
-           padding: "2px 6px 4px",
-           "& label": { fontSize: "80%" }
-       }
-   });
-
-   const defaultHighlightOptions = {
-       highlightWordAroundCursor: false,
-       minSelectionLength: 1,
-       maxMatches: 100,
-       wholeWords: false
-   };
-   const highlightConfig = /*@__PURE__*/Facet$1.define({
-       combine(options) {
-           return combineConfig$1(options, defaultHighlightOptions, {
-               highlightWordAroundCursor: (a, b) => a || b,
-               minSelectionLength: Math.min,
-               maxMatches: Math.min
-           });
-       }
-   });
-   /**
-   This extension highlights text that matches the selection. It uses
-   the `"cm-selectionMatch"` class for the highlighting. When
-   `highlightWordAroundCursor` is enabled, the word at the cursor
-   itself will be highlighted with `"cm-selectionMatch-main"`.
-   */
-   function highlightSelectionMatches(options) {
-       let ext = [defaultTheme, matchHighlighter];
-       return ext;
-   }
-   const matchDeco = /*@__PURE__*/Decoration$1.mark({ class: "cm-selectionMatch" });
-   const mainMatchDeco = /*@__PURE__*/Decoration$1.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
-   // Whether the characters directly outside the given positions are non-word characters
-   function insideWordBoundaries(check, state, from, to) {
-       return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory$1.Word) &&
-           (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory$1.Word);
-   }
-   // Whether the characters directly at the given positions are word characters
-   function insideWord(check, state, from, to) {
-       return check(state.sliceDoc(from, from + 1)) == CharCategory$1.Word
-           && check(state.sliceDoc(to - 1, to)) == CharCategory$1.Word;
-   }
-   const matchHighlighter = /*@__PURE__*/ViewPlugin$1.fromClass(class {
-       constructor(view) {
-           this.decorations = this.getDeco(view);
-       }
-       update(update) {
-           if (update.selectionSet || update.docChanged || update.viewportChanged)
-               this.decorations = this.getDeco(update.view);
-       }
-       getDeco(view) {
-           let conf = view.state.facet(highlightConfig);
-           let { state } = view, sel = state.selection;
-           if (sel.ranges.length > 1)
-               return Decoration$1.none;
-           let range = sel.main, query, check = null;
-           if (range.empty) {
-               if (!conf.highlightWordAroundCursor)
-                   return Decoration$1.none;
-               let word = state.wordAt(range.head);
-               if (!word)
-                   return Decoration$1.none;
-               check = state.charCategorizer(range.head);
-               query = state.sliceDoc(word.from, word.to);
-           }
-           else {
-               let len = range.to - range.from;
-               if (len < conf.minSelectionLength || len > 200)
-                   return Decoration$1.none;
-               if (conf.wholeWords) {
-                   query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?
-                   check = state.charCategorizer(range.head);
-                   if (!(insideWordBoundaries(check, state, range.from, range.to)
-                       && insideWord(check, state, range.from, range.to)))
-                       return Decoration$1.none;
-               }
-               else {
-                   query = state.sliceDoc(range.from, range.to).trim();
-                   if (!query)
-                       return Decoration$1.none;
-               }
-           }
-           let deco = [];
-           for (let part of view.visibleRanges) {
-               let cursor = new SearchCursor(state.doc, query, part.from, part.to);
-               while (!cursor.next().done) {
-                   let { from, to } = cursor.value;
-                   if (!check || insideWordBoundaries(check, state, from, to)) {
-                       if (range.empty && from <= range.from && to >= range.to)
-                           deco.push(mainMatchDeco.range(from, to));
-                       else if (from >= range.to || to <= range.from)
-                           deco.push(matchDeco.range(from, to));
-                       if (deco.length > conf.maxMatches)
-                           return Decoration$1.none;
-                   }
-               }
-           }
-           return Decoration$1.set(deco);
-       }
-   }, {
-       decorations: v => v.decorations
-   });
-   const defaultTheme = /*@__PURE__*/EditorView$1.baseTheme({
-       ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
-       ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
-   });
-   // Select the words around the cursors.
-   const selectWord = ({ state, dispatch }) => {
-       let { selection } = state;
-       let newSel = EditorSelection$1.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection$1.cursor(range.head)), selection.mainIndex);
-       if (newSel.eq(selection))
-           return false;
-       dispatch(state.update({ selection: newSel }));
-       return true;
-   };
-   // Find next occurrence of query relative to last cursor. Wrap around
-   // the document if there are no more matches.
-   function findNextOccurrence(state, query) {
-       let { main, ranges } = state.selection;
-       let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;
-       for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {
-           cursor.next();
-           if (cursor.done) {
-               if (cycled)
-                   return null;
-               cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));
-               cycled = true;
-           }
-           else {
-               if (cycled && ranges.some(r => r.from == cursor.value.from))
-                   continue;
-               if (fullWord) {
-                   let word = state.wordAt(cursor.value.from);
-                   if (!word || word.from != cursor.value.from || word.to != cursor.value.to)
-                       continue;
-               }
-               return cursor.value;
-           }
-       }
-   }
-   /**
-   Select next occurrence of the current selection. Expand selection
-   to the surrounding word when the selection is empty.
-   */
-   const selectNextOccurrence = ({ state, dispatch }) => {
-       let { ranges } = state.selection;
-       if (ranges.some(sel => sel.from === sel.to))
-           return selectWord({ state, dispatch });
-       let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);
-       if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText))
-           return false;
-       let range = findNextOccurrence(state, searchedText);
-       if (!range)
-           return false;
-       dispatch(state.update({
-           selection: state.selection.addRange(EditorSelection$1.range(range.from, range.to), false),
-           effects: EditorView$1.scrollIntoView(range.to)
-       }));
-       return true;
-   };
-
-   const searchConfigFacet = /*@__PURE__*/Facet$1.define({
-       combine(configs) {
-           var _a;
-           return {
-               top: configs.reduce((val, conf) => val !== null && val !== void 0 ? val : conf.top, undefined) || false,
-               caseSensitive: configs.reduce((val, conf) => val !== null && val !== void 0 ? val : conf.caseSensitive, undefined) || false,
-               createPanel: ((_a = configs.find(c => c.createPanel)) === null || _a === void 0 ? void 0 : _a.createPanel) || (view => new SearchPanel(view))
-           };
-       }
-   });
-   /**
-   A search query. Part of the editor's search state.
-   */
-   class SearchQuery {
-       /**
-       Create a query object.
-       */
-       constructor(config) {
-           this.search = config.search;
-           this.caseSensitive = !!config.caseSensitive;
-           this.regexp = !!config.regexp;
-           this.replace = config.replace || "";
-           this.valid = !!this.search && (!this.regexp || validRegExp(this.search));
-           this.unquoted = config.literal ? this.search : this.search.replace(/\\([nrt\\])/g, (_, ch) => ch == "n" ? "\n" : ch == "r" ? "\r" : ch == "t" ? "\t" : "\\");
-       }
-       /**
-       Compare this query to another query.
-       */
-       eq(other) {
-           return this.search == other.search && this.replace == other.replace &&
-               this.caseSensitive == other.caseSensitive && this.regexp == other.regexp;
-       }
-       /**
-       @internal
-       */
-       create() {
-           return this.regexp ? new RegExpQuery(this) : new StringQuery(this);
-       }
-       /**
-       Get a search cursor for this query, searching through the given
-       range in the given document.
-       */
-       getCursor(doc, from = 0, to = doc.length) {
-           return this.regexp ? regexpCursor(this, doc, from, to) : stringCursor(this, doc, from, to);
-       }
-   }
-   let QueryType$1 = class QueryType {
-       constructor(spec) {
-           this.spec = spec;
-       }
-   };
-   function stringCursor(spec, doc, from, to) {
-       return new SearchCursor(doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase());
-   }
-   class StringQuery extends QueryType$1 {
-       constructor(spec) {
-           super(spec);
-       }
-       nextMatch(doc, curFrom, curTo) {
-           let cursor = stringCursor(this.spec, doc, curTo, doc.length).nextOverlapping();
-           if (cursor.done)
-               cursor = stringCursor(this.spec, doc, 0, curFrom).nextOverlapping();
-           return cursor.done ? null : cursor.value;
-       }
-       // Searching in reverse is, rather than implementing inverted search
-       // cursor, done by scanning chunk after chunk forward.
-       prevMatchInRange(doc, from, to) {
-           for (let pos = to;;) {
-               let start = Math.max(from, pos - 10000 /* ChunkSize */ - this.spec.unquoted.length);
-               let cursor = stringCursor(this.spec, doc, start, pos), range = null;
-               while (!cursor.nextOverlapping().done)
-                   range = cursor.value;
-               if (range)
-                   return range;
-               if (start == from)
-                   return null;
-               pos -= 10000 /* ChunkSize */;
-           }
-       }
-       prevMatch(doc, curFrom, curTo) {
-           return this.prevMatchInRange(doc, 0, curFrom) ||
-               this.prevMatchInRange(doc, curTo, doc.length);
-       }
-       getReplacement(_result) { return this.spec.replace; }
-       matchAll(doc, limit) {
-           let cursor = stringCursor(this.spec, doc, 0, doc.length), ranges = [];
-           while (!cursor.next().done) {
-               if (ranges.length >= limit)
-                   return null;
-               ranges.push(cursor.value);
-           }
-           return ranges;
-       }
-       highlight(doc, from, to, add) {
-           let cursor = stringCursor(this.spec, doc, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, doc.length));
-           while (!cursor.next().done)
-               add(cursor.value.from, cursor.value.to);
-       }
-   }
-   function regexpCursor(spec, doc, from, to) {
-       return new RegExpCursor(doc, spec.search, spec.caseSensitive ? undefined : { ignoreCase: true }, from, to);
-   }
-   class RegExpQuery extends QueryType$1 {
-       nextMatch(doc, curFrom, curTo) {
-           let cursor = regexpCursor(this.spec, doc, curTo, doc.length).next();
-           if (cursor.done)
-               cursor = regexpCursor(this.spec, doc, 0, curFrom).next();
-           return cursor.done ? null : cursor.value;
-       }
-       prevMatchInRange(doc, from, to) {
-           for (let size = 1;; size++) {
-               let start = Math.max(from, to - size * 10000 /* ChunkSize */);
-               let cursor = regexpCursor(this.spec, doc, start, to), range = null;
-               while (!cursor.next().done)
-                   range = cursor.value;
-               if (range && (start == from || range.from > start + 10))
-                   return range;
-               if (start == from)
-                   return null;
-           }
-       }
-       prevMatch(doc, curFrom, curTo) {
-           return this.prevMatchInRange(doc, 0, curFrom) ||
-               this.prevMatchInRange(doc, curTo, doc.length);
-       }
-       getReplacement(result) {
-           return this.spec.replace.replace(/\$([$&\d+])/g, (m, i) => i == "$" ? "$"
-               : i == "&" ? result.match[0]
-                   : i != "0" && +i < result.match.length ? result.match[i]
-                       : m);
-       }
-       matchAll(doc, limit) {
-           let cursor = regexpCursor(this.spec, doc, 0, doc.length), ranges = [];
-           while (!cursor.next().done) {
-               if (ranges.length >= limit)
-                   return null;
-               ranges.push(cursor.value);
-           }
-           return ranges;
-       }
-       highlight(doc, from, to, add) {
-           let cursor = regexpCursor(this.spec, doc, Math.max(0, from - 250 /* HighlightMargin */), Math.min(to + 250 /* HighlightMargin */, doc.length));
-           while (!cursor.next().done)
-               add(cursor.value.from, cursor.value.to);
-       }
-   }
-   /**
-   A state effect that updates the current search query. Note that
-   this only has an effect if the search state has been initialized
-   (by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
-   by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
-   once).
-   */
-   const setSearchQuery = /*@__PURE__*/StateEffect$1.define();
-   const togglePanel$2 = /*@__PURE__*/StateEffect$1.define();
-   const searchState = /*@__PURE__*/StateField$1.define({
-       create(state) {
-           return new SearchState(defaultQuery(state).create(), null);
-       },
-       update(value, tr) {
-           for (let effect of tr.effects) {
-               if (effect.is(setSearchQuery))
-                   value = new SearchState(effect.value.create(), value.panel);
-               else if (effect.is(togglePanel$2))
-                   value = new SearchState(value.query, effect.value ? createSearchPanel : null);
-           }
-           return value;
-       },
-       provide: f => showPanel$1.from(f, val => val.panel)
-   });
-   class SearchState {
-       constructor(query, panel) {
-           this.query = query;
-           this.panel = panel;
-       }
-   }
-   const matchMark = /*@__PURE__*/Decoration$1.mark({ class: "cm-searchMatch" }), selectedMatchMark = /*@__PURE__*/Decoration$1.mark({ class: "cm-searchMatch cm-searchMatch-selected" });
-   const searchHighlighter = /*@__PURE__*/ViewPlugin$1.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.decorations = this.highlight(view.state.field(searchState));
-       }
-       update(update) {
-           let state = update.state.field(searchState);
-           if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged)
-               this.decorations = this.highlight(state);
-       }
-       highlight({ query, panel }) {
-           if (!panel || !query.spec.valid)
-               return Decoration$1.none;
-           let { view } = this;
-           let builder = new RangeSetBuilder$1();
-           for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {
-               let { from, to } = ranges[i];
-               while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* HighlightMargin */)
-                   to = ranges[++i].to;
-               query.highlight(view.state.doc, from, to, (from, to) => {
-                   let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);
-                   builder.add(from, to, selected ? selectedMatchMark : matchMark);
-               });
-           }
-           return builder.finish();
-       }
-   }, {
-       decorations: v => v.decorations
-   });
-   function searchCommand(f) {
-       return view => {
-           let state = view.state.field(searchState, false);
-           return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);
-       };
-   }
-   /**
-   Open the search panel if it isn't already open, and move the
-   selection to the first match after the current main selection.
-   Will wrap around to the start of the document when it reaches the
-   end.
-   */
-   const findNext = /*@__PURE__*/searchCommand((view, { query }) => {
-       let { from, to } = view.state.selection.main;
-       let next = query.nextMatch(view.state.doc, from, to);
-       if (!next || next.from == from && next.to == to)
-           return false;
-       view.dispatch({
-           selection: { anchor: next.from, head: next.to },
-           scrollIntoView: true,
-           effects: announceMatch(view, next),
-           userEvent: "select.search"
-       });
-       return true;
-   });
-   /**
-   Move the selection to the previous instance of the search query,
-   before the current main selection. Will wrap past the start
-   of the document to start searching at the end again.
-   */
-   const findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {
-       let { state } = view, { from, to } = state.selection.main;
-       let range = query.prevMatch(state.doc, from, to);
-       if (!range)
-           return false;
-       view.dispatch({
-           selection: { anchor: range.from, head: range.to },
-           scrollIntoView: true,
-           effects: announceMatch(view, range),
-           userEvent: "select.search"
-       });
-       return true;
-   });
-   /**
-   Select all instances of the search query.
-   */
-   const selectMatches = /*@__PURE__*/searchCommand((view, { query }) => {
-       let ranges = query.matchAll(view.state.doc, 1000);
-       if (!ranges || !ranges.length)
-           return false;
-       view.dispatch({
-           selection: EditorSelection$1.create(ranges.map(r => EditorSelection$1.range(r.from, r.to))),
-           userEvent: "select.search.matches"
-       });
-       return true;
-   });
-   /**
-   Select all instances of the currently selected text.
-   */
-   const selectSelectionMatches = ({ state, dispatch }) => {
-       let sel = state.selection;
-       if (sel.ranges.length > 1 || sel.main.empty)
-           return false;
-       let { from, to } = sel.main;
-       let ranges = [], main = 0;
-       for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {
-           if (ranges.length > 1000)
-               return false;
-           if (cur.value.from == from)
-               main = ranges.length;
-           ranges.push(EditorSelection$1.range(cur.value.from, cur.value.to));
-       }
-       dispatch(state.update({
-           selection: EditorSelection$1.create(ranges, main),
-           userEvent: "select.search.matches"
-       }));
-       return true;
-   };
-   /**
-   Replace the current match of the search query.
-   */
-   const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
-       let { state } = view, { from, to } = state.selection.main;
-       if (state.readOnly)
-           return false;
-       let next = query.nextMatch(state.doc, from, from);
-       if (!next)
-           return false;
-       let changes = [], selection, replacement;
-       if (next.from == from && next.to == to) {
-           replacement = state.toText(query.getReplacement(next));
-           changes.push({ from: next.from, to: next.to, insert: replacement });
-           next = query.nextMatch(state.doc, next.from, next.to);
-       }
-       if (next) {
-           let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;
-           selection = { anchor: next.from - off, head: next.to - off };
-       }
-       view.dispatch({
-           changes, selection,
-           scrollIntoView: !!selection,
-           effects: next ? announceMatch(view, next) : undefined,
-           userEvent: "input.replace"
-       });
-       return true;
-   });
-   /**
-   Replace all instances of the search query with the given
-   replacement.
-   */
-   const replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {
-       if (view.state.readOnly)
-           return false;
-       let changes = query.matchAll(view.state.doc, 1e9).map(match => {
-           let { from, to } = match;
-           return { from, to, insert: query.getReplacement(match) };
-       });
-       if (!changes.length)
-           return false;
-       view.dispatch({
-           changes,
-           userEvent: "input.replace.all"
-       });
-       return true;
-   });
-   function createSearchPanel(view) {
-       return view.state.facet(searchConfigFacet).createPanel(view);
-   }
-   function defaultQuery(state, fallback) {
-       var _a;
-       let sel = state.selection.main;
-       let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to);
-       let caseSensitive = (_a = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _a !== void 0 ? _a : state.facet(searchConfigFacet).caseSensitive;
-       return fallback && !selText ? fallback : new SearchQuery({ search: selText.replace(/\n/g, "\\n"), caseSensitive });
-   }
-   /**
-   Make sure the search panel is open and focused.
-   */
-   const openSearchPanel = view => {
-       let state = view.state.field(searchState, false);
-       if (state && state.panel) {
-           let panel = getPanel(view, createSearchPanel);
-           if (!panel)
-               return false;
-           let searchInput = panel.dom.querySelector("[name=search]");
-           if (searchInput != view.root.activeElement) {
-               let query = defaultQuery(view.state, state.query.spec);
-               if (query.valid)
-                   view.dispatch({ effects: setSearchQuery.of(query) });
-               searchInput.focus();
-               searchInput.select();
-           }
-       }
-       else {
-           view.dispatch({ effects: [
-                   togglePanel$2.of(true),
-                   state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect$1.appendConfig.of(searchExtensions)
-               ] });
-       }
-       return true;
-   };
-   /**
-   Close the search panel.
-   */
-   const closeSearchPanel = view => {
-       let state = view.state.field(searchState, false);
-       if (!state || !state.panel)
-           return false;
-       let panel = getPanel(view, createSearchPanel);
-       if (panel && panel.dom.contains(view.root.activeElement))
-           view.focus();
-       view.dispatch({ effects: togglePanel$2.of(false) });
-       return true;
-   };
-   /**
-   Default search-related key bindings.
-
-    - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
-    - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
-    - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
-    - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
-    - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
-   */
-   const searchKeymap = [
-       { key: "Mod-f", run: openSearchPanel, scope: "editor search-panel" },
-       { key: "F3", run: findNext, shift: findPrevious, scope: "editor search-panel", preventDefault: true },
-       { key: "Mod-g", run: findNext, shift: findPrevious, scope: "editor search-panel", preventDefault: true },
-       { key: "Escape", run: closeSearchPanel, scope: "editor search-panel" },
-       { key: "Mod-Shift-l", run: selectSelectionMatches },
-       { key: "Alt-g", run: gotoLine },
-       { key: "Mod-d", run: selectNextOccurrence, preventDefault: true },
-   ];
-   class SearchPanel {
-       constructor(view) {
-           this.view = view;
-           let query = this.query = view.state.field(searchState).query.spec;
-           this.commit = this.commit.bind(this);
-           this.searchField = crelt("input", {
-               value: query.search,
-               placeholder: phrase(view, "Find"),
-               "aria-label": phrase(view, "Find"),
-               class: "cm-textfield",
-               name: "search",
-               onchange: this.commit,
-               onkeyup: this.commit
-           });
-           this.replaceField = crelt("input", {
-               value: query.replace,
-               placeholder: phrase(view, "Replace"),
-               "aria-label": phrase(view, "Replace"),
-               class: "cm-textfield",
-               name: "replace",
-               onchange: this.commit,
-               onkeyup: this.commit
-           });
-           this.caseField = crelt("input", {
-               type: "checkbox",
-               name: "case",
-               checked: query.caseSensitive,
-               onchange: this.commit
-           });
-           this.reField = crelt("input", {
-               type: "checkbox",
-               name: "re",
-               checked: query.regexp,
-               onchange: this.commit
-           });
-           function button(name, onclick, content) {
-               return crelt("button", { class: "cm-button", name, onclick, type: "button" }, content);
-           }
-           this.dom = crelt("div", { onkeydown: (e) => this.keydown(e), class: "cm-search" }, [
-               this.searchField,
-               button("next", () => findNext(view), [phrase(view, "next")]),
-               button("prev", () => findPrevious(view), [phrase(view, "previous")]),
-               button("select", () => selectMatches(view), [phrase(view, "all")]),
-               crelt("label", null, [this.caseField, phrase(view, "match case")]),
-               crelt("label", null, [this.reField, phrase(view, "regexp")]),
-               ...view.state.readOnly ? [] : [
-                   crelt("br"),
-                   this.replaceField,
-                   button("replace", () => replaceNext(view), [phrase(view, "replace")]),
-                   button("replaceAll", () => replaceAll(view), [phrase(view, "replace all")]),
-                   crelt("button", {
-                       name: "close",
-                       onclick: () => closeSearchPanel(view),
-                       "aria-label": phrase(view, "close"),
-                       type: "button"
-                   }, ["×"])
-               ]
-           ]);
-       }
-       commit() {
-           let query = new SearchQuery({
-               search: this.searchField.value,
-               caseSensitive: this.caseField.checked,
-               regexp: this.reField.checked,
-               replace: this.replaceField.value
-           });
-           if (!query.eq(this.query)) {
-               this.query = query;
-               this.view.dispatch({ effects: setSearchQuery.of(query) });
-           }
-       }
-       keydown(e) {
-           if (runScopeHandlers(this.view, e, "search-panel")) {
-               e.preventDefault();
-           }
-           else if (e.keyCode == 13 && e.target == this.searchField) {
-               e.preventDefault();
-               (e.shiftKey ? findPrevious : findNext)(this.view);
-           }
-           else if (e.keyCode == 13 && e.target == this.replaceField) {
-               e.preventDefault();
-               replaceNext(this.view);
-           }
-       }
-       update(update) {
-           for (let tr of update.transactions)
-               for (let effect of tr.effects) {
-                   if (effect.is(setSearchQuery) && !effect.value.eq(this.query))
-                       this.setQuery(effect.value);
-               }
-       }
-       setQuery(query) {
-           this.query = query;
-           this.searchField.value = query.search;
-           this.replaceField.value = query.replace;
-           this.caseField.checked = query.caseSensitive;
-           this.reField.checked = query.regexp;
-       }
-       mount() {
-           this.searchField.select();
-       }
-       get pos() { return 80; }
-       get top() { return this.view.state.facet(searchConfigFacet).top; }
-   }
-   function phrase(view, phrase) { return view.state.phrase(phrase); }
-   const AnnounceMargin = 30;
-   const Break = /[\s\.,:;?!]/;
-   function announceMatch(view, { from, to }) {
-       let lineStart = view.state.doc.lineAt(from).from, lineEnd = view.state.doc.lineAt(to).to;
-       let start = Math.max(lineStart, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);
-       let text = view.state.sliceDoc(start, end);
-       if (start != lineStart) {
-           for (let i = 0; i < AnnounceMargin; i++)
-               if (!Break.test(text[i + 1]) && Break.test(text[i])) {
-                   text = text.slice(i);
-                   break;
-               }
-       }
-       if (end != lineEnd) {
-           for (let i = text.length - 1; i > text.length - AnnounceMargin; i--)
-               if (!Break.test(text[i - 1]) && Break.test(text[i])) {
-                   text = text.slice(0, i);
-                   break;
-               }
-       }
-       return EditorView$1.announce.of(`${view.state.phrase("current match")}. ${text} ${view.state.phrase("on line")} ${view.state.doc.lineAt(from).number}`);
-   }
-   const baseTheme$5 = /*@__PURE__*/EditorView$1.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" }
-   });
-   const searchExtensions = [
-       searchState,
-       /*@__PURE__*/Prec$1.lowest(searchHighlighter),
-       baseTheme$5
-   ];
-
-   /**
-   An instance of this is passed to completion source functions.
-   */
-   let CompletionContext$1 = class CompletionContext {
-       /**
-       Create a new completion context. (Mostly useful for testing
-       completion sources—in the editor, the extension will create
-       these for you.)
-       */
-       constructor(
-       /**
-       The editor state that the completion happens in.
-       */
-       state, 
-       /**
-       The position at which the completion is happening.
-       */
-       pos, 
-       /**
-       Indicates whether completion was activated explicitly, or
-       implicitly by typing. The usual way to respond to this is to
-       only return completions when either there is part of a
-       completable entity before the cursor, or `explicit` is true.
-       */
-       explicit) {
-           this.state = state;
-           this.pos = pos;
-           this.explicit = explicit;
-           /**
-           @internal
-           */
-           this.abortListeners = [];
-       }
-       /**
-       Get the extent, content, and (if there is a token) type of the
-       token before `this.pos`.
-       */
-       tokenBefore(types) {
-           let token = syntaxTree$2(this.state).resolveInner(this.pos, -1);
-           while (token && types.indexOf(token.name) < 0)
-               token = token.parent;
-           return token ? { from: token.from, to: this.pos,
-               text: this.state.sliceDoc(token.from, this.pos),
-               type: token.type } : null;
-       }
-       /**
-       Get the match of the given expression directly before the
-       cursor.
-       */
-       matchBefore(expr) {
-           let line = this.state.doc.lineAt(this.pos);
-           let start = Math.max(line.from, this.pos - 250);
-           let str = line.text.slice(start - line.from, this.pos - line.from);
-           let found = str.search(ensureAnchor$1(expr, false));
-           return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) };
-       }
-       /**
-       Yields true when the query has been aborted. Can be useful in
-       asynchronous queries to avoid doing work that will be ignored.
-       */
-       get aborted() { return this.abortListeners == null; }
-       /**
-       Allows you to register abort handlers, which will be called when
-       the query is
-       [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
-       */
-       addEventListener(type, listener) {
-           if (type == "abort" && this.abortListeners)
-               this.abortListeners.push(listener);
-       }
-   };
-   function toSet$1(chars) {
-       let flat = Object.keys(chars).join("");
-       let words = /\w/.test(flat);
-       if (words)
-           flat = flat.replace(/\w/g, "");
-       return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
-   }
-   function prefixMatch$1(options) {
-       let first = Object.create(null), rest = Object.create(null);
-       for (let { label } of options) {
-           first[label[0]] = true;
-           for (let i = 1; i < label.length; i++)
-               rest[label[i]] = true;
-       }
-       let source = toSet$1(first) + toSet$1(rest) + "*$";
-       return [new RegExp("^" + source), new RegExp(source)];
-   }
-   /**
-   Given a a fixed array of options, return an autocompleter that
-   completes them.
-   */
-   function completeFromList$1(list) {
-       let options = list.map(o => typeof o == "string" ? { label: o } : o);
-       let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch$1(options);
-       return (context) => {
-           let token = context.matchBefore(match);
-           return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null;
-       };
-   }
-   let Option$1 = class Option {
-       constructor(completion, source, match) {
-           this.completion = completion;
-           this.source = source;
-           this.match = match;
-       }
-   };
-   function cur$1(state) { return state.selection.main.head; }
-   // Make sure the given regexp has a $ at its end and, if `start` is
-   // true, a ^ at its start.
-   function ensureAnchor$1(expr, start) {
-       var _a;
-       let { source } = expr;
-       let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$";
-       if (!addStart && !addEnd)
-           return expr;
-       return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : ""));
-   }
-   /**
-   Helper function that returns a transaction spec which inserts a
-   completion's text in the main selection range, and any other
-   selection range that has the same text in front of it.
-   */
-   function insertCompletionText$1(state, text, from, to) {
-       return Object.assign(Object.assign({}, state.changeByRange(range => {
-           if (range == state.selection.main)
-               return {
-                   changes: { from: from, to: to, insert: text },
-                   range: EditorSelection$3.cursor(from + text.length)
-               };
-           let len = to - from;
-           if (!range.empty ||
-               len && state.sliceDoc(range.from - len, range.from) != state.sliceDoc(from, to))
-               return { range };
-           return {
-               changes: { from: range.from - len, to: range.from, insert: text },
-               range: EditorSelection$3.cursor(range.from - len + text.length)
-           };
-       })), { userEvent: "input.complete" });
-   }
-   function applyCompletion$1(view, option) {
-       const apply = option.completion.apply || option.completion.label;
-       let result = option.source;
-       if (typeof apply == "string")
-           view.dispatch(insertCompletionText$1(view.state, apply, result.from, result.to));
-       else
-           apply(view, option.completion, result.from, result.to);
-   }
-   const SourceCache$1 = /*@__PURE__*/new WeakMap();
-   function asSource$1(source) {
-       if (!Array.isArray(source))
-           return source;
-       let known = SourceCache$1.get(source);
-       if (!known)
-           SourceCache$1.set(source, known = completeFromList$1(source));
-       return known;
-   }
-
-   // A pattern matcher for fuzzy completion matching. Create an instance
-   // once for a pattern, and then use that to match any number of
-   // completions.
-   let FuzzyMatcher$1 = class FuzzyMatcher {
-       constructor(pattern) {
-           this.pattern = pattern;
-           this.chars = [];
-           this.folded = [];
-           // Buffers reused by calls to `match` to track matched character
-           // positions.
-           this.any = [];
-           this.precise = [];
-           this.byWord = [];
-           for (let p = 0; p < pattern.length;) {
-               let char = codePointAt$4(pattern, p), size = codePointSize$4(char);
-               this.chars.push(char);
-               let part = pattern.slice(p, p + size), upper = part.toUpperCase();
-               this.folded.push(codePointAt$4(upper == part ? part.toLowerCase() : upper, 0));
-               p += size;
-           }
-           this.astral = pattern.length != this.chars.length;
-       }
-       // Matches a given word (completion) against the pattern (input).
-       // Will return null for no match, and otherwise an array that starts
-       // with the match score, followed by any number of `from, to` pairs
-       // indicating the matched parts of `word`.
-       //
-       // The score is a number that is more negative the worse the match
-       // is. See `Penalty` above.
-       match(word) {
-           if (this.pattern.length == 0)
-               return [0];
-           if (word.length < this.pattern.length)
-               return null;
-           let { chars, folded, any, precise, byWord } = this;
-           // For single-character queries, only match when they occur right
-           // at the start
-           if (chars.length == 1) {
-               let first = codePointAt$4(word, 0);
-               return first == chars[0] ? [0, 0, codePointSize$4(first)]
-                   : first == folded[0] ? [-200 /* CaseFold */, 0, codePointSize$4(first)] : null;
-           }
-           let direct = word.indexOf(this.pattern);
-           if (direct == 0)
-               return [0, 0, this.pattern.length];
-           let len = chars.length, anyTo = 0;
-           if (direct < 0) {
-               for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) {
-                   let next = codePointAt$4(word, i);
-                   if (next == chars[anyTo] || next == folded[anyTo])
-                       any[anyTo++] = i;
-                   i += codePointSize$4(next);
-               }
-               // No match, exit immediately
-               if (anyTo < len)
-                   return null;
-           }
-           // This tracks the extent of the precise (non-folded, not
-           // necessarily adjacent) match
-           let preciseTo = 0;
-           // Tracks whether there is a match that hits only characters that
-           // appear to be starting words. `byWordFolded` is set to true when
-           // a case folded character is encountered in such a match
-           let byWordTo = 0, byWordFolded = false;
-           // If we've found a partial adjacent match, these track its state
-           let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
-           let hasLower = /[a-z]/.test(word), wordAdjacent = true;
-           // Go over the option's text, scanning for the various kinds of matches
-           for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* NonWord */; i < e && byWordTo < len;) {
-               let next = codePointAt$4(word, i);
-               if (direct < 0) {
-                   if (preciseTo < len && next == chars[preciseTo])
-                       precise[preciseTo++] = i;
-                   if (adjacentTo < len) {
-                       if (next == chars[adjacentTo] || next == folded[adjacentTo]) {
-                           if (adjacentTo == 0)
-                               adjacentStart = i;
-                           adjacentEnd = i + 1;
-                           adjacentTo++;
-                       }
-                       else {
-                           adjacentTo = 0;
-                       }
-                   }
-               }
-               let ch, type = next < 0xff
-                   ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Lower */ : next >= 65 && next <= 90 ? 1 /* Upper */ : 0 /* NonWord */)
-                   : ((ch = fromCodePoint$2(next)) != ch.toLowerCase() ? 1 /* Upper */ : ch != ch.toUpperCase() ? 2 /* Lower */ : 0 /* NonWord */);
-               if (!i || type == 1 /* Upper */ && hasLower || prevType == 0 /* NonWord */ && type != 0 /* NonWord */) {
-                   if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
-                       byWord[byWordTo++] = i;
-                   else if (byWord.length)
-                       wordAdjacent = false;
-               }
-               prevType = type;
-               i += codePointSize$4(next);
-           }
-           if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
-               return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0), byWord, word);
-           if (adjacentTo == len && adjacentStart == 0)
-               return [-200 /* CaseFold */ - word.length, 0, adjacentEnd];
-           if (direct > -1)
-               return [-700 /* NotStart */ - word.length, direct, direct + this.pattern.length];
-           if (adjacentTo == len)
-               return [-200 /* CaseFold */ + -700 /* NotStart */ - word.length, adjacentStart, adjacentEnd];
-           if (byWordTo == len)
-               return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0) + -700 /* NotStart */ +
-                   (wordAdjacent ? 0 : -1100 /* Gap */), byWord, word);
-           return chars.length == 2 ? null : this.result((any[0] ? -700 /* NotStart */ : 0) + -200 /* CaseFold */ + -1100 /* Gap */, any, word);
-       }
-       result(score, positions, word) {
-           let result = [score - word.length], i = 1;
-           for (let pos of positions) {
-               let to = pos + (this.astral ? codePointSize$4(codePointAt$4(word, pos)) : 1);
-               if (i > 1 && result[i - 1] == pos)
-                   result[i - 1] = to;
-               else {
-                   result[i++] = pos;
-                   result[i++] = to;
-               }
-           }
-           return result;
-       }
-   };
-
-   const completionConfig$1 = /*@__PURE__*/Facet$3.define({
-       combine(configs) {
-           return combineConfig$3(configs, {
-               activateOnTyping: true,
-               override: null,
-               closeOnBlur: true,
-               maxRenderedOptions: 100,
-               defaultKeymap: true,
-               optionClass: () => "",
-               aboveCursor: false,
-               icons: true,
-               addToOptions: []
-           }, {
-               defaultKeymap: (a, b) => a && b,
-               closeOnBlur: (a, b) => a && b,
-               icons: (a, b) => a && b,
-               optionClass: (a, b) => c => joinClass$1(a(c), b(c)),
-               addToOptions: (a, b) => a.concat(b)
-           });
-       }
-   });
-   function joinClass$1(a, b) {
-       return a ? b ? a + " " + b : a : b;
-   }
-
-   function optionContent$1(config) {
-       let content = config.addToOptions.slice();
-       if (config.icons)
-           content.push({
-               render(completion) {
-                   let icon = document.createElement("div");
-                   icon.classList.add("cm-completionIcon");
-                   if (completion.type)
-                       icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls));
-                   icon.setAttribute("aria-hidden", "true");
-                   return icon;
-               },
-               position: 20
-           });
-       content.push({
-           render(completion, _s, match) {
-               let labelElt = document.createElement("span");
-               labelElt.className = "cm-completionLabel";
-               let { label } = completion, off = 0;
-               for (let j = 1; j < match.length;) {
-                   let from = match[j++], to = match[j++];
-                   if (from > off)
-                       labelElt.appendChild(document.createTextNode(label.slice(off, from)));
-                   let span = labelElt.appendChild(document.createElement("span"));
-                   span.appendChild(document.createTextNode(label.slice(from, to)));
-                   span.className = "cm-completionMatchedText";
-                   off = to;
-               }
-               if (off < label.length)
-                   labelElt.appendChild(document.createTextNode(label.slice(off)));
-               return labelElt;
-           },
-           position: 50
-       }, {
-           render(completion) {
-               if (!completion.detail)
-                   return null;
-               let detailElt = document.createElement("span");
-               detailElt.className = "cm-completionDetail";
-               detailElt.textContent = completion.detail;
-               return detailElt;
-           },
-           position: 80
-       });
-       return content.sort((a, b) => a.position - b.position).map(a => a.render);
-   }
-   function rangeAroundSelected$1(total, selected, max) {
-       if (total <= max)
-           return { from: 0, to: total };
-       if (selected <= (total >> 1)) {
-           let off = Math.floor(selected / max);
-           return { from: off * max, to: (off + 1) * max };
-       }
-       let off = Math.floor((total - selected) / max);
-       return { from: total - (off + 1) * max, to: total - off * max };
-   }
-   let CompletionTooltip$1 = class CompletionTooltip {
-       constructor(view, stateField) {
-           this.view = view;
-           this.stateField = stateField;
-           this.info = null;
-           this.placeInfo = {
-               read: () => this.measureInfo(),
-               write: (pos) => this.positionInfo(pos),
-               key: this
-           };
-           let cState = view.state.field(stateField);
-           let { options, selected } = cState.open;
-           let config = view.state.facet(completionConfig$1);
-           this.optionContent = optionContent$1(config);
-           this.optionClass = config.optionClass;
-           this.range = rangeAroundSelected$1(options.length, selected, config.maxRenderedOptions);
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-tooltip-autocomplete";
-           this.dom.addEventListener("mousedown", (e) => {
-               for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) {
-                   if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) {
-                       applyCompletion$1(view, options[+match[1]]);
-                       e.preventDefault();
-                       return;
-                   }
-               }
-           });
-           this.list = this.dom.appendChild(this.createListBox(options, cState.id, this.range));
-           this.list.addEventListener("scroll", () => {
-               if (this.info)
-                   this.view.requestMeasure(this.placeInfo);
-           });
-       }
-       mount() { this.updateSel(); }
-       update(update) {
-           if (update.state.field(this.stateField) != update.startState.field(this.stateField))
-               this.updateSel();
-       }
-       positioned() {
-           if (this.info)
-               this.view.requestMeasure(this.placeInfo);
-       }
-       updateSel() {
-           let cState = this.view.state.field(this.stateField), open = cState.open;
-           if (open.selected < this.range.from || open.selected >= this.range.to) {
-               this.range = rangeAroundSelected$1(open.options.length, open.selected, this.view.state.facet(completionConfig$1).maxRenderedOptions);
-               this.list.remove();
-               this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
-               this.list.addEventListener("scroll", () => {
-                   if (this.info)
-                       this.view.requestMeasure(this.placeInfo);
-               });
-           }
-           if (this.updateSelectedOption(open.selected)) {
-               if (this.info) {
-                   this.info.remove();
-                   this.info = null;
-               }
-               let { completion } = open.options[open.selected];
-               let { info } = completion;
-               if (!info)
-                   return;
-               let infoResult = typeof info === 'string' ? document.createTextNode(info) : info(completion);
-               if (!infoResult)
-                   return;
-               if ('then' in infoResult) {
-                   infoResult.then(node => {
-                       if (node && this.view.state.field(this.stateField, false) == cState)
-                           this.addInfoPane(node);
-                   }).catch(e => logException$3(this.view.state, e, "completion info"));
-               }
-               else {
-                   this.addInfoPane(infoResult);
-               }
-           }
-       }
-       addInfoPane(content) {
-           let dom = this.info = document.createElement("div");
-           dom.className = "cm-tooltip cm-completionInfo";
-           dom.appendChild(content);
-           this.dom.appendChild(dom);
-           this.view.requestMeasure(this.placeInfo);
-       }
-       updateSelectedOption(selected) {
-           let set = null;
-           for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) {
-               if (i == selected) {
-                   if (!opt.hasAttribute("aria-selected")) {
-                       opt.setAttribute("aria-selected", "true");
-                       set = opt;
-                   }
-               }
-               else {
-                   if (opt.hasAttribute("aria-selected"))
-                       opt.removeAttribute("aria-selected");
-               }
-           }
-           if (set)
-               scrollIntoView$2(this.list, set);
-           return set;
-       }
-       measureInfo() {
-           let sel = this.dom.querySelector("[aria-selected]");
-           if (!sel || !this.info)
-               return null;
-           let listRect = this.dom.getBoundingClientRect();
-           let infoRect = this.info.getBoundingClientRect();
-           let selRect = sel.getBoundingClientRect();
-           if (selRect.top > Math.min(innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
-               return null;
-           let top = Math.max(0, Math.min(selRect.top, innerHeight - infoRect.height)) - listRect.top;
-           let left = this.view.textDirection == Direction$3.RTL;
-           let spaceLeft = listRect.left, spaceRight = innerWidth - listRect.right;
-           if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
-               left = false;
-           else if (!left && spaceRight < Math.min(infoRect.width, spaceLeft))
-               left = true;
-           return { top, left };
-       }
-       positionInfo(pos) {
-           if (this.info) {
-               this.info.style.top = (pos ? pos.top : -1e6) + "px";
-               if (pos) {
-                   this.info.classList.toggle("cm-completionInfo-left", pos.left);
-                   this.info.classList.toggle("cm-completionInfo-right", !pos.left);
-               }
-           }
-       }
-       createListBox(options, id, range) {
-           const ul = document.createElement("ul");
-           ul.id = id;
-           ul.setAttribute("role", "listbox");
-           ul.setAttribute("aria-expanded", "true");
-           ul.setAttribute("aria-label", this.view.state.phrase("Completions"));
-           for (let i = range.from; i < range.to; i++) {
-               let { completion, match } = options[i];
-               const li = ul.appendChild(document.createElement("li"));
-               li.id = id + "-" + i;
-               li.setAttribute("role", "option");
-               let cls = this.optionClass(completion);
-               if (cls)
-                   li.className = cls;
-               for (let source of this.optionContent) {
-                   let node = source(completion, this.view.state, match);
-                   if (node)
-                       li.appendChild(node);
-               }
-           }
-           if (range.from)
-               ul.classList.add("cm-completionListIncompleteTop");
-           if (range.to < options.length)
-               ul.classList.add("cm-completionListIncompleteBottom");
-           return ul;
-       }
-   };
-   // We allocate a new function instance every time the completion
-   // changes to force redrawing/repositioning of the tooltip
-   function completionTooltip$1(stateField) {
-       return (view) => new CompletionTooltip$1(view, stateField);
-   }
-   function scrollIntoView$2(container, element) {
-       let parent = container.getBoundingClientRect();
-       let self = element.getBoundingClientRect();
-       if (self.top < parent.top)
-           container.scrollTop -= parent.top - self.top;
-       else if (self.bottom > parent.bottom)
-           container.scrollTop += self.bottom - parent.bottom;
-   }
-
-   // Used to pick a preferred option when two options with the same
-   // label occur in the result.
-   function score$1(option) {
-       return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) +
-           (option.type ? 1 : 0);
-   }
-   function sortOptions$1(active, state) {
-       let options = [], i = 0;
-       for (let a of active)
-           if (a.hasResult()) {
-               if (a.result.filter === false) {
-                   let getMatch = a.result.getMatch;
-                   for (let option of a.result.options) {
-                       let match = [1e9 - i++];
-                       if (getMatch)
-                           for (let n of getMatch(option))
-                               match.push(n);
-                       options.push(new Option$1(option, a, match));
-                   }
-               }
-               else {
-                   let matcher = new FuzzyMatcher$1(state.sliceDoc(a.from, a.to)), match;
-                   for (let option of a.result.options)
-                       if (match = matcher.match(option.label)) {
-                           if (option.boost != null)
-                               match[0] += option.boost;
-                           options.push(new Option$1(option, a, match));
-                       }
-               }
-           }
-       let result = [], prev = null;
-       for (let opt of options.sort(cmpOption)) {
-           if (!prev || prev.label != opt.completion.label || prev.detail != opt.completion.detail ||
-               (prev.type != null && opt.completion.type != null && prev.type != opt.completion.type) ||
-               prev.apply != opt.completion.apply)
-               result.push(opt);
-           else if (score$1(opt.completion) > score$1(prev))
-               result[result.length - 1] = opt;
-           prev = opt.completion;
-       }
-       return result;
-   }
-   let CompletionDialog$1 = class CompletionDialog {
-       constructor(options, attrs, tooltip, timestamp, selected) {
-           this.options = options;
-           this.attrs = attrs;
-           this.tooltip = tooltip;
-           this.timestamp = timestamp;
-           this.selected = selected;
-       }
-       setSelected(selected, id) {
-           return selected == this.selected || selected >= this.options.length ? this
-               : new CompletionDialog(this.options, makeAttrs$1(id, selected), this.tooltip, this.timestamp, selected);
-       }
-       static build(active, state, id, prev, conf) {
-           let options = sortOptions$1(active, state);
-           if (!options.length)
-               return null;
-           let selected = 0;
-           if (prev && prev.selected) {
-               let selectedValue = prev.options[prev.selected].completion;
-               for (let i = 0; i < options.length; i++)
-                   if (options[i].completion == selectedValue) {
-                       selected = i;
-                       break;
-                   }
-           }
-           return new CompletionDialog(options, makeAttrs$1(id, selected), {
-               pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
-               create: completionTooltip$1(completionState$1),
-               above: conf.aboveCursor,
-           }, prev ? prev.timestamp : Date.now(), selected);
-       }
-       map(changes) {
-           return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected);
-       }
-   };
-   let CompletionState$1 = class CompletionState {
-       constructor(active, id, open) {
-           this.active = active;
-           this.id = id;
-           this.open = open;
-       }
-       static start() {
-           return new CompletionState(none$2, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
-       }
-       update(tr) {
-           let { state } = tr, conf = state.facet(completionConfig$1);
-           let sources = conf.override ||
-               state.languageDataAt("autocomplete", cur$1(state)).map(asSource$1);
-           let active = sources.map(source => {
-               let value = this.active.find(s => s.source == source) ||
-                   new ActiveSource$1(source, this.active.some(a => a.state != 0 /* Inactive */) ? 1 /* Pending */ : 0 /* Inactive */);
-               return value.update(tr, conf);
-           });
-           if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
-               active = this.active;
-           let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
-               !sameResults$1(active, this.active) ? CompletionDialog$1.build(active, state, this.id, this.open, conf)
-               : this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
-           if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
-               active = active.map(a => a.hasResult() ? new ActiveSource$1(a.source, 0 /* Inactive */) : a);
-           for (let effect of tr.effects)
-               if (effect.is(setSelectedEffect$1))
-                   open = open && open.setSelected(effect.value, this.id);
-           return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
-       }
-       get tooltip() { return this.open ? this.open.tooltip : null; }
-       get attrs() { return this.open ? this.open.attrs : baseAttrs$1; }
-   };
-   function sameResults$1(a, b) {
-       if (a == b)
-           return true;
-       for (let iA = 0, iB = 0;;) {
-           while (iA < a.length && !a[iA].hasResult)
-               iA++;
-           while (iB < b.length && !b[iB].hasResult)
-               iB++;
-           let endA = iA == a.length, endB = iB == b.length;
-           if (endA || endB)
-               return endA == endB;
-           if (a[iA++].result != b[iB++].result)
-               return false;
-       }
-   }
-   const baseAttrs$1 = {
-       "aria-autocomplete": "list"
-   };
-   function makeAttrs$1(id, selected) {
-       return {
-           "aria-autocomplete": "list",
-           "aria-haspopup": "listbox",
-           "aria-activedescendant": id + "-" + selected,
-           "aria-controls": id
-       };
-   }
-   const none$2 = [];
-   function cmpOption(a, b) {
-       let dScore = b.match[0] - a.match[0];
-       if (dScore)
-           return dScore;
-       return a.completion.label.localeCompare(b.completion.label);
-   }
-   function getUserEvent(tr) {
-       return tr.isUserEvent("input.type") ? "input" : tr.isUserEvent("delete.backward") ? "delete" : null;
-   }
-   let ActiveSource$1 = class ActiveSource {
-       constructor(source, state, explicitPos = -1) {
-           this.source = source;
-           this.state = state;
-           this.explicitPos = explicitPos;
-       }
-       hasResult() { return false; }
-       update(tr, conf) {
-           let event = getUserEvent(tr), value = this;
-           if (event)
-               value = value.handleUserEvent(tr, event, conf);
-           else if (tr.docChanged)
-               value = value.handleChange(tr);
-           else if (tr.selection && value.state != 0 /* Inactive */)
-               value = new ActiveSource(value.source, 0 /* Inactive */);
-           for (let effect of tr.effects) {
-               if (effect.is(startCompletionEffect$1))
-                   value = new ActiveSource(value.source, 1 /* Pending */, effect.value ? cur$1(tr.state) : -1);
-               else if (effect.is(closeCompletionEffect$1))
-                   value = new ActiveSource(value.source, 0 /* Inactive */);
-               else if (effect.is(setActiveEffect$1))
-                   for (let active of effect.value)
-                       if (active.source == value.source)
-                           value = active;
-           }
-           return value;
-       }
-       handleUserEvent(tr, type, conf) {
-           return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* Pending */);
-       }
-       handleChange(tr) {
-           return tr.changes.touchesRange(cur$1(tr.startState)) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
-       }
-       map(changes) {
-           return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
-       }
-   };
-   let ActiveResult$1 = class ActiveResult extends ActiveSource$1 {
-       constructor(source, explicitPos, result, from, to) {
-           super(source, 2 /* Result */, explicitPos);
-           this.result = result;
-           this.from = from;
-           this.to = to;
-       }
-       hasResult() { return true; }
-       handleUserEvent(tr, type, conf) {
-           var _a;
-           let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1);
-           let pos = cur$1(tr.state);
-           if ((this.explicitPos < 0 ? pos <= from : pos < this.from) ||
-               pos > to ||
-               type == "delete" && cur$1(tr.startState) == this.from)
-               return new ActiveSource$1(this.source, type == "input" && conf.activateOnTyping ? 1 /* Pending */ : 0 /* Inactive */);
-           let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos), updated;
-           if (checkValid$1(this.result.validFor, tr.state, from, to))
-               return new ActiveResult(this.source, explicitPos, this.result, from, to);
-           if (this.result.update &&
-               (updated = this.result.update(this.result, from, to, new CompletionContext$1(tr.state, pos, explicitPos >= 0))))
-               return new ActiveResult(this.source, explicitPos, updated, updated.from, (_a = updated.to) !== null && _a !== void 0 ? _a : cur$1(tr.state));
-           return new ActiveSource$1(this.source, 1 /* Pending */, explicitPos);
-       }
-       handleChange(tr) {
-           return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource$1(this.source, 0 /* Inactive */) : this.map(tr.changes);
-       }
-       map(mapping) {
-           return mapping.empty ? this :
-               new ActiveResult(this.source, this.explicitPos < 0 ? -1 : mapping.mapPos(this.explicitPos), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
-       }
-   };
-   function checkValid$1(validFor, state, from, to) {
-       if (!validFor)
-           return false;
-       let text = state.sliceDoc(from, to);
-       return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor$1(validFor, true).test(text);
-   }
-   const startCompletionEffect$1 = /*@__PURE__*/StateEffect$3.define();
-   const closeCompletionEffect$1 = /*@__PURE__*/StateEffect$3.define();
-   const setActiveEffect$1 = /*@__PURE__*/StateEffect$3.define({
-       map(sources, mapping) { return sources.map(s => s.map(mapping)); }
-   });
-   const setSelectedEffect$1 = /*@__PURE__*/StateEffect$3.define();
-   const completionState$1 = /*@__PURE__*/StateField$3.define({
-       create() { return CompletionState$1.start(); },
-       update(value, tr) { return value.update(tr); },
-       provide: f => [
-           showTooltip$1.from(f, val => val.tooltip),
-           EditorView$3.contentAttributes.from(f, state => state.attrs)
-       ]
-   });
-
-   const CompletionInteractMargin = 75;
-   /**
-   Returns a command that moves the completion selection forward or
-   backward by the given amount.
-   */
-   function moveCompletionSelection$1(forward, by = "option") {
-       return (view) => {
-           let cState = view.state.field(completionState$1, false);
-           if (!cState || !cState.open || Date.now() - cState.open.timestamp < CompletionInteractMargin)
-               return false;
-           let step = 1, tooltip;
-           if (by == "page" && (tooltip = getTooltip$1(view, cState.open.tooltip)))
-               step = Math.max(2, Math.floor(tooltip.dom.offsetHeight /
-                   tooltip.dom.querySelector("li").offsetHeight) - 1);
-           let selected = cState.open.selected + step * (forward ? 1 : -1), { length } = cState.open.options;
-           if (selected < 0)
-               selected = by == "page" ? 0 : length - 1;
-           else if (selected >= length)
-               selected = by == "page" ? length - 1 : 0;
-           view.dispatch({ effects: setSelectedEffect$1.of(selected) });
-           return true;
-       };
-   }
-   /**
-   Accept the current completion.
-   */
-   const acceptCompletion$1 = (view) => {
-       let cState = view.state.field(completionState$1, false);
-       if (view.state.readOnly || !cState || !cState.open || Date.now() - cState.open.timestamp < CompletionInteractMargin)
-           return false;
-       applyCompletion$1(view, cState.open.options[cState.open.selected]);
-       return true;
-   };
-   /**
-   Explicitly start autocompletion.
-   */
-   const startCompletion$1 = (view) => {
-       let cState = view.state.field(completionState$1, false);
-       if (!cState)
-           return false;
-       view.dispatch({ effects: startCompletionEffect$1.of(true) });
-       return true;
-   };
-   /**
-   Close the currently active completion.
-   */
-   const closeCompletion$1 = (view) => {
-       let cState = view.state.field(completionState$1, false);
-       if (!cState || !cState.active.some(a => a.state != 0 /* Inactive */))
-           return false;
-       view.dispatch({ effects: closeCompletionEffect$1.of(null) });
-       return true;
-   };
-   let RunningQuery$1 = class RunningQuery {
-       constructor(active, context) {
-           this.active = active;
-           this.context = context;
-           this.time = Date.now();
-           this.updates = [];
-           // Note that 'undefined' means 'not done yet', whereas 'null' means
-           // 'query returned null'.
-           this.done = undefined;
-       }
-   };
-   const DebounceTime = 50, MaxUpdateCount$1 = 50, MinAbortTime$1 = 1000;
-   const completionPlugin$1 = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.debounceUpdate = -1;
-           this.running = [];
-           this.debounceAccept = -1;
-           this.composing = 0 /* None */;
-           for (let active of view.state.field(completionState$1).active)
-               if (active.state == 1 /* Pending */)
-                   this.startQuery(active);
-       }
-       update(update) {
-           let cState = update.state.field(completionState$1);
-           if (!update.selectionSet && !update.docChanged && update.startState.field(completionState$1) == cState)
-               return;
-           let doesReset = update.transactions.some(tr => {
-               return (tr.selection || tr.docChanged) && !getUserEvent(tr);
-           });
-           for (let i = 0; i < this.running.length; i++) {
-               let query = this.running[i];
-               if (doesReset ||
-                   query.updates.length + update.transactions.length > MaxUpdateCount$1 && Date.now() - query.time > MinAbortTime$1) {
-                   for (let handler of query.context.abortListeners) {
-                       try {
-                           handler();
-                       }
-                       catch (e) {
-                           logException$3(this.view.state, e);
-                       }
-                   }
-                   query.context.abortListeners = null;
-                   this.running.splice(i--, 1);
-               }
-               else {
-                   query.updates.push(...update.transactions);
-               }
-           }
-           if (this.debounceUpdate > -1)
-               clearTimeout(this.debounceUpdate);
-           this.debounceUpdate = cState.active.some(a => a.state == 1 /* Pending */ && !this.running.some(q => q.active.source == a.source))
-               ? setTimeout(() => this.startUpdate(), DebounceTime) : -1;
-           if (this.composing != 0 /* None */)
-               for (let tr of update.transactions) {
-                   if (getUserEvent(tr) == "input")
-                       this.composing = 2 /* Changed */;
-                   else if (this.composing == 2 /* Changed */ && tr.selection)
-                       this.composing = 3 /* ChangedAndMoved */;
-               }
-       }
-       startUpdate() {
-           this.debounceUpdate = -1;
-           let { state } = this.view, cState = state.field(completionState$1);
-           for (let active of cState.active) {
-               if (active.state == 1 /* Pending */ && !this.running.some(r => r.active.source == active.source))
-                   this.startQuery(active);
-           }
-       }
-       startQuery(active) {
-           let { state } = this.view, pos = cur$1(state);
-           let context = new CompletionContext$1(state, pos, active.explicitPos == pos);
-           let pending = new RunningQuery$1(active, context);
-           this.running.push(pending);
-           Promise.resolve(active.source(context)).then(result => {
-               if (!pending.context.aborted) {
-                   pending.done = result || null;
-                   this.scheduleAccept();
-               }
-           }, err => {
-               this.view.dispatch({ effects: closeCompletionEffect$1.of(null) });
-               logException$3(this.view.state, err);
-           });
-       }
-       scheduleAccept() {
-           if (this.running.every(q => q.done !== undefined))
-               this.accept();
-           else if (this.debounceAccept < 0)
-               this.debounceAccept = setTimeout(() => this.accept(), DebounceTime);
-       }
-       // For each finished query in this.running, try to create a result
-       // or, if appropriate, restart the query.
-       accept() {
-           var _a;
-           if (this.debounceAccept > -1)
-               clearTimeout(this.debounceAccept);
-           this.debounceAccept = -1;
-           let updated = [];
-           let conf = this.view.state.facet(completionConfig$1);
-           for (let i = 0; i < this.running.length; i++) {
-               let query = this.running[i];
-               if (query.done === undefined)
-                   continue;
-               this.running.splice(i--, 1);
-               if (query.done) {
-                   let active = new ActiveResult$1(query.active.source, query.active.explicitPos, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : cur$1(query.updates.length ? query.updates[0].startState : this.view.state));
-                   // Replay the transactions that happened since the start of
-                   // the request and see if that preserves the result
-                   for (let tr of query.updates)
-                       active = active.update(tr, conf);
-                   if (active.hasResult()) {
-                       updated.push(active);
-                       continue;
-                   }
-               }
-               let current = this.view.state.field(completionState$1).active.find(a => a.source == query.active.source);
-               if (current && current.state == 1 /* Pending */) {
-                   if (query.done == null) {
-                       // Explicitly failed. Should clear the pending status if it
-                       // hasn't been re-set in the meantime.
-                       let active = new ActiveSource$1(query.active.source, 0 /* Inactive */);
-                       for (let tr of query.updates)
-                           active = active.update(tr, conf);
-                       if (active.state != 1 /* Pending */)
-                           updated.push(active);
-                   }
-                   else {
-                       // Cleared by subsequent transactions. Restart.
-                       this.startQuery(current);
-                   }
-               }
-           }
-           if (updated.length)
-               this.view.dispatch({ effects: setActiveEffect$1.of(updated) });
-       }
-   }, {
-       eventHandlers: {
-           blur() {
-               let state = this.view.state.field(completionState$1, false);
-               if (state && state.tooltip && this.view.state.facet(completionConfig$1).closeOnBlur)
-                   this.view.dispatch({ effects: closeCompletionEffect$1.of(null) });
-           },
-           compositionstart() {
-               this.composing = 1 /* Started */;
-           },
-           compositionend() {
-               if (this.composing == 3 /* ChangedAndMoved */) {
-                   // Safari fires compositionend events synchronously, possibly
-                   // from inside an update, so dispatch asynchronously to avoid reentrancy
-                   setTimeout(() => this.view.dispatch({ effects: startCompletionEffect$1.of(false) }), 20);
-               }
-               this.composing = 0 /* None */;
-           }
-       }
-   });
-
-   const baseTheme$4 = /*@__PURE__*/EditorView$3.baseTheme({
-       ".cm-tooltip.cm-tooltip-autocomplete": {
-           "& > ul": {
-               fontFamily: "monospace",
-               whiteSpace: "nowrap",
-               overflow: "hidden auto",
-               maxWidth_fallback: "700px",
-               maxWidth: "min(700px, 95vw)",
-               minWidth: "250px",
-               maxHeight: "10em",
-               listStyle: "none",
-               margin: 0,
-               padding: 0,
-               "& > li": {
-                   overflowX: "hidden",
-                   textOverflow: "ellipsis",
-                   cursor: "pointer",
-                   padding: "1px 3px",
-                   lineHeight: 1.2
-               },
-           }
-       },
-       "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
-           background: "#17c",
-           color: "white",
-       },
-       "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
-           background: "#347",
-           color: "white",
-       },
-       ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
-           content: '"···"',
-           opacity: 0.5,
-           display: "block",
-           textAlign: "center"
-       },
-       ".cm-tooltip.cm-completionInfo": {
-           position: "absolute",
-           padding: "3px 9px",
-           width: "max-content",
-           maxWidth: "300px",
-       },
-       ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
-       ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
-       "&light .cm-snippetField": { backgroundColor: "#00000022" },
-       "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
-       ".cm-snippetFieldPosition": {
-           verticalAlign: "text-top",
-           width: 0,
-           height: "1.15em",
-           margin: "0 -0.7px -.7em",
-           borderLeft: "1.4px dotted #888"
-       },
-       ".cm-completionMatchedText": {
-           textDecoration: "underline"
-       },
-       ".cm-completionDetail": {
-           marginLeft: "0.5em",
-           fontStyle: "italic"
-       },
-       ".cm-completionIcon": {
-           fontSize: "90%",
-           width: ".8em",
-           display: "inline-block",
-           textAlign: "center",
-           paddingRight: ".6em",
-           opacity: "0.6"
-       },
-       ".cm-completionIcon-function, .cm-completionIcon-method": {
-           "&:after": { content: "'ƒ'" }
-       },
-       ".cm-completionIcon-class": {
-           "&:after": { content: "'○'" }
-       },
-       ".cm-completionIcon-interface": {
-           "&:after": { content: "'◌'" }
-       },
-       ".cm-completionIcon-variable": {
-           "&:after": { content: "'𝑥'" }
-       },
-       ".cm-completionIcon-constant": {
-           "&:after": { content: "'𝐶'" }
-       },
-       ".cm-completionIcon-type": {
-           "&:after": { content: "'𝑡'" }
-       },
-       ".cm-completionIcon-enum": {
-           "&:after": { content: "'∪'" }
-       },
-       ".cm-completionIcon-property": {
-           "&:after": { content: "'□'" }
-       },
-       ".cm-completionIcon-keyword": {
-           "&:after": { content: "'🔑\uFE0E'" } // Disable emoji rendering
-       },
-       ".cm-completionIcon-namespace": {
-           "&:after": { content: "'▢'" }
-       },
-       ".cm-completionIcon-text": {
-           "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
-       }
-   });
-
-   const defaults$1 = {
-       brackets: ["(", "[", "{", "'", '"'],
-       before: ")]}:;>"
-   };
-   const closeBracketEffect = /*@__PURE__*/StateEffect$3.define({
-       map(value, mapping) {
-           let mapped = mapping.mapPos(value, -1, MapMode$3.TrackAfter);
-           return mapped == null ? undefined : mapped;
-       }
-   });
-   const skipBracketEffect = /*@__PURE__*/StateEffect$3.define({
-       map(value, mapping) { return mapping.mapPos(value); }
-   });
-   const closedBracket$1 = /*@__PURE__*/new class extends RangeValue$3 {
-   };
-   closedBracket$1.startSide = 1;
-   closedBracket$1.endSide = -1;
-   const bracketState = /*@__PURE__*/StateField$3.define({
-       create() { return RangeSet$3.empty; },
-       update(value, tr) {
-           if (tr.selection) {
-               let lineStart = tr.state.doc.lineAt(tr.selection.main.head).from;
-               let prevLineStart = tr.startState.doc.lineAt(tr.startState.selection.main.head).from;
-               if (lineStart != tr.changes.mapPos(prevLineStart, -1))
-                   value = RangeSet$3.empty;
-           }
-           value = value.map(tr.changes);
-           for (let effect of tr.effects) {
-               if (effect.is(closeBracketEffect))
-                   value = value.update({ add: [closedBracket$1.range(effect.value, effect.value + 1)] });
-               else if (effect.is(skipBracketEffect))
-                   value = value.update({ filter: from => from != effect.value });
-           }
-           return value;
-       }
-   });
-   /**
-   Extension to enable bracket-closing behavior. When a closeable
-   bracket is typed, its closing bracket is immediately inserted
-   after the cursor. When closing a bracket directly in front of a
-   closing bracket inserted by the extension, the cursor moves over
-   that bracket.
-   */
-   function closeBrackets() {
-       return [inputHandler$1, bracketState];
-   }
-   const definedClosing = "()[]{}<>";
-   function closing(ch) {
-       for (let i = 0; i < definedClosing.length; i += 2)
-           if (definedClosing.charCodeAt(i) == ch)
-               return definedClosing.charAt(i + 1);
-       return fromCodePoint$2(ch < 128 ? ch : ch + 1);
-   }
-   function config(state, pos) {
-       return state.languageDataAt("closeBrackets", pos)[0] || defaults$1;
-   }
-   const android$1 = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
-   const inputHandler$1 = /*@__PURE__*/EditorView$3.inputHandler.of((view, from, to, insert) => {
-       if ((android$1 ? view.composing : view.compositionStarted) || view.state.readOnly)
-           return false;
-       let sel = view.state.selection.main;
-       if (insert.length > 2 || insert.length == 2 && codePointSize$4(codePointAt$4(insert, 0)) == 1 ||
-           from != sel.from || to != sel.to)
-           return false;
-       let tr = insertBracket(view.state, insert);
-       if (!tr)
-           return false;
-       view.dispatch(tr);
-       return true;
-   });
-   /**
-   Command that implements deleting a pair of matching brackets when
-   the cursor is between them.
-   */
-   const deleteBracketPair = ({ state, dispatch }) => {
-       if (state.readOnly)
-           return false;
-       let conf = config(state, state.selection.main.head);
-       let tokens = conf.brackets || defaults$1.brackets;
-       let dont = null, changes = state.changeByRange(range => {
-           if (range.empty) {
-               let before = prevChar(state.doc, range.head);
-               for (let token of tokens) {
-                   if (token == before && nextChar(state.doc, range.head) == closing(codePointAt$4(token, 0)))
-                       return { changes: { from: range.head - token.length, to: range.head + token.length },
-                           range: EditorSelection$3.cursor(range.head - token.length),
-                           userEvent: "delete.backward" };
-               }
-           }
-           return { range: dont = range };
-       });
-       if (!dont)
-           dispatch(state.update(changes, { scrollIntoView: true }));
-       return !dont;
-   };
-   /**
-   Close-brackets related key bindings. Binds Backspace to
-   [`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
-   */
-   const closeBracketsKeymap = [
-       { key: "Backspace", run: deleteBracketPair }
-   ];
-   /**
-   Implements the extension's behavior on text insertion. If the
-   given string counts as a bracket in the language around the
-   selection, and replacing the selection with it requires custom
-   behavior (inserting a closing version or skipping past a
-   previously-closed bracket), this function returns a transaction
-   representing that custom behavior. (You only need this if you want
-   to programmatically insert brackets—the
-   [`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
-   take care of running this for user input.)
-   */
-   function insertBracket(state, bracket) {
-       let conf = config(state, state.selection.main.head);
-       let tokens = conf.brackets || defaults$1.brackets;
-       for (let tok of tokens) {
-           let closed = closing(codePointAt$4(tok, 0));
-           if (bracket == tok)
-               return closed == tok ? handleSame(state, tok, tokens.indexOf(tok + tok + tok) > -1)
-                   : handleOpen(state, tok, closed, conf.before || defaults$1.before);
-           if (bracket == closed && closedBracketAt(state, state.selection.main.from))
-               return handleClose(state, tok, closed);
-       }
-       return null;
-   }
-   function closedBracketAt(state, pos) {
-       let found = false;
-       state.field(bracketState).between(0, state.doc.length, from => {
-           if (from == pos)
-               found = true;
-       });
-       return found;
-   }
-   function nextChar(doc, pos) {
-       let next = doc.sliceString(pos, pos + 2);
-       return next.slice(0, codePointSize$4(codePointAt$4(next, 0)));
-   }
-   function prevChar(doc, pos) {
-       let prev = doc.sliceString(pos - 2, pos);
-       return codePointSize$4(codePointAt$4(prev, 0)) == prev.length ? prev : prev.slice(1);
-   }
-   function handleOpen(state, open, close, closeBefore) {
-       let dont = null, changes = state.changeByRange(range => {
-           if (!range.empty)
-               return { changes: [{ insert: open, from: range.from }, { insert: close, from: range.to }],
-                   effects: closeBracketEffect.of(range.to + open.length),
-                   range: EditorSelection$3.range(range.anchor + open.length, range.head + open.length) };
-           let next = nextChar(state.doc, range.head);
-           if (!next || /\s/.test(next) || closeBefore.indexOf(next) > -1)
-               return { changes: { insert: open + close, from: range.head },
-                   effects: closeBracketEffect.of(range.head + open.length),
-                   range: EditorSelection$3.cursor(range.head + open.length) };
-           return { range: dont = range };
-       });
-       return dont ? null : state.update(changes, {
-           scrollIntoView: true,
-           userEvent: "input.type"
-       });
-   }
-   function handleClose(state, _open, close) {
-       let dont = null, moved = state.selection.ranges.map(range => {
-           if (range.empty && nextChar(state.doc, range.head) == close)
-               return EditorSelection$3.cursor(range.head + close.length);
-           return dont = range;
-       });
-       return dont ? null : state.update({
-           selection: EditorSelection$3.create(moved, state.selection.mainIndex),
-           scrollIntoView: true,
-           effects: state.selection.ranges.map(({ from }) => skipBracketEffect.of(from))
-       });
-   }
-   // Handles cases where the open and close token are the same, and
-   // possibly triple quotes (as in `"""abc"""`-style quoting).
-   function handleSame(state, token, allowTriple) {
-       let dont = null, changes = state.changeByRange(range => {
-           if (!range.empty)
-               return { changes: [{ insert: token, from: range.from }, { insert: token, from: range.to }],
-                   effects: closeBracketEffect.of(range.to + token.length),
-                   range: EditorSelection$3.range(range.anchor + token.length, range.head + token.length) };
-           let pos = range.head, next = nextChar(state.doc, pos);
-           if (next == token) {
-               if (nodeStart(state, pos)) {
-                   return { changes: { insert: token + token, from: pos },
-                       effects: closeBracketEffect.of(pos + token.length),
-                       range: EditorSelection$3.cursor(pos + token.length) };
-               }
-               else if (closedBracketAt(state, pos)) {
-                   let isTriple = allowTriple && state.sliceDoc(pos, pos + token.length * 3) == token + token + token;
-                   return { range: EditorSelection$3.cursor(pos + token.length * (isTriple ? 3 : 1)),
-                       effects: skipBracketEffect.of(pos) };
-               }
-           }
-           else if (allowTriple && state.sliceDoc(pos - 2 * token.length, pos) == token + token &&
-               nodeStart(state, pos - 2 * token.length)) {
-               return { changes: { insert: token + token + token + token, from: pos },
-                   effects: closeBracketEffect.of(pos + token.length),
-                   range: EditorSelection$3.cursor(pos + token.length) };
-           }
-           else if (state.charCategorizer(pos)(next) != CharCategory$3.Word) {
-               let prev = state.sliceDoc(pos - 1, pos);
-               if (prev != token && state.charCategorizer(pos)(prev) != CharCategory$3.Word && !probablyInString(state, pos, token))
-                   return { changes: { insert: token + token, from: pos },
-                       effects: closeBracketEffect.of(pos + token.length),
-                       range: EditorSelection$3.cursor(pos + token.length) };
-           }
-           return { range: dont = range };
-       });
-       return dont ? null : state.update(changes, {
-           scrollIntoView: true,
-           userEvent: "input.type"
-       });
-   }
-   function nodeStart(state, pos) {
-       let tree = syntaxTree$2(state).resolveInner(pos + 1);
-       return tree.parent && tree.from == pos;
-   }
-   function probablyInString(state, pos, quoteToken) {
-       let node = syntaxTree$2(state).resolveInner(pos, -1);
-       for (let i = 0; i < 5; i++) {
-           if (state.sliceDoc(node.from, node.from + quoteToken.length) == quoteToken)
-               return true;
-           let parent = node.to == pos && node.parent;
-           if (!parent)
-               break;
-           node = parent;
-       }
-       return false;
-   }
-
-   /**
-   Returns an extension that enables autocompletion.
-   */
-   function autocompletion$1(config = {}) {
-       return [
-           completionState$1,
-           completionConfig$1.of(config),
-           completionPlugin$1,
-           completionKeymapExt$1,
-           baseTheme$4
-       ];
-   }
-   /**
-   Basic keybindings for autocompletion.
-
-    - Ctrl-Space: [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
-    - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
-    - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
-    - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
-    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
-    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
-    - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
-   */
-   const completionKeymap$1 = [
-       { key: "Ctrl-Space", run: startCompletion$1 },
-       { key: "Escape", run: closeCompletion$1 },
-       { key: "ArrowDown", run: /*@__PURE__*/moveCompletionSelection$1(true) },
-       { key: "ArrowUp", run: /*@__PURE__*/moveCompletionSelection$1(false) },
-       { key: "PageDown", run: /*@__PURE__*/moveCompletionSelection$1(true, "page") },
-       { key: "PageUp", run: /*@__PURE__*/moveCompletionSelection$1(false, "page") },
-       { key: "Enter", run: acceptCompletion$1 }
-   ];
-   const completionKeymapExt$1 = /*@__PURE__*/Prec$3.highest(/*@__PURE__*/keymap$2.computeN([completionConfig$1], state => state.facet(completionConfig$1).defaultKeymap ? [completionKeymap$1] : []));
-
-   let SelectedDiagnostic$1 = class SelectedDiagnostic {
-       constructor(from, to, diagnostic) {
-           this.from = from;
-           this.to = to;
-           this.diagnostic = diagnostic;
-       }
-   };
-   let LintState$1 = class LintState {
-       constructor(diagnostics, panel, selected) {
-           this.diagnostics = diagnostics;
-           this.panel = panel;
-           this.selected = selected;
-       }
-       static init(diagnostics, panel, state) {
-           // Filter the list of diagnostics for which to create markers
-           let markedDiagnostics = diagnostics;
-           let diagnosticFilter = state.facet(lintConfig$1).markerFilter;
-           if (diagnosticFilter)
-               markedDiagnostics = diagnosticFilter(markedDiagnostics);
-           let ranges = Decoration$3.set(markedDiagnostics.map((d) => {
-               // For zero-length ranges or ranges covering only a line break, create a widget
-               return d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from)
-                   ? Decoration$3.widget({
-                       widget: new DiagnosticWidget$1(d),
-                       diagnostic: d
-                   }).range(d.from)
-                   : Decoration$3.mark({
-                       attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
-                       diagnostic: d
-                   }).range(d.from, d.to);
-           }), true);
-           return new LintState(ranges, panel, findDiagnostic$1(ranges));
-       }
-   };
-   function findDiagnostic$1(diagnostics, diagnostic = null, after = 0) {
-       let found = null;
-       diagnostics.between(after, 1e9, (from, to, { spec }) => {
-           if (diagnostic && spec.diagnostic != diagnostic)
-               return;
-           found = new SelectedDiagnostic$1(from, to, spec.diagnostic);
-           return false;
-       });
-       return found;
-   }
-   function hideTooltip$1(tr, tooltip) {
-       return !!(tr.effects.some(e => e.is(setDiagnosticsEffect$1)) || tr.changes.touchesRange(tooltip.pos));
-   }
-   function maybeEnableLint(state, effects) {
-       return state.field(lintState$1, false) ? effects : effects.concat(StateEffect$3.appendConfig.of([
-           lintState$1,
-           EditorView$3.decorations.compute([lintState$1], state => {
-               let { selected, panel } = state.field(lintState$1);
-               return !selected || !panel || selected.from == selected.to ? Decoration$3.none : Decoration$3.set([
-                   activeMark.range(selected.from, selected.to)
-               ]);
-           }),
-           hoverTooltip(lintTooltip, { hideOn: hideTooltip$1 }),
-           baseTheme$3
-       ]));
-   }
-   /**
-   Returns a transaction spec which updates the current set of
-   diagnostics, and enables the lint extension if if wasn't already
-   active.
-   */
-   function setDiagnostics(state, diagnostics) {
-       return {
-           effects: maybeEnableLint(state, [setDiagnosticsEffect$1.of(diagnostics)])
-       };
-   }
-   /**
-   The state effect that updates the set of active diagnostics. Can
-   be useful when writing an extension that needs to track these.
-   */
-   const setDiagnosticsEffect$1 = /*@__PURE__*/StateEffect$3.define();
-   const togglePanel$1 = /*@__PURE__*/StateEffect$3.define();
-   const movePanelSelection$1 = /*@__PURE__*/StateEffect$3.define();
-   const lintState$1 = /*@__PURE__*/StateField$3.define({
-       create() {
-           return new LintState$1(Decoration$3.none, null, null);
-       },
-       update(value, tr) {
-           if (tr.docChanged) {
-               let mapped = value.diagnostics.map(tr.changes), selected = null;
-               if (value.selected) {
-                   let selPos = tr.changes.mapPos(value.selected.from, 1);
-                   selected = findDiagnostic$1(mapped, value.selected.diagnostic, selPos) || findDiagnostic$1(mapped, null, selPos);
-               }
-               value = new LintState$1(mapped, value.panel, selected);
-           }
-           for (let effect of tr.effects) {
-               if (effect.is(setDiagnosticsEffect$1)) {
-                   value = LintState$1.init(effect.value, value.panel, tr.state);
-               }
-               else if (effect.is(togglePanel$1)) {
-                   value = new LintState$1(value.diagnostics, effect.value ? LintPanel$1.open : null, value.selected);
-               }
-               else if (effect.is(movePanelSelection$1)) {
-                   value = new LintState$1(value.diagnostics, value.panel, effect.value);
-               }
-           }
-           return value;
-       },
-       provide: f => [showPanel$2.from(f, val => val.panel),
-           EditorView$3.decorations.from(f, s => s.diagnostics)]
-   });
-   const activeMark = /*@__PURE__*/Decoration$3.mark({ class: "cm-lintRange cm-lintRange-active" });
-   function lintTooltip(view, pos, side) {
-       let { diagnostics } = view.state.field(lintState$1);
-       let found = [], stackStart = 2e8, stackEnd = 0;
-       diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
-           if (pos >= from && pos <= to &&
-               (from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
-               found.push(spec.diagnostic);
-               stackStart = Math.min(from, stackStart);
-               stackEnd = Math.max(to, stackEnd);
-           }
-       });
-       let diagnosticFilter = view.state.facet(lintConfig$1).tooltipFilter;
-       if (diagnosticFilter)
-           found = diagnosticFilter(found);
-       if (!found.length)
-           return null;
-       return {
-           pos: stackStart,
-           end: stackEnd,
-           above: view.state.doc.lineAt(stackStart).to < stackEnd,
-           create() {
-               return { dom: diagnosticsTooltip$1(view, found) };
-           }
-       };
-   }
-   function diagnosticsTooltip$1(view, diagnostics) {
-       return crelt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic$1(view, d, false)));
-   }
-   /**
-   Command to open and focus the lint panel.
-   */
-   const openLintPanel = (view) => {
-       let field = view.state.field(lintState$1, false);
-       if (!field || !field.panel)
-           view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel$1.of(true)]) });
-       let panel = getPanel$1(view, LintPanel$1.open);
-       if (panel)
-           panel.dom.querySelector(".cm-panel-lint ul").focus();
-       return true;
-   };
-   /**
-   Command to close the lint panel, when open.
-   */
-   const closeLintPanel$1 = (view) => {
-       let field = view.state.field(lintState$1, false);
-       if (!field || !field.panel)
-           return false;
-       view.dispatch({ effects: togglePanel$1.of(false) });
-       return true;
-   };
-   /**
-   Move the selection to the next diagnostic.
-   */
-   const nextDiagnostic = (view) => {
-       let field = view.state.field(lintState$1, false);
-       if (!field)
-           return false;
-       let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1);
-       if (!next.value) {
-           next = field.diagnostics.iter(0);
-           if (!next.value || next.from == sel.from && next.to == sel.to)
-               return false;
-       }
-       view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true });
-       return true;
-   };
-   /**
-   A set of default key bindings for the lint functionality.
-
-   - Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
-   - F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
-   */
-   const lintKeymap = [
-       { key: "Mod-Shift-m", run: openLintPanel },
-       { key: "F8", run: nextDiagnostic }
-   ];
-   const lintPlugin = /*@__PURE__*/ViewPlugin$3.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.timeout = -1;
-           this.set = true;
-           let { delay } = view.state.facet(lintConfig$1);
-           this.lintTime = Date.now() + delay;
-           this.run = this.run.bind(this);
-           this.timeout = setTimeout(this.run, delay);
-       }
-       run() {
-           let now = Date.now();
-           if (now < this.lintTime - 10) {
-               setTimeout(this.run, this.lintTime - now);
-           }
-           else {
-               this.set = false;
-               let { state } = this.view, { sources } = state.facet(lintConfig$1);
-               Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
-                   let all = annotations.reduce((a, b) => a.concat(b));
-                   if (this.view.state.doc == state.doc)
-                       this.view.dispatch(setDiagnostics(this.view.state, all));
-               }, error => { logException$3(this.view.state, error); });
-           }
-       }
-       update(update) {
-           let config = update.state.facet(lintConfig$1);
-           if (update.docChanged || config != update.startState.facet(lintConfig$1)) {
-               this.lintTime = Date.now() + config.delay;
-               if (!this.set) {
-                   this.set = true;
-                   this.timeout = setTimeout(this.run, config.delay);
-               }
-           }
-       }
-       force() {
-           if (this.set) {
-               this.lintTime = Date.now();
-               this.run();
-           }
-       }
-       destroy() {
-           clearTimeout(this.timeout);
-       }
-   });
-   const lintConfig$1 = /*@__PURE__*/Facet$3.define({
-       combine(input) {
-           return Object.assign({ sources: input.map(i => i.source) }, combineConfig$3(input.map(i => i.config), {
-               delay: 750,
-               markerFilter: null,
-               tooltipFilter: null
-           }));
-       },
-       enables: lintPlugin
-   });
-   function assignKeys$1(actions) {
-       let assigned = [];
-       if (actions)
-           actions: for (let { name } of actions) {
-               for (let i = 0; i < name.length; i++) {
-                   let ch = name[i];
-                   if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
-                       assigned.push(ch);
-                       continue actions;
-                   }
-               }
-               assigned.push("");
-           }
-       return assigned;
-   }
-   function renderDiagnostic$1(view, diagnostic, inPanel) {
-       var _a;
-       let keys = inPanel ? assignKeys$1(diagnostic.actions) : [];
-       return crelt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, crelt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
-           let click = (e) => {
-               e.preventDefault();
-               let found = findDiagnostic$1(view.state.field(lintState$1).diagnostics, diagnostic);
-               if (found)
-                   action.apply(view, found.from, found.to);
-           };
-           let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
-           let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
-               crelt("u", name.slice(keyIndex, keyIndex + 1)),
-               name.slice(keyIndex + 1)];
-           return crelt("button", {
-               type: "button",
-               class: "cm-diagnosticAction",
-               onclick: click,
-               onmousedown: click,
-               "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
-           }, nameElt);
-       }), diagnostic.source && crelt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
-   }
-   let DiagnosticWidget$1 = class DiagnosticWidget extends WidgetType$3 {
-       constructor(diagnostic) {
-           super();
-           this.diagnostic = diagnostic;
-       }
-       eq(other) { return other.diagnostic == this.diagnostic; }
-       toDOM() {
-           return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
-       }
-   };
-   let PanelItem$1 = class PanelItem {
-       constructor(view, diagnostic) {
-           this.diagnostic = diagnostic;
-           this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
-           this.dom = renderDiagnostic$1(view, diagnostic, true);
-           this.dom.id = this.id;
-           this.dom.setAttribute("role", "option");
-       }
-   };
-   let LintPanel$1 = class LintPanel {
-       constructor(view) {
-           this.view = view;
-           this.items = [];
-           let onkeydown = (event) => {
-               if (event.keyCode == 27) { // Escape
-                   closeLintPanel$1(this.view);
-                   this.view.focus();
-               }
-               else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
-                   this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
-               }
-               else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
-                   this.moveSelection((this.selectedIndex + 1) % this.items.length);
-               }
-               else if (event.keyCode == 36) { // Home
-                   this.moveSelection(0);
-               }
-               else if (event.keyCode == 35) { // End
-                   this.moveSelection(this.items.length - 1);
-               }
-               else if (event.keyCode == 13) { // Enter
-                   this.view.focus();
-               }
-               else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
-                   let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys$1(diagnostic.actions);
-                   for (let i = 0; i < keys.length; i++)
-                       if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
-                           let found = findDiagnostic$1(this.view.state.field(lintState$1).diagnostics, diagnostic);
-                           if (found)
-                               diagnostic.actions[i].apply(view, found.from, found.to);
-                       }
-               }
-               else {
-                   return;
-               }
-               event.preventDefault();
-           };
-           let onclick = (event) => {
-               for (let i = 0; i < this.items.length; i++) {
-                   if (this.items[i].dom.contains(event.target))
-                       this.moveSelection(i);
-               }
-           };
-           this.list = crelt("ul", {
-               tabIndex: 0,
-               role: "listbox",
-               "aria-label": this.view.state.phrase("Diagnostics"),
-               onkeydown,
-               onclick
-           });
-           this.dom = crelt("div", { class: "cm-panel-lint" }, this.list, crelt("button", {
-               type: "button",
-               name: "close",
-               "aria-label": this.view.state.phrase("close"),
-               onclick: () => closeLintPanel$1(this.view)
-           }, "×"));
-           this.update();
-       }
-       get selectedIndex() {
-           let selected = this.view.state.field(lintState$1).selected;
-           if (!selected)
-               return -1;
-           for (let i = 0; i < this.items.length; i++)
-               if (this.items[i].diagnostic == selected.diagnostic)
-                   return i;
-           return -1;
-       }
-       update() {
-           let { diagnostics, selected } = this.view.state.field(lintState$1);
-           let i = 0, needsSync = false, newSelectedItem = null;
-           diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
-               let found = -1, item;
-               for (let j = i; j < this.items.length; j++)
-                   if (this.items[j].diagnostic == spec.diagnostic) {
-                       found = j;
-                       break;
-                   }
-               if (found < 0) {
-                   item = new PanelItem$1(this.view, spec.diagnostic);
-                   this.items.splice(i, 0, item);
-                   needsSync = true;
-               }
-               else {
-                   item = this.items[found];
-                   if (found > i) {
-                       this.items.splice(i, found - i);
-                       needsSync = true;
-                   }
-               }
-               if (selected && item.diagnostic == selected.diagnostic) {
-                   if (!item.dom.hasAttribute("aria-selected")) {
-                       item.dom.setAttribute("aria-selected", "true");
-                       newSelectedItem = item;
-                   }
-               }
-               else if (item.dom.hasAttribute("aria-selected")) {
-                   item.dom.removeAttribute("aria-selected");
-               }
-               i++;
-           });
-           while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
-               needsSync = true;
-               this.items.pop();
-           }
-           if (this.items.length == 0) {
-               this.items.push(new PanelItem$1(this.view, {
-                   from: -1, to: -1,
-                   severity: "info",
-                   message: this.view.state.phrase("No diagnostics")
-               }));
-               needsSync = true;
-           }
-           if (newSelectedItem) {
-               this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
-               this.view.requestMeasure({
-                   key: this,
-                   read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
-                   write: ({ sel, panel }) => {
-                       if (sel.top < panel.top)
-                           this.list.scrollTop -= panel.top - sel.top;
-                       else if (sel.bottom > panel.bottom)
-                           this.list.scrollTop += sel.bottom - panel.bottom;
-                   }
-               });
-           }
-           else if (this.selectedIndex < 0) {
-               this.list.removeAttribute("aria-activedescendant");
-           }
-           if (needsSync)
-               this.sync();
-       }
-       sync() {
-           let domPos = this.list.firstChild;
-           function rm() {
-               let prev = domPos;
-               domPos = prev.nextSibling;
-               prev.remove();
-           }
-           for (let item of this.items) {
-               if (item.dom.parentNode == this.list) {
-                   while (domPos != item.dom)
-                       rm();
-                   domPos = item.dom.nextSibling;
-               }
-               else {
-                   this.list.insertBefore(item.dom, domPos);
-               }
-           }
-           while (domPos)
-               rm();
-       }
-       moveSelection(selectedIndex) {
-           if (this.selectedIndex < 0)
-               return;
-           let field = this.view.state.field(lintState$1);
-           let selection = findDiagnostic$1(field.diagnostics, this.items[selectedIndex].diagnostic);
-           if (!selection)
-               return;
-           this.view.dispatch({
-               selection: { anchor: selection.from, head: selection.to },
-               scrollIntoView: true,
-               effects: movePanelSelection$1.of(selection)
-           });
-       }
-       static open(view) { return new LintPanel(view); }
-   };
-   function svg$1(content, attrs = `viewBox="0 0 40 40"`) {
-       return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
-   }
-   function underline(color) {
-       return svg$1(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
-   }
-   const baseTheme$3 = /*@__PURE__*/EditorView$3.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-diagnosticAction": {
-           font: "inherit",
-           border: "none",
-           padding: "2px 4px",
-           backgroundColor: "#444",
-           color: "white",
-           borderRadius: "3px",
-           marginLeft: "8px"
-       },
-       ".cm-diagnosticSource": {
-           fontSize: "70%",
-           opacity: .7
-       },
-       ".cm-lintRange": {
-           backgroundPosition: "left bottom",
-           backgroundRepeat: "repeat-x",
-           paddingBottom: "0.7px",
-       },
-       ".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") },
-       ".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") },
-       ".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") },
-       ".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-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
-           }
-       }
-   });
-
-   /**
-   This is an extension value that just pulls together a number of
-   extensions that you might want in a basic editor. It is meant as a
-   convenient helper to quickly set up CodeMirror without installing
-   and importing a lot of separate packages.
-
-   Specifically, it includes...
-
-    - [the default command bindings](https://codemirror.net/6/docs/ref/#commands.defaultKeymap)
-    - [line numbers](https://codemirror.net/6/docs/ref/#view.lineNumbers)
-    - [special character highlighting](https://codemirror.net/6/docs/ref/#view.highlightSpecialChars)
-    - [the undo history](https://codemirror.net/6/docs/ref/#commands.history)
-    - [a fold gutter](https://codemirror.net/6/docs/ref/#language.foldGutter)
-    - [custom selection drawing](https://codemirror.net/6/docs/ref/#view.drawSelection)
-    - [drop cursor](https://codemirror.net/6/docs/ref/#view.dropCursor)
-    - [multiple selections](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
-    - [reindentation on input](https://codemirror.net/6/docs/ref/#language.indentOnInput)
-    - [the default highlight style](https://codemirror.net/6/docs/ref/#language.defaultHighlightStyle) (as fallback)
-    - [bracket matching](https://codemirror.net/6/docs/ref/#language.bracketMatching)
-    - [bracket closing](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets)
-    - [autocompletion](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion)
-    - [rectangular selection](https://codemirror.net/6/docs/ref/#view.rectangularSelection) and [crosshair cursor](https://codemirror.net/6/docs/ref/#view.crosshairCursor)
-    - [active line highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLine)
-    - [active line gutter highlighting](https://codemirror.net/6/docs/ref/#view.highlightActiveLineGutter)
-    - [selection match highlighting](https://codemirror.net/6/docs/ref/#search.highlightSelectionMatches)
-    - [search](https://codemirror.net/6/docs/ref/#search.searchKeymap)
-    - [linting](https://codemirror.net/6/docs/ref/#lint.lintKeymap)
-
-   (You'll probably want to add some language package to your setup
-   too.)
-
-   This package does not allow customization. The idea is that, once
-   you decide you want to configure your editor more precisely, you
-   take this package's source (which is just a bunch of imports and
-   an array literal), copy it into your own code, and adjust it as
-   desired.
-   */
-   const basicSetup = [
-       /*@__PURE__*/lineNumbers$1(),
-       /*@__PURE__*/highlightActiveLineGutter(),
-       /*@__PURE__*/highlightSpecialChars(),
-       /*@__PURE__*/history(),
-       /*@__PURE__*/foldGutter(),
-       /*@__PURE__*/drawSelection(),
-       /*@__PURE__*/dropCursor(),
-       /*@__PURE__*/EditorState$3.allowMultipleSelections.of(true),
-       /*@__PURE__*/indentOnInput(),
-       /*@__PURE__*/syntaxHighlighting$1(defaultHighlightStyle, { fallback: true }),
-       /*@__PURE__*/bracketMatching(),
-       /*@__PURE__*/closeBrackets(),
-       /*@__PURE__*/autocompletion$1(),
-       /*@__PURE__*/rectangularSelection(),
-       /*@__PURE__*/crosshairCursor(),
-       /*@__PURE__*/highlightActiveLine(),
-       /*@__PURE__*/highlightSelectionMatches(),
-       /*@__PURE__*/keymap$2.of([
-           ...closeBracketsKeymap,
-           ...defaultKeymap,
-           ...searchKeymap,
-           ...historyKeymap,
-           ...foldKeymap,
-           ...completionKeymap$1,
-           ...lintKeymap
-       ])
-   ];
-
-   /**
-   The default maximum length of a `TreeBuffer` node.
-   */
-   const DefaultBufferLength = 1024;
-   let nextPropID = 0;
-   let Range$1 = class Range {
-       constructor(from, to) {
-           this.from = from;
-           this.to = to;
-       }
-   };
-   /**
-   Each [node type](#common.NodeType) or [individual tree](#common.Tree)
-   can have metadata associated with it in props. Instances of this
-   class represent prop names.
-   */
-   class NodeProp {
-       /**
-       Create a new node prop type.
-       */
-       constructor(config = {}) {
-           this.id = nextPropID++;
-           this.perNode = !!config.perNode;
-           this.deserialize = config.deserialize || (() => {
-               throw new Error("This node type doesn't define a deserialize function");
-           });
-       }
-       /**
-       This is meant to be used with
-       [`NodeSet.extend`](#common.NodeSet.extend) or
-       [`LRParser.configure`](#lr.ParserConfig.props) to compute
-       prop values for each node type in the set. Takes a [match
-       object](#common.NodeType^match) or function that returns undefined
-       if the node type doesn't get this prop, and the prop's value if
-       it does.
-       */
-       add(match) {
-           if (this.perNode)
-               throw new RangeError("Can't add per-node props to node types");
-           if (typeof match != "function")
-               match = NodeType.match(match);
-           return (type) => {
-               let result = match(type);
-               return result === undefined ? null : [this, result];
-           };
-       }
-   }
-   /**
-   Prop that is used to describe matching delimiters. For opening
-   delimiters, this holds an array of node names (written as a
-   space-separated string when declaring this prop in a grammar)
-   for the node types of closing delimiters that match it.
-   */
-   NodeProp.closedBy = new NodeProp({ deserialize: str => str.split(" ") });
-   /**
-   The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
-   attached to closing delimiters, holding an array of node names
-   of types of matching opening delimiters.
-   */
-   NodeProp.openedBy = new NodeProp({ deserialize: str => str.split(" ") });
-   /**
-   Used to assign node types to groups (for example, all node
-   types that represent an expression could be tagged with an
-   `"Expression"` group).
-   */
-   NodeProp.group = new NodeProp({ deserialize: str => str.split(" ") });
-   /**
-   Attached to nodes to indicate these should be
-   [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
-   in a bidirectional text isolate, so that direction-neutral
-   characters on their sides don't incorrectly get associated with
-   surrounding text. You'll generally want to set this for nodes
-   that contain arbitrary text, like strings and comments, and for
-   nodes that appear _inside_ arbitrary text, like HTML tags. When
-   not given a value, in a grammar declaration, defaults to
-   `"auto"`.
-   */
-   NodeProp.isolate = new NodeProp({ deserialize: value => {
-           if (value && value != "rtl" && value != "ltr" && value != "auto")
-               throw new RangeError("Invalid value for isolate: " + value);
-           return value || "auto";
-       } });
-   /**
-   The hash of the [context](#lr.ContextTracker.constructor)
-   that the node was parsed in, if any. Used to limit reuse of
-   contextual nodes.
-   */
-   NodeProp.contextHash = new NodeProp({ perNode: true });
-   /**
-   The distance beyond the end of the node that the tokenizer
-   looked ahead for any of the tokens inside the node. (The LR
-   parser only stores this when it is larger than 25, for
-   efficiency reasons.)
-   */
-   NodeProp.lookAhead = new NodeProp({ perNode: true });
-   /**
-   This per-node prop is used to replace a given node, or part of a
-   node, with another tree. This is useful to include trees from
-   different languages in mixed-language parsers.
-   */
-   NodeProp.mounted = new NodeProp({ perNode: true });
-   /**
-   A mounted tree, which can be [stored](#common.NodeProp^mounted) on
-   a tree node to indicate that parts of its content are
-   represented by another tree.
-   */
-   class MountedTree {
-       constructor(
-       /**
-       The inner tree.
-       */
-       tree, 
-       /**
-       If this is null, this tree replaces the entire node (it will
-       be included in the regular iteration instead of its host
-       node). If not, only the given ranges are considered to be
-       covered by this tree. This is used for trees that are mixed in
-       a way that isn't strictly hierarchical. Such mounted trees are
-       only entered by [`resolveInner`](#common.Tree.resolveInner)
-       and [`enter`](#common.SyntaxNode.enter).
-       */
-       overlay, 
-       /**
-       The parser used to create this subtree.
-       */
-       parser) {
-           this.tree = tree;
-           this.overlay = overlay;
-           this.parser = parser;
-       }
-       /**
-       @internal
-       */
-       static get(tree) {
-           return tree && tree.props && tree.props[NodeProp.mounted.id];
-       }
-   }
-   const noProps = Object.create(null);
-   /**
-   Each node in a syntax tree has a node type associated with it.
-   */
-   class NodeType {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The name of the node type. Not necessarily unique, but if the
-       grammar was written properly, different node types with the
-       same name within a node set should play the same semantic
-       role.
-       */
-       name, 
-       /**
-       @internal
-       */
-       props, 
-       /**
-       The id of this node in its set. Corresponds to the term ids
-       used in the parser.
-       */
-       id, 
-       /**
-       @internal
-       */
-       flags = 0) {
-           this.name = name;
-           this.props = props;
-           this.id = id;
-           this.flags = flags;
-       }
-       /**
-       Define a node type.
-       */
-       static define(spec) {
-           let props = spec.props && spec.props.length ? Object.create(null) : noProps;
-           let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |
-               (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);
-           let type = new NodeType(spec.name || "", props, spec.id, flags);
-           if (spec.props)
-               for (let src of spec.props) {
-                   if (!Array.isArray(src))
-                       src = src(type);
-                   if (src) {
-                       if (src[0].perNode)
-                           throw new RangeError("Can't store a per-node prop on a node type");
-                       props[src[0].id] = src[1];
-                   }
-               }
-           return type;
-       }
-       /**
-       Retrieves a node prop for this type. Will return `undefined` if
-       the prop isn't present on this node.
-       */
-       prop(prop) { return this.props[prop.id]; }
-       /**
-       True when this is the top node of a grammar.
-       */
-       get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }
-       /**
-       True when this node is produced by a skip rule.
-       */
-       get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }
-       /**
-       Indicates whether this is an error node.
-       */
-       get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }
-       /**
-       When true, this node type doesn't correspond to a user-declared
-       named node, for example because it is used to cache repetition.
-       */
-       get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }
-       /**
-       Returns true when this node's name or one of its
-       [groups](#common.NodeProp^group) matches the given string.
-       */
-       is(name) {
-           if (typeof name == 'string') {
-               if (this.name == name)
-                   return true;
-               let group = this.prop(NodeProp.group);
-               return group ? group.indexOf(name) > -1 : false;
-           }
-           return this.id == name;
-       }
-       /**
-       Create a function from node types to arbitrary values by
-       specifying an object whose property names are node or
-       [group](#common.NodeProp^group) names. Often useful with
-       [`NodeProp.add`](#common.NodeProp.add). You can put multiple
-       names, separated by spaces, in a single property name to map
-       multiple node names to a single value.
-       */
-       static match(map) {
-           let direct = Object.create(null);
-           for (let prop in map)
-               for (let name of prop.split(" "))
-                   direct[name] = map[prop];
-           return (node) => {
-               for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
-                   let found = direct[i < 0 ? node.name : groups[i]];
-                   if (found)
-                       return found;
-               }
-           };
-       }
-   }
-   /**
-   An empty dummy node type to use when no actual type is available.
-   */
-   NodeType.none = new NodeType("", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);
-   /**
-   A node set holds a collection of node types. It is used to
-   compactly represent trees by storing their type ids, rather than a
-   full pointer to the type object, in a numeric array. Each parser
-   [has](#lr.LRParser.nodeSet) a node set, and [tree
-   buffers](#common.TreeBuffer) can only store collections of nodes
-   from the same set. A set can have a maximum of 2**16 (65536) node
-   types in it, so that the ids fit into 16-bit typed array slots.
-   */
-   class NodeSet {
-       /**
-       Create a set with the given types. The `id` property of each
-       type should correspond to its position within the array.
-       */
-       constructor(
-       /**
-       The node types in this set, by id.
-       */
-       types) {
-           this.types = types;
-           for (let i = 0; i < types.length; i++)
-               if (types[i].id != i)
-                   throw new RangeError("Node type ids should correspond to array positions when creating a node set");
-       }
-       /**
-       Create a copy of this set with some node properties added. The
-       arguments to this method can be created with
-       [`NodeProp.add`](#common.NodeProp.add).
-       */
-       extend(...props) {
-           let newTypes = [];
-           for (let type of this.types) {
-               let newProps = null;
-               for (let source of props) {
-                   let add = source(type);
-                   if (add) {
-                       if (!newProps)
-                           newProps = Object.assign({}, type.props);
-                       newProps[add[0].id] = add[1];
-                   }
-               }
-               newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
-           }
-           return new NodeSet(newTypes);
-       }
-   }
-   const CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();
-   /**
-   Options that control iteration. Can be combined with the `|`
-   operator to enable multiple ones.
-   */
-   var IterMode;
-   (function (IterMode) {
-       /**
-       When enabled, iteration will only visit [`Tree`](#common.Tree)
-       objects, not nodes packed into
-       [`TreeBuffer`](#common.TreeBuffer)s.
-       */
-       IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
-       /**
-       Enable this to make iteration include anonymous nodes (such as
-       the nodes that wrap repeated grammar constructs into a balanced
-       tree).
-       */
-       IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
-       /**
-       By default, regular [mounted](#common.NodeProp^mounted) nodes
-       replace their base node in iteration. Enable this to ignore them
-       instead.
-       */
-       IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
-       /**
-       This option only applies in
-       [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
-       library to not enter mounted overlays if one covers the given
-       position.
-       */
-       IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
-   })(IterMode || (IterMode = {}));
-   /**
-   A piece of syntax tree. There are two ways to approach these
-   trees: the way they are actually stored in memory, and the
-   convenient way.
-
-   Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
-   objects. By packing detail information into `TreeBuffer` leaf
-   nodes, the representation is made a lot more memory-efficient.
-
-   However, when you want to actually work with tree nodes, this
-   representation is very awkward, so most client code will want to
-   use the [`TreeCursor`](#common.TreeCursor) or
-   [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
-   a view on some part of this data structure, and can be used to
-   move around to adjacent nodes.
-   */
-   class Tree {
-       /**
-       Construct a new tree. See also [`Tree.build`](#common.Tree^build).
-       */
-       constructor(
-       /**
-       The type of the top node.
-       */
-       type, 
-       /**
-       This node's child nodes.
-       */
-       children, 
-       /**
-       The positions (offsets relative to the start of this tree) of
-       the children.
-       */
-       positions, 
-       /**
-       The total length of this tree
-       */
-       length, 
-       /**
-       Per-node [node props](#common.NodeProp) to associate with this node.
-       */
-       props) {
-           this.type = type;
-           this.children = children;
-           this.positions = positions;
-           this.length = length;
-           /**
-           @internal
-           */
-           this.props = null;
-           if (props && props.length) {
-               this.props = Object.create(null);
-               for (let [prop, value] of props)
-                   this.props[typeof prop == "number" ? prop : prop.id] = value;
-           }
-       }
-       /**
-       @internal
-       */
-       toString() {
-           let mounted = MountedTree.get(this);
-           if (mounted && !mounted.overlay)
-               return mounted.tree.toString();
-           let children = "";
-           for (let ch of this.children) {
-               let str = ch.toString();
-               if (str) {
-                   if (children)
-                       children += ",";
-                   children += str;
-               }
-           }
-           return !this.type.name ? children :
-               (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +
-                   (children.length ? "(" + children + ")" : "");
-       }
-       /**
-       Get a [tree cursor](#common.TreeCursor) positioned at the top of
-       the tree. Mode can be used to [control](#common.IterMode) which
-       nodes the cursor visits.
-       */
-       cursor(mode = 0) {
-           return new TreeCursor(this.topNode, mode);
-       }
-       /**
-       Get a [tree cursor](#common.TreeCursor) pointing into this tree
-       at the given position and side (see
-       [`moveTo`](#common.TreeCursor.moveTo).
-       */
-       cursorAt(pos, side = 0, mode = 0) {
-           let scope = CachedNode.get(this) || this.topNode;
-           let cursor = new TreeCursor(scope);
-           cursor.moveTo(pos, side);
-           CachedNode.set(this, cursor._tree);
-           return cursor;
-       }
-       /**
-       Get a [syntax node](#common.SyntaxNode) object for the top of the
-       tree.
-       */
-       get topNode() {
-           return new TreeNode(this, 0, 0, null);
-       }
-       /**
-       Get the [syntax node](#common.SyntaxNode) at the given position.
-       If `side` is -1, this will move into nodes that end at the
-       position. If 1, it'll move into nodes that start at the
-       position. With 0, it'll only enter nodes that cover the position
-       from both sides.
-       
-       Note that this will not enter
-       [overlays](#common.MountedTree.overlay), and you often want
-       [`resolveInner`](#common.Tree.resolveInner) instead.
-       */
-       resolve(pos, side = 0) {
-           let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
-           CachedNode.set(this, node);
-           return node;
-       }
-       /**
-       Like [`resolve`](#common.Tree.resolve), but will enter
-       [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
-       pointing into the innermost overlaid tree at the given position
-       (with parent links going through all parent structure, including
-       the host trees).
-       */
-       resolveInner(pos, side = 0) {
-           let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
-           CachedInnerNode.set(this, node);
-           return node;
-       }
-       /**
-       In some situations, it can be useful to iterate through all
-       nodes around a position, including those in overlays that don't
-       directly cover the position. This method gives you an iterator
-       that will produce all nodes, from small to big, around the given
-       position.
-       */
-       resolveStack(pos, side = 0) {
-           return stackIterator(this, pos, side);
-       }
-       /**
-       Iterate over the tree and its children, calling `enter` for any
-       node that touches the `from`/`to` region (if given) before
-       running over such a node's children, and `leave` (if given) when
-       leaving the node. When `enter` returns `false`, that node will
-       not have its children iterated over (or `leave` called).
-       */
-       iterate(spec) {
-           let { enter, leave, from = 0, to = this.length } = spec;
-           let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
-           for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {
-               let entered = false;
-               if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
-                   if (c.firstChild())
-                       continue;
-                   entered = true;
-               }
-               for (;;) {
-                   if (entered && leave && (anon || !c.type.isAnonymous))
-                       leave(c);
-                   if (c.nextSibling())
-                       break;
-                   if (!c.parent())
-                       return;
-                   entered = true;
-               }
-           }
-       }
-       /**
-       Get the value of the given [node prop](#common.NodeProp) for this
-       node. Works with both per-node and per-type props.
-       */
-       prop(prop) {
-           return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;
-       }
-       /**
-       Returns the node's [per-node props](#common.NodeProp.perNode) in a
-       format that can be passed to the [`Tree`](#common.Tree)
-       constructor.
-       */
-       get propValues() {
-           let result = [];
-           if (this.props)
-               for (let id in this.props)
-                   result.push([+id, this.props[id]]);
-           return result;
-       }
-       /**
-       Balance the direct children of this tree, producing a copy of
-       which may have children grouped into subtrees with type
-       [`NodeType.none`](#common.NodeType^none).
-       */
-       balance(config = {}) {
-           return this.children.length <= 8 /* Balance.BranchFactor */ ? this :
-               balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
-       }
-       /**
-       Build a tree from a postfix-ordered buffer of node information,
-       or a cursor over such a buffer.
-       */
-       static build(data) { return buildTree(data); }
-   }
-   /**
-   The empty tree
-   */
-   Tree.empty = new Tree(NodeType.none, [], [], 0);
-   class FlatBufferCursor {
-       constructor(buffer, index) {
-           this.buffer = buffer;
-           this.index = index;
-       }
-       get id() { return this.buffer[this.index - 4]; }
-       get start() { return this.buffer[this.index - 3]; }
-       get end() { return this.buffer[this.index - 2]; }
-       get size() { return this.buffer[this.index - 1]; }
-       get pos() { return this.index; }
-       next() { this.index -= 4; }
-       fork() { return new FlatBufferCursor(this.buffer, this.index); }
-   }
-   /**
-   Tree buffers contain (type, start, end, endIndex) quads for each
-   node. In such a buffer, nodes are stored in prefix order (parents
-   before children, with the endIndex of the parent indicating which
-   children belong to it).
-   */
-   class TreeBuffer {
-       /**
-       Create a tree buffer.
-       */
-       constructor(
-       /**
-       The buffer's content.
-       */
-       buffer, 
-       /**
-       The total length of the group of nodes in the buffer.
-       */
-       length, 
-       /**
-       The node set used in this buffer.
-       */
-       set) {
-           this.buffer = buffer;
-           this.length = length;
-           this.set = set;
-       }
-       /**
-       @internal
-       */
-       get type() { return NodeType.none; }
-       /**
-       @internal
-       */
-       toString() {
-           let result = [];
-           for (let index = 0; index < this.buffer.length;) {
-               result.push(this.childString(index));
-               index = this.buffer[index + 3];
-           }
-           return result.join(",");
-       }
-       /**
-       @internal
-       */
-       childString(index) {
-           let id = this.buffer[index], endIndex = this.buffer[index + 3];
-           let type = this.set.types[id], result = type.name;
-           if (/\W/.test(result) && !type.isError)
-               result = JSON.stringify(result);
-           index += 4;
-           if (endIndex == index)
-               return result;
-           let children = [];
-           while (index < endIndex) {
-               children.push(this.childString(index));
-               index = this.buffer[index + 3];
-           }
-           return result + "(" + children.join(",") + ")";
-       }
-       /**
-       @internal
-       */
-       findChild(startIndex, endIndex, dir, pos, side) {
-           let { buffer } = this, pick = -1;
-           for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
-               if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
-                   pick = i;
-                   if (dir > 0)
-                       break;
-               }
-           }
-           return pick;
-       }
-       /**
-       @internal
-       */
-       slice(startI, endI, from) {
-           let b = this.buffer;
-           let copy = new Uint16Array(endI - startI), len = 0;
-           for (let i = startI, j = 0; i < endI;) {
-               copy[j++] = b[i++];
-               copy[j++] = b[i++] - from;
-               let to = copy[j++] = b[i++] - from;
-               copy[j++] = b[i++] - startI;
-               len = Math.max(len, to);
-           }
-           return new TreeBuffer(copy, len, this.set);
-       }
-   }
-   function checkSide(side, pos, from, to) {
-       switch (side) {
-           case -2 /* Side.Before */: return from < pos;
-           case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;
-           case 0 /* Side.Around */: return from < pos && to > pos;
-           case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;
-           case 2 /* Side.After */: return to > pos;
-           case 4 /* Side.DontCare */: return true;
-       }
-   }
-   function resolveNode(node, pos, side, overlays) {
-       var _a;
-       // Move up to a node that actually holds the position, if possible
-       while (node.from == node.to ||
-           (side < 1 ? node.from >= pos : node.from > pos) ||
-           (side > -1 ? node.to <= pos : node.to < pos)) {
-           let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
-           if (!parent)
-               return node;
-           node = parent;
-       }
-       let mode = overlays ? 0 : IterMode.IgnoreOverlays;
-       // Must go up out of overlays when those do not overlap with pos
-       if (overlays)
-           for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
-               if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
-                   node = parent;
-           }
-       for (;;) {
-           let inner = node.enter(pos, side, mode);
-           if (!inner)
-               return node;
-           node = inner;
-       }
-   }
-   class BaseNode {
-       cursor(mode = 0) { return new TreeCursor(this, mode); }
-       getChild(type, before = null, after = null) {
-           let r = getChildren(this, type, before, after);
-           return r.length ? r[0] : null;
-       }
-       getChildren(type, before = null, after = null) {
-           return getChildren(this, type, before, after);
-       }
-       resolve(pos, side = 0) {
-           return resolveNode(this, pos, side, false);
-       }
-       resolveInner(pos, side = 0) {
-           return resolveNode(this, pos, side, true);
-       }
-       matchContext(context) {
-           return matchNodeContext(this.parent, context);
-       }
-       enterUnfinishedNodesBefore(pos) {
-           let scan = this.childBefore(pos), node = this;
-           while (scan) {
-               let last = scan.lastChild;
-               if (!last || last.to != scan.to)
-                   break;
-               if (last.type.isError && last.from == last.to) {
-                   node = scan;
-                   scan = last.prevSibling;
-               }
-               else {
-                   scan = last;
-               }
-           }
-           return node;
-       }
-       get node() { return this; }
-       get next() { return this.parent; }
-   }
-   class TreeNode extends BaseNode {
-       constructor(_tree, from, 
-       // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)
-       index, _parent) {
-           super();
-           this._tree = _tree;
-           this.from = from;
-           this.index = index;
-           this._parent = _parent;
-       }
-       get type() { return this._tree.type; }
-       get name() { return this._tree.type.name; }
-       get to() { return this.from + this._tree.length; }
-       nextChild(i, dir, pos, side, mode = 0) {
-           for (let parent = this;;) {
-               for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
-                   let next = children[i], start = positions[i] + parent.from;
-                   if (!checkSide(side, pos, start, start + next.length))
-                       continue;
-                   if (next instanceof TreeBuffer) {
-                       if (mode & IterMode.ExcludeBuffers)
-                           continue;
-                       let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
-                       if (index > -1)
-                           return new BufferNode(new BufferContext(parent, next, i, start), null, index);
-                   }
-                   else if ((mode & IterMode.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {
-                       let mounted;
-                       if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)
-                           return new TreeNode(mounted.tree, start, i, parent);
-                       let inner = new TreeNode(next, start, i, parent);
-                       return (mode & IterMode.IncludeAnonymous) || !inner.type.isAnonymous ? inner
-                           : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
-                   }
-               }
-               if ((mode & IterMode.IncludeAnonymous) || !parent.type.isAnonymous)
-                   return null;
-               if (parent.index >= 0)
-                   i = parent.index + dir;
-               else
-                   i = dir < 0 ? -1 : parent._parent._tree.children.length;
-               parent = parent._parent;
-               if (!parent)
-                   return null;
-           }
-       }
-       get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); }
-       get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }
-       childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }
-       childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }
-       enter(pos, side, mode = 0) {
-           let mounted;
-           if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
-               let rPos = pos - this.from;
-               for (let { from, to } of mounted.overlay) {
-                   if ((side > 0 ? from <= rPos : from < rPos) &&
-                       (side < 0 ? to >= rPos : to > rPos))
-                       return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
-               }
-           }
-           return this.nextChild(0, 1, pos, side, mode);
-       }
-       nextSignificantParent() {
-           let val = this;
-           while (val.type.isAnonymous && val._parent)
-               val = val._parent;
-           return val;
-       }
-       get parent() {
-           return this._parent ? this._parent.nextSignificantParent() : null;
-       }
-       get nextSibling() {
-           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null;
-       }
-       get prevSibling() {
-           return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null;
-       }
-       get tree() { return this._tree; }
-       toTree() { return this._tree; }
-       /**
-       @internal
-       */
-       toString() { return this._tree.toString(); }
-   }
-   function getChildren(node, type, before, after) {
-       let cur = node.cursor(), result = [];
-       if (!cur.firstChild())
-           return result;
-       if (before != null)
-           for (let found = false; !found;) {
-               found = cur.type.is(before);
-               if (!cur.nextSibling())
-                   return result;
-           }
-       for (;;) {
-           if (after != null && cur.type.is(after))
-               return result;
-           if (cur.type.is(type))
-               result.push(cur.node);
-           if (!cur.nextSibling())
-               return after == null ? result : [];
-       }
-   }
-   function matchNodeContext(node, context, i = context.length - 1) {
-       for (let p = node; i >= 0; p = p.parent) {
-           if (!p)
-               return false;
-           if (!p.type.isAnonymous) {
-               if (context[i] && context[i] != p.name)
-                   return false;
-               i--;
-           }
-       }
-       return true;
-   }
-   class BufferContext {
-       constructor(parent, buffer, index, start) {
-           this.parent = parent;
-           this.buffer = buffer;
-           this.index = index;
-           this.start = start;
-       }
-   }
-   class BufferNode extends BaseNode {
-       get name() { return this.type.name; }
-       get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }
-       get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }
-       constructor(context, _parent, index) {
-           super();
-           this.context = context;
-           this._parent = _parent;
-           this.index = index;
-           this.type = context.buffer.set.types[context.buffer.buffer[index]];
-       }
-       child(dir, pos, side) {
-           let { buffer } = this.context;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
-           return index < 0 ? null : new BufferNode(this.context, this, index);
-       }
-       get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }
-       get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }
-       childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }
-       childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }
-       enter(pos, side, mode = 0) {
-           if (mode & IterMode.ExcludeBuffers)
-               return null;
-           let { buffer } = this.context;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
-           return index < 0 ? null : new BufferNode(this.context, this, index);
-       }
-       get parent() {
-           return this._parent || this.context.parent.nextSignificantParent();
-       }
-       externalSibling(dir) {
-           return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */);
-       }
-       get nextSibling() {
-           let { buffer } = this.context;
-           let after = buffer.buffer[this.index + 3];
-           if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
-               return new BufferNode(this.context, this._parent, after);
-           return this.externalSibling(1);
-       }
-       get prevSibling() {
-           let { buffer } = this.context;
-           let parentStart = this._parent ? this._parent.index + 4 : 0;
-           if (this.index == parentStart)
-               return this.externalSibling(-1);
-           return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
-       }
-       get tree() { return null; }
-       toTree() {
-           let children = [], positions = [];
-           let { buffer } = this.context;
-           let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
-           if (endI > startI) {
-               let from = buffer.buffer[this.index + 1];
-               children.push(buffer.slice(startI, endI, from));
-               positions.push(0);
-           }
-           return new Tree(this.type, children, positions, this.to - this.from);
-       }
-       /**
-       @internal
-       */
-       toString() { return this.context.buffer.childString(this.index); }
-   }
-   function iterStack(heads) {
-       if (!heads.length)
-           return null;
-       let pick = 0, picked = heads[0];
-       for (let i = 1; i < heads.length; i++) {
-           let node = heads[i];
-           if (node.from > picked.from || node.to < picked.to) {
-               picked = node;
-               pick = i;
-           }
-       }
-       let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
-       let newHeads = heads.slice();
-       if (next)
-           newHeads[pick] = next;
-       else
-           newHeads.splice(pick, 1);
-       return new StackIterator(newHeads, picked);
-   }
-   class StackIterator {
-       constructor(heads, node) {
-           this.heads = heads;
-           this.node = node;
-       }
-       get next() { return iterStack(this.heads); }
-   }
-   function stackIterator(tree, pos, side) {
-       let inner = tree.resolveInner(pos, side), layers = null;
-       for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {
-           if (scan.index < 0) { // This is an overlay root
-               let parent = scan.parent;
-               (layers || (layers = [inner])).push(parent.resolve(pos, side));
-               scan = parent;
-           }
-           else {
-               let mount = MountedTree.get(scan.tree);
-               // Relevant overlay branching off
-               if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
-                   let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
-                   (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
-               }
-           }
-       }
-       return layers ? iterStack(layers) : inner;
-   }
-   /**
-   A tree cursor object focuses on a given node in a syntax tree, and
-   allows you to move to adjacent nodes.
-   */
-   class TreeCursor {
-       /**
-       Shorthand for `.type.name`.
-       */
-       get name() { return this.type.name; }
-       /**
-       @internal
-       */
-       constructor(node, 
-       /**
-       @internal
-       */
-       mode = 0) {
-           this.mode = mode;
-           /**
-           @internal
-           */
-           this.buffer = null;
-           this.stack = [];
-           /**
-           @internal
-           */
-           this.index = 0;
-           this.bufferNode = null;
-           if (node instanceof TreeNode) {
-               this.yieldNode(node);
-           }
-           else {
-               this._tree = node.context.parent;
-               this.buffer = node.context;
-               for (let n = node._parent; n; n = n._parent)
-                   this.stack.unshift(n.index);
-               this.bufferNode = node;
-               this.yieldBuf(node.index);
-           }
-       }
-       yieldNode(node) {
-           if (!node)
-               return false;
-           this._tree = node;
-           this.type = node.type;
-           this.from = node.from;
-           this.to = node.to;
-           return true;
-       }
-       yieldBuf(index, type) {
-           this.index = index;
-           let { start, buffer } = this.buffer;
-           this.type = type || buffer.set.types[buffer.buffer[index]];
-           this.from = start + buffer.buffer[index + 1];
-           this.to = start + buffer.buffer[index + 2];
-           return true;
-       }
-       /**
-       @internal
-       */
-       yield(node) {
-           if (!node)
-               return false;
-           if (node instanceof TreeNode) {
-               this.buffer = null;
-               return this.yieldNode(node);
-           }
-           this.buffer = node.context;
-           return this.yieldBuf(node.index, node.type);
-       }
-       /**
-       @internal
-       */
-       toString() {
-           return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
-       }
-       /**
-       @internal
-       */
-       enterChild(dir, pos, side) {
-           if (!this.buffer)
-               return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
-           let { buffer } = this.buffer;
-           let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
-           if (index < 0)
-               return false;
-           this.stack.push(this.index);
-           return this.yieldBuf(index);
-       }
-       /**
-       Move the cursor to this node's first child. When this returns
-       false, the node has no child, and the cursor has not been moved.
-       */
-       firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); }
-       /**
-       Move the cursor to this node's last child.
-       */
-       lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); }
-       /**
-       Move the cursor to the first child that ends after `pos`.
-       */
-       childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); }
-       /**
-       Move to the last child that starts before `pos`.
-       */
-       childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); }
-       /**
-       Move the cursor to the child around `pos`. If side is -1 the
-       child may end at that position, when 1 it may start there. This
-       will also enter [overlaid](#common.MountedTree.overlay)
-       [mounted](#common.NodeProp^mounted) trees unless `overlays` is
-       set to false.
-       */
-       enter(pos, side, mode = this.mode) {
-           if (!this.buffer)
-               return this.yield(this._tree.enter(pos, side, mode));
-           return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
-       }
-       /**
-       Move to the node's parent node, if this isn't the top node.
-       */
-       parent() {
-           if (!this.buffer)
-               return this.yieldNode((this.mode & IterMode.IncludeAnonymous) ? this._tree._parent : this._tree.parent);
-           if (this.stack.length)
-               return this.yieldBuf(this.stack.pop());
-           let parent = (this.mode & IterMode.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
-           this.buffer = null;
-           return this.yieldNode(parent);
-       }
-       /**
-       @internal
-       */
-       sibling(dir) {
-           if (!this.buffer)
-               return !this._tree._parent ? false
-                   : this.yield(this._tree.index < 0 ? null
-                       : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode));
-           let { buffer } = this.buffer, d = this.stack.length - 1;
-           if (dir < 0) {
-               let parentStart = d < 0 ? 0 : this.stack[d] + 4;
-               if (this.index != parentStart)
-                   return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));
-           }
-           else {
-               let after = buffer.buffer[this.index + 3];
-               if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
-                   return this.yieldBuf(after);
-           }
-           return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false;
-       }
-       /**
-       Move to this node's next sibling, if any.
-       */
-       nextSibling() { return this.sibling(1); }
-       /**
-       Move to this node's previous sibling, if any.
-       */
-       prevSibling() { return this.sibling(-1); }
-       atLastNode(dir) {
-           let index, parent, { buffer } = this;
-           if (buffer) {
-               if (dir > 0) {
-                   if (this.index < buffer.buffer.buffer.length)
-                       return false;
-               }
-               else {
-                   for (let i = 0; i < this.index; i++)
-                       if (buffer.buffer.buffer[i + 3] < this.index)
-                           return false;
-               }
-               ({ index, parent } = buffer);
-           }
-           else {
-               ({ index, _parent: parent } = this._tree);
-           }
-           for (; parent; { index, _parent: parent } = parent) {
-               if (index > -1)
-                   for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
-                       let child = parent._tree.children[i];
-                       if ((this.mode & IterMode.IncludeAnonymous) ||
-                           child instanceof TreeBuffer ||
-                           !child.type.isAnonymous ||
-                           hasChild(child))
-                           return false;
-                   }
-           }
-           return true;
-       }
-       move(dir, enter) {
-           if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */))
-               return true;
-           for (;;) {
-               if (this.sibling(dir))
-                   return true;
-               if (this.atLastNode(dir) || !this.parent())
-                   return false;
-           }
-       }
-       /**
-       Move to the next node in a
-       [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
-       traversal, going from a node to its first child or, if the
-       current node is empty or `enter` is false, its next sibling or
-       the next sibling of the first parent node that has one.
-       */
-       next(enter = true) { return this.move(1, enter); }
-       /**
-       Move to the next node in a last-to-first pre-order traversal. A
-       node is followed by its last child or, if it has none, its
-       previous sibling or the previous sibling of the first parent
-       node that has one.
-       */
-       prev(enter = true) { return this.move(-1, enter); }
-       /**
-       Move the cursor to the innermost node that covers `pos`. If
-       `side` is -1, it will enter nodes that end at `pos`. If it is 1,
-       it will enter nodes that start at `pos`.
-       */
-       moveTo(pos, side = 0) {
-           // Move up to a node that actually holds the position, if possible
-           while (this.from == this.to ||
-               (side < 1 ? this.from >= pos : this.from > pos) ||
-               (side > -1 ? this.to <= pos : this.to < pos))
-               if (!this.parent())
-                   break;
-           // Then scan down into child nodes as far as possible
-           while (this.enterChild(1, pos, side)) { }
-           return this;
-       }
-       /**
-       Get a [syntax node](#common.SyntaxNode) at the cursor's current
-       position.
-       */
-       get node() {
-           if (!this.buffer)
-               return this._tree;
-           let cache = this.bufferNode, result = null, depth = 0;
-           if (cache && cache.context == this.buffer) {
-               scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
-                   for (let c = cache; c; c = c._parent)
-                       if (c.index == index) {
-                           if (index == this.index)
-                               return c;
-                           result = c;
-                           depth = d + 1;
-                           break scan;
-                       }
-                   index = this.stack[--d];
-               }
-           }
-           for (let i = depth; i < this.stack.length; i++)
-               result = new BufferNode(this.buffer, result, this.stack[i]);
-           return this.bufferNode = new BufferNode(this.buffer, result, this.index);
-       }
-       /**
-       Get the [tree](#common.Tree) that represents the current node, if
-       any. Will return null when the node is in a [tree
-       buffer](#common.TreeBuffer).
-       */
-       get tree() {
-           return this.buffer ? null : this._tree._tree;
-       }
-       /**
-       Iterate over the current node and all its descendants, calling
-       `enter` when entering a node and `leave`, if given, when leaving
-       one. When `enter` returns `false`, any children of that node are
-       skipped, and `leave` isn't called for it.
-       */
-       iterate(enter, leave) {
-           for (let depth = 0;;) {
-               let mustLeave = false;
-               if (this.type.isAnonymous || enter(this) !== false) {
-                   if (this.firstChild()) {
-                       depth++;
-                       continue;
-                   }
-                   if (!this.type.isAnonymous)
-                       mustLeave = true;
-               }
-               for (;;) {
-                   if (mustLeave && leave)
-                       leave(this);
-                   mustLeave = this.type.isAnonymous;
-                   if (!depth)
-                       return;
-                   if (this.nextSibling())
-                       break;
-                   this.parent();
-                   depth--;
-                   mustLeave = true;
-               }
-           }
-       }
-       /**
-       Test whether the current node matches a given context—a sequence
-       of direct parent node names. Empty strings in the context array
-       are treated as wildcards.
-       */
-       matchContext(context) {
-           if (!this.buffer)
-               return matchNodeContext(this.node.parent, context);
-           let { buffer } = this.buffer, { types } = buffer.set;
-           for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
-               if (d < 0)
-                   return matchNodeContext(this._tree, context, i);
-               let type = types[buffer.buffer[this.stack[d]]];
-               if (!type.isAnonymous) {
-                   if (context[i] && context[i] != type.name)
-                       return false;
-                   i--;
-               }
-           }
-           return true;
-       }
-   }
-   function hasChild(tree) {
-       return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
-   }
-   function buildTree(data) {
-       var _a;
-       let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
-       let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
-       let types = nodeSet.types;
-       let contextHash = 0, lookAhead = 0;
-       function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
-           let { id, start, end, size } = cursor;
-           let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
-           while (size < 0) {
-               cursor.next();
-               if (size == -1 /* SpecialRecord.Reuse */) {
-                   let node = reused[id];
-                   children.push(node);
-                   positions.push(start - parentStart);
-                   return;
-               }
-               else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change
-                   contextHash = id;
-                   return;
-               }
-               else if (size == -4 /* SpecialRecord.LookAhead */) {
-                   lookAhead = id;
-                   return;
-               }
-               else {
-                   throw new RangeError(`Unrecognized record size: ${size}`);
-               }
-           }
-           let type = types[id], node, buffer;
-           let startPos = start - parentStart;
-           if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
-               // Small enough for a buffer, and no reused nodes inside
-               let data = new Uint16Array(buffer.size - buffer.skip);
-               let endPos = cursor.pos - buffer.size, index = data.length;
-               while (cursor.pos > endPos)
-                   index = copyToBuffer(buffer.start, data, index);
-               node = new TreeBuffer(data, end - buffer.start, nodeSet);
-               startPos = buffer.start - parentStart;
-           }
-           else { // Make it a node
-               let endPos = cursor.pos - size;
-               cursor.next();
-               let localChildren = [], localPositions = [];
-               let localInRepeat = id >= minRepeatType ? id : -1;
-               let lastGroup = 0, lastEnd = end;
-               while (cursor.pos > endPos) {
-                   if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
-                       if (cursor.end <= lastEnd - maxBufferLength) {
-                           makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
-                           lastGroup = localChildren.length;
-                           lastEnd = cursor.end;
-                       }
-                       cursor.next();
-                   }
-                   else if (depth > 2500 /* CutOff.Depth */) {
-                       takeFlatNode(start, endPos, localChildren, localPositions);
-                   }
-                   else {
-                       takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
-                   }
-               }
-               if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
-                   makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
-               localChildren.reverse();
-               localPositions.reverse();
-               if (localInRepeat > -1 && lastGroup > 0) {
-                   let make = makeBalanced(type, contextAtStart);
-                   node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
-               }
-               else {
-                   node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
-               }
-           }
-           children.push(node);
-           positions.push(startPos);
-       }
-       function takeFlatNode(parentStart, minPos, children, positions) {
-           let nodes = []; // Temporary, inverted array of leaf nodes found, with absolute positions
-           let nodeCount = 0, stopAt = -1;
-           while (cursor.pos > minPos) {
-               let { id, start, end, size } = cursor;
-               if (size > 4) { // Not a leaf
-                   cursor.next();
-               }
-               else if (stopAt > -1 && start < stopAt) {
-                   break;
-               }
-               else {
-                   if (stopAt < 0)
-                       stopAt = end - maxBufferLength;
-                   nodes.push(id, start, end);
-                   nodeCount++;
-                   cursor.next();
-               }
-           }
-           if (nodeCount) {
-               let buffer = new Uint16Array(nodeCount * 4);
-               let start = nodes[nodes.length - 2];
-               for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
-                   buffer[j++] = nodes[i];
-                   buffer[j++] = nodes[i + 1] - start;
-                   buffer[j++] = nodes[i + 2] - start;
-                   buffer[j++] = j;
-               }
-               children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));
-               positions.push(start - parentStart);
-           }
-       }
-       function makeBalanced(type, contextHash) {
-           return (children, positions, length) => {
-               let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
-               if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
-                   if (!lastI && last.type == type && last.length == length)
-                       return last;
-                   if (lookAheadProp = last.prop(NodeProp.lookAhead))
-                       lookAhead = positions[lastI] + last.length + lookAheadProp;
-               }
-               return makeTree(type, children, positions, length, lookAhead, contextHash);
-           };
-       }
-       function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead, contextHash) {
-           let localChildren = [], localPositions = [];
-           while (children.length > i) {
-               localChildren.push(children.pop());
-               localPositions.push(positions.pop() + base - from);
-           }
-           children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to, contextHash));
-           positions.push(from - base);
-       }
-       function makeTree(type, children, positions, length, lookAhead, contextHash, props) {
-           if (contextHash) {
-               let pair = [NodeProp.contextHash, contextHash];
-               props = props ? [pair].concat(props) : [pair];
-           }
-           if (lookAhead > 25) {
-               let pair = [NodeProp.lookAhead, lookAhead];
-               props = props ? [pair].concat(props) : [pair];
-           }
-           return new Tree(type, children, positions, length, props);
-       }
-       function findBufferSize(maxSize, inRepeat) {
-           // Scan through the buffer to find previous siblings that fit
-           // together in a TreeBuffer, and don't contain any reused nodes
-           // (which can't be stored in a buffer).
-           // If `inRepeat` is > -1, ignore node boundaries of that type for
-           // nesting, but make sure the end falls either at the start
-           // (`maxSize`) or before such a node.
-           let fork = cursor.fork();
-           let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
-           let result = { size: 0, start: 0, skip: 0 };
-           scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
-               let nodeSize = fork.size;
-               // Pretend nested repeat nodes of the same type don't exist
-               if (fork.id == inRepeat && nodeSize >= 0) {
-                   // Except that we store the current state as a valid return
-                   // value.
-                   result.size = size;
-                   result.start = start;
-                   result.skip = skip;
-                   skip += 4;
-                   size += 4;
-                   fork.next();
-                   continue;
-               }
-               let startPos = fork.pos - nodeSize;
-               if (nodeSize < 0 || startPos < minPos || fork.start < minStart)
-                   break;
-               let localSkipped = fork.id >= minRepeatType ? 4 : 0;
-               let nodeStart = fork.start;
-               fork.next();
-               while (fork.pos > startPos) {
-                   if (fork.size < 0) {
-                       if (fork.size == -3 /* SpecialRecord.ContextChange */)
-                           localSkipped += 4;
-                       else
-                           break scan;
-                   }
-                   else if (fork.id >= minRepeatType) {
-                       localSkipped += 4;
-                   }
-                   fork.next();
-               }
-               start = nodeStart;
-               size += nodeSize;
-               skip += localSkipped;
-           }
-           if (inRepeat < 0 || size == maxSize) {
-               result.size = size;
-               result.start = start;
-               result.skip = skip;
-           }
-           return result.size > 4 ? result : undefined;
-       }
-       function copyToBuffer(bufferStart, buffer, index) {
-           let { id, start, end, size } = cursor;
-           cursor.next();
-           if (size >= 0 && id < minRepeatType) {
-               let startIndex = index;
-               if (size > 4) {
-                   let endPos = cursor.pos - (size - 4);
-                   while (cursor.pos > endPos)
-                       index = copyToBuffer(bufferStart, buffer, index);
-               }
-               buffer[--index] = startIndex;
-               buffer[--index] = end - bufferStart;
-               buffer[--index] = start - bufferStart;
-               buffer[--index] = id;
-           }
-           else if (size == -3 /* SpecialRecord.ContextChange */) {
-               contextHash = id;
-           }
-           else if (size == -4 /* SpecialRecord.LookAhead */) {
-               lookAhead = id;
-           }
-           return index;
-       }
-       let children = [], positions = [];
-       while (cursor.pos > 0)
-           takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
-       let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);
-       return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
-   }
-   const nodeSizeCache = new WeakMap;
-   function nodeSize(balanceType, node) {
-       if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
-           return 1;
-       let size = nodeSizeCache.get(node);
-       if (size == null) {
-           size = 1;
-           for (let child of node.children) {
-               if (child.type != balanceType || !(child instanceof Tree)) {
-                   size = 1;
-                   break;
-               }
-               size += nodeSize(balanceType, child);
-           }
-           nodeSizeCache.set(node, size);
-       }
-       return size;
-   }
-   function balanceRange(
-   // The type the balanced tree's inner nodes.
-   balanceType, 
-   // The direct children and their positions
-   children, positions, 
-   // The index range in children/positions to use
-   from, to, 
-   // The start position of the nodes, relative to their parent.
-   start, 
-   // Length of the outer node
-   length, 
-   // Function to build the top node of the balanced tree
-   mkTop, 
-   // Function to build internal nodes for the balanced tree
-   mkTree) {
-       let total = 0;
-       for (let i = from; i < to; i++)
-           total += nodeSize(balanceType, children[i]);
-       let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);
-       let localChildren = [], localPositions = [];
-       function divide(children, positions, from, to, offset) {
-           for (let i = from; i < to;) {
-               let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
-               i++;
-               for (; i < to; i++) {
-                   let nextSize = nodeSize(balanceType, children[i]);
-                   if (groupSize + nextSize >= maxChild)
-                       break;
-                   groupSize += nextSize;
-               }
-               if (i == groupFrom + 1) {
-                   if (groupSize > maxChild) {
-                       let only = children[groupFrom]; // Only trees can have a size > 1
-                       divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
-                       continue;
-                   }
-                   localChildren.push(children[groupFrom]);
-               }
-               else {
-                   let length = positions[i - 1] + children[i - 1].length - groupStart;
-                   localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
-               }
-               localPositions.push(groupStart + offset - start);
-           }
-       }
-       divide(children, positions, from, to, 0);
-       return (mkTop || mkTree)(localChildren, localPositions, length);
-   }
-   /**
-   Provides a way to associate values with pieces of trees. As long
-   as that part of the tree is reused, the associated values can be
-   retrieved from an updated tree.
-   */
-   class NodeWeakMap {
-       constructor() {
-           this.map = new WeakMap();
-       }
-       setBuffer(buffer, index, value) {
-           let inner = this.map.get(buffer);
-           if (!inner)
-               this.map.set(buffer, inner = new Map);
-           inner.set(index, value);
-       }
-       getBuffer(buffer, index) {
-           let inner = this.map.get(buffer);
-           return inner && inner.get(index);
-       }
-       /**
-       Set the value for this syntax node.
-       */
-       set(node, value) {
-           if (node instanceof BufferNode)
-               this.setBuffer(node.context.buffer, node.index, value);
-           else if (node instanceof TreeNode)
-               this.map.set(node.tree, value);
-       }
-       /**
-       Retrieve value for this syntax node, if it exists in the map.
-       */
-       get(node) {
-           return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index)
-               : node instanceof TreeNode ? this.map.get(node.tree) : undefined;
-       }
-       /**
-       Set the value for the node that a cursor currently points to.
-       */
-       cursorSet(cursor, value) {
-           if (cursor.buffer)
-               this.setBuffer(cursor.buffer.buffer, cursor.index, value);
-           else
-               this.map.set(cursor.tree, value);
-       }
-       /**
-       Retrieve the value for the node that a cursor currently points
-       to.
-       */
-       cursorGet(cursor) {
-           return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
-       }
-   }
-
-   /**
-   Tree fragments are used during [incremental
-   parsing](#common.Parser.startParse) to track parts of old trees
-   that can be reused in a new parse. An array of fragments is used
-   to track regions of an old tree whose nodes might be reused in new
-   parses. Use the static
-   [`applyChanges`](#common.TreeFragment^applyChanges) method to
-   update fragments for document changes.
-   */
-   class TreeFragment {
-       /**
-       Construct a tree fragment. You'll usually want to use
-       [`addTree`](#common.TreeFragment^addTree) and
-       [`applyChanges`](#common.TreeFragment^applyChanges) instead of
-       calling this directly.
-       */
-       constructor(
-       /**
-       The start of the unchanged range pointed to by this fragment.
-       This refers to an offset in the _updated_ document (as opposed
-       to the original tree).
-       */
-       from, 
-       /**
-       The end of the unchanged range.
-       */
-       to, 
-       /**
-       The tree that this fragment is based on.
-       */
-       tree, 
-       /**
-       The offset between the fragment's tree and the document that
-       this fragment can be used against. Add this when going from
-       document to tree positions, subtract it to go from tree to
-       document positions.
-       */
-       offset, openStart = false, openEnd = false) {
-           this.from = from;
-           this.to = to;
-           this.tree = tree;
-           this.offset = offset;
-           this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0);
-       }
-       /**
-       Whether the start of the fragment represents the start of a
-       parse, or the end of a change. (In the second case, it may not
-       be safe to reuse some nodes at the start, depending on the
-       parsing algorithm.)
-       */
-       get openStart() { return (this.open & 1 /* Open.Start */) > 0; }
-       /**
-       Whether the end of the fragment represents the end of a
-       full-document parse, or the start of a change.
-       */
-       get openEnd() { return (this.open & 2 /* Open.End */) > 0; }
-       /**
-       Create a set of fragments from a freshly parsed tree, or update
-       an existing set of fragments by replacing the ones that overlap
-       with a tree with content from the new tree. When `partial` is
-       true, the parse is treated as incomplete, and the resulting
-       fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
-       true.
-       */
-       static addTree(tree, fragments = [], partial = false) {
-           let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
-           for (let f of fragments)
-               if (f.to > tree.length)
-                   result.push(f);
-           return result;
-       }
-       /**
-       Apply a set of edits to an array of fragments, removing or
-       splitting fragments as necessary to remove edited ranges, and
-       adjusting offsets for fragments that moved.
-       */
-       static applyChanges(fragments, changes, minGap = 128) {
-           if (!changes.length)
-               return fragments;
-           let result = [];
-           let fI = 1, nextF = fragments.length ? fragments[0] : null;
-           for (let cI = 0, pos = 0, off = 0;; cI++) {
-               let nextC = cI < changes.length ? changes[cI] : null;
-               let nextPos = nextC ? nextC.fromA : 1e9;
-               if (nextPos - pos >= minGap)
-                   while (nextF && nextF.from < nextPos) {
-                       let cut = nextF;
-                       if (pos >= cut.from || nextPos <= cut.to || off) {
-                           let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
-                           cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
-                       }
-                       if (cut)
-                           result.push(cut);
-                       if (nextF.to > nextPos)
-                           break;
-                       nextF = fI < fragments.length ? fragments[fI++] : null;
-                   }
-               if (!nextC)
-                   break;
-               pos = nextC.toA;
-               off = nextC.toA - nextC.toB;
-           }
-           return result;
-       }
-   }
-   /**
-   A superclass that parsers should extend.
-   */
-   class Parser {
-       /**
-       Start a parse, returning a [partial parse](#common.PartialParse)
-       object. [`fragments`](#common.TreeFragment) can be passed in to
-       make the parse incremental.
-       
-       By default, the entire input is parsed. You can pass `ranges`,
-       which should be a sorted array of non-empty, non-overlapping
-       ranges, to parse only those ranges. The tree returned in that
-       case will start at `ranges[0].from`.
-       */
-       startParse(input, fragments, ranges) {
-           if (typeof input == "string")
-               input = new StringInput(input);
-           ranges = !ranges ? [new Range$1(0, input.length)] : ranges.length ? ranges.map(r => new Range$1(r.from, r.to)) : [new Range$1(0, 0)];
-           return this.createParse(input, fragments || [], ranges);
-       }
-       /**
-       Run a full parse, returning the resulting tree.
-       */
-       parse(input, fragments, ranges) {
-           let parse = this.startParse(input, fragments, ranges);
-           for (;;) {
-               let done = parse.advance();
-               if (done)
-                   return done;
-           }
-       }
-   }
-   class StringInput {
-       constructor(string) {
-           this.string = string;
-       }
-       get length() { return this.string.length; }
-       chunk(from) { return this.string.slice(from); }
-       get lineChunks() { return false; }
-       read(from, to) { return this.string.slice(from, to); }
-   }
-   new NodeProp({ perNode: true });
-
-   /**
-   A parse stack. These are used internally by the parser to track
-   parsing progress. They also provide some properties and methods
-   that external code such as a tokenizer can use to get information
-   about the parse state.
-   */
-   class Stack {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The parse that this stack is part of @internal
-       */
-       p, 
-       /**
-       Holds state, input pos, buffer index triplets for all but the
-       top state @internal
-       */
-       stack, 
-       /**
-       The current parse state @internal
-       */
-       state, 
-       // The position at which the next reduce should take place. This
-       // can be less than `this.pos` when skipped expressions have been
-       // added to the stack (which should be moved outside of the next
-       // reduction)
-       /**
-       @internal
-       */
-       reducePos, 
-       /**
-       The input position up to which this stack has parsed.
-       */
-       pos, 
-       /**
-       The dynamic score of the stack, including dynamic precedence
-       and error-recovery penalties
-       @internal
-       */
-       score, 
-       // The output buffer. Holds (type, start, end, size) quads
-       // representing nodes created by the parser, where `size` is
-       // amount of buffer array entries covered by this node.
-       /**
-       @internal
-       */
-       buffer, 
-       // The base offset of the buffer. When stacks are split, the split
-       // instance shared the buffer history with its parent up to
-       // `bufferBase`, which is the absolute offset (including the
-       // offset of previous splits) into the buffer at which this stack
-       // starts writing.
-       /**
-       @internal
-       */
-       bufferBase, 
-       /**
-       @internal
-       */
-       curContext, 
-       /**
-       @internal
-       */
-       lookAhead = 0, 
-       // A parent stack from which this was split off, if any. This is
-       // set up so that it always points to a stack that has some
-       // additional buffer content, never to a stack with an equal
-       // `bufferBase`.
-       /**
-       @internal
-       */
-       parent) {
-           this.p = p;
-           this.stack = stack;
-           this.state = state;
-           this.reducePos = reducePos;
-           this.pos = pos;
-           this.score = score;
-           this.buffer = buffer;
-           this.bufferBase = bufferBase;
-           this.curContext = curContext;
-           this.lookAhead = lookAhead;
-           this.parent = parent;
-       }
-       /**
-       @internal
-       */
-       toString() {
-           return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
-       }
-       // Start an empty stack
-       /**
-       @internal
-       */
-       static start(p, state, pos = 0) {
-           let cx = p.parser.context;
-           return new Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
-       }
-       /**
-       The stack's current [context](#lr.ContextTracker) value, if
-       any. Its type will depend on the context tracker's type
-       parameter, or it will be `null` if there is no context
-       tracker.
-       */
-       get context() { return this.curContext ? this.curContext.context : null; }
-       // Push a state onto the stack, tracking its start position as well
-       // as the buffer base at that point.
-       /**
-       @internal
-       */
-       pushState(state, start) {
-           this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
-           this.state = state;
-       }
-       // Apply a reduce action
-       /**
-       @internal
-       */
-       reduce(action) {
-           var _a;
-           let depth = action >> 19 /* Action.ReduceDepthShift */, type = action & 65535 /* Action.ValueMask */;
-           let { parser } = this.p;
-           let lookaheadRecord = this.reducePos < this.pos - 25 /* Lookahead.Margin */;
-           if (lookaheadRecord)
-               this.setLookAhead(this.pos);
-           let dPrec = parser.dynamicPrecedence(type);
-           if (dPrec)
-               this.score += dPrec;
-           if (depth == 0) {
-               this.pushState(parser.getGoto(this.state, type, true), this.reducePos);
-               // Zero-depth reductions are a special case—they add stuff to
-               // the stack without popping anything off.
-               if (type < parser.minRepeatTerm)
-                   this.storeNode(type, this.reducePos, this.reducePos, lookaheadRecord ? 8 : 4, true);
-               this.reduceContext(type, this.reducePos);
-               return;
-           }
-           // Find the base index into `this.stack`, content after which will
-           // be dropped. Note that with `StayFlag` reductions we need to
-           // consume two extra frames (the dummy parent node for the skipped
-           // expression and the state that we'll be staying in, which should
-           // be moved to `this.state`).
-           let base = this.stack.length - ((depth - 1) * 3) - (action & 262144 /* Action.StayFlag */ ? 6 : 0);
-           let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start;
-           // This is a kludge to try and detect overly deep left-associative
-           // trees, which will not increase the parse stack depth and thus
-           // won't be caught by the regular stack-depth limit check.
-           if (size >= 2000 /* Recover.MinBigReduction */ && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) {
-               if (start == this.p.lastBigReductionStart) {
-                   this.p.bigReductionCount++;
-                   this.p.lastBigReductionSize = size;
-               }
-               else if (this.p.lastBigReductionSize < size) {
-                   this.p.bigReductionCount = 1;
-                   this.p.lastBigReductionStart = start;
-                   this.p.lastBigReductionSize = size;
-               }
-           }
-           let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
-           // Store normal terms or `R -> R R` repeat reductions
-           if (type < parser.minRepeatTerm || (action & 131072 /* Action.RepeatFlag */)) {
-               let pos = parser.stateFlag(this.state, 1 /* StateFlag.Skipped */) ? this.pos : this.reducePos;
-               this.storeNode(type, start, pos, count + 4, true);
-           }
-           if (action & 262144 /* Action.StayFlag */) {
-               this.state = this.stack[base];
-           }
-           else {
-               let baseStateID = this.stack[base - 3];
-               this.state = parser.getGoto(baseStateID, type, true);
-           }
-           while (this.stack.length > base)
-               this.stack.pop();
-           this.reduceContext(type, start);
-       }
-       // Shift a value into the buffer
-       /**
-       @internal
-       */
-       storeNode(term, start, end, size = 4, mustSink = false) {
-           if (term == 0 /* Term.Err */ &&
-               (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
-               // Try to omit/merge adjacent error nodes
-               let cur = this, top = this.buffer.length;
-               if (top == 0 && cur.parent) {
-                   top = cur.bufferBase - cur.parent.bufferBase;
-                   cur = cur.parent;
-               }
-               if (top > 0 && cur.buffer[top - 4] == 0 /* Term.Err */ && cur.buffer[top - 1] > -1) {
-                   if (start == end)
-                       return;
-                   if (cur.buffer[top - 2] >= start) {
-                       cur.buffer[top - 2] = end;
-                       return;
-                   }
-               }
-           }
-           if (!mustSink || this.pos == end) { // Simple case, just append
-               this.buffer.push(term, start, end, size);
-           }
-           else { // There may be skipped nodes that have to be moved forward
-               let index = this.buffer.length;
-               if (index > 0 && this.buffer[index - 4] != 0 /* Term.Err */) {
-                   let mustMove = false;
-                   for (let scan = index; scan > 0 && this.buffer[scan - 2] > end; scan -= 4) {
-                       if (this.buffer[scan - 1] >= 0) {
-                           mustMove = true;
-                           break;
-                       }
-                   }
-                   if (mustMove)
-                       while (index > 0 && this.buffer[index - 2] > end) {
-                           // Move this record forward
-                           this.buffer[index] = this.buffer[index - 4];
-                           this.buffer[index + 1] = this.buffer[index - 3];
-                           this.buffer[index + 2] = this.buffer[index - 2];
-                           this.buffer[index + 3] = this.buffer[index - 1];
-                           index -= 4;
-                           if (size > 4)
-                               size -= 4;
-                       }
-               }
-               this.buffer[index] = term;
-               this.buffer[index + 1] = start;
-               this.buffer[index + 2] = end;
-               this.buffer[index + 3] = size;
-           }
-       }
-       // Apply a shift action
-       /**
-       @internal
-       */
-       shift(action, type, start, end) {
-           if (action & 131072 /* Action.GotoFlag */) {
-               this.pushState(action & 65535 /* Action.ValueMask */, this.pos);
-           }
-           else if ((action & 262144 /* Action.StayFlag */) == 0) { // Regular shift
-               let nextState = action, { parser } = this.p;
-               if (end > this.pos || type <= parser.maxNode) {
-                   this.pos = end;
-                   if (!parser.stateFlag(nextState, 1 /* StateFlag.Skipped */))
-                       this.reducePos = end;
-               }
-               this.pushState(nextState, start);
-               this.shiftContext(type, start);
-               if (type <= parser.maxNode)
-                   this.buffer.push(type, start, end, 4);
-           }
-           else { // Shift-and-stay, which means this is a skipped token
-               this.pos = end;
-               this.shiftContext(type, start);
-               if (type <= this.p.parser.maxNode)
-                   this.buffer.push(type, start, end, 4);
-           }
-       }
-       // Apply an action
-       /**
-       @internal
-       */
-       apply(action, next, nextStart, nextEnd) {
-           if (action & 65536 /* Action.ReduceFlag */)
-               this.reduce(action);
-           else
-               this.shift(action, next, nextStart, nextEnd);
-       }
-       // Add a prebuilt (reused) node into the buffer.
-       /**
-       @internal
-       */
-       useNode(value, next) {
-           let index = this.p.reused.length - 1;
-           if (index < 0 || this.p.reused[index] != value) {
-               this.p.reused.push(value);
-               index++;
-           }
-           let start = this.pos;
-           this.reducePos = this.pos = start + value.length;
-           this.pushState(next, start);
-           this.buffer.push(index, start, this.reducePos, -1 /* size == -1 means this is a reused value */);
-           if (this.curContext)
-               this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
-       }
-       // Split the stack. Due to the buffer sharing and the fact
-       // that `this.stack` tends to stay quite shallow, this isn't very
-       // expensive.
-       /**
-       @internal
-       */
-       split() {
-           let parent = this;
-           let off = parent.buffer.length;
-           // Because the top of the buffer (after this.pos) may be mutated
-           // to reorder reductions and skipped tokens, and shared buffers
-           // should be immutable, this copies any outstanding skipped tokens
-           // to the new buffer, and puts the base pointer before them.
-           while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
-               off -= 4;
-           let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
-           // Make sure parent points to an actual parent with content, if there is such a parent.
-           while (parent && base == parent.bufferBase)
-               parent = parent.parent;
-           return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
-       }
-       // Try to recover from an error by 'deleting' (ignoring) one token.
-       /**
-       @internal
-       */
-       recoverByDelete(next, nextEnd) {
-           let isNode = next <= this.p.parser.maxNode;
-           if (isNode)
-               this.storeNode(next, this.pos, nextEnd, 4);
-           this.storeNode(0 /* Term.Err */, this.pos, nextEnd, isNode ? 8 : 4);
-           this.pos = this.reducePos = nextEnd;
-           this.score -= 190 /* Recover.Delete */;
-       }
-       /**
-       Check if the given term would be able to be shifted (optionally
-       after some reductions) on this stack. This can be useful for
-       external tokenizers that want to make sure they only provide a
-       given token when it applies.
-       */
-       canShift(term) {
-           for (let sim = new SimulatedStack(this);;) {
-               let action = this.p.parser.stateSlot(sim.state, 4 /* ParseState.DefaultReduce */) || this.p.parser.hasAction(sim.state, term);
-               if (action == 0)
-                   return false;
-               if ((action & 65536 /* Action.ReduceFlag */) == 0)
-                   return true;
-               sim.reduce(action);
-           }
-       }
-       // Apply up to Recover.MaxNext recovery actions that conceptually
-       // inserts some missing token or rule.
-       /**
-       @internal
-       */
-       recoverByInsert(next) {
-           if (this.stack.length >= 300 /* Recover.MaxInsertStackDepth */)
-               return [];
-           let nextStates = this.p.parser.nextStates(this.state);
-           if (nextStates.length > 4 /* Recover.MaxNext */ << 1 || this.stack.length >= 120 /* Recover.DampenInsertStackDepth */) {
-               let best = [];
-               for (let i = 0, s; i < nextStates.length; i += 2) {
-                   if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
-                       best.push(nextStates[i], s);
-               }
-               if (this.stack.length < 120 /* Recover.DampenInsertStackDepth */)
-                   for (let i = 0; best.length < 4 /* Recover.MaxNext */ << 1 && i < nextStates.length; i += 2) {
-                       let s = nextStates[i + 1];
-                       if (!best.some((v, i) => (i & 1) && v == s))
-                           best.push(nextStates[i], s);
-                   }
-               nextStates = best;
-           }
-           let result = [];
-           for (let i = 0; i < nextStates.length && result.length < 4 /* Recover.MaxNext */; i += 2) {
-               let s = nextStates[i + 1];
-               if (s == this.state)
-                   continue;
-               let stack = this.split();
-               stack.pushState(s, this.pos);
-               stack.storeNode(0 /* Term.Err */, stack.pos, stack.pos, 4, true);
-               stack.shiftContext(nextStates[i], this.pos);
-               stack.reducePos = this.pos;
-               stack.score -= 200 /* Recover.Insert */;
-               result.push(stack);
-           }
-           return result;
-       }
-       // Force a reduce, if possible. Return false if that can't
-       // be done.
-       /**
-       @internal
-       */
-       forceReduce() {
-           let { parser } = this.p;
-           let reduce = parser.stateSlot(this.state, 5 /* ParseState.ForcedReduce */);
-           if ((reduce & 65536 /* Action.ReduceFlag */) == 0)
-               return false;
-           if (!parser.validAction(this.state, reduce)) {
-               let depth = reduce >> 19 /* Action.ReduceDepthShift */, term = reduce & 65535 /* Action.ValueMask */;
-               let target = this.stack.length - depth * 3;
-               if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) {
-                   let backup = this.findForcedReduction();
-                   if (backup == null)
-                       return false;
-                   reduce = backup;
-               }
-               this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
-               this.score -= 100 /* Recover.Reduce */;
-           }
-           this.reducePos = this.pos;
-           this.reduce(reduce);
-           return true;
-       }
-       /**
-       Try to scan through the automaton to find some kind of reduction
-       that can be applied. Used when the regular ForcedReduce field
-       isn't a valid action. @internal
-       */
-       findForcedReduction() {
-           let { parser } = this.p, seen = [];
-           let explore = (state, depth) => {
-               if (seen.includes(state))
-                   return;
-               seen.push(state);
-               return parser.allActions(state, (action) => {
-                   if (action & (262144 /* Action.StayFlag */ | 131072 /* Action.GotoFlag */)) ;
-                   else if (action & 65536 /* Action.ReduceFlag */) {
-                       let rDepth = (action >> 19 /* Action.ReduceDepthShift */) - depth;
-                       if (rDepth > 1) {
-                           let term = action & 65535 /* Action.ValueMask */, target = this.stack.length - rDepth * 3;
-                           if (target >= 0 && parser.getGoto(this.stack[target], term, false) >= 0)
-                               return (rDepth << 19 /* Action.ReduceDepthShift */) | 65536 /* Action.ReduceFlag */ | term;
-                       }
-                   }
-                   else {
-                       let found = explore(action, depth + 1);
-                       if (found != null)
-                           return found;
-                   }
-               });
-           };
-           return explore(this.state, 0);
-       }
-       /**
-       @internal
-       */
-       forceAll() {
-           while (!this.p.parser.stateFlag(this.state, 2 /* StateFlag.Accepting */)) {
-               if (!this.forceReduce()) {
-                   this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
-                   break;
-               }
-           }
-           return this;
-       }
-       /**
-       Check whether this state has no further actions (assumed to be a direct descendant of the
-       top state, since any other states must be able to continue
-       somehow). @internal
-       */
-       get deadEnd() {
-           if (this.stack.length != 3)
-               return false;
-           let { parser } = this.p;
-           return parser.data[parser.stateSlot(this.state, 1 /* ParseState.Actions */)] == 65535 /* Seq.End */ &&
-               !parser.stateSlot(this.state, 4 /* ParseState.DefaultReduce */);
-       }
-       /**
-       Restart the stack (put it back in its start state). Only safe
-       when this.stack.length == 3 (state is directly below the top
-       state). @internal
-       */
-       restart() {
-           this.storeNode(0 /* Term.Err */, this.pos, this.pos, 4, true);
-           this.state = this.stack[0];
-           this.stack.length = 0;
-       }
-       /**
-       @internal
-       */
-       sameState(other) {
-           if (this.state != other.state || this.stack.length != other.stack.length)
-               return false;
-           for (let i = 0; i < this.stack.length; i += 3)
-               if (this.stack[i] != other.stack[i])
-                   return false;
-           return true;
-       }
-       /**
-       Get the parser used by this stack.
-       */
-       get parser() { return this.p.parser; }
-       /**
-       Test whether a given dialect (by numeric ID, as exported from
-       the terms file) is enabled.
-       */
-       dialectEnabled(dialectID) { return this.p.parser.dialect.flags[dialectID]; }
-       shiftContext(term, start) {
-           if (this.curContext)
-               this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
-       }
-       reduceContext(term, start) {
-           if (this.curContext)
-               this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
-       }
-       /**
-       @internal
-       */
-       emitContext() {
-           let last = this.buffer.length - 1;
-           if (last < 0 || this.buffer[last] != -3)
-               this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
-       }
-       /**
-       @internal
-       */
-       emitLookAhead() {
-           let last = this.buffer.length - 1;
-           if (last < 0 || this.buffer[last] != -4)
-               this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
-       }
-       updateContext(context) {
-           if (context != this.curContext.context) {
-               let newCx = new StackContext(this.curContext.tracker, context);
-               if (newCx.hash != this.curContext.hash)
-                   this.emitContext();
-               this.curContext = newCx;
-           }
-       }
-       /**
-       @internal
-       */
-       setLookAhead(lookAhead) {
-           if (lookAhead > this.lookAhead) {
-               this.emitLookAhead();
-               this.lookAhead = lookAhead;
-           }
-       }
-       /**
-       @internal
-       */
-       close() {
-           if (this.curContext && this.curContext.tracker.strict)
-               this.emitContext();
-           if (this.lookAhead > 0)
-               this.emitLookAhead();
-       }
-   }
-   class StackContext {
-       constructor(tracker, context) {
-           this.tracker = tracker;
-           this.context = context;
-           this.hash = tracker.strict ? tracker.hash(context) : 0;
-       }
-   }
-   // Used to cheaply run some reductions to scan ahead without mutating
-   // an entire stack
-   class SimulatedStack {
-       constructor(start) {
-           this.start = start;
-           this.state = start.state;
-           this.stack = start.stack;
-           this.base = this.stack.length;
-       }
-       reduce(action) {
-           let term = action & 65535 /* Action.ValueMask */, depth = action >> 19 /* Action.ReduceDepthShift */;
-           if (depth == 0) {
-               if (this.stack == this.start.stack)
-                   this.stack = this.stack.slice();
-               this.stack.push(this.state, 0, 0);
-               this.base += 3;
-           }
-           else {
-               this.base -= (depth - 1) * 3;
-           }
-           let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
-           this.state = goto;
-       }
-   }
-   // This is given to `Tree.build` to build a buffer, and encapsulates
-   // the parent-stack-walking necessary to read the nodes.
-   class StackBufferCursor {
-       constructor(stack, pos, index) {
-           this.stack = stack;
-           this.pos = pos;
-           this.index = index;
-           this.buffer = stack.buffer;
-           if (this.index == 0)
-               this.maybeNext();
-       }
-       static create(stack, pos = stack.bufferBase + stack.buffer.length) {
-           return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
-       }
-       maybeNext() {
-           let next = this.stack.parent;
-           if (next != null) {
-               this.index = this.stack.bufferBase - next.bufferBase;
-               this.stack = next;
-               this.buffer = next.buffer;
-           }
-       }
-       get id() { return this.buffer[this.index - 4]; }
-       get start() { return this.buffer[this.index - 3]; }
-       get end() { return this.buffer[this.index - 2]; }
-       get size() { return this.buffer[this.index - 1]; }
-       next() {
-           this.index -= 4;
-           this.pos -= 4;
-           if (this.index == 0)
-               this.maybeNext();
-       }
-       fork() {
-           return new StackBufferCursor(this.stack, this.pos, this.index);
-       }
-   }
-
-   // See lezer-generator/src/encode.ts for comments about the encoding
-   // used here
-   function decodeArray(input, Type = Uint16Array) {
-       if (typeof input != "string")
-           return input;
-       let array = null;
-       for (let pos = 0, out = 0; pos < input.length;) {
-           let value = 0;
-           for (;;) {
-               let next = input.charCodeAt(pos++), stop = false;
-               if (next == 126 /* Encode.BigValCode */) {
-                   value = 65535 /* Encode.BigVal */;
-                   break;
-               }
-               if (next >= 92 /* Encode.Gap2 */)
-                   next--;
-               if (next >= 34 /* Encode.Gap1 */)
-                   next--;
-               let digit = next - 32 /* Encode.Start */;
-               if (digit >= 46 /* Encode.Base */) {
-                   digit -= 46 /* Encode.Base */;
-                   stop = true;
-               }
-               value += digit;
-               if (stop)
-                   break;
-               value *= 46 /* Encode.Base */;
-           }
-           if (array)
-               array[out++] = value;
-           else
-               array = new Type(value);
-       }
-       return array;
-   }
-
-   class CachedToken {
-       constructor() {
-           this.start = -1;
-           this.value = -1;
-           this.end = -1;
-           this.extended = -1;
-           this.lookAhead = 0;
-           this.mask = 0;
-           this.context = 0;
-       }
-   }
-   const nullToken = new CachedToken;
-   /**
-   [Tokenizers](#lr.ExternalTokenizer) interact with the input
-   through this interface. It presents the input as a stream of
-   characters, tracking lookahead and hiding the complexity of
-   [ranges](#common.Parser.parse^ranges) from tokenizer code.
-   */
-   class InputStream {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       @internal
-       */
-       input, 
-       /**
-       @internal
-       */
-       ranges) {
-           this.input = input;
-           this.ranges = ranges;
-           /**
-           @internal
-           */
-           this.chunk = "";
-           /**
-           @internal
-           */
-           this.chunkOff = 0;
-           /**
-           Backup chunk
-           */
-           this.chunk2 = "";
-           this.chunk2Pos = 0;
-           /**
-           The character code of the next code unit in the input, or -1
-           when the stream is at the end of the input.
-           */
-           this.next = -1;
-           /**
-           @internal
-           */
-           this.token = nullToken;
-           this.rangeIndex = 0;
-           this.pos = this.chunkPos = ranges[0].from;
-           this.range = ranges[0];
-           this.end = ranges[ranges.length - 1].to;
-           this.readNext();
-       }
-       /**
-       @internal
-       */
-       resolveOffset(offset, assoc) {
-           let range = this.range, index = this.rangeIndex;
-           let pos = this.pos + offset;
-           while (pos < range.from) {
-               if (!index)
-                   return null;
-               let next = this.ranges[--index];
-               pos -= range.from - next.to;
-               range = next;
-           }
-           while (assoc < 0 ? pos > range.to : pos >= range.to) {
-               if (index == this.ranges.length - 1)
-                   return null;
-               let next = this.ranges[++index];
-               pos += next.from - range.to;
-               range = next;
-           }
-           return pos;
-       }
-       /**
-       @internal
-       */
-       clipPos(pos) {
-           if (pos >= this.range.from && pos < this.range.to)
-               return pos;
-           for (let range of this.ranges)
-               if (range.to > pos)
-                   return Math.max(pos, range.from);
-           return this.end;
-       }
-       /**
-       Look at a code unit near the stream position. `.peek(0)` equals
-       `.next`, `.peek(-1)` gives you the previous character, and so
-       on.
-       
-       Note that looking around during tokenizing creates dependencies
-       on potentially far-away content, which may reduce the
-       effectiveness incremental parsing—when looking forward—or even
-       cause invalid reparses when looking backward more than 25 code
-       units, since the library does not track lookbehind.
-       */
-       peek(offset) {
-           let idx = this.chunkOff + offset, pos, result;
-           if (idx >= 0 && idx < this.chunk.length) {
-               pos = this.pos + offset;
-               result = this.chunk.charCodeAt(idx);
-           }
-           else {
-               let resolved = this.resolveOffset(offset, 1);
-               if (resolved == null)
-                   return -1;
-               pos = resolved;
-               if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
-                   result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
-               }
-               else {
-                   let i = this.rangeIndex, range = this.range;
-                   while (range.to <= pos)
-                       range = this.ranges[++i];
-                   this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
-                   if (pos + this.chunk2.length > range.to)
-                       this.chunk2 = this.chunk2.slice(0, range.to - pos);
-                   result = this.chunk2.charCodeAt(0);
-               }
-           }
-           if (pos >= this.token.lookAhead)
-               this.token.lookAhead = pos + 1;
-           return result;
-       }
-       /**
-       Accept a token. By default, the end of the token is set to the
-       current stream position, but you can pass an offset (relative to
-       the stream position) to change that.
-       */
-       acceptToken(token, endOffset = 0) {
-           let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
-           if (end == null || end < this.token.start)
-               throw new RangeError("Token end out of bounds");
-           this.token.value = token;
-           this.token.end = end;
-       }
-       /**
-       Accept a token ending at a specific given position.
-       */
-       acceptTokenTo(token, endPos) {
-           this.token.value = token;
-           this.token.end = endPos;
-       }
-       getChunk() {
-           if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
-               let { chunk, chunkPos } = this;
-               this.chunk = this.chunk2;
-               this.chunkPos = this.chunk2Pos;
-               this.chunk2 = chunk;
-               this.chunk2Pos = chunkPos;
-               this.chunkOff = this.pos - this.chunkPos;
-           }
-           else {
-               this.chunk2 = this.chunk;
-               this.chunk2Pos = this.chunkPos;
-               let nextChunk = this.input.chunk(this.pos);
-               let end = this.pos + nextChunk.length;
-               this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
-               this.chunkPos = this.pos;
-               this.chunkOff = 0;
-           }
-       }
-       readNext() {
-           if (this.chunkOff >= this.chunk.length) {
-               this.getChunk();
-               if (this.chunkOff == this.chunk.length)
-                   return this.next = -1;
-           }
-           return this.next = this.chunk.charCodeAt(this.chunkOff);
-       }
-       /**
-       Move the stream forward N (defaults to 1) code units. Returns
-       the new value of [`next`](#lr.InputStream.next).
-       */
-       advance(n = 1) {
-           this.chunkOff += n;
-           while (this.pos + n >= this.range.to) {
-               if (this.rangeIndex == this.ranges.length - 1)
-                   return this.setDone();
-               n -= this.range.to - this.pos;
-               this.range = this.ranges[++this.rangeIndex];
-               this.pos = this.range.from;
-           }
-           this.pos += n;
-           if (this.pos >= this.token.lookAhead)
-               this.token.lookAhead = this.pos + 1;
-           return this.readNext();
-       }
-       setDone() {
-           this.pos = this.chunkPos = this.end;
-           this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
-           this.chunk = "";
-           return this.next = -1;
-       }
-       /**
-       @internal
-       */
-       reset(pos, token) {
-           if (token) {
-               this.token = token;
-               token.start = pos;
-               token.lookAhead = pos + 1;
-               token.value = token.extended = -1;
-           }
-           else {
-               this.token = nullToken;
-           }
-           if (this.pos != pos) {
-               this.pos = pos;
-               if (pos == this.end) {
-                   this.setDone();
-                   return this;
-               }
-               while (pos < this.range.from)
-                   this.range = this.ranges[--this.rangeIndex];
-               while (pos >= this.range.to)
-                   this.range = this.ranges[++this.rangeIndex];
-               if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
-                   this.chunkOff = pos - this.chunkPos;
-               }
-               else {
-                   this.chunk = "";
-                   this.chunkOff = 0;
-               }
-               this.readNext();
-           }
-           return this;
-       }
-       /**
-       @internal
-       */
-       read(from, to) {
-           if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
-               return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
-           if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
-               return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
-           if (from >= this.range.from && to <= this.range.to)
-               return this.input.read(from, to);
-           let result = "";
-           for (let r of this.ranges) {
-               if (r.from >= to)
-                   break;
-               if (r.to > from)
-                   result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
-           }
-           return result;
-       }
-   }
-   /**
-   @internal
-   */
-   class TokenGroup {
-       constructor(data, id) {
-           this.data = data;
-           this.id = id;
-       }
-       token(input, stack) {
-           let { parser } = stack.p;
-           readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable);
-       }
-   }
-   TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
-   /**
-   @hide
-   */
-   class LocalTokenGroup {
-       constructor(data, precTable, elseToken) {
-           this.precTable = precTable;
-           this.elseToken = elseToken;
-           this.data = typeof data == "string" ? decodeArray(data) : data;
-       }
-       token(input, stack) {
-           let start = input.pos, skipped = 0;
-           for (;;) {
-               let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
-               readToken(this.data, input, stack, 0, this.data, this.precTable);
-               if (input.token.value > -1)
-                   break;
-               if (this.elseToken == null)
-                   return;
-               if (!atEof)
-                   skipped++;
-               if (nextPos == null)
-                   break;
-               input.reset(nextPos, input.token);
-           }
-           if (skipped) {
-               input.reset(start, input.token);
-               input.acceptToken(this.elseToken, skipped);
-           }
-       }
-   }
-   LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
-   /**
-   `@external tokens` declarations in the grammar should resolve to
-   an instance of this class.
-   */
-   class ExternalTokenizer {
-       /**
-       Create a tokenizer. The first argument is the function that,
-       given an input stream, scans for the types of tokens it
-       recognizes at the stream's position, and calls
-       [`acceptToken`](#lr.InputStream.acceptToken) when it finds
-       one.
-       */
-       constructor(
-       /**
-       @internal
-       */
-       token, options = {}) {
-           this.token = token;
-           this.contextual = !!options.contextual;
-           this.fallback = !!options.fallback;
-           this.extend = !!options.extend;
-       }
-   }
-   // Tokenizer data is stored a big uint16 array containing, for each
-   // state:
-   //
-   //  - A group bitmask, indicating what token groups are reachable from
-   //    this state, so that paths that can only lead to tokens not in
-   //    any of the current groups can be cut off early.
-   //
-   //  - The position of the end of the state's sequence of accepting
-   //    tokens
-   //
-   //  - The number of outgoing edges for the state
-   //
-   //  - The accepting tokens, as (token id, group mask) pairs
-   //
-   //  - The outgoing edges, as (start character, end character, state
-   //    index) triples, with end character being exclusive
-   //
-   // This function interprets that data, running through a stream as
-   // long as new states with the a matching group mask can be reached,
-   // and updating `input.token` when it matches a token.
-   function readToken(data, input, stack, group, precTable, precOffset) {
-       let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
-       scan: for (;;) {
-           if ((groupMask & data[state]) == 0)
-               break;
-           let accEnd = data[state + 1];
-           // Check whether this state can lead to a token in the current group
-           // Accept tokens in this state, possibly overwriting
-           // lower-precedence / shorter tokens
-           for (let i = state + 3; i < accEnd; i += 2)
-               if ((data[i + 1] & groupMask) > 0) {
-                   let term = data[i];
-                   if (dialect.allows(term) &&
-                       (input.token.value == -1 || input.token.value == term ||
-                           overrides(term, input.token.value, precTable, precOffset))) {
-                       input.acceptToken(term);
-                       break;
-                   }
-               }
-           let next = input.next, low = 0, high = data[state + 2];
-           // Special case for EOF
-           if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 /* Seq.End */) {
-               state = data[accEnd + high * 3 - 1];
-               continue scan;
-           }
-           // Do a binary search on the state's edges
-           for (; low < high;) {
-               let mid = (low + high) >> 1;
-               let index = accEnd + mid + (mid << 1);
-               let from = data[index], to = data[index + 1] || 0x10000;
-               if (next < from)
-                   high = mid;
-               else if (next >= to)
-                   low = mid + 1;
-               else {
-                   state = data[index + 2];
-                   input.advance();
-                   continue scan;
-               }
-           }
-           break;
-       }
-   }
-   function findOffset(data, start, term) {
-       for (let i = start, next; (next = data[i]) != 65535 /* Seq.End */; i++)
-           if (next == term)
-               return i - start;
-       return -1;
-   }
-   function overrides(token, prev, tableData, tableOffset) {
-       let iPrev = findOffset(tableData, tableOffset, prev);
-       return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
-   }
-
-   // Environment variable used to control console output
-   const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
-   let stackIDs = null;
-   function cutAt(tree, pos, side) {
-       let cursor = tree.cursor(IterMode.IncludeAnonymous);
-       cursor.moveTo(pos);
-       for (;;) {
-           if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
-               for (;;) {
-                   if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
-                       return side < 0 ? Math.max(0, Math.min(cursor.to - 1, pos - 25 /* Lookahead.Margin */))
-                           : Math.min(tree.length, Math.max(cursor.from + 1, pos + 25 /* Lookahead.Margin */));
-                   if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
-                       break;
-                   if (!cursor.parent())
-                       return side < 0 ? 0 : tree.length;
-               }
-       }
-   }
-   class FragmentCursor {
-       constructor(fragments, nodeSet) {
-           this.fragments = fragments;
-           this.nodeSet = nodeSet;
-           this.i = 0;
-           this.fragment = null;
-           this.safeFrom = -1;
-           this.safeTo = -1;
-           this.trees = [];
-           this.start = [];
-           this.index = [];
-           this.nextFragment();
-       }
-       nextFragment() {
-           let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
-           if (fr) {
-               this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
-               this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
-               while (this.trees.length) {
-                   this.trees.pop();
-                   this.start.pop();
-                   this.index.pop();
-               }
-               this.trees.push(fr.tree);
-               this.start.push(-fr.offset);
-               this.index.push(0);
-               this.nextStart = this.safeFrom;
-           }
-           else {
-               this.nextStart = 1e9;
-           }
-       }
-       // `pos` must be >= any previously given `pos` for this cursor
-       nodeAt(pos) {
-           if (pos < this.nextStart)
-               return null;
-           while (this.fragment && this.safeTo <= pos)
-               this.nextFragment();
-           if (!this.fragment)
-               return null;
-           for (;;) {
-               let last = this.trees.length - 1;
-               if (last < 0) { // End of tree
-                   this.nextFragment();
-                   return null;
-               }
-               let top = this.trees[last], index = this.index[last];
-               if (index == top.children.length) {
-                   this.trees.pop();
-                   this.start.pop();
-                   this.index.pop();
-                   continue;
-               }
-               let next = top.children[index];
-               let start = this.start[last] + top.positions[index];
-               if (start > pos) {
-                   this.nextStart = start;
-                   return null;
-               }
-               if (next instanceof Tree) {
-                   if (start == pos) {
-                       if (start < this.safeFrom)
-                           return null;
-                       let end = start + next.length;
-                       if (end <= this.safeTo) {
-                           let lookAhead = next.prop(NodeProp.lookAhead);
-                           if (!lookAhead || end + lookAhead < this.fragment.to)
-                               return next;
-                       }
-                   }
-                   this.index[last]++;
-                   if (start + next.length >= Math.max(this.safeFrom, pos)) { // Enter this node
-                       this.trees.push(next);
-                       this.start.push(start);
-                       this.index.push(0);
-                   }
-               }
-               else {
-                   this.index[last]++;
-                   this.nextStart = start + next.length;
-               }
-           }
-       }
-   }
-   class TokenCache {
-       constructor(parser, stream) {
-           this.stream = stream;
-           this.tokens = [];
-           this.mainToken = null;
-           this.actions = [];
-           this.tokens = parser.tokenizers.map(_ => new CachedToken);
-       }
-       getActions(stack) {
-           let actionIndex = 0;
-           let main = null;
-           let { parser } = stack.p, { tokenizers } = parser;
-           let mask = parser.stateSlot(stack.state, 3 /* ParseState.TokenizerMask */);
-           let context = stack.curContext ? stack.curContext.hash : 0;
-           let lookAhead = 0;
-           for (let i = 0; i < tokenizers.length; i++) {
-               if (((1 << i) & mask) == 0)
-                   continue;
-               let tokenizer = tokenizers[i], token = this.tokens[i];
-               if (main && !tokenizer.fallback)
-                   continue;
-               if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
-                   this.updateCachedToken(token, tokenizer, stack);
-                   token.mask = mask;
-                   token.context = context;
-               }
-               if (token.lookAhead > token.end + 25 /* Lookahead.Margin */)
-                   lookAhead = Math.max(token.lookAhead, lookAhead);
-               if (token.value != 0 /* Term.Err */) {
-                   let startIndex = actionIndex;
-                   if (token.extended > -1)
-                       actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
-                   actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
-                   if (!tokenizer.extend) {
-                       main = token;
-                       if (actionIndex > startIndex)
-                           break;
-                   }
-               }
-           }
-           while (this.actions.length > actionIndex)
-               this.actions.pop();
-           if (lookAhead)
-               stack.setLookAhead(lookAhead);
-           if (!main && stack.pos == this.stream.end) {
-               main = new CachedToken;
-               main.value = stack.p.parser.eofTerm;
-               main.start = main.end = stack.pos;
-               actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
-           }
-           this.mainToken = main;
-           return this.actions;
-       }
-       getMainToken(stack) {
-           if (this.mainToken)
-               return this.mainToken;
-           let main = new CachedToken, { pos, p } = stack;
-           main.start = pos;
-           main.end = Math.min(pos + 1, p.stream.end);
-           main.value = pos == p.stream.end ? p.parser.eofTerm : 0 /* Term.Err */;
-           return main;
-       }
-       updateCachedToken(token, tokenizer, stack) {
-           let start = this.stream.clipPos(stack.pos);
-           tokenizer.token(this.stream.reset(start, token), stack);
-           if (token.value > -1) {
-               let { parser } = stack.p;
-               for (let i = 0; i < parser.specialized.length; i++)
-                   if (parser.specialized[i] == token.value) {
-                       let result = parser.specializers[i](this.stream.read(token.start, token.end), stack);
-                       if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
-                           if ((result & 1) == 0 /* Specialize.Specialize */)
-                               token.value = result >> 1;
-                           else
-                               token.extended = result >> 1;
-                           break;
-                       }
-                   }
-           }
-           else {
-               token.value = 0 /* Term.Err */;
-               token.end = this.stream.clipPos(start + 1);
-           }
-       }
-       putAction(action, token, end, index) {
-           // Don't add duplicate actions
-           for (let i = 0; i < index; i += 3)
-               if (this.actions[i] == action)
-                   return index;
-           this.actions[index++] = action;
-           this.actions[index++] = token;
-           this.actions[index++] = end;
-           return index;
-       }
-       addActions(stack, token, end, index) {
-           let { state } = stack, { parser } = stack.p, { data } = parser;
-           for (let set = 0; set < 2; set++) {
-               for (let i = parser.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */);; i += 3) {
-                   if (data[i] == 65535 /* Seq.End */) {
-                       if (data[i + 1] == 1 /* Seq.Next */) {
-                           i = pair(data, i + 2);
-                       }
-                       else {
-                           if (index == 0 && data[i + 1] == 2 /* Seq.Other */)
-                               index = this.putAction(pair(data, i + 2), token, end, index);
-                           break;
-                       }
-                   }
-                   if (data[i] == token)
-                       index = this.putAction(pair(data, i + 1), token, end, index);
-               }
-           }
-           return index;
-       }
-   }
-   class Parse {
-       constructor(parser, input, fragments, ranges) {
-           this.parser = parser;
-           this.input = input;
-           this.ranges = ranges;
-           this.recovering = 0;
-           this.nextStackID = 0x2654; // ♔, ♕, ♖, ♗, ♘, ♙, ♠, ♡, ♢, ♣, ♤, ♥, ♦, ♧
-           this.minStackPos = 0;
-           this.reused = [];
-           this.stoppedAt = null;
-           this.lastBigReductionStart = -1;
-           this.lastBigReductionSize = 0;
-           this.bigReductionCount = 0;
-           this.stream = new InputStream(input, ranges);
-           this.tokens = new TokenCache(parser, this.stream);
-           this.topTerm = parser.top[1];
-           let { from } = ranges[0];
-           this.stacks = [Stack.start(this, parser.top[0], from)];
-           this.fragments = fragments.length && this.stream.end - from > parser.bufferLength * 4
-               ? new FragmentCursor(fragments, parser.nodeSet) : null;
-       }
-       get parsedPos() {
-           return this.minStackPos;
-       }
-       // Move the parser forward. This will process all parse stacks at
-       // `this.pos` and try to advance them to a further position. If no
-       // stack for such a position is found, it'll start error-recovery.
-       //
-       // When the parse is finished, this will return a syntax tree. When
-       // not, it returns `null`.
-       advance() {
-           let stacks = this.stacks, pos = this.minStackPos;
-           // This will hold stacks beyond `pos`.
-           let newStacks = this.stacks = [];
-           let stopped, stoppedTokens;
-           // If a large amount of reductions happened with the same start
-           // position, force the stack out of that production in order to
-           // avoid creating a tree too deep to recurse through.
-           // (This is an ugly kludge, because unfortunately there is no
-           // straightforward, cheap way to check for this happening, due to
-           // the history of reductions only being available in an
-           // expensive-to-access format in the stack buffers.)
-           if (this.bigReductionCount > 300 /* Rec.MaxLeftAssociativeReductionCount */ && stacks.length == 1) {
-               let [s] = stacks;
-               while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) { }
-               this.bigReductionCount = this.lastBigReductionSize = 0;
-           }
-           // Keep advancing any stacks at `pos` until they either move
-           // forward or can't be advanced. Gather stacks that can't be
-           // advanced further in `stopped`.
-           for (let i = 0; i < stacks.length; i++) {
-               let stack = stacks[i];
-               for (;;) {
-                   this.tokens.mainToken = null;
-                   if (stack.pos > pos) {
-                       newStacks.push(stack);
-                   }
-                   else if (this.advanceStack(stack, newStacks, stacks)) {
-                       continue;
-                   }
-                   else {
-                       if (!stopped) {
-                           stopped = [];
-                           stoppedTokens = [];
-                       }
-                       stopped.push(stack);
-                       let tok = this.tokens.getMainToken(stack);
-                       stoppedTokens.push(tok.value, tok.end);
-                   }
-                   break;
-               }
-           }
-           if (!newStacks.length) {
-               let finished = stopped && findFinished(stopped);
-               if (finished) {
-                   if (verbose)
-                       console.log("Finish with " + this.stackID(finished));
-                   return this.stackToTree(finished);
-               }
-               if (this.parser.strict) {
-                   if (verbose && stopped)
-                       console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
-                   throw new SyntaxError("No parse at " + pos);
-               }
-               if (!this.recovering)
-                   this.recovering = 5 /* Rec.Distance */;
-           }
-           if (this.recovering && stopped) {
-               let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0]
-                   : this.runRecovery(stopped, stoppedTokens, newStacks);
-               if (finished) {
-                   if (verbose)
-                       console.log("Force-finish " + this.stackID(finished));
-                   return this.stackToTree(finished.forceAll());
-               }
-           }
-           if (this.recovering) {
-               let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3 /* Rec.MaxRemainingPerStep */;
-               if (newStacks.length > maxRemaining) {
-                   newStacks.sort((a, b) => b.score - a.score);
-                   while (newStacks.length > maxRemaining)
-                       newStacks.pop();
-               }
-               if (newStacks.some(s => s.reducePos > pos))
-                   this.recovering--;
-           }
-           else if (newStacks.length > 1) {
-               // Prune stacks that are in the same state, or that have been
-               // running without splitting for a while, to avoid getting stuck
-               // with multiple successful stacks running endlessly on.
-               outer: for (let i = 0; i < newStacks.length - 1; i++) {
-                   let stack = newStacks[i];
-                   for (let j = i + 1; j < newStacks.length; j++) {
-                       let other = newStacks[j];
-                       if (stack.sameState(other) ||
-                           stack.buffer.length > 500 /* Rec.MinBufferLengthPrune */ && other.buffer.length > 500 /* Rec.MinBufferLengthPrune */) {
-                           if (((stack.score - other.score) || (stack.buffer.length - other.buffer.length)) > 0) {
-                               newStacks.splice(j--, 1);
-                           }
-                           else {
-                               newStacks.splice(i--, 1);
-                               continue outer;
-                           }
-                       }
-                   }
-               }
-               if (newStacks.length > 12 /* Rec.MaxStackCount */)
-                   newStacks.splice(12 /* Rec.MaxStackCount */, newStacks.length - 12 /* Rec.MaxStackCount */);
-           }
-           this.minStackPos = newStacks[0].pos;
-           for (let i = 1; i < newStacks.length; i++)
-               if (newStacks[i].pos < this.minStackPos)
-                   this.minStackPos = newStacks[i].pos;
-           return null;
-       }
-       stopAt(pos) {
-           if (this.stoppedAt != null && this.stoppedAt < pos)
-               throw new RangeError("Can't move stoppedAt forward");
-           this.stoppedAt = pos;
-       }
-       // Returns an updated version of the given stack, or null if the
-       // stack can't advance normally. When `split` and `stacks` are
-       // given, stacks split off by ambiguous operations will be pushed to
-       // `split`, or added to `stacks` if they move `pos` forward.
-       advanceStack(stack, stacks, split) {
-           let start = stack.pos, { parser } = this;
-           let base = verbose ? this.stackID(stack) + " -> " : "";
-           if (this.stoppedAt != null && start > this.stoppedAt)
-               return stack.forceReduce() ? stack : null;
-           if (this.fragments) {
-               let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
-               for (let cached = this.fragments.nodeAt(start); cached;) {
-                   let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser.getGoto(stack.state, cached.type.id) : -1;
-                   if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
-                       stack.useNode(cached, match);
-                       if (verbose)
-                           console.log(base + this.stackID(stack) + ` (via reuse of ${parser.getName(cached.type.id)})`);
-                       return true;
-                   }
-                   if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
-                       break;
-                   let inner = cached.children[0];
-                   if (inner instanceof Tree && cached.positions[0] == 0)
-                       cached = inner;
-                   else
-                       break;
-               }
-           }
-           let defaultReduce = parser.stateSlot(stack.state, 4 /* ParseState.DefaultReduce */);
-           if (defaultReduce > 0) {
-               stack.reduce(defaultReduce);
-               if (verbose)
-                   console.log(base + this.stackID(stack) + ` (via always-reduce ${parser.getName(defaultReduce & 65535 /* Action.ValueMask */)})`);
-               return true;
-           }
-           if (stack.stack.length >= 8400 /* Rec.CutDepth */) {
-               while (stack.stack.length > 6000 /* Rec.CutTo */ && stack.forceReduce()) { }
-           }
-           let actions = this.tokens.getActions(stack);
-           for (let i = 0; i < actions.length;) {
-               let action = actions[i++], term = actions[i++], end = actions[i++];
-               let last = i == actions.length || !split;
-               let localStack = last ? stack : stack.split();
-               let main = this.tokens.mainToken;
-               localStack.apply(action, term, main ? main.start : localStack.pos, end);
-               if (verbose)
-                   console.log(base + this.stackID(localStack) + ` (via ${(action & 65536 /* Action.ReduceFlag */) == 0 ? "shift"
-                    : `reduce of ${parser.getName(action & 65535 /* Action.ValueMask */)}`} for ${parser.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
-               if (last)
-                   return true;
-               else if (localStack.pos > start)
-                   stacks.push(localStack);
-               else
-                   split.push(localStack);
-           }
-           return false;
-       }
-       // Advance a given stack forward as far as it will go. Returns the
-       // (possibly updated) stack if it got stuck, or null if it moved
-       // forward and was given to `pushStackDedup`.
-       advanceFully(stack, newStacks) {
-           let pos = stack.pos;
-           for (;;) {
-               if (!this.advanceStack(stack, null, null))
-                   return false;
-               if (stack.pos > pos) {
-                   pushStackDedup(stack, newStacks);
-                   return true;
-               }
-           }
-       }
-       runRecovery(stacks, tokens, newStacks) {
-           let finished = null, restarted = false;
-           for (let i = 0; i < stacks.length; i++) {
-               let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
-               let base = verbose ? this.stackID(stack) + " -> " : "";
-               if (stack.deadEnd) {
-                   if (restarted)
-                       continue;
-                   restarted = true;
-                   stack.restart();
-                   if (verbose)
-                       console.log(base + this.stackID(stack) + " (restarted)");
-                   let done = this.advanceFully(stack, newStacks);
-                   if (done)
-                       continue;
-               }
-               let force = stack.split(), forceBase = base;
-               for (let j = 0; force.forceReduce() && j < 10 /* Rec.ForceReduceLimit */; j++) {
-                   if (verbose)
-                       console.log(forceBase + this.stackID(force) + " (via force-reduce)");
-                   let done = this.advanceFully(force, newStacks);
-                   if (done)
-                       break;
-                   if (verbose)
-                       forceBase = this.stackID(force) + " -> ";
-               }
-               for (let insert of stack.recoverByInsert(token)) {
-                   if (verbose)
-                       console.log(base + this.stackID(insert) + " (via recover-insert)");
-                   this.advanceFully(insert, newStacks);
-               }
-               if (this.stream.end > stack.pos) {
-                   if (tokenEnd == stack.pos) {
-                       tokenEnd++;
-                       token = 0 /* Term.Err */;
-                   }
-                   stack.recoverByDelete(token, tokenEnd);
-                   if (verbose)
-                       console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
-                   pushStackDedup(stack, newStacks);
-               }
-               else if (!finished || finished.score < stack.score) {
-                   finished = stack;
-               }
-           }
-           return finished;
-       }
-       // Convert the stack's buffer to a syntax tree.
-       stackToTree(stack) {
-           stack.close();
-           return Tree.build({ buffer: StackBufferCursor.create(stack),
-               nodeSet: this.parser.nodeSet,
-               topID: this.topTerm,
-               maxBufferLength: this.parser.bufferLength,
-               reused: this.reused,
-               start: this.ranges[0].from,
-               length: stack.pos - this.ranges[0].from,
-               minRepeatType: this.parser.minRepeatTerm });
-       }
-       stackID(stack) {
-           let id = (stackIDs || (stackIDs = new WeakMap)).get(stack);
-           if (!id)
-               stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
-           return id + stack;
-       }
-   }
-   function pushStackDedup(stack, newStacks) {
-       for (let i = 0; i < newStacks.length; i++) {
-           let other = newStacks[i];
-           if (other.pos == stack.pos && other.sameState(stack)) {
-               if (newStacks[i].score < stack.score)
-                   newStacks[i] = stack;
-               return;
-           }
-       }
-       newStacks.push(stack);
-   }
-   class Dialect {
-       constructor(source, flags, disabled) {
-           this.source = source;
-           this.flags = flags;
-           this.disabled = disabled;
-       }
-       allows(term) { return !this.disabled || this.disabled[term] == 0; }
-   }
-   const id = x => x;
-   /**
-   Context trackers are used to track stateful context (such as
-   indentation in the Python grammar, or parent elements in the XML
-   grammar) needed by external tokenizers. You declare them in a
-   grammar file as `@context exportName from "module"`.
-
-   Context values should be immutable, and can be updated (replaced)
-   on shift or reduce actions.
-
-   The export used in a `@context` declaration should be of this
-   type.
-   */
-   class ContextTracker {
-       /**
-       Define a context tracker.
-       */
-       constructor(spec) {
-           this.start = spec.start;
-           this.shift = spec.shift || id;
-           this.reduce = spec.reduce || id;
-           this.reuse = spec.reuse || id;
-           this.hash = spec.hash || (() => 0);
-           this.strict = spec.strict !== false;
-       }
-   }
-   /**
-   Holds the parse tables for a given grammar, as generated by
-   `lezer-generator`, and provides [methods](#common.Parser) to parse
-   content with.
-   */
-   class LRParser extends Parser {
-       /**
-       @internal
-       */
-       constructor(spec) {
-           super();
-           /**
-           @internal
-           */
-           this.wrappers = [];
-           if (spec.version != 14 /* File.Version */)
-               throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14 /* File.Version */})`);
-           let nodeNames = spec.nodeNames.split(" ");
-           this.minRepeatTerm = nodeNames.length;
-           for (let i = 0; i < spec.repeatNodeCount; i++)
-               nodeNames.push("");
-           let topTerms = Object.keys(spec.topRules).map(r => spec.topRules[r][1]);
-           let nodeProps = [];
-           for (let i = 0; i < nodeNames.length; i++)
-               nodeProps.push([]);
-           function setProp(nodeID, prop, value) {
-               nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
-           }
-           if (spec.nodeProps)
-               for (let propSpec of spec.nodeProps) {
-                   let prop = propSpec[0];
-                   if (typeof prop == "string")
-                       prop = NodeProp[prop];
-                   for (let i = 1; i < propSpec.length;) {
-                       let next = propSpec[i++];
-                       if (next >= 0) {
-                           setProp(next, prop, propSpec[i++]);
-                       }
-                       else {
-                           let value = propSpec[i + -next];
-                           for (let j = -next; j > 0; j--)
-                               setProp(propSpec[i++], prop, value);
-                           i++;
-                       }
-                   }
-               }
-           this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType.define({
-               name: i >= this.minRepeatTerm ? undefined : name,
-               id: i,
-               props: nodeProps[i],
-               top: topTerms.indexOf(i) > -1,
-               error: i == 0,
-               skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
-           })));
-           if (spec.propSources)
-               this.nodeSet = this.nodeSet.extend(...spec.propSources);
-           this.strict = false;
-           this.bufferLength = DefaultBufferLength;
-           let tokenArray = decodeArray(spec.tokenData);
-           this.context = spec.context;
-           this.specializerSpecs = spec.specialized || [];
-           this.specialized = new Uint16Array(this.specializerSpecs.length);
-           for (let i = 0; i < this.specializerSpecs.length; i++)
-               this.specialized[i] = this.specializerSpecs[i].term;
-           this.specializers = this.specializerSpecs.map(getSpecializer);
-           this.states = decodeArray(spec.states, Uint32Array);
-           this.data = decodeArray(spec.stateData);
-           this.goto = decodeArray(spec.goto);
-           this.maxTerm = spec.maxTerm;
-           this.tokenizers = spec.tokenizers.map(value => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
-           this.topRules = spec.topRules;
-           this.dialects = spec.dialects || {};
-           this.dynamicPrecedences = spec.dynamicPrecedences || null;
-           this.tokenPrecTable = spec.tokenPrec;
-           this.termNames = spec.termNames || null;
-           this.maxNode = this.nodeSet.types.length - 1;
-           this.dialect = this.parseDialect();
-           this.top = this.topRules[Object.keys(this.topRules)[0]];
-       }
-       createParse(input, fragments, ranges) {
-           let parse = new Parse(this, input, fragments, ranges);
-           for (let w of this.wrappers)
-               parse = w(parse, input, fragments, ranges);
-           return parse;
-       }
-       /**
-       Get a goto table entry @internal
-       */
-       getGoto(state, term, loose = false) {
-           let table = this.goto;
-           if (term >= table[0])
-               return -1;
-           for (let pos = table[term + 1];;) {
-               let groupTag = table[pos++], last = groupTag & 1;
-               let target = table[pos++];
-               if (last && loose)
-                   return target;
-               for (let end = pos + (groupTag >> 1); pos < end; pos++)
-                   if (table[pos] == state)
-                       return target;
-               if (last)
-                   return -1;
-           }
-       }
-       /**
-       Check if this state has an action for a given terminal @internal
-       */
-       hasAction(state, terminal) {
-           let data = this.data;
-           for (let set = 0; set < 2; set++) {
-               for (let i = this.stateSlot(state, set ? 2 /* ParseState.Skip */ : 1 /* ParseState.Actions */), next;; i += 3) {
-                   if ((next = data[i]) == 65535 /* Seq.End */) {
-                       if (data[i + 1] == 1 /* Seq.Next */)
-                           next = data[i = pair(data, i + 2)];
-                       else if (data[i + 1] == 2 /* Seq.Other */)
-                           return pair(data, i + 2);
-                       else
-                           break;
-                   }
-                   if (next == terminal || next == 0 /* Term.Err */)
-                       return pair(data, i + 1);
-               }
-           }
-           return 0;
-       }
-       /**
-       @internal
-       */
-       stateSlot(state, slot) {
-           return this.states[(state * 6 /* ParseState.Size */) + slot];
-       }
-       /**
-       @internal
-       */
-       stateFlag(state, flag) {
-           return (this.stateSlot(state, 0 /* ParseState.Flags */) & flag) > 0;
-       }
-       /**
-       @internal
-       */
-       validAction(state, action) {
-           return !!this.allActions(state, a => a == action ? true : null);
-       }
-       /**
-       @internal
-       */
-       allActions(state, action) {
-           let deflt = this.stateSlot(state, 4 /* ParseState.DefaultReduce */);
-           let result = deflt ? action(deflt) : undefined;
-           for (let i = this.stateSlot(state, 1 /* ParseState.Actions */); result == null; i += 3) {
-               if (this.data[i] == 65535 /* Seq.End */) {
-                   if (this.data[i + 1] == 1 /* Seq.Next */)
-                       i = pair(this.data, i + 2);
-                   else
-                       break;
-               }
-               result = action(pair(this.data, i + 1));
-           }
-           return result;
-       }
-       /**
-       Get the states that can follow this one through shift actions or
-       goto jumps. @internal
-       */
-       nextStates(state) {
-           let result = [];
-           for (let i = this.stateSlot(state, 1 /* ParseState.Actions */);; i += 3) {
-               if (this.data[i] == 65535 /* Seq.End */) {
-                   if (this.data[i + 1] == 1 /* Seq.Next */)
-                       i = pair(this.data, i + 2);
-                   else
-                       break;
-               }
-               if ((this.data[i + 2] & (65536 /* Action.ReduceFlag */ >> 16)) == 0) {
-                   let value = this.data[i + 1];
-                   if (!result.some((v, i) => (i & 1) && v == value))
-                       result.push(this.data[i], value);
-               }
-           }
-           return result;
-       }
-       /**
-       Configure the parser. Returns a new parser instance that has the
-       given settings modified. Settings not provided in `config` are
-       kept from the original parser.
-       */
-       configure(config) {
-           // Hideous reflection-based kludge to make it easy to create a
-           // slightly modified copy of a parser.
-           let copy = Object.assign(Object.create(LRParser.prototype), this);
-           if (config.props)
-               copy.nodeSet = this.nodeSet.extend(...config.props);
-           if (config.top) {
-               let info = this.topRules[config.top];
-               if (!info)
-                   throw new RangeError(`Invalid top rule name ${config.top}`);
-               copy.top = info;
-           }
-           if (config.tokenizers)
-               copy.tokenizers = this.tokenizers.map(t => {
-                   let found = config.tokenizers.find(r => r.from == t);
-                   return found ? found.to : t;
-               });
-           if (config.specializers) {
-               copy.specializers = this.specializers.slice();
-               copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
-                   let found = config.specializers.find(r => r.from == s.external);
-                   if (!found)
-                       return s;
-                   let spec = Object.assign(Object.assign({}, s), { external: found.to });
-                   copy.specializers[i] = getSpecializer(spec);
-                   return spec;
-               });
-           }
-           if (config.contextTracker)
-               copy.context = config.contextTracker;
-           if (config.dialect)
-               copy.dialect = this.parseDialect(config.dialect);
-           if (config.strict != null)
-               copy.strict = config.strict;
-           if (config.wrap)
-               copy.wrappers = copy.wrappers.concat(config.wrap);
-           if (config.bufferLength != null)
-               copy.bufferLength = config.bufferLength;
-           return copy;
-       }
-       /**
-       Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
-       are registered for this parser.
-       */
-       hasWrappers() {
-           return this.wrappers.length > 0;
-       }
-       /**
-       Returns the name associated with a given term. This will only
-       work for all terms when the parser was generated with the
-       `--names` option. By default, only the names of tagged terms are
-       stored.
-       */
-       getName(term) {
-           return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
-       }
-       /**
-       The eof term id is always allocated directly after the node
-       types. @internal
-       */
-       get eofTerm() { return this.maxNode + 1; }
-       /**
-       The type of top node produced by the parser.
-       */
-       get topNode() { return this.nodeSet.types[this.top[1]]; }
-       /**
-       @internal
-       */
-       dynamicPrecedence(term) {
-           let prec = this.dynamicPrecedences;
-           return prec == null ? 0 : prec[term] || 0;
-       }
-       /**
-       @internal
-       */
-       parseDialect(dialect) {
-           let values = Object.keys(this.dialects), flags = values.map(() => false);
-           if (dialect)
-               for (let part of dialect.split(" ")) {
-                   let id = values.indexOf(part);
-                   if (id >= 0)
-                       flags[id] = true;
-               }
-           let disabled = null;
-           for (let i = 0; i < values.length; i++)
-               if (!flags[i]) {
-                   for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535 /* Seq.End */;)
-                       (disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
-               }
-           return new Dialect(dialect, flags, disabled);
-       }
-       /**
-       Used by the output of the parser generator. Not available to
-       user code. @hide
-       */
-       static deserialize(spec) {
-           return new LRParser(spec);
-       }
-   }
-   function pair(data, off) { return data[off] | (data[off + 1] << 16); }
-   function findFinished(stacks) {
-       let best = null;
-       for (let stack of stacks) {
-           let stopped = stack.p.stoppedAt;
-           if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) &&
-               stack.p.parser.stateFlag(stack.state, 2 /* StateFlag.Accepting */) &&
-               (!best || best.score < stack.score))
-               best = stack;
-       }
-       return best;
-   }
-   function getSpecializer(spec) {
-       if (spec.external) {
-           let mask = spec.extend ? 1 /* Specialize.Extend */ : 0 /* Specialize.Specialize */;
-           return (value, stack) => (spec.external(value, stack) << 1) | mask;
-       }
-       return spec.get;
-   }
-
-   let nextTagID = 0;
-   /**
-   Highlighting tags are markers that denote a highlighting category.
-   They are [associated](#highlight.styleTags) with parts of a syntax
-   tree by a language mode, and then mapped to an actual CSS style by
-   a [highlighter](#highlight.Highlighter).
-
-   Because syntax tree node types and highlight styles have to be
-   able to talk the same language, CodeMirror uses a mostly _closed_
-   [vocabulary](#highlight.tags) of syntax tags (as opposed to
-   traditional open string-based systems, which make it hard for
-   highlighting themes to cover all the tokens produced by the
-   various languages).
-
-   It _is_ possible to [define](#highlight.Tag^define) your own
-   highlighting tags for system-internal use (where you control both
-   the language package and the highlighter), but such tags will not
-   be picked up by regular highlighters (though you can derive them
-   from standard tags to allow highlighters to fall back to those).
-   */
-   class Tag {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The optional name of the base tag @internal
-       */
-       name, 
-       /**
-       The set of this tag and all its parent tags, starting with
-       this one itself and sorted in order of decreasing specificity.
-       */
-       set, 
-       /**
-       The base unmodified tag that this one is based on, if it's
-       modified @internal
-       */
-       base, 
-       /**
-       The modifiers applied to this.base @internal
-       */
-       modified) {
-           this.name = name;
-           this.set = set;
-           this.base = base;
-           this.modified = modified;
-           /**
-           @internal
-           */
-           this.id = nextTagID++;
-       }
-       toString() {
-           let { name } = this;
-           for (let mod of this.modified)
-               if (mod.name)
-                   name = `${mod.name}(${name})`;
-           return name;
-       }
-       static define(nameOrParent, parent) {
-           let name = typeof nameOrParent == "string" ? nameOrParent : "?";
-           if (nameOrParent instanceof Tag)
-               parent = nameOrParent;
-           if (parent === null || parent === void 0 ? void 0 : parent.base)
-               throw new Error("Can not derive from a modified tag");
-           let tag = new Tag(name, [], null, []);
-           tag.set.push(tag);
-           if (parent)
-               for (let t of parent.set)
-                   tag.set.push(t);
-           return tag;
-       }
-       /**
-       Define a tag _modifier_, which is a function that, given a tag,
-       will return a tag that is a subtag of the original. Applying the
-       same modifier to a twice tag will return the same value (`m1(t1)
-       == m1(t1)`) and applying multiple modifiers will, regardless or
-       order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
-       
-       When multiple modifiers are applied to a given base tag, each
-       smaller set of modifiers is registered as a parent, so that for
-       example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
-       `m1(m3(t1)`, and so on.
-       */
-       static defineModifier(name) {
-           let mod = new Modifier(name);
-           return (tag) => {
-               if (tag.modified.indexOf(mod) > -1)
-                   return tag;
-               return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
-           };
-       }
-   }
-   let nextModifierID = 0;
-   class Modifier {
-       constructor(name) {
-           this.name = name;
-           this.instances = [];
-           this.id = nextModifierID++;
-       }
-       static get(base, mods) {
-           if (!mods.length)
-               return base;
-           let exists = mods[0].instances.find(t => t.base == base && sameArray$1(mods, t.modified));
-           if (exists)
-               return exists;
-           let set = [], tag = new Tag(base.name, set, base, mods);
-           for (let m of mods)
-               m.instances.push(tag);
-           let configs = powerSet(mods);
-           for (let parent of base.set)
-               if (!parent.modified.length)
-                   for (let config of configs)
-                       set.push(Modifier.get(parent, config));
-           return tag;
-       }
-   }
-   function sameArray$1(a, b) {
-       return a.length == b.length && a.every((x, i) => x == b[i]);
-   }
-   function powerSet(array) {
-       let sets = [[]];
-       for (let i = 0; i < array.length; i++) {
-           for (let j = 0, e = sets.length; j < e; j++) {
-               sets.push(sets[j].concat(array[i]));
-           }
-       }
-       return sets.sort((a, b) => b.length - a.length);
-   }
-   /**
-   This function is used to add a set of tags to a language syntax
-   via [`NodeSet.extend`](#common.NodeSet.extend) or
-   [`LRParser.configure`](#lr.LRParser.configure).
-
-   The argument object maps node selectors to [highlighting
-   tags](#highlight.Tag) or arrays of tags.
-
-   Node selectors may hold one or more (space-separated) node paths.
-   Such a path can be a [node name](#common.NodeType.name), or
-   multiple node names (or `*` wildcards) separated by slash
-   characters, as in `"Block/Declaration/VariableName"`. Such a path
-   matches the final node but only if its direct parent nodes are the
-   other nodes mentioned. A `*` in such a path matches any parent,
-   but only a single level—wildcards that match multiple parents
-   aren't supported, both for efficiency reasons and because Lezer
-   trees make it rather hard to reason about what they would match.)
-
-   A path can be ended with `/...` to indicate that the tag assigned
-   to the node should also apply to all child nodes, even if they
-   match their own style (by default, only the innermost style is
-   used).
-
-   When a path ends in `!`, as in `Attribute!`, no further matching
-   happens for the node's child nodes, and the entire node gets the
-   given style.
-
-   In this notation, node names that contain `/`, `!`, `*`, or `...`
-   must be quoted as JSON strings.
-
-   For example:
-
-   ```javascript
-   parser.withProps(
-     styleTags({
-       // Style Number and BigNumber nodes
-       "Number BigNumber": tags.number,
-       // Style Escape nodes whose parent is String
-       "String/Escape": tags.escape,
-       // Style anything inside Attributes nodes
-       "Attributes!": tags.meta,
-       // Add a style to all content inside Italic nodes
-       "Italic/...": tags.emphasis,
-       // Style InvalidString nodes as both `string` and `invalid`
-       "InvalidString": [tags.string, tags.invalid],
-       // Style the node named "/" as punctuation
-       '"/"': tags.punctuation
-     })
-   )
-   ```
-   */
-   function styleTags(spec) {
-       let byName = Object.create(null);
-       for (let prop in spec) {
-           let tags = spec[prop];
-           if (!Array.isArray(tags))
-               tags = [tags];
-           for (let part of prop.split(" "))
-               if (part) {
-                   let pieces = [], mode = 2 /* Mode.Normal */, rest = part;
-                   for (let pos = 0;;) {
-                       if (rest == "..." && pos > 0 && pos + 3 == part.length) {
-                           mode = 1 /* Mode.Inherit */;
-                           break;
-                       }
-                       let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
-                       if (!m)
-                           throw new RangeError("Invalid path: " + part);
-                       pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
-                       pos += m[0].length;
-                       if (pos == part.length)
-                           break;
-                       let next = part[pos++];
-                       if (pos == part.length && next == "!") {
-                           mode = 0 /* Mode.Opaque */;
-                           break;
-                       }
-                       if (next != "/")
-                           throw new RangeError("Invalid path: " + part);
-                       rest = part.slice(pos);
-                   }
-                   let last = pieces.length - 1, inner = pieces[last];
-                   if (!inner)
-                       throw new RangeError("Invalid path: " + part);
-                   let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);
-                   byName[inner] = rule.sort(byName[inner]);
-               }
-       }
-       return ruleNodeProp.add(byName);
-   }
-   const ruleNodeProp = new NodeProp();
-   class Rule {
-       constructor(tags, mode, context, next) {
-           this.tags = tags;
-           this.mode = mode;
-           this.context = context;
-           this.next = next;
-       }
-       get opaque() { return this.mode == 0 /* Mode.Opaque */; }
-       get inherit() { return this.mode == 1 /* Mode.Inherit */; }
-       sort(other) {
-           if (!other || other.depth < this.depth) {
-               this.next = other;
-               return this;
-           }
-           other.next = this.sort(other.next);
-           return other;
-       }
-       get depth() { return this.context ? this.context.length : 0; }
-   }
-   Rule.empty = new Rule([], 2 /* Mode.Normal */, null);
-   /**
-   Define a [highlighter](#highlight.Highlighter) from an array of
-   tag/class pairs. Classes associated with more specific tags will
-   take precedence.
-   */
-   function tagHighlighter(tags, options) {
-       let map = Object.create(null);
-       for (let style of tags) {
-           if (!Array.isArray(style.tag))
-               map[style.tag.id] = style.class;
-           else
-               for (let tag of style.tag)
-                   map[tag.id] = style.class;
-       }
-       let { scope, all = null } = options || {};
-       return {
-           style: (tags) => {
-               let cls = all;
-               for (let tag of tags) {
-                   for (let sub of tag.set) {
-                       let tagClass = map[sub.id];
-                       if (tagClass) {
-                           cls = cls ? cls + " " + tagClass : tagClass;
-                           break;
-                       }
-                   }
-               }
-               return cls;
-           },
-           scope
-       };
-   }
-   function highlightTags(highlighters, tags) {
-       let result = null;
-       for (let highlighter of highlighters) {
-           let value = highlighter.style(tags);
-           if (value)
-               result = result ? result + " " + value : value;
-       }
-       return result;
-   }
-   /**
-   Highlight the given [tree](#common.Tree) with the given
-   [highlighter](#highlight.Highlighter). Often, the higher-level
-   [`highlightCode`](#highlight.highlightCode) function is easier to
-   use.
-   */
-   function highlightTree(tree, highlighter, 
-   /**
-   Assign styling to a region of the text. Will be called, in order
-   of position, for any ranges where more than zero classes apply.
-   `classes` is a space separated string of CSS classes.
-   */
-   putStyle, 
-   /**
-   The start of the range to highlight.
-   */
-   from = 0, 
-   /**
-   The end of the range.
-   */
-   to = tree.length) {
-       let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
-       builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
-       builder.flush(to);
-   }
-   class HighlightBuilder {
-       constructor(at, highlighters, span) {
-           this.at = at;
-           this.highlighters = highlighters;
-           this.span = span;
-           this.class = "";
-       }
-       startSpan(at, cls) {
-           if (cls != this.class) {
-               this.flush(at);
-               if (at > this.at)
-                   this.at = at;
-               this.class = cls;
-           }
-       }
-       flush(to) {
-           if (to > this.at && this.class)
-               this.span(this.at, to, this.class);
-       }
-       highlightRange(cursor, from, to, inheritedClass, highlighters) {
-           let { type, from: start, to: end } = cursor;
-           if (start >= to || end <= from)
-               return;
-           if (type.isTop)
-               highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
-           let cls = inheritedClass;
-           let rule = getStyleTags(cursor) || Rule.empty;
-           let tagCls = highlightTags(highlighters, rule.tags);
-           if (tagCls) {
-               if (cls)
-                   cls += " ";
-               cls += tagCls;
-               if (rule.mode == 1 /* Mode.Inherit */)
-                   inheritedClass += (inheritedClass ? " " : "") + tagCls;
-           }
-           this.startSpan(Math.max(from, start), cls);
-           if (rule.opaque)
-               return;
-           let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
-           if (mounted && mounted.overlay) {
-               let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
-               let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
-               let hasChild = cursor.firstChild();
-               for (let i = 0, pos = start;; i++) {
-                   let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
-                   let nextPos = next ? next.from + start : end;
-                   let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
-                   if (rangeFrom < rangeTo && hasChild) {
-                       while (cursor.from < rangeTo) {
-                           this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
-                           this.startSpan(Math.min(rangeTo, cursor.to), cls);
-                           if (cursor.to >= nextPos || !cursor.nextSibling())
-                               break;
-                       }
-                   }
-                   if (!next || nextPos > to)
-                       break;
-                   pos = next.to + start;
-                   if (pos > from) {
-                       this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters);
-                       this.startSpan(Math.min(to, pos), cls);
-                   }
-               }
-               if (hasChild)
-                   cursor.parent();
-           }
-           else if (cursor.firstChild()) {
-               if (mounted)
-                   inheritedClass = "";
-               do {
-                   if (cursor.to <= from)
-                       continue;
-                   if (cursor.from >= to)
-                       break;
-                   this.highlightRange(cursor, from, to, inheritedClass, highlighters);
-                   this.startSpan(Math.min(to, cursor.to), cls);
-               } while (cursor.nextSibling());
-               cursor.parent();
-           }
-       }
-   }
-   /**
-   Match a syntax node's [highlight rules](#highlight.styleTags). If
-   there's a match, return its set of tags, and whether it is
-   opaque (uses a `!`) or applies to all child nodes (`/...`).
-   */
-   function getStyleTags(node) {
-       let rule = node.type.prop(ruleNodeProp);
-       while (rule && rule.context && !node.matchContext(rule.context))
-           rule = rule.next;
-       return rule || null;
-   }
-   const t = Tag.define;
-   const comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();
-   /**
-   The default set of highlighting [tags](#highlight.Tag).
-
-   This collection is heavily biased towards programming languages,
-   and necessarily incomplete. A full ontology of syntactic
-   constructs would fill a stack of books, and be impractical to
-   write themes for. So try to make do with this set. If all else
-   fails, [open an
-   issue](https://github.com/codemirror/codemirror.next) to propose a
-   new tag, or [define](#highlight.Tag^define) a local custom tag for
-   your use case.
-
-   Note that it is not obligatory to always attach the most specific
-   tag possible to an element—if your grammar can't easily
-   distinguish a certain type of element (such as a local variable),
-   it is okay to style it as its more general variant (a variable).
-
-   For tags that extend some parent tag, the documentation links to
-   the parent.
-   */
-   const tags = {
-       /**
-       A comment.
-       */
-       comment,
-       /**
-       A line [comment](#highlight.tags.comment).
-       */
-       lineComment: t(comment),
-       /**
-       A block [comment](#highlight.tags.comment).
-       */
-       blockComment: t(comment),
-       /**
-       A documentation [comment](#highlight.tags.comment).
-       */
-       docComment: t(comment),
-       /**
-       Any kind of identifier.
-       */
-       name,
-       /**
-       The [name](#highlight.tags.name) of a variable.
-       */
-       variableName: t(name),
-       /**
-       A type [name](#highlight.tags.name).
-       */
-       typeName: typeName,
-       /**
-       A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
-       */
-       tagName: t(typeName),
-       /**
-       A property or field [name](#highlight.tags.name).
-       */
-       propertyName: propertyName,
-       /**
-       An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
-       */
-       attributeName: t(propertyName),
-       /**
-       The [name](#highlight.tags.name) of a class.
-       */
-       className: t(name),
-       /**
-       A label [name](#highlight.tags.name).
-       */
-       labelName: t(name),
-       /**
-       A namespace [name](#highlight.tags.name).
-       */
-       namespace: t(name),
-       /**
-       The [name](#highlight.tags.name) of a macro.
-       */
-       macroName: t(name),
-       /**
-       A literal value.
-       */
-       literal,
-       /**
-       A string [literal](#highlight.tags.literal).
-       */
-       string,
-       /**
-       A documentation [string](#highlight.tags.string).
-       */
-       docString: t(string),
-       /**
-       A character literal (subtag of [string](#highlight.tags.string)).
-       */
-       character: t(string),
-       /**
-       An attribute value (subtag of [string](#highlight.tags.string)).
-       */
-       attributeValue: t(string),
-       /**
-       A number [literal](#highlight.tags.literal).
-       */
-       number,
-       /**
-       An integer [number](#highlight.tags.number) literal.
-       */
-       integer: t(number),
-       /**
-       A floating-point [number](#highlight.tags.number) literal.
-       */
-       float: t(number),
-       /**
-       A boolean [literal](#highlight.tags.literal).
-       */
-       bool: t(literal),
-       /**
-       Regular expression [literal](#highlight.tags.literal).
-       */
-       regexp: t(literal),
-       /**
-       An escape [literal](#highlight.tags.literal), for example a
-       backslash escape in a string.
-       */
-       escape: t(literal),
-       /**
-       A color [literal](#highlight.tags.literal).
-       */
-       color: t(literal),
-       /**
-       A URL [literal](#highlight.tags.literal).
-       */
-       url: t(literal),
-       /**
-       A language keyword.
-       */
-       keyword,
-       /**
-       The [keyword](#highlight.tags.keyword) for the self or this
-       object.
-       */
-       self: t(keyword),
-       /**
-       The [keyword](#highlight.tags.keyword) for null.
-       */
-       null: t(keyword),
-       /**
-       A [keyword](#highlight.tags.keyword) denoting some atomic value.
-       */
-       atom: t(keyword),
-       /**
-       A [keyword](#highlight.tags.keyword) that represents a unit.
-       */
-       unit: t(keyword),
-       /**
-       A modifier [keyword](#highlight.tags.keyword).
-       */
-       modifier: t(keyword),
-       /**
-       A [keyword](#highlight.tags.keyword) that acts as an operator.
-       */
-       operatorKeyword: t(keyword),
-       /**
-       A control-flow related [keyword](#highlight.tags.keyword).
-       */
-       controlKeyword: t(keyword),
-       /**
-       A [keyword](#highlight.tags.keyword) that defines something.
-       */
-       definitionKeyword: t(keyword),
-       /**
-       A [keyword](#highlight.tags.keyword) related to defining or
-       interfacing with modules.
-       */
-       moduleKeyword: t(keyword),
-       /**
-       An operator.
-       */
-       operator,
-       /**
-       An [operator](#highlight.tags.operator) that dereferences something.
-       */
-       derefOperator: t(operator),
-       /**
-       Arithmetic-related [operator](#highlight.tags.operator).
-       */
-       arithmeticOperator: t(operator),
-       /**
-       Logical [operator](#highlight.tags.operator).
-       */
-       logicOperator: t(operator),
-       /**
-       Bit [operator](#highlight.tags.operator).
-       */
-       bitwiseOperator: t(operator),
-       /**
-       Comparison [operator](#highlight.tags.operator).
-       */
-       compareOperator: t(operator),
-       /**
-       [Operator](#highlight.tags.operator) that updates its operand.
-       */
-       updateOperator: t(operator),
-       /**
-       [Operator](#highlight.tags.operator) that defines something.
-       */
-       definitionOperator: t(operator),
-       /**
-       Type-related [operator](#highlight.tags.operator).
-       */
-       typeOperator: t(operator),
-       /**
-       Control-flow [operator](#highlight.tags.operator).
-       */
-       controlOperator: t(operator),
-       /**
-       Program or markup punctuation.
-       */
-       punctuation,
-       /**
-       [Punctuation](#highlight.tags.punctuation) that separates
-       things.
-       */
-       separator: t(punctuation),
-       /**
-       Bracket-style [punctuation](#highlight.tags.punctuation).
-       */
-       bracket,
-       /**
-       Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
-       tokens).
-       */
-       angleBracket: t(bracket),
-       /**
-       Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
-       tokens).
-       */
-       squareBracket: t(bracket),
-       /**
-       Parentheses (usually `(` and `)` tokens). Subtag of
-       [bracket](#highlight.tags.bracket).
-       */
-       paren: t(bracket),
-       /**
-       Braces (usually `{` and `}` tokens). Subtag of
-       [bracket](#highlight.tags.bracket).
-       */
-       brace: t(bracket),
-       /**
-       Content, for example plain text in XML or markup documents.
-       */
-       content,
-       /**
-       [Content](#highlight.tags.content) that represents a heading.
-       */
-       heading,
-       /**
-       A level 1 [heading](#highlight.tags.heading).
-       */
-       heading1: t(heading),
-       /**
-       A level 2 [heading](#highlight.tags.heading).
-       */
-       heading2: t(heading),
-       /**
-       A level 3 [heading](#highlight.tags.heading).
-       */
-       heading3: t(heading),
-       /**
-       A level 4 [heading](#highlight.tags.heading).
-       */
-       heading4: t(heading),
-       /**
-       A level 5 [heading](#highlight.tags.heading).
-       */
-       heading5: t(heading),
-       /**
-       A level 6 [heading](#highlight.tags.heading).
-       */
-       heading6: t(heading),
-       /**
-       A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
-       */
-       contentSeparator: t(content),
-       /**
-       [Content](#highlight.tags.content) that represents a list.
-       */
-       list: t(content),
-       /**
-       [Content](#highlight.tags.content) that represents a quote.
-       */
-       quote: t(content),
-       /**
-       [Content](#highlight.tags.content) that is emphasized.
-       */
-       emphasis: t(content),
-       /**
-       [Content](#highlight.tags.content) that is styled strong.
-       */
-       strong: t(content),
-       /**
-       [Content](#highlight.tags.content) that is part of a link.
-       */
-       link: t(content),
-       /**
-       [Content](#highlight.tags.content) that is styled as code or
-       monospace.
-       */
-       monospace: t(content),
-       /**
-       [Content](#highlight.tags.content) that has a strike-through
-       style.
-       */
-       strikethrough: t(content),
-       /**
-       Inserted text in a change-tracking format.
-       */
-       inserted: t(),
-       /**
-       Deleted text.
-       */
-       deleted: t(),
-       /**
-       Changed text.
-       */
-       changed: t(),
-       /**
-       An invalid or unsyntactic element.
-       */
-       invalid: t(),
-       /**
-       Metadata or meta-instruction.
-       */
-       meta,
-       /**
-       [Metadata](#highlight.tags.meta) that applies to the entire
-       document.
-       */
-       documentMeta: t(meta),
-       /**
-       [Metadata](#highlight.tags.meta) that annotates or adds
-       attributes to a given syntactic element.
-       */
-       annotation: t(meta),
-       /**
-       Processing instruction or preprocessor directive. Subtag of
-       [meta](#highlight.tags.meta).
-       */
-       processingInstruction: t(meta),
-       /**
-       [Modifier](#highlight.Tag^defineModifier) that indicates that a
-       given element is being defined. Expected to be used with the
-       various [name](#highlight.tags.name) tags.
-       */
-       definition: Tag.defineModifier("definition"),
-       /**
-       [Modifier](#highlight.Tag^defineModifier) that indicates that
-       something is constant. Mostly expected to be used with
-       [variable names](#highlight.tags.variableName).
-       */
-       constant: Tag.defineModifier("constant"),
-       /**
-       [Modifier](#highlight.Tag^defineModifier) used to indicate that
-       a [variable](#highlight.tags.variableName) or [property
-       name](#highlight.tags.propertyName) is being called or defined
-       as a function.
-       */
-       function: Tag.defineModifier("function"),
-       /**
-       [Modifier](#highlight.Tag^defineModifier) that can be applied to
-       [names](#highlight.tags.name) to indicate that they belong to
-       the language's standard environment.
-       */
-       standard: Tag.defineModifier("standard"),
-       /**
-       [Modifier](#highlight.Tag^defineModifier) that indicates a given
-       [names](#highlight.tags.name) is local to some scope.
-       */
-       local: Tag.defineModifier("local"),
-       /**
-       A generic variant [modifier](#highlight.Tag^defineModifier) that
-       can be used to tag language-specific alternative variants of
-       some common tag. It is recommended for themes to define special
-       forms of at least the [string](#highlight.tags.string) and
-       [variable name](#highlight.tags.variableName) tags, since those
-       come up a lot.
-       */
-       special: Tag.defineModifier("special")
-   };
-   for (let name in tags) {
-       let val = tags[name];
-       if (val instanceof Tag)
-           val.name = name;
-   }
-   /**
-   This is a highlighter that adds stable, predictable classes to
-   tokens, for styling with external CSS.
-
-   The following tags are mapped to their name prefixed with `"tok-"`
-   (for example `"tok-comment"`):
-
-   * [`link`](#highlight.tags.link)
-   * [`heading`](#highlight.tags.heading)
-   * [`emphasis`](#highlight.tags.emphasis)
-   * [`strong`](#highlight.tags.strong)
-   * [`keyword`](#highlight.tags.keyword)
-   * [`atom`](#highlight.tags.atom)
-   * [`bool`](#highlight.tags.bool)
-   * [`url`](#highlight.tags.url)
-   * [`labelName`](#highlight.tags.labelName)
-   * [`inserted`](#highlight.tags.inserted)
-   * [`deleted`](#highlight.tags.deleted)
-   * [`literal`](#highlight.tags.literal)
-   * [`string`](#highlight.tags.string)
-   * [`number`](#highlight.tags.number)
-   * [`variableName`](#highlight.tags.variableName)
-   * [`typeName`](#highlight.tags.typeName)
-   * [`namespace`](#highlight.tags.namespace)
-   * [`className`](#highlight.tags.className)
-   * [`macroName`](#highlight.tags.macroName)
-   * [`propertyName`](#highlight.tags.propertyName)
-   * [`operator`](#highlight.tags.operator)
-   * [`comment`](#highlight.tags.comment)
-   * [`meta`](#highlight.tags.meta)
-   * [`punctuation`](#highlight.tags.punctuation)
-   * [`invalid`](#highlight.tags.invalid)
-
-   In addition, these mappings are provided:
-
-   * [`regexp`](#highlight.tags.regexp),
-     [`escape`](#highlight.tags.escape), and
-     [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
-     are mapped to `"tok-string2"`
-   * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
-     to `"tok-variableName2"`
-   * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
-     to `"tok-variableName tok-local"`
-   * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
-     to `"tok-variableName tok-definition"`
-   * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
-     to `"tok-propertyName tok-definition"`
-   */
-   tagHighlighter([
-       { tag: tags.link, class: "tok-link" },
-       { tag: tags.heading, class: "tok-heading" },
-       { tag: tags.emphasis, class: "tok-emphasis" },
-       { tag: tags.strong, class: "tok-strong" },
-       { tag: tags.keyword, class: "tok-keyword" },
-       { tag: tags.atom, class: "tok-atom" },
-       { tag: tags.bool, class: "tok-bool" },
-       { tag: tags.url, class: "tok-url" },
-       { tag: tags.labelName, class: "tok-labelName" },
-       { tag: tags.inserted, class: "tok-inserted" },
-       { tag: tags.deleted, class: "tok-deleted" },
-       { tag: tags.literal, class: "tok-literal" },
-       { tag: tags.string, class: "tok-string" },
-       { tag: tags.number, class: "tok-number" },
-       { tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" },
-       { tag: tags.variableName, class: "tok-variableName" },
-       { tag: tags.local(tags.variableName), class: "tok-variableName tok-local" },
-       { tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" },
-       { tag: tags.special(tags.variableName), class: "tok-variableName2" },
-       { tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" },
-       { tag: tags.typeName, class: "tok-typeName" },
-       { tag: tags.namespace, class: "tok-namespace" },
-       { tag: tags.className, class: "tok-className" },
-       { tag: tags.macroName, class: "tok-macroName" },
-       { tag: tags.propertyName, class: "tok-propertyName" },
-       { tag: tags.operator, class: "tok-operator" },
-       { tag: tags.comment, class: "tok-comment" },
-       { tag: tags.meta, class: "tok-meta" },
-       { tag: tags.invalid, class: "tok-invalid" },
-       { tag: tags.punctuation, class: "tok-punctuation" }
-   ]);
-
-   // This file was generated by lezer-generator. You probably shouldn't edit it.
-   const noSemi = 314,
-     noSemiType = 315,
-     incdec = 1,
-     incdecPrefix = 2,
-     questionDot = 3,
-     JSXStartTag = 4,
-     insertSemi = 316,
-     spaces = 318,
-     newline = 319,
-     LineComment = 5,
-     BlockComment = 6,
-     Dialect_jsx = 0;
-
-   /* Hand-written tokenizers for JavaScript tokens that can't be
-      expressed by lezer's built-in tokenizer. */
-
-   const space = [9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200,
-                  8201, 8202, 8232, 8233, 8239, 8287, 12288];
-
-   const braceR = 125, semicolon = 59, slash = 47, star = 42, plus = 43, minus = 45, lt = 60, comma = 44,
-         question = 63, dot = 46, bracketL = 91;
-
-   const trackNewline = new ContextTracker({
-     start: false,
-     shift(context, term) {
-       return term == LineComment || term == BlockComment || term == spaces ? context : term == newline
-     },
-     strict: false
-   });
-
-   const insertSemicolon = new ExternalTokenizer((input, stack) => {
-     let {next} = input;
-     if (next == braceR || next == -1 || stack.context)
-       input.acceptToken(insertSemi);
-   }, {contextual: true, fallback: true});
-
-   const noSemicolon = new ExternalTokenizer((input, stack) => {
-     let {next} = input, after;
-     if (space.indexOf(next) > -1) return
-     if (next == slash && ((after = input.peek(1)) == slash || after == star)) return
-     if (next != braceR && next != semicolon && next != -1 && !stack.context)
-       input.acceptToken(noSemi);
-   }, {contextual: true});
-
-   const noSemicolonType = new ExternalTokenizer((input, stack) => {
-     if (input.next == bracketL && !stack.context) input.acceptToken(noSemiType);
-   }, {contextual: true});
-
-   const operatorToken = new ExternalTokenizer((input, stack) => {
-     let {next} = input;
-     if (next == plus || next == minus) {
-       input.advance();
-       if (next == input.next) {
-         input.advance();
-         let mayPostfix = !stack.context && stack.canShift(incdec);
-         input.acceptToken(mayPostfix ? incdec : incdecPrefix);
-       }
-     } else if (next == question && input.peek(1) == dot) {
-       input.advance(); input.advance();
-       if (input.next < 48 || input.next > 57) // No digit after
-         input.acceptToken(questionDot);
-     }
-   }, {contextual: true});
-
-   function identifierChar(ch, start) {
-     return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch == 95 || ch >= 192 ||
-       !start && ch >= 48 && ch <= 57
-   }
-
-   const jsx = new ExternalTokenizer((input, stack) => {
-     if (input.next != lt || !stack.dialectEnabled(Dialect_jsx)) return
-     input.advance();
-     if (input.next == slash) return
-     // Scan for an identifier followed by a comma or 'extends', don't
-     // treat this as a start tag if present.
-     let back = 0;
-     while (space.indexOf(input.next) > -1) { input.advance(); back++; }
-     if (identifierChar(input.next, true)) {
-       input.advance();
-       back++;
-       while (identifierChar(input.next, false)) { input.advance(); back++; }
-       while (space.indexOf(input.next) > -1) { input.advance(); back++; }
-       if (input.next == comma) return
-       for (let i = 0;; i++) {
-         if (i == 7) {
-           if (!identifierChar(input.next, true)) return
-           break
-         }
-         if (input.next != "extends".charCodeAt(i)) break
-         input.advance();
-         back++;
-       }
-     }
-     input.acceptToken(JSXStartTag, -back);
-   });
-
-   const jsHighlight = styleTags({
-     "get set async static": tags.modifier,
-     "for while do if else switch try catch finally return throw break continue default case": tags.controlKeyword,
-     "in of await yield void typeof delete instanceof": tags.operatorKeyword,
-     "let var const using function class extends": tags.definitionKeyword,
-     "import export from": tags.moduleKeyword,
-     "with debugger as new": tags.keyword,
-     TemplateString: tags.special(tags.string),
-     super: tags.atom,
-     BooleanLiteral: tags.bool,
-     this: tags.self,
-     null: tags.null,
-     Star: tags.modifier,
-     VariableName: tags.variableName,
-     "CallExpression/VariableName TaggedTemplateExpression/VariableName": tags.function(tags.variableName),
-     VariableDefinition: tags.definition(tags.variableName),
-     Label: tags.labelName,
-     PropertyName: tags.propertyName,
-     PrivatePropertyName: tags.special(tags.propertyName),
-     "CallExpression/MemberExpression/PropertyName": tags.function(tags.propertyName),
-     "FunctionDeclaration/VariableDefinition": tags.function(tags.definition(tags.variableName)),
-     "ClassDeclaration/VariableDefinition": tags.definition(tags.className),
-     "NewExpression/VariableName": tags.className,
-     PropertyDefinition: tags.definition(tags.propertyName),
-     PrivatePropertyDefinition: tags.definition(tags.special(tags.propertyName)),
-     UpdateOp: tags.updateOperator,
-     "LineComment Hashbang": tags.lineComment,
-     BlockComment: tags.blockComment,
-     Number: tags.number,
-     String: tags.string,
-     Escape: tags.escape,
-     ArithOp: tags.arithmeticOperator,
-     LogicOp: tags.logicOperator,
-     BitOp: tags.bitwiseOperator,
-     CompareOp: tags.compareOperator,
-     RegExp: tags.regexp,
-     Equals: tags.definitionOperator,
-     Arrow: tags.function(tags.punctuation),
-     ": Spread": tags.punctuation,
-     "( )": tags.paren,
-     "[ ]": tags.squareBracket,
-     "{ }": tags.brace,
-     "InterpolationStart InterpolationEnd": tags.special(tags.brace),
-     ".": tags.derefOperator,
-     ", ;": tags.separator,
-     "@": tags.meta,
-
-     TypeName: tags.typeName,
-     TypeDefinition: tags.definition(tags.typeName),
-     "type enum interface implements namespace module declare": tags.definitionKeyword,
-     "abstract global Privacy readonly override": tags.modifier,
-     "is keyof unique infer asserts": tags.operatorKeyword,
-
-     JSXAttributeValue: tags.attributeValue,
-     JSXText: tags.content,
-     "JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag": tags.angleBracket,
-     "JSXIdentifier JSXNameSpacedName": tags.tagName,
-     "JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName": tags.attributeName,
-     "JSXBuiltin/JSXIdentifier": tags.standard(tags.tagName)
-   });
-
-   // This file was generated by lezer-generator. You probably shouldn't edit it.
-   const spec_identifier = {__proto__:null,export:20, as:25, from:33, default:36, async:41, function:42, const:52, extends:56, this:60, true:68, false:68, null:80, void:84, typeof:88, super:104, new:138, delete:150, yield:159, await:163, class:168, public:231, private:231, protected:231, readonly:233, instanceof:252, satisfies:255, in:256, import:290, keyof:347, unique:351, infer:357, asserts:393, is:395, abstract:415, implements:417, type:419, let:422, var:424, using:427, interface:433, enum:437, namespace:443, module:445, declare:449, global:453, for:472, of:481, while:484, with:488, do:492, if:496, else:498, switch:502, case:508, try:514, catch:518, finally:522, return:526, throw:530, break:534, continue:538, debugger:542};
-   const spec_word = {__proto__:null,async:125, get:127, set:129, declare:191, public:193, private:193, protected:193, static:195, abstract:197, override:199, readonly:205, accessor:207, new:399};
-   const spec_LessThan = {__proto__:null,"<":189};
-   const parser = LRParser.deserialize({
-     version: 14,
-     states: "$EOQ%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#D_O.QQlO'#DeO.bQlO'#DpO%[QlO'#DxO0fQlO'#EQOOQ!0Lf'#EY'#EYO1PQ`O'#EVOOQO'#En'#EnOOQO'#Ij'#IjO1XQ`O'#GrO1dQ`O'#EmO1iQ`O'#EmO3hQ!0MxO'#JpO6[Q!0MxO'#JqO6uQ`O'#F[O6zQ,UO'#FsOOQ!0Lf'#Fe'#FeO7VO7dO'#FeO7eQMhO'#F{O9UQ`O'#FzOOQ!0Lf'#Jq'#JqOOQ!0Lb'#Jp'#JpO9ZQ`O'#GvOOQ['#K]'#K]O9fQ`O'#IWO9kQ!0LrO'#IXOOQ['#J^'#J^OOQ['#I]'#I]Q`QlOOQ`QlOOO9sQ!L^O'#DtO9zQlO'#D|O:RQlO'#EOO9aQ`O'#GrO:YQMhO'#CoO:hQ`O'#ElO:sQ`O'#EwO:xQMhO'#FdO;gQ`O'#GrOOQO'#K^'#K^O;lQ`O'#K^O;zQ`O'#GzO;zQ`O'#G{O;zQ`O'#G}O9aQ`O'#HQO<qQ`O'#HTO>YQ`O'#CeO>jQ`O'#HaO>rQ`O'#HgO>rQ`O'#HiO`QlO'#HkO>rQ`O'#HmO>rQ`O'#HpO>wQ`O'#HvO>|Q!0LsO'#H|O%[QlO'#IOO?XQ!0LsO'#IQO?dQ!0LsO'#ISO9kQ!0LrO'#IUO?oQ!0MxO'#CiO@qQpO'#DjQOQ`OOO%[QlO'#EOOAXQ`O'#ERO:YQMhO'#ElOAdQ`O'#ElOAoQ!bO'#FdOOQ['#Cg'#CgOOQ!0Lb'#Do'#DoOOQ!0Lb'#Jt'#JtO%[QlO'#JtOOQO'#Jw'#JwOOQO'#If'#IfOBoQpO'#EeOOQ!0Lb'#Ed'#EdOOQ!0Lb'#J{'#J{OCkQ!0MSO'#EeOCuQpO'#EUOOQO'#Jv'#JvODZQpO'#JwOEhQpO'#EUOCuQpO'#EePEuO&2DjO'#CbPOOO)CD{)CD{OOOO'#I^'#I^OFQO#tO,59UOOQ!0Lh,59U,59UOOOO'#I_'#I_OF`O&jO,59UOFnQ!L^O'#DaOOOO'#Ia'#IaOFuO#@ItO,59yOOQ!0Lf,59y,59yOGTQlO'#IbOGhQ`O'#JrOIgQ!fO'#JrO+}QlO'#JrOInQ`O,5:POJUQ`O'#EnOJcQ`O'#KROJnQ`O'#KQOJnQ`O'#KQOJvQ`O,5;[OJ{Q`O'#KPOOQ!0Ln,5:[,5:[OKSQlO,5:[OMQQ!0MxO,5:dOMqQ`O,5:lON[Q!0LrO'#KOONcQ`O'#J}O9ZQ`O'#J}ONwQ`O'#J}O! PQ`O,5;ZO! UQ`O'#J}O!#ZQ!fO'#JqOOQ!0Lh'#Ci'#CiO%[QlO'#EQO!#yQ!fO,5:qOOQS'#Jx'#JxOOQO-E<h-E<hO9aQ`O,5=^O!$aQ`O,5=^O!$fQlO,5;XO!&iQMhO'#EiO!(SQ`O,5;XO!(XQlO'#DwO!(cQpO,5;bO!(kQpO,5;bO%[QlO,5;bOOQ['#FS'#FSOOQ['#FU'#FUO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cO%[QlO,5;cOOQ['#FY'#FYO!(yQlO,5;sOOQ!0Lf,5;x,5;xOOQ!0Lf,5;y,5;yOOQ!0Lf,5;{,5;{O%[QlO'#InO!*|Q!0LrO,5<hO%[QlO,5;cO!&iQMhO,5;cO!+kQMhO,5;cO!-]QMhO'#E[O%[QlO,5;vOOQ!0Lf,5;z,5;zO!-dQ,UO'#FiO!.aQ,UO'#KVO!-{Q,UO'#KVO!.hQ,UO'#KVOOQO'#KV'#KVO!.|Q,UO,5<ROOOW,5<_,5<_O!/_QlO'#FuOOOW'#Im'#ImO7VO7dO,5<PO!/fQ,UO'#FwOOQ!0Lf,5<P,5<PO!0VQ$IUO'#CwOOQ!0Lh'#C{'#C{O!0jO#@ItO'#DPO!1WQMjO,5<dO!1_Q`O,5<gO!2zQ(CWO'#GWO!3XQ`O'#GXO!3^Q`O'#GXO!4|Q(CWO'#G]O!6RQpO'#GaOOQO'#Gm'#GmO!+rQMhO'#GlOOQO'#Go'#GoO!+rQMhO'#GnO!6tQ$IUO'#JjOOQ!0Lh'#Jj'#JjO!7OQ`O'#JiO!7^Q`O'#JhO!7fQ`O'#CuOOQ!0Lh'#Cy'#CyO!7qQ`O'#C{OOQ!0Lh'#DT'#DTOOQ!0Lh'#DV'#DVO1SQ`O'#DXO!+rQMhO'#GOO!+rQMhO'#GQO!7vQ`O'#GSO!7{Q`O'#GTO!3^Q`O'#GZO!+rQMhO'#G`O;zQ`O'#JiO!8QQ`O'#EoO!8oQ`O,5<fOOQ!0Lb'#Cr'#CrO!8wQ`O'#EpO!9qQpO'#EqOOQ!0Lb'#KP'#KPO!9xQ!0LrO'#K_O9kQ!0LrO,5=bO`QlO,5>rOOQ['#Jf'#JfOOQ[,5>s,5>sOOQ[-E<Z-E<ZO!;wQ!0MxO,5:`O!9lQpO,5:^O!>bQ!0MxO,5:hO%[QlO,5:hO!@xQ!0MxO,5:jOOQO,5@x,5@xO!AiQMhO,5=^O!AwQ!0LrO'#JgO9UQ`O'#JgO!BYQ!0LrO,59ZO!BeQpO,59ZO!BmQMhO,59ZO:YQMhO,59ZO!BxQ`O,5;XO!CQQ`O'#H`O!CfQ`O'#KbO%[QlO,5;|O!9lQpO,5<OO!CnQ`O,5=yO!CsQ`O,5=yO!CxQ`O,5=yO9kQ!0LrO,5=yO;zQ`O,5=iOOQO'#Cw'#CwO!DWQpO,5=fO!D`QMhO,5=gO!DkQ`O,5=iO!DpQ!bO,5=lO!DxQ`O'#K^O>wQ`O'#HVO9aQ`O'#HXO!D}Q`O'#HXO:YQMhO'#HZO!ESQ`O'#HZOOQ[,5=o,5=oO!EXQ`O'#H[O!EjQ`O'#CoO!EoQ`O,59PO!EyQ`O,59PO!HOQlO,59POOQ[,59P,59PO!H`Q!0LrO,59PO%[QlO,59PO!JkQlO'#HcOOQ['#Hd'#HdOOQ['#He'#HeO`QlO,5={O!KRQ`O,5={O`QlO,5>RO`QlO,5>TO!KWQ`O,5>VO`QlO,5>XO!K]Q`O,5>[O!KbQlO,5>bOOQ[,5>h,5>hO%[QlO,5>hO9kQ!0LrO,5>jOOQ[,5>l,5>lO# lQ`O,5>lOOQ[,5>n,5>nO# lQ`O,5>nOOQ[,5>p,5>pO#!YQpO'#D]O%[QlO'#JtO#!{QpO'#JtO##VQpO'#DkO##hQpO'#DkO#%yQlO'#DkO#&QQ`O'#JsO#&YQ`O,5:UO#&_Q`O'#ErO#&mQ`O'#KSO#&uQ`O,5;]O#&zQpO'#DkO#'XQpO'#ETOOQ!0Lf,5:m,5:mO%[QlO,5:mO#'`Q`O,5:mO>wQ`O,5;WO!BeQpO,5;WO!BmQMhO,5;WO:YQMhO,5;WO#'hQ`O,5@`O#'mQ07dO,5:qOOQO-E<d-E<dO#(sQ!0MSO,5;POCuQpO,5:pO#(}QpO,5:pOCuQpO,5;PO!BYQ!0LrO,5:pOOQ!0Lb'#Eh'#EhOOQO,5;P,5;PO%[QlO,5;PO#)[Q!0LrO,5;PO#)gQ!0LrO,5;PO!BeQpO,5:pOOQO,5;V,5;VO#)uQ!0LrO,5;PPOOO'#I['#I[P#*ZO&2DjO,58|POOO,58|,58|OOOO-E<[-E<[OOQ!0Lh1G.p1G.pOOOO-E<]-E<]OOOO,59{,59{O#*fQ!bO,59{OOOO-E<_-E<_OOQ!0Lf1G/e1G/eO#*kQ!fO,5>|O+}QlO,5>|OOQO,5?S,5?SO#*uQlO'#IbOOQO-E<`-E<`O#+SQ`O,5@^O#+[Q!fO,5@^O#+cQ`O,5@lOOQ!0Lf1G/k1G/kO%[QlO,5@mO#+kQ`O'#IhOOQO-E<f-E<fO#+cQ`O,5@lOOQ!0Lb1G0v1G0vOOQ!0Ln1G/v1G/vOOQ!0Ln1G0W1G0WO%[QlO,5@jO#,PQ!0LrO,5@jO#,bQ!0LrO,5@jO#,iQ`O,5@iO9ZQ`O,5@iO#,qQ`O,5@iO#-PQ`O'#IkO#,iQ`O,5@iOOQ!0Lb1G0u1G0uO!(cQpO,5:sO!(nQpO,5:sOOQS,5:u,5:uO#-qQdO,5:uO#-yQMhO1G2xO9aQ`O1G2xOOQ!0Lf1G0s1G0sO#.XQ!0MxO1G0sO#/^Q!0MvO,5;TOOQ!0Lh'#GV'#GVO#/zQ!0MzO'#JjO!$fQlO1G0sO#2VQ!fO'#JuO%[QlO'#JuO#2aQ`O,5:cOOQ!0Lh'#D]'#D]OOQ!0Lf1G0|1G0|O%[QlO1G0|OOQ!0Lf1G1e1G1eO#2fQ`O1G0|O#4zQ!0MxO1G0}O#5RQ!0MxO1G0}O#7iQ!0MxO1G0}O#7pQ!0MxO1G0}O#:WQ!0MxO1G0}O#<nQ!0MxO1G0}O#<uQ!0MxO1G0}O#<|Q!0MxO1G0}O#?dQ!0MxO1G0}O#?kQ!0MxO1G0}O#AxQ?MtO'#CiO#CsQ?MtO1G1_O#CzQ?MtO'#JqO#D_Q!0MxO,5?YOOQ!0Lb-E<l-E<lO#FlQ!0MxO1G0}O#GiQ!0MzO1G0}OOQ!0Lf1G0}1G0}O#HlQMjO'#JzO#HvQ`O,5:vO#H{Q!0MxO1G1bO#IoQ,UO,5<VO#IwQ,UO,5<WO#JPQ,UO'#FnO#JhQ`O'#FmOOQO'#KW'#KWOOQO'#Il'#IlO#JmQ,UO1G1mOOQ!0Lf1G1m1G1mOOOW1G1x1G1xO#KOQ?MtO'#JpO#KYQ`O,5<aO!(yQlO,5<aOOOW-E<k-E<kOOQ!0Lf1G1k1G1kO#K_QpO'#KVOOQ!0Lf,5<c,5<cO#KgQpO,5<cO#KlQMhO'#DROOOO'#I`'#I`O#KsO#@ItO,59kOOQ!0Lh,59k,59kO%[QlO1G2OO!7{Q`O'#IpO#LOQ`O,5<yOOQ!0Lh,5<v,5<vO!+rQMhO'#IsO#LlQMjO,5=WO!+rQMhO'#IuO#M_QMjO,5=YO!&iQMhO,5=[OOQO1G2R1G2RO#MiQ!dO'#CrO#M|Q(CWO'#EpO$ RQpO'#GaO$ iQ!dO,5<rO$ pQ`O'#KYO9ZQ`O'#KYO$!OQ`O,5<tO!+rQMhO,5<sO$!TQ`O'#GYO$!fQ`O,5<sO$!kQ!dO'#GVO$!xQ!dO'#KZO$#SQ`O'#KZO!&iQMhO'#KZO$#XQ`O,5<wO$#^QlO'#JtO$#hQpO'#GbO##hQpO'#GbO$#yQ`O'#GfO!3^Q`O'#GjO$$OQ!0LrO'#IrO$$ZQpO,5<{OOQ!0Lp,5<{,5<{O$$bQpO'#GbO$$oQpO'#GcO$%QQpO'#GcO$%VQMjO,5=WO$%gQMjO,5=YOOQ!0Lh,5=],5=]O!+rQMhO,5@TO!+rQMhO,5@TO$%wQ`O'#IwO$&VQ`O,5@SO$&_Q`O,59aOOQ!0Lh,59g,59gO$'UQ$IYO,59sOOQ!0Lh'#Jn'#JnO$'wQMjO,5<jO$(jQMjO,5<lO@iQ`O,5<nOOQ!0Lh,5<o,5<oO$(tQ`O,5<uO$(yQMjO,5<zO$)ZQ`O,5@TO$)iQ`O'#J}O!$fQlO1G2QO$)nQ`O1G2QO9ZQ`O'#KQO9ZQ`O'#ErO%[QlO'#ErO9ZQ`O'#IyO$)sQ!0LrO,5@yOOQ[1G2|1G2|OOQ[1G4^1G4^OOQ!0Lf1G/z1G/zOOQ!0Lf1G/x1G/xO$+uQ!0MxO1G0SOOQ[1G2x1G2xO!&iQMhO1G2xO%[QlO1G2xO#-|Q`O1G2xO$-yQMhO'#EiOOQ!0Lb,5@R,5@RO$.WQ!0LrO,5@ROOQ[1G.u1G.uO!BYQ!0LrO1G.uO!BeQpO1G.uO!BmQMhO1G.uO$.iQ`O1G0sO$.nQ`O'#CiO$.yQ`O'#KcO$/RQ`O,5=zO$/WQ`O'#KcO$/]Q`O'#KcO$/kQ`O'#JPO$/yQ`O,5@|O$0RQ!fO1G1hOOQ!0Lf1G1j1G1jO9aQ`O1G3eO@iQ`O1G3eO$0YQ`O1G3eO$0_Q`O1G3eOOQ[1G3e1G3eO!DkQ`O1G3TO!&iQMhO1G3QO$0dQ`O1G3QOOQ[1G3R1G3RO!&iQMhO1G3RO$0iQ`O1G3RO$0qQpO'#HPOOQ[1G3T1G3TO!5|QpO'#I{O!DpQ!bO1G3WOOQ[1G3W1G3WOOQ[,5=q,5=qO$0yQMhO,5=sO9aQ`O,5=sO$#yQ`O,5=uO9UQ`O,5=uO!BeQpO,5=uO!BmQMhO,5=uO:YQMhO,5=uO$1XQ`O'#KaO$1dQ`O,5=vOOQ[1G.k1G.kO$1iQ!0LrO1G.kO@iQ`O1G.kO$1tQ`O1G.kO9kQ!0LrO1G.kO$3|Q!fO,5AOO$4ZQ`O,5AOO9ZQ`O,5AOO$4fQlO,5=}O$4mQ`O,5=}OOQ[1G3g1G3gO`QlO1G3gOOQ[1G3m1G3mOOQ[1G3o1G3oO>rQ`O1G3qO$4rQlO1G3sO$8vQlO'#HrOOQ[1G3v1G3vO$9TQ`O'#HxO>wQ`O'#HzOOQ[1G3|1G3|O$9]QlO1G3|O9kQ!0LrO1G4SOOQ[1G4U1G4UOOQ!0Lb'#G^'#G^O9kQ!0LrO1G4WO9kQ!0LrO1G4YO$=dQ`O,5@`O!(yQlO,5;^O9ZQ`O,5;^O>wQ`O,5:VO!(yQlO,5:VO!BeQpO,5:VO$=iQ?MtO,5:VOOQO,5;^,5;^O$=sQpO'#IcO$>ZQ`O,5@_OOQ!0Lf1G/p1G/pO$>cQpO'#IiO$>mQ`O,5@nOOQ!0Lb1G0w1G0wO##hQpO,5:VOOQO'#Ie'#IeO$>uQpO,5:oOOQ!0Ln,5:o,5:oO#'cQ`O1G0XOOQ!0Lf1G0X1G0XO%[QlO1G0XOOQ!0Lf1G0r1G0rO>wQ`O1G0rO!BeQpO1G0rO!BmQMhO1G0rOOQ!0Lb1G5z1G5zO!BYQ!0LrO1G0[OOQO1G0k1G0kO%[QlO1G0kO$>|Q!0LrO1G0kO$?XQ!0LrO1G0kO!BeQpO1G0[OCuQpO1G0[O$?gQ!0LrO1G0kOOQO1G0[1G0[O$?{Q!0MxO1G0kPOOO-E<Y-E<YPOOO1G.h1G.hOOOO1G/g1G/gO$@VQ!bO,5<hO$@_Q!fO1G4hOOQO1G4n1G4nO%[QlO,5>|O$@iQ`O1G5xO$@qQ`O1G6WO$@yQ!fO1G6XO9ZQ`O,5?SO$ATQ!0MxO1G6UO%[QlO1G6UO$AeQ!0LrO1G6UO$AvQ`O1G6TO$AvQ`O1G6TO9ZQ`O1G6TO$BOQ`O,5?VO9ZQ`O,5?VOOQO,5?V,5?VO$BdQ`O,5?VO$)iQ`O,5?VOOQO-E<i-E<iOOQS1G0_1G0_OOQS1G0a1G0aO#-tQ`O1G0aOOQ[7+(d7+(dO!&iQMhO7+(dO%[QlO7+(dO$BrQ`O7+(dO$B}QMhO7+(dO$C]Q!0MzO,5=WO$EhQ!0MzO,5=YO$GsQ!0MzO,5=WO$JUQ!0MzO,5=YO$LgQ!0MzO,59sO$NlQ!0MzO,5<jO%!wQ!0MzO,5<lO%%SQ!0MzO,5<zOOQ!0Lf7+&_7+&_O%'eQ!0MxO7+&_O%(XQlO'#IdO%(fQ`O,5@aO%(nQ!fO,5@aOOQ!0Lf1G/}1G/}O%(xQ`O7+&hOOQ!0Lf7+&h7+&hO%(}Q?MtO,5:dO%[QlO7+&yO%)XQ?MtO,5:`O%)fQ?MtO,5:hO%)pQ?MtO,5:jO%)zQMhO'#IgO%*UQ`O,5@fOOQ!0Lh1G0b1G0bOOQO1G1q1G1qOOQO1G1r1G1rO%*^Q!jO,5<YO!(yQlO,5<XOOQO-E<j-E<jOOQ!0Lf7+'X7+'XOOOW7+'d7+'dOOOW1G1{1G1{O%*iQ`O1G1{OOQ!0Lf1G1}1G1}OOOO,59m,59mO%*nQ!dO,59mOOOO-E<^-E<^OOQ!0Lh1G/V1G/VO%*uQ!0MxO7+'jOOQ!0Lh,5?[,5?[O%+iQMhO1G2eP%+pQ`O'#IpPOQ!0Lh-E<n-E<nO%,^QMjO,5?_OOQ!0Lh-E<q-E<qO%-PQMjO,5?aOOQ!0Lh-E<s-E<sO%-ZQ!dO1G2vO%-bQ!dO'#CrO%-xQMhO'#KQO$#^QlO'#JtOOQ!0Lh1G2^1G2^O%.PQ`O'#IoO%.eQ`O,5@tO%.eQ`O,5@tO%.mQ`O,5@tO%.xQ`O,5@tOOQO1G2`1G2`O%/WQMjO1G2_O!+rQMhO1G2_O%/hQ(CWO'#IqO%/uQ`O,5@uO!&iQMhO,5@uO%/}Q!dO,5@uOOQ!0Lh1G2c1G2cO%2_Q!fO'#CiO%2iQ`O,5=OOOQ!0Lb,5<|,5<|O%2qQpO,5<|OOQ!0Lb,5<},5<}OCfQ`O,5<|O%2|QpO,5<|OOQ!0Lb,5=Q,5=QO$)iQ`O,5=UOOQO,5?^,5?^OOQO-E<p-E<pOOQ!0Lp1G2g1G2gO##hQpO,5<|O$#^QlO,5=OO%3[Q`O,5<}O%3gQpO,5<}O!+rQMhO'#IsO%4aQMjO1G2rO!+rQMhO'#IuO%5SQMjO1G2tO%5^QMjO1G5oO%5hQMjO1G5oOOQO,5?c,5?cOOQO-E<u-E<uOOQO1G.{1G.{O!9lQpO,59uO%[QlO,59uOOQ!0Lh,5<i,5<iO%5uQ`O1G2YO!+rQMhO1G2aO!+rQMhO1G5oO!+rQMhO1G5oO%5zQ!0MxO7+'lOOQ!0Lf7+'l7+'lO!$fQlO7+'lO%6nQ`O,5;^OOQ!0Lb,5?e,5?eOOQ!0Lb-E<w-E<wO%6sQ!dO'#K[O#'cQ`O7+(dO4UQ!fO7+(dO$BuQ`O7+(dO%6}Q!0MvO'#CiO%7nQ!0LrO,5=RO%8PQ!0MvO,5=RO%8dQ`O,5=ROOQ!0Lb1G5m1G5mOOQ[7+$a7+$aO!BYQ!0LrO7+$aO!BeQpO7+$aO!$fQlO7+&_O%8lQ`O'#JOO%9TQ`O,5@}OOQO1G3f1G3fO9aQ`O,5@}O%9TQ`O,5@}O%9]Q`O,5@}OOQO,5?k,5?kOOQO-E<}-E<}OOQ!0Lf7+'S7+'SO%9bQ`O7+)PO9kQ!0LrO7+)PO9aQ`O7+)PO@iQ`O7+)POOQ[7+(o7+(oO%9gQ!0MvO7+(lO!&iQMhO7+(lO!DfQ`O7+(mOOQ[7+(m7+(mO!&iQMhO7+(mO%9qQ`O'#K`O%9|Q`O,5=kOOQO,5?g,5?gOOQO-E<y-E<yOOQ[7+(r7+(rO%;`QpO'#HYOOQ[1G3_1G3_O!&iQMhO1G3_O%[QlO1G3_O%;gQ`O1G3_O%;rQMhO1G3_O9kQ!0LrO1G3aO$#yQ`O1G3aO9UQ`O1G3aO!BeQpO1G3aO!BmQMhO1G3aO%<QQ`O'#I}O%<fQ`O,5@{O%<nQpO,5@{OOQ!0Lb1G3b1G3bOOQ[7+$V7+$VO@iQ`O7+$VO9kQ!0LrO7+$VO%<yQ`O7+$VO%[QlO1G6jO%[QlO1G6kO%=OQ!0LrO1G6jO%=YQlO1G3iO%=aQ`O1G3iO%=fQlO1G3iOOQ[7+)R7+)RO9kQ!0LrO7+)]O`QlO7+)_OOQ['#Kf'#KfOOQ['#JQ'#JQO%=mQlO,5>^OOQ[,5>^,5>^O%[QlO'#HsO%=zQ`O'#HuOOQ[,5>d,5>dO9ZQ`O,5>dOOQ[,5>f,5>fOOQ[7+)h7+)hOOQ[7+)n7+)nOOQ[7+)r7+)rOOQ[7+)t7+)tO%>PQpO1G5zO%>kQ?MtO1G0xO%>uQ`O1G0xOOQO1G/q1G/qO%?QQ?MtO1G/qO>wQ`O1G/qO!(yQlO'#DkOOQO,5>},5>}OOQO-E<a-E<aOOQO,5?T,5?TOOQO-E<g-E<gO!BeQpO1G/qOOQO-E<c-E<cOOQ!0Ln1G0Z1G0ZOOQ!0Lf7+%s7+%sO#'cQ`O7+%sOOQ!0Lf7+&^7+&^O>wQ`O7+&^O!BeQpO7+&^OOQO7+%v7+%vO$?{Q!0MxO7+&VOOQO7+&V7+&VO%[QlO7+&VO%?[Q!0LrO7+&VO!BYQ!0LrO7+%vO!BeQpO7+%vO%?gQ!0LrO7+&VO%?uQ!0MxO7++pO%[QlO7++pO%@VQ`O7++oO%@VQ`O7++oOOQO1G4q1G4qO9ZQ`O1G4qO%@_Q`O1G4qOOQS7+%{7+%{O#'cQ`O<<LOO4UQ!fO<<LOO%@mQ`O<<LOOOQ[<<LO<<LOO!&iQMhO<<LOO%[QlO<<LOO%@uQ`O<<LOO%AQQ!0MzO,5?_O%C]Q!0MzO,5?aO%EhQ!0MzO1G2_O%GyQ!0MzO1G2rO%JUQ!0MzO1G2tO%LaQ!fO,5?OO%[QlO,5?OOOQO-E<b-E<bO%LkQ`O1G5{OOQ!0Lf<<JS<<JSO%LsQ?MtO1G0sO%NzQ?MtO1G0}O& RQ?MtO1G0}O&#SQ?MtO1G0}O&#ZQ?MtO1G0}O&%[Q?MtO1G0}O&']Q?MtO1G0}O&'dQ?MtO1G0}O&'kQ?MtO1G0}O&)lQ?MtO1G0}O&)sQ?MtO1G0}O&)zQ!0MxO<<JeO&+rQ?MtO1G0}O&,oQ?MvO1G0}O&-rQ?MvO'#JjO&/xQ?MtO1G1bO&0VQ?MtO1G0SO&0aQMjO,5?ROOQO-E<e-E<eO!(yQlO'#FpOOQO'#KX'#KXOOQO1G1t1G1tO&0kQ`O1G1sO&0pQ?MtO,5?YOOOW7+'g7+'gOOOO1G/X1G/XO&0zQ!dO1G4vOOQ!0Lh7+(P7+(PP!&iQMhO,5?[O!+rQMhO7+(bO&1RQ`O,5?ZO9ZQ`O,5?ZOOQO-E<m-E<mO&1aQ`O1G6`O&1aQ`O1G6`O&1iQ`O1G6`O&1tQMjO7+'yO&2UQ!dO,5?]O&2`Q`O,5?]O!&iQMhO,5?]OOQO-E<o-E<oO&2eQ!dO1G6aO&2oQ`O1G6aO&2wQ`O1G2jO!&iQMhO1G2jOOQ!0Lb1G2h1G2hOOQ!0Lb1G2i1G2iO%2qQpO1G2hO!BeQpO1G2hOCfQ`O1G2hOOQ!0Lb1G2p1G2pO&2|QpO1G2hO&3[Q`O1G2jO$)iQ`O1G2iOCfQ`O1G2iO$#^QlO1G2jO&3dQ`O1G2iO&4WQMjO,5?_OOQ!0Lh-E<r-E<rO&4yQMjO,5?aOOQ!0Lh-E<t-E<tO!+rQMhO7++ZOOQ!0Lh1G/a1G/aO&5TQ`O1G/aOOQ!0Lh7+'t7+'tO&5YQMjO7+'{O&5jQMjO7++ZO&5tQMjO7++ZO&6RQ!0MxO<<KWOOQ!0Lf<<KW<<KWO&6uQ`O1G0xO!&iQMhO'#IxO&6zQ`O,5@vO&8|Q!fO<<LOO!&iQMhO1G2mO&9TQ!0LrO1G2mOOQ[<<G{<<G{O!BYQ!0LrO<<G{O&9fQ!0MxO<<IyOOQ!0Lf<<Iy<<IyOOQO,5?j,5?jO&:YQ`O,5?jO&:_Q`O,5?jOOQO-E<|-E<|O&:mQ`O1G6iO&:mQ`O1G6iO9aQ`O1G6iO@iQ`O<<LkOOQ[<<Lk<<LkO&:uQ`O<<LkO9kQ!0LrO<<LkOOQ[<<LW<<LWO%9gQ!0MvO<<LWOOQ[<<LX<<LXO!DfQ`O<<LXO&:zQpO'#IzO&;VQ`O,5@zO!(yQlO,5@zOOQ[1G3V1G3VOOQO'#I|'#I|O9kQ!0LrO'#I|O&;_QpO,5=tOOQ[,5=t,5=tO&;fQpO'#EeO&;mQpO'#GdO&;rQ`O7+(yO&;wQ`O7+(yOOQ[7+(y7+(yO!&iQMhO7+(yO%[QlO7+(yO&<PQ`O7+(yOOQ[7+({7+({O9kQ!0LrO7+({O$#yQ`O7+({O9UQ`O7+({O!BeQpO7+({O&<[Q`O,5?iOOQO-E<{-E<{OOQO'#H]'#H]O&<gQ`O1G6gO9kQ!0LrO<<GqOOQ[<<Gq<<GqO@iQ`O<<GqO&<oQ`O7+,UO&<tQ`O7+,VO%[QlO7+,UO%[QlO7+,VOOQ[7+)T7+)TO&<yQ`O7+)TO&=OQlO7+)TO&=VQ`O7+)TOOQ[<<Lw<<LwOOQ[<<Ly<<LyOOQ[-E=O-E=OOOQ[1G3x1G3xO&=[Q`O,5>_OOQ[,5>a,5>aO&=aQ`O1G4OO9ZQ`O7+&dO!(yQlO7+&dOOQO7+%]7+%]O&=fQ?MtO1G6XO>wQ`O7+%]OOQ!0Lf<<I_<<I_OOQ!0Lf<<Ix<<IxO>wQ`O<<IxOOQO<<Iq<<IqO$?{Q!0MxO<<IqO%[QlO<<IqOOQO<<Ib<<IbO!BYQ!0LrO<<IbO&=pQ!0LrO<<IqO&={Q!0MxO<= [O&>]Q`O<= ZOOQO7+*]7+*]O9ZQ`O7+*]OOQ[ANAjANAjO&>eQ!fOANAjO!&iQMhOANAjO#'cQ`OANAjO4UQ!fOANAjO&>lQ`OANAjO%[QlOANAjO&>tQ!0MzO7+'yO&AVQ!0MzO,5?_O&CbQ!0MzO,5?aO&EmQ!0MzO7+'{O&HOQ!fO1G4jO&HYQ?MtO7+&_O&J^Q?MvO,5=WO&LeQ?MvO,5=YO&LuQ?MvO,5=WO&MVQ?MvO,5=YO&MgQ?MvO,59sO' mQ?MvO,5<jO'#pQ?MvO,5<lO'&UQ?MvO,5<zO''zQ?MtO7+'jO'(XQ?MtO7+'lO'(fQ`O,5<[OOQO7+'_7+'_OOQ!0Lh7+*b7+*bO'(kQMjO<<K|OOQO1G4u1G4uO'(rQ`O1G4uO'(}Q`O1G4uO')]Q`O7++zO')]Q`O7++zO!&iQMhO1G4wO')eQ!dO1G4wO')oQ`O7++{O')wQ`O7+(UO'*SQ!dO7+(UOOQ!0Lb7+(S7+(SOOQ!0Lb7+(T7+(TO!BeQpO7+(SOCfQ`O7+(SO'*^Q`O7+(UO!&iQMhO7+(UO$)iQ`O7+(TO'*cQ`O7+(UOCfQ`O7+(TO'*kQMjO<<NuOOQ!0Lh7+${7+${O!+rQMhO<<NuO'*uQ!dO,5?dOOQO-E<v-E<vO'+PQ!0MvO7+(XO!&iQMhO7+(XOOQ[AN=gAN=gO9aQ`O1G5UOOQO1G5U1G5UO'+aQ`O1G5UO'+fQ`O7+,TO'+fQ`O7+,TO9kQ!0LrOANBVO@iQ`OANBVOOQ[ANBVANBVOOQ[ANArANArOOQ[ANAsANAsO'+nQ`O,5?fOOQO-E<x-E<xO'+yQ?MtO1G6fOOQO,5?h,5?hOOQO-E<z-E<zOOQ[1G3`1G3`O',TQ`O,5=OOOQ[<<Le<<LeO!&iQMhO<<LeO&;rQ`O<<LeO',YQ`O<<LeO%[QlO<<LeOOQ[<<Lg<<LgO9kQ!0LrO<<LgO$#yQ`O<<LgO9UQ`O<<LgO',bQpO1G5TO',mQ`O7+,ROOQ[AN=]AN=]O9kQ!0LrOAN=]OOQ[<= p<= pOOQ[<= q<= qO',uQ`O<= pO',zQ`O<= qOOQ[<<Lo<<LoO'-PQ`O<<LoO'-UQlO<<LoOOQ[1G3y1G3yO>wQ`O7+)jO'-]Q`O<<JOO'-hQ?MtO<<JOOOQO<<Hw<<HwOOQ!0LfAN?dAN?dOOQOAN?]AN?]O$?{Q!0MxOAN?]OOQOAN>|AN>|O%[QlOAN?]OOQO<<Mw<<MwOOQ[G27UG27UO!&iQMhOG27UO#'cQ`OG27UO'-rQ!fOG27UO4UQ!fOG27UO'-yQ`OG27UO'.RQ?MtO<<JeO'.`Q?MvO1G2_O'0UQ?MvO,5?_O'2XQ?MvO,5?aO'4[Q?MvO1G2rO'6_Q?MvO1G2tO'8bQ?MtO<<KWO'8oQ?MtO<<IyOOQO1G1v1G1vO!+rQMhOANAhOOQO7+*a7+*aO'8|Q`O7+*aO'9XQ`O<= fO'9aQ!dO7+*cOOQ!0Lb<<Kp<<KpO$)iQ`O<<KpOCfQ`O<<KpO'9kQ`O<<KpO!&iQMhO<<KpOOQ!0Lb<<Kn<<KnO!BeQpO<<KnO'9vQ!dO<<KpOOQ!0Lb<<Ko<<KoO':QQ`O<<KpO!&iQMhO<<KpO$)iQ`O<<KoO':VQMjOANDaO':aQ!0MvO<<KsOOQO7+*p7+*pO9aQ`O7+*pO':qQ`O<= oOOQ[G27qG27qO9kQ!0LrOG27qO!(yQlO1G5QO':yQ`O7+,QO';RQ`O1G2jO&;rQ`OANBPOOQ[ANBPANBPO!&iQMhOANBPO';WQ`OANBPOOQ[ANBRANBRO9kQ!0LrOANBRO$#yQ`OANBROOQO'#H^'#H^OOQO7+*o7+*oOOQ[G22wG22wOOQ[ANE[ANE[OOQ[ANE]ANE]OOQ[ANBZANBZO';`Q`OANBZOOQ[<<MU<<MUO!(yQlOAN?jOOQOG24wG24wO$?{Q!0MxOG24wO#'cQ`OLD,pOOQ[LD,pLD,pO!&iQMhOLD,pO';eQ!fOLD,pO';lQ?MvO7+'yO'=bQ?MvO,5?_O'?eQ?MvO,5?aO'AhQ?MvO7+'{O'C^QMjOG27SOOQO<<M{<<M{OOQ!0LbANA[ANA[O$)iQ`OANA[OCfQ`OANA[O'CnQ!dOANA[OOQ!0LbANAYANAYO'CuQ`OANA[O!&iQMhOANA[O'DQQ!dOANA[OOQ!0LbANAZANAZOOQO<<N[<<N[OOQ[LD-]LD-]O'D[Q?MtO7+*lOOQO'#Ge'#GeOOQ[G27kG27kO&;rQ`OG27kO!&iQMhOG27kOOQ[G27mG27mO9kQ!0LrOG27mOOQ[G27uG27uO'DfQ?MtOG25UOOQOLD*cLD*cOOQ[!$(![!$(![O#'cQ`O!$(![O!&iQMhO!$(![O'DpQ!0MzOG27SOOQ!0LbG26vG26vO$)iQ`OG26vO'GRQ`OG26vOCfQ`OG26vO'G^Q!dOG26vO!&iQMhOG26vOOQ[LD-VLD-VO&;rQ`OLD-VOOQ[LD-XLD-XOOQ[!)9Ev!)9EvO#'cQ`O!)9EvOOQ!0LbLD,bLD,bO$)iQ`OLD,bOCfQ`OLD,bO'GeQ`OLD,bO'GpQ!dOLD,bOOQ[!$(!q!$(!qOOQ[!.K;b!.K;bO'GwQ?MvOG27SOOQ!0Lb!$( |!$( |O$)iQ`O!$( |OCfQ`O!$( |O'ImQ`O!$( |OOQ!0Lb!)9Eh!)9EhO$)iQ`O!)9EhOCfQ`O!)9EhOOQ!0Lb!.K;S!.K;SO$)iQ`O!.K;SOOQ!0Lb!4/0n!4/0nO!(yQlO'#DxO1PQ`O'#EVO'IxQ!fO'#JpO'JPQ!L^O'#DtO'JWQlO'#D|O'J_Q!fO'#CiO'LuQ!fO'#CiO!(yQlO'#EOO'MVQlO,5;XO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO,5;cO!(yQlO'#InO( YQ`O,5<hO!(yQlO,5;cO( bQMhO,5;cO(!{QMhO,5;cO!(yQlO,5;vO!&iQMhO'#GlO( bQMhO'#GlO!&iQMhO'#GnO( bQMhO'#GnO1SQ`O'#DXO1SQ`O'#DXO!&iQMhO'#GOO( bQMhO'#GOO!&iQMhO'#GQO( bQMhO'#GQO!&iQMhO'#G`O( bQMhO'#G`O!(yQlO,5:hO(#SQpO'#D]O(#^QpO'#JtO!(yQlO,5@mO'MVQlO1G0sO(#hQ?MtO'#CiO!(yQlO1G2OO!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO(#rQ!dO'#CrO!&iQMhO,5<sO( bQMhO,5<sO'MVQlO1G2QO!(yQlO7+&yO!&iQMhO1G2_O( bQMhO1G2_O!&iQMhO'#IsO( bQMhO'#IsO!&iQMhO'#IuO( bQMhO'#IuO!&iQMhO1G2aO( bQMhO1G2aO'MVQlO7+'lO'MVQlO7+&_O!&iQMhOANAhO( bQMhOANAhO($VQ`O'#EmO($[Q`O'#EmO($dQ`O'#F[O($iQ`O'#EwO($nQ`O'#KRO($yQ`O'#KPO(%UQ`O,5;XO(%ZQMjO,5<dO(%bQ`O'#GXO(%gQ`O'#GXO(%lQ`O,5<fO(%tQ`O,5;XO(%|Q?MtO1G1_O(&TQ`O,5<sO(&YQ`O,5<sO(&_Q`O,5<uO(&dQ`O,5<uO(&iQ`O1G2QO(&nQ`O1G0sO(&sQMjO<<K|O(&zQMjO<<K|O7eQMhO'#F{O9UQ`O'#FzOAdQ`O'#ElO!(yQlO,5;sO!3^Q`O'#GXO!3^Q`O'#GXO!3^Q`O'#GZO!3^Q`O'#GZO!+rQMhO7+(bO!+rQMhO7+(bO%-ZQ!dO1G2vO%-ZQ!dO1G2vO!&iQMhO,5=[O!&iQMhO,5=[",
-     stateData: "((P~O'zOS'{OSTOS'|RQ~OPYOQYOSfOY!VOaqOdzOeyOj!POnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!swO!vxO!z]O$V|O$miO%g}O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO&U!WO&[!XO&^!YO&`!ZO&b![O&e!]O&k!^O&q!_O&s!`O&u!aO&w!bO&y!cO(RSO(TTO(WUO(_VO(m[O~OWtO~P`OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa!wOq!nO!Q!oO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!xO#U!pO#V!pO#Y!zO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O'|!{O~OP]XR]X[]Xa]Xp]X!O]X!Q]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X'x]X(_]X(p]X(w]X(x]X~O!e%QX~P(qO_!}O(T#PO(U!}O(V#PO~O_#QO(V#PO(W#PO(X#QO~Ov#SO!S#TO(`#TO(a#VO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R;{O(TTO(WUO(_VO(m[O~O!Y#ZO!Z#WO!W(fP!W(tP~P+}O![#cO~P`OPYOQYOSfOd!jOe!iOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(TTO(WUO(_VO(m[O~On#mO!Y#iO!z]O#g#lO#h#iO(R;|O!i(qP~P.iO!j#oO(R#nO~O!v#sO!z]O%g#tO~O#i#uO~O!e#vO#i#uO~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z$_O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa(dX'x(dX'u(dX!i(dX!W(dX!](dX%h(dX!e(dX~P1qO#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX!](eX%h(eX~Oa(eX'x(eX'u(eX!W(eX!i(eXt(eX!e(eX~P4UO#^$eO~O$[$hO$^$gO$e$mO~OSfO!]$nO$h$oO$j$qO~Oh%VOj%cOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R$sO(TTO(WUO(_$uO(w$}O(x%POg([P~O!j%dO~O!Q%gO!]%hO(R%fO~O!e%lO~Oa%mO'x%mO~O!O%qO~P%[O(S!lO~P%[O%m%uO~P%[Oh%VO!j%dO(R%fO(S!lO~Oe%|O!j%dO(R%fO~O#t$RO~O!O&RO!]&OO!j&QO%i&UO(R%fO(S!lO(TTO(WUO`)UP~O!v#sO~O%r&WO!Q)QX!])QX(R)QX~O(R&XO~Oj!PO!s&^O%i!QO%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO~Od&cOe&bO!v&`O%g&aO%z&_O~P<POd&fOeyOj!PO!]&eO!s&^O!vxO!z]O%g}O%k!OO%l!OO%m!OO%p!RO%r!SO%u!TO%v!TO%x!UO~Ob&iO#^&lO%i&gO(S!lO~P=UO!j&mO!s&qO~O!j#oO~O!]XO~Oa%mO'v&yO'x%mO~Oa%mO'v&|O'x%mO~Oa%mO'v'OO'x%mO~O'u]X!W]Xt]X!i]X&Y]X!]]X%h]X!e]X~P(qO!`']O!a'UO!b'UO(S!lO(TTO(WUO~Oq'SO!Q'RO!Y'VO(c'QO![(gP![(vP~P@]Ol'`O!]'^O(R%fO~Oe'eO!j%dO(R%fO~O!O&RO!j&QO~Oq!nO!Q!oO!z;wO#R!pO#S!pO#U!pO#V!pO(S!lO(TTO(WUO(c!mO(m!sO~O!`'kO!a'jO!b'jO#T!pO#Y'lO#Z'lO~PAwOa%mOh%VO!e#vO!j%dO'x%mO(p'nO~O!n'rO#^'pO~PCVOq!nO!Q!oO(TTO(WUO(c!mO(m!sO~O!]XOq(kX!Q(kX!`(kX!a(kX!b(kX!z(kX#R(kX#S(kX#T(kX#U(kX#V(kX#Y(kX#Z(kX(S(kX(T(kX(W(kX(c(kX(m(kX~O!a'jO!b'jO(S!lO~PCuO'}'vO(O'vO(P'xO~O_!}O(T'zO(U!}O(V'zO~O_#QO(V'zO(W'zO(X#QO~Ot'|O~P%[Ov#SO!S#TO(`#TO(a(PO~O!Y(RO!W'UX!W'[X!Z'UX!Z'[X~P+}O!Z(TO!W(fX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!Z(TO!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~O!W(fX~PGpO!W(YO~O!W(sX!Z(sX!e(sX!i(sX(p(sX~O#^(sX#i#bX![(sX~PIsO#^(ZO!W(uX!Z(uX~O!Z([O!W(tX~O!W(_O~O#^$eO~PIsO![(`O~P`OR#zO!O#yO!Q#{O!j#xO(_VOP!la[!lap!la!Z!la!n!la#P!la#l!la#m!la#n!la#o!la#p!la#q!la#r!la#s!la#t!la#u!la#w!la#y!la#z!la(p!la(w!la(x!la~Oa!la'x!la'u!la!W!la!i!lat!la!]!la%h!la!e!la~PKZO!i(aO~O!e#vO#^(bO(p'nO!Z(rXa(rX'x(rX~O!i(rX~PMvO!Q%gO!]%hO!z]O#g(gO#h(fO(R%fO~O!Z(hO!i(qX~O!i(jO~O!Q%gO!]%hO#h(fO(R%fO~OP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#t(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O!e#vO!i(eX~P! dOR(lO!O(kO!j#xO#Q$dO!z!ya!Q!ya~O!v!ya%g!ya!]!ya#g!ya#h!ya(R!ya~P!#eO!v(pO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]XO!guO!jZO!mYO!nYO!oYO!qvO!s!gO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~O#i(vO~O!Y(xO!i(iP~P%[O(c(zO(m[O~O!Q(|O!j#xO(c(zO(m[O~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z$_Oa$pa'x$pa'u$pa!i$pa!W$pa!]$pa%h$pa!e$pa~Oj)bO~P!&iOh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|%[O!Q${O!]$|O!g%aO!j$xO#h%bO$V%_O$s%]O$u%^O$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Og(nP~P!+rO!O)gO!e)fO!]$]X$Y$]X$[$]X$^$]X$e$]X~O!e)fO!](yX$Y(yX$[(yX$^(yX$e(yX~O!O)gO~P!-{O!O)gO!](yX$Y(yX$[(yX$^(yX$e(yX~O!])iO$Y)mO$[)hO$^)hO$e)nO~O!Y)qO~P!(yO$[$hO$^$gO$e)uO~Ol$yX!O$yX#Q$yX'w$yX(w$yX(x$yX~OgkXg$yXlkX!ZkX#^kX~P!/qOv)wO(`)xO(a)zO~Ol*TO!O)|O'w)}O(w$}O(x%PO~Og){O~P!0uOg*UO~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q*WO!]*XO!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~O!Y*[O(R*VO!i(|P~P!1dO#i*^O~O!j*_O~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(R*aO(TTO(WUO(_$uO(w$}O(x%PO~O!Y*dO!W(}P~P!3cOp*pOq!nO!Q*fO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO(c!mO~O![*mO~P!5WO#Q$dOl(^X!O(^X'w(^X(w(^X(x(^X!Z(^X#^(^X~Og(^X#}(^X~P!6YOl*uO#^*tOg(]X!Z(]X~O!Z*vOg([X~Oj%cO(R&XOg([P~Oq*yO~O!j+OO~O(R(tO~On+TO!Q%gO!Y#iO!]%hO!z]O#g#lO#h#iO(R%fO!i(qP~O!e#vO#i+UO~O!Q%gO!Y+WO!Z([O!]%hO(R%fO!W(tP~Oq'YO!Q+YO!Y+XO(TTO(WUO(c(zO~O![(vP~P!9]O!Z+ZOa)RX'x)RX~OP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO#y$WO#z$XO(_VO(p$YO(w#|O(x#}O~Oa!ha!Z!ha'x!ha'u!ha!W!ha!i!hat!ha!]!ha%h!ha!e!ha~P!:TOR#zO!O#yO!Q#{O!j#xO(_VOP!pa[!pap!pa!Z!pa!n!pa#P!pa#l!pa#m!pa#n!pa#o!pa#p!pa#q!pa#r!pa#s!pa#t!pa#u!pa#w!pa#y!pa#z!pa(p!pa(w!pa(x!pa~Oa!pa'x!pa'u!pa!W!pa!i!pat!pa!]!pa%h!pa!e!pa~P!<kOR#zO!O#yO!Q#{O!j#xO(_VOP!ra[!rap!ra!Z!ra!n!ra#P!ra#l!ra#m!ra#n!ra#o!ra#p!ra#q!ra#r!ra#s!ra#t!ra#u!ra#w!ra#y!ra#z!ra(p!ra(w!ra(x!ra~Oa!ra'x!ra'u!ra!W!ra!i!rat!ra!]!ra%h!ra!e!ra~P!?ROh%VOl+dO!]'^O%h+cO~O!e+fOa(ZX!](ZX'x(ZX!Z(ZX~Oa%mO!]XO'x%mO~Oh%VO!j%dO~Oh%VO!j%dO(R%fO~O!e#vO#i(vO~Ob+qO%i+rO(R+nO(TTO(WUO![)VP~O!Z+sO`)UX~O[+wO~O`+xO~O!]&OO(R%fO(S!lO`)UP~Oh%VO#^+}O~Oh%VOl,QO!]$|O~O!],SO~O!O,UO!]XO~O%m%uO~O!v,ZO~Oe,`O~Ob,aO(R#nO(TTO(WUO![)TP~Oe%|O~O%i!QO(R&XO~P=UO[,fO`,eO~OPYOQYOSfOdzOeyOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!guO!jZO!mYO!nYO!oYO!qvO!vxO!z]O$miO%g}O(TTO(WUO(_VO(m[O~O!]!eO!s!gO$V!kO(R!dO~P!FRO`,eOa%mO'x%mO~OPYOQYOSfOd!jOe!iOnkOpYOqkOrkOxkOzYO|YO!QWO!UkO!VkO!]!eO!guO!jZO!mYO!nYO!oYO!qvO!v!hO$V!kO$miO(R!dO(TTO(WUO(_VO(m[O~Oa,kOj!OO!swO%k!OO%l!OO%m!OO~P!HkO!j&mO~O&[,qO~O!],sO~O&m,uO&o,vOP&jaQ&jaS&jaY&jaa&jad&jae&jaj&jan&jap&jaq&jar&jax&jaz&ja|&ja!Q&ja!U&ja!V&ja!]&ja!g&ja!j&ja!m&ja!n&ja!o&ja!q&ja!s&ja!v&ja!z&ja$V&ja$m&ja%g&ja%i&ja%k&ja%l&ja%m&ja%p&ja%r&ja%u&ja%v&ja%x&ja&U&ja&[&ja&^&ja&`&ja&b&ja&e&ja&k&ja&q&ja&s&ja&u&ja&w&ja&y&ja'u&ja(R&ja(T&ja(W&ja(_&ja(m&ja![&ja&c&jab&ja&h&ja~O(R,{O~Oh!cX!Z!PX![!PX!e!PX!e!cX!j!cX#^!PX~O!Z!cX![!cX~P# qO!e-QO#^-POh(hX!Z#fX![#fX!e(hX!j(hX~O!Z(hX![(hX~P#!dOh%VO!e-SO!j%dO!Z!_X![!_X~Oq!nO!Q!oO(TTO(WUO(c!mO~OP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]!eO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(TTO(WUO(_VO(m[O~O(R<rO~P##yO!Z-WO![(gX~O![-YO~O!e-QO#^-PO!Z#fX![#fX~O!Z-ZO![(vX~O![-]O~O!a-^O!b-^O(S!lO~P##hO![-aO~P'_Ol-dO!]'^O~O!W-iO~Oq!ya!`!ya!a!ya!b!ya#R!ya#S!ya#T!ya#U!ya#V!ya#Y!ya#Z!ya(S!ya(T!ya(W!ya(c!ya(m!ya~P!#eO!n-nO#^-lO~PCVO!a-pO!b-pO(S!lO~PCuOa%mO#^-lO'x%mO~Oa%mO!e#vO#^-lO'x%mO~Oa%mO!e#vO!n-nO#^-lO'x%mO(p'nO~O'}'vO(O'vO(P-uO~Ot-vO~O!W'Ua!Z'Ua~P!:TO!Y-zO!W'UX!Z'UX~P%[O!Z(TO!W(fa~O!W(fa~PGpO!Z([O!W(ta~O!Q%gO!Y.OO!]%hO(R%fO!W'[X!Z'[X~O#^.QO!Z(ra!i(raa(ra'x(ra~O!e#vO~P#,PO!Z(hO!i(qa~O!Q%gO!]%hO#h.UO(R%fO~On.ZO!Q%gO!Y.WO!]%hO!z]O#g.YO#h.WO(R%fO!Z'_X!i'_X~OR._O!j#xO~Oh%VOl.bO!]'^O%h.aO~Oa#ai!Z#ai'x#ai'u#ai!W#ai!i#ait#ai!]#ai%h#ai!e#ai~P!:TOl=|O!O)|O'w)}O(w$}O(x%PO~O#i#]aa#]a#^#]a'x#]a!Z#]a!i#]a!]#]a!W#]a~P#.{O#i(^XP(^XR(^X[(^Xa(^Xp(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X'x(^X(_(^X(p(^X!i(^X!W(^X'u(^Xt(^X!](^X%h(^X!e(^X~P!6YO!Z.oO!i(iX~P!:TO!i.rO~O!W.tO~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kia#kip#ki!Z#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#l#ki~P#2kO#l$OO~P#2kOP$[OR#zOp$aO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO[#kia#ki!Z#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#p#ki~P#5YO#p$QO~P#5YOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO(_VOa#ki!Z#ki#w#ki#y#ki#z#ki'x#ki(p#ki(w#ki(x#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#u#ki~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO(_VO(x#}Oa#ki!Z#ki#y#ki#z#ki'x#ki(p#ki(w#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#w$UO~P#:_O#w#ki~P#:_O#u$SO~P#7wOP$[OR#zO[$cOp$aO!O#yO!Q#{O!j#xO!n$[O#P$RO#l$OO#m$PO#n$PO#o$PO#p$QO#q$RO#r$RO#s$bO#t$RO#u$SO#w$UO(_VO(w#|O(x#}Oa#ki!Z#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~O#y#ki~P#=TO#y$WO~P#=TOP]XR]X[]Xp]X!O]X!Q]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X!Z]X![]X~O#}]X~P#?rOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO#y<XO#z<YO(_VO(p$YO(w#|O(x#}O~O#}.vO~P#BPO#Q$dO#^<`O$P<`O#}(eX![(eX~P! dOa'ba!Z'ba'x'ba'u'ba!i'ba!W'bat'ba!]'ba%h'ba!e'ba~P!:TO[#kia#kip#ki!Z#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki'x#ki(p#ki'u#ki!W#ki!i#kit#ki!]#ki%h#ki!e#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l$OO#m$PO#n$PO#o$PO(_VO(w#ki(x#ki~P#EROl=|O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P#ERO!Z.zOg(nX~P!0uOg.|O~Oa$Oi!Z$Oi'x$Oi'u$Oi!W$Oi!i$Oit$Oi!]$Oi%h$Oi!e$Oi~P!:TO$[.}O$^.}O~O$[/OO$^/OO~O!e)fO#^/PO!]$bX$Y$bX$[$bX$^$bX$e$bX~O!Y/QO~O!])iO$Y/SO$[)hO$^)hO$e/TO~O!Z<ZO![(dX~P#BPO![/UO~O!e)fO$e(yX~O$e/WO~Ot/XO~P!&iOv)wO(`)xO(a/[O~O!Q/_O~O(w$}Ol%`a!O%`a'w%`a(x%`a!Z%`a#^%`a~Og%`a#}%`a~P#LTO(x%POl%ba!O%ba'w%ba(w%ba!Z%ba#^%ba~Og%ba#}%ba~P#LvO!ZfX!efX!ifX!i$yX(pfX~P!/qO!Y/hO!Z([O(R/gO!W(tP!W(}P~P!1dOp*pO!`*nO!a*hO!b*hO!j*_O#Y*oO%_*jO(S!lO(TTO(WUO~Oq<oO!Q/iO!Y+XO![*mO(c<nO![(vP~P#NaO!i/jO~P#.{O!Z/kO!e#vO(p'nO!i(|X~O!i/pO~O!Q%gO!Y*[O!]%hO(R%fO!i(|P~O#i/rO~O!W$yX!Z$yX!e%QX~P!/qO!Z/sO!W(}X~P#.{O!e/uO~O!W/wO~OnkO(R/xO~P.iOh%VOp/}O!e#vO!j%dO(p'nO~O!e+fO~Oa%mO!Z0RO'x%mO~O![0TO~P!5WO!a0UO!b0UO(S!lO~P##hOq!nO!Q0VO(TTO(WUO(c!mO~O#Y0XO~Og%`a!Z%`a#^%`a#}%`a~P!0uOg%ba!Z%ba#^%ba#}%ba~P!0uOj%cO(R&XOg'kX!Z'kX~O!Z*vOg([a~Og0bO~OR0cO!O0cO!Q0dO#Q$dOl{a'w{a(w{a(x{a!Z{a#^{a~Og{a#}{a~P$&dO!O)|O'w)}Ol$ra(w$ra(x$ra!Z$ra#^$ra~Og$ra#}$ra~P$'`O!O)|O'w)}Ol$ta(w$ta(x$ta!Z$ta#^$ta~Og$ta#}$ta~P$(RO#i0gO~Og%Sa!Z%Sa#^%Sa#}%Sa~P!0uOl0iO#^0hOg(]a!Z(]a~O!e#vO~O#i0lO~O!Z+ZOa)Ra'x)Ra~OR#zO!O#yO!Q#{O!j#xO(_VOP!pi[!pip!pi!Z!pi!n!pi#P!pi#l!pi#m!pi#n!pi#o!pi#p!pi#q!pi#r!pi#s!pi#t!pi#u!pi#w!pi#y!pi#z!pi(p!pi(w!pi(x!pi~Oa!pi'x!pi'u!pi!W!pi!i!pit!pi!]!pi%h!pi!e!pi~P$*OOh%VOp%XOq$tOr$tOx%YOz%ZO|<eO!Q${O!]$|O!g=vO!j$xO#h<kO$V%_O$s<gO$u<iO$x%`O(TTO(WUO(_$uO(w$}O(x%PO~On0vO%[0wO(R0tO~P$,fO!e+fOa(Za!](Za'x(Za!Z(Za~O#i0|O~O[]X!ZfX![fX~O!Z0}O![)VX~O![1PO~O[1QO~Ob1SO(R+nO(TTO(WUO~O!]&OO(R%fO`'sX!Z'sX~O!Z+sO`)Ua~O!i1VO~P!:TO[1YO~O`1ZO~O#^1^O~Ol1aO!]$|O~O(c(zO![)SP~Oh%VOl1jO!]1gO%h1iO~O[1tO!Z1rO![)TX~O![1uO~O`1wOa%mO'x%mO~O(R#nO(TTO(WUO~O#Q$dO#^$eO$P$eOP(eXR(eX[(eXp(eX!O(eX!Q(eX!Z(eX!j(eX!n(eX#P(eX#l(eX#m(eX#n(eX#o(eX#p(eX#q(eX#r(eX#s(eX#u(eX#w(eX#y(eX#z(eX(_(eX(p(eX(w(eX(x(eX~O#t1zO&Y1{Oa(eX~P$2PO#^$eO#t1zO&Y1{O~Oa1}O~P%[Oa2PO~O&c2SOP&aiQ&aiS&aiY&aia&aid&aie&aij&ain&aip&aiq&air&aix&aiz&ai|&ai!Q&ai!U&ai!V&ai!]&ai!g&ai!j&ai!m&ai!n&ai!o&ai!q&ai!s&ai!v&ai!z&ai$V&ai$m&ai%g&ai%i&ai%k&ai%l&ai%m&ai%p&ai%r&ai%u&ai%v&ai%x&ai&U&ai&[&ai&^&ai&`&ai&b&ai&e&ai&k&ai&q&ai&s&ai&u&ai&w&ai&y&ai'u&ai(R&ai(T&ai(W&ai(_&ai(m&ai![&aib&ai&h&ai~Ob2YO![2WO&h2XO~P`O!]XO!j2[O~O&o,vOP&jiQ&jiS&jiY&jia&jid&jie&jij&jin&jip&jiq&jir&jix&jiz&ji|&ji!Q&ji!U&ji!V&ji!]&ji!g&ji!j&ji!m&ji!n&ji!o&ji!q&ji!s&ji!v&ji!z&ji$V&ji$m&ji%g&ji%i&ji%k&ji%l&ji%m&ji%p&ji%r&ji%u&ji%v&ji%x&ji&U&ji&[&ji&^&ji&`&ji&b&ji&e&ji&k&ji&q&ji&s&ji&u&ji&w&ji&y&ji'u&ji(R&ji(T&ji(W&ji(_&ji(m&ji![&ji&c&jib&ji&h&ji~O!W2bO~O!Z!_a![!_a~P#BPOq!nO!Q!oO!Y2hO(c!mO!Z'VX!['VX~P@]O!Z-WO![(ga~O!Z']X![']X~P!9]O!Z-ZO![(va~O![2oO~P'_Oa%mO#^2xO'x%mO~Oa%mO!e#vO#^2xO'x%mO~Oa%mO!e#vO!n2|O#^2xO'x%mO(p'nO~Oa%mO'x%mO~P!:TO!Z$_Ot$pa~O!W'Ui!Z'Ui~P!:TO!Z(TO!W(fi~O!Z([O!W(ti~O!W(ui!Z(ui~P!:TO!Z(ri!i(ria(ri'x(ri~P!:TO#^3OO!Z(ri!i(ria(ri'x(ri~O!Z(hO!i(qi~O!Q%gO!]%hO!z]O#g3TO#h3SO(R%fO~O!Q%gO!]%hO#h3SO(R%fO~Ol3[O!]'^O%h3ZO~Oh%VOl3[O!]'^O%h3ZO~O#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`at%`a!]%`a%h%`a!e%`a~P#LTO#i%baP%baR%ba[%baa%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%bat%ba!]%ba%h%ba!e%ba~P#LvO#i%`aP%`aR%`a[%`aa%`ap%`a!Q%`a!Z%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a'x%`a(_%`a(p%`a!i%`a!W%`a'u%`a#^%`at%`a!]%`a%h%`a!e%`a~P#.{O#i%baP%baR%ba[%baa%bap%ba!Q%ba!Z%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba'x%ba(_%ba(p%ba!i%ba!W%ba'u%ba#^%bat%ba!]%ba%h%ba!e%ba~P#.{O#i{aP{a[{aa{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a'x{a(_{a(p{a!i{a!W{a'u{at{a!]{a%h{a!e{a~P$&dO#i$raP$raR$ra[$raa$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra'x$ra(_$ra(p$ra!i$ra!W$ra'u$rat$ra!]$ra%h$ra!e$ra~P$'`O#i$taP$taR$ta[$taa$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta'x$ta(_$ta(p$ta!i$ta!W$ta'u$tat$ta!]$ta%h$ta!e$ta~P$(RO#i%SaP%SaR%Sa[%Saa%Sap%Sa!Q%Sa!Z%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa'x%Sa(_%Sa(p%Sa!i%Sa!W%Sa'u%Sa#^%Sat%Sa!]%Sa%h%Sa!e%Sa~P#.{Oa#aq!Z#aq'x#aq'u#aq!W#aq!i#aqt#aq!]#aq%h#aq!e#aq~P!:TO!Y3dO!Z'WX!i'WX~P%[O!Z.oO!i(ia~O!Z.oO!i(ia~P!:TO!W3gO~O#}!la![!la~PKZO#}!ha!Z!ha![!ha~P#BPO#}!pa![!pa~P!<kO#}!ra![!ra~P!?ROg'ZX!Z'ZX~P!+rO!Z.zOg(na~OSfO!]3{O$c3|O~O![4QO~Ot4RO~P#.{Oa$lq!Z$lq'x$lq'u$lq!W$lq!i$lqt$lq!]$lq%h$lq!e$lq~P!:TO!W4TO~P!&iO!Q4UO~O!O)|O'w)}O(x%POl'ga(w'ga!Z'ga#^'ga~Og'ga#}'ga~P%+uO!O)|O'w)}Ol'ia(w'ia(x'ia!Z'ia#^'ia~Og'ia#}'ia~P%,hO(p$YO~P#.{O!WfX!W$yX!ZfX!Z$yX!e%QX#^fX~P!/qO(R<xO~P!1dO!Q%gO!Y4XO!]%hO(R%fO!Z'cX!i'cX~O!Z/kO!i(|a~O!Z/kO!e#vO!i(|a~O!Z/kO!e#vO(p'nO!i(|a~Og${i!Z${i#^${i#}${i~P!0uO!Y4aO!W'eX!Z'eX~P!3cO!Z/sO!W(}a~O!Z/sO!W(}a~P#.{OP]XR]X[]Xp]X!O]X!Q]X!W]X!Z]X!j]X!n]X#P]X#Q]X#^]X#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!e%XX#t%XX~P%0XO!e#vO#t4fO~Oh%VO!e#vO!j%dO~Oh%VOp4kO!j%dO(p'nO~Op4pO!e#vO(p'nO~Oq!nO!Q4qO(TTO(WUO(c!mO~O(w$}Ol%`i!O%`i'w%`i(x%`i!Z%`i#^%`i~Og%`i#}%`i~P%3xO(x%POl%bi!O%bi'w%bi(w%bi!Z%bi#^%bi~Og%bi#}%bi~P%4kOg(]i!Z(]i~P!0uO#^4wOg(]i!Z(]i~P!0uO!i4zO~Oa$nq!Z$nq'x$nq'u$nq!W$nq!i$nqt$nq!]$nq%h$nq!e$nq~P!:TO!W5QO~O!Z5RO!])OX~P#.{Oa]Xa$yX!]]X!]$yX%]]X'x]X'x$yX!Z]X!Z$yX~P!/qO%]5UOa%Za!]%Za'x%Za!Z%Za~OlmX!OmX'wmX(wmX(xmX~P%7nOn5VO(R#nO~Ob5]O%i5^O(R+nO(TTO(WUO!Z'rX!['rX~O!Z0}O![)Va~O[5bO~O`5cO~Oa%mO'x%mO~P#.{O!Z5kO#^5mO![)SX~O![5nO~Op5tOq!nO!Q*fO!`!yO!a!vO!b!vO!z;wO#R!pO#S!pO#T!pO#U!pO#V!pO#Y5sO#Z!zO(S!lO(TTO(WUO(c!mO(m!sO~O![5rO~P%:ROl5yO!]1gO%h5xO~Oh%VOl5yO!]1gO%h5xO~Ob6QO(R#nO(TTO(WUO!Z'qX!['qX~O!Z1rO![)Ta~O(TTO(WUO(c6SO~O`6WO~O#t6ZO&Y6[O~PMvO!i6]O~P%[Oa6_O~Oa6_O~P%[Ob2YO![6dO&h2XO~P`O!e6fO~O!e6hOh(hi!Z(hi![(hi!e(hi!j(hip(hi(p(hi~O!Z#fi![#fi~P#BPO#^6iO!Z#fi![#fi~O!Z!_i![!_i~P#BPOa%mO#^6rO'x%mO~Oa%mO!e#vO#^6rO'x%mO~O!Z(rq!i(rqa(rq'x(rq~P!:TO!Z(hO!i(qq~O!Q%gO!]%hO#h6yO(R%fO~O!]'^O%h6|O~Ol7QO!]'^O%h6|O~O#i'gaP'gaR'ga['gaa'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga'x'ga(_'ga(p'ga!i'ga!W'ga'u'gat'ga!]'ga%h'ga!e'ga~P%+uO#i'iaP'iaR'ia['iaa'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia'x'ia(_'ia(p'ia!i'ia!W'ia'u'iat'ia!]'ia%h'ia!e'ia~P%,hO#i${iP${iR${i[${ia${ip${i!Q${i!Z${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i'x${i(_${i(p${i!i${i!W${i'u${i#^${it${i!]${i%h${i!e${i~P#.{O#i%`iP%`iR%`i[%`ia%`ip%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i'x%`i(_%`i(p%`i!i%`i!W%`i'u%`it%`i!]%`i%h%`i!e%`i~P%3xO#i%biP%biR%bi[%bia%bip%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi'x%bi(_%bi(p%bi!i%bi!W%bi'u%bit%bi!]%bi%h%bi!e%bi~P%4kO!Z'Wa!i'Wa~P!:TO!Z.oO!i(ii~O#}#ai!Z#ai![#ai~P#BPOP$[OR#zO!O#yO!Q#{O!j#xO!n$[O(_VO[#kip#ki#P#ki#m#ki#n#ki#o#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#l#ki~P%MQO#l<PO~P%MQOP$[OR#zOp<]O!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO[#ki#P#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#p#ki~P& YO#p<RO~P& YOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO(_VO#w#ki#y#ki#z#ki#}#ki(p#ki(w#ki(x#ki!Z#ki![#ki~O#u#ki~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO(_VO(x#}O#y#ki#z#ki#}#ki(p#ki(w#ki!Z#ki![#ki~O#w<VO~P&%cO#w#ki~P&%cO#u<TO~P&#bOP$[OR#zO[<_Op<]O!O#yO!Q#{O!j#xO!n$[O#P<SO#l<PO#m<QO#n<QO#o<QO#p<RO#q<SO#r<SO#s<^O#t<SO#u<TO#w<VO(_VO(w#|O(x#}O#z#ki#}#ki(p#ki!Z#ki![#ki~O#y#ki~P&'rO#y<XO~P&'rOa#{y!Z#{y'x#{y'u#{y!W#{y!i#{yt#{y!]#{y%h#{y!e#{y~P!:TO[#kip#ki#P#ki#p#ki#q#ki#r#ki#s#ki#t#ki#u#ki#w#ki#y#ki#z#ki#}#ki(p#ki!Z#ki![#ki~OP$[OR#zO!O#yO!Q#{O!j#xO!n$[O#l<PO#m<QO#n<QO#o<QO(_VO(w#ki(x#ki~P&*nOl=}O!O)|O'w)}O(w$}O(x%POP#kiR#ki!Q#ki!j#ki!n#ki#l#ki#m#ki#n#ki#o#ki(_#ki~P&*nO#Q$dOP(^XR(^X[(^Xl(^Xp(^X!O(^X!Q(^X!j(^X!n(^X#P(^X#l(^X#m(^X#n(^X#o(^X#p(^X#q(^X#r(^X#s(^X#t(^X#u(^X#w(^X#y(^X#z(^X#}(^X'w(^X(_(^X(p(^X(w(^X(x(^X!Z(^X![(^X~O#}$Oi!Z$Oi![$Oi~P#BPO#}!pi![!pi~P$*OOg'Za!Z'Za~P!0uO![7dO~O!Z'ba!['ba~P#BPO!W7eO~P#.{O!e#vO(p'nO!Z'ca!i'ca~O!Z/kO!i(|i~O!Z/kO!e#vO!i(|i~Og${q!Z${q#^${q#}${q~P!0uO!W'ea!Z'ea~P#.{O!e7lO~O!Z/sO!W(}i~P#.{O!Z/sO!W(}i~O!W7oO~Oh%VOp7tO!j%dO(p'nO~O!e#vO#t7vO~Op7yO!e#vO(p'nO~O!O)|O'w)}O(x%POl'ha(w'ha!Z'ha#^'ha~Og'ha#}'ha~P&3oO!O)|O'w)}Ol'ja(w'ja(x'ja!Z'ja#^'ja~Og'ja#}'ja~P&4bO!W7{O~Og$}q!Z$}q#^$}q#}$}q~P!0uOg(]q!Z(]q~P!0uO#^7|Og(]q!Z(]q~P!0uOa$ny!Z$ny'x$ny'u$ny!W$ny!i$nyt$ny!]$ny%h$ny!e$ny~P!:TO!e6hO~O!Z5RO!])Oa~O!]'^OP$SaR$Sa[$Sap$Sa!O$Sa!Q$Sa!Z$Sa!j$Sa!n$Sa#P$Sa#l$Sa#m$Sa#n$Sa#o$Sa#p$Sa#q$Sa#r$Sa#s$Sa#t$Sa#u$Sa#w$Sa#y$Sa#z$Sa(_$Sa(p$Sa(w$Sa(x$Sa~O%h6|O~P&7SO%]8QOa%Zi!]%Zi'x%Zi!Z%Zi~Oa#ay!Z#ay'x#ay'u#ay!W#ay!i#ayt#ay!]#ay%h#ay!e#ay~P!:TO[8SO~Ob8UO(R+nO(TTO(WUO~O!Z0}O![)Vi~O`8YO~O(c(zO!Z'nX!['nX~O!Z5kO![)Sa~O![8cO~P%:RO(m!sO~P$$oO#Y8dO~O!]1gO~O!]1gO%h8fO~Ol8iO!]1gO%h8fO~O[8nO!Z'qa!['qa~O!Z1rO![)Ti~O!i8rO~O!i8sO~O!i8vO~O!i8vO~P%[Oa8xO~O!e8yO~O!i8zO~O!Z(ui![(ui~P#BPOa%mO#^9SO'x%mO~O!Z(ry!i(rya(ry'x(ry~P!:TO!Z(hO!i(qy~O%h9VO~P&7SO!]'^O%h9VO~O#i${qP${qR${q[${qa${qp${q!Q${q!Z${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q'x${q(_${q(p${q!i${q!W${q'u${q#^${qt${q!]${q%h${q!e${q~P#.{O#i'haP'haR'ha['haa'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha'x'ha(_'ha(p'ha!i'ha!W'ha'u'hat'ha!]'ha%h'ha!e'ha~P&3oO#i'jaP'jaR'ja['jaa'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja'x'ja(_'ja(p'ja!i'ja!W'ja'u'jat'ja!]'ja%h'ja!e'ja~P&4bO#i$}qP$}qR$}q[$}qa$}qp$}q!Q$}q!Z$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q'x$}q(_$}q(p$}q!i$}q!W$}q'u$}q#^$}qt$}q!]$}q%h$}q!e$}q~P#.{O!Z'Wi!i'Wi~P!:TO#}#aq!Z#aq![#aq~P#BPO(w$}OP%`aR%`a[%`ap%`a!Q%`a!j%`a!n%`a#P%`a#l%`a#m%`a#n%`a#o%`a#p%`a#q%`a#r%`a#s%`a#t%`a#u%`a#w%`a#y%`a#z%`a#}%`a(_%`a(p%`a!Z%`a![%`a~Ol%`a!O%`a'w%`a(x%`a~P&HgO(x%POP%baR%ba[%bap%ba!Q%ba!j%ba!n%ba#P%ba#l%ba#m%ba#n%ba#o%ba#p%ba#q%ba#r%ba#s%ba#t%ba#u%ba#w%ba#y%ba#z%ba#}%ba(_%ba(p%ba!Z%ba![%ba~Ol%ba!O%ba'w%ba(w%ba~P&JnOl=}O!O)|O'w)}O(x%PO~P&HgOl=}O!O)|O'w)}O(w$}O~P&JnOR0cO!O0cO!Q0dO#Q$dOP{a[{al{ap{a!j{a!n{a#P{a#l{a#m{a#n{a#o{a#p{a#q{a#r{a#s{a#t{a#u{a#w{a#y{a#z{a#}{a'w{a(_{a(p{a(w{a(x{a!Z{a![{a~O!O)|O'w)}OP$raR$ra[$ral$rap$ra!Q$ra!j$ra!n$ra#P$ra#l$ra#m$ra#n$ra#o$ra#p$ra#q$ra#r$ra#s$ra#t$ra#u$ra#w$ra#y$ra#z$ra#}$ra(_$ra(p$ra(w$ra(x$ra!Z$ra![$ra~O!O)|O'w)}OP$taR$ta[$tal$tap$ta!Q$ta!j$ta!n$ta#P$ta#l$ta#m$ta#n$ta#o$ta#p$ta#q$ta#r$ta#s$ta#t$ta#u$ta#w$ta#y$ta#z$ta#}$ta(_$ta(p$ta(w$ta(x$ta!Z$ta![$ta~Ol=}O!O)|O'w)}O(w$}O(x%PO~OP%SaR%Sa[%Sap%Sa!Q%Sa!j%Sa!n%Sa#P%Sa#l%Sa#m%Sa#n%Sa#o%Sa#p%Sa#q%Sa#r%Sa#s%Sa#t%Sa#u%Sa#w%Sa#y%Sa#z%Sa#}%Sa(_%Sa(p%Sa!Z%Sa![%Sa~P'%sO#}$lq!Z$lq![$lq~P#BPO#}$nq!Z$nq![$nq~P#BPO![9dO~O#}9eO~P!0uO!e#vO!Z'ci!i'ci~O!e#vO(p'nO!Z'ci!i'ci~O!Z/kO!i(|q~O!W'ei!Z'ei~P#.{O!Z/sO!W(}q~Op9lO!e#vO(p'nO~O[9nO!W9mO~P#.{O!W9mO~O!e#vO#t9tO~Og(]y!Z(]y~P!0uO!Z'la!]'la~P#.{Oa%Zq!]%Zq'x%Zq!Z%Zq~P#.{O[9yO~O!Z0}O![)Vq~O#^9}O!Z'na!['na~O!Z5kO![)Si~P#BPO!Q:PO~O!]1gO%h:SO~O(TTO(WUO(c:XO~O!Z1rO![)Tq~O!i:[O~O!i:]O~O!i:^O~O!i:^O~P%[O#^:aO!Z#fy![#fy~O!Z#fy![#fy~P#BPO%h:fO~P&7SO!]'^O%h:fO~O#}#{y!Z#{y![#{y~P#BPOP${iR${i[${ip${i!Q${i!j${i!n${i#P${i#l${i#m${i#n${i#o${i#p${i#q${i#r${i#s${i#t${i#u${i#w${i#y${i#z${i#}${i(_${i(p${i!Z${i![${i~P'%sO!O)|O'w)}O(x%POP'gaR'ga['gal'gap'ga!Q'ga!j'ga!n'ga#P'ga#l'ga#m'ga#n'ga#o'ga#p'ga#q'ga#r'ga#s'ga#t'ga#u'ga#w'ga#y'ga#z'ga#}'ga(_'ga(p'ga(w'ga!Z'ga!['ga~O!O)|O'w)}OP'iaR'ia['ial'iap'ia!Q'ia!j'ia!n'ia#P'ia#l'ia#m'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#w'ia#y'ia#z'ia#}'ia(_'ia(p'ia(w'ia(x'ia!Z'ia!['ia~O(w$}OP%`iR%`i[%`il%`ip%`i!O%`i!Q%`i!j%`i!n%`i#P%`i#l%`i#m%`i#n%`i#o%`i#p%`i#q%`i#r%`i#s%`i#t%`i#u%`i#w%`i#y%`i#z%`i#}%`i'w%`i(_%`i(p%`i(x%`i!Z%`i![%`i~O(x%POP%biR%bi[%bil%bip%bi!O%bi!Q%bi!j%bi!n%bi#P%bi#l%bi#m%bi#n%bi#o%bi#p%bi#q%bi#r%bi#s%bi#t%bi#u%bi#w%bi#y%bi#z%bi#}%bi'w%bi(_%bi(p%bi(w%bi!Z%bi![%bi~O#}$ny!Z$ny![$ny~P#BPO#}#ay!Z#ay![#ay~P#BPO!e#vO!Z'cq!i'cq~O!Z/kO!i(|y~O!W'eq!Z'eq~P#.{Op:pO!e#vO(p'nO~O[:tO!W:sO~P#.{O!W:sO~Og(]!R!Z(]!R~P!0uOa%Zy!]%Zy'x%Zy!Z%Zy~P#.{O!Z0}O![)Vy~O!Z5kO![)Sq~O(R:zO~O!]1gO%h:}O~O!i;QO~O%h;VO~P&7SOP${qR${q[${qp${q!Q${q!j${q!n${q#P${q#l${q#m${q#n${q#o${q#p${q#q${q#r${q#s${q#t${q#u${q#w${q#y${q#z${q#}${q(_${q(p${q!Z${q![${q~P'%sO!O)|O'w)}O(x%POP'haR'ha['hal'hap'ha!Q'ha!j'ha!n'ha#P'ha#l'ha#m'ha#n'ha#o'ha#p'ha#q'ha#r'ha#s'ha#t'ha#u'ha#w'ha#y'ha#z'ha#}'ha(_'ha(p'ha(w'ha!Z'ha!['ha~O!O)|O'w)}OP'jaR'ja['jal'jap'ja!Q'ja!j'ja!n'ja#P'ja#l'ja#m'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#w'ja#y'ja#z'ja#}'ja(_'ja(p'ja(w'ja(x'ja!Z'ja!['ja~OP$}qR$}q[$}qp$}q!Q$}q!j$}q!n$}q#P$}q#l$}q#m$}q#n$}q#o$}q#p$}q#q$}q#r$}q#s$}q#t$}q#u$}q#w$}q#y$}q#z$}q#}$}q(_$}q(p$}q!Z$}q![$}q~P'%sOg%d!Z!Z%d!Z#^%d!Z#}%d!Z~P!0uO!W;ZO~P#.{Op;[O!e#vO(p'nO~O[;^O!W;ZO~P#.{O!Z'nq!['nq~P#BPO!Z#f!Z![#f!Z~P#BPO#i%d!ZP%d!ZR%d!Z[%d!Za%d!Zp%d!Z!Q%d!Z!Z%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z'x%d!Z(_%d!Z(p%d!Z!i%d!Z!W%d!Z'u%d!Z#^%d!Zt%d!Z!]%d!Z%h%d!Z!e%d!Z~P#.{Op;fO!e#vO(p'nO~O!W;gO~P#.{Op;nO!e#vO(p'nO~O!W;oO~P#.{OP%d!ZR%d!Z[%d!Zp%d!Z!Q%d!Z!j%d!Z!n%d!Z#P%d!Z#l%d!Z#m%d!Z#n%d!Z#o%d!Z#p%d!Z#q%d!Z#r%d!Z#s%d!Z#t%d!Z#u%d!Z#w%d!Z#y%d!Z#z%d!Z#}%d!Z(_%d!Z(p%d!Z!Z%d!Z![%d!Z~P'%sOp;rO!e#vO(p'nO~Ot(dX~P1qO!O%qO~P!(yO(S!lO~P!(yO!WfX!ZfX#^fX~P%0XOP]XR]X[]Xp]X!O]X!Q]X!Z]X!ZfX!j]X!n]X#P]X#Q]X#^]X#^fX#ifX#l]X#m]X#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#w]X#y]X#z]X$P]X(_]X(p]X(w]X(x]X~O!efX!i]X!ifX(pfX~P'JlOP;vOQ;vOSfOd=rOe!iOnkOp;vOqkOrkOxkOz;vO|;vO!QWO!UkO!VkO!]XO!g;yO!jZO!m;vO!n;vO!o;vO!q;zO!s;}O!v!hO$V!kO$m=pO(R)ZO(TTO(WUO(_VO(m[O~O!Z<ZO![$pa~Oh%VOn%WOp%XOq$tOr$tOx%YOz%ZO|<fO!Q${O!]$|O!g=wO!j$xO#h<lO$V%_O$s<hO$u<jO$x%`O(R(tO(TTO(WUO(_$uO(w$}O(x%PO~Oj)bO~P( bOp!cX(p!cX~P# qOp(hX(p(hX~P#!dO![]X![fX~P'JlO!WfX!W$yX!ZfX!Z$yX#^fX~P!/qO#i<OO~O!e#vO#i<OO~O#^<`O~O#t<SO~O#^<pO!Z(uX![(uX~O#^<`O!Z(sX![(sX~O#i<qO~Og<sO~P!0uO#i<yO~O#i<zO~O!e#vO#i<{O~O!e#vO#i<qO~O#}<|O~P#BPO#i<}O~O#i=OO~O#i=TO~O#i=UO~O#i=VO~O#i=WO~O#}=XO~P!0uO#}=YO~P!0uO#Q#R#S#U#V#Y#g#h#s$m$s$u$x%[%]%g%h%i%p%r%u%v%x%z~'|T#m!V'z(S#nq#l#op!O'{$['{(R$^(c~",
-     goto: "$8f)ZPPPPPP)[PP)_P)pP+Q/VPPPP6aPP6wPP<oP@cP@yP@yPPP@yPCRP@yP@yP@yPCVPC[PCyPHsPPPHwPPPPHwKzPPPLQLrPHwPHwPP! QHwPPPHwPHwP!#XHwP!&o!'t!'}P!(q!(u!(q!,SPPPPPPP!,s!'tPP!-T!.uP!2RHwHw!2W!5d!:Q!:Q!>PPPP!>XHwPPPPPPPPPP!AhP!BuPPHw!DWPHwPHwHwHwHwHwPHw!EjP!HtP!KzP!LO!LY!L^!L^P!HqP!Lb!LbP# hP# lHwPHw# r#$wCV@yP@yP@y@yP#&U@y@y#(h@y#+`@y#-l@y@y#.[#0p#0p#0u#1O#0p#1ZPP#0pP@y#1s@y#5r@y@y6aPPP#9wPPP#:b#:bP#:bP#:x#:bPP#;OP#:uP#:u#;c#:u#;}#<T#<W)_#<Z)_P#<b#<b#<bP)_P)_P)_P)_PP)_P#<h#<kP#<k)_P#<oP#<rP)_P)_P)_P)_P)_P)_)_PP#<x#=O#=Z#=a#=g#=m#=s#>R#>X#>c#>i#>s#>y#?Z#?a#@R#@e#@k#@q#AP#Af#CZ#Ci#Cp#E[#Ej#G[#Gj#Gp#Gv#G|#HW#H^#Hd#Hn#IQ#IWPPPPPPPPPPP#I^PPPPPPP#JR#MY#Nr#Ny$ RPPP$&mP$&v$)o$0Y$0]$0`$1_$1b$1i$1qP$1w$1zP$2h$2l$3d$4r$4w$5_PP$5d$5j$5n$5q$5u$5y$6u$7^$7u$7y$7|$8P$8V$8Y$8^$8bR!|RoqOXst!Z#d%l&p&r&s&u,n,s2S2VY!vQ'^-`1g5qQ%svQ%{yQ&S|Q&h!VS'U!e-WQ'd!iS'j!r!yU*h$|*X*lQ+l%|Q+y&UQ,_&bQ-^']Q-h'eQ-p'kQ0U*nQ1q,`R<m;z%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y,k,n,s-d-l-z.Q.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3d4q5y6Z6[6_6r8i8x9SS#q];w!r)]$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sU*{%[<e<fQ+q&OQ,a&eQ,h&mQ0r+dQ0u+fQ1S+rQ1y,fQ3W.bQ5V0wQ5]0}Q6Q1rQ7O3[Q8U5^R9Y7Q'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s!S!nQ!r!v!y!z$|'U']'^'j'k'l*h*l*n*o-W-^-`-p0U0X1g5q5s%[$ti#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}Q&V|Q'S!eS'Y%h-ZQ+q&OQ,a&eQ0f+OQ1S+rQ1X+xQ1x,eQ1y,fQ5]0}Q5f1ZQ6Q1rQ6T1tQ6U1wQ8U5^Q8X5cQ8q6WQ9|8YQ:Y8nR<o*XrnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VR,c&i&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=r=s[#]WZ#W#Z'V(R!b%im#h#i#l$x%d%g([(f(g(h*W*[*_+W+X+Z,j-Q.O.U.V.W.Y/h/k2[3S3T4X6h6yQ%vxQ%zyS&P|&UQ&]!TQ'a!hQ'c!iQ(o#sS+k%{%|Q+o&OQ,Y&`Q,^&bS-g'd'eQ.d(pQ0{+lQ1R+rQ1T+sQ1W+wQ1l,ZS1p,_,`Q2t-hQ5[0}Q5`1QQ5e1YQ6P1qQ8T5^Q8W5bQ9x8SR:w9y!U$zi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y!^%xy!i!u%z%{%|'T'c'd'e'i's*g+k+l-T-g-h-o/{0O0{2m2t2{4i4j4m7s9pQ+e%vQ,O&YQ,R&ZQ,]&bQ.c(oQ1k,YU1o,^,_,`Q3].dQ5z1lS6O1p1qQ8m6P#f=t#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}o=u<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YW%Ti%V*v=pS&Y!Q&gQ&Z!RQ&[!SQ+S%cR+|&W%]%Si#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}T)x$u)yV*{%[<e<fW'Y!e%h*X-ZS({#y#zQ+`%qQ+v&RS.](k(lQ1b,SQ4x0cR8^5k'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s$i$^c#Y#e%p%r%t(Q(W(r(w)P)Q)R)S)T)U)V)W)X)Y)[)^)`)e)o+a+u-U-s-x-}.P.n.q.u.w.x.y/]0j2c2f2v2}3c3h3i3j3k3l3m3n3o3p3q3r3s3t3w3x4P5O5Y6k6q6v7V7W7a7b8`8|9Q9[9b9c:c:y;R;x=gT#TV#U'RkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ'W!eR2i-W!W!nQ!e!r!v!y!z$|'U']'^'j'k'l*X*h*l*n*o-W-^-`-p0U0X1g5q5sR1d,UnqOXst!Z#d%l&p&r&s&u,n,s2S2VQ&w!^Q't!xS(q#u<OQ+i%yQ,W&]Q,X&_Q-e'bQ-r'mS.m(v<qS0k+U<{Q0y+jQ1f,VQ2Z,uQ2],vQ2e-RQ2r-fQ2u-jS5P0l=VQ5W0zS5Z0|=WQ6j2gQ6n2sQ6s2zQ8R5XQ8}6lQ9O6oQ9R6tR:`8z$d$]c#Y#e%r%t(Q(W(r(w)P)Q)R)S)T)U)V)W)X)Y)[)^)`)e)o+a+u-U-s-x-}.P.n.q.u.x.y/]0j2c2f2v2}3c3h3i3j3k3l3m3n3o3p3q3r3s3t3w3x4P5O5Y6k6q6v7V7W7a7b8`8|9Q9[9b9c:c:y;R;x=gS(m#p'gQ(}#zS+_%p.wS.^(l(nR3U._'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sS#q];wQ&r!XQ&s!YQ&u![Q&v!]R2R,qQ'_!hQ+b%vQ-c'aS.`(o+eQ2p-bW3Y.c.d0q0sQ6m2qW6z3V3X3]5TU9U6{6}7PU:e9W9X9ZS;T:d:gQ;b;UR;j;cU!wQ'^-`T5o1g5q!Q_OXZ`st!V!Z#d#h%d%l&g&i&p&r&s&u(h,n,s.V2S2V]!pQ!r'^-`1g5qT#q];w%^{OPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SS({#y#zS.](k(l!s=^$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sU$fd)],hS(n#p'gU*s%R(u3vU0e*z.i7]Q5T0rQ6{3WQ9X7OR:g9Ym!tQ!r!v!y!z'^'j'k'l-`-p1g5q5sQ'r!uS(d#g1|S-n'i'uQ/n*ZQ/{*gQ2|-qQ4]/oQ4i/}Q4j0OQ4o0WQ7h4WS7s4k4mS7w4p4rQ9g7iQ9k7oQ9p7tQ9u7yS:o9l9mS;Y:p:sS;e;Z;[S;m;f;gS;q;n;oR;t;rQ#wbQ'q!uS(c#g1|S(e#m+TQ+V%eQ+g%wQ+m%}U-m'i'r'uQ.R(dQ/m*ZQ/|*gQ0P*iQ0x+hQ1m,[S2y-n-qQ3R.ZS4[/n/oQ4e/yS4h/{0WQ4l0QQ5|1nQ6u2|Q7g4WQ7k4]U7r4i4o4rQ7u4nQ8k5}S9f7h7iQ9j7oQ9r7wQ9s7xQ:V8lQ:m9gS:n9k9mQ:v9uQ;P:WS;X:o:sS;d;Y;ZS;l;e;gS;p;m;oQ;s;qQ;u;tQ=a=[Q=l=eR=m=fV!wQ'^-`%^aOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SS#wz!j!r=Z$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sR=a=r%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SQ%ej!^%wy!i!u%z%{%|'T'c'd'e'i's*g+k+l-T-g-h-o/{0O0{2m2t2{4i4j4m7s9pS%}z!jQ+h%xQ,[&bW1n,],^,_,`U5}1o1p1qS8l6O6PQ:W8m!r=[$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ=e=qR=f=r%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9SY#bWZ#W#Z(R!b%im#h#i#l$x%d%g([(f(g(h*W*[*_+W+X+Z,j-Q.O.U.V.W.Y/h/k2[3S3T4X6h6yQ,i&m!p=]$Z$n)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sR=`'VU'Z!e%h*XR2k-Z%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y,k,n,s-d-l-z.Q.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3d4q5y6Z6[6_6r8i8x9S!r)]$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sQ,h&mQ0r+dQ3W.bQ7O3[R9Y7Q!b$Tc#Y%p(Q(W(r(w)X)Y)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;x!P<U)[)o-U.w2c2f3h3q3r3w4P6k7W7a7b8`8|9[9b9c:y;R=g!f$Vc#Y%p(Q(W(r(w)U)V)X)Y)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;x!T<W)[)o-U.w2c2f3h3n3o3q3r3w4P6k7W7a7b8`8|9[9b9c:y;R=g!^$Zc#Y%p(Q(W(r(w)^)e+u-s-x-}.P.n.q/]0j2v2}3c3s5O5Y6q6v7V9Q:c;xQ4V/fz=s)[)o-U.w2c2f3h3w4P6k7W7a7b8`8|9[9b9c:y;R=gQ=x=zR=y={'QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sS$oh$pR3|/P'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/P/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sT$kf$qQ$ifS)h$l)lR)t$qT$jf$qT)j$l)l'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%l%s&Q&i&l&m&p&r&s&u&y'R'V'`'p(R(T(Z(b(v(x(|)q){*f+U+Y+d,k,n,s-P-S-d-l-z.Q.b.o.v/P/Q/i0V0d0l0|1j1z1{1}2P2S2V2X2h2x3O3[3d3{4q5m5y6Z6[6_6i6r7Q8i8x9S9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=sT$oh$pQ$rhR)s$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%l%s&Q&i&l&m&p&r&s&u&y'R'`'p(R(T(Z(b(v(x(|){*f+U+Y+d,k,n,s-d-l-z.Q.b.o.v/i0V0d0l0|1j1z1{1}2P2S2V2X2x3O3[3d4q5y6Z6[6_6r7Q8i8x9S!s=q$Z$n'V)q-P-S/Q2h3{5m6i9}:a;v;y;z;}<O<P<Q<R<S<T<U<V<W<X<Y<Z<]<`<m<p<q<s<{<|=V=W=s#glOPXZst!Z!`!o#S#d#o#{$n%l&i&l&m&p&r&s&u&y'R'`(|)q*f+Y+d,k,n,s-d.b/Q/i0V0d1j1z1{1}2P2S2V2X3[3{4q5y6Z6[6_7Q8i8x!U%Ri$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y#f(u#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}Q+P%`Q/^)|o3v<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!U$yi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=yQ*`$zU*i$|*X*lQ+Q%aQ0Q*j#f=c#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n=d<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YQ=h=tQ=i=uQ=j=vR=k=w!U%Ri$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y#f(u#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}o3v<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=YnoOXst!Z#d%l&p&r&s&u,n,s2S2VS*c${*WQ,|&|Q,}'OR4`/s%[%Si#v$b$c$d$x${%O%Q%]%^%b)w*P*R*T*W*^*d*t*u+c+f+},Q.a.z/_/h/r/s/u0Y0[0g0h0i1^1a1i3Z4U4V4a4f4w5R5U5x6|7l7v7|8Q8f9V9e9n9t:S:f:t:};V;^<^<_<a<b<c<d<g<h<i<j<k<l<t<u<v<w<y<z<}=O=P=Q=R=S=T=U=X=Y=p=x=y=|=}Q,P&ZQ1`,RQ5i1_R8]5jV*k$|*X*lU*k$|*X*lT5p1g5qS/y*f/iQ4n0VT7x4q:PQ+g%wQ0P*iQ0x+hQ1m,[Q5|1nQ8k5}Q:V8lR;P:W!U%Oi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=yx*P$v)c*Q*r+R/q0^0_3y4^4{4|4}7f7z9v:l=b=n=oS0Y*q0Z#f<a#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n<b<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!d<t(s)a*Y*b.e.h.l/Y/f/v0p1]3`4S4_4c5h7R7U7m7p7}8P9i9q9w:q:u;W;];h=z={`<u3u7X7[7`9]:h:k;kS=P.g3aT=Q7Z9`!U%Qi$d%O%Q%]%^%b*P*R*^*t*u.z/r0Y0[0g0h0i4V4w7|9e=p=x=y|*R$v)c*S*q+R/b/q0^0_3y4^4s4{4|4}7f7z9v:l=b=n=oS0[*r0]#f<c#v$b$c$x${)w*T*W*d+c+f+},Q.a/_/h/s/u1^1a1i3Z4U4a4f5R5U5x6|7l7v8Q8f9V9n9t:S:f:t:};V;^<a<c<g<i<k<t<v<y<}=P=R=T=X=|=}n<d<^<_<b<d<h<j<l<u<w<z=O=Q=S=U=Y!h<v(s)a*Y*b.f.g.l/Y/f/v0p1]3^3`4S4_4c5h7R7S7U7m7p7}8P9i9q9w:q:u;W;];h=z={d<w3u7Y7Z7`9]9^:h:i:k;kS=R.h3bT=S7[9arnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VQ&d!UR,k&mrnOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VR&d!UQ,T&[R1[+|snOXst!V!Z#d%l&g&p&r&s&u,n,s2S2VQ1h,YS5w1k1lU8e5u5v5zS:R8g8hS:{:Q:TQ;_:|R;i;`Q&k!VR,d&gR6T1tR:Y8nS&P|&UR1T+sQ&p!WR,n&qR,t&vT2T,s2VR,x&wQ,w&wR2^,xQ'w!{R-t'wSsOtQ#dXT%os#dQ#OTR'y#OQ#RUR'{#RQ)y$uR/Z)yQ#UVR(O#UQ#XWU(U#X(V-{Q(V#YR-{(WQ-X'WR2j-XQ.p(wS3e.p3fR3f.qQ-`'^R2n-`Y!rQ'^-`1g5qR'h!rQ.{)cR3z.{U#_W%g*WU(]#_(^-|Q(^#`R-|(XQ-['ZR2l-[t`OXst!V!Z#d%l&g&i&p&r&s&u,n,s2S2VS#hZ%dU#r`#h.VR.V(hQ(i#jQ.S(eW.[(i.S3P6wQ3P.TR6w3QQ)l$lR/R)lQ$phR)r$pQ$`cU)_$`-w<[Q-w;xR<[)oQ/l*ZW4Y/l4Z7j9hU4Z/m/n/oS7j4[4]R9h7k$e*O$v(s)a)c*Y*b*q*r*|*}+R.g.h.j.k.l/Y/b/d/f/q/v0^0_0p1]3^3_3`3u3y4S4^4_4c4s4u4{4|4}5h7R7S7T7U7Z7[7^7_7`7f7m7p7z7}8P9]9^9_9i9q9v9w:h:i:j:k:l:q:u;W;];h;k=b=n=o=z={Q/t*bU4b/t4d7nQ4d/vR7n4cS*l$|*XR0S*lx*Q$v)c*q*r+R/q0^0_3y4^4{4|4}7f7z9v:l=b=n=o!d.e(s)a*Y*b.g.h.l/Y/f/v0p1]3`4S4_4c5h7R7U7m7p7}8P9i9q9w:q:u;W;];h=z={U/c*Q.e7Xa7X3u7Z7[7`9]:h:k;kQ0Z*qQ3a.gU4t0Z3a9`R9`7Z|*S$v)c*q*r+R/b/q0^0_3y4^4s4{4|4}7f7z9v:l=b=n=o!h.f(s)a*Y*b.g.h.l/Y/f/v0p1]3^3`4S4_4c5h7R7S7U7m7p7}8P9i9q9w:q:u;W;];h=z={U/e*S.f7Ye7Y3u7Z7[7`9]9^:h:i:k;kQ0]*rQ3b.hU4v0]3b9aR9a7[Q*w%UR0a*wQ5S0pR8O5SQ+[%jR0o+[Q5l1bS8_5l:OR:O8`Q,V&]R1e,VQ5q1gR8b5qQ1s,aS6R1s8oR8o6TQ1O+oW5_1O5a8V9zQ5a1RQ8V5`R9z8WQ+t&PR1U+tQ2V,sR6c2VYrOXst#dQ&t!ZQ+^%lQ,m&pQ,o&rQ,p&sQ,r&uQ2Q,nS2T,s2VR6b2SQ%npQ&x!_Q&{!aQ&}!bQ'P!cQ'o!uQ+]%kQ+i%yQ+{&VQ,c&kQ,z&zW-k'i'q'r'uQ-r'mQ0R*kQ0y+jS1v,d,gQ2_,yQ2`,|Q2a,}Q2u-jW2w-m-n-q-sQ5W0zQ5d1XQ5g1]Q5{1mQ6V1xQ6a2RU6p2v2y2|Q6s2zQ8R5XQ8Z5fQ8[5hQ8a5pQ8j5|Q8p6US9P6q6uQ9R6tQ9{8XQ:U8kQ:Z8qQ:b9QQ:x9|Q;O:VQ;S:cR;a;PQ%yyQ'b!iQ'm!uU+j%z%{%|Q-R'TU-f'c'd'eS-j'i'sQ/z*gS0z+k+lQ2g-TS2s-g-hQ2z-oS4g/{0OQ5X0{Q6l2mQ6o2tQ6t2{U7q4i4j4mQ9o7sR:r9pS$wi=pR*x%VU%Ui%V=pR0`*vQ$viS(s#v+fS)a$b$cQ)c$dQ*Y$xS*b${*WQ*q%OQ*r%QQ*|%]Q*}%^Q+R%bQ.g<aQ.h<cQ.j<gQ.k<iQ.l<kQ/Y)wQ/b*PQ/d*RQ/f*TQ/q*^S/v*d/hQ0^*tQ0_*ul0p+c,Q.a1a1i3Z5x6|8f9V:S:f:};VQ1]+}Q3^<tQ3_<vQ3`<yS3u<^<_Q3y.zS4S/_4UQ4^/rQ4_/sQ4c/uQ4s0YQ4u0[Q4{0gQ4|0hQ4}0iQ5h1^Q7R<}Q7S=PQ7T=RQ7U=TQ7Z<bQ7[<dQ7^<hQ7_<jQ7`<lQ7f4VQ7m4aQ7p4fQ7z4wQ7}5RQ8P5UQ9]<zQ9^<uQ9_<wQ9i7lQ9q7vQ9v7|Q9w8QQ:h=OQ:i=QQ:j=SQ:k=UQ:l9eQ:q9nQ:u9tQ;W=XQ;]:tQ;h;^Q;k=YQ=b=pQ=n=xQ=o=yQ=z=|R={=}Q*z%[Q.i<eR7]<fnpOXst!Z#d%l&p&r&s&u,n,s2S2VQ!fPS#fZ#oQ&z!`W'f!o*f0V4qQ'}#SQ)O#{Q)p$nS,g&i&lQ,l&mQ,y&yS-O'R/iQ-b'`Q.s(|Q/V)qQ0m+YQ0s+dQ2O,kQ2q-dQ3X.bQ4O/QQ4y0dQ5v1jQ6X1zQ6Y1{Q6^1}Q6`2PQ6e2XQ7P3[Q7c3{Q8h5yQ8t6ZQ8u6[Q8w6_Q9Z7QQ:T8iR:_8x#[cOPXZst!Z!`!o#d#o#{%l&i&l&m&p&r&s&u&y'R'`(|*f+Y+d,k,n,s-d.b/i0V0d1j1z1{1}2P2S2V2X3[4q5y6Z6[6_7Q8i8xQ#YWQ#eYQ%puQ%rvS%tw!gS(Q#W(TQ(W#ZQ(r#uQ(w#xQ)P$OQ)Q$PQ)R$QQ)S$RQ)T$SQ)U$TQ)V$UQ)W$VQ)X$WQ)Y$XQ)[$ZQ)^$_Q)`$aQ)e$eW)o$n)q/Q3{Q+a%sQ+u&QS-U'V2hQ-s'pS-x(R-zQ-}(ZQ.P(bQ.n(vQ.q(xQ.u;vQ.w;yQ.x;zQ.y;}Q/]){Q0j+UQ2c-PQ2f-SQ2v-lQ2}.QQ3c.oQ3h<OQ3i<PQ3j<QQ3k<RQ3l<SQ3m<TQ3n<UQ3o<VQ3p<WQ3q<XQ3r<YQ3s.vQ3t<]Q3w<`Q3x<mQ4P<ZQ5O0lQ5Y0|Q6k<pQ6q2xQ6v3OQ7V3dQ7W<qQ7a<sQ7b<{Q8`5mQ8|6iQ9Q6rQ9[<|Q9b=VQ9c=WQ:c9SQ:y9}Q;R:aQ;x#SR=g=sR#[WR'X!el!tQ!r!v!y!z'^'j'k'l-`-p1g5q5sS'T!e-WU*g$|*X*lS-T'U']S0O*h*nQ0W*oQ2m-^Q4m0UR4r0XR(y#xQ!fQT-_'^-`]!qQ!r'^-`1g5qQ#p]R'g;wR)d$dY!uQ'^-`1g5qQ'i!rS's!v!yS'u!z5sS-o'j'kQ-q'lR2{-pT#kZ%dS#jZ%dS%jm,jU(e#h#i#lS.T(f(gQ.X(hQ0n+ZQ3Q.UU3R.V.W.YS6x3S3TR9T6yd#^W#W#Z%g(R([*W+W.O/hr#gZm#h#i#l%d(f(g(h+Z.U.V.W.Y3S3T6yS*Z$x*_Q/o*[Q1|,jQ2d-QQ4W/kQ6g2[Q7i4XQ8{6hT=_'V+XV#aW%g*WU#`W%g*WS(S#W([U(X#Z+W/hS-V'V+XT-y(R.OV'[!e%h*XQ$lfR)v$qT)k$l)lR3}/PT*]$x*_T*e${*WQ0q+cQ1_,QQ3V.aQ5j1aQ5u1iQ6}3ZQ8g5xQ9W6|Q:Q8fQ:d9VQ:|:SQ;U:fQ;`:}R;c;VnqOXst!Z#d%l&p&r&s&u,n,s2S2VQ&j!VR,c&gtmOXst!U!V!Z#d%l&g&p&r&s&u,n,s2S2VR,j&mT%km,jR1c,SR,b&eQ&T|R+z&UR+p&OT&n!W&qT&o!W&qT2U,s2V",
-     nodeNames: "⚠ ArithOp ArithOp ?. JSXStartTag LineComment BlockComment Script Hashbang ExportDeclaration export Star as VariableName String Escape from ; default FunctionDeclaration async function VariableDefinition > < TypeParamList const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",
-     maxTerm: 378,
-     context: trackNewline,
-     nodeProps: [
-       ["isolate", -8,5,6,14,35,37,49,51,53,""],
-       ["group", -26,9,17,19,66,206,210,214,215,217,220,223,233,235,241,243,245,247,250,256,262,264,266,268,270,272,273,"Statement",-34,13,14,30,33,34,40,49,52,53,55,60,68,70,74,78,80,82,83,108,109,118,119,135,138,140,141,142,143,144,146,147,166,168,170,"Expression",-23,29,31,35,39,41,43,172,174,176,177,179,180,181,183,184,185,187,188,189,200,202,204,205,"Type",-3,86,101,107,"ClassItem"],
-       ["openedBy", 23,"<",36,"InterpolationStart",54,"[",58,"{",71,"(",159,"JSXStartCloseTag"],
-       ["closedBy", -2,24,167,">",38,"InterpolationEnd",48,"]",59,"}",72,")",164,"JSXEndTag"]
-     ],
-     propSources: [jsHighlight],
-     skippedNodes: [0,5,6,276],
-     repeatNodeCount: 37,
-     tokenData: "$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$<r#p#q$=h#q#r$>x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$h&j(UpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(UpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$h&j(Up(X!b'z0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(V#S$h&j'{0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$h&j(Up(X!b'{0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$h&j!n),Q(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(T':f$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$h&j(X!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$h&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$c`$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$c``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$c`$h&j(X!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(X!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$c`(X!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$h&j(Up(X!bOY%ZYZ&cZq%Zqr<Srs&}st%ZtuCruw%Zwx(rx!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr(r<__WS$h&j(Up(X!bOY<SYZ&cZr<Srs=^sw<Swx@nx!^<S!^!_Bm!_#O<S#O#P>`#P#o<S#o#pBm#p;'S<S;'S;=`Cl<%lO<S(Q=g]WS$h&j(X!bOY=^YZ&cZw=^wx>`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$h&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(X!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$h&j(UpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(UpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Up(X!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l<S%9[C}i$h&j(m%1l(Up(X!bOY%ZYZ&cZr%Zrs&}st%ZtuCruw%Zwx(rx!Q%Z!Q![Cr![!^%Z!^!_*g!_!c%Z!c!}Cr!}#O%Z#O#P&c#P#R%Z#R#SCr#S#T%Z#T#oCr#o#p*g#p$g%Z$g;'SCr;'S;=`El<%lOCr%9[EoP;=`<%lCr07[FRk$h&j(Up(X!b$[#t(R,2j(c$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr+dHRk$h&j(Up(X!b$[#tOY%ZYZ&cZr%Zrs&}st%ZtuGvuw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Gv![!^%Z!^!_*g!_!c%Z!c!}Gv!}#O%Z#O#P&c#P#R%Z#R#SGv#S#T%Z#T#oGv#o#p*g#p$g%Z$g;'SGv;'S;=`Iv<%lOGv+dIyP;=`<%lGv07[JPP;=`<%lEr(KWJ_`$h&j(Up(X!b#n(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWKl_$h&j$P(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,#xLva(x+JY$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sv%ZvwM{wx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KWNW`$h&j#y(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At! c_(W';W$h&j(UpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b'l!!i_$h&j(UpOY!!bYZ!#hZr!!brs!#hsw!!bwx!$xx!^!!b!^!_!%z!_#O!!b#O#P!#h#P#o!!b#o#p!%z#p;'S!!b;'S;=`!'c<%lO!!b&z!#mX$h&jOw!#hwx6cx!^!#h!^!_!$Y!_#o!#h#o#p!$Y#p;'S!#h;'S;=`!$r<%lO!#h`!$]TOw!$Ywx7]x;'S!$Y;'S;=`!$l<%lO!$Y`!$oP;=`<%l!$Y&z!$uP;=`<%l!#h'l!%R]$c`$h&j(UpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r!Q!&PZ(UpOY!%zYZ!$YZr!%zrs!$Ysw!%zwx!&rx#O!%z#O#P!$Y#P;'S!%z;'S;=`!']<%lO!%z!Q!&yU$c`(UpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)r!Q!'`P;=`<%l!%z'l!'fP;=`<%l!!b/5|!'t_!j/.^$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#&U!)O_!i!Lf$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z-!n!*[b$h&j(Up(X!b(S%&f#o(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rxz%Zz{!+d{!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW!+o`$h&j(Up(X!b#l(ChOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;x!,|`$h&j(Up(X!bp+4YOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z,$U!.Z_!Z+Jf$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!/ec$h&j(Up(X!b!O.2^OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!0p!P!Q%Z!Q![!3Y![!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!0ya$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!2O!P!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z#%|!2Z_!Y!L^$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!3eg$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!3Y![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S!3Y#S#X%Z#X#Y!4|#Y#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!5Vg$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx{%Z{|!6n|}%Z}!O!6n!O!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!6wc$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad!8_c$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![!8S![!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S!8S#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[!9uf$h&j(Up(X!b#m(ChOY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcxz!;Zz{#-}{!P!;Z!P!Q#/d!Q!^!;Z!^!_#(i!_!`#7S!`!a#8i!a!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z?O!;fb$h&j(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z>^!<w`$h&j(X!b!V7`OY!<nYZ&cZw!<nwx!=yx!P!<n!P!Q!Eq!Q!^!<n!^!_!Gr!_!}!<n!}#O!KS#O#P!Dy#P#o!<n#o#p!Gr#p;'S!<n;'S;=`!L]<%lO!<n<z!>Q^$h&j!V7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!?Td$h&j!V7`O!^&c!_#W&c#W#X!>|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!V7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!V7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c<z!C][$h&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#O!CW#O#P!DR#P#Q!=y#Q#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DWX$h&jOY!CWYZ&cZ!^!CW!^!_!Ar!_#o!CW#o#p!Ar#p;'S!CW;'S;=`!Ds<%lO!CW<z!DvP;=`<%l!CW<z!EOX$h&jOY!=yYZ&cZ!^!=y!^!_!@c!_#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y<z!EnP;=`<%l!=y>^!Ezl$h&j(X!b!V7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(X!b!V7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(X!b!V7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(X!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$h&j(X!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!<n#Q#o!KS#o#p!JU#p;'S!KS;'S;=`!LV<%lO!KS>^!LYP;=`<%l!KS>^!L`P;=`<%l!<n=l!Ll`$h&j(Up!V7`OY!LcYZ&cZr!Lcrs!=ys!P!Lc!P!Q!Mn!Q!^!Lc!^!_# o!_!}!Lc!}#O#%P#O#P!Dy#P#o!Lc#o#p# o#p;'S!Lc;'S;=`#&Y<%lO!Lc=l!Mwl$h&j(Up!V7`OY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#W(r#W#X!Mn#X#Z(r#Z#[!Mn#[#](r#]#^!Mn#^#a(r#a#b!Mn#b#g(r#g#h!Mn#h#i(r#i#j!Mn#j#k!Mn#k#m(r#m#n!Mn#n#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(r8Q# vZ(Up!V7`OY# oZr# ors!@cs!P# o!P!Q#!i!Q!}# o!}#O#$R#O#P!Bq#P;'S# o;'S;=`#$y<%lO# o8Q#!pe(Up!V7`OY)rZr)rs#O)r#P#W)r#W#X#!i#X#Z)r#Z#[#!i#[#])r#]#^#!i#^#a)r#a#b#!i#b#g)r#g#h#!i#h#i)r#i#j#!i#j#k#!i#k#m)r#m#n#!i#n;'S)r;'S;=`*Z<%lO)r8Q#$WX(UpOY#$RZr#$Rrs!Ars#O#$R#O#P!B[#P#Q# o#Q;'S#$R;'S;=`#$s<%lO#$R8Q#$vP;=`<%l#$R8Q#$|P;=`<%l# o=l#%W^$h&j(UpOY#%PYZ&cZr#%Prs!CWs!^#%P!^!_#$R!_#O#%P#O#P!DR#P#Q!Lc#Q#o#%P#o#p#$R#p;'S#%P;'S;=`#&S<%lO#%P=l#&VP;=`<%l#%P=l#&]P;=`<%l!Lc?O#&kn$h&j(Up(X!b!V7`OY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#W%Z#W#X#&`#X#Z%Z#Z#[#&`#[#]%Z#]#^#&`#^#a%Z#a#b#&`#b#g%Z#g#h#&`#h#i%Z#i#j#&`#j#k#&`#k#m%Z#m#n#&`#n#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z9d#(r](Up(X!b!V7`OY#(iZr#(irs!Grsw#(iwx# ox!P#(i!P!Q#)k!Q!}#(i!}#O#+`#O#P!Bq#P;'S#(i;'S;=`#,`<%lO#(i9d#)th(Up(X!b!V7`OY*gZr*grs'}sw*gwx)rx#O*g#P#W*g#W#X#)k#X#Z*g#Z#[#)k#[#]*g#]#^#)k#^#a*g#a#b#)k#b#g*g#g#h#)k#h#i*g#i#j#)k#j#k#)k#k#m*g#m#n#)k#n;'S*g;'S;=`+Z<%lO*g9d#+gZ(Up(X!bOY#+`Zr#+`rs!JUsw#+`wx#$Rx#O#+`#O#P!B[#P#Q#(i#Q;'S#+`;'S;=`#,Y<%lO#+`9d#,]P;=`<%l#+`9d#,cP;=`<%l#(i?O#,o`$h&j(Up(X!bOY#,fYZ&cZr#,frs!KSsw#,fwx#%Px!^#,f!^!_#+`!_#O#,f#O#P!DR#P#Q!;Z#Q#o#,f#o#p#+`#p;'S#,f;'S;=`#-q<%lO#,f?O#-tP;=`<%l#,f?O#-zP;=`<%l!;Z07[#.[b$h&j(Up(X!b'|0/l!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z07[#/o_$h&j(Up(X!bT0/lOY#/dYZ&cZr#/drs#0nsw#/dwx#4Ox!^#/d!^!_#5}!_#O#/d#O#P#1p#P#o#/d#o#p#5}#p;'S#/d;'S;=`#6|<%lO#/d06j#0w]$h&j(X!bT0/lOY#0nYZ&cZw#0nwx#1px!^#0n!^!_#3R!_#O#0n#O#P#1p#P#o#0n#o#p#3R#p;'S#0n;'S;=`#3x<%lO#0n05W#1wX$h&jT0/lOY#1pYZ&cZ!^#1p!^!_#2d!_#o#1p#o#p#2d#p;'S#1p;'S;=`#2{<%lO#1p0/l#2iST0/lOY#2dZ;'S#2d;'S;=`#2u<%lO#2d0/l#2xP;=`<%l#2d05W#3OP;=`<%l#1p01O#3YW(X!bT0/lOY#3RZw#3Rwx#2dx#O#3R#O#P#2d#P;'S#3R;'S;=`#3r<%lO#3R01O#3uP;=`<%l#3R06j#3{P;=`<%l#0n05x#4X]$h&j(UpT0/lOY#4OYZ&cZr#4Ors#1ps!^#4O!^!_#5Q!_#O#4O#O#P#1p#P#o#4O#o#p#5Q#p;'S#4O;'S;=`#5w<%lO#4O00^#5XW(UpT0/lOY#5QZr#5Qrs#2ds#O#5Q#O#P#2d#P;'S#5Q;'S;=`#5q<%lO#5Q00^#5tP;=`<%l#5Q05x#5zP;=`<%l#4O01p#6WY(Up(X!bT0/lOY#5}Zr#5}rs#3Rsw#5}wx#5Qx#O#5}#O#P#2d#P;'S#5};'S;=`#6v<%lO#5}01p#6yP;=`<%l#5}07[#7PP;=`<%l#/d)3h#7ab$h&j$P(Ch(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;ZAt#8vb$Y#t$h&j(Up(X!b!V7`OY!;ZYZ&cZr!;Zrs!<nsw!;Zwx!Lcx!P!;Z!P!Q#&`!Q!^!;Z!^!_#(i!_!}!;Z!}#O#,f#O#P!Dy#P#o!;Z#o#p#(i#p;'S!;Z;'S;=`#-w<%lO!;Z'Ad#:Zp$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#U%Z#U#V#?i#V#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#<jk$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!O%Z!O!P!3Y!P!Q%Z!Q![#<_![!^%Z!^!_*g!_!g%Z!g!h!4|!h#O%Z#O#P&c#P#R%Z#R#S#<_#S#X%Z#X#Y!4|#Y#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$h&j(Up(X!bq'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!e$b$h&j#})Lv(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#P-<U(Up(X!b$m7`OY*gZr*grs'}sw*gwx)rx!P*g!P!Q#MO!Q!^*g!^!_#Mt!_!`$ f!`#O*g#P;'S*g;'S;=`+Z<%lO*g(n#MXX$j&j(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El#M}Z#p(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx!_*g!_!`#Np!`#O*g#P;'S*g;'S;=`+Z<%lO*g(El#NyX$P(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g(El$ oX#q(Ch(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g*)x$!ga#^*!Y$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`!a$#l!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(K[$#w_#i(Cl$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x$%Vag!*r#q(Ch$e#|$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`$&[!`!a$'f!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$&g_#q(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$'qa#p(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`!a$(v!a#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$)R`#p(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(Kd$*`a(p(Ct$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!a%Z!a!b$+e!b#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$+p`$h&j#z(Ch(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z%#`$,}_!z$Ip$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f$.X_!Q0,v$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(n$/]Z$h&jO!^$0O!^!_$0f!_#i$0O#i#j$0k#j#l$0O#l#m$2^#m#o$0O#o#p$0f#p;'S$0O;'S;=`$4i<%lO$0O(n$0VT_#S$h&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c#S$0kO_#S(n$0p[$h&jO!Q&c!Q![$1f![!^&c!_!c&c!c!i$1f!i#T&c#T#Z$1f#Z#o&c#o#p$3|#p;'S&c;'S;=`&w<%lO&c(n$1kZ$h&jO!Q&c!Q![$2^![!^&c!_!c&c!c!i$2^!i#T&c#T#Z$2^#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$2cZ$h&jO!Q&c!Q![$3U![!^&c!_!c&c!c!i$3U!i#T&c#T#Z$3U#Z#o&c#p;'S&c;'S;=`&w<%lO&c(n$3ZZ$h&jO!Q&c!Q![$0O![!^&c!_!c&c!c!i$0O!i#T&c#T#Z$0O#Z#o&c#p;'S&c;'S;=`&w<%lO&c#S$4PR!Q![$4Y!c!i$4Y#T#Z$4Y#S$4]S!Q![$4Y!c!i$4Y#T#Z$4Y#q#r$0f(n$4lP;=`<%l$0O#1[$4z_!W#)l$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW$6U`#w(Ch$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z+;p$7c_$h&j(Up(X!b(_+4QOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$8qk$h&j(Up(X!b(R,2j$^#t(c$I[OY%ZYZ&cZr%Zrs&}st%Ztu$8buw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$8b![!^%Z!^!_*g!_!c%Z!c!}$8b!}#O%Z#O#P&c#P#R%Z#R#S$8b#S#T%Z#T#o$8b#o#p*g#p$g%Z$g;'S$8b;'S;=`$<l<%lO$8b+d$:qk$h&j(Up(X!b$^#tOY%ZYZ&cZr%Zrs&}st%Ztu$:fuw%Zwx(rx}%Z}!O$:f!O!Q%Z!Q![$:f![!^%Z!^!_*g!_!c%Z!c!}$:f!}#O%Z#O#P&c#P#R%Z#R#S$:f#S#T%Z#T#o$:f#o#p*g#p$g%Z$g;'S$:f;'S;=`$<f<%lO$:f+d$<iP;=`<%l$:f07[$<oP;=`<%l$8b#Jf$<{X!]#Hb(Up(X!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g,#x$=sa(w+JY$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p#q$+e#q;'S%Z;'S;=`+a<%lO%Z)>v$?V_![(CdtBr$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!o7`$h&j(Up(X!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$h&j(Up(X!b'z0/l$[#t(R,2j(c$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$h&j(Up(X!b'{0/l$[#t(R,2j(c$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",
-     tokenizers: [noSemicolon, noSemicolonType, operatorToken, jsx, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, insertSemicolon, new LocalTokenGroup("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOv~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!S~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(a~~", 141, 338), new LocalTokenGroup("j~RQYZXz{^~^O(O~~aP!P!Qd~iO(P~~", 25, 321)],
-     topRules: {"Script":[0,7],"SingleExpression":[1,274],"SingleClassItem":[2,275]},
-     dialects: {jsx: 0, ts: 15091},
-     dynamicPrecedences: {"78":1,"80":1,"92":1,"168":1,"198":1},
-     specialized: [{term: 325, get: (value) => spec_identifier[value] || -1},{term: 341, get: (value) => spec_word[value] || -1},{term: 93, get: (value) => spec_LessThan[value] || -1}],
-     tokenPrec: 15116
-   });
-
-   // These are filled with ranges (rangeFrom[i] up to but not including
-   // rangeTo[i]) of code points that count as extending characters.
-   let rangeFrom = [], rangeTo = []
-
-   ;(() => {
-     // Compressed representation of the Grapheme_Cluster_Break=Extend
-     // information from
-     // http://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.
-     // Each pair of elements represents a range, as an offet from the
-     // previous range and a length. Numbers are in base-36, with the empty
-     // string being a shorthand for 1.
-     let numbers = "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s => s ? parseInt(s, 36) : 1);
-     for (let i = 0, n = 0; i < numbers.length; i++)
-       (i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i]);
-   })();
-
-   function isExtendingChar(code) {
-     if (code < 768) return false
-     for (let from = 0, to = rangeFrom.length;;) {
-       let mid = (from + to) >> 1;
-       if (code < rangeFrom[mid]) to = mid;
-       else if (code >= rangeTo[mid]) from = mid + 1;
-       else return true
-       if (from == to) return false
-     }
-   }
-
-   function isRegionalIndicator(code) {
-     return code >= 0x1F1E6 && code <= 0x1F1FF
-   }
-
-   const ZWJ = 0x200d;
-
-   function findClusterBreak$1(str, pos, forward = true, includeExtending = true) {
-     return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)
-   }
-
-   function nextClusterBreak(str, pos, includeExtending) {
-     if (pos == str.length) return pos
-     // If pos is in the middle of a surrogate pair, move to its start
-     if (pos && surrogateLow$1(str.charCodeAt(pos)) && surrogateHigh$1(str.charCodeAt(pos - 1))) pos--;
-     let prev = codePointAt$1(str, pos);
-     pos += codePointSize$1(prev);
-     while (pos < str.length) {
-       let next = codePointAt$1(str, pos);
-       if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {
-         pos += codePointSize$1(next);
-         prev = next;
-       } else if (isRegionalIndicator(next)) {
-         let countBefore = 0, i = pos - 2;
-         while (i >= 0 && isRegionalIndicator(codePointAt$1(str, i))) { countBefore++; i -= 2; }
-         if (countBefore % 2 == 0) break
-         else pos += 2;
-       } else {
-         break
-       }
-     }
-     return pos
-   }
-
-   function prevClusterBreak(str, pos, includeExtending) {
-     while (pos > 0) {
-       let found = nextClusterBreak(str, pos - 2, includeExtending);
-       if (found < pos) return found
-       pos--;
-     }
-     return 0
-   }
-
-   function codePointAt$1(str, pos) {
-     let code0 = str.charCodeAt(pos);
-     if (!surrogateHigh$1(code0) || pos + 1 == str.length) return code0
-     let code1 = str.charCodeAt(pos + 1);
-     if (!surrogateLow$1(code1)) return code0
-     return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000
-   }
-
-   function surrogateLow$1(ch) { return ch >= 0xDC00 && ch < 0xE000 }
-   function surrogateHigh$1(ch) { return ch >= 0xD800 && ch < 0xDC00 }
-   function codePointSize$1(code) { return code < 0x10000 ? 1 : 2 }
-
-   /**
-   The data structure for documents. @nonabstract
-   */
-   class Text {
-       /**
-       Get the line description around the given position.
-       */
-       lineAt(pos) {
-           if (pos < 0 || pos > this.length)
-               throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);
-           return this.lineInner(pos, false, 1, 0);
-       }
-       /**
-       Get the description for the given (1-based) line number.
-       */
-       line(n) {
-           if (n < 1 || n > this.lines)
-               throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);
-           return this.lineInner(n, true, 1, 0);
-       }
-       /**
-       Replace a range of the text with the given content.
-       */
-       replace(from, to, text) {
-           [from, to] = clip(this, from, to);
-           let parts = [];
-           this.decompose(0, from, parts, 2 /* Open.To */);
-           if (text.length)
-               text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);
-           this.decompose(to, this.length, parts, 1 /* Open.From */);
-           return TextNode.from(parts, this.length - (to - from) + text.length);
-       }
-       /**
-       Append another document to this one.
-       */
-       append(other) {
-           return this.replace(this.length, this.length, other);
-       }
-       /**
-       Retrieve the text between the given points.
-       */
-       slice(from, to = this.length) {
-           [from, to] = clip(this, from, to);
-           let parts = [];
-           this.decompose(from, to, parts, 0);
-           return TextNode.from(parts, to - from);
-       }
-       /**
-       Test whether this text is equal to another instance.
-       */
-       eq(other) {
-           if (other == this)
-               return true;
-           if (other.length != this.length || other.lines != this.lines)
-               return false;
-           let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);
-           let a = new RawTextCursor(this), b = new RawTextCursor(other);
-           for (let skip = start, pos = start;;) {
-               a.next(skip);
-               b.next(skip);
-               skip = 0;
-               if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)
-                   return false;
-               pos += a.value.length;
-               if (a.done || pos >= end)
-                   return true;
-           }
-       }
-       /**
-       Iterate over the text. When `dir` is `-1`, iteration happens
-       from end to start. This will return lines and the breaks between
-       them as separate strings.
-       */
-       iter(dir = 1) { return new RawTextCursor(this, dir); }
-       /**
-       Iterate over a range of the text. When `from` > `to`, the
-       iterator will run in reverse.
-       */
-       iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); }
-       /**
-       Return a cursor that iterates over the given range of lines,
-       _without_ returning the line breaks between, and yielding empty
-       strings for empty lines.
-       
-       When `from` and `to` are given, they should be 1-based line numbers.
-       */
-       iterLines(from, to) {
-           let inner;
-           if (from == null) {
-               inner = this.iter();
-           }
-           else {
-               if (to == null)
-                   to = this.lines + 1;
-               let start = this.line(from).from;
-               inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));
-           }
-           return new LineCursor(inner);
-       }
-       /**
-       Return the document as a string, using newline characters to
-       separate lines.
-       */
-       toString() { return this.sliceString(0); }
-       /**
-       Convert the document to an array of lines (which can be
-       deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
-       */
-       toJSON() {
-           let lines = [];
-           this.flatten(lines);
-           return lines;
-       }
-       /**
-       @internal
-       */
-       constructor() { }
-       /**
-       Create a `Text` instance for the given array of lines.
-       */
-       static of(text) {
-           if (text.length == 0)
-               throw new RangeError("A document must have at least one line");
-           if (text.length == 1 && !text[0])
-               return Text.empty;
-           return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
-       }
-   }
-   // Leaves store an array of line strings. There are always line breaks
-   // between these strings. Leaves are limited in size and have to be
-   // contained in TextNode instances for bigger documents.
-   class TextLeaf extends Text {
-       constructor(text, length = textLength(text)) {
-           super();
-           this.text = text;
-           this.length = length;
-       }
-       get lines() { return this.text.length; }
-       get children() { return null; }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let string = this.text[i], end = offset + string.length;
-               if ((isLine ? line : end) >= target)
-                   return new Line(offset, end, line, string);
-               offset = end + 1;
-               line++;
-           }
-       }
-       decompose(from, to, target, open) {
-           let text = from <= 0 && to >= this.length ? this
-               : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
-           if (open & 1 /* Open.From */) {
-               let prev = target.pop();
-               let joined = appendText(text.text, prev.text.slice(), 0, text.length);
-               if (joined.length <= 32 /* Tree.Branch */) {
-                   target.push(new TextLeaf(joined, prev.length + text.length));
-               }
-               else {
-                   let mid = joined.length >> 1;
-                   target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));
-               }
-           }
-           else {
-               target.push(text);
-           }
-       }
-       replace(from, to, text) {
-           if (!(text instanceof TextLeaf))
-               return super.replace(from, to, text);
-           [from, to] = clip(this, from, to);
-           let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
-           let newLen = this.length + text.length - (to - from);
-           if (lines.length <= 32 /* Tree.Branch */)
-               return new TextLeaf(lines, newLen);
-           return TextNode.from(TextLeaf.split(lines, []), newLen);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           [from, to] = clip(this, from, to);
-           let result = "";
-           for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {
-               let line = this.text[i], end = pos + line.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += line.slice(Math.max(0, from - pos), to - pos);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let line of this.text)
-               target.push(line);
-       }
-       scanIdentical() { return 0; }
-       static split(text, target) {
-           let part = [], len = -1;
-           for (let line of text) {
-               part.push(line);
-               len += line.length + 1;
-               if (part.length == 32 /* Tree.Branch */) {
-                   target.push(new TextLeaf(part, len));
-                   part = [];
-                   len = -1;
-               }
-           }
-           if (len > -1)
-               target.push(new TextLeaf(part, len));
-           return target;
-       }
-   }
-   // Nodes provide the tree structure of the `Text` type. They store a
-   // number of other nodes or leaves, taking care to balance themselves
-   // on changes. There are implied line breaks _between_ the children of
-   // a node (but not before the first or after the last child).
-   class TextNode extends Text {
-       constructor(children, length) {
-           super();
-           this.children = children;
-           this.length = length;
-           this.lines = 0;
-           for (let child of children)
-               this.lines += child.lines;
-       }
-       lineInner(target, isLine, line, offset) {
-           for (let i = 0;; i++) {
-               let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;
-               if ((isLine ? endLine : end) >= target)
-                   return child.lineInner(target, isLine, line, offset);
-               offset = end + 1;
-               line = endLine + 1;
-           }
-       }
-       decompose(from, to, target, open) {
-           for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (from <= end && to >= pos) {
-                   let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));
-                   if (pos >= from && end <= to && !childOpen)
-                       target.push(child);
-                   else
-                       child.decompose(from - pos, to - pos, target, childOpen);
-               }
-               pos = end + 1;
-           }
-       }
-       replace(from, to, text) {
-           [from, to] = clip(this, from, to);
-           if (text.lines < this.lines)
-               for (let i = 0, pos = 0; i < this.children.length; i++) {
-                   let child = this.children[i], end = pos + child.length;
-                   // Fast path: if the change only affects one child and the
-                   // child's size remains in the acceptable range, only update
-                   // that child
-                   if (from >= pos && to <= end) {
-                       let updated = child.replace(from - pos, to - pos, text);
-                       let totalLines = this.lines - child.lines + updated.lines;
-                       if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&
-                           updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {
-                           let copy = this.children.slice();
-                           copy[i] = updated;
-                           return new TextNode(copy, this.length - (to - from) + text.length);
-                       }
-                       return super.replace(pos, end, updated);
-                   }
-                   pos = end + 1;
-               }
-           return super.replace(from, to, text);
-       }
-       sliceString(from, to = this.length, lineSep = "\n") {
-           [from, to] = clip(this, from, to);
-           let result = "";
-           for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos > from && i)
-                   result += lineSep;
-               if (from < end && to > pos)
-                   result += child.sliceString(from - pos, to - pos, lineSep);
-               pos = end + 1;
-           }
-           return result;
-       }
-       flatten(target) {
-           for (let child of this.children)
-               child.flatten(target);
-       }
-       scanIdentical(other, dir) {
-           if (!(other instanceof TextNode))
-               return 0;
-           let length = 0;
-           let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]
-               : [this.children.length - 1, other.children.length - 1, -1, -1];
-           for (;; iA += dir, iB += dir) {
-               if (iA == eA || iB == eB)
-                   return length;
-               let chA = this.children[iA], chB = other.children[iB];
-               if (chA != chB)
-                   return length + chA.scanIdentical(chB, dir);
-               length += chA.length + 1;
-           }
-       }
-       static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {
-           let lines = 0;
-           for (let ch of children)
-               lines += ch.lines;
-           if (lines < 32 /* Tree.Branch */) {
-               let flat = [];
-               for (let ch of children)
-                   ch.flatten(flat);
-               return new TextLeaf(flat, length);
-           }
-           let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
-           let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
-           function add(child) {
-               let last;
-               if (child.lines > maxChunk && child instanceof TextNode) {
-                   for (let node of child.children)
-                       add(node);
-               }
-               else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {
-                   flush();
-                   chunked.push(child);
-               }
-               else if (child instanceof TextLeaf && currentLines &&
-                   (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&
-                   child.lines + last.lines <= 32 /* Tree.Branch */) {
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
-               }
-               else {
-                   if (currentLines + child.lines > chunk)
-                       flush();
-                   currentLines += child.lines;
-                   currentLen += child.length + 1;
-                   currentChunk.push(child);
-               }
-           }
-           function flush() {
-               if (currentLines == 0)
-                   return;
-               chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));
-               currentLen = -1;
-               currentLines = currentChunk.length = 0;
-           }
-           for (let child of children)
-               add(child);
-           flush();
-           return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
-       }
-   }
-   Text.empty = /*@__PURE__*/new TextLeaf([""], 0);
-   function textLength(text) {
-       let length = -1;
-       for (let line of text)
-           length += line.length + 1;
-       return length;
-   }
-   function appendText(text, target, from = 0, to = 1e9) {
-       for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {
-           let line = text[i], end = pos + line.length;
-           if (end >= from) {
-               if (end > to)
-                   line = line.slice(0, to - pos);
-               if (pos < from)
-                   line = line.slice(from - pos);
-               if (first) {
-                   target[target.length - 1] += line;
-                   first = false;
-               }
-               else
-                   target.push(line);
-           }
-           pos = end + 1;
-       }
-       return target;
-   }
-   function sliceText(text, from, to) {
-       return appendText(text, [""], from, to);
-   }
-   class RawTextCursor {
-       constructor(text, dir = 1) {
-           this.dir = dir;
-           this.done = false;
-           this.lineBreak = false;
-           this.value = "";
-           this.nodes = [text];
-           this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];
-       }
-       nextInner(skip, dir) {
-           this.done = this.lineBreak = false;
-           for (;;) {
-               let last = this.nodes.length - 1;
-               let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;
-               let size = top instanceof TextLeaf ? top.text.length : top.children.length;
-               if (offset == (dir > 0 ? size : 0)) {
-                   if (last == 0) {
-                       this.done = true;
-                       this.value = "";
-                       return this;
-                   }
-                   if (dir > 0)
-                       this.offsets[last - 1]++;
-                   this.nodes.pop();
-                   this.offsets.pop();
-               }
-               else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {
-                   this.offsets[last] += dir;
-                   if (skip == 0) {
-                       this.lineBreak = true;
-                       this.value = "\n";
-                       return this;
-                   }
-                   skip--;
-               }
-               else if (top instanceof TextLeaf) {
-                   // Move to the next string
-                   let next = top.text[offset + (dir < 0 ? -1 : 0)];
-                   this.offsets[last] += dir;
-                   if (next.length > Math.max(0, skip)) {
-                       this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);
-                       return this;
-                   }
-                   skip -= next.length;
-               }
-               else {
-                   let next = top.children[offset + (dir < 0 ? -1 : 0)];
-                   if (skip > next.length) {
-                       skip -= next.length;
-                       this.offsets[last] += dir;
-                   }
-                   else {
-                       if (dir < 0)
-                           this.offsets[last]--;
-                       this.nodes.push(next);
-                       this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);
-                   }
-               }
-           }
-       }
-       next(skip = 0) {
-           if (skip < 0) {
-               this.nextInner(-skip, (-this.dir));
-               skip = this.value.length;
-           }
-           return this.nextInner(skip, this.dir);
-       }
-   }
-   class PartialTextCursor {
-       constructor(text, start, end) {
-           this.value = "";
-           this.done = false;
-           this.cursor = new RawTextCursor(text, start > end ? -1 : 1);
-           this.pos = start > end ? text.length : 0;
-           this.from = Math.min(start, end);
-           this.to = Math.max(start, end);
-       }
-       nextInner(skip, dir) {
-           if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {
-               this.value = "";
-               this.done = true;
-               return this;
-           }
-           skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);
-           let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;
-           if (skip > limit)
-               skip = limit;
-           limit -= skip;
-           let { value } = this.cursor.next(skip);
-           this.pos += (value.length + skip) * dir;
-           this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);
-           this.done = !this.value;
-           return this;
-       }
-       next(skip = 0) {
-           if (skip < 0)
-               skip = Math.max(skip, this.from - this.pos);
-           else if (skip > 0)
-               skip = Math.min(skip, this.to - this.pos);
-           return this.nextInner(skip, this.cursor.dir);
-       }
-       get lineBreak() { return this.cursor.lineBreak && this.value != ""; }
-   }
-   class LineCursor {
-       constructor(inner) {
-           this.inner = inner;
-           this.afterBreak = true;
-           this.value = "";
-           this.done = false;
-       }
-       next(skip = 0) {
-           let { done, lineBreak, value } = this.inner.next(skip);
-           if (done && this.afterBreak) {
-               this.value = "";
-               this.afterBreak = false;
-           }
-           else if (done) {
-               this.done = true;
-               this.value = "";
-           }
-           else if (lineBreak) {
-               if (this.afterBreak) {
-                   this.value = "";
-               }
-               else {
-                   this.afterBreak = true;
-                   this.next();
-               }
-           }
-           else {
-               this.value = value;
-               this.afterBreak = false;
-           }
-           return this;
-       }
-       get lineBreak() { return false; }
-   }
-   if (typeof Symbol != "undefined") {
-       Text.prototype[Symbol.iterator] = function () { return this.iter(); };
-       RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =
-           LineCursor.prototype[Symbol.iterator] = function () { return this; };
-   }
-   /**
-   This type describes a line in the document. It is created
-   on-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).
-   */
-   class Line {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The position of the start of the line.
-       */
-       from, 
-       /**
-       The position at the end of the line (_before_ the line break,
-       or at the end of document for the last line).
-       */
-       to, 
-       /**
-       This line's line number (1-based).
-       */
-       number, 
-       /**
-       The line's content.
-       */
-       text) {
-           this.from = from;
-           this.to = to;
-           this.number = number;
-           this.text = text;
-       }
-       /**
-       The length of the line (not including any line break after it).
-       */
-       get length() { return this.to - this.from; }
-   }
-   function clip(text, from, to) {
-       from = Math.max(0, Math.min(text.length, from));
-       return [from, Math.max(from, Math.min(text.length, to))];
-   }
-
-   /**
-   Returns a next grapheme cluster break _after_ (not equal to)
-   `pos`, if `forward` is true, or before otherwise. Returns `pos`
-   itself if no further cluster break is available in the string.
-   Moves across surrogate pairs, extending characters (when
-   `includeExtending` is true), characters joined with zero-width
-   joiners, and flag emoji.
-   */
-   function findClusterBreak(str, pos, forward = true, includeExtending = true) {
-       return findClusterBreak$1(str, pos, forward, includeExtending);
-   }
-   function surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000; }
-   function surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00; }
-   /**
-   Find the code point at the given position in a string (like the
-   [`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)
-   string method).
-   */
-   function codePointAt(str, pos) {
-       let code0 = str.charCodeAt(pos);
-       if (!surrogateHigh(code0) || pos + 1 == str.length)
-           return code0;
-       let code1 = str.charCodeAt(pos + 1);
-       if (!surrogateLow(code1))
-           return code0;
-       return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;
-   }
-   /**
-   Given a Unicode codepoint, return the JavaScript string that
-   respresents it (like
-   [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).
-   */
-   function fromCodePoint(code) {
-       if (code <= 0xffff)
-           return String.fromCharCode(code);
-       code -= 0x10000;
-       return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);
-   }
-   /**
-   The amount of positions a character takes up in a JavaScript string.
-   */
-   function codePointSize(code) { return code < 0x10000 ? 1 : 2; }
-
-   const DefaultSplit = /\r\n?|\n/;
-   /**
-   Distinguishes different ways in which positions can be mapped.
-   */
-   var MapMode = /*@__PURE__*/(function (MapMode) {
-       /**
-       Map a position to a valid new position, even when its context
-       was deleted.
-       */
-       MapMode[MapMode["Simple"] = 0] = "Simple";
-       /**
-       Return null if deletion happens across the position.
-       */
-       MapMode[MapMode["TrackDel"] = 1] = "TrackDel";
-       /**
-       Return null if the character _before_ the position is deleted.
-       */
-       MapMode[MapMode["TrackBefore"] = 2] = "TrackBefore";
-       /**
-       Return null if the character _after_ the position is deleted.
-       */
-       MapMode[MapMode["TrackAfter"] = 3] = "TrackAfter";
-   return MapMode})(MapMode || (MapMode = {}));
-   /**
-   A change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)
-   that doesn't store the inserted text. As such, it can't be
-   applied, but is cheaper to store and manipulate.
-   */
-   class ChangeDesc {
-       // Sections are encoded as pairs of integers. The first is the
-       // length in the current document, and the second is -1 for
-       // unaffected sections, and the length of the replacement content
-       // otherwise. So an insertion would be (0, n>0), a deletion (n>0,
-       // 0), and a replacement two positive numbers.
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       @internal
-       */
-       sections) {
-           this.sections = sections;
-       }
-       /**
-       The length of the document before the change.
-       */
-       get length() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2)
-               result += this.sections[i];
-           return result;
-       }
-       /**
-       The length of the document after the change.
-       */
-       get newLength() {
-           let result = 0;
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let ins = this.sections[i + 1];
-               result += ins < 0 ? this.sections[i] : ins;
-           }
-           return result;
-       }
-       /**
-       False when there are actual changes in this set.
-       */
-       get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }
-       /**
-       Iterate over the unchanged parts left by these changes. `posA`
-       provides the position of the range in the old document, `posB`
-       the new position in the changed document.
-       */
-       iterGaps(f) {
-           for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0) {
-                   f(posA, posB, len);
-                   posB += len;
-               }
-               else {
-                   posB += ins;
-               }
-               posA += len;
-           }
-       }
-       /**
-       Iterate over the ranges changed by these changes. (See
-       [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
-       variant that also provides you with the inserted text.)
-       `fromA`/`toA` provides the extent of the change in the starting
-       document, `fromB`/`toB` the extent of the replacement in the
-       changed document.
-       
-       When `individual` is true, adjacent changes (which are kept
-       separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
-       reported separately.
-       */
-       iterChangedRanges(f, individual = false) {
-           iterChanges(this, f, individual);
-       }
-       /**
-       Get a description of the inverted form of these changes.
-       */
-       get invertedDesc() {
-           let sections = [];
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               if (ins < 0)
-                   sections.push(len, ins);
-               else
-                   sections.push(ins, len);
-           }
-           return new ChangeDesc(sections);
-       }
-       /**
-       Compute the combined effect of applying another set of changes
-       after this one. The length of the document after this set should
-       match the length before `other`.
-       */
-       composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets(this, other); }
-       /**
-       Map this description, which should start with the same document
-       as `other`, over another set of changes, so that it can be
-       applied after it. When `before` is true, map as if the changes
-       in `this` happened before the ones in `other`.
-       */
-       mapDesc(other, before = false) { return other.empty ? this : mapSet(this, other, before); }
-       mapPos(pos, assoc = -1, mode = MapMode.Simple) {
-           let posA = 0, posB = 0;
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;
-               if (ins < 0) {
-                   if (endA > pos)
-                       return posB + (pos - posA);
-                   posB += len;
-               }
-               else {
-                   if (mode != MapMode.Simple && endA >= pos &&
-                       (mode == MapMode.TrackDel && posA < pos && endA > pos ||
-                           mode == MapMode.TrackBefore && posA < pos ||
-                           mode == MapMode.TrackAfter && endA > pos))
-                       return null;
-                   if (endA > pos || endA == pos && assoc < 0 && !len)
-                       return pos == posA || assoc < 0 ? posB : posB + ins;
-                   posB += ins;
-               }
-               posA = endA;
-           }
-           if (pos > posA)
-               throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);
-           return posB;
-       }
-       /**
-       Check whether these changes touch a given range. When one of the
-       changes entirely covers the range, the string `"cover"` is
-       returned.
-       */
-       touchesRange(from, to = from) {
-           for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
-               let len = this.sections[i++], ins = this.sections[i++], end = pos + len;
-               if (ins >= 0 && pos <= to && end >= from)
-                   return pos < from && end > to ? "cover" : true;
-               pos = end;
-           }
-           return false;
-       }
-       /**
-       @internal
-       */
-       toString() {
-           let result = "";
-           for (let i = 0; i < this.sections.length;) {
-               let len = this.sections[i++], ins = this.sections[i++];
-               result += (result ? " " : "") + len + (ins >= 0 ? ":" + ins : "");
-           }
-           return result;
-       }
-       /**
-       Serialize this change desc to a JSON-representable value.
-       */
-       toJSON() { return this.sections; }
-       /**
-       Create a change desc from its JSON representation (as produced
-       by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != "number"))
-               throw new RangeError("Invalid JSON representation of ChangeDesc");
-           return new ChangeDesc(json);
-       }
-       /**
-       @internal
-       */
-       static create(sections) { return new ChangeDesc(sections); }
-   }
-   /**
-   A change set represents a group of modifications to a document. It
-   stores the document length, and can only be applied to documents
-   with exactly that length.
-   */
-   class ChangeSet extends ChangeDesc {
-       constructor(sections, 
-       /**
-       @internal
-       */
-       inserted) {
-           super(sections);
-           this.inserted = inserted;
-       }
-       /**
-       Apply the changes to a document, returning the modified
-       document.
-       */
-       apply(doc) {
-           if (this.length != doc.length)
-               throw new RangeError("Applying change set to a document with the wrong length");
-           iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);
-           return doc;
-       }
-       mapDesc(other, before = false) { return mapSet(this, other, before, true); }
-       /**
-       Given the document as it existed _before_ the changes, return a
-       change set that represents the inverse of this set, which could
-       be used to go from the document created by the changes back to
-       the document as it existed before the changes.
-       */
-       invert(doc) {
-           let sections = this.sections.slice(), inserted = [];
-           for (let i = 0, pos = 0; i < sections.length; i += 2) {
-               let len = sections[i], ins = sections[i + 1];
-               if (ins >= 0) {
-                   sections[i] = ins;
-                   sections[i + 1] = len;
-                   let index = i >> 1;
-                   while (inserted.length < index)
-                       inserted.push(Text.empty);
-                   inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);
-               }
-               pos += len;
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       Combine two subsequent change sets into a single set. `other`
-       must start in the document produced by `this`. If `this` goes
-       `docA` → `docB` and `other` represents `docB` → `docC`, the
-       returned value will represent the change `docA` → `docC`.
-       */
-       compose(other) { return this.empty ? other : other.empty ? this : composeSets(this, other, true); }
-       /**
-       Given another change set starting in the same document, maps this
-       change set over the other, producing a new change set that can be
-       applied to the document produced by applying `other`. When
-       `before` is `true`, order changes as if `this` comes before
-       `other`, otherwise (the default) treat `other` as coming first.
-       
-       Given two changes `A` and `B`, `A.compose(B.map(A))` and
-       `B.compose(A.map(B, true))` will produce the same document. This
-       provides a basic form of [operational
-       transformation](https://en.wikipedia.org/wiki/Operational_transformation),
-       and can be used for collaborative editing.
-       */
-       map(other, before = false) { return other.empty ? this : mapSet(this, other, before, true); }
-       /**
-       Iterate over the changed ranges in the document, calling `f` for
-       each, with the range in the original document (`fromA`-`toA`)
-       and the range that replaces it in the new document
-       (`fromB`-`toB`).
-       
-       When `individual` is true, adjacent changes are reported
-       separately.
-       */
-       iterChanges(f, individual = false) {
-           iterChanges(this, f, individual);
-       }
-       /**
-       Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
-       set.
-       */
-       get desc() { return ChangeDesc.create(this.sections); }
-       /**
-       @internal
-       */
-       filter(ranges) {
-           let resultSections = [], resultInserted = [], filteredSections = [];
-           let iter = new SectionIter(this);
-           done: for (let i = 0, pos = 0;;) {
-               let next = i == ranges.length ? 1e9 : ranges[i++];
-               while (pos < next || pos == next && iter.len == 0) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, next - pos);
-                   addSection(filteredSections, len, -1);
-                   let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;
-                   addSection(resultSections, len, ins);
-                   if (ins > 0)
-                       addInsert(resultInserted, resultSections, iter.text);
-                   iter.forward(len);
-                   pos += len;
-               }
-               let end = ranges[i++];
-               while (pos < end) {
-                   if (iter.done)
-                       break done;
-                   let len = Math.min(iter.len, end - pos);
-                   addSection(resultSections, len, -1);
-                   addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);
-                   iter.forward(len);
-                   pos += len;
-               }
-           }
-           return { changes: new ChangeSet(resultSections, resultInserted),
-               filtered: ChangeDesc.create(filteredSections) };
-       }
-       /**
-       Serialize this change set to a JSON-representable value.
-       */
-       toJSON() {
-           let parts = [];
-           for (let i = 0; i < this.sections.length; i += 2) {
-               let len = this.sections[i], ins = this.sections[i + 1];
-               if (ins < 0)
-                   parts.push(len);
-               else if (ins == 0)
-                   parts.push([len]);
-               else
-                   parts.push([len].concat(this.inserted[i >> 1].toJSON()));
-           }
-           return parts;
-       }
-       /**
-       Create a change set for the given changes, for a document of the
-       given length, using `lineSep` as line separator.
-       */
-       static of(changes, length, lineSep) {
-           let sections = [], inserted = [], pos = 0;
-           let total = null;
-           function flush(force = false) {
-               if (!force && !sections.length)
-                   return;
-               if (pos < length)
-                   addSection(sections, length - pos, -1);
-               let set = new ChangeSet(sections, inserted);
-               total = total ? total.compose(set.map(total)) : set;
-               sections = [];
-               inserted = [];
-               pos = 0;
-           }
-           function process(spec) {
-               if (Array.isArray(spec)) {
-                   for (let sub of spec)
-                       process(sub);
-               }
-               else if (spec instanceof ChangeSet) {
-                   if (spec.length != length)
-                       throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
-                   flush();
-                   total = total ? total.compose(spec.map(total)) : spec;
-               }
-               else {
-                   let { from, to = from, insert } = spec;
-                   if (from > to || from < 0 || to > length)
-                       throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
-                   let insText = !insert ? Text.empty : typeof insert == "string" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;
-                   let insLen = insText.length;
-                   if (from == to && insLen == 0)
-                       return;
-                   if (from < pos)
-                       flush();
-                   if (from > pos)
-                       addSection(sections, from - pos, -1);
-                   addSection(sections, to - from, insLen);
-                   addInsert(inserted, sections, insText);
-                   pos = to;
-               }
-           }
-           process(changes);
-           flush(!total);
-           return total;
-       }
-       /**
-       Create an empty changeset of the given length.
-       */
-       static empty(length) {
-           return new ChangeSet(length ? [length, -1] : [], []);
-       }
-       /**
-       Create a changeset from its JSON representation (as produced by
-       [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
-       */
-       static fromJSON(json) {
-           if (!Array.isArray(json))
-               throw new RangeError("Invalid JSON representation of ChangeSet");
-           let sections = [], inserted = [];
-           for (let i = 0; i < json.length; i++) {
-               let part = json[i];
-               if (typeof part == "number") {
-                   sections.push(part, -1);
-               }
-               else if (!Array.isArray(part) || typeof part[0] != "number" || part.some((e, i) => i && typeof e != "string")) {
-                   throw new RangeError("Invalid JSON representation of ChangeSet");
-               }
-               else if (part.length == 1) {
-                   sections.push(part[0], 0);
-               }
-               else {
-                   while (inserted.length < i)
-                       inserted.push(Text.empty);
-                   inserted[i] = Text.of(part.slice(1));
-                   sections.push(part[0], inserted[i].length);
-               }
-           }
-           return new ChangeSet(sections, inserted);
-       }
-       /**
-       @internal
-       */
-       static createSet(sections, inserted) {
-           return new ChangeSet(sections, inserted);
-       }
-   }
-   function addSection(sections, len, ins, forceJoin = false) {
-       if (len == 0 && ins <= 0)
-           return;
-       let last = sections.length - 2;
-       if (last >= 0 && ins <= 0 && ins == sections[last + 1])
-           sections[last] += len;
-       else if (last >= 0 && len == 0 && sections[last] == 0)
-           sections[last + 1] += ins;
-       else if (forceJoin) {
-           sections[last] += len;
-           sections[last + 1] += ins;
-       }
-       else
-           sections.push(len, ins);
-   }
-   function addInsert(values, sections, value) {
-       if (value.length == 0)
-           return;
-       let index = (sections.length - 2) >> 1;
-       if (index < values.length) {
-           values[values.length - 1] = values[values.length - 1].append(value);
-       }
-       else {
-           while (values.length < index)
-               values.push(Text.empty);
-           values.push(value);
-       }
-   }
-   function iterChanges(desc, f, individual) {
-       let inserted = desc.inserted;
-       for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {
-           let len = desc.sections[i++], ins = desc.sections[i++];
-           if (ins < 0) {
-               posA += len;
-               posB += len;
-           }
-           else {
-               let endA = posA, endB = posB, text = Text.empty;
-               for (;;) {
-                   endA += len;
-                   endB += ins;
-                   if (ins && inserted)
-                       text = text.append(inserted[(i - 2) >> 1]);
-                   if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)
-                       break;
-                   len = desc.sections[i++];
-                   ins = desc.sections[i++];
-               }
-               f(posA, endA, posB, endB, text);
-               posA = endA;
-               posB = endB;
-           }
-       }
-   }
-   function mapSet(setA, setB, before, mkSet = false) {
-       // Produce a copy of setA that applies to the document after setB
-       // has been applied (assuming both start at the same document).
-       let sections = [], insert = mkSet ? [] : null;
-       let a = new SectionIter(setA), b = new SectionIter(setB);
-       // Iterate over both sets in parallel. inserted tracks, for changes
-       // in A that have to be processed piece-by-piece, whether their
-       // content has been inserted already, and refers to the section
-       // index.
-       for (let inserted = -1;;) {
-           if (a.done && b.len || b.done && a.len) {
-               throw new Error("Mismatched change set lengths");
-           }
-           else if (a.ins == -1 && b.ins == -1) {
-               // Move across ranges skipped by both sets.
-               let len = Math.min(a.len, b.len);
-               addSection(sections, len, -1);
-               a.forward(len);
-               b.forward(len);
-           }
-           else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {
-               // If there's a change in B that comes before the next change in
-               // A (ordered by start pos, then len, then before flag), skip
-               // that (and process any changes in A it covers).
-               let len = b.len;
-               addSection(sections, b.ins, -1);
-               while (len) {
-                   let piece = Math.min(a.len, len);
-                   if (a.ins >= 0 && inserted < a.i && a.len <= piece) {
-                       addSection(sections, 0, a.ins);
-                       if (insert)
-                           addInsert(insert, sections, a.text);
-                       inserted = a.i;
-                   }
-                   a.forward(piece);
-                   len -= piece;
-               }
-               b.next();
-           }
-           else if (a.ins >= 0) {
-               // Process the part of a change in A up to the start of the next
-               // non-deletion change in B (if overlapping).
-               let len = 0, left = a.len;
-               while (left) {
-                   if (b.ins == -1) {
-                       let piece = Math.min(left, b.len);
-                       len += piece;
-                       left -= piece;
-                       b.forward(piece);
-                   }
-                   else if (b.ins == 0 && b.len < left) {
-                       left -= b.len;
-                       b.next();
-                   }
-                   else {
-                       break;
-                   }
-               }
-               addSection(sections, len, inserted < a.i ? a.ins : 0);
-               if (insert && inserted < a.i)
-                   addInsert(insert, sections, a.text);
-               inserted = a.i;
-               a.forward(a.len - left);
-           }
-           else if (a.done && b.done) {
-               return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
-           }
-           else {
-               throw new Error("Mismatched change set lengths");
-           }
-       }
-   }
-   function composeSets(setA, setB, mkSet = false) {
-       let sections = [];
-       let insert = mkSet ? [] : null;
-       let a = new SectionIter(setA), b = new SectionIter(setB);
-       for (let open = false;;) {
-           if (a.done && b.done) {
-               return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);
-           }
-           else if (a.ins == 0) { // Deletion in A
-               addSection(sections, a.len, 0, open);
-               a.next();
-           }
-           else if (b.len == 0 && !b.done) { // Insertion in B
-               addSection(sections, 0, b.ins, open);
-               if (insert)
-                   addInsert(insert, sections, b.text);
-               b.next();
-           }
-           else if (a.done || b.done) {
-               throw new Error("Mismatched change set lengths");
-           }
-           else {
-               let len = Math.min(a.len2, b.len), sectionLen = sections.length;
-               if (a.ins == -1) {
-                   let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;
-                   addSection(sections, len, insB, open);
-                   if (insert && insB)
-                       addInsert(insert, sections, b.text);
-               }
-               else if (b.ins == -1) {
-                   addSection(sections, a.off ? 0 : a.len, len, open);
-                   if (insert)
-                       addInsert(insert, sections, a.textBit(len));
-               }
-               else {
-                   addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);
-                   if (insert && !b.off)
-                       addInsert(insert, sections, b.text);
-               }
-               open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);
-               a.forward2(len);
-               b.forward(len);
-           }
-       }
-   }
-   class SectionIter {
-       constructor(set) {
-           this.set = set;
-           this.i = 0;
-           this.next();
-       }
-       next() {
-           let { sections } = this.set;
-           if (this.i < sections.length) {
-               this.len = sections[this.i++];
-               this.ins = sections[this.i++];
-           }
-           else {
-               this.len = 0;
-               this.ins = -2;
-           }
-           this.off = 0;
-       }
-       get done() { return this.ins == -2; }
-       get len2() { return this.ins < 0 ? this.len : this.ins; }
-       get text() {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length ? Text.empty : inserted[index];
-       }
-       textBit(len) {
-           let { inserted } = this.set, index = (this.i - 2) >> 1;
-           return index >= inserted.length && !len ? Text.empty
-               : inserted[index].slice(this.off, len == null ? undefined : this.off + len);
-       }
-       forward(len) {
-           if (len == this.len)
-               this.next();
-           else {
-               this.len -= len;
-               this.off += len;
-           }
-       }
-       forward2(len) {
-           if (this.ins == -1)
-               this.forward(len);
-           else if (len == this.ins)
-               this.next();
-           else {
-               this.ins -= len;
-               this.off += len;
-           }
-       }
-   }
-
-   /**
-   A single selection range. When
-   [`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)
-   is enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold
-   multiple ranges. By default, selections hold exactly one range.
-   */
-   class SelectionRange {
-       constructor(
-       /**
-       The lower boundary of the range.
-       */
-       from, 
-       /**
-       The upper boundary of the range.
-       */
-       to, flags) {
-           this.from = from;
-           this.to = to;
-           this.flags = flags;
-       }
-       /**
-       The anchor of the range—the side that doesn't move when you
-       extend it.
-       */
-       get anchor() { return this.flags & 32 /* RangeFlag.Inverted */ ? 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 /* RangeFlag.Inverted */ ? 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 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 16 /* RangeFlag.AssocAfter */ ? 1 : 0; }
-       /**
-       The bidirectional text level associated with this cursor, if
-       any.
-       */
-       get bidiLevel() {
-           let level = this.flags & 7 /* RangeFlag.BidiLevelMask */;
-           return level == 7 ? null : level;
-       }
-       /**
-       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 value = this.flags >> 6 /* RangeFlag.GoalColumnOffset */;
-           return value == 16777215 /* RangeFlag.NoGoalColumn */ ? undefined : value;
-       }
-       /**
-       Map this range through a change, producing a valid range in the
-       updated document.
-       */
-       map(change, assoc = -1) {
-           let from, to;
-           if (this.empty) {
-               from = to = change.mapPos(this.from, assoc);
-           }
-           else {
-               from = change.mapPos(this.from, 1);
-               to = change.mapPos(this.to, -1);
-           }
-           return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
-       }
-       /**
-       Extend this range to cover at least `from` to `to`.
-       */
-       extend(from, to = from) {
-           if (from <= this.anchor && to >= this.anchor)
-               return EditorSelection.range(from, to);
-           let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;
-           return EditorSelection.range(this.anchor, head);
-       }
-       /**
-       Compare this range to another range.
-       */
-       eq(other, includeAssoc = false) {
-           return this.anchor == other.anchor && this.head == other.head &&
-               (!includeAssoc || !this.empty || this.assoc == other.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(json) {
-           if (!json || typeof json.anchor != "number" || typeof json.head != "number")
-               throw new RangeError("Invalid JSON representation for SelectionRange");
-           return EditorSelection.range(json.anchor, json.head);
-       }
-       /**
-       @internal
-       */
-       static create(from, to, flags) {
-           return new SelectionRange(from, to, flags);
-       }
-   }
-   /**
-   An editor selection holds one or more selection ranges.
-   */
-   class EditorSelection {
-       constructor(
-       /**
-       The ranges in the selection, sorted by position. Ranges cannot
-       overlap (but they may touch, if they aren't empty).
-       */
-       ranges, 
-       /**
-       The index of the _main_ range in the selection (which is
-       usually the range that was added last).
-       */
-       mainIndex) {
-           this.ranges = ranges;
-           this.mainIndex = mainIndex;
-       }
-       /**
-       Map a selection through a change. Used to adjust the selection
-       position for changes.
-       */
-       map(change, assoc = -1) {
-           if (change.empty)
-               return this;
-           return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), 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(other, includeAssoc = false) {
-           if (this.ranges.length != other.ranges.length ||
-               this.mainIndex != other.mainIndex)
-               return false;
-           for (let i = 0; i < this.ranges.length; i++)
-               if (!this.ranges[i].eq(other.ranges[i], includeAssoc))
-                   return false;
-           return true;
-       }
-       /**
-       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 EditorSelection([this.main], 0);
-       }
-       /**
-       Extend this selection with an extra range.
-       */
-       addRange(range, main = true) {
-           return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);
-       }
-       /**
-       Replace a given range with another range, and then normalize the
-       selection to merge and sort ranges if necessary.
-       */
-       replaceRange(range, which = this.mainIndex) {
-           let ranges = this.ranges.slice();
-           ranges[which] = range;
-           return EditorSelection.create(ranges, this.mainIndex);
-       }
-       /**
-       Convert this selection to an object that can be serialized to
-       JSON.
-       */
-       toJSON() {
-           return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };
-       }
-       /**
-       Create a selection from a JSON representation.
-       */
-       static fromJSON(json) {
-           if (!json || !Array.isArray(json.ranges) || typeof json.main != "number" || json.main >= json.ranges.length)
-               throw new RangeError("Invalid JSON representation for EditorSelection");
-           return new EditorSelection(json.ranges.map((r) => SelectionRange.fromJSON(r)), json.main);
-       }
-       /**
-       Create a selection holding a single range.
-       */
-       static single(anchor, head = anchor) {
-           return new EditorSelection([EditorSelection.range(anchor, head)], 0);
-       }
-       /**
-       Sort and merge the given set of ranges, creating a valid
-       selection.
-       */
-       static create(ranges, mainIndex = 0) {
-           if (ranges.length == 0)
-               throw new RangeError("A selection needs at least one range");
-           for (let pos = 0, i = 0; i < ranges.length; i++) {
-               let range = ranges[i];
-               if (range.empty ? range.from <= pos : range.from < pos)
-                   return EditorSelection.normalized(ranges.slice(), mainIndex);
-               pos = range.to;
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-       /**
-       Create a cursor selection range at the given position. You can
-       safely ignore the optional arguments in most situations.
-       */
-       static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
-           return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */) |
-               (bidiLevel == null ? 7 : Math.min(6, bidiLevel)) |
-               ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */));
-       }
-       /**
-       Create a selection range.
-       */
-       static range(anchor, head, goalColumn, bidiLevel) {
-           let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 16777215 /* RangeFlag.NoGoalColumn */) << 6 /* RangeFlag.GoalColumnOffset */) |
-               (bidiLevel == null ? 7 : Math.min(6, bidiLevel));
-           return head < anchor ? SelectionRange.create(head, anchor, 32 /* RangeFlag.Inverted */ | 16 /* RangeFlag.AssocAfter */ | flags)
-               : SelectionRange.create(anchor, head, (head > anchor ? 8 /* RangeFlag.AssocBefore */ : 0) | flags);
-       }
-       /**
-       @internal
-       */
-       static normalized(ranges, mainIndex = 0) {
-           let main = ranges[mainIndex];
-           ranges.sort((a, b) => a.from - b.from);
-           mainIndex = ranges.indexOf(main);
-           for (let i = 1; i < ranges.length; i++) {
-               let range = ranges[i], prev = ranges[i - 1];
-               if (range.empty ? range.from <= prev.to : range.from < prev.to) {
-                   let from = prev.from, to = Math.max(range.to, prev.to);
-                   if (i <= mainIndex)
-                       mainIndex--;
-                   ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));
-               }
-           }
-           return new EditorSelection(ranges, mainIndex);
-       }
-   }
-   function checkSelection(selection, docLength) {
-       for (let range of selection.ranges)
-           if (range.to > docLength)
-               throw new RangeError("Selection points outside of document");
-   }
-
-   let nextID = 0;
-   /**
-   A facet is a labeled value that is associated with an editor
-   state. It takes inputs from any number of extensions, and combines
-   those into a single output value.
-
-   Examples of uses of facets are the [tab
-   size](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor
-   attributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update
-   listeners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).
-
-   Note that `Facet` instances can be used anywhere where
-   [`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.
-   */
-   class Facet {
-       constructor(
-       /**
-       @internal
-       */
-       combine, 
-       /**
-       @internal
-       */
-       compareInput, 
-       /**
-       @internal
-       */
-       compare, isStatic, enables) {
-           this.combine = combine;
-           this.compareInput = compareInput;
-           this.compare = compare;
-           this.isStatic = isStatic;
-           /**
-           @internal
-           */
-           this.id = nextID++;
-           this.default = combine([]);
-           this.extensions = typeof enables == "function" ? enables(this) : enables;
-       }
-       /**
-       Returns a facet reader for this facet, which can be used to
-       [read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
-       */
-       get reader() { return this; }
-       /**
-       Define a new facet.
-       */
-       static define(config = {}) {
-           return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables);
-       }
-       /**
-       Returns an extension that adds the given value to this facet.
-       */
-       of(value) {
-           return new FacetProvider([], this, 0 /* Provider.Static */, value);
-       }
-       /**
-       Create an extension that computes a value for the facet from a
-       state. You must take care to declare the parts of the state that
-       this value depends on, since your function is only called again
-       for a new state when one of those parts changed.
-       
-       In cases where your value depends only on a single field, you'll
-       want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
-       */
-       compute(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider(deps, this, 1 /* Provider.Single */, get);
-       }
-       /**
-       Create an extension that computes zero or more values for this
-       facet from a state.
-       */
-       computeN(deps, get) {
-           if (this.isStatic)
-               throw new Error("Can't compute a static facet");
-           return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);
-       }
-       from(field, get) {
-           if (!get)
-               get = x => x;
-           return this.compute([field], state => get(state.field(field)));
-       }
-   }
-   function sameArray(a, b) {
-       return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
-   }
-   class FacetProvider {
-       constructor(dependencies, facet, type, value) {
-           this.dependencies = dependencies;
-           this.facet = facet;
-           this.type = type;
-           this.value = value;
-           this.id = nextID++;
-       }
-       dynamicSlot(addresses) {
-           var _a;
-           let getter = this.value;
-           let compare = this.facet.compareInput;
-           let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;
-           let depDoc = false, depSel = false, depAddrs = [];
-           for (let dep of this.dependencies) {
-               if (dep == "doc")
-                   depDoc = true;
-               else if (dep == "selection")
-                   depSel = true;
-               else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)
-                   depAddrs.push(addresses[dep.id]);
-           }
-           return {
-               create(state) {
-                   state.values[idx] = getter(state);
-                   return 1 /* SlotStatus.Changed */;
-               },
-               update(state, tr) {
-                   if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {
-                       let newVal = getter(state);
-                       if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
-                           state.values[idx] = newVal;
-                           return 1 /* SlotStatus.Changed */;
-                       }
-                   }
-                   return 0;
-               },
-               reconfigure: (state, oldState) => {
-                   let newVal, oldAddr = oldState.config.address[id];
-                   if (oldAddr != null) {
-                       let oldVal = getAddr(oldState, oldAddr);
-                       if (this.dependencies.every(dep => {
-                           return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :
-                               dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
-                       }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {
-                           state.values[idx] = oldVal;
-                           return 0;
-                       }
-                   }
-                   else {
-                       newVal = getter(state);
-                   }
-                   state.values[idx] = newVal;
-                   return 1 /* SlotStatus.Changed */;
-               }
-           };
-       }
-   }
-   function compareArray(a, b, compare) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (!compare(a[i], b[i]))
-               return false;
-       return true;
-   }
-   function ensureAll(state, addrs) {
-       let changed = false;
-       for (let addr of addrs)
-           if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)
-               changed = true;
-       return changed;
-   }
-   function dynamicFacetSlot(addresses, facet, providers) {
-       let providerAddrs = providers.map(p => addresses[p.id]);
-       let providerTypes = providers.map(p => p.type);
-       let dynamic = providerAddrs.filter(p => !(p & 1));
-       let idx = addresses[facet.id] >> 1;
-       function get(state) {
-           let values = [];
-           for (let i = 0; i < providerAddrs.length; i++) {
-               let value = getAddr(state, providerAddrs[i]);
-               if (providerTypes[i] == 2 /* Provider.Multi */)
-                   for (let val of value)
-                       values.push(val);
-               else
-                   values.push(value);
-           }
-           return facet.combine(values);
-       }
-       return {
-           create(state) {
-               for (let addr of providerAddrs)
-                   ensureAddr(state, addr);
-               state.values[idx] = get(state);
-               return 1 /* SlotStatus.Changed */;
-           },
-           update(state, tr) {
-               if (!ensureAll(state, dynamic))
-                   return 0;
-               let value = get(state);
-               if (facet.compare(value, state.values[idx]))
-                   return 0;
-               state.values[idx] = value;
-               return 1 /* SlotStatus.Changed */;
-           },
-           reconfigure(state, oldState) {
-               let depChanged = ensureAll(state, providerAddrs);
-               let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
-               if (oldProviders && !depChanged && sameArray(providers, oldProviders)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               let value = get(state);
-               if (facet.compare(value, oldValue)) {
-                   state.values[idx] = oldValue;
-                   return 0;
-               }
-               state.values[idx] = value;
-               return 1 /* SlotStatus.Changed */;
-           }
-       };
-   }
-   const initField = /*@__PURE__*/Facet.define({ static: true });
-   /**
-   Fields can store additional information in an editor state, and
-   keep it in sync with the rest of the state.
-   */
-   class StateField {
-       constructor(
-       /**
-       @internal
-       */
-       id, createF, updateF, compareF, 
-       /**
-       @internal
-       */
-       spec) {
-           this.id = id;
-           this.createF = createF;
-           this.updateF = updateF;
-           this.compareF = compareF;
-           this.spec = spec;
-           /**
-           @internal
-           */
-           this.provides = undefined;
-       }
-       /**
-       Define a state field.
-       */
-       static define(config) {
-           let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);
-           if (config.provide)
-               field.provides = config.provide(field);
-           return field;
-       }
-       create(state) {
-           let init = state.facet(initField).find(i => i.field == this);
-           return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);
-       }
-       /**
-       @internal
-       */
-       slot(addresses) {
-           let idx = addresses[this.id] >> 1;
-           return {
-               create: (state) => {
-                   state.values[idx] = this.create(state);
-                   return 1 /* SlotStatus.Changed */;
-               },
-               update: (state, tr) => {
-                   let oldVal = state.values[idx];
-                   let value = this.updateF(oldVal, tr);
-                   if (this.compareF(oldVal, value))
-                       return 0;
-                   state.values[idx] = value;
-                   return 1 /* SlotStatus.Changed */;
-               },
-               reconfigure: (state, oldState) => {
-                   if (oldState.config.address[this.id] != null) {
-                       state.values[idx] = oldState.field(this);
-                       return 0;
-                   }
-                   state.values[idx] = this.create(state);
-                   return 1 /* SlotStatus.Changed */;
-               }
-           };
-       }
-       /**
-       Returns an extension that enables this field and overrides the
-       way it is initialized. Can be useful when you need to provide a
-       non-default starting value for the field.
-       */
-       init(create) {
-           return [this, initField.of({ field: this, create })];
-       }
-       /**
-       State field instances can be used as
-       [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
-       given state.
-       */
-       get extension() { return this; }
-   }
-   const Prec_ = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
-   function prec(value) {
-       return (ext) => new PrecExtension(ext, value);
-   }
-   /**
-   By default extensions are registered in the order they are found
-   in the flattened form of nested array that was provided.
-   Individual extension values can be assigned a precedence to
-   override this. Extensions that do not have a precedence set get
-   the precedence of the nearest parent with a precedence, or
-   [`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The
-   final ordering of extensions is determined by first sorting by
-   precedence and then by order within each precedence.
-   */
-   const Prec = {
-       /**
-       The highest precedence level, for extensions that should end up
-       near the start of the precedence ordering.
-       */
-       highest: /*@__PURE__*/prec(Prec_.highest),
-       /**
-       A higher-than-default precedence, for extensions that should
-       come before those with default precedence.
-       */
-       high: /*@__PURE__*/prec(Prec_.high),
-       /**
-       The default precedence, which is also used for extensions
-       without an explicit precedence.
-       */
-       default: /*@__PURE__*/prec(Prec_.default),
-       /**
-       A lower-than-default precedence.
-       */
-       low: /*@__PURE__*/prec(Prec_.low),
-       /**
-       The lowest precedence level. Meant for things that should end up
-       near the end of the extension order.
-       */
-       lowest: /*@__PURE__*/prec(Prec_.lowest)
-   };
-   class PrecExtension {
-       constructor(inner, prec) {
-           this.inner = inner;
-           this.prec = prec;
-       }
-   }
-   /**
-   Extension compartments can be used to make a configuration
-   dynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your
-   configuration in a compartment, you can later
-   [replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a
-   transaction.
-   */
-   class Compartment {
-       /**
-       Create an instance of this compartment to add to your [state
-       configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
-       */
-       of(ext) { return new CompartmentInstance(this, ext); }
-       /**
-       Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
-       reconfigures this compartment.
-       */
-       reconfigure(content) {
-           return Compartment.reconfigure.of({ compartment: this, extension: content });
-       }
-       /**
-       Get the current content of the compartment in the state, or
-       `undefined` if it isn't present.
-       */
-       get(state) {
-           return state.config.compartments.get(this);
-       }
-   }
-   class CompartmentInstance {
-       constructor(compartment, inner) {
-           this.compartment = compartment;
-           this.inner = inner;
-       }
-   }
-   class Configuration {
-       constructor(base, compartments, dynamicSlots, address, staticValues, facets) {
-           this.base = base;
-           this.compartments = compartments;
-           this.dynamicSlots = dynamicSlots;
-           this.address = address;
-           this.staticValues = staticValues;
-           this.facets = facets;
-           this.statusTemplate = [];
-           while (this.statusTemplate.length < dynamicSlots.length)
-               this.statusTemplate.push(0 /* SlotStatus.Unresolved */);
-       }
-       staticFacet(facet) {
-           let addr = this.address[facet.id];
-           return addr == null ? facet.default : this.staticValues[addr >> 1];
-       }
-       static resolve(base, compartments, oldState) {
-           let fields = [];
-           let facets = Object.create(null);
-           let newCompartments = new Map();
-           for (let ext of flatten(base, compartments, newCompartments)) {
-               if (ext instanceof StateField)
-                   fields.push(ext);
-               else
-                   (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);
-           }
-           let address = Object.create(null);
-           let staticValues = [];
-           let dynamicSlots = [];
-           for (let field of fields) {
-               address[field.id] = dynamicSlots.length << 1;
-               dynamicSlots.push(a => field.slot(a));
-           }
-           let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
-           for (let id in facets) {
-               let providers = facets[id], facet = providers[0].facet;
-               let oldProviders = oldFacets && oldFacets[id] || [];
-               if (providers.every(p => p.type == 0 /* Provider.Static */)) {
-                   address[facet.id] = (staticValues.length << 1) | 1;
-                   if (sameArray(oldProviders, providers)) {
-                       staticValues.push(oldState.facet(facet));
-                   }
-                   else {
-                       let value = facet.combine(providers.map(p => p.value));
-                       staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
-                   }
-               }
-               else {
-                   for (let p of providers) {
-                       if (p.type == 0 /* Provider.Static */) {
-                           address[p.id] = (staticValues.length << 1) | 1;
-                           staticValues.push(p.value);
-                       }
-                       else {
-                           address[p.id] = dynamicSlots.length << 1;
-                           dynamicSlots.push(a => p.dynamicSlot(a));
-                       }
-                   }
-                   address[facet.id] = dynamicSlots.length << 1;
-                   dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));
-               }
-           }
-           let dynamic = dynamicSlots.map(f => f(address));
-           return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);
-       }
-   }
-   function flatten(extension, compartments, newCompartments) {
-       let result = [[], [], [], [], []];
-       let seen = new Map();
-       function inner(ext, prec) {
-           let known = seen.get(ext);
-           if (known != null) {
-               if (known <= prec)
-                   return;
-               let found = result[known].indexOf(ext);
-               if (found > -1)
-                   result[known].splice(found, 1);
-               if (ext instanceof CompartmentInstance)
-                   newCompartments.delete(ext.compartment);
-           }
-           seen.set(ext, prec);
-           if (Array.isArray(ext)) {
-               for (let e of ext)
-                   inner(e, prec);
-           }
-           else if (ext instanceof CompartmentInstance) {
-               if (newCompartments.has(ext.compartment))
-                   throw new RangeError(`Duplicate use of compartment in extensions`);
-               let content = compartments.get(ext.compartment) || ext.inner;
-               newCompartments.set(ext.compartment, content);
-               inner(content, prec);
-           }
-           else if (ext instanceof PrecExtension) {
-               inner(ext.inner, ext.prec);
-           }
-           else if (ext instanceof StateField) {
-               result[prec].push(ext);
-               if (ext.provides)
-                   inner(ext.provides, prec);
-           }
-           else if (ext instanceof FacetProvider) {
-               result[prec].push(ext);
-               if (ext.facet.extensions)
-                   inner(ext.facet.extensions, Prec_.default);
-           }
-           else {
-               let content = ext.extension;
-               if (!content)
-                   throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
-               inner(content, prec);
-           }
-       }
-       inner(extension, Prec_.default);
-       return result.reduce((a, b) => a.concat(b));
-   }
-   function ensureAddr(state, addr) {
-       if (addr & 1)
-           return 2 /* SlotStatus.Computed */;
-       let idx = addr >> 1;
-       let status = state.status[idx];
-       if (status == 4 /* SlotStatus.Computing */)
-           throw new Error("Cyclic dependency between fields and/or facets");
-       if (status & 2 /* SlotStatus.Computed */)
-           return status;
-       state.status[idx] = 4 /* SlotStatus.Computing */;
-       let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
-       return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;
-   }
-   function getAddr(state, addr) {
-       return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
-   }
-
-   const languageData = /*@__PURE__*/Facet.define();
-   const allowMultipleSelections = /*@__PURE__*/Facet.define({
-       combine: values => values.some(v => v),
-       static: true
-   });
-   const lineSeparator = /*@__PURE__*/Facet.define({
-       combine: values => values.length ? values[0] : undefined,
-       static: true
-   });
-   const changeFilter = /*@__PURE__*/Facet.define();
-   const transactionFilter = /*@__PURE__*/Facet.define();
-   const transactionExtender = /*@__PURE__*/Facet.define();
-   const readOnly = /*@__PURE__*/Facet.define({
-       combine: values => values.length ? values[0] : false
-   });
-
-   /**
-   Annotations are tagged values that are used to add metadata to
-   transactions in an extensible way. They should be used to model
-   things that effect the entire transaction (such as its [time
-   stamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its
-   [origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen
-   _alongside_ the other changes made by the transaction, [state
-   effects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.
-   */
-   class Annotation {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The annotation type.
-       */
-       type, 
-       /**
-       The value of this annotation.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Define a new type of annotation.
-       */
-       static define() { return new AnnotationType(); }
-   }
-   /**
-   Marker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).
-   */
-   class AnnotationType {
-       /**
-       Create an instance of this annotation.
-       */
-       of(value) { return new Annotation(this, value); }
-   }
-   /**
-   Representation of a type of state effect. Defined with
-   [`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).
-   */
-   class StateEffectType {
-       /**
-       @internal
-       */
-       constructor(
-       // The `any` types in these function types are there to work
-       // around TypeScript issue #37631, where the type guard on
-       // `StateEffect.is` mysteriously stops working when these properly
-       // have type `Value`.
-       /**
-       @internal
-       */
-       map) {
-           this.map = map;
-       }
-       /**
-       Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
-       type.
-       */
-       of(value) { return new StateEffect(this, value); }
-   }
-   /**
-   State effects can be used to represent additional effects
-   associated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They
-   are often useful to model changes to custom [state
-   fields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in
-   document or selection changes.
-   */
-   class StateEffect {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       @internal
-       */
-       type, 
-       /**
-       The value of this effect.
-       */
-       value) {
-           this.type = type;
-           this.value = value;
-       }
-       /**
-       Map this effect through a position mapping. Will return
-       `undefined` when that ends up deleting the effect.
-       */
-       map(mapping) {
-           let mapped = this.type.map(this.value, mapping);
-           return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);
-       }
-       /**
-       Tells you whether this effect object is of a given
-       [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
-       */
-       is(type) { return this.type == type; }
-       /**
-       Define a new effect type. The type parameter indicates the type
-       of values that his effect holds. It should be a type that
-       doesn't include `undefined`, since that is used in
-       [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
-       removed.
-       */
-       static define(spec = {}) {
-           return new StateEffectType(spec.map || (v => v));
-       }
-       /**
-       Map an array of effects through a change set.
-       */
-       static mapEffects(effects, mapping) {
-           if (!effects.length)
-               return effects;
-           let result = [];
-           for (let effect of effects) {
-               let mapped = effect.map(mapping);
-               if (mapped)
-                   result.push(mapped);
-           }
-           return result;
-       }
-   }
-   /**
-   This effect can be used to reconfigure the root extensions of
-   the editor. Doing this will discard any extensions
-   [appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset
-   the content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)
-   compartments.
-   */
-   StateEffect.reconfigure = /*@__PURE__*/StateEffect.define();
-   /**
-   Append extensions to the top-level configuration of the editor.
-   */
-   StateEffect.appendConfig = /*@__PURE__*/StateEffect.define();
-   /**
-   Changes to the editor state are grouped into transactions.
-   Typically, a user action creates a single transaction, which may
-   contain any number of document changes, may change the selection,
-   or have other effects. Create a transaction by calling
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately
-   dispatch one by calling
-   [`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).
-   */
-   class Transaction {
-       constructor(
-       /**
-       The state from which the transaction starts.
-       */
-       startState, 
-       /**
-       The document changes made by this transaction.
-       */
-       changes, 
-       /**
-       The selection set by this transaction, or undefined if it
-       doesn't explicitly set a selection.
-       */
-       selection, 
-       /**
-       The effects added to the transaction.
-       */
-       effects, 
-       /**
-       @internal
-       */
-       annotations, 
-       /**
-       Whether the selection should be scrolled into view after this
-       transaction is dispatched.
-       */
-       scrollIntoView) {
-           this.startState = startState;
-           this.changes = changes;
-           this.selection = selection;
-           this.effects = effects;
-           this.annotations = annotations;
-           this.scrollIntoView = scrollIntoView;
-           /**
-           @internal
-           */
-           this._doc = null;
-           /**
-           @internal
-           */
-           this._state = null;
-           if (selection)
-               checkSelection(selection, changes.newLength);
-           if (!annotations.some((a) => a.type == Transaction.time))
-               this.annotations = annotations.concat(Transaction.time.of(Date.now()));
-       }
-       /**
-       @internal
-       */
-       static create(startState, changes, selection, effects, annotations, scrollIntoView) {
-           return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);
-       }
-       /**
-       The new document produced by the transaction. Contrary to
-       [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
-       force the entire new state to be computed right away, so it is
-       recommended that [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
-       when they need to look at the new document.
-       */
-       get newDoc() {
-           return this._doc || (this._doc = this.changes.apply(this.startState.doc));
-       }
-       /**
-       The new selection produced by the transaction. If
-       [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
-       this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
-       current selection through the changes made by the transaction.
-       */
-       get newSelection() {
-           return this.selection || this.startState.selection.map(this.changes);
-       }
-       /**
-       The new state created by the transaction. Computed on demand
-       (but retained for subsequent access), so it is recommended not to
-       access it in [transaction
-       filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
-       */
-       get state() {
-           if (!this._state)
-               this.startState.applyTransaction(this);
-           return this._state;
-       }
-       /**
-       Get the value of the given annotation type, if any.
-       */
-       annotation(type) {
-           for (let ann of this.annotations)
-               if (ann.type == type)
-                   return ann.value;
-           return undefined;
-       }
-       /**
-       Indicates whether the transaction changed the document.
-       */
-       get docChanged() { return !this.changes.empty; }
-       /**
-       Indicates whether this transaction reconfigures the state
-       (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
-       with a top-level configuration
-       [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
-       */
-       get reconfigured() { return this.startState.config != this.state.config; }
-       /**
-       Returns true if the transaction has a [user
-       event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
-       or more specific than `event`. For example, if the transaction
-       has `"select.pointer"` as user event, `"select"` and
-       `"select.pointer"` will match it.
-       */
-       isUserEvent(event) {
-           let e = this.annotation(Transaction.userEvent);
-           return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == "."));
-       }
-   }
-   /**
-   Annotation used to store transaction timestamps. Automatically
-   added to every transaction, holding `Date.now()`.
-   */
-   Transaction.time = /*@__PURE__*/Annotation.define();
-   /**
-   Annotation used to associate a transaction with a user interface
-   event. Holds a string identifying the event, using a
-   dot-separated format to support attaching more specific
-   information. The events used by the core libraries are:
-
-    - `"input"` when content is entered
-      - `"input.type"` for typed input
-        - `"input.type.compose"` for composition
-      - `"input.paste"` for pasted input
-      - `"input.drop"` when adding content with drag-and-drop
-      - `"input.complete"` when autocompleting
-    - `"delete"` when the user deletes content
-      - `"delete.selection"` when deleting the selection
-      - `"delete.forward"` when deleting forward from the selection
-      - `"delete.backward"` when deleting backward from the selection
-      - `"delete.cut"` when cutting to the clipboard
-    - `"move"` when content is moved
-      - `"move.drop"` when content is moved within the editor through drag-and-drop
-    - `"select"` when explicitly changing the selection
-      - `"select.pointer"` when selecting with a mouse or other pointing device
-    - `"undo"` and `"redo"` for history actions
-
-   Use [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check
-   whether the annotation matches a given event.
-   */
-   Transaction.userEvent = /*@__PURE__*/Annotation.define();
-   /**
-   Annotation indicating whether a transaction should be added to
-   the undo history or not.
-   */
-   Transaction.addToHistory = /*@__PURE__*/Annotation.define();
-   /**
-   Annotation indicating (when present and true) that a transaction
-   represents a change made by some other actor, not the user. This
-   is used, for example, to tag other people's changes in
-   collaborative editing.
-   */
-   Transaction.remote = /*@__PURE__*/Annotation.define();
-   function joinRanges(a, b) {
-       let result = [];
-       for (let iA = 0, iB = 0;;) {
-           let from, to;
-           if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {
-               from = a[iA++];
-               to = a[iA++];
-           }
-           else if (iB < b.length) {
-               from = b[iB++];
-               to = b[iB++];
-           }
-           else
-               return result;
-           if (!result.length || result[result.length - 1] < from)
-               result.push(from, to);
-           else if (result[result.length - 1] < to)
-               result[result.length - 1] = to;
-       }
-   }
-   function mergeTransaction(a, b, sequential) {
-       var _a;
-       let mapForA, mapForB, changes;
-       if (sequential) {
-           mapForA = b.changes;
-           mapForB = ChangeSet.empty(b.changes.length);
-           changes = a.changes.compose(b.changes);
-       }
-       else {
-           mapForA = b.changes.map(a.changes);
-           mapForB = a.changes.mapDesc(b.changes, true);
-           changes = a.changes.compose(mapForA);
-       }
-       return {
-           changes,
-           selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),
-           effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),
-           annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,
-           scrollIntoView: a.scrollIntoView || b.scrollIntoView
-       };
-   }
-   function resolveTransactionInner(state, spec, docSize) {
-       let sel = spec.selection, annotations = asArray$1(spec.annotations);
-       if (spec.userEvent)
-           annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));
-       return {
-           changes: spec.changes instanceof ChangeSet ? spec.changes
-               : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),
-           selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),
-           effects: asArray$1(spec.effects),
-           annotations,
-           scrollIntoView: !!spec.scrollIntoView
-       };
-   }
-   function resolveTransaction(state, specs, filter) {
-       let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);
-       if (specs.length && specs[0].filter === false)
-           filter = false;
-       for (let i = 1; i < specs.length; i++) {
-           if (specs[i].filter === false)
-               filter = false;
-           let seq = !!specs[i].sequential;
-           s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);
-       }
-       let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);
-       return extendTransaction(filter ? filterTransaction(tr) : tr);
-   }
-   // Finish a transaction by applying filters if necessary.
-   function filterTransaction(tr) {
-       let state = tr.startState;
-       // Change filters
-       let result = true;
-       for (let filter of state.facet(changeFilter)) {
-           let value = filter(tr);
-           if (value === false) {
-               result = false;
-               break;
-           }
-           if (Array.isArray(value))
-               result = result === true ? value : joinRanges(result, value);
-       }
-       if (result !== true) {
-           let changes, back;
-           if (result === false) {
-               back = tr.changes.invertedDesc;
-               changes = ChangeSet.empty(state.doc.length);
-           }
-           else {
-               let filtered = tr.changes.filter(result);
-               changes = filtered.changes;
-               back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;
-           }
-           tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);
-       }
-       // Transaction filters
-       let filters = state.facet(transactionFilter);
-       for (let i = filters.length - 1; i >= 0; i--) {
-           let filtered = filters[i](tr);
-           if (filtered instanceof Transaction)
-               tr = filtered;
-           else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction)
-               tr = filtered[0];
-           else
-               tr = resolveTransaction(state, asArray$1(filtered), false);
-       }
-       return tr;
-   }
-   function extendTransaction(tr) {
-       let state = tr.startState, extenders = state.facet(transactionExtender), spec = tr;
-       for (let i = extenders.length - 1; i >= 0; i--) {
-           let extension = extenders[i](tr);
-           if (extension && Object.keys(extension).length)
-               spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
-       }
-       return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
-   }
-   const none$1 = [];
-   function asArray$1(value) {
-       return value == null ? none$1 : Array.isArray(value) ? value : [value];
-   }
-
-   /**
-   The categories produced by a [character
-   categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used
-   do things like selecting by word.
-   */
-   var CharCategory = /*@__PURE__*/(function (CharCategory) {
-       /**
-       Word characters.
-       */
-       CharCategory[CharCategory["Word"] = 0] = "Word";
-       /**
-       Whitespace.
-       */
-       CharCategory[CharCategory["Space"] = 1] = "Space";
-       /**
-       Anything else.
-       */
-       CharCategory[CharCategory["Other"] = 2] = "Other";
-   return CharCategory})(CharCategory || (CharCategory = {}));
-   const nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
-   let wordChar;
-   try {
-       wordChar = /*@__PURE__*/new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
-   }
-   catch (_) { }
-   function hasWordChar(str) {
-       if (wordChar)
-           return wordChar.test(str);
-       for (let i = 0; i < str.length; i++) {
-           let ch = str[i];
-           if (/\w/.test(ch) || ch > "\x80" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)))
-               return true;
-       }
-       return false;
-   }
-   function makeCategorizer(wordChars) {
-       return (char) => {
-           if (!/\S/.test(char))
-               return CharCategory.Space;
-           if (hasWordChar(char))
-               return CharCategory.Word;
-           for (let i = 0; i < wordChars.length; i++)
-               if (char.indexOf(wordChars[i]) > -1)
-                   return CharCategory.Word;
-           return CharCategory.Other;
-       };
-   }
-
-   /**
-   The editor state class is a persistent (immutable) data structure.
-   To update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a
-   [transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state
-   instance, without modifying the original object.
-
-   As such, _never_ mutate properties of a state directly. That'll
-   just break things.
-   */
-   class EditorState {
-       constructor(
-       /**
-       @internal
-       */
-       config, 
-       /**
-       The current document.
-       */
-       doc, 
-       /**
-       The current selection.
-       */
-       selection, 
-       /**
-       @internal
-       */
-       values, computeSlot, tr) {
-           this.config = config;
-           this.doc = doc;
-           this.selection = selection;
-           this.values = values;
-           this.status = config.statusTemplate.slice();
-           this.computeSlot = computeSlot;
-           // Fill in the computed state immediately, so that further queries
-           // for it made during the update return this state
-           if (tr)
-               tr._state = this;
-           for (let i = 0; i < this.config.dynamicSlots.length; i++)
-               ensureAddr(this, i << 1);
-           this.computeSlot = null;
-       }
-       field(field, require = true) {
-           let addr = this.config.address[field.id];
-           if (addr == null) {
-               if (require)
-                   throw new RangeError("Field is not present in this state");
-               return undefined;
-           }
-           ensureAddr(this, addr);
-           return getAddr(this, addr);
-       }
-       /**
-       Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
-       state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
-       can be passed. Unless
-       [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
-       [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
-       are assumed to start in the _current_ document (not the document
-       produced by previous specs), and its
-       [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
-       [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
-       to the document created by its _own_ changes. The resulting
-       transaction contains the combined effect of all the different
-       specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
-       specs take precedence over earlier ones.
-       */
-       update(...specs) {
-           return resolveTransaction(this, specs, true);
-       }
-       /**
-       @internal
-       */
-       applyTransaction(tr) {
-           let conf = this.config, { base, compartments } = conf;
-           for (let effect of tr.effects) {
-               if (effect.is(Compartment.reconfigure)) {
-                   if (conf) {
-                       compartments = new Map;
-                       conf.compartments.forEach((val, key) => compartments.set(key, val));
-                       conf = null;
-                   }
-                   compartments.set(effect.value.compartment, effect.value.extension);
-               }
-               else if (effect.is(StateEffect.reconfigure)) {
-                   conf = null;
-                   base = effect.value;
-               }
-               else if (effect.is(StateEffect.appendConfig)) {
-                   conf = null;
-                   base = asArray$1(base).concat(effect.value);
-               }
-           }
-           let startValues;
-           if (!conf) {
-               conf = Configuration.resolve(base, compartments, this);
-               let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);
-               startValues = intermediateState.values;
-           }
-           else {
-               startValues = tr.startState.values.slice();
-           }
-           let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();
-           new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);
-       }
-       /**
-       Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
-       replaces every selection range with the given content.
-       */
-       replaceSelection(text) {
-           if (typeof text == "string")
-               text = this.toText(text);
-           return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },
-               range: EditorSelection.cursor(range.from + text.length) }));
-       }
-       /**
-       Create a set of changes and a new selection by running the given
-       function for each range in the active selection. The function
-       can return an optional set of changes (in the coordinate space
-       of the start document), plus an updated range (in the coordinate
-       space of the document produced by the call's own changes). This
-       method will merge all the changes and ranges into a single
-       changeset and selection, and return it as a [transaction
-       spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
-       [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
-       */
-       changeByRange(f) {
-           let sel = this.selection;
-           let result1 = f(sel.ranges[0]);
-           let changes = this.changes(result1.changes), ranges = [result1.range];
-           let effects = asArray$1(result1.effects);
-           for (let i = 1; i < sel.ranges.length; i++) {
-               let result = f(sel.ranges[i]);
-               let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);
-               for (let j = 0; j < i; j++)
-                   ranges[j] = ranges[j].map(newMapped);
-               let mapBy = changes.mapDesc(newChanges, true);
-               ranges.push(result.range.map(mapBy));
-               changes = changes.compose(newMapped);
-               effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray$1(result.effects), mapBy));
-           }
-           return {
-               changes,
-               selection: EditorSelection.create(ranges, sel.mainIndex),
-               effects
-           };
-       }
-       /**
-       Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
-       description, taking the state's document length and line
-       separator into account.
-       */
-       changes(spec = []) {
-           if (spec instanceof ChangeSet)
-               return spec;
-           return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));
-       }
-       /**
-       Using the state's [line
-       separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
-       [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
-       */
-       toText(string) {
-           return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
-       }
-       /**
-       Return the given range of the document as a string.
-       */
-       sliceDoc(from = 0, to = this.doc.length) {
-           return this.doc.sliceString(from, to, this.lineBreak);
-       }
-       /**
-       Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
-       */
-       facet(facet) {
-           let addr = this.config.address[facet.id];
-           if (addr == null)
-               return facet.default;
-           ensureAddr(this, addr);
-           return getAddr(this, addr);
-       }
-       /**
-       Convert this state to a JSON-serializable object. When custom
-       fields should be serialized, you can pass them in as an object
-       mapping property names (in the resulting object, which should
-       not use `doc` or `selection`) to fields.
-       */
-       toJSON(fields) {
-           let result = {
-               doc: this.sliceDoc(),
-               selection: this.selection.toJSON()
-           };
-           if (fields)
-               for (let prop in fields) {
-                   let value = fields[prop];
-                   if (value instanceof StateField && this.config.address[value.id] != null)
-                       result[prop] = value.spec.toJSON(this.field(fields[prop]), this);
-               }
-           return result;
-       }
-       /**
-       Deserialize a state from its JSON representation. When custom
-       fields should be deserialized, pass the same object you passed
-       to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
-       third argument.
-       */
-       static fromJSON(json, config = {}, fields) {
-           if (!json || typeof json.doc != "string")
-               throw new RangeError("Invalid JSON representation for EditorState");
-           let fieldInit = [];
-           if (fields)
-               for (let prop in fields) {
-                   if (Object.prototype.hasOwnProperty.call(json, prop)) {
-                       let field = fields[prop], value = json[prop];
-                       fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));
-                   }
-               }
-           return EditorState.create({
-               doc: json.doc,
-               selection: EditorSelection.fromJSON(json.selection),
-               extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit
-           });
-       }
-       /**
-       Create a new state. You'll usually only need this when
-       initializing an editor—updated states are created by applying
-       transactions.
-       */
-       static create(config = {}) {
-           let configuration = Configuration.resolve(config.extensions || [], new Map);
-           let doc = config.doc instanceof Text ? config.doc
-               : Text.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
-           let selection = !config.selection ? EditorSelection.single(0)
-               : config.selection instanceof EditorSelection ? config.selection
-                   : EditorSelection.single(config.selection.anchor, config.selection.head);
-           checkSelection(selection, doc.length);
-           if (!configuration.staticFacet(allowMultipleSelections))
-               selection = selection.asSingle();
-           return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);
-       }
-       /**
-       The size (in columns) of a tab in the document, determined by
-       the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
-       */
-       get tabSize() { return this.facet(EditorState.tabSize); }
-       /**
-       Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
-       string for this state.
-       */
-       get lineBreak() { return this.facet(EditorState.lineSeparator) || "\n"; }
-       /**
-       Returns true when the editor is
-       [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
-       */
-       get readOnly() { return this.facet(readOnly); }
-       /**
-       Look up a translation for the given phrase (via the
-       [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
-       original string if no translation is found.
-       
-       If additional arguments are passed, they will be inserted in
-       place of markers like `$1` (for the first value) and `$2`, etc.
-       A single `$` is equivalent to `$1`, and `$$` will produce a
-       literal dollar sign.
-       */
-       phrase(phrase, ...insert) {
-           for (let map of this.facet(EditorState.phrases))
-               if (Object.prototype.hasOwnProperty.call(map, phrase)) {
-                   phrase = map[phrase];
-                   break;
-               }
-           if (insert.length)
-               phrase = phrase.replace(/\$(\$|\d*)/g, (m, i) => {
-                   if (i == "$")
-                       return "$";
-                   let n = +(i || 1);
-                   return !n || n > insert.length ? m : insert[n - 1];
-               });
-           return phrase;
-       }
-       /**
-       Find the values for a given language data field, provided by the
-       the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
-       
-       Examples of language data fields are...
-       
-       - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
-         comment syntax.
-       - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
-         for providing language-specific completion sources.
-       - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
-         characters that should be considered part of words in this
-         language.
-       - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
-         bracket closing behavior.
-       */
-       languageDataAt(name, pos, side = -1) {
-           let values = [];
-           for (let provider of this.facet(languageData)) {
-               for (let result of provider(this, pos, side)) {
-                   if (Object.prototype.hasOwnProperty.call(result, name))
-                       values.push(result[name]);
-               }
-           }
-           return values;
-       }
-       /**
-       Return a function that can categorize strings (expected to
-       represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
-       into one of:
-       
-        - Word (contains an alphanumeric character or a character
-          explicitly listed in the local language's `"wordChars"`
-          language data, which should be a string)
-        - Space (contains only whitespace)
-        - Other (anything else)
-       */
-       charCategorizer(at) {
-           return makeCategorizer(this.languageDataAt("wordChars", at).join(""));
-       }
-       /**
-       Find the word at the given position, meaning the range
-       containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
-       around it. If no word characters are adjacent to the position,
-       this returns null.
-       */
-       wordAt(pos) {
-           let { text, from, length } = this.doc.lineAt(pos);
-           let cat = this.charCategorizer(pos);
-           let start = pos - from, end = pos - from;
-           while (start > 0) {
-               let prev = findClusterBreak(text, start, false);
-               if (cat(text.slice(prev, start)) != CharCategory.Word)
-                   break;
-               start = prev;
-           }
-           while (end < length) {
-               let next = findClusterBreak(text, end);
-               if (cat(text.slice(end, next)) != CharCategory.Word)
-                   break;
-               end = next;
-           }
-           return start == end ? null : EditorSelection.range(start + from, end + from);
-       }
-   }
-   /**
-   A facet that, when enabled, causes the editor to allow multiple
-   ranges to be selected. Be careful though, because by default the
-   editor relies on the native DOM selection, which cannot handle
-   multiple selections. An extension like
-   [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make
-   secondary selections visible to the user.
-   */
-   EditorState.allowMultipleSelections = allowMultipleSelections;
-   /**
-   Configures the tab size to use in this state. The first
-   (highest-precedence) value of the facet is used. If no value is
-   given, this defaults to 4.
-   */
-   EditorState.tabSize = /*@__PURE__*/Facet.define({
-       combine: values => values.length ? values[0] : 4
-   });
-   /**
-   The line separator to use. By default, any of `"\n"`, `"\r\n"`
-   and `"\r"` is treated as a separator when splitting lines, and
-   lines are joined with `"\n"`.
-
-   When you configure a value here, only that precise separator
-   will be used, allowing you to round-trip documents through the
-   editor without normalizing line separators.
-   */
-   EditorState.lineSeparator = lineSeparator;
-   /**
-   This facet controls the value of the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is
-   consulted by commands and extensions that implement editing
-   functionality to determine whether they should apply. It
-   defaults to false, but when its highest-precedence value is
-   `true`, such functionality disables itself.
-
-   Not to be confused with
-   [`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which
-   controls whether the editor's DOM is set to be editable (and
-   thus focusable).
-   */
-   EditorState.readOnly = readOnly;
-   /**
-   Registers translation phrases. The
-   [`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through
-   all objects registered with this facet to find translations for
-   its argument.
-   */
-   EditorState.phrases = /*@__PURE__*/Facet.define({
-       compare(a, b) {
-           let kA = Object.keys(a), kB = Object.keys(b);
-           return kA.length == kB.length && kA.every(k => a[k] == b[k]);
-       }
-   });
-   /**
-   A facet used to register [language
-   data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.
-   */
-   EditorState.languageData = languageData;
-   /**
-   Facet used to register change filters, which are called for each
-   transaction (unless explicitly
-   [disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress
-   part of the transaction's changes.
-
-   Such a function can return `true` to indicate that it doesn't
-   want to do anything, `false` to completely stop the changes in
-   the transaction, or a set of ranges in which changes should be
-   suppressed. Such ranges are represented as an array of numbers,
-   with each pair of two numbers indicating the start and end of a
-   range. So for example `[10, 20, 100, 110]` suppresses changes
-   between 10 and 20, and between 100 and 110.
-   */
-   EditorState.changeFilter = changeFilter;
-   /**
-   Facet used to register a hook that gets a chance to update or
-   replace transaction specs before they are applied. This will
-   only be applied for transactions that don't have
-   [`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You
-   can either return a single transaction spec (possibly the input
-   transaction), or an array of specs (which will be combined in
-   the same way as the arguments to
-   [`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).
-
-   When possible, it is recommended to avoid accessing
-   [`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,
-   since it will force creation of a state that will then be
-   discarded again, if the transaction is actually filtered.
-
-   (This functionality should be used with care. Indiscriminately
-   modifying transaction is likely to break something or degrade
-   the user experience.)
-   */
-   EditorState.transactionFilter = transactionFilter;
-   /**
-   This is a more limited form of
-   [`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),
-   which can only add
-   [annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and
-   [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type
-   of filter runs even if the transaction has disabled regular
-   [filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable
-   for effects that don't need to touch the changes or selection,
-   but do want to process every transaction.
-
-   Extenders run _after_ filters, when both are present.
-   */
-   EditorState.transactionExtender = transactionExtender;
-   Compartment.reconfigure = /*@__PURE__*/StateEffect.define();
-
-   /**
-   Utility function for combining behaviors to fill in a config
-   object from an array of provided configs. `defaults` should hold
-   default values for all optional fields in `Config`.
-
-   The function will, by default, error
-   when a field gets two values that aren't `===`-equal, but you can
-   provide combine functions per field to do something else.
-   */
-   function combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that
-   combine = {}) {
-       let result = {};
-       for (let config of configs)
-           for (let key of Object.keys(config)) {
-               let value = config[key], current = result[key];
-               if (current === undefined)
-                   result[key] = value;
-               else if (current === value || value === undefined) ; // No conflict
-               else if (Object.hasOwnProperty.call(combine, key))
-                   result[key] = combine[key](current, value);
-               else
-                   throw new Error("Config merge conflict for field " + key);
-           }
-       for (let key in defaults)
-           if (result[key] === undefined)
-               result[key] = defaults[key];
-       return result;
-   }
-
-   /**
-   Each range is associated with a value, which must inherit from
-   this class.
-   */
-   class RangeValue {
-       /**
-       Compare this value with another value. Used when comparing
-       rangesets. The default implementation compares by identity.
-       Unless you are only creating a fixed number of unique instances
-       of your value type, it is a good idea to implement this
-       properly.
-       */
-       eq(other) { return this == other; }
-       /**
-       Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
-       */
-       range(from, to = from) { return Range.create(from, to, this); }
-   }
-   RangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;
-   RangeValue.prototype.point = false;
-   RangeValue.prototype.mapMode = MapMode.TrackDel;
-   /**
-   A range associates a value with a range of positions.
-   */
-   class Range {
-       constructor(
-       /**
-       The range's start position.
-       */
-       from, 
-       /**
-       Its end position.
-       */
-       to, 
-       /**
-       The value associated with this range.
-       */
-       value) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-       }
-       /**
-       @internal
-       */
-       static create(from, to, value) {
-           return new Range(from, to, value);
-       }
-   }
-   function cmpRange(a, b) {
-       return a.from - b.from || a.value.startSide - b.value.startSide;
-   }
-   class Chunk {
-       constructor(from, to, value, 
-       // Chunks are marked with the largest point that occurs
-       // in them (or -1 for no points), so that scans that are
-       // only interested in points (such as the
-       // heightmap-related logic) can skip range-only chunks.
-       maxPoint) {
-           this.from = from;
-           this.to = to;
-           this.value = value;
-           this.maxPoint = maxPoint;
-       }
-       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(pos, side, end, startAt = 0) {
-           let arr = end ? this.to : this.from;
-           for (let lo = startAt, hi = arr.length;;) {
-               if (lo == hi)
-                   return lo;
-               let mid = (lo + hi) >> 1;
-               let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;
-               if (mid == lo)
-                   return diff >= 0 ? lo : hi;
-               if (diff >= 0)
-                   hi = mid;
-               else
-                   lo = mid + 1;
-           }
-       }
-       between(offset, from, to, f) {
-           for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)
-               if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
-                   return false;
-       }
-       map(offset, changes) {
-           let value = [], from = [], to = [], newPos = -1, maxPoint = -1;
-           for (let i = 0; i < this.value.length; i++) {
-               let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;
-               if (curFrom == curTo) {
-                   let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);
-                   if (mapped == null)
-                       continue;
-                   newFrom = newTo = mapped;
-                   if (val.startSide != val.endSide) {
-                       newTo = changes.mapPos(curFrom, val.endSide);
-                       if (newTo < newFrom)
-                           continue;
-                   }
-               }
-               else {
-                   newFrom = changes.mapPos(curFrom, val.startSide);
-                   newTo = changes.mapPos(curTo, val.endSide);
-                   if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)
-                       continue;
-               }
-               if ((newTo - newFrom || val.endSide - val.startSide) < 0)
-                   continue;
-               if (newPos < 0)
-                   newPos = newFrom;
-               if (val.point)
-                   maxPoint = Math.max(maxPoint, newTo - newFrom);
-               value.push(val);
-               from.push(newFrom - newPos);
-               to.push(newTo - newPos);
-           }
-           return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };
-       }
-   }
-   /**
-   A range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a
-   way that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and
-   [update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data
-   structure.
-   */
-   class RangeSet {
-       constructor(
-       /**
-       @internal
-       */
-       chunkPos, 
-       /**
-       @internal
-       */
-       chunk, 
-       /**
-       @internal
-       */
-       nextLayer, 
-       /**
-       @internal
-       */
-       maxPoint) {
-           this.chunkPos = chunkPos;
-           this.chunk = chunk;
-           this.nextLayer = nextLayer;
-           this.maxPoint = maxPoint;
-       }
-       /**
-       @internal
-       */
-       static create(chunkPos, chunk, nextLayer, maxPoint) {
-           return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);
-       }
-       /**
-       @internal
-       */
-       get length() {
-           let last = this.chunk.length - 1;
-           return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);
-       }
-       /**
-       The number of ranges in the set.
-       */
-       get size() {
-           if (this.isEmpty)
-               return 0;
-           let size = this.nextLayer.size;
-           for (let chunk of this.chunk)
-               size += chunk.value.length;
-           return size;
-       }
-       /**
-       @internal
-       */
-       chunkEnd(index) {
-           return this.chunkPos[index] + this.chunk[index].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(updateSpec) {
-           let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;
-           let filter = updateSpec.filter;
-           if (add.length == 0 && !filter)
-               return this;
-           if (sort)
-               add = add.slice().sort(cmpRange);
-           if (this.isEmpty)
-               return add.length ? RangeSet.of(add) : this;
-           let cur = new LayerCursor(this, null, -1).goto(0), i = 0, spill = [];
-           let builder = new RangeSetBuilder();
-           while (cur.value || i < add.length) {
-               if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
-                   let range = add[i++];
-                   if (!builder.addInner(range.from, range.to, range.value))
-                       spill.push(range);
-               }
-               else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
-                   (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&
-                   (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&
-                   builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {
-                   cur.nextChunk();
-               }
-               else {
-                   if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
-                       if (!builder.addInner(cur.from, cur.to, cur.value))
-                           spill.push(Range.create(cur.from, cur.to, cur.value));
-                   }
-                   cur.next();
-               }
-           }
-           return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty
-               : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));
-       }
-       /**
-       Map this range set through a set of changes, return the new set.
-       */
-       map(changes) {
-           if (changes.empty || this.isEmpty)
-               return this;
-           let chunks = [], chunkPos = [], maxPoint = -1;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               let touch = changes.touchesRange(start, start + chunk.length);
-               if (touch === false) {
-                   maxPoint = Math.max(maxPoint, chunk.maxPoint);
-                   chunks.push(chunk);
-                   chunkPos.push(changes.mapPos(start));
-               }
-               else if (touch === true) {
-                   let { mapped, pos } = chunk.map(start, changes);
-                   if (mapped) {
-                       maxPoint = Math.max(maxPoint, mapped.maxPoint);
-                       chunks.push(mapped);
-                       chunkPos.push(pos);
-                   }
-               }
-           }
-           let next = this.nextLayer.map(changes);
-           return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);
-       }
-       /**
-       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(from, to, f) {
-           if (this.isEmpty)
-               return;
-           for (let i = 0; i < this.chunk.length; i++) {
-               let start = this.chunkPos[i], chunk = this.chunk[i];
-               if (to >= start && from <= start + chunk.length &&
-                   chunk.between(start, from - start, to - start, f) === false)
-                   return;
-           }
-           this.nextLayer.between(from, to, f);
-       }
-       /**
-       Iterate over the ranges in this set, in order, including all
-       ranges that end at or after `from`.
-       */
-       iter(from = 0) {
-           return HeapCursor.from([this]).goto(from);
-       }
-       /**
-       @internal
-       */
-       get isEmpty() { return this.nextLayer == this; }
-       /**
-       Iterate over the ranges in a collection of sets, in order,
-       starting from `from`.
-       */
-       static iter(sets, from = 0) {
-           return HeapCursor.from(sets).goto(from);
-       }
-       /**
-       Iterate over two groups of sets, calling methods on `comparator`
-       to notify it of possible differences.
-       */
-       static compare(oldSets, newSets, 
-       /**
-       This indicates how the underlying data changed between these
-       ranges, and is needed to synchronize the iteration.
-       */
-       textDiff, comparator, 
-       /**
-       Can be used to ignore all non-point ranges, and points below
-       the given size. When -1, all ranges are compared.
-       */
-       minPointSize = -1) {
-           let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);
-           let sharedChunks = findSharedChunks(a, b, textDiff);
-           let sideA = new SpanCursor(a, sharedChunks, minPointSize);
-           let sideB = new SpanCursor(b, sharedChunks, minPointSize);
-           textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));
-           if (textDiff.empty && textDiff.length == 0)
-               compare(sideA, 0, sideB, 0, 0, comparator);
-       }
-       /**
-       Compare the contents of two groups of range sets, returning true
-       if they are equivalent in the given range.
-       */
-       static eq(oldSets, newSets, from = 0, to) {
-           if (to == null)
-               to = 1000000000 /* C.Far */ - 1;
-           let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
-           let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
-           if (a.length != b.length)
-               return false;
-           if (!a.length)
-               return true;
-           let sharedChunks = findSharedChunks(a, b);
-           let sideA = new SpanCursor(a, sharedChunks, 0).goto(from), sideB = new SpanCursor(b, sharedChunks, 0).goto(from);
-           for (;;) {
-               if (sideA.to != sideB.to ||
-                   !sameValues(sideA.active, sideB.active) ||
-                   sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))
-                   return false;
-               if (sideA.to > to)
-                   return true;
-               sideA.next();
-               sideB.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(sets, from, to, iterator, 
-       /**
-       When given and greater than -1, only points of at least this
-       size are taken into account.
-       */
-       minPointSize = -1) {
-           let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;
-           let openRanges = cursor.openStart;
-           for (;;) {
-               let curTo = Math.min(cursor.to, to);
-               if (cursor.point) {
-                   let active = cursor.activeForPoint(cursor.to);
-                   let openCount = cursor.pointFrom < from ? active.length + 1
-                       : cursor.point.startSide < 0 ? active.length
-                           : Math.min(active.length, openRanges);
-                   iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);
-                   openRanges = Math.min(cursor.openEnd(curTo), active.length);
-               }
-               else if (curTo > pos) {
-                   iterator.span(pos, curTo, cursor.active, openRanges);
-                   openRanges = cursor.openEnd(curTo);
-               }
-               if (cursor.to > to)
-                   return openRanges + (cursor.point && cursor.to > to ? 1 : 0);
-               pos = cursor.to;
-               cursor.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(ranges, sort = false) {
-           let build = new RangeSetBuilder();
-           for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges)
-               build.add(range.from, range.to, range.value);
-           return build.finish();
-       }
-       /**
-       Join an array of range sets into a single set.
-       */
-       static join(sets) {
-           if (!sets.length)
-               return RangeSet.empty;
-           let result = sets[sets.length - 1];
-           for (let i = sets.length - 2; i >= 0; i--) {
-               for (let layer = sets[i]; layer != RangeSet.empty; layer = layer.nextLayer)
-                   result = new RangeSet(layer.chunkPos, layer.chunk, result, Math.max(layer.maxPoint, result.maxPoint));
-           }
-           return result;
-       }
-   }
-   /**
-   The empty set of ranges.
-   */
-   RangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);
-   function lazySort(ranges) {
-       if (ranges.length > 1)
-           for (let prev = ranges[0], i = 1; i < ranges.length; i++) {
-               let cur = ranges[i];
-               if (cmpRange(prev, cur) > 0)
-                   return ranges.slice().sort(cmpRange);
-               prev = cur;
-           }
-       return ranges;
-   }
-   RangeSet.empty.nextLayer = RangeSet.empty;
-   /**
-   A range set builder is a data structure that helps build up a
-   [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating
-   an array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.
-   */
-   class RangeSetBuilder {
-       finishChunk(newArrays) {
-           this.chunks.push(new Chunk(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;
-           if (newArrays) {
-               this.from = [];
-               this.to = [];
-               this.value = [];
-           }
-       }
-       /**
-       Create an empty builder.
-       */
-       constructor() {
-           this.chunks = [];
-           this.chunkPos = [];
-           this.chunkStart = -1;
-           this.last = null;
-           this.lastFrom = -1000000000 /* C.Far */;
-           this.lastTo = -1000000000 /* C.Far */;
-           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(from, to, value) {
-           if (!this.addInner(from, to, value))
-               (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
-       }
-       /**
-       @internal
-       */
-       addInner(from, to, value) {
-           let diff = from - this.lastTo || value.startSide - this.last.endSide;
-           if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
-               throw new Error("Ranges must be added sorted by `from` position and `startSide`");
-           if (diff < 0)
-               return false;
-           if (this.from.length == 250 /* C.ChunkSize */)
-               this.finishChunk(true);
-           if (this.chunkStart < 0)
-               this.chunkStart = from;
-           this.from.push(from - this.chunkStart);
-           this.to.push(to - this.chunkStart);
-           this.last = value;
-           this.lastFrom = from;
-           this.lastTo = to;
-           this.value.push(value);
-           if (value.point)
-               this.maxPoint = Math.max(this.maxPoint, to - from);
-           return true;
-       }
-       /**
-       @internal
-       */
-       addChunk(from, chunk) {
-           if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)
-               return false;
-           if (this.from.length)
-               this.finishChunk(true);
-           this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);
-           this.chunks.push(chunk);
-           this.chunkPos.push(from);
-           let last = chunk.value.length - 1;
-           this.last = chunk.value[last];
-           this.lastFrom = chunk.from[last] + from;
-           this.lastTo = chunk.to[last] + from;
-           return true;
-       }
-       /**
-       Finish the range set. Returns the new set. The builder can't be
-       used anymore after this has been called.
-       */
-       finish() { return this.finishInner(RangeSet.empty); }
-       /**
-       @internal
-       */
-       finishInner(next) {
-           if (this.from.length)
-               this.finishChunk(false);
-           if (this.chunks.length == 0)
-               return next;
-           let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);
-           this.from = null; // Make sure further `add` calls produce errors
-           return result;
-       }
-   }
-   function findSharedChunks(a, b, textDiff) {
-       let inA = new Map();
-       for (let set of a)
-           for (let i = 0; i < set.chunk.length; i++)
-               if (set.chunk[i].maxPoint <= 0)
-                   inA.set(set.chunk[i], set.chunkPos[i]);
-       let shared = new Set();
-       for (let set of b)
-           for (let i = 0; i < set.chunk.length; i++) {
-               let known = inA.get(set.chunk[i]);
-               if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&
-                   !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))
-                   shared.add(set.chunk[i]);
-           }
-       return shared;
-   }
-   class LayerCursor {
-       constructor(layer, skip, minPoint, rank = 0) {
-           this.layer = layer;
-           this.skip = skip;
-           this.minPoint = minPoint;
-           this.rank = rank;
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       get endSide() { return this.value ? this.value.endSide : 0; }
-       goto(pos, side = -1000000000 /* C.Far */) {
-           this.chunkIndex = this.rangeIndex = 0;
-           this.gotoInner(pos, side, false);
-           return this;
-       }
-       gotoInner(pos, side, forward) {
-           while (this.chunkIndex < this.layer.chunk.length) {
-               let next = this.layer.chunk[this.chunkIndex];
-               if (!(this.skip && this.skip.has(next) ||
-                   this.layer.chunkEnd(this.chunkIndex) < pos ||
-                   next.maxPoint < this.minPoint))
-                   break;
-               this.chunkIndex++;
-               forward = false;
-           }
-           if (this.chunkIndex < this.layer.chunk.length) {
-               let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);
-               if (!forward || this.rangeIndex < rangeIndex)
-                   this.setRangeIndex(rangeIndex);
-           }
-           this.next();
-       }
-       forward(pos, side) {
-           if ((this.to - pos || this.endSide - side) < 0)
-               this.gotoInner(pos, side, true);
-       }
-       next() {
-           for (;;) {
-               if (this.chunkIndex == this.layer.chunk.length) {
-                   this.from = this.to = 1000000000 /* C.Far */;
-                   this.value = null;
-                   break;
-               }
-               else {
-                   let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];
-                   let from = chunkPos + chunk.from[this.rangeIndex];
-                   this.from = from;
-                   this.to = chunkPos + chunk.to[this.rangeIndex];
-                   this.value = chunk.value[this.rangeIndex];
-                   this.setRangeIndex(this.rangeIndex + 1);
-                   if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
-                       break;
-               }
-           }
-       }
-       setRangeIndex(index) {
-           if (index == this.layer.chunk[this.chunkIndex].value.length) {
-               this.chunkIndex++;
-               if (this.skip) {
-                   while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))
-                       this.chunkIndex++;
-               }
-               this.rangeIndex = 0;
-           }
-           else {
-               this.rangeIndex = index;
-           }
-       }
-       nextChunk() {
-           this.chunkIndex++;
-           this.rangeIndex = 0;
-           this.next();
-       }
-       compare(other) {
-           return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||
-               this.to - other.to || this.endSide - other.endSide;
-       }
-   }
-   class HeapCursor {
-       constructor(heap) {
-           this.heap = heap;
-       }
-       static from(sets, skip = null, minPoint = -1) {
-           let heap = [];
-           for (let i = 0; i < sets.length; i++) {
-               for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {
-                   if (cur.maxPoint >= minPoint)
-                       heap.push(new LayerCursor(cur, skip, minPoint, i));
-               }
-           }
-           return heap.length == 1 ? heap[0] : new HeapCursor(heap);
-       }
-       get startSide() { return this.value ? this.value.startSide : 0; }
-       goto(pos, side = -1000000000 /* C.Far */) {
-           for (let cur of this.heap)
-               cur.goto(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble(this.heap, i);
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           for (let cur of this.heap)
-               cur.forward(pos, side);
-           for (let i = this.heap.length >> 1; i >= 0; i--)
-               heapBubble(this.heap, i);
-           if ((this.to - pos || this.value.endSide - side) < 0)
-               this.next();
-       }
-       next() {
-           if (this.heap.length == 0) {
-               this.from = this.to = 1000000000 /* C.Far */;
-               this.value = null;
-               this.rank = -1;
-           }
-           else {
-               let top = this.heap[0];
-               this.from = top.from;
-               this.to = top.to;
-               this.value = top.value;
-               this.rank = top.rank;
-               if (top.value)
-                   top.next();
-               heapBubble(this.heap, 0);
-           }
-       }
-   }
-   function heapBubble(heap, index) {
-       for (let cur = heap[index];;) {
-           let childIndex = (index << 1) + 1;
-           if (childIndex >= heap.length)
-               break;
-           let child = heap[childIndex];
-           if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {
-               child = heap[childIndex + 1];
-               childIndex++;
-           }
-           if (cur.compare(child) < 0)
-               break;
-           heap[childIndex] = cur;
-           heap[index] = child;
-           index = childIndex;
-       }
-   }
-   class SpanCursor {
-       constructor(sets, skip, minPoint) {
-           this.minPoint = minPoint;
-           this.active = [];
-           this.activeTo = [];
-           this.activeRank = [];
-           this.minActive = -1;
-           // A currently active point range, if any
-           this.point = null;
-           this.pointFrom = 0;
-           this.pointRank = 0;
-           this.to = -1000000000 /* C.Far */;
-           this.endSide = 0;
-           // The amount of open active ranges at the start of the iterator.
-           // Not including points.
-           this.openStart = -1;
-           this.cursor = HeapCursor.from(sets, skip, minPoint);
-       }
-       goto(pos, side = -1000000000 /* C.Far */) {
-           this.cursor.goto(pos, side);
-           this.active.length = this.activeTo.length = this.activeRank.length = 0;
-           this.minActive = -1;
-           this.to = pos;
-           this.endSide = side;
-           this.openStart = -1;
-           this.next();
-           return this;
-       }
-       forward(pos, side) {
-           while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)
-               this.removeActive(this.minActive);
-           this.cursor.forward(pos, side);
-       }
-       removeActive(index) {
-           remove(this.active, index);
-           remove(this.activeTo, index);
-           remove(this.activeRank, index);
-           this.minActive = findMinIndex(this.active, this.activeTo);
-       }
-       addActive(trackOpen) {
-           let i = 0, { value, to, rank } = this.cursor;
-           // Organize active marks by rank first, then by size
-           while (i < this.activeRank.length && (rank - this.activeRank[i] || to - this.activeTo[i]) > 0)
-               i++;
-           insert(this.active, i, value);
-           insert(this.activeTo, i, to);
-           insert(this.activeRank, i, rank);
-           if (trackOpen)
-               insert(trackOpen, i, this.cursor.from);
-           this.minActive = findMinIndex(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 from = this.to, wasPoint = this.point;
-           this.point = null;
-           let trackOpen = this.openStart < 0 ? [] : null;
-           for (;;) {
-               let a = this.minActive;
-               if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {
-                   if (this.activeTo[a] > from) {
-                       this.to = this.activeTo[a];
-                       this.endSide = this.active[a].endSide;
-                       break;
-                   }
-                   this.removeActive(a);
-                   if (trackOpen)
-                       remove(trackOpen, a);
-               }
-               else if (!this.cursor.value) {
-                   this.to = this.endSide = 1000000000 /* C.Far */;
-                   break;
-               }
-               else if (this.cursor.from > from) {
-                   this.to = this.cursor.from;
-                   this.endSide = this.cursor.startSide;
-                   break;
-               }
-               else {
-                   let nextVal = this.cursor.value;
-                   if (!nextVal.point) { // Opening a range
-                       this.addActive(trackOpen);
-                       this.cursor.next();
-                   }
-                   else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {
-                       // Ignore any non-empty points that end precisely at the end of the prev point
-                       this.cursor.next();
-                   }
-                   else { // New point
-                       this.point = nextVal;
-                       this.pointFrom = this.cursor.from;
-                       this.pointRank = this.cursor.rank;
-                       this.to = this.cursor.to;
-                       this.endSide = nextVal.endSide;
-                       this.cursor.next();
-                       this.forward(this.to, this.endSide);
-                       break;
-                   }
-               }
-           }
-           if (trackOpen) {
-               this.openStart = 0;
-               for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)
-                   this.openStart++;
-           }
-       }
-       activeForPoint(to) {
-           if (!this.active.length)
-               return this.active;
-           let active = [];
-           for (let i = this.active.length - 1; i >= 0; i--) {
-               if (this.activeRank[i] < this.pointRank)
-                   break;
-               if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)
-                   active.push(this.active[i]);
-           }
-           return active.reverse();
-       }
-       openEnd(to) {
-           let open = 0;
-           for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)
-               open++;
-           return open;
-       }
-   }
-   function compare(a, startA, b, startB, length, comparator) {
-       a.goto(startA);
-       b.goto(startB);
-       let endB = startB + length;
-       let pos = startB, dPos = startB - startA;
-       for (;;) {
-           let dEnd = (a.to + dPos) - b.to, diff = dEnd || a.endSide - b.endSide;
-           let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);
-           if (a.point || b.point) {
-               if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&
-                   sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))
-                   comparator.comparePoint(pos, clipEnd, a.point, b.point);
-           }
-           else {
-               if (clipEnd > pos && !sameValues(a.active, b.active))
-                   comparator.compareRange(pos, clipEnd, a.active, b.active);
-           }
-           if (end > endB)
-               break;
-           if ((dEnd || a.openEnd != b.openEnd) && comparator.boundChange)
-               comparator.boundChange(end);
-           pos = end;
-           if (diff <= 0)
-               a.next();
-           if (diff >= 0)
-               b.next();
-       }
-   }
-   function sameValues(a, b) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (a[i] != b[i] && !a[i].eq(b[i]))
-               return false;
-       return true;
-   }
-   function remove(array, index) {
-       for (let i = index, e = array.length - 1; i < e; i++)
-           array[i] = array[i + 1];
-       array.pop();
-   }
-   function insert(array, index, value) {
-       for (let i = array.length - 1; i >= index; i--)
-           array[i + 1] = array[i];
-       array[index] = value;
-   }
-   function findMinIndex(value, array) {
-       let found = -1, foundPos = 1000000000 /* C.Far */;
-       for (let i = 0; i < array.length; i++)
-           if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
-               found = i;
-               foundPos = array[i];
-           }
-       return found;
-   }
-   /**
-   Find the offset that corresponds to the given column position in a
-   string, taking extending characters and tab size into account. By
-   default, the string length is returned when it is too short to
-   reach the column. Pass `strict` true to make it return -1 in that
-   situation.
-   */
-   function findColumn(string, col, tabSize, strict) {
-       for (let i = 0, n = 0;;) {
-           if (n >= col)
-               return i;
-           if (i == string.length)
-               break;
-           n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;
-           i = findClusterBreak(string, i);
-       }
-       return strict === true ? -1 : string.length;
-   }
-
-   function getSelection(root) {
-       let target;
-       // Browsers differ on whether shadow roots have a getSelection
-       // method. If it exists, use that, otherwise, call it on the
-       // document.
-       if (root.nodeType == 11) { // Shadow root
-           target = root.getSelection ? root : root.ownerDocument;
-       }
-       else {
-           target = root;
-       }
-       return target.getSelection();
-   }
-   function contains(dom, node) {
-       return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;
-   }
-   function hasSelection(dom, selection) {
-       if (!selection.anchorNode)
-           return false;
-       try {
-           // Firefox will raise 'permission denied' errors when accessing
-           // properties of `sel.anchorNode` when it's in a generated CSS
-           // element.
-           return contains(dom, selection.anchorNode);
-       }
-       catch (_) {
-           return false;
-       }
-   }
-   function clientRectsFor(dom) {
-       if (dom.nodeType == 3)
-           return textRange(dom, 0, dom.nodeValue.length).getClientRects();
-       else if (dom.nodeType == 1)
-           return dom.getClientRects();
-       else
-           return [];
-   }
-   // Scans forward and backward through DOM positions equivalent to the
-   // given one to see if the two are in the same place (i.e. after a
-   // text node vs at the end of that text node)
-   function isEquivalentPosition(node, off, targetNode, targetOff) {
-       return targetNode ? (scanFor(node, off, targetNode, targetOff, -1) ||
-           scanFor(node, off, targetNode, targetOff, 1)) : false;
-   }
-   function domIndex(node) {
-       for (var index = 0;; index++) {
-           node = node.previousSibling;
-           if (!node)
-               return index;
-       }
-   }
-   function isBlockElement(node) {
-       return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
-   }
-   function scanFor(node, off, targetNode, targetOff, dir) {
-       for (;;) {
-           if (node == targetNode && off == targetOff)
-               return true;
-           if (off == (dir < 0 ? 0 : maxOffset(node))) {
-               if (node.nodeName == "DIV")
-                   return false;
-               let parent = node.parentNode;
-               if (!parent || parent.nodeType != 1)
-                   return false;
-               off = domIndex(node) + (dir < 0 ? 0 : 1);
-               node = parent;
-           }
-           else if (node.nodeType == 1) {
-               node = node.childNodes[off + (dir < 0 ? -1 : 0)];
-               if (node.nodeType == 1 && node.contentEditable == "false")
-                   return false;
-               off = dir < 0 ? maxOffset(node) : 0;
-           }
-           else {
-               return false;
-           }
-       }
-   }
-   function maxOffset(node) {
-       return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
-   }
-   function flattenRect(rect, left) {
-       let x = left ? rect.left : rect.right;
-       return { left: x, right: x, top: rect.top, bottom: rect.bottom };
-   }
-   function windowRect(win) {
-       let vp = win.visualViewport;
-       if (vp)
-           return {
-               left: 0, right: vp.width,
-               top: 0, bottom: vp.height
-           };
-       return { left: 0, right: win.innerWidth,
-           top: 0, bottom: win.innerHeight };
-   }
-   function getScale(elt, rect) {
-       let scaleX = rect.width / elt.offsetWidth;
-       let scaleY = rect.height / elt.offsetHeight;
-       if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX) || Math.abs(rect.width - elt.offsetWidth) < 1)
-           scaleX = 1;
-       if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY) || Math.abs(rect.height - elt.offsetHeight) < 1)
-           scaleY = 1;
-       return { scaleX, scaleY };
-   }
-   function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
-       let doc = dom.ownerDocument, win = doc.defaultView || window;
-       for (let cur = dom, stop = false; cur && !stop;) {
-           if (cur.nodeType == 1) { // Element
-               let bounding, top = cur == doc.body;
-               let scaleX = 1, scaleY = 1;
-               if (top) {
-                   bounding = windowRect(win);
-               }
-               else {
-                   if (/^(fixed|sticky)$/.test(getComputedStyle(cur).position))
-                       stop = true;
-                   if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {
-                       cur = cur.assignedSlot || cur.parentNode;
-                       continue;
-                   }
-                   let rect = cur.getBoundingClientRect();
-                   ({ scaleX, scaleY } = getScale(cur, rect));
-                   // Make sure scrollbar width isn't included in the rectangle
-                   bounding = { left: rect.left, right: rect.left + cur.clientWidth * scaleX,
-                       top: rect.top, bottom: rect.top + cur.clientHeight * scaleY };
-               }
-               let moveX = 0, moveY = 0;
-               if (y == "nearest") {
-                   if (rect.top < bounding.top) {
-                       moveY = -(bounding.top - rect.top + yMargin);
-                       if (side > 0 && rect.bottom > bounding.bottom + moveY)
-                           moveY = rect.bottom - bounding.bottom + moveY + yMargin;
-                   }
-                   else if (rect.bottom > bounding.bottom) {
-                       moveY = rect.bottom - bounding.bottom + yMargin;
-                       if (side < 0 && (rect.top - moveY) < bounding.top)
-                           moveY = -(bounding.top + moveY - rect.top + yMargin);
-                   }
-               }
-               else {
-                   let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;
-                   let targetTop = y == "center" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :
-                       y == "start" || y == "center" && side < 0 ? rect.top - yMargin :
-                           rect.bottom - boundingHeight + yMargin;
-                   moveY = targetTop - bounding.top;
-               }
-               if (x == "nearest") {
-                   if (rect.left < bounding.left) {
-                       moveX = -(bounding.left - rect.left + xMargin);
-                       if (side > 0 && rect.right > bounding.right + moveX)
-                           moveX = rect.right - bounding.right + moveX + xMargin;
-                   }
-                   else if (rect.right > bounding.right) {
-                       moveX = rect.right - bounding.right + xMargin;
-                       if (side < 0 && rect.left < bounding.left + moveX)
-                           moveX = -(bounding.left + moveX - rect.left + xMargin);
-                   }
-               }
-               else {
-                   let targetLeft = x == "center" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :
-                       (x == "start") == ltr ? rect.left - xMargin :
-                           rect.right - (bounding.right - bounding.left) + xMargin;
-                   moveX = targetLeft - bounding.left;
-               }
-               if (moveX || moveY) {
-                   if (top) {
-                       win.scrollBy(moveX, moveY);
-                   }
-                   else {
-                       let movedX = 0, movedY = 0;
-                       if (moveY) {
-                           let start = cur.scrollTop;
-                           cur.scrollTop += moveY / scaleY;
-                           movedY = (cur.scrollTop - start) * scaleY;
-                       }
-                       if (moveX) {
-                           let start = cur.scrollLeft;
-                           cur.scrollLeft += moveX / scaleX;
-                           movedX = (cur.scrollLeft - start) * scaleX;
-                       }
-                       rect = { left: rect.left - movedX, top: rect.top - movedY,
-                           right: rect.right - movedX, bottom: rect.bottom - movedY };
-                       if (movedX && Math.abs(movedX - moveX) < 1)
-                           x = "nearest";
-                       if (movedY && Math.abs(movedY - moveY) < 1)
-                           y = "nearest";
-                   }
-               }
-               if (top)
-                   break;
-               cur = cur.assignedSlot || cur.parentNode;
-           }
-           else if (cur.nodeType == 11) { // A shadow root
-               cur = cur.host;
-           }
-           else {
-               break;
-           }
-       }
-   }
-   function scrollableParents(dom) {
-       let doc = dom.ownerDocument, x, y;
-       for (let cur = dom.parentNode; cur;) {
-           if (cur == doc.body || (x && y)) {
-               break;
-           }
-           else if (cur.nodeType == 1) {
-               if (!y && cur.scrollHeight > cur.clientHeight)
-                   y = cur;
-               if (!x && cur.scrollWidth > cur.clientWidth)
-                   x = cur;
-               cur = cur.assignedSlot || cur.parentNode;
-           }
-           else if (cur.nodeType == 11) {
-               cur = cur.host;
-           }
-           else {
-               break;
-           }
-       }
-       return { x, y };
-   }
-   class DOMSelectionState {
-       constructor() {
-           this.anchorNode = null;
-           this.anchorOffset = 0;
-           this.focusNode = null;
-           this.focusOffset = 0;
-       }
-       eq(domSel) {
-           return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&
-               this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;
-       }
-       setRange(range) {
-           let { anchorNode, focusNode } = range;
-           // Clip offsets to node size to avoid crashes when Safari reports bogus offsets (#1152)
-           this.set(anchorNode, Math.min(range.anchorOffset, anchorNode ? maxOffset(anchorNode) : 0), focusNode, Math.min(range.focusOffset, focusNode ? maxOffset(focusNode) : 0));
-       }
-       set(anchorNode, anchorOffset, focusNode, focusOffset) {
-           this.anchorNode = anchorNode;
-           this.anchorOffset = anchorOffset;
-           this.focusNode = focusNode;
-           this.focusOffset = focusOffset;
-       }
-   }
-   let preventScrollSupported = null;
-   // Feature-detects support for .focus({preventScroll: true}), and uses
-   // a fallback kludge when not supported.
-   function focusPreventScroll(dom) {
-       if (dom.setActive)
-           return dom.setActive(); // in IE
-       if (preventScrollSupported)
-           return dom.focus(preventScrollSupported);
-       let stack = [];
-       for (let cur = dom; cur; cur = cur.parentNode) {
-           stack.push(cur, cur.scrollTop, cur.scrollLeft);
-           if (cur == cur.ownerDocument)
-               break;
-       }
-       dom.focus(preventScrollSupported == null ? {
-           get preventScroll() {
-               preventScrollSupported = { preventScroll: true };
-               return true;
-           }
-       } : undefined);
-       if (!preventScrollSupported) {
-           preventScrollSupported = false;
-           for (let i = 0; i < stack.length;) {
-               let elt = stack[i++], top = stack[i++], left = stack[i++];
-               if (elt.scrollTop != top)
-                   elt.scrollTop = top;
-               if (elt.scrollLeft != left)
-                   elt.scrollLeft = left;
-           }
-       }
-   }
-   let scratchRange;
-   function textRange(node, from, to = from) {
-       let range = scratchRange || (scratchRange = document.createRange());
-       range.setEnd(node, to);
-       range.setStart(node, from);
-       return range;
-   }
-   function dispatchKey(elt, name, code, mods) {
-       let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };
-       if (mods)
-           ({ altKey: options.altKey, ctrlKey: options.ctrlKey, shiftKey: options.shiftKey, metaKey: options.metaKey } = mods);
-       let down = new KeyboardEvent("keydown", options);
-       down.synthetic = true;
-       elt.dispatchEvent(down);
-       let up = new KeyboardEvent("keyup", options);
-       up.synthetic = true;
-       elt.dispatchEvent(up);
-       return down.defaultPrevented || up.defaultPrevented;
-   }
-   function getRoot(node) {
-       while (node) {
-           if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))
-               return node;
-           node = node.assignedSlot || node.parentNode;
-       }
-       return null;
-   }
-   function clearAttributes(node) {
-       while (node.attributes.length)
-           node.removeAttributeNode(node.attributes[0]);
-   }
-   function atElementStart(doc, selection) {
-       let node = selection.focusNode, offset = selection.focusOffset;
-       if (!node || selection.anchorNode != node || selection.anchorOffset != offset)
-           return false;
-       // Safari can report bogus offsets (#1152)
-       offset = Math.min(offset, maxOffset(node));
-       for (;;) {
-           if (offset) {
-               if (node.nodeType != 1)
-                   return false;
-               let prev = node.childNodes[offset - 1];
-               if (prev.contentEditable == "false")
-                   offset--;
-               else {
-                   node = prev;
-                   offset = maxOffset(node);
-               }
-           }
-           else if (node == doc) {
-               return true;
-           }
-           else {
-               offset = domIndex(node);
-               node = node.parentNode;
-           }
-       }
-   }
-   function isScrolledToBottom(elt) {
-       return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);
-   }
-   function textNodeBefore(startNode, startOffset) {
-       for (let node = startNode, offset = startOffset;;) {
-           if (node.nodeType == 3 && offset > 0) {
-               return { node: node, offset: offset };
-           }
-           else if (node.nodeType == 1 && offset > 0) {
-               if (node.contentEditable == "false")
-                   return null;
-               node = node.childNodes[offset - 1];
-               offset = maxOffset(node);
-           }
-           else if (node.parentNode && !isBlockElement(node)) {
-               offset = domIndex(node);
-               node = node.parentNode;
-           }
-           else {
-               return null;
-           }
-       }
-   }
-   function textNodeAfter(startNode, startOffset) {
-       for (let node = startNode, offset = startOffset;;) {
-           if (node.nodeType == 3 && offset < node.nodeValue.length) {
-               return { node: node, offset: offset };
-           }
-           else if (node.nodeType == 1 && offset < node.childNodes.length) {
-               if (node.contentEditable == "false")
-                   return null;
-               node = node.childNodes[offset];
-               offset = 0;
-           }
-           else if (node.parentNode && !isBlockElement(node)) {
-               offset = domIndex(node) + 1;
-               node = node.parentNode;
-           }
-           else {
-               return null;
-           }
-       }
-   }
-
-   class DOMPos {
-       constructor(node, offset, precise = true) {
-           this.node = node;
-           this.offset = offset;
-           this.precise = precise;
-       }
-       static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom), precise); }
-       static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom) + 1, precise); }
-   }
-   const noChildren = [];
-   class ContentView {
-       constructor() {
-           this.parent = null;
-           this.dom = null;
-           this.flags = 2 /* ViewFlag.NodeDirty */;
-       }
-       get overrideDOMText() { return null; }
-       get posAtStart() {
-           return this.parent ? this.parent.posBefore(this) : 0;
-       }
-       get posAtEnd() {
-           return this.posAtStart + this.length;
-       }
-       posBefore(view) {
-           let pos = this.posAtStart;
-           for (let child of this.children) {
-               if (child == view)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-           throw new RangeError("Invalid child in posBefore");
-       }
-       posAfter(view) {
-           return this.posBefore(view) + view.length;
-       }
-       sync(view, track) {
-           if (this.flags & 2 /* ViewFlag.NodeDirty */) {
-               let parent = this.dom;
-               let prev = null, next;
-               for (let child of this.children) {
-                   if (child.flags & 7 /* ViewFlag.Dirty */) {
-                       if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
-                           let contentView = ContentView.get(next);
-                           if (!contentView || !contentView.parent && contentView.canReuseDOM(child))
-                               child.reuseDOM(next);
-                       }
-                       child.sync(view, track);
-                       child.flags &= ~7 /* ViewFlag.Dirty */;
-                   }
-                   next = prev ? prev.nextSibling : parent.firstChild;
-                   if (track && !track.written && track.node == parent && next != child.dom)
-                       track.written = true;
-                   if (child.dom.parentNode == parent) {
-                       while (next && next != child.dom)
-                           next = rm$1(next);
-                   }
-                   else {
-                       parent.insertBefore(child.dom, next);
-                   }
-                   prev = child.dom;
-               }
-               next = prev ? prev.nextSibling : parent.firstChild;
-               if (next && track && track.node == parent)
-                   track.written = true;
-               while (next)
-                   next = rm$1(next);
-           }
-           else if (this.flags & 1 /* ViewFlag.ChildDirty */) {
-               for (let child of this.children)
-                   if (child.flags & 7 /* ViewFlag.Dirty */) {
-                       child.sync(view, track);
-                       child.flags &= ~7 /* ViewFlag.Dirty */;
-                   }
-           }
-       }
-       reuseDOM(_dom) { }
-       localPosFromDOM(node, offset) {
-           let after;
-           if (node == this.dom) {
-               after = this.dom.childNodes[offset];
-           }
-           else {
-               let bias = maxOffset(node) == 0 ? 0 : offset == 0 ? -1 : 1;
-               for (;;) {
-                   let parent = node.parentNode;
-                   if (parent == this.dom)
-                       break;
-                   if (bias == 0 && parent.firstChild != parent.lastChild) {
-                       if (node == parent.firstChild)
-                           bias = -1;
-                       else
-                           bias = 1;
-                   }
-                   node = parent;
-               }
-               if (bias < 0)
-                   after = node;
-               else
-                   after = node.nextSibling;
-           }
-           if (after == this.dom.firstChild)
-               return 0;
-           while (after && !ContentView.get(after))
-               after = after.nextSibling;
-           if (!after)
-               return this.length;
-           for (let i = 0, pos = 0;; i++) {
-               let child = this.children[i];
-               if (child.dom == after)
-                   return pos;
-               pos += child.length + child.breakAfter;
-           }
-       }
-       domBoundsAround(from, to, offset = 0) {
-           let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;
-           for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (pos < from && end > to)
-                   return child.domBoundsAround(from, to, pos);
-               if (end >= from && fromI == -1) {
-                   fromI = i;
-                   fromStart = pos;
-               }
-               if (pos > to && child.dom.parentNode == this.dom) {
-                   toI = i;
-                   toEnd = prevEnd;
-                   break;
-               }
-               prevEnd = end;
-               pos = end + child.breakAfter;
-           }
-           return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,
-               startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,
-               endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };
-       }
-       markDirty(andParent = false) {
-           this.flags |= 2 /* ViewFlag.NodeDirty */;
-           this.markParentsDirty(andParent);
-       }
-       markParentsDirty(childList) {
-           for (let parent = this.parent; parent; parent = parent.parent) {
-               if (childList)
-                   parent.flags |= 2 /* ViewFlag.NodeDirty */;
-               if (parent.flags & 1 /* ViewFlag.ChildDirty */)
-                   return;
-               parent.flags |= 1 /* ViewFlag.ChildDirty */;
-               childList = false;
-           }
-       }
-       setParent(parent) {
-           if (this.parent != parent) {
-               this.parent = parent;
-               if (this.flags & 7 /* ViewFlag.Dirty */)
-                   this.markParentsDirty(true);
-           }
-       }
-       setDOM(dom) {
-           if (this.dom == dom)
-               return;
-           if (this.dom)
-               this.dom.cmView = null;
-           this.dom = dom;
-           dom.cmView = this;
-       }
-       get rootView() {
-           for (let v = this;;) {
-               let parent = v.parent;
-               if (!parent)
-                   return v;
-               v = parent;
-           }
-       }
-       replaceChildren(from, to, children = noChildren) {
-           this.markDirty();
-           for (let i = from; i < to; i++) {
-               let child = this.children[i];
-               if (child.parent == this && children.indexOf(child) < 0)
-                   child.destroy();
-           }
-           if (children.length < 250)
-               this.children.splice(from, to - from, ...children);
-           else
-               this.children = [].concat(this.children.slice(0, from), children, this.children.slice(to));
-           for (let i = 0; i < children.length; i++)
-               children[i].setParent(this);
-       }
-       ignoreMutation(_rec) { return false; }
-       ignoreEvent(_event) { return false; }
-       childCursor(pos = this.length) {
-           return new ChildCursor(this.children, pos, this.children.length);
-       }
-       childPos(pos, bias = 1) {
-           return this.childCursor().findPos(pos, bias);
-       }
-       toString() {
-           let name = this.constructor.name.replace("View", "");
-           return name + (this.children.length ? "(" + this.children.join() + ")" :
-               this.length ? "[" + (name == "Text" ? this.text : this.length) + "]" : "") +
-               (this.breakAfter ? "#" : "");
-       }
-       static get(node) { return node.cmView; }
-       get isEditable() { return true; }
-       get isWidget() { return false; }
-       get isHidden() { return false; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           return false;
-       }
-       become(other) { return false; }
-       canReuseDOM(other) {
-           return other.constructor == this.constructor && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);
-       }
-       // When this is a zero-length view with a side, this should return a
-       // number <= 0 to indicate it is before its position, or a
-       // number > 0 when after its position.
-       getSide() { return 0; }
-       destroy() {
-           for (let child of this.children)
-               if (child.parent == this)
-                   child.destroy();
-           this.parent = null;
-       }
-   }
-   ContentView.prototype.breakAfter = 0;
-   // Remove a DOM node and return its next sibling.
-   function rm$1(dom) {
-       let next = dom.nextSibling;
-       dom.parentNode.removeChild(dom);
-       return next;
-   }
-   class ChildCursor {
-       constructor(children, pos, i) {
-           this.children = children;
-           this.pos = pos;
-           this.i = i;
-           this.off = 0;
-       }
-       findPos(pos, bias = 1) {
-           for (;;) {
-               if (pos > this.pos || pos == this.pos &&
-                   (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {
-                   this.off = pos - this.pos;
-                   return this;
-               }
-               let next = this.children[--this.i];
-               this.pos -= next.length + next.breakAfter;
-           }
-       }
-   }
-   function replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {
-       let { children } = parent;
-       let before = children.length ? children[fromI] : null;
-       let last = insert.length ? insert[insert.length - 1] : null;
-       let breakAtEnd = last ? last.breakAfter : breakAtStart;
-       // Change within a single child
-       if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&
-           before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))
-           return;
-       if (toI < children.length) {
-           let after = children[toI];
-           // Make sure the end of the child after the update is preserved in `after`
-           if (after && (toOff < after.length || after.breakAfter && (last === null || last === void 0 ? void 0 : last.breakAfter))) {
-               // If we're splitting a child, separate part of it to avoid that
-               // being mangled when updating the child before the update.
-               if (fromI == toI) {
-                   after = after.split(toOff);
-                   toOff = 0;
-               }
-               // If the element after the replacement should be merged with
-               // the last replacing element, update `content`
-               if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {
-                   insert[insert.length - 1] = after;
-               }
-               else {
-                   // Remove the start of the after element, if necessary, and
-                   // add it to `content`.
-                   if (toOff || after.children.length && !after.children[0].length)
-                       after.merge(0, toOff, null, false, 0, openEnd);
-                   insert.push(after);
-               }
-           }
-           else if (after === null || after === void 0 ? void 0 : after.breakAfter) {
-               // The element at `toI` is entirely covered by this range.
-               // Preserve its line break, if any.
-               if (last)
-                   last.breakAfter = 1;
-               else
-                   breakAtStart = 1;
-           }
-           // Since we've handled the next element from the current elements
-           // now, make sure `toI` points after that.
-           toI++;
-       }
-       if (before) {
-           before.breakAfter = breakAtStart;
-           if (fromOff > 0) {
-               if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {
-                   before.breakAfter = insert.shift().breakAfter;
-               }
-               else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {
-                   before.merge(fromOff, before.length, null, false, openStart, 0);
-               }
-               fromI++;
-           }
-       }
-       // Try to merge widgets on the boundaries of the replacement
-       while (fromI < toI && insert.length) {
-           if (children[toI - 1].become(insert[insert.length - 1])) {
-               toI--;
-               insert.pop();
-               openEnd = insert.length ? 0 : openStart;
-           }
-           else if (children[fromI].become(insert[0])) {
-               fromI++;
-               insert.shift();
-               openStart = insert.length ? 0 : openEnd;
-           }
-           else {
-               break;
-           }
-       }
-       if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&
-           children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))
-           fromI--;
-       if (fromI < toI || insert.length)
-           parent.replaceChildren(fromI, toI, insert);
-   }
-   function mergeChildrenInto(parent, from, to, insert, openStart, openEnd) {
-       let cur = parent.childCursor();
-       let { i: toI, off: toOff } = cur.findPos(to, 1);
-       let { i: fromI, off: fromOff } = cur.findPos(from, -1);
-       let dLen = from - to;
-       for (let view of insert)
-           dLen += view.length;
-       parent.length += dLen;
-       replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
-   }
-
-   let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
-   let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
-   const ie_edge = /*@__PURE__*//Edge\/(\d+)/.exec(nav.userAgent);
-   const ie_upto10 = /*@__PURE__*//MSIE \d/.test(nav.userAgent);
-   const ie_11up = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
-   const ie = !!(ie_upto10 || ie_11up || ie_edge);
-   const gecko = !ie && /*@__PURE__*//gecko\/(\d+)/i.test(nav.userAgent);
-   const chrome = !ie && /*@__PURE__*//Chrome\/(\d+)/.exec(nav.userAgent);
-   const webkit = "webkitFontSmoothing" in doc.documentElement.style;
-   const safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);
-   const ios = safari && (/*@__PURE__*//Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
-   var browser = {
-       mac: ios || /*@__PURE__*//Mac/.test(nav.platform),
-       windows: /*@__PURE__*//Win/.test(nav.platform),
-       linux: /*@__PURE__*//Linux|X11/.test(nav.platform),
-       ie,
-       ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
-       gecko,
-       gecko_version: gecko ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
-       chrome: !!chrome,
-       chrome_version: chrome ? +chrome[1] : 0,
-       ios,
-       android: /*@__PURE__*//Android\b/.test(nav.userAgent),
-       webkit,
-       safari,
-       webkit_version: webkit ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
-       tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
-   };
-
-   const MaxJoinLen = 256;
-   class TextView extends ContentView {
-       constructor(text) {
-           super();
-           this.text = text;
-       }
-       get length() { return this.text.length; }
-       createDOM(textDOM) {
-           this.setDOM(textDOM || document.createTextNode(this.text));
-       }
-       sync(view, track) {
-           if (!this.dom)
-               this.createDOM();
-           if (this.dom.nodeValue != this.text) {
-               if (track && track.node == this.dom)
-                   track.written = true;
-               this.dom.nodeValue = this.text;
-           }
-       }
-       reuseDOM(dom) {
-           if (dom.nodeType == 3)
-               this.createDOM(dom);
-       }
-       merge(from, to, source) {
-           if ((this.flags & 8 /* ViewFlag.Composition */) ||
-               source && (!(source instanceof TextView) ||
-                   this.length - (to - from) + source.length > MaxJoinLen ||
-                   (source.flags & 8 /* ViewFlag.Composition */)))
-               return false;
-           this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = new TextView(this.text.slice(from));
-           this.text = this.text.slice(0, from);
-           this.markDirty();
-           result.flags |= this.flags & 8 /* ViewFlag.Composition */;
-           return result;
-       }
-       localPosFromDOM(node, offset) {
-           return node == this.dom ? offset : offset ? this.text.length : 0;
-       }
-       domAtPos(pos) { return new DOMPos(this.dom, pos); }
-       domBoundsAround(_from, _to, offset) {
-           return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
-       }
-       coordsAt(pos, side) {
-           return textCoords(this.dom, pos, side);
-       }
-   }
-   class MarkView extends ContentView {
-       constructor(mark, children = [], length = 0) {
-           super();
-           this.mark = mark;
-           this.children = children;
-           this.length = length;
-           for (let ch of children)
-               ch.setParent(this);
-       }
-       setAttrs(dom) {
-           clearAttributes(dom);
-           if (this.mark.class)
-               dom.className = this.mark.class;
-           if (this.mark.attrs)
-               for (let name in this.mark.attrs)
-                   dom.setAttribute(name, this.mark.attrs[name]);
-           return dom;
-       }
-       canReuseDOM(other) {
-           return super.canReuseDOM(other) && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);
-       }
-       reuseDOM(node) {
-           if (node.nodeName == this.mark.tagName.toUpperCase()) {
-               this.setDOM(node);
-               this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;
-           }
-       }
-       sync(view, track) {
-           if (!this.dom)
-               this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
-           else if (this.flags & 4 /* ViewFlag.AttrsDirty */)
-               this.setAttrs(this.dom);
-           super.sync(view, track);
-       }
-       merge(from, to, source, _hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||
-               (from && openStart <= 0) || (to < this.length && openEnd <= 0)))
-               return false;
-           mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart - 1, openEnd - 1);
-           this.markDirty();
-           return true;
-       }
-       split(from) {
-           let result = [], off = 0, detachFrom = -1, i = 0;
-           for (let elt of this.children) {
-               let end = off + elt.length;
-               if (end > from)
-                   result.push(off < from ? elt.split(from - off) : elt);
-               if (detachFrom < 0 && off >= from)
-                   detachFrom = i;
-               off = end;
-               i++;
-           }
-           let length = this.length - from;
-           this.length = from;
-           if (detachFrom > -1) {
-               this.children.length = detachFrom;
-               this.markDirty();
-           }
-           return new MarkView(this.mark, result, length);
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos(this, pos);
-       }
-       coordsAt(pos, side) {
-           return coordsInChildren(this, pos, side);
-       }
-   }
-   function textCoords(text, pos, side) {
-       let length = text.nodeValue.length;
-       if (pos > length)
-           pos = length;
-       let from = pos, to = pos, flatten = 0;
-       if (pos == 0 && side < 0 || pos == length && side >= 0) {
-           if (!(browser.chrome || browser.gecko)) { // These browsers reliably return valid rectangles for empty ranges
-               if (pos) {
-                   from--;
-                   flatten = 1;
-               } // FIXME this is wrong in RTL text
-               else if (to < length) {
-                   to++;
-                   flatten = -1;
-               }
-           }
-       }
-       else {
-           if (side < 0)
-               from--;
-           else if (to < length)
-               to++;
-       }
-       let rects = textRange(text, from, to).getClientRects();
-       if (!rects.length)
-           return null;
-       let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];
-       if (browser.safari && !flatten && rect.width == 0)
-           rect = Array.prototype.find.call(rects, r => r.width) || rect;
-       return flatten ? flattenRect(rect, flatten < 0) : rect || null;
-   }
-   // Also used for collapsed ranges that don't have a placeholder widget!
-   class WidgetView extends ContentView {
-       static create(widget, length, side) {
-           return new WidgetView(widget, length, side);
-       }
-       constructor(widget, length, side) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.side = side;
-           this.prevWidget = null;
-       }
-       split(from) {
-           let result = WidgetView.create(this.widget, this.length - from, this.side);
-           this.length -= from;
-           return result;
-       }
-       sync(view) {
-           if (!this.dom || !this.widget.updateDOM(this.dom, view)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(view));
-               if (!this.widget.editable)
-                   this.dom.contentEditable = "false";
-           }
-       }
-       getSide() { return this.side; }
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       become(other) {
-           if (other instanceof WidgetView && other.side == this.side &&
-               this.widget.constructor == other.widget.constructor) {
-               if (!this.widget.compare(other.widget))
-                   this.markDirty(true);
-               if (this.dom && !this.prevWidget)
-                   this.prevWidget = this.widget;
-               this.widget = other.widget;
-               this.length = other.length;
-               return true;
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       get overrideDOMText() {
-           if (this.length == 0)
-               return Text.empty;
-           let top = this;
-           while (top.parent)
-               top = top.parent;
-           let { view } = top, text = view && view.state.doc, start = this.posAtStart;
-           return text ? text.slice(start, start + this.length) : Text.empty;
-       }
-       domAtPos(pos) {
-           return (this.length ? pos == 0 : this.side > 0)
-               ? DOMPos.before(this.dom)
-               : DOMPos.after(this.dom, pos == this.length);
-       }
-       domBoundsAround() { return null; }
-       coordsAt(pos, side) {
-           let custom = this.widget.coordsAt(this.dom, pos, side);
-           if (custom)
-               return custom;
-           let rects = this.dom.getClientRects(), rect = null;
-           if (!rects.length)
-               return null;
-           let fromBack = this.side ? this.side < 0 : pos > 0;
-           for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {
-               rect = rects[i];
-               if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)
-                   break;
-           }
-           return flattenRect(rect, !fromBack);
-       }
-       get isEditable() { return false; }
-       get isWidget() { return true; }
-       get isHidden() { return this.widget.isHidden; }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-   }
-   // These are drawn around uneditable widgets to avoid a number of
-   // browser bugs that show up when the cursor is directly next to
-   // uneditable inline content.
-   class WidgetBufferView extends ContentView {
-       constructor(side) {
-           super();
-           this.side = side;
-       }
-       get length() { return 0; }
-       merge() { return false; }
-       become(other) {
-           return other instanceof WidgetBufferView && other.side == this.side;
-       }
-       split() { return new WidgetBufferView(this.side); }
-       sync() {
-           if (!this.dom) {
-               let dom = document.createElement("img");
-               dom.className = "cm-widgetBuffer";
-               dom.setAttribute("aria-hidden", "true");
-               this.setDOM(dom);
-           }
-       }
-       getSide() { return this.side; }
-       domAtPos(pos) { return this.side > 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom); }
-       localPosFromDOM() { return 0; }
-       domBoundsAround() { return null; }
-       coordsAt(pos) {
-           return this.dom.getBoundingClientRect();
-       }
-       get overrideDOMText() {
-           return Text.empty;
-       }
-       get isHidden() { return true; }
-   }
-   TextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;
-   function inlineDOMAtPos(parent, pos) {
-       let dom = parent.dom, { children } = parent, i = 0;
-       for (let off = 0; i < children.length; i++) {
-           let child = children[i], end = off + child.length;
-           if (end == off && child.getSide() <= 0)
-               continue;
-           if (pos > off && pos < end && child.dom.parentNode == dom)
-               return child.domAtPos(pos - off);
-           if (pos <= off)
-               break;
-           off = end;
-       }
-       for (let j = i; j > 0; j--) {
-           let prev = children[j - 1];
-           if (prev.dom.parentNode == dom)
-               return prev.domAtPos(prev.length);
-       }
-       for (let j = i; j < children.length; j++) {
-           let next = children[j];
-           if (next.dom.parentNode == dom)
-               return next.domAtPos(0);
-       }
-       return new DOMPos(dom, 0);
-   }
-   // Assumes `view`, if a mark view, has precisely 1 child.
-   function joinInlineInto(parent, view, open) {
-       let last, { children } = parent;
-       if (open > 0 && view instanceof MarkView && children.length &&
-           (last = children[children.length - 1]) instanceof MarkView && last.mark.eq(view.mark)) {
-           joinInlineInto(last, view.children[0], open - 1);
-       }
-       else {
-           children.push(view);
-           view.setParent(parent);
-       }
-       parent.length += view.length;
-   }
-   function coordsInChildren(view, pos, side) {
-       let before = null, beforePos = -1, after = null, afterPos = -1;
-       function scan(view, pos) {
-           for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {
-               let child = view.children[i], end = off + child.length;
-               if (end >= pos) {
-                   if (child.children.length) {
-                       scan(child, pos - off);
-                   }
-                   else if ((!after || after.isHidden && side > 0) &&
-                       (end > pos || off == end && child.getSide() > 0)) {
-                       after = child;
-                       afterPos = pos - off;
-                   }
-                   else if (off < pos || (off == end && child.getSide() < 0) && !child.isHidden) {
-                       before = child;
-                       beforePos = pos - off;
-                   }
-               }
-               off = end;
-           }
-       }
-       scan(view, pos);
-       let target = (side < 0 ? before : after) || before || after;
-       if (target)
-           return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);
-       return fallbackRect(view);
-   }
-   function fallbackRect(view) {
-       let last = view.dom.lastChild;
-       if (!last)
-           return view.dom.getBoundingClientRect();
-       let rects = clientRectsFor(last);
-       return rects[rects.length - 1] || null;
-   }
-
-   function combineAttrs(source, target) {
-       for (let name in source) {
-           if (name == "class" && target.class)
-               target.class += " " + source.class;
-           else if (name == "style" && target.style)
-               target.style += ";" + source.style;
-           else
-               target[name] = source[name];
-       }
-       return target;
-   }
-   const noAttrs$1 = /*@__PURE__*/Object.create(null);
-   function attrsEq(a, b, ignore) {
-       if (a == b)
-           return true;
-       if (!a)
-           a = noAttrs$1;
-       if (!b)
-           b = noAttrs$1;
-       let keysA = Object.keys(a), keysB = Object.keys(b);
-       if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) !=
-           keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0))
-           return false;
-       for (let key of keysA) {
-           if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key]))
-               return false;
-       }
-       return true;
-   }
-   function updateAttrs(dom, prev, attrs) {
-       let changed = false;
-       if (prev)
-           for (let name in prev)
-               if (!(attrs && name in attrs)) {
-                   changed = true;
-                   if (name == "style")
-                       dom.style.cssText = "";
-                   else
-                       dom.removeAttribute(name);
-               }
-       if (attrs)
-           for (let name in attrs)
-               if (!(prev && prev[name] == attrs[name])) {
-                   changed = true;
-                   if (name == "style")
-                       dom.style.cssText = attrs[name];
-                   else
-                       dom.setAttribute(name, attrs[name]);
-               }
-       return changed;
-   }
-   function getAttrs(dom) {
-       let attrs = Object.create(null);
-       for (let i = 0; i < dom.attributes.length; i++) {
-           let attr = dom.attributes[i];
-           attrs[attr.name] = attr.value;
-       }
-       return attrs;
-   }
-
-   /**
-   Widgets added to the content are described by subclasses of this
-   class. Using a description object like that makes it possible to
-   delay creating of the DOM structure for a widget until it is
-   needed, and to avoid redrawing widgets even if the decorations
-   that define them are recreated.
-   */
-   class WidgetType {
-       /**
-       Compare this instance to another instance of the same type.
-       (TypeScript can't express this, but only instances of the same
-       specific class will be passed to this method.) This is used to
-       avoid redrawing widgets when they are replaced by a new
-       decoration of the same type. The default implementation just
-       returns `false`, which will cause new instances of the widget to
-       always be redrawn.
-       */
-       eq(widget) { return false; }
-       /**
-       Update a DOM element created by a widget of the same type (but
-       different, non-`eq` content) to reflect this widget. May return
-       true to indicate that it could update, false to indicate it
-       couldn't (in which case the widget will be redrawn). The default
-       implementation just returns false.
-       */
-       updateDOM(dom, view) { return false; }
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       The estimated height this widget will have, to be used when
-       estimating the height of content that hasn't been drawn. May
-       return -1 to indicate you don't know. The default implementation
-       returns -1.
-       */
-       get estimatedHeight() { return -1; }
-       /**
-       For inline widgets that are displayed inline (as opposed to
-       `inline-block`) and introduce line breaks (through `<br>` tags
-       or textual newlines), this must indicate the amount of line
-       breaks they introduce. Defaults to 0.
-       */
-       get lineBreaks() { return 0; }
-       /**
-       Can be used to configure which kinds of events inside the widget
-       should be ignored by the editor. The default is to ignore all
-       events.
-       */
-       ignoreEvent(event) { return true; }
-       /**
-       Override the way screen coordinates for positions at/in the
-       widget are found. `pos` will be the offset into the widget, and
-       `side` the side of the position that is being queried—less than
-       zero for before, greater than zero for after, and zero for
-       directly at that position.
-       */
-       coordsAt(dom, pos, side) { return null; }
-       /**
-       @internal
-       */
-       get isHidden() { return false; }
-       /**
-       @internal
-       */
-       get editable() { return false; }
-       /**
-       This is called when the an instance of the widget is removed
-       from the editor view.
-       */
-       destroy(dom) { }
-   }
-   /**
-   The different types of blocks that can occur in an editor view.
-   */
-   var BlockType = /*@__PURE__*/(function (BlockType) {
-       /**
-       A line of text.
-       */
-       BlockType[BlockType["Text"] = 0] = "Text";
-       /**
-       A block widget associated with the position after it.
-       */
-       BlockType[BlockType["WidgetBefore"] = 1] = "WidgetBefore";
-       /**
-       A block widget associated with the position before it.
-       */
-       BlockType[BlockType["WidgetAfter"] = 2] = "WidgetAfter";
-       /**
-       A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.
-       */
-       BlockType[BlockType["WidgetRange"] = 3] = "WidgetRange";
-   return BlockType})(BlockType || (BlockType = {}));
-   /**
-   A decoration provides information on how to draw or style a piece
-   of content. You'll usually use it wrapped in a
-   [`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.
-   @nonabstract
-   */
-   class Decoration extends RangeValue {
-       constructor(
-       /**
-       @internal
-       */
-       startSide, 
-       /**
-       @internal
-       */
-       endSide, 
-       /**
-       @internal
-       */
-       widget, 
-       /**
-       The config object used to create this decoration. You can
-       include additional properties in there to store metadata about
-       your decoration.
-       */
-       spec) {
-           super();
-           this.startSide = startSide;
-           this.endSide = endSide;
-           this.widget = widget;
-           this.spec = spec;
-       }
-       /**
-       @internal
-       */
-       get heightRelevant() { return false; }
-       /**
-       Create a mark decoration, which influences the styling of the
-       content in its range. Nested mark decorations will cause nested
-       DOM elements to be created. Nesting order is determined by
-       precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
-       the higher-precedence decorations creating the inner DOM nodes.
-       Such elements are split on line boundaries and on the boundaries
-       of lower-precedence decorations.
-       */
-       static mark(spec) {
-           return new MarkDecoration(spec);
-       }
-       /**
-       Create a widget decoration, which displays a DOM element at the
-       given position.
-       */
-       static widget(spec) {
-           let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;
-           side += (block && !spec.inlineOrder)
-               ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */)
-               : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);
-           return new PointDecoration(spec, side, side, block, spec.widget || null, false);
-       }
-       /**
-       Create a replace decoration which replaces the given range with
-       a widget, or simply hides it.
-       */
-       static replace(spec) {
-           let block = !!spec.block, startSide, endSide;
-           if (spec.isBlockGap) {
-               startSide = -500000000 /* Side.GapStart */;
-               endSide = 400000000 /* Side.GapEnd */;
-           }
-           else {
-               let { start, end } = getInclusive(spec, block);
-               startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;
-               endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;
-           }
-           return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);
-       }
-       /**
-       Create a line decoration, which can add DOM attributes to the
-       line starting at the given position.
-       */
-       static line(spec) {
-           return new LineDecoration(spec);
-       }
-       /**
-       Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
-       decorated range or ranges. If the ranges aren't already sorted,
-       pass `true` for `sort` to make the library sort them for you.
-       */
-       static set(of, sort = false) {
-           return RangeSet.of(of, sort);
-       }
-       /**
-       @internal
-       */
-       hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }
-   }
-   /**
-   The empty set of decorations.
-   */
-   Decoration.none = RangeSet.empty;
-   class MarkDecoration extends Decoration {
-       constructor(spec) {
-           let { start, end } = getInclusive(spec);
-           super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);
-           this.tagName = spec.tagName || "span";
-           this.class = spec.class || "";
-           this.attrs = spec.attributes || null;
-       }
-       eq(other) {
-           var _a, _b;
-           return this == other ||
-               other instanceof MarkDecoration &&
-                   this.tagName == other.tagName &&
-                   (this.class || ((_a = this.attrs) === null || _a === void 0 ? void 0 : _a.class)) == (other.class || ((_b = other.attrs) === null || _b === void 0 ? void 0 : _b.class)) &&
-                   attrsEq(this.attrs, other.attrs, "class");
-       }
-       range(from, to = from) {
-           if (from >= to)
-               throw new RangeError("Mark decorations may not be empty");
-           return super.range(from, to);
-       }
-   }
-   MarkDecoration.prototype.point = false;
-   class LineDecoration extends Decoration {
-       constructor(spec) {
-           super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
-       }
-       eq(other) {
-           return other instanceof LineDecoration &&
-               this.spec.class == other.spec.class &&
-               attrsEq(this.spec.attributes, other.spec.attributes);
-       }
-       range(from, to = from) {
-           if (to != from)
-               throw new RangeError("Line decoration ranges must be zero-length");
-           return super.range(from, to);
-       }
-   }
-   LineDecoration.prototype.mapMode = MapMode.TrackBefore;
-   LineDecoration.prototype.point = true;
-   class PointDecoration extends Decoration {
-       constructor(spec, startSide, endSide, block, widget, isReplace) {
-           super(startSide, endSide, widget, spec);
-           this.block = block;
-           this.isReplace = isReplace;
-           this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter;
-       }
-       // Only relevant when this.block == true
-       get type() {
-           return this.startSide != this.endSide ? BlockType.WidgetRange
-               : this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;
-       }
-       get heightRelevant() {
-           return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
-       }
-       eq(other) {
-           return other instanceof PointDecoration &&
-               widgetsEq(this.widget, other.widget) &&
-               this.block == other.block &&
-               this.startSide == other.startSide && this.endSide == other.endSide;
-       }
-       range(from, to = from) {
-           if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))
-               throw new RangeError("Invalid range for replacement decoration");
-           if (!this.isReplace && to != from)
-               throw new RangeError("Widget decorations can only have zero-length ranges");
-           return super.range(from, to);
-       }
-   }
-   PointDecoration.prototype.point = true;
-   function getInclusive(spec, block = false) {
-       let { inclusiveStart: start, inclusiveEnd: end } = spec;
-       if (start == null)
-           start = spec.inclusive;
-       if (end == null)
-           end = spec.inclusive;
-       return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };
-   }
-   function widgetsEq(a, b) {
-       return a == b || !!(a && b && a.compare(b));
-   }
-   function addRange(from, to, ranges, margin = 0) {
-       let last = ranges.length - 1;
-       if (last >= 0 && ranges[last] + margin >= from)
-           ranges[last] = Math.max(ranges[last], to);
-       else
-           ranges.push(from, to);
-   }
-
-   class LineView extends ContentView {
-       constructor() {
-           super(...arguments);
-           this.children = [];
-           this.length = 0;
-           this.prevAttrs = undefined;
-           this.attrs = null;
-           this.breakAfter = 0;
-       }
-       // Consumes source
-       merge(from, to, source, hasStart, openStart, openEnd) {
-           if (source) {
-               if (!(source instanceof LineView))
-                   return false;
-               if (!this.dom)
-                   source.transferDOM(this); // Reuse source.dom when appropriate
-           }
-           if (hasStart)
-               this.setDeco(source ? source.attrs : null);
-           mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart, openEnd);
-           return true;
-       }
-       split(at) {
-           let end = new LineView;
-           end.breakAfter = this.breakAfter;
-           if (this.length == 0)
-               return end;
-           let { i, off } = this.childPos(at);
-           if (off) {
-               end.append(this.children[i].split(off), 0);
-               this.children[i].merge(off, this.children[i].length, null, false, 0, 0);
-               i++;
-           }
-           for (let j = i; j < this.children.length; j++)
-               end.append(this.children[j], 0);
-           while (i > 0 && this.children[i - 1].length == 0)
-               this.children[--i].destroy();
-           this.children.length = i;
-           this.markDirty();
-           this.length = at;
-           return end;
-       }
-       transferDOM(other) {
-           if (!this.dom)
-               return;
-           this.markDirty();
-           other.setDOM(this.dom);
-           other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;
-           this.prevAttrs = undefined;
-           this.dom = null;
-       }
-       setDeco(attrs) {
-           if (!attrsEq(this.attrs, attrs)) {
-               if (this.dom) {
-                   this.prevAttrs = this.attrs;
-                   this.markDirty();
-               }
-               this.attrs = attrs;
-           }
-       }
-       append(child, openStart) {
-           joinInlineInto(this, child, openStart);
-       }
-       // Only called when building a line view in ContentBuilder
-       addLineDeco(deco) {
-           let attrs = deco.spec.attributes, cls = deco.spec.class;
-           if (attrs)
-               this.attrs = combineAttrs(attrs, this.attrs || {});
-           if (cls)
-               this.attrs = combineAttrs({ class: cls }, this.attrs || {});
-       }
-       domAtPos(pos) {
-           return inlineDOMAtPos(this, pos);
-       }
-       reuseDOM(node) {
-           if (node.nodeName == "DIV") {
-               this.setDOM(node);
-               this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;
-           }
-       }
-       sync(view, track) {
-           var _a;
-           if (!this.dom) {
-               this.setDOM(document.createElement("div"));
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           else if (this.flags & 4 /* ViewFlag.AttrsDirty */) {
-               clearAttributes(this.dom);
-               this.dom.className = "cm-line";
-               this.prevAttrs = this.attrs ? null : undefined;
-           }
-           if (this.prevAttrs !== undefined) {
-               updateAttrs(this.dom, this.prevAttrs, this.attrs);
-               this.dom.classList.add("cm-line");
-               this.prevAttrs = undefined;
-           }
-           super.sync(view, track);
-           let last = this.dom.lastChild;
-           while (last && ContentView.get(last) instanceof MarkView)
-               last = last.lastChild;
-           if (!last || !this.length ||
-               last.nodeName != "BR" && ((_a = ContentView.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&
-                   (!browser.ios || !this.children.some(ch => ch instanceof TextView))) {
-               let hack = document.createElement("BR");
-               hack.cmIgnore = true;
-               this.dom.appendChild(hack);
-           }
-       }
-       measureTextSize() {
-           if (this.children.length == 0 || this.length > 20)
-               return null;
-           let totalWidth = 0, textHeight;
-           for (let child of this.children) {
-               if (!(child instanceof TextView) || /[^ -~]/.test(child.text))
-                   return null;
-               let rects = clientRectsFor(child.dom);
-               if (rects.length != 1)
-                   return null;
-               totalWidth += rects[0].width;
-               textHeight = rects[0].height;
-           }
-           return !totalWidth ? null : {
-               lineHeight: this.dom.getBoundingClientRect().height,
-               charWidth: totalWidth / this.length,
-               textHeight
-           };
-       }
-       coordsAt(pos, side) {
-           let rect = coordsInChildren(this, pos, side);
-           // Correct rectangle height for empty lines when the returned
-           // height is larger than the text height.
-           if (!this.children.length && rect && this.parent) {
-               let { heightOracle } = this.parent.view.viewState, height = rect.bottom - rect.top;
-               if (Math.abs(height - heightOracle.lineHeight) < 2 && heightOracle.textHeight < height) {
-                   let dist = (height - heightOracle.textHeight) / 2;
-                   return { top: rect.top + dist, bottom: rect.bottom - dist, left: rect.left, right: rect.left };
-               }
-           }
-           return rect;
-       }
-       become(other) {
-           return other instanceof LineView && this.children.length == 0 && other.children.length == 0 &&
-               attrsEq(this.attrs, other.attrs) && this.breakAfter == other.breakAfter;
-       }
-       covers() { return true; }
-       static find(docView, pos) {
-           for (let i = 0, off = 0; i < docView.children.length; i++) {
-               let block = docView.children[i], end = off + block.length;
-               if (end >= pos) {
-                   if (block instanceof LineView)
-                       return block;
-                   if (end > pos)
-                       break;
-               }
-               off = end + block.breakAfter;
-           }
-           return null;
-       }
-   }
-   class BlockWidgetView extends ContentView {
-       constructor(widget, length, deco) {
-           super();
-           this.widget = widget;
-           this.length = length;
-           this.deco = deco;
-           this.breakAfter = 0;
-           this.prevWidget = null;
-       }
-       merge(from, to, source, _takeDeco, openStart, openEnd) {
-           if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||
-               from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))
-               return false;
-           this.length = from + (source ? source.length : 0) + (this.length - to);
-           return true;
-       }
-       domAtPos(pos) {
-           return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);
-       }
-       split(at) {
-           let len = this.length - at;
-           this.length = at;
-           let end = new BlockWidgetView(this.widget, len, this.deco);
-           end.breakAfter = this.breakAfter;
-           return end;
-       }
-       get children() { return noChildren; }
-       sync(view) {
-           if (!this.dom || !this.widget.updateDOM(this.dom, view)) {
-               if (this.dom && this.prevWidget)
-                   this.prevWidget.destroy(this.dom);
-               this.prevWidget = null;
-               this.setDOM(this.widget.toDOM(view));
-               if (!this.widget.editable)
-                   this.dom.contentEditable = "false";
-           }
-       }
-       get overrideDOMText() {
-           return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;
-       }
-       domBoundsAround() { return null; }
-       become(other) {
-           if (other instanceof BlockWidgetView &&
-               other.widget.constructor == this.widget.constructor) {
-               if (!other.widget.compare(this.widget))
-                   this.markDirty(true);
-               if (this.dom && !this.prevWidget)
-                   this.prevWidget = this.widget;
-               this.widget = other.widget;
-               this.length = other.length;
-               this.deco = other.deco;
-               this.breakAfter = other.breakAfter;
-               return true;
-           }
-           return false;
-       }
-       ignoreMutation() { return true; }
-       ignoreEvent(event) { return this.widget.ignoreEvent(event); }
-       get isEditable() { return false; }
-       get isWidget() { return true; }
-       coordsAt(pos, side) {
-           let custom = this.widget.coordsAt(this.dom, pos, side);
-           if (custom)
-               return custom;
-           if (this.widget instanceof BlockGapWidget)
-               return null;
-           return flattenRect(this.dom.getBoundingClientRect(), this.length ? pos == 0 : side <= 0);
-       }
-       destroy() {
-           super.destroy();
-           if (this.dom)
-               this.widget.destroy(this.dom);
-       }
-       covers(side) {
-           let { startSide, endSide } = this.deco;
-           return startSide == endSide ? false : side < 0 ? startSide < 0 : endSide > 0;
-       }
-   }
-   class BlockGapWidget extends WidgetType {
-       constructor(height) {
-           super();
-           this.height = height;
-       }
-       toDOM() {
-           let elt = document.createElement("div");
-           elt.className = "cm-gap";
-           this.updateDOM(elt);
-           return elt;
-       }
-       eq(other) { return other.height == this.height; }
-       updateDOM(elt) {
-           elt.style.height = this.height + "px";
-           return true;
-       }
-       get editable() { return true; }
-       get estimatedHeight() { return this.height; }
-       ignoreEvent() { return false; }
-   }
-
-   class ContentBuilder {
-       constructor(doc, pos, end, disallowBlockEffectsFor) {
-           this.doc = doc;
-           this.pos = pos;
-           this.end = end;
-           this.disallowBlockEffectsFor = disallowBlockEffectsFor;
-           this.content = [];
-           this.curLine = null;
-           this.breakAtStart = 0;
-           this.pendingBuffer = 0 /* Buf.No */;
-           this.bufferMarks = [];
-           // Set to false directly after a widget that covers the position after it
-           this.atCursorPos = true;
-           this.openStart = -1;
-           this.openEnd = -1;
-           this.text = "";
-           this.textOff = 0;
-           this.cursor = doc.iter();
-           this.skip = pos;
-       }
-       posCovered() {
-           if (this.content.length == 0)
-               return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
-           let last = this.content[this.content.length - 1];
-           return !(last.breakAfter || last instanceof BlockWidgetView && last.deco.endSide < 0);
-       }
-       getLine() {
-           if (!this.curLine) {
-               this.content.push(this.curLine = new LineView);
-               this.atCursorPos = true;
-           }
-           return this.curLine;
-       }
-       flushBuffer(active = this.bufferMarks) {
-           if (this.pendingBuffer) {
-               this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);
-               this.pendingBuffer = 0 /* Buf.No */;
-           }
-       }
-       addBlockWidget(view) {
-           this.flushBuffer();
-           this.curLine = null;
-           this.content.push(view);
-       }
-       finish(openEnd) {
-           if (this.pendingBuffer && openEnd <= this.bufferMarks.length)
-               this.flushBuffer();
-           else
-               this.pendingBuffer = 0 /* Buf.No */;
-           if (!this.posCovered() &&
-               !(openEnd && this.content.length && this.content[this.content.length - 1] instanceof BlockWidgetView))
-               this.getLine();
-       }
-       buildText(length, active, openStart) {
-           while (length > 0) {
-               if (this.textOff == this.text.length) {
-                   let { value, lineBreak, done } = this.cursor.next(this.skip);
-                   this.skip = 0;
-                   if (done)
-                       throw new Error("Ran out of text content when drawing inline views");
-                   if (lineBreak) {
-                       if (!this.posCovered())
-                           this.getLine();
-                       if (this.content.length)
-                           this.content[this.content.length - 1].breakAfter = 1;
-                       else
-                           this.breakAtStart = 1;
-                       this.flushBuffer();
-                       this.curLine = null;
-                       this.atCursorPos = true;
-                       length--;
-                       continue;
-                   }
-                   else {
-                       this.text = value;
-                       this.textOff = 0;
-                   }
-               }
-               let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);
-               this.flushBuffer(active.slice(active.length - openStart));
-               this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);
-               this.atCursorPos = true;
-               this.textOff += take;
-               length -= take;
-               openStart = 0;
-           }
-       }
-       span(from, to, active, openStart) {
-           this.buildText(to - from, active, openStart);
-           this.pos = to;
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       point(from, to, deco, active, openStart, index) {
-           if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration) {
-               if (deco.block)
-                   throw new RangeError("Block decorations may not be specified via plugins");
-               if (to > this.doc.lineAt(this.pos).to)
-                   throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
-           }
-           let len = to - from;
-           if (deco instanceof PointDecoration) {
-               if (deco.block) {
-                   if (deco.startSide > 0 && !this.posCovered())
-                       this.getLine();
-                   this.addBlockWidget(new BlockWidgetView(deco.widget || NullWidget.block, len, deco));
-               }
-               else {
-                   let view = WidgetView.create(deco.widget || NullWidget.inline, len, len ? 0 : deco.startSide);
-                   let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length &&
-                       (from < to || deco.startSide > 0);
-                   let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);
-                   let line = this.getLine();
-                   if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore && !view.isEditable)
-                       this.pendingBuffer = 0 /* Buf.No */;
-                   this.flushBuffer(active);
-                   if (cursorBefore) {
-                       line.append(wrapMarks(new WidgetBufferView(1), active), openStart);
-                       openStart = active.length + Math.max(0, openStart - active.length);
-                   }
-                   line.append(wrapMarks(view, active), openStart);
-                   this.atCursorPos = cursorAfter;
-                   this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to || openStart > active.length ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;
-                   if (this.pendingBuffer)
-                       this.bufferMarks = active.slice();
-               }
-           }
-           else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration
-               this.getLine().addLineDeco(deco);
-           }
-           if (len) {
-               // Advance the iterator past the replaced content
-               if (this.textOff + len <= this.text.length) {
-                   this.textOff += len;
-               }
-               else {
-                   this.skip += len - (this.text.length - this.textOff);
-                   this.text = "";
-                   this.textOff = 0;
-               }
-               this.pos = to;
-           }
-           if (this.openStart < 0)
-               this.openStart = openStart;
-       }
-       static build(text, from, to, decorations, dynamicDecorationMap) {
-           let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);
-           builder.openEnd = RangeSet.spans(decorations, from, to, builder);
-           if (builder.openStart < 0)
-               builder.openStart = builder.openEnd;
-           builder.finish(builder.openEnd);
-           return builder;
-       }
-   }
-   function wrapMarks(view, active) {
-       for (let mark of active)
-           view = new MarkView(mark, [view], view.length);
-       return view;
-   }
-   class NullWidget extends WidgetType {
-       constructor(tag) {
-           super();
-           this.tag = tag;
-       }
-       eq(other) { return other.tag == this.tag; }
-       toDOM() { return document.createElement(this.tag); }
-       updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }
-       get isHidden() { return true; }
-   }
-   NullWidget.inline = /*@__PURE__*/new NullWidget("span");
-   NullWidget.block = /*@__PURE__*/new NullWidget("div");
-
-   /**
-   Used to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-   */
-   var Direction = /*@__PURE__*/(function (Direction) {
-       // (These are chosen to match the base levels, in bidi algorithm
-       // terms, of spans in that direction.)
-       /**
-       Left-to-right.
-       */
-       Direction[Direction["LTR"] = 0] = "LTR";
-       /**
-       Right-to-left.
-       */
-       Direction[Direction["RTL"] = 1] = "RTL";
-   return Direction})(Direction || (Direction = {}));
-   const LTR = Direction.LTR, RTL = Direction.RTL;
-   // Decode a string with each type encoded as log2(type)
-   function dec(str) {
-       let result = [];
-       for (let i = 0; i < str.length; i++)
-           result.push(1 << +str[i]);
-       return result;
-   }
-   // Character types for codepoints 0 to 0xf8
-   const LowTypes = /*@__PURE__*/dec("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008");
-   // Character types for codepoints 0x600 to 0x6f9
-   const ArabicTypes = /*@__PURE__*/dec("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333");
-   const Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];
-   // There's a lot more in
-   // https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,
-   // which are left out to keep code size down.
-   for (let p of ["()", "[]", "{}"]) {
-       let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);
-       Brackets[l] = r;
-       Brackets[r] = -l;
-   }
-   function charType(ch) {
-       return ch <= 0xf7 ? LowTypes[ch] :
-           0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :
-               0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :
-                   0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :
-                       0x2000 <= ch && ch <= 0x200c ? 256 /* T.NI */ :
-                           0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ : 1 /* T.L */;
-   }
-   const BidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
-   /**
-   Represents a contiguous range of text that has a single direction
-   (as in left-to-right or right-to-left).
-   */
-   class BidiSpan {
-       /**
-       The direction of this span.
-       */
-       get dir() { return this.level % 2 ? RTL : LTR; }
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the span (relative to the start of the line).
-       */
-       from, 
-       /**
-       The end of the span.
-       */
-       to, 
-       /**
-       The ["bidi
-       level"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)
-       of the span (in this context, 0 means
-       left-to-right, 1 means right-to-left, 2 means left-to-right
-       number inside right-to-left text).
-       */
-       level) {
-           this.from = from;
-           this.to = to;
-           this.level = level;
-       }
-       /**
-       @internal
-       */
-       side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }
-       /**
-       @internal
-       */
-       forward(forward, dir) { return forward == (this.dir == dir); }
-       /**
-       @internal
-       */
-       static find(order, index, level, assoc) {
-           let maybe = -1;
-           for (let i = 0; i < order.length; i++) {
-               let span = order[i];
-               if (span.from <= index && span.to >= index) {
-                   if (span.level == level)
-                       return i;
-                   // When multiple spans match, if assoc != 0, take the one that
-                   // covers that side, otherwise take the one with the minimum
-                   // level.
-                   if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))
-                       maybe = i;
-               }
-           }
-           if (maybe < 0)
-               throw new RangeError("Index out of range");
-           return maybe;
-       }
-   }
-   function isolatesEq(a, b) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++) {
-           let iA = a[i], iB = b[i];
-           if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))
-               return false;
-       }
-       return true;
-   }
-   // Reused array of character types
-   const types = [];
-   // Fill in the character types (in `types`) from `from` to `to` and
-   // apply W normalization rules.
-   function computeCharTypes(line, rFrom, rTo, isolates, outerType) {
-       for (let iI = 0; iI <= isolates.length; iI++) {
-           let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
-           let prevType = iI ? 256 /* T.NI */ : outerType;
-           // W1. Examine each non-spacing mark (NSM) in the level run, and
-           // change the type of the NSM to the type of the previous
-           // character. If the NSM is at the start of the level run, it will
-           // get the type of sor.
-           // W2. Search backwards from each instance of a European number
-           // until the first strong type (R, L, AL, or sor) is found. If an
-           // AL is found, change the type of the European number to Arabic
-           // number.
-           // W3. Change all ALs to R.
-           // (Left after this: L, R, EN, AN, ET, CS, NI)
-           for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {
-               let type = charType(line.charCodeAt(i));
-               if (type == 512 /* T.NSM */)
-                   type = prev;
-               else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)
-                   type = 16 /* T.AN */;
-               types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;
-               if (type & 7 /* T.Strong */)
-                   prevStrong = type;
-               prev = type;
-           }
-           // W5. A sequence of European terminators adjacent to European
-           // numbers changes to all European numbers.
-           // W6. Otherwise, separators and terminators change to Other
-           // Neutral.
-           // W7. Search backwards from each instance of a European number
-           // until the first strong type (R, L, or sor) is found. If an L is
-           // found, then change the type of the European number to L.
-           // (Left after this: L, R, EN+AN, NI)
-           for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {
-               let type = types[i];
-               if (type == 128 /* T.CS */) {
-                   if (i < to - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))
-                       type = types[i] = prev;
-                   else
-                       types[i] = 256 /* T.NI */;
-               }
-               else if (type == 64 /* T.ET */) {
-                   let end = i + 1;
-                   while (end < to && types[end] == 64 /* T.ET */)
-                       end++;
-                   let replace = (i && prev == 8 /* T.EN */) || (end < rTo && types[end] == 8 /* T.EN */) ? (prevStrong == 1 /* T.L */ ? 1 /* T.L */ : 8 /* T.EN */) : 256 /* T.NI */;
-                   for (let j = i; j < end; j++)
-                       types[j] = replace;
-                   i = end - 1;
-               }
-               else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {
-                   types[i] = 1 /* T.L */;
-               }
-               prev = type;
-               if (type & 7 /* T.Strong */)
-                   prevStrong = type;
-           }
-       }
-   }
-   // Process brackets throughout a run sequence.
-   function processBracketPairs(line, rFrom, rTo, isolates, outerType) {
-       let oppositeType = outerType == 1 /* T.L */ ? 2 /* T.R */ : 1 /* T.L */;
-       for (let iI = 0, sI = 0, context = 0; iI <= isolates.length; iI++) {
-           let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
-           // N0. Process bracket pairs in an isolating run sequence
-           // sequentially in the logical order of the text positions of the
-           // opening paired brackets using the logic given below. Within this
-           // scope, bidirectional types EN and AN are treated as R.
-           for (let i = from, ch, br, type; i < to; i++) {
-               // Keeps [startIndex, type, strongSeen] triples for each open
-               // bracket on BracketStack.
-               if (br = Brackets[ch = line.charCodeAt(i)]) {
-                   if (br < 0) { // Closing bracket
-                       for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                           if (BracketStack[sJ + 1] == -br) {
-                               let flags = BracketStack[sJ + 2];
-                               let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :
-                                   !(flags & 4 /* Bracketed.OppositeInside */) ? 0 :
-                                       (flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;
-                               if (type)
-                                   types[i] = types[BracketStack[sJ]] = type;
-                               sI = sJ;
-                               break;
-                           }
-                       }
-                   }
-                   else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {
-                       break;
-                   }
-                   else {
-                       BracketStack[sI++] = i;
-                       BracketStack[sI++] = ch;
-                       BracketStack[sI++] = context;
-                   }
-               }
-               else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {
-                   let embed = type == outerType;
-                   context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;
-                   for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {
-                       let cur = BracketStack[sJ + 2];
-                       if (cur & 2 /* Bracketed.EmbedInside */)
-                           break;
-                       if (embed) {
-                           BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;
-                       }
-                       else {
-                           if (cur & 4 /* Bracketed.OppositeInside */)
-                               break;
-                           BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;
-                       }
-                   }
-               }
-           }
-       }
-   }
-   function processNeutrals(rFrom, rTo, isolates, outerType) {
-       for (let iI = 0, prev = outerType; iI <= isolates.length; iI++) {
-           let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;
-           // N1. A sequence of neutrals takes the direction of the
-           // surrounding strong text if the text on both sides has the same
-           // direction. European and Arabic numbers act as if they were R in
-           // terms of their influence on neutrals. Start-of-level-run (sor)
-           // and end-of-level-run (eor) are used at level run boundaries.
-           // N2. Any remaining neutrals take the embedding direction.
-           // (Left after this: L, R, EN+AN)
-           for (let i = from; i < to;) {
-               let type = types[i];
-               if (type == 256 /* T.NI */) {
-                   let end = i + 1;
-                   for (;;) {
-                       if (end == to) {
-                           if (iI == isolates.length)
-                               break;
-                           end = isolates[iI++].to;
-                           to = iI < isolates.length ? isolates[iI].from : rTo;
-                       }
-                       else if (types[end] == 256 /* T.NI */) {
-                           end++;
-                       }
-                       else {
-                           break;
-                       }
-                   }
-                   let beforeL = prev == 1 /* T.L */;
-                   let afterL = (end < rTo ? types[end] : outerType) == 1 /* T.L */;
-                   let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;
-                   for (let j = end, jI = iI, fromJ = jI ? isolates[jI - 1].to : rFrom; j > i;) {
-                       if (j == fromJ) {
-                           j = isolates[--jI].from;
-                           fromJ = jI ? isolates[jI - 1].to : rFrom;
-                       }
-                       types[--j] = replace;
-                   }
-                   i = end;
-               }
-               else {
-                   prev = type;
-                   i++;
-               }
-           }
-       }
-   }
-   // Find the contiguous ranges of character types in a given range, and
-   // emit spans for them. Flip the order of the spans as appropriate
-   // based on the level, and call through to compute the spans for
-   // isolates at the proper point.
-   function emitSpans(line, from, to, level, baseLevel, isolates, order) {
-       let ourType = level % 2 ? 2 /* T.R */ : 1 /* T.L */;
-       if ((level % 2) == (baseLevel % 2)) { // Same dir as base direction, don't flip
-           for (let iCh = from, iI = 0; iCh < to;) {
-               // Scan a section of characters in direction ourType, unless
-               // there's another type of char right after iCh, in which case
-               // we scan a section of other characters (which, if ourType ==
-               // T.L, may contain both T.R and T.AN chars).
-               let sameDir = true, isNum = false;
-               if (iI == isolates.length || iCh < isolates[iI].from) {
-                   let next = types[iCh];
-                   if (next != ourType) {
-                       sameDir = false;
-                       isNum = next == 16 /* T.AN */;
-                   }
-               }
-               // Holds an array of isolates to pass to a recursive call if we
-               // must recurse (to distinguish T.AN inside an RTL section in
-               // LTR text), null if we can emit directly
-               let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;
-               let localLevel = sameDir ? level : level + 1;
-               let iScan = iCh;
-               run: for (;;) {
-                   if (iI < isolates.length && iScan == isolates[iI].from) {
-                       if (isNum)
-                           break run;
-                       let iso = isolates[iI];
-                       // Scan ahead to verify that there is another char in this dir after the isolate(s)
-                       if (!sameDir)
-                           for (let upto = iso.to, jI = iI + 1;;) {
-                               if (upto == to)
-                                   break run;
-                               if (jI < isolates.length && isolates[jI].from == upto)
-                                   upto = isolates[jI++].to;
-                               else if (types[upto] == ourType)
-                                   break run;
-                               else
-                                   break;
-                           }
-                       iI++;
-                       if (recurse) {
-                           recurse.push(iso);
-                       }
-                       else {
-                           if (iso.from > iCh)
-                               order.push(new BidiSpan(iCh, iso.from, localLevel));
-                           let dirSwap = (iso.direction == LTR) != !(localLevel % 2);
-                           computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
-                           iCh = iso.to;
-                       }
-                       iScan = iso.to;
-                   }
-                   else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {
-                       break;
-                   }
-                   else {
-                       iScan++;
-                   }
-               }
-               if (recurse)
-                   emitSpans(line, iCh, iScan, level + 1, baseLevel, recurse, order);
-               else if (iCh < iScan)
-                   order.push(new BidiSpan(iCh, iScan, localLevel));
-               iCh = iScan;
-           }
-       }
-       else {
-           // Iterate in reverse to flip the span order. Same code again, but
-           // going from the back of the section to the front
-           for (let iCh = to, iI = isolates.length; iCh > from;) {
-               let sameDir = true, isNum = false;
-               if (!iI || iCh > isolates[iI - 1].to) {
-                   let next = types[iCh - 1];
-                   if (next != ourType) {
-                       sameDir = false;
-                       isNum = next == 16 /* T.AN */;
-                   }
-               }
-               let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;
-               let localLevel = sameDir ? level : level + 1;
-               let iScan = iCh;
-               run: for (;;) {
-                   if (iI && iScan == isolates[iI - 1].to) {
-                       if (isNum)
-                           break run;
-                       let iso = isolates[--iI];
-                       // Scan ahead to verify that there is another char in this dir after the isolate(s)
-                       if (!sameDir)
-                           for (let upto = iso.from, jI = iI;;) {
-                               if (upto == from)
-                                   break run;
-                               if (jI && isolates[jI - 1].to == upto)
-                                   upto = isolates[--jI].from;
-                               else if (types[upto - 1] == ourType)
-                                   break run;
-                               else
-                                   break;
-                           }
-                       if (recurse) {
-                           recurse.push(iso);
-                       }
-                       else {
-                           if (iso.to < iCh)
-                               order.push(new BidiSpan(iso.to, iCh, localLevel));
-                           let dirSwap = (iso.direction == LTR) != !(localLevel % 2);
-                           computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);
-                           iCh = iso.from;
-                       }
-                       iScan = iso.from;
-                   }
-                   else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {
-                       break;
-                   }
-                   else {
-                       iScan--;
-                   }
-               }
-               if (recurse)
-                   emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);
-               else if (iScan < iCh)
-                   order.push(new BidiSpan(iScan, iCh, localLevel));
-               iCh = iScan;
-           }
-       }
-   }
-   function computeSectionOrder(line, level, baseLevel, isolates, from, to, order) {
-       let outerType = (level % 2 ? 2 /* T.R */ : 1 /* T.L */);
-       computeCharTypes(line, from, to, isolates, outerType);
-       processBracketPairs(line, from, to, isolates, outerType);
-       processNeutrals(from, to, isolates, outerType);
-       emitSpans(line, from, to, level, baseLevel, isolates, order);
-   }
-   function computeOrder(line, direction, isolates) {
-       if (!line)
-           return [new BidiSpan(0, 0, direction == RTL ? 1 : 0)];
-       if (direction == LTR && !isolates.length && !BidiRE.test(line))
-           return trivialOrder(line.length);
-       if (isolates.length)
-           while (line.length > types.length)
-               types[types.length] = 256 /* T.NI */; // Make sure types array has no gaps
-       let order = [], level = direction == LTR ? 0 : 1;
-       computeSectionOrder(line, level, level, isolates, 0, line.length, order);
-       return order;
-   }
-   function trivialOrder(length) {
-       return [new BidiSpan(0, length, 0)];
-   }
-   let movedOver = "";
-   // This implementation moves strictly visually, without concern for a
-   // traversal visiting every logical position in the string. It will
-   // still do so for simple input, but situations like multiple isolates
-   // with the same level next to each other, or text going against the
-   // main dir at the end of the line, will make some positions
-   // unreachable with this motion. Each visible cursor position will
-   // correspond to the lower-level bidi span that touches it.
-   //
-   // The alternative would be to solve an order globally for a given
-   // line, making sure that it includes every position, but that would
-   // require associating non-canonical (higher bidi span level)
-   // positions with a given visual position, which is likely to confuse
-   // people. (And would generally be a lot more complicated.)
-   function moveVisually(line, order, dir, start, forward) {
-       var _a;
-       let startIndex = start.head - line.from;
-       let spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);
-       let span = order[spanI], spanEnd = span.side(forward, dir);
-       // End of span
-       if (startIndex == spanEnd) {
-           let nextI = spanI += forward ? 1 : -1;
-           if (nextI < 0 || nextI >= order.length)
-               return null;
-           span = order[spanI = nextI];
-           startIndex = span.side(!forward, dir);
-           spanEnd = span.side(forward, dir);
-       }
-       let nextIndex = findClusterBreak(line.text, startIndex, span.forward(forward, dir));
-       if (nextIndex < span.from || nextIndex > span.to)
-           nextIndex = spanEnd;
-       movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));
-       let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];
-       if (nextSpan && nextIndex == spanEnd && nextSpan.level + (forward ? 0 : 1) < span.level)
-           return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, nextSpan.forward(forward, dir) ? 1 : -1, nextSpan.level);
-       return EditorSelection.cursor(nextIndex + line.from, span.forward(forward, dir) ? -1 : 1, span.level);
-   }
-   function autoDirection(text, from, to) {
-       for (let i = from; i < to; i++) {
-           let type = charType(text.charCodeAt(i));
-           if (type == 1 /* T.L */)
-               return LTR;
-           if (type == 2 /* T.R */ || type == 4 /* T.AL */)
-               return RTL;
-       }
-       return LTR;
-   }
-
-   const clickAddsSelectionRange = /*@__PURE__*/Facet.define();
-   const dragMovesSelection$1 = /*@__PURE__*/Facet.define();
-   const mouseSelectionStyle = /*@__PURE__*/Facet.define();
-   const exceptionSink = /*@__PURE__*/Facet.define();
-   const updateListener = /*@__PURE__*/Facet.define();
-   const inputHandler = /*@__PURE__*/Facet.define();
-   const focusChangeEffect = /*@__PURE__*/Facet.define();
-   const clipboardInputFilter = /*@__PURE__*/Facet.define();
-   const clipboardOutputFilter = /*@__PURE__*/Facet.define();
-   const perLineTextDirection = /*@__PURE__*/Facet.define({
-       combine: values => values.some(x => x)
-   });
-   const nativeSelectionHidden = /*@__PURE__*/Facet.define({
-       combine: values => values.some(x => x)
-   });
-   const scrollHandler = /*@__PURE__*/Facet.define();
-   class ScrollTarget {
-       constructor(range, y = "nearest", x = "nearest", yMargin = 5, xMargin = 5, 
-       // This data structure is abused to also store precise scroll
-       // snapshots, instead of a `scrollIntoView` request. When this
-       // flag is `true`, `range` points at a position in the reference
-       // line, `yMargin` holds the difference between the top of that
-       // line and the top of the editor, and `xMargin` holds the
-       // editor's `scrollLeft`.
-       isSnapshot = false) {
-           this.range = range;
-           this.y = y;
-           this.x = x;
-           this.yMargin = yMargin;
-           this.xMargin = xMargin;
-           this.isSnapshot = isSnapshot;
-       }
-       map(changes) {
-           return changes.empty ? this :
-               new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
-       }
-       clip(state) {
-           return this.range.to <= state.doc.length ? this :
-               new ScrollTarget(EditorSelection.cursor(state.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
-       }
-   }
-   const scrollIntoView$1 = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });
-   const setEditContextFormatting = /*@__PURE__*/StateEffect.define();
-   /**
-   Log or report an unhandled exception in client code. Should
-   probably only be used by extension code that allows client code to
-   provide functions, and calls those functions in a context where an
-   exception can't be propagated to calling code in a reasonable way
-   (for example when in an event handler).
-
-   Either calls a handler registered with
-   [`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),
-   `window.onerror`, if defined, or `console.error` (in which case
-   it'll pass `context`, when given, as first argument).
-   */
-   function logException(state, exception, context) {
-       let handler = state.facet(exceptionSink);
-       if (handler.length)
-           handler[0](exception);
-       else if (window.onerror)
-           window.onerror(String(exception), context, undefined, undefined, exception);
-       else if (context)
-           console.error(context + ":", exception);
-       else
-           console.error(exception);
-   }
-   const editable = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : true });
-   let nextPluginID = 0;
-   const viewPlugin = /*@__PURE__*/Facet.define();
-   /**
-   View plugins associate stateful values with a view. They can
-   influence the way the content is drawn, and are notified of things
-   that happen in the view.
-   */
-   class ViewPlugin {
-       constructor(
-       /**
-       @internal
-       */
-       id, 
-       /**
-       @internal
-       */
-       create, 
-       /**
-       @internal
-       */
-       domEventHandlers, 
-       /**
-       @internal
-       */
-       domEventObservers, buildExtensions) {
-           this.id = id;
-           this.create = create;
-           this.domEventHandlers = domEventHandlers;
-           this.domEventObservers = domEventObservers;
-           this.extension = buildExtensions(this);
-       }
-       /**
-       Define a plugin from a constructor function that creates the
-       plugin's value, given an editor view.
-       */
-       static define(create, spec) {
-           const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};
-           return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, plugin => {
-               let ext = [viewPlugin.of(plugin)];
-               if (deco)
-                   ext.push(decorations.of(view => {
-                       let pluginInst = view.plugin(plugin);
-                       return pluginInst ? deco(pluginInst) : Decoration.none;
-                   }));
-               if (provide)
-                   ext.push(provide(plugin));
-               return ext;
-           });
-       }
-       /**
-       Create a plugin for a class whose constructor takes a single
-       editor view as argument.
-       */
-       static fromClass(cls, spec) {
-           return ViewPlugin.define(view => new cls(view), spec);
-       }
-   }
-   class PluginInstance {
-       constructor(spec) {
-           this.spec = spec;
-           // When starting an update, all plugins have this field set to the
-           // update object, indicating they need to be updated. When finished
-           // updating, it is set to `false`. Retrieving a plugin that needs to
-           // be updated with `view.plugin` forces an eager update.
-           this.mustUpdate = null;
-           // This is null when the plugin is initially created, but
-           // initialized on the first update.
-           this.value = null;
-       }
-       update(view) {
-           if (!this.value) {
-               if (this.spec) {
-                   try {
-                       this.value = this.spec.create(view);
-                   }
-                   catch (e) {
-                       logException(view.state, e, "CodeMirror plugin crashed");
-                       this.deactivate();
-                   }
-               }
-           }
-           else if (this.mustUpdate) {
-               let update = this.mustUpdate;
-               this.mustUpdate = null;
-               if (this.value.update) {
-                   try {
-                       this.value.update(update);
-                   }
-                   catch (e) {
-                       logException(update.state, e, "CodeMirror plugin crashed");
-                       if (this.value.destroy)
-                           try {
-                               this.value.destroy();
-                           }
-                           catch (_) { }
-                       this.deactivate();
-                   }
-               }
-           }
-           return this;
-       }
-       destroy(view) {
-           var _a;
-           if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {
-               try {
-                   this.value.destroy();
-               }
-               catch (e) {
-                   logException(view.state, e, "CodeMirror plugin crashed");
-               }
-           }
-       }
-       deactivate() {
-           this.spec = this.value = null;
-       }
-   }
-   const editorAttributes = /*@__PURE__*/Facet.define();
-   const contentAttributes = /*@__PURE__*/Facet.define();
-   // Provide decorations
-   const decorations = /*@__PURE__*/Facet.define();
-   const outerDecorations = /*@__PURE__*/Facet.define();
-   const atomicRanges = /*@__PURE__*/Facet.define();
-   const bidiIsolatedRanges = /*@__PURE__*/Facet.define();
-   function getIsolatedRanges(view, line) {
-       let isolates = view.state.facet(bidiIsolatedRanges);
-       if (!isolates.length)
-           return isolates;
-       let sets = isolates.map(i => i instanceof Function ? i(view) : i);
-       let result = [];
-       RangeSet.spans(sets, line.from, line.to, {
-           point() { },
-           span(fromDoc, toDoc, active, open) {
-               let from = fromDoc - line.from, to = toDoc - line.from;
-               let level = result;
-               for (let i = active.length - 1; i >= 0; i--, open--) {
-                   let direction = active[i].spec.bidiIsolate, update;
-                   if (direction == null)
-                       direction = autoDirection(line.text, from, to);
-                   if (open > 0 && level.length &&
-                       (update = level[level.length - 1]).to == from && update.direction == direction) {
-                       update.to = to;
-                       level = update.inner;
-                   }
-                   else {
-                       let add = { from, to, direction, inner: [] };
-                       level.push(add);
-                       level = add.inner;
-                   }
-               }
-           }
-       });
-       return result;
-   }
-   const scrollMargins = /*@__PURE__*/Facet.define();
-   function getScrollMargins(view) {
-       let left = 0, right = 0, top = 0, bottom = 0;
-       for (let source of view.state.facet(scrollMargins)) {
-           let m = source(view);
-           if (m) {
-               if (m.left != null)
-                   left = Math.max(left, m.left);
-               if (m.right != null)
-                   right = Math.max(right, m.right);
-               if (m.top != null)
-                   top = Math.max(top, m.top);
-               if (m.bottom != null)
-                   bottom = Math.max(bottom, m.bottom);
-           }
-       }
-       return { left, right, top, bottom };
-   }
-   const styleModule = /*@__PURE__*/Facet.define();
-   class ChangedRange {
-       constructor(fromA, toA, fromB, toB) {
-           this.fromA = fromA;
-           this.toA = toA;
-           this.fromB = fromB;
-           this.toB = toB;
-       }
-       join(other) {
-           return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));
-       }
-       addToSet(set) {
-           let i = set.length, me = this;
-           for (; i > 0; i--) {
-               let range = set[i - 1];
-               if (range.fromA > me.toA)
-                   continue;
-               if (range.toA < me.fromA)
-                   break;
-               me = me.join(range);
-               set.splice(i - 1, 1);
-           }
-           set.splice(i, 0, me);
-           return set;
-       }
-       static extendWithRanges(diff, ranges) {
-           if (ranges.length == 0)
-               return diff;
-           let result = [];
-           for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {
-               let next = dI == diff.length ? null : diff[dI], off = posA - posB;
-               let end = next ? next.fromB : 1e9;
-               while (rI < ranges.length && ranges[rI] < end) {
-                   let from = ranges[rI], to = ranges[rI + 1];
-                   let fromB = Math.max(posB, from), toB = Math.min(end, to);
-                   if (fromB <= toB)
-                       new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);
-                   if (to > end)
-                       break;
-                   else
-                       rI += 2;
-               }
-               if (!next)
-                   return result;
-               new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);
-               posA = next.toA;
-               posB = next.toB;
-           }
-       }
-   }
-   /**
-   View [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this
-   class, which describe what happened, whenever the view is updated.
-   */
-   class ViewUpdate {
-       constructor(
-       /**
-       The editor view that the update is associated with.
-       */
-       view, 
-       /**
-       The new editor state.
-       */
-       state, 
-       /**
-       The transactions involved in the update. May be empty.
-       */
-       transactions) {
-           this.view = view;
-           this.state = state;
-           this.transactions = transactions;
-           /**
-           @internal
-           */
-           this.flags = 0;
-           this.startState = view.state;
-           this.changes = ChangeSet.empty(this.startState.doc.length);
-           for (let tr of transactions)
-               this.changes = this.changes.compose(tr.changes);
-           let changedRanges = [];
-           this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));
-           this.changedRanges = changedRanges;
-       }
-       /**
-       @internal
-       */
-       static create(view, state, transactions) {
-           return new ViewUpdate(view, state, transactions);
-       }
-       /**
-       Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
-       [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
-       update.
-       */
-       get viewportChanged() {
-           return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;
-       }
-       /**
-       Returns true when
-       [`viewportChanged`](https://codemirror.net/6/docs/ref/#view.ViewUpdate.viewportChanged) is true
-       and the viewport change is not just the result of mapping it in
-       response to document changes.
-       */
-       get viewportMoved() {
-           return (this.flags & 8 /* UpdateFlag.ViewportMoved */) > 0;
-       }
-       /**
-       Indicates whether the height of a block element in the editor
-       changed in this update.
-       */
-       get heightChanged() {
-           return (this.flags & 2 /* UpdateFlag.Height */) > 0;
-       }
-       /**
-       Returns true when the document was modified or the size of the
-       editor, or elements within the editor, changed.
-       */
-       get geometryChanged() {
-           return this.docChanged || (this.flags & (16 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;
-       }
-       /**
-       True when this update indicates a focus change.
-       */
-       get focusChanged() {
-           return (this.flags & 1 /* UpdateFlag.Focus */) > 0;
-       }
-       /**
-       Whether the document changed in this update.
-       */
-       get docChanged() {
-           return !this.changes.empty;
-       }
-       /**
-       Whether the selection was explicitly set in this update.
-       */
-       get selectionSet() {
-           return this.transactions.some(tr => tr.selection);
-       }
-       /**
-       @internal
-       */
-       get empty() { return this.flags == 0 && this.transactions.length == 0; }
-   }
-
-   class DocView extends ContentView {
-       get length() { return this.view.state.doc.length; }
-       constructor(view) {
-           super();
-           this.view = view;
-           this.decorations = [];
-           this.dynamicDecorationMap = [false];
-           this.domChanged = null;
-           this.hasComposition = null;
-           this.markedForComposition = new Set;
-           this.editContextFormatting = Decoration.none;
-           this.lastCompositionAfterCursor = false;
-           // Track a minimum width for the editor. When measuring sizes in
-           // measureVisibleLineHeights, this is updated to point at the width
-           // of a given element and its extent in the document. When a change
-           // happens in that range, these are reset. That way, once we've seen
-           // a line/element of a given length, we keep the editor wide enough
-           // to fit at least that element, until it is changed, at which point
-           // we forget it again.
-           this.minWidth = 0;
-           this.minWidthFrom = 0;
-           this.minWidthTo = 0;
-           // Track whether the DOM selection was set in a lossy way, so that
-           // we don't mess it up when reading it back it
-           this.impreciseAnchor = null;
-           this.impreciseHead = null;
-           this.forceSelection = false;
-           // Used by the resize observer to ignore resizes that we caused
-           // ourselves
-           this.lastUpdate = Date.now();
-           this.setDOM(view.contentDOM);
-           this.children = [new LineView];
-           this.children[0].setParent(this);
-           this.updateDeco();
-           this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0, null);
-       }
-       // Update the document view to a given state.
-       update(update) {
-           var _a;
-           let changedRanges = update.changedRanges;
-           if (this.minWidth > 0 && changedRanges.length) {
-               if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {
-                   this.minWidth = this.minWidthFrom = this.minWidthTo = 0;
-               }
-               else {
-                   this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);
-                   this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
-               }
-           }
-           this.updateEditContextFormatting(update);
-           let readCompositionAt = -1;
-           if (this.view.inputState.composing >= 0 && !this.view.observer.editContext) {
-               if ((_a = this.domChanged) === null || _a === void 0 ? void 0 : _a.newSel)
-                   readCompositionAt = this.domChanged.newSel.head;
-               else if (!touchesComposition(update.changes, this.hasComposition) && !update.selectionSet)
-                   readCompositionAt = update.state.selection.main.head;
-           }
-           let composition = readCompositionAt > -1 ? findCompositionRange(this.view, update.changes, readCompositionAt) : null;
-           this.domChanged = null;
-           if (this.hasComposition) {
-               this.markedForComposition.clear();
-               let { from, to } = this.hasComposition;
-               changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))
-                   .addToSet(changedRanges.slice());
-           }
-           this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;
-           // When the DOM nodes around the selection are moved to another
-           // parent, Chrome sometimes reports a different selection through
-           // getSelection than the one that it actually shows to the user.
-           // This forces a selection update when lines are joined to work
-           // around that. Issue #54
-           if ((browser.ie || browser.chrome) && !composition && update &&
-               update.state.doc.lines != update.startState.doc.lines)
-               this.forceSelection = true;
-           let prevDeco = this.decorations, deco = this.updateDeco();
-           let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
-           changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
-           if (!(this.flags & 7 /* ViewFlag.Dirty */) && changedRanges.length == 0) {
-               return false;
-           }
-           else {
-               this.updateInner(changedRanges, update.startState.doc.length, composition);
-               if (update.transactions.length)
-                   this.lastUpdate = Date.now();
-               return true;
-           }
-       }
-       // Used by update and the constructor do perform the actual DOM
-       // update
-       updateInner(changes, oldLength, composition) {
-           this.view.viewState.mustMeasureContent = true;
-           this.updateChildren(changes, oldLength, composition);
-           let { observer } = this.view;
-           observer.ignore(() => {
-               // Lock the height during redrawing, since Chrome sometimes
-               // messes with the scroll position during DOM mutation (though
-               // no relayout is triggered and I cannot imagine how it can
-               // recompute the scroll position without a layout)
-               this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + "px";
-               this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
-               // Chrome will sometimes, when DOM mutations occur directly
-               // around the selection, get confused and report a different
-               // selection from the one it displays (issue #218). This tries
-               // to detect that situation.
-               let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;
-               this.sync(this.view, track);
-               this.flags &= ~7 /* ViewFlag.Dirty */;
-               if (track && (track.written || observer.selectionRange.focusNode != track.node))
-                   this.forceSelection = true;
-               this.dom.style.height = "";
-           });
-           this.markedForComposition.forEach(cView => cView.flags &= ~8 /* ViewFlag.Composition */);
-           let gaps = [];
-           if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
-               for (let child of this.children)
-                   if (child instanceof BlockWidgetView && child.widget instanceof BlockGapWidget)
-                       gaps.push(child.dom);
-           observer.updateGaps(gaps);
-       }
-       updateChildren(changes, oldLength, composition) {
-           let ranges = composition ? composition.range.addToSet(changes.slice()) : changes;
-           let cursor = this.childCursor(oldLength);
-           for (let i = ranges.length - 1;; i--) {
-               let next = i >= 0 ? ranges[i] : null;
-               if (!next)
-                   break;
-               let { fromA, toA, fromB, toB } = next, content, breakAtStart, openStart, openEnd;
-               if (composition && composition.range.fromB < toB && composition.range.toB > fromB) {
-                   let before = ContentBuilder.build(this.view.state.doc, fromB, composition.range.fromB, this.decorations, this.dynamicDecorationMap);
-                   let after = ContentBuilder.build(this.view.state.doc, composition.range.toB, toB, this.decorations, this.dynamicDecorationMap);
-                   breakAtStart = before.breakAtStart;
-                   openStart = before.openStart;
-                   openEnd = after.openEnd;
-                   let compLine = this.compositionView(composition);
-                   if (after.breakAtStart) {
-                       compLine.breakAfter = 1;
-                   }
-                   else if (after.content.length &&
-                       compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {
-                       compLine.breakAfter = after.content[0].breakAfter;
-                       after.content.shift();
-                   }
-                   if (before.content.length &&
-                       compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {
-                       before.content.pop();
-                   }
-                   content = before.content.concat(compLine).concat(after.content);
-               }
-               else {
-                   ({ content, breakAtStart, openStart, openEnd } =
-                       ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap));
-               }
-               let { i: toI, off: toOff } = cursor.findPos(toA, 1);
-               let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
-               replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
-           }
-           if (composition)
-               this.fixCompositionDOM(composition);
-       }
-       updateEditContextFormatting(update) {
-           this.editContextFormatting = this.editContextFormatting.map(update.changes);
-           for (let tr of update.transactions)
-               for (let effect of tr.effects)
-                   if (effect.is(setEditContextFormatting)) {
-                       this.editContextFormatting = effect.value;
-                   }
-       }
-       compositionView(composition) {
-           let cur = new TextView(composition.text.nodeValue);
-           cur.flags |= 8 /* ViewFlag.Composition */;
-           for (let { deco } of composition.marks)
-               cur = new MarkView(deco, [cur], cur.length);
-           let line = new LineView;
-           line.append(cur, 0);
-           return line;
-       }
-       fixCompositionDOM(composition) {
-           let fix = (dom, cView) => {
-               cView.flags |= 8 /* ViewFlag.Composition */ | (cView.children.some(c => c.flags & 7 /* ViewFlag.Dirty */) ? 1 /* ViewFlag.ChildDirty */ : 0);
-               this.markedForComposition.add(cView);
-               let prev = ContentView.get(dom);
-               if (prev && prev != cView)
-                   prev.dom = null;
-               cView.setDOM(dom);
-           };
-           let pos = this.childPos(composition.range.fromB, 1);
-           let cView = this.children[pos.i];
-           fix(composition.line, cView);
-           for (let i = composition.marks.length - 1; i >= -1; i--) {
-               pos = cView.childPos(pos.off, 1);
-               cView = cView.children[pos.i];
-               fix(i >= 0 ? composition.marks[i].node : composition.text, cView);
-           }
-       }
-       // Sync the DOM selection to this.state.selection
-       updateSelection(mustRead = false, fromPointer = false) {
-           if (mustRead || !this.view.observer.selectionRange.focusNode)
-               this.view.observer.readSelectionRange();
-           let activeElt = this.view.root.activeElement, focused = activeElt == this.dom;
-           let selectionNotFocus = !focused && !(this.view.state.facet(editable) || this.dom.tabIndex > -1) &&
-               hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));
-           if (!(focused || fromPointer || selectionNotFocus))
-               return;
-           let force = this.forceSelection;
-           this.forceSelection = false;
-           let main = this.view.state.selection.main;
-           let anchor = this.moveToLine(this.domAtPos(main.anchor));
-           let head = main.empty ? anchor : this.moveToLine(this.domAtPos(main.head));
-           // Always reset on Firefox when next to an uneditable node to
-           // avoid invisible cursor bugs (#111)
-           if (browser.gecko && main.empty && !this.hasComposition && betweenUneditable(anchor)) {
-               let dummy = document.createTextNode("");
-               this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
-               anchor = head = new DOMPos(dummy, 0);
-               force = true;
-           }
-           let domSel = this.view.observer.selectionRange;
-           // If the selection is already here, or in an equivalent position, don't touch it
-           if (force || !domSel.focusNode || (!isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||
-               !isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) && !this.suppressWidgetCursorChange(domSel, main)) {
-               this.view.observer.ignore(() => {
-                   // Chrome Android will hide the virtual keyboard when tapping
-                   // inside an uneditable node, and not bring it back when we
-                   // move the cursor to its proper position. This tries to
-                   // restore the keyboard by cycling focus.
-                   if (browser.android && browser.chrome && this.dom.contains(domSel.focusNode) &&
-                       inUneditable(domSel.focusNode, this.dom)) {
-                       this.dom.blur();
-                       this.dom.focus({ preventScroll: true });
-                   }
-                   let rawSel = getSelection(this.view.root);
-                   if (!rawSel) ;
-                   else if (main.empty) {
-                       // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076
-                       if (browser.gecko) {
-                           let nextTo = nextToUneditable(anchor.node, anchor.offset);
-                           if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {
-                               let text = (nextTo == 1 /* NextTo.Before */ ? textNodeBefore : textNodeAfter)(anchor.node, anchor.offset);
-                               if (text)
-                                   anchor = new DOMPos(text.node, text.offset);
-                           }
-                       }
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       if (main.bidiLevel != null && rawSel.caretBidiLevel !== undefined)
-                           rawSel.caretBidiLevel = main.bidiLevel;
-                   }
-                   else if (rawSel.extend) {
-                       // Selection.extend can be used to create an 'inverted' selection
-                       // (one where the focus is before the anchor), but not all
-                       // browsers support it yet.
-                       rawSel.collapse(anchor.node, anchor.offset);
-                       // Safari will ignore the call above when the editor is
-                       // hidden, and then raise an error on the call to extend
-                       // (#940).
-                       try {
-                           rawSel.extend(head.node, head.offset);
-                       }
-                       catch (_) { }
-                   }
-                   else {
-                       // Primitive (IE) way
-                       let range = document.createRange();
-                       if (main.anchor > main.head)
-                           [anchor, head] = [head, anchor];
-                       range.setEnd(head.node, head.offset);
-                       range.setStart(anchor.node, anchor.offset);
-                       rawSel.removeAllRanges();
-                       rawSel.addRange(range);
-                   }
-                   if (selectionNotFocus && this.view.root.activeElement == this.dom) {
-                       this.dom.blur();
-                       if (activeElt)
-                           activeElt.focus();
-                   }
-               });
-               this.view.observer.setSelectionRange(anchor, head);
-           }
-           this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);
-           this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);
-       }
-       // If a zero-length widget is inserted next to the cursor during
-       // composition, avoid moving it across it and disrupting the
-       // composition.
-       suppressWidgetCursorChange(sel, cursor) {
-           return this.hasComposition && cursor.empty &&
-               isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset) &&
-               this.posFromDOM(sel.focusNode, sel.focusOffset) == cursor.head;
-       }
-       enforceCursorAssoc() {
-           if (this.hasComposition)
-               return;
-           let { view } = this, cursor = view.state.selection.main;
-           let sel = getSelection(view.root);
-           let { anchorNode, anchorOffset } = view.observer.selectionRange;
-           if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)
-               return;
-           let line = LineView.find(this, cursor.head);
-           if (!line)
-               return;
-           let lineStart = line.posAtStart;
-           if (cursor.head == lineStart || cursor.head == lineStart + line.length)
-               return;
-           let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);
-           if (!before || !after || before.bottom > after.top)
-               return;
-           let dom = this.domAtPos(cursor.head + cursor.assoc);
-           sel.collapse(dom.node, dom.offset);
-           sel.modify("move", cursor.assoc < 0 ? "forward" : "backward", "lineboundary");
-           // This can go wrong in corner cases like single-character lines,
-           // so check and reset if necessary.
-           view.observer.readSelectionRange();
-           let newRange = view.observer.selectionRange;
-           if (view.docView.posFromDOM(newRange.anchorNode, newRange.anchorOffset) != cursor.from)
-               sel.collapse(anchorNode, anchorOffset);
-       }
-       // If a position is in/near a block widget, move it to a nearby text
-       // line, since we don't want the cursor inside a block widget.
-       moveToLine(pos) {
-           // Block widgets will return positions before/after them, which
-           // are thus directly in the document DOM element.
-           let dom = this.dom, newPos;
-           if (pos.node != dom)
-               return pos;
-           for (let i = pos.offset; !newPos && i < dom.childNodes.length; i++) {
-               let view = ContentView.get(dom.childNodes[i]);
-               if (view instanceof LineView)
-                   newPos = view.domAtPos(0);
-           }
-           for (let i = pos.offset - 1; !newPos && i >= 0; i--) {
-               let view = ContentView.get(dom.childNodes[i]);
-               if (view instanceof LineView)
-                   newPos = view.domAtPos(view.length);
-           }
-           return newPos ? new DOMPos(newPos.node, newPos.offset, true) : pos;
-       }
-       nearest(dom) {
-           for (let cur = dom; cur;) {
-               let domView = ContentView.get(cur);
-               if (domView && domView.rootView == this)
-                   return domView;
-               cur = cur.parentNode;
-           }
-           return null;
-       }
-       posFromDOM(node, offset) {
-           let view = this.nearest(node);
-           if (!view)
-               throw new RangeError("Trying to find position for a DOM position outside of the document");
-           return view.localPosFromDOM(node, offset) + view.posAtStart;
-       }
-       domAtPos(pos) {
-           let { i, off } = this.childCursor().findPos(pos, -1);
-           for (; i < this.children.length - 1;) {
-               let child = this.children[i];
-               if (off < child.length || child instanceof LineView)
-                   break;
-               i++;
-               off = 0;
-           }
-           return this.children[i].domAtPos(off);
-       }
-       coordsAt(pos, side) {
-           let best = null, bestPos = 0;
-           for (let off = this.length, i = this.children.length - 1; i >= 0; i--) {
-               let child = this.children[i], end = off - child.breakAfter, start = end - child.length;
-               if (end < pos)
-                   break;
-               if (start <= pos && (start < pos || child.covers(-1)) && (end > pos || child.covers(1)) &&
-                   (!best || child instanceof LineView && !(best instanceof LineView && side >= 0))) {
-                   best = child;
-                   bestPos = start;
-               }
-               else if (best && start == pos && end == pos && child instanceof BlockWidgetView && Math.abs(side) < 2) {
-                   if (child.deco.startSide < 0)
-                       break;
-                   else if (i)
-                       best = null;
-               }
-               off = start;
-           }
-           return best ? best.coordsAt(pos - bestPos, side) : null;
-       }
-       coordsForChar(pos) {
-           let { i, off } = this.childPos(pos, 1), child = this.children[i];
-           if (!(child instanceof LineView))
-               return null;
-           while (child.children.length) {
-               let { i, off: childOff } = child.childPos(off, 1);
-               for (;; i++) {
-                   if (i == child.children.length)
-                       return null;
-                   if ((child = child.children[i]).length)
-                       break;
-               }
-               off = childOff;
-           }
-           if (!(child instanceof TextView))
-               return null;
-           let end = findClusterBreak(child.text, off);
-           if (end == off)
-               return null;
-           let rects = textRange(child.dom, off, end).getClientRects();
-           for (let i = 0; i < rects.length; i++) {
-               let rect = rects[i];
-               if (i == rects.length - 1 || rect.top < rect.bottom && rect.left < rect.right)
-                   return rect;
-           }
-           return null;
-       }
-       measureVisibleLineHeights(viewport) {
-           let result = [], { from, to } = viewport;
-           let contentWidth = this.view.contentDOM.clientWidth;
-           let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;
-           let widest = -1, ltr = this.view.textDirection == Direction.LTR;
-           for (let pos = 0, i = 0; i < this.children.length; i++) {
-               let child = this.children[i], end = pos + child.length;
-               if (end > to)
-                   break;
-               if (pos >= from) {
-                   let childRect = child.dom.getBoundingClientRect();
-                   result.push(childRect.height);
-                   if (isWider) {
-                       let last = child.dom.lastChild;
-                       let rects = last ? clientRectsFor(last) : [];
-                       if (rects.length) {
-                           let rect = rects[rects.length - 1];
-                           let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;
-                           if (width > widest) {
-                               widest = width;
-                               this.minWidth = contentWidth;
-                               this.minWidthFrom = pos;
-                               this.minWidthTo = end;
-                           }
-                       }
-                   }
-               }
-               pos = end + child.breakAfter;
-           }
-           return result;
-       }
-       textDirectionAt(pos) {
-           let { i } = this.childPos(pos, 1);
-           return getComputedStyle(this.children[i].dom).direction == "rtl" ? Direction.RTL : Direction.LTR;
-       }
-       measureTextSize() {
-           for (let child of this.children) {
-               if (child instanceof LineView) {
-                   let measure = child.measureTextSize();
-                   if (measure)
-                       return measure;
-               }
-           }
-           // If no workable line exists, force a layout of a measurable element
-           let dummy = document.createElement("div"), lineHeight, charWidth, textHeight;
-           dummy.className = "cm-line";
-           dummy.style.width = "99999px";
-           dummy.style.position = "absolute";
-           dummy.textContent = "abc def ghi jkl mno pqr stu";
-           this.view.observer.ignore(() => {
-               this.dom.appendChild(dummy);
-               let rect = clientRectsFor(dummy.firstChild)[0];
-               lineHeight = dummy.getBoundingClientRect().height;
-               charWidth = rect ? rect.width / 27 : 7;
-               textHeight = rect ? rect.height : lineHeight;
-               dummy.remove();
-           });
-           return { lineHeight, charWidth, textHeight };
-       }
-       childCursor(pos = this.length) {
-           // Move back to start of last element when possible, so that
-           // `ChildCursor.findPos` doesn't have to deal with the edge case
-           // of being after the last element.
-           let i = this.children.length;
-           if (i)
-               pos -= this.children[--i].length;
-           return new ChildCursor(this.children, pos, i);
-       }
-       computeBlockGapDeco() {
-           let deco = [], vs = this.view.viewState;
-           for (let pos = 0, i = 0;; i++) {
-               let next = i == vs.viewports.length ? null : vs.viewports[i];
-               let end = next ? next.from - 1 : this.length;
-               if (end > pos) {
-                   let height = (vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top) / this.view.scaleY;
-                   deco.push(Decoration.replace({
-                       widget: new BlockGapWidget(height),
-                       block: true,
-                       inclusive: true,
-                       isBlockGap: true,
-                   }).range(pos, end));
-               }
-               if (!next)
-                   break;
-               pos = next.to + 1;
-           }
-           return Decoration.set(deco);
-       }
-       updateDeco() {
-           let i = 1;
-           let allDeco = this.view.state.facet(decorations).map(d => {
-               let dynamic = this.dynamicDecorationMap[i++] = typeof d == "function";
-               return dynamic ? d(this.view) : d;
-           });
-           let dynamicOuter = false, outerDeco = this.view.state.facet(outerDecorations).map((d, i) => {
-               let dynamic = typeof d == "function";
-               if (dynamic)
-                   dynamicOuter = true;
-               return dynamic ? d(this.view) : d;
-           });
-           if (outerDeco.length) {
-               this.dynamicDecorationMap[i++] = dynamicOuter;
-               allDeco.push(RangeSet.join(outerDeco));
-           }
-           this.decorations = [
-               this.editContextFormatting,
-               ...allDeco,
-               this.computeBlockGapDeco(),
-               this.view.viewState.lineGapDeco
-           ];
-           while (i < this.decorations.length)
-               this.dynamicDecorationMap[i++] = false;
-           return this.decorations;
-       }
-       scrollIntoView(target) {
-           if (target.isSnapshot) {
-               let ref = this.view.viewState.lineBlockAt(target.range.head);
-               this.view.scrollDOM.scrollTop = ref.top - target.yMargin;
-               this.view.scrollDOM.scrollLeft = target.xMargin;
-               return;
-           }
-           for (let handler of this.view.state.facet(scrollHandler)) {
-               try {
-                   if (handler(this.view, target.range, target))
-                       return true;
-               }
-               catch (e) {
-                   logException(this.view.state, e, "scroll handler");
-               }
-           }
-           let { range } = target;
-           let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;
-           if (!rect)
-               return;
-           if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))
-               rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),
-                   right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };
-           let margins = getScrollMargins(this.view);
-           let targetRect = {
-               left: rect.left - margins.left, top: rect.top - margins.top,
-               right: rect.right + margins.right, bottom: rect.bottom + margins.bottom
-           };
-           let { offsetWidth, offsetHeight } = this.view.scrollDOM;
-           scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, Math.max(Math.min(target.xMargin, offsetWidth), -offsetWidth), Math.max(Math.min(target.yMargin, offsetHeight), -offsetHeight), this.view.textDirection == Direction.LTR);
-       }
-   }
-   function betweenUneditable(pos) {
-       return pos.node.nodeType == 1 && pos.node.firstChild &&
-           (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == "false") &&
-           (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == "false");
-   }
-   function findCompositionNode(view, headPos) {
-       let sel = view.observer.selectionRange;
-       if (!sel.focusNode)
-           return null;
-       let textBefore = textNodeBefore(sel.focusNode, sel.focusOffset);
-       let textAfter = textNodeAfter(sel.focusNode, sel.focusOffset);
-       let textNode = textBefore || textAfter;
-       if (textAfter && textBefore && textAfter.node != textBefore.node) {
-           let descAfter = ContentView.get(textAfter.node);
-           if (!descAfter || descAfter instanceof TextView && descAfter.text != textAfter.node.nodeValue) {
-               textNode = textAfter;
-           }
-           else if (view.docView.lastCompositionAfterCursor) {
-               let descBefore = ContentView.get(textBefore.node);
-               if (!(!descBefore || descBefore instanceof TextView && descBefore.text != textBefore.node.nodeValue))
-                   textNode = textAfter;
-           }
-       }
-       view.docView.lastCompositionAfterCursor = textNode != textBefore;
-       if (!textNode)
-           return null;
-       let from = headPos - textNode.offset;
-       return { from, to: from + textNode.node.nodeValue.length, node: textNode.node };
-   }
-   function findCompositionRange(view, changes, headPos) {
-       let found = findCompositionNode(view, headPos);
-       if (!found)
-           return null;
-       let { node: textNode, from, to } = found, text = textNode.nodeValue;
-       // Don't try to preserve multi-line compositions
-       if (/[\n\r]/.test(text))
-           return null;
-       if (view.state.doc.sliceString(found.from, found.to) != text)
-           return null;
-       let inv = changes.invertedDesc;
-       let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);
-       let marks = [];
-       for (let parent = textNode.parentNode;; parent = parent.parentNode) {
-           let parentView = ContentView.get(parent);
-           if (parentView instanceof MarkView)
-               marks.push({ node: parent, deco: parentView.mark });
-           else if (parentView instanceof LineView || parent.nodeName == "DIV" && parent.parentNode == view.contentDOM)
-               return { range, text: textNode, marks, line: parent };
-           else if (parent != view.contentDOM)
-               marks.push({ node: parent, deco: new MarkDecoration({
-                       inclusive: true,
-                       attributes: getAttrs(parent),
-                       tagName: parent.tagName.toLowerCase()
-                   }) });
-           else
-               return null;
-       }
-   }
-   function nextToUneditable(node, offset) {
-       if (node.nodeType != 1)
-           return 0;
-       return (offset && node.childNodes[offset - 1].contentEditable == "false" ? 1 /* NextTo.Before */ : 0) |
-           (offset < node.childNodes.length && node.childNodes[offset].contentEditable == "false" ? 2 /* NextTo.After */ : 0);
-   }
-   let DecorationComparator$1 = class DecorationComparator {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange(from, to) { addRange(from, to, this.changes); }
-       comparePoint(from, to) { addRange(from, to, this.changes); }
-       boundChange(pos) { addRange(pos, pos, this.changes); }
-   };
-   function findChangedDeco(a, b, diff) {
-       let comp = new DecorationComparator$1;
-       RangeSet.compare(a, b, diff, comp);
-       return comp.changes;
-   }
-   function inUneditable(node, inside) {
-       for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {
-           if (cur.nodeType == 1 && cur.contentEditable == 'false') {
-               return true;
-           }
-       }
-       return false;
-   }
-   function touchesComposition(changes, composition) {
-       let touched = false;
-       if (composition)
-           changes.iterChangedRanges((from, to) => {
-               if (from < composition.to && to > composition.from)
-                   touched = true;
-           });
-       return touched;
-   }
-
-   function groupAt(state, pos, bias = 1) {
-       let categorize = state.charCategorizer(pos);
-       let line = state.doc.lineAt(pos), linePos = pos - line.from;
-       if (line.length == 0)
-           return EditorSelection.cursor(pos);
-       if (linePos == 0)
-           bias = 1;
-       else if (linePos == line.length)
-           bias = -1;
-       let from = linePos, to = linePos;
-       if (bias < 0)
-           from = findClusterBreak(line.text, linePos, false);
-       else
-           to = findClusterBreak(line.text, linePos);
-       let cat = categorize(line.text.slice(from, to));
-       while (from > 0) {
-           let prev = findClusterBreak(line.text, from, false);
-           if (categorize(line.text.slice(prev, from)) != cat)
-               break;
-           from = prev;
-       }
-       while (to < line.length) {
-           let next = findClusterBreak(line.text, to);
-           if (categorize(line.text.slice(to, next)) != cat)
-               break;
-           to = next;
-       }
-       return EditorSelection.range(from + line.from, to + line.from);
-   }
-   // Search the DOM for the {node, offset} position closest to the given
-   // coordinates. Very inefficient and crude, but can usually be avoided
-   // by calling caret(Position|Range)FromPoint instead.
-   function getdx(x, rect) {
-       return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);
-   }
-   function getdy(y, rect) {
-       return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);
-   }
-   function yOverlap(a, b) {
-       return a.top < b.bottom - 1 && a.bottom > b.top + 1;
-   }
-   function upTop(rect, top) {
-       return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;
-   }
-   function upBot(rect, bottom) {
-       return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;
-   }
-   function domPosAtCoords(parent, x, y) {
-       let closest, closestRect, closestX, closestY, closestOverlap = false;
-       let above, below, aboveRect, belowRect;
-       for (let child = parent.firstChild; child; child = child.nextSibling) {
-           let rects = clientRectsFor(child);
-           for (let i = 0; i < rects.length; i++) {
-               let rect = rects[i];
-               if (closestRect && yOverlap(closestRect, rect))
-                   rect = upTop(upBot(rect, closestRect.bottom), closestRect.top);
-               let dx = getdx(x, rect), dy = getdy(y, rect);
-               if (dx == 0 && dy == 0)
-                   return child.nodeType == 3 ? domPosInText(child, x, y) : domPosAtCoords(child, x, y);
-               if (!closest || closestY > dy || closestY == dy && closestX > dx) {
-                   closest = child;
-                   closestRect = rect;
-                   closestX = dx;
-                   closestY = dy;
-                   let side = dy ? (y < rect.top ? -1 : 1) : dx ? (x < rect.left ? -1 : 1) : 0;
-                   closestOverlap = !side || (side > 0 ? i < rects.length - 1 : i > 0);
-               }
-               if (dx == 0) {
-                   if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {
-                       above = child;
-                       aboveRect = rect;
-                   }
-                   else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {
-                       below = child;
-                       belowRect = rect;
-                   }
-               }
-               else if (aboveRect && yOverlap(aboveRect, rect)) {
-                   aboveRect = upBot(aboveRect, rect.bottom);
-               }
-               else if (belowRect && yOverlap(belowRect, rect)) {
-                   belowRect = upTop(belowRect, rect.top);
-               }
-           }
-       }
-       if (aboveRect && aboveRect.bottom >= y) {
-           closest = above;
-           closestRect = aboveRect;
-       }
-       else if (belowRect && belowRect.top <= y) {
-           closest = below;
-           closestRect = belowRect;
-       }
-       if (!closest)
-           return { node: parent, offset: 0 };
-       let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));
-       if (closest.nodeType == 3)
-           return domPosInText(closest, clipX, y);
-       if (closestOverlap && closest.contentEditable != "false")
-           return domPosAtCoords(closest, clipX, y);
-       let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +
-           (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);
-       return { node: parent, offset };
-   }
-   function domPosInText(node, x, y) {
-       let len = node.nodeValue.length;
-       let closestOffset = -1, closestDY = 1e9, generalSide = 0;
-       for (let i = 0; i < len; i++) {
-           let rects = textRange(node, i, i + 1).getClientRects();
-           for (let j = 0; j < rects.length; j++) {
-               let rect = rects[j];
-               if (rect.top == rect.bottom)
-                   continue;
-               if (!generalSide)
-                   generalSide = x - rect.left;
-               let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;
-               if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {
-                   let right = x >= (rect.left + rect.right) / 2, after = right;
-                   if (browser.chrome || browser.gecko) {
-                       // Check for RTL on browsers that support getting client
-                       // rects for empty ranges.
-                       let rectBefore = textRange(node, i).getBoundingClientRect();
-                       if (rectBefore.left == rect.right)
-                           after = !right;
-                   }
-                   if (dy <= 0)
-                       return { node, offset: i + (after ? 1 : 0) };
-                   closestOffset = i + (after ? 1 : 0);
-                   closestDY = dy;
-               }
-           }
-       }
-       return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };
-   }
-   function posAtCoords(view, coords, precise, bias = -1) {
-       var _a, _b;
-       let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;
-       let block, { docHeight } = view.viewState;
-       let { x, y } = coords, yOffset = y - docTop;
-       if (yOffset < 0)
-           return 0;
-       if (yOffset > docHeight)
-           return view.state.doc.length;
-       // Scan for a text block near the queried y position
-       for (let halfLine = view.viewState.heightOracle.textHeight / 2, bounced = false;;) {
-           block = view.elementAtHeight(yOffset);
-           if (block.type == BlockType.Text)
-               break;
-           for (;;) {
-               // Move the y position out of this block
-               yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;
-               if (yOffset >= 0 && yOffset <= docHeight)
-                   break;
-               // If the document consists entirely of replaced widgets, we
-               // won't find a text block, so return 0
-               if (bounced)
-                   return precise ? null : 0;
-               bounced = true;
-               bias = -bias;
-           }
-       }
-       y = docTop + yOffset;
-       let lineStart = block.from;
-       // If this is outside of the rendered viewport, we can't determine a position
-       if (lineStart < view.viewport.from)
-           return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise(view, content, block, x, y);
-       if (lineStart > view.viewport.to)
-           return view.viewport.to == view.state.doc.length ? view.state.doc.length :
-               precise ? null : posAtCoordsImprecise(view, content, block, x, y);
-       // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not
-       let doc = view.dom.ownerDocument;
-       let root = view.root.elementFromPoint ? view.root : doc;
-       let element = root.elementFromPoint(x, y);
-       if (element && !view.contentDOM.contains(element))
-           element = null;
-       // If the element is unexpected, clip x at the sides of the content area and try again
-       if (!element) {
-           x = Math.max(content.left + 1, Math.min(content.right - 1, x));
-           element = root.elementFromPoint(x, y);
-           if (element && !view.contentDOM.contains(element))
-               element = null;
-       }
-       // There's visible editor content under the point, so we can try
-       // using caret(Position|Range)FromPoint as a shortcut
-       let node, offset = -1;
-       if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {
-           if (doc.caretPositionFromPoint) {
-               let pos = doc.caretPositionFromPoint(x, y);
-               if (pos)
-                   ({ offsetNode: node, offset } = pos);
-           }
-           else if (doc.caretRangeFromPoint) {
-               let range = doc.caretRangeFromPoint(x, y);
-               if (range) {
-                   ({ startContainer: node, startOffset: offset } = range);
-                   if (!view.contentDOM.contains(node) ||
-                       browser.safari && isSuspiciousSafariCaretResult(node, offset, x) ||
-                       browser.chrome && isSuspiciousChromeCaretResult(node, offset, x))
-                       node = undefined;
-               }
-           }
-           // Chrome will return offsets into <input> elements without child
-           // nodes, which will lead to a null deref below, so clip the
-           // offset to the node size.
-           if (node)
-               offset = Math.min(maxOffset(node), offset);
-       }
-       // No luck, do our own (potentially expensive) search
-       if (!node || !view.docView.dom.contains(node)) {
-           let line = LineView.find(view.docView, lineStart);
-           if (!line)
-               return yOffset > block.top + block.height / 2 ? block.to : block.from;
-           ({ node, offset } = domPosAtCoords(line.dom, x, y));
-       }
-       let nearest = view.docView.nearest(node);
-       if (!nearest)
-           return null;
-       if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {
-           let rect = nearest.dom.getBoundingClientRect();
-           return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2
-               ? nearest.posAtStart : nearest.posAtEnd;
-       }
-       else {
-           return nearest.localPosFromDOM(node, offset) + nearest.posAtStart;
-       }
-   }
-   function posAtCoordsImprecise(view, contentRect, block, x, y) {
-       let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);
-       if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {
-           let textHeight = view.viewState.heightOracle.textHeight;
-           let line = Math.floor((y - block.top - (view.defaultLineHeight - textHeight) * 0.5) / textHeight);
-           into += line * view.viewState.heightOracle.lineLength;
-       }
-       let content = view.state.sliceDoc(block.from, block.to);
-       return block.from + findColumn(content, into, view.state.tabSize);
-   }
-   // In case of a high line height, Safari's caretRangeFromPoint treats
-   // the space between lines as belonging to the last character of the
-   // line before. This is used to detect such a result so that it can be
-   // ignored (issue #401).
-   function isSuspiciousSafariCaretResult(node, offset, x) {
-       let len;
-       if (node.nodeType != 3 || offset != (len = node.nodeValue.length))
-           return false;
-       for (let next = node.nextSibling; next; next = next.nextSibling)
-           if (next.nodeType != 1 || next.nodeName != "BR")
-               return false;
-       return textRange(node, len - 1, len).getBoundingClientRect().left > x;
-   }
-   // Chrome will move positions between lines to the start of the next line
-   function isSuspiciousChromeCaretResult(node, offset, x) {
-       if (offset != 0)
-           return false;
-       for (let cur = node;;) {
-           let parent = cur.parentNode;
-           if (!parent || parent.nodeType != 1 || parent.firstChild != cur)
-               return false;
-           if (parent.classList.contains("cm-line"))
-               break;
-           cur = parent;
-       }
-       let rect = node.nodeType == 1 ? node.getBoundingClientRect()
-           : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
-       return x - rect.left > 5;
-   }
-   function blockAt(view, pos) {
-       let line = view.lineBlockAt(pos);
-       if (Array.isArray(line.type))
-           for (let l of line.type) {
-               if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))
-                   return l;
-           }
-       return line;
-   }
-   function moveToLineBoundary(view, start, forward, includeWrap) {
-       let line = blockAt(view, start.head);
-       let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
-           : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
-       if (coords) {
-           let editorRect = view.dom.getBoundingClientRect();
-           let direction = view.textDirectionAt(line.from);
-           let pos = view.posAtCoords({ x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,
-               y: (coords.top + coords.bottom) / 2 });
-           if (pos != null)
-               return EditorSelection.cursor(pos, forward ? -1 : 1);
-       }
-       return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);
-   }
-   function moveByChar(view, start, forward, by) {
-       let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);
-       let direction = view.textDirectionAt(line.from);
-       for (let cur = start, check = null;;) {
-           let next = moveVisually(line, spans, direction, cur, forward), char = movedOver;
-           if (!next) {
-               if (line.number == (forward ? view.state.doc.lines : 1))
-                   return cur;
-               char = "\n";
-               line = view.state.doc.line(line.number + (forward ? 1 : -1));
-               spans = view.bidiSpans(line);
-               next = view.visualLineSide(line, !forward);
-           }
-           if (!check) {
-               if (!by)
-                   return next;
-               check = by(char);
-           }
-           else if (!check(char)) {
-               return cur;
-           }
-           cur = next;
-       }
-   }
-   function byGroup(view, pos, start) {
-       let categorize = view.state.charCategorizer(pos);
-       let cat = categorize(start);
-       return (next) => {
-           let nextCat = categorize(next);
-           if (cat == CharCategory.Space)
-               cat = nextCat;
-           return cat == nextCat;
-       };
-   }
-   function moveVertically(view, start, forward, distance) {
-       let startPos = start.head, dir = forward ? 1 : -1;
-       if (startPos == (forward ? view.state.doc.length : 0))
-           return EditorSelection.cursor(startPos, start.assoc);
-       let goal = start.goalColumn, startY;
-       let rect = view.contentDOM.getBoundingClientRect();
-       let startCoords = view.coordsAtPos(startPos, start.assoc || -1), docTop = view.documentTop;
-       if (startCoords) {
-           if (goal == null)
-               goal = startCoords.left - rect.left;
-           startY = dir < 0 ? startCoords.top : startCoords.bottom;
-       }
-       else {
-           let line = view.viewState.lineBlockAt(startPos);
-           if (goal == null)
-               goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
-           startY = (dir < 0 ? line.top : line.bottom) + docTop;
-       }
-       let resolvedGoal = rect.left + goal;
-       let dist = distance !== null && distance !== void 0 ? distance : (view.viewState.heightOracle.textHeight >> 1);
-       for (let extra = 0;; extra += 10) {
-           let curY = startY + (dist + extra) * dir;
-           let pos = posAtCoords(view, { x: resolvedGoal, y: curY }, false, dir);
-           if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos)) {
-               let charRect = view.docView.coordsForChar(pos);
-               let assoc = !charRect || curY < charRect.top ? -1 : 1;
-               return EditorSelection.cursor(pos, assoc, undefined, goal);
-           }
-       }
-   }
-   function skipAtomicRanges(atoms, pos, bias) {
-       for (;;) {
-           let moved = 0;
-           for (let set of atoms) {
-               set.between(pos - 1, pos + 1, (from, to, value) => {
-                   if (pos > from && pos < to) {
-                       let side = moved || bias || (pos - from < to - pos ? -1 : 1);
-                       pos = side < 0 ? from : to;
-                       moved = side;
-                   }
-               });
-           }
-           if (!moved)
-               return pos;
-       }
-   }
-   function skipAtoms(view, oldPos, pos) {
-       let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);
-       return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);
-   }
-
-   const LineBreakPlaceholder = "\uffff";
-   class DOMReader {
-       constructor(points, state) {
-           this.points = points;
-           this.text = "";
-           this.lineSeparator = state.facet(EditorState.lineSeparator);
-       }
-       append(text) {
-           this.text += text;
-       }
-       lineBreak() {
-           this.text += LineBreakPlaceholder;
-       }
-       readRange(start, end) {
-           if (!start)
-               return this;
-           let parent = start.parentNode;
-           for (let cur = start;;) {
-               this.findPointBefore(parent, cur);
-               let oldLen = this.text.length;
-               this.readNode(cur);
-               let next = cur.nextSibling;
-               if (next == end)
-                   break;
-               let view = ContentView.get(cur), nextView = ContentView.get(next);
-               if (view && nextView ? view.breakAfter :
-                   (view ? view.breakAfter : isBlockElement(cur)) ||
-                       (isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore) && this.text.length > oldLen))
-                   this.lineBreak();
-               cur = next;
-           }
-           this.findPointBefore(parent, end);
-           return this;
-       }
-       readTextNode(node) {
-           let text = node.nodeValue;
-           for (let point of this.points)
-               if (point.node == node)
-                   point.pos = this.text.length + Math.min(point.offset, text.length);
-           for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g;;) {
-               let nextBreak = -1, breakSize = 1, m;
-               if (this.lineSeparator) {
-                   nextBreak = text.indexOf(this.lineSeparator, off);
-                   breakSize = this.lineSeparator.length;
-               }
-               else if (m = re.exec(text)) {
-                   nextBreak = m.index;
-                   breakSize = m[0].length;
-               }
-               this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
-               if (nextBreak < 0)
-                   break;
-               this.lineBreak();
-               if (breakSize > 1)
-                   for (let point of this.points)
-                       if (point.node == node && point.pos > this.text.length)
-                           point.pos -= breakSize - 1;
-               off = nextBreak + breakSize;
-           }
-       }
-       readNode(node) {
-           if (node.cmIgnore)
-               return;
-           let view = ContentView.get(node);
-           let fromView = view && view.overrideDOMText;
-           if (fromView != null) {
-               this.findPointInside(node, fromView.length);
-               for (let i = fromView.iter(); !i.next().done;) {
-                   if (i.lineBreak)
-                       this.lineBreak();
-                   else
-                       this.append(i.value);
-               }
-           }
-           else if (node.nodeType == 3) {
-               this.readTextNode(node);
-           }
-           else if (node.nodeName == "BR") {
-               if (node.nextSibling)
-                   this.lineBreak();
-           }
-           else if (node.nodeType == 1) {
-               this.readRange(node.firstChild, null);
-           }
-       }
-       findPointBefore(node, next) {
-           for (let point of this.points)
-               if (point.node == node && node.childNodes[point.offset] == next)
-                   point.pos = this.text.length;
-       }
-       findPointInside(node, length) {
-           for (let point of this.points)
-               if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
-                   point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);
-       }
-   }
-   function isAtEnd(parent, node, offset) {
-       for (;;) {
-           if (!node || offset < maxOffset(node))
-               return false;
-           if (node == parent)
-               return true;
-           offset = domIndex(node) + 1;
-           node = node.parentNode;
-       }
-   }
-   class DOMPoint {
-       constructor(node, offset) {
-           this.node = node;
-           this.offset = offset;
-           this.pos = -1;
-       }
-   }
-
-   class DOMChange {
-       constructor(view, start, end, typeOver) {
-           this.typeOver = typeOver;
-           this.bounds = null;
-           this.text = "";
-           this.domChanged = start > -1;
-           let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;
-           if (view.state.readOnly && start > -1) {
-               // Ignore changes when the editor is read-only
-               this.newSel = null;
-           }
-           else if (start > -1 && (this.bounds = view.docView.domBoundsAround(start, end, 0))) {
-               let selPoints = iHead || iAnchor ? [] : selectionPoints(view);
-               let reader = new DOMReader(selPoints, view.state);
-               reader.readRange(this.bounds.startDOM, this.bounds.endDOM);
-               this.text = reader.text;
-               this.newSel = selectionFromPoints(selPoints, this.bounds.from);
-           }
-           else {
-               let domSel = view.observer.selectionRange;
-               let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||
-                   !contains(view.contentDOM, domSel.focusNode)
-                   ? view.state.selection.main.head
-                   : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
-               let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||
-                   !contains(view.contentDOM, domSel.anchorNode)
-                   ? view.state.selection.main.anchor
-                   : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
-               // iOS will refuse to select the block gaps when doing
-               // select-all.
-               // Chrome will put the selection *inside* them, confusing
-               // posFromDOM
-               let vp = view.viewport;
-               if ((browser.ios || browser.chrome) && view.state.selection.main.empty && head != anchor &&
-                   (vp.from > 0 || vp.to < view.state.doc.length)) {
-                   let from = Math.min(head, anchor), to = Math.max(head, anchor);
-                   let offFrom = vp.from - from, offTo = vp.to - to;
-                   if ((offFrom == 0 || offFrom == 1 || from == 0) && (offTo == 0 || offTo == -1 || to == view.state.doc.length)) {
-                       head = 0;
-                       anchor = view.state.doc.length;
-                   }
-               }
-               this.newSel = EditorSelection.single(anchor, head);
-           }
-       }
-   }
-   function applyDOMChange(view, domChange) {
-       let change;
-       let { newSel } = domChange, sel = view.state.selection.main;
-       let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;
-       if (domChange.bounds) {
-           let { from, to } = domChange.bounds;
-           let preferredPos = sel.from, preferredSide = null;
-           // Prefer anchoring to end when Backspace is pressed (or, on
-           // Android, when something was deleted)
-           if (lastKey === 8 || browser.android && domChange.text.length < to - from) {
-               preferredPos = sel.to;
-               preferredSide = "end";
-           }
-           let diff = findDiff(view.state.doc.sliceString(from, to, LineBreakPlaceholder), domChange.text, preferredPos - from, preferredSide);
-           if (diff) {
-               // Chrome inserts two newlines when pressing shift-enter at the
-               // end of a line. DomChange drops one of those.
-               if (browser.chrome && lastKey == 13 &&
-                   diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)
-                   diff.toB--;
-               change = { from: from + diff.from, to: from + diff.toA,
-                   insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
-           }
-       }
-       else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
-           newSel = null;
-       }
-       if (!change && !newSel)
-           return false;
-       if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {
-           // Heuristic to notice typing over a selected character
-           change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };
-       }
-       else if (change && change.from >= sel.from && change.to <= sel.to &&
-           (change.from != sel.from || change.to != sel.to) &&
-           (sel.to - sel.from) - (change.to - change.from) <= 4) {
-           // If the change is inside the selection and covers most of it,
-           // assume it is a selection replace (with identical characters at
-           // the start/end not included in the diff)
-           change = {
-               from: sel.from, to: sel.to,
-               insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))
-           };
-       }
-       else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&
-           /^\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute("autocorrect") == "off") {
-           // Detect insert-period-on-double-space Mac and Android behavior,
-           // and transform it into a regular space insert.
-           if (newSel && change.insert.length == 2)
-               newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
-           change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
-       }
-       else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&
-           change.insert.toString() == "\n " && view.lineWrapping) {
-           // In Chrome, if you insert a space at the start of a wrapped
-           // line, it will actually insert a newline and a space, causing a
-           // bogus new line to be created in CodeMirror (#968)
-           if (newSel)
-               newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
-           change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
-       }
-       if (change) {
-           return applyDOMChangeInner(view, change, newSel, lastKey);
-       }
-       else if (newSel && !newSel.main.eq(sel)) {
-           let scrollIntoView = false, userEvent = "select";
-           if (view.inputState.lastSelectionTime > Date.now() - 50) {
-               if (view.inputState.lastSelectionOrigin == "select")
-                   scrollIntoView = true;
-               userEvent = view.inputState.lastSelectionOrigin;
-           }
-           view.dispatch({ selection: newSel, scrollIntoView, userEvent });
-           return true;
-       }
-       else {
-           return false;
-       }
-   }
-   function applyDOMChangeInner(view, change, newSel, lastKey = -1) {
-       if (browser.ios && view.inputState.flushIOSKey(change))
-           return true;
-       let sel = view.state.selection.main;
-       // Android browsers don't fire reasonable key events for enter,
-       // backspace, or delete. So this detects changes that look like
-       // they're caused by those keys, and reinterprets them as key
-       // events. (Some of these keys are also handled by beforeinput
-       // events and the pendingAndroidKey mechanism, but that's not
-       // reliable in all situations.)
-       if (browser.android &&
-           ((change.to == sel.to &&
-               // GBoard will sometimes remove a space it just inserted
-               // after a completion when you press enter
-               (change.from == sel.from || change.from == sel.from - 1 && view.state.sliceDoc(change.from, sel.from) == " ") &&
-               change.insert.length == 1 && change.insert.lines == 2 &&
-               dispatchKey(view.contentDOM, "Enter", 13)) ||
-               ((change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 ||
-                   lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) &&
-                   dispatchKey(view.contentDOM, "Backspace", 8)) ||
-               (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&
-                   dispatchKey(view.contentDOM, "Delete", 46))))
-           return true;
-       let text = change.insert.toString();
-       if (view.inputState.composing >= 0)
-           view.inputState.composing++;
-       let defaultTr;
-       let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));
-       if (!view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text, defaultInsert)))
-           view.dispatch(defaultInsert());
-       return true;
-   }
-   function applyDefaultInsert(view, change, newSel) {
-       let tr, startState = view.state, sel = startState.selection.main;
-       if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&
-           (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&
-           view.inputState.composing < 0) {
-           let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : "";
-           let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : "";
-           tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));
-       }
-       else {
-           let changes = startState.changes(change);
-           let mainSel = newSel && newSel.main.to <= changes.newLength ? newSel.main : undefined;
-           // Try to apply a composition change to all cursors
-           if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&
-               change.to <= sel.to && change.to >= sel.to - 10) {
-               let replaced = view.state.sliceDoc(change.from, change.to);
-               let compositionRange, composition = newSel && findCompositionNode(view, newSel.main.head);
-               if (composition) {
-                   let dLen = change.insert.length - (change.to - change.from);
-                   compositionRange = { from: composition.from, to: composition.to - dLen };
-               }
-               else {
-                   compositionRange = view.state.doc.lineAt(sel.head);
-               }
-               let offset = sel.to - change.to, size = sel.to - sel.from;
-               tr = startState.changeByRange(range => {
-                   if (range.from == sel.from && range.to == sel.to)
-                       return { changes, range: mainSel || range.map(changes) };
-                   let to = range.to - offset, from = to - replaced.length;
-                   if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||
-                       // Unfortunately, there's no way to make multiple
-                       // changes in the same node work without aborting
-                       // composition, so cursors in the composition range are
-                       // ignored.
-                       range.to >= compositionRange.from && range.from <= compositionRange.to)
-                       return { range };
-                   let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
-                   return {
-                       changes: rangeChanges,
-                       range: !mainSel ? range.map(rangeChanges) :
-                           EditorSelection.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))
-                   };
-               });
-           }
-           else {
-               tr = {
-                   changes,
-                   selection: mainSel && startState.selection.replaceRange(mainSel)
-               };
-           }
-       }
-       let userEvent = "input.type";
-       if (view.composing ||
-           view.inputState.compositionPendingChange && view.inputState.compositionEndedAt > Date.now() - 50) {
-           view.inputState.compositionPendingChange = false;
-           userEvent += ".compose";
-           if (view.inputState.compositionFirstChange) {
-               userEvent += ".start";
-               view.inputState.compositionFirstChange = false;
-           }
-       }
-       return startState.update(tr, { userEvent, scrollIntoView: true });
-   }
-   function findDiff(a, b, preferredPos, preferredSide) {
-       let minLen = Math.min(a.length, b.length);
-       let from = 0;
-       while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))
-           from++;
-       if (from == minLen && a.length == b.length)
-           return null;
-       let toA = a.length, toB = b.length;
-       while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {
-           toA--;
-           toB--;
-       }
-       if (preferredSide == "end") {
-           let adjust = Math.max(0, from - Math.min(toA, toB));
-           preferredPos -= toA + adjust - from;
-       }
-       if (toA < from && a.length < b.length) {
-           let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;
-           from -= move;
-           toB = from + (toB - toA);
-           toA = from;
-       }
-       else if (toB < from) {
-           let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;
-           from -= move;
-           toA = from + (toA - toB);
-           toB = from;
-       }
-       return { from, toA, toB };
-   }
-   function selectionPoints(view) {
-       let result = [];
-       if (view.root.activeElement != view.contentDOM)
-           return result;
-       let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;
-       if (anchorNode) {
-           result.push(new DOMPoint(anchorNode, anchorOffset));
-           if (focusNode != anchorNode || focusOffset != anchorOffset)
-               result.push(new DOMPoint(focusNode, focusOffset));
-       }
-       return result;
-   }
-   function selectionFromPoints(points, base) {
-       if (points.length == 0)
-           return null;
-       let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;
-       return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;
-   }
-
-   class InputState {
-       setSelectionOrigin(origin) {
-           this.lastSelectionOrigin = origin;
-           this.lastSelectionTime = Date.now();
-       }
-       constructor(view) {
-           this.view = view;
-           this.lastKeyCode = 0;
-           this.lastKeyTime = 0;
-           this.lastTouchTime = 0;
-           this.lastFocusTime = 0;
-           this.lastScrollTop = 0;
-           this.lastScrollLeft = 0;
-           // On iOS, some keys need to have their default behavior happen
-           // (after which we retroactively handle them and reset the DOM) to
-           // avoid messing up the virtual keyboard state.
-           this.pendingIOSKey = undefined;
-           /**
-           When enabled (>-1), tab presses are not given to key handlers,
-           leaving the browser's default behavior. If >0, the mode expires
-           at that timestamp, and any other keypress clears it.
-           Esc enables temporary tab focus mode for two seconds when not
-           otherwise handled.
-           */
-           this.tabFocusMode = -1;
-           this.lastSelectionOrigin = null;
-           this.lastSelectionTime = 0;
-           this.lastContextMenu = 0;
-           this.scrollHandlers = [];
-           this.handlers = Object.create(null);
-           // -1 means not in a composition. Otherwise, this counts the number
-           // of changes made during the composition. The count is used to
-           // avoid treating the start state of the composition, before any
-           // changes have been made, as part of the composition.
-           this.composing = -1;
-           // Tracks whether the next change should be marked as starting the
-           // composition (null means no composition, true means next is the
-           // first, false means first has already been marked for this
-           // composition)
-           this.compositionFirstChange = null;
-           // End time of the previous composition
-           this.compositionEndedAt = 0;
-           // Used in a kludge to detect when an Enter keypress should be
-           // considered part of the composition on Safari, which fires events
-           // in the wrong order
-           this.compositionPendingKey = false;
-           // Used to categorize changes as part of a composition, even when
-           // the mutation events fire shortly after the compositionend event
-           this.compositionPendingChange = false;
-           this.mouseSelection = null;
-           // When a drag from the editor is active, this points at the range
-           // being dragged.
-           this.draggedContent = null;
-           this.handleEvent = this.handleEvent.bind(this);
-           this.notifiedFocused = view.hasFocus;
-           // On Safari adding an input event handler somehow prevents an
-           // issue where the composition vanishes when you press enter.
-           if (browser.safari)
-               view.contentDOM.addEventListener("input", () => null);
-           if (browser.gecko)
-               firefoxCopyCutHack(view.contentDOM.ownerDocument);
-       }
-       handleEvent(event) {
-           if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event))
-               return;
-           if (event.type == "keydown" && this.keydown(event))
-               return;
-           this.runHandlers(event.type, event);
-       }
-       runHandlers(type, event) {
-           let handlers = this.handlers[type];
-           if (handlers) {
-               for (let observer of handlers.observers)
-                   observer(this.view, event);
-               for (let handler of handlers.handlers) {
-                   if (event.defaultPrevented)
-                       break;
-                   if (handler(this.view, event)) {
-                       event.preventDefault();
-                       break;
-                   }
-               }
-           }
-       }
-       ensureHandlers(plugins) {
-           let handlers = computeHandlers(plugins), prev = this.handlers, dom = this.view.contentDOM;
-           for (let type in handlers)
-               if (type != "scroll") {
-                   let passive = !handlers[type].handlers.length;
-                   let exists = prev[type];
-                   if (exists && passive != !exists.handlers.length) {
-                       dom.removeEventListener(type, this.handleEvent);
-                       exists = null;
-                   }
-                   if (!exists)
-                       dom.addEventListener(type, this.handleEvent, { passive });
-               }
-           for (let type in prev)
-               if (type != "scroll" && !handlers[type])
-                   dom.removeEventListener(type, this.handleEvent);
-           this.handlers = handlers;
-       }
-       keydown(event) {
-           // Must always run, even if a custom handler handled the event
-           this.lastKeyCode = event.keyCode;
-           this.lastKeyTime = Date.now();
-           if (event.keyCode == 9 && this.tabFocusMode > -1 && (!this.tabFocusMode || Date.now() <= this.tabFocusMode))
-               return true;
-           if (this.tabFocusMode > 0 && event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)
-               this.tabFocusMode = -1;
-           // Chrome for Android usually doesn't fire proper key events, but
-           // occasionally does, usually surrounded by a bunch of complicated
-           // composition changes. When an enter or backspace key event is
-           // seen, hold off on handling DOM events for a bit, and then
-           // dispatch it.
-           if (browser.android && browser.chrome && !event.synthetic &&
-               (event.keyCode == 13 || event.keyCode == 8)) {
-               this.view.observer.delayAndroidKey(event.key, event.keyCode);
-               return true;
-           }
-           // Preventing the default behavior of Enter on iOS makes the
-           // virtual keyboard get stuck in the wrong (lowercase)
-           // state. So we let it go through, and then, in
-           // applyDOMChange, notify key handlers of it and reset to
-           // the state they produce.
-           let pending;
-           if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&
-               ((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||
-                   EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {
-               this.pendingIOSKey = pending || event;
-               setTimeout(() => this.flushIOSKey(), 250);
-               return true;
-           }
-           if (event.keyCode != 229)
-               this.view.observer.forceFlush();
-           return false;
-       }
-       flushIOSKey(change) {
-           let key = this.pendingIOSKey;
-           if (!key)
-               return false;
-           // This looks like an autocorrection before Enter
-           if (key.key == "Enter" && change && change.from < change.to && /^\S+$/.test(change.insert.toString()))
-               return false;
-           this.pendingIOSKey = undefined;
-           return dispatchKey(this.view.contentDOM, key.key, key.keyCode, key instanceof KeyboardEvent ? key : undefined);
-       }
-       ignoreDuringComposition(event) {
-           if (!/^key/.test(event.type))
-               return false;
-           if (this.composing > 0)
-               return true;
-           // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.
-           // On some input method editors (IMEs), the Enter key is used to
-           // confirm character selection. On Safari, when Enter is pressed,
-           // compositionend and keydown events are sometimes emitted in the
-           // wrong order. The key event should still be ignored, even when
-           // it happens after the compositionend event.
-           if (browser.safari && !browser.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100) {
-               this.compositionPendingKey = false;
-               return true;
-           }
-           return false;
-       }
-       startMouseSelection(mouseSelection) {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-           this.mouseSelection = mouseSelection;
-       }
-       update(update) {
-           this.view.observer.update(update);
-           if (this.mouseSelection)
-               this.mouseSelection.update(update);
-           if (this.draggedContent && update.docChanged)
-               this.draggedContent = this.draggedContent.map(update.changes);
-           if (update.transactions.length)
-               this.lastKeyCode = this.lastSelectionTime = 0;
-       }
-       destroy() {
-           if (this.mouseSelection)
-               this.mouseSelection.destroy();
-       }
-   }
-   function bindHandler(plugin, handler) {
-       return (view, event) => {
-           try {
-               return handler.call(plugin, event, view);
-           }
-           catch (e) {
-               logException(view.state, e);
-           }
-       };
-   }
-   function computeHandlers(plugins) {
-       let result = Object.create(null);
-       function record(type) {
-           return result[type] || (result[type] = { observers: [], handlers: [] });
-       }
-       for (let plugin of plugins) {
-           let spec = plugin.spec;
-           if (spec && spec.domEventHandlers)
-               for (let type in spec.domEventHandlers) {
-                   let f = spec.domEventHandlers[type];
-                   if (f)
-                       record(type).handlers.push(bindHandler(plugin.value, f));
-               }
-           if (spec && spec.domEventObservers)
-               for (let type in spec.domEventObservers) {
-                   let f = spec.domEventObservers[type];
-                   if (f)
-                       record(type).observers.push(bindHandler(plugin.value, f));
-               }
-       }
-       for (let type in handlers)
-           record(type).handlers.push(handlers[type]);
-       for (let type in observers)
-           record(type).observers.push(observers[type]);
-       return result;
-   }
-   const PendingKeys = [
-       { key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
-       { key: "Enter", keyCode: 13, inputType: "insertParagraph" },
-       { key: "Enter", keyCode: 13, inputType: "insertLineBreak" },
-       { key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
-   ];
-   const EmacsyPendingKeys = "dthko";
-   // Key codes for modifier keys
-   const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
-   const dragScrollMargin = 6;
-   function dragScrollSpeed(dist) {
-       return Math.max(0, dist) * 0.7 + 8;
-   }
-   function dist(a, b) {
-       return Math.max(Math.abs(a.clientX - b.clientX), Math.abs(a.clientY - b.clientY));
-   }
-   class MouseSelection {
-       constructor(view, startEvent, style, mustSelect) {
-           this.view = view;
-           this.startEvent = startEvent;
-           this.style = style;
-           this.mustSelect = mustSelect;
-           this.scrollSpeed = { x: 0, y: 0 };
-           this.scrolling = -1;
-           this.lastEvent = startEvent;
-           this.scrollParents = scrollableParents(view.contentDOM);
-           this.atoms = view.state.facet(atomicRanges).map(f => f(view));
-           let doc = view.contentDOM.ownerDocument;
-           doc.addEventListener("mousemove", this.move = this.move.bind(this));
-           doc.addEventListener("mouseup", this.up = this.up.bind(this));
-           this.extend = startEvent.shiftKey;
-           this.multiple = view.state.facet(EditorState.allowMultipleSelections) && addsSelectionRange(view, startEvent);
-           this.dragging = isInPrimarySelection(view, startEvent) && getClickType(startEvent) == 1 ? null : false;
-       }
-       start(event) {
-           // When clicking outside of the selection, immediately apply the
-           // effect of starting the selection
-           if (this.dragging === false)
-               this.select(event);
-       }
-       move(event) {
-           if (event.buttons == 0)
-               return this.destroy();
-           if (this.dragging || this.dragging == null && dist(this.startEvent, event) < 10)
-               return;
-           this.select(this.lastEvent = event);
-           let sx = 0, sy = 0;
-           let left = 0, top = 0, right = this.view.win.innerWidth, bottom = this.view.win.innerHeight;
-           if (this.scrollParents.x)
-               ({ left, right } = this.scrollParents.x.getBoundingClientRect());
-           if (this.scrollParents.y)
-               ({ top, bottom } = this.scrollParents.y.getBoundingClientRect());
-           let margins = getScrollMargins(this.view);
-           if (event.clientX - margins.left <= left + dragScrollMargin)
-               sx = -dragScrollSpeed(left - event.clientX);
-           else if (event.clientX + margins.right >= right - dragScrollMargin)
-               sx = dragScrollSpeed(event.clientX - right);
-           if (event.clientY - margins.top <= top + dragScrollMargin)
-               sy = -dragScrollSpeed(top - event.clientY);
-           else if (event.clientY + margins.bottom >= bottom - dragScrollMargin)
-               sy = dragScrollSpeed(event.clientY - bottom);
-           this.setScrollSpeed(sx, sy);
-       }
-       up(event) {
-           if (this.dragging == null)
-               this.select(this.lastEvent);
-           if (!this.dragging)
-               event.preventDefault();
-           this.destroy();
-       }
-       destroy() {
-           this.setScrollSpeed(0, 0);
-           let doc = this.view.contentDOM.ownerDocument;
-           doc.removeEventListener("mousemove", this.move);
-           doc.removeEventListener("mouseup", this.up);
-           this.view.inputState.mouseSelection = this.view.inputState.draggedContent = null;
-       }
-       setScrollSpeed(sx, sy) {
-           this.scrollSpeed = { x: sx, y: sy };
-           if (sx || sy) {
-               if (this.scrolling < 0)
-                   this.scrolling = setInterval(() => this.scroll(), 50);
-           }
-           else if (this.scrolling > -1) {
-               clearInterval(this.scrolling);
-               this.scrolling = -1;
-           }
-       }
-       scroll() {
-           let { x, y } = this.scrollSpeed;
-           if (x && this.scrollParents.x) {
-               this.scrollParents.x.scrollLeft += x;
-               x = 0;
-           }
-           if (y && this.scrollParents.y) {
-               this.scrollParents.y.scrollTop += y;
-               y = 0;
-           }
-           if (x || y)
-               this.view.win.scrollBy(x, y);
-           if (this.dragging === false)
-               this.select(this.lastEvent);
-       }
-       skipAtoms(sel) {
-           let ranges = null;
-           for (let i = 0; i < sel.ranges.length; i++) {
-               let range = sel.ranges[i], updated = null;
-               if (range.empty) {
-                   let pos = skipAtomicRanges(this.atoms, range.from, 0);
-                   if (pos != range.from)
-                       updated = EditorSelection.cursor(pos, -1);
-               }
-               else {
-                   let from = skipAtomicRanges(this.atoms, range.from, -1);
-                   let to = skipAtomicRanges(this.atoms, range.to, 1);
-                   if (from != range.from || to != range.to)
-                       updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);
-               }
-               if (updated) {
-                   if (!ranges)
-                       ranges = sel.ranges.slice();
-                   ranges[i] = updated;
-               }
-           }
-           return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;
-       }
-       select(event) {
-           let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
-           if (this.mustSelect || !selection.eq(view.state.selection, this.dragging === false))
-               this.view.dispatch({
-                   selection,
-                   userEvent: "select.pointer"
-               });
-           this.mustSelect = false;
-       }
-       update(update) {
-           if (update.transactions.some(tr => tr.isUserEvent("input.type")))
-               this.destroy();
-           else if (this.style.update(update))
-               setTimeout(() => this.select(this.lastEvent), 20);
-       }
-   }
-   function addsSelectionRange(view, event) {
-       let facet = view.state.facet(clickAddsSelectionRange);
-       return facet.length ? facet[0](event) : browser.mac ? event.metaKey : event.ctrlKey;
-   }
-   function dragMovesSelection(view, event) {
-       let facet = view.state.facet(dragMovesSelection$1);
-       return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;
-   }
-   function isInPrimarySelection(view, event) {
-       let { main } = view.state.selection;
-       if (main.empty)
-           return false;
-       // On boundary clicks, check whether the coordinates are inside the
-       // selection's client rectangles
-       let sel = getSelection(view.root);
-       if (!sel || sel.rangeCount == 0)
-           return true;
-       let rects = sel.getRangeAt(0).getClientRects();
-       for (let i = 0; i < rects.length; i++) {
-           let rect = rects[i];
-           if (rect.left <= event.clientX && rect.right >= event.clientX &&
-               rect.top <= event.clientY && rect.bottom >= event.clientY)
-               return true;
-       }
-       return false;
-   }
-   function eventBelongsToEditor(view, event) {
-       if (!event.bubbles)
-           return true;
-       if (event.defaultPrevented)
-           return false;
-       for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)
-           if (!node || node.nodeType == 11 || ((cView = ContentView.get(node)) && cView.ignoreEvent(event)))
-               return false;
-       return true;
-   }
-   const handlers = /*@__PURE__*/Object.create(null);
-   const observers = /*@__PURE__*/Object.create(null);
-   // This is very crude, but unfortunately both these browsers _pretend_
-   // that they have a clipboard API—all the objects and methods are
-   // there, they just don't work, and they are hard to test.
-   const brokenClipboardAPI = (browser.ie && browser.ie_version < 15) ||
-       (browser.ios && browser.webkit_version < 604);
-   function capturePaste(view) {
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.focus();
-       setTimeout(() => {
-           view.focus();
-           target.remove();
-           doPaste(view, target.value);
-       }, 50);
-   }
-   function textFilter(state, facet, text) {
-       for (let filter of state.facet(facet))
-           text = filter(text, state);
-       return text;
-   }
-   function doPaste(view, input) {
-       input = textFilter(view.state, clipboardInputFilter, input);
-       let { state } = view, changes, i = 1, text = state.toText(input);
-       let byLine = text.lines == state.selection.ranges.length;
-       let linewise = lastLinewiseCopy != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy == text.toString();
-       if (linewise) {
-           let lastLine = -1;
-           changes = state.changeByRange(range => {
-               let line = state.doc.lineAt(range.from);
-               if (line.from == lastLine)
-                   return { range };
-               lastLine = line.from;
-               let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);
-               return { changes: { from: line.from, insert },
-                   range: EditorSelection.cursor(range.from + insert.length) };
-           });
-       }
-       else if (byLine) {
-           changes = state.changeByRange(range => {
-               let line = text.line(i++);
-               return { changes: { from: range.from, to: range.to, insert: line.text },
-                   range: EditorSelection.cursor(range.from + line.length) };
-           });
-       }
-       else {
-           changes = state.replaceSelection(text);
-       }
-       view.dispatch(changes, {
-           userEvent: "input.paste",
-           scrollIntoView: true
-       });
-   }
-   observers.scroll = view => {
-       view.inputState.lastScrollTop = view.scrollDOM.scrollTop;
-       view.inputState.lastScrollLeft = view.scrollDOM.scrollLeft;
-   };
-   handlers.keydown = (view, event) => {
-       view.inputState.setSelectionOrigin("select");
-       if (event.keyCode == 27 && view.inputState.tabFocusMode != 0)
-           view.inputState.tabFocusMode = Date.now() + 2000;
-       return false;
-   };
-   observers.touchstart = (view, e) => {
-       view.inputState.lastTouchTime = Date.now();
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   observers.touchmove = view => {
-       view.inputState.setSelectionOrigin("select.pointer");
-   };
-   handlers.mousedown = (view, event) => {
-       view.observer.flush();
-       if (view.inputState.lastTouchTime > Date.now() - 2000)
-           return false; // Ignore touch interaction
-       let style = null;
-       for (let makeStyle of view.state.facet(mouseSelectionStyle)) {
-           style = makeStyle(view, event);
-           if (style)
-               break;
-       }
-       if (!style && event.button == 0)
-           style = basicMouseSelection(view, event);
-       if (style) {
-           let mustFocus = !view.hasFocus;
-           view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));
-           if (mustFocus)
-               view.observer.ignore(() => {
-                   focusPreventScroll(view.contentDOM);
-                   let active = view.root.activeElement;
-                   if (active && !active.contains(view.contentDOM))
-                       active.blur();
-               });
-           let mouseSel = view.inputState.mouseSelection;
-           if (mouseSel) {
-               mouseSel.start(event);
-               return mouseSel.dragging === false;
-           }
-       }
-       return false;
-   };
-   function rangeForClick(view, pos, bias, type) {
-       if (type == 1) { // Single click
-           return EditorSelection.cursor(pos, bias);
-       }
-       else if (type == 2) { // Double click
-           return groupAt(view.state, pos, bias);
-       }
-       else { // Triple click
-           let visual = LineView.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);
-           let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;
-           if (to < view.state.doc.length && to == line.to)
-               to++;
-           return EditorSelection.range(from, to);
-       }
-   }
-   let inside = (x, y, rect) => y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;
-   // Try to determine, for the given coordinates, associated with the
-   // given position, whether they are related to the element before or
-   // the element after the position.
-   function findPositionSide(view, pos, x, y) {
-       let line = LineView.find(view.docView, pos);
-       if (!line)
-           return 1;
-       let off = pos - line.posAtStart;
-       // Line boundaries point into the line
-       if (off == 0)
-           return 1;
-       if (off == line.length)
-           return -1;
-       // Positions on top of an element point at that element
-       let before = line.coordsAt(off, -1);
-       if (before && inside(x, y, before))
-           return -1;
-       let after = line.coordsAt(off, 1);
-       if (after && inside(x, y, after))
-           return 1;
-       // This is probably a line wrap point. Pick before if the point is
-       // above its bottom.
-       return before && before.bottom >= y ? -1 : 1;
-   }
-   function queryPos(view, event) {
-       let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };
-   }
-   const BadMouseDetail = browser.ie && browser.ie_version <= 11;
-   let lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;
-   function getClickType(event) {
-       if (!BadMouseDetail)
-           return event.detail;
-       let last = lastMouseDown, lastTime = lastMouseDownTime;
-       lastMouseDown = event;
-       lastMouseDownTime = Date.now();
-       return lastMouseDownCount = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&
-           Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;
-   }
-   function basicMouseSelection(view, event) {
-       let start = queryPos(view, event), type = getClickType(event);
-       let startSel = view.state.selection;
-       return {
-           update(update) {
-               if (update.docChanged) {
-                   start.pos = update.changes.mapPos(start.pos);
-                   startSel = startSel.map(update.changes);
-               }
-           },
-           get(event, extend, multiple) {
-               let cur = queryPos(view, event), removed;
-               let range = rangeForClick(view, cur.pos, cur.bias, type);
-               if (start.pos != cur.pos && !extend) {
-                   let startRange = rangeForClick(view, start.pos, start.bias, type);
-                   let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);
-                   range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);
-               }
-               if (extend)
-                   return startSel.replaceRange(startSel.main.extend(range.from, range.to));
-               else if (multiple && type == 1 && startSel.ranges.length > 1 && (removed = removeRangeAround(startSel, cur.pos)))
-                   return removed;
-               else if (multiple)
-                   return startSel.addRange(range);
-               else
-                   return EditorSelection.create([range]);
-           }
-       };
-   }
-   function removeRangeAround(sel, pos) {
-       for (let i = 0; i < sel.ranges.length; i++) {
-           let { from, to } = sel.ranges[i];
-           if (from <= pos && to >= pos)
-               return EditorSelection.create(sel.ranges.slice(0, i).concat(sel.ranges.slice(i + 1)), sel.mainIndex == i ? 0 : sel.mainIndex - (sel.mainIndex > i ? 1 : 0));
-       }
-       return null;
-   }
-   handlers.dragstart = (view, event) => {
-       let { selection: { main: range } } = view.state;
-       if (event.target.draggable) {
-           let cView = view.docView.nearest(event.target);
-           if (cView && cView.isWidget) {
-               let from = cView.posAtStart, to = from + cView.length;
-               if (from >= range.to || to <= range.from)
-                   range = EditorSelection.range(from, to);
-           }
-       }
-       let { inputState } = view;
-       if (inputState.mouseSelection)
-           inputState.mouseSelection.dragging = true;
-       inputState.draggedContent = range;
-       if (event.dataTransfer) {
-           event.dataTransfer.setData("Text", textFilter(view.state, clipboardOutputFilter, view.state.sliceDoc(range.from, range.to)));
-           event.dataTransfer.effectAllowed = "copyMove";
-       }
-       return false;
-   };
-   handlers.dragend = view => {
-       view.inputState.draggedContent = null;
-       return false;
-   };
-   function dropText(view, event, text, direct) {
-       text = textFilter(view.state, clipboardInputFilter, text);
-       if (!text)
-           return;
-       let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
-       let { draggedContent } = view.inputState;
-       let del = direct && draggedContent && dragMovesSelection(view, event)
-           ? { from: draggedContent.from, to: draggedContent.to } : null;
-       let ins = { from: dropPos, insert: text };
-       let changes = view.state.changes(del ? [del, ins] : ins);
-       view.focus();
-       view.dispatch({
-           changes,
-           selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },
-           userEvent: del ? "move.drop" : "input.drop"
-       });
-       view.inputState.draggedContent = null;
-   }
-   handlers.drop = (view, event) => {
-       if (!event.dataTransfer)
-           return false;
-       if (view.state.readOnly)
-           return true;
-       let files = event.dataTransfer.files;
-       if (files && files.length) { // For a file drop, read the file's text.
-           let text = Array(files.length), read = 0;
-           let finishFile = () => {
-               if (++read == files.length)
-                   dropText(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);
-           };
-           for (let i = 0; i < files.length; i++) {
-               let reader = new FileReader;
-               reader.onerror = finishFile;
-               reader.onload = () => {
-                   if (!/[\x00-\x08\x0e-\x1f]{2}/.test(reader.result))
-                       text[i] = reader.result;
-                   finishFile();
-               };
-               reader.readAsText(files[i]);
-           }
-           return true;
-       }
-       else {
-           let text = event.dataTransfer.getData("Text");
-           if (text) {
-               dropText(view, event, text, true);
-               return true;
-           }
-       }
-       return false;
-   };
-   handlers.paste = (view, event) => {
-       if (view.state.readOnly)
-           return true;
-       view.observer.flush();
-       let data = brokenClipboardAPI ? null : event.clipboardData;
-       if (data) {
-           doPaste(view, data.getData("text/plain") || data.getData("text/uri-list"));
-           return true;
-       }
-       else {
-           capturePaste(view);
-           return false;
-       }
-   };
-   function captureCopy(view, text) {
-       // The extra wrapper is somehow necessary on IE/Edge to prevent the
-       // content from being mangled when it is put onto the clipboard
-       let parent = view.dom.parentNode;
-       if (!parent)
-           return;
-       let target = parent.appendChild(document.createElement("textarea"));
-       target.style.cssText = "position: fixed; left: -10000px; top: 10px";
-       target.value = text;
-       target.focus();
-       target.selectionEnd = text.length;
-       target.selectionStart = 0;
-       setTimeout(() => {
-           target.remove();
-           view.focus();
-       }, 50);
-   }
-   function copiedRange(state) {
-       let content = [], ranges = [], linewise = false;
-       for (let range of state.selection.ranges)
-           if (!range.empty) {
-               content.push(state.sliceDoc(range.from, range.to));
-               ranges.push(range);
-           }
-       if (!content.length) {
-           // Nothing selected, do a line-wise copy
-           let upto = -1;
-           for (let { from } of state.selection.ranges) {
-               let line = state.doc.lineAt(from);
-               if (line.number > upto) {
-                   content.push(line.text);
-                   ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });
-               }
-               upto = line.number;
-           }
-           linewise = true;
-       }
-       return { text: textFilter(state, clipboardOutputFilter, content.join(state.lineBreak)), ranges, linewise };
-   }
-   let lastLinewiseCopy = null;
-   handlers.copy = handlers.cut = (view, event) => {
-       let { text, ranges, linewise } = copiedRange(view.state);
-       if (!text && !linewise)
-           return false;
-       lastLinewiseCopy = linewise ? text : null;
-       if (event.type == "cut" && !view.state.readOnly)
-           view.dispatch({
-               changes: ranges,
-               scrollIntoView: true,
-               userEvent: "delete.cut"
-           });
-       let data = brokenClipboardAPI ? null : event.clipboardData;
-       if (data) {
-           data.clearData();
-           data.setData("text/plain", text);
-           return true;
-       }
-       else {
-           captureCopy(view, text);
-           return false;
-       }
-   };
-   const isFocusChange = /*@__PURE__*/Annotation.define();
-   function focusChangeTransaction(state, focus) {
-       let effects = [];
-       for (let getEffect of state.facet(focusChangeEffect)) {
-           let effect = getEffect(state, focus);
-           if (effect)
-               effects.push(effect);
-       }
-       return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
-   }
-   function updateForFocusChange(view) {
-       setTimeout(() => {
-           let focus = view.hasFocus;
-           if (focus != view.inputState.notifiedFocused) {
-               let tr = focusChangeTransaction(view.state, focus);
-               if (tr)
-                   view.dispatch(tr);
-               else
-                   view.update([]);
-           }
-       }, 10);
-   }
-   observers.focus = view => {
-       view.inputState.lastFocusTime = Date.now();
-       // When focusing reset the scroll position, move it back to where it was
-       if (!view.scrollDOM.scrollTop && (view.inputState.lastScrollTop || view.inputState.lastScrollLeft)) {
-           view.scrollDOM.scrollTop = view.inputState.lastScrollTop;
-           view.scrollDOM.scrollLeft = view.inputState.lastScrollLeft;
-       }
-       updateForFocusChange(view);
-   };
-   observers.blur = view => {
-       view.observer.clearSelectionRange();
-       updateForFocusChange(view);
-   };
-   observers.compositionstart = observers.compositionupdate = view => {
-       if (view.observer.editContext)
-           return; // Composition handled by edit context
-       if (view.inputState.compositionFirstChange == null)
-           view.inputState.compositionFirstChange = true;
-       if (view.inputState.composing < 0) {
-           // FIXME possibly set a timeout to clear it again on Android
-           view.inputState.composing = 0;
-       }
-   };
-   observers.compositionend = view => {
-       if (view.observer.editContext)
-           return; // Composition handled by edit context
-       view.inputState.composing = -1;
-       view.inputState.compositionEndedAt = Date.now();
-       view.inputState.compositionPendingKey = true;
-       view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;
-       view.inputState.compositionFirstChange = null;
-       if (browser.chrome && browser.android) {
-           // Delay flushing for a bit on Android because it'll often fire a
-           // bunch of contradictory changes in a row at end of compositon
-           view.observer.flushSoon();
-       }
-       else if (view.inputState.compositionPendingChange) {
-           // If we found pending records, schedule a flush.
-           Promise.resolve().then(() => view.observer.flush());
-       }
-       else {
-           // Otherwise, make sure that, if no changes come in soon, the
-           // composition view is cleared.
-           setTimeout(() => {
-               if (view.inputState.composing < 0 && view.docView.hasComposition)
-                   view.update([]);
-           }, 50);
-       }
-   };
-   observers.contextmenu = view => {
-       view.inputState.lastContextMenu = Date.now();
-   };
-   handlers.beforeinput = (view, event) => {
-       var _a, _b;
-       // In EditContext mode, we must handle insertReplacementText events
-       // directly, to make spell checking corrections work
-       if (event.inputType == "insertReplacementText" && view.observer.editContext) {
-           let text = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData("text/plain"), ranges = event.getTargetRanges();
-           if (text && ranges.length) {
-               let r = ranges[0];
-               let from = view.posAtDOM(r.startContainer, r.startOffset), to = view.posAtDOM(r.endContainer, r.endOffset);
-               applyDOMChangeInner(view, { from, to, insert: view.state.toText(text) }, null);
-               return true;
-           }
-       }
-       // Because Chrome Android doesn't fire useful key events, use
-       // beforeinput to detect backspace (and possibly enter and delete,
-       // but those usually don't even seem to fire beforeinput events at
-       // the moment) and fake a key event for it.
-       //
-       // (preventDefault on beforeinput, though supported in the spec,
-       // seems to do nothing at all on Chrome).
-       let pending;
-       if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {
-           view.observer.delayAndroidKey(pending.key, pending.keyCode);
-           if (pending.key == "Backspace" || pending.key == "Delete") {
-               let startViewHeight = ((_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.height) || 0;
-               setTimeout(() => {
-                   var _a;
-                   // Backspacing near uneditable nodes on Chrome Android sometimes
-                   // closes the virtual keyboard. This tries to crudely detect
-                   // that and refocus to get it back.
-                   if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
-                       view.contentDOM.blur();
-                       view.focus();
-                   }
-               }, 100);
-           }
-       }
-       if (browser.ios && event.inputType == "deleteContentForward") {
-           // For some reason, DOM changes (and beforeinput) happen _before_
-           // the key event for ctrl-d on iOS when using an external
-           // keyboard.
-           view.observer.flushSoon();
-       }
-       // Safari will occasionally forget to fire compositionend at the end of a dead-key composition
-       if (browser.safari && event.inputType == "insertText" && view.inputState.composing >= 0) {
-           setTimeout(() => observers.compositionend(view, event), 20);
-       }
-       return false;
-   };
-   const appliedFirefoxHack = /*@__PURE__*/new Set;
-   // In Firefox, when cut/copy handlers are added to the document, that
-   // somehow avoids a bug where those events aren't fired when the
-   // selection is empty. See https://github.com/codemirror/dev/issues/1082
-   // and https://bugzilla.mozilla.org/show_bug.cgi?id=995961
-   function firefoxCopyCutHack(doc) {
-       if (!appliedFirefoxHack.has(doc)) {
-           appliedFirefoxHack.add(doc);
-           doc.addEventListener("copy", () => { });
-           doc.addEventListener("cut", () => { });
-       }
-   }
-
-   const wrappingWhiteSpace = ["pre-wrap", "normal", "pre-line", "break-spaces"];
-   // Used to track, during updateHeight, if any actual heights changed
-   let heightChangeFlag = false;
-   function clearHeightChangeFlag() { heightChangeFlag = false; }
-   class HeightOracle {
-       constructor(lineWrapping) {
-           this.lineWrapping = lineWrapping;
-           this.doc = Text.empty;
-           this.heightSamples = {};
-           this.lineHeight = 14; // The height of an entire line (line-height)
-           this.charWidth = 7;
-           this.textHeight = 14; // The height of the actual font (font-size)
-           this.lineLength = 30;
-       }
-       heightForGap(from, to) {
-           let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;
-           if (this.lineWrapping)
-               lines += Math.max(0, Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength));
-           return this.lineHeight * lines;
-       }
-       heightForLine(length) {
-           if (!this.lineWrapping)
-               return this.lineHeight;
-           let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));
-           return lines * this.lineHeight;
-       }
-       setDoc(doc) { this.doc = doc; return this; }
-       mustRefreshForWrapping(whiteSpace) {
-           return (wrappingWhiteSpace.indexOf(whiteSpace) > -1) != this.lineWrapping;
-       }
-       mustRefreshForHeights(lineHeights) {
-           let newHeight = false;
-           for (let i = 0; i < lineHeights.length; i++) {
-               let h = lineHeights[i];
-               if (h < 0) {
-                   i++;
-               }
-               else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels
-                   newHeight = true;
-                   this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return newHeight;
-       }
-       refresh(whiteSpace, lineHeight, charWidth, textHeight, lineLength, knownHeights) {
-           let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;
-           let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;
-           this.lineWrapping = lineWrapping;
-           this.lineHeight = lineHeight;
-           this.charWidth = charWidth;
-           this.textHeight = textHeight;
-           this.lineLength = lineLength;
-           if (changed) {
-               this.heightSamples = {};
-               for (let i = 0; i < knownHeights.length; i++) {
-                   let h = knownHeights[i];
-                   if (h < 0)
-                       i++;
-                   else
-                       this.heightSamples[Math.floor(h * 10)] = true;
-               }
-           }
-           return changed;
-       }
-   }
-   // This object is used by `updateHeight` to make DOM measurements
-   // arrive at the right nides. The `heights` array is a sequence of
-   // block heights, starting from position `from`.
-   class MeasuredHeights {
-       constructor(from, heights) {
-           this.from = from;
-           this.heights = heights;
-           this.index = 0;
-       }
-       get more() { return this.index < this.heights.length; }
-   }
-   /**
-   Record used to represent information about a block-level element
-   in the editor view.
-   */
-   class BlockInfo {
-       /**
-       @internal
-       */
-       constructor(
-       /**
-       The start of the element in the document.
-       */
-       from, 
-       /**
-       The length of the element.
-       */
-       length, 
-       /**
-       The top position of the element (relative to the top of the
-       document).
-       */
-       top, 
-       /**
-       Its height.
-       */
-       height, 
-       /**
-       @internal Weird packed field that holds an array of children
-       for composite blocks, a decoration for block widgets, and a
-       number indicating the amount of widget-create line breaks for
-       text blocks.
-       */
-       _content) {
-           this.from = from;
-           this.length = length;
-           this.top = top;
-           this.height = height;
-           this._content = _content;
-       }
-       /**
-       The type of element this is. When querying lines, this may be
-       an array of all the blocks that make up the line.
-       */
-       get type() {
-           return typeof this._content == "number" ? BlockType.Text :
-               Array.isArray(this._content) ? this._content : this._content.type;
-       }
-       /**
-       The end of the element as a document position.
-       */
-       get to() { return this.from + this.length; }
-       /**
-       The bottom position of the element.
-       */
-       get bottom() { return this.top + this.height; }
-       /**
-       If this is a widget block, this will return the widget
-       associated with it.
-       */
-       get widget() {
-           return this._content instanceof PointDecoration ? this._content.widget : null;
-       }
-       /**
-       If this is a textblock, this holds the number of line breaks
-       that appear in widgets inside the block.
-       */
-       get widgetLineBreaks() {
-           return typeof this._content == "number" ? this._content : 0;
-       }
-       /**
-       @internal
-       */
-       join(other) {
-           let content = (Array.isArray(this._content) ? this._content : [this])
-               .concat(Array.isArray(other._content) ? other._content : [other]);
-           return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);
-       }
-   }
-   var QueryType = /*@__PURE__*/(function (QueryType) {
-       QueryType[QueryType["ByPos"] = 0] = "ByPos";
-       QueryType[QueryType["ByHeight"] = 1] = "ByHeight";
-       QueryType[QueryType["ByPosNoHeight"] = 2] = "ByPosNoHeight";
-   return QueryType})(QueryType || (QueryType = {}));
-   const Epsilon = 1e-3;
-   class HeightMap {
-       constructor(length, // The number of characters covered
-       height, // Height of this part of the document
-       flags = 2 /* Flag.Outdated */) {
-           this.length = length;
-           this.height = height;
-           this.flags = flags;
-       }
-       get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }
-       set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }
-       setHeight(height) {
-           if (this.height != height) {
-               if (Math.abs(this.height - height) > Epsilon)
-                   heightChangeFlag = true;
-               this.height = height;
-           }
-       }
-       // Base case is to replace a leaf node, which simply builds a tree
-       // from the new nodes and returns that (HeightMapBranch and
-       // HeightMapGap override this to actually use from/to)
-       replace(_from, _to, nodes) {
-           return HeightMap.of(nodes);
-       }
-       // Again, these are base cases, and are overridden for branch and gap nodes.
-       decomposeLeft(_to, result) { result.push(this); }
-       decomposeRight(_from, result) { result.push(this); }
-       applyChanges(decorations, oldDoc, oracle, changes) {
-           let me = this, doc = oracle.doc;
-           for (let i = changes.length - 1; i >= 0; i--) {
-               let { fromA, toA, fromB, toB } = changes[i];
-               let start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle.setDoc(oldDoc), 0, 0);
-               let end = start.to >= toA ? start : me.lineAt(toA, QueryType.ByPosNoHeight, oracle, 0, 0);
-               toB += end.to - toA;
-               toA = end.to;
-               while (i > 0 && start.from <= changes[i - 1].toA) {
-                   fromA = changes[i - 1].fromA;
-                   fromB = changes[i - 1].fromB;
-                   i--;
-                   if (fromA < start.from)
-                       start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle, 0, 0);
-               }
-               fromB += start.from - fromA;
-               fromA = start.from;
-               let nodes = NodeBuilder.build(oracle.setDoc(doc), decorations, fromB, toB);
-               me = replace(me, me.replace(fromA, toA, nodes));
-           }
-           return me.updateHeight(oracle, 0);
-       }
-       static empty() { return new HeightMapText(0, 0); }
-       // nodes uses null values to indicate the position of line breaks.
-       // There are never line breaks at the start or end of the array, or
-       // two line breaks next to each other, and the array isn't allowed
-       // to be empty (same restrictions as return value from the builder).
-       static of(nodes) {
-           if (nodes.length == 1)
-               return nodes[0];
-           let i = 0, j = nodes.length, before = 0, after = 0;
-           for (;;) {
-               if (i == j) {
-                   if (before > after * 2) {
-                       let split = nodes[i - 1];
-                       if (split.break)
-                           nodes.splice(--i, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(--i, 1, split.left, split.right);
-                       j += 1 + split.break;
-                       before -= split.size;
-                   }
-                   else if (after > before * 2) {
-                       let split = nodes[j];
-                       if (split.break)
-                           nodes.splice(j, 1, split.left, null, split.right);
-                       else
-                           nodes.splice(j, 1, split.left, split.right);
-                       j += 2 + split.break;
-                       after -= split.size;
-                   }
-                   else {
-                       break;
-                   }
-               }
-               else if (before < after) {
-                   let next = nodes[i++];
-                   if (next)
-                       before += next.size;
-               }
-               else {
-                   let next = nodes[--j];
-                   if (next)
-                       after += next.size;
-               }
-           }
-           let brk = 0;
-           if (nodes[i - 1] == null) {
-               brk = 1;
-               i--;
-           }
-           else if (nodes[i] == null) {
-               brk = 1;
-               j++;
-           }
-           return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));
-       }
-   }
-   function replace(old, val) {
-       if (old == val)
-           return old;
-       if (old.constructor != val.constructor)
-           heightChangeFlag = true;
-       return val;
-   }
-   HeightMap.prototype.size = 1;
-   class HeightMapBlock extends HeightMap {
-       constructor(length, height, deco) {
-           super(length, height);
-           this.deco = deco;
-       }
-       blockAt(_height, _oracle, top, offset) {
-           return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);
-       }
-       lineAt(_value, _type, oracle, top, offset) {
-           return this.blockAt(0, oracle, top, offset);
-       }
-       forEachLine(from, to, oracle, top, offset, f) {
-           if (from <= offset + this.length && to >= offset)
-               f(this.blockAt(0, oracle, top, offset));
-       }
-       updateHeight(oracle, offset = 0, _force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(measured.heights[measured.index++]);
-           this.outdated = false;
-           return this;
-       }
-       toString() { return `block(${this.length})`; }
-   }
-   class HeightMapText extends HeightMapBlock {
-       constructor(length, height) {
-           super(length, height, null);
-           this.collapsed = 0; // Amount of collapsed content in the line
-           this.widgetHeight = 0; // Maximum inline widget height
-           this.breaks = 0; // Number of widget-introduced line breaks on the line
-       }
-       blockAt(_height, _oracle, top, offset) {
-           return new BlockInfo(offset, this.length, top, this.height, this.breaks);
-       }
-       replace(_from, _to, nodes) {
-           let node = nodes[0];
-           if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&
-               Math.abs(this.length - node.length) < 10) {
-               if (node instanceof HeightMapGap)
-                   node = new HeightMapText(node.length, this.height);
-               else
-                   node.height = this.height;
-               if (!this.outdated)
-                   node.outdated = false;
-               return node;
-           }
-           else {
-               return HeightMap.of(nodes);
-           }
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           if (measured && measured.from <= offset && measured.more)
-               this.setHeight(measured.heights[measured.index++]);
-           else if (force || this.outdated)
-               this.setHeight(Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +
-                   this.breaks * oracle.lineHeight);
-           this.outdated = false;
-           return this;
-       }
-       toString() {
-           return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
-       }
-   }
-   class HeightMapGap extends HeightMap {
-       constructor(length) { super(length, 0); }
-       heightMetrics(oracle, offset) {
-           let firstLine = oracle.doc.lineAt(offset).number, lastLine = oracle.doc.lineAt(offset + this.length).number;
-           let lines = lastLine - firstLine + 1;
-           let perLine, perChar = 0;
-           if (oracle.lineWrapping) {
-               let totalPerLine = Math.min(this.height, oracle.lineHeight * lines);
-               perLine = totalPerLine / lines;
-               if (this.length > lines + 1)
-                   perChar = (this.height - totalPerLine) / (this.length - lines - 1);
-           }
-           else {
-               perLine = this.height / lines;
-           }
-           return { firstLine, lastLine, perLine, perChar };
-       }
-       blockAt(height, oracle, top, offset) {
-           let { firstLine, lastLine, perLine, perChar } = this.heightMetrics(oracle, offset);
-           if (oracle.lineWrapping) {
-               let guess = offset + (height < oracle.lineHeight ? 0
-                   : Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length));
-               let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;
-               let lineTop = Math.max(top, height - lineHeight / 2);
-               return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);
-           }
-           else {
-               let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
-               let { from, length } = oracle.doc.line(firstLine + line);
-               return new BlockInfo(from, length, top + perLine * line, perLine, 0);
-           }
-       }
-       lineAt(value, type, oracle, top, offset) {
-           if (type == QueryType.ByHeight)
-               return this.blockAt(value, oracle, top, offset);
-           if (type == QueryType.ByPosNoHeight) {
-               let { from, to } = oracle.doc.lineAt(value);
-               return new BlockInfo(from, to - from, 0, 0, 0);
-           }
-           let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
-           let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;
-           let linesAbove = line.number - firstLine;
-           let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
-           return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);
-       }
-       forEachLine(from, to, oracle, top, offset, f) {
-           from = Math.max(from, offset);
-           to = Math.min(to, offset + this.length);
-           let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
-           for (let pos = from, lineTop = top; pos <= to;) {
-               let line = oracle.doc.lineAt(pos);
-               if (pos == from) {
-                   let linesAbove = line.number - firstLine;
-                   lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
-               }
-               let lineHeight = perLine + perChar * line.length;
-               f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));
-               lineTop += lineHeight;
-               pos = line.to + 1;
-           }
-       }
-       replace(from, to, nodes) {
-           let after = this.length - to;
-           if (after > 0) {
-               let last = nodes[nodes.length - 1];
-               if (last instanceof HeightMapGap)
-                   nodes[nodes.length - 1] = new HeightMapGap(last.length + after);
-               else
-                   nodes.push(null, new HeightMapGap(after - 1));
-           }
-           if (from > 0) {
-               let first = nodes[0];
-               if (first instanceof HeightMapGap)
-                   nodes[0] = new HeightMapGap(from + first.length);
-               else
-                   nodes.unshift(new HeightMapGap(from - 1), null);
-           }
-           return HeightMap.of(nodes);
-       }
-       decomposeLeft(to, result) {
-           result.push(new HeightMapGap(to - 1), null);
-       }
-       decomposeRight(from, result) {
-           result.push(null, new HeightMapGap(this.length - from - 1));
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let end = offset + this.length;
-           if (measured && measured.from <= offset + this.length && measured.more) {
-               // Fill in part of this gap with measured lines. We know there
-               // can't be widgets or collapsed ranges in those lines, because
-               // they would already have been added to the heightmap (gaps
-               // only contain plain text).
-               let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;
-               if (measured.from > offset)
-                   nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));
-               while (pos <= end && measured.more) {
-                   let len = oracle.doc.lineAt(pos).length;
-                   if (nodes.length)
-                       nodes.push(null);
-                   let height = measured.heights[measured.index++];
-                   if (singleHeight == -1)
-                       singleHeight = height;
-                   else if (Math.abs(height - singleHeight) >= Epsilon)
-                       singleHeight = -2;
-                   let line = new HeightMapText(len, height);
-                   line.outdated = false;
-                   nodes.push(line);
-                   pos += len + 1;
-               }
-               if (pos <= end)
-                   nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));
-               let result = HeightMap.of(nodes);
-               if (singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon ||
-                   Math.abs(singleHeight - this.heightMetrics(oracle, offset).perLine) >= Epsilon)
-                   heightChangeFlag = true;
-               return replace(this, result);
-           }
-           else if (force || this.outdated) {
-               this.setHeight(oracle.heightForGap(offset, offset + this.length));
-               this.outdated = false;
-           }
-           return this;
-       }
-       toString() { return `gap(${this.length})`; }
-   }
-   class HeightMapBranch extends HeightMap {
-       constructor(left, brk, right) {
-           super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));
-           this.left = left;
-           this.right = right;
-           this.size = left.size + right.size;
-       }
-       get break() { return this.flags & 1 /* Flag.Break */; }
-       blockAt(height, oracle, top, offset) {
-           let mid = top + this.left.height;
-           return height < mid ? this.left.blockAt(height, oracle, top, offset)
-               : this.right.blockAt(height, oracle, mid, offset + this.left.length + this.break);
-       }
-       lineAt(value, type, oracle, top, offset) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           let left = type == QueryType.ByHeight ? value < rightTop : value < rightOffset;
-           let base = left ? this.left.lineAt(value, type, oracle, top, offset)
-               : this.right.lineAt(value, type, oracle, rightTop, rightOffset);
-           if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))
-               return base;
-           let subQuery = type == QueryType.ByPosNoHeight ? QueryType.ByPosNoHeight : QueryType.ByPos;
-           if (left)
-               return base.join(this.right.lineAt(rightOffset, subQuery, oracle, rightTop, rightOffset));
-           else
-               return this.left.lineAt(rightOffset, subQuery, oracle, top, offset).join(base);
-       }
-       forEachLine(from, to, oracle, top, offset, f) {
-           let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;
-           if (this.break) {
-               if (from < rightOffset)
-                   this.left.forEachLine(from, to, oracle, top, offset, f);
-               if (to >= rightOffset)
-                   this.right.forEachLine(from, to, oracle, rightTop, rightOffset, f);
-           }
-           else {
-               let mid = this.lineAt(rightOffset, QueryType.ByPos, oracle, top, offset);
-               if (from < mid.from)
-                   this.left.forEachLine(from, mid.from - 1, oracle, top, offset, f);
-               if (mid.to >= from && mid.from <= to)
-                   f(mid);
-               if (to > mid.to)
-                   this.right.forEachLine(mid.to + 1, to, oracle, rightTop, rightOffset, f);
-           }
-       }
-       replace(from, to, nodes) {
-           let rightStart = this.left.length + this.break;
-           if (to < rightStart)
-               return this.balanced(this.left.replace(from, to, nodes), this.right);
-           if (from > this.left.length)
-               return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));
-           let result = [];
-           if (from > 0)
-               this.decomposeLeft(from, result);
-           let left = result.length;
-           for (let node of nodes)
-               result.push(node);
-           if (from > 0)
-               mergeGaps(result, left - 1);
-           if (to < this.length) {
-               let right = result.length;
-               this.decomposeRight(to, result);
-               mergeGaps(result, right);
-           }
-           return HeightMap.of(result);
-       }
-       decomposeLeft(to, result) {
-           let left = this.left.length;
-           if (to <= left)
-               return this.left.decomposeLeft(to, result);
-           result.push(this.left);
-           if (this.break) {
-               left++;
-               if (to >= left)
-                   result.push(null);
-           }
-           if (to > left)
-               this.right.decomposeLeft(to - left, result);
-       }
-       decomposeRight(from, result) {
-           let left = this.left.length, right = left + this.break;
-           if (from >= right)
-               return this.right.decomposeRight(from - right, result);
-           if (from < left)
-               this.left.decomposeRight(from, result);
-           if (this.break && from < right)
-               result.push(null);
-           result.push(this.right);
-       }
-       balanced(left, right) {
-           if (left.size > 2 * right.size || right.size > 2 * left.size)
-               return HeightMap.of(this.break ? [left, null, right] : [left, right]);
-           this.left = replace(this.left, left);
-           this.right = replace(this.right, right);
-           this.setHeight(left.height + right.height);
-           this.outdated = left.outdated || right.outdated;
-           this.size = left.size + right.size;
-           this.length = left.length + this.break + right.length;
-           return this;
-       }
-       updateHeight(oracle, offset = 0, force = false, measured) {
-           let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;
-           if (measured && measured.from <= offset + left.length && measured.more)
-               rebalance = left = left.updateHeight(oracle, offset, force, measured);
-           else
-               left.updateHeight(oracle, offset, force);
-           if (measured && measured.from <= rightStart + right.length && measured.more)
-               rebalance = right = right.updateHeight(oracle, rightStart, force, measured);
-           else
-               right.updateHeight(oracle, rightStart, force);
-           if (rebalance)
-               return this.balanced(left, right);
-           this.height = this.left.height + this.right.height;
-           this.outdated = false;
-           return this;
-       }
-       toString() { return this.left + (this.break ? " " : "-") + this.right; }
-   }
-   function mergeGaps(nodes, around) {
-       let before, after;
-       if (nodes[around] == null &&
-           (before = nodes[around - 1]) instanceof HeightMapGap &&
-           (after = nodes[around + 1]) instanceof HeightMapGap)
-           nodes.splice(around - 1, 3, new HeightMapGap(before.length + 1 + after.length));
-   }
-   const relevantWidgetHeight = 5;
-   class NodeBuilder {
-       constructor(pos, oracle) {
-           this.pos = pos;
-           this.oracle = oracle;
-           this.nodes = [];
-           this.lineStart = -1;
-           this.lineEnd = -1;
-           this.covering = null;
-           this.writtenTo = pos;
-       }
-       get isCovered() {
-           return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
-       }
-       span(_from, to) {
-           if (this.lineStart > -1) {
-               let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];
-               if (last instanceof HeightMapText)
-                   last.length += end - this.pos;
-               else if (end > this.pos || !this.isCovered)
-                   this.nodes.push(new HeightMapText(end - this.pos, -1));
-               this.writtenTo = end;
-               if (to > end) {
-                   this.nodes.push(null);
-                   this.writtenTo++;
-                   this.lineStart = -1;
-               }
-           }
-           this.pos = to;
-       }
-       point(from, to, deco) {
-           if (from < to || deco.heightRelevant) {
-               let height = deco.widget ? deco.widget.estimatedHeight : 0;
-               let breaks = deco.widget ? deco.widget.lineBreaks : 0;
-               if (height < 0)
-                   height = this.oracle.lineHeight;
-               let len = to - from;
-               if (deco.block) {
-                   this.addBlock(new HeightMapBlock(len, height, deco));
-               }
-               else if (len || breaks || height >= relevantWidgetHeight) {
-                   this.addLineDeco(height, breaks, len);
-               }
-           }
-           else if (to > from) {
-               this.span(from, to);
-           }
-           if (this.lineEnd > -1 && this.lineEnd < this.pos)
-               this.lineEnd = this.oracle.doc.lineAt(this.pos).to;
-       }
-       enterLine() {
-           if (this.lineStart > -1)
-               return;
-           let { from, to } = this.oracle.doc.lineAt(this.pos);
-           this.lineStart = from;
-           this.lineEnd = to;
-           if (this.writtenTo < from) {
-               if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)
-                   this.nodes.push(this.blankContent(this.writtenTo, from - 1));
-               this.nodes.push(null);
-           }
-           if (this.pos > from)
-               this.nodes.push(new HeightMapText(this.pos - from, -1));
-           this.writtenTo = this.pos;
-       }
-       blankContent(from, to) {
-           let gap = new HeightMapGap(to - from);
-           if (this.oracle.doc.lineAt(from).to == to)
-               gap.flags |= 4 /* Flag.SingleLine */;
-           return gap;
-       }
-       ensureLine() {
-           this.enterLine();
-           let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
-           if (last instanceof HeightMapText)
-               return last;
-           let line = new HeightMapText(0, -1);
-           this.nodes.push(line);
-           return line;
-       }
-       addBlock(block) {
-           this.enterLine();
-           let deco = block.deco;
-           if (deco && deco.startSide > 0 && !this.isCovered)
-               this.ensureLine();
-           this.nodes.push(block);
-           this.writtenTo = this.pos = this.pos + block.length;
-           if (deco && deco.endSide > 0)
-               this.covering = block;
-       }
-       addLineDeco(height, breaks, length) {
-           let line = this.ensureLine();
-           line.length += length;
-           line.collapsed += length;
-           line.widgetHeight = Math.max(line.widgetHeight, height);
-           line.breaks += breaks;
-           this.writtenTo = this.pos = this.pos + length;
-       }
-       finish(from) {
-           let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
-           if (this.lineStart > -1 && !(last instanceof HeightMapText) && !this.isCovered)
-               this.nodes.push(new HeightMapText(0, -1));
-           else if (this.writtenTo < this.pos || last == null)
-               this.nodes.push(this.blankContent(this.writtenTo, this.pos));
-           let pos = from;
-           for (let node of this.nodes) {
-               if (node instanceof HeightMapText)
-                   node.updateHeight(this.oracle, pos);
-               pos += node ? node.length : 1;
-           }
-           return this.nodes;
-       }
-       // Always called with a region that on both sides either stretches
-       // to a line break or the end of the document.
-       // The returned array uses null to indicate line breaks, but never
-       // starts or ends in a line break, or has multiple line breaks next
-       // to each other.
-       static build(oracle, decorations, from, to) {
-           let builder = new NodeBuilder(from, oracle);
-           RangeSet.spans(decorations, from, to, builder, 0);
-           return builder.finish(from);
-       }
-   }
-   function heightRelevantDecoChanges(a, b, diff) {
-       let comp = new DecorationComparator;
-       RangeSet.compare(a, b, diff, comp, 0);
-       return comp.changes;
-   }
-   class DecorationComparator {
-       constructor() {
-           this.changes = [];
-       }
-       compareRange() { }
-       comparePoint(from, to, a, b) {
-           if (from < to || a && a.heightRelevant || b && b.heightRelevant)
-               addRange(from, to, this.changes, 5);
-       }
-   }
-
-   function visiblePixelRange(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       let doc = dom.ownerDocument, win = doc.defaultView || window;
-       let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);
-       let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);
-       for (let parent = dom.parentNode; parent && parent != doc.body;) {
-           if (parent.nodeType == 1) {
-               let elt = parent;
-               let style = window.getComputedStyle(elt);
-               if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&
-                   style.overflow != "visible") {
-                   let parentRect = elt.getBoundingClientRect();
-                   left = Math.max(left, parentRect.left);
-                   right = Math.min(right, parentRect.right);
-                   top = Math.max(top, parentRect.top);
-                   bottom = Math.min(parent == dom.parentNode ? win.innerHeight : bottom, parentRect.bottom);
-               }
-               parent = style.position == "absolute" || style.position == "fixed" ? elt.offsetParent : elt.parentNode;
-           }
-           else if (parent.nodeType == 11) { // Shadow root
-               parent = parent.host;
-           }
-           else {
-               break;
-           }
-       }
-       return { left: left - rect.left, right: Math.max(left, right) - rect.left,
-           top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };
-   }
-   function fullPixelRange(dom, paddingTop) {
-       let rect = dom.getBoundingClientRect();
-       return { left: 0, right: rect.right - rect.left,
-           top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };
-   }
-   // Line gaps are placeholder widgets used to hide pieces of overlong
-   // lines within the viewport, as a kludge to keep the editor
-   // responsive when a ridiculously long line is loaded into it.
-   class LineGap {
-       constructor(from, to, size, displaySize) {
-           this.from = from;
-           this.to = to;
-           this.size = size;
-           this.displaySize = displaySize;
-       }
-       static same(a, b) {
-           if (a.length != b.length)
-               return false;
-           for (let i = 0; i < a.length; i++) {
-               let gA = a[i], gB = b[i];
-               if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)
-                   return false;
-           }
-           return true;
-       }
-       draw(viewState, wrapping) {
-           return Decoration.replace({
-               widget: new LineGapWidget(this.displaySize * (wrapping ? viewState.scaleY : viewState.scaleX), wrapping)
-           }).range(this.from, this.to);
-       }
-   }
-   class LineGapWidget extends WidgetType {
-       constructor(size, vertical) {
-           super();
-           this.size = size;
-           this.vertical = vertical;
-       }
-       eq(other) { return other.size == this.size && other.vertical == this.vertical; }
-       toDOM() {
-           let elt = document.createElement("div");
-           if (this.vertical) {
-               elt.style.height = this.size + "px";
-           }
-           else {
-               elt.style.width = this.size + "px";
-               elt.style.height = "2px";
-               elt.style.display = "inline-block";
-           }
-           return elt;
-       }
-       get estimatedHeight() { return this.vertical ? this.size : -1; }
-   }
-   class ViewState {
-       constructor(state) {
-           this.state = state;
-           // These are contentDOM-local coordinates
-           this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };
-           this.inView = true;
-           this.paddingTop = 0; // Padding above the document, scaled
-           this.paddingBottom = 0; // Padding below the document, scaled
-           this.contentDOMWidth = 0; // contentDOM.getBoundingClientRect().width
-           this.contentDOMHeight = 0; // contentDOM.getBoundingClientRect().height
-           this.editorHeight = 0; // scrollDOM.clientHeight, unscaled
-           this.editorWidth = 0; // scrollDOM.clientWidth, unscaled
-           this.scrollTop = 0; // Last seen scrollDOM.scrollTop, scaled
-           this.scrolledToBottom = false;
-           // The CSS-transformation scale of the editor (transformed size /
-           // concrete size)
-           this.scaleX = 1;
-           this.scaleY = 1;
-           // The vertical position (document-relative) to which to anchor the
-           // scroll position. -1 means anchor to the end of the document.
-           this.scrollAnchorPos = 0;
-           // The height at the anchor position. Set by the DOM update phase.
-           // -1 means no height available.
-           this.scrollAnchorHeight = -1;
-           // See VP.MaxDOMHeight
-           this.scaler = IdScaler;
-           this.scrollTarget = null;
-           // Briefly set to true when printing, to disable viewport limiting
-           this.printing = false;
-           // Flag set when editor content was redrawn, so that the next
-           // measure stage knows it must read DOM layout
-           this.mustMeasureContent = true;
-           this.defaultTextDirection = Direction.LTR;
-           this.visibleRanges = [];
-           // Cursor 'assoc' is only significant when the cursor is on a line
-           // wrap point, where it must stick to the character that it is
-           // associated with. Since browsers don't provide a reasonable
-           // interface to set or query this, when a selection is set that
-           // might cause this to be significant, this flag is set. The next
-           // measure phase will check whether the cursor is on a line-wrapping
-           // boundary and, if so, reset it to make sure it is positioned in
-           // the right place.
-           this.mustEnforceCursorAssoc = false;
-           let guessWrapping = state.facet(contentAttributes).some(v => typeof v != "function" && v.class == "cm-lineWrapping");
-           this.heightOracle = new HeightOracle(guessWrapping);
-           this.stateDeco = state.facet(decorations).filter(d => typeof d != "function");
-           this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
-           for (let i = 0; i < 2; i++) {
-               this.viewport = this.getViewport(0, null);
-               if (!this.updateForViewport())
-                   break;
-           }
-           this.updateViewportLines();
-           this.lineGaps = this.ensureLineGaps([]);
-           this.lineGapDeco = Decoration.set(this.lineGaps.map(gap => gap.draw(this, false)));
-           this.computeVisibleRanges();
-       }
-       updateForViewport() {
-           let viewports = [this.viewport], { main } = this.state.selection;
-           for (let i = 0; i <= 1; i++) {
-               let pos = i ? main.head : main.anchor;
-               if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
-                   let { from, to } = this.lineBlockAt(pos);
-                   viewports.push(new Viewport(from, to));
-               }
-           }
-           this.viewports = viewports.sort((a, b) => a.from - b.from);
-           return this.updateScaler();
-       }
-       updateScaler() {
-           let scaler = this.scaler;
-           this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :
-               new BigScaler(this.heightOracle, this.heightMap, this.viewports);
-           return scaler.eq(this.scaler) ? 0 : 2 /* UpdateFlag.Height */;
-       }
-       updateViewportLines() {
-           this.viewportLines = [];
-           this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, block => {
-               this.viewportLines.push(scaleBlock(block, this.scaler));
-           });
-       }
-       update(update, scrollTarget = null) {
-           this.state = update.state;
-           let prevDeco = this.stateDeco;
-           this.stateDeco = this.state.facet(decorations).filter(d => typeof d != "function");
-           let contentChanges = update.changedRanges;
-           let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));
-           let prevHeight = this.heightMap.height;
-           let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);
-           clearHeightChangeFlag();
-           this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);
-           if (this.heightMap.height != prevHeight || heightChangeFlag)
-               update.flags |= 2 /* UpdateFlag.Height */;
-           if (scrollAnchor) {
-               this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);
-               this.scrollAnchorHeight = scrollAnchor.top;
-           }
-           else {
-               this.scrollAnchorPos = -1;
-               this.scrollAnchorHeight = this.heightMap.height;
-           }
-           let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
-           if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
-               !this.viewportIsAppropriate(viewport))
-               viewport = this.getViewport(0, scrollTarget);
-           let viewportChange = viewport.from != this.viewport.from || viewport.to != this.viewport.to;
-           this.viewport = viewport;
-           update.flags |= this.updateForViewport();
-           if (viewportChange || !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */))
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))
-               this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
-           update.flags |= this.computeVisibleRanges(update.changes);
-           if (scrollTarget)
-               this.scrollTarget = scrollTarget;
-           if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&
-               update.state.selection.main.empty && update.state.selection.main.assoc &&
-               !update.state.facet(nativeSelectionHidden))
-               this.mustEnforceCursorAssoc = true;
-       }
-       measure(view) {
-           let dom = view.contentDOM, style = window.getComputedStyle(dom);
-           let oracle = this.heightOracle;
-           let whiteSpace = style.whiteSpace;
-           this.defaultTextDirection = style.direction == "rtl" ? Direction.RTL : Direction.LTR;
-           let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);
-           let domRect = dom.getBoundingClientRect();
-           let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != domRect.height;
-           this.contentDOMHeight = domRect.height;
-           this.mustMeasureContent = false;
-           let result = 0, bias = 0;
-           if (domRect.width && domRect.height) {
-               let { scaleX, scaleY } = getScale(dom, domRect);
-               if (scaleX > .005 && Math.abs(this.scaleX - scaleX) > .005 ||
-                   scaleY > .005 && Math.abs(this.scaleY - scaleY) > .005) {
-                   this.scaleX = scaleX;
-                   this.scaleY = scaleY;
-                   result |= 16 /* UpdateFlag.Geometry */;
-                   refresh = measureContent = true;
-               }
-           }
-           // Vertical padding
-           let paddingTop = (parseInt(style.paddingTop) || 0) * this.scaleY;
-           let paddingBottom = (parseInt(style.paddingBottom) || 0) * this.scaleY;
-           if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {
-               this.paddingTop = paddingTop;
-               this.paddingBottom = paddingBottom;
-               result |= 16 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;
-           }
-           if (this.editorWidth != view.scrollDOM.clientWidth) {
-               if (oracle.lineWrapping)
-                   measureContent = true;
-               this.editorWidth = view.scrollDOM.clientWidth;
-               result |= 16 /* UpdateFlag.Geometry */;
-           }
-           let scrollTop = view.scrollDOM.scrollTop * this.scaleY;
-           if (this.scrollTop != scrollTop) {
-               this.scrollAnchorHeight = -1;
-               this.scrollTop = scrollTop;
-           }
-           this.scrolledToBottom = isScrolledToBottom(view.scrollDOM);
-           // Pixel viewport
-           let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);
-           let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;
-           this.pixelViewport = pixelViewport;
-           let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
-           if (inView != this.inView) {
-               this.inView = inView;
-               if (inView)
-                   measureContent = true;
-           }
-           if (!this.inView && !this.scrollTarget)
-               return 0;
-           let contentWidth = domRect.width;
-           if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {
-               this.contentDOMWidth = domRect.width;
-               this.editorHeight = view.scrollDOM.clientHeight;
-               result |= 16 /* UpdateFlag.Geometry */;
-           }
-           if (measureContent) {
-               let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);
-               if (oracle.mustRefreshForHeights(lineHeights))
-                   refresh = true;
-               if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
-                   let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();
-                   refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);
-                   if (refresh) {
-                       view.docView.minWidth = 0;
-                       result |= 16 /* UpdateFlag.Geometry */;
-                   }
-               }
-               if (dTop > 0 && dBottom > 0)
-                   bias = Math.max(dTop, dBottom);
-               else if (dTop < 0 && dBottom < 0)
-                   bias = Math.min(dTop, dBottom);
-               clearHeightChangeFlag();
-               for (let vp of this.viewports) {
-                   let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
-                   this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
-               }
-               if (heightChangeFlag)
-                   result |= 2 /* UpdateFlag.Height */;
-           }
-           let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||
-               this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||
-                   this.scrollTarget.range.head > this.viewport.to);
-           if (viewportChange) {
-               if (result & 2 /* UpdateFlag.Height */)
-                   result |= this.updateScaler();
-               this.viewport = this.getViewport(bias, this.scrollTarget);
-               result |= this.updateForViewport();
-           }
-           if ((result & 2 /* UpdateFlag.Height */) || viewportChange)
-               this.updateViewportLines();
-           if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))
-               this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));
-           result |= this.computeVisibleRanges();
-           if (this.mustEnforceCursorAssoc) {
-               this.mustEnforceCursorAssoc = false;
-               // This is done in the read stage, because moving the selection
-               // to a line end is going to trigger a layout anyway, so it
-               // can't be a pure write. It should be rare that it does any
-               // writing.
-               view.docView.enforceCursorAssoc();
-           }
-           return result;
-       }
-       get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }
-       get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }
-       getViewport(bias, scrollTarget) {
-           // This will divide VP.Margin between the top and the
-           // bottom, depending on the bias (the change in viewport position
-           // since the last update). It'll hold a number between 0 and 1
-           let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));
-           let map = this.heightMap, oracle = this.heightOracle;
-           let { visibleTop, visibleBottom } = this;
-           let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).to);
-           // If scrollTarget is given, make sure the viewport includes that position
-           if (scrollTarget) {
-               let { head } = scrollTarget.range;
-               if (head < viewport.from || head > viewport.to) {
-                   let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);
-                   let block = map.lineAt(head, QueryType.ByPos, oracle, 0, 0), topPos;
-                   if (scrollTarget.y == "center")
-                       topPos = (block.top + block.bottom) / 2 - viewHeight / 2;
-                   else if (scrollTarget.y == "start" || scrollTarget.y == "nearest" && head < viewport.from)
-                       topPos = block.top;
-                   else
-                       topPos = block.bottom - viewHeight;
-                   viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).to);
-               }
-           }
-           return viewport;
-       }
-       mapViewport(viewport, changes) {
-           let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);
-           return new Viewport(this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0).to);
-       }
-       // Checks if a given viewport covers the visible part of the
-       // document and not too much beyond that.
-       viewportIsAppropriate({ from, to }, bias = 0) {
-           if (!this.inView)
-               return true;
-           let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);
-           let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);
-           let { visibleTop, visibleBottom } = this;
-           return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&
-               (to == this.state.doc.length ||
-                   bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&
-               (top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);
-       }
-       mapLineGaps(gaps, changes) {
-           if (!gaps.length || changes.empty)
-               return gaps;
-           let mapped = [];
-           for (let gap of gaps)
-               if (!changes.touchesRange(gap.from, gap.to))
-                   mapped.push(new LineGap(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size, gap.displaySize));
-           return mapped;
-       }
-       // Computes positions in the viewport where the start or end of a
-       // line should be hidden, trying to reuse existing line gaps when
-       // appropriate to avoid unneccesary redraws.
-       // Uses crude character-counting for the positioning and sizing,
-       // since actual DOM coordinates aren't always available and
-       // predictable. Relies on generous margins (see LG.Margin) to hide
-       // the artifacts this might produce from the user.
-       ensureLineGaps(current, mayMeasure) {
-           let wrapping = this.heightOracle.lineWrapping;
-           let margin = wrapping ? 10000 /* LG.MarginWrap */ : 2000 /* LG.Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;
-           // The non-wrapping logic won't work at all in predominantly right-to-left text.
-           if (this.defaultTextDirection != Direction.LTR && !wrapping)
-               return [];
-           let gaps = [];
-           let addGap = (from, to, line, structure) => {
-               if (to - from < halfMargin)
-                   return;
-               let sel = this.state.selection.main, avoid = [sel.from];
-               if (!sel.empty)
-                   avoid.push(sel.to);
-               for (let pos of avoid) {
-                   if (pos > from && pos < to) {
-                       addGap(from, pos - 10 /* LG.SelectionMargin */, line, structure);
-                       addGap(pos + 10 /* LG.SelectionMargin */, to, line, structure);
-                       return;
-                   }
-               }
-               let gap = find(current, gap => gap.from >= line.from && gap.to <= line.to &&
-                   Math.abs(gap.from - from) < halfMargin && Math.abs(gap.to - to) < halfMargin &&
-                   !avoid.some(pos => gap.from < pos && gap.to > pos));
-               if (!gap) {
-                   // When scrolling down, snap gap ends to line starts to avoid shifts in wrapping
-                   if (to < line.to && mayMeasure && wrapping &&
-                       mayMeasure.visibleRanges.some(r => r.from <= to && r.to >= to)) {
-                       let lineStart = mayMeasure.moveToLineBoundary(EditorSelection.cursor(to), false, true).head;
-                       if (lineStart > from)
-                           to = lineStart;
-                   }
-                   let size = this.gapSize(line, from, to, structure);
-                   let displaySize = wrapping || size < 2000000 /* VP.MaxHorizGap */ ? size : 2000000 /* VP.MaxHorizGap */;
-                   gap = new LineGap(from, to, size, displaySize);
-               }
-               gaps.push(gap);
-           };
-           let checkLine = (line) => {
-               if (line.length < doubleMargin || line.type != BlockType.Text)
-                   return;
-               let structure = lineStructure(line.from, line.to, this.stateDeco);
-               if (structure.total < doubleMargin)
-                   return;
-               let target = this.scrollTarget ? this.scrollTarget.range.head : null;
-               let viewFrom, viewTo;
-               if (wrapping) {
-                   let marginHeight = (margin / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
-                   let top, bot;
-                   if (target != null) {
-                       let targetFrac = findFraction(structure, target);
-                       let spaceFrac = ((this.visibleBottom - this.visibleTop) / 2 + marginHeight) / line.height;
-                       top = targetFrac - spaceFrac;
-                       bot = targetFrac + spaceFrac;
-                   }
-                   else {
-                       top = (this.visibleTop - line.top - marginHeight) / line.height;
-                       bot = (this.visibleBottom - line.top + marginHeight) / line.height;
-                   }
-                   viewFrom = findPosition(structure, top);
-                   viewTo = findPosition(structure, bot);
-               }
-               else {
-                   let totalWidth = structure.total * this.heightOracle.charWidth;
-                   let marginWidth = margin * this.heightOracle.charWidth;
-                   let horizOffset = 0;
-                   if (totalWidth > 2000000 /* VP.MaxHorizGap */)
-                       for (let old of current) {
-                           if (old.from >= line.from && old.from < line.to && old.size != old.displaySize &&
-                               old.from * this.heightOracle.charWidth + horizOffset < this.pixelViewport.left)
-                               horizOffset = old.size - old.displaySize;
-                       }
-                   let pxLeft = this.pixelViewport.left + horizOffset, pxRight = this.pixelViewport.right + horizOffset;
-                   let left, right;
-                   if (target != null) {
-                       let targetFrac = findFraction(structure, target);
-                       let spaceFrac = ((pxRight - pxLeft) / 2 + marginWidth) / totalWidth;
-                       left = targetFrac - spaceFrac;
-                       right = targetFrac + spaceFrac;
-                   }
-                   else {
-                       left = (pxLeft - marginWidth) / totalWidth;
-                       right = (pxRight + marginWidth) / totalWidth;
-                   }
-                   viewFrom = findPosition(structure, left);
-                   viewTo = findPosition(structure, right);
-               }
-               if (viewFrom > line.from)
-                   addGap(line.from, viewFrom, line, structure);
-               if (viewTo < line.to)
-                   addGap(viewTo, line.to, line, structure);
-           };
-           for (let line of this.viewportLines) {
-               if (Array.isArray(line.type))
-                   line.type.forEach(checkLine);
-               else
-                   checkLine(line);
-           }
-           return gaps;
-       }
-       gapSize(line, from, to, structure) {
-           let fraction = findFraction(structure, to) - findFraction(structure, from);
-           if (this.heightOracle.lineWrapping) {
-               return line.height * fraction;
-           }
-           else {
-               return structure.total * this.heightOracle.charWidth * fraction;
-           }
-       }
-       updateLineGaps(gaps) {
-           if (!LineGap.same(gaps, this.lineGaps)) {
-               this.lineGaps = gaps;
-               this.lineGapDeco = Decoration.set(gaps.map(gap => gap.draw(this, this.heightOracle.lineWrapping)));
-           }
-       }
-       computeVisibleRanges(changes) {
-           let deco = this.stateDeco;
-           if (this.lineGaps.length)
-               deco = deco.concat(this.lineGapDeco);
-           let ranges = [];
-           RangeSet.spans(deco, this.viewport.from, this.viewport.to, {
-               span(from, to) { ranges.push({ from, to }); },
-               point() { }
-           }, 20);
-           let changed = 0;
-           if (ranges.length != this.visibleRanges.length) {
-               changed = 8 /* UpdateFlag.ViewportMoved */ | 4 /* UpdateFlag.Viewport */;
-           }
-           else {
-               for (let i = 0; i < ranges.length && !(changed & 8 /* UpdateFlag.ViewportMoved */); i++) {
-                   let old = this.visibleRanges[i], nw = ranges[i];
-                   if (old.from != nw.from || old.to != nw.to) {
-                       changed |= 4 /* UpdateFlag.Viewport */;
-                       if (!(changes && changes.mapPos(old.from, -1) == nw.from && changes.mapPos(old.to, 1) == nw.to))
-                           changed |= 8 /* UpdateFlag.ViewportMoved */;
-                   }
-               }
-           }
-           this.visibleRanges = ranges;
-           return changed;
-       }
-       lineBlockAt(pos) {
-           return (pos >= this.viewport.from && pos <= this.viewport.to &&
-               this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||
-               scaleBlock(this.heightMap.lineAt(pos, QueryType.ByPos, this.heightOracle, 0, 0), this.scaler);
-       }
-       lineBlockAtHeight(height) {
-           return (height >= this.viewportLines[0].top && height <= this.viewportLines[this.viewportLines.length - 1].bottom &&
-               this.viewportLines.find(l => l.top <= height && l.bottom >= height)) ||
-               scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.heightOracle, 0, 0), this.scaler);
-       }
-       scrollAnchorAt(scrollTop) {
-           let block = this.lineBlockAtHeight(scrollTop + 8);
-           return block.from >= this.viewport.from || this.viewportLines[0].top - scrollTop > 200 ? block : this.viewportLines[0];
-       }
-       elementAtHeight(height) {
-           return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.heightOracle, 0, 0), this.scaler);
-       }
-       get docHeight() {
-           return this.scaler.toDOM(this.heightMap.height);
-       }
-       get contentHeight() {
-           return this.docHeight + this.paddingTop + this.paddingBottom;
-       }
-   }
-   class Viewport {
-       constructor(from, to) {
-           this.from = from;
-           this.to = to;
-       }
-   }
-   function lineStructure(from, to, stateDeco) {
-       let ranges = [], pos = from, total = 0;
-       RangeSet.spans(stateDeco, from, to, {
-           span() { },
-           point(from, to) {
-               if (from > pos) {
-                   ranges.push({ from: pos, to: from });
-                   total += from - pos;
-               }
-               pos = to;
-           }
-       }, 20); // We're only interested in collapsed ranges of a significant size
-       if (pos < to) {
-           ranges.push({ from: pos, to });
-           total += to - pos;
-       }
-       return { total, ranges };
-   }
-   function findPosition({ total, ranges }, ratio) {
-       if (ratio <= 0)
-           return ranges[0].from;
-       if (ratio >= 1)
-           return ranges[ranges.length - 1].to;
-       let dist = Math.floor(total * ratio);
-       for (let i = 0;; i++) {
-           let { from, to } = ranges[i], size = to - from;
-           if (dist <= size)
-               return from + dist;
-           dist -= size;
-       }
-   }
-   function findFraction(structure, pos) {
-       let counted = 0;
-       for (let { from, to } of structure.ranges) {
-           if (pos <= to) {
-               counted += pos - from;
-               break;
-           }
-           counted += to - from;
-       }
-       return counted / structure.total;
-   }
-   function find(array, f) {
-       for (let val of array)
-           if (f(val))
-               return val;
-       return undefined;
-   }
-   // Don't scale when the document height is within the range of what
-   // the DOM can handle.
-   const IdScaler = {
-       toDOM(n) { return n; },
-       fromDOM(n) { return n; },
-       scale: 1,
-       eq(other) { return other == this; }
-   };
-   // When the height is too big (> VP.MaxDOMHeight), scale down the
-   // regions outside the viewports so that the total height is
-   // VP.MaxDOMHeight.
-   class BigScaler {
-       constructor(oracle, heightMap, viewports) {
-           let vpHeight = 0, base = 0, domBase = 0;
-           this.viewports = viewports.map(({ from, to }) => {
-               let top = heightMap.lineAt(from, QueryType.ByPos, oracle, 0, 0).top;
-               let bottom = heightMap.lineAt(to, QueryType.ByPos, oracle, 0, 0).bottom;
-               vpHeight += bottom - top;
-               return { from, to, top, bottom, domTop: 0, domBottom: 0 };
-           });
-           this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);
-           for (let obj of this.viewports) {
-               obj.domTop = domBase + (obj.top - base) * this.scale;
-               domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);
-               base = obj.bottom;
-           }
-       }
-       toDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.top)
-                   return domBase + (n - base) * this.scale;
-               if (n <= vp.bottom)
-                   return vp.domTop + (n - vp.top);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-       fromDOM(n) {
-           for (let i = 0, base = 0, domBase = 0;; i++) {
-               let vp = i < this.viewports.length ? this.viewports[i] : null;
-               if (!vp || n < vp.domTop)
-                   return base + (n - domBase) / this.scale;
-               if (n <= vp.domBottom)
-                   return vp.top + (n - vp.domTop);
-               base = vp.bottom;
-               domBase = vp.domBottom;
-           }
-       }
-       eq(other) {
-           if (!(other instanceof BigScaler))
-               return false;
-           return this.scale == other.scale && this.viewports.length == other.viewports.length &&
-               this.viewports.every((vp, i) => vp.from == other.viewports[i].from && vp.to == other.viewports[i].to);
-       }
-   }
-   function scaleBlock(block, scaler) {
-       if (scaler.scale == 1)
-           return block;
-       let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
-       return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);
-   }
-
-   const theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(" ") });
-   const darkTheme = /*@__PURE__*/Facet.define({ combine: values => values.indexOf(true) > -1 });
-   const baseThemeID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();
-   const lightDarkIDs = { "&light": "." + baseLightID, "&dark": "." + baseDarkID };
-   function buildTheme(main, spec, scopes) {
-       return new StyleModule(spec, {
-           finish(sel) {
-               return /&/.test(sel) ? sel.replace(/&\w*/, m => {
-                   if (m == "&")
-                       return main;
-                   if (!scopes || !scopes[m])
-                       throw new RangeError(`Unsupported selector: ${m}`);
-                   return scopes[m];
-               }) : main + " " + sel;
-           }
-       });
-   }
-   const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
-       "&": {
-           position: "relative !important",
-           boxSizing: "border-box",
-           "&.cm-focused": {
-               // Provide a simple default outline to make sure a focused
-               // editor is visually distinct. Can't leave the default behavior
-               // because that will apply to the content element, which is
-               // inside the scrollable container and doesn't include the
-               // gutters. We also can't use an 'auto' outline, since those
-               // are, for some reason, drawn behind the element content, which
-               // will cause things like the active line background to cover
-               // the outline (#297).
-               outline: "1px dotted #212121"
-           },
-           display: "flex !important",
-           flexDirection: "column"
-       },
-       ".cm-scroller": {
-           display: "flex !important",
-           alignItems: "flex-start !important",
-           fontFamily: "monospace",
-           lineHeight: 1.4,
-           height: "100%",
-           overflowX: "auto",
-           position: "relative",
-           zIndex: 0,
-           overflowAnchor: "none",
-       },
-       ".cm-content": {
-           margin: 0,
-           flexGrow: 2,
-           flexShrink: 0,
-           display: "block",
-           whiteSpace: "pre",
-           wordWrap: "normal", // https://github.com/codemirror/dev/issues/456
-           boxSizing: "border-box",
-           minHeight: "100%",
-           padding: "4px 0",
-           outline: "none",
-           "&[contenteditable=true]": {
-               WebkitUserModify: "read-write-plaintext-only",
-           }
-       },
-       ".cm-lineWrapping": {
-           whiteSpace_fallback: "pre-wrap", // For IE
-           whiteSpace: "break-spaces",
-           wordBreak: "break-word", // For Safari, which doesn't support overflow-wrap: anywhere
-           overflowWrap: "anywhere",
-           flexShrink: 1
-       },
-       "&light .cm-content": { caretColor: "black" },
-       "&dark .cm-content": { caretColor: "white" },
-       ".cm-line": {
-           display: "block",
-           padding: "0 2px 0 6px"
-       },
-       ".cm-layer": {
-           position: "absolute",
-           left: 0,
-           top: 0,
-           contain: "size style",
-           "& > *": {
-               position: "absolute"
-           }
-       },
-       "&light .cm-selectionBackground": {
-           background: "#d9d9d9"
-       },
-       "&dark .cm-selectionBackground": {
-           background: "#222"
-       },
-       "&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
-           background: "#d7d4f0"
-       },
-       "&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
-           background: "#233"
-       },
-       ".cm-cursorLayer": {
-           pointerEvents: "none"
-       },
-       "&.cm-focused > .cm-scroller > .cm-cursorLayer": {
-           animation: "steps(1) cm-blink 1.2s infinite"
-       },
-       // Two animations defined so that we can switch between them to
-       // restart the animation without forcing another style
-       // recomputation.
-       "@keyframes cm-blink": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
-       "@keyframes cm-blink2": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
-       ".cm-cursor, .cm-dropCursor": {
-           borderLeft: "1.2px solid black",
-           marginLeft: "-0.6px",
-           pointerEvents: "none",
-       },
-       ".cm-cursor": {
-           display: "none"
-       },
-       "&dark .cm-cursor": {
-           borderLeftColor: "#ddd"
-       },
-       ".cm-dropCursor": {
-           position: "absolute"
-       },
-       "&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
-           display: "block"
-       },
-       ".cm-iso": {
-           unicodeBidi: "isolate"
-       },
-       ".cm-announced": {
-           position: "fixed",
-           top: "-10000px"
-       },
-       "@media print": {
-           ".cm-announced": { display: "none" }
-       },
-       "&light .cm-activeLine": { backgroundColor: "#cceeff44" },
-       "&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
-       "&light .cm-specialChar": { color: "red" },
-       "&dark .cm-specialChar": { color: "#f78" },
-       ".cm-gutters": {
-           flexShrink: 0,
-           display: "flex",
-           height: "100%",
-           boxSizing: "border-box",
-           insetInlineStart: 0,
-           zIndex: 200
-       },
-       "&light .cm-gutters": {
-           backgroundColor: "#f5f5f5",
-           color: "#6c6c6c",
-           borderRight: "1px solid #ddd"
-       },
-       "&dark .cm-gutters": {
-           backgroundColor: "#333338",
-           color: "#ccc"
-       },
-       ".cm-gutter": {
-           display: "flex !important", // Necessary -- prevents margin collapsing
-           flexDirection: "column",
-           flexShrink: 0,
-           boxSizing: "border-box",
-           minHeight: "100%",
-           overflow: "hidden"
-       },
-       ".cm-gutterElement": {
-           boxSizing: "border-box"
-       },
-       ".cm-lineNumbers .cm-gutterElement": {
-           padding: "0 3px 0 5px",
-           minWidth: "20px",
-           textAlign: "right",
-           whiteSpace: "nowrap"
-       },
-       "&light .cm-activeLineGutter": {
-           backgroundColor: "#e2f2ff"
-       },
-       "&dark .cm-activeLineGutter": {
-           backgroundColor: "#222227"
-       },
-       ".cm-panels": {
-           boxSizing: "border-box",
-           position: "sticky",
-           left: 0,
-           right: 0,
-           zIndex: 300
-       },
-       "&light .cm-panels": {
-           backgroundColor: "#f5f5f5",
-           color: "black"
-       },
-       "&light .cm-panels-top": {
-           borderBottom: "1px solid #ddd"
-       },
-       "&light .cm-panels-bottom": {
-           borderTop: "1px solid #ddd"
-       },
-       "&dark .cm-panels": {
-           backgroundColor: "#333338",
-           color: "white"
-       },
-       ".cm-tab": {
-           display: "inline-block",
-           overflow: "hidden",
-           verticalAlign: "bottom"
-       },
-       ".cm-widgetBuffer": {
-           verticalAlign: "text-top",
-           height: "1em",
-           width: 0,
-           display: "inline"
-       },
-       ".cm-placeholder": {
-           color: "#888",
-           display: "inline-block",
-           verticalAlign: "top",
-       },
-       ".cm-highlightSpace": {
-           backgroundImage: "radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",
-           backgroundPosition: "center",
-       },
-       ".cm-highlightTab": {
-           backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
-           backgroundSize: "auto 100%",
-           backgroundPosition: "right 90%",
-           backgroundRepeat: "no-repeat"
-       },
-       ".cm-trailingSpace": {
-           backgroundColor: "#ff332255"
-       },
-       ".cm-button": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           padding: ".2em 1em",
-           borderRadius: "1px"
-       },
-       "&light .cm-button": {
-           backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
-           }
-       },
-       "&dark .cm-button": {
-           backgroundImage: "linear-gradient(#393939, #111)",
-           border: "1px solid #888",
-           "&:active": {
-               backgroundImage: "linear-gradient(#111, #333)"
-           }
-       },
-       ".cm-textfield": {
-           verticalAlign: "middle",
-           color: "inherit",
-           fontSize: "70%",
-           border: "1px solid silver",
-           padding: ".2em .5em"
-       },
-       "&light .cm-textfield": {
-           backgroundColor: "white"
-       },
-       "&dark .cm-textfield": {
-           border: "1px solid #555",
-           backgroundColor: "inherit"
-       }
-   }, lightDarkIDs);
-
-   const observeOptions = {
-       childList: true,
-       characterData: true,
-       subtree: true,
-       attributes: true,
-       characterDataOldValue: true
-   };
-   // IE11 has very broken mutation observers, so we also listen to
-   // DOMCharacterDataModified there
-   const useCharData = browser.ie && browser.ie_version <= 11;
-   class DOMObserver {
-       constructor(view) {
-           this.view = view;
-           this.active = false;
-           this.editContext = null;
-           // The known selection. Kept in our own object, as opposed to just
-           // directly accessing the selection because:
-           //  - Safari doesn't report the right selection in shadow DOM
-           //  - Reading from the selection forces a DOM layout
-           //  - This way, we can ignore selectionchange events if we have
-           //    already seen the 'new' selection
-           this.selectionRange = new DOMSelectionState;
-           // Set when a selection change is detected, cleared on flush
-           this.selectionChanged = false;
-           this.delayedFlush = -1;
-           this.resizeTimeout = -1;
-           this.queue = [];
-           this.delayedAndroidKey = null;
-           this.flushingAndroidKey = -1;
-           this.lastChange = 0;
-           this.scrollTargets = [];
-           this.intersection = null;
-           this.resizeScroll = null;
-           this.intersecting = false;
-           this.gapIntersection = null;
-           this.gaps = [];
-           this.printQuery = null;
-           // Timeout for scheduling check of the parents that need scroll handlers
-           this.parentCheck = -1;
-           this.dom = view.contentDOM;
-           this.observer = new MutationObserver(mutations => {
-               for (let mut of mutations)
-                   this.queue.push(mut);
-               // IE11 will sometimes (on typing over a selection or
-               // backspacing out a single character text node) call the
-               // observer callback before actually updating the DOM.
-               //
-               // Unrelatedly, iOS Safari will, when ending a composition,
-               // sometimes first clear it, deliver the mutations, and then
-               // reinsert the finished text. CodeMirror's handling of the
-               // deletion will prevent the reinsertion from happening,
-               // breaking composition.
-               if ((browser.ie && browser.ie_version <= 11 || browser.ios && view.composing) &&
-                   mutations.some(m => m.type == "childList" && m.removedNodes.length ||
-                       m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length))
-                   this.flushSoon();
-               else
-                   this.flush();
-           });
-           if (window.EditContext && view.constructor.EDIT_CONTEXT !== false &&
-               // Chrome <126 doesn't support inverted selections in edit context (#1392)
-               !(browser.chrome && browser.chrome_version < 126)) {
-               this.editContext = new EditContextManager(view);
-               if (view.state.facet(editable))
-                   view.contentDOM.editContext = this.editContext.editContext;
-           }
-           if (useCharData)
-               this.onCharData = (event) => {
-                   this.queue.push({ target: event.target,
-                       type: "characterData",
-                       oldValue: event.prevValue });
-                   this.flushSoon();
-               };
-           this.onSelectionChange = this.onSelectionChange.bind(this);
-           this.onResize = this.onResize.bind(this);
-           this.onPrint = this.onPrint.bind(this);
-           this.onScroll = this.onScroll.bind(this);
-           if (window.matchMedia)
-               this.printQuery = window.matchMedia("print");
-           if (typeof ResizeObserver == "function") {
-               this.resizeScroll = new ResizeObserver(() => {
-                   var _a;
-                   if (((_a = this.view.docView) === null || _a === void 0 ? void 0 : _a.lastUpdate) < Date.now() - 75)
-                       this.onResize();
-               });
-               this.resizeScroll.observe(view.scrollDOM);
-           }
-           this.addWindowListeners(this.win = view.win);
-           this.start();
-           if (typeof IntersectionObserver == "function") {
-               this.intersection = new IntersectionObserver(entries => {
-                   if (this.parentCheck < 0)
-                       this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);
-                   if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {
-                       this.intersecting = !this.intersecting;
-                       if (this.intersecting != this.view.inView)
-                           this.onScrollChanged(document.createEvent("Event"));
-                   }
-               }, { threshold: [0, .001] });
-               this.intersection.observe(this.dom);
-               this.gapIntersection = new IntersectionObserver(entries => {
-                   if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)
-                       this.onScrollChanged(document.createEvent("Event"));
-               }, {});
-           }
-           this.listenForScroll();
-           this.readSelectionRange();
-       }
-       onScrollChanged(e) {
-           this.view.inputState.runHandlers("scroll", e);
-           if (this.intersecting)
-               this.view.measure();
-       }
-       onScroll(e) {
-           if (this.intersecting)
-               this.flush(false);
-           if (this.editContext)
-               this.view.requestMeasure(this.editContext.measureReq);
-           this.onScrollChanged(e);
-       }
-       onResize() {
-           if (this.resizeTimeout < 0)
-               this.resizeTimeout = setTimeout(() => {
-                   this.resizeTimeout = -1;
-                   this.view.requestMeasure();
-               }, 50);
-       }
-       onPrint(event) {
-           if ((event.type == "change" || !event.type) && !event.matches)
-               return;
-           this.view.viewState.printing = true;
-           this.view.measure();
-           setTimeout(() => {
-               this.view.viewState.printing = false;
-               this.view.requestMeasure();
-           }, 500);
-       }
-       updateGaps(gaps) {
-           if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {
-               this.gapIntersection.disconnect();
-               for (let gap of gaps)
-                   this.gapIntersection.observe(gap);
-               this.gaps = gaps;
-           }
-       }
-       onSelectionChange(event) {
-           let wasChanged = this.selectionChanged;
-           if (!this.readSelectionRange() || this.delayedAndroidKey)
-               return;
-           let { view } = this, sel = this.selectionRange;
-           if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(this.dom, sel))
-               return;
-           let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);
-           if (context && context.ignoreEvent(event)) {
-               if (!wasChanged)
-                   this.selectionChanged = false;
-               return;
-           }
-           // Deletions on IE11 fire their events in the wrong order, giving
-           // us a selection change event before the DOM changes are
-           // reported.
-           // Chrome Android has a similar issue when backspacing out a
-           // selection (#645).
-           if ((browser.ie && browser.ie_version <= 11 || browser.android && browser.chrome) && !view.state.selection.main.empty &&
-               // (Selection.isCollapsed isn't reliable on IE)
-               sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))
-               this.flushSoon();
-           else
-               this.flush(false);
-       }
-       readSelectionRange() {
-           let { view } = this;
-           // The Selection object is broken in shadow roots in Safari. See
-           // https://github.com/codemirror/dev/issues/414
-           let selection = getSelection(view.root);
-           if (!selection)
-               return false;
-           let range = browser.safari && view.root.nodeType == 11 &&
-               view.root.activeElement == this.dom &&
-               safariSelectionRangeHack(this.view, selection) || selection;
-           if (!range || this.selectionRange.eq(range))
-               return false;
-           let local = hasSelection(this.dom, range);
-           // Detect the situation where the browser has, on focus, moved the
-           // selection to the start of the content element. Reset it to the
-           // position from the editor state.
-           if (local && !this.selectionChanged &&
-               view.inputState.lastFocusTime > Date.now() - 200 &&
-               view.inputState.lastTouchTime < Date.now() - 300 &&
-               atElementStart(this.dom, range)) {
-               this.view.inputState.lastFocusTime = 0;
-               view.docView.updateSelection();
-               return false;
-           }
-           this.selectionRange.setRange(range);
-           if (local)
-               this.selectionChanged = true;
-           return true;
-       }
-       setSelectionRange(anchor, head) {
-           this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);
-           this.selectionChanged = false;
-       }
-       clearSelectionRange() {
-           this.selectionRange.set(null, 0, null, 0);
-       }
-       listenForScroll() {
-           this.parentCheck = -1;
-           let i = 0, changed = null;
-           for (let dom = this.dom; dom;) {
-               if (dom.nodeType == 1) {
-                   if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)
-                       i++;
-                   else if (!changed)
-                       changed = this.scrollTargets.slice(0, i);
-                   if (changed)
-                       changed.push(dom);
-                   dom = dom.assignedSlot || dom.parentNode;
-               }
-               else if (dom.nodeType == 11) { // Shadow root
-                   dom = dom.host;
-               }
-               else {
-                   break;
-               }
-           }
-           if (i < this.scrollTargets.length && !changed)
-               changed = this.scrollTargets.slice(0, i);
-           if (changed) {
-               for (let dom of this.scrollTargets)
-                   dom.removeEventListener("scroll", this.onScroll);
-               for (let dom of this.scrollTargets = changed)
-                   dom.addEventListener("scroll", this.onScroll);
-           }
-       }
-       ignore(f) {
-           if (!this.active)
-               return f();
-           try {
-               this.stop();
-               return f();
-           }
-           finally {
-               this.start();
-               this.clear();
-           }
-       }
-       start() {
-           if (this.active)
-               return;
-           this.observer.observe(this.dom, observeOptions);
-           if (useCharData)
-               this.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
-           this.active = true;
-       }
-       stop() {
-           if (!this.active)
-               return;
-           this.active = false;
-           this.observer.disconnect();
-           if (useCharData)
-               this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
-       }
-       // Throw away any pending changes
-       clear() {
-           this.processRecords();
-           this.queue.length = 0;
-           this.selectionChanged = false;
-       }
-       // Chrome Android, especially in combination with GBoard, not only
-       // doesn't reliably fire regular key events, but also often
-       // surrounds the effect of enter or backspace with a bunch of
-       // composition events that, when interrupted, cause text duplication
-       // or other kinds of corruption. This hack makes the editor back off
-       // from handling DOM changes for a moment when such a key is
-       // detected (via beforeinput or keydown), and then tries to flush
-       // them or, if that has no effect, dispatches the given key.
-       delayAndroidKey(key, keyCode) {
-           var _a;
-           if (!this.delayedAndroidKey) {
-               let flush = () => {
-                   let key = this.delayedAndroidKey;
-                   if (key) {
-                       this.clearDelayedAndroidKey();
-                       this.view.inputState.lastKeyCode = key.keyCode;
-                       this.view.inputState.lastKeyTime = Date.now();
-                       let flushed = this.flush();
-                       if (!flushed && key.force)
-                           dispatchKey(this.dom, key.key, key.keyCode);
-                   }
-               };
-               this.flushingAndroidKey = this.view.win.requestAnimationFrame(flush);
-           }
-           // Since backspace beforeinput is sometimes signalled spuriously,
-           // Enter always takes precedence.
-           if (!this.delayedAndroidKey || key == "Enter")
-               this.delayedAndroidKey = {
-                   key, keyCode,
-                   // Only run the key handler when no changes are detected if
-                   // this isn't coming right after another change, in which case
-                   // it is probably part of a weird chain of updates, and should
-                   // be ignored if it returns the DOM to its previous state.
-                   force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)
-               };
-       }
-       clearDelayedAndroidKey() {
-           this.win.cancelAnimationFrame(this.flushingAndroidKey);
-           this.delayedAndroidKey = null;
-           this.flushingAndroidKey = -1;
-       }
-       flushSoon() {
-           if (this.delayedFlush < 0)
-               this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });
-       }
-       forceFlush() {
-           if (this.delayedFlush >= 0) {
-               this.view.win.cancelAnimationFrame(this.delayedFlush);
-               this.delayedFlush = -1;
-           }
-           this.flush();
-       }
-       pendingRecords() {
-           for (let mut of this.observer.takeRecords())
-               this.queue.push(mut);
-           return this.queue;
-       }
-       processRecords() {
-           let records = this.pendingRecords();
-           if (records.length)
-               this.queue = [];
-           let from = -1, to = -1, typeOver = false;
-           for (let record of records) {
-               let range = this.readMutation(record);
-               if (!range)
-                   continue;
-               if (range.typeOver)
-                   typeOver = true;
-               if (from == -1) {
-                   ({ from, to } = range);
-               }
-               else {
-                   from = Math.min(range.from, from);
-                   to = Math.max(range.to, to);
-               }
-           }
-           return { from, to, typeOver };
-       }
-       readChange() {
-           let { from, to, typeOver } = this.processRecords();
-           let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);
-           if (from < 0 && !newSel)
-               return null;
-           if (from > -1)
-               this.lastChange = Date.now();
-           this.view.inputState.lastFocusTime = 0;
-           this.selectionChanged = false;
-           let change = new DOMChange(this.view, from, to, typeOver);
-           this.view.docView.domChanged = { newSel: change.newSel ? change.newSel.main : null };
-           return change;
-       }
-       // Apply pending changes, if any
-       flush(readSelection = true) {
-           // Completely hold off flushing when pending keys are set—the code
-           // managing those will make sure processRecords is called and the
-           // view is resynchronized after
-           if (this.delayedFlush >= 0 || this.delayedAndroidKey)
-               return false;
-           if (readSelection)
-               this.readSelectionRange();
-           let domChange = this.readChange();
-           if (!domChange) {
-               this.view.requestMeasure();
-               return false;
-           }
-           let startState = this.view.state;
-           let handled = applyDOMChange(this.view, domChange);
-           // The view wasn't updated but DOM/selection changes were seen. Reset the view.
-           if (this.view.state == startState &&
-               (domChange.domChanged || domChange.newSel && !domChange.newSel.main.eq(this.view.state.selection.main)))
-               this.view.update([]);
-           return handled;
-       }
-       readMutation(rec) {
-           let cView = this.view.docView.nearest(rec.target);
-           if (!cView || cView.ignoreMutation(rec))
-               return null;
-           cView.markDirty(rec.type == "attributes");
-           if (rec.type == "attributes")
-               cView.flags |= 4 /* ViewFlag.AttrsDirty */;
-           if (rec.type == "childList") {
-               let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
-               let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
-               return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,
-                   to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };
-           }
-           else if (rec.type == "characterData") {
-               return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };
-           }
-           else {
-               return null;
-           }
-       }
-       setWindow(win) {
-           if (win != this.win) {
-               this.removeWindowListeners(this.win);
-               this.win = win;
-               this.addWindowListeners(this.win);
-           }
-       }
-       addWindowListeners(win) {
-           win.addEventListener("resize", this.onResize);
-           if (this.printQuery) {
-               if (this.printQuery.addEventListener)
-                   this.printQuery.addEventListener("change", this.onPrint);
-               else
-                   this.printQuery.addListener(this.onPrint);
-           }
-           else
-               win.addEventListener("beforeprint", this.onPrint);
-           win.addEventListener("scroll", this.onScroll);
-           win.document.addEventListener("selectionchange", this.onSelectionChange);
-       }
-       removeWindowListeners(win) {
-           win.removeEventListener("scroll", this.onScroll);
-           win.removeEventListener("resize", this.onResize);
-           if (this.printQuery) {
-               if (this.printQuery.removeEventListener)
-                   this.printQuery.removeEventListener("change", this.onPrint);
-               else
-                   this.printQuery.removeListener(this.onPrint);
-           }
-           else
-               win.removeEventListener("beforeprint", this.onPrint);
-           win.document.removeEventListener("selectionchange", this.onSelectionChange);
-       }
-       update(update) {
-           if (this.editContext) {
-               this.editContext.update(update);
-               if (update.startState.facet(editable) != update.state.facet(editable))
-                   update.view.contentDOM.editContext = update.state.facet(editable) ? this.editContext.editContext : null;
-           }
-       }
-       destroy() {
-           var _a, _b, _c;
-           this.stop();
-           (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
-           (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
-           (_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();
-           for (let dom of this.scrollTargets)
-               dom.removeEventListener("scroll", this.onScroll);
-           this.removeWindowListeners(this.win);
-           clearTimeout(this.parentCheck);
-           clearTimeout(this.resizeTimeout);
-           this.win.cancelAnimationFrame(this.delayedFlush);
-           this.win.cancelAnimationFrame(this.flushingAndroidKey);
-           if (this.editContext) {
-               this.view.contentDOM.editContext = null;
-               this.editContext.destroy();
-           }
-       }
-   }
-   function findChild(cView, dom, dir) {
-       while (dom) {
-           let curView = ContentView.get(dom);
-           if (curView && curView.parent == cView)
-               return curView;
-           let parent = dom.parentNode;
-           dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;
-       }
-       return null;
-   }
-   function buildSelectionRangeFromRange(view, range) {
-       let anchorNode = range.startContainer, anchorOffset = range.startOffset;
-       let focusNode = range.endContainer, focusOffset = range.endOffset;
-       let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);
-       // Since such a range doesn't distinguish between anchor and head,
-       // use a heuristic that flips it around if its end matches the
-       // current anchor.
-       if (isEquivalentPosition(curAnchor.node, curAnchor.offset, focusNode, focusOffset))
-           [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
-       return { anchorNode, anchorOffset, focusNode, focusOffset };
-   }
-   // Used to work around a Safari Selection/shadow DOM bug (#414)
-   function safariSelectionRangeHack(view, selection) {
-       if (selection.getComposedRanges) {
-           let range = selection.getComposedRanges(view.root)[0];
-           if (range)
-               return buildSelectionRangeFromRange(view, range);
-       }
-       let found = null;
-       // Because Safari (at least in 2018-2021) doesn't provide regular
-       // access to the selection inside a shadowroot, we have to perform a
-       // ridiculous hack to get at it—using `execCommand` to trigger a
-       // `beforeInput` event so that we can read the target range from the
-       // event.
-       function read(event) {
-           event.preventDefault();
-           event.stopImmediatePropagation();
-           found = event.getTargetRanges()[0];
-       }
-       view.contentDOM.addEventListener("beforeinput", read, true);
-       view.dom.ownerDocument.execCommand("indent");
-       view.contentDOM.removeEventListener("beforeinput", read, true);
-       return found ? buildSelectionRangeFromRange(view, found) : null;
-   }
-   class EditContextManager {
-       constructor(view) {
-           // The document window for which the text in the context is
-           // maintained. For large documents, this may be smaller than the
-           // editor document. This window always includes the selection head.
-           this.from = 0;
-           this.to = 0;
-           // When applying a transaction, this is used to compare the change
-           // made to the context content to the change in the transaction in
-           // order to make the minimal changes to the context (since touching
-           // that sometimes breaks series of multiple edits made for a single
-           // user action on some Android keyboards)
-           this.pendingContextChange = null;
-           this.handlers = Object.create(null);
-           // Kludge to work around the fact that EditContext does not respond
-           // well to having its content updated during a composition (see #1472)
-           this.composing = null;
-           this.resetRange(view.state);
-           let context = this.editContext = new window.EditContext({
-               text: view.state.doc.sliceString(this.from, this.to),
-               selectionStart: this.toContextPos(Math.max(this.from, Math.min(this.to, view.state.selection.main.anchor))),
-               selectionEnd: this.toContextPos(view.state.selection.main.head)
-           });
-           this.handlers.textupdate = e => {
-               let { anchor } = view.state.selection.main;
-               let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
-               if (view.inputState.composing >= 0 && !this.composing)
-                   this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
-               let change = { from, to, insert: Text.of(e.text.split("\n")) };
-               // If the window doesn't include the anchor, assume changes
-               // adjacent to a side go up to the anchor.
-               if (change.from == this.from && anchor < this.from)
-                   change.from = anchor;
-               else if (change.to == this.to && anchor > this.to)
-                   change.to = anchor;
-               // Edit contexts sometimes fire empty changes
-               if (change.from == change.to && !change.insert.length)
-                   return;
-               this.pendingContextChange = change;
-               if (!view.state.readOnly) {
-                   let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
-                   applyDOMChangeInner(view, change, EditorSelection.single(this.toEditorPos(e.selectionStart, newLen), this.toEditorPos(e.selectionEnd, newLen)));
-               }
-               // If the transaction didn't flush our change, revert it so
-               // that the context is in sync with the editor state again.
-               if (this.pendingContextChange) {
-                   this.revertPending(view.state);
-                   this.setSelection(view.state);
-               }
-           };
-           this.handlers.characterboundsupdate = e => {
-               let rects = [], prev = null;
-               for (let i = this.toEditorPos(e.rangeStart), end = this.toEditorPos(e.rangeEnd); i < end; i++) {
-                   let rect = view.coordsForChar(i);
-                   prev = (rect && new DOMRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top))
-                       || prev || new DOMRect;
-                   rects.push(prev);
-               }
-               context.updateCharacterBounds(e.rangeStart, rects);
-           };
-           this.handlers.textformatupdate = e => {
-               let deco = [];
-               for (let format of e.getTextFormats()) {
-                   let lineStyle = format.underlineStyle, thickness = format.underlineThickness;
-                   if (lineStyle != "None" && thickness != "None") {
-                       let from = this.toEditorPos(format.rangeStart), to = this.toEditorPos(format.rangeEnd);
-                       if (from < to) {
-                           let style = `text-decoration: underline ${lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${thickness == "Thin" ? 1 : 2}px`;
-                           deco.push(Decoration.mark({ attributes: { style } }).range(from, to));
-                       }
-                   }
-               }
-               view.dispatch({ effects: setEditContextFormatting.of(Decoration.set(deco)) });
-           };
-           this.handlers.compositionstart = () => {
-               if (view.inputState.composing < 0) {
-                   view.inputState.composing = 0;
-                   view.inputState.compositionFirstChange = true;
-               }
-           };
-           this.handlers.compositionend = () => {
-               view.inputState.composing = -1;
-               view.inputState.compositionFirstChange = null;
-               if (this.composing) {
-                   let { drifted } = this.composing;
-                   this.composing = null;
-                   if (drifted)
-                       this.reset(view.state);
-               }
-           };
-           for (let event in this.handlers)
-               context.addEventListener(event, this.handlers[event]);
-           this.measureReq = { read: view => {
-                   this.editContext.updateControlBounds(view.contentDOM.getBoundingClientRect());
-                   let sel = getSelection(view.root);
-                   if (sel && sel.rangeCount)
-                       this.editContext.updateSelectionBounds(sel.getRangeAt(0).getBoundingClientRect());
-               } };
-       }
-       applyEdits(update) {
-           let off = 0, abort = false, pending = this.pendingContextChange;
-           update.changes.iterChanges((fromA, toA, _fromB, _toB, insert) => {
-               if (abort)
-                   return;
-               let dLen = insert.length - (toA - fromA);
-               if (pending && toA >= pending.to) {
-                   if (pending.from == fromA && pending.to == toA && pending.insert.eq(insert)) {
-                       pending = this.pendingContextChange = null; // Match
-                       off += dLen;
-                       this.to += dLen;
-                       return;
-                   }
-                   else { // Mismatch, revert
-                       pending = null;
-                       this.revertPending(update.state);
-                   }
-               }
-               fromA += off;
-               toA += off;
-               if (toA <= this.from) { // Before the window
-                   this.from += dLen;
-                   this.to += dLen;
-               }
-               else if (fromA < this.to) { // Overlaps with window
-                   if (fromA < this.from || toA > this.to || (this.to - this.from) + insert.length > 30000 /* CxVp.MaxSize */) {
-                       abort = true;
-                       return;
-                   }
-                   this.editContext.updateText(this.toContextPos(fromA), this.toContextPos(toA), insert.toString());
-                   this.to += dLen;
-               }
-               off += dLen;
-           });
-           if (pending && !abort)
-               this.revertPending(update.state);
-           return !abort;
-       }
-       update(update) {
-           let reverted = this.pendingContextChange;
-           if (this.composing && (this.composing.drifted || update.transactions.some(tr => !tr.isUserEvent("input.type") && tr.changes.touchesRange(this.from, this.to)))) {
-               this.composing.drifted = true;
-               this.composing.editorBase = update.changes.mapPos(this.composing.editorBase);
-           }
-           else if (!this.applyEdits(update) || !this.rangeIsValid(update.state)) {
-               this.pendingContextChange = null;
-               this.reset(update.state);
-           }
-           else if (update.docChanged || update.selectionSet || reverted) {
-               this.setSelection(update.state);
-           }
-           if (update.geometryChanged || update.docChanged || update.selectionSet)
-               update.view.requestMeasure(this.measureReq);
-       }
-       resetRange(state) {
-           let { head } = state.selection.main;
-           this.from = Math.max(0, head - 10000 /* CxVp.Margin */);
-           this.to = Math.min(state.doc.length, head + 10000 /* CxVp.Margin */);
-       }
-       reset(state) {
-           this.resetRange(state);
-           this.editContext.updateText(0, this.editContext.text.length, state.doc.sliceString(this.from, this.to));
-           this.setSelection(state);
-       }
-       revertPending(state) {
-           let pending = this.pendingContextChange;
-           this.pendingContextChange = null;
-           this.editContext.updateText(this.toContextPos(pending.from), this.toContextPos(pending.from + pending.insert.length), state.doc.sliceString(pending.from, pending.to));
-       }
-       setSelection(state) {
-           let { main } = state.selection;
-           let start = this.toContextPos(Math.max(this.from, Math.min(this.to, main.anchor)));
-           let end = this.toContextPos(main.head);
-           if (this.editContext.selectionStart != start || this.editContext.selectionEnd != end)
-               this.editContext.updateSelection(start, end);
-       }
-       rangeIsValid(state) {
-           let { head } = state.selection.main;
-           return !(this.from > 0 && head - this.from < 500 /* CxVp.MinMargin */ ||
-               this.to < state.doc.length && this.to - head < 500 /* CxVp.MinMargin */ ||
-               this.to - this.from > 10000 /* CxVp.Margin */ * 3);
-       }
-       toEditorPos(contextPos, clipLen = this.to - this.from) {
-           contextPos = Math.min(contextPos, clipLen);
-           let c = this.composing;
-           return c && c.drifted ? c.editorBase + (contextPos - c.contextBase) : contextPos + this.from;
-       }
-       toContextPos(editorPos) {
-           let c = this.composing;
-           return c && c.drifted ? c.contextBase + (editorPos - c.editorBase) : editorPos - this.from;
-       }
-       destroy() {
-           for (let event in this.handlers)
-               this.editContext.removeEventListener(event, this.handlers[event]);
-       }
-   }
-
-   // The editor's update state machine looks something like this:
-   //
-   //     Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle
-   //                                         ↑      ↓
-   //                                         Updating (measure)
-   //
-   // The difference between 'Idle' and 'Idle (unchecked)' lies in
-   // whether a layout check has been scheduled. A regular update through
-   // the `update` method updates the DOM in a write-only fashion, and
-   // relies on a check (scheduled with `requestAnimationFrame`) to make
-   // sure everything is where it should be and the viewport covers the
-   // visible code. That check continues to measure and then optionally
-   // update until it reaches a coherent state.
-   /**
-   An editor view represents the editor's user interface. It holds
-   the editable DOM surface, and possibly other elements such as the
-   line number gutter. It handles events and dispatches state
-   transactions for editing actions.
-   */
-   class EditorView {
-       /**
-       The current editor state.
-       */
-       get state() { return this.viewState.state; }
-       /**
-       To be able to display large documents without consuming too much
-       memory or overloading the browser, CodeMirror only draws the
-       code that is visible (plus a margin around it) to the DOM. This
-       property tells you the extent of the current drawn viewport, in
-       document positions.
-       */
-       get viewport() { return this.viewState.viewport; }
-       /**
-       When there are, for example, large collapsed ranges in the
-       viewport, its size can be a lot bigger than the actual visible
-       content. Thus, if you are doing something like styling the
-       content in the viewport, it is preferable to only do so for
-       these ranges, which are the subset of the viewport that is
-       actually drawn.
-       */
-       get visibleRanges() { return this.viewState.visibleRanges; }
-       /**
-       Returns false when the editor is entirely scrolled out of view
-       or otherwise hidden.
-       */
-       get inView() { return this.viewState.inView; }
-       /**
-       Indicates whether the user is currently composing text via
-       [IME](https://en.wikipedia.org/wiki/Input_method), and at least
-       one change has been made in the current composition.
-       */
-       get composing() { return this.inputState.composing > 0; }
-       /**
-       Indicates whether the user is currently in composing state. Note
-       that on some platforms, like Android, this will be the case a
-       lot, since just putting the cursor on a word starts a
-       composition there.
-       */
-       get compositionStarted() { return this.inputState.composing >= 0; }
-       /**
-       The document or shadow root that the view lives in.
-       */
-       get root() { return this._root; }
-       /**
-       @internal
-       */
-       get win() { return this.dom.ownerDocument.defaultView || window; }
-       /**
-       Construct a new view. You'll want to either provide a `parent`
-       option, or put `view.dom` into your document after creating a
-       view, so that the user can see the editor.
-       */
-       constructor(config = {}) {
-           var _a;
-           this.plugins = [];
-           this.pluginMap = new Map;
-           this.editorAttrs = {};
-           this.contentAttrs = {};
-           this.bidiCache = [];
-           this.destroyed = false;
-           /**
-           @internal
-           */
-           this.updateState = 2 /* UpdateState.Updating */;
-           /**
-           @internal
-           */
-           this.measureScheduled = -1;
-           /**
-           @internal
-           */
-           this.measureRequests = [];
-           this.contentDOM = document.createElement("div");
-           this.scrollDOM = document.createElement("div");
-           this.scrollDOM.tabIndex = -1;
-           this.scrollDOM.className = "cm-scroller";
-           this.scrollDOM.appendChild(this.contentDOM);
-           this.announceDOM = document.createElement("div");
-           this.announceDOM.className = "cm-announced";
-           this.announceDOM.setAttribute("aria-live", "polite");
-           this.dom = document.createElement("div");
-           this.dom.appendChild(this.announceDOM);
-           this.dom.appendChild(this.scrollDOM);
-           if (config.parent)
-               config.parent.appendChild(this.dom);
-           let { dispatch } = config;
-           this.dispatchTransactions = config.dispatchTransactions ||
-               (dispatch && ((trs) => trs.forEach(tr => dispatch(tr, this)))) ||
-               ((trs) => this.update(trs));
-           this.dispatch = this.dispatch.bind(this);
-           this._root = (config.root || getRoot(config.parent) || document);
-           this.viewState = new ViewState(config.state || EditorState.create(config));
-           if (config.scrollTo && config.scrollTo.is(scrollIntoView$1))
-               this.viewState.scrollTarget = config.scrollTo.value.clip(this.viewState.state);
-           this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));
-           for (let plugin of this.plugins)
-               plugin.update(this);
-           this.observer = new DOMObserver(this);
-           this.inputState = new InputState(this);
-           this.inputState.ensureHandlers(this.plugins);
-           this.docView = new DocView(this);
-           this.mountStyles();
-           this.updateAttrs();
-           this.updateState = 0 /* UpdateState.Idle */;
-           this.requestMeasure();
-           if ((_a = document.fonts) === null || _a === void 0 ? void 0 : _a.ready)
-               document.fonts.ready.then(() => this.requestMeasure());
-       }
-       dispatch(...input) {
-           let trs = input.length == 1 && input[0] instanceof Transaction ? input
-               : input.length == 1 && Array.isArray(input[0]) ? input[0]
-                   : [this.state.update(...input)];
-           this.dispatchTransactions(trs, this);
-       }
-       /**
-       Update the view for the given array of transactions. This will
-       update the visible document and selection to match the state
-       produced by the transactions, and notify view plugins of the
-       change. You should usually call
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
-       as a primitive.
-       */
-       update(transactions) {
-           if (this.updateState != 0 /* UpdateState.Idle */)
-               throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
-           let redrawn = false, attrsChanged = false, update;
-           let state = this.state;
-           for (let tr of transactions) {
-               if (tr.startState != state)
-                   throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
-               state = tr.state;
-           }
-           if (this.destroyed) {
-               this.viewState.state = state;
-               return;
-           }
-           let focus = this.hasFocus, focusFlag = 0, dispatchFocus = null;
-           if (transactions.some(tr => tr.annotation(isFocusChange))) {
-               this.inputState.notifiedFocused = focus;
-               // If a focus-change transaction is being dispatched, set this update flag.
-               focusFlag = 1 /* UpdateFlag.Focus */;
-           }
-           else if (focus != this.inputState.notifiedFocused) {
-               this.inputState.notifiedFocused = focus;
-               // Schedule a separate focus transaction if necessary, otherwise
-               // add a flag to this update
-               dispatchFocus = focusChangeTransaction(state, focus);
-               if (!dispatchFocus)
-                   focusFlag = 1 /* UpdateFlag.Focus */;
-           }
-           // If there was a pending DOM change, eagerly read it and try to
-           // apply it after the given transactions.
-           let pendingKey = this.observer.delayedAndroidKey, domChange = null;
-           if (pendingKey) {
-               this.observer.clearDelayedAndroidKey();
-               domChange = this.observer.readChange();
-               // Only try to apply DOM changes if the transactions didn't
-               // change the doc or selection.
-               if (domChange && !this.state.doc.eq(state.doc) || !this.state.selection.eq(state.selection))
-                   domChange = null;
-           }
-           else {
-               this.observer.clear();
-           }
-           // When the phrases change, redraw the editor
-           if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases))
-               return this.setState(state);
-           update = ViewUpdate.create(this, state, transactions);
-           update.flags |= focusFlag;
-           let scrollTarget = this.viewState.scrollTarget;
-           try {
-               this.updateState = 2 /* UpdateState.Updating */;
-               for (let tr of transactions) {
-                   if (scrollTarget)
-                       scrollTarget = scrollTarget.map(tr.changes);
-                   if (tr.scrollIntoView) {
-                       let { main } = tr.state.selection;
-                       scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1));
-                   }
-                   for (let e of tr.effects)
-                       if (e.is(scrollIntoView$1))
-                           scrollTarget = e.value.clip(this.state);
-               }
-               this.viewState.update(update, scrollTarget);
-               this.bidiCache = CachedOrder.update(this.bidiCache, update.changes);
-               if (!update.empty) {
-                   this.updatePlugins(update);
-                   this.inputState.update(update);
-               }
-               redrawn = this.docView.update(update);
-               if (this.state.facet(styleModule) != this.styleModules)
-                   this.mountStyles();
-               attrsChanged = this.updateAttrs();
-               this.showAnnouncements(transactions);
-               this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent("select.pointer")));
-           }
-           finally {
-               this.updateState = 0 /* UpdateState.Idle */;
-           }
-           if (update.startState.facet(theme) != update.state.facet(theme))
-               this.viewState.mustMeasureContent = true;
-           if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)
-               this.requestMeasure();
-           if (redrawn)
-               this.docViewUpdate();
-           if (!update.empty)
-               for (let listener of this.state.facet(updateListener)) {
-                   try {
-                       listener(update);
-                   }
-                   catch (e) {
-                       logException(this.state, e, "update listener");
-                   }
-               }
-           if (dispatchFocus || domChange)
-               Promise.resolve().then(() => {
-                   if (dispatchFocus && this.state == dispatchFocus.startState)
-                       this.dispatch(dispatchFocus);
-                   if (domChange) {
-                       if (!applyDOMChange(this, domChange) && pendingKey.force)
-                           dispatchKey(this.contentDOM, pendingKey.key, pendingKey.keyCode);
-                   }
-               });
-       }
-       /**
-       Reset the view to the given state. (This will cause the entire
-       document to be redrawn and all view plugins to be reinitialized,
-       so you should probably only use it when the new state isn't
-       derived from the old state. Otherwise, use
-       [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
-       */
-       setState(newState) {
-           if (this.updateState != 0 /* UpdateState.Idle */)
-               throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
-           if (this.destroyed) {
-               this.viewState.state = newState;
-               return;
-           }
-           this.updateState = 2 /* UpdateState.Updating */;
-           let hadFocus = this.hasFocus;
-           try {
-               for (let plugin of this.plugins)
-                   plugin.destroy(this);
-               this.viewState = new ViewState(newState);
-               this.plugins = newState.facet(viewPlugin).map(spec => new PluginInstance(spec));
-               this.pluginMap.clear();
-               for (let plugin of this.plugins)
-                   plugin.update(this);
-               this.docView.destroy();
-               this.docView = new DocView(this);
-               this.inputState.ensureHandlers(this.plugins);
-               this.mountStyles();
-               this.updateAttrs();
-               this.bidiCache = [];
-           }
-           finally {
-               this.updateState = 0 /* UpdateState.Idle */;
-           }
-           if (hadFocus)
-               this.focus();
-           this.requestMeasure();
-       }
-       updatePlugins(update) {
-           let prevSpecs = update.startState.facet(viewPlugin), specs = update.state.facet(viewPlugin);
-           if (prevSpecs != specs) {
-               let newPlugins = [];
-               for (let spec of specs) {
-                   let found = prevSpecs.indexOf(spec);
-                   if (found < 0) {
-                       newPlugins.push(new PluginInstance(spec));
-                   }
-                   else {
-                       let plugin = this.plugins[found];
-                       plugin.mustUpdate = update;
-                       newPlugins.push(plugin);
-                   }
-               }
-               for (let plugin of this.plugins)
-                   if (plugin.mustUpdate != update)
-                       plugin.destroy(this);
-               this.plugins = newPlugins;
-               this.pluginMap.clear();
-           }
-           else {
-               for (let p of this.plugins)
-                   p.mustUpdate = update;
-           }
-           for (let i = 0; i < this.plugins.length; i++)
-               this.plugins[i].update(this);
-           if (prevSpecs != specs)
-               this.inputState.ensureHandlers(this.plugins);
-       }
-       docViewUpdate() {
-           for (let plugin of this.plugins) {
-               let val = plugin.value;
-               if (val && val.docViewUpdate) {
-                   try {
-                       val.docViewUpdate(this);
-                   }
-                   catch (e) {
-                       logException(this.state, e, "doc view update listener");
-                   }
-               }
-           }
-       }
-       /**
-       @internal
-       */
-       measure(flush = true) {
-           if (this.destroyed)
-               return;
-           if (this.measureScheduled > -1)
-               this.win.cancelAnimationFrame(this.measureScheduled);
-           if (this.observer.delayedAndroidKey) {
-               this.measureScheduled = -1;
-               this.requestMeasure();
-               return;
-           }
-           this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame
-           if (flush)
-               this.observer.forceFlush();
-           let updated = null;
-           let sDOM = this.scrollDOM, scrollTop = sDOM.scrollTop * this.scaleY;
-           let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;
-           if (Math.abs(scrollTop - this.viewState.scrollTop) > 1)
-               scrollAnchorHeight = -1;
-           this.viewState.scrollAnchorHeight = -1;
-           try {
-               for (let i = 0;; i++) {
-                   if (scrollAnchorHeight < 0) {
-                       if (isScrolledToBottom(sDOM)) {
-                           scrollAnchorPos = -1;
-                           scrollAnchorHeight = this.viewState.heightMap.height;
-                       }
-                       else {
-                           let block = this.viewState.scrollAnchorAt(scrollTop);
-                           scrollAnchorPos = block.from;
-                           scrollAnchorHeight = block.top;
-                       }
-                   }
-                   this.updateState = 1 /* UpdateState.Measuring */;
-                   let changed = this.viewState.measure(this);
-                   if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)
-                       break;
-                   if (i > 5) {
-                       console.warn(this.measureRequests.length
-                           ? "Measure loop restarted more than 5 times"
-                           : "Viewport failed to stabilize");
-                       break;
-                   }
-                   let measuring = [];
-                   // Only run measure requests in this cycle when the viewport didn't change
-                   if (!(changed & 4 /* UpdateFlag.Viewport */))
-                       [this.measureRequests, measuring] = [measuring, this.measureRequests];
-                   let measured = measuring.map(m => {
-                       try {
-                           return m.read(this);
-                       }
-                       catch (e) {
-                           logException(this.state, e);
-                           return BadMeasure;
-                       }
-                   });
-                   let update = ViewUpdate.create(this, this.state, []), redrawn = false;
-                   update.flags |= changed;
-                   if (!updated)
-                       updated = update;
-                   else
-                       updated.flags |= changed;
-                   this.updateState = 2 /* UpdateState.Updating */;
-                   if (!update.empty) {
-                       this.updatePlugins(update);
-                       this.inputState.update(update);
-                       this.updateAttrs();
-                       redrawn = this.docView.update(update);
-                       if (redrawn)
-                           this.docViewUpdate();
-                   }
-                   for (let i = 0; i < measuring.length; i++)
-                       if (measured[i] != BadMeasure) {
-                           try {
-                               let m = measuring[i];
-                               if (m.write)
-                                   m.write(measured[i], this);
-                           }
-                           catch (e) {
-                               logException(this.state, e);
-                           }
-                       }
-                   if (redrawn)
-                       this.docView.updateSelection(true);
-                   if (!update.viewportChanged && this.measureRequests.length == 0) {
-                       if (this.viewState.editorHeight) {
-                           if (this.viewState.scrollTarget) {
-                               this.docView.scrollIntoView(this.viewState.scrollTarget);
-                               this.viewState.scrollTarget = null;
-                               scrollAnchorHeight = -1;
-                               continue;
-                           }
-                           else {
-                               let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :
-                                   this.viewState.lineBlockAt(scrollAnchorPos).top;
-                               let diff = newAnchorHeight - scrollAnchorHeight;
-                               if (diff > 1 || diff < -1) {
-                                   scrollTop = scrollTop + diff;
-                                   sDOM.scrollTop = scrollTop / this.scaleY;
-                                   scrollAnchorHeight = -1;
-                                   continue;
-                               }
-                           }
-                       }
-                       break;
-                   }
-               }
-           }
-           finally {
-               this.updateState = 0 /* UpdateState.Idle */;
-               this.measureScheduled = -1;
-           }
-           if (updated && !updated.empty)
-               for (let listener of this.state.facet(updateListener))
-                   listener(updated);
-       }
-       /**
-       Get the CSS classes for the currently active editor themes.
-       */
-       get themeClasses() {
-           return baseThemeID + " " +
-               (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + " " +
-               this.state.facet(theme);
-       }
-       updateAttrs() {
-           let editorAttrs = attrsFromFacet(this, editorAttributes, {
-               class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
-           });
-           let contentAttrs = {
-               spellcheck: "false",
-               autocorrect: "off",
-               autocapitalize: "off",
-               writingsuggestions: "false",
-               translate: "no",
-               contenteditable: !this.state.facet(editable) ? "false" : "true",
-               class: "cm-content",
-               style: `${browser.tabSize}: ${this.state.tabSize}`,
-               role: "textbox",
-               "aria-multiline": "true"
-           };
-           if (this.state.readOnly)
-               contentAttrs["aria-readonly"] = "true";
-           attrsFromFacet(this, contentAttributes, contentAttrs);
-           let changed = this.observer.ignore(() => {
-               let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);
-               let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);
-               return changedContent || changedEditor;
-           });
-           this.editorAttrs = editorAttrs;
-           this.contentAttrs = contentAttrs;
-           return changed;
-       }
-       showAnnouncements(trs) {
-           let first = true;
-           for (let tr of trs)
-               for (let effect of tr.effects)
-                   if (effect.is(EditorView.announce)) {
-                       if (first)
-                           this.announceDOM.textContent = "";
-                       first = false;
-                       let div = this.announceDOM.appendChild(document.createElement("div"));
-                       div.textContent = effect.value;
-                   }
-       }
-       mountStyles() {
-           this.styleModules = this.state.facet(styleModule);
-           let nonce = this.state.facet(EditorView.cspNonce);
-           StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse(), nonce ? { nonce } : undefined);
-       }
-       readMeasured() {
-           if (this.updateState == 2 /* UpdateState.Updating */)
-               throw new Error("Reading the editor layout isn't allowed during an update");
-           if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)
-               this.measure(false);
-       }
-       /**
-       Schedule a layout measurement, optionally providing callbacks to
-       do custom DOM measuring followed by a DOM write phase. Using
-       this is preferable reading DOM layout directly from, for
-       example, an event handler, because it'll make sure measuring and
-       drawing done by other components is synchronized, avoiding
-       unnecessary DOM layout computations.
-       */
-       requestMeasure(request) {
-           if (this.measureScheduled < 0)
-               this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
-           if (request) {
-               if (this.measureRequests.indexOf(request) > -1)
-                   return;
-               if (request.key != null)
-                   for (let i = 0; i < this.measureRequests.length; i++) {
-                       if (this.measureRequests[i].key === request.key) {
-                           this.measureRequests[i] = request;
-                           return;
-                       }
-                   }
-               this.measureRequests.push(request);
-           }
-       }
-       /**
-       Get the value of a specific plugin, if present. Note that
-       plugins that crash can be dropped from a view, so even when you
-       know you registered a given plugin, it is recommended to check
-       the return value of this method.
-       */
-       plugin(plugin) {
-           let known = this.pluginMap.get(plugin);
-           if (known === undefined || known && known.spec != plugin)
-               this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);
-           return known && known.update(this).value;
-       }
-       /**
-       The top position of the document, in screen coordinates. This
-       may be negative when the editor is scrolled down. Points
-       directly to the top of the first line, not above the padding.
-       */
-       get documentTop() {
-           return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
-       }
-       /**
-       Reports the padding above and below the document.
-       */
-       get documentPadding() {
-           return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
-       }
-       /**
-       If the editor is transformed with CSS, this provides the scale
-       along the X axis. Otherwise, it will just be 1. Note that
-       transforms other than translation and scaling are not supported.
-       */
-       get scaleX() { return this.viewState.scaleX; }
-       /**
-       Provide the CSS transformed scale along the Y axis.
-       */
-       get scaleY() { return this.viewState.scaleY; }
-       /**
-       Find the text line or block widget at the given vertical
-       position (which is interpreted as relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).
-       */
-       elementAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.elementAtHeight(height);
-       }
-       /**
-       Find the line block (see
-       [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
-       height, again interpreted relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
-       */
-       lineBlockAtHeight(height) {
-           this.readMeasured();
-           return this.viewState.lineBlockAtHeight(height);
-       }
-       /**
-       Get the extent and vertical position of all [line
-       blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
-       are relative to the [top of the
-       document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
-       */
-       get viewportLineBlocks() {
-           return this.viewState.viewportLines;
-       }
-       /**
-       Find the line block around the given document position. A line
-       block is a range delimited on both sides by either a
-       non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line break, or the
-       start/end of the document. It will usually just hold a line of
-       text, but may be broken into multiple textblocks by block
-       widgets.
-       */
-       lineBlockAt(pos) {
-           return this.viewState.lineBlockAt(pos);
-       }
-       /**
-       The editor's total content height.
-       */
-       get contentHeight() {
-           return this.viewState.contentHeight;
-       }
-       /**
-       Move a cursor position by [grapheme
-       cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
-       the motion is away from the line start, or towards it. In
-       bidirectional text, the line is traversed in visual order, using
-       the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
-       When the start position was the last one on the line, the
-       returned position will be across the line break. If there is no
-       further line, the original position is returned.
-       
-       By default, this method moves over a single cluster. The
-       optional `by` argument can be used to move across more. It will
-       be called with the first cluster as argument, and should return
-       a predicate that determines, for each subsequent cluster,
-       whether it should also be moved over.
-       */
-       moveByChar(start, forward, by) {
-           return skipAtoms(this, start, moveByChar(this, start, forward, by));
-       }
-       /**
-       Move a cursor position across the next group of either
-       [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
-       non-whitespace characters.
-       */
-       moveByGroup(start, forward) {
-           return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));
-       }
-       /**
-       Get the cursor position visually at the start or end of a line.
-       Note that this may differ from the _logical_ position at its
-       start or end (which is simply at `line.from`/`line.to`) if text
-       at the start or end goes against the line's base text direction.
-       */
-       visualLineSide(line, end) {
-           let order = this.bidiSpans(line), dir = this.textDirectionAt(line.from);
-           let span = order[end ? order.length - 1 : 0];
-           return EditorSelection.cursor(span.side(end, dir) + line.from, span.forward(!end, dir) ? 1 : -1);
-       }
-       /**
-       Move to the next line boundary in the given direction. If
-       `includeWrap` is true, line wrapping is on, and there is a
-       further wrap point on the current line, the wrap point will be
-       returned. Otherwise this function will return the start or end
-       of the line.
-       */
-       moveToLineBoundary(start, forward, includeWrap = true) {
-           return moveToLineBoundary(this, start, forward, includeWrap);
-       }
-       /**
-       Move a cursor position vertically. When `distance` isn't given,
-       it defaults to moving to the next line (including wrapped
-       lines). Otherwise, `distance` should provide a positive distance
-       in pixels.
-       
-       When `start` has a
-       [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
-       motion will use that as a target horizontal position. Otherwise,
-       the cursor's own horizontal position is used. The returned
-       cursor will have its goal column set to whichever column was
-       used.
-       */
-       moveVertically(start, forward, distance) {
-           return skipAtoms(this, start, moveVertically(this, start, forward, distance));
-       }
-       /**
-       Find the DOM parent node and offset (child offset if `node` is
-       an element, character offset when it is a text node) at the
-       given document position.
-       
-       Note that for positions that aren't currently in
-       `visibleRanges`, the resulting DOM position isn't necessarily
-       meaningful (it may just point before or after a placeholder
-       element).
-       */
-       domAtPos(pos) {
-           return this.docView.domAtPos(pos);
-       }
-       /**
-       Find the document position at the given DOM node. Can be useful
-       for associating positions with DOM events. Will raise an error
-       when `node` isn't part of the editor content.
-       */
-       posAtDOM(node, offset = 0) {
-           return this.docView.posFromDOM(node, offset);
-       }
-       posAtCoords(coords, precise = true) {
-           this.readMeasured();
-           return posAtCoords(this, coords, precise);
-       }
-       /**
-       Get the screen coordinates at the given document position.
-       `side` determines whether the coordinates are based on the
-       element before (-1) or after (1) the position (if no element is
-       available on the given side, the method will transparently use
-       another strategy to get reasonable coordinates).
-       */
-       coordsAtPos(pos, side = 1) {
-           this.readMeasured();
-           let rect = this.docView.coordsAt(pos, side);
-           if (!rect || rect.left == rect.right)
-               return rect;
-           let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);
-           let span = order[BidiSpan.find(order, pos - line.from, -1, side)];
-           return flattenRect(rect, (span.dir == Direction.LTR) == (side > 0));
-       }
-       /**
-       Return the rectangle around a given character. If `pos` does not
-       point in front of a character that is in the viewport and
-       rendered (i.e. not replaced, not a line break), this will return
-       null. For space characters that are a line wrap point, this will
-       return the position before the line break.
-       */
-       coordsForChar(pos) {
-           this.readMeasured();
-           return this.docView.coordsForChar(pos);
-       }
-       /**
-       The default width of a character in the editor. May not
-       accurately reflect the width of all characters (given variable
-       width fonts or styling of invididual ranges).
-       */
-       get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }
-       /**
-       The default height of a line in the editor. May not be accurate
-       for all lines.
-       */
-       get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }
-       /**
-       The text direction
-       ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
-       CSS property) of the editor's content element.
-       */
-       get textDirection() { return this.viewState.defaultTextDirection; }
-       /**
-       Find the text direction of the block at the given position, as
-       assigned by CSS. If
-       [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
-       isn't enabled, or the given position is outside of the viewport,
-       this will always return the same as
-       [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
-       this may trigger a DOM layout.
-       */
-       textDirectionAt(pos) {
-           let perLine = this.state.facet(perLineTextDirection);
-           if (!perLine || pos < this.viewport.from || pos > this.viewport.to)
-               return this.textDirection;
-           this.readMeasured();
-           return this.docView.textDirectionAt(pos);
-       }
-       /**
-       Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
-       (as determined by the
-       [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
-       CSS property of its content element).
-       */
-       get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }
-       /**
-       Returns the bidirectional text structure of the given line
-       (which should be in the current document) as an array of span
-       objects. The order of these spans matches the [text
-       direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
-       left-to-right, the leftmost spans come first, otherwise the
-       rightmost spans come first.
-       */
-       bidiSpans(line) {
-           if (line.length > MaxBidiLine)
-               return trivialOrder(line.length);
-           let dir = this.textDirectionAt(line.from), isolates;
-           for (let entry of this.bidiCache) {
-               if (entry.from == line.from && entry.dir == dir &&
-                   (entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line))))
-                   return entry.order;
-           }
-           if (!isolates)
-               isolates = getIsolatedRanges(this, line);
-           let order = computeOrder(line.text, dir, isolates);
-           this.bidiCache.push(new CachedOrder(line.from, line.to, dir, isolates, true, order));
-           return order;
-       }
-       /**
-       Check whether the editor has focus.
-       */
-       get hasFocus() {
-           var _a;
-           // Safari return false for hasFocus when the context menu is open
-           // or closing, which leads us to ignore selection changes from the
-           // context menu because it looks like the editor isn't focused.
-           // This kludges around that.
-           return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&
-               this.root.activeElement == this.contentDOM;
-       }
-       /**
-       Put focus on the editor.
-       */
-       focus() {
-           this.observer.ignore(() => {
-               focusPreventScroll(this.contentDOM);
-               this.docView.updateSelection();
-           });
-       }
-       /**
-       Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only
-       necessary when moving the editor's existing DOM to a new window or shadow root.
-       */
-       setRoot(root) {
-           if (this._root != root) {
-               this._root = root;
-               this.observer.setWindow((root.nodeType == 9 ? root : root.ownerDocument).defaultView || window);
-               this.mountStyles();
-           }
-       }
-       /**
-       Clean up this editor view, removing its element from the
-       document, unregistering event handlers, and notifying
-       plugins. The view instance can no longer be used after
-       calling this.
-       */
-       destroy() {
-           if (this.root.activeElement == this.contentDOM)
-               this.contentDOM.blur();
-           for (let plugin of this.plugins)
-               plugin.destroy(this);
-           this.plugins = [];
-           this.inputState.destroy();
-           this.docView.destroy();
-           this.dom.remove();
-           this.observer.destroy();
-           if (this.measureScheduled > -1)
-               this.win.cancelAnimationFrame(this.measureScheduled);
-           this.destroyed = true;
-       }
-       /**
-       Returns an effect that can be
-       [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
-       cause it to scroll the given position or range into view.
-       */
-       static scrollIntoView(pos, options = {}) {
-           return scrollIntoView$1.of(new ScrollTarget(typeof pos == "number" ? EditorSelection.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));
-       }
-       /**
-       Return an effect that resets the editor to its current (at the
-       time this method was called) scroll position. Note that this
-       only affects the editor's own scrollable element, not parents.
-       See also
-       [`EditorViewConfig.scrollTo`](https://codemirror.net/6/docs/ref/#view.EditorViewConfig.scrollTo).
-       
-       The effect should be used with a document identical to the one
-       it was created for. Failing to do so is not an error, but may
-       not scroll to the expected position. You can
-       [map](https://codemirror.net/6/docs/ref/#state.StateEffect.map) the effect to account for changes.
-       */
-       scrollSnapshot() {
-           let { scrollTop, scrollLeft } = this.scrollDOM;
-           let ref = this.viewState.scrollAnchorAt(scrollTop);
-           return scrollIntoView$1.of(new ScrollTarget(EditorSelection.cursor(ref.from), "start", "start", ref.top - scrollTop, scrollLeft, true));
-       }
-       /**
-       Enable or disable tab-focus mode, which disables key bindings
-       for Tab and Shift-Tab, letting the browser's default
-       focus-changing behavior go through instead. This is useful to
-       prevent trapping keyboard users in your editor.
-       
-       Without argument, this toggles the mode. With a boolean, it
-       enables (true) or disables it (false). Given a number, it
-       temporarily enables the mode until that number of milliseconds
-       have passed or another non-Tab key is pressed.
-       */
-       setTabFocusMode(to) {
-           if (to == null)
-               this.inputState.tabFocusMode = this.inputState.tabFocusMode < 0 ? 0 : -1;
-           else if (typeof to == "boolean")
-               this.inputState.tabFocusMode = to ? 0 : -1;
-           else if (this.inputState.tabFocusMode != 0)
-               this.inputState.tabFocusMode = Date.now() + to;
-       }
-       /**
-       Returns an extension that can be used to add DOM event handlers.
-       The value should be an object mapping event names to handler
-       functions. For any given event, such functions are ordered by
-       extension precedence, and the first handler to return true will
-       be assumed to have handled that event, and no other handlers or
-       built-in behavior will be activated for it. These are registered
-       on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
-       for `scroll` handlers, which will be called any time the
-       editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
-       its parent nodes is scrolled.
-       */
-       static domEventHandlers(handlers) {
-           return ViewPlugin.define(() => ({}), { eventHandlers: handlers });
-       }
-       /**
-       Create an extension that registers DOM event observers. Contrary
-       to event [handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers),
-       observers can't be prevented from running by a higher-precedence
-       handler returning true. They also don't prevent other handlers
-       and observers from running when they return true, and should not
-       call `preventDefault`.
-       */
-       static domEventObservers(observers) {
-           return ViewPlugin.define(() => ({}), { eventObservers: observers });
-       }
-       /**
-       Create a theme extension. The first argument can be a
-       [`style-mod`](https://github.com/marijnh/style-mod#documentation)
-       style spec providing the styles for the theme. These will be
-       prefixed with a generated class for the style.
-       
-       Because the selectors will be prefixed with a scope class, rule
-       that directly match the editor's [wrapper
-       element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
-       added—need to be explicitly differentiated by adding an `&` to
-       the selector for that element—for example
-       `&.cm-focused`.
-       
-       When `dark` is set to true, the theme will be marked as dark,
-       which will cause the `&dark` rules from [base
-       themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
-       `&light` when a light theme is active).
-       */
-       static theme(spec, options) {
-           let prefix = StyleModule.newName();
-           let result = [theme.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];
-           if (options && options.dark)
-               result.push(darkTheme.of(true));
-           return result;
-       }
-       /**
-       Create an extension that adds styles to the base theme. Like
-       with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
-       place of the editor wrapper element when directly targeting
-       that. You can also use `&dark` or `&light` instead to only
-       target editors with a dark or light theme.
-       */
-       static baseTheme(spec) {
-           return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
-       }
-       /**
-       Retrieve an editor view instance from the view's DOM
-       representation.
-       */
-       static findFromDOM(dom) {
-           var _a;
-           let content = dom.querySelector(".cm-content");
-           let cView = content && ContentView.get(content) || ContentView.get(dom);
-           return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;
-       }
-   }
-   /**
-   Facet to add a [style
-   module](https://github.com/marijnh/style-mod#documentation) to
-   an editor view. The view will ensure that the module is
-   mounted in its [document
-   root](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).
-   */
-   EditorView.styleModule = styleModule;
-   /**
-   An input handler can override the way changes to the editable
-   DOM content are handled. Handlers are passed the document
-   positions between which the change was found, and the new
-   content. When one returns true, no further input handlers are
-   called and the default behavior is prevented.
-
-   The `insert` argument can be used to get the default transaction
-   that would be applied for this input. This can be useful when
-   dispatching the custom behavior as a separate transaction.
-   */
-   EditorView.inputHandler = inputHandler;
-   /**
-   Functions provided in this facet will be used to transform text
-   pasted or dropped into the editor.
-   */
-   EditorView.clipboardInputFilter = clipboardInputFilter;
-   /**
-   Transform text copied or dragged from the editor.
-   */
-   EditorView.clipboardOutputFilter = clipboardOutputFilter;
-   /**
-   Scroll handlers can override how things are scrolled into view.
-   If they return `true`, no further handling happens for the
-   scrolling. If they return false, the default scroll behavior is
-   applied. Scroll handlers should never initiate editor updates.
-   */
-   EditorView.scrollHandler = scrollHandler;
-   /**
-   This facet can be used to provide functions that create effects
-   to be dispatched when the editor's focus state changes.
-   */
-   EditorView.focusChangeEffect = focusChangeEffect;
-   /**
-   By default, the editor assumes all its content has the same
-   [text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`
-   value to make it read the text direction of every (rendered)
-   line separately.
-   */
-   EditorView.perLineTextDirection = perLineTextDirection;
-   /**
-   Allows you to provide a function that should be called when the
-   library catches an exception from an extension (mostly from view
-   plugins, but may be used by other extensions to route exceptions
-   from user-code-provided callbacks). This is mostly useful for
-   debugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).
-   */
-   EditorView.exceptionSink = exceptionSink;
-   /**
-   A facet that can be used to register a function to be called
-   every time the view updates.
-   */
-   EditorView.updateListener = updateListener;
-   /**
-   Facet that controls whether the editor content DOM is editable.
-   When its highest-precedence value is `false`, the element will
-   not have its `contenteditable` attribute set. (Note that this
-   doesn't affect API calls that change the editor content, even
-   when those are bound to keys or buttons. See the
-   [`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)
-   */
-   EditorView.editable = editable;
-   /**
-   Allows you to influence the way mouse selection happens. The
-   functions in this facet will be called for a `mousedown` event
-   on the editor, and can return an object that overrides the way a
-   selection is computed from that mouse click or drag.
-   */
-   EditorView.mouseSelectionStyle = mouseSelectionStyle;
-   /**
-   Facet used to configure whether a given selection drag event
-   should move or copy the selection. The given predicate will be
-   called with the `mousedown` event, and can return `true` when
-   the drag should move the content.
-   */
-   EditorView.dragMovesSelection = dragMovesSelection$1;
-   /**
-   Facet used to configure whether a given selecting click adds a
-   new range to the existing selection or replaces it entirely. The
-   default behavior is to check `event.metaKey` on macOS, and
-   `event.ctrlKey` elsewhere.
-   */
-   EditorView.clickAddsSelectionRange = clickAddsSelectionRange;
-   /**
-   A facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)
-   are shown in the view. Decorations can be provided in two
-   ways—directly, or via a function that takes an editor view.
-
-   Only decoration sets provided directly are allowed to influence
-   the editor's vertical layout structure. The ones provided as
-   functions are called _after_ the new viewport has been computed,
-   and thus **must not** introduce block widgets or replacing
-   decorations that cover line breaks.
-
-   If you want decorated ranges to behave like atomic units for
-   cursor motion and deletion purposes, also provide the range set
-   containing the decorations to
-   [`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).
-   */
-   EditorView.decorations = decorations;
-   /**
-   Facet that works much like
-   [`decorations`](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), but puts its
-   inputs at the very bottom of the precedence stack, meaning mark
-   decorations provided here will only be split by other, partially
-   overlapping \`outerDecorations\` ranges, and wrap around all
-   regular decorations. Use this for mark elements that should, as
-   much as possible, remain in one piece.
-   */
-   EditorView.outerDecorations = outerDecorations;
-   /**
-   Used to provide ranges that should be treated as atoms as far as
-   cursor motion is concerned. This causes methods like
-   [`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and
-   [`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the
-   commands built on top of them) to skip across such regions when
-   a selection endpoint would enter them. This does _not_ prevent
-   direct programmatic [selection
-   updates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such
-   regions.
-   */
-   EditorView.atomicRanges = atomicRanges;
-   /**
-   When range decorations add a `unicode-bidi: isolate` style, they
-   should also include a
-   [`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property
-   in their decoration spec, and be exposed through this facet, so
-   that the editor can compute the proper text order. (Other values
-   for `unicode-bidi`, except of course `normal`, are not
-   supported.)
-   */
-   EditorView.bidiIsolatedRanges = bidiIsolatedRanges;
-   /**
-   Facet that allows extensions to provide additional scroll
-   margins (space around the sides of the scrolling element that
-   should be considered invisible). This can be useful when the
-   plugin introduces elements that cover part of that element (for
-   example a horizontally fixed gutter).
-   */
-   EditorView.scrollMargins = scrollMargins;
-   /**
-   This facet records whether a dark theme is active. The extension
-   returned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically
-   includes an instance of this when the `dark` option is set to
-   true.
-   */
-   EditorView.darkTheme = darkTheme;
-   /**
-   Provides a Content Security Policy nonce to use when creating
-   the style sheets for the editor. Holds the empty string when no
-   nonce has been provided.
-   */
-   EditorView.cspNonce = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : "" });
-   /**
-   Facet that provides additional DOM attributes for the editor's
-   editable DOM element.
-   */
-   EditorView.contentAttributes = contentAttributes;
-   /**
-   Facet that provides DOM attributes for the editor's outer
-   element.
-   */
-   EditorView.editorAttributes = editorAttributes;
-   /**
-   An extension that enables line wrapping in the editor (by
-   setting CSS `white-space` to `pre-wrap` in the content).
-   */
-   EditorView.lineWrapping = /*@__PURE__*/EditorView.contentAttributes.of({ "class": "cm-lineWrapping" });
-   /**
-   State effect used to include screen reader announcements in a
-   transaction. These will be added to the DOM in a visually hidden
-   element with `aria-live="polite"` set, and should be used to
-   describe effects that are visually obvious but may not be
-   noticed by screen reader users (such as moving to the next
-   search match).
-   */
-   EditorView.announce = /*@__PURE__*/StateEffect.define();
-   // Maximum line length for which we compute accurate bidi info
-   const MaxBidiLine = 4096;
-   const BadMeasure = {};
-   class CachedOrder {
-       constructor(from, to, dir, isolates, fresh, order) {
-           this.from = from;
-           this.to = to;
-           this.dir = dir;
-           this.isolates = isolates;
-           this.fresh = fresh;
-           this.order = order;
-       }
-       static update(cache, changes) {
-           if (changes.empty && !cache.some(c => c.fresh))
-               return cache;
-           let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction.LTR;
-           for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {
-               let entry = cache[i];
-               if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))
-                   result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.isolates, false, entry.order));
-           }
-           return result;
-       }
-   }
-   function attrsFromFacet(view, facet, base) {
-       for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {
-           let source = sources[i], value = typeof source == "function" ? source(view) : source;
-           if (value)
-               combineAttrs(value, base);
-       }
-       return base;
-   }
-
-   const currentPlatform = browser.mac ? "mac" : browser.windows ? "win" : browser.linux ? "linux" : "key";
-   function normalizeKeyName(name, platform) {
-       const parts = name.split(/-(?!$)/);
-       let result = parts[parts.length - 1];
-       if (result == "Space")
-           result = " ";
-       let alt, ctrl, shift, meta;
-       for (let i = 0; i < parts.length - 1; ++i) {
-           const mod = parts[i];
-           if (/^(cmd|meta|m)$/i.test(mod))
-               meta = true;
-           else if (/^a(lt)?$/i.test(mod))
-               alt = true;
-           else if (/^(c|ctrl|control)$/i.test(mod))
-               ctrl = true;
-           else if (/^s(hift)?$/i.test(mod))
-               shift = true;
-           else if (/^mod$/i.test(mod)) {
-               if (platform == "mac")
-                   meta = true;
-               else
-                   ctrl = true;
-           }
-           else
-               throw new Error("Unrecognized modifier name: " + mod);
-       }
-       if (alt)
-           result = "Alt-" + result;
-       if (ctrl)
-           result = "Ctrl-" + result;
-       if (meta)
-           result = "Meta-" + result;
-       if (shift)
-           result = "Shift-" + result;
-       return result;
-   }
-   function modifiers(name, event, shift) {
-       if (event.altKey)
-           name = "Alt-" + name;
-       if (event.ctrlKey)
-           name = "Ctrl-" + name;
-       if (event.metaKey)
-           name = "Meta-" + name;
-       if (shift !== false && event.shiftKey)
-           name = "Shift-" + name;
-       return name;
-   }
-   const handleKeyEvents = /*@__PURE__*/Prec.default(/*@__PURE__*/EditorView.domEventHandlers({
-       keydown(event, view) {
-           return runHandlers(getKeymap(view.state), event, view, "editor");
-       }
-   }));
-   /**
-   Facet used for registering keymaps.
-
-   You can add multiple keymaps to an editor. Their priorities
-   determine their precedence (the ones specified early or with high
-   priority get checked first). When a handler has returned `true`
-   for a given key, no further handlers are called.
-   */
-   const keymap = /*@__PURE__*/Facet.define({ enables: handleKeyEvents });
-   const Keymaps = /*@__PURE__*/new WeakMap();
-   // This is hidden behind an indirection, rather than directly computed
-   // by the facet, to keep internal types out of the facet's type.
-   function getKeymap(state) {
-       let bindings = state.facet(keymap);
-       let map = Keymaps.get(bindings);
-       if (!map)
-           Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));
-       return map;
-   }
-   let storedPrefix = null;
-   const PrefixTimeout = 4000;
-   function buildKeymap(bindings, platform = currentPlatform) {
-       let bound = Object.create(null);
-       let isPrefix = Object.create(null);
-       let checkPrefix = (name, is) => {
-           let current = isPrefix[name];
-           if (current == null)
-               isPrefix[name] = is;
-           else if (current != is)
-               throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
-       };
-       let add = (scope, key, command, preventDefault, stopPropagation) => {
-           var _a, _b;
-           let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
-           let parts = key.split(/ (?!$)/).map(k => normalizeKeyName(k, platform));
-           for (let i = 1; i < parts.length; i++) {
-               let prefix = parts.slice(0, i).join(" ");
-               checkPrefix(prefix, true);
-               if (!scopeObj[prefix])
-                   scopeObj[prefix] = {
-                       preventDefault: true,
-                       stopPropagation: false,
-                       run: [(view) => {
-                               let ourObj = storedPrefix = { view, prefix, scope };
-                               setTimeout(() => { if (storedPrefix == ourObj)
-                                   storedPrefix = null; }, PrefixTimeout);
-                               return true;
-                           }]
-                   };
-           }
-           let full = parts.join(" ");
-           checkPrefix(full, false);
-           let binding = scopeObj[full] || (scopeObj[full] = {
-               preventDefault: false,
-               stopPropagation: false,
-               run: ((_b = (_a = scopeObj._any) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.slice()) || []
-           });
-           if (command)
-               binding.run.push(command);
-           if (preventDefault)
-               binding.preventDefault = true;
-           if (stopPropagation)
-               binding.stopPropagation = true;
-       };
-       for (let b of bindings) {
-           let scopes = b.scope ? b.scope.split(" ") : ["editor"];
-           if (b.any)
-               for (let scope of scopes) {
-                   let scopeObj = bound[scope] || (bound[scope] = Object.create(null));
-                   if (!scopeObj._any)
-                       scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };
-                   let { any } = b;
-                   for (let key in scopeObj)
-                       scopeObj[key].run.push(view => any(view, currentKeyEvent));
-               }
-           let name = b[platform] || b.key;
-           if (!name)
-               continue;
-           for (let scope of scopes) {
-               add(scope, name, b.run, b.preventDefault, b.stopPropagation);
-               if (b.shift)
-                   add(scope, "Shift-" + name, b.shift, b.preventDefault, b.stopPropagation);
-           }
-       }
-       return bound;
-   }
-   let currentKeyEvent = null;
-   function runHandlers(map, event, view, scope) {
-       currentKeyEvent = event;
-       let name = keyName(event);
-       let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != " ";
-       let prefix = "", handled = false, prevented = false, stopPropagation = false;
-       if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
-           prefix = storedPrefix.prefix + " ";
-           if (modifierCodes.indexOf(event.keyCode) < 0) {
-               prevented = true;
-               storedPrefix = null;
-           }
-       }
-       let ran = new Set;
-       let runFor = (binding) => {
-           if (binding) {
-               for (let cmd of binding.run)
-                   if (!ran.has(cmd)) {
-                       ran.add(cmd);
-                       if (cmd(view)) {
-                           if (binding.stopPropagation)
-                               stopPropagation = true;
-                           return true;
-                       }
-                   }
-               if (binding.preventDefault) {
-                   if (binding.stopPropagation)
-                       stopPropagation = true;
-                   prevented = true;
-               }
-           }
-           return false;
-       };
-       let scopeObj = map[scope], baseName, shiftName;
-       if (scopeObj) {
-           if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {
-               handled = true;
-           }
-           else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
-               // Ctrl-Alt may be used for AltGr on Windows
-               !(browser.windows && event.ctrlKey && event.altKey) &&
-               (baseName = base[event.keyCode]) && baseName != name) {
-               if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
-                   handled = true;
-               }
-               else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName &&
-                   runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) {
-                   handled = true;
-               }
-           }
-           else if (isChar && event.shiftKey &&
-               runFor(scopeObj[prefix + modifiers(name, event, true)])) {
-               handled = true;
-           }
-           if (!handled && runFor(scopeObj._any))
-               handled = true;
-       }
-       if (prevented)
-           handled = true;
-       if (handled && stopPropagation)
-           event.stopPropagation();
-       currentKeyEvent = null;
-       return handled;
-   }
-
-   const CanHidePrimary = !(browser.ios && browser.webkit && browser.webkit_version < 534);
-   const themeSpec = {
-       ".cm-line": {
-           "& ::selection, &::selection": { backgroundColor: "transparent !important" },
-       },
-       ".cm-content": {
-           "& :focus": {
-               caretColor: "initial !important",
-               "&::selection, & ::selection": {
-                   backgroundColor: "Highlight !important"
-               }
-           }
-       }
-   };
-   if (CanHidePrimary)
-       themeSpec[".cm-line"].caretColor = themeSpec[".cm-content"].caretColor = "transparent !important";
-
-   const Outside = "-10000px";
-   class TooltipViewManager {
-       constructor(view, facet, createTooltipView, removeTooltipView) {
-           this.facet = facet;
-           this.createTooltipView = createTooltipView;
-           this.removeTooltipView = removeTooltipView;
-           this.input = view.state.facet(facet);
-           this.tooltips = this.input.filter(t => t);
-           let prev = null;
-           this.tooltipViews = this.tooltips.map(t => prev = createTooltipView(t, prev));
-       }
-       update(update, above) {
-           var _a;
-           let input = update.state.facet(this.facet);
-           let tooltips = input.filter(x => x);
-           if (input === this.input) {
-               for (let t of this.tooltipViews)
-                   if (t.update)
-                       t.update(update);
-               return false;
-           }
-           let tooltipViews = [], newAbove = above ? [] : null;
-           for (let i = 0; i < tooltips.length; i++) {
-               let tip = tooltips[i], known = -1;
-               if (!tip)
-                   continue;
-               for (let i = 0; i < this.tooltips.length; i++) {
-                   let other = this.tooltips[i];
-                   if (other && other.create == tip.create)
-                       known = i;
-               }
-               if (known < 0) {
-                   tooltipViews[i] = this.createTooltipView(tip, i ? tooltipViews[i - 1] : null);
-                   if (newAbove)
-                       newAbove[i] = !!tip.above;
-               }
-               else {
-                   let tooltipView = tooltipViews[i] = this.tooltipViews[known];
-                   if (newAbove)
-                       newAbove[i] = above[known];
-                   if (tooltipView.update)
-                       tooltipView.update(update);
-               }
-           }
-           for (let t of this.tooltipViews)
-               if (tooltipViews.indexOf(t) < 0) {
-                   this.removeTooltipView(t);
-                   (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
-               }
-           if (above) {
-               newAbove.forEach((val, i) => above[i] = val);
-               above.length = newAbove.length;
-           }
-           this.input = input;
-           this.tooltips = tooltips;
-           this.tooltipViews = tooltipViews;
-           return true;
-       }
-   }
-   function windowSpace(view) {
-       let { win } = view;
-       return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
-   }
-   const tooltipConfig = /*@__PURE__*/Facet.define({
-       combine: values => {
-           var _a, _b, _c;
-           return ({
-               position: browser.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
-               parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
-               tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,
-           });
-       }
-   });
-   const knownHeight = /*@__PURE__*/new WeakMap();
-   const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.above = [];
-           this.inView = true;
-           this.madeAbsolute = false;
-           this.lastTransaction = 0;
-           this.measureTimeout = -1;
-           let config = view.state.facet(tooltipConfig);
-           this.position = config.position;
-           this.parent = config.parent;
-           this.classes = view.themeClasses;
-           this.createContainer();
-           this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
-           this.resizeObserver = typeof ResizeObserver == "function" ? new ResizeObserver(() => this.measureSoon()) : null;
-           this.manager = new TooltipViewManager(view, showTooltip, (t, p) => this.createTooltip(t, p), t => {
-               if (this.resizeObserver)
-                   this.resizeObserver.unobserve(t.dom);
-               t.dom.remove();
-           });
-           this.above = this.manager.tooltips.map(t => !!t.above);
-           this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
-               if (Date.now() > this.lastTransaction - 50 &&
-                   entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
-                   this.measureSoon();
-           }, { threshold: [1] }) : null;
-           this.observeIntersection();
-           view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
-           this.maybeMeasure();
-       }
-       createContainer() {
-           if (this.parent) {
-               this.container = document.createElement("div");
-               this.container.style.position = "relative";
-               this.container.className = this.view.themeClasses;
-               this.parent.appendChild(this.container);
-           }
-           else {
-               this.container = this.view.dom;
-           }
-       }
-       observeIntersection() {
-           if (this.intersectionObserver) {
-               this.intersectionObserver.disconnect();
-               for (let tooltip of this.manager.tooltipViews)
-                   this.intersectionObserver.observe(tooltip.dom);
-           }
-       }
-       measureSoon() {
-           if (this.measureTimeout < 0)
-               this.measureTimeout = setTimeout(() => {
-                   this.measureTimeout = -1;
-                   this.maybeMeasure();
-               }, 50);
-       }
-       update(update) {
-           if (update.transactions.length)
-               this.lastTransaction = Date.now();
-           let updated = this.manager.update(update, this.above);
-           if (updated)
-               this.observeIntersection();
-           let shouldMeasure = updated || update.geometryChanged;
-           let newConfig = update.state.facet(tooltipConfig);
-           if (newConfig.position != this.position && !this.madeAbsolute) {
-               this.position = newConfig.position;
-               for (let t of this.manager.tooltipViews)
-                   t.dom.style.position = this.position;
-               shouldMeasure = true;
-           }
-           if (newConfig.parent != this.parent) {
-               if (this.parent)
-                   this.container.remove();
-               this.parent = newConfig.parent;
-               this.createContainer();
-               for (let t of this.manager.tooltipViews)
-                   this.container.appendChild(t.dom);
-               shouldMeasure = true;
-           }
-           else if (this.parent && this.view.themeClasses != this.classes) {
-               this.classes = this.container.className = this.view.themeClasses;
-           }
-           if (shouldMeasure)
-               this.maybeMeasure();
-       }
-       createTooltip(tooltip, prev) {
-           let tooltipView = tooltip.create(this.view);
-           let before = prev ? prev.dom : null;
-           tooltipView.dom.classList.add("cm-tooltip");
-           if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
-               let arrow = document.createElement("div");
-               arrow.className = "cm-tooltip-arrow";
-               tooltipView.dom.appendChild(arrow);
-           }
-           tooltipView.dom.style.position = this.position;
-           tooltipView.dom.style.top = Outside;
-           tooltipView.dom.style.left = "0px";
-           this.container.insertBefore(tooltipView.dom, before);
-           if (tooltipView.mount)
-               tooltipView.mount(this.view);
-           if (this.resizeObserver)
-               this.resizeObserver.observe(tooltipView.dom);
-           return tooltipView;
-       }
-       destroy() {
-           var _a, _b, _c;
-           this.view.win.removeEventListener("resize", this.measureSoon);
-           for (let tooltipView of this.manager.tooltipViews) {
-               tooltipView.dom.remove();
-               (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);
-           }
-           if (this.parent)
-               this.container.remove();
-           (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
-           (_c = this.intersectionObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
-           clearTimeout(this.measureTimeout);
-       }
-       readMeasure() {
-           let scaleX = 1, scaleY = 1, makeAbsolute = false;
-           if (this.position == "fixed" && this.manager.tooltipViews.length) {
-               let { dom } = this.manager.tooltipViews[0];
-               if (browser.gecko) {
-                   // Firefox sets the element's `offsetParent` to the
-                   // transformed element when a transform interferes with fixed
-                   // positioning.
-                   makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
-               }
-               else if (dom.style.top == Outside && dom.style.left == "0px") {
-                   // On other browsers, we have to awkwardly try and use other
-                   // information to detect a transform.
-                   let rect = dom.getBoundingClientRect();
-                   makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
-               }
-           }
-           if (makeAbsolute || this.position == "absolute") {
-               if (this.parent) {
-                   let rect = this.parent.getBoundingClientRect();
-                   if (rect.width && rect.height) {
-                       scaleX = rect.width / this.parent.offsetWidth;
-                       scaleY = rect.height / this.parent.offsetHeight;
-                   }
-               }
-               else {
-                   ({ scaleX, scaleY } = this.view.viewState);
-               }
-           }
-           let visible = this.view.scrollDOM.getBoundingClientRect(), margins = getScrollMargins(this.view);
-           return {
-               visible: {
-                   left: visible.left + margins.left, top: visible.top + margins.top,
-                   right: visible.right - margins.right, bottom: visible.bottom - margins.bottom
-               },
-               parent: this.parent ? this.container.getBoundingClientRect() : this.view.dom.getBoundingClientRect(),
-               pos: this.manager.tooltips.map((t, i) => {
-                   let tv = this.manager.tooltipViews[i];
-                   return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
-               }),
-               size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
-               space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
-               scaleX, scaleY, makeAbsolute
-           };
-       }
-       writeMeasure(measured) {
-           var _a;
-           if (measured.makeAbsolute) {
-               this.madeAbsolute = true;
-               this.position = "absolute";
-               for (let t of this.manager.tooltipViews)
-                   t.dom.style.position = "absolute";
-           }
-           let { visible, space, scaleX, scaleY } = measured;
-           let others = [];
-           for (let i = 0; i < this.manager.tooltips.length; i++) {
-               let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
-               let pos = measured.pos[i], size = measured.size[i];
-               // Hide tooltips that are outside of the editor.
-               if (!pos || tooltip.clip !== false && (pos.bottom <= Math.max(visible.top, space.top) ||
-                   pos.top >= Math.min(visible.bottom, space.bottom) ||
-                   pos.right < Math.max(visible.left, space.left) - .1 ||
-                   pos.left > Math.min(visible.right, space.right) + .1)) {
-                   dom.style.top = Outside;
-                   continue;
-               }
-               let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
-               let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
-               let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
-               let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
-               let left = size.width > space.right - space.left
-                   ? (ltr ? space.left : space.right - size.width)
-                   : ltr ? Math.max(space.left, Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width))
-                       : Math.min(Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x), space.right - width);
-               let above = this.above[i];
-               if (!tooltip.strictSide && (above
-                   ? pos.top - height - arrowHeight - offset.y < space.top
-                   : pos.bottom + height + arrowHeight + offset.y > space.bottom) &&
-                   above == (space.bottom - pos.bottom > pos.top - space.top))
-                   above = this.above[i] = !above;
-               let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
-               if (spaceVert < height && tView.resize !== false) {
-                   if (spaceVert < this.view.defaultLineHeight) {
-                       dom.style.top = Outside;
-                       continue;
-                   }
-                   knownHeight.set(tView, height);
-                   dom.style.height = (height = spaceVert) / scaleY + "px";
-               }
-               else if (dom.style.height) {
-                   dom.style.height = "";
-               }
-               let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
-               let right = left + width;
-               if (tView.overlap !== true)
-                   for (let r of others)
-                       if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
-                           top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
-               if (this.position == "absolute") {
-                   dom.style.top = (top - measured.parent.top) / scaleY + "px";
-                   setLeftStyle(dom, (left - measured.parent.left) / scaleX);
-               }
-               else {
-                   dom.style.top = top / scaleY + "px";
-                   setLeftStyle(dom, left / scaleX);
-               }
-               if (arrow) {
-                   let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);
-                   arrow.style.left = arrowLeft / scaleX + "px";
-               }
-               if (tView.overlap !== true)
-                   others.push({ left, top, right, bottom: top + height });
-               dom.classList.toggle("cm-tooltip-above", above);
-               dom.classList.toggle("cm-tooltip-below", !above);
-               if (tView.positioned)
-                   tView.positioned(measured.space);
-           }
-       }
-       maybeMeasure() {
-           if (this.manager.tooltips.length) {
-               if (this.view.inView)
-                   this.view.requestMeasure(this.measureReq);
-               if (this.inView != this.view.inView) {
-                   this.inView = this.view.inView;
-                   if (!this.inView)
-                       for (let tv of this.manager.tooltipViews)
-                           tv.dom.style.top = Outside;
-               }
-           }
-       }
-   }, {
-       eventObservers: {
-           scroll() { this.maybeMeasure(); }
-       }
-   });
-   function setLeftStyle(elt, value) {
-       let current = parseInt(elt.style.left, 10);
-       if (isNaN(current) || Math.abs(value - current) > 1)
-           elt.style.left = value + "px";
-   }
-   const baseTheme$2 = /*@__PURE__*/EditorView.baseTheme({
-       ".cm-tooltip": {
-           zIndex: 500,
-           boxSizing: "border-box"
-       },
-       "&light .cm-tooltip": {
-           border: "1px solid #bbb",
-           backgroundColor: "#f5f5f5"
-       },
-       "&light .cm-tooltip-section:not(:first-child)": {
-           borderTop: "1px solid #bbb",
-       },
-       "&dark .cm-tooltip": {
-           backgroundColor: "#333338",
-           color: "white"
-       },
-       ".cm-tooltip-arrow": {
-           height: `${7 /* Arrow.Size */}px`,
-           width: `${7 /* Arrow.Size */ * 2}px`,
-           position: "absolute",
-           zIndex: -1,
-           overflow: "hidden",
-           "&:before, &:after": {
-               content: "''",
-               position: "absolute",
-               width: 0,
-               height: 0,
-               borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
-               borderRight: `${7 /* Arrow.Size */}px solid transparent`,
-           },
-           ".cm-tooltip-above &": {
-               bottom: `-${7 /* Arrow.Size */}px`,
-               "&:before": {
-                   borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
-               },
-               "&:after": {
-                   borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
-                   bottom: "1px"
-               }
-           },
-           ".cm-tooltip-below &": {
-               top: `-${7 /* Arrow.Size */}px`,
-               "&:before": {
-                   borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
-               },
-               "&:after": {
-                   borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
-                   top: "1px"
-               }
-           },
-       },
-       "&dark .cm-tooltip .cm-tooltip-arrow": {
-           "&:before": {
-               borderTopColor: "#333338",
-               borderBottomColor: "#333338"
-           },
-           "&:after": {
-               borderTopColor: "transparent",
-               borderBottomColor: "transparent"
-           }
-       }
-   });
-   const noOffset = { x: 0, y: 0 };
-   /**
-   Facet to which an extension can add a value to show a tooltip.
-   */
-   const showTooltip = /*@__PURE__*/Facet.define({
-       enables: [tooltipPlugin, baseTheme$2]
-   });
-   /**
-   Get the active tooltip view for a given tooltip, if available.
-   */
-   function getTooltip(view, tooltip) {
-       let plugin = view.plugin(tooltipPlugin);
-       if (!plugin)
-           return null;
-       let found = plugin.manager.tooltips.indexOf(tooltip);
-       return found < 0 ? null : plugin.manager.tooltipViews[found];
-   }
-
-   const panelConfig = /*@__PURE__*/Facet.define({
-       combine(configs) {
-           let topContainer, bottomContainer;
-           for (let c of configs) {
-               topContainer = topContainer || c.topContainer;
-               bottomContainer = bottomContainer || c.bottomContainer;
-           }
-           return { topContainer, bottomContainer };
-       }
-   });
-   const panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
-       constructor(view) {
-           this.input = view.state.facet(showPanel);
-           this.specs = this.input.filter(s => s);
-           this.panels = this.specs.map(spec => spec(view));
-           let conf = view.state.facet(panelConfig);
-           this.top = new PanelGroup(view, true, conf.topContainer);
-           this.bottom = new PanelGroup(view, false, conf.bottomContainer);
-           this.top.sync(this.panels.filter(p => p.top));
-           this.bottom.sync(this.panels.filter(p => !p.top));
-           for (let p of this.panels) {
-               p.dom.classList.add("cm-panel");
-               if (p.mount)
-                   p.mount();
-           }
-       }
-       update(update) {
-           let conf = update.state.facet(panelConfig);
-           if (this.top.container != conf.topContainer) {
-               this.top.sync([]);
-               this.top = new PanelGroup(update.view, true, conf.topContainer);
-           }
-           if (this.bottom.container != conf.bottomContainer) {
-               this.bottom.sync([]);
-               this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);
-           }
-           this.top.syncClasses();
-           this.bottom.syncClasses();
-           let input = update.state.facet(showPanel);
-           if (input != this.input) {
-               let specs = input.filter(x => x);
-               let panels = [], top = [], bottom = [], mount = [];
-               for (let spec of specs) {
-                   let known = this.specs.indexOf(spec), panel;
-                   if (known < 0) {
-                       panel = spec(update.view);
-                       mount.push(panel);
-                   }
-                   else {
-                       panel = this.panels[known];
-                       if (panel.update)
-                           panel.update(update);
-                   }
-                   panels.push(panel);
-                   (panel.top ? top : bottom).push(panel);
-               }
-               this.specs = specs;
-               this.panels = panels;
-               this.top.sync(top);
-               this.bottom.sync(bottom);
-               for (let p of mount) {
-                   p.dom.classList.add("cm-panel");
-                   if (p.mount)
-                       p.mount();
-               }
-           }
-           else {
-               for (let p of this.panels)
-                   if (p.update)
-                       p.update(update);
-           }
-       }
-       destroy() {
-           this.top.sync([]);
-           this.bottom.sync([]);
-       }
-   }, {
-       provide: plugin => EditorView.scrollMargins.of(view => {
-           let value = view.plugin(plugin);
-           return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
-       })
-   });
-   class PanelGroup {
-       constructor(view, top, container) {
-           this.view = view;
-           this.top = top;
-           this.container = container;
-           this.dom = undefined;
-           this.classes = "";
-           this.panels = [];
-           this.syncClasses();
-       }
-       sync(panels) {
-           for (let p of this.panels)
-               if (p.destroy && panels.indexOf(p) < 0)
-                   p.destroy();
-           this.panels = panels;
-           this.syncDOM();
-       }
-       syncDOM() {
-           if (this.panels.length == 0) {
-               if (this.dom) {
-                   this.dom.remove();
-                   this.dom = undefined;
-               }
-               return;
-           }
-           if (!this.dom) {
-               this.dom = document.createElement("div");
-               this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
-               this.dom.style[this.top ? "top" : "bottom"] = "0";
-               let parent = this.container || this.view.dom;
-               parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
-           }
-           let curDOM = this.dom.firstChild;
-           for (let panel of this.panels) {
-               if (panel.dom.parentNode == this.dom) {
-                   while (curDOM != panel.dom)
-                       curDOM = rm(curDOM);
-                   curDOM = curDOM.nextSibling;
-               }
-               else {
-                   this.dom.insertBefore(panel.dom, curDOM);
-               }
-           }
-           while (curDOM)
-               curDOM = rm(curDOM);
-       }
-       scrollMargin() {
-           return !this.dom || this.container ? 0
-               : Math.max(0, this.top ?
-                   this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
-                   Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
-       }
-       syncClasses() {
-           if (!this.container || this.classes == this.view.themeClasses)
-               return;
-           for (let cls of this.classes.split(" "))
-               if (cls)
-                   this.container.classList.remove(cls);
-           for (let cls of (this.classes = this.view.themeClasses).split(" "))
-               if (cls)
-                   this.container.classList.add(cls);
-       }
-   }
-   function rm(node) {
-       let next = node.nextSibling;
-       node.remove();
-       return next;
-   }
-   /**
-   Opening a panel is done by providing a constructor function for
-   the panel through this facet. (The panel is closed again when its
-   constructor is no longer provided.) Values of `null` are ignored.
-   */
-   const showPanel = /*@__PURE__*/Facet.define({
-       enables: panelPlugin
-   });
-
-   /**
-   A gutter marker represents a bit of information attached to a line
-   in a specific gutter. Your own custom markers have to extend this
-   class.
-   */
-   class GutterMarker extends RangeValue {
-       /**
-       @internal
-       */
-       compare(other) {
-           return this == other || this.constructor == other.constructor && this.eq(other);
-       }
-       /**
-       Compare this marker to another marker of the same type.
-       */
-       eq(other) { return false; }
-       /**
-       Called if the marker has a `toDOM` method and its representation
-       was removed from a gutter.
-       */
-       destroy(dom) { }
-   }
-   GutterMarker.prototype.elementClass = "";
-   GutterMarker.prototype.toDOM = undefined;
-   GutterMarker.prototype.mapMode = MapMode.TrackBefore;
-   GutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;
-   GutterMarker.prototype.point = true;
-   /**
-   Facet used to add a class to all gutter elements for a given line.
-   Markers given to this facet should _only_ define an
-   [`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a
-   [`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear
-   in all gutters for the line).
-   */
-   const gutterLineClass = /*@__PURE__*/Facet.define();
-   /**
-   Facet used to add a class to all gutter elements next to a widget.
-   Should not provide widgets with a `toDOM` method.
-   */
-   const gutterWidgetClass = /*@__PURE__*/Facet.define();
-   const defaults = {
-       class: "",
-       renderEmptyElements: false,
-       elementStyle: "",
-       markers: () => RangeSet.empty,
-       lineMarker: () => null,
-       widgetMarker: () => null,
-       lineMarkerChange: null,
-       initialSpacer: null,
-       updateSpacer: null,
-       domEventHandlers: {}
-   };
-   const activeGutters = /*@__PURE__*/Facet.define();
-   /**
-   Define an editor gutter. The order in which the gutters appear is
-   determined by their extension priority.
-   */
-   function gutter(config) {
-       return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults), config))];
-   }
-   const unfixGutters = /*@__PURE__*/Facet.define({
-       combine: values => values.some(x => x)
-   });
-   /**
-   The gutter-drawing plugin is automatically enabled when you add a
-   gutter, but you can use this function to explicitly configure it.
-
-   Unless `fixed` is explicitly set to `false`, the gutters are
-   fixed, meaning they don't scroll along with the content
-   horizontally (except on Internet Explorer, which doesn't support
-   CSS [`position:
-   sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
-   */
-   function gutters(config) {
-       let result = [
-           gutterView,
-       ];
-       return result;
-   }
-   const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.prevViewport = view.viewport;
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-gutters";
-           this.dom.setAttribute("aria-hidden", "true");
-           this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
-           this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));
-           for (let gutter of this.gutters)
-               this.dom.appendChild(gutter.dom);
-           this.fixed = !view.state.facet(unfixGutters);
-           if (this.fixed) {
-               // FIXME IE11 fallback, which doesn't support position: sticky,
-               // by using position: relative + event handlers that realign the
-               // gutter (or just force fixed=false on IE11?)
-               this.dom.style.position = "sticky";
-           }
-           this.syncGutters(false);
-           view.scrollDOM.insertBefore(this.dom, view.contentDOM);
-       }
-       update(update) {
-           if (this.updateGutters(update)) {
-               // Detach during sync when the viewport changed significantly
-               // (such as during scrolling), since for large updates that is
-               // faster.
-               let vpA = this.prevViewport, vpB = update.view.viewport;
-               let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);
-               this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);
-           }
-           if (update.geometryChanged) {
-               this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
-           }
-           if (this.view.state.facet(unfixGutters) != !this.fixed) {
-               this.fixed = !this.fixed;
-               this.dom.style.position = this.fixed ? "sticky" : "";
-           }
-           this.prevViewport = update.view.viewport;
-       }
-       syncGutters(detach) {
-           let after = this.dom.nextSibling;
-           if (detach)
-               this.dom.remove();
-           let lineClasses = RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);
-           let classSet = [];
-           let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
-           for (let line of this.view.viewportLineBlocks) {
-               if (classSet.length)
-                   classSet = [];
-               if (Array.isArray(line.type)) {
-                   let first = true;
-                   for (let b of line.type) {
-                       if (b.type == BlockType.Text && first) {
-                           advanceCursor(lineClasses, classSet, b.from);
-                           for (let cx of contexts)
-                               cx.line(this.view, b, classSet);
-                           first = false;
-                       }
-                       else if (b.widget) {
-                           for (let cx of contexts)
-                               cx.widget(this.view, b);
-                       }
-                   }
-               }
-               else if (line.type == BlockType.Text) {
-                   advanceCursor(lineClasses, classSet, line.from);
-                   for (let cx of contexts)
-                       cx.line(this.view, line, classSet);
-               }
-               else if (line.widget) {
-                   for (let cx of contexts)
-                       cx.widget(this.view, line);
-               }
-           }
-           for (let cx of contexts)
-               cx.finish();
-           if (detach)
-               this.view.scrollDOM.insertBefore(this.dom, after);
-       }
-       updateGutters(update) {
-           let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);
-           let change = update.docChanged || update.heightChanged || update.viewportChanged ||
-               !RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);
-           if (prev == cur) {
-               for (let gutter of this.gutters)
-                   if (gutter.update(update))
-                       change = true;
-           }
-           else {
-               change = true;
-               let gutters = [];
-               for (let conf of cur) {
-                   let known = prev.indexOf(conf);
-                   if (known < 0) {
-                       gutters.push(new SingleGutterView(this.view, conf));
-                   }
-                   else {
-                       this.gutters[known].update(update);
-                       gutters.push(this.gutters[known]);
-                   }
-               }
-               for (let g of this.gutters) {
-                   g.dom.remove();
-                   if (gutters.indexOf(g) < 0)
-                       g.destroy();
-               }
-               for (let g of gutters)
-                   this.dom.appendChild(g.dom);
-               this.gutters = gutters;
-           }
-           return change;
-       }
-       destroy() {
-           for (let view of this.gutters)
-               view.destroy();
-           this.dom.remove();
-       }
-   }, {
-       provide: plugin => EditorView.scrollMargins.of(view => {
-           let value = view.plugin(plugin);
-           if (!value || value.gutters.length == 0 || !value.fixed)
-               return null;
-           return view.textDirection == Direction.LTR
-               ? { left: value.dom.offsetWidth * view.scaleX }
-               : { right: value.dom.offsetWidth * view.scaleX };
-       })
-   });
-   function asArray(val) { return (Array.isArray(val) ? val : [val]); }
-   function advanceCursor(cursor, collect, pos) {
-       while (cursor.value && cursor.from <= pos) {
-           if (cursor.from == pos)
-               collect.push(cursor.value);
-           cursor.next();
-       }
-   }
-   class UpdateContext {
-       constructor(gutter, viewport, height) {
-           this.gutter = gutter;
-           this.height = height;
-           this.i = 0;
-           this.cursor = RangeSet.iter(gutter.markers, viewport.from);
-       }
-       addElement(view, block, markers) {
-           let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;
-           if (this.i == gutter.elements.length) {
-               let newElt = new GutterElement(view, height, above, markers);
-               gutter.elements.push(newElt);
-               gutter.dom.appendChild(newElt.dom);
-           }
-           else {
-               gutter.elements[this.i].update(view, height, above, markers);
-           }
-           this.height = block.bottom;
-           this.i++;
-       }
-       line(view, line, extraMarkers) {
-           let localMarkers = [];
-           advanceCursor(this.cursor, localMarkers, line.from);
-           if (extraMarkers.length)
-               localMarkers = localMarkers.concat(extraMarkers);
-           let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
-           if (forLine)
-               localMarkers.unshift(forLine);
-           let gutter = this.gutter;
-           if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
-               return;
-           this.addElement(view, line, localMarkers);
-       }
-       widget(view, block) {
-           let marker = this.gutter.config.widgetMarker(view, block.widget, block), markers = marker ? [marker] : null;
-           for (let cls of view.state.facet(gutterWidgetClass)) {
-               let marker = cls(view, block.widget, block);
-               if (marker)
-                   (markers || (markers = [])).push(marker);
-           }
-           if (markers)
-               this.addElement(view, block, markers);
-       }
-       finish() {
-           let gutter = this.gutter;
-           while (gutter.elements.length > this.i) {
-               let last = gutter.elements.pop();
-               gutter.dom.removeChild(last.dom);
-               last.destroy();
-           }
-       }
-   }
-   class SingleGutterView {
-       constructor(view, config) {
-           this.view = view;
-           this.config = config;
-           this.elements = [];
-           this.spacer = null;
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
-           for (let prop in config.domEventHandlers) {
-               this.dom.addEventListener(prop, (event) => {
-                   let target = event.target, y;
-                   if (target != this.dom && this.dom.contains(target)) {
-                       while (target.parentNode != this.dom)
-                           target = target.parentNode;
-                       let rect = target.getBoundingClientRect();
-                       y = (rect.top + rect.bottom) / 2;
-                   }
-                   else {
-                       y = event.clientY;
-                   }
-                   let line = view.lineBlockAtHeight(y - view.documentTop);
-                   if (config.domEventHandlers[prop](view, line, event))
-                       event.preventDefault();
-               });
-           }
-           this.markers = asArray(config.markers(view));
-           if (config.initialSpacer) {
-               this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);
-               this.dom.appendChild(this.spacer.dom);
-               this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none";
-           }
-       }
-       update(update) {
-           let prevMarkers = this.markers;
-           this.markers = asArray(this.config.markers(update.view));
-           if (this.spacer && this.config.updateSpacer) {
-               let updated = this.config.updateSpacer(this.spacer.markers[0], update);
-               if (updated != this.spacer.markers[0])
-                   this.spacer.update(update.view, 0, 0, [updated]);
-           }
-           let vp = update.view.viewport;
-           return !RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||
-               (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);
-       }
-       destroy() {
-           for (let elt of this.elements)
-               elt.destroy();
-       }
-   }
-   class GutterElement {
-       constructor(view, height, above, markers) {
-           this.height = -1;
-           this.above = 0;
-           this.markers = [];
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-gutterElement";
-           this.update(view, height, above, markers);
-       }
-       update(view, height, above, markers) {
-           if (this.height != height) {
-               this.height = height;
-               this.dom.style.height = height + "px";
-           }
-           if (this.above != above)
-               this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
-           if (!sameMarkers(this.markers, markers))
-               this.setMarkers(view, markers);
-       }
-       setMarkers(view, markers) {
-           let cls = "cm-gutterElement", domPos = this.dom.firstChild;
-           for (let iNew = 0, iOld = 0;;) {
-               let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;
-               if (marker) {
-                   let c = marker.elementClass;
-                   if (c)
-                       cls += " " + c;
-                   for (let i = iOld; i < this.markers.length; i++)
-                       if (this.markers[i].compare(marker)) {
-                           skipTo = i;
-                           matched = true;
-                           break;
-                       }
-               }
-               else {
-                   skipTo = this.markers.length;
-               }
-               while (iOld < skipTo) {
-                   let next = this.markers[iOld++];
-                   if (next.toDOM) {
-                       next.destroy(domPos);
-                       let after = domPos.nextSibling;
-                       domPos.remove();
-                       domPos = after;
-                   }
-               }
-               if (!marker)
-                   break;
-               if (marker.toDOM) {
-                   if (matched)
-                       domPos = domPos.nextSibling;
-                   else
-                       this.dom.insertBefore(marker.toDOM(view), domPos);
-               }
-               if (matched)
-                   iOld++;
-           }
-           this.dom.className = cls;
-           this.markers = markers;
-       }
-       destroy() {
-           this.setMarkers(null, []); // First argument not used unless creating markers
-       }
-   }
-   function sameMarkers(a, b) {
-       if (a.length != b.length)
-           return false;
-       for (let i = 0; i < a.length; i++)
-           if (!a[i].compare(b[i]))
-               return false;
-       return true;
-   }
-   /**
-   Facet used to provide markers to the line number gutter.
-   */
-   const lineNumberMarkers = /*@__PURE__*/Facet.define();
-   /**
-   Facet used to create markers in the line number gutter next to widgets.
-   */
-   const lineNumberWidgetMarker = /*@__PURE__*/Facet.define();
-   const lineNumberConfig = /*@__PURE__*/Facet.define({
-       combine(values) {
-           return combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {
-               domEventHandlers(a, b) {
-                   let result = Object.assign({}, a);
-                   for (let event in b) {
-                       let exists = result[event], add = b[event];
-                       result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;
-                   }
-                   return result;
-               }
-           });
-       }
-   });
-   class NumberMarker extends GutterMarker {
-       constructor(number) {
-           super();
-           this.number = number;
-       }
-       eq(other) { return this.number == other.number; }
-       toDOM() { return document.createTextNode(this.number); }
-   }
-   function formatNumber(view, number) {
-       return view.state.facet(lineNumberConfig).formatNumber(number, view.state);
-   }
-   const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({
-       class: "cm-lineNumbers",
-       renderEmptyElements: false,
-       markers(view) { return view.state.facet(lineNumberMarkers); },
-       lineMarker(view, line, others) {
-           if (others.some(m => m.toDOM))
-               return null;
-           return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
-       },
-       widgetMarker: (view, widget, block) => {
-           for (let m of view.state.facet(lineNumberWidgetMarker)) {
-               let result = m(view, widget, block);
-               if (result)
-                   return result;
-           }
-           return null;
-       },
-       lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
-       initialSpacer(view) {
-           return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
-       },
-       updateSpacer(spacer, update) {
-           let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
-           return max == spacer.number ? spacer : new NumberMarker(max);
-       },
-       domEventHandlers: state.facet(lineNumberConfig).domEventHandlers
-   }));
-   /**
-   Create a line number gutter extension.
-   */
-   function lineNumbers(config = {}) {
-       return [
-           lineNumberConfig.of(config),
-           gutters(),
-           lineNumberGutter
-       ];
-   }
-   function maxLineNumber(lines) {
-       let last = 9;
-       while (last < lines)
-           last = last * 10 + 9;
-       return last;
-   }
-
-   var _a;
-   /**
-   Node prop stored in a parser's top syntax node to provide the
-   facet that stores language-specific data for that language.
-   */
-   const languageDataProp = /*@__PURE__*/new NodeProp();
-   /**
-   Helper function to define a facet (to be added to the top syntax
-   node(s) for a language via
-   [`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be
-   used to associate language data with the language. You
-   probably only need this when subclassing
-   [`Language`](https://codemirror.net/6/docs/ref/#language.Language).
-   */
-   function defineLanguageFacet(baseData) {
-       return Facet.define({
-           combine: baseData ? values => values.concat(baseData) : undefined
-       });
-   }
-   /**
-   Syntax node prop used to register sublanguages. Should be added to
-   the top level node type for the language.
-   */
-   const sublanguageProp = /*@__PURE__*/new NodeProp();
-   /**
-   A language object manages parsing and per-language
-   [metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is
-   managed as a [Lezer](https://lezer.codemirror.net) tree. The class
-   can be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)
-   subclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or
-   via the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass
-   for stream parsers.
-   */
-   class Language {
-       /**
-       Construct a language object. If you need to invoke this
-       directly, first define a data facet with
-       [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
-       configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
-       to the language's outer syntax node.
-       */
-       constructor(
-       /**
-       The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet
-       used for this language.
-       */
-       data, parser, extraExtensions = [], 
-       /**
-       A language name.
-       */
-       name = "") {
-           this.data = data;
-           this.name = name;
-           // Kludge to define EditorState.tree as a debugging helper,
-           // without the EditorState package actually knowing about
-           // languages and lezer trees.
-           if (!EditorState.prototype.hasOwnProperty("tree"))
-               Object.defineProperty(EditorState.prototype, "tree", { get() { return syntaxTree(this); } });
-           this.parser = parser;
-           this.extension = [
-               language.of(this),
-               EditorState.languageData.of((state, pos, side) => {
-                   let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);
-                   if (!data)
-                       return [];
-                   let base = state.facet(data), sub = top.type.prop(sublanguageProp);
-                   if (sub) {
-                       let innerNode = top.resolve(pos - top.from, side);
-                       for (let sublang of sub)
-                           if (sublang.test(innerNode, state)) {
-                               let data = state.facet(sublang.facet);
-                               return sublang.type == "replace" ? data : data.concat(base);
-                           }
-                   }
-                   return base;
-               })
-           ].concat(extraExtensions);
-       }
-       /**
-       Query whether this language is active at the given position.
-       */
-       isActiveAt(state, pos, side = -1) {
-           return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;
-       }
-       /**
-       Find the document regions that were parsed using this language.
-       The returned regions will _include_ any nested languages rooted
-       in this language, when those exist.
-       */
-       findRegions(state) {
-           let lang = state.facet(language);
-           if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)
-               return [{ from: 0, to: state.doc.length }];
-           if (!lang || !lang.allowsNesting)
-               return [];
-           let result = [];
-           let explore = (tree, from) => {
-               if (tree.prop(languageDataProp) == this.data) {
-                   result.push({ from, to: from + tree.length });
-                   return;
-               }
-               let mount = tree.prop(NodeProp.mounted);
-               if (mount) {
-                   if (mount.tree.prop(languageDataProp) == this.data) {
-                       if (mount.overlay)
-                           for (let r of mount.overlay)
-                               result.push({ from: r.from + from, to: r.to + from });
-                       else
-                           result.push({ from: from, to: from + tree.length });
-                       return;
-                   }
-                   else if (mount.overlay) {
-                       let size = result.length;
-                       explore(mount.tree, mount.overlay[0].from + from);
-                       if (result.length > size)
-                           return;
-                   }
-               }
-               for (let i = 0; i < tree.children.length; i++) {
-                   let ch = tree.children[i];
-                   if (ch instanceof Tree)
-                       explore(ch, tree.positions[i] + from);
-               }
-           };
-           explore(syntaxTree(state), 0);
-           return result;
-       }
-       /**
-       Indicates whether this language allows nested languages. The
-       default implementation returns true.
-       */
-       get allowsNesting() { return true; }
-   }
-   /**
-   @internal
-   */
-   Language.setState = /*@__PURE__*/StateEffect.define();
-   function topNodeAt(state, pos, side) {
-       let topLang = state.facet(language), tree = syntaxTree(state).topNode;
-       if (!topLang || topLang.allowsNesting) {
-           for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers))
-               if (node.type.isTop)
-                   tree = node;
-       }
-       return tree;
-   }
-   /**
-   A subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer
-   [LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)
-   parsers.
-   */
-   class LRLanguage extends Language {
-       constructor(data, parser, name) {
-           super(data, parser, [], name);
-           this.parser = parser;
-       }
-       /**
-       Define a language from a parser.
-       */
-       static define(spec) {
-           let data = defineLanguageFacet(spec.languageData);
-           return new LRLanguage(data, spec.parser.configure({
-               props: [languageDataProp.add(type => type.isTop ? data : undefined)]
-           }), spec.name);
-       }
-       /**
-       Create a new instance of this language with a reconfigured
-       version of its parser and optionally a new name.
-       */
-       configure(options, name) {
-           return new LRLanguage(this.data, this.parser.configure(options), name || this.name);
-       }
-       get allowsNesting() { return this.parser.hasWrappers(); }
-   }
-   /**
-   Get the syntax tree for a state, which is the current (possibly
-   incomplete) parse tree of the active
-   [language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no
-   language available.
-   */
-   function syntaxTree(state) {
-       let field = state.field(Language.state, false);
-       return field ? field.tree : Tree.empty;
-   }
-   /**
-   Lezer-style
-   [`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
-   object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
-   */
-   class DocInput {
-       /**
-       Create an input object for the given document.
-       */
-       constructor(doc) {
-           this.doc = doc;
-           this.cursorPos = 0;
-           this.string = "";
-           this.cursor = doc.iter();
-       }
-       get length() { return this.doc.length; }
-       syncTo(pos) {
-           this.string = this.cursor.next(pos - this.cursorPos).value;
-           this.cursorPos = pos + this.string.length;
-           return this.cursorPos - this.string.length;
-       }
-       chunk(pos) {
-           this.syncTo(pos);
-           return this.string;
-       }
-       get lineChunks() { return true; }
-       read(from, to) {
-           let stringStart = this.cursorPos - this.string.length;
-           if (from < stringStart || to >= this.cursorPos)
-               return this.doc.sliceString(from, to);
-           else
-               return this.string.slice(from - stringStart, to - stringStart);
-       }
-   }
-   let currentContext = null;
-   /**
-   A parse context provided to parsers working on the editor content.
-   */
-   class ParseContext {
-       constructor(parser, 
-       /**
-       The current editor state.
-       */
-       state, 
-       /**
-       Tree fragments that can be reused by incremental re-parses.
-       */
-       fragments = [], 
-       /**
-       @internal
-       */
-       tree, 
-       /**
-       @internal
-       */
-       treeLen, 
-       /**
-       The current editor viewport (or some overapproximation
-       thereof). Intended to be used for opportunistically avoiding
-       work (in which case
-       [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)
-       should be called to make sure the parser is restarted when the
-       skipped region becomes visible).
-       */
-       viewport, 
-       /**
-       @internal
-       */
-       skipped, 
-       /**
-       This is where skipping parsers can register a promise that,
-       when resolved, will schedule a new parse. It is cleared when
-       the parse worker picks up the promise. @internal
-       */
-       scheduleOn) {
-           this.parser = parser;
-           this.state = state;
-           this.fragments = fragments;
-           this.tree = tree;
-           this.treeLen = treeLen;
-           this.viewport = viewport;
-           this.skipped = skipped;
-           this.scheduleOn = scheduleOn;
-           this.parse = null;
-           /**
-           @internal
-           */
-           this.tempSkipped = [];
-       }
-       /**
-       @internal
-       */
-       static create(parser, state, viewport) {
-           return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
-       }
-       startParse() {
-           return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
-       }
-       /**
-       @internal
-       */
-       work(until, upto) {
-           if (upto != null && upto >= this.state.doc.length)
-               upto = undefined;
-           if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {
-               this.takeTree();
-               return true;
-           }
-           return this.withContext(() => {
-               var _a;
-               if (typeof until == "number") {
-                   let endTime = Date.now() + until;
-                   until = () => Date.now() > endTime;
-               }
-               if (!this.parse)
-                   this.parse = this.startParse();
-               if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&
-                   upto < this.state.doc.length)
-                   this.parse.stopAt(upto);
-               for (;;) {
-                   let done = this.parse.advance();
-                   if (done) {
-                       this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));
-                       this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;
-                       this.tree = done;
-                       this.parse = null;
-                       if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))
-                           this.parse = this.startParse();
-                       else
-                           return true;
-                   }
-                   if (until())
-                       return false;
-               }
-           });
-       }
-       /**
-       @internal
-       */
-       takeTree() {
-           let pos, tree;
-           if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {
-               if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)
-                   this.parse.stopAt(pos);
-               this.withContext(() => { while (!(tree = this.parse.advance())) { } });
-               this.treeLen = pos;
-               this.tree = tree;
-               this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));
-               this.parse = null;
-           }
-       }
-       withContext(f) {
-           let prev = currentContext;
-           currentContext = this;
-           try {
-               return f();
-           }
-           finally {
-               currentContext = prev;
-           }
-       }
-       withoutTempSkipped(fragments) {
-           for (let r; r = this.tempSkipped.pop();)
-               fragments = cutFragments(fragments, r.from, r.to);
-           return fragments;
-       }
-       /**
-       @internal
-       */
-       changes(changes, newState) {
-           let { fragments, tree, treeLen, viewport, skipped } = this;
-           this.takeTree();
-           if (!changes.empty) {
-               let ranges = [];
-               changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));
-               fragments = TreeFragment.applyChanges(fragments, ranges);
-               tree = Tree.empty;
-               treeLen = 0;
-               viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };
-               if (this.skipped.length) {
-                   skipped = [];
-                   for (let r of this.skipped) {
-                       let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);
-                       if (from < to)
-                           skipped.push({ from, to });
-                   }
-               }
-           }
-           return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);
-       }
-       /**
-       @internal
-       */
-       updateViewport(viewport) {
-           if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)
-               return false;
-           this.viewport = viewport;
-           let startLen = this.skipped.length;
-           for (let i = 0; i < this.skipped.length; i++) {
-               let { from, to } = this.skipped[i];
-               if (from < viewport.to && to > viewport.from) {
-                   this.fragments = cutFragments(this.fragments, from, to);
-                   this.skipped.splice(i--, 1);
-               }
-           }
-           if (this.skipped.length >= startLen)
-               return false;
-           this.reset();
-           return true;
-       }
-       /**
-       @internal
-       */
-       reset() {
-           if (this.parse) {
-               this.takeTree();
-               this.parse = null;
-           }
-       }
-       /**
-       Notify the parse scheduler that the given region was skipped
-       because it wasn't in view, and the parse should be restarted
-       when it comes into view.
-       */
-       skipUntilInView(from, to) {
-           this.skipped.push({ from, to });
-       }
-       /**
-       Returns a parser intended to be used as placeholder when
-       asynchronously loading a nested parser. It'll skip its input and
-       mark it as not-really-parsed, so that the next update will parse
-       it again.
-       
-       When `until` is given, a reparse will be scheduled when that
-       promise resolves.
-       */
-       static getSkippingParser(until) {
-           return new class extends Parser {
-               createParse(input, fragments, ranges) {
-                   let from = ranges[0].from, to = ranges[ranges.length - 1].to;
-                   let parser = {
-                       parsedPos: from,
-                       advance() {
-                           let cx = currentContext;
-                           if (cx) {
-                               for (let r of ranges)
-                                   cx.tempSkipped.push(r);
-                               if (until)
-                                   cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;
-                           }
-                           this.parsedPos = to;
-                           return new Tree(NodeType.none, [], [], to - from);
-                       },
-                       stoppedAt: null,
-                       stopAt() { }
-                   };
-                   return parser;
-               }
-           };
-       }
-       /**
-       @internal
-       */
-       isDone(upto) {
-           upto = Math.min(upto, this.state.doc.length);
-           let frags = this.fragments;
-           return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;
-       }
-       /**
-       Get the context for the current parse, or `null` if no editor
-       parse is in progress.
-       */
-       static get() { return currentContext; }
-   }
-   function cutFragments(fragments, from, to) {
-       return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);
-   }
-   class LanguageState {
-       constructor(
-       // A mutable parse state that is used to preserve work done during
-       // the lifetime of a state when moving to the next state.
-       context) {
-           this.context = context;
-           this.tree = context.tree;
-       }
-       apply(tr) {
-           if (!tr.docChanged && this.tree == this.context.tree)
-               return this;
-           let newCx = this.context.changes(tr.changes, tr.state);
-           // If the previous parse wasn't done, go forward only up to its
-           // end position or the end of the viewport, to avoid slowing down
-           // state updates with parse work beyond the viewport.
-           let upto = this.context.treeLen == tr.startState.doc.length ? undefined
-               : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);
-           if (!newCx.work(20 /* Work.Apply */, upto))
-               newCx.takeTree();
-           return new LanguageState(newCx);
-       }
-       static init(state) {
-           let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);
-           let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
-           if (!parseState.work(20 /* Work.Apply */, vpTo))
-               parseState.takeTree();
-           return new LanguageState(parseState);
-       }
-   }
-   Language.state = /*@__PURE__*/StateField.define({
-       create: LanguageState.init,
-       update(value, tr) {
-           for (let e of tr.effects)
-               if (e.is(Language.setState))
-                   return e.value;
-           if (tr.startState.facet(language) != tr.state.facet(language))
-               return LanguageState.init(tr.state);
-           return value.apply(tr);
-       }
-   });
-   let requestIdle = (callback) => {
-       let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);
-       return () => clearTimeout(timeout);
-   };
-   if (typeof requestIdleCallback != "undefined")
-       requestIdle = (callback) => {
-           let idle = -1, timeout = setTimeout(() => {
-               idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });
-           }, 100 /* Work.MinPause */);
-           return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);
-       };
-   const isInputPending = typeof navigator != "undefined" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)
-       ? () => navigator.scheduling.isInputPending() : null;
-   const parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {
-       constructor(view) {
-           this.view = view;
-           this.working = null;
-           this.workScheduled = 0;
-           // End of the current time chunk
-           this.chunkEnd = -1;
-           // Milliseconds of budget left for this chunk
-           this.chunkBudget = -1;
-           this.work = this.work.bind(this);
-           this.scheduleWork();
-       }
-       update(update) {
-           let cx = this.view.state.field(Language.state).context;
-           if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)
-               this.scheduleWork();
-           if (update.docChanged || update.selectionSet) {
-               if (this.view.hasFocus)
-                   this.chunkBudget += 50 /* Work.ChangeBonus */;
-               this.scheduleWork();
-           }
-           this.checkAsyncSchedule(cx);
-       }
-       scheduleWork() {
-           if (this.working)
-               return;
-           let { state } = this.view, field = state.field(Language.state);
-           if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))
-               this.working = requestIdle(this.work);
-       }
-       work(deadline) {
-           this.working = null;
-           let now = Date.now();
-           if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk
-               this.chunkEnd = now + 30000 /* Work.ChunkTime */;
-               this.chunkBudget = 3000 /* Work.ChunkBudget */;
-           }
-           if (this.chunkBudget <= 0)
-               return; // No more budget
-           let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);
-           if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))
-               return;
-           let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);
-           let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;
-           let done = field.context.work(() => {
-               return isInputPending && isInputPending() || Date.now() > endTime;
-           }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));
-           this.chunkBudget -= Date.now() - now;
-           if (done || this.chunkBudget <= 0) {
-               field.context.takeTree();
-               this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });
-           }
-           if (this.chunkBudget > 0 && !(done && !viewportFirst))
-               this.scheduleWork();
-           this.checkAsyncSchedule(field.context);
-       }
-       checkAsyncSchedule(cx) {
-           if (cx.scheduleOn) {
-               this.workScheduled++;
-               cx.scheduleOn
-                   .then(() => this.scheduleWork())
-                   .catch(err => logException(this.view.state, err))
-                   .then(() => this.workScheduled--);
-               cx.scheduleOn = null;
-           }
-       }
-       destroy() {
-           if (this.working)
-               this.working();
-       }
-       isWorking() {
-           return !!(this.working || this.workScheduled > 0);
-       }
-   }, {
-       eventHandlers: { focus() { this.scheduleWork(); } }
-   });
-   /**
-   The facet used to associate a language with an editor state. Used
-   by `Language` object's `extension` property (so you don't need to
-   manually wrap your languages in this). Can be used to access the
-   current language on a state.
-   */
-   const language = /*@__PURE__*/Facet.define({
-       combine(languages) { return languages.length ? languages[0] : null; },
-       enables: language => [
-           Language.state,
-           parseWorker,
-           EditorView.contentAttributes.compute([language], state => {
-               let lang = state.facet(language);
-               return lang && lang.name ? { "data-language": lang.name } : {};
-           })
-       ]
-   });
-   /**
-   This class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an
-   optional set of supporting extensions. Language packages are
-   encouraged to export a function that optionally takes a
-   configuration object and returns a `LanguageSupport` instance, as
-   the main way for client code to use the package.
-   */
-   class LanguageSupport {
-       /**
-       Create a language support object.
-       */
-       constructor(
-       /**
-       The language object.
-       */
-       language, 
-       /**
-       An optional set of supporting extensions. When nesting a
-       language in another language, the outer language is encouraged
-       to include the supporting extensions for its inner languages
-       in its own set of support extensions.
-       */
-       support = []) {
-           this.language = language;
-           this.support = support;
-           this.extension = [language, support];
-       }
-   }
-   /**
-   Facet for overriding the unit by which indentation happens. Should
-   be a string consisting either entirely of the same whitespace
-   character. When not set, this defaults to 2 spaces.
-   */
-   const indentUnit = /*@__PURE__*/Facet.define({
-       combine: values => {
-           if (!values.length)
-               return "  ";
-           let unit = values[0];
-           if (!unit || /\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))
-               throw new Error("Invalid indent unit: " + JSON.stringify(values[0]));
-           return unit;
-       }
-   });
-   /**
-   A syntax tree node prop used to associate indentation strategies
-   with node types. Such a strategy is a function from an indentation
-   context to a column number (see also
-   [`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null
-   indicates that no definitive indentation can be determined.
-   */
-   const indentNodeProp = /*@__PURE__*/new NodeProp();
-   // Check whether a delimited node is aligned (meaning there are
-   // non-skipped nodes on the same line as the opening delimiter). And
-   // if so, return the opening token.
-   function bracketedAligned(context) {
-       let tree = context.node;
-       let openToken = tree.childAfter(tree.from), last = tree.lastChild;
-       if (!openToken)
-           return null;
-       let sim = context.options.simulateBreak;
-       let openLine = context.state.doc.lineAt(openToken.from);
-       let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);
-       for (let pos = openToken.to;;) {
-           let next = tree.childAfter(pos);
-           if (!next || next == last)
-               return null;
-           if (!next.type.isSkipped) {
-               if (next.from >= lineEnd)
-                   return null;
-               let space = /^ */.exec(openLine.text.slice(openToken.to - openLine.from))[0].length;
-               return { from: openToken.from, to: openToken.to + space };
-           }
-           pos = next.to;
-       }
-   }
-   /**
-   An indentation strategy for delimited (usually bracketed) nodes.
-   Will, by default, indent one unit more than the parent's base
-   indent unless the line starts with a closing token. When `align`
-   is true and there are non-skipped nodes on the node's opening
-   line, the content of the node will be aligned with the end of the
-   opening node, like this:
-
-       foo(bar,
-           baz)
-   */
-   function delimitedIndent({ closing, align = true, units = 1 }) {
-       return (context) => delimitedStrategy(context, align, units, closing);
-   }
-   function delimitedStrategy(context, align, units, closing, closedAt) {
-       let after = context.textAfter, space = after.match(/^\s*/)[0].length;
-       let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;
-       let aligned = align ? bracketedAligned(context) : null;
-       if (aligned)
-           return closed ? context.column(aligned.from) : context.column(aligned.to);
-       return context.baseIndent + (closed ? 0 : context.unit * units);
-   }
-   /**
-   An indentation strategy that aligns a node's content to its base
-   indentation.
-   */
-   const flatIndent = (context) => context.baseIndent;
-   /**
-   Creates an indentation strategy that, by default, indents
-   continued lines one unit more than the node's base indentation.
-   You can provide `except` to prevent indentation of lines that
-   match a pattern (for example `/^else\b/` in `if`/`else`
-   constructs), and you can change the amount of units used with the
-   `units` option.
-   */
-   function continuedIndent({ except, units = 1 } = {}) {
-       return (context) => {
-           let matchExcept = except && except.test(context.textAfter);
-           return context.baseIndent + (matchExcept ? 0 : units * context.unit);
-       };
-   }
-   /**
-   This node prop is used to associate folding information with
-   syntax node types. Given a syntax node, it should check whether
-   that tree is foldable and return the range that can be collapsed
-   when it is.
-   */
-   const foldNodeProp = /*@__PURE__*/new NodeProp();
-   /**
-   [Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but
-   the first and the last child of a syntax node. Useful for nodes
-   that start and end with delimiters.
-   */
-   function foldInside(node) {
-       let first = node.firstChild, last = node.lastChild;
-       return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;
-   }
-
-   /**
-   A highlight style associates CSS styles with higlighting
-   [tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).
-   */
-   class HighlightStyle {
-       constructor(
-       /**
-       The tag styles used to create this highlight style.
-       */
-       specs, options) {
-           this.specs = specs;
-           let modSpec;
-           function def(spec) {
-               let cls = StyleModule.newName();
-               (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
-               return cls;
-           }
-           const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
-           const scopeOpt = options.scope;
-           this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
-               : scopeOpt ? (type) => type == scopeOpt : undefined;
-           this.style = tagHighlighter(specs.map(style => ({
-               tag: style.tag,
-               class: style.class || def(Object.assign({}, style, { tag: null }))
-           })), {
-               all,
-           }).style;
-           this.module = modSpec ? new StyleModule(modSpec) : null;
-           this.themeType = options.themeType;
-       }
-       /**
-       Create a highlighter style that associates the given styles to
-       the given tags. The specs must be objects that hold a style tag
-       or array of tags in their `tag` property, and either a single
-       `class` property providing a static CSS class (for highlighter
-       that rely on external styling), or a
-       [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
-       set of CSS properties (which define the styling for those tags).
-       
-       The CSS rules created for a highlighter will be emitted in the
-       order of the spec's properties. That means that for elements that
-       have multiple tags associated with them, styles defined further
-       down in the list will have a higher CSS precedence than styles
-       defined earlier.
-       */
-       static define(specs, options) {
-           return new HighlightStyle(specs, options || {});
-       }
-   }
-   const highlighterFacet = /*@__PURE__*/Facet.define();
-   const fallbackHighlighter = /*@__PURE__*/Facet.define({
-       combine(values) { return values.length ? [values[0]] : null; }
-   });
-   function getHighlighters(state) {
-       let main = state.facet(highlighterFacet);
-       return main.length ? main : state.facet(fallbackHighlighter);
-   }
-   /**
-   Wrap a highlighter in an editor extension that uses it to apply
-   syntax highlighting to the editor content.
-
-   When multiple (non-fallback) styles are provided, the styling
-   applied is the union of the classes they emit.
-   */
-   function syntaxHighlighting(highlighter, options) {
-       let ext = [treeHighlighter], themeType;
-       if (highlighter instanceof HighlightStyle) {
-           if (highlighter.module)
-               ext.push(EditorView.styleModule.of(highlighter.module));
-           themeType = highlighter.themeType;
-       }
-       if (themeType)
-           ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {
-               return state.facet(EditorView.darkTheme) == (themeType == "dark") ? [highlighter] : [];
-           }));
-       else
-           ext.push(highlighterFacet.of(highlighter));
-       return ext;
-   }
-   class TreeHighlighter {
-       constructor(view) {
-           this.markCache = Object.create(null);
-           this.tree = syntaxTree(view.state);
-           this.decorations = this.buildDeco(view, getHighlighters(view.state));
-           this.decoratedTo = view.viewport.to;
-       }
-       update(update) {
-           let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);
-           let styleChange = highlighters != getHighlighters(update.startState);
-           let { viewport } = update.view, decoratedToMapped = update.changes.mapPos(this.decoratedTo, 1);
-           if (tree.length < viewport.to && !styleChange && tree.type == this.tree.type && decoratedToMapped >= viewport.to) {
-               this.decorations = this.decorations.map(update.changes);
-               this.decoratedTo = decoratedToMapped;
-           }
-           else if (tree != this.tree || update.viewportChanged || styleChange) {
-               this.tree = tree;
-               this.decorations = this.buildDeco(update.view, highlighters);
-               this.decoratedTo = viewport.to;
-           }
-       }
-       buildDeco(view, highlighters) {
-           if (!highlighters || !this.tree.length)
-               return Decoration.none;
-           let builder = new RangeSetBuilder();
-           for (let { from, to } of view.visibleRanges) {
-               highlightTree(this.tree, highlighters, (from, to, style) => {
-                   builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));
-               }, from, to);
-           }
-           return builder.finish();
-       }
-   }
-   const treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {
-       decorations: v => v.decorations
-   }));
-   /**
-   A default highlight style (works well with light themes).
-   */
-   /*@__PURE__*/HighlightStyle.define([
-       { tag: tags.meta,
-           color: "#404740" },
-       { tag: tags.link,
-           textDecoration: "underline" },
-       { tag: tags.heading,
-           textDecoration: "underline",
-           fontWeight: "bold" },
-       { tag: tags.emphasis,
-           fontStyle: "italic" },
-       { tag: tags.strong,
-           fontWeight: "bold" },
-       { tag: tags.strikethrough,
-           textDecoration: "line-through" },
-       { tag: tags.keyword,
-           color: "#708" },
-       { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],
-           color: "#219" },
-       { tag: [tags.literal, tags.inserted],
-           color: "#164" },
-       { tag: [tags.string, tags.deleted],
-           color: "#a11" },
-       { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],
-           color: "#e40" },
-       { tag: /*@__PURE__*/tags.definition(tags.variableName),
-           color: "#00f" },
-       { tag: /*@__PURE__*/tags.local(tags.variableName),
-           color: "#30a" },
-       { tag: [tags.typeName, tags.namespace],
-           color: "#085" },
-       { tag: tags.className,
-           color: "#167" },
-       { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],
-           color: "#256" },
-       { tag: /*@__PURE__*/tags.definition(tags.propertyName),
-           color: "#00c" },
-       { tag: tags.comment,
-           color: "#940" },
-       { tag: tags.invalid,
-           color: "#f00" }
-   ]);
-   const noTokens = /*@__PURE__*/Object.create(null);
-   const typeArray = [NodeType.none];
-   const warned = [];
-   // Cache of node types by name and tags
-   const byTag = /*@__PURE__*/Object.create(null);
-   const defaultTable = /*@__PURE__*/Object.create(null);
-   for (let [legacyName, name] of [
-       ["variable", "variableName"],
-       ["variable-2", "variableName.special"],
-       ["string-2", "string.special"],
-       ["def", "variableName.definition"],
-       ["tag", "tagName"],
-       ["attribute", "attributeName"],
-       ["type", "typeName"],
-       ["builtin", "variableName.standard"],
-       ["qualifier", "modifier"],
-       ["error", "invalid"],
-       ["header", "heading"],
-       ["property", "propertyName"]
-   ])
-       defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);
-   function warnForPart(part, msg) {
-       if (warned.indexOf(part) > -1)
-           return;
-       warned.push(part);
-       console.warn(msg);
-   }
-   function createTokenType(extra, tagStr) {
-       let tags$1 = [];
-       for (let name of tagStr.split(" ")) {
-           let found = [];
-           for (let part of name.split(".")) {
-               let value = (extra[part] || tags[part]);
-               if (!value) {
-                   warnForPart(part, `Unknown highlighting tag ${part}`);
-               }
-               else if (typeof value == "function") {
-                   if (!found.length)
-                       warnForPart(part, `Modifier ${part} used at start of tag`);
-                   else
-                       found = found.map(value);
-               }
-               else {
-                   if (found.length)
-                       warnForPart(part, `Tag ${part} used as modifier`);
-                   else
-                       found = Array.isArray(value) ? value : [value];
-               }
-           }
-           for (let tag of found)
-               tags$1.push(tag);
-       }
-       if (!tags$1.length)
-           return 0;
-       let name = tagStr.replace(/ /g, "_"), key = name + " " + tags$1.map(t => t.id);
-       let known = byTag[key];
-       if (known)
-           return known.id;
-       let type = byTag[key] = NodeType.define({
-           id: typeArray.length,
-           name,
-           props: [styleTags({ [name]: tags$1 })]
-       });
-       typeArray.push(type);
-       return type.id;
-   }
-   ({
-       rtl: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "rtl" }, bidiIsolate: Direction.RTL }),
-       ltr: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "ltr" }, bidiIsolate: Direction.LTR }),
-       auto: /*@__PURE__*/Decoration.mark({ class: "cm-iso", inclusive: true, attributes: { dir: "auto" }, bidiIsolate: null })
-   });
-
-   /**
-   An instance of this is passed to completion source functions.
-   */
-   class CompletionContext {
-       /**
-       Create a new completion context. (Mostly useful for testing
-       completion sources—in the editor, the extension will create
-       these for you.)
-       */
-       constructor(
-       /**
-       The editor state that the completion happens in.
-       */
-       state, 
-       /**
-       The position at which the completion is happening.
-       */
-       pos, 
-       /**
-       Indicates whether completion was activated explicitly, or
-       implicitly by typing. The usual way to respond to this is to
-       only return completions when either there is part of a
-       completable entity before the cursor, or `explicit` is true.
-       */
-       explicit, 
-       /**
-       The editor view. May be undefined if the context was created
-       in a situation where there is no such view available, such as
-       in synchronous updates via
-       [`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
-       or when called by test code.
-       */
-       view) {
-           this.state = state;
-           this.pos = pos;
-           this.explicit = explicit;
-           this.view = view;
-           /**
-           @internal
-           */
-           this.abortListeners = [];
-           /**
-           @internal
-           */
-           this.abortOnDocChange = false;
-       }
-       /**
-       Get the extent, content, and (if there is a token) type of the
-       token before `this.pos`.
-       */
-       tokenBefore(types) {
-           let token = syntaxTree(this.state).resolveInner(this.pos, -1);
-           while (token && types.indexOf(token.name) < 0)
-               token = token.parent;
-           return token ? { from: token.from, to: this.pos,
-               text: this.state.sliceDoc(token.from, this.pos),
-               type: token.type } : null;
-       }
-       /**
-       Get the match of the given expression directly before the
-       cursor.
-       */
-       matchBefore(expr) {
-           let line = this.state.doc.lineAt(this.pos);
-           let start = Math.max(line.from, this.pos - 250);
-           let str = line.text.slice(start - line.from, this.pos - line.from);
-           let found = str.search(ensureAnchor(expr, false));
-           return found < 0 ? null : { from: start + found, to: this.pos, text: str.slice(found) };
-       }
-       /**
-       Yields true when the query has been aborted. Can be useful in
-       asynchronous queries to avoid doing work that will be ignored.
-       */
-       get aborted() { return this.abortListeners == null; }
-       /**
-       Allows you to register abort handlers, which will be called when
-       the query is
-       [aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
-       
-       By default, running queries will not be aborted for regular
-       typing or backspacing, on the assumption that they are likely to
-       return a result with a
-       [`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
-       allows the result to be used after all. Passing `onDocChange:
-       true` will cause this query to be aborted for any document
-       change.
-       */
-       addEventListener(type, listener, options) {
-           if (type == "abort" && this.abortListeners) {
-               this.abortListeners.push(listener);
-               if (options && options.onDocChange)
-                   this.abortOnDocChange = true;
-           }
-       }
-   }
-   function toSet(chars) {
-       let flat = Object.keys(chars).join("");
-       let words = /\w/.test(flat);
-       if (words)
-           flat = flat.replace(/\w/g, "");
-       return `[${words ? "\\w" : ""}${flat.replace(/[^\w\s]/g, "\\$&")}]`;
-   }
-   function prefixMatch(options) {
-       let first = Object.create(null), rest = Object.create(null);
-       for (let { label } of options) {
-           first[label[0]] = true;
-           for (let i = 1; i < label.length; i++)
-               rest[label[i]] = true;
-       }
-       let source = toSet(first) + toSet(rest) + "*$";
-       return [new RegExp("^" + source), new RegExp(source)];
-   }
-   /**
-   Given a a fixed array of options, return an autocompleter that
-   completes them.
-   */
-   function completeFromList(list) {
-       let options = list.map(o => typeof o == "string" ? { label: o } : o);
-       let [validFor, match] = options.every(o => /^\w+$/.test(o.label)) ? [/\w*$/, /\w+$/] : prefixMatch(options);
-       return (context) => {
-           let token = context.matchBefore(match);
-           return token || context.explicit ? { from: token ? token.from : context.pos, options, validFor } : null;
-       };
-   }
-   /**
-   Wrap the given completion source so that it will not fire when the
-   cursor is in a syntax node with one of the given names.
-   */
-   function ifNotIn(nodes, source) {
-       return (context) => {
-           for (let pos = syntaxTree(context.state).resolveInner(context.pos, -1); pos; pos = pos.parent) {
-               if (nodes.indexOf(pos.name) > -1)
-                   return null;
-               if (pos.type.isTop)
-                   break;
-           }
-           return source(context);
-       };
-   }
-   class Option {
-       constructor(completion, source, match, score) {
-           this.completion = completion;
-           this.source = source;
-           this.match = match;
-           this.score = score;
-       }
-   }
-   function cur(state) { return state.selection.main.from; }
-   // Make sure the given regexp has a $ at its end and, if `start` is
-   // true, a ^ at its start.
-   function ensureAnchor(expr, start) {
-       var _a;
-       let { source } = expr;
-       let addStart = start && source[0] != "^", addEnd = source[source.length - 1] != "$";
-       if (!addStart && !addEnd)
-           return expr;
-       return new RegExp(`${addStart ? "^" : ""}(?:${source})${addEnd ? "$" : ""}`, (_a = expr.flags) !== null && _a !== void 0 ? _a : (expr.ignoreCase ? "i" : ""));
-   }
-   /**
-   This annotation is added to transactions that are produced by
-   picking a completion.
-   */
-   const pickedCompletion = /*@__PURE__*/Annotation.define();
-   /**
-   Helper function that returns a transaction spec which inserts a
-   completion's text in the main selection range, and any other
-   selection range that has the same text in front of it.
-   */
-   function insertCompletionText(state, text, from, to) {
-       let { main } = state.selection, fromOff = from - main.from, toOff = to - main.from;
-       return Object.assign(Object.assign({}, state.changeByRange(range => {
-           if (range != main && from != to &&
-               state.sliceDoc(range.from + fromOff, range.from + toOff) != state.sliceDoc(from, to))
-               return { range };
-           let lines = state.toText(text);
-           return {
-               changes: { from: range.from + fromOff, to: to == main.from ? range.to : range.from + toOff, insert: lines },
-               range: EditorSelection.cursor(range.from + fromOff + lines.length)
-           };
-       })), { scrollIntoView: true, userEvent: "input.complete" });
-   }
-   const SourceCache = /*@__PURE__*/new WeakMap();
-   function asSource(source) {
-       if (!Array.isArray(source))
-           return source;
-       let known = SourceCache.get(source);
-       if (!known)
-           SourceCache.set(source, known = completeFromList(source));
-       return known;
-   }
-   const startCompletionEffect = /*@__PURE__*/StateEffect.define();
-   const closeCompletionEffect = /*@__PURE__*/StateEffect.define();
-
-   // A pattern matcher for fuzzy completion matching. Create an instance
-   // once for a pattern, and then use that to match any number of
-   // completions.
-   class FuzzyMatcher {
-       constructor(pattern) {
-           this.pattern = pattern;
-           this.chars = [];
-           this.folded = [];
-           // Buffers reused by calls to `match` to track matched character
-           // positions.
-           this.any = [];
-           this.precise = [];
-           this.byWord = [];
-           this.score = 0;
-           this.matched = [];
-           for (let p = 0; p < pattern.length;) {
-               let char = codePointAt(pattern, p), size = codePointSize(char);
-               this.chars.push(char);
-               let part = pattern.slice(p, p + size), upper = part.toUpperCase();
-               this.folded.push(codePointAt(upper == part ? part.toLowerCase() : upper, 0));
-               p += size;
-           }
-           this.astral = pattern.length != this.chars.length;
-       }
-       ret(score, matched) {
-           this.score = score;
-           this.matched = matched;
-           return this;
-       }
-       // Matches a given word (completion) against the pattern (input).
-       // Will return a boolean indicating whether there was a match and,
-       // on success, set `this.score` to the score, `this.matched` to an
-       // array of `from, to` pairs indicating the matched parts of `word`.
-       //
-       // The score is a number that is more negative the worse the match
-       // is. See `Penalty` above.
-       match(word) {
-           if (this.pattern.length == 0)
-               return this.ret(-100 /* Penalty.NotFull */, []);
-           if (word.length < this.pattern.length)
-               return null;
-           let { chars, folded, any, precise, byWord } = this;
-           // For single-character queries, only match when they occur right
-           // at the start
-           if (chars.length == 1) {
-               let first = codePointAt(word, 0), firstSize = codePointSize(first);
-               let score = firstSize == word.length ? 0 : -100 /* Penalty.NotFull */;
-               if (first == chars[0]) ;
-               else if (first == folded[0])
-                   score += -200 /* Penalty.CaseFold */;
-               else
-                   return null;
-               return this.ret(score, [0, firstSize]);
-           }
-           let direct = word.indexOf(this.pattern);
-           if (direct == 0)
-               return this.ret(word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */, [0, this.pattern.length]);
-           let len = chars.length, anyTo = 0;
-           if (direct < 0) {
-               for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len;) {
-                   let next = codePointAt(word, i);
-                   if (next == chars[anyTo] || next == folded[anyTo])
-                       any[anyTo++] = i;
-                   i += codePointSize(next);
-               }
-               // No match, exit immediately
-               if (anyTo < len)
-                   return null;
-           }
-           // This tracks the extent of the precise (non-folded, not
-           // necessarily adjacent) match
-           let preciseTo = 0;
-           // Tracks whether there is a match that hits only characters that
-           // appear to be starting words. `byWordFolded` is set to true when
-           // a case folded character is encountered in such a match
-           let byWordTo = 0, byWordFolded = false;
-           // If we've found a partial adjacent match, these track its state
-           let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
-           let hasLower = /[a-z]/.test(word), wordAdjacent = true;
-           // Go over the option's text, scanning for the various kinds of matches
-           for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) {
-               let next = codePointAt(word, i);
-               if (direct < 0) {
-                   if (preciseTo < len && next == chars[preciseTo])
-                       precise[preciseTo++] = i;
-                   if (adjacentTo < len) {
-                       if (next == chars[adjacentTo] || next == folded[adjacentTo]) {
-                           if (adjacentTo == 0)
-                               adjacentStart = i;
-                           adjacentEnd = i + 1;
-                           adjacentTo++;
-                       }
-                       else {
-                           adjacentTo = 0;
-                       }
-                   }
-               }
-               let ch, type = next < 0xff
-                   ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */)
-                   : ((ch = fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */);
-               if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) {
-                   if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
-                       byWord[byWordTo++] = i;
-                   else if (byWord.length)
-                       wordAdjacent = false;
-               }
-               prevType = type;
-               i += codePointSize(next);
-           }
-           if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
-               return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word);
-           if (adjacentTo == len && adjacentStart == 0)
-               return this.ret(-200 /* Penalty.CaseFold */ - word.length + (adjacentEnd == word.length ? 0 : -100 /* Penalty.NotFull */), [0, adjacentEnd]);
-           if (direct > -1)
-               return this.ret(-700 /* Penalty.NotStart */ - word.length, [direct, direct + this.pattern.length]);
-           if (adjacentTo == len)
-               return this.ret(-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, [adjacentStart, adjacentEnd]);
-           if (byWordTo == len)
-               return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ +
-                   (wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word);
-           return chars.length == 2 ? null
-               : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word);
-       }
-       result(score, positions, word) {
-           let result = [], i = 0;
-           for (let pos of positions) {
-               let to = pos + (this.astral ? codePointSize(codePointAt(word, pos)) : 1);
-               if (i && result[i - 1] == pos)
-                   result[i - 1] = to;
-               else {
-                   result[i++] = pos;
-                   result[i++] = to;
-               }
-           }
-           return this.ret(score - word.length, result);
-       }
-   }
-   class StrictMatcher {
-       constructor(pattern) {
-           this.pattern = pattern;
-           this.matched = [];
-           this.score = 0;
-           this.folded = pattern.toLowerCase();
-       }
-       match(word) {
-           if (word.length < this.pattern.length)
-               return null;
-           let start = word.slice(0, this.pattern.length);
-           let match = start == this.pattern ? 0 : start.toLowerCase() == this.folded ? -200 /* Penalty.CaseFold */ : null;
-           if (match == null)
-               return null;
-           this.matched = [0, start.length];
-           this.score = match + (word.length == this.pattern.length ? 0 : -100 /* Penalty.NotFull */);
-           return this;
-       }
-   }
-
-   const completionConfig = /*@__PURE__*/Facet.define({
-       combine(configs) {
-           return combineConfig(configs, {
-               activateOnTyping: true,
-               activateOnCompletion: () => false,
-               activateOnTypingDelay: 100,
-               selectOnOpen: true,
-               override: null,
-               closeOnBlur: true,
-               maxRenderedOptions: 100,
-               defaultKeymap: true,
-               tooltipClass: () => "",
-               optionClass: () => "",
-               aboveCursor: false,
-               icons: true,
-               addToOptions: [],
-               positionInfo: defaultPositionInfo,
-               filterStrict: false,
-               compareCompletions: (a, b) => a.label.localeCompare(b.label),
-               interactionDelay: 75,
-               updateSyncTime: 100
-           }, {
-               defaultKeymap: (a, b) => a && b,
-               closeOnBlur: (a, b) => a && b,
-               icons: (a, b) => a && b,
-               tooltipClass: (a, b) => c => joinClass(a(c), b(c)),
-               optionClass: (a, b) => c => joinClass(a(c), b(c)),
-               addToOptions: (a, b) => a.concat(b),
-               filterStrict: (a, b) => a || b,
-           });
-       }
-   });
-   function joinClass(a, b) {
-       return a ? b ? a + " " + b : a : b;
-   }
-   function defaultPositionInfo(view, list, option, info, space, tooltip) {
-       let rtl = view.textDirection == Direction.RTL, left = rtl, narrow = false;
-       let side = "top", offset, maxWidth;
-       let spaceLeft = list.left - space.left, spaceRight = space.right - list.right;
-       let infoWidth = info.right - info.left, infoHeight = info.bottom - info.top;
-       if (left && spaceLeft < Math.min(infoWidth, spaceRight))
-           left = false;
-       else if (!left && spaceRight < Math.min(infoWidth, spaceLeft))
-           left = true;
-       if (infoWidth <= (left ? spaceLeft : spaceRight)) {
-           offset = Math.max(space.top, Math.min(option.top, space.bottom - infoHeight)) - list.top;
-           maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight);
-       }
-       else {
-           narrow = true;
-           maxWidth = Math.min(400 /* Info.Width */, (rtl ? list.right : space.right - list.left) - 30 /* Info.Margin */);
-           let spaceBelow = space.bottom - list.bottom;
-           if (spaceBelow >= infoHeight || spaceBelow > list.top) { // Below the completion
-               offset = option.bottom - list.top;
-           }
-           else { // Above it
-               side = "bottom";
-               offset = list.bottom - option.top;
-           }
-       }
-       let scaleY = (list.bottom - list.top) / tooltip.offsetHeight;
-       let scaleX = (list.right - list.left) / tooltip.offsetWidth;
-       return {
-           style: `${side}: ${offset / scaleY}px; max-width: ${maxWidth / scaleX}px`,
-           class: "cm-completionInfo-" + (narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right")
-       };
-   }
-
-   function optionContent(config) {
-       let content = config.addToOptions.slice();
-       if (config.icons)
-           content.push({
-               render(completion) {
-                   let icon = document.createElement("div");
-                   icon.classList.add("cm-completionIcon");
-                   if (completion.type)
-                       icon.classList.add(...completion.type.split(/\s+/g).map(cls => "cm-completionIcon-" + cls));
-                   icon.setAttribute("aria-hidden", "true");
-                   return icon;
-               },
-               position: 20
-           });
-       content.push({
-           render(completion, _s, _v, match) {
-               let labelElt = document.createElement("span");
-               labelElt.className = "cm-completionLabel";
-               let label = completion.displayLabel || completion.label, off = 0;
-               for (let j = 0; j < match.length;) {
-                   let from = match[j++], to = match[j++];
-                   if (from > off)
-                       labelElt.appendChild(document.createTextNode(label.slice(off, from)));
-                   let span = labelElt.appendChild(document.createElement("span"));
-                   span.appendChild(document.createTextNode(label.slice(from, to)));
-                   span.className = "cm-completionMatchedText";
-                   off = to;
-               }
-               if (off < label.length)
-                   labelElt.appendChild(document.createTextNode(label.slice(off)));
-               return labelElt;
-           },
-           position: 50
-       }, {
-           render(completion) {
-               if (!completion.detail)
-                   return null;
-               let detailElt = document.createElement("span");
-               detailElt.className = "cm-completionDetail";
-               detailElt.textContent = completion.detail;
-               return detailElt;
-           },
-           position: 80
-       });
-       return content.sort((a, b) => a.position - b.position).map(a => a.render);
-   }
-   function rangeAroundSelected(total, selected, max) {
-       if (total <= max)
-           return { from: 0, to: total };
-       if (selected < 0)
-           selected = 0;
-       if (selected <= (total >> 1)) {
-           let off = Math.floor(selected / max);
-           return { from: off * max, to: (off + 1) * max };
-       }
-       let off = Math.floor((total - selected) / max);
-       return { from: total - (off + 1) * max, to: total - off * max };
-   }
-   class CompletionTooltip {
-       constructor(view, stateField, applyCompletion) {
-           this.view = view;
-           this.stateField = stateField;
-           this.applyCompletion = applyCompletion;
-           this.info = null;
-           this.infoDestroy = null;
-           this.placeInfoReq = {
-               read: () => this.measureInfo(),
-               write: (pos) => this.placeInfo(pos),
-               key: this
-           };
-           this.space = null;
-           this.currentClass = "";
-           let cState = view.state.field(stateField);
-           let { options, selected } = cState.open;
-           let config = view.state.facet(completionConfig);
-           this.optionContent = optionContent(config);
-           this.optionClass = config.optionClass;
-           this.tooltipClass = config.tooltipClass;
-           this.range = rangeAroundSelected(options.length, selected, config.maxRenderedOptions);
-           this.dom = document.createElement("div");
-           this.dom.className = "cm-tooltip-autocomplete";
-           this.updateTooltipClass(view.state);
-           this.dom.addEventListener("mousedown", (e) => {
-               let { options } = view.state.field(stateField).open;
-               for (let dom = e.target, match; dom && dom != this.dom; dom = dom.parentNode) {
-                   if (dom.nodeName == "LI" && (match = /-(\d+)$/.exec(dom.id)) && +match[1] < options.length) {
-                       this.applyCompletion(view, options[+match[1]]);
-                       e.preventDefault();
-                       return;
-                   }
-               }
-           });
-           this.dom.addEventListener("focusout", (e) => {
-               let state = view.state.field(this.stateField, false);
-               if (state && state.tooltip && view.state.facet(completionConfig).closeOnBlur &&
-                   e.relatedTarget != view.contentDOM)
-                   view.dispatch({ effects: closeCompletionEffect.of(null) });
-           });
-           this.showOptions(options, cState.id);
-       }
-       mount() { this.updateSel(); }
-       showOptions(options, id) {
-           if (this.list)
-               this.list.remove();
-           this.list = this.dom.appendChild(this.createListBox(options, id, this.range));
-           this.list.addEventListener("scroll", () => {
-               if (this.info)
-                   this.view.requestMeasure(this.placeInfoReq);
-           });
-       }
-       update(update) {
-           var _a;
-           let cState = update.state.field(this.stateField);
-           let prevState = update.startState.field(this.stateField);
-           this.updateTooltipClass(update.state);
-           if (cState != prevState) {
-               let { options, selected, disabled } = cState.open;
-               if (!prevState.open || prevState.open.options != options) {
-                   this.range = rangeAroundSelected(options.length, selected, update.state.facet(completionConfig).maxRenderedOptions);
-                   this.showOptions(options, cState.id);
-               }
-               this.updateSel();
-               if (disabled != ((_a = prevState.open) === null || _a === void 0 ? void 0 : _a.disabled))
-                   this.dom.classList.toggle("cm-tooltip-autocomplete-disabled", !!disabled);
-           }
-       }
-       updateTooltipClass(state) {
-           let cls = this.tooltipClass(state);
-           if (cls != this.currentClass) {
-               for (let c of this.currentClass.split(" "))
-                   if (c)
-                       this.dom.classList.remove(c);
-               for (let c of cls.split(" "))
-                   if (c)
-                       this.dom.classList.add(c);
-               this.currentClass = cls;
-           }
-       }
-       positioned(space) {
-           this.space = space;
-           if (this.info)
-               this.view.requestMeasure(this.placeInfoReq);
-       }
-       updateSel() {
-           let cState = this.view.state.field(this.stateField), open = cState.open;
-           if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
-               this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
-               this.showOptions(open.options, cState.id);
-           }
-           if (this.updateSelectedOption(open.selected)) {
-               this.destroyInfo();
-               let { completion } = open.options[open.selected];
-               let { info } = completion;
-               if (!info)
-                   return;
-               let infoResult = typeof info === "string" ? document.createTextNode(info) : info(completion);
-               if (!infoResult)
-                   return;
-               if ("then" in infoResult) {
-                   infoResult.then(obj => {
-                       if (obj && this.view.state.field(this.stateField, false) == cState)
-                           this.addInfoPane(obj, completion);
-                   }).catch(e => logException(this.view.state, e, "completion info"));
-               }
-               else {
-                   this.addInfoPane(infoResult, completion);
-               }
-           }
-       }
-       addInfoPane(content, completion) {
-           this.destroyInfo();
-           let wrap = this.info = document.createElement("div");
-           wrap.className = "cm-tooltip cm-completionInfo";
-           if (content.nodeType != null) {
-               wrap.appendChild(content);
-               this.infoDestroy = null;
-           }
-           else {
-               let { dom, destroy } = content;
-               wrap.appendChild(dom);
-               this.infoDestroy = destroy || null;
-           }
-           this.dom.appendChild(wrap);
-           this.view.requestMeasure(this.placeInfoReq);
-       }
-       updateSelectedOption(selected) {
-           let set = null;
-           for (let opt = this.list.firstChild, i = this.range.from; opt; opt = opt.nextSibling, i++) {
-               if (opt.nodeName != "LI" || !opt.id) {
-                   i--; // A section header
-               }
-               else if (i == selected) {
-                   if (!opt.hasAttribute("aria-selected")) {
-                       opt.setAttribute("aria-selected", "true");
-                       set = opt;
-                   }
-               }
-               else {
-                   if (opt.hasAttribute("aria-selected"))
-                       opt.removeAttribute("aria-selected");
-               }
-           }
-           if (set)
-               scrollIntoView(this.list, set);
-           return set;
-       }
-       measureInfo() {
-           let sel = this.dom.querySelector("[aria-selected]");
-           if (!sel || !this.info)
-               return null;
-           let listRect = this.dom.getBoundingClientRect();
-           let infoRect = this.info.getBoundingClientRect();
-           let selRect = sel.getBoundingClientRect();
-           let space = this.space;
-           if (!space) {
-               let win = this.dom.ownerDocument.defaultView || window;
-               space = { left: 0, top: 0, right: win.innerWidth, bottom: win.innerHeight };
-           }
-           if (selRect.top > Math.min(space.bottom, listRect.bottom) - 10 ||
-               selRect.bottom < Math.max(space.top, listRect.top) + 10)
-               return null;
-           return this.view.state.facet(completionConfig).positionInfo(this.view, listRect, selRect, infoRect, space, this.dom);
-       }
-       placeInfo(pos) {
-           if (this.info) {
-               if (pos) {
-                   if (pos.style)
-                       this.info.style.cssText = pos.style;
-                   this.info.className = "cm-tooltip cm-completionInfo " + (pos.class || "");
-               }
-               else {
-                   this.info.style.cssText = "top: -1e6px";
-               }
-           }
-       }
-       createListBox(options, id, range) {
-           const ul = document.createElement("ul");
-           ul.id = id;
-           ul.setAttribute("role", "listbox");
-           ul.setAttribute("aria-expanded", "true");
-           ul.setAttribute("aria-label", this.view.state.phrase("Completions"));
-           let curSection = null;
-           for (let i = range.from; i < range.to; i++) {
-               let { completion, match } = options[i], { section } = completion;
-               if (section) {
-                   let name = typeof section == "string" ? section : section.name;
-                   if (name != curSection && (i > range.from || range.from == 0)) {
-                       curSection = name;
-                       if (typeof section != "string" && section.header) {
-                           ul.appendChild(section.header(section));
-                       }
-                       else {
-                           let header = ul.appendChild(document.createElement("completion-section"));
-                           header.textContent = name;
-                       }
-                   }
-               }
-               const li = ul.appendChild(document.createElement("li"));
-               li.id = id + "-" + i;
-               li.setAttribute("role", "option");
-               let cls = this.optionClass(completion);
-               if (cls)
-                   li.className = cls;
-               for (let source of this.optionContent) {
-                   let node = source(completion, this.view.state, this.view, match);
-                   if (node)
-                       li.appendChild(node);
-               }
-           }
-           if (range.from)
-               ul.classList.add("cm-completionListIncompleteTop");
-           if (range.to < options.length)
-               ul.classList.add("cm-completionListIncompleteBottom");
-           return ul;
-       }
-       destroyInfo() {
-           if (this.info) {
-               if (this.infoDestroy)
-                   this.infoDestroy();
-               this.info.remove();
-               this.info = null;
-           }
-       }
-       destroy() {
-           this.destroyInfo();
-       }
-   }
-   function completionTooltip(stateField, applyCompletion) {
-       return (view) => new CompletionTooltip(view, stateField, applyCompletion);
-   }
-   function scrollIntoView(container, element) {
-       let parent = container.getBoundingClientRect();
-       let self = element.getBoundingClientRect();
-       let scaleY = parent.height / container.offsetHeight;
-       if (self.top < parent.top)
-           container.scrollTop -= (parent.top - self.top) / scaleY;
-       else if (self.bottom > parent.bottom)
-           container.scrollTop += (self.bottom - parent.bottom) / scaleY;
-   }
-
-   // Used to pick a preferred option when two options with the same
-   // label occur in the result.
-   function score(option) {
-       return (option.boost || 0) * 100 + (option.apply ? 10 : 0) + (option.info ? 5 : 0) +
-           (option.type ? 1 : 0);
-   }
-   function sortOptions(active, state) {
-       let options = [];
-       let sections = null;
-       let addOption = (option) => {
-           options.push(option);
-           let { section } = option.completion;
-           if (section) {
-               if (!sections)
-                   sections = [];
-               let name = typeof section == "string" ? section : section.name;
-               if (!sections.some(s => s.name == name))
-                   sections.push(typeof section == "string" ? { name } : section);
-           }
-       };
-       let conf = state.facet(completionConfig);
-       for (let a of active)
-           if (a.hasResult()) {
-               let getMatch = a.result.getMatch;
-               if (a.result.filter === false) {
-                   for (let option of a.result.options) {
-                       addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length));
-                   }
-               }
-               else {
-                   let pattern = state.sliceDoc(a.from, a.to), match;
-                   let matcher = conf.filterStrict ? new StrictMatcher(pattern) : new FuzzyMatcher(pattern);
-                   for (let option of a.result.options)
-                       if (match = matcher.match(option.label)) {
-                           let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : [];
-                           addOption(new Option(option, a.source, matched, match.score + (option.boost || 0)));
-                       }
-               }
-           }
-       if (sections) {
-           let sectionOrder = Object.create(null), pos = 0;
-           let cmp = (a, b) => { var _a, _b; return ((_a = a.rank) !== null && _a !== void 0 ? _a : 1e9) - ((_b = b.rank) !== null && _b !== void 0 ? _b : 1e9) || (a.name < b.name ? -1 : 1); };
-           for (let s of sections.sort(cmp)) {
-               pos -= 1e5;
-               sectionOrder[s.name] = pos;
-           }
-           for (let option of options) {
-               let { section } = option.completion;
-               if (section)
-                   option.score += sectionOrder[typeof section == "string" ? section : section.name];
-           }
-       }
-       let result = [], prev = null;
-       let compare = conf.compareCompletions;
-       for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) {
-           let cur = opt.completion;
-           if (!prev || prev.label != cur.label || prev.detail != cur.detail ||
-               (prev.type != null && cur.type != null && prev.type != cur.type) ||
-               prev.apply != cur.apply || prev.boost != cur.boost)
-               result.push(opt);
-           else if (score(opt.completion) > score(prev))
-               result[result.length - 1] = opt;
-           prev = opt.completion;
-       }
-       return result;
-   }
-   class CompletionDialog {
-       constructor(options, attrs, tooltip, timestamp, selected, disabled) {
-           this.options = options;
-           this.attrs = attrs;
-           this.tooltip = tooltip;
-           this.timestamp = timestamp;
-           this.selected = selected;
-           this.disabled = disabled;
-       }
-       setSelected(selected, id) {
-           return selected == this.selected || selected >= this.options.length ? this
-               : new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
-       }
-       static build(active, state, id, prev, conf, didSetActive) {
-           if (prev && !didSetActive && active.some(s => s.isPending))
-               return prev.setDisabled();
-           let options = sortOptions(active, state);
-           if (!options.length)
-               return prev && active.some(a => a.isPending) ? prev.setDisabled() : null;
-           let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;
-           if (prev && prev.selected != selected && prev.selected != -1) {
-               let selectedValue = prev.options[prev.selected].completion;
-               for (let i = 0; i < options.length; i++)
-                   if (options[i].completion == selectedValue) {
-                       selected = i;
-                       break;
-                   }
-           }
-           return new CompletionDialog(options, makeAttrs(id, selected), {
-               pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
-               create: createTooltip,
-               above: conf.aboveCursor,
-           }, prev ? prev.timestamp : Date.now(), selected, false);
-       }
-       map(changes) {
-           return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected, this.disabled);
-       }
-       setDisabled() {
-           return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true);
-       }
-   }
-   class CompletionState {
-       constructor(active, id, open) {
-           this.active = active;
-           this.id = id;
-           this.open = open;
-       }
-       static start() {
-           return new CompletionState(none, "cm-ac-" + Math.floor(Math.random() * 2e6).toString(36), null);
-       }
-       update(tr) {
-           let { state } = tr, conf = state.facet(completionConfig);
-           let sources = conf.override ||
-               state.languageDataAt("autocomplete", cur(state)).map(asSource);
-           let active = sources.map(source => {
-               let value = this.active.find(s => s.source == source) ||
-                   new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */);
-               return value.update(tr, conf);
-           });
-           if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
-               active = this.active;
-           let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect));
-           if (open && tr.docChanged)
-               open = open.map(tr.changes);
-           if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
-               !sameResults(active, this.active) || didSet)
-               open = CompletionDialog.build(active, state, this.id, open, conf, didSet);
-           else if (open && open.disabled && !active.some(a => a.isPending))
-               open = null;
-           if (!open && active.every(a => !a.isPending) && active.some(a => a.hasResult()))
-               active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
-           for (let effect of tr.effects)
-               if (effect.is(setSelectedEffect))
-                   open = open && open.setSelected(effect.value, this.id);
-           return active == this.active && open == this.open ? this : new CompletionState(active, this.id, open);
-       }
-       get tooltip() { return this.open ? this.open.tooltip : null; }
-       get attrs() { return this.open ? this.open.attrs : this.active.length ? baseAttrs : noAttrs; }
-   }
-   function sameResults(a, b) {
-       if (a == b)
-           return true;
-       for (let iA = 0, iB = 0;;) {
-           while (iA < a.length && !a[iA].hasResult())
-               iA++;
-           while (iB < b.length && !b[iB].hasResult())
-               iB++;
-           let endA = iA == a.length, endB = iB == b.length;
-           if (endA || endB)
-               return endA == endB;
-           if (a[iA++].result != b[iB++].result)
-               return false;
-       }
-   }
-   const baseAttrs = {
-       "aria-autocomplete": "list"
-   };
-   const noAttrs = {};
-   function makeAttrs(id, selected) {
-       let result = {
-           "aria-autocomplete": "list",
-           "aria-haspopup": "listbox",
-           "aria-controls": id
-       };
-       if (selected > -1)
-           result["aria-activedescendant"] = id + "-" + selected;
-       return result;
-   }
-   const none = [];
-   function getUpdateType(tr, conf) {
-       if (tr.isUserEvent("input.complete")) {
-           let completion = tr.annotation(pickedCompletion);
-           if (completion && conf.activateOnCompletion(completion))
-               return 4 /* UpdateType.Activate */ | 8 /* UpdateType.Reset */;
-       }
-       let typing = tr.isUserEvent("input.type");
-       return typing && conf.activateOnTyping ? 4 /* UpdateType.Activate */ | 1 /* UpdateType.Typing */
-           : typing ? 1 /* UpdateType.Typing */
-               : tr.isUserEvent("delete.backward") ? 2 /* UpdateType.Backspacing */
-                   : tr.selection ? 8 /* UpdateType.Reset */
-                       : tr.docChanged ? 16 /* UpdateType.ResetIfTouching */ : 0 /* UpdateType.None */;
-   }
-   class ActiveSource {
-       constructor(source, state, explicit = false) {
-           this.source = source;
-           this.state = state;
-           this.explicit = explicit;
-       }
-       hasResult() { return false; }
-       get isPending() { return this.state == 1 /* State.Pending */; }
-       update(tr, conf) {
-           let type = getUpdateType(tr, conf), value = this;
-           if ((type & 8 /* UpdateType.Reset */) || (type & 16 /* UpdateType.ResetIfTouching */) && this.touches(tr))
-               value = new ActiveSource(value.source, 0 /* State.Inactive */);
-           if ((type & 4 /* UpdateType.Activate */) && value.state == 0 /* State.Inactive */)
-               value = new ActiveSource(this.source, 1 /* State.Pending */);
-           value = value.updateFor(tr, type);
-           for (let effect of tr.effects) {
-               if (effect.is(startCompletionEffect))
-                   value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value);
-               else if (effect.is(closeCompletionEffect))
-                   value = new ActiveSource(value.source, 0 /* State.Inactive */);
-               else if (effect.is(setActiveEffect))
-                   for (let active of effect.value)
-                       if (active.source == value.source)
-                           value = active;
-           }
-           return value;
-       }
-       updateFor(tr, type) { return this.map(tr.changes); }
-       map(changes) { return this; }
-       touches(tr) {
-           return tr.changes.touchesRange(cur(tr.state));
-       }
-   }
-   class ActiveResult extends ActiveSource {
-       constructor(source, explicit, limit, result, from, to) {
-           super(source, 3 /* State.Result */, explicit);
-           this.limit = limit;
-           this.result = result;
-           this.from = from;
-           this.to = to;
-       }
-       hasResult() { return true; }
-       updateFor(tr, type) {
-           var _a;
-           if (!(type & 3 /* UpdateType.SimpleInteraction */))
-               return this.map(tr.changes);
-           let result = this.result;
-           if (result.map && !tr.changes.empty)
-               result = result.map(result, tr.changes);
-           let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1);
-           let pos = cur(tr.state);
-           if (pos > to || !result ||
-               (type & 2 /* UpdateType.Backspacing */) && (cur(tr.startState) == this.from || pos < this.limit))
-               return new ActiveSource(this.source, type & 4 /* UpdateType.Activate */ ? 1 /* State.Pending */ : 0 /* State.Inactive */);
-           let limit = tr.changes.mapPos(this.limit);
-           if (checkValid(result.validFor, tr.state, from, to))
-               return new ActiveResult(this.source, this.explicit, limit, result, from, to);
-           if (result.update &&
-               (result = result.update(result, from, to, new CompletionContext(tr.state, pos, false))))
-               return new ActiveResult(this.source, this.explicit, limit, result, result.from, (_a = result.to) !== null && _a !== void 0 ? _a : cur(tr.state));
-           return new ActiveSource(this.source, 1 /* State.Pending */, this.explicit);
-       }
-       map(mapping) {
-           if (mapping.empty)
-               return this;
-           let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
-           if (!result)
-               return new ActiveSource(this.source, 0 /* State.Inactive */);
-           return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
-       }
-       touches(tr) {
-           return tr.changes.touchesRange(this.from, this.to);
-       }
-   }
-   function checkValid(validFor, state, from, to) {
-       if (!validFor)
-           return false;
-       let text = state.sliceDoc(from, to);
-       return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text);
-   }
-   const setActiveEffect = /*@__PURE__*/StateEffect.define({
-       map(sources, mapping) { return sources.map(s => s.map(mapping)); }
-   });
-   const setSelectedEffect = /*@__PURE__*/StateEffect.define();
-   const completionState = /*@__PURE__*/StateField.define({
-       create() { return CompletionState.start(); },
-       update(value, tr) { return value.update(tr); },
-       provide: f => [
-           showTooltip.from(f, val => val.tooltip),
-           EditorView.contentAttributes.from(f, state => state.attrs)
-       ]
-   });
-   function applyCompletion(view, option) {
-       const apply = option.completion.apply || option.completion.label;
-       let result = view.state.field(completionState).active.find(a => a.source == option.source);
-       if (!(result instanceof ActiveResult))
-           return false;
-       if (typeof apply == "string")
-           view.dispatch(Object.assign(Object.assign({}, insertCompletionText(view.state, apply, result.from, result.to)), { annotations: pickedCompletion.of(option.completion) }));
-       else
-           apply(view, option.completion, result.from, result.to);
-       return true;
-   }
-   const createTooltip = /*@__PURE__*/completionTooltip(completionState, applyCompletion);
-
-   /**
-   Returns a command that moves the completion selection forward or
-   backward by the given amount.
-   */
-   function moveCompletionSelection(forward, by = "option") {
-       return (view) => {
-           let cState = view.state.field(completionState, false);
-           if (!cState || !cState.open || cState.open.disabled ||
-               Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
-               return false;
-           let step = 1, tooltip;
-           if (by == "page" && (tooltip = getTooltip(view, cState.open.tooltip)))
-               step = Math.max(2, Math.floor(tooltip.dom.offsetHeight /
-                   tooltip.dom.querySelector("li").offsetHeight) - 1);
-           let { length } = cState.open.options;
-           let selected = cState.open.selected > -1 ? cState.open.selected + step * (forward ? 1 : -1) : forward ? 0 : length - 1;
-           if (selected < 0)
-               selected = by == "page" ? 0 : length - 1;
-           else if (selected >= length)
-               selected = by == "page" ? length - 1 : 0;
-           view.dispatch({ effects: setSelectedEffect.of(selected) });
-           return true;
-       };
-   }
-   /**
-   Accept the current completion.
-   */
-   const acceptCompletion = (view) => {
-       let cState = view.state.field(completionState, false);
-       if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || cState.open.disabled ||
-           Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
-           return false;
-       return applyCompletion(view, cState.open.options[cState.open.selected]);
-   };
-   /**
-   Explicitly start autocompletion.
-   */
-   const startCompletion = (view) => {
-       let cState = view.state.field(completionState, false);
-       if (!cState)
-           return false;
-       view.dispatch({ effects: startCompletionEffect.of(true) });
-       return true;
-   };
-   /**
-   Close the currently active completion.
-   */
-   const closeCompletion = (view) => {
-       let cState = view.state.field(completionState, false);
-       if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */))
-           return false;
-       view.dispatch({ effects: closeCompletionEffect.of(null) });
-       return true;
-   };
-   class RunningQuery {
-       constructor(active, context) {
-           this.active = active;
-           this.context = context;
-           this.time = Date.now();
-           this.updates = [];
-           // Note that 'undefined' means 'not done yet', whereas 'null' means
-           // 'query returned null'.
-           this.done = undefined;
-       }
-   }
-   const MaxUpdateCount = 50, MinAbortTime = 1000;
-   const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
-       constructor(view) {
-           this.view = view;
-           this.debounceUpdate = -1;
-           this.running = [];
-           this.debounceAccept = -1;
-           this.pendingStart = false;
-           this.composing = 0 /* CompositionState.None */;
-           for (let active of view.state.field(completionState).active)
-               if (active.isPending)
-                   this.startQuery(active);
-       }
-       update(update) {
-           let cState = update.state.field(completionState);
-           let conf = update.state.facet(completionConfig);
-           if (!update.selectionSet && !update.docChanged && update.startState.field(completionState) == cState)
-               return;
-           let doesReset = update.transactions.some(tr => {
-               let type = getUpdateType(tr, conf);
-               return (type & 8 /* UpdateType.Reset */) || (tr.selection || tr.docChanged) && !(type & 3 /* UpdateType.SimpleInteraction */);
-           });
-           for (let i = 0; i < this.running.length; i++) {
-               let query = this.running[i];
-               if (doesReset ||
-                   query.context.abortOnDocChange && update.docChanged ||
-                   query.updates.length + update.transactions.length > MaxUpdateCount && Date.now() - query.time > MinAbortTime) {
-                   for (let handler of query.context.abortListeners) {
-                       try {
-                           handler();
-                       }
-                       catch (e) {
-                           logException(this.view.state, e);
-                       }
-                   }
-                   query.context.abortListeners = null;
-                   this.running.splice(i--, 1);
-               }
-               else {
-                   query.updates.push(...update.transactions);
-               }
-           }
-           if (this.debounceUpdate > -1)
-               clearTimeout(this.debounceUpdate);
-           if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect))))
-               this.pendingStart = true;
-           let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay;
-           this.debounceUpdate = cState.active.some(a => a.isPending && !this.running.some(q => q.active.source == a.source))
-               ? setTimeout(() => this.startUpdate(), delay) : -1;
-           if (this.composing != 0 /* CompositionState.None */)
-               for (let tr of update.transactions) {
-                   if (tr.isUserEvent("input.type"))
-                       this.composing = 2 /* CompositionState.Changed */;
-                   else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
-                       this.composing = 3 /* CompositionState.ChangedAndMoved */;
-               }
-       }
-       startUpdate() {
-           this.debounceUpdate = -1;
-           this.pendingStart = false;
-           let { state } = this.view, cState = state.field(completionState);
-           for (let active of cState.active) {
-               if (active.isPending && !this.running.some(r => r.active.source == active.source))
-                   this.startQuery(active);
-           }
-           if (this.running.length && cState.open && cState.open.disabled)
-               this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
-       }
-       startQuery(active) {
-           let { state } = this.view, pos = cur(state);
-           let context = new CompletionContext(state, pos, active.explicit, this.view);
-           let pending = new RunningQuery(active, context);
-           this.running.push(pending);
-           Promise.resolve(active.source(context)).then(result => {
-               if (!pending.context.aborted) {
-                   pending.done = result || null;
-                   this.scheduleAccept();
-               }
-           }, err => {
-               this.view.dispatch({ effects: closeCompletionEffect.of(null) });
-               logException(this.view.state, err);
-           });
-       }
-       scheduleAccept() {
-           if (this.running.every(q => q.done !== undefined))
-               this.accept();
-           else if (this.debounceAccept < 0)
-               this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
-       }
-       // For each finished query in this.running, try to create a result
-       // or, if appropriate, restart the query.
-       accept() {
-           var _a;
-           if (this.debounceAccept > -1)
-               clearTimeout(this.debounceAccept);
-           this.debounceAccept = -1;
-           let updated = [];
-           let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState);
-           for (let i = 0; i < this.running.length; i++) {
-               let query = this.running[i];
-               if (query.done === undefined)
-                   continue;
-               this.running.splice(i--, 1);
-               if (query.done) {
-                   let pos = cur(query.updates.length ? query.updates[0].startState : this.view.state);
-                   let limit = Math.min(pos, query.done.from + (query.active.explicit ? 0 : 1));
-                   let active = new ActiveResult(query.active.source, query.active.explicit, limit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : pos);
-                   // Replay the transactions that happened since the start of
-                   // the request and see if that preserves the result
-                   for (let tr of query.updates)
-                       active = active.update(tr, conf);
-                   if (active.hasResult()) {
-                       updated.push(active);
-                       continue;
-                   }
-               }
-               let current = cState.active.find(a => a.source == query.active.source);
-               if (current && current.isPending) {
-                   if (query.done == null) {
-                       // Explicitly failed. Should clear the pending status if it
-                       // hasn't been re-set in the meantime.
-                       let active = new ActiveSource(query.active.source, 0 /* State.Inactive */);
-                       for (let tr of query.updates)
-                           active = active.update(tr, conf);
-                       if (!active.isPending)
-                           updated.push(active);
-                   }
-                   else {
-                       // Cleared by subsequent transactions. Restart.
-                       this.startQuery(current);
-                   }
-               }
-           }
-           if (updated.length || cState.open && cState.open.disabled)
-               this.view.dispatch({ effects: setActiveEffect.of(updated) });
-       }
-   }, {
-       eventHandlers: {
-           blur(event) {
-               let state = this.view.state.field(completionState, false);
-               if (state && state.tooltip && this.view.state.facet(completionConfig).closeOnBlur) {
-                   let dialog = state.open && getTooltip(this.view, state.open.tooltip);
-                   if (!dialog || !dialog.dom.contains(event.relatedTarget))
-                       setTimeout(() => this.view.dispatch({ effects: closeCompletionEffect.of(null) }), 10);
-               }
-           },
-           compositionstart() {
-               this.composing = 1 /* CompositionState.Started */;
-           },
-           compositionend() {
-               if (this.composing == 3 /* CompositionState.ChangedAndMoved */) {
-                   // Safari fires compositionend events synchronously, possibly
-                   // from inside an update, so dispatch asynchronously to avoid reentrancy
-                   setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20);
-               }
-               this.composing = 0 /* CompositionState.None */;
-           }
-       }
-   });
-   const windows = typeof navigator == "object" && /*@__PURE__*//Win/.test(navigator.platform);
-   const commitCharacters = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.domEventHandlers({
-       keydown(event, view) {
-           let field = view.state.field(completionState, false);
-           if (!field || !field.open || field.open.disabled || field.open.selected < 0 ||
-               event.key.length > 1 || event.ctrlKey && !(windows && event.altKey) || event.metaKey)
-               return false;
-           let option = field.open.options[field.open.selected];
-           let result = field.active.find(a => a.source == option.source);
-           let commitChars = option.completion.commitCharacters || result.result.commitCharacters;
-           if (commitChars && commitChars.indexOf(event.key) > -1)
-               applyCompletion(view, option);
-           return false;
-       }
-   }));
-
-   const baseTheme = /*@__PURE__*/EditorView.baseTheme({
-       ".cm-tooltip.cm-tooltip-autocomplete": {
-           "& > ul": {
-               fontFamily: "monospace",
-               whiteSpace: "nowrap",
-               overflow: "hidden auto",
-               maxWidth_fallback: "700px",
-               maxWidth: "min(700px, 95vw)",
-               minWidth: "250px",
-               maxHeight: "10em",
-               height: "100%",
-               listStyle: "none",
-               margin: 0,
-               padding: 0,
-               "& > li, & > completion-section": {
-                   padding: "1px 3px",
-                   lineHeight: 1.2
-               },
-               "& > li": {
-                   overflowX: "hidden",
-                   textOverflow: "ellipsis",
-                   cursor: "pointer"
-               },
-               "& > completion-section": {
-                   display: "list-item",
-                   borderBottom: "1px solid silver",
-                   paddingLeft: "0.5em",
-                   opacity: 0.7
-               }
-           }
-       },
-       "&light .cm-tooltip-autocomplete ul li[aria-selected]": {
-           background: "#17c",
-           color: "white",
-       },
-       "&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
-           background: "#777",
-       },
-       "&dark .cm-tooltip-autocomplete ul li[aria-selected]": {
-           background: "#347",
-           color: "white",
-       },
-       "&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]": {
-           background: "#444",
-       },
-       ".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after": {
-           content: '"···"',
-           opacity: 0.5,
-           display: "block",
-           textAlign: "center"
-       },
-       ".cm-tooltip.cm-completionInfo": {
-           position: "absolute",
-           padding: "3px 9px",
-           width: "max-content",
-           maxWidth: `${400 /* Info.Width */}px`,
-           boxSizing: "border-box",
-           whiteSpace: "pre-line"
-       },
-       ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
-       ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
-       ".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` },
-       ".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` },
-       "&light .cm-snippetField": { backgroundColor: "#00000022" },
-       "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
-       ".cm-snippetFieldPosition": {
-           verticalAlign: "text-top",
-           width: 0,
-           height: "1.15em",
-           display: "inline-block",
-           margin: "0 -0.7px -.7em",
-           borderLeft: "1.4px dotted #888"
-       },
-       ".cm-completionMatchedText": {
-           textDecoration: "underline"
-       },
-       ".cm-completionDetail": {
-           marginLeft: "0.5em",
-           fontStyle: "italic"
-       },
-       ".cm-completionIcon": {
-           fontSize: "90%",
-           width: ".8em",
-           display: "inline-block",
-           textAlign: "center",
-           paddingRight: ".6em",
-           opacity: "0.6",
-           boxSizing: "content-box"
-       },
-       ".cm-completionIcon-function, .cm-completionIcon-method": {
-           "&:after": { content: "'ƒ'" }
-       },
-       ".cm-completionIcon-class": {
-           "&:after": { content: "'○'" }
-       },
-       ".cm-completionIcon-interface": {
-           "&:after": { content: "'◌'" }
-       },
-       ".cm-completionIcon-variable": {
-           "&:after": { content: "'𝑥'" }
-       },
-       ".cm-completionIcon-constant": {
-           "&:after": { content: "'𝐶'" }
-       },
-       ".cm-completionIcon-type": {
-           "&:after": { content: "'𝑡'" }
-       },
-       ".cm-completionIcon-enum": {
-           "&:after": { content: "'∪'" }
-       },
-       ".cm-completionIcon-property": {
-           "&:after": { content: "'□'" }
-       },
-       ".cm-completionIcon-keyword": {
-           "&:after": { content: "'🔑\uFE0E'" } // Disable emoji rendering
-       },
-       ".cm-completionIcon-namespace": {
-           "&:after": { content: "'▢'" }
-       },
-       ".cm-completionIcon-text": {
-           "&:after": { content: "'abc'", fontSize: "50%", verticalAlign: "middle" }
-       }
-   });
-
-   class FieldPos {
-       constructor(field, line, from, to) {
-           this.field = field;
-           this.line = line;
-           this.from = from;
-           this.to = to;
-       }
-   }
-   class FieldRange {
-       constructor(field, from, to) {
-           this.field = field;
-           this.from = from;
-           this.to = to;
-       }
-       map(changes) {
-           let from = changes.mapPos(this.from, -1, MapMode.TrackDel);
-           let to = changes.mapPos(this.to, 1, MapMode.TrackDel);
-           return from == null || to == null ? null : new FieldRange(this.field, from, to);
-       }
-   }
-   class Snippet {
-       constructor(lines, fieldPositions) {
-           this.lines = lines;
-           this.fieldPositions = fieldPositions;
-       }
-       instantiate(state, pos) {
-           let text = [], lineStart = [pos];
-           let lineObj = state.doc.lineAt(pos), baseIndent = /^\s*/.exec(lineObj.text)[0];
-           for (let line of this.lines) {
-               if (text.length) {
-                   let indent = baseIndent, tabs = /^\t*/.exec(line)[0].length;
-                   for (let i = 0; i < tabs; i++)
-                       indent += state.facet(indentUnit);
-                   lineStart.push(pos + indent.length - tabs);
-                   line = indent + line.slice(tabs);
-               }
-               text.push(line);
-               pos += line.length + 1;
-           }
-           let ranges = this.fieldPositions.map(pos => new FieldRange(pos.field, lineStart[pos.line] + pos.from, lineStart[pos.line] + pos.to));
-           return { text, ranges };
-       }
-       static parse(template) {
-           let fields = [];
-           let lines = [], positions = [], m;
-           for (let line of template.split(/\r\n?|\n/)) {
-               while (m = /[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(line)) {
-                   let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
-                   let name = rawName.replace(/\\[{}]/g, m => m[1]);
-                   for (let i = 0; i < fields.length; i++) {
-                       if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
-                           found = i;
-                   }
-                   if (found < 0) {
-                       let i = 0;
-                       while (i < fields.length && (seq == null || (fields[i].seq != null && fields[i].seq < seq)))
-                           i++;
-                       fields.splice(i, 0, { seq, name });
-                       found = i;
-                       for (let pos of positions)
-                           if (pos.field >= found)
-                               pos.field++;
-                   }
-                   positions.push(new FieldPos(found, lines.length, m.index, m.index + name.length));
-                   line = line.slice(0, m.index) + rawName + line.slice(m.index + m[0].length);
-               }
-               line = line.replace(/\\([{}])/g, (_, brace, index) => {
-                   for (let pos of positions)
-                       if (pos.line == lines.length && pos.from > index) {
-                           pos.from--;
-                           pos.to--;
-                       }
-                   return brace;
-               });
-               lines.push(line);
-           }
-           return new Snippet(lines, positions);
-       }
-   }
-   let fieldMarker = /*@__PURE__*/Decoration.widget({ widget: /*@__PURE__*/new class extends WidgetType {
-           toDOM() {
-               let span = document.createElement("span");
-               span.className = "cm-snippetFieldPosition";
-               return span;
-           }
-           ignoreEvent() { return false; }
-       } });
-   let fieldRange = /*@__PURE__*/Decoration.mark({ class: "cm-snippetField" });
-   class ActiveSnippet {
-       constructor(ranges, active) {
-           this.ranges = ranges;
-           this.active = active;
-           this.deco = Decoration.set(ranges.map(r => (r.from == r.to ? fieldMarker : fieldRange).range(r.from, r.to)));
-       }
-       map(changes) {
-           let ranges = [];
-           for (let r of this.ranges) {
-               let mapped = r.map(changes);
-               if (!mapped)
-                   return null;
-               ranges.push(mapped);
-           }
-           return new ActiveSnippet(ranges, this.active);
-       }
-       selectionInsideField(sel) {
-           return sel.ranges.every(range => this.ranges.some(r => r.field == this.active && r.from <= range.from && r.to >= range.to));
-       }
-   }
-   const setActive = /*@__PURE__*/StateEffect.define({
-       map(value, changes) { return value && value.map(changes); }
-   });
-   const moveToField = /*@__PURE__*/StateEffect.define();
-   const snippetState = /*@__PURE__*/StateField.define({
-       create() { return null; },
-       update(value, tr) {
-           for (let effect of tr.effects) {
-               if (effect.is(setActive))
-                   return effect.value;
-               if (effect.is(moveToField) && value)
-                   return new ActiveSnippet(value.ranges, effect.value);
-           }
-           if (value && tr.docChanged)
-               value = value.map(tr.changes);
-           if (value && tr.selection && !value.selectionInsideField(tr.selection))
-               value = null;
-           return value;
-       },
-       provide: f => EditorView.decorations.from(f, val => val ? val.deco : Decoration.none)
-   });
-   function fieldSelection(ranges, field) {
-       return EditorSelection.create(ranges.filter(r => r.field == field).map(r => EditorSelection.range(r.from, r.to)));
-   }
-   /**
-   Convert a snippet template to a function that can
-   [apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
-   using syntax like this:
-
-       "for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
-
-   Each `${}` placeholder (you may also use `#{}`) indicates a field
-   that the user can fill in. Its name, if any, will be the default
-   content for the field.
-
-   When the snippet is activated by calling the returned function,
-   the code is inserted at the given position. Newlines in the
-   template are indented by the indentation of the start line, plus
-   one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
-   the newline.
-
-   On activation, (all instances of) the first field are selected.
-   The user can move between fields with Tab and Shift-Tab as long as
-   the fields are active. Moving to the last field or moving the
-   cursor out of the current field deactivates the fields.
-
-   The order of fields defaults to textual order, but you can add
-   numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
-   a custom order.
-
-   To include a literal `{` or `}` in your template, put a backslash
-   in front of it. This will be removed and the brace will not be
-   interpreted as indicating a placeholder.
-   */
-   function snippet(template) {
-       let snippet = Snippet.parse(template);
-       return (editor, completion, from, to) => {
-           let { text, ranges } = snippet.instantiate(editor.state, from);
-           let { main } = editor.state.selection;
-           let spec = {
-               changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) },
-               scrollIntoView: true,
-               annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
-           };
-           if (ranges.length)
-               spec.selection = fieldSelection(ranges, 0);
-           if (ranges.some(r => r.field > 0)) {
-               let active = new ActiveSnippet(ranges, 0);
-               let effects = spec.effects = [setActive.of(active)];
-               if (editor.state.field(snippetState, false) === undefined)
-                   effects.push(StateEffect.appendConfig.of([snippetState, addSnippetKeymap, snippetPointerHandler, baseTheme]));
-           }
-           editor.dispatch(editor.state.update(spec));
-       };
-   }
-   function moveField(dir) {
-       return ({ state, dispatch }) => {
-           let active = state.field(snippetState, false);
-           if (!active || dir < 0 && active.active == 0)
-               return false;
-           let next = active.active + dir, last = dir > 0 && !active.ranges.some(r => r.field == next + dir);
-           dispatch(state.update({
-               selection: fieldSelection(active.ranges, next),
-               effects: setActive.of(last ? null : new ActiveSnippet(active.ranges, next)),
-               scrollIntoView: true
-           }));
-           return true;
-       };
-   }
-   /**
-   A command that clears the active snippet, if any.
-   */
-   const clearSnippet = ({ state, dispatch }) => {
-       let active = state.field(snippetState, false);
-       if (!active)
-           return false;
-       dispatch(state.update({ effects: setActive.of(null) }));
-       return true;
-   };
-   /**
-   Move to the next snippet field, if available.
-   */
-   const nextSnippetField = /*@__PURE__*/moveField(1);
-   /**
-   Move to the previous snippet field, if available.
-   */
-   const prevSnippetField = /*@__PURE__*/moveField(-1);
-   const defaultSnippetKeymap = [
-       { key: "Tab", run: nextSnippetField, shift: prevSnippetField },
-       { key: "Escape", run: clearSnippet }
-   ];
-   /**
-   A facet that can be used to configure the key bindings used by
-   snippets. The default binds Tab to
-   [`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
-   [`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
-   to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
-   */
-   const snippetKeymap = /*@__PURE__*/Facet.define({
-       combine(maps) { return maps.length ? maps[0] : defaultSnippetKeymap; }
-   });
-   const addSnippetKeymap = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.compute([snippetKeymap], state => state.facet(snippetKeymap)));
-   /**
-   Create a completion from a snippet. Returns an object with the
-   properties from `completion`, plus an `apply` function that
-   applies the snippet.
-   */
-   function snippetCompletion(template, completion) {
-       return Object.assign(Object.assign({}, completion), { apply: snippet(template) });
-   }
-   const snippetPointerHandler = /*@__PURE__*/EditorView.domEventHandlers({
-       mousedown(event, view) {
-           let active = view.state.field(snippetState, false), pos;
-           if (!active || (pos = view.posAtCoords({ x: event.clientX, y: event.clientY })) == null)
-               return false;
-           let match = active.ranges.find(r => r.from <= pos && r.to >= pos);
-           if (!match || match.field == active.active)
-               return false;
-           view.dispatch({
-               selection: fieldSelection(active.ranges, match.field),
-               effects: setActive.of(active.ranges.some(r => r.field > match.field)
-                   ? new ActiveSnippet(active.ranges, match.field) : null),
-               scrollIntoView: true
-           });
-           return true;
-       }
-   });
-   const closedBracket = /*@__PURE__*/new class extends RangeValue {
-   };
-   closedBracket.startSide = 1;
-   closedBracket.endSide = -1;
-
-   /**
-   Returns an extension that enables autocompletion.
-   */
-   function autocompletion(config = {}) {
-       return [
-           commitCharacters,
-           completionState,
-           completionConfig.of(config),
-           completionPlugin,
-           completionKeymapExt,
-           baseTheme
-       ];
-   }
-   /**
-   Basic keybindings for autocompletion.
-
-    - Ctrl-Space (and Alt-\` on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
-    - Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
-    - ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
-    - ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
-    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
-    - PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
-    - Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
-   */
-   const completionKeymap = [
-       { key: "Ctrl-Space", run: startCompletion },
-       { mac: "Alt-`", run: startCompletion },
-       { key: "Escape", run: closeCompletion },
-       { key: "ArrowDown", run: /*@__PURE__*/moveCompletionSelection(true) },
-       { key: "ArrowUp", run: /*@__PURE__*/moveCompletionSelection(false) },
-       { key: "PageDown", run: /*@__PURE__*/moveCompletionSelection(true, "page") },
-       { key: "PageUp", run: /*@__PURE__*/moveCompletionSelection(false, "page") },
-       { key: "Enter", run: acceptCompletion }
-   ];
-   const completionKeymapExt = /*@__PURE__*/Prec.highest(/*@__PURE__*/keymap.computeN([completionConfig], state => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
-
-   /**
-   A collection of JavaScript-related
-   [snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
-   */
-   const snippets = [
-       /*@__PURE__*/snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
-           label: "function",
-           detail: "definition",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
-           label: "for",
-           detail: "loop",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
-           label: "for",
-           detail: "of loop",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("do {\n\t${}\n} while (${})", {
-           label: "do",
-           detail: "loop",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("while (${}) {\n\t${}\n}", {
-           label: "while",
-           detail: "loop",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
-           label: "try",
-           detail: "/ catch block",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n}", {
-           label: "if",
-           detail: "block",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", {
-           label: "if",
-           detail: "/ else block",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
-           label: "class",
-           detail: "definition",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("import {${names}} from \"${module}\"\n${}", {
-           label: "import",
-           detail: "named",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("import ${name} from \"${module}\"\n${}", {
-           label: "import",
-           detail: "default",
-           type: "keyword"
-       })
-   ];
-   /**
-   A collection of snippet completions for TypeScript. Includes the
-   JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
-   */
-   const typescriptSnippets = /*@__PURE__*/snippets.concat([
-       /*@__PURE__*/snippetCompletion("interface ${name} {\n\t${}\n}", {
-           label: "interface",
-           detail: "definition",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("type ${name} = ${type}", {
-           label: "type",
-           detail: "definition",
-           type: "keyword"
-       }),
-       /*@__PURE__*/snippetCompletion("enum ${name} {\n\t${}\n}", {
-           label: "enum",
-           detail: "definition",
-           type: "keyword"
-       })
-   ]);
-
-   const cache = /*@__PURE__*/new NodeWeakMap();
-   const ScopeNodes = /*@__PURE__*/new Set([
-       "Script", "Block",
-       "FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration",
-       "ForStatement"
-   ]);
-   function defID(type) {
-       return (node, def) => {
-           let id = node.node.getChild("VariableDefinition");
-           if (id)
-               def(id, type);
-           return true;
-       };
-   }
-   const functionContext = ["FunctionDeclaration"];
-   const gatherCompletions = {
-       FunctionDeclaration: /*@__PURE__*/defID("function"),
-       ClassDeclaration: /*@__PURE__*/defID("class"),
-       ClassExpression: () => true,
-       EnumDeclaration: /*@__PURE__*/defID("constant"),
-       TypeAliasDeclaration: /*@__PURE__*/defID("type"),
-       NamespaceDeclaration: /*@__PURE__*/defID("namespace"),
-       VariableDefinition(node, def) { if (!node.matchContext(functionContext))
-           def(node, "variable"); },
-       TypeDefinition(node, def) { def(node, "type"); },
-       __proto__: null
-   };
-   function getScope(doc, node) {
-       let cached = cache.get(node);
-       if (cached)
-           return cached;
-       let completions = [], top = true;
-       function def(node, type) {
-           let name = doc.sliceString(node.from, node.to);
-           completions.push({ label: name, type });
-       }
-       node.cursor(IterMode.IncludeAnonymous).iterate(node => {
-           if (top) {
-               top = false;
-           }
-           else if (node.name) {
-               let gather = gatherCompletions[node.name];
-               if (gather && gather(node, def) || ScopeNodes.has(node.name))
-                   return false;
-           }
-           else if (node.to - node.from > 8192) {
-               // Allow caching for bigger internal nodes
-               for (let c of getScope(doc, node.node))
-                   completions.push(c);
-               return false;
-           }
-       });
-       cache.set(node, completions);
-       return completions;
-   }
-   const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
-   const dontComplete = [
-       "TemplateString", "String", "RegExp",
-       "LineComment", "BlockComment",
-       "VariableDefinition", "TypeDefinition", "Label",
-       "PropertyDefinition", "PropertyName",
-       "PrivatePropertyDefinition", "PrivatePropertyName",
-       ".", "?."
-   ];
-   /**
-   Completion source that looks up locally defined names in
-   JavaScript code.
-   */
-   function localCompletionSource(context) {
-       let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
-       if (dontComplete.indexOf(inner.name) > -1)
-           return null;
-       let isWord = inner.name == "VariableName" ||
-           inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
-       if (!isWord && !context.explicit)
-           return null;
-       let options = [];
-       for (let pos = inner; pos; pos = pos.parent) {
-           if (ScopeNodes.has(pos.name))
-               options = options.concat(getScope(context.state.doc, pos));
-       }
-       return {
-           options,
-           from: isWord ? inner.from : context.pos,
-           validFor: Identifier
-       };
-   }
-
-   /**
-   A language provider based on the [Lezer JavaScript
-   parser](https://github.com/lezer-parser/javascript), extended with
-   highlighting and indentation information.
-   */
-   const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
-       name: "javascript",
-       parser: /*@__PURE__*/parser.configure({
-           props: [
-               /*@__PURE__*/indentNodeProp.add({
-                   IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
-                   TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
-                   LabeledStatement: flatIndent,
-                   SwitchBody: context => {
-                       let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
-                       return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
-                   },
-                   Block: /*@__PURE__*/delimitedIndent({ closing: "}" }),
-                   ArrowFunction: cx => cx.baseIndent + cx.unit,
-                   "TemplateString BlockComment": () => null,
-                   "Statement Property": /*@__PURE__*/continuedIndent({ except: /^{/ }),
-                   JSXElement(context) {
-                       let closed = /^\s*<\//.test(context.textAfter);
-                       return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
-                   },
-                   JSXEscape(context) {
-                       let closed = /\s*\}/.test(context.textAfter);
-                       return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
-                   },
-                   "JSXOpenTag JSXSelfClosingTag"(context) {
-                       return context.column(context.node.from) + context.unit;
-                   }
-               }),
-               /*@__PURE__*/foldNodeProp.add({
-                   "Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": foldInside,
-                   BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
-               })
-           ]
-       }),
-       languageData: {
-           closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
-           commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
-           indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
-           wordChars: "$"
-       }
-   });
-   const jsxSublanguage = {
-       test: node => /^JSX/.test(node.name),
-       facet: /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } })
-   };
-   /**
-   A language provider for TypeScript.
-   */
-   const typescriptLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "ts" }, "typescript");
-   /**
-   Language provider for JSX.
-   */
-   const jsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
-       dialect: "jsx",
-       props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
-   });
-   /**
-   Language provider for JSX + TypeScript.
-   */
-   const tsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
-       dialect: "jsx ts",
-       props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
-   }, "typescript");
-   let kwCompletion = (name) => ({ label: name, type: "keyword" });
-   const keywords = /*@__PURE__*/"break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);
-   const typescriptKeywords = /*@__PURE__*/keywords.concat(/*@__PURE__*/["declare", "implements", "private", "protected", "public"].map(kwCompletion));
-   /**
-   JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
-   and local variable completion.
-   */
-   function javascript(config = {}) {
-       let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage)
-           : config.typescript ? typescriptLanguage : javascriptLanguage;
-       let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords);
-       return new LanguageSupport(lang, [
-           javascriptLanguage.data.of({
-               autocomplete: ifNotIn(dontComplete, completeFromList(completions))
-           }),
-           javascriptLanguage.data.of({
-               autocomplete: localCompletionSource
-           }),
-           config.jsx ? autoCloseTags : [],
-       ]);
-   }
-   function findOpenTag(node) {
-       for (;;) {
-           if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag")
-               return node;
-           if (node.name == "JSXEscape" || !node.parent)
-               return null;
-           node = node.parent;
-       }
-   }
-   function elementName(doc, tree, max = doc.length) {
-       for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
-           if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
-               ch.name == "JSXMemberExpression")
-               return doc.sliceString(ch.from, Math.min(ch.to, max));
-       }
-       return "";
-   }
-   const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
-   /**
-   Extension that will automatically insert JSX close tags when a `>` or
-   `/` is typed.
-   */
-   const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
-       if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
-           from != to || (text != ">" && text != "/") ||
-           !javascriptLanguage.isActiveAt(view.state, from, -1))
-           return false;
-       let base = defaultInsert(), { state } = base;
-       let closeTags = state.changeByRange(range => {
-           var _a;
-           let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name;
-           if (around.name == "JSXStartTag")
-               around = around.parent;
-           if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
-           else if (text == ">" && around.name == "JSXFragmentTag") {
-               return { range, changes: { from: head, insert: `</>` } };
-           }
-           else if (text == "/" && around.name == "JSXStartCloseTag") {
-               let empty = around.parent, base = empty.parent;
-               if (base && empty.from == head - 2 &&
-                   ((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
-                   let insert = `${name}>`;
-                   return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
-               }
-           }
-           else if (text == ">") {
-               let openTag = findOpenTag(around);
-               if (openTag && openTag.name == "JSXOpenTag" &&
-                   !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
-                   (name = elementName(state.doc, openTag, head)))
-                   return { range, changes: { from: head, insert: `</${name}>` } };
-           }
-           return { range };
-       });
-       if (closeTags.changes.empty)
-           return false;
-       view.dispatch([
-           base,
-           state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
-       ]);
-       return true;
-   });
-
-   // Using https://github.com/one-dark/vscode-one-dark-theme/ as reference for the colors
-   const chalky = "#e5c07b", coral = "#e06c75", cyan = "#56b6c2", invalid = "#ffffff", ivory = "#abb2bf", stone = "#7d8799", // Brightened compared to original to increase contrast
-   malibu = "#61afef", sage = "#98c379", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#2c313a", background = "#282c34", tooltipBackground = "#353a42", selection = "#3E4451", cursor = "#528bff";
-   /**
-   The editor theme styles for One Dark.
-   */
-   const oneDarkTheme = /*@__PURE__*/EditorView.theme({
-       "&": {
-           color: ivory,
-           backgroundColor: background
-       },
-       ".cm-content": {
-           caretColor: cursor
-       },
-       ".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
-       "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
-       ".cm-panels": { backgroundColor: darkBackground, color: ivory },
-       ".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: background,
-           color: stone,
-           border: "none"
-       },
-       ".cm-activeLineGutter": {
-           backgroundColor: highlightBackground
-       },
-       ".cm-foldPlaceholder": {
-           backgroundColor: "transparent",
-           border: "none",
-           color: "#ddd"
-       },
-       ".cm-tooltip": {
-           border: "none",
-           backgroundColor: tooltipBackground
-       },
-       ".cm-tooltip .cm-tooltip-arrow:before": {
-           borderTopColor: "transparent",
-           borderBottomColor: "transparent"
-       },
-       ".cm-tooltip .cm-tooltip-arrow:after": {
-           borderTopColor: tooltipBackground,
-           borderBottomColor: tooltipBackground
-       },
-       ".cm-tooltip-autocomplete": {
-           "& > ul > li[aria-selected]": {
-               backgroundColor: highlightBackground,
-               color: ivory
-           }
-       }
-   }, { dark: true });
-   /**
-   The highlighting style for code in the One Dark theme.
-   */
-   const oneDarkHighlightStyle = /*@__PURE__*/HighlightStyle.define([
-       { tag: tags.keyword,
-           color: violet },
-       { tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
-           color: coral },
-       { tag: [/*@__PURE__*/tags.function(tags.variableName), tags.labelName],
-           color: malibu },
-       { tag: [tags.color, /*@__PURE__*/tags.constant(tags.name), /*@__PURE__*/tags.standard(tags.name)],
-           color: whiskey },
-       { tag: [/*@__PURE__*/tags.definition(tags.name), tags.separator],
-           color: ivory },
-       { tag: [tags.typeName, tags.className, tags.number, tags.changed, tags.annotation, tags.modifier, tags.self, tags.namespace],
-           color: chalky },
-       { tag: [tags.operator, tags.operatorKeyword, tags.url, tags.escape, tags.regexp, tags.link, /*@__PURE__*/tags.special(tags.string)],
-           color: cyan },
-       { tag: [tags.meta, tags.comment],
-           color: stone },
-       { tag: tags.strong,
-           fontWeight: "bold" },
-       { tag: tags.emphasis,
-           fontStyle: "italic" },
-       { tag: tags.strikethrough,
-           textDecoration: "line-through" },
-       { tag: tags.link,
-           color: stone,
-           textDecoration: "underline" },
-       { tag: tags.heading,
-           fontWeight: "bold",
-           color: coral },
-       { tag: [tags.atom, tags.bool, /*@__PURE__*/tags.special(tags.variableName)],
-           color: whiskey },
-       { tag: [tags.processingInstruction, tags.string, tags.inserted],
-           color: sage },
-       { tag: tags.invalid,
-           color: invalid },
-   ]);
-   /**
-   Extension to enable the One Dark theme (both the editor theme and
-   the highlight style).
-   */
-   const oneDark = [oneDarkTheme, /*@__PURE__*/syntaxHighlighting(oneDarkHighlightStyle)];
-
-   class SelectedDiagnostic {
-       constructor(from, to, diagnostic) {
-           this.from = from;
-           this.to = to;
-           this.diagnostic = diagnostic;
-       }
-   }
-   class LintState {
-       constructor(diagnostics, panel, selected) {
-           this.diagnostics = diagnostics;
-           this.panel = panel;
-           this.selected = selected;
-       }
-       static init(diagnostics, panel, state) {
-           // Filter the list of diagnostics for which to create markers
-           let markedDiagnostics = diagnostics;
-           let diagnosticFilter = state.facet(lintConfig).markerFilter;
-           if (diagnosticFilter)
-               markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
-           let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
-           let deco = new RangeSetBuilder(), active = [], pos = 0;
-           for (let i = 0;;) {
-               let next = i == sorted.length ? null : sorted[i];
-               if (!next && !active.length)
-                   break;
-               let from, to;
-               if (active.length) {
-                   from = pos;
-                   to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8);
-               }
-               else {
-                   from = next.from;
-                   to = next.to;
-                   active.push(next);
-                   i++;
-               }
-               while (i < sorted.length) {
-                   let next = sorted[i];
-                   if (next.from == from && (next.to > next.from || next.to == from)) {
-                       active.push(next);
-                       i++;
-                       to = Math.min(next.to, to);
-                   }
-                   else {
-                       to = Math.min(next.from, to);
-                       break;
-                   }
-               }
-               let sev = maxSeverity(active);
-               if (active.some(d => d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from))) {
-                   deco.add(from, from, Decoration.widget({
-                       widget: new DiagnosticWidget(sev),
-                       diagnostics: active.slice()
-                   }));
-               }
-               else {
-                   let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, "");
-                   deco.add(from, to, Decoration.mark({
-                       class: "cm-lintRange cm-lintRange-" + sev + markClass,
-                       diagnostics: active.slice(),
-                       inclusiveEnd: active.some(a => a.to > to)
-                   }));
-               }
-               pos = to;
-               for (let i = 0; i < active.length; i++)
-                   if (active[i].to <= pos)
-                       active.splice(i--, 1);
-           }
-           let set = deco.finish();
-           return new LintState(set, panel, findDiagnostic(set));
-       }
-   }
-   function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
-       let found = null;
-       diagnostics.between(after, 1e9, (from, to, { spec }) => {
-           if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0)
-               return;
-           if (!found)
-               found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]);
-           else if (spec.diagnostics.indexOf(found.diagnostic) < 0)
-               return false;
-           else
-               found = new SelectedDiagnostic(found.from, to, found.diagnostic);
-       });
-       return found;
-   }
-   function hideTooltip(tr, tooltip) {
-       let from = tooltip.pos, to = tooltip.end || from;
-       let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
-       if (result != null)
-           return result;
-       let line = tr.startState.doc.lineAt(tooltip.pos);
-       return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
-   }
-   /**
-   The state effect that updates the set of active diagnostics. Can
-   be useful when writing an extension that needs to track these.
-   */
-   const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
-   const togglePanel = /*@__PURE__*/StateEffect.define();
-   const movePanelSelection = /*@__PURE__*/StateEffect.define();
-   const lintState = /*@__PURE__*/StateField.define({
-       create() {
-           return new LintState(Decoration.none, null, null);
-       },
-       update(value, tr) {
-           if (tr.docChanged && value.diagnostics.size) {
-               let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
-               if (value.selected) {
-                   let selPos = tr.changes.mapPos(value.selected.from, 1);
-                   selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
-               }
-               if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel)
-                   panel = null;
-               value = new LintState(mapped, panel, selected);
-           }
-           for (let effect of tr.effects) {
-               if (effect.is(setDiagnosticsEffect)) {
-                   let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
-                   value = LintState.init(effect.value, panel, tr.state);
-               }
-               else if (effect.is(togglePanel)) {
-                   value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
-               }
-               else if (effect.is(movePanelSelection)) {
-                   value = new LintState(value.diagnostics, value.panel, effect.value);
-               }
-           }
-           return value;
-       },
-       provide: f => [showPanel.from(f, val => val.panel),
-           EditorView.decorations.from(f, s => s.diagnostics)]
-   });
-   function diagnosticsTooltip(view, diagnostics) {
-       return crelt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
-   }
-   /**
-   Command to close the lint panel, when open.
-   */
-   const closeLintPanel = (view) => {
-       let field = view.state.field(lintState, false);
-       if (!field || !field.panel)
-           return false;
-       view.dispatch({ effects: togglePanel.of(false) });
-       return true;
-   };
-   const lintConfig = /*@__PURE__*/Facet.define({
-       combine(input) {
-           return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
-               delay: 750,
-               markerFilter: null,
-               tooltipFilter: null,
-               needsRefresh: null,
-               hideOn: () => null,
-           }, {
-               needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
-           }));
-       }
-   });
-   function assignKeys(actions) {
-       let assigned = [];
-       if (actions)
-           actions: for (let { name } of actions) {
-               for (let i = 0; i < name.length; i++) {
-                   let ch = name[i];
-                   if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
-                       assigned.push(ch);
-                       continue actions;
-                   }
-               }
-               assigned.push("");
-           }
-       return assigned;
-   }
-   function renderDiagnostic(view, diagnostic, inPanel) {
-       var _a;
-       let keys = inPanel ? assignKeys(diagnostic.actions) : [];
-       return crelt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, crelt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
-           let fired = false, click = (e) => {
-               e.preventDefault();
-               if (fired)
-                   return;
-               fired = true;
-               let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
-               if (found)
-                   action.apply(view, found.from, found.to);
-           };
-           let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
-           let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
-               crelt("u", name.slice(keyIndex, keyIndex + 1)),
-               name.slice(keyIndex + 1)];
-           return crelt("button", {
-               type: "button",
-               class: "cm-diagnosticAction",
-               onclick: click,
-               onmousedown: click,
-               "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
-           }, nameElt);
-       }), diagnostic.source && crelt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
-   }
-   class DiagnosticWidget extends WidgetType {
-       constructor(sev) {
-           super();
-           this.sev = sev;
-       }
-       eq(other) { return other.sev == this.sev; }
-       toDOM() {
-           return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
-       }
-   }
-   class PanelItem {
-       constructor(view, diagnostic) {
-           this.diagnostic = diagnostic;
-           this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
-           this.dom = renderDiagnostic(view, diagnostic, true);
-           this.dom.id = this.id;
-           this.dom.setAttribute("role", "option");
-       }
-   }
-   class LintPanel {
-       constructor(view) {
-           this.view = view;
-           this.items = [];
-           let onkeydown = (event) => {
-               if (event.keyCode == 27) { // Escape
-                   closeLintPanel(this.view);
-                   this.view.focus();
-               }
-               else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
-                   this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
-               }
-               else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
-                   this.moveSelection((this.selectedIndex + 1) % this.items.length);
-               }
-               else if (event.keyCode == 36) { // Home
-                   this.moveSelection(0);
-               }
-               else if (event.keyCode == 35) { // End
-                   this.moveSelection(this.items.length - 1);
-               }
-               else if (event.keyCode == 13) { // Enter
-                   this.view.focus();
-               }
-               else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
-                   let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions);
-                   for (let i = 0; i < keys.length; i++)
-                       if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
-                           let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
-                           if (found)
-                               diagnostic.actions[i].apply(view, found.from, found.to);
-                       }
-               }
-               else {
-                   return;
-               }
-               event.preventDefault();
-           };
-           let onclick = (event) => {
-               for (let i = 0; i < this.items.length; i++) {
-                   if (this.items[i].dom.contains(event.target))
-                       this.moveSelection(i);
-               }
-           };
-           this.list = crelt("ul", {
-               tabIndex: 0,
-               role: "listbox",
-               "aria-label": this.view.state.phrase("Diagnostics"),
-               onkeydown,
-               onclick
-           });
-           this.dom = crelt("div", { class: "cm-panel-lint" }, this.list, crelt("button", {
-               type: "button",
-               name: "close",
-               "aria-label": this.view.state.phrase("close"),
-               onclick: () => closeLintPanel(this.view)
-           }, "×"));
-           this.update();
-       }
-       get selectedIndex() {
-           let selected = this.view.state.field(lintState).selected;
-           if (!selected)
-               return -1;
-           for (let i = 0; i < this.items.length; i++)
-               if (this.items[i].diagnostic == selected.diagnostic)
-                   return i;
-           return -1;
-       }
-       update() {
-           let { diagnostics, selected } = this.view.state.field(lintState);
-           let i = 0, needsSync = false, newSelectedItem = null;
-           let seen = new Set();
-           diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
-               for (let diagnostic of spec.diagnostics) {
-                   if (seen.has(diagnostic))
-                       continue;
-                   seen.add(diagnostic);
-                   let found = -1, item;
-                   for (let j = i; j < this.items.length; j++)
-                       if (this.items[j].diagnostic == diagnostic) {
-                           found = j;
-                           break;
-                       }
-                   if (found < 0) {
-                       item = new PanelItem(this.view, diagnostic);
-                       this.items.splice(i, 0, item);
-                       needsSync = true;
-                   }
-                   else {
-                       item = this.items[found];
-                       if (found > i) {
-                           this.items.splice(i, found - i);
-                           needsSync = true;
-                       }
-                   }
-                   if (selected && item.diagnostic == selected.diagnostic) {
-                       if (!item.dom.hasAttribute("aria-selected")) {
-                           item.dom.setAttribute("aria-selected", "true");
-                           newSelectedItem = item;
-                       }
-                   }
-                   else if (item.dom.hasAttribute("aria-selected")) {
-                       item.dom.removeAttribute("aria-selected");
-                   }
-                   i++;
-               }
-           });
-           while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
-               needsSync = true;
-               this.items.pop();
-           }
-           if (this.items.length == 0) {
-               this.items.push(new PanelItem(this.view, {
-                   from: -1, to: -1,
-                   severity: "info",
-                   message: this.view.state.phrase("No diagnostics")
-               }));
-               needsSync = true;
-           }
-           if (newSelectedItem) {
-               this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
-               this.view.requestMeasure({
-                   key: this,
-                   read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
-                   write: ({ sel, panel }) => {
-                       let scaleY = panel.height / this.list.offsetHeight;
-                       if (sel.top < panel.top)
-                           this.list.scrollTop -= (panel.top - sel.top) / scaleY;
-                       else if (sel.bottom > panel.bottom)
-                           this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY;
-                   }
-               });
-           }
-           else if (this.selectedIndex < 0) {
-               this.list.removeAttribute("aria-activedescendant");
-           }
-           if (needsSync)
-               this.sync();
-       }
-       sync() {
-           let domPos = this.list.firstChild;
-           function rm() {
-               let prev = domPos;
-               domPos = prev.nextSibling;
-               prev.remove();
-           }
-           for (let item of this.items) {
-               if (item.dom.parentNode == this.list) {
-                   while (domPos != item.dom)
-                       rm();
-                   domPos = item.dom.nextSibling;
-               }
-               else {
-                   this.list.insertBefore(item.dom, domPos);
-               }
-           }
-           while (domPos)
-               rm();
-       }
-       moveSelection(selectedIndex) {
-           if (this.selectedIndex < 0)
-               return;
-           let field = this.view.state.field(lintState);
-           let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
-           if (!selection)
-               return;
-           this.view.dispatch({
-               selection: { anchor: selection.from, head: selection.to },
-               scrollIntoView: true,
-               effects: movePanelSelection.of(selection)
-           });
-       }
-       static open(view) { return new LintPanel(view); }
-   }
-   function svg(content, attrs = `viewBox="0 0 40 40"`) {
-       return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
-   }
-   function severityWeight(sev) {
-       return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
-   }
-   function maxSeverity(diagnostics) {
-       let sev = "hint", weight = 1;
-       for (let d of diagnostics) {
-           let w = severityWeight(d.severity);
-           if (w > weight) {
-               weight = w;
-               sev = d.severity;
-           }
-       }
-       return sev;
-   }
-   class LintGutterMarker extends GutterMarker {
-       constructor(diagnostics) {
-           super();
-           this.diagnostics = diagnostics;
-           this.severity = maxSeverity(diagnostics);
-       }
-       toDOM(view) {
-           let elt = document.createElement("div");
-           elt.className = "cm-lint-marker cm-lint-marker-" + this.severity;
-           let diagnostics = this.diagnostics;
-           let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter;
-           if (diagnosticsFilter)
-               diagnostics = diagnosticsFilter(diagnostics, view.state);
-           if (diagnostics.length)
-               elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics);
-           return elt;
-       }
-   }
-   function trackHoverOn(view, marker) {
-       let mousemove = (event) => {
-           let rect = marker.getBoundingClientRect();
-           if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
-               event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
-               return;
-           for (let target = event.target; target; target = target.parentNode) {
-               if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
-                   return;
-           }
-           window.removeEventListener("mousemove", mousemove);
-           if (view.state.field(lintGutterTooltip))
-               view.dispatch({ effects: setLintGutterTooltip.of(null) });
-       };
-       window.addEventListener("mousemove", mousemove);
-   }
-   function gutterMarkerMouseOver(view, marker, diagnostics) {
-       function hovered() {
-           let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
-           const linePos = view.coordsAtPos(line.from);
-           if (linePos) {
-               view.dispatch({ effects: setLintGutterTooltip.of({
-                       pos: line.from,
-                       above: false,
-                       clip: false,
-                       create() {
-                           return {
-                               dom: diagnosticsTooltip(view, diagnostics),
-                               getCoords: () => marker.getBoundingClientRect()
-                           };
-                       }
-                   }) });
-           }
-           marker.onmouseout = marker.onmousemove = null;
-           trackHoverOn(view, marker);
-       }
-       let { hoverTime } = view.state.facet(lintGutterConfig);
-       let hoverTimeout = setTimeout(hovered, hoverTime);
-       marker.onmouseout = () => {
-           clearTimeout(hoverTimeout);
-           marker.onmouseout = marker.onmousemove = null;
-       };
-       marker.onmousemove = () => {
-           clearTimeout(hoverTimeout);
-           hoverTimeout = setTimeout(hovered, hoverTime);
-       };
-   }
-   function markersForDiagnostics(doc, diagnostics) {
-       let byLine = Object.create(null);
-       for (let diagnostic of diagnostics) {
-           let line = doc.lineAt(diagnostic.from);
-           (byLine[line.from] || (byLine[line.from] = [])).push(diagnostic);
-       }
-       let markers = [];
-       for (let line in byLine) {
-           markers.push(new LintGutterMarker(byLine[line]).range(+line));
-       }
-       return RangeSet.of(markers, true);
-   }
-   const lintGutterExtension = /*@__PURE__*/gutter({
-       class: "cm-gutter-lint",
-       markers: view => view.state.field(lintGutterMarkers),
-       widgetMarker: (view, widget, block) => {
-           let diagnostics = [];
-           view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
-               if (from > block.from && from < block.to)
-                   diagnostics.push(...value.diagnostics);
-           });
-           return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
-       }
-   });
-   const lintGutterMarkers = /*@__PURE__*/StateField.define({
-       create() {
-           return RangeSet.empty;
-       },
-       update(markers, tr) {
-           markers = markers.map(tr.changes);
-           let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter;
-           for (let effect of tr.effects) {
-               if (effect.is(setDiagnosticsEffect)) {
-                   let diagnostics = effect.value;
-                   if (diagnosticFilter)
-                       diagnostics = diagnosticFilter(diagnostics || [], tr.state);
-                   markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0));
-               }
-           }
-           return markers;
-       }
-   });
-   const setLintGutterTooltip = /*@__PURE__*/StateEffect.define();
-   const lintGutterTooltip = /*@__PURE__*/StateField.define({
-       create() { return null; },
-       update(tooltip, tr) {
-           if (tooltip && tr.docChanged)
-               tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
-           return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
-       },
-       provide: field => showTooltip.from(field)
-   });
-   const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
-       ".cm-gutter-lint": {
-           width: "1.4em",
-           "& .cm-gutterElement": {
-               padding: ".2em"
-           }
-       },
-       ".cm-lint-marker": {
-           width: "1em",
-           height: "1em"
-       },
-       ".cm-lint-marker-info": {
-           content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
-       },
-       ".cm-lint-marker-warning": {
-           content: /*@__PURE__*/svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
-       },
-       ".cm-lint-marker-error": {
-           content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
-       },
-   });
-   const lintGutterConfig = /*@__PURE__*/Facet.define({
-       combine(configs) {
-           return combineConfig(configs, {
-               hoverTime: 300 /* Hover.Time */,
-               markerFilter: null,
-               tooltipFilter: null
-           });
-       }
-   });
-   /**
-   Returns an extension that installs a gutter showing markers for
-   each line that has diagnostics, which can be hovered over to see
-   the diagnostics.
-   */
-   function lintGutter(config = {}) {
-       return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
-   }
-
-   window.basicSetup = basicSetup;
-   window.javascript = javascript;
-   window.oneDark = oneDark;
-   window.EditorView = EditorView;
-   window.EditorState = EditorState;
-   window.lintGutter = lintGutter;
-   window.autocompletion = autocompletion;
-   window.language = language;
-   window.lineNumbers = lineNumbers;
-
-})();
diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index a7273ef17..364e8ff97 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -380,7 +380,27 @@
             border: 1px solid #ccc;
             height: 500px !important;
         }
-       .cm-lint-marker-error {
+  .custom-tooltip {
+  position: absolute;
+  background-color: white;
+  color: black;
+  padding: 5px 10px;
+  border-radius: 4px;
+  font-size: 14px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
+  z-index: 1000;
+  pointer-events: none;
+  margin-bottom: 5px;
+  border: 1px solid #ddd;
+  max-width: 300px;
+  word-break: break-word;
+}
+
+        .CodeMirror-lint-mark-error {
+            background-color: rgba(255, 0, 0, 0.2); /* Light red background for errors */
+        }
+
+       .cm-lint-error {
             background-color: red;
             color: white;
             font-size: 12px;
@@ -410,6 +430,7 @@
     [data-validation-error-message] {
       position: relative;
       display: inline-block;
+      cursor: pointer;
     }
 
     .CodeMirror pre.CodeMirror-line[role="presentation"] {
@@ -1240,33 +1261,30 @@ <h2 th:text="${contractFilePath}"></h2>
 <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>-->
 <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->
 <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>-->
-<script src="codemirror-bundle.js"></script>
-<script>
-      window.onload = function () {
-        const examplePreDiv = document.createElement("div");
-        examplePreDiv.style.height = "400px";
-        examplePreDiv.style.width = "600px";
-        examplePreDiv.style.border = "1px solid #ccc";
-
-        // Create the editor
-        const editor = new window.EditorView({
-          state: window.EditorState.create({
-            doc: '{"hello":"hello"}',
-            extensions: [
-              window.basicSetup,
-              window.javascript()
-            ],
-          }),
-          parent: examplePreDiv,
-        });
+<script type="module">
+import { Decoration,EditorState, EditorView, StateEffect, StateField,autocompletion, basicSetup, hoverTooltip,javascript, json,jsonParseLinter, language, lineNumbers, lintGutter, linter,oneDark,tooltips } from './codemirror-bundle.esm.js'
+    window.EditorState = EditorState
+    window.EditorView = EditorView
+    window.basicSetup = basicSetup
+    window.javascript = javascript()
+    window.autocompletion = autocompletion()
+    window.oneDark = oneDark
+    window.language = language
+    window.lineNumbers = lineNumbers()
+    window.lintGutter = lintGutter()
+    window.json = json()
+    window.linter = linter(jsonParseLinter())
+    window.Decoration = Decoration
+    window.StateField = StateField
+    window.StateEffect = StateEffect
+    window.tooltips = tooltips
+    window.hoverTooltip = hoverTooltip
 
-        // Append the div to the body
-        document.body.appendChild(examplePreDiv);
-      };
 </script>
 <script>var escapedChars={b:"\b",f:"\f",n:"\n",r:"\r",t:"	",'"':'"',"/":"/","\\":"\\"},A_CODE="a".charCodeAt();const jsonMapParser=function(e,n,r){var a={},t=0,o=0,c=0,i=r&&r.bigint&&"undefined"!=typeof BigInt;return{data:function n(r,a){f(),E(r,"value");var t,o,$,g,S=l();switch(S){case"t":s("rue"),g=!0;break;case"f":s("alse"),g=!1;break;case"n":s("ull"),g=null;break;case'"':g=u();break;case"[":g=function e(r){f();var a=[],t=0;if("]"==l())return a;for(v();;){var o=r+"/"+t;a.push(n(o)),f();var c=l();if("]"==c)break;","!=c&&k(),f(),t++}return a}(r);break;case"{":g=function e(r){f();var a={};if("}"==l())return a;for(v();;){var t=d();'"'!=l()&&k();var o=u(),c=r+"/"+escapeJsonPointer(o);b(c,"key",t),E(c,"keyEnd"),f(),":"!=l()&&k(),f(),a[o]=n(c),f();var i=l();if("}"==i)break;","!=i&&k(),f()}return a}(r);break;default:v(),"-0123456789".indexOf(S)>=0?g=(t="",o=!0,"-"==e[c]&&(t+=l()),t+="0"==e[c]?l():p(),"."==e[c]&&(t+=l()+p(),o=!1),("e"==e[c]||"E"==e[c])&&(t+=l(),("+"==e[c]||"-"==e[c])&&(t+=l()),t+=p(),o=!1),$=+t,i&&o&&($>Number.MAX_SAFE_INTEGER||$<Number.MIN_SAFE_INTEGER)?BigInt(t):$):h()}return E(r,"valueEnd"),f(),a&&c<e.length&&h(),g}("",!0),pointers:a};function f(){loop:for(;c<e.length;){switch(e[c]){case" ":o++;break;case"	":o+=4;break;case"\r":o=0;break;case"\n":o=0,t++;break;default:break loop}c++}}function u(){for(var e,n="";'"'!=(e=l());)"\\"==e?(e=l())in escapedChars?n+=escapedChars[e]:"u"==e?n+=$():k():n+=e;return n}function s(e){for(var n=0;n<e.length;n++)l()!==e[n]&&k()}function l(){g();var n=e[c];return c++,o++,n}function v(){c--,o--}function $(){for(var e=4,n=0;e--;){n<<=4;var r=l().toLowerCase();r>="a"&&r<="f"?n+=r.charCodeAt()-A_CODE+10:r>="0"&&r<="9"?n+=+r:k()}return String.fromCharCode(n)}function p(){for(var n="";e[c]>="0"&&e[c]<="9";)n+=l();if(n.length)return n;g(),h()}function E(e,n){b(e,n,d())}function b(e,n,r){a[e]=a[e]||{},a[e][n]=r}function d(){return{line:t,column:o,pos:c}}function h(){throw SyntaxError("Unexpected token "+e[c]+" in JSON at position "+c)}function k(){v(),h()}function g(){if(c>=e.length)throw SyntaxError("Unexpected end of JSON input")}},jsonMapStringify=function(e,n,r){if(validType(e)){var a,t,o=0,c="object"==typeof r?r.space:r;switch(typeof c){case"number":var i=c>10?10:c<0?0:Math.floor(c);c=i&&k(i," "),a=i,t=i;break;case"string":c=c.slice(0,10),a=0,t=0;for(var f=0;f<c.length;f++){var u=c[f];switch(u){case" ":t++;break;case"	":t+=4;break;case"\r":t=0;break;case"\n":t=0,o++;break;default:throw Error("whitespace characters not allowed in JSON")}a++}break;default:c=void 0}var s="",l={},v=0,$=0,p=0,E=r&&r.es6&&"function"==typeof Map;return function e(n,r,a){switch(h(a,"value"),typeof n){case"number":case"bigint":case"boolean":b(""+n);break;case"string":b(quoted(n));break;case"object":null===n?b("null"):"function"==typeof n.toJSON?b(quoted(n.toJSON())):Array.isArray(n)?t():E?n.constructor.BYTES_PER_ELEMENT?t():n instanceof Map?i():n instanceof Set?i(!0):o():o()}function t(){if(n.length){b("[");for(var t=r+1,o=0;o<n.length;o++){o&&b(","),d(t);var c=validType(n[o])?n[o]:null;e(c,t,a+"/"+o)}d(r),b("]")}else b("[]")}function o(){var t=Object.keys(n);if(t.length){b("{");for(var o=r+1,i=0;i<t.length;i++){var f=t[i],u=n[f];if(validType(u)){i&&b(",");var s=a+"/"+escapeJsonPointer(f);d(o),h(s,"key"),b(quoted(f)),h(s,"keyEnd"),b(":"),c&&b(" "),e(u,o,s)}}d(r),b("}")}else b("{}")}function i(t){if(n.size){b("{");for(var o=r+1,i=!0,f=n.entries(),u=f.next();!u.done;){var s=u.value,l=s[0],v=!!t||s[1];if(validType(v)){i||b(","),i=!1;var $=a+"/"+escapeJsonPointer(l);d(o),h($,"key"),b(quoted(l)),h($,"keyEnd"),b(":"),c&&b(" "),e(v,o,$)}u=f.next()}d(r),b("}")}else b("{}")}h(a,"valueEnd")}(e,0,""),{json:s,pointers:l}}function b(e){$+=e.length,p+=e.length,s+=e}function d(e){if(c){for(s+="\n"+k(e,c),v++,$=0;e--;)o?(v+=o,$=t):$+=t,p+=a;p+=1}}function h(e,n){l[e]=l[e]||{},l[e][n]={line:v,column:$,pos:p}}function k(e,n){return Array(e+1).join(n)}};var VALID_TYPES=["number","bigint","boolean","string","object"];function validType(e){return VALID_TYPES.indexOf(typeof e)>=0}var ESC_QUOTE=/"|\\/g,ESC_B=/[\b]/g,ESC_F=/\f/g,ESC_N=/\n/g,ESC_R=/\r/g,ESC_T=/\t/g;function quoted(e){return'"'+(e=e.replace(ESC_QUOTE,"\\$&").replace(ESC_F,"\\f").replace(ESC_B,"\\b").replace(ESC_N,"\\n").replace(ESC_R,"\\r").replace(ESC_T,"\\t"))+'"'}var ESC_0=/~/g,ESC_1=/\//g;function escapeJsonPointer(e){return e.replace(ESC_0,"~0").replace(ESC_1,"~1")}</script>
 </body>
 <script>
+
     const mainElement = document.querySelector("main");
     const table = document.querySelector("table");
     const backBtn = document.querySelector("button#back");
@@ -1277,7 +1295,8 @@ <h2 th:text="${contractFilePath}"></h2>
     const bulkGenerateBtn = document.querySelector("button#bulk-generate");
     const bulkTestBtn = document.querySelector("button#bulk-test");
     const chevronDownIcon = document.querySelector("svg.chevron");
-
+    let setDecorationsEffect;
+    let decorationsField;
     let savedEditorResponse = null;
     let scrollYPosition = 0;
     let selectedTableRow = null;
@@ -1774,6 +1793,7 @@ <h2 th:text="${contractFilePath}"></h2>
         return docFragment;
     }
 
+
     function createExampleSummary(example) {
         const exampleDiv = document.createElement("div");
         const exampleName = document.createElement("p");
@@ -1849,43 +1869,82 @@ <h2 th:text="${contractFilePath}"></h2>
         detailsFragment.appendChild(detailsDropdown);
         detailsFragment.appendChild(detailsPre);
 
-    console.log(window.EditorView);
-    console.log(window.EditorState);
-    console.log(window.basicSetup);
-    console.log(window.javascript);
-    console.log(window.autocompletion);
-    console.log(window.lintGutter);
-    console.log(window.lineNumbers);
-    console.log(window.oneDark);
-
+ setDecorationsEffect = window.StateEffect.define();
+   decorationsField = window.StateField.define({
+    create() {
+        return window.Decoration.none;
+    },
+    update(decorations, transaction) {
+        for (let effect of transaction.effects) {
+            if (effect.is(setDecorationsEffect)) {
+                return effect.value;
+            }
+        }
+        return decorations;
+    },
+    provide: field => window.EditorView.decorations.from(field)
+});
+ const lineDecorationHoverTooltip = hoverTooltip((view, pos, side) => {
+  const decoSet = view.state.field(decorationsField);
+
+  // Loop through each decoration in the set
+  for (let deco of decoSet) {
+    // Check if the position is within the range of the decoration
+    if (deco.from <= pos && pos <= deco.to) {
+      const message = deco.spec.attributes["data-validation-error-message"];
+      if (message) {
+        return {
+          pos,
+          above: true,
+          create(view) {
+            const dom = document.createElement("div");
+            dom.className = "custom-tooltip";
+            dom.textContent = message;
+            return { dom };
+          }
+        };
+      }
+    }
+  }
 
+  return null;
+});
     const editor = new window.EditorView({
     state: window.EditorState.create({
-      doc: '{"hello":"hello"}',
+      doc: example.exampleJson,
       extensions: [
         window.basicSetup,
-        window.javascript(),
-        window.autocompletion(),
-        window.lintGutter(),
-        window.lineNumbers(),
-        window.oneDark
-      ],
-    }),
-    parent: examplePrevDiv
+        window.autocompletion,
+        window.json,
+        window.linter,
+        window.lintGutter,
+        window.lineNumbers,
+        window.oneDark,
+        decorationsField,
+        lineDecorationHoverTooltip,
+        window.EditorView.updateListener.of((update) => {
+        if (update.docChanged) {
+          isSaved = false;
+          const editorElement = editor.dom;
+          updateBorderColorExampleBlock(editorElement, examplePreDiv);
+          savedEditorResponse = update.state.doc.toString();
+        }
+      })
+    ],
+  }),
+    parent: examplePreDiv
   });
+
+
         if (example.errorList) {
             if (Array.isArray(example.errorList) && example.errorList.every(item => typeof item === 'object')) {
+                if(example.errorList.length >0)
                 highlightErrorLines(editor, example.errorList, example.exampleJson);
             } else {
                 createAlert("Example Validation Failed", example.errorMessage, true);
             }
         }
 
-        editor.on("change", (instance, changes) => {
-            isSaved = false;
-            updateBorderColorExampleBlock(editor, examplePreDiv);
-            savedEditorResponse = editor.getValue();
-        });
 
         if (example.test) {
             const testPara = document.createElement("p");
@@ -1942,46 +2001,50 @@ <h2 th:text="${contractFilePath}"></h2>
     }
 
 
-    function updateBorderColorExampleBlock(editor, examplePreDiv) {
-        try {
-            JSON.parse(editor.getValue());
-            editor.getWrapperElement().style.borderWidth = "2px";
-            editor.getWrapperElement().style.borderStyle = "solid";
-            editor.getWrapperElement().style.borderColor = "green";
+   function updateBorderColorExampleBlock(editorElement, examplePreDiv) {
+    try {
+        JSON.parse(editorElement.state.doc.toString());
+        editorElement.style.borderWidth = "2px";
+        editorElement.style.borderStyle = "solid";
+        editorElement.style.borderColor = "green";
+    } catch (e) {
+        editorElement.style.borderWidth = "2px";
+        editorElement.style.borderStyle = "solid";
+        editorElement.style.borderColor = "red";
+    }
+}
 
-        } catch (e) {
-            editor.getWrapperElement().style.borderWidth = "2px";
-            editor.getWrapperElement().style.borderStyle = "solid";
-            editor.getWrapperElement().style.borderColor = "red";
 
+   function highlightErrorLines(editor, metadata, exampleJson) {
+    const { data, pointers } = jsonMapParser(exampleJson);
+    let decorations = [];
+
+    metadata.forEach(meta => {
+        var location = findObjectByPath(pointers, meta.jsonPath);
+        if (location == null) {
+            meta.jsonPath = meta.jsonPath.substring(0, meta.jsonPath.lastIndexOf('/'));
+            location = findObjectByPath(pointers, meta.jsonPath);
         }
-    }
+        const lineNumber = location.key ? location.key.line : (location.value ? location.value.line : null);
 
-    function highlightErrorLines(editor, metadata, exampleJson) {
-        const { data, pointers } = jsonMapParser(exampleJson);
-        metadata.forEach(meta => {
-            var location = findObjectByPath(pointers, meta.jsonPath);
-            if (location == null) {
-                meta.jsonPath = meta.jsonPath.substring(0, meta.jsonPath.lastIndexOf('/'));
-                location = findObjectByPath(pointers, meta.jsonPath);
-            }
-            const lineNumber = location.key ? location.key.line : (location.value ? location.value.line : null);
-            const lineLength = editor.getLine(lineNumber).length;
-            editor.markText(
-                { line: lineNumber, ch: 0 },
-                { line: lineNumber, ch: lineLength },
-                {
-                    className: "CodeMirror-lint-mark-error",
-                    attributes: {
-                        "data-validation-error-message": meta.description
-                    },
+        if (lineNumber !== null) {
+            const lineLength = editor.state.doc.line(lineNumber + 1)
+            decorations.push(
+            window.Decoration.line({
+                class: "CodeMirror-lint-mark-error",
+                attributes: { "data-validation-error-message": meta.description
                 }
+            }).range(lineLength.from)
             );
+        }
+    });
+   const decorationSet = window.Decoration.set(decorations);
+    const transaction = editor.state.update({
+        effects: setDecorationsEffect.of(decorationSet)
+    });
 
-            editor.setGutterMarker(lineNumber, "CodeMirror-lint-markers", createErrorMarker(meta.description));
-        });
-    }
-
+    editor.dispatch(transaction);
+}
     function findObjectByPath(pointers, patch) {
         for (const path in pointers) {
             if (path === patch) {
@@ -1991,6 +2054,7 @@ <h2 th:text="${contractFilePath}"></h2>
         return null;
     }
 
+
     function createErrorMarker() {
         const marker = document.createElement("div");
         marker.className = "CodeMirror-lint-mark-error";
@@ -2039,6 +2103,7 @@ <h2 th:text="${contractFilePath}"></h2>
         testDetails[key][exampleData] = data;
     }
 
+
     function getExampleTestData(tableRow) {
         const key = tableRow.getAttribute("data-key");
 

From 7dda9600b533ac7274e7160457870f83a1e8f850 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sat, 21 Dec 2024 17:30:29 +0530
Subject: [PATCH 03/14] Tooltip and highlight supports in place

---
 .../resources/templates/examples/index.html   | 128 ++++++++----------
 1 file changed, 55 insertions(+), 73 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index 364e8ff97..f422c2005 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -365,21 +365,13 @@
           height: auto;
         }
 
-        /* Make elements with the HTML hidden attribute stay hidden by default */
+
         [hidden] {
           display: none;
         }
 
-          #error-log {
-            color: red;
-            margin-top: 10px;
-            font-family: monospace;
-            white-space: pre-wrap;
-        }
-        .CodeMirror {
-            border: 1px solid #ccc;
-            height: 500px !important;
-        }
+
+
   .custom-tooltip {
   position: absolute;
   background-color: white;
@@ -397,7 +389,8 @@
 }
 
         .CodeMirror-lint-mark-error {
-            background-color: rgba(255, 0, 0, 0.2); /* Light red background for errors */
+            background-color: rgba(255, 0, 0, 0.2);
+            overflow : hidden;
         }
 
        .cm-lint-error {
@@ -427,37 +420,6 @@
         }
 
     }
-    [data-validation-error-message] {
-      position: relative;
-      display: inline-block;
-      cursor: pointer;
-    }
-
-    .CodeMirror pre.CodeMirror-line[role="presentation"] {
-        position: initial;
-    }
-
-    [data-validation-error-message]:hover::before {
-      content: attr(data-validation-error-message);
-      position: absolute;
-      top: 100%;
-      left: 0;
-      background: white;
-      color: black;
-      padding: 5px 10px;
-      border-radius: 4px;
-      font-size: 20px;
-      white-space: pre-wrap;
-      z-index: 1000;
-      box-shadow: 0 2px 4px rgba(0,0,0,0.2);
-      pointer-events: none;
-      margin-bottom: 5px;
-      border: 1px solid #ddd;
-      min-width: max-content;
-      width: auto;
-      max-width: 400px;
-      word-break: normal;
-    }
     </style>
     <style>
         @import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");
@@ -1284,7 +1246,6 @@ <h2 th:text="${contractFilePath}"></h2>
 <script>var escapedChars={b:"\b",f:"\f",n:"\n",r:"\r",t:"	",'"':'"',"/":"/","\\":"\\"},A_CODE="a".charCodeAt();const jsonMapParser=function(e,n,r){var a={},t=0,o=0,c=0,i=r&&r.bigint&&"undefined"!=typeof BigInt;return{data:function n(r,a){f(),E(r,"value");var t,o,$,g,S=l();switch(S){case"t":s("rue"),g=!0;break;case"f":s("alse"),g=!1;break;case"n":s("ull"),g=null;break;case'"':g=u();break;case"[":g=function e(r){f();var a=[],t=0;if("]"==l())return a;for(v();;){var o=r+"/"+t;a.push(n(o)),f();var c=l();if("]"==c)break;","!=c&&k(),f(),t++}return a}(r);break;case"{":g=function e(r){f();var a={};if("}"==l())return a;for(v();;){var t=d();'"'!=l()&&k();var o=u(),c=r+"/"+escapeJsonPointer(o);b(c,"key",t),E(c,"keyEnd"),f(),":"!=l()&&k(),f(),a[o]=n(c),f();var i=l();if("}"==i)break;","!=i&&k(),f()}return a}(r);break;default:v(),"-0123456789".indexOf(S)>=0?g=(t="",o=!0,"-"==e[c]&&(t+=l()),t+="0"==e[c]?l():p(),"."==e[c]&&(t+=l()+p(),o=!1),("e"==e[c]||"E"==e[c])&&(t+=l(),("+"==e[c]||"-"==e[c])&&(t+=l()),t+=p(),o=!1),$=+t,i&&o&&($>Number.MAX_SAFE_INTEGER||$<Number.MIN_SAFE_INTEGER)?BigInt(t):$):h()}return E(r,"valueEnd"),f(),a&&c<e.length&&h(),g}("",!0),pointers:a};function f(){loop:for(;c<e.length;){switch(e[c]){case" ":o++;break;case"	":o+=4;break;case"\r":o=0;break;case"\n":o=0,t++;break;default:break loop}c++}}function u(){for(var e,n="";'"'!=(e=l());)"\\"==e?(e=l())in escapedChars?n+=escapedChars[e]:"u"==e?n+=$():k():n+=e;return n}function s(e){for(var n=0;n<e.length;n++)l()!==e[n]&&k()}function l(){g();var n=e[c];return c++,o++,n}function v(){c--,o--}function $(){for(var e=4,n=0;e--;){n<<=4;var r=l().toLowerCase();r>="a"&&r<="f"?n+=r.charCodeAt()-A_CODE+10:r>="0"&&r<="9"?n+=+r:k()}return String.fromCharCode(n)}function p(){for(var n="";e[c]>="0"&&e[c]<="9";)n+=l();if(n.length)return n;g(),h()}function E(e,n){b(e,n,d())}function b(e,n,r){a[e]=a[e]||{},a[e][n]=r}function d(){return{line:t,column:o,pos:c}}function h(){throw SyntaxError("Unexpected token "+e[c]+" in JSON at position "+c)}function k(){v(),h()}function g(){if(c>=e.length)throw SyntaxError("Unexpected end of JSON input")}},jsonMapStringify=function(e,n,r){if(validType(e)){var a,t,o=0,c="object"==typeof r?r.space:r;switch(typeof c){case"number":var i=c>10?10:c<0?0:Math.floor(c);c=i&&k(i," "),a=i,t=i;break;case"string":c=c.slice(0,10),a=0,t=0;for(var f=0;f<c.length;f++){var u=c[f];switch(u){case" ":t++;break;case"	":t+=4;break;case"\r":t=0;break;case"\n":t=0,o++;break;default:throw Error("whitespace characters not allowed in JSON")}a++}break;default:c=void 0}var s="",l={},v=0,$=0,p=0,E=r&&r.es6&&"function"==typeof Map;return function e(n,r,a){switch(h(a,"value"),typeof n){case"number":case"bigint":case"boolean":b(""+n);break;case"string":b(quoted(n));break;case"object":null===n?b("null"):"function"==typeof n.toJSON?b(quoted(n.toJSON())):Array.isArray(n)?t():E?n.constructor.BYTES_PER_ELEMENT?t():n instanceof Map?i():n instanceof Set?i(!0):o():o()}function t(){if(n.length){b("[");for(var t=r+1,o=0;o<n.length;o++){o&&b(","),d(t);var c=validType(n[o])?n[o]:null;e(c,t,a+"/"+o)}d(r),b("]")}else b("[]")}function o(){var t=Object.keys(n);if(t.length){b("{");for(var o=r+1,i=0;i<t.length;i++){var f=t[i],u=n[f];if(validType(u)){i&&b(",");var s=a+"/"+escapeJsonPointer(f);d(o),h(s,"key"),b(quoted(f)),h(s,"keyEnd"),b(":"),c&&b(" "),e(u,o,s)}}d(r),b("}")}else b("{}")}function i(t){if(n.size){b("{");for(var o=r+1,i=!0,f=n.entries(),u=f.next();!u.done;){var s=u.value,l=s[0],v=!!t||s[1];if(validType(v)){i||b(","),i=!1;var $=a+"/"+escapeJsonPointer(l);d(o),h($,"key"),b(quoted(l)),h($,"keyEnd"),b(":"),c&&b(" "),e(v,o,$)}u=f.next()}d(r),b("}")}else b("{}")}h(a,"valueEnd")}(e,0,""),{json:s,pointers:l}}function b(e){$+=e.length,p+=e.length,s+=e}function d(e){if(c){for(s+="\n"+k(e,c),v++,$=0;e--;)o?(v+=o,$=t):$+=t,p+=a;p+=1}}function h(e,n){l[e]=l[e]||{},l[e][n]={line:v,column:$,pos:p}}function k(e,n){return Array(e+1).join(n)}};var VALID_TYPES=["number","bigint","boolean","string","object"];function validType(e){return VALID_TYPES.indexOf(typeof e)>=0}var ESC_QUOTE=/"|\\/g,ESC_B=/[\b]/g,ESC_F=/\f/g,ESC_N=/\n/g,ESC_R=/\r/g,ESC_T=/\t/g;function quoted(e){return'"'+(e=e.replace(ESC_QUOTE,"\\$&").replace(ESC_F,"\\f").replace(ESC_B,"\\b").replace(ESC_N,"\\n").replace(ESC_R,"\\r").replace(ESC_T,"\\t"))+'"'}var ESC_0=/~/g,ESC_1=/\//g;function escapeJsonPointer(e){return e.replace(ESC_0,"~0").replace(ESC_1,"~1")}</script>
 </body>
 <script>
-
     const mainElement = document.querySelector("main");
     const table = document.querySelector("table");
     const backBtn = document.querySelector("button#back");
@@ -1304,6 +1265,7 @@ <h2 th:text="${contractFilePath}"></h2>
     const defaultAttrs = { "data-generate": "not-generated", "data-valid": "not-validated", "data-test": "not-tested", "data-main": "false" }
     const dataValidationSuccessValues = ["success", "partial"]
     let isSaved = true;
+    let errorMetadata = [];
 
     examplesOl.addEventListener("click", (event) => {
         const target = event.target;
@@ -1884,31 +1846,7 @@ <h2 th:text="${contractFilePath}"></h2>
     },
     provide: field => window.EditorView.decorations.from(field)
 });
- const lineDecorationHoverTooltip = hoverTooltip((view, pos, side) => {
-  const decoSet = view.state.field(decorationsField);
-
-  // Loop through each decoration in the set
-  for (let deco of decoSet) {
-    // Check if the position is within the range of the decoration
-    if (deco.from <= pos && pos <= deco.to) {
-      const message = deco.spec.attributes["data-validation-error-message"];
-      if (message) {
-        return {
-          pos,
-          above: true,
-          create(view) {
-            const dom = document.createElement("div");
-            dom.className = "custom-tooltip";
-            dom.textContent = message;
-            return { dom };
-          }
-        };
-      }
-    }
-  }
 
-  return null;
-});
     const editor = new window.EditorView({
     state: window.EditorState.create({
       doc: example.exampleJson,
@@ -1921,12 +1859,14 @@ <h2 th:text="${contractFilePath}"></h2>
         window.lineNumbers,
         window.oneDark,
         decorationsField,
-        lineDecorationHoverTooltip,
         window.EditorView.updateListener.of((update) => {
         if (update.docChanged) {
           isSaved = false;
           const editorElement = editor.dom;
           updateBorderColorExampleBlock(editorElement, examplePreDiv);
+           if (example.errorList && example.errorList.length >0) {
+                highlightErrorLines(editor, example.errorList, example.exampleJson);
+                }
           savedEditorResponse = update.state.doc.toString();
         }
       })
@@ -1936,14 +1876,12 @@ <h2 th:text="${contractFilePath}"></h2>
   });
 
 
-        if (example.errorList) {
-            if (Array.isArray(example.errorList) && example.errorList.every(item => typeof item === 'object')) {
-                if(example.errorList.length >0)
+       if (example.errorList && example.errorList.length >0) {
                 highlightErrorLines(editor, example.errorList, example.exampleJson);
             } else {
                 createAlert("Example Validation Failed", example.errorMessage, true);
             }
-        }
+
 
 
         if (example.test) {
@@ -2036,6 +1974,10 @@ <h2 th:text="${contractFilePath}"></h2>
                 }
             }).range(lineLength.from)
             );
+            errorMetadata.push({
+                line: lineNumber+1,
+                message: meta.description,
+            });
         }
     });
    const decorationSet = window.Decoration.set(decorations);
@@ -2044,6 +1986,14 @@ <h2 th:text="${contractFilePath}"></h2>
     });
 
     editor.dispatch(transaction);
+     const errorTooltipExtension = createErrorTooltipExtension(errorMetadata);
+    editor.dispatch({
+        effects: setDecorationsEffect.of(decorationSet),
+    });
+    editor.dispatch({
+        effects: window.StateEffect.appendConfig.of([errorTooltipExtension]),
+    });
+
 }
     function findObjectByPath(pointers, patch) {
         for (const path in pointers) {
@@ -2053,7 +2003,39 @@ <h2 th:text="${contractFilePath}"></h2>
         }
         return null;
     }
+   const createErrorTooltipExtension = (errorMetadata) => {
+    return window.hoverTooltip((view, pos) => {
+        const line = view.state.doc.lineAt(pos);
+        const error = errorMetadata.find(err => err.line === line.number);
+        const lineCoords = view.coordsAtPos(pos);
+        if (error) {
+            return {
+                pos,
+                above: true,
+                create: () => {
+                    const tooltip = document.createElement("div");
+                    tooltip.textContent = error.message;
+                    tooltip.innerHTML = error.message.replace(/\n/g, "<br>");
+                    tooltip.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
+                    tooltip.style.color = "white";
+                    tooltip.style.padding = "5px";
+                    tooltip.style.borderRadius = "3px";
+                    tooltip.style.fontSize = "20px";
+                    tooltip.style.pointerEvents = "none";
+                    tooltip.style.display = "block";
+                    tooltip.style.width = "700px";
+                     tooltip.style.zIndex = "1000";
+                      tooltip.style.position = "fixed";
+                       tooltip.style.top = `${lineCoords.top + window.scrollY - tooltip.offsetHeight - 120}px`; // Position above the line
+                    tooltip.style.left = `${lineCoords.left + 20}px`;
+                    return { dom: tooltip};
+                },
+            };
+        }
 
+        return null;
+    });
+};
 
     function createErrorMarker() {
         const marker = document.createElement("div");

From 68c2bf4746004f9d97a390015ad3302f7b83673e Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 15:38:47 +0530
Subject: [PATCH 04/14] Tooltip and highlight supports in place

---
 .../resources/templates/examples/index.html   | 56 +++----------------
 1 file changed, 9 insertions(+), 47 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index f422c2005..fb5e2852f 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -370,55 +370,18 @@
           display: none;
         }
 
-
-
-  .custom-tooltip {
-  position: absolute;
-  background-color: white;
-  color: black;
-  padding: 5px 10px;
-  border-radius: 4px;
-  font-size: 14px;
-  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
-  z-index: 1000;
-  pointer-events: none;
-  margin-bottom: 5px;
-  border: 1px solid #ddd;
-  max-width: 300px;
-  word-break: break-word;
-}
-
         .CodeMirror-lint-mark-error {
             background-color: rgba(255, 0, 0, 0.2);
             overflow : hidden;
         }
 
-       .cm-lint-error {
-            background-color: red;
-            color: white;
-            font-size: 12px;
-            width: 20px;
-            height: 20px;
-            line-height: 20px;
-            text-align: center;
-            border-radius: 50%;
-            margin-left: -10px;
-            display: inline-block;
-            cursor: default;
-        }
-        .cm-lint-message {
-            color: red;
-            background-color: rgba(255, 0, 0, 0.2);
-            padding: 5px;
-            font-size: 12px;
-            border-radius: 3px;
-            margin-left: 30px; /* Move it a bit to the right of the gutter marker */
-            position: absolute;
-        }
          .CodeMirror-gutter-wrapper {
             position: relative;
         }
-
+    .cm-content {
+    font-size: 16px;
+    line-height: 1.5;
+}
     }
     </style>
     <style>
@@ -1224,7 +1187,7 @@ <h2 th:text="${contractFilePath}"></h2>
 <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->
 <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>-->
 <script type="module">
-import { Decoration,EditorState, EditorView, StateEffect, StateField,autocompletion, basicSetup, hoverTooltip,javascript, json,jsonParseLinter, language, lineNumbers, lintGutter, linter,oneDark,tooltips } from './codemirror-bundle.esm.js'
+import { Decoration,EditorState, EditorView, StateEffect, StateField,autocompletion, basicSetup, hoverTooltip,javascript, json,jsonParseLinter, language, lineNumbers, lintGutter, linter,oneDark } from './codemirror-bundle.esm.js'
     window.EditorState = EditorState
     window.EditorView = EditorView
     window.basicSetup = basicSetup
@@ -1239,7 +1202,6 @@ <h2 th:text="${contractFilePath}"></h2>
     window.Decoration = Decoration
     window.StateField = StateField
     window.StateEffect = StateEffect
-    window.tooltips = tooltips
     window.hoverTooltip = hoverTooltip
 
 </script>
@@ -1969,7 +1931,7 @@ <h2 th:text="${contractFilePath}"></h2>
             const lineLength = editor.state.doc.line(lineNumber + 1)
             decorations.push(
             window.Decoration.line({
-                class: "CodeMirror-lint-mark-error",
+                class: "cm-lint-mark-error CodeMirror-lint-mark-error",
                 attributes: { "data-validation-error-message": meta.description
                 }
             }).range(lineLength.from)
@@ -2016,16 +1978,16 @@ <h2 th:text="${contractFilePath}"></h2>
                     const tooltip = document.createElement("div");
                     tooltip.textContent = error.message;
                     tooltip.innerHTML = error.message.replace(/\n/g, "<br>");
-                    tooltip.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
+                    tooltip.className = "cm-tooltip cm-tooltip-lint";
                     tooltip.style.color = "white";
-                    tooltip.style.padding = "5px";
+                    tooltip.style.padding = "15px";
                     tooltip.style.borderRadius = "3px";
                     tooltip.style.fontSize = "20px";
                     tooltip.style.pointerEvents = "none";
                     tooltip.style.display = "block";
-                    tooltip.style.width = "700px";
                      tooltip.style.zIndex = "1000";
                       tooltip.style.position = "fixed";
+                      tooltip.style.borderLeft = "4px solid red";
                        tooltip.style.top = `${lineCoords.top + window.scrollY - tooltip.offsetHeight - 120}px`; // Position above the line
                     tooltip.style.left = `${lineCoords.left + 20}px`;
                     return { dom: tooltip};

From 0638e00057a09fed271a608159b4c0c7921fc539 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 19:59:18 +0530
Subject: [PATCH 05/14] Amber Validation FE

---
 .../resources/templates/examples/index.html     | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index fb5e2852f..be8e1e409 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -374,14 +374,17 @@
             background-color: rgba(255, 0, 0, 0.2);
             overflow : hidden;
         }
-
+          .CodeMirror-lint-mark-warning {
+            background-color:  rgba(255, 255, 0, 0.2);
+            overflow : hidden;
+        }
          .CodeMirror-gutter-wrapper {
             position: relative;
         }
     .cm-content {
     font-size: 16px;
     line-height: 1.5;
-}
+    }
     }
     </style>
     <style>
@@ -1929,9 +1932,13 @@ <h2 th:text="${contractFilePath}"></h2>
 
         if (lineNumber !== null) {
             const lineLength = editor.state.doc.line(lineNumber + 1)
+            const className = meta.isPartial
+                ? "cm-lint-mark-warning CodeMirror-lint-mark-warning"
+                : "cm-lint-mark-error CodeMirror-lint-mark-error";
+
             decorations.push(
             window.Decoration.line({
-                class: "cm-lint-mark-error CodeMirror-lint-mark-error",
+                class: className,
                 attributes: { "data-validation-error-message": meta.description
                 }
             }).range(lineLength.from)
@@ -1939,6 +1946,7 @@ <h2 th:text="${contractFilePath}"></h2>
             errorMetadata.push({
                 line: lineNumber+1,
                 message: meta.description,
+                isPartial: meta.isPartial
             });
         }
     });
@@ -1987,7 +1995,8 @@ <h2 th:text="${contractFilePath}"></h2>
                     tooltip.style.display = "block";
                      tooltip.style.zIndex = "1000";
                       tooltip.style.position = "fixed";
-                      tooltip.style.borderLeft = "4px solid red";
+                      tooltip.style.borderLeft = error.isPartial ? "4px solid yellow"
+                        : "4px solid red";
                        tooltip.style.top = `${lineCoords.top + window.scrollY - tooltip.offsetHeight - 120}px`; // Position above the line
                     tooltip.style.left = `${lineCoords.left + 20}px`;
                     return { dom: tooltip};

From 2402f9daa951ab10ae1bf0ce941c513b2b7547a7 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 20:12:55 +0530
Subject: [PATCH 06/14] Amber Validation FE

---
 core/src/main/resources/templates/examples/index.html | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index be8e1e409..d9616e64e 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1843,12 +1843,9 @@ <h2 th:text="${contractFilePath}"></h2>
 
        if (example.errorList && example.errorList.length >0) {
                 highlightErrorLines(editor, example.errorList, example.exampleJson);
-            } else {
-                createAlert("Example Validation Failed", example.errorMessage, true);
             }
 
 
-
         if (example.test) {
             const testPara = document.createElement("p");
             testPara.textContent = "Test Log: ";

From 330af579a1cb1d27baf6de4da70844f066b98923 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 21:27:39 +0530
Subject: [PATCH 07/14] Edge cases added

---
 core/src/main/resources/templates/examples/index.html | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index d9616e64e..ce32c23b3 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1224,6 +1224,7 @@ <h2 th:text="${contractFilePath}"></h2>
     let setDecorationsEffect;
     let decorationsField;
     let savedEditorResponse = null;
+    let originalEditorText = null;
     let scrollYPosition = 0;
     let selectedTableRow = null;
     let blockGenValidate = false;
@@ -1669,6 +1670,7 @@ <h2 th:text="${contractFilePath}"></h2>
                 isPartialFailure: tableRow.getAttribute("data-valid") === "partial",
                 test: getExampleTestData(tableRow)
             }]);
+             originalEditorText = example;
         }
 
         bulkTestBtn.classList.toggle("bulk-disabled", tableRow.getAttribute("data-valid") !== "success")
@@ -1891,11 +1893,13 @@ <h2 th:text="${contractFilePath}"></h2>
                 const errorMessage = await response.text();
                 createAlert("Failed to save example.", `Failed to save example to ${examplePath}: ${errorMessage}`, true);
                 console.error("Error saving example:", response.status);
+                savedEditorResponse = originalEditorText;
                 return false;
             }
         } catch (e) {
             console.error("Error during save request:", e);
             createAlert("Failed to save example.", `An error occurred while saving example to ${examplePath}: ${e.message}`, true);
+            savedEditorResponse = originalEditorText;
             return false;
         }
     }

From 3d197c26b55fe3fec77313bae75ba4bbf143eee0 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 21:58:04 +0530
Subject: [PATCH 08/14] Indented

---
 .../resources/templates/examples/index.html   | 4138 ++++++++++-------
 1 file changed, 2442 insertions(+), 1696 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index ce32c23b3..89aef5d23 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1,340 +1,367 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Interactive Examples</title>
-    <style>
-        *,
-        ::before,
-        ::after {
-          box-sizing: border-box;
-        }
-
-        /*
+< !DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Interactive Examples</title><style>*,
+::before,
+::after {
+    box-sizing: border-box;
+}
+
+/*
         1. Use a consistent sensible line-height in all browsers.
         2. Prevent adjustments of font size after orientation changes in iOS.
         3. Use a more readable tab size.
         4. Normalize font features
         */
 
-        :root {
-          line-height: 1.5; /* 1 */
-          text-size-adjust: 100%; /* 2: -webkit-text-size-adjust */
-          tab-size: 4; /* 3: -moz-tab-size */
-          font-feature-settings: normal; /* 4 */
-          font-variation-settings: normal; /* 4 */
-        }
+:root {
+    line-height: 1.5;
+    /* 1 */
+    text-size-adjust: 100%;
+    /* 2: -webkit-text-size-adjust */
+    tab-size: 4;
+    /* 3: -moz-tab-size */
+    font-feature-settings: normal;
+    /* 4 */
+    font-variation-settings: normal;
+    /* 4 */
+}
 
-        /*
+/*
         1. Remove the margin in all browsers.
         2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
         */
 
-        body {
-          margin: 0; /* 1 */
-          line-height: inherit; /* 2 */
-        }
+body {
+    margin: 0;
+    /* 1 */
+    line-height: inherit;
+    /* 2 */
+}
 
-        /*
+/*
         1. Add the correct height in Firefox.
         2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
         3. Ensure horizontal rules are visible by default.
         */
 
-        hr {
-          height: 0; /* 1 */
-          color: inherit; /* 2 */
-          border-top-width: 1px; /* 3 */
-        }
+hr {
+    height: 0;
+    /* 1 */
+    color: inherit;
+    /* 2 */
+    border-top-width: 1px;
+    /* 3 */
+}
 
-        /*
+/*
         Add the correct text decoration in Chrome, Edge, and Safari.
         */
 
-        abbr:where([title]) {
-          text-decoration: underline dotted;
-        }
+abbr:where([title]) {
+    text-decoration: underline dotted;
+}
 
-        /*
+/*
         Remove the default font size and weight for headings.
         */
 
-        h1,
-        h2,
-        h3,
-        h4,
-        h5,
-        h6 {
-          font-size: inherit;
-          font-weight: inherit;
-        }
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+    font-size: inherit;
+    font-weight: inherit;
+}
 
-        /*
+/*
         Reset links to optimize for opt-in styling instead of opt-out.
         */
 
-        a {
-          color: inherit;
-          text-decoration: inherit;
-        }
+a {
+    color: inherit;
+    text-decoration: inherit;
+}
 
-        /*
+/*
         Add the correct font weight in Edge and Safari.
         */
 
-        b,
-        strong {
-          font-weight: bolder;
-        }
+b,
+strong {
+    font-weight: bolder;
+}
 
-        /*
+/*
         1. Correct the odd `em` font sizing in all browsers.
         2. Use a web-safe monospace font.
         */
 
-        code,
-        kbd,
-        samp,
-        pre {
-          font-size: 1em; /* 1 */
-          font-family: 'Courier New', Courier, monospace; /* 2 */
-        }
+code,
+kbd,
+samp,
+pre {
+    font-size: 1em;
+    /* 1 */
+    font-family: 'Courier New', Courier, monospace;
+    /* 2 */
+}
 
-        /*
+/*
         Add the correct font size in all browsers.
         */
 
-        small {
-          font-size: 80%;
-        }
+small {
+    font-size: 80%;
+}
 
-        /*
+/*
         Prevent `sub` and `sup` elements from affecting the line height in all browsers.
         */
 
-        sub,
-        sup {
-          font-size: 75%;
-          line-height: 0;
-          position: relative;
-          vertical-align: baseline;
-        }
+sub,
+sup {
+    font-size: 75%;
+    line-height: 0;
+    position: relative;
+    vertical-align: baseline;
+}
 
-        sub {
-          bottom: -0.25em;
-        }
+sub {
+    bottom: -0.25em;
+}
 
-        sup {
-          top: -0.5em;
-        }
+sup {
+    top: -0.5em;
+}
 
-        /*
+/*
         1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
         2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
         3. Remove gaps between table borders by default.
         */
 
-        table {
-          text-indent: 0; /* 1 */
-          border-color: inherit; /* 2 */
-          border-collapse: collapse; /* 3 */
-        }
+table {
+    text-indent: 0;
+    /* 1 */
+    border-color: inherit;
+    /* 2 */
+    border-collapse: collapse;
+    /* 3 */
+}
 
-        /*
+/*
         1. Change the font styles in all browsers.
         2. Remove the margin in Firefox and Safari.
         3. Remove default padding in all browsers.
         */
 
-        button,
-        input,
-        optgroup,
-        select,
-        textarea {
-          font-family: inherit; /* 1 */
-          font-feature-settings: inherit; /* 1 */
-          font-variation-settings: inherit; /* 1 */
-          font-size: 100%; /* 1 */
-          font-weight: inherit; /* 1 */
-          line-height: inherit; /* 1 */
-          color: inherit; /* 1 */
-          margin: 0; /* 2 */
-          padding: 0; /* 3 */
-        }
-
-        /*
+button,
+input,
+optgroup,
+select,
+textarea {
+    font-family: inherit;
+    /* 1 */
+    font-feature-settings: inherit;
+    /* 1 */
+    font-variation-settings: inherit;
+    /* 1 */
+    font-size: 100%;
+    /* 1 */
+    font-weight: inherit;
+    /* 1 */
+    line-height: inherit;
+    /* 1 */
+    color: inherit;
+    /* 1 */
+    margin: 0;
+    /* 2 */
+    padding: 0;
+    /* 3 */
+}
+
+/*
         Remove the inheritance of text transform in Edge and Firefox.
         */
 
-        button,
-        select {
-          text-transform: none;
-        }
+button,
+select {
+    text-transform: none;
+}
 
-        /*
+/*
         1. Correct the inability to style clickable types in iOS and Safari.
         2. Remove default button styles.
         */
 
-        button,
-        [type='button'],
-        [type='reset'],
-        [type='submit'] {
-          appearance: button; /* -webkit-appearance */
-          background-color: transparent; /* 2 */
-          background-image: none; /* 2 */
-        }
+button,
+[type='button'],
+[type='reset'],
+[type='submit'] {
+    appearance: button;
+    /* -webkit-appearance */
+    background-color: transparent;
+    /* 2 */
+    background-image: none;
+    /* 2 */
+}
 
-        /*
+/*
         Use the modern Firefox focus style for all focusable elements.
         */
 
-        :-moz-focusring {
-          outline: auto;
-        }
+:-moz-focusring {
+    outline: auto;
+}
 
-        /*
+/*
         Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
         */
 
-        :-moz-ui-invalid {
-          box-shadow: none;
-        }
+:-moz-ui-invalid {
+    box-shadow: none;
+}
 
-        /*
+/*
         Add the correct vertical alignment in Chrome and Firefox.
         */
 
-        progress {
-          vertical-align: baseline;
-        }
+progress {
+    vertical-align: baseline;
+}
 
-        /*
+/*
         Correct the cursor style of increment and decrement buttons in Safari.
         */
 
-        ::-webkit-inner-spin-button,
-        ::-webkit-outer-spin-button {
-          height: auto;
-        }
+::-webkit-inner-spin-button,
+::-webkit-outer-spin-button {
+    height: auto;
+}
 
-        /*
+/*
         1. Correct the odd appearance in Chrome and Safari.
         2. Correct the outline style in Safari.
         */
 
-        [type='search'] {
-          appearance: textfield; /* -webkit-appearance */
-          outline-offset: -2px; /* 2 */
-        }
+[type='search'] {
+    appearance: textfield;
+    /* -webkit-appearance */
+    outline-offset: -2px;
+    /* 2 */
+}
 
-        /*
+/*
         Remove the inner padding in Chrome and Safari on macOS.
         */
 
-        ::-webkit-search-decoration {
-          appearance: none; /* -webkit-appeaance */
-        }
+::-webkit-search-decoration {
+    appearance: none;
+    /* -webkit-appeaance */
+}
 
-        /*
+/*
         1. Correct the inability to style clickable types in iOS and Safari.
         2. Change font properties to `inherit` in Safari.
         */
 
-        ::-webkit-file-upload-button {
-          appearance: button; /* -webkit-appearance */
-          font: inherit; /* 2 */
-        }
+::-webkit-file-upload-button {
+    appearance: button;
+    /* -webkit-appearance */
+    font: inherit;
+    /* 2 */
+}
 
-        /*
+/*
         Add the correct display in Chrome and Safari.
         */
 
-        summary {
-          display: list-item;
-        }
+summary {
+    display: list-item;
+}
 
-        /*
+/*
         Removes the default spacing and border for appropriate elements.
         */
 
-        blockquote,
-        dl,
-        dd,
-        h1,
-        h2,
-        h3,
-        h4,
-        h5,
-        h6,
-        hr,
-        figure,
-        p,
-        pre {
-          margin: 0;
-        }
+blockquote,
+dl,
+dd,
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+hr,
+figure,
+p,
+pre {
+    margin: 0;
+}
 
-        fieldset {
-          margin: 0;
-          padding: 0;
-        }
+fieldset {
+    margin: 0;
+    padding: 0;
+}
 
-        legend {
-          padding: 0;
-        }
+legend {
+    padding: 0;
+}
 
-        ol,
-        ul,
-        menu {
-          list-style: none;
-          margin: 0;
-          padding: 0;
-        }
+ol,
+ul,
+menu {
+    list-style: none;
+    margin: 0;
+    padding: 0;
+}
 
-        /*
+/*
         Reset default styling for dialogs.
         */
-        dialog {
-          padding: 0;
-        }
+dialog {
+    padding: 0;
+}
 
-        /*
+/*
         Prevent resizing textareas horizontally by default.
         */
 
-        textarea {
-          resize: vertical;
-        }
+textarea {
+    resize: vertical;
+}
 
-        /*
+/*
         1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
         2. Set the default placeholder color to gray.
         */
 
-        input::placeholder,
-        textarea::placeholder {
-          opacity: 1; /* 1 */
-          color: #9ca3af; /* 2 */
-        }
+input::placeholder,
+textarea::placeholder {
+    opacity: 1;
+    /* 1 */
+    color: #9ca3af;
+    /* 2 */
+}
 
-        /*
+/*
         Set the default cursor for buttons.
         */
 
-        button,
-        [role='button'] {
-          cursor: pointer;
-        }
+button,
+[role='button'] {
+    cursor: pointer;
+}
 
-        /*
+/*
         Make sure disabled buttons don't get the pointer cursor.
         */
-        :disabled {
-          cursor: default;
-        }
+:disabled {
+    cursor: default;
+}
 
-        /*
+/*
         1. Make replaced elements `display: block` by default.
           (https://github.com/mozdevs/cssremedy/issues/14)
         2. Add `vertical-align: middle` to align replaced elements more sensibly by default.
@@ -342,909 +369,1266 @@
            This can trigger a poorly considered lint error in some tools but is included by design.
         */
 
-        img,
-        svg,
-        video,
-        canvas,
-        audio,
-        iframe,
-        embed,
-        object {
-          display: block; /* 1 */
-          vertical-align: middle; /* 2 */
-        }
+img,
+svg,
+video,
+canvas,
+audio,
+iframe,
+embed,
+object {
+    display: block;
+    /* 1 */
+    vertical-align: middle;
+    /* 2 */
+}
 
-        /*
+/*
         Constrain images and videos to the parent width and preserve their intrinsic aspect ratio.
         (https://github.com/mozdevs/cssremedy/issues/14)
         */
 
-        img,
-        video {
-          max-width: 100%;
-          height: auto;
-        }
-
-
-        [hidden] {
-          display: none;
-        }
-
-        .CodeMirror-lint-mark-error {
-            background-color: rgba(255, 0, 0, 0.2);
-            overflow : hidden;
-        }
-          .CodeMirror-lint-mark-warning {
-            background-color:  rgba(255, 255, 0, 0.2);
-            overflow : hidden;
-        }
-         .CodeMirror-gutter-wrapper {
-            position: relative;
-        }
-    .cm-content {
-    font-size: 16px;
-    line-height: 1.5;
-    }
-    }
-    </style>
-    <style>
-        @import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");
-        @import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@200;300;400;500;600;700&display=swap");
-
-        :root {
-            /* COLORS */
-            --smoky-black: 23, 18, 7;
-            --alice-blue: 233, 241, 247;
-            /* PRIMARY COLORS */
-            --white: 255, 255, 255;
-            --black: 0, 0, 0;
-            --slate: 241, 245, 249;
-            --yellow: 255, 207, 51;
-            --blue: 52, 115, 217;
-            --green: 34, 197, 94;
-            --red: 239, 68, 68;
-            --blue-dark: 29, 78, 216;
-            --gray: 128, 128, 128;
-            /* PILL COLORS */
-            --pill-green: 134, 239, 172;
-            --pill-red: 252, 165, 165;
-
-            /* Font Families */
-            --sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
-            --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
-            --roboto: "Roboto", var(--mono), var(--sans);
-
-            /* Shadows */
-            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
-            --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
-            --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
-        }
-
-        html {
-            scroll-behavior: smooth;
-            scrollbar-gutter: stable;
-        }
-
-        body {
-            font-family: var(--roboto);
-
-            & > .chevron {
-                display: none;
-            }
-        }
-
-        main {
-            display: flex;
-            align-items: start;
-            overflow: hidden;
-            flex: 1;
-            background-color: rgba(var(--alice-blue));
-        }
-
-        .chevron {
-            width: 1.5rem;
-            height: 1.5rem;
-            animation: bounce 2s infinite;
-        }
+img,
+video {
+    max-width: 100%;
+    height: auto;
+}
 
-        /* HEADER STYLES */
 
-        header {
-            display: flex;
-            flex-direction: column;
-            justify-content: center;
-            align-items: center;
-            gap: .25rem;
-            padding-bottom: .5rem;
+[hidden] {
+    display: none;
+}
 
-            & > #main-info {
-                display: flex;
-                text-align: center;
-                flex-direction: column;
+.CodeMirror-lint-mark-error {
+    background-color: rgba(255, 0, 0, 0.2);
+    overflow: hidden;
+}
 
-                & > h1 {
-                    font-size: 1.5rem;
-                    font-weight: 600;
-                    font-family: var(--roboto);
-                    letter-spacing: 0.025rem;
-                }
+.CodeMirror-lint-mark-warning {
+    background-color: rgba(255, 255, 0, 0.2);
+    overflow: hidden;
+}
 
-                & > h2 {
-                    font-size: 0.75rem;
-                    font-weight: 400;
-                    font-family: var(--mono);
-                }
-            }
+.CodeMirror-gutter-wrapper {
+    position: relative;
+}
 
-            & .btn-grp {
-                display: flex;
-                align-items: center;
-                gap: 1rem;
+.cm-content {
+    font-size: 16px;
+    line-height: 1.5;
+}
+}
 
-                &[data-test-mode="false"] > #bulk-test {
-                    display: none;
-                }
-            }
+</style><style>@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");
+@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@200;300;400;500;600;700&display=swap");
+
+:root {
+    /* COLORS */
+    --smoky-black: 23, 18, 7;
+    --alice-blue: 233, 241, 247;
+    /* PRIMARY COLORS */
+    --white: 255, 255, 255;
+    --black: 0, 0, 0;
+    --slate: 241, 245, 249;
+    --yellow: 255, 207, 51;
+    --blue: 52, 115, 217;
+    --green: 34, 197, 94;
+    --red: 239, 68, 68;
+    --blue-dark: 29, 78, 216;
+    --gray: 128, 128, 128;
+    /* PILL COLORS */
+    --pill-green: 134, 239, 172;
+    --pill-red: 252, 165, 165;
+
+    /* Font Families */
+    --sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
+    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
+    --roboto: "Roboto", var(--mono), var(--sans);
+
+    /* Shadows */
+    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
+    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
+    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
+}
 
-            & button {
-                --_radius: 0.25rem;
-                --_background-color: var(--blue);
-
-                color: white;
-                padding: var(--_padding);
-                background-color: rgba(var(--_background-color));
-                border-radius: var(--_radius);
-                padding: .5rem 1rem;
-                min-width: 9rem;
-                display: flex;
-                align-items: center;
-                justify-content: space-around;
-                gap: .1rem;
-
-                &#bulk-validate {
-                    --_content: "Validate Selected";
-
-                    &[data-panel="details"] {
-                        --_content: "Save & Validate";
-                    }
-                }
+html {
+    scroll-behavior: smooth;
+    scrollbar-gutter: stable;
+}
 
-                &[data-selected="0"][data-panel="table"], &.bulk-disabled {
-                    --_background-color: var(--gray);
-                    pointer-events: none;
-                }
+body {
+    font-family: var(--roboto);
 
-                &[data-panel="table"]::after, &[data-panel="details"]::after  {
-                    content: var(--_content);
-                }
+    &>.chevron {
+        display: none;
+    }
+}
 
-                &[data-selected][data-panel="table"]::before {
-                    content: var(--_after_content, " (" attr(data-selected) ") ");
-                    color: white;
-                }
+main {
+    display: flex;
+    align-items: start;
+    overflow: hidden;
+    flex: 1;
+    background-color: rgba(var(--alice-blue));
+}
 
-                /* Temporarily Remove Selected Count */
-                &#bulk-generate[data-selected][data-panel="table"]::before {
-                    content: var(--_after_content);
-                    color: white;
-                }
+.chevron {
+    width: 1.5rem;
+    height: 1.5rem;
+    animation: bounce 2s infinite;
+}
 
-                &#bulk-generate {
-                    --_content: "Generate Selected";
+/* HEADER STYLES */
 
-                    &::after {
-                        content: var(--_content, "Generate Selected");
-                    }
+header {
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+    gap: .25rem;
+    padding-bottom: .5rem;
 
-                    &[data-panel="details"] {
-                        --_background-color: var(--gray);
-                        pointer-events: none;
-                    }
-                }
+    &>#main-info {
+        display: flex;
+        text-align: center;
+        flex-direction: column;
 
-                &#bulk-test {
-                    --_content: "Test Selected";
+        &>h1 {
+            font-size: 1.5rem;
+            font-weight: 600;
+            font-family: var(--roboto);
+            letter-spacing: 0.025rem;
+        }
 
-                    &[data-panel="details"] {
-                        --_content: "Test Examples";
-                    }
-                }
+        &>h2 {
+            font-size: 0.75rem;
+            font-weight: 400;
+            font-family: var(--mono);
+        }
+    }
 
-                &[data-valid="processing"],
-                &[data-generate="processing"],
-                &[data-test="processing"] {
-                    pointer-events: none;
-
-                    &::after {
-                        --_content: "";
-                        width: 24px;
-                        height: 24px;
-                        border: 3px solid #FFF;
-                        border-bottom-color: transparent;
-                        border-radius: 50%;
-                        display: inline-flex;
-                        animation: rotation 1s linear infinite;
-                    }
+    & .btn-grp {
+        display: flex;
+        align-items: center;
+        gap: 1rem;
 
-                    &::before {
-                        --_after_content: "Processing";
-                    }
-                }
-            }
+        &[data-test-mode="false"]>#bulk-test {
+            display: none;
         }
+    }
 
-        /* TABLE STYLES */
+    & button {
+        --_radius: 0.25rem;
+        --_background-color: var(--blue);
 
-        table {
-            width: 100%;
-            table-layout: auto;
-            text-align: center;
-            font-size: 0.99rem;
-            counter-reset: Serial;
-        }
+        color: white;
+        padding: var(--_padding);
+        background-color: rgba(var(--_background-color));
+        border-radius: var(--_radius);
+        padding: .5rem 1rem;
+        min-width: 9rem;
+        display: flex;
+        align-items: center;
+        justify-content: space-around;
+        gap: .1rem;
 
-        thead {
-            background: rgb(var(--slate));
-            font-weight: 500;
-            border-collapse: collapse;
-            font-family: var(--roboto);
+        &#bulk-validate {
+            --_content: "Validate Selected";
 
-            & > tr > th:not(:first-child) {
-                pointer-events: none;
+            &[data-panel="details"] {
+                --_content: "Save & Validate";
             }
         }
 
-        th {
-            white-space: nowrap;
+        &[data-selected="0"][data-panel="table"],
+        &.bulk-disabled {
+            --_background-color: var(--gray);
+            pointer-events: none;
         }
 
-        td,
-        th {
-            --_td-padding: 0.75rem;
-
-            border: 1px solid rgba(var(--smoky-black), 0.2);
-            padding: var(--_td-padding);
+        &[data-panel="table"]::after,
+        &[data-panel="details"]::after {
+            content: var(--_content);
         }
 
-        .response-cell {
-            & > span {
-                font-size: 0.75rem;
-            }
+        &[data-selected][data-panel="table"]::before {
+            content: var(--_after_content, " (" attr(data-selected) ") ");
+            color: white;
         }
 
-        tbody {
-            background-color: rgb(var(--white));
-            font-family: var(--mono);
-            font-weight: 500;
-
-            & > tr {
-                &:hover {
-                    background-color: rgb(var(--slate));
-                }
-
-                & > td:nth-child(n+3):nth-last-child(n+3) {
-                    background-color: rgb(var(--white));
-                    word-break: break-word;
-                    pointer-events: none;
-                }
-
-                & > td:nth-last-child(-n + 3) {
-                    cursor: pointer;
-                }
-            }
+        /* Temporarily Remove Selected Count */
+        &#bulk-generate[data-selected][data-panel="table"]::before {
+            content: var(--_after_content);
+            color: white;
         }
 
-        tbody > tr {
-            & button {
-                --_padding: 0.5rem 0rem;
-                --_background-color: var(--blue);
-                --_text-color: var(--white);
-                --_width: 7rem;
-                --_font-size: 1rem;
-                --_radius: 0.5rem;
+        &#bulk-generate {
+            --_content: "Generate Selected";
 
-                padding: var(--_padding);
-                display: inline-block;
-                width: var(--_width);
-                border-radius: var(--_radius);
-                color: rgb(var(--_text-color));
-                background-color: rgba(var(--_background-color));
-                font-size: var(--_font-size);
-
-                &:hover {
-                    --_background-color: var(--blue-dark);
-                }
+            &::after {
+                content: var(--_content, "Generate Selected");
             }
 
-            & > td:nth-child(2)::before {
-                content: counter(Serial);
-                counter-increment: Serial;
+            &[data-panel="details"] {
+                --_background-color: var(--gray);
+                pointer-events: none;
             }
+        }
 
-            & > td:last-child {
-                & > span {
-                    font-size: .75rem;
-                    line-height: 1.5rem;
-                    text-decoration: underline;
-                }
-            }
+        &#bulk-test {
+            --_content: "Test Selected";
 
-            &[data-valid="partial"] button.validate {
-                --_background-color: var(--yellow);
-                --_text-color: var(--smoky-black);
+            &[data-panel="details"] {
+                --_content: "Test Examples";
             }
+        }
 
-            &[data-valid="failed"] button.validate, &[data-generate="failed"] button.generate, &[data-test="failed"] button.test {
-                --_background-color: var(--red);
-            }
+        &[data-valid="processing"],
+        &[data-generate="processing"],
+        &[data-test="processing"] {
+            pointer-events: none;
 
-            &[data-valid="success"] button.validate, &[data-test="success"] button.test {
-                --_background-color: var(--green);
+            &::after {
+                --_content: "";
+                width: 24px;
+                height: 24px;
+                border: 3px solid #FFF;
+                border-bottom-color: transparent;
+                border-radius: 50%;
+                display: inline-flex;
+                animation: rotation 1s linear infinite;
             }
 
-            &[data-generate="success"], &[data-example] {
-                & td:last-child {
-                    & button.validate {
-                        display: inline-block;
-                    }
-
-                    & > span {
-                        display: block;
-                    }
-                }
+            &::before {
+                --_after_content: "Processing";
             }
+        }
+    }
+}
 
-            &[data-generate="processing"] button, &[data-valid="processing"] button.validate, &[data-test="processing"] button.test {
-                --_padding: 0.15rem 0rem;
-                --_background-color: var(--blue) !important;
-
-                &::after {
-                    --_content: "";
-                    margin-top: 5px;
-                    width: 24px;
-                    height: 24px;
-                    border: 3px solid #FFF;
-                    border-bottom-color: transparent;
-                    border-radius: 50%;
-                    display: inline-block;
-                    animation: rotation 1s linear infinite;
-                }
-            }
+/* TABLE STYLES */
 
-            & button.generate::after {
-                content: var(--_content, "Generate");
-            }
+table {
+    width: 100%;
+    table-layout: auto;
+    text-align: center;
+    font-size: 0.99rem;
+    counter-reset: Serial;
+}
 
-            & button.validate::after {
-                content: var(--_content, "Validate");
-            }
+thead {
+    background: rgb(var(--slate));
+    font-weight: 500;
+    border-collapse: collapse;
+    font-family: var(--roboto);
 
-            & button.test::after {
-                content: var(--_content, "Test");
-            }
+    &>tr>th:not(:first-child) {
+        pointer-events: none;
+    }
+}
 
-            &[data-generate="success"] > td:nth-last-child(3) {
-                pointer-events: all;
+th {
+    white-space: nowrap;
+}
 
-                & > button.multigen {
-                    --_padding: 0.35rem 0.35rem;
-                    --_font-size: 0.75rem;
-                    --_radius: 0.35rem;
-                    display: inline-block;
+td,
+th {
+    --_td-padding: 0.75rem;
 
-                    &::after {
-                        content: var(--_content, "Generate More");
-                    }
-                }
-            }
-        }
+    border: 1px solid rgba(var(--smoky-black), 0.2);
+    padding: var(--_td-padding);
+}
 
+.response-cell {
+    &>span {
+        font-size: 0.75rem;
+    }
+}
 
-        tbody {
-            &[data-test-mode="true"] > tr[data-valid="success"] {
-                & td:last-child {
-                    & button.validate {
-                        display: none;
-                    }
+tbody {
+    background-color: rgb(var(--white));
+    font-family: var(--mono);
+    font-weight: 500;
 
-                    & button.test {
-                        display: inline-block;
-                    }
-                }
-            }
+    &>tr {
+        &:hover {
+            background-color: rgb(var(--slate));
         }
 
-        td:nth-child(3) {
-            text-align: initial;
-            min-width: 10rem;
+        &>td:nth-child(n+3):nth-last-child(n+3) {
+            background-color: rgb(var(--white));
+            word-break: break-word;
+            pointer-events: none;
         }
 
-        td:nth-child(4) {
-            min-width: 2rem;
+        &>td:nth-last-child(-n + 3) {
+            cursor: pointer;
         }
+    }
+}
 
-        td:last-child {
-            max-width: 9rem;
+tbody>tr {
+    & button {
+        --_padding: 0.5rem 0rem;
+        --_background-color: var(--blue);
+        --_text-color: var(--white);
+        --_width: 7rem;
+        --_font-size: 1rem;
+        --_radius: 0.5rem;
+
+        padding: var(--_padding);
+        display: inline-block;
+        width: var(--_width);
+        border-radius: var(--_radius);
+        color: rgb(var(--_text-color));
+        background-color: rgba(var(--_background-color));
+        font-size: var(--_font-size);
+
+        &:hover {
+            --_background-color: var(--blue-dark);
         }
+    }
 
-        td:nth-last-child(2) {
-            max-width: 15rem;
-            word-break: break-word;
-            font-size: .85rem;
-        }
+    &>td:nth-child(2)::before {
+        content: counter(Serial);
+        counter-increment: Serial;
+    }
 
-        td p, td button {
-            white-space: nowrap;
-            min-width: fit-content;
+    &>td:last-child {
+        &>span {
+            font-size: .75rem;
+            line-height: 1.5rem;
+            text-decoration: underline;
         }
+    }
 
-        button {
-            border: none;
-
-            &:active {
-                scale: 0.9;
-            }
-        }
+    &[data-valid="partial"] button.validate {
+        --_background-color: var(--yellow);
+        --_text-color: var(--smoky-black);
+    }
 
-        /* TABLE AND DETAILS TRANSITIONS */
+    &[data-valid="failed"] button.validate,
+    &[data-generate="failed"] button.generate,
+    &[data-test="failed"] button.test {
+        --_background-color: var(--red);
+    }
 
-        table,
-        #details {
-            transition: transform 0.5s ease-in-out;
-            min-width: 100%;
-        }
+    &[data-valid="success"] button.validate,
+    &[data-test="success"] button.test {
+        --_background-color: var(--green);
+    }
 
-        .group[data-panel="table"] {
-            & > #details {
-                transform: translateX(100%);
+    &[data-generate="success"],
+    &[data-example] {
+        & td:last-child {
+            & button.validate {
+                display: inline-block;
             }
-        }
 
-        .group[data-panel="details"] {
-            & > table {
-                transform: translateX(-100%);
+            &>span {
+                display: block;
             }
+        }
+    }
 
-            & > #details {
-                transform: translateX(-100%);
-            }
+    &[data-generate="processing"] button,
+    &[data-valid="processing"] button.validate,
+    &[data-test="processing"] button.test {
+        --_padding: 0.15rem 0rem;
+        --_background-color: var(--blue) !important;
+
+        &::after {
+            --_content: "";
+            margin-top: 5px;
+            width: 24px;
+            height: 24px;
+            border: 3px solid #FFF;
+            border-bottom-color: transparent;
+            border-radius: 50%;
+            display: inline-block;
+            animation: rotation 1s linear infinite;
         }
+    }
 
-        /* DETAILS STYLES */
+    & button.generate::after {
+        content: var(--_content, "Generate");
+    }
 
-        #details {
-            padding: 0.5rem;
-        }
+    & button.validate::after {
+        content: var(--_content, "Validate");
+    }
 
-        button#back {
-            --_padding: 0.5rem 1rem;
-            --_radius: 0.25rem;
+    & button.test::after {
+        content: var(--_content, "Test");
+    }
 
-            color: white;
-            padding: var(--_padding);
-            background-color: rgba(var(--blue));
-            border-radius: var(--_radius);
+    &[data-generate="success"]>td:nth-last-child(3) {
+        pointer-events: all;
 
-            &:hover,
-            &:focus {
-                background-color: rgba(var(--blue-dark));
+        &>button.multigen {
+            --_padding: 0.35rem 0.35rem;
+            --_font-size: 0.75rem;
+            --_radius: 0.35rem;
+            display: inline-block;
+
+            &::after {
+                content: var(--_content, "Generate More");
             }
         }
-        button#save-example {
-            position: relative;
-            margin-top: 10px;
-            left: 50%;
-            transform: translate(-50%, 10%);
-            --_padding: 0.5rem 3rem;
-            --_radius: 0.25rem;
+    }
+}
 
-            color: white;
-            padding: var(--_padding);
-            background-color: rgba(var(--blue));
-            border-radius: var(--_radius);
 
-            &:hover, &:focus {
-                background-color: rgba(var(--blue-dark));
+tbody {
+    &[data-test-mode="true"]>tr[data-valid="success"] {
+        & td:last-child {
+            & button.validate {
+                display: none;
             }
-        }
 
-        #path-details {
-            display: flex;
-            align-items: center;
-            gap: 1rem;
+            & button.test {
+                display: inline-block;
+            }
         }
+    }
+}
 
-        #path-summary {
-            flex: 1;
-            display: flex;
-            padding: 0.5rem 1rem;
-            align-items: center;
-            justify-content: space-between;
-            gap: 1rem;
-            background-color: rgba(var(--white));
-            border: 1px solid rgba(var(--smoky-black), 0.25);
-            border-radius: 0.25rem;
+td:nth-child(3) {
+    text-align: initial;
+    min-width: 10rem;
+}
 
-            & > li > span:first-of-type {
-                font-weight: 300;
-                text-transform: capitalize;
+td:nth-child(4) {
+    min-width: 2rem;
+}
 
-                &::after {
-                    content: ": ";
-                }
-            }
+td:last-child {
+    max-width: 9rem;
+}
 
-            & > li > span:last-of-type {
-                font-weight: 400;
-                word-break: break-word;
-            }
-        }
+td:nth-last-child(2) {
+    max-width: 15rem;
+    word-break: break-word;
+    font-size: .85rem;
+}
 
-        /* EXAMPLE STYLES */
+td p,
+td button {
+    white-space: nowrap;
+    min-width: fit-content;
+}
 
-        ol#examples {
-            margin-top: 1rem;
-            display: flex;
-            flex-direction: column;
-            gap: 1rem;
+button {
+    border: none;
 
-            & > li {
-                background-color: rgba(var(--white));
-                border-radius: 0.25rem;
-                border: 1px solid rgba(var(--smoky-black), 0.25);
-                box-shadow: var(--shadow-md);
-                padding: 0rem 1rem 1rem 1rem;
-            }
-        }
+    &:active {
+        scale: 0.9;
+    }
+}
 
-        div.example {
-            display: flex;
-            align-items: center;
-            justify-content: space-between;
-            padding: 0.5rem;
+/* TABLE AND DETAILS TRANSITIONS */
 
-            & > p {
-                word-break: break-all;
-                margin-right: 4rem;
-                flex: 1;
-            }
+table,
+#details {
+    transition: transform 0.5s ease-in-out;
+    min-width: 100%;
+}
 
-            & > .expand-info {
-                display: flex;
-                align-items: center;
-                gap: .25rem;
-            }
-        }
+.group[data-panel="table"] {
+    &>#details {
+        transform: translateX(100%);
+    }
+}
 
-        div.details {
-            display: flex;
-            flex-direction: column;
-            gap: 0.5rem;
+.group[data-panel="details"] {
+    &>table {
+        transform: translateX(-100%);
+    }
 
-            & pre {
-                white-space: pre-wrap;
-                font-family: var(--mono);
-                background-color: rgba(var(--slate));
-                border-radius: 0.25rem;
-                padding: 0.75rem;
-                display: none;
-            }
-        }
+    &>#details {
+        transform: translateX(-100%);
+    }
+}
 
-        div.details > div.dropdown {
-            display: flex;
-            align-items: center;
-            justify-content: space-between;
-            padding: 0.5rem;
-            font-family: var(--mono);
-            background-color: rgba(var(--slate));
-            cursor: pointer;
-        }
+/* DETAILS STYLES */
 
-        div.details.expanded {
-            & > div.dropdown {
-                margin-bottom: 1rem;
+#details {
+    padding: 0.5rem;
+}
 
-                & .chevron {
-                    animation: none;
-                    transform: rotate(180deg);
-                }
-            }
+button#back {
+    --_padding: 0.5rem 1rem;
+    --_radius: 0.25rem;
 
-            & pre {
-                display: block;
-            }
-        }
+    color: white;
+    padding: var(--_padding);
+    background-color: rgba(var(--blue));
+    border-radius: var(--_radius);
 
-        .pill {
-            --_pill-padding: 0.5rem 1.25rem;
-            --_pill-radius: 0.5rem;
-            --_background-color: rgb(var(--gray));
+    &:hover,
+    &:focus {
+        background-color: rgba(var(--blue-dark));
+    }
+}
 
-            padding: var(--_pill-padding);
-            border-radius: var(--_pill-radius);
-            background-color: var(--_background-color);
-            text-transform: capitalize;
-            font-weight: 500;
-            flex-shrink: 0;
-            color: white;
-        }
+button#save-example {
+    position: relative;
+    margin-top: 10px;
+    left: 50%;
+    transform: translate(-50%, 10%);
+    --_padding: 0.5rem 3rem;
+    --_radius: 0.25rem;
+
+    color: white;
+    padding: var(--_padding);
+    background-color: rgba(var(--blue));
+    border-radius: var(--_radius);
+
+    &:hover,
+    &:focus {
+        background-color: rgba(var(--blue-dark));
+    }
+}
 
-        .pill.red {
-            --_background-color: rgb(var(--pill-red));
-            color: black;
-        }
+#path-details {
+    display: flex;
+    align-items: center;
+    gap: 1rem;
+}
 
-        .pill.green {
-            --_background-color: rgb(var(--pill-green));
-            color: black;
-        }
+#path-summary {
+    flex: 1;
+    display: flex;
+    padding: 0.5rem 1rem;
+    align-items: center;
+    justify-content: space-between;
+    gap: 1rem;
+    background-color: rgba(var(--white));
+    border: 1px solid rgba(var(--smoky-black), 0.25);
+    border-radius: 0.25rem;
+
+    &>li>span:first-of-type {
+        font-weight: 300;
+        text-transform: capitalize;
 
-        .pill.yellow {
-            --_background-color: rgb(var(--yellow));
-            color: black;
+        &::after {
+            content: ": ";
         }
+    }
 
-        /* ALERT STYLES */
+    &>li>span:last-of-type {
+        font-weight: 400;
+        word-break: break-word;
+    }
+}
 
-        #alert-container {
-            z-index: 1;
-            background-color: rgba(var(--white));
-        }
+/* EXAMPLE STYLES */
 
-        .alert-msg {
-            --_before-content: "⚠";
-            --_text-color: rgba(var(--smoky-black));
-            --_border-color: rgba(var(--smoky-black), 0.1);
+ol#examples {
+    margin-top: 1rem;
+    display: flex;
+    flex-direction: column;
+    gap: 1rem;
 
-            max-width: 75%;
-            border: 1px solid var(--_border-color);
-            background-color: rgba(var(--white));
-            box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
-            top: 20px;
-            left: 20px;
-            padding: 1rem;
-            position: fixed;
-            z-index: 10;
+    &>li {
+        background-color: rgba(var(--white));
+        border-radius: 0.25rem;
+        border: 1px solid rgba(var(--smoky-black), 0.25);
+        box-shadow: var(--shadow-md);
+        padding: 0rem 1rem 1rem 1rem;
+    }
+}
 
-            & > p::before {
-                content: var(--_before-content);
-                word-break: break-word;
-                font-weight: bold;
-                padding-right: 0.5rem;
-                color: var(--_text-color);
-            }
+div.example {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: 0.5rem;
 
-            & > pre {
-                word-break: break-word;
-                white-space: pre-wrap;
-            }
-        }
+    &>p {
+        word-break: break-all;
+        margin-right: 4rem;
+        flex: 1;
+    }
 
-        .alert-msg.green {
-            --_before-content: "✓";
-            --_text-color: rgba(var(--green));
-            --_border-color: rgba(var(--green));
-        }
+    &>.expand-info {
+        display: flex;
+        align-items: center;
+        gap: .25rem;
+    }
+}
 
-        .alert-msg.red {
-            --_before-content: "✗";
-            --_text-color: rgba(var(--red));
-            --_border-color: rgba(var(--red));
-        }
+div.details {
+    display: flex;
+    flex-direction: column;
+    gap: 0.5rem;
+
+    & pre {
+        white-space: pre-wrap;
+        font-family: var(--mono);
+        background-color: rgba(var(--slate));
+        border-radius: 0.25rem;
+        padding: 0.75rem;
+        display: none;
+    }
+}
 
-        .slide-in {
-            animation: slideIn 0.5s;
-        }
+div.details>div.dropdown {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: 0.5rem;
+    font-family: var(--mono);
+    background-color: rgba(var(--slate));
+    cursor: pointer;
+}
+
+div.details.expanded {
+    &>div.dropdown {
+        margin-bottom: 1rem;
 
-        .slide-out {
-            animation: slideOut 0.5s;
+        & .chevron {
+            animation: none;
+            transform: rotate(180deg);
         }
+    }
 
-        @keyframes slideIn {
-            from {
-                transform: translateX(-200%);
-            }
+    & pre {
+        display: block;
+    }
+}
+
+.pill {
+    --_pill-padding: 0.5rem 1.25rem;
+    --_pill-radius: 0.5rem;
+    --_background-color: rgb(var(--gray));
+
+    padding: var(--_pill-padding);
+    border-radius: var(--_pill-radius);
+    background-color: var(--_background-color);
+    text-transform: capitalize;
+    font-weight: 500;
+    flex-shrink: 0;
+    color: white;
+}
+
+.pill.red {
+    --_background-color: rgb(var(--pill-red));
+    color: black;
+}
+
+.pill.green {
+    --_background-color: rgb(var(--pill-green));
+    color: black;
+}
+
+.pill.yellow {
+    --_background-color: rgb(var(--yellow));
+    color: black;
+}
+
+/* ALERT STYLES */
+
+#alert-container {
+    z-index: 1;
+    background-color: rgba(var(--white));
+}
+
+.alert-msg {
+    --_before-content: "⚠";
+    --_text-color: rgba(var(--smoky-black));
+    --_border-color: rgba(var(--smoky-black), 0.1);
+
+    max-width: 75%;
+    border: 1px solid var(--_border-color);
+    background-color: rgba(var(--white));
+    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
+    top: 20px;
+    left: 20px;
+    padding: 1rem;
+    position: fixed;
+    z-index: 10;
+
+    &>p::before {
+        content: var(--_before-content);
+        word-break: break-word;
+        font-weight: bold;
+        padding-right: 0.5rem;
+        color: var(--_text-color);
+    }
+
+    &>pre {
+        word-break: break-word;
+        white-space: pre-wrap;
+    }
+}
+
+.alert-msg.green {
+    --_before-content: "✓";
+    --_text-color: rgba(var(--green));
+    --_border-color: rgba(var(--green));
+}
+
+.alert-msg.red {
+    --_before-content: "✗";
+    --_text-color: rgba(var(--red));
+    --_border-color: rgba(var(--red));
+}
+
+.slide-in {
+    animation: slideIn 0.5s;
+}
+
+.slide-out {
+    animation: slideOut 0.5s;
+}
+
+@keyframes slideIn {
+    from {
+        transform: translateX(-200%);
+    }
+
+    to {
+        transform: translateX(0);
+    }
+}
+
+@keyframes slideOut {
+    from {
+        transform: translateX(0);
+    }
+
+    to {
+        transform: translateX(-200%);
+    }
+}
+
+@keyframes rotation {
+    0% {
+        transform: rotate(0deg);
+    }
+
+    100% {
+        transform: rotate(360deg);
+    }
+}
+
+@keyframes bounce {
+
+    0%,
+    100% {
+        transform: translateY(-25%);
+        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
+    }
+
+    50% {
+        transform: translateY(0);
+        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
+    }
+}
+
+/* UTILITIES */
+
+.hidden {
+    display: none;
+}
+
+</style></head><body><header><div id="main-info"><h1 th:text="${contractFile}"></h1><h2 th:text="${contractFilePath}"></h2></div><div class="btn-grp" th:attr="data-test-mode=${isTestMode}"><button data-selected="0" id="bulk-generate" data-panel="table"></button><button data-selected="0" data-panel="table" id="bulk-validate"></button><button data-selected="0" data-panel="table" id="bulk-test"></button></div></header><main class="group" data-panel="table"><table th:attr="data-generated=${hasExamples},data-hostPort=${hostPort}"><thead><tr><th><label for="select-all"><input type="checkbox" name="select-all" id="select-all"></label></th><th>S. No</th><th colspan="3">Path</th><th>Method</th><th>Response</th><th>Examples</th><th>Action</th></tr></thead><tbody th:attr="data-test-mode=${isTestMode}"><tr th:each="row, iter : ${tableRows}"
+
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      th:attr="data-raw-path=${row.rawPath}, data-key=${row.uniqueKey}, data-schema-based=${row.isSchemaBased},
+ data-example=$ {
+    row.example
+}
+
+,
+data-main=$ {
+    row.isMainRow
+}
+
+,
+data-disc=$ {
+    row.isDiscriminatorBased
+}
 
-            to {
-                transform: translateX(0);
+,
+data-generate=$ {
+    row.isGenerated ? 'success': 'not-generated'
+}
+
+,
+data-test='not-tested',
+data-valid=$ {
+    row.isGenerated ? (row.isValid ? 'success' : row.isPartialFailure ? 'partial' : 'failed'): 'not-validated'
+}
+
+">
+    <td><input type="checkbox" name="path-row" class="path-row"></td><td></td><td th:class="${row.showPath ? '' : 'hidden'}" th:attr="rowspan=${row.pathSpan}, colspan=${row.pathColSpan}"><span>[[$ {
+    row.path
+}
+
+]]</span></td><td th:class="${row.showMethod ? '' : 'hidden'}" th:attr="rowspan=${row.methodSpan}, colspan=${row.methodColSpan}"><p>[[$ {
+    row.method
+    }
+
+    ]]</p></td><td class="response-cell" th:classappend="${row.showStatus ? '' : 'hidden'}" th:attr="rowspan=${row.statusSpan}"><p>[[$ {
+    row.responseStatus
+    }
+
+    ]]</p><span>[[$ {
+    row.contentType
+}
+
+]]</span><br th:if="${row.contentType != null}" /><button class="multigen hidden" aria-label="Generate More"></button></td><td><button th:unless="${row.isGenerated}" class="generate" aria-label="Generate"></button><span th:if="${row.isGenerated}" th:text="${row.exampleName}"></span></td><td><button class="validate hidden" aria-label="Validate"></button><button class="test hidden" aria-label="Test"></button><span th:class="hidden">View Details</span></td></tr></tbody></table><div id="details"><div id="path-details"><button id="back" tabindex="-1"><span>&larr;
+</span><span>Go Back</span></button><ul id="path-summary"></ul></div><ol id="examples"></ol></div></main><div id="alert-container"></div><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="chevron"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 5.25 7.5 7.5 7.5-7.5m-15 6 7.5 7.5 7.5-7.5" /></svg><script th:inline="javascript">const exampleDetails=
+
+/*[[${exampleDetails}]]*/
+    {}
+
+;
+
+const testDetails= {}
+
+;
+
+</script><script src="https://cdnjs.cloudflare.com/ajax/libs/jsonlint/1.6.0/jsonlint.min.js"></script>< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">-->< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">-->< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">-->< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/addon/lint/lint.min.css">-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>--><script type="module">import {
+    Decoration,
+    EditorState,
+    EditorView,
+    StateEffect,
+    StateField,
+    autocompletion,
+    basicSetup,
+    hoverTooltip,
+    javascript,
+    json,
+    jsonParseLinter,
+    language,
+    lineNumbers,
+    lintGutter,
+    linter,
+    oneDark
+}
+
+from './codemirror-bundle.esm.js'
+
+window.EditorState=EditorState window.EditorView=EditorView window.basicSetup=basicSetup window.javascript=javascript() window.autocompletion=autocompletion() window.oneDark=oneDark window.language=language window.lineNumbers=lineNumbers() window.lintGutter=lintGutter() window.json=json() window.linter=linter(jsonParseLinter()) window.Decoration=Decoration window.StateField=StateField window.StateEffect=StateEffect window.hoverTooltip=hoverTooltip </script><script>var escapedChars= {
+    b: "\b", f:"\f", n:"\n", r:"\r", t:"	", '"':'"', "/":"/", "\\":"\\"
+}
+
+,
+A_CODE="a" .charCodeAt();
+
+const jsonMapParser=function(e, n, r) {
+    var a= {}
+
+    ,
+    t=0,
+    o=0,
+    c=0,
+    i=r&&r.bigint&&"undefined" !=typeof BigInt;
+
+    return {
+        data:function n(r, a) {
+            f(),
+            E(r, "value");
+            var t,
+            o,
+            $,
+            g,
+            S=l();
+
+            switch(S) {
+                case"t": s("rue"), g= !0;
+                break;
+                case"f": s("alse"), g= !1;
+                break;
+                case"n": s("ull"), g=null;
+                break;
+                case'"': g=u();
+                break;
+
+                case"[":g=function e(r) {
+                    f();
+                    var a=[],
+                    t=0;
+                    if("]"==l())return a;
+
+                    for(v(); ; ) {
+                        var o=r+"/"+t;
+                        a.push(n(o)),
+                        f();
+                        var c=l();
+                        if("]"==c)break;
+                        "," !=c&&k(),
+                        f(),
+                        t++
+                    }
+
+                    return a
+                }
+
+                (r);
+                break;
+
+                case"{":g=function e(r) {
+                    f();
+
+                    var a= {}
+
+                    ;
+                    if("}"==l())return a;
+
+                    for(v(); ; ) {
+                        var t=d();
+                        '"' !=l()&&k();
+                        var o=u(),
+                        c=r+"/"+escapeJsonPointer(o);
+                        b(c, "key", t),
+                        E(c, "keyEnd"),
+                        f(),
+                        ":" !=l()&&k(),
+                        f(),
+                        a[o]=n(c),
+                        f();
+                        var i=l();
+                        if("}"==i)break;
+                        "," !=i&&k(),
+                        f()
+                    }
+
+                    return a
+                }
+
+                (r);
+                break;
+                default:v(),
+                "-0123456789" .indexOf(S)>=0?g=(t="", o= !0, "-"==e[c]&&(t+=l()), t+="0"==e[c]?l():p(), "."==e[c]&&(t+=l()+p(), o= !1), ("e"==e[c]||"E"==e[c])&&(t+=l(), ("+"==e[c]||"-"==e[c])&&(t+=l()), t+=p(), o= !1), $=+t, i&&o&&($>Number.MAX_SAFE_INTEGER||$<Number.MIN_SAFE_INTEGER)?BigInt(t):$):h()
             }
+
+            return E(r, "valueEnd"),
+            f(),
+            a&&c<e.length&&h(),
+            g
         }
 
-        @keyframes slideOut {
-            from {
-                transform: translateX(0);
-            }
+        ("", !0),
+        pointers:a
+    }
+
+    ;
 
-            to {
-                transform: translateX(-200%);
+    function f() {
+        loop: for(; c<e.length; ) {
+            switch(e[c]) {
+                case" ": o++;
+                break;
+                case"	": o+=4;
+                break;
+                case"\r": o=0;
+                break;
+                case"\n": o=0, t++;
+                break;
+                default: break loop
             }
+
+            c++
         }
+    }
 
-        @keyframes rotation {
-            0% {
-                transform: rotate(0deg);
-            }
-            100% {
-                transform: rotate(360deg);
+    function u() {
+        for(var e, n=""; '"' !=(e=l()); )"\\"==e?(e=l())in escapedChars?n+=escapedChars[e]: "u"==e?n+=$(
+            ):k():n+=e;
+        return n
+    }
+
+    function s(e) {
+        for(var n=0; n<e.length; n++)l() !==e[n]&&k()
+    }
+
+    function l() {
+        g(
+    );
+    var n=e[c];
+    return c++,
+    o++,
+    n
+}
+
+function v() {
+    c--,
+    o--
+}
+
+function $() {
+    for(var e=4, n=0; e--; ) {
+        n<<=4;
+        var r=l().toLowerCase();
+        r>="a" &&r<="f" ?n+=r.charCodeAt()-A_CODE+10: r>="0" &&r<="9" ?n+=+r:k()
+    }
+
+    return String.fromCharCode(n)
+}
+
+function p() {
+    for(var n=""; e[c]>="0" &&e[c]<="9"; )n+=l();
+    if(n.length)return n;
+    g(),
+    h()
+}
+
+function E(e, n) {
+    b(e, n, d())
+}
+
+function b(e, n, r) {
+    a[e]=a[e]|| {}
+
+    ,
+    a[e][n]=r
+}
+
+function d() {
+    return {
+        line: t, column:o, pos:c
+    }
+}
+
+function h() {
+    throw SyntaxError("Unexpected token " +e[c]+" in JSON at position " +c)
+}
+
+function k() {
+    v(),
+    h()
+}
+
+function g() {
+    if(c>=e.length)throw SyntaxError("Unexpected end of JSON input")
+}
+}
+
+,
+jsonMapStringify=function(e, n, r) {
+    if(validType(e)) {
+        var a,
+        t,
+        o=0,
+        c="object"==typeof r?r.space: r;
+
+        switch(typeof c) {
+            case"number": var i=c>10?10:c<0?0:Math.floor(c);
+            c=i&&k(i, " "),
+            a=i,
+            t=i;
+            break;
+            case"string": c=c.slice(0, 10), a=0, t=0;
+
+            for(var f=0; f<c.length; f++) {
+                var u=c[f];
+
+                switch(u) {
+                    case" ": t++;
+                    break;
+                    case"	": t+=4;
+                    break;
+                    case"\r": t=0;
+                    break;
+                    case"\n": t=0, o++;
+                    break;
+                    default: throw Error("whitespace characters not allowed in JSON")
+                }
+
+                a++
             }
+
+            break;
+            default:c=void 0
         }
 
-        @keyframes bounce {
+        var s="",
+        l= {}
+
+        ,
+        v=0,
+        $=0,
+        p=0,
+        E=r&&r.es6&&"function"==typeof Map;
 
-            0%, 100% {
-                transform: translateY(-25%);
-                animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
+        return function e(n, r, a) {
+            switch(h(a, "value"), typeof n) {
+                case"number": case"bigint":case"boolean":b("" +n);
+                break;
+                case"string": b(quoted(n));
+                break;
+                case"object": null===n?b("null"):"function"==typeof n.toJSON?b(quoted(n.toJSON())):Array.isArray(n)?t():E?n.constructor.BYTES_PER_ELEMENT?t():n instanceof Map?i():n instanceof Set?i( !0):o():o()
             }
 
-            50% {
-                transform: translateY(0);
-                animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
+            function t() {
+                if(n.length) {
+                    b("[");
+
+                    for(var t=r+1, o=0; o<n.length; o++) {
+                        o&&b(","),
+                        d(t);
+                        var c=validType(n[o])?n[o]: null;
+                        e(c, t, a+"/" +o)
+                    }
+
+                    d(r),
+                    b("]")
+                }
+
+                else b("[]")
             }
-        }
 
-        /* UTILITIES */
+            function o() {
+                var t=Object.keys(n);
 
-        .hidden {
-            display: none;
+                if(t.length) {
+                    b("{");
+
+                    for(var o=r+1, i=0; i<t.length; i++) {
+                        var f=t[i],
+                        u=n[f];
+
+                        if(validType(u)) {
+                            i&&b(",");
+                            var s=a+"/"+escapeJsonPointer(f);
+                            d(o),
+                            h(s, "key"),
+                            b(quoted(f)),
+                            h(s, "keyEnd"),
+                            b(":"),
+                            c&&b(" "),
+                            e(u, o, s)
+                        }
+                    }
+
+                    d(r),
+                    b("}")
+                }
+
+                else b("{}")
+            }
+
+            function i(t) {
+                if(n.size) {
+                    b("{");
+
+                    for(var o=r+1, i= !0, f=n.entries(), u=f.next(); !u.done; ) {
+                        var s=u.value,
+                        l=s[0],
+                        v= ! !t||s[1];
+
+                        if(validType(v)) {
+                            i||b(","),
+                            i= !1;
+                            var $=a+"/"+escapeJsonPointer(l);
+                            d(o),
+                            h($, "key"),
+                            b(quoted(l)),
+                            h($, "keyEnd"),
+                            b(":"),
+                            c&&b(" "),
+                            e(v, o, $)
+                        }
+
+                        u=f.next()
+                    }
+
+                    d(r),
+                    b("}")
+                }
+
+                else b("{}")
+            }
+
+            h(a, "valueEnd")
         }
 
-    </style>
-</head>
-
-<body>
-
-<header>
-    <div id="main-info">
-        <h1 th:text="${contractFile}"></h1>
-        <h2 th:text="${contractFilePath}"></h2>
-    </div>
-    <div class="btn-grp" th:attr="data-test-mode=${isTestMode}">
-        <button data-selected="0" id="bulk-generate" data-panel="table"></button>
-        <button data-selected="0" data-panel="table" id="bulk-validate"></button>
-        <button data-selected="0" data-panel="table" id="bulk-test"></button>
-    </div>
-</header>
-
-<main class="group" data-panel="table">
-    <table th:attr="data-generated=${hasExamples},data-hostPort=${hostPort}">
-        <thead>
-            <tr>
-                <th>
-                    <label for="select-all">
-                        <input type="checkbox" name="select-all" id="select-all">
-                    </label>
-                </th>
-                <th>S. No</th>
-                <th colspan="3">Path</th>
-                <th>Method</th>
-                <th>Response</th>
-                <th>Examples</th>
-                <th>Action</th>
-            </tr>
-        </thead>
-        <tbody th:attr="data-test-mode=${isTestMode}">
-            <tr
-                th:each="row, iter : ${tableRows}"
-                th:attr="data-raw-path=${row.rawPath}, data-key=${row.uniqueKey}, data-schema-based=${row.isSchemaBased},
-                        data-example=${row.example}, data-main=${row.isMainRow}, data-disc=${row.isDiscriminatorBased},
-                        data-generate=${row.isGenerated ? 'success' : 'not-generated'}, data-test='not-tested',
-                        data-valid=${row.isGenerated ? (row.isValid ? 'success' : row.isPartialFailure ? 'partial' : 'failed') : 'not-validated'}">
-                <td>
-                    <input type="checkbox" name="path-row" class="path-row">
-                </td>
-                <td></td>
-                <td th:class="${row.showPath ? '' : 'hidden'}" th:attr="rowspan=${row.pathSpan}, colspan=${row.pathColSpan}">
-                    <span>[[${row.path}]]</span>
-                </td>
-                <td th:class="${row.showMethod ? '' : 'hidden'}" th:attr="rowspan=${row.methodSpan}, colspan=${row.methodColSpan}">
-                    <p>[[${row.method}]]</p>
-                </td>
-                <td class="response-cell" th:classappend="${row.showStatus ? '' : 'hidden'}" th:attr="rowspan=${row.statusSpan}">
-                    <p>[[${row.responseStatus}]]</p>
-                    <span>[[${row.contentType}]]</span>
-                    <br th:if="${row.contentType != null}"/>
-                    <button class="multigen hidden" aria-label="Generate More"></button>
-                </td>
-                <td>
-                    <button th:unless="${row.isGenerated}" class="generate" aria-label="Generate"></button>
-                    <span th:if="${row.isGenerated}" th:text="${row.exampleName}"></span>
-                </td>
-                <td>
-                    <button class="validate hidden" aria-label="Validate"></button>
-                    <button class="test hidden" aria-label="Test"></button>
-                    <span th:class="hidden">View Details</span>
-                </td>
-            </tr>
-        </tbody>
-    </table>
-    <div id="details">
-        <div id="path-details">
-            <button id="back" tabindex="-1">
-                <span>&larr;</span>
-                <span>Go Back</span>
-            </button>
-            <ul id="path-summary"></ul>
-        </div>
-        <ol id="examples"></ol>
-    </div>
-</main>
-
-<div id="alert-container"></div>
-<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="chevron">
-    <path stroke-linecap="round" stroke-linejoin="round" d="m4.5 5.25 7.5 7.5 7.5-7.5m-15 6 7.5 7.5 7.5-7.5" />
-</svg>
-
-<script th:inline="javascript">
-    const exampleDetails = /*[[${exampleDetails}]]*/ {};
-    const testDetails = {};
-</script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/jsonlint/1.6.0/jsonlint.min.js"></script>
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">-->
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">-->
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">-->
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/addon/lint/lint.min.css">-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>-->
-<script type="module">
-import { Decoration,EditorState, EditorView, StateEffect, StateField,autocompletion, basicSetup, hoverTooltip,javascript, json,jsonParseLinter, language, lineNumbers, lintGutter, linter,oneDark } from './codemirror-bundle.esm.js'
-    window.EditorState = EditorState
-    window.EditorView = EditorView
-    window.basicSetup = basicSetup
-    window.javascript = javascript()
-    window.autocompletion = autocompletion()
-    window.oneDark = oneDark
-    window.language = language
-    window.lineNumbers = lineNumbers()
-    window.lintGutter = lintGutter()
-    window.json = json()
-    window.linter = linter(jsonParseLinter())
-    window.Decoration = Decoration
-    window.StateField = StateField
-    window.StateEffect = StateEffect
-    window.hoverTooltip = hoverTooltip
-
-</script>
-<script>var escapedChars={b:"\b",f:"\f",n:"\n",r:"\r",t:"	",'"':'"',"/":"/","\\":"\\"},A_CODE="a".charCodeAt();const jsonMapParser=function(e,n,r){var a={},t=0,o=0,c=0,i=r&&r.bigint&&"undefined"!=typeof BigInt;return{data:function n(r,a){f(),E(r,"value");var t,o,$,g,S=l();switch(S){case"t":s("rue"),g=!0;break;case"f":s("alse"),g=!1;break;case"n":s("ull"),g=null;break;case'"':g=u();break;case"[":g=function e(r){f();var a=[],t=0;if("]"==l())return a;for(v();;){var o=r+"/"+t;a.push(n(o)),f();var c=l();if("]"==c)break;","!=c&&k(),f(),t++}return a}(r);break;case"{":g=function e(r){f();var a={};if("}"==l())return a;for(v();;){var t=d();'"'!=l()&&k();var o=u(),c=r+"/"+escapeJsonPointer(o);b(c,"key",t),E(c,"keyEnd"),f(),":"!=l()&&k(),f(),a[o]=n(c),f();var i=l();if("}"==i)break;","!=i&&k(),f()}return a}(r);break;default:v(),"-0123456789".indexOf(S)>=0?g=(t="",o=!0,"-"==e[c]&&(t+=l()),t+="0"==e[c]?l():p(),"."==e[c]&&(t+=l()+p(),o=!1),("e"==e[c]||"E"==e[c])&&(t+=l(),("+"==e[c]||"-"==e[c])&&(t+=l()),t+=p(),o=!1),$=+t,i&&o&&($>Number.MAX_SAFE_INTEGER||$<Number.MIN_SAFE_INTEGER)?BigInt(t):$):h()}return E(r,"valueEnd"),f(),a&&c<e.length&&h(),g}("",!0),pointers:a};function f(){loop:for(;c<e.length;){switch(e[c]){case" ":o++;break;case"	":o+=4;break;case"\r":o=0;break;case"\n":o=0,t++;break;default:break loop}c++}}function u(){for(var e,n="";'"'!=(e=l());)"\\"==e?(e=l())in escapedChars?n+=escapedChars[e]:"u"==e?n+=$():k():n+=e;return n}function s(e){for(var n=0;n<e.length;n++)l()!==e[n]&&k()}function l(){g();var n=e[c];return c++,o++,n}function v(){c--,o--}function $(){for(var e=4,n=0;e--;){n<<=4;var r=l().toLowerCase();r>="a"&&r<="f"?n+=r.charCodeAt()-A_CODE+10:r>="0"&&r<="9"?n+=+r:k()}return String.fromCharCode(n)}function p(){for(var n="";e[c]>="0"&&e[c]<="9";)n+=l();if(n.length)return n;g(),h()}function E(e,n){b(e,n,d())}function b(e,n,r){a[e]=a[e]||{},a[e][n]=r}function d(){return{line:t,column:o,pos:c}}function h(){throw SyntaxError("Unexpected token "+e[c]+" in JSON at position "+c)}function k(){v(),h()}function g(){if(c>=e.length)throw SyntaxError("Unexpected end of JSON input")}},jsonMapStringify=function(e,n,r){if(validType(e)){var a,t,o=0,c="object"==typeof r?r.space:r;switch(typeof c){case"number":var i=c>10?10:c<0?0:Math.floor(c);c=i&&k(i," "),a=i,t=i;break;case"string":c=c.slice(0,10),a=0,t=0;for(var f=0;f<c.length;f++){var u=c[f];switch(u){case" ":t++;break;case"	":t+=4;break;case"\r":t=0;break;case"\n":t=0,o++;break;default:throw Error("whitespace characters not allowed in JSON")}a++}break;default:c=void 0}var s="",l={},v=0,$=0,p=0,E=r&&r.es6&&"function"==typeof Map;return function e(n,r,a){switch(h(a,"value"),typeof n){case"number":case"bigint":case"boolean":b(""+n);break;case"string":b(quoted(n));break;case"object":null===n?b("null"):"function"==typeof n.toJSON?b(quoted(n.toJSON())):Array.isArray(n)?t():E?n.constructor.BYTES_PER_ELEMENT?t():n instanceof Map?i():n instanceof Set?i(!0):o():o()}function t(){if(n.length){b("[");for(var t=r+1,o=0;o<n.length;o++){o&&b(","),d(t);var c=validType(n[o])?n[o]:null;e(c,t,a+"/"+o)}d(r),b("]")}else b("[]")}function o(){var t=Object.keys(n);if(t.length){b("{");for(var o=r+1,i=0;i<t.length;i++){var f=t[i],u=n[f];if(validType(u)){i&&b(",");var s=a+"/"+escapeJsonPointer(f);d(o),h(s,"key"),b(quoted(f)),h(s,"keyEnd"),b(":"),c&&b(" "),e(u,o,s)}}d(r),b("}")}else b("{}")}function i(t){if(n.size){b("{");for(var o=r+1,i=!0,f=n.entries(),u=f.next();!u.done;){var s=u.value,l=s[0],v=!!t||s[1];if(validType(v)){i||b(","),i=!1;var $=a+"/"+escapeJsonPointer(l);d(o),h($,"key"),b(quoted(l)),h($,"keyEnd"),b(":"),c&&b(" "),e(v,o,$)}u=f.next()}d(r),b("}")}else b("{}")}h(a,"valueEnd")}(e,0,""),{json:s,pointers:l}}function b(e){$+=e.length,p+=e.length,s+=e}function d(e){if(c){for(s+="\n"+k(e,c),v++,$=0;e--;)o?(v+=o,$=t):$+=t,p+=a;p+=1}}function h(e,n){l[e]=l[e]||{},l[e][n]={line:v,column:$,pos:p}}function k(e,n){return Array(e+1).join(n)}};var VALID_TYPES=["number","bigint","boolean","string","object"];function validType(e){return VALID_TYPES.indexOf(typeof e)>=0}var ESC_QUOTE=/"|\\/g,ESC_B=/[\b]/g,ESC_F=/\f/g,ESC_N=/\n/g,ESC_R=/\r/g,ESC_T=/\t/g;function quoted(e){return'"'+(e=e.replace(ESC_QUOTE,"\\$&").replace(ESC_F,"\\f").replace(ESC_B,"\\b").replace(ESC_N,"\\n").replace(ESC_R,"\\r").replace(ESC_T,"\\t"))+'"'}var ESC_0=/~/g,ESC_1=/\//g;function escapeJsonPointer(e){return e.replace(ESC_0,"~0").replace(ESC_1,"~1")}</script>
-</body>
-<script>
-    const mainElement = document.querySelector("main");
-    const table = document.querySelector("table");
-    const backBtn = document.querySelector("button#back");
-    const pathSummaryUl = document.querySelector("ul#path-summary");
-    const examplesOl = document.querySelector("ol#examples");
-    const alerts = document.getElementById("alert-container");
-    const bulkValidateBtn = document.querySelector("button#bulk-validate");
-    const bulkGenerateBtn = document.querySelector("button#bulk-generate");
-    const bulkTestBtn = document.querySelector("button#bulk-test");
-    const chevronDownIcon = document.querySelector("svg.chevron");
-    let setDecorationsEffect;
-    let decorationsField;
-    let savedEditorResponse = null;
-    let originalEditorText = null;
-    let scrollYPosition = 0;
-    let selectedTableRow = null;
-    let blockGenValidate = false;
-    const defaultAttrs = { "data-generate": "not-generated", "data-valid": "not-validated", "data-test": "not-tested", "data-main": "false" }
-    const dataValidationSuccessValues = ["success", "partial"]
-    let isSaved = true;
-    let errorMetadata = [];
-
-    examplesOl.addEventListener("click", (event) => {
-        const target = event.target;
+        (e, 0, ""),
+        {
+        json: s, pointers:l
+    }
+}
+
+function b(e) {
+    $+=e.length,
+    p+=e.length,
+    s+=e
+}
+
+function d(e) {
+    if(c) {
+        for(s+="\n" +k(e, c), v++, $=0; e--; )o?(v+=o, $=t): $+=t, p+=a;
+        p+=1
+    }
+}
+
+function h(e, n) {
+    l[e]=l[e]|| {}
+
+    ,
+    l[e][n]= {
+        line: v, column:$, pos:p
+    }
+}
+
+function k(e, n) {
+    return Array(e+1).join(n)
+}
+}
+
+;
+var VALID_TYPES=["number",
+"bigint",
+"boolean",
+"string",
+"object"];
+
+function validType(e) {
+    return VALID_TYPES.indexOf(typeof e)>=0
+}
+
+var ESC_QUOTE=/"|\\/g,ESC_B=/[\b]/g,ESC_F=/\f/g,ESC_N=/\n/g,ESC_R=/\r/g,ESC_T=/\t/g;function quoted(e){return'" '+(e=e.replace(ESC_QUOTE,"\\$&").replace(ESC_F,"\\f").replace(ESC_B,"\\b").replace(ESC_N,"\\n").replace(ESC_R,"\\r").replace(ESC_T,"\\t"))+' "'}var ESC_0=/~/g,ESC_1=/\//g;function escapeJsonPointer(e){return e.replace(ESC_0,"~0").replace(ESC_1,"~1")}</script>
+</body><script>const mainElement=document.querySelector("main");
+const table=document.querySelector("table");
+const backBtn=document.querySelector("button#back");
+const pathSummaryUl=document.querySelector("ul#path-summary");
+const examplesOl=document.querySelector("ol#examples");
+const alerts=document.getElementById("alert-container");
+const bulkValidateBtn=document.querySelector("button#bulk-validate");
+const bulkGenerateBtn=document.querySelector("button#bulk-generate");
+const bulkTestBtn=document.querySelector("button#bulk-test");
+const chevronDownIcon=document.querySelector("svg.chevron");
+let setDecorationsEffect;
+let decorationsField;
+let savedEditorResponse=null;
+let originalEditorText=null;
+let scrollYPosition=0;
+let selectedTableRow=null;
+let blockGenValidate=false;
+
+const defaultAttrs= {
+    "data-generate": "not-generated", "data-valid": "not-validated", "data-test": "not-tested", "data-main": "false"
+}
+
+const dataValidationSuccessValues=["success",
+"partial"] let isSaved=true;
+let errorMetadata=[];
+
+examplesOl.addEventListener("click", (event)=> {
+        const target=event.target;
+
         if (target.matches(".dropdown, .dropdown *")) {
             target.closest("div.details")?.classList.toggle("expanded");
             event.stopPropagation();
         }
-    })
 
-    backBtn.addEventListener("click", () => {
-        if (!isSaved) {
-            const modalContainer = createModal({
-                onDiscard: () => {
+    }) backBtn.addEventListener("click", ()=> {
+        if ( !isSaved) {
+            const modalContainer=createModal({
+                onDiscard: ()=> {
                     examplesOl.replaceChildren();
                     mainElement.setAttribute("data-panel", "table");
                     bulkValidateBtn.setAttribute("data-panel", "table");
@@ -1252,42 +1636,46 @@ <h2 th:text="${contractFilePath}"></h2>
                     bulkTestBtn.setAttribute("data-panel", "table");
                     window.scrollTo(0, scrollYPosition);
                     console.log("Changes discarded!");
-                    isSaved = true;
-                },
+                    isSaved=true;
+                }
+
+                ,
 
             });
-            document.body.appendChild(modalContainer);
-            return;
-        }
+        document.body.appendChild(modalContainer);
+        return;
+    }
 
-        examplesOl.replaceChildren();
-        mainElement.setAttribute("data-panel", "table");
-        bulkValidateBtn.setAttribute("data-panel", "table");
-        bulkGenerateBtn.setAttribute("data-panel", "table");
-        bulkTestBtn.setAttribute("data-panel", "table");
-        window.scrollTo(0, scrollYPosition);
-    });
+    examplesOl.replaceChildren();
+    mainElement.setAttribute("data-panel", "table");
+    bulkValidateBtn.setAttribute("data-panel", "table");
+    bulkGenerateBtn.setAttribute("data-panel", "table");
+    bulkTestBtn.setAttribute("data-panel", "table");
+    window.scrollTo(0, scrollYPosition);
+});
 
-    table.addEventListener("click", async (event) => {
-        const target = event.target;
-        const nearestTableRow = target.closest("tr");
+table.addEventListener("click", async (event)=> {
+        const target=event.target;
+        const nearestTableRow=target.closest("tr");
 
         if (nearestTableRow) {
-            selectedTableRow = nearestTableRow;
-            const rowValues = extractRowValues(nearestTableRow);
+            selectedTableRow=nearestTableRow;
+            const rowValues=extractRowValues(nearestTableRow);
             event.stopPropagation();
 
             switch (target.tagName) {
                 case "BUTTON": {
                     if (blockGenValidate) break;
+
                     switch (target.getAttribute("aria-label")) {
-                        case "Generate":
-                        case "Generate More": {
+                        case "Generate": case "Generate More": {
                             return await generateRowExamples(nearestTableRow, rowValues);
                         }
+
                         case "Validate": {
                             return await validateRowExamples(nearestTableRow);
                         }
+
                         default: {
                             return await testRowExample(nearestTableRow);
                         }
@@ -1296,7 +1684,11 @@ <h2 th:text="${contractFilePath}"></h2>
 
                 case "INPUT": {
                     if (target.matches("th > label > input")) {
-                        const { validatedCount, generatedCount, discAndMainCount, totalCount } = getRowsCount();
+                        const {
+                            validatedCount, generatedCount, discAndMainCount, totalCount
+                        }
+
+                        =getRowsCount();
                         toggleAllSelects(target.checked);
 
                         if (table.hasAttribute("data-generated")) {
@@ -1311,7 +1703,7 @@ <h2 th:text="${contractFilePath}"></h2>
                 }
 
                 default: {
-                    if (!target.matches("tr > *:first-child, tr > *:first-child *") && nearestTableRow.getAttribute("data-generate") === "success") {
+                    if ( !target.matches("tr > *:first-child, tr > *:first-child *") && nearestTableRow.getAttribute("data-generate")==="success") {
                         return await goToDetails(nearestTableRow, rowValues);
                     }
                 }
@@ -1319,35 +1711,39 @@ <h2 th:text="${contractFilePath}"></h2>
         }
     });
 
-    function handleSingleInput(nearestTableRow, checked) {
-        const getPreSelectCount = (btn, attr) => Number.parseInt(btn.getAttribute(attr) || 0);
+function handleSingleInput(nearestTableRow, checked) {
+    const getPreSelectCount=(btn, attr)=>Number.parseInt(btn.getAttribute(attr) || 0);
 
-        const valPreSelectCount = getPreSelectCount(bulkValidateBtn, "data-selected");
-        const genPreSelectCount = getPreSelectCount(bulkGenerateBtn, "data-selected");
-        const testPreSelectCount = getPreSelectCount(bulkTestBtn, "data-selected");
+    const valPreSelectCount=getPreSelectCount(bulkValidateBtn, "data-selected");
+    const genPreSelectCount=getPreSelectCount(bulkGenerateBtn, "data-selected");
+    const testPreSelectCount=getPreSelectCount(bulkTestBtn, "data-selected");
 
-        const hasBeenGenerated = nearestTableRow.getAttribute("data-generate") === "success";
-        const hasBeenValidated = dataValidationSuccessValues.includes(nearestTableRow.getAttribute("data-valid"));
-        const isDiscriminatorRow = nearestTableRow.getAttribute("data-disc") === "true";
-        const isMainRow = nearestTableRow.getAttribute("data-main") === "true";
+    const hasBeenGenerated=nearestTableRow.getAttribute("data-generate")==="success";
+    const hasBeenValidated=dataValidationSuccessValues.includes(nearestTableRow.getAttribute("data-valid"));
+    const isDiscriminatorRow=nearestTableRow.getAttribute("data-disc")==="true";
+    const isMainRow=nearestTableRow.getAttribute("data-main")==="true";
 
-        const countAdjustment = checked ? 1 : -1;
+    const countAdjustment=checked ? 1: -1;
 
-        if (hasBeenGenerated) {
-            bulkValidateBtn.setAttribute("data-selected", valPreSelectCount + countAdjustment);
-            if (isDiscriminatorRow && isMainRow) {
-                bulkGenerateBtn.setAttribute("data-selected", genPreSelectCount + countAdjustment);
-            }
-            if (hasBeenValidated) {
-                bulkTestBtn.setAttribute("data-selected", testPreSelectCount + countAdjustment);
-            }
-        } else if (isMainRow) {
+    if (hasBeenGenerated) {
+        bulkValidateBtn.setAttribute("data-selected", valPreSelectCount + countAdjustment);
+
+        if (isDiscriminatorRow && isMainRow) {
             bulkGenerateBtn.setAttribute("data-selected", genPreSelectCount + countAdjustment);
         }
+
+        if (hasBeenValidated) {
+            bulkTestBtn.setAttribute("data-selected", testPreSelectCount + countAdjustment);
+        }
+    }
+
+    else if (isMainRow) {
+        bulkGenerateBtn.setAttribute("data-selected", genPreSelectCount + countAdjustment);
     }
+}
 
-    bulkValidateBtn.addEventListener("click", async () => {
-        blockGenValidate = true;
+bulkValidateBtn.addEventListener("click", async ()=> {
+        blockGenValidate=true;
         bulkValidateBtn.setAttribute("data-valid", "processing");
 
         switch (bulkValidateBtn.getAttribute("data-panel")) {
@@ -1358,9 +1754,9 @@ <h2 th:text="${contractFilePath}"></h2>
 
             case "details": {
                 await validateRowExamples(selectedTableRow);
-                const originalYScroll = scrollYPosition;
+                const originalYScroll=scrollYPosition;
                 await goToDetails(selectedTableRow, extractRowValues(selectedTableRow));
-                scrollYPosition = originalYScroll;
+                scrollYPosition=originalYScroll;
                 break;
             }
         }
@@ -1369,53 +1765,80 @@ <h2 th:text="${contractFilePath}"></h2>
         return cleanUpSelections();
     });
 
-    bulkGenerateBtn.addEventListener("click", async () => {
-        blockGenValidate = true;
+bulkGenerateBtn.addEventListener("click", async ()=> {
+        blockGenValidate=true;
         bulkGenerateBtn.setAttribute("data-generate", "processing");
 
-        let failedCount = 0; createdCount = 0; existedCount = 0;
-        const selectedRows = Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox) => checkbox.closest("tr"));
-        const rowsWithNoExamplesOrDiscriminator = selectedRows.filter(row =>
-            row.getAttribute("data-main") === "true" && (row.getAttribute("data-generate") === defaultAttrs["data-generate"] || row.getAttribute("data-disc") === "true")
-        );
+        let failedCount=0; createdCount=0; existedCount=0;
+        const selectedRows=Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox)=> checkbox.closest("tr"));
+        const rowsWithNoExamplesOrDiscriminator=selectedRows.filter(row=> row.getAttribute("data-main")==="true" && (row.getAttribute("data-generate")===defaultAttrs["data-generate"] || row.getAttribute("data-disc")==="true"));
 
         for (const row of rowsWithNoExamplesOrDiscriminator) {
-            const rowValues = extractRowValues(row);
-            const { success, created, existed, count } = await generateRowExamples(row, rowValues, true);
+            const rowValues=extractRowValues(row);
+
+            const {
+                success, created, existed, count
+            }
 
-            if (!success) failedCount += count;
-            createdCount += created;
-            existedCount += existed;
+            =await generateRowExamples(row, rowValues, true);
+
+            if ( !success) failedCount +=count;
+            createdCount +=created;
+            existedCount +=existed;
         }
 
         bulkGenerateBtn.removeAttribute("data-generate");
-        const message = `${createdCount} Example(s) Created\n${existedCount} Example(s) Existed\n${failedCount} Example(s) Failed`
-        const title = `Generation Complete (${createdCount + existedCount + failedCount}) Example(s)`;
-        createAlert(title, message, failedCount !== 0);
-        return cleanUpSelections();
-    });
 
-    async function validateAllSelected() {
-        bulkValidateBtn.setAttribute("data-valid", "processing");
+        const message=`$ {
+            createdCount
+        }
 
-        let errorsCount = 0;
-        const selectedRows = Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox) => checkbox.closest("tr"));
-        const rowsWithExamples = selectedRows.filter(row => row.getAttribute("data-generate") === "success");
+        Example(s) Created\n$ {
+            existedCount
+        }
 
-        for (const row of rowsWithExamples) {
-            const success = await validateRowExamples(row, true);
-            if (!success) {
-                errorsCount++;
-            }
+        Example(s) Existed\n$ {
+            failedCount
         }
 
-        bulkValidateBtn.removeAttribute("data-generate");
-        createAlert("Validations Complete", `${errorsCount} out of ${rowsWithExamples.length} are invalid`, errorsCount !== 0);
+        Example(s) Failed` const title=`Generation Complete ($ {
+                createdCount + existedCount + failedCount
+            }) Example(s)`;
+        createAlert(title, message, failedCount !==0);
         return cleanUpSelections();
+    });
+
+async function validateAllSelected() {
+    bulkValidateBtn.setAttribute("data-valid", "processing");
+
+    let errorsCount=0;
+    const selectedRows=Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox)=> checkbox.closest("tr"));
+    const rowsWithExamples=selectedRows.filter(row=> row.getAttribute("data-generate")==="success");
+
+    for (const row of rowsWithExamples) {
+        const success=await validateRowExamples(row, true);
+
+        if ( !success) {
+            errorsCount++;
+        }
     }
 
-    bulkTestBtn.addEventListener("click", async () => {
-        blockGenValidate = true;
+    bulkValidateBtn.removeAttribute("data-generate");
+
+    createAlert("Validations Complete", `$ {
+            errorsCount
+        }
+
+        out of $ {
+            rowsWithExamples.length
+        }
+
+        are invalid`, errorsCount !==0);
+    return cleanUpSelections();
+}
+
+bulkTestBtn.addEventListener("click", async ()=> {
+        blockGenValidate=true;
         bulkTestBtn.setAttribute("data-test", "processing");
 
         switch (bulkValidateBtn.getAttribute("data-panel")) {
@@ -1426,9 +1849,8 @@ <h2 th:text="${contractFilePath}"></h2>
 
             case "details": {
                 await testRowExample(selectedTableRow);
-                const originalYScroll = scrollYPosition
-                await goToDetails(selectedTableRow, extractRowValues(selectedTableRow));
-                scrollYPosition = originalYScroll;
+                const originalYScroll=scrollYPosition await goToDetails(selectedTableRow, extractRowValues(selectedTableRow));
+                scrollYPosition=originalYScroll;
                 break;
             }
         }
@@ -1437,388 +1859,566 @@ <h2 th:text="${contractFilePath}"></h2>
         return cleanUpSelections();
     });
 
-    async function testAllSelected() {
-        const selectedRows = Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox) => checkbox.closest("tr"));
-        const rowsWithValidations = selectedRows.filter(row => dataValidationSuccessValues.includes(row.getAttribute("data-valid")));
+async function testAllSelected() {
+    const selectedRows=Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox)=> checkbox.closest("tr"));
+    const rowsWithValidations=selectedRows.filter(row=> dataValidationSuccessValues.includes(row.getAttribute("data-valid")));
+
+    for (const row of rowsWithValidations) {
+        row.setAttribute("data-test", "processing");
+    }
+
+    let failureCount=0;
+
+    for (const row of rowsWithValidations) {
+        const result=await testRowExample(row, true);
 
-        for (const row of rowsWithValidations) {
-            row.setAttribute("data-test", "processing");
+        if ( !result) {
+            failureCount++;
         }
+    }
 
-        let failureCount = 0;
-        for (const row of rowsWithValidations) {
-            const result = await testRowExample(row, true);
+    blockGenValidate=false;
 
-            if (!result) {
-                failureCount++;
-            }
+    createAlert("Tests Complete", `$ {
+            failureCount
         }
 
-        blockGenValidate = false;
-        createAlert("Tests Complete", `${failureCount} out of ${rowsWithValidations.length} have failed`, failureCount !== 0);
-    }
+        out of $ {
+            rowsWithValidations.length
+        }
+
+        have failed`, failureCount !==0);
+}
 
-    function extractRowValues(tableRow) {
-        const [method, responseAndContentType] = [...tableRow.children].slice(3, 5).map((child) => child.textContent.trim());
-        const [responseStatusCode, contentType] = responseAndContentType.split("\n").map((str) => str.trim());
-        const isSchemaBased = tableRow.getAttribute("data-schema-based") === "true"
+function extractRowValues(tableRow) {
+    const [method,
+    responseAndContentType]=[...tableRow.children].slice(3, 5).map((child)=> child.textContent.trim());
+    const [responseStatusCode,
+    contentType]=responseAndContentType.split("\n").map((str)=> str.trim());
+    const isSchemaBased=tableRow.getAttribute("data-schema-based")==="true"
 
-        return { path: tableRow.getAttribute("data-raw-path"), method, responseStatusCode, contentType, isSchemaBased };
+    return {
+        path: tableRow.getAttribute("data-raw-path"), method, responseStatusCode, contentType, isSchemaBased
     }
 
-    function getRowsCount() {
-        const tableRows = table.querySelectorAll("tbody > tr");
-        return Array.from(tableRows).reduce((acc, row) => {
-            const isRowGenerated = row.getAttribute("data-generate") === "success";
-            const isRowValidated = dataValidationSuccessValues.includes(row.getAttribute("data-valid"));
-            const isRowDiscAndMain = row.getAttribute("data-main") === "true" && row.getAttribute("data-disc") === "true";
+    ;
+}
+
+function getRowsCount() {
+    const tableRows=table.querySelectorAll("tbody > tr");
+
+    return Array.from(tableRows).reduce((acc, row)=> {
+            const isRowGenerated=row.getAttribute("data-generate")==="success";
+            const isRowValidated=dataValidationSuccessValues.includes(row.getAttribute("data-valid"));
+            const isRowDiscAndMain=row.getAttribute("data-main")==="true" && row.getAttribute("data-disc")==="true";
 
-            acc.validatedCount += isRowValidated ? 1 : 0;
-            acc.generatedCount += isRowGenerated ? 1 : 0;
-            acc.discAndMainCount += isRowGenerated && isRowDiscAndMain ? 1 : 0;
-            acc.totalCount += 1;
+            acc.validatedCount +=isRowValidated ? 1 : 0;
+            acc.generatedCount +=isRowGenerated ? 1 : 0;
+            acc.discAndMainCount +=isRowGenerated && isRowDiscAndMain ? 1 : 0;
+            acc.totalCount +=1;
             return acc;
 
-        }, { validatedCount: 0, generatedCount: 0, discAndMainCount: 0, totalCount: 0 });
+        }
+
+        , {
+        validatedCount: 0, generatedCount: 0, discAndMainCount: 0, totalCount: 0
+    });
+}
+
+function toggleAllSelects(isSelected=true) {
+    const checkboxes=table.querySelectorAll("input[type=checkbox]");
+
+    for (const checkbox of checkboxes) {
+        checkbox.checked=isSelected;
     }
+}
 
-    function toggleAllSelects(isSelected = true) {
-        const checkboxes = table.querySelectorAll("input[type=checkbox]");
-        for (const checkbox of checkboxes) {
-            checkbox.checked = isSelected;
-        }
+async function generateRowExamples(tableRow, rowValues, bulkMode=false) {
+    const originalState=tableRow.getAttribute("data-generate");
+
+    tableRow.setAttribute("data-generate", "processing");
+
+    const {
+        examples,
+        error
     }
 
-    async function generateRowExamples(tableRow, rowValues, bulkMode = false) {
-        const originalState = tableRow.getAttribute("data-generate");
+    =await generateExample(rowValues, bulkMode);
+    tableRow.setAttribute("data-generate", originalState);
 
-        tableRow.setAttribute("data-generate", "processing");
-        const { examples, error } = await generateExample(rowValues, bulkMode);
-        tableRow.setAttribute("data-generate", originalState);
+    if (error) {
+        if ( !bulkMode) createAlert("Example Generation Failed", error, true);
+        tableRow.setAttribute("data-generate", originalState===defaultAttrs["data-generate"] ? "failed" : originalState);
 
-        if (error) {
-            if (!bulkMode) createAlert("Example Generation Failed", error, true);
-            tableRow.setAttribute("data-generate", originalState === defaultAttrs["data-generate"] ? "failed" : originalState);
-            return { success: false, created: 0, existed: 0, count: 0 };
+        return {
+            success: false, created: 0, existed: 0, count: 0
         }
 
-        const { createdCount, existedCount, totalCount } = getExamplesCount(examples);
-        const newExamples = getOnlyNewExamples(tableRow, examples);
-        const thisRowIsGenerated = tableRow.getAttribute("data-generate") === "success";
-        const newRows = newExamples.map((ex, idx) => updateRowWithExample(tableRow, thisRowIsGenerated || idx > 0, ex));
+        ;
+    }
+
+    const {
+        createdCount,
+        existedCount,
+        totalCount
+    }
+
+    =getExamplesCount(examples);
+    const newExamples=getOnlyNewExamples(tableRow, examples);
+    const thisRowIsGenerated=tableRow.getAttribute("data-generate")==="success";
+    const newRows=newExamples.map((ex, idx)=> updateRowWithExample(tableRow, thisRowIsGenerated || idx > 0, ex));
 
-        const rowsToBeAdded = newRows.filter((row, idx) => idx > 0 || thisRowIsGenerated);
-        const exampleFragment = document.createDocumentFragment();
-        rowsToBeAdded.forEach(row => exampleFragment.appendChild(row))
+    const rowsToBeAdded=newRows.filter((row, idx)=> idx > 0 || thisRowIsGenerated);
+    const exampleFragment=document.createDocumentFragment();
 
-        requestAnimationFrame(() => {
-            rowsToBeAdded.forEach(row => tableRow.parentElement.insertBefore(row, tableRow.nextSibling));
+    rowsToBeAdded.forEach(row=> exampleFragment.appendChild(row)) requestAnimationFrame(()=> {
+            rowsToBeAdded.forEach(row=> tableRow.parentElement.insertBefore(row, tableRow.nextSibling));
             updateSpans(tableRow, rowValues, rowsToBeAdded.length);
-        })
 
-        if (!bulkMode) {
-            const alertTitle = `Example(s) Generated, ${existedCount} already existed`;
-            const alertMessage = `Example name(s): ${newExamples.map(example => parseFileName(example.exampleFilePath)).join("\n")}`;
-            createAlert(alertTitle, alertMessage, false)
-        };
+        }) if ( !bulkMode) {
+
+        const alertTitle=`Example(s) Generated,
+        $ {
+            existedCount
+        }
+
+        already existed`;
+
+        const alertMessage=`Example name(s): $ {
+            newExamples.map(example=> parseFileName(example.exampleFilePath)).join("\n")
+        }
+
+        `;
+        createAlert(alertTitle, alertMessage, false)
+    }
+
+    ;
+
+    return {
+        success: true, created: createdCount, existed: existedCount, count: totalCount
+    }
+
+    ;
+}
+
+async function validateRowExamples(tableRow, bulkMode=false) {
+    tableRow.setAttribute("data-valid", "processing");
+    const exampleData=getExampleData(tableRow);
+
+    if ( !isSaved) {
+        const exampleSaved=await saveExample(exampleData);
+
+        if ( !exampleSaved) {
+            return false;
+        }
+    }
+
+    const {
+        exampleAbsPath,
+        errorMessage,
+        errorList,
+        isPartialFailure
+    }
+
+    =await validateExample(exampleData);
+
+    if (errorMessage && !exampleAbsPath) {
+        if ( !bulkMode) createAlert("Validation Failed", `Error: $ {
+                error ?? "Unknown Error"
+            }
+
+            `, true);
+        tableRow.setAttribute("data-valid", "failed");
+        return false;
+    }
+
+    tableRow.setAttribute("data-valid", errorMessage ? isPartialFailure ? "partial" : "failed" : "success");
+
+    storeExampleValidationData(tableRow, {
+        errorMessage, errorList
+    });
+storeExampleTestData(tableRow, null);
+tableRow.setAttribute("data-test", defaultAttrs["data-test"]);
+
+if (errorMessage && !isPartialFailure) {
+    if ( !bulkMode) createAlert("Invalid Example", `Example name: $ {
+            parseFileName(exampleAbsPath)
+        }
+
+        `, true);
+    return false;
+}
+
+if ( !bulkMode) createAlert("Valid Example", `Example name: $ {
+        parseFileName(exampleAbsPath)
+    }
+
+    `, false);
+return true;
+}
+
+async function testRowExample(tableRow, bulkMode=false) {
+    tableRow.setAttribute("data-test", "processing");
+
+    const isExampleValid=await validateRowExamples(tableRow, bulkMode);
+
+    if ( !isExampleValid) {
+        createAlert("Invalid Example or Network Failure", `Example name: $ {
+                parseFileName(getExampleData(tableRow))
+            }
+
+            `, true);
+        return false;
+    }
+
+    const exampleData=getExampleData(tableRow);
+
+    const {
+        data,
+        error
+    }
+
+    =await testExample({
+        exampleFile: exampleData
+    });
+
+if (error && !data) {
+    if ( !bulkMode) createAlert("Testing Failed", `Error: $ {
+            error ?? "Unknown Error"
+        }
+
+        `, true);
+    tableRow.setAttribute("data-test", "failed");
+    return false;
+}
+
+tableRow.setAttribute("data-test", (error || data?.result !=="Success") ? "failed" : "success");
+storeExampleTestData(tableRow, data);
+
+if (error || data?.result !=="Success") {
+    if ( !bulkMode) createAlert(`Test $ {
+            data ? data.result : "Failed"
+        }
+
+        `, `Example name: $ {
+            parseFileName(exampleData)
+        }
+
+        `, true);
+    return false;
+}
+
+if ( !bulkMode) createAlert("Test Passed", `Example name: $ {
+        parseFileName(exampleData)
+    }
+
+    `, false);
+return true;
+}
+
+// ACTION HELPERS
+function getExamplesCount(examples) {
+    return examples.reduce((counts, example)=> {
+            if (example.created) {
+                counts.createdCount++;
+            }
+
+            else if (example.existed) {
+                counts.existedCount++;
+            }
+
+            return counts;
+        }
+
+        , {
+        createdCount: 0, existedCount: 0, totalCount: examples.length
+    });
+}
+
+function getOnlyNewExamples(tableRow, examples) {
+    const existingExamples=new Set(getAllSameGroupExamples(tableRow));
+    return examples.filter(example=> !existingExamples.has(example.exampleFilePath));
+}
+
+function updateRowWithExample(tableRow, shouldClone, example) {
+    const newRow=shouldClone ? tableRow.cloneNode(true): tableRow;
+    storeExampleData(newRow, example);
+    insertExampleIntoRow(example, newRow);
 
-        return { success: true, created: createdCount, existed: existedCount, count: totalCount };
+    if (shouldClone) {
+        Object.entries(defaultAttrs).forEach(([attr, value])=> newRow.setAttribute(attr, value));
+        Array.from(newRow.children).slice(2, -2).forEach(cell=> cell.classList.add("hidden"));
     }
 
-    async function validateRowExamples(tableRow, bulkMode = false) {
-        tableRow.setAttribute("data-valid", "processing");
-        const exampleData = getExampleData(tableRow);
+    newRow.setAttribute("data-generate", "success");
+    enableValidateBtn(newRow);
+    return newRow;
+}
 
-        if (!isSaved) {
-            const exampleSaved = await saveExample(exampleData);
-            if (!exampleSaved) {
-                return false;
-            }
-        }
+function insertExampleIntoRow(example, tableRow) {
+    const exampleSpan=document.createElement("span");
+    exampleSpan.textContent=parseFileName(example.exampleFilePath);
+    const generateColumn=tableRow.querySelector("td:nth-last-child(2)") generateColumn.replaceChildren(exampleSpan);
+}
 
-        const { exampleAbsPath, errorMessage, errorList, isPartialFailure } = await validateExample(exampleData);
+function updateSpans(tableRow, rowValues, increment) {
+    const origMainValues=Object.values(rowValues) let curRow=tableRow;
 
-        if (errorMessage && !exampleAbsPath) {
-            if (!bulkMode) createAlert("Validation Failed", `Error: ${error ?? "Unknown Error"}`, true);
-            tableRow.setAttribute("data-valid", "failed");
-            return false;
-        }
+    while (curRow) {
+        const curRowValues=Object.values(extractRowValues(curRow));
+        if (curRowValues[0] !==origMainValues[0]) break;
 
-        tableRow.setAttribute("data-valid", errorMessage ? isPartialFailure ? "partial" : "failed" : "success");
-        storeExampleValidationData(tableRow, { errorMessage, errorList });
-        storeExampleTestData(tableRow, null);
-        tableRow.setAttribute("data-test", defaultAttrs["data-test"]);
+        const cells=Array.from(curRow.children).slice(2, -2);
+        let isMatchingCell=true;
 
-        if (errorMessage && !isPartialFailure) {
-            if (!bulkMode) createAlert("Invalid Example", `Example name: ${parseFileName(exampleAbsPath)}`, true);
-            return false;
+        for (let i=0; i < cells.length; i++) {
+            isMatchingCell=isMatchingCell && curRowValues[i]===origMainValues[i];
+
+            if (i==cells.length - 1) {
+                isMatchingCell=isMatchingCell && curRowValues[i+1]==origMainValues[i+1];
+            }
+
+            if (isMatchingCell) {
+                cells[i].rowSpan+=increment;
+            }
         }
 
-        if (!bulkMode) createAlert("Valid Example", `Example name: ${parseFileName(exampleAbsPath)}`, false);
-        return true;
+        curRow=curRow.previousElementSibling;
     }
+}
 
-    async function testRowExample(tableRow, bulkMode = false) {
-        tableRow.setAttribute("data-test", "processing");
+async function goToDetails(tableRow, rowValues) {
+    const exampleAbsPath=getExampleData(tableRow);
+    let docFragment=[];
 
-        const isExampleValid = await validateRowExamples(tableRow, bulkMode);
-        if (!isExampleValid) {
-            createAlert("Invalid Example or Network Failure", `Example name: ${parseFileName(getExampleData(tableRow))}`, true);
-            return false;
+    if (exampleAbsPath) {
+        const {
+            example,
+            error
         }
 
-        const exampleData = getExampleData(tableRow);
-        const { data, error } = await testExample({
-            exampleFile: exampleData
-        });
+        =await getExampleContent(exampleAbsPath);
 
-        if (error && !data) {
-            if (!bulkMode) createAlert("Testing Failed", `Error: ${error ?? "Unknown Error"}`, true);
-            tableRow.setAttribute("data-test", "failed");
-            return false;
+        const {
+            errorList,
+            errorMessage
         }
 
-        tableRow.setAttribute("data-test", (error || data?.result !== "Success") ? "failed" : "success");
-        storeExampleTestData(tableRow, data);
-
-        if (error || data?.result !== "Success") {
-            if (!bulkMode) createAlert(`Test ${data ? data.result : "Failed"}`, `Example name: ${parseFileName(exampleData)}`, true);
-            return false;
+        =getExampleValidationData(tableRow) || {
+            errorList: null, errorMessage: null
         }
 
-        if (!bulkMode) createAlert("Test Passed", `Example name: ${parseFileName(exampleData)}`, false);
-        return true;
-    }
+        ;
 
-    // ACTION HELPERS
-    function getExamplesCount(examples) {
-        return examples.reduce((counts, example) => {
-            if (example.created) {
-                counts.createdCount++;
-            } else if (example.existed) {
-                counts.existedCount++;
+        docFragment=createExampleRows([ {
+                absPath: exampleAbsPath,
+                exampleJson: example,
+                errorList: errorList,
+                errorMessage: error || errorMessage,
+                hasBeenValidated: tableRow.getAttribute("data-valid") !==defaultAttrs["data-valid"],
+                isPartialFailure: tableRow.getAttribute("data-valid")==="partial",
+                test: getExampleTestData(tableRow)
             }
-            return counts;
-        }, { createdCount: 0, existedCount: 0, totalCount: examples.length });
+
+            ]);
+        originalEditorText=example;
     }
 
-    function getOnlyNewExamples(tableRow, examples) {
-        const existingExamples = new Set(getAllSameGroupExamples(tableRow));
-        return examples.filter(example => !existingExamples.has(example.exampleFilePath));
+    bulkTestBtn.classList.toggle("bulk-disabled", tableRow.getAttribute("data-valid") !=="success") pathSummaryUl.replaceChildren(createPathSummary(rowValues));
+    examplesOl.replaceChildren(docFragment);
+    mainElement.setAttribute("data-panel", "details");
+    bulkValidateBtn.setAttribute("data-panel", "details");
+    bulkGenerateBtn.setAttribute("data-panel", "details");
+    bulkTestBtn.setAttribute("data-panel", "details");
+    scrollYPosition=window.scrollY;
+    window.scrollTo(0, 0);
+}
+
+function createExampleRows(examples) {
+    const docFragment=document.createDocumentFragment();
+
+    for (const example of examples) {
+        const exampleLi=document.createElement("li");
+        exampleLi.appendChild(createExampleSummary(example));
+        exampleLi.appendChild(createExampleDropDown(example));
+        docFragment.appendChild(exampleLi);
     }
 
-    function updateRowWithExample(tableRow, shouldClone, example) {
-        const newRow = shouldClone ? tableRow.cloneNode(true) : tableRow;
-        storeExampleData(newRow, example);
-        insertExampleIntoRow(example, newRow);
+    return docFragment;
+}
+
+function createPathSummary(rowValues) {
+    const docFragment=document.createDocumentFragment();
 
-        if (shouldClone) {
-            Object.entries(defaultAttrs).forEach(([attr, value]) => newRow.setAttribute(attr, value));
-            Array.from(newRow.children).slice(2, -2).forEach(cell => cell.classList.add("hidden"));
+    if (rowValues.isSchemaBased) {
+        rowValues= {
+            "schema": rowValues["path"], ...rowValues
         }
 
-        newRow.setAttribute("data-generate", "success");
-        enableValidateBtn(newRow);
-        return newRow;
+        ;
+        delete rowValues["path"];
+        delete rowValues["isSchemaBased"];
     }
 
-    function insertExampleIntoRow(example, tableRow) {
-        const exampleSpan = document.createElement("span");
-        exampleSpan.textContent = parseFileName(example.exampleFilePath);
-        const generateColumn = tableRow.querySelector("td:nth-last-child(2)")
-        generateColumn.replaceChildren(exampleSpan);
+    for (const [key, value] of Object.entries(rowValues)) {
+        if ( !value) continue;
+
+        const li=document.createElement("li");
+        const keySpan=document.createElement("span");
+        const valueSpan=document.createElement("span");
+
+        keySpan.textContent=key;
+        valueSpan.textContent=value;
+        li.appendChild(keySpan);
+        li.appendChild(valueSpan);
+
+        docFragment.appendChild(li);
     }
 
-    function updateSpans(tableRow, rowValues, increment) {
-        const origMainValues = Object.values(rowValues)
-        let curRow = tableRow;
+    return docFragment;
+}
 
-        while (curRow) {
-            const curRowValues = Object.values(extractRowValues(curRow));
-            if (curRowValues[0] !== origMainValues[0]) break;
 
-            const cells = Array.from(curRow.children).slice(2, -2);
-            let isMatchingCell = true;
+function createExampleSummary(example) {
+    const exampleDiv=document.createElement("div");
+    const exampleName=document.createElement("p");
+    const exampleBadge=document.createElement("span");
+    const testBadge=document.createElement("span");
 
-            for (let i = 0; i < cells.length; i++) {
-                isMatchingCell = isMatchingCell && curRowValues[i] === origMainValues[i];
-                if (i == cells.length - 1) {
-                    isMatchingCell = isMatchingCell && curRowValues[i + 1] == origMainValues[i + 1];
-                }
-                if (isMatchingCell) {
-                    cells[i].rowSpan += increment;
-                }
-            }
+    exampleDiv.classList.add("example");
+    exampleBadge.classList.add("pill", example.hasBeenValidated ? (example.errorMessage ? (example.isPartialFailure ? "yellow" : "red"): "green") : "blue");
+    exampleName.textContent=example.absPath;
 
-            curRow = curRow.previousElementSibling;
-        }
+    if (example.hasBeenValidated) {
+        exampleBadge.textContent=example.errorMessage ? example.isPartialFailure ? "Valid": "Invalid": "Valid";
+        exampleBadge.textContent+=" Example";
     }
 
-    async function goToDetails(tableRow, rowValues) {
-        const exampleAbsPath = getExampleData(tableRow);
-        let docFragment = [];
+    else {
+        exampleBadge.textContent="Example";
+    }
 
-        if (exampleAbsPath) {
-            const { example, error } = await getExampleContent(exampleAbsPath);
-            const { errorList, errorMessage } = getExampleValidationData(tableRow) || { errorList: null, errorMessage: null };
-            docFragment = createExampleRows([{
-                absPath: exampleAbsPath,
-                exampleJson: example,
-                errorList: errorList,
-                errorMessage: error || errorMessage,
-                hasBeenValidated: tableRow.getAttribute("data-valid") !== defaultAttrs["data-valid"],
-                isPartialFailure: tableRow.getAttribute("data-valid") === "partial",
-                test: getExampleTestData(tableRow)
-            }]);
-             originalEditorText = example;
-        }
+    const expandDiv=document.createElement("div");
+    expandDiv.classList.add("expand-info");
+    expandDiv.appendChild(exampleBadge);
 
-        bulkTestBtn.classList.toggle("bulk-disabled", tableRow.getAttribute("data-valid") !== "success")
-        pathSummaryUl.replaceChildren(createPathSummary(rowValues));
-        examplesOl.replaceChildren(docFragment);
-        mainElement.setAttribute("data-panel", "details");
-        bulkValidateBtn.setAttribute("data-panel", "details");
-        bulkGenerateBtn.setAttribute("data-panel", "details");
-        bulkTestBtn.setAttribute("data-panel", "details");
-        scrollYPosition = window.scrollY;
-        window.scrollTo(0, 0);
-    }
+    if (example.test) {
+        console.log(example.test);
+        testBadge.classList.add("pill", example.test.result==="Success" ? "green" : "red");
 
-    function createExampleRows(examples) {
-        const docFragment = document.createDocumentFragment();
-        for (const example of examples) {
-            const exampleLi = document.createElement("li");
-            exampleLi.appendChild(createExampleSummary(example));
-            exampleLi.appendChild(createExampleDropDown(example));
-            docFragment.appendChild(exampleLi);
+        testBadge.textContent=`Test $ {
+            example.test.result
         }
 
-        return docFragment;
+        `;
+        expandDiv.appendChild(testBadge);
     }
 
-    function createPathSummary(rowValues) {
-        const docFragment = document.createDocumentFragment();
+    exampleDiv.appendChild(exampleName);
+    exampleDiv.appendChild(expandDiv);
+    return exampleDiv;
+}
 
-        if (rowValues.isSchemaBased) {
-            rowValues = { "schema": rowValues["path"], ...rowValues };
-            delete rowValues["path"];
-            delete rowValues["isSchemaBased"];
-        }
+function createExampleDropDown(example) {
+    const detailsDiv=document.createElement("div");
+    detailsDiv.classList.add("details");
 
-        for (const [key, value] of Object.entries(rowValues)) {
-            if (!value) continue;
+    const detailsDropdown=document.createElement("div");
+    detailsDropdown.classList.add("dropdown");
+    const detailsPara=document.createElement("p");
+    detailsDropdown.appendChild(detailsPara);
+    detailsDropdown.appendChild(chevronDownIcon.cloneNode(true));
 
-            const li = document.createElement("li");
-            const keySpan = document.createElement("span");
-            const valueSpan = document.createElement("span");
+    const detailsPre=document.createElement("pre");
+    const examplePara=document.createElement("p");
+    examplePara.textContent="Example: ";
 
-            keySpan.textContent = key;
-            valueSpan.textContent = value;
-            li.appendChild(keySpan);
-            li.appendChild(valueSpan);
+    if (example.errorMessage) {
+        const issueCount=example.errorList.length;
+        const issueOrIssues=issueCount===1 ? "issue": "issues";
 
-            docFragment.appendChild(li);
+        detailsPara.textContent=`Example has $ {
+            issueCount || ""
         }
-        return docFragment;
-    }
 
+        $ {
+            issueOrIssues
+        }
+
+        `;
 
-    function createExampleSummary(example) {
-        const exampleDiv = document.createElement("div");
-        const exampleName = document.createElement("p");
-        const exampleBadge = document.createElement("span");
-        const testBadge = document.createElement("span");
+        if (issueCount > 0) {
+            detailsPara.style.color="red";
+        }
+    }
 
-        exampleDiv.classList.add("example");
-        exampleBadge.classList.add("pill", example.hasBeenValidated ? (example.errorMessage ? (example.isPartialFailure ? "yellow" : "red"): "green") : "blue");
-        exampleName.textContent = example.absPath;
+    else {
+        detailsPara.textContent=example.hasBeenValidated ? "Example has no errors": "Example has not yet been validated";
+    }
 
-        if (example.hasBeenValidated) {
-           exampleBadge.textContent = example.errorMessage ? example.isPartialFailure ? "Valid" : "Invalid" : "Valid";
-            exampleBadge.textContent += " Example";
-        } else {
-            exampleBadge.textContent = "Example";
+    if (example.hasBeenValidated) {
+        detailsPre.textContent=example.errorMessage ? example.errorMessage : `$ {
+            parseFileName(example.absPath)
         }
 
-        const expandDiv = document.createElement("div");
-        expandDiv.classList.add("expand-info");
-        expandDiv.appendChild(exampleBadge);
+        IS VALID`;
 
         if (example.test) {
-            console.log(example.test);
-            testBadge.classList.add("pill", example.test.result === "Success" ? "green" : "red");
-            testBadge.textContent = `Test ${example.test.result}`;
-            expandDiv.appendChild(testBadge);
+            detailsPre.textContent=`$ {
+                detailsPre.textContent
+            }
+
+            \n$ {
+                example.test.details
+            }
+
+            `;
+        }
+    }
+
+    else {
+        detailsPre.textContent=`$ {
+            parseFileName(example.absPath)
         }
 
-        exampleDiv.appendChild(exampleName);
-        exampleDiv.appendChild(expandDiv);
-        return exampleDiv;
+        HAS NOT YET BEEN VALIDATED`;
     }
 
-    function createExampleDropDown(example) {
-        const detailsDiv = document.createElement("div");
-        detailsDiv.classList.add("details");
+    const examplePreDiv=document.createElement("div");
+    const detailsFragment=document.createDocumentFragment();
 
-        const detailsDropdown = document.createElement("div");
-        detailsDropdown.classList.add("dropdown");
-        const detailsPara = document.createElement("p");
-        detailsDropdown.appendChild(detailsPara);
-        detailsDropdown.appendChild(chevronDownIcon.cloneNode(true));
+    examplePreDiv.setAttribute("id", "example-pre");
+    examplePreDiv.classList.add("language-json");
+    detailsFragment.appendChild(detailsDropdown);
+    detailsFragment.appendChild(detailsPre);
 
-        const detailsPre = document.createElement("pre");
-        const examplePara = document.createElement("p");
-        examplePara.textContent = "Example: ";
+    setDecorationsEffect=window.StateEffect.define();
 
-        if (example.errorMessage) {
-            const issueCount = example.errorList.length;
-            const issueOrIssues = issueCount === 1 ? "issue" : "issues";
-            detailsPara.textContent = `Example has ${issueCount || ""} ${issueOrIssues}`;
-            if (issueCount > 0) {
-                detailsPara.style.color = "red";
-            }
-        } else {
-            detailsPara.textContent = example.hasBeenValidated ? "Example has no errors" : "Example has not yet been validated";
+    decorationsField=window.StateField.define({
+        create() {
+            return window.Decoration.none;
         }
 
-        if (example.hasBeenValidated) {
-            detailsPre.textContent = example.errorMessage ? example.errorMessage : `${parseFileName(example.absPath)} IS VALID`;
-            if (example.test) {
-                detailsPre.textContent = `${detailsPre.textContent}\n${example.test.details}`;
-            }
-        } else {
-            detailsPre.textContent = `${parseFileName(example.absPath)} HAS NOT YET BEEN VALIDATED`;
-        }
-
-        const examplePreDiv = document.createElement("div");
-        const detailsFragment = document.createDocumentFragment();
-
-        examplePreDiv.setAttribute("id", "example-pre");
-        examplePreDiv.classList.add("language-json");
-        detailsFragment.appendChild(detailsDropdown);
-        detailsFragment.appendChild(detailsPre);
-
- setDecorationsEffect = window.StateEffect.define();
-   decorationsField = window.StateField.define({
-    create() {
-        return window.Decoration.none;
-    },
-    update(decorations, transaction) {
-        for (let effect of transaction.effects) {
-            if (effect.is(setDecorationsEffect)) {
-                return effect.value;
+        ,
+        update(decorations, transaction) {
+            for (let effect of transaction.effects) {
+                if (effect.is(setDecorationsEffect)) {
+                    return effect.value;
+                }
             }
+
+            return decorations;
         }
-        return decorations;
-    },
-    provide: field => window.EditorView.decorations.from(field)
-});
 
-    const editor = new window.EditorView({
+        ,
+        provide: field=> window.EditorView.decorations.from(field)
+    });
+
+const editor=new window.EditorView({
     state: window.EditorState.create({
-      doc: example.exampleJson,
-      extensions: [
-        window.basicSetup,
+
+        doc: example.exampleJson,
+        extensions: [ window.basicSetup,
         window.autocompletion,
         window.json,
         window.linter,
@@ -1826,491 +2426,637 @@ <h2 th:text="${contractFilePath}"></h2>
         window.lineNumbers,
         window.oneDark,
         decorationsField,
-        window.EditorView.updateListener.of((update) => {
-        if (update.docChanged) {
-          isSaved = false;
-          const editorElement = editor.dom;
-          updateBorderColorExampleBlock(editorElement, examplePreDiv);
-           if (example.errorList && example.errorList.length >0) {
-                highlightErrorLines(editor, example.errorList, example.exampleJson);
+        window.EditorView.updateListener.of((update)=> {
+                if (update.docChanged) {
+                    isSaved=false;
+                    const editorElement=editor.dom;
+                    updateBorderColorExampleBlock(editorElement, examplePreDiv);
+
+                    if (example.errorList && example.errorList.length >0) {
+                        highlightErrorLines(editor, example.errorList, example.exampleJson);
+                    }
+
+                    savedEditorResponse=update.state.doc.toString();
                 }
-          savedEditorResponse = update.state.doc.toString();
-        }
-      })
-    ],
-  }),
-    parent: examplePreDiv
-  });
+            })],
+    }),
+parent: examplePreDiv
+});
+
+
+if (example.errorList && example.errorList.length >0) {
+    highlightErrorLines(editor, example.errorList, example.exampleJson);
+}
+
 
+if (example.test) {
+    const testPara=document.createElement("p");
+    testPara.textContent="Test Log: ";
+    const testPre=document.createElement("pre");
+    testPre.textContent=example.test.testLog;
+    detailsFragment.appendChild(testPara);
+    detailsFragment.appendChild(testPre);
+}
+
+detailsDiv.appendChild(detailsFragment);
+detailsDiv.appendChild(examplePara);
+
+const fragment=document.createDocumentFragment();
+
+if (example.errorMessage) {
+    fragment.appendChild(detailsDiv);
+}
+
+fragment.appendChild(examplePreDiv);
+
+return fragment;
+}
 
-       if (example.errorList && example.errorList.length >0) {
-                highlightErrorLines(editor, example.errorList, example.exampleJson);
+async function saveExample(examplePath) {
+    const editedText=savedEditorResponse;
+
+    try {
+        const parsedContent=JSON.parse(editedText);
+
+        const response=await fetch(`$ {
+                getHostPort()
+            }
+
+            /_specmatic/examples/update`, {
+            method: "POST",
+            headers: {
+                "Content-Type": "application/json",
             }
 
+            ,
+            body: JSON.stringify({
+                exampleFile: examplePath,
+                exampleContent: editedText,
+            }),
+    });
 
-        if (example.test) {
-            const testPara = document.createElement("p");
-            testPara.textContent = "Test Log: ";
-            const testPre = document.createElement("pre");
-            testPre.textContent = example.test.testLog;
-            detailsFragment.appendChild(testPara);
-            detailsFragment.appendChild(testPre);
-        }
+if (response.ok) {
+    createAlert("Saved", "Example saved to file", false);
+    isSaved=true;
+    return true;
+}
 
-        detailsDiv.appendChild(detailsFragment);
-        detailsDiv.appendChild(examplePara);
+else {
+    const errorMessage=await response.text();
 
-        const fragment = document.createDocumentFragment();
-        if (example.errorMessage) {
-            fragment.appendChild(detailsDiv);
+    createAlert("Failed to save example.", `Failed to save example to $ {
+            examplePath
         }
-        fragment.appendChild(examplePreDiv);
 
-        return fragment;
-    }
+        : $ {
+            errorMessage
+        }
 
-    async function saveExample(examplePath) {
-        const editedText = savedEditorResponse;
-        try {
-            const parsedContent = JSON.parse(editedText);
+        `, true);
+    console.error("Error saving example:", response.status);
+    savedEditorResponse=originalEditorText;
+    return false;
+}
+}
 
-            const response = await fetch(`${getHostPort()}/_specmatic/examples/update`, {
-                method: "POST",
-                headers: {
-                    "Content-Type": "application/json",
-                },
-                body: JSON.stringify({
-                    exampleFile: examplePath,
-                    exampleContent: editedText,
-                }),
-            });
+catch (e) {
+    console.error("Error during save request:", e);
 
-            if (response.ok) {
-                createAlert("Saved", "Example saved to file", false);
-                isSaved = true;
-                return true;
-            } else {
-                const errorMessage = await response.text();
-                createAlert("Failed to save example.", `Failed to save example to ${examplePath}: ${errorMessage}`, true);
-                console.error("Error saving example:", response.status);
-                savedEditorResponse = originalEditorText;
-                return false;
-            }
-        } catch (e) {
-            console.error("Error during save request:", e);
-            createAlert("Failed to save example.", `An error occurred while saving example to ${examplePath}: ${e.message}`, true);
-            savedEditorResponse = originalEditorText;
-            return false;
+    createAlert("Failed to save example.", `An error occurred while saving example to $ {
+            examplePath
         }
-    }
+
+        : $ {
+            e.message
+        }
+
+        `, true);
+    savedEditorResponse=originalEditorText;
+    return false;
+}
+}
 
 
-   function updateBorderColorExampleBlock(editorElement, examplePreDiv) {
+function updateBorderColorExampleBlock(editorElement, examplePreDiv) {
     try {
         JSON.parse(editorElement.state.doc.toString());
-        editorElement.style.borderWidth = "2px";
-        editorElement.style.borderStyle = "solid";
-        editorElement.style.borderColor = "green";
-    } catch (e) {
-        editorElement.style.borderWidth = "2px";
-        editorElement.style.borderStyle = "solid";
-        editorElement.style.borderColor = "red";
+        editorElement.style.borderWidth="2px";
+        editorElement.style.borderStyle="solid";
+        editorElement.style.borderColor="green";
+    }
+
+    catch (e) {
+        editorElement.style.borderWidth="2px";
+        editorElement.style.borderStyle="solid";
+        editorElement.style.borderColor="red";
     }
 }
 
 
-   function highlightErrorLines(editor, metadata, exampleJson) {
-    const { data, pointers } = jsonMapParser(exampleJson);
-    let decorations = [];
+function highlightErrorLines(editor, metadata, exampleJson) {
+    const {
+        data,
+        pointers
+    }
 
-    metadata.forEach(meta => {
-        var location = findObjectByPath(pointers, meta.jsonPath);
-        if (location == null) {
-            meta.jsonPath = meta.jsonPath.substring(0, meta.jsonPath.lastIndexOf('/'));
-            location = findObjectByPath(pointers, meta.jsonPath);
-        }
-        const lineNumber = location.key ? location.key.line : (location.value ? location.value.line : null);
+    =jsonMapParser(exampleJson);
+    let decorations=[];
+
+    metadata.forEach(meta=> {
+            var location=findObjectByPath(pointers, meta.jsonPath);
+
+            if (location==null) {
+                meta.jsonPath=meta.jsonPath.substring(0, meta.jsonPath.lastIndexOf('/'));
+                location=findObjectByPath(pointers, meta.jsonPath);
+            }
+
+            const lineNumber=location.key ? location.key.line : (location.value ? location.value.line : null);
 
-        if (lineNumber !== null) {
-            const lineLength = editor.state.doc.line(lineNumber + 1)
-            const className = meta.isPartial
-                ? "cm-lint-mark-warning CodeMirror-lint-mark-warning"
+            if (lineNumber !==null) {
+                const lineLength=editor.state.doc.line(lineNumber + 1) const className=meta.isPartial ? "cm-lint-mark-warning CodeMirror-lint-mark-warning"
                 : "cm-lint-mark-error CodeMirror-lint-mark-error";
 
-            decorations.push(
-            window.Decoration.line({
-                class: className,
-                attributes: { "data-validation-error-message": meta.description
-                }
-            }).range(lineLength.from)
-            );
+                decorations.push(window.Decoration.line({
+
+                        class: className,
+                        attributes: {
+                            "data-validation-error-message": meta.description
+                        }
+                    }).range(lineLength.from));
+
             errorMetadata.push({
                 line: lineNumber+1,
                 message: meta.description,
                 isPartial: meta.isPartial
             });
-        }
-    });
-   const decorationSet = window.Decoration.set(decorations);
-    const transaction = editor.state.update({
-        effects: setDecorationsEffect.of(decorationSet)
-    });
+    }
+});
+const decorationSet=window.Decoration.set(decorations);
 
-    editor.dispatch(transaction);
-     const errorTooltipExtension = createErrorTooltipExtension(errorMetadata);
-    editor.dispatch({
-        effects: setDecorationsEffect.of(decorationSet),
-    });
-    editor.dispatch({
-        effects: window.StateEffect.appendConfig.of([errorTooltipExtension]),
-    });
+const transaction=editor.state.update({
+    effects: setDecorationsEffect.of(decorationSet)
+});
+
+editor.dispatch(transaction);
+const errorTooltipExtension=createErrorTooltipExtension(errorMetadata);
+
+editor.dispatch({
+    effects: setDecorationsEffect.of(decorationSet),
+});
+
+editor.dispatch({
+    effects: window.StateEffect.appendConfig.of([errorTooltipExtension]),
+});
 
 }
-    function findObjectByPath(pointers, patch) {
-        for (const path in pointers) {
-            if (path === patch) {
-                return pointers[path];
-            }
+
+function findObjectByPath(pointers, patch) {
+    for (const path in pointers) {
+        if (path===patch) {
+            return pointers[path];
         }
-        return null;
     }
-   const createErrorTooltipExtension = (errorMetadata) => {
-    return window.hoverTooltip((view, pos) => {
-        const line = view.state.doc.lineAt(pos);
-        const error = errorMetadata.find(err => err.line === line.number);
-        const lineCoords = view.coordsAtPos(pos);
-        if (error) {
-            return {
-                pos,
-                above: true,
-                create: () => {
-                    const tooltip = document.createElement("div");
-                    tooltip.textContent = error.message;
-                    tooltip.innerHTML = error.message.replace(/\n/g, "<br>");
-                    tooltip.className = "cm-tooltip cm-tooltip-lint";
-                    tooltip.style.color = "white";
-                    tooltip.style.padding = "15px";
-                    tooltip.style.borderRadius = "3px";
-                    tooltip.style.fontSize = "20px";
-                    tooltip.style.pointerEvents = "none";
-                    tooltip.style.display = "block";
-                     tooltip.style.zIndex = "1000";
-                      tooltip.style.position = "fixed";
-                      tooltip.style.borderLeft = error.isPartial ? "4px solid yellow"
+
+    return null;
+}
+
+const createErrorTooltipExtension=(errorMetadata)=> {
+    return window.hoverTooltip((view, pos)=> {
+            const line=view.state.doc.lineAt(pos);
+            const error=errorMetadata.find(err=> err.line===line.number);
+            const lineCoords=view.coordsAtPos(pos);
+
+            if (error) {
+                return {
+
+                    pos,
+                    above: true,
+                    create: ()=> {
+                        const tooltip=document.createElement("div");
+                        tooltip.textContent=error.message;
+                        tooltip.innerHTML=error.message.replace(/\n/g, "<br>");
+                        tooltip.className="cm-tooltip cm-tooltip-lint";
+                        tooltip.style.color="white";
+                        tooltip.style.padding="15px";
+                        tooltip.style.borderRadius="3px";
+                        tooltip.style.fontSize="20px";
+                        tooltip.style.pointerEvents="none";
+                        tooltip.style.display="block";
+                        tooltip.style.zIndex="1000";
+                        tooltip.style.position="fixed";
+                        tooltip.style.borderLeft=error.isPartial ? "4px solid yellow"
                         : "4px solid red";
-                       tooltip.style.top = `${lineCoords.top + window.scrollY - tooltip.offsetHeight - 120}px`; // Position above the line
-                    tooltip.style.left = `${lineCoords.left + 20}px`;
-                    return { dom: tooltip};
-                },
-            };
-        }
 
-        return null;
-    });
-};
+                        tooltip.style.top=`$ {
+                            lineCoords.top + window.scrollY - tooltip.offsetHeight - 120
+                        }
 
-    function createErrorMarker() {
-        const marker = document.createElement("div");
-        marker.className = "CodeMirror-lint-mark-error";
-        return marker;
-    }
+                        px`; // Position above the line
 
+                        tooltip.style.left=`$ {
+                            lineCoords.left + 20
+                        }
 
-    function parseFileName(path) {
-        return path.split('/').pop();
-    }
-    function storeExampleData(tableRow, example) {
-        const key = tableRow.getAttribute("data-key");
-        tableRow.setAttribute("data-example", example.exampleFilePath);
-        exampleDetails[key][example.exampleFilePath] = null;
-        return example;
-    }
+                        px`;
 
-    function getExampleData(tableRow) {
-        return tableRow.getAttribute("data-example");
-    }
+                        return {
+                            dom: tooltip
+                        }
 
-    function getAllSameGroupExamples(tableRow) {
-        const rowKey = tableRow.getAttribute("data-key");
-        const examplePairs = exampleDetails[rowKey];
-        return Object.keys(examplePairs).filter(value => value !== "null");
-    }
+                        ;
+                    }
 
-    function storeExampleValidationData(tableRow, result) {
-        const key = tableRow.getAttribute("data-key");
-        exampleDetails[key][tableRow.getAttribute("data-example")] = result;
-    }
+                    ,
+                }
 
-    function getExampleValidationData(tableRow) {
-        const key = tableRow.getAttribute("data-key");
-        return exampleDetails[key][getExampleData(tableRow)];
-    }
+                ;
+            }
+
+            return null;
+        });
+}
 
-    function storeExampleTestData(tableRow, data) {
-        const key = tableRow.getAttribute("data-key");
-        const exampleData = getExampleData(tableRow);
+;
 
-        if (!testDetails[key]) {
-            testDetails[key] = {};
-        }
+function createErrorMarker() {
+    const marker=document.createElement("div");
+    marker.className="CodeMirror-lint-mark-error";
+    return marker;
+}
+
+
+function parseFileName(path) {
+    return path.split('/').pop();
+}
+
+function storeExampleData(tableRow, example) {
+    const key=tableRow.getAttribute("data-key");
+    tableRow.setAttribute("data-example", example.exampleFilePath);
+    exampleDetails[key][example.exampleFilePath]=null;
+    return example;
+}
+
+function getExampleData(tableRow) {
+    return tableRow.getAttribute("data-example");
+}
+
+function getAllSameGroupExamples(tableRow) {
+    const rowKey=tableRow.getAttribute("data-key");
+    const examplePairs=exampleDetails[rowKey];
+    return Object.keys(examplePairs).filter(value=> value !=="null");
+}
+
+function storeExampleValidationData(tableRow, result) {
+    const key=tableRow.getAttribute("data-key");
+    exampleDetails[key][tableRow.getAttribute("data-example")]=result;
+}
+
+function getExampleValidationData(tableRow) {
+    const key=tableRow.getAttribute("data-key");
+    return exampleDetails[key][getExampleData(tableRow)];
+}
 
-        testDetails[key][exampleData] = data;
+function storeExampleTestData(tableRow, data) {
+    const key=tableRow.getAttribute("data-key");
+    const exampleData=getExampleData(tableRow);
+
+    if ( !testDetails[key]) {
+        testDetails[key]= {}
+
+        ;
     }
 
+    testDetails[key][exampleData]=data;
+}
 
-    function getExampleTestData(tableRow) {
-        const key = tableRow.getAttribute("data-key");
 
-        if (!testDetails[key]) {
-            return null;
-        }
+function getExampleTestData(tableRow) {
+    const key=tableRow.getAttribute("data-key");
 
-        return testDetails[key][getExampleData(tableRow)];
+    if ( !testDetails[key]) {
+        return null;
     }
 
-    async function generateExample(pathInfo, bulkMode) {
-        try {
-            const resp = await fetch(`${getHostPort()}/_specmatic/examples/generate`, {
-                method: "POST",
-                body: JSON.stringify({ ...pathInfo, bulkMode }),
-                headers: {
-                    "Content-Type": "application/json",
-                }
-            });
-            const data = await resp.json();
+    return testDetails[key][getExampleData(tableRow)];
+}
 
-            if (!resp.ok) {
-                throw new Error(data.error);
+async function generateExample(pathInfo, bulkMode) {
+    try {
+        const resp=await fetch(`$ {
+                getHostPort()
             }
 
-            return { examples: data.examples, error: data.error };
-        } catch (error) {
-            return { error: error.message, examples: null };
+            /_specmatic/examples/generate`, {
+            method: "POST",
+            body: JSON.stringify({
+                ...pathInfo, bulkMode
+
+            }),
+        headers: {
+            "Content-Type": "application/json",
         }
+    });
+const data=await resp.json();
+
+if ( !resp.ok) {
+    throw new Error(data.error);
+}
+
+return {
+    examples: data.examples, error: data.error
+}
+
+;
+}
+
+catch (error) {
+    return {
+        error: error.message, examples: null
     }
 
-    async function validateExample(exampleFile) {
-        try {
-            const resp = await fetch(`${getHostPort()}/_specmatic/examples/validate`, {
-                method: "POST",
-                body: JSON.stringify({ exampleFile }),
-                headers: {
-                    "Content-Type": "application/json",
-                }
-            });
-            const data = await resp.json();
+    ;
+}
+}
 
-            if (!resp.ok) {
-                throw new Error(data.errorMessage);
+async function validateExample(exampleFile) {
+    try {
+        const resp=await fetch(`$ {
+                getHostPort()
             }
 
-            return { exampleAbsPath: data.absPath, errorList: data.errorList, errorMessage: data.errorMessage, isPartialFailure: data.isPartialFailure };
-        } catch (error) {
-            return { errorMessage: error.message, exampleAbsPath: null, isPartialFailure: false, errorList: null };
+            /_specmatic/examples/validate`, {
+            method: "POST",
+            body: JSON.stringify({
+                exampleFile
+
+            }),
+        headers: {
+            "Content-Type": "application/json",
         }
+    });
+const data=await resp.json();
+
+if ( !resp.ok) {
+    throw new Error(data.errorMessage);
+}
+
+return {
+    exampleAbsPath: data.absPath, errorList: data.errorList, errorMessage: data.errorMessage, isPartialFailure: data.isPartialFailure
+}
+
+;
+}
+
+catch (error) {
+    return {
+        errorMessage: error.message, exampleAbsPath: null, isPartialFailure: false, errorList: null
     }
 
-    async function getExampleContent(example) {
-        const exampleFileName = encodeURIComponent(example);
-        try {
-            const resp = await fetch(`${getHostPort()}/_specmatic/examples/content?fileName=${exampleFileName}`)
-            const data = await resp.json();
+    ;
+}
+}
+
+async function getExampleContent(example) {
+    const exampleFileName=encodeURIComponent(example);
 
-            if (!resp.ok) {
-                throw new Error(data.error);
+    try {
+        const resp=await fetch(`$ {
+                getHostPort()
+            }
+
+            /_specmatic/examples/content?fileName=$ {
+                exampleFileName
             }
 
-            return { example: data.content, error: null };
-        } catch (e) {
-            return { example: null, error: e.message }
+            `) const data=await resp.json();
+
+        if ( !resp.ok) {
+            throw new Error(data.error);
         }
-    }
 
-    async function testExample(exampleData) {
-        try {
-            const resp = await fetch(`${getHostPort()}/_specmatic/examples/test`, {
-                method: "POST",
-                body: JSON.stringify(exampleData),
-                headers: {
-                    "Content-Type": "application/json",
-                }
-            });
-            const data = await resp.json();
+        return {
+            example: data.content, error: null
+        }
 
-            if (!resp.ok) {
-                throw new Error(data.error);
-            }
+        ;
+    }
 
-            return { data, error: data.error }
-        } catch (error) {
-            return { data: null, error: error.message }
+    catch (e) {
+        return {
+            example: null, error: e.message
         }
     }
+}
+
+async function testExample(exampleData) {
+    try {
+        const resp=await fetch(`$ {
+                getHostPort()
+            }
+
+            /_specmatic/examples/test`, {
+            method: "POST",
+            body: JSON.stringify(exampleData),
+            headers: {
+                "Content-Type": "application/json",
+            }
+        });
+    const data=await resp.json();
 
-    function parseFileName(absPath) {
-        const fileName = absPath.split("\\").pop().split("/").pop();
-        const lastIndex = fileName.lastIndexOf(".");
-        return fileName.slice(0, lastIndex);
+    if ( !resp.ok) {
+        throw new Error(data.error);
     }
 
-    function getHostPort() {
-        const hostPort = table.getAttribute("data-hostPort");
-        return hostPort ? hostPort.replace(/\/$/, '') : hostPort;
+    return {
+        data,
+        error: data.error
     }
+}
 
-    function enableValidateBtn(tableRow) {
-        table.setAttribute("data-generated", "true");
+catch (error) {
+    return {
+        data: null, error: error.message
     }
+}
+}
 
-    function createAlert(heading, message, error) {
-        const alertBox = document.createElement("div");
-        alertBox.classList.add("alert-msg", "slide-in", error ? "red" : "green");
+function parseFileName(absPath) {
+    const fileName=absPath.split("\\").pop().split("/").pop();
+    const lastIndex=fileName.lastIndexOf(".");
+    return fileName.slice(0, lastIndex);
+}
+
+function getHostPort() {
+    const hostPort=table.getAttribute("data-hostPort");
+    return hostPort ? hostPort.replace(/\/$/, ''): hostPort;
+}
+
+function enableValidateBtn(tableRow) {
+    table.setAttribute("data-generated", "true");
+}
+
+function createAlert(heading, message, error) {
+    const alertBox=document.createElement("div");
+    alertBox.classList.add("alert-msg", "slide-in", error ? "red" : "green");
 
-        const alertTitle = document.createElement("p");
-        alertTitle.textContent = heading;
+    const alertTitle=document.createElement("p");
+    alertTitle.textContent=heading;
 
-        const alertMsg = document.createElement("pre");
-        alertMsg.textContent = message;
+    const alertMsg=document.createElement("pre");
+    alertMsg.textContent=message;
 
-        alertBox.appendChild(alertTitle);
-        alertBox.appendChild(alertMsg);
-        alerts.replaceChildren(alertBox);
+    alertBox.appendChild(alertTitle);
+    alertBox.appendChild(alertMsg);
+    alerts.replaceChildren(alertBox);
 
-        setTimeout(() => {
-            if (!alerts.matches(":hover")) {
+    setTimeout(()=> {
+            if ( !alerts.matches(":hover")) {
                 removeAlertBox(alertBox);
-            } else {
-                const handleMouseLeave = () => {
+            }
+
+            else {
+                const handleMouseLeave=()=> {
                     removeAlertBox(alertBox);
                     alerts.removeEventListener("mouseleave", handleMouseLeave);
-                };
+                }
+
+                ;
                 alerts.addEventListener("mouseleave", handleMouseLeave);
             }
-        }, 3000);
-    }
+        }
 
-    function removeAlertBox(alertBox) {
-        alertBox.classList.add("slide-out");
-        setTimeout(() => {
+        , 3000);
+}
+
+function removeAlertBox(alertBox) {
+    alertBox.classList.add("slide-out");
+
+    setTimeout(()=> {
             alertBox.remove();
-        }, 250);
-    }
+        }
+
+        , 250);
+}
 
-    function cleanUpSelections() {
-        requestAnimationFrame(() => {
+function cleanUpSelections() {
+    requestAnimationFrame(()=> {
             for (const checkbox of table.querySelectorAll("input[type=checkbox]")) {
-                checkbox.checked = false;
+                checkbox.checked=false;
             }
         });
-        bulkGenerateBtn.setAttribute("data-selected", "0");
-        bulkValidateBtn.setAttribute("data-selected", "0");
-        bulkTestBtn.setAttribute("data-selected", "0");
-        blockGenValidate = false;
-    }
-    function createModal({ onSave, onDiscard }) {
-        // Data for modal
-        const title = "Unsaved Changes";
-        const closeText = "No";
-        const discardText = "Yes";
-        const bodyText = "Your changes are not saved & validated. To save your changes click on the Save & Validate button. Discard changes?";
-
-        // Create modal container dynamically
-        const modalContainer = document.createElement("div");
-        modalContainer.classList.add("go-back-modal");
-        modalContainer.style.position = "fixed";
-        modalContainer.style.top = "0";
-        modalContainer.style.left = "0";
-        modalContainer.style.width = "100%";
-        modalContainer.style.height = "100%";
-        modalContainer.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
-        modalContainer.style.display = "flex";
-        modalContainer.style.alignItems = "center";
-        modalContainer.style.justifyContent = "center";
-        modalContainer.style.zIndex = "9999";
-
-        // Create modal content box
-        const modalContent = document.createElement("div");
-        modalContent.style.backgroundColor = "#fff";
-        modalContent.style.borderRadius = "8px";
-        modalContent.style.padding = "20px";
-        modalContent.style.width = "400px";
-        modalContent.style.boxShadow = "0 4px 8px rgba(0, 0, 0, 0.2)";
-        modalContent.style.textAlign = "center";
-
-        // Create modal header
-        const modalHeader = document.createElement("div");
-        const modalTitle = document.createElement("h5");
-        modalTitle.textContent = title;
-        modalHeader.style.fontSize = "18px";
-        modalHeader.style.fontWeight = "bold";
-        modalHeader.style.marginBottom = "15px";
-        modalHeader.appendChild(modalTitle);
-
-        // Create modal body
-        const modalBody = document.createElement("div");
-        modalBody.textContent = bodyText;
-        modalBody.style.marginBottom = "15px";
-
-        // Create modal footer
-        const modalFooter = document.createElement("div");
-
-        const closeButton = document.createElement("button");
-        closeButton.textContent = closeText;
-        closeButton.style.backgroundColor = "#007bff";
-        closeButton.style.color = "#fff";
-        closeButton.style.border = "none";
-        closeButton.style.padding = "8px 16px";
-        closeButton.style.borderRadius = "4px";
-        closeButton.style.cursor = "pointer";
-        closeButton.style.marginRight = "10px";
-
-        const discardButton = document.createElement("button");
-        discardButton.textContent = discardText;
-        discardButton.style.backgroundColor = "#007bff";
-        discardButton.style.color = "#fff";
-        discardButton.style.border = "none";
-        discardButton.style.padding = "8px 16px";
-        discardButton.style.borderRadius = "4px";
-        discardButton.style.cursor = "pointer";
-
-        // Add buttons to footer
-        modalFooter.appendChild(closeButton);
-        modalFooter.appendChild(discardButton);
-
-        // Append everything to the modal content
-        modalContent.appendChild(modalHeader);
-        modalContent.appendChild(modalBody);
-        modalContent.appendChild(modalFooter);
-
-        // Append modal content to modal container
-        modalContainer.appendChild(modalContent);
-
-
-        // Button event listeners
-        closeButton.addEventListener("click", () => {
+    bulkGenerateBtn.setAttribute("data-selected", "0");
+    bulkValidateBtn.setAttribute("data-selected", "0");
+    bulkTestBtn.setAttribute("data-selected", "0");
+    blockGenValidate=false;
+}
+
+function createModal({
+    onSave, onDiscard
+
+}) {
+    // Data for modal
+    const title="Unsaved Changes";
+    const closeText="No";
+    const discardText="Yes";
+    const bodyText="Your changes are not saved & validated. To save your changes click on the Save & Validate button. Discard changes?";
+
+    // Create modal container dynamically
+    const modalContainer=document.createElement("div");
+    modalContainer.classList.add("go-back-modal");
+    modalContainer.style.position="fixed";
+    modalContainer.style.top="0";
+    modalContainer.style.left="0";
+    modalContainer.style.width="100%";
+    modalContainer.style.height="100%";
+    modalContainer.style.backgroundColor="rgba(0, 0, 0, 0.5)";
+    modalContainer.style.display="flex";
+    modalContainer.style.alignItems="center";
+    modalContainer.style.justifyContent="center";
+    modalContainer.style.zIndex="9999";
+
+    // Create modal content box
+    const modalContent=document.createElement("div");
+    modalContent.style.backgroundColor="#fff";
+    modalContent.style.borderRadius="8px";
+    modalContent.style.padding="20px";
+    modalContent.style.width="400px";
+    modalContent.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)";
+    modalContent.style.textAlign="center";
+
+    // Create modal header
+    const modalHeader=document.createElement("div");
+    const modalTitle=document.createElement("h5");
+    modalTitle.textContent=title;
+    modalHeader.style.fontSize="18px";
+    modalHeader.style.fontWeight="bold";
+    modalHeader.style.marginBottom="15px";
+    modalHeader.appendChild(modalTitle);
+
+    // Create modal body
+    const modalBody=document.createElement("div");
+    modalBody.textContent=bodyText;
+    modalBody.style.marginBottom="15px";
+
+    // Create modal footer
+    const modalFooter=document.createElement("div");
+
+    const closeButton=document.createElement("button");
+    closeButton.textContent=closeText;
+    closeButton.style.backgroundColor="#007bff";
+    closeButton.style.color="#fff";
+    closeButton.style.border="none";
+    closeButton.style.padding="8px 16px";
+    closeButton.style.borderRadius="4px";
+    closeButton.style.cursor="pointer";
+    closeButton.style.marginRight="10px";
+
+    const discardButton=document.createElement("button");
+    discardButton.textContent=discardText;
+    discardButton.style.backgroundColor="#007bff";
+    discardButton.style.color="#fff";
+    discardButton.style.border="none";
+    discardButton.style.padding="8px 16px";
+    discardButton.style.borderRadius="4px";
+    discardButton.style.cursor="pointer";
+
+    // Add buttons to footer
+    modalFooter.appendChild(closeButton);
+    modalFooter.appendChild(discardButton);
+
+    // Append everything to the modal content
+    modalContent.appendChild(modalHeader);
+    modalContent.appendChild(modalBody);
+    modalContent.appendChild(modalFooter);
+
+    // Append modal content to modal container
+    modalContainer.appendChild(modalContent);
+
+
+    // Button event listeners
+    closeButton.addEventListener("click", ()=> {
             closeModal();
         });
 
-        discardButton.addEventListener("click", () => {
+    discardButton.addEventListener("click", ()=> {
             onDiscard();
             closeModal();
         });
 
 
-        modalContainer.addEventListener("click", (event) => {
-            if (event.target === modalContainer) {
+    modalContainer.addEventListener("click", (event)=> {
+            if (event.target===modalContainer) {
                 closeModal();
             }
         });
 
 
-        function closeModal() {
-            modalContainer.remove();
-        }
-        return modalContainer;
+    function closeModal() {
+        modalContainer.remove();
     }
 
+    return modalContainer;
+}
+
 
-    (() => cleanUpSelections())();
-</script>
-</html>
\ No newline at end of file
+(()=> cleanUpSelections())();
+</script></html>
\ No newline at end of file

From f8da5687170559e918845a1af3d7be48d070af7d Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 22:04:20 +0530
Subject: [PATCH 09/14] Indentation fixed

---
 .../resources/templates/examples/index.html   | 4138 +++++++----------
 1 file changed, 1696 insertions(+), 2442 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index 89aef5d23..df9491c58 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1,367 +1,340 @@
-< !DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Interactive Examples</title><style>*,
-::before,
-::after {
-    box-sizing: border-box;
-}
-
-/*
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Interactive Examples</title>
+    <style>
+        *,
+        ::before,
+        ::after {
+          box-sizing: border-box;
+        }
+
+        /*
         1. Use a consistent sensible line-height in all browsers.
         2. Prevent adjustments of font size after orientation changes in iOS.
         3. Use a more readable tab size.
         4. Normalize font features
         */
 
-:root {
-    line-height: 1.5;
-    /* 1 */
-    text-size-adjust: 100%;
-    /* 2: -webkit-text-size-adjust */
-    tab-size: 4;
-    /* 3: -moz-tab-size */
-    font-feature-settings: normal;
-    /* 4 */
-    font-variation-settings: normal;
-    /* 4 */
-}
+        :root {
+          line-height: 1.5; /* 1 */
+          text-size-adjust: 100%; /* 2: -webkit-text-size-adjust */
+          tab-size: 4; /* 3: -moz-tab-size */
+          font-feature-settings: normal; /* 4 */
+          font-variation-settings: normal; /* 4 */
+        }
 
-/*
+        /*
         1. Remove the margin in all browsers.
         2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
         */
 
-body {
-    margin: 0;
-    /* 1 */
-    line-height: inherit;
-    /* 2 */
-}
+        body {
+          margin: 0; /* 1 */
+          line-height: inherit; /* 2 */
+        }
 
-/*
+        /*
         1. Add the correct height in Firefox.
         2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
         3. Ensure horizontal rules are visible by default.
         */
 
-hr {
-    height: 0;
-    /* 1 */
-    color: inherit;
-    /* 2 */
-    border-top-width: 1px;
-    /* 3 */
-}
+        hr {
+          height: 0; /* 1 */
+          color: inherit; /* 2 */
+          border-top-width: 1px; /* 3 */
+        }
 
-/*
+        /*
         Add the correct text decoration in Chrome, Edge, and Safari.
         */
 
-abbr:where([title]) {
-    text-decoration: underline dotted;
-}
+        abbr:where([title]) {
+          text-decoration: underline dotted;
+        }
 
-/*
+        /*
         Remove the default font size and weight for headings.
         */
 
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
-    font-size: inherit;
-    font-weight: inherit;
-}
+        h1,
+        h2,
+        h3,
+        h4,
+        h5,
+        h6 {
+          font-size: inherit;
+          font-weight: inherit;
+        }
 
-/*
+        /*
         Reset links to optimize for opt-in styling instead of opt-out.
         */
 
-a {
-    color: inherit;
-    text-decoration: inherit;
-}
+        a {
+          color: inherit;
+          text-decoration: inherit;
+        }
 
-/*
+        /*
         Add the correct font weight in Edge and Safari.
         */
 
-b,
-strong {
-    font-weight: bolder;
-}
+        b,
+        strong {
+          font-weight: bolder;
+        }
 
-/*
+        /*
         1. Correct the odd `em` font sizing in all browsers.
         2. Use a web-safe monospace font.
         */
 
-code,
-kbd,
-samp,
-pre {
-    font-size: 1em;
-    /* 1 */
-    font-family: 'Courier New', Courier, monospace;
-    /* 2 */
-}
+        code,
+        kbd,
+        samp,
+        pre {
+          font-size: 1em; /* 1 */
+          font-family: 'Courier New', Courier, monospace; /* 2 */
+        }
 
-/*
+        /*
         Add the correct font size in all browsers.
         */
 
-small {
-    font-size: 80%;
-}
+        small {
+          font-size: 80%;
+        }
 
-/*
+        /*
         Prevent `sub` and `sup` elements from affecting the line height in all browsers.
         */
 
-sub,
-sup {
-    font-size: 75%;
-    line-height: 0;
-    position: relative;
-    vertical-align: baseline;
-}
+        sub,
+        sup {
+          font-size: 75%;
+          line-height: 0;
+          position: relative;
+          vertical-align: baseline;
+        }
 
-sub {
-    bottom: -0.25em;
-}
+        sub {
+          bottom: -0.25em;
+        }
 
-sup {
-    top: -0.5em;
-}
+        sup {
+          top: -0.5em;
+        }
 
-/*
+        /*
         1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
         2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
         3. Remove gaps between table borders by default.
         */
 
-table {
-    text-indent: 0;
-    /* 1 */
-    border-color: inherit;
-    /* 2 */
-    border-collapse: collapse;
-    /* 3 */
-}
+        table {
+          text-indent: 0; /* 1 */
+          border-color: inherit; /* 2 */
+          border-collapse: collapse; /* 3 */
+        }
 
-/*
+        /*
         1. Change the font styles in all browsers.
         2. Remove the margin in Firefox and Safari.
         3. Remove default padding in all browsers.
         */
 
-button,
-input,
-optgroup,
-select,
-textarea {
-    font-family: inherit;
-    /* 1 */
-    font-feature-settings: inherit;
-    /* 1 */
-    font-variation-settings: inherit;
-    /* 1 */
-    font-size: 100%;
-    /* 1 */
-    font-weight: inherit;
-    /* 1 */
-    line-height: inherit;
-    /* 1 */
-    color: inherit;
-    /* 1 */
-    margin: 0;
-    /* 2 */
-    padding: 0;
-    /* 3 */
-}
-
-/*
+        button,
+        input,
+        optgroup,
+        select,
+        textarea {
+          font-family: inherit; /* 1 */
+          font-feature-settings: inherit; /* 1 */
+          font-variation-settings: inherit; /* 1 */
+          font-size: 100%; /* 1 */
+          font-weight: inherit; /* 1 */
+          line-height: inherit; /* 1 */
+          color: inherit; /* 1 */
+          margin: 0; /* 2 */
+          padding: 0; /* 3 */
+        }
+
+        /*
         Remove the inheritance of text transform in Edge and Firefox.
         */
 
-button,
-select {
-    text-transform: none;
-}
+        button,
+        select {
+          text-transform: none;
+        }
 
-/*
+        /*
         1. Correct the inability to style clickable types in iOS and Safari.
         2. Remove default button styles.
         */
 
-button,
-[type='button'],
-[type='reset'],
-[type='submit'] {
-    appearance: button;
-    /* -webkit-appearance */
-    background-color: transparent;
-    /* 2 */
-    background-image: none;
-    /* 2 */
-}
+        button,
+        [type='button'],
+        [type='reset'],
+        [type='submit'] {
+          appearance: button; /* -webkit-appearance */
+          background-color: transparent; /* 2 */
+          background-image: none; /* 2 */
+        }
 
-/*
+        /*
         Use the modern Firefox focus style for all focusable elements.
         */
 
-:-moz-focusring {
-    outline: auto;
-}
+        :-moz-focusring {
+          outline: auto;
+        }
 
-/*
+        /*
         Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
         */
 
-:-moz-ui-invalid {
-    box-shadow: none;
-}
+        :-moz-ui-invalid {
+          box-shadow: none;
+        }
 
-/*
+        /*
         Add the correct vertical alignment in Chrome and Firefox.
         */
 
-progress {
-    vertical-align: baseline;
-}
+        progress {
+          vertical-align: baseline;
+        }
 
-/*
+        /*
         Correct the cursor style of increment and decrement buttons in Safari.
         */
 
-::-webkit-inner-spin-button,
-::-webkit-outer-spin-button {
-    height: auto;
-}
+        ::-webkit-inner-spin-button,
+        ::-webkit-outer-spin-button {
+          height: auto;
+        }
 
-/*
+        /*
         1. Correct the odd appearance in Chrome and Safari.
         2. Correct the outline style in Safari.
         */
 
-[type='search'] {
-    appearance: textfield;
-    /* -webkit-appearance */
-    outline-offset: -2px;
-    /* 2 */
-}
+        [type='search'] {
+          appearance: textfield; /* -webkit-appearance */
+          outline-offset: -2px; /* 2 */
+        }
 
-/*
+        /*
         Remove the inner padding in Chrome and Safari on macOS.
         */
 
-::-webkit-search-decoration {
-    appearance: none;
-    /* -webkit-appeaance */
-}
+        ::-webkit-search-decoration {
+          appearance: none; /* -webkit-appeaance */
+        }
 
-/*
+        /*
         1. Correct the inability to style clickable types in iOS and Safari.
         2. Change font properties to `inherit` in Safari.
         */
 
-::-webkit-file-upload-button {
-    appearance: button;
-    /* -webkit-appearance */
-    font: inherit;
-    /* 2 */
-}
+        ::-webkit-file-upload-button {
+          appearance: button; /* -webkit-appearance */
+          font: inherit; /* 2 */
+        }
 
-/*
+        /*
         Add the correct display in Chrome and Safari.
         */
 
-summary {
-    display: list-item;
-}
+        summary {
+          display: list-item;
+        }
 
-/*
+        /*
         Removes the default spacing and border for appropriate elements.
         */
 
-blockquote,
-dl,
-dd,
-h1,
-h2,
-h3,
-h4,
-h5,
-h6,
-hr,
-figure,
-p,
-pre {
-    margin: 0;
-}
+        blockquote,
+        dl,
+        dd,
+        h1,
+        h2,
+        h3,
+        h4,
+        h5,
+        h6,
+        hr,
+        figure,
+        p,
+        pre {
+          margin: 0;
+        }
 
-fieldset {
-    margin: 0;
-    padding: 0;
-}
+        fieldset {
+          margin: 0;
+          padding: 0;
+        }
 
-legend {
-    padding: 0;
-}
+        legend {
+          padding: 0;
+        }
 
-ol,
-ul,
-menu {
-    list-style: none;
-    margin: 0;
-    padding: 0;
-}
+        ol,
+        ul,
+        menu {
+          list-style: none;
+          margin: 0;
+          padding: 0;
+        }
 
-/*
+        /*
         Reset default styling for dialogs.
         */
-dialog {
-    padding: 0;
-}
+        dialog {
+          padding: 0;
+        }
 
-/*
+        /*
         Prevent resizing textareas horizontally by default.
         */
 
-textarea {
-    resize: vertical;
-}
+        textarea {
+          resize: vertical;
+        }
 
-/*
+        /*
         1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
         2. Set the default placeholder color to gray.
         */
 
-input::placeholder,
-textarea::placeholder {
-    opacity: 1;
-    /* 1 */
-    color: #9ca3af;
-    /* 2 */
-}
+        input::placeholder,
+        textarea::placeholder {
+          opacity: 1; /* 1 */
+          color: #9ca3af; /* 2 */
+        }
 
-/*
+        /*
         Set the default cursor for buttons.
         */
 
-button,
-[role='button'] {
-    cursor: pointer;
-}
+        button,
+        [role='button'] {
+          cursor: pointer;
+        }
 
-/*
+        /*
         Make sure disabled buttons don't get the pointer cursor.
         */
-:disabled {
-    cursor: default;
-}
+        :disabled {
+          cursor: default;
+        }
 
-/*
+        /*
         1. Make replaced elements `display: block` by default.
           (https://github.com/mozdevs/cssremedy/issues/14)
         2. Add `vertical-align: middle` to align replaced elements more sensibly by default.
@@ -369,1266 +342,909 @@
            This can trigger a poorly considered lint error in some tools but is included by design.
         */
 
-img,
-svg,
-video,
-canvas,
-audio,
-iframe,
-embed,
-object {
-    display: block;
-    /* 1 */
-    vertical-align: middle;
-    /* 2 */
-}
+        img,
+        svg,
+        video,
+        canvas,
+        audio,
+        iframe,
+        embed,
+        object {
+          display: block; /* 1 */
+          vertical-align: middle; /* 2 */
+        }
 
-/*
+        /*
         Constrain images and videos to the parent width and preserve their intrinsic aspect ratio.
         (https://github.com/mozdevs/cssremedy/issues/14)
         */
 
-img,
-video {
-    max-width: 100%;
-    height: auto;
-}
+        img,
+        video {
+          max-width: 100%;
+          height: auto;
+        }
 
 
-[hidden] {
-    display: none;
-}
+        [hidden] {
+          display: none;
+        }
 
-.CodeMirror-lint-mark-error {
-    background-color: rgba(255, 0, 0, 0.2);
-    overflow: hidden;
-}
+        .CodeMirror-lint-mark-error {
+            background-color: rgba(255, 0, 0, 0.2);
+            overflow : hidden;
+        }
+          .CodeMirror-lint-mark-warning {
+            background-color:  rgba(255, 255, 0, 0.2);
+            overflow : hidden;
+        }
+         .CodeMirror-gutter-wrapper {
+            position: relative;
+        }
+    .cm-content {
+    font-size: 16px;
+    line-height: 1.5;
+    }
+    }
+    </style>
+    <style>
+        @import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");
+        @import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@200;300;400;500;600;700&display=swap");
+
+        :root {
+            /* COLORS */
+            --smoky-black: 23, 18, 7;
+            --alice-blue: 233, 241, 247;
+            /* PRIMARY COLORS */
+            --white: 255, 255, 255;
+            --black: 0, 0, 0;
+            --slate: 241, 245, 249;
+            --yellow: 255, 207, 51;
+            --blue: 52, 115, 217;
+            --green: 34, 197, 94;
+            --red: 239, 68, 68;
+            --blue-dark: 29, 78, 216;
+            --gray: 128, 128, 128;
+            /* PILL COLORS */
+            --pill-green: 134, 239, 172;
+            --pill-red: 252, 165, 165;
+
+            /* Font Families */
+            --sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
+            --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
+            --roboto: "Roboto", var(--mono), var(--sans);
+
+            /* Shadows */
+            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
+            --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
+            --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
+        }
+
+        html {
+            scroll-behavior: smooth;
+            scrollbar-gutter: stable;
+        }
+
+        body {
+            font-family: var(--roboto);
 
-.CodeMirror-lint-mark-warning {
-    background-color: rgba(255, 255, 0, 0.2);
-    overflow: hidden;
-}
+            & > .chevron {
+                display: none;
+            }
+        }
 
-.CodeMirror-gutter-wrapper {
-    position: relative;
-}
+        main {
+            display: flex;
+            align-items: start;
+            overflow: hidden;
+            flex: 1;
+            background-color: rgba(var(--alice-blue));
+        }
 
-.cm-content {
-    font-size: 16px;
-    line-height: 1.5;
-}
-}
+        .chevron {
+            width: 1.5rem;
+            height: 1.5rem;
+            animation: bounce 2s infinite;
+        }
 
-</style><style>@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");
-@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@200;300;400;500;600;700&display=swap");
-
-:root {
-    /* COLORS */
-    --smoky-black: 23, 18, 7;
-    --alice-blue: 233, 241, 247;
-    /* PRIMARY COLORS */
-    --white: 255, 255, 255;
-    --black: 0, 0, 0;
-    --slate: 241, 245, 249;
-    --yellow: 255, 207, 51;
-    --blue: 52, 115, 217;
-    --green: 34, 197, 94;
-    --red: 239, 68, 68;
-    --blue-dark: 29, 78, 216;
-    --gray: 128, 128, 128;
-    /* PILL COLORS */
-    --pill-green: 134, 239, 172;
-    --pill-red: 252, 165, 165;
-
-    /* Font Families */
-    --sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
-    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
-    --roboto: "Roboto", var(--mono), var(--sans);
-
-    /* Shadows */
-    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
-    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
-    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
-}
+        /* HEADER STYLES */
 
-html {
-    scroll-behavior: smooth;
-    scrollbar-gutter: stable;
-}
+        header {
+            display: flex;
+            flex-direction: column;
+            justify-content: center;
+            align-items: center;
+            gap: .25rem;
+            padding-bottom: .5rem;
 
-body {
-    font-family: var(--roboto);
+            & > #main-info {
+                display: flex;
+                text-align: center;
+                flex-direction: column;
 
-    &>.chevron {
-        display: none;
-    }
-}
+                & > h1 {
+                    font-size: 1.5rem;
+                    font-weight: 600;
+                    font-family: var(--roboto);
+                    letter-spacing: 0.025rem;
+                }
 
-main {
-    display: flex;
-    align-items: start;
-    overflow: hidden;
-    flex: 1;
-    background-color: rgba(var(--alice-blue));
-}
+                & > h2 {
+                    font-size: 0.75rem;
+                    font-weight: 400;
+                    font-family: var(--mono);
+                }
+            }
 
-.chevron {
-    width: 1.5rem;
-    height: 1.5rem;
-    animation: bounce 2s infinite;
-}
+            & .btn-grp {
+                display: flex;
+                align-items: center;
+                gap: 1rem;
 
-/* HEADER STYLES */
+                &[data-test-mode="false"] > #bulk-test {
+                    display: none;
+                }
+            }
 
-header {
-    display: flex;
-    flex-direction: column;
-    justify-content: center;
-    align-items: center;
-    gap: .25rem;
-    padding-bottom: .5rem;
+            & button {
+                --_radius: 0.25rem;
+                --_background-color: var(--blue);
+
+                color: white;
+                padding: var(--_padding);
+                background-color: rgba(var(--_background-color));
+                border-radius: var(--_radius);
+                padding: .5rem 1rem;
+                min-width: 9rem;
+                display: flex;
+                align-items: center;
+                justify-content: space-around;
+                gap: .1rem;
+
+                &#bulk-validate {
+                    --_content: "Validate Selected";
+
+                    &[data-panel="details"] {
+                        --_content: "Save & Validate";
+                    }
+                }
 
-    &>#main-info {
-        display: flex;
-        text-align: center;
-        flex-direction: column;
+                &[data-selected="0"][data-panel="table"], &.bulk-disabled {
+                    --_background-color: var(--gray);
+                    pointer-events: none;
+                }
 
-        &>h1 {
-            font-size: 1.5rem;
-            font-weight: 600;
-            font-family: var(--roboto);
-            letter-spacing: 0.025rem;
-        }
+                &[data-panel="table"]::after, &[data-panel="details"]::after  {
+                    content: var(--_content);
+                }
 
-        &>h2 {
-            font-size: 0.75rem;
-            font-weight: 400;
-            font-family: var(--mono);
-        }
-    }
+                &[data-selected][data-panel="table"]::before {
+                    content: var(--_after_content, " (" attr(data-selected) ") ");
+                    color: white;
+                }
 
-    & .btn-grp {
-        display: flex;
-        align-items: center;
-        gap: 1rem;
+                /* Temporarily Remove Selected Count */
+                &#bulk-generate[data-selected][data-panel="table"]::before {
+                    content: var(--_after_content);
+                    color: white;
+                }
 
-        &[data-test-mode="false"]>#bulk-test {
-            display: none;
+                &#bulk-generate {
+                    --_content: "Generate Selected";
+
+                    &::after {
+                        content: var(--_content, "Generate Selected");
+                    }
+
+                    &[data-panel="details"] {
+                        --_background-color: var(--gray);
+                        pointer-events: none;
+                    }
+                }
+
+                &#bulk-test {
+                    --_content: "Test Selected";
+
+                    &[data-panel="details"] {
+                        --_content: "Test Examples";
+                    }
+                }
+
+                &[data-valid="processing"],
+                &[data-generate="processing"],
+                &[data-test="processing"] {
+                    pointer-events: none;
+
+                    &::after {
+                        --_content: "";
+                        width: 24px;
+                        height: 24px;
+                        border: 3px solid #FFF;
+                        border-bottom-color: transparent;
+                        border-radius: 50%;
+                        display: inline-flex;
+                        animation: rotation 1s linear infinite;
+                    }
+
+                    &::before {
+                        --_after_content: "Processing";
+                    }
+                }
+            }
         }
-    }
 
-    & button {
-        --_radius: 0.25rem;
-        --_background-color: var(--blue);
+        /* TABLE STYLES */
 
-        color: white;
-        padding: var(--_padding);
-        background-color: rgba(var(--_background-color));
-        border-radius: var(--_radius);
-        padding: .5rem 1rem;
-        min-width: 9rem;
-        display: flex;
-        align-items: center;
-        justify-content: space-around;
-        gap: .1rem;
+        table {
+            width: 100%;
+            table-layout: auto;
+            text-align: center;
+            font-size: 0.99rem;
+            counter-reset: Serial;
+        }
 
-        &#bulk-validate {
-            --_content: "Validate Selected";
+        thead {
+            background: rgb(var(--slate));
+            font-weight: 500;
+            border-collapse: collapse;
+            font-family: var(--roboto);
 
-            &[data-panel="details"] {
-                --_content: "Save & Validate";
+            & > tr > th:not(:first-child) {
+                pointer-events: none;
             }
         }
 
-        &[data-selected="0"][data-panel="table"],
-        &.bulk-disabled {
-            --_background-color: var(--gray);
-            pointer-events: none;
+        th {
+            white-space: nowrap;
         }
 
-        &[data-panel="table"]::after,
-        &[data-panel="details"]::after {
-            content: var(--_content);
+        td,
+        th {
+            --_td-padding: 0.75rem;
+
+            border: 1px solid rgba(var(--smoky-black), 0.2);
+            padding: var(--_td-padding);
         }
 
-        &[data-selected][data-panel="table"]::before {
-            content: var(--_after_content, " (" attr(data-selected) ") ");
-            color: white;
+        .response-cell {
+            & > span {
+                font-size: 0.75rem;
+            }
         }
 
-        /* Temporarily Remove Selected Count */
-        &#bulk-generate[data-selected][data-panel="table"]::before {
-            content: var(--_after_content);
-            color: white;
+        tbody {
+            background-color: rgb(var(--white));
+            font-family: var(--mono);
+            font-weight: 500;
+
+            & > tr {
+                &:hover {
+                    background-color: rgb(var(--slate));
+                }
+
+                & > td:nth-child(n+3):nth-last-child(n+3) {
+                    background-color: rgb(var(--white));
+                    word-break: break-word;
+                    pointer-events: none;
+                }
+
+                & > td:nth-last-child(-n + 3) {
+                    cursor: pointer;
+                }
+            }
         }
 
-        &#bulk-generate {
-            --_content: "Generate Selected";
+        tbody > tr {
+            & button {
+                --_padding: 0.5rem 0rem;
+                --_background-color: var(--blue);
+                --_text-color: var(--white);
+                --_width: 7rem;
+                --_font-size: 1rem;
+                --_radius: 0.5rem;
 
-            &::after {
-                content: var(--_content, "Generate Selected");
+                padding: var(--_padding);
+                display: inline-block;
+                width: var(--_width);
+                border-radius: var(--_radius);
+                color: rgb(var(--_text-color));
+                background-color: rgba(var(--_background-color));
+                font-size: var(--_font-size);
+
+                &:hover {
+                    --_background-color: var(--blue-dark);
+                }
             }
 
-            &[data-panel="details"] {
-                --_background-color: var(--gray);
-                pointer-events: none;
+            & > td:nth-child(2)::before {
+                content: counter(Serial);
+                counter-increment: Serial;
             }
-        }
 
-        &#bulk-test {
-            --_content: "Test Selected";
+            & > td:last-child {
+                & > span {
+                    font-size: .75rem;
+                    line-height: 1.5rem;
+                    text-decoration: underline;
+                }
+            }
 
-            &[data-panel="details"] {
-                --_content: "Test Examples";
+            &[data-valid="partial"] button.validate {
+                --_background-color: var(--yellow);
+                --_text-color: var(--smoky-black);
             }
-        }
 
-        &[data-valid="processing"],
-        &[data-generate="processing"],
-        &[data-test="processing"] {
-            pointer-events: none;
+            &[data-valid="failed"] button.validate, &[data-generate="failed"] button.generate, &[data-test="failed"] button.test {
+                --_background-color: var(--red);
+            }
 
-            &::after {
-                --_content: "";
-                width: 24px;
-                height: 24px;
-                border: 3px solid #FFF;
-                border-bottom-color: transparent;
-                border-radius: 50%;
-                display: inline-flex;
-                animation: rotation 1s linear infinite;
+            &[data-valid="success"] button.validate, &[data-test="success"] button.test {
+                --_background-color: var(--green);
             }
 
-            &::before {
-                --_after_content: "Processing";
+            &[data-generate="success"], &[data-example] {
+                & td:last-child {
+                    & button.validate {
+                        display: inline-block;
+                    }
+
+                    & > span {
+                        display: block;
+                    }
+                }
             }
-        }
-    }
-}
 
-/* TABLE STYLES */
+            &[data-generate="processing"] button, &[data-valid="processing"] button.validate, &[data-test="processing"] button.test {
+                --_padding: 0.15rem 0rem;
+                --_background-color: var(--blue) !important;
+
+                &::after {
+                    --_content: "";
+                    margin-top: 5px;
+                    width: 24px;
+                    height: 24px;
+                    border: 3px solid #FFF;
+                    border-bottom-color: transparent;
+                    border-radius: 50%;
+                    display: inline-block;
+                    animation: rotation 1s linear infinite;
+                }
+            }
 
-table {
-    width: 100%;
-    table-layout: auto;
-    text-align: center;
-    font-size: 0.99rem;
-    counter-reset: Serial;
-}
+            & button.generate::after {
+                content: var(--_content, "Generate");
+            }
 
-thead {
-    background: rgb(var(--slate));
-    font-weight: 500;
-    border-collapse: collapse;
-    font-family: var(--roboto);
+            & button.validate::after {
+                content: var(--_content, "Validate");
+            }
 
-    &>tr>th:not(:first-child) {
-        pointer-events: none;
-    }
-}
+            & button.test::after {
+                content: var(--_content, "Test");
+            }
 
-th {
-    white-space: nowrap;
-}
+            &[data-generate="success"] > td:nth-last-child(3) {
+                pointer-events: all;
 
-td,
-th {
-    --_td-padding: 0.75rem;
+                & > button.multigen {
+                    --_padding: 0.35rem 0.35rem;
+                    --_font-size: 0.75rem;
+                    --_radius: 0.35rem;
+                    display: inline-block;
 
-    border: 1px solid rgba(var(--smoky-black), 0.2);
-    padding: var(--_td-padding);
-}
+                    &::after {
+                        content: var(--_content, "Generate More");
+                    }
+                }
+            }
+        }
 
-.response-cell {
-    &>span {
-        font-size: 0.75rem;
-    }
-}
 
-tbody {
-    background-color: rgb(var(--white));
-    font-family: var(--mono);
-    font-weight: 500;
+        tbody {
+            &[data-test-mode="true"] > tr[data-valid="success"] {
+                & td:last-child {
+                    & button.validate {
+                        display: none;
+                    }
 
-    &>tr {
-        &:hover {
-            background-color: rgb(var(--slate));
+                    & button.test {
+                        display: inline-block;
+                    }
+                }
+            }
         }
 
-        &>td:nth-child(n+3):nth-last-child(n+3) {
-            background-color: rgb(var(--white));
-            word-break: break-word;
-            pointer-events: none;
+        td:nth-child(3) {
+            text-align: initial;
+            min-width: 10rem;
         }
 
-        &>td:nth-last-child(-n + 3) {
-            cursor: pointer;
+        td:nth-child(4) {
+            min-width: 2rem;
         }
-    }
-}
 
-tbody>tr {
-    & button {
-        --_padding: 0.5rem 0rem;
-        --_background-color: var(--blue);
-        --_text-color: var(--white);
-        --_width: 7rem;
-        --_font-size: 1rem;
-        --_radius: 0.5rem;
-
-        padding: var(--_padding);
-        display: inline-block;
-        width: var(--_width);
-        border-radius: var(--_radius);
-        color: rgb(var(--_text-color));
-        background-color: rgba(var(--_background-color));
-        font-size: var(--_font-size);
-
-        &:hover {
-            --_background-color: var(--blue-dark);
+        td:last-child {
+            max-width: 9rem;
         }
-    }
 
-    &>td:nth-child(2)::before {
-        content: counter(Serial);
-        counter-increment: Serial;
-    }
+        td:nth-last-child(2) {
+            max-width: 15rem;
+            word-break: break-word;
+            font-size: .85rem;
+        }
 
-    &>td:last-child {
-        &>span {
-            font-size: .75rem;
-            line-height: 1.5rem;
-            text-decoration: underline;
+        td p, td button {
+            white-space: nowrap;
+            min-width: fit-content;
         }
-    }
 
-    &[data-valid="partial"] button.validate {
-        --_background-color: var(--yellow);
-        --_text-color: var(--smoky-black);
-    }
+        button {
+            border: none;
 
-    &[data-valid="failed"] button.validate,
-    &[data-generate="failed"] button.generate,
-    &[data-test="failed"] button.test {
-        --_background-color: var(--red);
-    }
+            &:active {
+                scale: 0.9;
+            }
+        }
 
-    &[data-valid="success"] button.validate,
-    &[data-test="success"] button.test {
-        --_background-color: var(--green);
-    }
+        /* TABLE AND DETAILS TRANSITIONS */
 
-    &[data-generate="success"],
-    &[data-example] {
-        & td:last-child {
-            & button.validate {
-                display: inline-block;
-            }
+        table,
+        #details {
+            transition: transform 0.5s ease-in-out;
+            min-width: 100%;
+        }
 
-            &>span {
-                display: block;
+        .group[data-panel="table"] {
+            & > #details {
+                transform: translateX(100%);
             }
         }
-    }
 
-    &[data-generate="processing"] button,
-    &[data-valid="processing"] button.validate,
-    &[data-test="processing"] button.test {
-        --_padding: 0.15rem 0rem;
-        --_background-color: var(--blue) !important;
-
-        &::after {
-            --_content: "";
-            margin-top: 5px;
-            width: 24px;
-            height: 24px;
-            border: 3px solid #FFF;
-            border-bottom-color: transparent;
-            border-radius: 50%;
-            display: inline-block;
-            animation: rotation 1s linear infinite;
-        }
-    }
+        .group[data-panel="details"] {
+            & > table {
+                transform: translateX(-100%);
+            }
 
-    & button.generate::after {
-        content: var(--_content, "Generate");
-    }
+            & > #details {
+                transform: translateX(-100%);
+            }
+        }
 
-    & button.validate::after {
-        content: var(--_content, "Validate");
-    }
+        /* DETAILS STYLES */
 
-    & button.test::after {
-        content: var(--_content, "Test");
-    }
+        #details {
+            padding: 0.5rem;
+        }
 
-    &[data-generate="success"]>td:nth-last-child(3) {
-        pointer-events: all;
+        button#back {
+            --_padding: 0.5rem 1rem;
+            --_radius: 0.25rem;
 
-        &>button.multigen {
-            --_padding: 0.35rem 0.35rem;
-            --_font-size: 0.75rem;
-            --_radius: 0.35rem;
-            display: inline-block;
+            color: white;
+            padding: var(--_padding);
+            background-color: rgba(var(--blue));
+            border-radius: var(--_radius);
 
-            &::after {
-                content: var(--_content, "Generate More");
+            &:hover,
+            &:focus {
+                background-color: rgba(var(--blue-dark));
             }
         }
-    }
-}
-
+        button#save-example {
+            position: relative;
+            margin-top: 10px;
+            left: 50%;
+            transform: translate(-50%, 10%);
+            --_padding: 0.5rem 3rem;
+            --_radius: 0.25rem;
 
-tbody {
-    &[data-test-mode="true"]>tr[data-valid="success"] {
-        & td:last-child {
-            & button.validate {
-                display: none;
-            }
+            color: white;
+            padding: var(--_padding);
+            background-color: rgba(var(--blue));
+            border-radius: var(--_radius);
 
-            & button.test {
-                display: inline-block;
+            &:hover, &:focus {
+                background-color: rgba(var(--blue-dark));
             }
         }
-    }
-}
 
-td:nth-child(3) {
-    text-align: initial;
-    min-width: 10rem;
-}
+        #path-details {
+            display: flex;
+            align-items: center;
+            gap: 1rem;
+        }
 
-td:nth-child(4) {
-    min-width: 2rem;
-}
+        #path-summary {
+            flex: 1;
+            display: flex;
+            padding: 0.5rem 1rem;
+            align-items: center;
+            justify-content: space-between;
+            gap: 1rem;
+            background-color: rgba(var(--white));
+            border: 1px solid rgba(var(--smoky-black), 0.25);
+            border-radius: 0.25rem;
 
-td:last-child {
-    max-width: 9rem;
-}
+            & > li > span:first-of-type {
+                font-weight: 300;
+                text-transform: capitalize;
 
-td:nth-last-child(2) {
-    max-width: 15rem;
-    word-break: break-word;
-    font-size: .85rem;
-}
+                &::after {
+                    content: ": ";
+                }
+            }
 
-td p,
-td button {
-    white-space: nowrap;
-    min-width: fit-content;
-}
+            & > li > span:last-of-type {
+                font-weight: 400;
+                word-break: break-word;
+            }
+        }
 
-button {
-    border: none;
+        /* EXAMPLE STYLES */
 
-    &:active {
-        scale: 0.9;
-    }
-}
+        ol#examples {
+            margin-top: 1rem;
+            display: flex;
+            flex-direction: column;
+            gap: 1rem;
 
-/* TABLE AND DETAILS TRANSITIONS */
+            & > li {
+                background-color: rgba(var(--white));
+                border-radius: 0.25rem;
+                border: 1px solid rgba(var(--smoky-black), 0.25);
+                box-shadow: var(--shadow-md);
+                padding: 0rem 1rem 1rem 1rem;
+            }
+        }
 
-table,
-#details {
-    transition: transform 0.5s ease-in-out;
-    min-width: 100%;
-}
+        div.example {
+            display: flex;
+            align-items: center;
+            justify-content: space-between;
+            padding: 0.5rem;
 
-.group[data-panel="table"] {
-    &>#details {
-        transform: translateX(100%);
-    }
-}
+            & > p {
+                word-break: break-all;
+                margin-right: 4rem;
+                flex: 1;
+            }
 
-.group[data-panel="details"] {
-    &>table {
-        transform: translateX(-100%);
-    }
+            & > .expand-info {
+                display: flex;
+                align-items: center;
+                gap: .25rem;
+            }
+        }
 
-    &>#details {
-        transform: translateX(-100%);
-    }
-}
+        div.details {
+            display: flex;
+            flex-direction: column;
+            gap: 0.5rem;
 
-/* DETAILS STYLES */
+            & pre {
+                white-space: pre-wrap;
+                font-family: var(--mono);
+                background-color: rgba(var(--slate));
+                border-radius: 0.25rem;
+                padding: 0.75rem;
+                display: none;
+            }
+        }
 
-#details {
-    padding: 0.5rem;
-}
+        div.details > div.dropdown {
+            display: flex;
+            align-items: center;
+            justify-content: space-between;
+            padding: 0.5rem;
+            font-family: var(--mono);
+            background-color: rgba(var(--slate));
+            cursor: pointer;
+        }
 
-button#back {
-    --_padding: 0.5rem 1rem;
-    --_radius: 0.25rem;
+        div.details.expanded {
+            & > div.dropdown {
+                margin-bottom: 1rem;
 
-    color: white;
-    padding: var(--_padding);
-    background-color: rgba(var(--blue));
-    border-radius: var(--_radius);
+                & .chevron {
+                    animation: none;
+                    transform: rotate(180deg);
+                }
+            }
 
-    &:hover,
-    &:focus {
-        background-color: rgba(var(--blue-dark));
-    }
-}
-
-button#save-example {
-    position: relative;
-    margin-top: 10px;
-    left: 50%;
-    transform: translate(-50%, 10%);
-    --_padding: 0.5rem 3rem;
-    --_radius: 0.25rem;
-
-    color: white;
-    padding: var(--_padding);
-    background-color: rgba(var(--blue));
-    border-radius: var(--_radius);
-
-    &:hover,
-    &:focus {
-        background-color: rgba(var(--blue-dark));
-    }
-}
-
-#path-details {
-    display: flex;
-    align-items: center;
-    gap: 1rem;
-}
-
-#path-summary {
-    flex: 1;
-    display: flex;
-    padding: 0.5rem 1rem;
-    align-items: center;
-    justify-content: space-between;
-    gap: 1rem;
-    background-color: rgba(var(--white));
-    border: 1px solid rgba(var(--smoky-black), 0.25);
-    border-radius: 0.25rem;
-
-    &>li>span:first-of-type {
-        font-weight: 300;
-        text-transform: capitalize;
-
-        &::after {
-            content: ": ";
+            & pre {
+                display: block;
+            }
         }
-    }
-
-    &>li>span:last-of-type {
-        font-weight: 400;
-        word-break: break-word;
-    }
-}
-
-/* EXAMPLE STYLES */
-
-ol#examples {
-    margin-top: 1rem;
-    display: flex;
-    flex-direction: column;
-    gap: 1rem;
 
-    &>li {
-        background-color: rgba(var(--white));
-        border-radius: 0.25rem;
-        border: 1px solid rgba(var(--smoky-black), 0.25);
-        box-shadow: var(--shadow-md);
-        padding: 0rem 1rem 1rem 1rem;
-    }
-}
-
-div.example {
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
-    padding: 0.5rem;
-
-    &>p {
-        word-break: break-all;
-        margin-right: 4rem;
-        flex: 1;
-    }
+        .pill {
+            --_pill-padding: 0.5rem 1.25rem;
+            --_pill-radius: 0.5rem;
+            --_background-color: rgb(var(--gray));
 
-    &>.expand-info {
-        display: flex;
-        align-items: center;
-        gap: .25rem;
-    }
-}
-
-div.details {
-    display: flex;
-    flex-direction: column;
-    gap: 0.5rem;
-
-    & pre {
-        white-space: pre-wrap;
-        font-family: var(--mono);
-        background-color: rgba(var(--slate));
-        border-radius: 0.25rem;
-        padding: 0.75rem;
-        display: none;
-    }
-}
-
-div.details>div.dropdown {
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
-    padding: 0.5rem;
-    font-family: var(--mono);
-    background-color: rgba(var(--slate));
-    cursor: pointer;
-}
-
-div.details.expanded {
-    &>div.dropdown {
-        margin-bottom: 1rem;
-
-        & .chevron {
-            animation: none;
-            transform: rotate(180deg);
+            padding: var(--_pill-padding);
+            border-radius: var(--_pill-radius);
+            background-color: var(--_background-color);
+            text-transform: capitalize;
+            font-weight: 500;
+            flex-shrink: 0;
+            color: white;
         }
-    }
-
-    & pre {
-        display: block;
-    }
-}
-
-.pill {
-    --_pill-padding: 0.5rem 1.25rem;
-    --_pill-radius: 0.5rem;
-    --_background-color: rgb(var(--gray));
-
-    padding: var(--_pill-padding);
-    border-radius: var(--_pill-radius);
-    background-color: var(--_background-color);
-    text-transform: capitalize;
-    font-weight: 500;
-    flex-shrink: 0;
-    color: white;
-}
-
-.pill.red {
-    --_background-color: rgb(var(--pill-red));
-    color: black;
-}
-
-.pill.green {
-    --_background-color: rgb(var(--pill-green));
-    color: black;
-}
-
-.pill.yellow {
-    --_background-color: rgb(var(--yellow));
-    color: black;
-}
-
-/* ALERT STYLES */
-
-#alert-container {
-    z-index: 1;
-    background-color: rgba(var(--white));
-}
-
-.alert-msg {
-    --_before-content: "⚠";
-    --_text-color: rgba(var(--smoky-black));
-    --_border-color: rgba(var(--smoky-black), 0.1);
-
-    max-width: 75%;
-    border: 1px solid var(--_border-color);
-    background-color: rgba(var(--white));
-    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
-    top: 20px;
-    left: 20px;
-    padding: 1rem;
-    position: fixed;
-    z-index: 10;
-
-    &>p::before {
-        content: var(--_before-content);
-        word-break: break-word;
-        font-weight: bold;
-        padding-right: 0.5rem;
-        color: var(--_text-color);
-    }
-
-    &>pre {
-        word-break: break-word;
-        white-space: pre-wrap;
-    }
-}
-
-.alert-msg.green {
-    --_before-content: "✓";
-    --_text-color: rgba(var(--green));
-    --_border-color: rgba(var(--green));
-}
-
-.alert-msg.red {
-    --_before-content: "✗";
-    --_text-color: rgba(var(--red));
-    --_border-color: rgba(var(--red));
-}
-
-.slide-in {
-    animation: slideIn 0.5s;
-}
-
-.slide-out {
-    animation: slideOut 0.5s;
-}
-
-@keyframes slideIn {
-    from {
-        transform: translateX(-200%);
-    }
-
-    to {
-        transform: translateX(0);
-    }
-}
-
-@keyframes slideOut {
-    from {
-        transform: translateX(0);
-    }
-
-    to {
-        transform: translateX(-200%);
-    }
-}
-
-@keyframes rotation {
-    0% {
-        transform: rotate(0deg);
-    }
-
-    100% {
-        transform: rotate(360deg);
-    }
-}
-
-@keyframes bounce {
-
-    0%,
-    100% {
-        transform: translateY(-25%);
-        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
-    }
-
-    50% {
-        transform: translateY(0);
-        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
-    }
-}
-
-/* UTILITIES */
-
-.hidden {
-    display: none;
-}
-
-</style></head><body><header><div id="main-info"><h1 th:text="${contractFile}"></h1><h2 th:text="${contractFilePath}"></h2></div><div class="btn-grp" th:attr="data-test-mode=${isTestMode}"><button data-selected="0" id="bulk-generate" data-panel="table"></button><button data-selected="0" data-panel="table" id="bulk-validate"></button><button data-selected="0" data-panel="table" id="bulk-test"></button></div></header><main class="group" data-panel="table"><table th:attr="data-generated=${hasExamples},data-hostPort=${hostPort}"><thead><tr><th><label for="select-all"><input type="checkbox" name="select-all" id="select-all"></label></th><th>S. No</th><th colspan="3">Path</th><th>Method</th><th>Response</th><th>Examples</th><th>Action</th></tr></thead><tbody th:attr="data-test-mode=${isTestMode}"><tr th:each="row, iter : ${tableRows}"
-
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      th:attr="data-raw-path=${row.rawPath}, data-key=${row.uniqueKey}, data-schema-based=${row.isSchemaBased},
- data-example=$ {
-    row.example
-}
-
-,
-data-main=$ {
-    row.isMainRow
-}
 
-,
-data-disc=$ {
-    row.isDiscriminatorBased
-}
-
-,
-data-generate=$ {
-    row.isGenerated ? 'success': 'not-generated'
-}
-
-,
-data-test='not-tested',
-data-valid=$ {
-    row.isGenerated ? (row.isValid ? 'success' : row.isPartialFailure ? 'partial' : 'failed'): 'not-validated'
-}
-
-">
-    <td><input type="checkbox" name="path-row" class="path-row"></td><td></td><td th:class="${row.showPath ? '' : 'hidden'}" th:attr="rowspan=${row.pathSpan}, colspan=${row.pathColSpan}"><span>[[$ {
-    row.path
-}
-
-]]</span></td><td th:class="${row.showMethod ? '' : 'hidden'}" th:attr="rowspan=${row.methodSpan}, colspan=${row.methodColSpan}"><p>[[$ {
-    row.method
-    }
-
-    ]]</p></td><td class="response-cell" th:classappend="${row.showStatus ? '' : 'hidden'}" th:attr="rowspan=${row.statusSpan}"><p>[[$ {
-    row.responseStatus
-    }
-
-    ]]</p><span>[[$ {
-    row.contentType
-}
-
-]]</span><br th:if="${row.contentType != null}" /><button class="multigen hidden" aria-label="Generate More"></button></td><td><button th:unless="${row.isGenerated}" class="generate" aria-label="Generate"></button><span th:if="${row.isGenerated}" th:text="${row.exampleName}"></span></td><td><button class="validate hidden" aria-label="Validate"></button><button class="test hidden" aria-label="Test"></button><span th:class="hidden">View Details</span></td></tr></tbody></table><div id="details"><div id="path-details"><button id="back" tabindex="-1"><span>&larr;
-</span><span>Go Back</span></button><ul id="path-summary"></ul></div><ol id="examples"></ol></div></main><div id="alert-container"></div><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="chevron"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 5.25 7.5 7.5 7.5-7.5m-15 6 7.5 7.5 7.5-7.5" /></svg><script th:inline="javascript">const exampleDetails=
-
-/*[[${exampleDetails}]]*/
-    {}
-
-;
-
-const testDetails= {}
-
-;
-
-</script><script src="https://cdnjs.cloudflare.com/ajax/libs/jsonlint/1.6.0/jsonlint.min.js"></script>< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">-->< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">-->< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">-->< !--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/addon/lint/lint.min.css">-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->< !--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>--><script type="module">import {
-    Decoration,
-    EditorState,
-    EditorView,
-    StateEffect,
-    StateField,
-    autocompletion,
-    basicSetup,
-    hoverTooltip,
-    javascript,
-    json,
-    jsonParseLinter,
-    language,
-    lineNumbers,
-    lintGutter,
-    linter,
-    oneDark
-}
-
-from './codemirror-bundle.esm.js'
-
-window.EditorState=EditorState window.EditorView=EditorView window.basicSetup=basicSetup window.javascript=javascript() window.autocompletion=autocompletion() window.oneDark=oneDark window.language=language window.lineNumbers=lineNumbers() window.lintGutter=lintGutter() window.json=json() window.linter=linter(jsonParseLinter()) window.Decoration=Decoration window.StateField=StateField window.StateEffect=StateEffect window.hoverTooltip=hoverTooltip </script><script>var escapedChars= {
-    b: "\b", f:"\f", n:"\n", r:"\r", t:"	", '"':'"', "/":"/", "\\":"\\"
-}
-
-,
-A_CODE="a" .charCodeAt();
-
-const jsonMapParser=function(e, n, r) {
-    var a= {}
-
-    ,
-    t=0,
-    o=0,
-    c=0,
-    i=r&&r.bigint&&"undefined" !=typeof BigInt;
-
-    return {
-        data:function n(r, a) {
-            f(),
-            E(r, "value");
-            var t,
-            o,
-            $,
-            g,
-            S=l();
-
-            switch(S) {
-                case"t": s("rue"), g= !0;
-                break;
-                case"f": s("alse"), g= !1;
-                break;
-                case"n": s("ull"), g=null;
-                break;
-                case'"': g=u();
-                break;
-
-                case"[":g=function e(r) {
-                    f();
-                    var a=[],
-                    t=0;
-                    if("]"==l())return a;
-
-                    for(v(); ; ) {
-                        var o=r+"/"+t;
-                        a.push(n(o)),
-                        f();
-                        var c=l();
-                        if("]"==c)break;
-                        "," !=c&&k(),
-                        f(),
-                        t++
-                    }
-
-                    return a
-                }
-
-                (r);
-                break;
+        .pill.red {
+            --_background-color: rgb(var(--pill-red));
+            color: black;
+        }
 
-                case"{":g=function e(r) {
-                    f();
-
-                    var a= {}
-
-                    ;
-                    if("}"==l())return a;
-
-                    for(v(); ; ) {
-                        var t=d();
-                        '"' !=l()&&k();
-                        var o=u(),
-                        c=r+"/"+escapeJsonPointer(o);
-                        b(c, "key", t),
-                        E(c, "keyEnd"),
-                        f(),
-                        ":" !=l()&&k(),
-                        f(),
-                        a[o]=n(c),
-                        f();
-                        var i=l();
-                        if("}"==i)break;
-                        "," !=i&&k(),
-                        f()
-                    }
+        .pill.green {
+            --_background-color: rgb(var(--pill-green));
+            color: black;
+        }
 
-                    return a
-                }
+        .pill.yellow {
+            --_background-color: rgb(var(--yellow));
+            color: black;
+        }
 
-                (r);
-                break;
-                default:v(),
-                "-0123456789" .indexOf(S)>=0?g=(t="", o= !0, "-"==e[c]&&(t+=l()), t+="0"==e[c]?l():p(), "."==e[c]&&(t+=l()+p(), o= !1), ("e"==e[c]||"E"==e[c])&&(t+=l(), ("+"==e[c]||"-"==e[c])&&(t+=l()), t+=p(), o= !1), $=+t, i&&o&&($>Number.MAX_SAFE_INTEGER||$<Number.MIN_SAFE_INTEGER)?BigInt(t):$):h()
-            }
+        /* ALERT STYLES */
 
-            return E(r, "valueEnd"),
-            f(),
-            a&&c<e.length&&h(),
-            g
+        #alert-container {
+            z-index: 1;
+            background-color: rgba(var(--white));
         }
 
-        ("", !0),
-        pointers:a
-    }
+        .alert-msg {
+            --_before-content: "⚠";
+            --_text-color: rgba(var(--smoky-black));
+            --_border-color: rgba(var(--smoky-black), 0.1);
 
-    ;
+            max-width: 75%;
+            border: 1px solid var(--_border-color);
+            background-color: rgba(var(--white));
+            box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
+            top: 20px;
+            left: 20px;
+            padding: 1rem;
+            position: fixed;
+            z-index: 10;
 
-    function f() {
-        loop: for(; c<e.length; ) {
-            switch(e[c]) {
-                case" ": o++;
-                break;
-                case"	": o+=4;
-                break;
-                case"\r": o=0;
-                break;
-                case"\n": o=0, t++;
-                break;
-                default: break loop
+            & > p::before {
+                content: var(--_before-content);
+                word-break: break-word;
+                font-weight: bold;
+                padding-right: 0.5rem;
+                color: var(--_text-color);
             }
 
-            c++
+            & > pre {
+                word-break: break-word;
+                white-space: pre-wrap;
+            }
         }
-    }
-
-    function u() {
-        for(var e, n=""; '"' !=(e=l()); )"\\"==e?(e=l())in escapedChars?n+=escapedChars[e]: "u"==e?n+=$(
-            ):k():n+=e;
-        return n
-    }
 
-    function s(e) {
-        for(var n=0; n<e.length; n++)l() !==e[n]&&k()
-    }
-
-    function l() {
-        g(
-    );
-    var n=e[c];
-    return c++,
-    o++,
-    n
-}
-
-function v() {
-    c--,
-    o--
-}
-
-function $() {
-    for(var e=4, n=0; e--; ) {
-        n<<=4;
-        var r=l().toLowerCase();
-        r>="a" &&r<="f" ?n+=r.charCodeAt()-A_CODE+10: r>="0" &&r<="9" ?n+=+r:k()
-    }
-
-    return String.fromCharCode(n)
-}
-
-function p() {
-    for(var n=""; e[c]>="0" &&e[c]<="9"; )n+=l();
-    if(n.length)return n;
-    g(),
-    h()
-}
-
-function E(e, n) {
-    b(e, n, d())
-}
-
-function b(e, n, r) {
-    a[e]=a[e]|| {}
-
-    ,
-    a[e][n]=r
-}
-
-function d() {
-    return {
-        line: t, column:o, pos:c
-    }
-}
-
-function h() {
-    throw SyntaxError("Unexpected token " +e[c]+" in JSON at position " +c)
-}
+        .alert-msg.green {
+            --_before-content: "✓";
+            --_text-color: rgba(var(--green));
+            --_border-color: rgba(var(--green));
+        }
 
-function k() {
-    v(),
-    h()
-}
+        .alert-msg.red {
+            --_before-content: "✗";
+            --_text-color: rgba(var(--red));
+            --_border-color: rgba(var(--red));
+        }
 
-function g() {
-    if(c>=e.length)throw SyntaxError("Unexpected end of JSON input")
-}
-}
+        .slide-in {
+            animation: slideIn 0.5s;
+        }
 
-,
-jsonMapStringify=function(e, n, r) {
-    if(validType(e)) {
-        var a,
-        t,
-        o=0,
-        c="object"==typeof r?r.space: r;
-
-        switch(typeof c) {
-            case"number": var i=c>10?10:c<0?0:Math.floor(c);
-            c=i&&k(i, " "),
-            a=i,
-            t=i;
-            break;
-            case"string": c=c.slice(0, 10), a=0, t=0;
-
-            for(var f=0; f<c.length; f++) {
-                var u=c[f];
-
-                switch(u) {
-                    case" ": t++;
-                    break;
-                    case"	": t+=4;
-                    break;
-                    case"\r": t=0;
-                    break;
-                    case"\n": t=0, o++;
-                    break;
-                    default: throw Error("whitespace characters not allowed in JSON")
-                }
+        .slide-out {
+            animation: slideOut 0.5s;
+        }
 
-                a++
+        @keyframes slideIn {
+            from {
+                transform: translateX(-200%);
             }
 
-            break;
-            default:c=void 0
+            to {
+                transform: translateX(0);
+            }
         }
 
-        var s="",
-        l= {}
-
-        ,
-        v=0,
-        $=0,
-        p=0,
-        E=r&&r.es6&&"function"==typeof Map;
-
-        return function e(n, r, a) {
-            switch(h(a, "value"), typeof n) {
-                case"number": case"bigint":case"boolean":b("" +n);
-                break;
-                case"string": b(quoted(n));
-                break;
-                case"object": null===n?b("null"):"function"==typeof n.toJSON?b(quoted(n.toJSON())):Array.isArray(n)?t():E?n.constructor.BYTES_PER_ELEMENT?t():n instanceof Map?i():n instanceof Set?i( !0):o():o()
+        @keyframes slideOut {
+            from {
+                transform: translateX(0);
             }
 
-            function t() {
-                if(n.length) {
-                    b("[");
-
-                    for(var t=r+1, o=0; o<n.length; o++) {
-                        o&&b(","),
-                        d(t);
-                        var c=validType(n[o])?n[o]: null;
-                        e(c, t, a+"/" +o)
-                    }
-
-                    d(r),
-                    b("]")
-                }
-
-                else b("[]")
+            to {
+                transform: translateX(-200%);
             }
+        }
 
-            function o() {
-                var t=Object.keys(n);
-
-                if(t.length) {
-                    b("{");
-
-                    for(var o=r+1, i=0; i<t.length; i++) {
-                        var f=t[i],
-                        u=n[f];
-
-                        if(validType(u)) {
-                            i&&b(",");
-                            var s=a+"/"+escapeJsonPointer(f);
-                            d(o),
-                            h(s, "key"),
-                            b(quoted(f)),
-                            h(s, "keyEnd"),
-                            b(":"),
-                            c&&b(" "),
-                            e(u, o, s)
-                        }
-                    }
-
-                    d(r),
-                    b("}")
-                }
-
-                else b("{}")
-            }
-
-            function i(t) {
-                if(n.size) {
-                    b("{");
-
-                    for(var o=r+1, i= !0, f=n.entries(), u=f.next(); !u.done; ) {
-                        var s=u.value,
-                        l=s[0],
-                        v= ! !t||s[1];
-
-                        if(validType(v)) {
-                            i||b(","),
-                            i= !1;
-                            var $=a+"/"+escapeJsonPointer(l);
-                            d(o),
-                            h($, "key"),
-                            b(quoted(l)),
-                            h($, "keyEnd"),
-                            b(":"),
-                            c&&b(" "),
-                            e(v, o, $)
-                        }
-
-                        u=f.next()
-                    }
-
-                    d(r),
-                    b("}")
-                }
-
-                else b("{}")
+        @keyframes rotation {
+            0% {
+                transform: rotate(0deg);
+            }
+            100% {
+                transform: rotate(360deg);
             }
-
-            h(a, "valueEnd")
         }
 
-        (e, 0, ""),
-        {
-        json: s, pointers:l
-    }
-}
-
-function b(e) {
-    $+=e.length,
-    p+=e.length,
-    s+=e
-}
-
-function d(e) {
-    if(c) {
-        for(s+="\n" +k(e, c), v++, $=0; e--; )o?(v+=o, $=t): $+=t, p+=a;
-        p+=1
-    }
-}
+        @keyframes bounce {
 
-function h(e, n) {
-    l[e]=l[e]|| {}
-
-    ,
-    l[e][n]= {
-        line: v, column:$, pos:p
-    }
-}
-
-function k(e, n) {
-    return Array(e+1).join(n)
-}
-}
-
-;
-var VALID_TYPES=["number",
-"bigint",
-"boolean",
-"string",
-"object"];
-
-function validType(e) {
-    return VALID_TYPES.indexOf(typeof e)>=0
-}
+            0%, 100% {
+                transform: translateY(-25%);
+                animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
+            }
 
-var ESC_QUOTE=/"|\\/g,ESC_B=/[\b]/g,ESC_F=/\f/g,ESC_N=/\n/g,ESC_R=/\r/g,ESC_T=/\t/g;function quoted(e){return'" '+(e=e.replace(ESC_QUOTE,"\\$&").replace(ESC_F,"\\f").replace(ESC_B,"\\b").replace(ESC_N,"\\n").replace(ESC_R,"\\r").replace(ESC_T,"\\t"))+' "'}var ESC_0=/~/g,ESC_1=/\//g;function escapeJsonPointer(e){return e.replace(ESC_0,"~0").replace(ESC_1,"~1")}</script>
-</body><script>const mainElement=document.querySelector("main");
-const table=document.querySelector("table");
-const backBtn=document.querySelector("button#back");
-const pathSummaryUl=document.querySelector("ul#path-summary");
-const examplesOl=document.querySelector("ol#examples");
-const alerts=document.getElementById("alert-container");
-const bulkValidateBtn=document.querySelector("button#bulk-validate");
-const bulkGenerateBtn=document.querySelector("button#bulk-generate");
-const bulkTestBtn=document.querySelector("button#bulk-test");
-const chevronDownIcon=document.querySelector("svg.chevron");
-let setDecorationsEffect;
-let decorationsField;
-let savedEditorResponse=null;
-let originalEditorText=null;
-let scrollYPosition=0;
-let selectedTableRow=null;
-let blockGenValidate=false;
-
-const defaultAttrs= {
-    "data-generate": "not-generated", "data-valid": "not-validated", "data-test": "not-tested", "data-main": "false"
-}
+            50% {
+                transform: translateY(0);
+                animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
+            }
+        }
 
-const dataValidationSuccessValues=["success",
-"partial"] let isSaved=true;
-let errorMetadata=[];
+        /* UTILITIES */
 
-examplesOl.addEventListener("click", (event)=> {
-        const target=event.target;
+        .hidden {
+            display: none;
+        }
 
+    </style>
+</head>
+
+<body>
+
+<header>
+    <div id="main-info">
+        <h1 th:text="${contractFile}"></h1>
+        <h2 th:text="${contractFilePath}"></h2>
+    </div>
+    <div class="btn-grp" th:attr="data-test-mode=${isTestMode}">
+        <button data-selected="0" id="bulk-generate" data-panel="table"></button>
+        <button data-selected="0" data-panel="table" id="bulk-validate"></button>
+        <button data-selected="0" data-panel="table" id="bulk-test"></button>
+    </div>
+</header>
+
+<main class="group" data-panel="table">
+    <table th:attr="data-generated=${hasExamples},data-hostPort=${hostPort}">
+        <thead>
+        <tr>
+            <th>
+                <label for="select-all">
+                    <input type="checkbox" name="select-all" id="select-all">
+                </label>
+            </th>
+            <th>S. No</th>
+            <th colspan="3">Path</th>
+            <th>Method</th>
+            <th>Response</th>
+            <th>Examples</th>
+            <th>Action</th>
+        </tr>
+        </thead>
+        <tbody th:attr="data-test-mode=${isTestMode}">
+        <tr
+                th:each="row, iter : ${tableRows}"
+                th:attr="data-raw-path=${row.rawPath}, data-key=${row.uniqueKey}, data-schema-based=${row.isSchemaBased},
+                        data-example=${row.example}, data-main=${row.isMainRow}, data-disc=${row.isDiscriminatorBased},
+                        data-generate=${row.isGenerated ? 'success' : 'not-generated'}, data-test='not-tested',
+                        data-valid=${row.isGenerated ? (row.isValid ? 'success' : row.isPartialFailure ? 'partial' : 'failed') : 'not-validated'}">
+            <td>
+                <input type="checkbox" name="path-row" class="path-row">
+            </td>
+            <td></td>
+            <td th:class="${row.showPath ? '' : 'hidden'}" th:attr="rowspan=${row.pathSpan}, colspan=${row.pathColSpan}">
+                <span>[[${row.path}]]</span>
+            </td>
+            <td th:class="${row.showMethod ? '' : 'hidden'}" th:attr="rowspan=${row.methodSpan}, colspan=${row.methodColSpan}">
+                <p>[[${row.method}]]</p>
+            </td>
+            <td class="response-cell" th:classappend="${row.showStatus ? '' : 'hidden'}" th:attr="rowspan=${row.statusSpan}">
+                <p>[[${row.responseStatus}]]</p>
+                <span>[[${row.contentType}]]</span>
+                <br th:if="${row.contentType != null}"/>
+                <button class="multigen hidden" aria-label="Generate More"></button>
+            </td>
+            <td>
+                <button th:unless="${row.isGenerated}" class="generate" aria-label="Generate"></button>
+                <span th:if="${row.isGenerated}" th:text="${row.exampleName}"></span>
+            </td>
+            <td>
+                <button class="validate hidden" aria-label="Validate"></button>
+                <button class="test hidden" aria-label="Test"></button>
+                <span th:class="hidden">View Details</span>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+    <div id="details">
+        <div id="path-details">
+            <button id="back" tabindex="-1">
+                <span>&larr;</span>
+                <span>Go Back</span>
+            </button>
+            <ul id="path-summary"></ul>
+        </div>
+        <ol id="examples"></ol>
+    </div>
+</main>
+
+<div id="alert-container"></div>
+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="chevron">
+    <path stroke-linecap="round" stroke-linejoin="round" d="m4.5 5.25 7.5 7.5 7.5-7.5m-15 6 7.5 7.5 7.5-7.5" />
+</svg>
+
+<script th:inline="javascript">
+    const exampleDetails = /*[[${exampleDetails}]]*/ {};
+    const testDetails = {};
+</script>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/jsonlint/1.6.0/jsonlint.min.js"></script>
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">-->
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">-->
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">-->
+<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/addon/lint/lint.min.css">-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->
+<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>-->
+<script type="module">
+    import { Decoration,EditorState, EditorView, StateEffect, StateField,autocompletion, basicSetup, hoverTooltip,javascript, json,jsonParseLinter, language, lineNumbers, lintGutter, linter,oneDark } from './codemirror-bundle.esm.js'
+        window.EditorState = EditorState
+        window.EditorView = EditorView
+        window.basicSetup = basicSetup
+        window.javascript = javascript()
+        window.autocompletion = autocompletion()
+        window.oneDark = oneDark
+        window.language = language
+        window.lineNumbers = lineNumbers()
+        window.lintGutter = lintGutter()
+        window.json = json()
+        window.linter = linter(jsonParseLinter())
+        window.Decoration = Decoration
+        window.StateField = StateField
+        window.StateEffect = StateEffect
+        window.hoverTooltip = hoverTooltip
+
+</script>
+<script>var escapedChars={b:"\b",f:"\f",n:"\n",r:"\r",t:"	",'"':'"',"/":"/","\\":"\\"},A_CODE="a".charCodeAt();const jsonMapParser=function(e,n,r){var a={},t=0,o=0,c=0,i=r&&r.bigint&&"undefined"!=typeof BigInt;return{data:function n(r,a){f(),E(r,"value");var t,o,$,g,S=l();switch(S){case"t":s("rue"),g=!0;break;case"f":s("alse"),g=!1;break;case"n":s("ull"),g=null;break;case'"':g=u();break;case"[":g=function e(r){f();var a=[],t=0;if("]"==l())return a;for(v();;){var o=r+"/"+t;a.push(n(o)),f();var c=l();if("]"==c)break;","!=c&&k(),f(),t++}return a}(r);break;case"{":g=function e(r){f();var a={};if("}"==l())return a;for(v();;){var t=d();'"'!=l()&&k();var o=u(),c=r+"/"+escapeJsonPointer(o);b(c,"key",t),E(c,"keyEnd"),f(),":"!=l()&&k(),f(),a[o]=n(c),f();var i=l();if("}"==i)break;","!=i&&k(),f()}return a}(r);break;default:v(),"-0123456789".indexOf(S)>=0?g=(t="",o=!0,"-"==e[c]&&(t+=l()),t+="0"==e[c]?l():p(),"."==e[c]&&(t+=l()+p(),o=!1),("e"==e[c]||"E"==e[c])&&(t+=l(),("+"==e[c]||"-"==e[c])&&(t+=l()),t+=p(),o=!1),$=+t,i&&o&&($>Number.MAX_SAFE_INTEGER||$<Number.MIN_SAFE_INTEGER)?BigInt(t):$):h()}return E(r,"valueEnd"),f(),a&&c<e.length&&h(),g}("",!0),pointers:a};function f(){loop:for(;c<e.length;){switch(e[c]){case" ":o++;break;case"	":o+=4;break;case"\r":o=0;break;case"\n":o=0,t++;break;default:break loop}c++}}function u(){for(var e,n="";'"'!=(e=l());)"\\"==e?(e=l())in escapedChars?n+=escapedChars[e]:"u"==e?n+=$():k():n+=e;return n}function s(e){for(var n=0;n<e.length;n++)l()!==e[n]&&k()}function l(){g();var n=e[c];return c++,o++,n}function v(){c--,o--}function $(){for(var e=4,n=0;e--;){n<<=4;var r=l().toLowerCase();r>="a"&&r<="f"?n+=r.charCodeAt()-A_CODE+10:r>="0"&&r<="9"?n+=+r:k()}return String.fromCharCode(n)}function p(){for(var n="";e[c]>="0"&&e[c]<="9";)n+=l();if(n.length)return n;g(),h()}function E(e,n){b(e,n,d())}function b(e,n,r){a[e]=a[e]||{},a[e][n]=r}function d(){return{line:t,column:o,pos:c}}function h(){throw SyntaxError("Unexpected token "+e[c]+" in JSON at position "+c)}function k(){v(),h()}function g(){if(c>=e.length)throw SyntaxError("Unexpected end of JSON input")}},jsonMapStringify=function(e,n,r){if(validType(e)){var a,t,o=0,c="object"==typeof r?r.space:r;switch(typeof c){case"number":var i=c>10?10:c<0?0:Math.floor(c);c=i&&k(i," "),a=i,t=i;break;case"string":c=c.slice(0,10),a=0,t=0;for(var f=0;f<c.length;f++){var u=c[f];switch(u){case" ":t++;break;case"	":t+=4;break;case"\r":t=0;break;case"\n":t=0,o++;break;default:throw Error("whitespace characters not allowed in JSON")}a++}break;default:c=void 0}var s="",l={},v=0,$=0,p=0,E=r&&r.es6&&"function"==typeof Map;return function e(n,r,a){switch(h(a,"value"),typeof n){case"number":case"bigint":case"boolean":b(""+n);break;case"string":b(quoted(n));break;case"object":null===n?b("null"):"function"==typeof n.toJSON?b(quoted(n.toJSON())):Array.isArray(n)?t():E?n.constructor.BYTES_PER_ELEMENT?t():n instanceof Map?i():n instanceof Set?i(!0):o():o()}function t(){if(n.length){b("[");for(var t=r+1,o=0;o<n.length;o++){o&&b(","),d(t);var c=validType(n[o])?n[o]:null;e(c,t,a+"/"+o)}d(r),b("]")}else b("[]")}function o(){var t=Object.keys(n);if(t.length){b("{");for(var o=r+1,i=0;i<t.length;i++){var f=t[i],u=n[f];if(validType(u)){i&&b(",");var s=a+"/"+escapeJsonPointer(f);d(o),h(s,"key"),b(quoted(f)),h(s,"keyEnd"),b(":"),c&&b(" "),e(u,o,s)}}d(r),b("}")}else b("{}")}function i(t){if(n.size){b("{");for(var o=r+1,i=!0,f=n.entries(),u=f.next();!u.done;){var s=u.value,l=s[0],v=!!t||s[1];if(validType(v)){i||b(","),i=!1;var $=a+"/"+escapeJsonPointer(l);d(o),h($,"key"),b(quoted(l)),h($,"keyEnd"),b(":"),c&&b(" "),e(v,o,$)}u=f.next()}d(r),b("}")}else b("{}")}h(a,"valueEnd")}(e,0,""),{json:s,pointers:l}}function b(e){$+=e.length,p+=e.length,s+=e}function d(e){if(c){for(s+="\n"+k(e,c),v++,$=0;e--;)o?(v+=o,$=t):$+=t,p+=a;p+=1}}function h(e,n){l[e]=l[e]||{},l[e][n]={line:v,column:$,pos:p}}function k(e,n){return Array(e+1).join(n)}};var VALID_TYPES=["number","bigint","boolean","string","object"];function validType(e){return VALID_TYPES.indexOf(typeof e)>=0}var ESC_QUOTE=/"|\\/g,ESC_B=/[\b]/g,ESC_F=/\f/g,ESC_N=/\n/g,ESC_R=/\r/g,ESC_T=/\t/g;function quoted(e){return'"'+(e=e.replace(ESC_QUOTE,"\\$&").replace(ESC_F,"\\f").replace(ESC_B,"\\b").replace(ESC_N,"\\n").replace(ESC_R,"\\r").replace(ESC_T,"\\t"))+'"'}var ESC_0=/~/g,ESC_1=/\//g;function escapeJsonPointer(e){return e.replace(ESC_0,"~0").replace(ESC_1,"~1")}</script>
+</body>
+<script>
+    const mainElement = document.querySelector("main");
+    const table = document.querySelector("table");
+    const backBtn = document.querySelector("button#back");
+    const pathSummaryUl = document.querySelector("ul#path-summary");
+    const examplesOl = document.querySelector("ol#examples");
+    const alerts = document.getElementById("alert-container");
+    const bulkValidateBtn = document.querySelector("button#bulk-validate");
+    const bulkGenerateBtn = document.querySelector("button#bulk-generate");
+    const bulkTestBtn = document.querySelector("button#bulk-test");
+    const chevronDownIcon = document.querySelector("svg.chevron");
+    let setDecorationsEffect;
+    let decorationsField;
+    let savedEditorResponse = null;
+    let originalEditorText = null;
+    let scrollYPosition = 0;
+    let selectedTableRow = null;
+    let blockGenValidate = false;
+    const defaultAttrs = { "data-generate": "not-generated", "data-valid": "not-validated", "data-test": "not-tested", "data-main": "false" }
+    const dataValidationSuccessValues = ["success", "partial"]
+    let isSaved = true;
+    let errorMetadata = [];
+
+    examplesOl.addEventListener("click", (event) => {
+        const target = event.target;
         if (target.matches(".dropdown, .dropdown *")) {
             target.closest("div.details")?.classList.toggle("expanded");
             event.stopPropagation();
         }
+    })
 
-    }) backBtn.addEventListener("click", ()=> {
-        if ( !isSaved) {
-            const modalContainer=createModal({
-                onDiscard: ()=> {
+    backBtn.addEventListener("click", () => {
+        if (!isSaved) {
+            const modalContainer = createModal({
+                onDiscard: () => {
                     examplesOl.replaceChildren();
                     mainElement.setAttribute("data-panel", "table");
                     bulkValidateBtn.setAttribute("data-panel", "table");
@@ -1636,46 +1252,42 @@
                     bulkTestBtn.setAttribute("data-panel", "table");
                     window.scrollTo(0, scrollYPosition);
                     console.log("Changes discarded!");
-                    isSaved=true;
-                }
-
-                ,
+                    isSaved = true;
+                },
 
             });
-        document.body.appendChild(modalContainer);
-        return;
-    }
+            document.body.appendChild(modalContainer);
+            return;
+        }
 
-    examplesOl.replaceChildren();
-    mainElement.setAttribute("data-panel", "table");
-    bulkValidateBtn.setAttribute("data-panel", "table");
-    bulkGenerateBtn.setAttribute("data-panel", "table");
-    bulkTestBtn.setAttribute("data-panel", "table");
-    window.scrollTo(0, scrollYPosition);
-});
+        examplesOl.replaceChildren();
+        mainElement.setAttribute("data-panel", "table");
+        bulkValidateBtn.setAttribute("data-panel", "table");
+        bulkGenerateBtn.setAttribute("data-panel", "table");
+        bulkTestBtn.setAttribute("data-panel", "table");
+        window.scrollTo(0, scrollYPosition);
+    });
 
-table.addEventListener("click", async (event)=> {
-        const target=event.target;
-        const nearestTableRow=target.closest("tr");
+    table.addEventListener("click", async (event) => {
+        const target = event.target;
+        const nearestTableRow = target.closest("tr");
 
         if (nearestTableRow) {
-            selectedTableRow=nearestTableRow;
-            const rowValues=extractRowValues(nearestTableRow);
+            selectedTableRow = nearestTableRow;
+            const rowValues = extractRowValues(nearestTableRow);
             event.stopPropagation();
 
             switch (target.tagName) {
                 case "BUTTON": {
                     if (blockGenValidate) break;
-
                     switch (target.getAttribute("aria-label")) {
-                        case "Generate": case "Generate More": {
+                        case "Generate":
+                        case "Generate More": {
                             return await generateRowExamples(nearestTableRow, rowValues);
                         }
-
                         case "Validate": {
                             return await validateRowExamples(nearestTableRow);
                         }
-
                         default: {
                             return await testRowExample(nearestTableRow);
                         }
@@ -1684,11 +1296,7 @@
 
                 case "INPUT": {
                     if (target.matches("th > label > input")) {
-                        const {
-                            validatedCount, generatedCount, discAndMainCount, totalCount
-                        }
-
-                        =getRowsCount();
+                        const { validatedCount, generatedCount, discAndMainCount, totalCount } = getRowsCount();
                         toggleAllSelects(target.checked);
 
                         if (table.hasAttribute("data-generated")) {
@@ -1703,7 +1311,7 @@
                 }
 
                 default: {
-                    if ( !target.matches("tr > *:first-child, tr > *:first-child *") && nearestTableRow.getAttribute("data-generate")==="success") {
+                    if (!target.matches("tr > *:first-child, tr > *:first-child *") && nearestTableRow.getAttribute("data-generate") === "success") {
                         return await goToDetails(nearestTableRow, rowValues);
                     }
                 }
@@ -1711,39 +1319,35 @@
         }
     });
 
-function handleSingleInput(nearestTableRow, checked) {
-    const getPreSelectCount=(btn, attr)=>Number.parseInt(btn.getAttribute(attr) || 0);
-
-    const valPreSelectCount=getPreSelectCount(bulkValidateBtn, "data-selected");
-    const genPreSelectCount=getPreSelectCount(bulkGenerateBtn, "data-selected");
-    const testPreSelectCount=getPreSelectCount(bulkTestBtn, "data-selected");
+    function handleSingleInput(nearestTableRow, checked) {
+        const getPreSelectCount = (btn, attr) => Number.parseInt(btn.getAttribute(attr) || 0);
 
-    const hasBeenGenerated=nearestTableRow.getAttribute("data-generate")==="success";
-    const hasBeenValidated=dataValidationSuccessValues.includes(nearestTableRow.getAttribute("data-valid"));
-    const isDiscriminatorRow=nearestTableRow.getAttribute("data-disc")==="true";
-    const isMainRow=nearestTableRow.getAttribute("data-main")==="true";
+        const valPreSelectCount = getPreSelectCount(bulkValidateBtn, "data-selected");
+        const genPreSelectCount = getPreSelectCount(bulkGenerateBtn, "data-selected");
+        const testPreSelectCount = getPreSelectCount(bulkTestBtn, "data-selected");
 
-    const countAdjustment=checked ? 1: -1;
+        const hasBeenGenerated = nearestTableRow.getAttribute("data-generate") === "success";
+        const hasBeenValidated = dataValidationSuccessValues.includes(nearestTableRow.getAttribute("data-valid"));
+        const isDiscriminatorRow = nearestTableRow.getAttribute("data-disc") === "true";
+        const isMainRow = nearestTableRow.getAttribute("data-main") === "true";
 
-    if (hasBeenGenerated) {
-        bulkValidateBtn.setAttribute("data-selected", valPreSelectCount + countAdjustment);
+        const countAdjustment = checked ? 1 : -1;
 
-        if (isDiscriminatorRow && isMainRow) {
+        if (hasBeenGenerated) {
+            bulkValidateBtn.setAttribute("data-selected", valPreSelectCount + countAdjustment);
+            if (isDiscriminatorRow && isMainRow) {
+                bulkGenerateBtn.setAttribute("data-selected", genPreSelectCount + countAdjustment);
+            }
+            if (hasBeenValidated) {
+                bulkTestBtn.setAttribute("data-selected", testPreSelectCount + countAdjustment);
+            }
+        } else if (isMainRow) {
             bulkGenerateBtn.setAttribute("data-selected", genPreSelectCount + countAdjustment);
         }
-
-        if (hasBeenValidated) {
-            bulkTestBtn.setAttribute("data-selected", testPreSelectCount + countAdjustment);
-        }
-    }
-
-    else if (isMainRow) {
-        bulkGenerateBtn.setAttribute("data-selected", genPreSelectCount + countAdjustment);
     }
-}
 
-bulkValidateBtn.addEventListener("click", async ()=> {
-        blockGenValidate=true;
+    bulkValidateBtn.addEventListener("click", async () => {
+        blockGenValidate = true;
         bulkValidateBtn.setAttribute("data-valid", "processing");
 
         switch (bulkValidateBtn.getAttribute("data-panel")) {
@@ -1754,9 +1358,9 @@
 
             case "details": {
                 await validateRowExamples(selectedTableRow);
-                const originalYScroll=scrollYPosition;
+                const originalYScroll = scrollYPosition;
                 await goToDetails(selectedTableRow, extractRowValues(selectedTableRow));
-                scrollYPosition=originalYScroll;
+                scrollYPosition = originalYScroll;
                 break;
             }
         }
@@ -1765,80 +1369,53 @@
         return cleanUpSelections();
     });
 
-bulkGenerateBtn.addEventListener("click", async ()=> {
-        blockGenValidate=true;
+    bulkGenerateBtn.addEventListener("click", async () => {
+        blockGenValidate = true;
         bulkGenerateBtn.setAttribute("data-generate", "processing");
 
-        let failedCount=0; createdCount=0; existedCount=0;
-        const selectedRows=Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox)=> checkbox.closest("tr"));
-        const rowsWithNoExamplesOrDiscriminator=selectedRows.filter(row=> row.getAttribute("data-main")==="true" && (row.getAttribute("data-generate")===defaultAttrs["data-generate"] || row.getAttribute("data-disc")==="true"));
+        let failedCount = 0; createdCount = 0; existedCount = 0;
+        const selectedRows = Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox) => checkbox.closest("tr"));
+        const rowsWithNoExamplesOrDiscriminator = selectedRows.filter(row =>
+            row.getAttribute("data-main") === "true" && (row.getAttribute("data-generate") === defaultAttrs["data-generate"] || row.getAttribute("data-disc") === "true")
+        );
 
         for (const row of rowsWithNoExamplesOrDiscriminator) {
-            const rowValues=extractRowValues(row);
-
-            const {
-                success, created, existed, count
-            }
+            const rowValues = extractRowValues(row);
+            const { success, created, existed, count } = await generateRowExamples(row, rowValues, true);
 
-            =await generateRowExamples(row, rowValues, true);
-
-            if ( !success) failedCount +=count;
-            createdCount +=created;
-            existedCount +=existed;
+            if (!success) failedCount += count;
+            createdCount += created;
+            existedCount += existed;
         }
 
         bulkGenerateBtn.removeAttribute("data-generate");
-
-        const message=`$ {
-            createdCount
-        }
-
-        Example(s) Created\n$ {
-            existedCount
-        }
-
-        Example(s) Existed\n$ {
-            failedCount
-        }
-
-        Example(s) Failed` const title=`Generation Complete ($ {
-                createdCount + existedCount + failedCount
-            }) Example(s)`;
-        createAlert(title, message, failedCount !==0);
+        const message = `${createdCount} Example(s) Created\n${existedCount} Example(s) Existed\n${failedCount} Example(s) Failed`
+        const title = `Generation Complete (${createdCount + existedCount + failedCount}) Example(s)`;
+        createAlert(title, message, failedCount !== 0);
         return cleanUpSelections();
     });
 
-async function validateAllSelected() {
-    bulkValidateBtn.setAttribute("data-valid", "processing");
-
-    let errorsCount=0;
-    const selectedRows=Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox)=> checkbox.closest("tr"));
-    const rowsWithExamples=selectedRows.filter(row=> row.getAttribute("data-generate")==="success");
-
-    for (const row of rowsWithExamples) {
-        const success=await validateRowExamples(row, true);
-
-        if ( !success) {
-            errorsCount++;
-        }
-    }
-
-    bulkValidateBtn.removeAttribute("data-generate");
+    async function validateAllSelected() {
+        bulkValidateBtn.setAttribute("data-valid", "processing");
 
-    createAlert("Validations Complete", `$ {
-            errorsCount
-        }
+        let errorsCount = 0;
+        const selectedRows = Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox) => checkbox.closest("tr"));
+        const rowsWithExamples = selectedRows.filter(row => row.getAttribute("data-generate") === "success");
 
-        out of $ {
-            rowsWithExamples.length
+        for (const row of rowsWithExamples) {
+            const success = await validateRowExamples(row, true);
+            if (!success) {
+                errorsCount++;
+            }
         }
 
-        are invalid`, errorsCount !==0);
-    return cleanUpSelections();
-}
+        bulkValidateBtn.removeAttribute("data-generate");
+        createAlert("Validations Complete", `${errorsCount} out of ${rowsWithExamples.length} are invalid`, errorsCount !== 0);
+        return cleanUpSelections();
+    }
 
-bulkTestBtn.addEventListener("click", async ()=> {
-        blockGenValidate=true;
+    bulkTestBtn.addEventListener("click", async () => {
+        blockGenValidate = true;
         bulkTestBtn.setAttribute("data-test", "processing");
 
         switch (bulkValidateBtn.getAttribute("data-panel")) {
@@ -1849,8 +1426,9 @@
 
             case "details": {
                 await testRowExample(selectedTableRow);
-                const originalYScroll=scrollYPosition await goToDetails(selectedTableRow, extractRowValues(selectedTableRow));
-                scrollYPosition=originalYScroll;
+                const originalYScroll = scrollYPosition
+                await goToDetails(selectedTableRow, extractRowValues(selectedTableRow));
+                scrollYPosition = originalYScroll;
                 break;
             }
         }
@@ -1859,566 +1437,388 @@
         return cleanUpSelections();
     });
 
-async function testAllSelected() {
-    const selectedRows=Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox)=> checkbox.closest("tr"));
-    const rowsWithValidations=selectedRows.filter(row=> dataValidationSuccessValues.includes(row.getAttribute("data-valid")));
-
-    for (const row of rowsWithValidations) {
-        row.setAttribute("data-test", "processing");
-    }
-
-    let failureCount=0;
-
-    for (const row of rowsWithValidations) {
-        const result=await testRowExample(row, true);
-
-        if ( !result) {
-            failureCount++;
-        }
-    }
-
-    blockGenValidate=false;
-
-    createAlert("Tests Complete", `$ {
-            failureCount
-        }
-
-        out of $ {
-            rowsWithValidations.length
-        }
-
-        have failed`, failureCount !==0);
-}
-
-function extractRowValues(tableRow) {
-    const [method,
-    responseAndContentType]=[...tableRow.children].slice(3, 5).map((child)=> child.textContent.trim());
-    const [responseStatusCode,
-    contentType]=responseAndContentType.split("\n").map((str)=> str.trim());
-    const isSchemaBased=tableRow.getAttribute("data-schema-based")==="true"
-
-    return {
-        path: tableRow.getAttribute("data-raw-path"), method, responseStatusCode, contentType, isSchemaBased
-    }
-
-    ;
-}
-
-function getRowsCount() {
-    const tableRows=table.querySelectorAll("tbody > tr");
-
-    return Array.from(tableRows).reduce((acc, row)=> {
-            const isRowGenerated=row.getAttribute("data-generate")==="success";
-            const isRowValidated=dataValidationSuccessValues.includes(row.getAttribute("data-valid"));
-            const isRowDiscAndMain=row.getAttribute("data-main")==="true" && row.getAttribute("data-disc")==="true";
-
-            acc.validatedCount +=isRowValidated ? 1 : 0;
-            acc.generatedCount +=isRowGenerated ? 1 : 0;
-            acc.discAndMainCount +=isRowGenerated && isRowDiscAndMain ? 1 : 0;
-            acc.totalCount +=1;
-            return acc;
-
-        }
-
-        , {
-        validatedCount: 0, generatedCount: 0, discAndMainCount: 0, totalCount: 0
-    });
-}
-
-function toggleAllSelects(isSelected=true) {
-    const checkboxes=table.querySelectorAll("input[type=checkbox]");
-
-    for (const checkbox of checkboxes) {
-        checkbox.checked=isSelected;
-    }
-}
-
-async function generateRowExamples(tableRow, rowValues, bulkMode=false) {
-    const originalState=tableRow.getAttribute("data-generate");
-
-    tableRow.setAttribute("data-generate", "processing");
-
-    const {
-        examples,
-        error
-    }
-
-    =await generateExample(rowValues, bulkMode);
-    tableRow.setAttribute("data-generate", originalState);
-
-    if (error) {
-        if ( !bulkMode) createAlert("Example Generation Failed", error, true);
-        tableRow.setAttribute("data-generate", originalState===defaultAttrs["data-generate"] ? "failed" : originalState);
+    async function testAllSelected() {
+        const selectedRows = Array.from(table.querySelectorAll("td > input[type=checkbox]:checked")).map((checkbox) => checkbox.closest("tr"));
+        const rowsWithValidations = selectedRows.filter(row => dataValidationSuccessValues.includes(row.getAttribute("data-valid")));
 
-        return {
-            success: false, created: 0, existed: 0, count: 0
+        for (const row of rowsWithValidations) {
+            row.setAttribute("data-test", "processing");
         }
 
-        ;
-    }
-
-    const {
-        createdCount,
-        existedCount,
-        totalCount
-    }
-
-    =getExamplesCount(examples);
-    const newExamples=getOnlyNewExamples(tableRow, examples);
-    const thisRowIsGenerated=tableRow.getAttribute("data-generate")==="success";
-    const newRows=newExamples.map((ex, idx)=> updateRowWithExample(tableRow, thisRowIsGenerated || idx > 0, ex));
-
-    const rowsToBeAdded=newRows.filter((row, idx)=> idx > 0 || thisRowIsGenerated);
-    const exampleFragment=document.createDocumentFragment();
-
-    rowsToBeAdded.forEach(row=> exampleFragment.appendChild(row)) requestAnimationFrame(()=> {
-            rowsToBeAdded.forEach(row=> tableRow.parentElement.insertBefore(row, tableRow.nextSibling));
-            updateSpans(tableRow, rowValues, rowsToBeAdded.length);
-
-        }) if ( !bulkMode) {
-
-        const alertTitle=`Example(s) Generated,
-        $ {
-            existedCount
-        }
-
-        already existed`;
+        let failureCount = 0;
+        for (const row of rowsWithValidations) {
+            const result = await testRowExample(row, true);
 
-        const alertMessage=`Example name(s): $ {
-            newExamples.map(example=> parseFileName(example.exampleFilePath)).join("\n")
+            if (!result) {
+                failureCount++;
+            }
         }
 
-        `;
-        createAlert(alertTitle, alertMessage, false)
-    }
-
-    ;
-
-    return {
-        success: true, created: createdCount, existed: existedCount, count: totalCount
+        blockGenValidate = false;
+        createAlert("Tests Complete", `${failureCount} out of ${rowsWithValidations.length} have failed`, failureCount !== 0);
     }
 
-    ;
-}
-
-async function validateRowExamples(tableRow, bulkMode=false) {
-    tableRow.setAttribute("data-valid", "processing");
-    const exampleData=getExampleData(tableRow);
-
-    if ( !isSaved) {
-        const exampleSaved=await saveExample(exampleData);
-
-        if ( !exampleSaved) {
-            return false;
-        }
-    }
+    function extractRowValues(tableRow) {
+        const [method, responseAndContentType] = [...tableRow.children].slice(3, 5).map((child) => child.textContent.trim());
+        const [responseStatusCode, contentType] = responseAndContentType.split("\n").map((str) => str.trim());
+        const isSchemaBased = tableRow.getAttribute("data-schema-based") === "true"
 
-    const {
-        exampleAbsPath,
-        errorMessage,
-        errorList,
-        isPartialFailure
+        return { path: tableRow.getAttribute("data-raw-path"), method, responseStatusCode, contentType, isSchemaBased };
     }
 
-    =await validateExample(exampleData);
+    function getRowsCount() {
+        const tableRows = table.querySelectorAll("tbody > tr");
+        return Array.from(tableRows).reduce((acc, row) => {
+            const isRowGenerated = row.getAttribute("data-generate") === "success";
+            const isRowValidated = dataValidationSuccessValues.includes(row.getAttribute("data-valid"));
+            const isRowDiscAndMain = row.getAttribute("data-main") === "true" && row.getAttribute("data-disc") === "true";
 
-    if (errorMessage && !exampleAbsPath) {
-        if ( !bulkMode) createAlert("Validation Failed", `Error: $ {
-                error ?? "Unknown Error"
-            }
+            acc.validatedCount += isRowValidated ? 1 : 0;
+            acc.generatedCount += isRowGenerated ? 1 : 0;
+            acc.discAndMainCount += isRowGenerated && isRowDiscAndMain ? 1 : 0;
+            acc.totalCount += 1;
+            return acc;
 
-            `, true);
-        tableRow.setAttribute("data-valid", "failed");
-        return false;
+        }, { validatedCount: 0, generatedCount: 0, discAndMainCount: 0, totalCount: 0 });
     }
 
-    tableRow.setAttribute("data-valid", errorMessage ? isPartialFailure ? "partial" : "failed" : "success");
-
-    storeExampleValidationData(tableRow, {
-        errorMessage, errorList
-    });
-storeExampleTestData(tableRow, null);
-tableRow.setAttribute("data-test", defaultAttrs["data-test"]);
-
-if (errorMessage && !isPartialFailure) {
-    if ( !bulkMode) createAlert("Invalid Example", `Example name: $ {
-            parseFileName(exampleAbsPath)
+    function toggleAllSelects(isSelected = true) {
+        const checkboxes = table.querySelectorAll("input[type=checkbox]");
+        for (const checkbox of checkboxes) {
+            checkbox.checked = isSelected;
         }
-
-        `, true);
-    return false;
-}
-
-if ( !bulkMode) createAlert("Valid Example", `Example name: $ {
-        parseFileName(exampleAbsPath)
     }
 
-    `, false);
-return true;
-}
-
-async function testRowExample(tableRow, bulkMode=false) {
-    tableRow.setAttribute("data-test", "processing");
-
-    const isExampleValid=await validateRowExamples(tableRow, bulkMode);
+    async function generateRowExamples(tableRow, rowValues, bulkMode = false) {
+        const originalState = tableRow.getAttribute("data-generate");
 
-    if ( !isExampleValid) {
-        createAlert("Invalid Example or Network Failure", `Example name: $ {
-                parseFileName(getExampleData(tableRow))
-            }
+        tableRow.setAttribute("data-generate", "processing");
+        const { examples, error } = await generateExample(rowValues, bulkMode);
+        tableRow.setAttribute("data-generate", originalState);
 
-            `, true);
-        return false;
-    }
-
-    const exampleData=getExampleData(tableRow);
-
-    const {
-        data,
-        error
-    }
-
-    =await testExample({
-        exampleFile: exampleData
-    });
-
-if (error && !data) {
-    if ( !bulkMode) createAlert("Testing Failed", `Error: $ {
-            error ?? "Unknown Error"
+        if (error) {
+            if (!bulkMode) createAlert("Example Generation Failed", error, true);
+            tableRow.setAttribute("data-generate", originalState === defaultAttrs["data-generate"] ? "failed" : originalState);
+            return { success: false, created: 0, existed: 0, count: 0 };
         }
 
-        `, true);
-    tableRow.setAttribute("data-test", "failed");
-    return false;
-}
+        const { createdCount, existedCount, totalCount } = getExamplesCount(examples);
+        const newExamples = getOnlyNewExamples(tableRow, examples);
+        const thisRowIsGenerated = tableRow.getAttribute("data-generate") === "success";
+        const newRows = newExamples.map((ex, idx) => updateRowWithExample(tableRow, thisRowIsGenerated || idx > 0, ex));
 
-tableRow.setAttribute("data-test", (error || data?.result !=="Success") ? "failed" : "success");
-storeExampleTestData(tableRow, data);
+        const rowsToBeAdded = newRows.filter((row, idx) => idx > 0 || thisRowIsGenerated);
+        const exampleFragment = document.createDocumentFragment();
+        rowsToBeAdded.forEach(row => exampleFragment.appendChild(row))
 
-if (error || data?.result !=="Success") {
-    if ( !bulkMode) createAlert(`Test $ {
-            data ? data.result : "Failed"
-        }
-
-        `, `Example name: $ {
-            parseFileName(exampleData)
-        }
-
-        `, true);
-    return false;
-}
-
-if ( !bulkMode) createAlert("Test Passed", `Example name: $ {
-        parseFileName(exampleData)
-    }
-
-    `, false);
-return true;
-}
-
-// ACTION HELPERS
-function getExamplesCount(examples) {
-    return examples.reduce((counts, example)=> {
-            if (example.created) {
-                counts.createdCount++;
-            }
-
-            else if (example.existed) {
-                counts.existedCount++;
-            }
-
-            return counts;
-        }
-
-        , {
-        createdCount: 0, existedCount: 0, totalCount: examples.length
-    });
-}
-
-function getOnlyNewExamples(tableRow, examples) {
-    const existingExamples=new Set(getAllSameGroupExamples(tableRow));
-    return examples.filter(example=> !existingExamples.has(example.exampleFilePath));
-}
+        requestAnimationFrame(() => {
+            rowsToBeAdded.forEach(row => tableRow.parentElement.insertBefore(row, tableRow.nextSibling));
+            updateSpans(tableRow, rowValues, rowsToBeAdded.length);
+        })
 
-function updateRowWithExample(tableRow, shouldClone, example) {
-    const newRow=shouldClone ? tableRow.cloneNode(true): tableRow;
-    storeExampleData(newRow, example);
-    insertExampleIntoRow(example, newRow);
+        if (!bulkMode) {
+            const alertTitle = `Example(s) Generated, ${existedCount} already existed`;
+            const alertMessage = `Example name(s): ${newExamples.map(example => parseFileName(example.exampleFilePath)).join("\n")}`;
+            createAlert(alertTitle, alertMessage, false)
+        };
 
-    if (shouldClone) {
-        Object.entries(defaultAttrs).forEach(([attr, value])=> newRow.setAttribute(attr, value));
-        Array.from(newRow.children).slice(2, -2).forEach(cell=> cell.classList.add("hidden"));
+        return { success: true, created: createdCount, existed: existedCount, count: totalCount };
     }
 
-    newRow.setAttribute("data-generate", "success");
-    enableValidateBtn(newRow);
-    return newRow;
-}
-
-function insertExampleIntoRow(example, tableRow) {
-    const exampleSpan=document.createElement("span");
-    exampleSpan.textContent=parseFileName(example.exampleFilePath);
-    const generateColumn=tableRow.querySelector("td:nth-last-child(2)") generateColumn.replaceChildren(exampleSpan);
-}
-
-function updateSpans(tableRow, rowValues, increment) {
-    const origMainValues=Object.values(rowValues) let curRow=tableRow;
+    async function validateRowExamples(tableRow, bulkMode = false) {
+        tableRow.setAttribute("data-valid", "processing");
+        const exampleData = getExampleData(tableRow);
 
-    while (curRow) {
-        const curRowValues=Object.values(extractRowValues(curRow));
-        if (curRowValues[0] !==origMainValues[0]) break;
+        if (!isSaved) {
+            const exampleSaved = await saveExample(exampleData);
+            if (!exampleSaved) {
+                return false;
+            }
+        }
 
-        const cells=Array.from(curRow.children).slice(2, -2);
-        let isMatchingCell=true;
+        const { exampleAbsPath, errorMessage, errorList, isPartialFailure } = await validateExample(exampleData);
 
-        for (let i=0; i < cells.length; i++) {
-            isMatchingCell=isMatchingCell && curRowValues[i]===origMainValues[i];
+        if (errorMessage && !exampleAbsPath) {
+            if (!bulkMode) createAlert("Validation Failed", `Error: ${error ?? "Unknown Error"}`, true);
+            tableRow.setAttribute("data-valid", "failed");
+            return false;
+        }
 
-            if (i==cells.length - 1) {
-                isMatchingCell=isMatchingCell && curRowValues[i+1]==origMainValues[i+1];
-            }
+        tableRow.setAttribute("data-valid", errorMessage ? isPartialFailure ? "partial" : "failed" : "success");
+        storeExampleValidationData(tableRow, { errorMessage, errorList });
+        storeExampleTestData(tableRow, null);
+        tableRow.setAttribute("data-test", defaultAttrs["data-test"]);
 
-            if (isMatchingCell) {
-                cells[i].rowSpan+=increment;
-            }
+        if (errorMessage && !isPartialFailure) {
+            if (!bulkMode) createAlert("Invalid Example", `Example name: ${parseFileName(exampleAbsPath)}`, true);
+            return false;
         }
 
-        curRow=curRow.previousElementSibling;
+        if (!bulkMode) createAlert("Valid Example", `Example name: ${parseFileName(exampleAbsPath)}`, false);
+        return true;
     }
-}
 
-async function goToDetails(tableRow, rowValues) {
-    const exampleAbsPath=getExampleData(tableRow);
-    let docFragment=[];
+    async function testRowExample(tableRow, bulkMode = false) {
+        tableRow.setAttribute("data-test", "processing");
 
-    if (exampleAbsPath) {
-        const {
-            example,
-            error
+        const isExampleValid = await validateRowExamples(tableRow, bulkMode);
+        if (!isExampleValid) {
+            createAlert("Invalid Example or Network Failure", `Example name: ${parseFileName(getExampleData(tableRow))}`, true);
+            return false;
         }
 
-        =await getExampleContent(exampleAbsPath);
+        const exampleData = getExampleData(tableRow);
+        const { data, error } = await testExample({
+            exampleFile: exampleData
+        });
 
-        const {
-            errorList,
-            errorMessage
+        if (error && !data) {
+            if (!bulkMode) createAlert("Testing Failed", `Error: ${error ?? "Unknown Error"}`, true);
+            tableRow.setAttribute("data-test", "failed");
+            return false;
         }
 
-        =getExampleValidationData(tableRow) || {
-            errorList: null, errorMessage: null
+        tableRow.setAttribute("data-test", (error || data?.result !== "Success") ? "failed" : "success");
+        storeExampleTestData(tableRow, data);
+
+        if (error || data?.result !== "Success") {
+            if (!bulkMode) createAlert(`Test ${data ? data.result : "Failed"}`, `Example name: ${parseFileName(exampleData)}`, true);
+            return false;
         }
 
-        ;
+        if (!bulkMode) createAlert("Test Passed", `Example name: ${parseFileName(exampleData)}`, false);
+        return true;
+    }
 
-        docFragment=createExampleRows([ {
-                absPath: exampleAbsPath,
-                exampleJson: example,
-                errorList: errorList,
-                errorMessage: error || errorMessage,
-                hasBeenValidated: tableRow.getAttribute("data-valid") !==defaultAttrs["data-valid"],
-                isPartialFailure: tableRow.getAttribute("data-valid")==="partial",
-                test: getExampleTestData(tableRow)
+    // ACTION HELPERS
+    function getExamplesCount(examples) {
+        return examples.reduce((counts, example) => {
+            if (example.created) {
+                counts.createdCount++;
+            } else if (example.existed) {
+                counts.existedCount++;
             }
-
-            ]);
-        originalEditorText=example;
+            return counts;
+        }, { createdCount: 0, existedCount: 0, totalCount: examples.length });
     }
 
-    bulkTestBtn.classList.toggle("bulk-disabled", tableRow.getAttribute("data-valid") !=="success") pathSummaryUl.replaceChildren(createPathSummary(rowValues));
-    examplesOl.replaceChildren(docFragment);
-    mainElement.setAttribute("data-panel", "details");
-    bulkValidateBtn.setAttribute("data-panel", "details");
-    bulkGenerateBtn.setAttribute("data-panel", "details");
-    bulkTestBtn.setAttribute("data-panel", "details");
-    scrollYPosition=window.scrollY;
-    window.scrollTo(0, 0);
-}
-
-function createExampleRows(examples) {
-    const docFragment=document.createDocumentFragment();
-
-    for (const example of examples) {
-        const exampleLi=document.createElement("li");
-        exampleLi.appendChild(createExampleSummary(example));
-        exampleLi.appendChild(createExampleDropDown(example));
-        docFragment.appendChild(exampleLi);
+    function getOnlyNewExamples(tableRow, examples) {
+        const existingExamples = new Set(getAllSameGroupExamples(tableRow));
+        return examples.filter(example => !existingExamples.has(example.exampleFilePath));
     }
 
-    return docFragment;
-}
-
-function createPathSummary(rowValues) {
-    const docFragment=document.createDocumentFragment();
+    function updateRowWithExample(tableRow, shouldClone, example) {
+        const newRow = shouldClone ? tableRow.cloneNode(true) : tableRow;
+        storeExampleData(newRow, example);
+        insertExampleIntoRow(example, newRow);
 
-    if (rowValues.isSchemaBased) {
-        rowValues= {
-            "schema": rowValues["path"], ...rowValues
+        if (shouldClone) {
+            Object.entries(defaultAttrs).forEach(([attr, value]) => newRow.setAttribute(attr, value));
+            Array.from(newRow.children).slice(2, -2).forEach(cell => cell.classList.add("hidden"));
         }
 
-        ;
-        delete rowValues["path"];
-        delete rowValues["isSchemaBased"];
+        newRow.setAttribute("data-generate", "success");
+        enableValidateBtn(newRow);
+        return newRow;
     }
 
-    for (const [key, value] of Object.entries(rowValues)) {
-        if ( !value) continue;
-
-        const li=document.createElement("li");
-        const keySpan=document.createElement("span");
-        const valueSpan=document.createElement("span");
-
-        keySpan.textContent=key;
-        valueSpan.textContent=value;
-        li.appendChild(keySpan);
-        li.appendChild(valueSpan);
-
-        docFragment.appendChild(li);
+    function insertExampleIntoRow(example, tableRow) {
+        const exampleSpan = document.createElement("span");
+        exampleSpan.textContent = parseFileName(example.exampleFilePath);
+        const generateColumn = tableRow.querySelector("td:nth-last-child(2)")
+        generateColumn.replaceChildren(exampleSpan);
     }
 
-    return docFragment;
-}
+    function updateSpans(tableRow, rowValues, increment) {
+        const origMainValues = Object.values(rowValues)
+        let curRow = tableRow;
 
+        while (curRow) {
+            const curRowValues = Object.values(extractRowValues(curRow));
+            if (curRowValues[0] !== origMainValues[0]) break;
 
-function createExampleSummary(example) {
-    const exampleDiv=document.createElement("div");
-    const exampleName=document.createElement("p");
-    const exampleBadge=document.createElement("span");
-    const testBadge=document.createElement("span");
+            const cells = Array.from(curRow.children).slice(2, -2);
+            let isMatchingCell = true;
 
-    exampleDiv.classList.add("example");
-    exampleBadge.classList.add("pill", example.hasBeenValidated ? (example.errorMessage ? (example.isPartialFailure ? "yellow" : "red"): "green") : "blue");
-    exampleName.textContent=example.absPath;
+            for (let i = 0; i < cells.length; i++) {
+                isMatchingCell = isMatchingCell && curRowValues[i] === origMainValues[i];
+                if (i == cells.length - 1) {
+                    isMatchingCell = isMatchingCell && curRowValues[i + 1] == origMainValues[i + 1];
+                }
+                if (isMatchingCell) {
+                    cells[i].rowSpan += increment;
+                }
+            }
 
-    if (example.hasBeenValidated) {
-        exampleBadge.textContent=example.errorMessage ? example.isPartialFailure ? "Valid": "Invalid": "Valid";
-        exampleBadge.textContent+=" Example";
+            curRow = curRow.previousElementSibling;
+        }
     }
 
-    else {
-        exampleBadge.textContent="Example";
-    }
+    async function goToDetails(tableRow, rowValues) {
+        const exampleAbsPath = getExampleData(tableRow);
+        let docFragment = [];
 
-    const expandDiv=document.createElement("div");
-    expandDiv.classList.add("expand-info");
-    expandDiv.appendChild(exampleBadge);
+        if (exampleAbsPath) {
+            const { example, error } = await getExampleContent(exampleAbsPath);
+            const { errorList, errorMessage } = getExampleValidationData(tableRow) || { errorList: null, errorMessage: null };
+            docFragment = createExampleRows([{
+                absPath: exampleAbsPath,
+                exampleJson: example,
+                errorList: errorList,
+                errorMessage: error || errorMessage,
+                hasBeenValidated: tableRow.getAttribute("data-valid") !== defaultAttrs["data-valid"],
+                isPartialFailure: tableRow.getAttribute("data-valid") === "partial",
+                test: getExampleTestData(tableRow)
+            }]);
+             originalEditorText = example;
+        }
 
-    if (example.test) {
-        console.log(example.test);
-        testBadge.classList.add("pill", example.test.result==="Success" ? "green" : "red");
+        bulkTestBtn.classList.toggle("bulk-disabled", tableRow.getAttribute("data-valid") !== "success")
+        pathSummaryUl.replaceChildren(createPathSummary(rowValues));
+        examplesOl.replaceChildren(docFragment);
+        mainElement.setAttribute("data-panel", "details");
+        bulkValidateBtn.setAttribute("data-panel", "details");
+        bulkGenerateBtn.setAttribute("data-panel", "details");
+        bulkTestBtn.setAttribute("data-panel", "details");
+        scrollYPosition = window.scrollY;
+        window.scrollTo(0, 0);
+    }
 
-        testBadge.textContent=`Test $ {
-            example.test.result
+    function createExampleRows(examples) {
+        const docFragment = document.createDocumentFragment();
+        for (const example of examples) {
+            const exampleLi = document.createElement("li");
+            exampleLi.appendChild(createExampleSummary(example));
+            exampleLi.appendChild(createExampleDropDown(example));
+            docFragment.appendChild(exampleLi);
         }
 
-        `;
-        expandDiv.appendChild(testBadge);
+        return docFragment;
     }
 
-    exampleDiv.appendChild(exampleName);
-    exampleDiv.appendChild(expandDiv);
-    return exampleDiv;
-}
-
-function createExampleDropDown(example) {
-    const detailsDiv=document.createElement("div");
-    detailsDiv.classList.add("details");
+    function createPathSummary(rowValues) {
+        const docFragment = document.createDocumentFragment();
 
-    const detailsDropdown=document.createElement("div");
-    detailsDropdown.classList.add("dropdown");
-    const detailsPara=document.createElement("p");
-    detailsDropdown.appendChild(detailsPara);
-    detailsDropdown.appendChild(chevronDownIcon.cloneNode(true));
+        if (rowValues.isSchemaBased) {
+            rowValues = { "schema": rowValues["path"], ...rowValues };
+            delete rowValues["path"];
+            delete rowValues["isSchemaBased"];
+        }
 
-    const detailsPre=document.createElement("pre");
-    const examplePara=document.createElement("p");
-    examplePara.textContent="Example: ";
+        for (const [key, value] of Object.entries(rowValues)) {
+            if (!value) continue;
 
-    if (example.errorMessage) {
-        const issueCount=example.errorList.length;
-        const issueOrIssues=issueCount===1 ? "issue": "issues";
+            const li = document.createElement("li");
+            const keySpan = document.createElement("span");
+            const valueSpan = document.createElement("span");
 
-        detailsPara.textContent=`Example has $ {
-            issueCount || ""
-        }
+            keySpan.textContent = key;
+            valueSpan.textContent = value;
+            li.appendChild(keySpan);
+            li.appendChild(valueSpan);
 
-        $ {
-            issueOrIssues
+            docFragment.appendChild(li);
         }
+        return docFragment;
+    }
 
-        `;
 
-        if (issueCount > 0) {
-            detailsPara.style.color="red";
-        }
-    }
+    function createExampleSummary(example) {
+        const exampleDiv = document.createElement("div");
+        const exampleName = document.createElement("p");
+        const exampleBadge = document.createElement("span");
+        const testBadge = document.createElement("span");
 
-    else {
-        detailsPara.textContent=example.hasBeenValidated ? "Example has no errors": "Example has not yet been validated";
-    }
+        exampleDiv.classList.add("example");
+        exampleBadge.classList.add("pill", example.hasBeenValidated ? (example.errorMessage ? (example.isPartialFailure ? "yellow" : "red"): "green") : "blue");
+        exampleName.textContent = example.absPath;
 
-    if (example.hasBeenValidated) {
-        detailsPre.textContent=example.errorMessage ? example.errorMessage : `$ {
-            parseFileName(example.absPath)
+        if (example.hasBeenValidated) {
+           exampleBadge.textContent = example.errorMessage ? example.isPartialFailure ? "Valid" : "Invalid" : "Valid";
+            exampleBadge.textContent += " Example";
+        } else {
+            exampleBadge.textContent = "Example";
         }
 
-        IS VALID`;
+        const expandDiv = document.createElement("div");
+        expandDiv.classList.add("expand-info");
+        expandDiv.appendChild(exampleBadge);
 
         if (example.test) {
-            detailsPre.textContent=`$ {
-                detailsPre.textContent
-            }
-
-            \n$ {
-                example.test.details
-            }
-
-            `;
-        }
-    }
-
-    else {
-        detailsPre.textContent=`$ {
-            parseFileName(example.absPath)
+            console.log(example.test);
+            testBadge.classList.add("pill", example.test.result === "Success" ? "green" : "red");
+            testBadge.textContent = `Test ${example.test.result}`;
+            expandDiv.appendChild(testBadge);
         }
 
-        HAS NOT YET BEEN VALIDATED`;
+        exampleDiv.appendChild(exampleName);
+        exampleDiv.appendChild(expandDiv);
+        return exampleDiv;
     }
 
-    const examplePreDiv=document.createElement("div");
-    const detailsFragment=document.createDocumentFragment();
+    function createExampleDropDown(example) {
+        const detailsDiv = document.createElement("div");
+        detailsDiv.classList.add("details");
 
-    examplePreDiv.setAttribute("id", "example-pre");
-    examplePreDiv.classList.add("language-json");
-    detailsFragment.appendChild(detailsDropdown);
-    detailsFragment.appendChild(detailsPre);
+        const detailsDropdown = document.createElement("div");
+        detailsDropdown.classList.add("dropdown");
+        const detailsPara = document.createElement("p");
+        detailsDropdown.appendChild(detailsPara);
+        detailsDropdown.appendChild(chevronDownIcon.cloneNode(true));
 
-    setDecorationsEffect=window.StateEffect.define();
+        const detailsPre = document.createElement("pre");
+        const examplePara = document.createElement("p");
+        examplePara.textContent = "Example: ";
 
-    decorationsField=window.StateField.define({
-        create() {
-            return window.Decoration.none;
+        if (example.errorMessage) {
+            const issueCount = example.errorList.length;
+            const issueOrIssues = issueCount === 1 ? "issue" : "issues";
+            detailsPara.textContent = `Example has ${issueCount || ""} ${issueOrIssues}`;
+            if (issueCount > 0) {
+                detailsPara.style.color = "red";
+            }
+        } else {
+            detailsPara.textContent = example.hasBeenValidated ? "Example has no errors" : "Example has not yet been validated";
         }
 
-        ,
-        update(decorations, transaction) {
-            for (let effect of transaction.effects) {
-                if (effect.is(setDecorationsEffect)) {
-                    return effect.value;
-                }
+        if (example.hasBeenValidated) {
+            detailsPre.textContent = example.errorMessage ? example.errorMessage : `${parseFileName(example.absPath)} IS VALID`;
+            if (example.test) {
+                detailsPre.textContent = `${detailsPre.textContent}\n${example.test.details}`;
+            }
+        } else {
+            detailsPre.textContent = `${parseFileName(example.absPath)} HAS NOT YET BEEN VALIDATED`;
+        }
+
+        const examplePreDiv = document.createElement("div");
+        const detailsFragment = document.createDocumentFragment();
+
+        examplePreDiv.setAttribute("id", "example-pre");
+        examplePreDiv.classList.add("language-json");
+        detailsFragment.appendChild(detailsDropdown);
+        detailsFragment.appendChild(detailsPre);
+
+ setDecorationsEffect = window.StateEffect.define();
+   decorationsField = window.StateField.define({
+    create() {
+        return window.Decoration.none;
+    },
+    update(decorations, transaction) {
+        for (let effect of transaction.effects) {
+            if (effect.is(setDecorationsEffect)) {
+                return effect.value;
             }
-
-            return decorations;
         }
+        return decorations;
+    },
+    provide: field => window.EditorView.decorations.from(field)
+});
 
-        ,
-        provide: field=> window.EditorView.decorations.from(field)
-    });
-
-const editor=new window.EditorView({
+    const editor = new window.EditorView({
     state: window.EditorState.create({
-
-        doc: example.exampleJson,
-        extensions: [ window.basicSetup,
+      doc: example.exampleJson,
+      extensions: [
+        window.basicSetup,
         window.autocompletion,
         window.json,
         window.linter,
@@ -2426,637 +1826,491 @@
         window.lineNumbers,
         window.oneDark,
         decorationsField,
-        window.EditorView.updateListener.of((update)=> {
-                if (update.docChanged) {
-                    isSaved=false;
-                    const editorElement=editor.dom;
-                    updateBorderColorExampleBlock(editorElement, examplePreDiv);
-
-                    if (example.errorList && example.errorList.length >0) {
-                        highlightErrorLines(editor, example.errorList, example.exampleJson);
-                    }
-
-                    savedEditorResponse=update.state.doc.toString();
+        window.EditorView.updateListener.of((update) => {
+        if (update.docChanged) {
+          isSaved = false;
+          const editorElement = editor.dom;
+          updateBorderColorExampleBlock(editorElement, examplePreDiv);
+           if (example.errorList && example.errorList.length >0) {
+                highlightErrorLines(editor, example.errorList, example.exampleJson);
                 }
-            })],
-    }),
-parent: examplePreDiv
-});
-
-
-if (example.errorList && example.errorList.length >0) {
-    highlightErrorLines(editor, example.errorList, example.exampleJson);
-}
-
-
-if (example.test) {
-    const testPara=document.createElement("p");
-    testPara.textContent="Test Log: ";
-    const testPre=document.createElement("pre");
-    testPre.textContent=example.test.testLog;
-    detailsFragment.appendChild(testPara);
-    detailsFragment.appendChild(testPre);
-}
-
-detailsDiv.appendChild(detailsFragment);
-detailsDiv.appendChild(examplePara);
-
-const fragment=document.createDocumentFragment();
-
-if (example.errorMessage) {
-    fragment.appendChild(detailsDiv);
-}
-
-fragment.appendChild(examplePreDiv);
-
-return fragment;
-}
-
-async function saveExample(examplePath) {
-    const editedText=savedEditorResponse;
-
-    try {
-        const parsedContent=JSON.parse(editedText);
+          savedEditorResponse = update.state.doc.toString();
+        }
+      })
+    ],
+  }),
+    parent: examplePreDiv
+  });
 
-        const response=await fetch(`$ {
-                getHostPort()
-            }
 
-            /_specmatic/examples/update`, {
-            method: "POST",
-            headers: {
-                "Content-Type": "application/json",
+       if (example.errorList && example.errorList.length >0) {
+                highlightErrorLines(editor, example.errorList, example.exampleJson);
             }
 
-            ,
-            body: JSON.stringify({
-                exampleFile: examplePath,
-                exampleContent: editedText,
-            }),
-    });
-
-if (response.ok) {
-    createAlert("Saved", "Example saved to file", false);
-    isSaved=true;
-    return true;
-}
-
-else {
-    const errorMessage=await response.text();
 
-    createAlert("Failed to save example.", `Failed to save example to $ {
-            examplePath
+        if (example.test) {
+            const testPara = document.createElement("p");
+            testPara.textContent = "Test Log: ";
+            const testPre = document.createElement("pre");
+            testPre.textContent = example.test.testLog;
+            detailsFragment.appendChild(testPara);
+            detailsFragment.appendChild(testPre);
         }
 
-        : $ {
-            errorMessage
+        detailsDiv.appendChild(detailsFragment);
+        detailsDiv.appendChild(examplePara);
+
+        const fragment = document.createDocumentFragment();
+        if (example.errorMessage) {
+            fragment.appendChild(detailsDiv);
         }
+        fragment.appendChild(examplePreDiv);
 
-        `, true);
-    console.error("Error saving example:", response.status);
-    savedEditorResponse=originalEditorText;
-    return false;
-}
-}
+        return fragment;
+    }
 
-catch (e) {
-    console.error("Error during save request:", e);
+    async function saveExample(examplePath) {
+        const editedText = savedEditorResponse;
+        try {
+            const parsedContent = JSON.parse(editedText);
 
-    createAlert("Failed to save example.", `An error occurred while saving example to $ {
-            examplePath
-        }
+            const response = await fetch(`${getHostPort()}/_specmatic/examples/update`, {
+                method: "POST",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                body: JSON.stringify({
+                    exampleFile: examplePath,
+                    exampleContent: editedText,
+                }),
+            });
 
-        : $ {
-            e.message
+            if (response.ok) {
+                createAlert("Saved", "Example saved to file", false);
+                isSaved = true;
+                return true;
+            } else {
+                const errorMessage = await response.text();
+                createAlert("Failed to save example.", `Failed to save example to ${examplePath}: ${errorMessage}`, true);
+                console.error("Error saving example:", response.status);
+                savedEditorResponse = originalEditorText;
+                return false;
+            }
+        } catch (e) {
+            console.error("Error during save request:", e);
+            createAlert("Failed to save example.", `An error occurred while saving example to ${examplePath}: ${e.message}`, true);
+            savedEditorResponse = originalEditorText;
+            return false;
         }
-
-        `, true);
-    savedEditorResponse=originalEditorText;
-    return false;
-}
-}
+    }
 
 
-function updateBorderColorExampleBlock(editorElement, examplePreDiv) {
+   function updateBorderColorExampleBlock(editorElement, examplePreDiv) {
     try {
         JSON.parse(editorElement.state.doc.toString());
-        editorElement.style.borderWidth="2px";
-        editorElement.style.borderStyle="solid";
-        editorElement.style.borderColor="green";
-    }
-
-    catch (e) {
-        editorElement.style.borderWidth="2px";
-        editorElement.style.borderStyle="solid";
-        editorElement.style.borderColor="red";
+        editorElement.style.borderWidth = "2px";
+        editorElement.style.borderStyle = "solid";
+        editorElement.style.borderColor = "green";
+    } catch (e) {
+        editorElement.style.borderWidth = "2px";
+        editorElement.style.borderStyle = "solid";
+        editorElement.style.borderColor = "red";
     }
 }
 
 
-function highlightErrorLines(editor, metadata, exampleJson) {
-    const {
-        data,
-        pointers
-    }
-
-    =jsonMapParser(exampleJson);
-    let decorations=[];
-
-    metadata.forEach(meta=> {
-            var location=findObjectByPath(pointers, meta.jsonPath);
-
-            if (location==null) {
-                meta.jsonPath=meta.jsonPath.substring(0, meta.jsonPath.lastIndexOf('/'));
-                location=findObjectByPath(pointers, meta.jsonPath);
-            }
+   function highlightErrorLines(editor, metadata, exampleJson) {
+    const { data, pointers } = jsonMapParser(exampleJson);
+    let decorations = [];
 
-            const lineNumber=location.key ? location.key.line : (location.value ? location.value.line : null);
+    metadata.forEach(meta => {
+        var location = findObjectByPath(pointers, meta.jsonPath);
+        if (location == null) {
+            meta.jsonPath = meta.jsonPath.substring(0, meta.jsonPath.lastIndexOf('/'));
+            location = findObjectByPath(pointers, meta.jsonPath);
+        }
+        const lineNumber = location.key ? location.key.line : (location.value ? location.value.line : null);
 
-            if (lineNumber !==null) {
-                const lineLength=editor.state.doc.line(lineNumber + 1) const className=meta.isPartial ? "cm-lint-mark-warning CodeMirror-lint-mark-warning"
+        if (lineNumber !== null) {
+            const lineLength = editor.state.doc.line(lineNumber + 1)
+            const className = meta.isPartial
+                ? "cm-lint-mark-warning CodeMirror-lint-mark-warning"
                 : "cm-lint-mark-error CodeMirror-lint-mark-error";
 
-                decorations.push(window.Decoration.line({
-
-                        class: className,
-                        attributes: {
-                            "data-validation-error-message": meta.description
-                        }
-                    }).range(lineLength.from));
-
+            decorations.push(
+            window.Decoration.line({
+                class: className,
+                attributes: { "data-validation-error-message": meta.description
+                }
+            }).range(lineLength.from)
+            );
             errorMetadata.push({
                 line: lineNumber+1,
                 message: meta.description,
                 isPartial: meta.isPartial
             });
-    }
-});
-const decorationSet=window.Decoration.set(decorations);
-
-const transaction=editor.state.update({
-    effects: setDecorationsEffect.of(decorationSet)
-});
-
-editor.dispatch(transaction);
-const errorTooltipExtension=createErrorTooltipExtension(errorMetadata);
-
-editor.dispatch({
-    effects: setDecorationsEffect.of(decorationSet),
-});
+        }
+    });
+   const decorationSet = window.Decoration.set(decorations);
+    const transaction = editor.state.update({
+        effects: setDecorationsEffect.of(decorationSet)
+    });
 
-editor.dispatch({
-    effects: window.StateEffect.appendConfig.of([errorTooltipExtension]),
-});
+    editor.dispatch(transaction);
+     const errorTooltipExtension = createErrorTooltipExtension(errorMetadata);
+    editor.dispatch({
+        effects: setDecorationsEffect.of(decorationSet),
+    });
+    editor.dispatch({
+        effects: window.StateEffect.appendConfig.of([errorTooltipExtension]),
+    });
 
 }
-
-function findObjectByPath(pointers, patch) {
-    for (const path in pointers) {
-        if (path===patch) {
-            return pointers[path];
+    function findObjectByPath(pointers, patch) {
+        for (const path in pointers) {
+            if (path === patch) {
+                return pointers[path];
+            }
         }
+        return null;
     }
-
-    return null;
-}
-
-const createErrorTooltipExtension=(errorMetadata)=> {
-    return window.hoverTooltip((view, pos)=> {
-            const line=view.state.doc.lineAt(pos);
-            const error=errorMetadata.find(err=> err.line===line.number);
-            const lineCoords=view.coordsAtPos(pos);
-
-            if (error) {
-                return {
-
-                    pos,
-                    above: true,
-                    create: ()=> {
-                        const tooltip=document.createElement("div");
-                        tooltip.textContent=error.message;
-                        tooltip.innerHTML=error.message.replace(/\n/g, "<br>");
-                        tooltip.className="cm-tooltip cm-tooltip-lint";
-                        tooltip.style.color="white";
-                        tooltip.style.padding="15px";
-                        tooltip.style.borderRadius="3px";
-                        tooltip.style.fontSize="20px";
-                        tooltip.style.pointerEvents="none";
-                        tooltip.style.display="block";
-                        tooltip.style.zIndex="1000";
-                        tooltip.style.position="fixed";
-                        tooltip.style.borderLeft=error.isPartial ? "4px solid yellow"
+   const createErrorTooltipExtension = (errorMetadata) => {
+    return window.hoverTooltip((view, pos) => {
+        const line = view.state.doc.lineAt(pos);
+        const error = errorMetadata.find(err => err.line === line.number);
+        const lineCoords = view.coordsAtPos(pos);
+        if (error) {
+            return {
+                pos,
+                above: true,
+                create: () => {
+                    const tooltip = document.createElement("div");
+                    tooltip.textContent = error.message;
+                    tooltip.innerHTML = error.message.replace(/\n/g, "<br>");
+                    tooltip.className = "cm-tooltip cm-tooltip-lint";
+                    tooltip.style.color = "white";
+                    tooltip.style.padding = "15px";
+                    tooltip.style.borderRadius = "3px";
+                    tooltip.style.fontSize = "20px";
+                    tooltip.style.pointerEvents = "none";
+                    tooltip.style.display = "block";
+                     tooltip.style.zIndex = "1000";
+                      tooltip.style.position = "fixed";
+                      tooltip.style.borderLeft = error.isPartial ? "4px solid yellow"
                         : "4px solid red";
+                       tooltip.style.top = `${lineCoords.top + window.scrollY - tooltip.offsetHeight - 120}px`; // Position above the line
+                    tooltip.style.left = `${lineCoords.left + 20}px`;
+                    return { dom: tooltip};
+                },
+            };
+        }
 
-                        tooltip.style.top=`$ {
-                            lineCoords.top + window.scrollY - tooltip.offsetHeight - 120
-                        }
-
-                        px`; // Position above the line
-
-                        tooltip.style.left=`$ {
-                            lineCoords.left + 20
-                        }
-
-                        px`;
-
-                        return {
-                            dom: tooltip
-                        }
-
-                        ;
-                    }
-
-                    ,
-                }
-
-                ;
-            }
-
-            return null;
-        });
-}
-
-;
-
-function createErrorMarker() {
-    const marker=document.createElement("div");
-    marker.className="CodeMirror-lint-mark-error";
-    return marker;
-}
-
-
-function parseFileName(path) {
-    return path.split('/').pop();
-}
-
-function storeExampleData(tableRow, example) {
-    const key=tableRow.getAttribute("data-key");
-    tableRow.setAttribute("data-example", example.exampleFilePath);
-    exampleDetails[key][example.exampleFilePath]=null;
-    return example;
-}
-
-function getExampleData(tableRow) {
-    return tableRow.getAttribute("data-example");
-}
+        return null;
+    });
+};
 
-function getAllSameGroupExamples(tableRow) {
-    const rowKey=tableRow.getAttribute("data-key");
-    const examplePairs=exampleDetails[rowKey];
-    return Object.keys(examplePairs).filter(value=> value !=="null");
-}
+    function createErrorMarker() {
+        const marker = document.createElement("div");
+        marker.className = "CodeMirror-lint-mark-error";
+        return marker;
+    }
 
-function storeExampleValidationData(tableRow, result) {
-    const key=tableRow.getAttribute("data-key");
-    exampleDetails[key][tableRow.getAttribute("data-example")]=result;
-}
 
-function getExampleValidationData(tableRow) {
-    const key=tableRow.getAttribute("data-key");
-    return exampleDetails[key][getExampleData(tableRow)];
-}
+    function parseFileName(path) {
+        return path.split('/').pop();
+    }
+    function storeExampleData(tableRow, example) {
+        const key = tableRow.getAttribute("data-key");
+        tableRow.setAttribute("data-example", example.exampleFilePath);
+        exampleDetails[key][example.exampleFilePath] = null;
+        return example;
+    }
 
-function storeExampleTestData(tableRow, data) {
-    const key=tableRow.getAttribute("data-key");
-    const exampleData=getExampleData(tableRow);
+    function getExampleData(tableRow) {
+        return tableRow.getAttribute("data-example");
+    }
 
-    if ( !testDetails[key]) {
-        testDetails[key]= {}
+    function getAllSameGroupExamples(tableRow) {
+        const rowKey = tableRow.getAttribute("data-key");
+        const examplePairs = exampleDetails[rowKey];
+        return Object.keys(examplePairs).filter(value => value !== "null");
+    }
 
-        ;
+    function storeExampleValidationData(tableRow, result) {
+        const key = tableRow.getAttribute("data-key");
+        exampleDetails[key][tableRow.getAttribute("data-example")] = result;
     }
 
-    testDetails[key][exampleData]=data;
-}
+    function getExampleValidationData(tableRow) {
+        const key = tableRow.getAttribute("data-key");
+        return exampleDetails[key][getExampleData(tableRow)];
+    }
 
+    function storeExampleTestData(tableRow, data) {
+        const key = tableRow.getAttribute("data-key");
+        const exampleData = getExampleData(tableRow);
 
-function getExampleTestData(tableRow) {
-    const key=tableRow.getAttribute("data-key");
+        if (!testDetails[key]) {
+            testDetails[key] = {};
+        }
 
-    if ( !testDetails[key]) {
-        return null;
+        testDetails[key][exampleData] = data;
     }
 
-    return testDetails[key][getExampleData(tableRow)];
-}
-
-async function generateExample(pathInfo, bulkMode) {
-    try {
-        const resp=await fetch(`$ {
-                getHostPort()
-            }
 
-            /_specmatic/examples/generate`, {
-            method: "POST",
-            body: JSON.stringify({
-                ...pathInfo, bulkMode
+    function getExampleTestData(tableRow) {
+        const key = tableRow.getAttribute("data-key");
 
-            }),
-        headers: {
-            "Content-Type": "application/json",
+        if (!testDetails[key]) {
+            return null;
         }
-    });
-const data=await resp.json();
-
-if ( !resp.ok) {
-    throw new Error(data.error);
-}
-
-return {
-    examples: data.examples, error: data.error
-}
-
-;
-}
 
-catch (error) {
-    return {
-        error: error.message, examples: null
+        return testDetails[key][getExampleData(tableRow)];
     }
 
-    ;
-}
-}
+    async function generateExample(pathInfo, bulkMode) {
+        try {
+            const resp = await fetch(`${getHostPort()}/_specmatic/examples/generate`, {
+                method: "POST",
+                body: JSON.stringify({ ...pathInfo, bulkMode }),
+                headers: {
+                    "Content-Type": "application/json",
+                }
+            });
+            const data = await resp.json();
 
-async function validateExample(exampleFile) {
-    try {
-        const resp=await fetch(`$ {
-                getHostPort()
+            if (!resp.ok) {
+                throw new Error(data.error);
             }
 
-            /_specmatic/examples/validate`, {
-            method: "POST",
-            body: JSON.stringify({
-                exampleFile
-
-            }),
-        headers: {
-            "Content-Type": "application/json",
+            return { examples: data.examples, error: data.error };
+        } catch (error) {
+            return { error: error.message, examples: null };
         }
-    });
-const data=await resp.json();
-
-if ( !resp.ok) {
-    throw new Error(data.errorMessage);
-}
-
-return {
-    exampleAbsPath: data.absPath, errorList: data.errorList, errorMessage: data.errorMessage, isPartialFailure: data.isPartialFailure
-}
-
-;
-}
-
-catch (error) {
-    return {
-        errorMessage: error.message, exampleAbsPath: null, isPartialFailure: false, errorList: null
     }
 
-    ;
-}
-}
-
-async function getExampleContent(example) {
-    const exampleFileName=encodeURIComponent(example);
-
-    try {
-        const resp=await fetch(`$ {
-                getHostPort()
-            }
+    async function validateExample(exampleFile) {
+        try {
+            const resp = await fetch(`${getHostPort()}/_specmatic/examples/validate`, {
+                method: "POST",
+                body: JSON.stringify({ exampleFile }),
+                headers: {
+                    "Content-Type": "application/json",
+                }
+            });
+            const data = await resp.json();
 
-            /_specmatic/examples/content?fileName=$ {
-                exampleFileName
+            if (!resp.ok) {
+                throw new Error(data.errorMessage);
             }
 
-            `) const data=await resp.json();
-
-        if ( !resp.ok) {
-            throw new Error(data.error);
+            return { exampleAbsPath: data.absPath, errorList: data.errorList, errorMessage: data.errorMessage, isPartialFailure: data.isPartialFailure };
+        } catch (error) {
+            return { errorMessage: error.message, exampleAbsPath: null, isPartialFailure: false, errorList: null };
         }
+    }
 
-        return {
-            example: data.content, error: null
-        }
+    async function getExampleContent(example) {
+        const exampleFileName = encodeURIComponent(example);
+        try {
+            const resp = await fetch(`${getHostPort()}/_specmatic/examples/content?fileName=${exampleFileName}`)
+            const data = await resp.json();
 
-        ;
-    }
+            if (!resp.ok) {
+                throw new Error(data.error);
+            }
 
-    catch (e) {
-        return {
-            example: null, error: e.message
+            return { example: data.content, error: null };
+        } catch (e) {
+            return { example: null, error: e.message }
         }
     }
-}
 
-async function testExample(exampleData) {
-    try {
-        const resp=await fetch(`$ {
-                getHostPort()
-            }
+    async function testExample(exampleData) {
+        try {
+            const resp = await fetch(`${getHostPort()}/_specmatic/examples/test`, {
+                method: "POST",
+                body: JSON.stringify(exampleData),
+                headers: {
+                    "Content-Type": "application/json",
+                }
+            });
+            const data = await resp.json();
 
-            /_specmatic/examples/test`, {
-            method: "POST",
-            body: JSON.stringify(exampleData),
-            headers: {
-                "Content-Type": "application/json",
+            if (!resp.ok) {
+                throw new Error(data.error);
             }
-        });
-    const data=await resp.json();
 
-    if ( !resp.ok) {
-        throw new Error(data.error);
+            return { data, error: data.error }
+        } catch (error) {
+            return { data: null, error: error.message }
+        }
     }
 
-    return {
-        data,
-        error: data.error
+    function parseFileName(absPath) {
+        const fileName = absPath.split("\\").pop().split("/").pop();
+        const lastIndex = fileName.lastIndexOf(".");
+        return fileName.slice(0, lastIndex);
     }
-}
 
-catch (error) {
-    return {
-        data: null, error: error.message
+    function getHostPort() {
+        const hostPort = table.getAttribute("data-hostPort");
+        return hostPort ? hostPort.replace(/\/$/, '') : hostPort;
     }
-}
-}
 
-function parseFileName(absPath) {
-    const fileName=absPath.split("\\").pop().split("/").pop();
-    const lastIndex=fileName.lastIndexOf(".");
-    return fileName.slice(0, lastIndex);
-}
-
-function getHostPort() {
-    const hostPort=table.getAttribute("data-hostPort");
-    return hostPort ? hostPort.replace(/\/$/, ''): hostPort;
-}
-
-function enableValidateBtn(tableRow) {
-    table.setAttribute("data-generated", "true");
-}
+    function enableValidateBtn(tableRow) {
+        table.setAttribute("data-generated", "true");
+    }
 
-function createAlert(heading, message, error) {
-    const alertBox=document.createElement("div");
-    alertBox.classList.add("alert-msg", "slide-in", error ? "red" : "green");
+    function createAlert(heading, message, error) {
+        const alertBox = document.createElement("div");
+        alertBox.classList.add("alert-msg", "slide-in", error ? "red" : "green");
 
-    const alertTitle=document.createElement("p");
-    alertTitle.textContent=heading;
+        const alertTitle = document.createElement("p");
+        alertTitle.textContent = heading;
 
-    const alertMsg=document.createElement("pre");
-    alertMsg.textContent=message;
+        const alertMsg = document.createElement("pre");
+        alertMsg.textContent = message;
 
-    alertBox.appendChild(alertTitle);
-    alertBox.appendChild(alertMsg);
-    alerts.replaceChildren(alertBox);
+        alertBox.appendChild(alertTitle);
+        alertBox.appendChild(alertMsg);
+        alerts.replaceChildren(alertBox);
 
-    setTimeout(()=> {
-            if ( !alerts.matches(":hover")) {
+        setTimeout(() => {
+            if (!alerts.matches(":hover")) {
                 removeAlertBox(alertBox);
-            }
-
-            else {
-                const handleMouseLeave=()=> {
+            } else {
+                const handleMouseLeave = () => {
                     removeAlertBox(alertBox);
                     alerts.removeEventListener("mouseleave", handleMouseLeave);
-                }
-
-                ;
+                };
                 alerts.addEventListener("mouseleave", handleMouseLeave);
             }
-        }
-
-        , 3000);
-}
-
-function removeAlertBox(alertBox) {
-    alertBox.classList.add("slide-out");
+        }, 3000);
+    }
 
-    setTimeout(()=> {
+    function removeAlertBox(alertBox) {
+        alertBox.classList.add("slide-out");
+        setTimeout(() => {
             alertBox.remove();
-        }
-
-        , 250);
-}
+        }, 250);
+    }
 
-function cleanUpSelections() {
-    requestAnimationFrame(()=> {
+    function cleanUpSelections() {
+        requestAnimationFrame(() => {
             for (const checkbox of table.querySelectorAll("input[type=checkbox]")) {
-                checkbox.checked=false;
+                checkbox.checked = false;
             }
         });
-    bulkGenerateBtn.setAttribute("data-selected", "0");
-    bulkValidateBtn.setAttribute("data-selected", "0");
-    bulkTestBtn.setAttribute("data-selected", "0");
-    blockGenValidate=false;
-}
-
-function createModal({
-    onSave, onDiscard
-
-}) {
-    // Data for modal
-    const title="Unsaved Changes";
-    const closeText="No";
-    const discardText="Yes";
-    const bodyText="Your changes are not saved & validated. To save your changes click on the Save & Validate button. Discard changes?";
-
-    // Create modal container dynamically
-    const modalContainer=document.createElement("div");
-    modalContainer.classList.add("go-back-modal");
-    modalContainer.style.position="fixed";
-    modalContainer.style.top="0";
-    modalContainer.style.left="0";
-    modalContainer.style.width="100%";
-    modalContainer.style.height="100%";
-    modalContainer.style.backgroundColor="rgba(0, 0, 0, 0.5)";
-    modalContainer.style.display="flex";
-    modalContainer.style.alignItems="center";
-    modalContainer.style.justifyContent="center";
-    modalContainer.style.zIndex="9999";
-
-    // Create modal content box
-    const modalContent=document.createElement("div");
-    modalContent.style.backgroundColor="#fff";
-    modalContent.style.borderRadius="8px";
-    modalContent.style.padding="20px";
-    modalContent.style.width="400px";
-    modalContent.style.boxShadow="0 4px 8px rgba(0, 0, 0, 0.2)";
-    modalContent.style.textAlign="center";
-
-    // Create modal header
-    const modalHeader=document.createElement("div");
-    const modalTitle=document.createElement("h5");
-    modalTitle.textContent=title;
-    modalHeader.style.fontSize="18px";
-    modalHeader.style.fontWeight="bold";
-    modalHeader.style.marginBottom="15px";
-    modalHeader.appendChild(modalTitle);
-
-    // Create modal body
-    const modalBody=document.createElement("div");
-    modalBody.textContent=bodyText;
-    modalBody.style.marginBottom="15px";
-
-    // Create modal footer
-    const modalFooter=document.createElement("div");
-
-    const closeButton=document.createElement("button");
-    closeButton.textContent=closeText;
-    closeButton.style.backgroundColor="#007bff";
-    closeButton.style.color="#fff";
-    closeButton.style.border="none";
-    closeButton.style.padding="8px 16px";
-    closeButton.style.borderRadius="4px";
-    closeButton.style.cursor="pointer";
-    closeButton.style.marginRight="10px";
-
-    const discardButton=document.createElement("button");
-    discardButton.textContent=discardText;
-    discardButton.style.backgroundColor="#007bff";
-    discardButton.style.color="#fff";
-    discardButton.style.border="none";
-    discardButton.style.padding="8px 16px";
-    discardButton.style.borderRadius="4px";
-    discardButton.style.cursor="pointer";
-
-    // Add buttons to footer
-    modalFooter.appendChild(closeButton);
-    modalFooter.appendChild(discardButton);
-
-    // Append everything to the modal content
-    modalContent.appendChild(modalHeader);
-    modalContent.appendChild(modalBody);
-    modalContent.appendChild(modalFooter);
-
-    // Append modal content to modal container
-    modalContainer.appendChild(modalContent);
-
-
-    // Button event listeners
-    closeButton.addEventListener("click", ()=> {
+        bulkGenerateBtn.setAttribute("data-selected", "0");
+        bulkValidateBtn.setAttribute("data-selected", "0");
+        bulkTestBtn.setAttribute("data-selected", "0");
+        blockGenValidate = false;
+    }
+    function createModal({ onSave, onDiscard }) {
+        // Data for modal
+        const title = "Unsaved Changes";
+        const closeText = "No";
+        const discardText = "Yes";
+        const bodyText = "Your changes are not saved & validated. To save your changes click on the Save & Validate button. Discard changes?";
+
+        // Create modal container dynamically
+        const modalContainer = document.createElement("div");
+        modalContainer.classList.add("go-back-modal");
+        modalContainer.style.position = "fixed";
+        modalContainer.style.top = "0";
+        modalContainer.style.left = "0";
+        modalContainer.style.width = "100%";
+        modalContainer.style.height = "100%";
+        modalContainer.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
+        modalContainer.style.display = "flex";
+        modalContainer.style.alignItems = "center";
+        modalContainer.style.justifyContent = "center";
+        modalContainer.style.zIndex = "9999";
+
+        // Create modal content box
+        const modalContent = document.createElement("div");
+        modalContent.style.backgroundColor = "#fff";
+        modalContent.style.borderRadius = "8px";
+        modalContent.style.padding = "20px";
+        modalContent.style.width = "400px";
+        modalContent.style.boxShadow = "0 4px 8px rgba(0, 0, 0, 0.2)";
+        modalContent.style.textAlign = "center";
+
+        // Create modal header
+        const modalHeader = document.createElement("div");
+        const modalTitle = document.createElement("h5");
+        modalTitle.textContent = title;
+        modalHeader.style.fontSize = "18px";
+        modalHeader.style.fontWeight = "bold";
+        modalHeader.style.marginBottom = "15px";
+        modalHeader.appendChild(modalTitle);
+
+        // Create modal body
+        const modalBody = document.createElement("div");
+        modalBody.textContent = bodyText;
+        modalBody.style.marginBottom = "15px";
+
+        // Create modal footer
+        const modalFooter = document.createElement("div");
+
+        const closeButton = document.createElement("button");
+        closeButton.textContent = closeText;
+        closeButton.style.backgroundColor = "#007bff";
+        closeButton.style.color = "#fff";
+        closeButton.style.border = "none";
+        closeButton.style.padding = "8px 16px";
+        closeButton.style.borderRadius = "4px";
+        closeButton.style.cursor = "pointer";
+        closeButton.style.marginRight = "10px";
+
+        const discardButton = document.createElement("button");
+        discardButton.textContent = discardText;
+        discardButton.style.backgroundColor = "#007bff";
+        discardButton.style.color = "#fff";
+        discardButton.style.border = "none";
+        discardButton.style.padding = "8px 16px";
+        discardButton.style.borderRadius = "4px";
+        discardButton.style.cursor = "pointer";
+
+        // Add buttons to footer
+        modalFooter.appendChild(closeButton);
+        modalFooter.appendChild(discardButton);
+
+        // Append everything to the modal content
+        modalContent.appendChild(modalHeader);
+        modalContent.appendChild(modalBody);
+        modalContent.appendChild(modalFooter);
+
+        // Append modal content to modal container
+        modalContainer.appendChild(modalContent);
+
+
+        // Button event listeners
+        closeButton.addEventListener("click", () => {
             closeModal();
         });
 
-    discardButton.addEventListener("click", ()=> {
+        discardButton.addEventListener("click", () => {
             onDiscard();
             closeModal();
         });
 
 
-    modalContainer.addEventListener("click", (event)=> {
-            if (event.target===modalContainer) {
+        modalContainer.addEventListener("click", (event) => {
+            if (event.target === modalContainer) {
                 closeModal();
             }
         });
 
 
-    function closeModal() {
-        modalContainer.remove();
+        function closeModal() {
+            modalContainer.remove();
+        }
+        return modalContainer;
     }
 
-    return modalContainer;
-}
-
 
-(()=> cleanUpSelections())();
-</script></html>
\ No newline at end of file
+    (() => cleanUpSelections())();
+</script>
+</html>
\ No newline at end of file

From a5057f6d5089ab39525b0cfc36d3ea7990c1da5c Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 22:06:33 +0530
Subject: [PATCH 10/14] Removed unused tags

---
 core/src/main/resources/templates/examples/index.html | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index df9491c58..7acba2bb6 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1180,15 +1180,6 @@ <h2 th:text="${contractFilePath}"></h2>
     const testDetails = {};
 </script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jsonlint/1.6.0/jsonlint.min.js"></script>
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.css">-->
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.css">-->
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/theme/dracula.min.css">-->
-<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/addon/lint/lint.min.css">-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/lint.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/addon/lint/json-lint.js"></script>-->
-<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/display/autorefresh.min.js"></script>-->
 <script type="module">
     import { Decoration,EditorState, EditorView, StateEffect, StateField,autocompletion, basicSetup, hoverTooltip,javascript, json,jsonParseLinter, language, lineNumbers, lintGutter, linter,oneDark } from './codemirror-bundle.esm.js'
         window.EditorState = EditorState

From b220db724b931e8e1e8222a4a71c71fc54d6b53b Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Sun, 22 Dec 2024 23:07:00 +0530
Subject: [PATCH 11/14] Multiple comments on same line

---
 .../resources/templates/examples/index.html   | 25 ++++++++++++++-----
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index 7acba2bb6..16c67fc00 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1913,6 +1913,8 @@ <h2 th:text="${contractFilePath}"></h2>
    function highlightErrorLines(editor, metadata, exampleJson) {
     const { data, pointers } = jsonMapParser(exampleJson);
     let decorations = [];
+    const existingMarkers = new Map();
+    const errorLines = [];
 
     metadata.forEach(meta => {
         var location = findObjectByPath(pointers, meta.jsonPath);
@@ -1924,6 +1926,12 @@ <h2 th:text="${contractFilePath}"></h2>
 
         if (lineNumber !== null) {
             const lineLength = editor.state.doc.line(lineNumber + 1)
+            if (!existingMarkers.has(lineNumber)) {
+            existingMarkers.set(lineNumber, []);
+            errorLines.push(lineNumber);
+            }
+            existingMarkers.get(lineNumber).push(meta.description);
+            const combinedDescriptions = existingMarkers.get(lineNumber).join('\n\n');
             const className = meta.isPartial
                 ? "cm-lint-mark-warning CodeMirror-lint-mark-warning"
                 : "cm-lint-mark-error CodeMirror-lint-mark-error";
@@ -1931,15 +1939,20 @@ <h2 th:text="${contractFilePath}"></h2>
             decorations.push(
             window.Decoration.line({
                 class: className,
-                attributes: { "data-validation-error-message": meta.description
+                attributes: { "data-validation-error-message": combinedDescriptions
                 }
             }).range(lineLength.from)
             );
-            errorMetadata.push({
-                line: lineNumber+1,
-                message: meta.description,
-                isPartial: meta.isPartial
-            });
+             const existingError = errorMetadata.find(err => err.line === lineNumber + 1);
+           if (existingError) {
+                existingError.message = combinedDescriptions;
+            } else {
+                errorMetadata.push({
+                    line: lineNumber + 1,
+                    message: combinedDescriptions,
+                    isPartial: meta.isPartial
+                });
+            }
         }
     });
    const decorationSet = window.Decoration.set(decorations);

From 1822a782cc1427a6a942bc18cfe372886d6758c0 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Mon, 23 Dec 2024 11:31:35 +0530
Subject: [PATCH 12/14] Fixed some use cases

---
 core/src/main/resources/templates/examples/index.html | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/src/main/resources/templates/examples/index.html b/core/src/main/resources/templates/examples/index.html
index 16c67fc00..75e09d913 100644
--- a/core/src/main/resources/templates/examples/index.html
+++ b/core/src/main/resources/templates/examples/index.html
@@ -1915,6 +1915,7 @@ <h2 th:text="${contractFilePath}"></h2>
     let decorations = [];
     const existingMarkers = new Map();
     const errorLines = [];
+    errorMetadata= [];
 
     metadata.forEach(meta => {
         var location = findObjectByPath(pointers, meta.jsonPath);
@@ -1955,6 +1956,7 @@ <h2 th:text="${contractFilePath}"></h2>
             }
         }
     });
+    decorations.sort((a, b) => a.from - b.from);
    const decorationSet = window.Decoration.set(decorations);
     const transaction = editor.state.update({
         effects: setDecorationsEffect.of(decorationSet)

From 1e38bff2a714373eb4d7446931fd6316b3dd9758 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Tue, 24 Dec 2024 14:50:10 +0530
Subject: [PATCH 13/14] Work flow Added

---
 .github/workflows/gradle.yml | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index dca5c1863..35b95d591 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -62,3 +62,21 @@ jobs:
       with:
         name: Gradle application build Log on ${{ matrix.os }}
         path: application/build/reports/
+
+    - name: Download release asset from example-inline-editor-module
+      uses: ncipollo/release-action@v1
+      with:
+        repository: znsio/example-inline-editor-module
+        asset_name: example-inline-editor-module-artifact.zip  # Adjust the name of the artifact
+        token: ${{ secrets.GITHUB_TOKEN }}
+        path: ./downloaded-artifact
+
+    - name: Unzip downloaded artifact
+      run: |
+        unzip ./downloaded-artifact/example-inline-editor-module-artifact.zip -d ./downloaded-artifact/  
+
+    - name: Upload unzipped artifact
+      uses: actions/upload-artifact@v4
+      with:
+        name: example-inline-editor-module-unzipped
+        path: ./downloaded-artifact/
\ No newline at end of file

From 0c16918be1b1a1385659b0b6b145a894f0e77314 Mon Sep 17 00:00:00 2001
From: Samy <samy@Samys-MacBook-Air.local>
Date: Tue, 24 Dec 2024 14:59:44 +0530
Subject: [PATCH 14/14] Work flow Added

---
 .github/workflows/gradle.yml          |   71 +-
 Dockerfile                            |    3 +-
 TMF621-Trouble_Ticket-v5.0.0.oas.yaml | 6578 +++++++++++++++++++++++++
 3 files changed, 6587 insertions(+), 65 deletions(-)
 create mode 100644 TMF621-Trouble_Ticket-v5.0.0.oas.yaml

diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 35b95d591..aecc16b10 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -15,68 +15,11 @@ jobs:
 
     steps:
     - uses: actions/checkout@v4
-
-    - name: Set up JDK 17
-      uses: actions/setup-java@v4
-      with:
-        java-version: '17'
-        distribution: 'temurin'
-
-    - name: Grant execute permission for gradlew
-      run: chmod +x gradlew
-
-    - name: Build with Gradle
-      run: |
-        ./gradlew clean
-        git clean -fd
-        ./gradlew build
-
-    - name: Fail if slf4j is found in the log
-      if: matrix.os == 'ubuntu-latest'
-      run: |
-        set +e
-        java -jar application/build/libs/specmatic.jar --version 2>&1 | grep -i slf4j
-        
-        if [ $? -eq 0 ]
-        then
-          exit 1
-        fi
-
-    - name: Upload core Gradle Log
-      if: always()
-      uses: actions/upload-artifact@v4
-      with:
-        name: Gradle core build Log on ${{ matrix.os }}
-        path: core/build/reports/
-
-    - name: Upload junit5-support Gradle Log
-      if: always()
-      uses: actions/upload-artifact@v4
-      with:
-        name: Gradle junit5-support build Log on ${{ matrix.os }}
-        path: junit5-support/build/reports/
-
-    - name: Upload application Gradle Log
-      if: always()
-      uses: actions/upload-artifact@v4
-      with:
-        name: Gradle application build Log on ${{ matrix.os }}
-        path: application/build/reports/
-
-    - name: Download release asset from example-inline-editor-module
-      uses: ncipollo/release-action@v1
-      with:
-        repository: znsio/example-inline-editor-module
-        asset_name: example-inline-editor-module-artifact.zip  # Adjust the name of the artifact
-        token: ${{ secrets.GITHUB_TOKEN }}
-        path: ./downloaded-artifact
-
-    - name: Unzip downloaded artifact
+    - name: Fetch artifact from another repository
       run: |
-        unzip ./downloaded-artifact/example-inline-editor-module-artifact.zip -d ./downloaded-artifact/  
-
-    - name: Upload unzipped artifact
-      uses: actions/upload-artifact@v4
-      with:
-        name: example-inline-editor-module-unzipped
-        path: ./downloaded-artifact/
\ No newline at end of file
+        curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
+         -H "Accept: application/vnd.github.v3+json" \
+         https://api.github.com/repos/znsio/example-inline-editor-module/actions/artifacts \
+         | jq '.artifacts[0].archive_download_url' \
+         | xargs curl -L -o artifact.zip
+        unzip artifact.zip -d ./downloaded-artifact/
diff --git a/Dockerfile b/Dockerfile
index f97dd043d..f0234d0d7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,7 +9,8 @@ RUN apk update && \
 
 # Copy the Specmatic JAR file into the container
 COPY ./application/build/libs/specmatic.jar /usr/src/app/specmatic.jar
-
+COPY ./TMF621-Trouble_Ticket-v5.0.0.oas.yaml /usr/src/app/TMF621-Trouble_Ticket-v5.0.0.oas.yaml
 # Set the entrypoint to run the Specmatic JAR
 ENTRYPOINT ["java", "-jar", "/usr/src/app/specmatic.jar"]
+CMD ["examples", "interactive", "--contract-file=TMF621-Trouble_Ticket-v5.0.0.oas.yaml"]
 
diff --git a/TMF621-Trouble_Ticket-v5.0.0.oas.yaml b/TMF621-Trouble_Ticket-v5.0.0.oas.yaml
new file mode 100644
index 000000000..6a1e6a571
--- /dev/null
+++ b/TMF621-Trouble_Ticket-v5.0.0.oas.yaml
@@ -0,0 +1,6578 @@
+openapi: 3.0.1
+info:
+  title: Trouble Ticket
+  description: "**TMF API Reference : TMF - 621 Trouble Ticket**\nThe Trouble Ticket API provides a standardized client interface to Trouble Ticket Management Systems for creating, tracking and managing trouble tickets as a result of an issue or problem identified by a customer or another system. \nExamples of Trouble Ticket API originators (clients) include CRM applications, network management or fault management systems, or other Trouble Ticket management systems (e.g. B2B).\nThe API supports the ability to send requests to create a new trouble ticket specifying the nature and severity of the trouble or issue as well as all necessary related information. The API also includes mechanisms to search for and update existing trouble tickets. Notifications are defined to provide information when a trouble ticket has been updated, including status changes. A basic set of states of a trouble ticket has been specified (as an example) to handle trouble ticket lifecycle management.\nTrouble Ticketing API manages trouble ticket resource:\n  -\tA trouble ticket represents a record, or an issue raised by requestor that need to be solved, used for reporting and managing the resolution of problems, incidents or request \n -\tMain trouble ticket attributes are its description, severity, type, related dates (creation, expected resolution, resolution), state and related information (change reason and change date), related parties (originator, owner, reviser, etc.), related entities (product, product order, customer bill) and notes \n Trouble Ticket API performs the following operations on trouble ticket: \n -\tRetrieval of a trouble ticket or a collection of trouble ticket depending on filter criteria \n -\tPartial update of a trouble ticket \n -\tCreation of a trouble ticket \n \tNotification of events on trouble ticket: \n \t-\tTrouble ticket state change \n \t-\tTrouble ticket attribute value change \n \t-\tTrouble ticket resoled \n \t-\tTrouble ticket delete (typically restricted to admin role) \n \t-\tTrouble ticket created  \n \t-\tTrouble ticket Information required \n Trouble Ticket API performs the following operations on trouble ticket specification \n-\tRetrieval of a trouble ticket specification or a collection of trouble ticket specification depending on filter criteria \n -\tPartial update of a trouble ticket specification \n-\tCreation of a trouble ticket specification \n-\tNotification of events on trouble ticket specification: \n \t-\tTrouble ticket specification state change \n \t-\tTrouble ticket specification attribute value change \n \t-\tTrouble ticket specification delete (typically restricted to admin role) \n \t-\tTrouble ticket specification created "
+  version: 5.0.0
+servers:
+  - url: '{apiRoot}/tmf-api/troubleTicket/v5/'
+    variables:
+      apiRoot:
+        default: 'https://serverRoot'
+        enum:
+          - 'https://serverRoot'
+tags:
+  - name: troubleTicket
+    description: Operations for TroubleTicket Resource
+  - name: troubleTicketSpecification
+    description: Operations for TroubleTicketSpecification Resource
+  - name: notification listener
+    description: Notifications for Resource Lifecycle and event notifications
+  - name: events subscription
+    description: Endpoints to register and terminate an Event Listener
+paths:
+  /hub:
+    post:
+      operationId: createHub
+      summary: Create a subscription (hub) to receive Events
+      description: Sets the communication endpoint to receive Events.
+      tags:
+        - events subscription
+      requestBody:
+        $ref: '#/components/requestBodies/Hub_FVO'
+      responses:
+        '201':
+          $ref: '#/components/responses/Hub'
+        default:
+          $ref: '#/components/responses/Error'
+  '/hub/{id}':
+    get:
+      operationId: hubGet
+      summary: Retrieve a subscription (hub)
+      description: ''
+      tags:
+        - events subscription
+      parameters:
+        - $ref: '#/components/parameters/Id'
+      responses:
+        '200':
+          $ref: '#/components/responses/Hub'
+        default:
+          $ref: '#/components/responses/Error'
+    delete:
+      operationId: hubDelete
+      summary: Remove a subscription (hub) to receive Events
+      description: ''
+      tags:
+        - events subscription
+      parameters:
+        - $ref: '#/components/parameters/Id'
+      responses:
+        '204':
+          description: Deleted
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketAttributeValueChangeEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketAttributeValueChangeEvent
+      description: >-
+        Example of a client listener for receiving the notification
+        TroubleTicketAttributeValueChangeEvent
+      operationId: troubleTicketAttributeValueChangeEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketAttributeValueChangeEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketCreateEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketCreateEvent
+      description: Example of a client listener for receiving the notification TroubleTicketCreateEvent
+      operationId: troubleTicketCreateEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketCreateEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketDeleteEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketDeleteEvent
+      description: Example of a client listener for receiving the notification TroubleTicketDeleteEvent
+      operationId: troubleTicketDeleteEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketDeleteEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketInformationRequiredEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketInformationRequiredEvent
+      description: >-
+        Example of a client listener for receiving the notification
+        TroubleTicketInformationRequiredEvent
+      operationId: troubleTicketInformationRequiredEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketInformationRequiredEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketResolvedEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketResolvedEvent
+      description: Example of a client listener for receiving the notification TroubleTicketResolvedEvent
+      operationId: troubleTicketResolvedEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketResolvedEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketSpecificationAttributeValueChangeEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketSpecificationAttributeValueChangeEvent
+      description: >-
+        Example of a client listener for receiving the notification
+        TroubleTicketSpecificationAttributeValueChangeEvent
+      operationId: troubleTicketSpecificationAttributeValueChangeEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketSpecificationAttributeValueChangeEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketSpecificationCreateEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketSpecificationCreateEvent
+      description: >-
+        Example of a client listener for receiving the notification
+        TroubleTicketSpecificationCreateEvent
+      operationId: troubleTicketSpecificationCreateEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketSpecificationCreateEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketSpecificationDeleteEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketSpecificationDeleteEvent
+      description: >-
+        Example of a client listener for receiving the notification
+        TroubleTicketSpecificationDeleteEvent
+      operationId: troubleTicketSpecificationDeleteEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketSpecificationDeleteEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketSpecificationStatusChangeEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketSpecificationStatusChangeEvent
+      description: >-
+        Example of a client listener for receiving the notification
+        TroubleTicketSpecificationStatusChangeEvent
+      operationId: troubleTicketSpecificationStatusChangeEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketSpecificationStatusChangeEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /listener/troubleTicketStatusChangeEvent:
+    post:
+      tags:
+        - notification listener
+      summary: Client listener for entity TroubleTicketStatusChangeEvent
+      description: Example of a client listener for receiving the notification TroubleTicketStatusChangeEvent
+      operationId: troubleTicketStatusChangeEvent
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketStatusChangeEvent'
+      responses:
+        '204':
+          description: Notified
+        default:
+          $ref: '#/components/responses/Error'
+  /troubleTicket:
+    get:
+      tags:
+        - troubleTicket
+      summary: List or find TroubleTicket objects
+      description: List or find TroubleTicket objects
+      operationId: listTroubleTicket
+      parameters:
+        - $ref: '#/components/parameters/Fields'
+        - $ref: '#/components/parameters/Offset'
+        - $ref: '#/components/parameters/Limit'
+        - $ref: '#/components/parameters/Before'
+        - $ref: '#/components/parameters/After'
+        - $ref: '#/components/parameters/Sort'
+        - $ref: '#/components/parameters/Filter'
+      responses:
+        '200':
+          $ref: '#/components/responses/200TroubleTicketArray'
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+    post:
+      tags:
+        - troubleTicket
+      summary: Creates a TroubleTicket
+      description: This operation creates a TroubleTicket entity.
+      operationId: createTroubleTicket
+      parameters:
+        - $ref: '#/components/parameters/Fields'
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicket_FVO'
+      responses:
+        '201':
+          $ref: '#/components/responses/201TroubleTicket'
+        '202':
+          description: Accepted
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '409':
+          $ref: '#/components/responses/409'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+  '/troubleTicket/{id}':
+    get:
+      tags:
+        - troubleTicket
+      summary: Retrieves a TroubleTicket by ID
+      description: >-
+        This operation retrieves a TroubleTicket entity. Attribute selection enabled for all first
+        level attributes.
+      operationId: retrieveTroubleTicket
+      parameters:
+        - $ref: '#/components/parameters/Id'
+        - $ref: '#/components/parameters/Fields'
+      responses:
+        '200':
+          $ref: '#/components/responses/200TroubleTicket_Get'
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+    patch:
+      tags:
+        - troubleTicket
+      summary: Updates partially a TroubleTicket
+      description: This operation updates partially a TroubleTicket entity.
+      operationId: patchTroubleTicket
+      parameters:
+        - $ref: '#/components/parameters/Id'
+        - $ref: '#/components/parameters/Fields'
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicket_MVO'
+      responses:
+        '200':
+          $ref: '#/components/responses/200TroubleTicket_Patch'
+        '202':
+          description: Accepted
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '409':
+          $ref: '#/components/responses/409'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+    delete:
+      tags:
+        - troubleTicket
+      summary: Deletes a TroubleTicket
+      description: This operation deletes a TroubleTicket entity.
+      operationId: deleteTroubleTicket
+      parameters:
+        - $ref: '#/components/parameters/Id'
+      responses:
+        '202':
+          $ref: '#/components/responses/202'
+        '204':
+          $ref: '#/components/responses/204'
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '409':
+          $ref: '#/components/responses/409'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+  /troubleTicketSpecification:
+    get:
+      tags:
+        - troubleTicketSpecification
+      summary: List or find TroubleTicketSpecification objects
+      description: List or find TroubleTicketSpecification objects
+      operationId: listTroubleTicketSpecification
+      parameters:
+        - $ref: '#/components/parameters/Fields'
+        - $ref: '#/components/parameters/Offset'
+        - $ref: '#/components/parameters/Limit'
+        - $ref: '#/components/parameters/Before'
+        - $ref: '#/components/parameters/After'
+        - $ref: '#/components/parameters/Sort'
+        - $ref: '#/components/parameters/Filter'
+      responses:
+        '200':
+          $ref: '#/components/responses/200TroubleTicketSpecificationArray'
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+    post:
+      tags:
+        - troubleTicketSpecification
+      summary: Creates a TroubleTicketSpecification
+      description: This operation creates a TroubleTicketSpecification entity.
+      operationId: createTroubleTicketSpecification
+      parameters:
+        - $ref: '#/components/parameters/Fields'
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketSpecification_FVO'
+      responses:
+        '201':
+          $ref: '#/components/responses/201TroubleTicketSpecification'
+        '202':
+          description: Accepted
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '409':
+          $ref: '#/components/responses/409'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+  '/troubleTicketSpecification/{id}':
+    get:
+      tags:
+        - troubleTicketSpecification
+      summary: Retrieves a TroubleTicketSpecification by ID
+      description: >-
+        This operation retrieves a TroubleTicketSpecification entity. Attribute selection enabled
+        for all first level attributes.
+      operationId: retrieveTroubleTicketSpecification
+      parameters:
+        - $ref: '#/components/parameters/Id'
+        - $ref: '#/components/parameters/Fields'
+      responses:
+        '200':
+          $ref: '#/components/responses/200TroubleTicketSpecification_Get'
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+    patch:
+      tags:
+        - troubleTicketSpecification
+      summary: Updates partially a TroubleTicketSpecification
+      description: This operation updates partially a TroubleTicketSpecification entity.
+      operationId: patchTroubleTicketSpecification
+      parameters:
+        - $ref: '#/components/parameters/Id'
+        - $ref: '#/components/parameters/Fields'
+      requestBody:
+        $ref: '#/components/requestBodies/TroubleTicketSpecification_MVO'
+      responses:
+        '200':
+          $ref: '#/components/responses/200TroubleTicketSpecification_Patch'
+        '202':
+          description: Accepted
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '409':
+          $ref: '#/components/responses/409'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+    delete:
+      tags:
+        - troubleTicketSpecification
+      summary: Deletes a TroubleTicketSpecification
+      description: This operation deletes a TroubleTicketSpecification entity.
+      operationId: deleteTroubleTicketSpecification
+      parameters:
+        - $ref: '#/components/parameters/Id'
+      responses:
+        '202':
+          $ref: '#/components/responses/202'
+        '204':
+          $ref: '#/components/responses/204'
+        '400':
+          $ref: '#/components/responses/400'
+        '401':
+          $ref: '#/components/responses/401'
+        '403':
+          $ref: '#/components/responses/403'
+        '404':
+          $ref: '#/components/responses/404'
+        '405':
+          $ref: '#/components/responses/405'
+        '409':
+          $ref: '#/components/responses/409'
+        '500':
+          $ref: '#/components/responses/500'
+        '501':
+          $ref: '#/components/responses/501'
+        '503':
+          $ref: '#/components/responses/503'
+components:
+  schemas:
+    Addressable:
+      type: object
+      description: Base schema for addressable entities
+      properties:
+        href:
+          type: string
+          description: Hyperlink reference
+        id:
+          type: string
+          description: unique identifier
+    Attachment:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            Complements the description of an element (for instance a product) through video,
+            pictures...
+          properties:
+            name:
+              type: string
+              description: The name of the attachment
+            description:
+              type: string
+              description: A narrative text describing the content of the attachment
+              example: Photograph of the Product
+            url:
+              type: string
+              description: 'Uniform Resource Locator, is a web page address (a subset of URI)'
+              example: 'https://host/Content/4aafacbd-11ff-4dc8-b445-305f2215715f'
+            content:
+              type: string
+              format: base64
+              description: 'The actual contents of the attachment object, if embedded, encoded as base64'
+            size:
+              $ref: '#/components/schemas/Quantity'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            attachmentType:
+              type: string
+              description: >-
+                a business characterization of the purpose of the attachment, for example logo,
+                instructionManual, contractCopy
+            mimeType:
+              type: string
+              description: a technical characterization of the attachment content format using IETF Mime Types
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Attachment: '#/components/schemas/Attachment'
+    AttachmentRef:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: >-
+            Attachment reference. An attachment complements the description of an element (for
+            instance a product) through video, pictures
+          properties:
+            description:
+              type: string
+              description: A narrative text describing the content of the attachment
+            url:
+              description: Link to the attachment media/content
+              type: string
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          AttachmentRef: '#/components/schemas/AttachmentRef'
+    AttachmentRefOrValue:
+      type: object
+      description: >-
+        The polymorphic attributes @type, @schemaLocation & @referredType are related to the
+        Attachment entity and not the AttachmentRefOrValue class itself
+      oneOf:
+        - $ref: '#/components/schemas/Attachment'
+        - $ref: '#/components/schemas/AttachmentRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Attachment: '#/components/schemas/Attachment'
+          AttachmentRef: '#/components/schemas/AttachmentRef'
+    AttachmentRefOrValue_FVO:
+      type: object
+      description: >-
+        The polymorphic attributes @type, @schemaLocation & @referredType are related to the
+        Attachment entity and not the AttachmentRefOrValue class itself
+      oneOf:
+        - $ref: '#/components/schemas/Attachment_FVO'
+        - $ref: '#/components/schemas/AttachmentRef_FVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Attachment: '#/components/schemas/Attachment_FVO'
+          AttachmentRef: '#/components/schemas/AttachmentRef_FVO'
+    AttachmentRefOrValue_MVO:
+      type: object
+      description: >-
+        The polymorphic attributes @type, @schemaLocation & @referredType are related to the
+        Attachment entity and not the AttachmentRefOrValue class itself
+      oneOf:
+        - $ref: '#/components/schemas/Attachment_MVO'
+        - $ref: '#/components/schemas/AttachmentRef_MVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Attachment: '#/components/schemas/Attachment_MVO'
+          AttachmentRef: '#/components/schemas/AttachmentRef_MVO'
+    AttachmentRef_FVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: >-
+            Attachment reference. An attachment complements the description of an element (for
+            instance a product) through video, pictures
+          properties:
+            description:
+              type: string
+              description: A narrative text describing the content of the attachment
+            url:
+              description: Link to the attachment media/content
+              type: string
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          AttachmentRef: '#/components/schemas/AttachmentRef_FVO'
+    AttachmentRef_MVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef_MVO'
+        - type: object
+          description: >-
+            Attachment reference. An attachment complements the description of an element (for
+            instance a product) through video, pictures
+          properties:
+            description:
+              type: string
+              description: A narrative text describing the content of the attachment
+            url:
+              description: Link to the attachment media/content
+              type: string
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          AttachmentRef: '#/components/schemas/AttachmentRef_MVO'
+    Attachment_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            Complements the description of an element (for instance a product) through video,
+            pictures...
+          properties:
+            name:
+              type: string
+              description: The name of the attachment
+            description:
+              type: string
+              description: A narrative text describing the content of the attachment
+              example: Photograph of the Product
+            url:
+              type: string
+              description: 'Uniform Resource Locator, is a web page address (a subset of URI)'
+              example: 'https://host/Content/4aafacbd-11ff-4dc8-b445-305f2215715f'
+            content:
+              type: string
+              format: base64
+              description: 'The actual contents of the attachment object, if embedded, encoded as base64'
+            size:
+              $ref: '#/components/schemas/Quantity'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            attachmentType:
+              type: string
+              description: >-
+                a business characterization of the purpose of the attachment, for example logo,
+                instructionManual, contractCopy
+            mimeType:
+              type: string
+              description: a technical characterization of the attachment content format using IETF Mime Types
+          required:
+            - attachmentType
+            - mimeType
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Attachment: '#/components/schemas/Attachment_FVO'
+    Attachment_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            Complements the description of an element (for instance a product) through video,
+            pictures...
+          properties:
+            name:
+              type: string
+              description: The name of the attachment
+            description:
+              type: string
+              description: A narrative text describing the content of the attachment
+              example: Photograph of the Product
+            url:
+              type: string
+              description: 'Uniform Resource Locator, is a web page address (a subset of URI)'
+              example: 'https://host/Content/4aafacbd-11ff-4dc8-b445-305f2215715f'
+            content:
+              type: string
+              format: base64
+              description: 'The actual contents of the attachment object, if embedded, encoded as base64'
+            size:
+              $ref: '#/components/schemas/Quantity'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            attachmentType:
+              type: string
+              description: >-
+                a business characterization of the purpose of the attachment, for example logo,
+                instructionManual, contractCopy
+            mimeType:
+              type: string
+              description: a technical characterization of the attachment content format using IETF Mime Types
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Attachment: '#/components/schemas/Attachment_MVO'
+    BaseEvent:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: Base event with common attributes.
+          properties:
+            event:
+              type: object
+              description: The event linked to the involved resource object
+            eventId:
+              type: string
+              description: The identifier of the notification.
+            eventTime:
+              type: string
+              format: date-time
+              description: Time of the event occurrence.
+            eventType:
+              type: string
+              description: The type of the notification.
+            correlationId:
+              type: string
+              description: The correlation id for this event.
+            domain:
+              type: string
+              description: The domain of the event.
+            title:
+              type: string
+              description: The title of the event.
+            description:
+              type: string
+              description: An explanatory of the event.
+            priority:
+              type: string
+              description: A priority.
+            timeOcurred:
+              type: string
+              format: date-time
+              description: The time the event occurred.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          BaseEvent: '#/components/schemas/BaseEvent'
+    BooleanArrayCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is an array of Boolean(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Boolean(s).
+              items:
+                type: boolean
+                description: Characteristic item boolean value
+    BooleanArrayCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is an array booleans
+          properties:
+            value:
+              type: array
+              items:
+                type: boolean
+                description: Characteristic specification item boolean value
+    BooleanArrayCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array booleans
+          properties:
+            value:
+              type: array
+              items:
+                type: boolean
+                description: Characteristic specification item boolean value
+    BooleanArrayCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array booleans
+          properties:
+            value:
+              type: array
+              items:
+                type: boolean
+                description: Characteristic specification item boolean value
+    BooleanArrayCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is an array of Boolean(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Boolean(s).
+              items:
+                type: boolean
+                description: Characteristic item boolean value
+          required:
+            - value
+    BooleanArrayCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is an array of Boolean(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Boolean(s).
+              items:
+                type: boolean
+                description: Characteristic item boolean value
+    BooleanCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is a Boolean.
+          properties:
+            value:
+              type: boolean
+              description: Value of the characteristic
+    BooleanCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is a boolean
+          properties:
+            value:
+              type: boolean
+              description: Value of the characteristic
+    BooleanCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a boolean
+          properties:
+            value:
+              type: boolean
+              description: Value of the characteristic
+    BooleanCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a boolean
+          properties:
+            value:
+              type: boolean
+              description: Value of the characteristic
+    BooleanCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is a Boolean.
+          properties:
+            value:
+              type: boolean
+              description: Value of the characteristic
+          required:
+            - value
+    BooleanCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is a Boolean.
+          properties:
+            value:
+              type: boolean
+              description: Value of the characteristic
+    ChannelRef:
+      type: object
+      description: >-
+        The channel to which the resource reference to. e.g. channel for selling product offerings,
+        channel for opening a trouble ticket etc..
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          ChannelRef: '#/components/schemas/ChannelRef'
+    ChannelRef_FVO:
+      type: object
+      description: >-
+        The channel to which the resource reference to. e.g. channel for selling product offerings,
+        channel for opening a trouble ticket etc..
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          ChannelRef: '#/components/schemas/ChannelRef_FVO'
+    ChannelRef_MVO:
+      type: object
+      description: >-
+        The channel to which the resource reference to. e.g. channel for selling product offerings,
+        channel for opening a trouble ticket etc..
+      allOf:
+        - $ref: '#/components/schemas/EntityRef_MVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          ChannelRef: '#/components/schemas/ChannelRef_MVO'
+    Characteristic:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            Describes a given characteristic of an object or entity through a name/value pair. This
+            is an abstract base class, the actual value is in one of the strongly-typed subclasses :
+            StringCharacteristic, ObjectCharacteristic, FloatCharacteristic, BooleanCharacteristic,
+            NumberCharacteristic, IntegerCharacteristic, StringArrayCharacteristic,
+            ObjectArrayCharacteristic, BooleanArrayCharacteristic, NumberArrayCharacteristic,
+            IntegerArrayCharacteristic...
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the characteristic
+            name:
+              type: string
+              description: Name of the characteristic
+            valueType:
+              type: string
+              description: Data type of the value of the characteristic
+            characteristicRelationship:
+              type: array
+              description: Collection of characteristic relationships
+              items:
+                $ref: '#/components/schemas/CharacteristicRelationship'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          BooleanArrayCharacteristic: '#/components/schemas/BooleanArrayCharacteristic'
+          BooleanCharacteristic: '#/components/schemas/BooleanCharacteristic'
+          Characteristic: '#/components/schemas/Characteristic'
+          FloatCharacteristic: '#/components/schemas/FloatCharacteristic'
+          IntegerArrayCharacteristic: '#/components/schemas/IntegerArrayCharacteristic'
+          IntegerCharacteristic: '#/components/schemas/IntegerCharacteristic'
+          NumberArrayCharacteristic: '#/components/schemas/NumberArrayCharacteristic'
+          NumberCharacteristic: '#/components/schemas/NumberCharacteristic'
+          ObjectArrayCharacteristic: '#/components/schemas/ObjectArrayCharacteristic'
+          ObjectCharacteristic: '#/components/schemas/ObjectCharacteristic'
+          StringArrayCharacteristic: '#/components/schemas/StringArrayCharacteristic'
+          StringCharacteristic: '#/components/schemas/StringCharacteristic'
+    CharacteristicRelationship:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: Another Characteristic that is related to the current Characteristic;
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the characteristic
+            relationshipType:
+              type: string
+              description: The type of relationship
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicRelationship: '#/components/schemas/CharacteristicRelationship'
+    CharacteristicRelationship_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: Another Characteristic that is related to the current Characteristic;
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the characteristic
+            relationshipType:
+              type: string
+              description: The type of relationship
+          required:
+            - id
+            - relationshipType
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicRelationship: '#/components/schemas/CharacteristicRelationship_FVO'
+    CharacteristicRelationship_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: Another Characteristic that is related to the current Characteristic;
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the characteristic
+            relationshipType:
+              type: string
+              description: The type of relationship
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicRelationship: '#/components/schemas/CharacteristicRelationship_MVO'
+    CharacteristicSpecification:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: This class defines a characteristic specification.
+          properties:
+            id:
+              type: string
+              description: Unique ID for the characteristic
+            name:
+              type: string
+              description: >-
+                A word, term, or phrase by which this characteristic specification is known and
+                distinguished from other characteristic specifications.
+            valueType:
+              type: string
+              description: >-
+                A kind of value that the characteristic can take on, such as numeric, text and so
+                forth
+            description:
+              type: string
+              description: A narrative that explains the CharacteristicSpecification.
+            configurable:
+              type: boolean
+              description: 'If true, the Boolean indicates that the target Characteristic is configurable'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            minCardinality:
+              type: integer
+              description: >-
+                The minimum number of instances a CharacteristicValue can take on. For example, zero
+                to five phone numbers in a group calling plan, where zero is the value for the
+                minCardinality.
+            maxCardinality:
+              type: integer
+              description: >-
+                The maximum number of instances a CharacteristicValue can take on. For example, zero
+                to five phone numbers in a group calling plan, where five is the value for the
+                maxCardinality.
+            isUnique:
+              type: boolean
+              description: >-
+                Specifies if the value of this characteristic is unique across all entities
+                instantiated from the specification that uses this characteristic. For example,
+                consider a ProductSpecification for a set-top box, with a
+                CharacteristicSpecification cardID. Each set-top box must have a different value for
+                cardID, so this isUnique attribute would be set to true for the characteristic.
+            regex:
+              type: string
+              description: >-
+                A rule or principle represented in regular expression used to derive the value of a
+                characteristic value.
+            extensible:
+              type: boolean
+              description: >-
+                An indicator that specifies that the values for the characteristic can be extended
+                by adding new values when instantiating a characteristic for a resource.
+            '@valueSchemaLocation':
+              type: string
+              description: This (optional) field provides a link to the schema describing the value type.
+            charSpecRelationship:
+              type: array
+              items:
+                $ref: '#/components/schemas/CharacteristicSpecificationRelationship'
+              description: >-
+                An aggregation, migration, substitution, dependency or exclusivity relationship
+                between/among Specification Characteristics.
+            characteristicValueSpecification:
+              type: array
+              items:
+                $ref: '#/components/schemas/CharacteristicValueSpecification'
+              description: >-
+                A CharacteristicValueSpecification object is used to define a set of attributes,
+                each of which can be assigned to a corresponding set of attributes in a
+                CharacteristicSpecification object. The values of the attributes in the
+                CharacteristicValueSpecification object describe the values of the attributes that a
+                corresponding Characteristic object can take on.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicSpecification: '#/components/schemas/CharacteristicSpecification'
+    CharacteristicSpecificationRelationship:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            An aggregation, migration, substitution, dependency or exclusivity relationship
+            between/among Characteristic specifications. The specification characteristic is
+            embedded within the specification whose ID and href are in this entity, and identified
+            by its ID.
+          properties:
+            relationshipType:
+              type: string
+              description: >-
+                Type of relationship such as aggregation, migration, substitution, dependency,
+                exclusivity
+            name:
+              type: string
+              description: Name of the target characteristic within the specification
+            characteristicSpecificationId:
+              type: string
+              description: Unique identifier of the characteristic within the specification
+            parentSpecificationHref:
+              type: string
+              format: uri
+              description: Hyperlink reference to the parent specification containing the target characteristic
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            parentSpecificationId:
+              type: string
+              description: Unique identifier of the parent specification containing the target characteristic
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicSpecificationRelationship: '#/components/schemas/CharacteristicSpecificationRelationship'
+    CharacteristicSpecificationRelationship_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            An aggregation, migration, substitution, dependency or exclusivity relationship
+            between/among Characteristic specifications. The specification characteristic is
+            embedded within the specification whose ID and href are in this entity, and identified
+            by its ID.
+          properties:
+            relationshipType:
+              type: string
+              description: >-
+                Type of relationship such as aggregation, migration, substitution, dependency,
+                exclusivity
+            name:
+              type: string
+              description: Name of the target characteristic within the specification
+            characteristicSpecificationId:
+              type: string
+              description: Unique identifier of the characteristic within the specification
+            parentSpecificationHref:
+              type: string
+              format: uri
+              description: Hyperlink reference to the parent specification containing the target characteristic
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            parentSpecificationId:
+              type: string
+              description: Unique identifier of the parent specification containing the target characteristic
+          required:
+            - parentSpecificationId
+            - name
+            - relationshipType
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicSpecificationRelationship: '#/components/schemas/CharacteristicSpecificationRelationship_FVO'
+    CharacteristicSpecificationRelationship_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            An aggregation, migration, substitution, dependency or exclusivity relationship
+            between/among Characteristic specifications. The specification characteristic is
+            embedded within the specification whose ID and href are in this entity, and identified
+            by its ID.
+          properties:
+            relationshipType:
+              type: string
+              description: >-
+                Type of relationship such as aggregation, migration, substitution, dependency,
+                exclusivity
+            name:
+              type: string
+              description: Name of the target characteristic within the specification
+            characteristicSpecificationId:
+              type: string
+              description: Unique identifier of the characteristic within the specification
+            parentSpecificationHref:
+              type: string
+              format: uri
+              description: Hyperlink reference to the parent specification containing the target characteristic
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            parentSpecificationId:
+              type: string
+              description: Unique identifier of the parent specification containing the target characteristic
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicSpecificationRelationship: '#/components/schemas/CharacteristicSpecificationRelationship_MVO'
+    CharacteristicSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: This class defines a characteristic specification.
+          properties:
+            id:
+              type: string
+              description: Unique ID for the characteristic
+            name:
+              type: string
+              description: >-
+                A word, term, or phrase by which this characteristic specification is known and
+                distinguished from other characteristic specifications.
+            valueType:
+              type: string
+              description: >-
+                A kind of value that the characteristic can take on, such as numeric, text and so
+                forth
+            description:
+              type: string
+              description: A narrative that explains the CharacteristicSpecification.
+            configurable:
+              type: boolean
+              description: 'If true, the Boolean indicates that the target Characteristic is configurable'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            minCardinality:
+              type: integer
+              description: >-
+                The minimum number of instances a CharacteristicValue can take on. For example, zero
+                to five phone numbers in a group calling plan, where zero is the value for the
+                minCardinality.
+            maxCardinality:
+              type: integer
+              description: >-
+                The maximum number of instances a CharacteristicValue can take on. For example, zero
+                to five phone numbers in a group calling plan, where five is the value for the
+                maxCardinality.
+            isUnique:
+              type: boolean
+              description: >-
+                Specifies if the value of this characteristic is unique across all entities
+                instantiated from the specification that uses this characteristic. For example,
+                consider a ProductSpecification for a set-top box, with a
+                CharacteristicSpecification cardID. Each set-top box must have a different value for
+                cardID, so this isUnique attribute would be set to true for the characteristic.
+            regex:
+              type: string
+              description: >-
+                A rule or principle represented in regular expression used to derive the value of a
+                characteristic value.
+            extensible:
+              type: boolean
+              description: >-
+                An indicator that specifies that the values for the characteristic can be extended
+                by adding new values when instantiating a characteristic for a resource.
+            '@valueSchemaLocation':
+              type: string
+              description: This (optional) field provides a link to the schema describing the value type.
+            charSpecRelationship:
+              type: array
+              items:
+                $ref: '#/components/schemas/CharacteristicSpecificationRelationship_FVO'
+              description: >-
+                An aggregation, migration, substitution, dependency or exclusivity relationship
+                between/among Specification Characteristics.
+            characteristicValueSpecification:
+              type: array
+              items:
+                $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+              description: >-
+                A CharacteristicValueSpecification object is used to define a set of attributes,
+                each of which can be assigned to a corresponding set of attributes in a
+                CharacteristicSpecification object. The values of the attributes in the
+                CharacteristicValueSpecification object describe the values of the attributes that a
+                corresponding Characteristic object can take on.
+          required:
+            - name
+            - valueType
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicSpecification: '#/components/schemas/CharacteristicSpecification_FVO'
+    CharacteristicSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: This class defines a characteristic specification.
+          properties:
+            id:
+              type: string
+              description: Unique ID for the characteristic
+            name:
+              type: string
+              description: >-
+                A word, term, or phrase by which this characteristic specification is known and
+                distinguished from other characteristic specifications.
+            valueType:
+              type: string
+              description: >-
+                A kind of value that the characteristic can take on, such as numeric, text and so
+                forth
+            description:
+              type: string
+              description: A narrative that explains the CharacteristicSpecification.
+            configurable:
+              type: boolean
+              description: 'If true, the Boolean indicates that the target Characteristic is configurable'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            minCardinality:
+              type: integer
+              description: >-
+                The minimum number of instances a CharacteristicValue can take on. For example, zero
+                to five phone numbers in a group calling plan, where zero is the value for the
+                minCardinality.
+            maxCardinality:
+              type: integer
+              description: >-
+                The maximum number of instances a CharacteristicValue can take on. For example, zero
+                to five phone numbers in a group calling plan, where five is the value for the
+                maxCardinality.
+            isUnique:
+              type: boolean
+              description: >-
+                Specifies if the value of this characteristic is unique across all entities
+                instantiated from the specification that uses this characteristic. For example,
+                consider a ProductSpecification for a set-top box, with a
+                CharacteristicSpecification cardID. Each set-top box must have a different value for
+                cardID, so this isUnique attribute would be set to true for the characteristic.
+            regex:
+              type: string
+              description: >-
+                A rule or principle represented in regular expression used to derive the value of a
+                characteristic value.
+            extensible:
+              type: boolean
+              description: >-
+                An indicator that specifies that the values for the characteristic can be extended
+                by adding new values when instantiating a characteristic for a resource.
+            '@valueSchemaLocation':
+              type: string
+              description: This (optional) field provides a link to the schema describing the value type.
+            charSpecRelationship:
+              type: array
+              items:
+                $ref: '#/components/schemas/CharacteristicSpecificationRelationship_MVO'
+              description: >-
+                An aggregation, migration, substitution, dependency or exclusivity relationship
+                between/among Specification Characteristics.
+            characteristicValueSpecification:
+              type: array
+              items:
+                $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+              description: >-
+                A CharacteristicValueSpecification object is used to define a set of attributes,
+                each of which can be assigned to a corresponding set of attributes in a
+                CharacteristicSpecification object. The values of the attributes in the
+                CharacteristicValueSpecification object describe the values of the attributes that a
+                corresponding Characteristic object can take on.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          CharacteristicSpecification: '#/components/schemas/CharacteristicSpecification_MVO'
+    CharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            specification of a value (number or text or an object) that can be assigned to a
+            Characteristic. This is an abstract base class, the actual value is in one of the
+            strongly-typed subclasses : BooleanArrayCharacteristicValueSpecification,
+            BooleanCharacteristicValueSpecification, FloatArrayCharacteristicValueSpecification,
+            FloatCharacteristicValueSpecification, IntegerArrayCharacteristicValueSpecification,
+            IntegerCharacteristicValueSpecification, MapArrayCharacteristicValueSpecification,
+            MapCharacteristicValueSpecification, NumberArrayCharacteristicValueSpecification,
+            NumberCharacteristicValueSpecification, ObjectArrayCharacteristicValueSpecification,
+            ObjectCharacteristicValueSpecification, StringArrayCharacteristicValueSpecification,
+            StringCharacteristicValueSpecification...
+          properties:
+            valueType:
+              type: string
+              description: >-
+                A kind of value that the characteristic value can take on, such as numeric, text and
+                so forth
+            isDefault:
+              type: boolean
+              description: >-
+                If true, the Boolean Indicates if the value is the default value for a
+                characteristic
+            unitOfMeasure:
+              type: string
+              description: >-
+                A length, surface, volume, dry measure, liquid measure, money, weight, time, and the
+                like. In general, a determinate quantity or magnitude of the kind designated, taken
+                as a standard of comparison for others of the same kind, in assigning to them
+                numerical values, as 1 foot, 1 yard, 1 mile, 1 square foot.
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            valueFrom:
+              type: integer
+              description: The low range value that a characteristic can take on
+            valueTo:
+              type: integer
+              description: The upper range value that a characteristic can take on
+            rangeInterval:
+              type: string
+              description: >-
+                An indicator that specifies the inclusion or exclusion of the valueFrom and valueTo
+                attributes. If applicable, possible values are "open", "closed", "closedBottom" and
+                "closedTop".
+            regex:
+              type: string
+              description: A regular expression constraint for given value
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          BooleanArrayCharacteristicValueSpecification: '#/components/schemas/BooleanArrayCharacteristicValueSpecification'
+          BooleanCharacteristicValueSpecification: '#/components/schemas/BooleanCharacteristicValueSpecification'
+          CharacteristicValueSpecification: '#/components/schemas/CharacteristicValueSpecification'
+          FloatArrayCharacteristicValueSpecification: '#/components/schemas/FloatArrayCharacteristicValueSpecification'
+          FloatCharacteristicValueSpecification: '#/components/schemas/FloatCharacteristicValueSpecification'
+          IntegerArrayCharacteristicValueSpecification: '#/components/schemas/IntegerArrayCharacteristicValueSpecification'
+          IntegerCharacteristicValueSpecification: '#/components/schemas/IntegerCharacteristicValueSpecification'
+          MapArrayCharacteristicValueSpecification: '#/components/schemas/MapArrayCharacteristicValueSpecification'
+          MapCharacteristicValueSpecification: '#/components/schemas/MapCharacteristicValueSpecification'
+          NumberArrayCharacteristicValueSpecification: '#/components/schemas/NumberArrayCharacteristicValueSpecification'
+          NumberCharacteristicValueSpecification: '#/components/schemas/NumberCharacteristicValueSpecification'
+          ObjectArrayCharacteristicValueSpecification: '#/components/schemas/ObjectArrayCharacteristicValueSpecification'
+          ObjectCharacteristicValueSpecification: '#/components/schemas/ObjectCharacteristicValueSpecification'
+          StringArrayCharacteristicValueSpecification: '#/components/schemas/StringArrayCharacteristicValueSpecification'
+          StringCharacteristicValueSpecification: '#/components/schemas/StringCharacteristicValueSpecification'
+    CharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            specification of a value (number or text or an object) that can be assigned to a
+            Characteristic. This is an abstract base class, the actual value is in one of the
+            strongly-typed subclasses : BooleanArrayCharacteristicValueSpecification,
+            BooleanCharacteristicValueSpecification, FloatArrayCharacteristicValueSpecification,
+            FloatCharacteristicValueSpecification, IntegerArrayCharacteristicValueSpecification,
+            IntegerCharacteristicValueSpecification, MapArrayCharacteristicValueSpecification,
+            MapCharacteristicValueSpecification, NumberArrayCharacteristicValueSpecification,
+            NumberCharacteristicValueSpecification, ObjectArrayCharacteristicValueSpecification,
+            ObjectCharacteristicValueSpecification, StringArrayCharacteristicValueSpecification,
+            StringCharacteristicValueSpecification...
+          properties:
+            valueType:
+              type: string
+              description: >-
+                A kind of value that the characteristic value can take on, such as numeric, text and
+                so forth
+            isDefault:
+              type: boolean
+              description: >-
+                If true, the Boolean Indicates if the value is the default value for a
+                characteristic
+            unitOfMeasure:
+              type: string
+              description: >-
+                A length, surface, volume, dry measure, liquid measure, money, weight, time, and the
+                like. In general, a determinate quantity or magnitude of the kind designated, taken
+                as a standard of comparison for others of the same kind, in assigning to them
+                numerical values, as 1 foot, 1 yard, 1 mile, 1 square foot.
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            valueFrom:
+              type: integer
+              description: The low range value that a characteristic can take on
+            valueTo:
+              type: integer
+              description: The upper range value that a characteristic can take on
+            rangeInterval:
+              type: string
+              description: >-
+                An indicator that specifies the inclusion or exclusion of the valueFrom and valueTo
+                attributes. If applicable, possible values are "open", "closed", "closedBottom" and
+                "closedTop".
+            regex:
+              type: string
+              description: A regular expression constraint for given value
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          BooleanArrayCharacteristicValueSpecification: '#/components/schemas/BooleanArrayCharacteristicValueSpecification_FVO'
+          BooleanCharacteristicValueSpecification: '#/components/schemas/BooleanCharacteristicValueSpecification_FVO'
+          CharacteristicValueSpecification: '#/components/schemas/CharacteristicValueSpecification_FVO'
+          FloatArrayCharacteristicValueSpecification: '#/components/schemas/FloatArrayCharacteristicValueSpecification_FVO'
+          FloatCharacteristicValueSpecification: '#/components/schemas/FloatCharacteristicValueSpecification_FVO'
+          IntegerArrayCharacteristicValueSpecification: '#/components/schemas/IntegerArrayCharacteristicValueSpecification_FVO'
+          IntegerCharacteristicValueSpecification: '#/components/schemas/IntegerCharacteristicValueSpecification_FVO'
+          MapArrayCharacteristicValueSpecification: '#/components/schemas/MapArrayCharacteristicValueSpecification_FVO'
+          MapCharacteristicValueSpecification: '#/components/schemas/MapCharacteristicValueSpecification_FVO'
+          NumberArrayCharacteristicValueSpecification: '#/components/schemas/NumberArrayCharacteristicValueSpecification_FVO'
+          NumberCharacteristicValueSpecification: '#/components/schemas/NumberCharacteristicValueSpecification_FVO'
+          ObjectArrayCharacteristicValueSpecification: '#/components/schemas/ObjectArrayCharacteristicValueSpecification_FVO'
+          ObjectCharacteristicValueSpecification: '#/components/schemas/ObjectCharacteristicValueSpecification_FVO'
+          StringArrayCharacteristicValueSpecification: '#/components/schemas/StringArrayCharacteristicValueSpecification_FVO'
+          StringCharacteristicValueSpecification: '#/components/schemas/StringCharacteristicValueSpecification_FVO'
+    CharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            specification of a value (number or text or an object) that can be assigned to a
+            Characteristic. This is an abstract base class, the actual value is in one of the
+            strongly-typed subclasses : BooleanArrayCharacteristicValueSpecification,
+            BooleanCharacteristicValueSpecification, FloatArrayCharacteristicValueSpecification,
+            FloatCharacteristicValueSpecification, IntegerArrayCharacteristicValueSpecification,
+            IntegerCharacteristicValueSpecification, MapArrayCharacteristicValueSpecification,
+            MapCharacteristicValueSpecification, NumberArrayCharacteristicValueSpecification,
+            NumberCharacteristicValueSpecification, ObjectArrayCharacteristicValueSpecification,
+            ObjectCharacteristicValueSpecification, StringArrayCharacteristicValueSpecification,
+            StringCharacteristicValueSpecification...
+          properties:
+            valueType:
+              type: string
+              description: >-
+                A kind of value that the characteristic value can take on, such as numeric, text and
+                so forth
+            isDefault:
+              type: boolean
+              description: >-
+                If true, the Boolean Indicates if the value is the default value for a
+                characteristic
+            unitOfMeasure:
+              type: string
+              description: >-
+                A length, surface, volume, dry measure, liquid measure, money, weight, time, and the
+                like. In general, a determinate quantity or magnitude of the kind designated, taken
+                as a standard of comparison for others of the same kind, in assigning to them
+                numerical values, as 1 foot, 1 yard, 1 mile, 1 square foot.
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            valueFrom:
+              type: integer
+              description: The low range value that a characteristic can take on
+            valueTo:
+              type: integer
+              description: The upper range value that a characteristic can take on
+            rangeInterval:
+              type: string
+              description: >-
+                An indicator that specifies the inclusion or exclusion of the valueFrom and valueTo
+                attributes. If applicable, possible values are "open", "closed", "closedBottom" and
+                "closedTop".
+            regex:
+              type: string
+              description: A regular expression constraint for given value
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          BooleanArrayCharacteristicValueSpecification: '#/components/schemas/BooleanArrayCharacteristicValueSpecification_MVO'
+          BooleanCharacteristicValueSpecification: '#/components/schemas/BooleanCharacteristicValueSpecification_MVO'
+          CharacteristicValueSpecification: '#/components/schemas/CharacteristicValueSpecification_MVO'
+          FloatArrayCharacteristicValueSpecification: '#/components/schemas/FloatArrayCharacteristicValueSpecification_MVO'
+          FloatCharacteristicValueSpecification: '#/components/schemas/FloatCharacteristicValueSpecification_MVO'
+          IntegerArrayCharacteristicValueSpecification: '#/components/schemas/IntegerArrayCharacteristicValueSpecification_MVO'
+          IntegerCharacteristicValueSpecification: '#/components/schemas/IntegerCharacteristicValueSpecification_MVO'
+          MapArrayCharacteristicValueSpecification: '#/components/schemas/MapArrayCharacteristicValueSpecification_MVO'
+          MapCharacteristicValueSpecification: '#/components/schemas/MapCharacteristicValueSpecification_MVO'
+          NumberArrayCharacteristicValueSpecification: '#/components/schemas/NumberArrayCharacteristicValueSpecification_MVO'
+          NumberCharacteristicValueSpecification: '#/components/schemas/NumberCharacteristicValueSpecification_MVO'
+          ObjectArrayCharacteristicValueSpecification: '#/components/schemas/ObjectArrayCharacteristicValueSpecification_MVO'
+          ObjectCharacteristicValueSpecification: '#/components/schemas/ObjectCharacteristicValueSpecification_MVO'
+          StringArrayCharacteristicValueSpecification: '#/components/schemas/StringArrayCharacteristicValueSpecification_MVO'
+          StringCharacteristicValueSpecification: '#/components/schemas/StringCharacteristicValueSpecification_MVO'
+    Characteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            Describes a given characteristic of an object or entity through a name/value pair. This
+            is an abstract base class, the actual value is in one of the strongly-typed subclasses :
+            StringCharacteristic, ObjectCharacteristic, FloatCharacteristic, BooleanCharacteristic,
+            NumberCharacteristic, IntegerCharacteristic, StringArrayCharacteristic,
+            ObjectArrayCharacteristic, BooleanArrayCharacteristic, NumberArrayCharacteristic,
+            IntegerArrayCharacteristic...
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the characteristic
+            name:
+              type: string
+              description: Name of the characteristic
+            valueType:
+              type: string
+              description: Data type of the value of the characteristic
+            characteristicRelationship:
+              type: array
+              description: Collection of characteristic relationships
+              items:
+                $ref: '#/components/schemas/CharacteristicRelationship_FVO'
+          required:
+            - name
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          BooleanArrayCharacteristic: '#/components/schemas/BooleanArrayCharacteristic_FVO'
+          BooleanCharacteristic: '#/components/schemas/BooleanCharacteristic_FVO'
+          Characteristic: '#/components/schemas/Characteristic_FVO'
+          FloatCharacteristic: '#/components/schemas/FloatCharacteristic_FVO'
+          IntegerArrayCharacteristic: '#/components/schemas/IntegerArrayCharacteristic_FVO'
+          IntegerCharacteristic: '#/components/schemas/IntegerCharacteristic_FVO'
+          NumberArrayCharacteristic: '#/components/schemas/NumberArrayCharacteristic_FVO'
+          NumberCharacteristic: '#/components/schemas/NumberCharacteristic_FVO'
+          ObjectArrayCharacteristic: '#/components/schemas/ObjectArrayCharacteristic_FVO'
+          ObjectCharacteristic: '#/components/schemas/ObjectCharacteristic_FVO'
+          StringArrayCharacteristic: '#/components/schemas/StringArrayCharacteristic_FVO'
+          StringCharacteristic: '#/components/schemas/StringCharacteristic_FVO'
+    Characteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            Describes a given characteristic of an object or entity through a name/value pair. This
+            is an abstract base class, the actual value is in one of the strongly-typed subclasses :
+            StringCharacteristic, ObjectCharacteristic, FloatCharacteristic, BooleanCharacteristic,
+            NumberCharacteristic, IntegerCharacteristic, StringArrayCharacteristic,
+            ObjectArrayCharacteristic, BooleanArrayCharacteristic, NumberArrayCharacteristic,
+            IntegerArrayCharacteristic...
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the characteristic
+            name:
+              type: string
+              description: Name of the characteristic
+            valueType:
+              type: string
+              description: Data type of the value of the characteristic
+            characteristicRelationship:
+              type: array
+              description: Collection of characteristic relationships
+              items:
+                $ref: '#/components/schemas/CharacteristicRelationship_MVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          BooleanArrayCharacteristic: '#/components/schemas/BooleanArrayCharacteristic_MVO'
+          BooleanCharacteristic: '#/components/schemas/BooleanCharacteristic_MVO'
+          Characteristic: '#/components/schemas/Characteristic_MVO'
+          FloatCharacteristic: '#/components/schemas/FloatCharacteristic_MVO'
+          IntegerArrayCharacteristic: '#/components/schemas/IntegerArrayCharacteristic_MVO'
+          IntegerCharacteristic: '#/components/schemas/IntegerCharacteristic_MVO'
+          NumberArrayCharacteristic: '#/components/schemas/NumberArrayCharacteristic_MVO'
+          NumberCharacteristic: '#/components/schemas/NumberCharacteristic_MVO'
+          ObjectArrayCharacteristic: '#/components/schemas/ObjectArrayCharacteristic_MVO'
+          ObjectCharacteristic: '#/components/schemas/ObjectCharacteristic_MVO'
+          StringArrayCharacteristic: '#/components/schemas/StringArrayCharacteristic_MVO'
+          StringCharacteristic: '#/components/schemas/StringCharacteristic_MVO'
+    ContactMedium:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            Indicates the contact medium that could be used to contact the party. This is an
+            abstract base class, the actual value is in one of the strongly-typed subclasses :
+            EmailContactMedium, FaxContactMedium, PhoneContactMedium,
+            GeographicAddressContactMedium, SocialMediaContactMedium...
+          properties:
+            id:
+              type: string
+              description: Identifier for this contact medium.
+            preferred:
+              type: boolean
+              description: 'If true, indicates that is the preferred contact medium'
+            contactType:
+              type: string
+              description: >-
+                Type of the contact medium to qualify it like pro email / personal email. This is
+                not used to define the contact medium used.
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          ContactMedium: '#/components/schemas/ContactMedium'
+          EmailContactMedium: '#/components/schemas/EmailContactMedium'
+          FaxContactMedium: '#/components/schemas/FaxContactMedium'
+          GeographicAddressContactMedium: '#/components/schemas/GeographicAddressContactMedium'
+          PhoneContactMedium: '#/components/schemas/PhoneContactMedium'
+    EmailContactMedium:
+      allOf:
+        - $ref: '#/components/schemas/ContactMedium'
+        - type: object
+          description: >-
+            Describes an email that could be used to contact a party (an individual or an
+            organization)
+          properties:
+            emailAddress:
+              type: string
+              description: Full email address in standard format
+    Entity:
+      type: object
+      description: Base entity schema for use in TMForum Open-APIs. Property.
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - $ref: '#/components/schemas/Addressable'
+    EntityRef:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - $ref: '#/components/schemas/Addressable'
+        - type: object
+          description: Entity reference schema to be use for all entityRef class.
+          properties:
+            id:
+              type: string
+              description: The identifier of the referred entity.
+            href:
+              type: string
+              description: The URI of the referred entity.
+            name:
+              type: string
+              description: Name of the referred entity.
+            '@referredType':
+              type: string
+              description: The actual type of the target instance when needed for disambiguation.
+          required:
+            - id
+    EntityRef_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - $ref: '#/components/schemas/Addressable'
+        - type: object
+          description: Entity reference schema to be use for all entityRef class.
+          properties:
+            id:
+              type: string
+              description: The identifier of the referred entity.
+            href:
+              type: string
+              description: The URI of the referred entity.
+            name:
+              type: string
+              description: Name of the referred entity.
+            '@referredType':
+              type: string
+              description: The actual type of the target instance when needed for disambiguation.
+    Event:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: event with common attributes.
+          properties:
+            href:
+              type: string
+              description: Hyperlink reference
+            id:
+              type: string
+              description: unique identifier
+            correlationId:
+              type: string
+              description: The correlation id for this event.
+            domain:
+              type: string
+              description: The domain of the event.
+            title:
+              type: string
+              description: The title of the event.
+            description:
+              type: string
+              description: An explanation of the event.
+            priority:
+              type: string
+              description: A priority.
+            timeOccurred:
+              type: string
+              format: date-time
+              description: The time the event occurred.
+            source:
+              $ref: '#/components/schemas/EntityRef'
+            reportingSystem:
+              $ref: '#/components/schemas/EntityRef'
+            relatedParty:
+              type: array
+              description: Collection of related parties
+              items:
+                $ref: '#/components/schemas/RelatedPartyRefOrPartyRoleRef'
+            analyticCharacteristic:
+              type: array
+              description: Collection of analytic characteristics
+              items:
+                $ref: '#/components/schemas/Characteristic'
+            eventId:
+              type: string
+              description: The identifier of the notification.
+            eventTime:
+              type: string
+              format: date-time
+              description: Time of the event occurrence.
+            eventType:
+              type: string
+              description: The type of the notification.
+            event:
+              description: The event linked to the involved resource object
+              type: object
+    Extensible:
+      type: object
+      description: >-
+        Base Extensible schema for use in TMForum Open-APIs - When used for in a schema it means
+        that the Entity described by the schema  MUST be extended with the @type
+      properties:
+        '@type':
+          type: string
+          description: 'When sub-classing, this defines the sub-class Extensible name'
+        '@baseType':
+          type: string
+          description: 'When sub-classing, this defines the super-class'
+        '@schemaLocation':
+          type: string
+          description: A URI to a JSON-Schema file that defines additional attributes and relationships
+      required:
+        - '@type'
+    ExternalIdentifier:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            An identification of an entity that is owned by or originates in a software system
+            different from the current system, for example a ProductOrder handed off from a commerce
+            platform into an order handling system. The structure identifies the system itself, the
+            nature of the entity within the system (e.g. class name) and the unique ID of the entity
+            within the system. It is anticipated that multiple external IDs can be held for a single
+            entity, e.g. if the entity passed through multiple systems on the way to the current
+            system. In this case the consumer is expected to sequence the IDs in the array in
+            reverse order of provenance, i.e. most recent system first in the list.
+          properties:
+            owner:
+              type: string
+              description: Name of the external system that owns the entity.
+              example: MagentoCommerce
+            externalIdentifierType:
+              type: string
+              description: >-
+                Type of the identification, typically would be the type of the entity within the
+                external system
+              example: ProductOrder
+            id:
+              type: string
+              description: identification of the entity within the external system.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          ExternalIdentifier: '#/components/schemas/ExternalIdentifier'
+    ExternalIdentifier_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            An identification of an entity that is owned by or originates in a software system
+            different from the current system, for example a ProductOrder handed off from a commerce
+            platform into an order handling system. The structure identifies the system itself, the
+            nature of the entity within the system (e.g. class name) and the unique ID of the entity
+            within the system. It is anticipated that multiple external IDs can be held for a single
+            entity, e.g. if the entity passed through multiple systems on the way to the current
+            system. In this case the consumer is expected to sequence the IDs in the array in
+            reverse order of provenance, i.e. most recent system first in the list.
+          properties:
+            owner:
+              type: string
+              description: Name of the external system that owns the entity.
+              example: MagentoCommerce
+            externalIdentifierType:
+              type: string
+              description: >-
+                Type of the identification, typically would be the type of the entity within the
+                external system
+              example: ProductOrder
+            id:
+              type: string
+              description: identification of the entity within the external system.
+          required:
+            - id
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          ExternalIdentifier: '#/components/schemas/ExternalIdentifier_FVO'
+    ExternalIdentifier_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            An identification of an entity that is owned by or originates in a software system
+            different from the current system, for example a ProductOrder handed off from a commerce
+            platform into an order handling system. The structure identifies the system itself, the
+            nature of the entity within the system (e.g. class name) and the unique ID of the entity
+            within the system. It is anticipated that multiple external IDs can be held for a single
+            entity, e.g. if the entity passed through multiple systems on the way to the current
+            system. In this case the consumer is expected to sequence the IDs in the array in
+            reverse order of provenance, i.e. most recent system first in the list.
+          properties:
+            owner:
+              type: string
+              description: Name of the external system that owns the entity.
+              example: MagentoCommerce
+            externalIdentifierType:
+              type: string
+              description: >-
+                Type of the identification, typically would be the type of the entity within the
+                external system
+              example: ProductOrder
+            id:
+              type: string
+              description: identification of the entity within the external system.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          ExternalIdentifier: '#/components/schemas/ExternalIdentifier_MVO'
+    FaxContactMedium:
+      allOf:
+        - $ref: '#/components/schemas/ContactMedium'
+        - type: object
+          description: Describes a fax that could be used to contact a party (an individual or an organization)
+          properties:
+            faxNumber:
+              type: string
+              description: The fax number of the contact
+    FloatArrayCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array of format
+            floating point
+          properties:
+            value:
+              type: array
+              items:
+                type: number
+                format: float
+                description: Characteristic value
+    FloatArrayCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array of format
+            floating point
+          properties:
+            value:
+              type: array
+              items:
+                type: number
+                format: float
+                description: Characteristic value
+    FloatArrayCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array of format
+            floating point
+          properties:
+            value:
+              type: array
+              items:
+                type: number
+                format: float
+                description: Characteristic value
+    FloatCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is a Float.
+          properties:
+            value:
+              type: number
+              format: float
+              description: Value of the characteristic
+    FloatCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is a floating point number
+          properties:
+            value:
+              type: number
+              format: float
+              description: Value of the characteristic
+    FloatCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a floating point number
+          properties:
+            value:
+              type: number
+              format: float
+              description: Value of the characteristic
+    FloatCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a floating point number
+          properties:
+            value:
+              type: number
+              format: float
+              description: Value of the characteristic
+    FloatCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is a Float.
+          properties:
+            value:
+              type: number
+              format: float
+              description: Value of the characteristic
+          required:
+            - value
+    FloatCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is a Float.
+          properties:
+            value:
+              type: number
+              format: float
+              description: Value of the characteristic
+    GeographicAddressContactMedium:
+      allOf:
+        - $ref: '#/components/schemas/ContactMedium'
+        - type: object
+          description: >-
+            Describes a geographical address that could be used to contact a party (an individual or
+            an organization)
+          properties:
+            city:
+              type: string
+              description: The city
+            country:
+              type: string
+              description: The country
+            postCode:
+              type: string
+              description: Postcode
+            stateOrProvince:
+              type: string
+              description: State or province
+            street1:
+              type: string
+              description: Describes the street
+            street2:
+              type: string
+              description: Complementary street description
+            geographicAddress:
+              $ref: '#/components/schemas/GeographicAddressRef'
+    GeographicAddressRef:
+      type: object
+      description: Reference to a Geographic Address.
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          GeographicAddressRef: '#/components/schemas/GeographicAddressRef'
+    IntegerArrayCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is an array of Integer(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Integer(s).
+              items:
+                type: integer
+                description: Characteristic value
+    IntegerArrayCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array of format
+            integer
+          properties:
+            value:
+              type: array
+              items:
+                type: integer
+                description: Characteristic value
+    IntegerArrayCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array of format
+            integer
+          properties:
+            value:
+              type: array
+              items:
+                type: integer
+                description: Characteristic value
+    IntegerArrayCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array of format
+            integer
+          properties:
+            value:
+              type: array
+              items:
+                type: integer
+                description: Characteristic value
+    IntegerArrayCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is an array of Integer(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Integer(s).
+              items:
+                type: integer
+                description: Characteristic value
+          required:
+            - value
+    IntegerArrayCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is an array of Integer(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Integer(s).
+              items:
+                type: integer
+                description: Characteristic value
+    IntegerCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is a Integer.
+          properties:
+            value:
+              type: integer
+              description: Value of the characteristic
+    IntegerCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is an integer number
+          properties:
+            value:
+              type: integer
+              description: Value of the characteristic
+    IntegerCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an integer number
+          properties:
+            value:
+              type: integer
+              description: Value of the characteristic
+    IntegerCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an integer number
+          properties:
+            value:
+              type: integer
+              description: Value of the characteristic
+    IntegerCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is a Integer.
+          properties:
+            value:
+              type: integer
+              description: Value of the characteristic
+          required:
+            - value
+    IntegerCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is a Integer.
+          properties:
+            value:
+              type: integer
+              description: Value of the characteristic
+    JsonPatch:
+      type: object
+      description: A JSONPatch document as defined by RFC 6902
+      required:
+        - op
+        - path
+      properties:
+        op:
+          type: string
+          description: The operation to be performed
+          enum:
+            - add
+            - remove
+            - replace
+            - move
+            - copy
+            - test
+        path:
+          type: string
+          description: A JSON-Pointer
+        value:
+          description: The value to be used within the operations.
+        from:
+          type: string
+          description: A string containing a JSON Pointer value.
+    MapArrayCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of mapped objects
+          properties:
+            value:
+              type: array
+              items:
+                type: object
+                properties:
+                  value:
+                    type: object
+                    additionalProperties:
+                      type: object
+    MapArrayCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of mapped objects
+          properties:
+            value:
+              type: array
+              items:
+                type: object
+                properties:
+                  value:
+                    type: object
+                    additionalProperties:
+                      type: object
+    MapArrayCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of mapped objects
+          properties:
+            value:
+              type: array
+              items:
+                type: object
+                properties:
+                  value:
+                    type: object
+                    additionalProperties:
+                      type: object
+    MapCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is a mapped object
+          properties:
+            value:
+              type: object
+              additionalProperties:
+                type: object
+              description: Value of the characteristic
+    MapCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a mapped object
+          properties:
+            value:
+              type: object
+              additionalProperties:
+                type: object
+              description: Value of the characteristic
+    MapCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a mapped object
+          properties:
+            value:
+              type: object
+              additionalProperties:
+                type: object
+              description: Value of the characteristic
+    Note:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: Extra information about a given entity
+          properties:
+            id:
+              type: string
+              description: Identifier of the note within its containing entity
+              example: afa9-3d90aaa8da0f
+            author:
+              type: string
+              description: Author of the note
+              example: Mr. N. Bene
+            date:
+              type: string
+              format: date-time
+              description: Date of the note
+              example: '2020-11-20T08:00:00Z'
+            text:
+              type: string
+              description: Text of the note
+              example: This is important
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Note: '#/components/schemas/Note'
+    Note_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: Extra information about a given entity
+          properties:
+            id:
+              type: string
+              description: Identifier of the note within its containing entity
+              example: afa9-3d90aaa8da0f
+            author:
+              type: string
+              description: Author of the note
+              example: Mr. N. Bene
+            date:
+              type: string
+              format: date-time
+              description: Date of the note
+              example: '2020-11-20T08:00:00Z'
+            text:
+              type: string
+              description: Text of the note
+              example: This is important
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Note: '#/components/schemas/Note_FVO'
+    Note_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: Extra information about a given entity
+          properties:
+            id:
+              type: string
+              description: Identifier of the note within its containing entity
+              example: afa9-3d90aaa8da0f
+            author:
+              type: string
+              description: Author of the note
+              example: Mr. N. Bene
+            date:
+              type: string
+              format: date-time
+              description: Date of the note
+              example: '2020-11-20T08:00:00Z'
+            text:
+              type: string
+              description: Text of the note
+              example: This is important
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Note: '#/components/schemas/Note_MVO'
+    NumberArrayCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is an array of Number(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Number(s).
+              items:
+                type: number
+                description: Characteristic value
+    NumberArrayCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array with no
+            specific format 
+          properties:
+            value:
+              type: array
+              items:
+                type: number
+                description: Characteristic value
+    NumberArrayCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array with no
+            specific format 
+          properties:
+            value:
+              type: array
+              items:
+                type: number
+                description: Characteristic value
+    NumberArrayCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number array with no
+            specific format 
+          properties:
+            value:
+              type: array
+              items:
+                type: number
+                description: Characteristic value
+    NumberArrayCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is an array of Number(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Number(s).
+              items:
+                type: number
+                description: Characteristic value
+          required:
+            - value
+    NumberArrayCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is an array of Number(s).
+          properties:
+            value:
+              type: array
+              description: A characteristic which value is an array of Number(s).
+              items:
+                type: number
+                description: Characteristic value
+    NumberCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is a Number.
+          properties:
+            value:
+              type: number
+              description: Value of the characteristic
+    NumberCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number of no specific
+            format
+          properties:
+            value:
+              type: number
+              description: Value of the characteristic
+    NumberCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number of no specific
+            format
+          properties:
+            value:
+              type: number
+              description: Value of the characteristic
+    NumberCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: >-
+            A specification for a characteristic for which the value is a number of no specific
+            format
+          properties:
+            value:
+              type: number
+              description: Value of the characteristic
+    NumberCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is a Number.
+          properties:
+            value:
+              type: number
+              description: Value of the characteristic
+          required:
+            - value
+    NumberCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is a Number.
+          properties:
+            value:
+              type: number
+              description: Value of the characteristic
+    ObjectArrayCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is an array of Object(s).
+          properties:
+            value:
+              type: array
+              description: Collection of characteristic values
+              items:
+                type: object
+                description: Characteristic value
+    ObjectArrayCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of objects
+          properties:
+            value:
+              type: array
+              description: Collection of characteristic values
+              items:
+                type: object
+                description: Characteristic value
+    ObjectArrayCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of objects
+          properties:
+            value:
+              type: array
+              description: Collection of characteristic values
+              items:
+                type: object
+                description: Characteristic value
+    ObjectArrayCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of objects
+          properties:
+            value:
+              type: array
+              description: Collection of characteristic values
+              items:
+                type: object
+                description: Characteristic value
+    ObjectArrayCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is an array of Object(s).
+          properties:
+            value:
+              type: array
+              description: Collection of characteristic values
+              items:
+                type: object
+                description: Characteristic value
+          required:
+            - value
+    ObjectArrayCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is an array of Object(s).
+          properties:
+            value:
+              type: array
+              description: Collection of characteristic values
+              items:
+                type: object
+                description: Characteristic value
+    ObjectCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is a Object.
+          properties:
+            value:
+              type: object
+              description: Value of the characteristic
+    ObjectCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is any object
+          properties:
+            value:
+              type: object
+              description: Value of the characteristic
+    ObjectCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is any object
+          properties:
+            value:
+              type: object
+              description: Value of the characteristic
+    ObjectCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is any object
+          properties:
+            value:
+              type: object
+              description: Value of the characteristic
+    ObjectCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is a Object.
+          properties:
+            value:
+              type: object
+              description: Value of the characteristic
+          required:
+            - value
+    ObjectCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is a Object.
+          properties:
+            value:
+              type: object
+              description: Value of the characteristic
+    PartyRef:
+      type: object
+      description: A Party reference
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRef: '#/components/schemas/PartyRef'
+    PartyRefOrPartyRoleRef:
+      type: object
+      description: ''
+      oneOf:
+        - $ref: '#/components/schemas/PartyRef'
+        - $ref: '#/components/schemas/PartyRoleRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRef: '#/components/schemas/PartyRef'
+          PartyRoleRef: '#/components/schemas/PartyRoleRef'
+    PartyRefOrPartyRoleRef_FVO:
+      type: object
+      description: ''
+      oneOf:
+        - $ref: '#/components/schemas/PartyRef_FVO'
+        - $ref: '#/components/schemas/PartyRoleRef_FVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRef: '#/components/schemas/PartyRef_FVO'
+          PartyRoleRef: '#/components/schemas/PartyRoleRef_FVO'
+    PartyRefOrPartyRoleRef_MVO:
+      type: object
+      description: ''
+      oneOf:
+        - $ref: '#/components/schemas/PartyRef_MVO'
+        - $ref: '#/components/schemas/PartyRoleRef_MVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRef: '#/components/schemas/PartyRef_MVO'
+          PartyRoleRef: '#/components/schemas/PartyRoleRef_MVO'
+    PartyRef_FVO:
+      type: object
+      description: A Party reference
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRef: '#/components/schemas/PartyRef_FVO'
+    PartyRef_MVO:
+      type: object
+      description: A Party reference
+      allOf:
+        - $ref: '#/components/schemas/EntityRef_MVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRef: '#/components/schemas/PartyRef_MVO'
+    PartyRoleRef:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: >-
+            Party role reference. A party role represents the part played by a party in a given
+            context.
+          properties:
+            partyId:
+              type: string
+              description: The identifier of the engaged party that is linked to the PartyRole object.
+            partyName:
+              type: string
+              description: The name of the engaged party that is linked to the PartyRole object.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRoleRef: '#/components/schemas/PartyRoleRef'
+    PartyRoleRef_FVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: >-
+            Party role reference. A party role represents the part played by a party in a given
+            context.
+          properties:
+            partyId:
+              type: string
+              description: The identifier of the engaged party that is linked to the PartyRole object.
+            partyName:
+              type: string
+              description: The name of the engaged party that is linked to the PartyRole object.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRoleRef: '#/components/schemas/PartyRoleRef_FVO'
+    PartyRoleRef_MVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef_MVO'
+        - type: object
+          description: >-
+            Party role reference. A party role represents the part played by a party in a given
+            context.
+          properties:
+            partyId:
+              type: string
+              description: The identifier of the engaged party that is linked to the PartyRole object.
+            partyName:
+              type: string
+              description: The name of the engaged party that is linked to the PartyRole object.
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          PartyRoleRef: '#/components/schemas/PartyRoleRef_MVO'
+    PhoneContactMedium:
+      allOf:
+        - $ref: '#/components/schemas/ContactMedium'
+        - type: object
+          description: >-
+            Describes a phone number that could be used to contact a party (an individual or an
+            organization)
+          properties:
+            phoneNumber:
+              type: string
+              description: The phone number of the contact
+    Quantity:
+      type: object
+      description: An amount in a given unit
+      properties:
+        amount:
+          type: number
+          format: float
+          default: 1
+          description: Numeric value in a given unit
+        units:
+          type: string
+          description: Unit
+    RelatedEntity:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: 'A reference to an entity, where the type of the entity is not known in advance.'
+          properties:
+            role:
+              type: string
+            entity:
+              $ref: '#/components/schemas/EntityRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          RelatedEntity: '#/components/schemas/RelatedEntity'
+    RelatedEntity_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: 'A reference to an entity, where the type of the entity is not known in advance.'
+          properties:
+            role:
+              type: string
+            entity:
+              $ref: '#/components/schemas/EntityRef'
+          required:
+            - role
+            - entity
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          RelatedEntity: '#/components/schemas/RelatedEntity_FVO'
+    RelatedEntity_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: 'A reference to an entity, where the type of the entity is not known in advance.'
+          properties:
+            role:
+              type: string
+            entity:
+              $ref: '#/components/schemas/EntityRef_MVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          RelatedEntity: '#/components/schemas/RelatedEntity_MVO'
+    RelatedPartyRefOrPartyRoleRef:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            RelatedParty reference. A related party defines party or party role or its reference,
+            linked to a specific entity
+          properties:
+            role:
+              description: >-
+                Role played by the related party or party role in the context of the specific entity
+                it is linked to. Such as 'initiator', 'customer',  'salesAgent', 'user'
+              type: string
+            partyOrPartyRole:
+              $ref: '#/components/schemas/PartyRefOrPartyRoleRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          RelatedPartyRefOrPartyRoleRef: '#/components/schemas/RelatedPartyRefOrPartyRoleRef'
+    RelatedPartyRefOrPartyRoleRef_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            RelatedParty reference. A related party defines party or party role or its reference,
+            linked to a specific entity
+          properties:
+            role:
+              description: >-
+                Role played by the related party or party role in the context of the specific entity
+                it is linked to. Such as 'initiator', 'customer',  'salesAgent', 'user'
+              type: string
+            partyOrPartyRole:
+              $ref: '#/components/schemas/PartyRefOrPartyRoleRef_FVO'
+          required:
+            - role
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          RelatedPartyRefOrPartyRoleRef: '#/components/schemas/RelatedPartyRefOrPartyRoleRef_FVO'
+    RelatedPartyRefOrPartyRoleRef_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            RelatedParty reference. A related party defines party or party role or its reference,
+            linked to a specific entity
+          properties:
+            role:
+              description: >-
+                Role played by the related party or party role in the context of the specific entity
+                it is linked to. Such as 'initiator', 'customer',  'salesAgent', 'user'
+              type: string
+            partyOrPartyRole:
+              $ref: '#/components/schemas/PartyRefOrPartyRoleRef_MVO'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          RelatedPartyRefOrPartyRoleRef: '#/components/schemas/RelatedPartyRefOrPartyRoleRef_MVO'
+    StatusChange:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            Holds the status, reasons and associated date the status changed, populated by the
+            server
+          properties:
+            statusChangeDate:
+              type: string
+              format: date-time
+              description: The date and time the status changed.
+            statusChangeReason:
+              type: string
+              description: The reason why the status changed.
+            status:
+              $ref: '#/components/schemas/TroubleTicketStatusType'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          StatusChange: '#/components/schemas/StatusChange'
+    StatusChange_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            Holds the status, reasons and associated date the status changed, populated by the
+            server
+          properties:
+            statusChangeDate:
+              type: string
+              format: date-time
+              description: The date and time the status changed.
+            statusChangeReason:
+              type: string
+              description: The reason why the status changed.
+            status:
+              $ref: '#/components/schemas/TroubleTicketStatusType'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          StatusChange: '#/components/schemas/StatusChange_FVO'
+    StatusChange_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          description: >-
+            Holds the status, reasons and associated date the status changed, populated by the
+            server
+          properties:
+            statusChangeDate:
+              type: string
+              format: date-time
+              description: The date and time the status changed.
+            statusChangeReason:
+              type: string
+              description: The reason why the status changed.
+            status:
+              $ref: '#/components/schemas/TroubleTicketStatusType'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          StatusChange: '#/components/schemas/StatusChange_MVO'
+    StringArrayCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is an array of String(s).
+          properties:
+            value:
+              type: array
+              description: Collection of string characteristics
+              items:
+                type: string
+                description: Characteristic value
+    StringArrayCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of strings
+          properties:
+            value:
+              type: array
+              items:
+                type: string
+                description: Characteristic value
+    StringArrayCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of strings
+          properties:
+            value:
+              type: array
+              items:
+                type: string
+                description: Characteristic value
+    StringArrayCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is an array of strings
+          properties:
+            value:
+              type: array
+              items:
+                type: string
+                description: Characteristic value
+    StringArrayCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is an array of String(s).
+          properties:
+            value:
+              type: array
+              description: Collection of string characteristics
+              items:
+                type: string
+                description: Characteristic value
+          required:
+            - value
+    StringArrayCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is an array of String(s).
+          properties:
+            value:
+              type: array
+              description: Collection of string characteristics
+              items:
+                type: string
+                description: Characteristic value
+    StringCharacteristic:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic'
+        - type: object
+          description: A characteristic which value is a String.
+          properties:
+            value:
+              type: string
+              description: Value of the characteristic
+    StringCharacteristicValueSpecification:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification'
+        - type: object
+          description: A specification for a characteristic for which the value is a string
+          properties:
+            value:
+              type: string
+              description: Value of the characteristic
+    StringCharacteristicValueSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_FVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a string
+          properties:
+            value:
+              type: string
+              description: Value of the characteristic
+    StringCharacteristicValueSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/CharacteristicValueSpecification_MVO'
+        - type: object
+          description: A specification for a characteristic for which the value is a string
+          properties:
+            value:
+              type: string
+              description: Value of the characteristic
+    StringCharacteristic_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_FVO'
+        - type: object
+          description: A characteristic which value is a String.
+          properties:
+            value:
+              type: string
+              description: Value of the characteristic
+          required:
+            - value
+    StringCharacteristic_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Characteristic_MVO'
+        - type: object
+          description: A characteristic which value is a String.
+          properties:
+            value:
+              type: string
+              description: Value of the characteristic
+    TimePeriod:
+      type: object
+      description: 'A period of time, either as a deadline (endDateTime only) a startDateTime only, or both'
+      properties:
+        startDateTime:
+          description: 'Start of the time period, using IETC-RFC-3339 format'
+          type: string
+          format: date-time
+          example: '1985-04-12T23:20:50.52Z'
+        endDateTime:
+          description: 'End of the time period, using IETC-RFC-3339 format'
+          type: string
+          format: date-time
+          example: '1985-04-12T23:20:50.52Z'
+    TroubleTicket:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            A trouble ticket is a record of an issue that is created, tracked, and managed by a
+            trouble ticket management system
+          properties:
+            name:
+              type: string
+              description: >-
+                Name of the trouble ticket, typically a short description provided by the user that
+                create the ticket
+            description:
+              type: string
+              description: Description of the trouble or issue
+            severity:
+              type: string
+              description: >-
+                The severity of the issue. Indicate the implication of the issue on the expected
+                functionality e.g. of a system, application, service etc.. 
+
+                Severity values can be for example : Critical, Major, Minor
+            ticketType:
+              type: string
+              description: 'Represent a business type of the trouble ticket e.g. incident, complain, request'
+            attachment:
+              type: array
+              items:
+                $ref: '#/components/schemas/AttachmentRefOrValue'
+              description: >-
+                File(s) attached to the trouble ticket. e.g. picture of broken device, scanning of a
+                bill or charge
+            channel:
+              $ref: '#/components/schemas/ChannelRef'
+            creationDate:
+              type: string
+              format: date-time
+              description: The date on which the trouble ticket was created
+            requestedResolutionDate:
+              type: string
+              format: date-time
+              description: The resolution date requested by the user
+            expectedResolutionDate:
+              type: string
+              format: date-time
+              description: The expected resolution date determined by the trouble ticket system
+            resolutionDate:
+              type: string
+              format: date-time
+              description: The date and time the trouble ticket was resolved
+            externalIdentifier:
+              type: array
+              items:
+                $ref: '#/components/schemas/ExternalIdentifier'
+            lastUpdate:
+              type: string
+              format: date-time
+              description: The date and time that the trouble ticket was last updated
+            note:
+              type: array
+              items:
+                $ref: '#/components/schemas/Note'
+              description: The note(s) that are associated to the ticket.
+            priority:
+              type: string
+              description: >-
+                The priority of the trouble ticket and how quickly the issue should be resolved.
+                Example: Critical, High, Medium, Low. The value is set by the ticket management
+                system considering the severity, ticket type etc...
+            relatedEntity:
+              type: array
+              items:
+                $ref: '#/components/schemas/RelatedEntity'
+              description: >-
+                An entity that is related to the ticket such as a bill, a product, etc. The entity
+                against which the ticket is associated.
+            relatedParty:
+              type: array
+              items:
+                $ref: '#/components/schemas/RelatedPartyRefOrPartyRoleRef'
+              description: The related party(ies) that are associated to the ticket.
+            status:
+              $ref: '#/components/schemas/TroubleTicketStatusType'
+            statusChangeDate:
+              type: string
+              format: date-time
+              description: The date and time the status changed.
+            statusChangeReason:
+              type: string
+              description: The reason for changing the status
+            statusChangeHistory:
+              type: array
+              items:
+                $ref: '#/components/schemas/StatusChange'
+              description: The status change history that are associated to the ticket. Populated by the server
+            troubleTicketRelationship:
+              type: array
+              items:
+                $ref: '#/components/schemas/TroubleTicketRelationship'
+              description: >-
+                A list of trouble ticket relationships (TroubleTicketRelationship [*]). Represents a
+                relationship between trouble tickets
+            troubleTicketSpecification:
+              $ref: '#/components/schemas/TroubleTicketSpecificationRef'
+            troubleTicketCharacteristic:
+              type: array
+              items:
+                $ref: '#/components/schemas/Characteristic'
+              description: List of characteristics of the trouble ticket
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicket: '#/components/schemas/TroubleTicket'
+    TroubleTicketAttributeValueChangeEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketAttributeValueChange structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketAttributeValueChangeEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketAttributeValueChangeEvent: '#/components/schemas/TroubleTicketAttributeValueChangeEvent'
+    TroubleTicketAttributeValueChangeEventPayload:
+      type: object
+      description: TroubleTicketAttributeValueChangeEventPayload generic structure
+      properties:
+        troubleTicket:
+          $ref: '#/components/schemas/TroubleTicket'
+    TroubleTicketCreateEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketCreateEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketCreateEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketCreateEvent: '#/components/schemas/TroubleTicketCreateEvent'
+    TroubleTicketCreateEventPayload:
+      type: object
+      description: TroubleTicketCreateEventPayload generic structure
+      properties:
+        troubleTicket:
+          $ref: '#/components/schemas/TroubleTicket'
+    TroubleTicketDeleteEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketDeleteEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketDeleteEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketDeleteEvent: '#/components/schemas/TroubleTicketDeleteEvent'
+    TroubleTicketDeleteEventPayload:
+      type: object
+      description: TroubleTicketDeleteEventPayload generic structure
+      properties:
+        troubleTicket:
+          $ref: '#/components/schemas/TroubleTicketRef'
+    TroubleTicketInformationRequiredEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketInformationRequiredEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketInformationRequiredEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketInformationRequiredEvent: '#/components/schemas/TroubleTicketInformationRequiredEvent'
+    TroubleTicketInformationRequiredEventPayload:
+      type: object
+      description: TroubleTicketInformationRequiredEventPayload generic structure
+      properties:
+        troubleTicket:
+          $ref: '#/components/schemas/TroubleTicket'
+        informationRequired:
+          $ref: '#/components/schemas/JsonPatch'
+    TroubleTicketRef:
+      type: object
+      description: reference to an TroubleTicket object
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketRef: '#/components/schemas/TroubleTicketRef'
+    TroubleTicketRelationship:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: Represents a relationship between trouble tickets
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the related trouble ticket
+            name:
+              type: string
+              description: Name of the trouble ticket
+            relationshipType:
+              type: string
+              description: Type of relationship
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketRelationship: '#/components/schemas/TroubleTicketRelationship'
+    TroubleTicketRelationship_FVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: Represents a relationship between trouble tickets
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the related trouble ticket
+            name:
+              type: string
+              description: Name of the trouble ticket
+            relationshipType:
+              type: string
+              description: Type of relationship
+          required:
+            - id
+            - relationshipType
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketRelationship: '#/components/schemas/TroubleTicketRelationship_FVO'
+    TroubleTicketRelationship_MVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef_MVO'
+        - type: object
+          description: Represents a relationship between trouble tickets
+          properties:
+            id:
+              type: string
+              description: Unique identifier of the related trouble ticket
+            name:
+              type: string
+              description: Name of the trouble ticket
+            relationshipType:
+              type: string
+              description: Type of relationship
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketRelationship: '#/components/schemas/TroubleTicketRelationship_MVO'
+    TroubleTicketResolvedEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketResolvedEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketResolvedEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketResolvedEvent: '#/components/schemas/TroubleTicketResolvedEvent'
+    TroubleTicketResolvedEventPayload:
+      type: object
+      description: TroubleTicketResolvedEventPayload generic structure
+      properties:
+        troubleTicket:
+          $ref: '#/components/schemas/TroubleTicket'
+    TroubleTicketSpecification:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            TroubleTicketSpecification defines the common attributes and relationships of a set of
+            related trouble tickets, while trouble ticket defines a specific instance that is based
+            on a particular trouble ticket specification.
+          properties:
+            name:
+              type: string
+              description: Name given to the specification
+            description:
+              type: string
+              description: Description of the specification
+            lifecycleStatus:
+              type: string
+              description: >-
+                Used to indicate the current lifecycle status of this specification such as
+                inDesign,active,rejected,retired
+            specCharacteristic:
+              type: array
+              description: List of characteristics that the entity can take
+              items:
+                $ref: '#/components/schemas/CharacteristicSpecification'
+            relatedParty:
+              type: array
+              description: Parties who manage or otherwise have an interest in this specification
+              items:
+                $ref: '#/components/schemas/RelatedPartyRefOrPartyRoleRef'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            version:
+              type: string
+              description: >-
+                The version of the trouble ticket specification, in case it is desired to maintain
+                multiple versions of trouble ticket specifications
+            creationDate:
+              type: string
+              format: date-time
+              description: The date on which the trouble ticket specification was created
+            lastUpdate:
+              type: string
+              format: date-time
+              description: Date and time of the last update of the specification
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecification: '#/components/schemas/TroubleTicketSpecification'
+    TroubleTicketSpecificationAttributeValueChangeEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketSpecificationAttributeValueChange structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketSpecificationAttributeValueChangeEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecificationAttributeValueChangeEvent: '#/components/schemas/TroubleTicketSpecificationAttributeValueChangeEvent'
+    TroubleTicketSpecificationAttributeValueChangeEventPayload:
+      type: object
+      description: TroubleTicketSpecificationAttributeValueChangeEventPayload generic structure
+      properties:
+        troubleTicketSpecification:
+          $ref: '#/components/schemas/TroubleTicketSpecification'
+    TroubleTicketSpecificationCreateEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketSpecificationCreateEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketSpecificationCreateEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecificationCreateEvent: '#/components/schemas/TroubleTicketSpecificationCreateEvent'
+    TroubleTicketSpecificationCreateEventPayload:
+      type: object
+      description: TroubleTicketSpecificationCreateEventPayload generic structure
+      properties:
+        troubleTicketSpecification:
+          $ref: '#/components/schemas/TroubleTicketSpecification'
+    TroubleTicketSpecificationDeleteEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketSpecificationDeleteEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketSpecificationDeleteEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecificationDeleteEvent: '#/components/schemas/TroubleTicketSpecificationDeleteEvent'
+    TroubleTicketSpecificationDeleteEventPayload:
+      type: object
+      description: TroubleTicketSpecificationDeleteEventPayload generic structure
+      properties:
+        troubleTicketSpecification:
+          $ref: '#/components/schemas/TroubleTicketSpecificationRef'
+    TroubleTicketSpecificationRef:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: reference to an TroubleTicketSpecification object
+          properties:
+            version:
+              type: string
+              description: >-
+                The version of the trouble ticket specification, in case it is desired to maintain
+                multiple versions of trouble ticket specifications
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecificationRef: '#/components/schemas/TroubleTicketSpecificationRef'
+    TroubleTicketSpecificationRef_FVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef'
+        - type: object
+          description: reference to an TroubleTicketSpecification object
+          properties:
+            version:
+              type: string
+              description: >-
+                The version of the trouble ticket specification, in case it is desired to maintain
+                multiple versions of trouble ticket specifications
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecificationRef: '#/components/schemas/TroubleTicketSpecificationRef_FVO'
+    TroubleTicketSpecificationRef_MVO:
+      allOf:
+        - $ref: '#/components/schemas/EntityRef_MVO'
+        - type: object
+          description: reference to an TroubleTicketSpecification object
+          properties:
+            version:
+              type: string
+              description: >-
+                The version of the trouble ticket specification, in case it is desired to maintain
+                multiple versions of trouble ticket specifications
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecificationRef: '#/components/schemas/TroubleTicketSpecificationRef_MVO'
+    TroubleTicketSpecificationStatusChangeEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketSpecificationStatusChangeEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketSpecificationStatusChangeEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecificationStatusChangeEvent: '#/components/schemas/TroubleTicketSpecificationStatusChangeEvent'
+    TroubleTicketSpecificationStatusChangeEventPayload:
+      type: object
+      description: TroubleTicketSpecificationStatusChangeEventPayload generic structure
+      properties:
+        troubleTicketSpecification:
+          $ref: '#/components/schemas/TroubleTicketSpecification'
+    TroubleTicketSpecification_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            TroubleTicketSpecification defines the common attributes and relationships of a set of
+            related trouble tickets, while trouble ticket defines a specific instance that is based
+            on a particular trouble ticket specification.
+          properties:
+            name:
+              type: string
+              description: Name given to the specification
+            description:
+              type: string
+              description: Description of the specification
+            lifecycleStatus:
+              type: string
+              description: >-
+                Used to indicate the current lifecycle status of this specification such as
+                inDesign,active,rejected,retired
+            specCharacteristic:
+              type: array
+              description: List of characteristics that the entity can take
+              items:
+                $ref: '#/components/schemas/CharacteristicSpecification_FVO'
+            relatedParty:
+              type: array
+              description: Parties who manage or otherwise have an interest in this specification
+              items:
+                $ref: '#/components/schemas/RelatedPartyRefOrPartyRoleRef_FVO'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            version:
+              type: string
+              description: >-
+                The version of the trouble ticket specification, in case it is desired to maintain
+                multiple versions of trouble ticket specifications
+          required:
+            - name
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecification: '#/components/schemas/TroubleTicketSpecification_FVO'
+    TroubleTicketSpecification_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            TroubleTicketSpecification defines the common attributes and relationships of a set of
+            related trouble tickets, while trouble ticket defines a specific instance that is based
+            on a particular trouble ticket specification.
+          properties:
+            name:
+              type: string
+              description: Name given to the specification
+            description:
+              type: string
+              description: Description of the specification
+            lifecycleStatus:
+              type: string
+              description: >-
+                Used to indicate the current lifecycle status of this specification such as
+                inDesign,active,rejected,retired
+            specCharacteristic:
+              type: array
+              description: List of characteristics that the entity can take
+              items:
+                $ref: '#/components/schemas/CharacteristicSpecification_MVO'
+            relatedParty:
+              type: array
+              description: Parties who manage or otherwise have an interest in this specification
+              items:
+                $ref: '#/components/schemas/RelatedPartyRefOrPartyRoleRef_MVO'
+            validFor:
+              $ref: '#/components/schemas/TimePeriod'
+            version:
+              type: string
+              description: >-
+                The version of the trouble ticket specification, in case it is desired to maintain
+                multiple versions of trouble ticket specifications
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecification: '#/components/schemas/TroubleTicketSpecification_MVO'
+    TroubleTicketSpecification_RES:
+      type: object
+      description: Response object for TroubleTicketSpecification
+      allOf:
+        - $ref: '#/components/schemas/TroubleTicketSpecification'
+      required:
+        - id
+        - href
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketSpecification: '#/components/schemas/TroubleTicketSpecification'
+    TroubleTicketStatusChangeEvent:
+      allOf:
+        - $ref: '#/components/schemas/Event'
+        - type: object
+          description: TroubleTicketStatusChangeEvent generic structure
+          properties:
+            event:
+              $ref: '#/components/schemas/TroubleTicketStatusChangeEventPayload'
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicketStatusChangeEvent: '#/components/schemas/TroubleTicketStatusChangeEvent'
+    TroubleTicketStatusChangeEventPayload:
+      type: object
+      description: TroubleTicketStatusChangeEventPayload generic structure
+      properties:
+        troubleTicket:
+          $ref: '#/components/schemas/TroubleTicket'
+    TroubleTicketStatusType:
+      enum:
+        - acknowledged
+        - rejected
+        - pending
+        - held
+        - inProgress
+        - cancelled
+        - closed
+        - resolved
+      type: string
+      description: Possible values for the status of the trouble ticket
+    TroubleTicket_FVO:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            A trouble ticket is a record of an issue that is created, tracked, and managed by a
+            trouble ticket management system
+          properties:
+            name:
+              type: string
+              description: >-
+                Name of the trouble ticket, typically a short description provided by the user that
+                create the ticket
+            description:
+              type: string
+              description: Description of the trouble or issue
+            severity:
+              type: string
+              description: >-
+                The severity of the issue. Indicate the implication of the issue on the expected
+                functionality e.g. of a system, application, service etc.. 
+
+                Severity values can be for example : Critical, Major, Minor
+            ticketType:
+              type: string
+              description: 'Represent a business type of the trouble ticket e.g. incident, complain, request'
+            attachment:
+              type: array
+              items:
+                $ref: '#/components/schemas/AttachmentRefOrValue_FVO'
+              description: >-
+                File(s) attached to the trouble ticket. e.g. picture of broken device, scanning of a
+                bill or charge
+            channel:
+              $ref: '#/components/schemas/ChannelRef_FVO'
+            requestedResolutionDate:
+              type: string
+              format: date-time
+              description: The resolution date requested by the user
+            expectedResolutionDate:
+              type: string
+              format: date-time
+              description: The expected resolution date determined by the trouble ticket system
+            resolutionDate:
+              type: string
+              format: date-time
+              description: The date and time the trouble ticket was resolved
+            externalIdentifier:
+              type: array
+              items:
+                $ref: '#/components/schemas/ExternalIdentifier_FVO'
+            note:
+              type: array
+              items:
+                $ref: '#/components/schemas/Note_FVO'
+              description: The note(s) that are associated to the ticket.
+            priority:
+              type: string
+              description: >-
+                The priority of the trouble ticket and how quickly the issue should be resolved.
+                Example: Critical, High, Medium, Low. The value is set by the ticket management
+                system considering the severity, ticket type etc...
+            relatedEntity:
+              type: array
+              items:
+                $ref: '#/components/schemas/RelatedEntity_FVO'
+              description: >-
+                An entity that is related to the ticket such as a bill, a product, etc. The entity
+                against which the ticket is associated.
+            relatedParty:
+              type: array
+              items:
+                $ref: '#/components/schemas/RelatedPartyRefOrPartyRoleRef_FVO'
+              description: The related party(ies) that are associated to the ticket.
+            status:
+              $ref: '#/components/schemas/TroubleTicketStatusType'
+            statusChangeDate:
+              type: string
+              format: date-time
+              description: The date and time the status changed.
+            statusChangeReason:
+              type: string
+              description: The reason for changing the status
+            troubleTicketRelationship:
+              type: array
+              items:
+                $ref: '#/components/schemas/TroubleTicketRelationship_FVO'
+              description: >-
+                A list of trouble ticket relationships (TroubleTicketRelationship [*]). Represents a
+                relationship between trouble tickets
+            troubleTicketSpecification:
+              $ref: '#/components/schemas/TroubleTicketSpecificationRef_FVO'
+            troubleTicketCharacteristic:
+              type: array
+              items:
+                $ref: '#/components/schemas/Characteristic_FVO'
+              description: List of characteristics of the trouble ticket
+          required:
+            - description
+            - severity
+            - ticketType
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicket: '#/components/schemas/TroubleTicket_FVO'
+    TroubleTicket_MVO:
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - type: object
+          description: >-
+            A trouble ticket is a record of an issue that is created, tracked, and managed by a
+            trouble ticket management system
+          properties:
+            name:
+              type: string
+              description: >-
+                Name of the trouble ticket, typically a short description provided by the user that
+                create the ticket
+            description:
+              type: string
+              description: Description of the trouble or issue
+            severity:
+              type: string
+              description: >-
+                The severity of the issue. Indicate the implication of the issue on the expected
+                functionality e.g. of a system, application, service etc.. 
+
+                Severity values can be for example : Critical, Major, Minor
+            ticketType:
+              type: string
+              description: 'Represent a business type of the trouble ticket e.g. incident, complain, request'
+            attachment:
+              type: array
+              items:
+                $ref: '#/components/schemas/AttachmentRefOrValue_MVO'
+              description: >-
+                File(s) attached to the trouble ticket. e.g. picture of broken device, scanning of a
+                bill or charge
+            channel:
+              $ref: '#/components/schemas/ChannelRef_MVO'
+            requestedResolutionDate:
+              type: string
+              format: date-time
+              description: The resolution date requested by the user
+            expectedResolutionDate:
+              type: string
+              format: date-time
+              description: The expected resolution date determined by the trouble ticket system
+            resolutionDate:
+              type: string
+              format: date-time
+              description: The date and time the trouble ticket was resolved
+            externalIdentifier:
+              type: array
+              items:
+                $ref: '#/components/schemas/ExternalIdentifier_MVO'
+            note:
+              type: array
+              items:
+                $ref: '#/components/schemas/Note_MVO'
+              description: The note(s) that are associated to the ticket.
+            priority:
+              type: string
+              description: >-
+                The priority of the trouble ticket and how quickly the issue should be resolved.
+                Example: Critical, High, Medium, Low. The value is set by the ticket management
+                system considering the severity, ticket type etc...
+            relatedEntity:
+              type: array
+              items:
+                $ref: '#/components/schemas/RelatedEntity_MVO'
+              description: >-
+                An entity that is related to the ticket such as a bill, a product, etc. The entity
+                against which the ticket is associated.
+            relatedParty:
+              type: array
+              items:
+                $ref: '#/components/schemas/RelatedPartyRefOrPartyRoleRef_MVO'
+              description: The related party(ies) that are associated to the ticket.
+            status:
+              $ref: '#/components/schemas/TroubleTicketStatusType'
+            statusChangeReason:
+              type: string
+              description: The reason for changing the status
+            statusChangeHistory:
+              type: array
+              items:
+                $ref: '#/components/schemas/StatusChange_MVO'
+              description: The status change history that are associated to the ticket. Populated by the server
+            troubleTicketRelationship:
+              type: array
+              items:
+                $ref: '#/components/schemas/TroubleTicketRelationship_MVO'
+              description: >-
+                A list of trouble ticket relationships (TroubleTicketRelationship [*]). Represents a
+                relationship between trouble tickets
+            troubleTicketSpecification:
+              $ref: '#/components/schemas/TroubleTicketSpecificationRef_MVO'
+            troubleTicketCharacteristic:
+              type: array
+              items:
+                $ref: '#/components/schemas/Characteristic_MVO'
+              description: List of characteristics of the trouble ticket
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicket: '#/components/schemas/TroubleTicket_MVO'
+    TroubleTicket_RES:
+      type: object
+      description: Response object for TroubleTicket
+      allOf:
+        - $ref: '#/components/schemas/TroubleTicket'
+      required:
+        - id
+        - href
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          TroubleTicket: '#/components/schemas/TroubleTicket'
+    Error:
+      discriminator:
+        propertyName: '@type'
+        mapping:
+          Error: '#/components/schemas/Error'
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - type: object
+          required:
+            - code
+            - reason
+          properties:
+            code:
+              type: string
+              description: 'Application relevant detail, defined in the API or a common list.'
+            reason:
+              type: string
+              description: Explanation of the reason for the error which can be shown to a client user.
+            message:
+              type: string
+              description: >-
+                More details and corrective actions related to the error which can be shown to a
+                client user.
+            status:
+              type: string
+              description: HTTP Error code extension
+            referenceError:
+              type: string
+              description: URI of documentation describing the error.
+      description: 'Used when an API throws an Error, typically with a HTTP error response-code (3xx, 4xx, 5xx)'
+    Hub_FVO:
+      type: object
+      description: >-
+        Sets the communication endpoint address the service instance must use to deliver
+        notification information
+      required:
+        - callback
+      allOf:
+        - $ref: '#/components/schemas/Extensible'
+        - properties:
+            callback:
+              type: string
+              description: The callback being registered.
+            query:
+              type: string
+              description: additional data to be passed
+    Hub:
+      type: object
+      description: >-
+        Sets the communication endpoint address the service instance must use to deliver
+        notification information
+      allOf:
+        - $ref: '#/components/schemas/Entity'
+        - properties:
+            id:
+              type: string
+              description: Id of the listener
+            callback:
+              type: string
+              description: The callback being registered.
+            query:
+              type: string
+              description: additional data to be passed
+          required:
+            - callback
+    JsonPatchOperations:
+      description: JSONPatch Operations document as defined by RFC 6902
+      type: array
+      items:
+        $ref: '#/components/schemas/JsonPatch'
+  parameters:
+    Id:
+      name: id
+      required: true
+      schema:
+        type: string
+      in: path
+      description: Identifier of the Resource
+    Fields:
+      name: fields
+      in: query
+      description: Comma-separated properties to be provided in response
+      schema:
+        type: string
+    Offset:
+      name: offset
+      in: query
+      description: Requested index for start of resources to be provided in response
+      schema:
+        type: integer
+    Limit:
+      name: limit
+      in: query
+      description: Requested number of resources to be provided in response
+      schema:
+        type: integer
+    Before:
+      name: before
+      in: query
+      description: An opaque string value representing the page results before the cursor value
+      schema:
+        type: string
+    After:
+      name: after
+      in: query
+      description: An opaque string value representing the page results after the cursor value
+      schema:
+        type: string
+    Sort:
+      name: sort
+      in: query
+      description: >-
+        The default direction is Ascending order, the use of the modifier in front of the sort field
+        name, “-“, changes the sort order direction.
+      schema:
+        type: string
+    Filter:
+      name: filter
+      in: query
+      description: Filter a collection using JSONPath
+      schema:
+        type: string
+        example: 'attachment[?(@size==300)]'
+  requestBodies:
+    TroubleTicket_FVO:
+      description: The TroubleTicket to be created
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicket_FVO'
+          examples:
+            TroubleTicket_create_example:
+              $ref: '#/components/examples/TroubleTicket_create_example_request'
+      required: true
+    TroubleTicket_MVO:
+      description: The TroubleTicket to be patched
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicket_MVO'
+          examples:
+            TroubleTicket_partialupdate_example_application_json:
+              $ref: '#/components/examples/TroubleTicket_partialupdate_example_application_json_request'
+        application/merge-patch+json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicket_MVO'
+          examples:
+            TroubleTicket_partialupdate_example_application_merge_json:
+              $ref: >-
+                #/components/examples/TroubleTicket_partialupdate_example_application_merge_json_request
+        application/json-patch+json:
+          schema:
+            $ref: '#/components/schemas/JsonPatchOperations'
+          examples:
+            TroubleTicket_partialupdate_example_application_json_patch:
+              $ref: >-
+                #/components/examples/TroubleTicket_partialupdate_example_application_json_patch_request
+        application/json-patch-query+json:
+          schema:
+            $ref: '#/components/schemas/JsonPatchOperations'
+          examples:
+            TroubleTicket_partialupdate_example_application_json_patch_query:
+              $ref: >-
+                #/components/examples/TroubleTicket_partialupdate_example_application_json_patch_query_request
+      required: true
+    TroubleTicketCreateEvent:
+      description: TroubleTicket create Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketCreateEvent'
+          examples:
+            TroubleTicketCreateEvent:
+              $ref: '#/components/examples/TroubleTicketCreateEvent_request'
+      required: true
+    TroubleTicketAttributeValueChangeEvent:
+      description: TroubleTicket attributeValueChange Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketAttributeValueChangeEvent'
+          examples:
+            TroubleTicketAttributeValueChangeEvent:
+              $ref: '#/components/examples/TroubleTicketAttributeValueChangeEvent_request'
+      required: true
+    TroubleTicketStatusChangeEvent:
+      description: TroubleTicket statusChange Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketStatusChangeEvent'
+          examples:
+            TroubleTicketStatusChangeEvent:
+              $ref: '#/components/examples/TroubleTicketStatusChangeEvent_request'
+      required: true
+    TroubleTicketDeleteEvent:
+      description: TroubleTicket delete Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketDeleteEvent'
+          examples:
+            TroubleTicketDeleteEvent:
+              $ref: '#/components/examples/TroubleTicketDeleteEvent_request'
+      required: true
+    TroubleTicketResolvedEvent:
+      description: TroubleTicket resolved Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketResolvedEvent'
+          examples:
+            TroubleTicketResolvedEvent:
+              $ref: '#/components/examples/TroubleTicketResolvedEvent_request'
+      required: true
+    TroubleTicketInformationRequiredEvent:
+      description: TroubleTicket informationRequired Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketInformationRequiredEvent'
+          examples:
+            TroubleTicketInformationRequiredEvent:
+              $ref: '#/components/examples/TroubleTicketInformationRequiredEvent_request'
+      required: true
+    TroubleTicketSpecification_FVO:
+      description: The TroubleTicketSpecification to be created
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecification_FVO'
+          examples:
+            TroubleTicketSpecification_create_example:
+              $ref: '#/components/examples/TroubleTicketSpecification_create_example_request'
+      required: true
+    TroubleTicketSpecification_MVO:
+      description: The TroubleTicketSpecification to be patched
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecification_MVO'
+          examples:
+            TroubleTicketSpecification_partialupdate_application_json:
+              $ref: >-
+                #/components/examples/TroubleTicketSpecification_partialupdate_application_json_request
+        application/merge-patch+json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecification_MVO'
+          examples:
+            TroubleTicketSpecification_partialupdate_application_merge_json:
+              $ref: >-
+                #/components/examples/TroubleTicketSpecification_partialupdate_application_merge_json_request
+        application/json-patch+json:
+          schema:
+            $ref: '#/components/schemas/JsonPatchOperations'
+          examples:
+            TroubleTicketSpecification_partialupdate_application_json_patch:
+              $ref: >-
+                #/components/examples/TroubleTicketSpecification_partialupdate_application_json_patch_request
+        application/json-patch-query+json:
+          schema:
+            $ref: '#/components/schemas/JsonPatchOperations'
+          examples:
+            TroubleTicketSpecification_partialupdate_application_json_patch_query:
+              $ref: >-
+                #/components/examples/TroubleTicketSpecification_partialupdate_application_json_patch_query_request
+      required: true
+    TroubleTicketSpecificationCreateEvent:
+      description: TroubleTicketSpecification create Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecificationCreateEvent'
+          examples:
+            TroubleTicketSpecificationCreateEvent:
+              $ref: '#/components/examples/TroubleTicketSpecificationCreateEvent_request'
+      required: true
+    TroubleTicketSpecificationAttributeValueChangeEvent:
+      description: TroubleTicketSpecification attributeValueChange Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecificationAttributeValueChangeEvent'
+          examples:
+            TroubleTicketSpecificationAttributeValueChangeEvent:
+              $ref: '#/components/examples/TroubleTicketSpecificationAttributeValueChangeEvent_request'
+      required: true
+    TroubleTicketSpecificationStatusChangeEvent:
+      description: TroubleTicketSpecification statusChange Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecificationStatusChangeEvent'
+          examples:
+            TroubleTicketSpecificationStatusChangeEvent:
+              $ref: '#/components/examples/TroubleTicketSpecificationStatusChangeEvent_request'
+      required: true
+    TroubleTicketSpecificationDeleteEvent:
+      description: TroubleTicketSpecification delete Event payload
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecificationDeleteEvent'
+          examples:
+            TroubleTicketSpecificationDeleteEvent:
+              $ref: '#/components/examples/TroubleTicketSpecificationDeleteEvent_request'
+      required: true
+    Hub_FVO:
+      description: Data containing the callback endpoint to deliver the information
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Hub_FVO'
+          examples:
+            Basic Hub Example Request:
+              value:
+                '@type': Hub
+                callback: 'https://host/tmf-api/specificAPIName/v5/listener/specificEventListener'
+                query: data
+      required: true
+  responses:
+    '200':
+      description: OK
+    '202':
+      description: Accepted
+    '204':
+      description: Deleted
+    '400':
+      description: Bad Request
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Bad Request Error
+              value:
+                '@type': Error
+                code: ERR400
+                reason: Bad Request
+                message: >-
+                  The server could not understand the request due to invalid syntax. Please correct
+                  the syntax and try again.
+                referenceError: 'https://host/errors'
+    '401':
+      description: Unauthorized
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Unauthorized Error
+              value:
+                '@type': Error
+                code: ERR401
+                reason: Unauthorized
+                message: >-
+                  You are not authorized to access the requested resource. Please provide the
+                  correct credentials.
+                referenceError: 'https://host/errors'
+    '403':
+      description: Forbidden
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Forbidden Error
+              value:
+                '@type': Error
+                code: ERR403
+                reason: Forbidden
+                message: >-
+                  You don't have the permission to access the requested resource. It is either
+                  read-protected or not readable by the server.
+                referenceError: 'https://host/errors'
+    '404':
+      description: Not Found
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Not Found Error
+              value:
+                '@type': Error
+                code: ERR404
+                reason: Not Found
+                message: The requested URL was not found on the server.
+                referenceError: 'https://host/errors'
+    '405':
+      description: Method Not allowed
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Method Not allowed Error
+              value:
+                '@type': Error
+                code: ERR405
+                reason: Method Not allowed
+                message: The method is not allowed for the requested URL.
+                referenceError: 'https://host/errors'
+    '409':
+      description: Conflict
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Conflict Error
+              value:
+                '@type': Error
+                code: ERR409
+                reason: Conflict
+                message: >-
+                  The request could not be completed due to a conflict with the current state of the
+                  target resource.
+                referenceError: 'https://host/errors'
+    '500':
+      description: Internal Server Error
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Internal Server Error example
+              value:
+                '@type': Error
+                code: ERR500
+                reason: Internal Server Error
+                message: The server encountered an internal error. Please contact the system administrator.
+                referenceError: 'https://host/errors'
+    '501':
+      description: Not Implemented
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Not Implemented Error
+              value:
+                '@type': Error
+                code: ERR501
+                reason: The requested operation is not implemented
+                message: >-
+                  The requested operation is not implemented. Please contact the system
+                  administrator.
+                referenceError: 'https://host/errors'
+    '503':
+      description: Service Unavailable
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Service Unavailable Error
+              value:
+                '@type': Error
+                code: ERR503
+                reason: Service Unavailable
+                message: The service is currently unavailable. Please try again later.
+                referenceError: 'https://host/errors'
+    200TroubleTicketArray:
+      description: Success
+      headers:
+        X-Total-Count:
+          $ref: '#/components/headers/X-Total-Count'
+        X-Result-Count:
+          $ref: '#/components/headers/X-Result-Count'
+      content:
+        application/json:
+          schema:
+            type: array
+            items:
+              $ref: '#/components/schemas/TroubleTicket_RES'
+          examples:
+            TroubleTicket_list_with_filter_and_fields_example:
+              $ref: '#/components/examples/TroubleTicket_list_with_filter_and_fields_example_response'
+            TroubleTicket_list_example:
+              $ref: '#/components/examples/TroubleTicket_list_example_response'
+    200TroubleTicket_Get:
+      description: Success
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicket_RES'
+          examples:
+            TroubleTicket_retrieve_example:
+              $ref: '#/components/examples/TroubleTicket_retrieve_example_response'
+    200TroubleTicket_Patch:
+      description: Success
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicket_RES'
+          examples:
+            TroubleTicket_partialupdate_example_application_json:
+              $ref: '#/components/examples/TroubleTicket_partialupdate_example_application_json_response'
+    201TroubleTicket:
+      description: OK/Created
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicket_RES'
+          examples:
+            TroubleTicket_create_example:
+              $ref: '#/components/examples/TroubleTicket_create_example_response'
+    200TroubleTicketSpecificationArray:
+      description: Success
+      headers:
+        X-Total-Count:
+          $ref: '#/components/headers/X-Total-Count'
+        X-Result-Count:
+          $ref: '#/components/headers/X-Result-Count'
+      content:
+        application/json:
+          schema:
+            type: array
+            items:
+              $ref: '#/components/schemas/TroubleTicketSpecification_RES'
+          examples:
+            TroubleTicketSpecification_with_filter_and_fields_list_example:
+              $ref: >-
+                #/components/examples/TroubleTicketSpecification_with_filter_and_fields_list_example_response
+            TroubleTicketSpecification_list_example:
+              $ref: '#/components/examples/TroubleTicketSpecification_list_example_response'
+    200TroubleTicketSpecification_Get:
+      description: Success
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecification_RES'
+          examples:
+            TroubleTicketSpecification_retrieve_example:
+              $ref: '#/components/examples/TroubleTicketSpecification_retrieve_example_response'
+    200TroubleTicketSpecification_Patch:
+      description: Success
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecification_RES'
+          examples:
+            TroubleTicketSpecification_partialupdate_application_json:
+              $ref: >-
+                #/components/examples/TroubleTicketSpecification_partialupdate_application_json_response
+    201TroubleTicketSpecification:
+      description: OK/Created
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/TroubleTicketSpecification_RES'
+          examples:
+            TroubleTicketSpecification_create_example:
+              $ref: '#/components/examples/TroubleTicketSpecification_create_example_response'
+    Error:
+      description: Error
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Error'
+          examples:
+            basic:
+              summary: Error example
+              value:
+                '@type': Error
+                code: ERR001
+                reason: Missing information
+                message: Please provide the additional example information
+                referenceError: 'https://host/errors'
+    Hub:
+      description: Notified
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/Hub'
+          examples:
+            basic:
+              summary: Hub example
+              value:
+                '@type': Hub
+                callback: 'https://host/tmf-api/specificAPIName/v5/listener/specificEventListener'
+  headers:
+    X-Total-Count:
+      description: Total number of items matching criteria
+      schema:
+        type: integer
+    X-Result-Count:
+      description: Actual number of items returned in the response body
+      schema:
+        type: integer
+  securitySchemes: {}
+  examples:
+    TroubleTicket_list_with_filter_and_fields_example_response:
+      value:
+        - id: '3180'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3180'
+          name: complaint over last bill
+          priority: High
+          '@type': TroubleTicket
+        - id: '3256'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3256'
+          name: Commerce problem
+          priority: High
+          '@type': TroubleTicket
+        - id: '4563'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/5/troubleTicket/4563'
+          name: Network latency
+          priority: High
+          '@type': TroubleTicket
+      description: >-
+        Here's an example of a request for retrieving a list of trouble ticket(s). The given filter
+        criteria is priority High and fields id,href,name,@type,priority
+    TroubleTicket_list_example_response:
+      value:
+        - id: '3256'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3256'
+          creationDate: '2023-05-31T07:34:45.968Z'
+          description: 'I ordered a new mobile line 2 week ago, but the mobile device did not arrived'
+          expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+          lastUpdate: '2023-05-31T07:34:45.968Z'
+          name: Commerce problem
+          priority: High
+          requestedResolutionDate: '2022-05-31T07:34:45.968Z'
+          resolutionDate: '2023-05-31T07:34:45.968Z'
+          severity: Minor
+          status: resolved
+          statusChangeDate: '2023-05-31T07:34:45.968Z'
+          statusChangeReason: Apply full credit
+          ticketType: Commerce Issue
+          troubleTicketCharacteristic:
+            - id: '1'
+              name: orderReferenceNumber
+              valueType: string
+              value: Order_888
+              '@type': StringCharacteristic
+            - id: '2'
+              name: orderCreationDate
+              valueType: string
+              value: '2023-05-31'
+              '@type': StringCharacteristic
+          attachment:
+            - description: Scanned Order
+              attachmentType: orderCopy
+              mimeType: image/png
+              name: New Mobile Order
+              url: 'https://mycsp.com:7070/docloader?docnum=3534888'
+              '@type': AttachmentRef
+          channel:
+            id: '8774'
+            name: self service
+            '@type': ChannelRef
+          note:
+            - id: '77458'
+              author: Jack Smith
+              date: '2023-05-31T07:34:45.968Z'
+              text: I did not recived the mobile device
+              '@type': Note
+          relatedEntity:
+            - role: disputedOrder
+              '@type': RelatedEntity
+              entity:
+                id: Order_888
+                href: 'https://mycsp.com:8080/tmf-api/productOrdering/v5/productOrder/Order_888'
+                name: New Mobile Order
+                '@type': EntityRef
+                '@referredType': ProductOrder
+          relatedParty:
+            - role: member
+              partyOrPartyRole:
+                id: '9866'
+                href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+                name: Sandy Smith
+                '@type': PartyRef
+                '@referredType': Individual
+              '@type': RelatedPartyRefOrPartyRoleRef
+            - role: reporter
+              partyOrPartyRole:
+                id: '9877'
+                name: Jacob Jac Miller
+                '@type': PartyRef
+                '@referredType': Individual
+              '@type': RelatedPartyRefOrPartyRoleRef
+            - role: customer
+              partyOrPartyRole:
+                id: '9176'
+                href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/customer/9176'
+                name: Jack Smith
+                '@type': PartyRoleRef
+                '@referredType': Customer
+              '@type': RelatedPartyRefOrPartyRoleRef
+          statusChangeHistory:
+            - statusChangeDate: '2023-05-28T07:34:45.968Z'
+              statusChangeReason: 'trouble ticket created '
+              status: acknowledged
+              '@type': StatusChange
+            - statusChangeDate: '2023-05-28T08:34:45.968Z'
+              statusChangeReason: start process
+              status: inProgress
+              '@type': StatusChange
+            - statusChangeDate: '2023-05-31T07:34:45.968Z'
+              statusChangeReason: Resend new device to the customer
+              status: resolved
+              '@type': StatusChange
+          '@type': TroubleTicket
+        - id: '3180'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3180'
+          creationDate: '2022-05-31T07:34:45.968Z'
+          description: >-
+            I do not accept the last VOD charge, since the movie was constantly interrupted, I had
+            to quick watching the movie in the middle 
+          expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+          lastUpdate: '2022-05-31T07:34:45.968Z'
+          name: complaint over last bill
+          priority: High
+          requestedResolutionDate: '2022-05-31T07:34:45.968Z'
+          resolutionDate: '2022-05-31T07:34:45.968Z'
+          severity: Minor
+          status: resolved
+          statusChangeDate: '2022-05-31T07:34:45.968Z'
+          statusChangeReason: Apply full credit
+          ticketType: Bill Dispute
+          troubleTicketCharacteristic:
+            - id: '1'
+              name: disputeAmount
+              valueType: number
+              value: '40'
+              '@type': NumberCharacteristic
+            - id: '2'
+              name: creditAmount
+              valueType: number
+              value: '40'
+              characteristicRelationship:
+                - id: '4'
+                  relationshipType: dependency
+                  '@type': CharacteristicRelationship
+              '@type': NubmerCharacteristic
+            - id: '3'
+              name: currency
+              valueType: string
+              value: USD
+              '@type': StringCharacteristic
+            - id: '4'
+              name: creditReason
+              valueType: string
+              value: Network connectivity issues
+              '@type': StringCharacteristic
+          attachment:
+            - description: Scanned disputed bill
+              attachmentType: billCopy
+              mimeType: image/png
+              name: March Bill
+              url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+              '@type': AttachmentRef
+          channel:
+            id: '8774'
+            name: self service
+            '@type': ChannelRef
+          note:
+            - id: '77456'
+              author: Jack Smith
+              date: '2019-05-31T07:34:45.968Z'
+              text: 'This is quite important, please approach me as soon as possible'
+              '@type': Note
+          relatedEntity:
+            - role: disputedBill
+              '@type': RelatedEntity
+              entity:
+                id: '3472'
+                href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+                name: March 2019 Bill
+                '@type': EntityRef
+                '@referredType': CustomerBill
+          relatedParty:
+            - role: member
+              partyOrPartyRole:
+                id: '9866'
+                href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+                name: Sandy Smith
+                '@type': PartyRef
+                '@referredType': Individual
+              '@type': RelatedPartyRefOrPartyRoleRef
+            - role: reporter
+              partyOrPartyRole:
+                id: '9877'
+                name: Jacob Jac Miller
+                '@type': PartyRef
+                '@referredType': Individual
+              '@type': RelatedPartyRefOrPartyRoleRef
+            - role: customer
+              partyOrPartyRole:
+                id: '9176'
+                href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/customer/9176'
+                name: Jack Smith
+                '@type': PartyRoleRef
+                '@referredType': Customer
+              '@type': RelatedPartyRefOrPartyRoleRef
+          statusChangeHistory:
+            - statusChangeDate: '2022-05-28T07:34:45.968Z'
+              statusChangeReason: 'trouble ticket created '
+              status: acknowledged
+              '@type': StatusChange
+            - statusChangeDate: '2022-05-28T08:34:45.968Z'
+              statusChangeReason: start process
+              status: inProgress
+              '@type': StatusChange
+            - statusChangeDate: '2022-05-29T07:34:45.968Z'
+              statusChangeReason: Need more information from the customer
+              status: pending
+              '@type': StatusChange
+            - statusChangeDate: '2022-05-31T07:34:45.968Z'
+              statusChangeReason: Apply full credit
+              status: resolved
+              '@type': StatusChange
+          troubleTicketRelationship:
+            - id: '567433'
+              href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/567433'
+              name: Network Coverage
+              relationshipType: dependecy
+              '@type': TroubleTicketRelationship
+          externalIdentifier:
+            - id: '3331234'
+              owner: BMC Remedy
+              externalIdentifierType: Incident
+              '@type': ExternalIdentifier
+          '@type': TroubleTicket
+      description: Here's an example of a request for retrieving a list of trouble ticket(s).
+    TroubleTicket_retrieve_example_response:
+      value:
+        id: '3180'
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3180'
+        creationDate: '2022-05-31T07:34:45.968Z'
+        description: >-
+          I do not accept the last VOD charge, since the movie was constantly interrupted, I had to
+          quick watching the movie in the middle 
+        expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+        lastUpdate: '2022-05-31T07:34:45.968Z'
+        name: complaint over last bill
+        priority: High
+        requestedResolutionDate: '2022-05-31T07:34:45.968Z'
+        resolutionDate: '2022-05-31T07:34:45.968Z'
+        severity: Minor
+        status: resolved
+        statusChangeDate: '2022-05-31T07:34:45.968Z'
+        statusChangeReason: Apply full credit
+        ticketType: Bill Dispute
+        troubleTicketCharacteristic:
+          - id: '1'
+            name: disputeAmount
+            valueType: number
+            value: '40'
+            '@type': NumberCharacteristic
+          - id: '2'
+            name: creditAmount
+            valueType: number
+            value: '40'
+            characteristicRelationship:
+              - id: '4'
+                relationshipType: dependency
+                '@type': CharacteristicRelationship
+            '@type': NubmerCharacteristic
+          - id: '3'
+            name: currency
+            valueType: string
+            value: USD
+            '@type': StringCharacteristic
+          - id: '4'
+            name: creditReason
+            valueType: string
+            value: Network connectivity issues
+            '@type': StringCharacteristic
+        attachment:
+          - description: Scanned disputed bill
+            attachmentType: billCopy
+            mimeType: image/png
+            name: March Bill
+            url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+            '@type': AttachmentRef
+        channel:
+          id: '8774'
+          name: self service
+          '@type': ChannelRef
+        note:
+          - id: '77456'
+            author: Jack Smith
+            date: '2019-05-31T07:34:45.968Z'
+            text: 'This is quite important, please approach me as soon as possible'
+            '@type': Note
+        relatedEntity:
+          - role: disputedBill
+            '@type': RelatedEntity
+            entity:
+              id: '3472'
+              href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v4/customerBill/8297'
+              name: March 2019 Bill
+              '@type': EntityRef
+              '@referredType': CustomerBill
+        relatedParty:
+          - role: member
+            partyOrPartyRole:
+              id: '9866'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+              name: Sandy Smith
+              '@type': PartyRef
+              '@referredType': Individual
+            '@type': RelatedPartyRefOrPartyRoleRef
+          - role: reporter
+            partyOrPartyRole:
+              id: '9877'
+              name: Jacob Jac Miller
+              '@type': PartyRef
+              '@referredType': Individual
+            '@type': RelatedPartyRefOrPartyRoleRef
+          - role: customer
+            partyOrPartyRole:
+              id: '9176'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v4/customer/9176'
+              name: Jack Smith
+              '@type': PartyRoleRef
+              '@referredType': Customer
+            '@type': RelatedPartyRefOrPartyRoleRef
+        statusChangeHistory:
+          - statusChangeDate: '2022-05-28T07:34:45.968Z'
+            statusChangeReason: 'trouble ticket created '
+            status: acknowledged
+            '@type': StatusChange
+          - statusChangeDate: '2022-05-28T08:34:45.968Z'
+            statusChangeReason: start process
+            status: inProgress
+            '@type': StatusChange
+          - statusChangeDate: '2022-05-29T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            status: pending
+            '@type': StatusChange
+          - statusChangeDate: '2022-05-31T07:34:45.968Z'
+            statusChangeReason: Apply full credit
+            status: resolved
+            '@type': StatusChange
+        troubleTicketRelationship:
+          - id: '567433'
+            href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/567433'
+            name: Network Coverage
+            relationshipType: dependecy
+            '@type': TroubleTicketRelationship
+        externalIdentifier:
+          - id: '3331234'
+            owner: BMC Remedy
+            externalIdentifierType: Incident
+            '@type': ExternalIdentifier
+        '@schemaLocation': 'https://mycsp.com:8080/tmf-api/troubleTicket/5/schema/troubleTicket.yaml'
+        '@type': TroubleTicket
+      description: Here's an example of a request for retrieving a spesific trouble ticket with id 3180.
+    TroubleTicketSpecification_with_filter_and_fields_list_example_response:
+      value:
+        - id: '453180'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/453180'
+          name: Billing Dispute
+          lifecycleStatus: active
+          '@type': TroubleTicketSpecification
+        - id: '453256'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/453256'
+          name: Technical TroubleTicket Specification
+          lifecycleStatus: active
+          '@type': TroubleTicketSpecification
+        - id: '454563'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/5/troubleTicketSpecification/454563'
+          name: Network and latency TicketSpecification
+          lifecycleStatus: active
+          '@type': TroubleTicketSpecification
+      description: >-
+        Here's an example of a request for retrieving a list of trouble ticket specification(s). The
+        given criteria is lifecycleStatus is active, and fields id,href,name,@type,lifecycleStatus
+    TroubleTicketSpecification_list_example_response:
+      value:
+        - href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/453180'
+          id: '453180'
+          name: Bill Dispute
+          lifecycleStatus: active
+          '@type': TroubleTicketSpecification
+          description: >-
+            This trouble ticket specification describes the characteristic and rules to apply when
+            creating a Trouble Ticket for Billing issues...
+          creationDate: '2022-05-22T10:36:30.709Z'
+          lastUpdate: '2022-06-22T10:36:30.709Z'
+          relatedParty:
+            - role: approver
+              '@referredType': Individual
+              partyOrPartyRole:
+                id: '6678'
+                href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+                name: Sara Smith
+                '@type': PartyRef
+                '@referredType': Individual
+              '@type': RelatedPartyRefOrPartyRoleRef
+          specCharacteristic:
+            - id: '1'
+              configurable: true
+              description: >-
+                The amount that is on dispute, it can be the entire charge amount or partial amount
+                of the charge
+              maxCardinality: 0
+              minCardinality: 1
+              name: disputeAmount
+              valueType: number
+              '@type': CharacteristicSpecification
+            - id: '2'
+              configurable: true
+              description: >-
+                The positive amount to be credit, it can be equal or less than the dispute amount.
+                In case credit is given a credit reason must be provided. In case no credit is given
+                a reject reason must be provided
+              maxCardinality: 0
+              minCardinality: 1
+              name: creditAmount
+              valueType: number
+              charSpecRelationship:
+                - '@type': CharacteristicSpecificationRelationship
+                  characteristicSpecificationId: '3'
+                  name: creditReason
+                  relationshipType: dependency
+                  parentSpecificationId: '25632415'
+              '@type': CharacteristicSpecification
+            - id: '3'
+              configurable: true
+              description: >-
+                The reason for giving the credit, in case credit apply. In case no credit apply a
+                reject reason must be provided
+              maxCardinality: 0
+              minCardinality: 1
+              name: creditReason
+              valueType: string
+              '@type': CharacteristicSpecification
+            - id: '4'
+              configurable: true
+              description: 'The reason for rejecting the dispute, in case no credit apply.'
+              maxCardinality: 0
+              minCardinality: 1
+              name: rejectReason
+              valueType: string
+              '@type': CharacteristicSpecification
+            - id: '5'
+              configurable: true
+              description: Currency (ISO4217 norm uses 3 letters to define the currency)
+              maxCardinality: 0
+              minCardinality: 1
+              name: currency
+              valueType: string
+              '@type': CharacteristicSpecification
+          validFor:
+            startDateTime: '2023-06-22T23:20:50.52Z'
+          version: '1'
+        - id: '453256'
+          href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/453256'
+          name: Commerce Issue
+          lifecycleStatus: active
+          '@type': TroubleTicketSpecification
+          description: >-
+            This trouble ticket specification describes the characteristic and rules to apply when
+            creating a Trouble Ticket for Commerce issues...
+          creationDate: '2023-06-22T10:36:30.709Z'
+          lastUpdate: '2023-06-23T10:36:30.709Z'
+          relatedParty:
+            - role: approver
+              '@referredType': Individual
+              partyOrPartyRole:
+                id: '6678'
+                href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+                name: Sara Smith
+                '@type': PartyRef
+                '@referredType': Individual
+              '@type': RelatedPartyRefOrPartyRoleRef
+          specCharacteristic:
+            - id: '1'
+              configurable: true
+              description: The Order reference nubmer that has an issue
+              maxCardinality: 0
+              minCardinality: 1
+              name: orderReferenceNumber
+              valueType: string
+              '@type': CharacteristicSpecification
+            - id: '2'
+              configurable: true
+              description: The creation date of the order that has an issue.
+              maxCardinality: 0
+              minCardinality: 0
+              name: orderCreationDate
+              valueType: string
+              '@type': CharacteristicSpecification
+          validFor:
+            startDateTime: '2023-06-23T23:20:50.52Z'
+          version: '1'
+      description: >-
+        Here's an example of a request for retrieving a list of trouble ticket
+        specification(s).       
+    TroubleTicketSpecification_retrieve_example_response:
+      value:
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+        id: '25632415'
+        name: Bill Dispute
+        '@type': TroubleTicketSpecification
+        description: >-
+          This trouble ticket specification describes the characteristic and rules to apply when
+          creating a Trouble Ticket...
+        creationDate: '2022-05-22T10:36:30.709Z'
+        lastUpdate: '2022-06-22T10:36:30.709Z'
+        relatedParty:
+          - role: approver
+            '@referredType': Individual
+            partyOrPartyRole:
+              id: '6678'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+              name: Sara Smith
+              '@type': PartyRef
+              '@referredType': Individual
+            '@type': RelatedPartyRefOrPartyRoleRef
+        lifecycleStatus: active
+        specCharacteristic:
+          - id: '1'
+            configurable: true
+            description: >-
+              The amount that is on dispute, it can be the entire charge amount or partial amount of
+              the charge
+            maxCardinality: 0
+            minCardinality: 1
+            name: disputeAmount
+            valueType: number
+            '@type': CharacteristicSpecification
+          - id: '2'
+            configurable: true
+            description: >-
+              The positive amount to be credit, it can be equal or less than the dispute amount. In
+              case credit is given a credit reason must be provided. In case no credit is given a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditAmount
+            valueType: number
+            charSpecRelationship:
+              - '@type': CharacteristicSpecificationRelationship
+                characteristicSpecificationId: '3'
+                name: creditReason
+                relationshipType: dependency
+                parentSpecificationId: '25632415'
+            '@type': CharacteristicSpecification
+          - id: '3'
+            configurable: true
+            description: >-
+              The reason for giving the credit, in case credit apply. In case no credit apply a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '4'
+            configurable: true
+            description: 'The reason for rejecting the dispute, in case no credit apply.'
+            maxCardinality: 0
+            minCardinality: 1
+            name: rejectReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '5'
+            configurable: true
+            description: Currency (ISO4217 norm uses 3 letters to define the currency)
+            maxCardinality: 0
+            minCardinality: 1
+            name: currency
+            valueType: string
+            '@type': CharacteristicSpecification
+        validFor:
+          startDateTime: '2022-06-22T23:20:50.52Z'
+        version: '1'
+      description: Here's an example of a request for retrieving a spesific trouble ticket specification.
+    TroubleTicket_create_example_request:
+      value:
+        name: complaint over last bill
+        description: >-
+          I do not accept the last VOD charge, since the movie was constantly interrupted, I had to
+          quick watching the movie in the middle 
+        severity: Major
+        status: inProgress
+        ticketType: Bill Dispute
+        expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+        requestedResolutionDate: '2022-05-31T07:34:45.968Z'
+        attachment:
+          - id: '34345'
+            description: Scanned disputed bill
+            attachmentType: billCopy
+            mimeType: image/png
+            name: March Bill
+            url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+            '@type': AttachmentRef
+        channel:
+          id: '8774'
+          name: self service
+          '@type': ChannelRef
+        note:
+          - id: '77456'
+            author: Jack Smith
+            date: '2022-05-31T07:34:45.968Z'
+            text: 'This is quite important, please aproch me as soon as posible'
+            '@type': Note
+        relatedEntity:
+          - role: disputedBill
+            '@type': RelatedEntity
+            entity:
+              id: '3472'
+              href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+              name: March 2019 Bill
+              '@type': EntityRef
+              '@referredType': CustomerBill
+        relatedParty:
+          - role: member
+            '@type': RelatedPartyRefOrPartyRoleRef
+            partyOrPartyRole:
+              id: '9866'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+              name: Sandy Smith
+              '@type': PartyRef
+              '@referredType': Individual
+          - role: reporter
+            '@type': RelatedPartyRefOrPartyRoleRef
+            partyOrPartyRole:
+              id: '9867'
+              name: Jacob Jac Miller
+              '@type': PartyRef
+              '@referredType': Individual
+          - role: customer
+            '@type': RelatedPartyRefOrPartyRoleRef
+            partyOrPartyRole:
+              id: '9176'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v4/customer/9176'
+              name: Jack Smith
+              '@type': PartyRoleRef
+              '@referredType': Customer
+        '@type': TroubleTicket
+      description: >-
+        POST trouble ticket request example - only a subset of trouble ticket attributes are used in
+        this example
+    TroubleTicket_create_example_response:
+      value:
+        id: '3180'
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v4/troubleTicket/3180'
+        creationDate: '2022-05-31T07:34:45.968Z'
+        description: >-
+          I do not accept the last VOD charge, since the movie was constantly interrupted, I had to
+          quick watching the movie in the middle 
+        expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+        lastUpdate: '2022-05-31T07:34:45.968Z'
+        name: complaint over last bill
+        priority: High
+        requestedResolutionDate: '2019-05-31T07:34:45.968Z'
+        severity: Major
+        status: pending
+        statusChangeDate: '2019-05-31T07:34:45.968Z'
+        statusChangeReason: Need more information from the customer
+        ticketType: Bill Dispute
+        attachment:
+          - description: Scanned disputed bill
+            attachmentType: billCopy
+            mimeType: image/png
+            name: March Bill
+            url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+            '@type': AttachmentRef
+        channel:
+          id: '8774'
+          name: self service
+          '@type': ChannelRef
+        note:
+          - id: '77456'
+            author: Jack Smith
+            date: '2019-05-31T07:34:45.968Z'
+            text: 'This is quite important, please approach  me as soon as possible'
+            '@type': Note
+        relatedEntity:
+          - role: disputedBill
+            '@type': RelatedEntity
+            entity:
+              id: '3472'
+              href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+              name: March 2019 Bill
+              '@type': EntityRef
+              '@referredType': CustomerBill
+        relatedParty:
+          - role: member
+            partyOrPartyRole:
+              id: '9866'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+              name: Sandy Smith
+              '@type': PartyRef
+              '@referredType': Individual
+            '@type': RelatedPartyRefOrPartyRoleRef
+          - role: reporter
+            partyOrPartyRole:
+              id: '9877'
+              name: Jacob Jac Miller
+              '@type': PartyRef
+              '@referredType': Individual
+            '@type': RelatedPartyRefOrPartyRoleRef
+          - role: customer
+            partyOrPartyRole:
+              id: '9176'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v4/customer/9176'
+              name: Jack Smith
+              '@type': PartyRoleRef
+              '@referredType': Customer
+            '@type': RelatedPartyRefOrPartyRoleRef
+        statusChangeHistory:
+          - statusChangeDate: '2019-05-31T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            status: pending
+            '@type': StatusChange
+        troubleTicketRelationship:
+          - id: '567433'
+            href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/567433'
+            name: Network Coverage
+            relationshipType: dependecy
+            '@type': TroubleTicketRelationship
+        '@schemaLocation': 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/schema/troubleTicket.yaml'
+        '@type': TroubleTicket
+      description: POST Trouble Ticket response description.
+    TroubleTicketSpecification_create_example_request:
+      value:
+        '@type': TroubleTicketSpecification
+        description: >-
+          This trouble ticket specification describes the characteristic and rules to apply when
+          creating a Trouble Ticket...
+        name: Bill Dispute
+        relatedParty:
+          - role: approver
+            '@type': RelatedPartyRefOrPartyRoleRef
+            '@referredType': Individual
+            partyOrPartyRole:
+              id: '6678'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+              name: Sara Smith
+              '@type': PartyRef
+              '@referredType': Individual
+        specCharacteristic:
+          - id: '1'
+            configurable: true
+            description: >-
+              The amount that is on dispute, it can be the entire charge amount or partial amount of
+              the charge
+            maxCardinality: 0
+            minCardinality: 1
+            name: disputeAmount
+            valueType: number
+            '@type': CharacteristicSpecification
+          - id: '2'
+            configurable: true
+            description: >-
+              The positive amount to be credit, it can be equal or less than the dispute amount. In
+              case credit is given a credit reason must be provided. In case no credit is given a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditAmount
+            valueType: number
+            '@type': CharacteristicSpecification
+            charSpecRelationship:
+              - '@type': CharacteristicSpecRelationship
+                '@baseType': CharacteristicSpecRelationship
+                '@schemaLocation': /someUri
+                characteristicSpecificationId: '3'
+                name: creditReason
+                relationshipType: dependency
+                parentSpecificationId: '25632415'
+          - id: '3'
+            configurable: true
+            description: >-
+              The reason for giving the credit, in case credit apply. In case no credit apply a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '4'
+            configurable: true
+            description: 'The reason for rejecting the dispute, in case no credit apply.'
+            maxCardinality: 0
+            minCardinality: 1
+            name: rejectReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '5'
+            configurable: true
+            description: Currency (ISO4217 norm uses 3 letters to define the currency)
+            maxCardinality: 0
+            minCardinality: 1
+            name: currency
+            valueType: string
+            '@type': CharacteristicSpecification
+        validFor:
+          startDateTime: '2022-06-22T23:20:50.52Z'
+        version: '1'
+      description: >-
+        POST trouble ticket request example - only a subset of trouble ticket specification
+        attributes are used in this example
+    TroubleTicketSpecification_create_example_response:
+      value:
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+        id: '25632415'
+        '@type': TroubleTicketSpecification
+        description: >-
+          This trouble ticket specification describes the characteristic and rules to apply when
+          creating a Trouble Ticket...
+        creationDate: '2022-05-22T10:36:30.709Z'
+        lastUpdate: '2022-06-22T10:36:30.709Z'
+        name: Bill Dispute
+        relatedParty:
+          - role: approver
+            '@type': RelatedPartyRefOrPartyRoleRef
+            '@referredType': Individual
+            partyOrPartyRole:
+              id: '6678'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+              name: Sara Smith
+              '@type': PartyRef
+              '@referredType': Individual
+        lifecycleStatus: inDesgin
+        specCharacteristic:
+          - id: '1'
+            configurable: true
+            description: >-
+              The amount that is on dispute, it can be the entire charge amount or partial amount of
+              the charge
+            maxCardinality: 0
+            minCardinality: 1
+            name: disputeAmount
+            valueType: number
+            '@type': CharacteristicSpecification
+          - id: '2'
+            configurable: true
+            description: >-
+              The positive amount to be credit, it can be equal or less than the dispute amount. In
+              case credit is given a credit reason must be provided. In case no credit is given a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditAmount
+            valueType: number
+            '@type': CharacteristicSpecification
+            charSpecRelationship:
+              - '@type': CharacteristicSpecificationRelationship
+                '@schemaLocation': string
+                characteristicSpecificationId: '3'
+                name: creditReason
+                relationshipType: dependency
+                parentSpecificationId: '25632415'
+          - id: '3'
+            configurable: true
+            description: >-
+              The reason for giving the credit, in case credit apply. In case no credit apply a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '4'
+            configurable: true
+            description: 'The reason for rejecting the dispute, in case no credit apply.'
+            maxCardinality: 0
+            minCardinality: 1
+            name: rejectReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '5'
+            configurable: true
+            description: Currency (ISO4217 norm uses 3 letters to define the currency)
+            maxCardinality: 0
+            minCardinality: 1
+            name: currency
+            valueType: string
+            '@type': CharacteristicSpecification
+        validFor:
+          startDateTime: '2022-06-22T23:20:50.52Z'
+        version: '1'
+      description: POST Trouble Ticket Specification response description.
+    TroubleTicket_partialupdate_example_application_json_request:
+      value:
+        '@type': TroubleTicket
+        status: resolved
+        statusChangeReason: Give credit and resent bill to customer
+      description: >-
+        Here's an example of a request for updating a trouble ticket - set status to resolved. This
+        example illustrating patch application/json
+    TroubleTicket_partialupdate_example_application_json_response:
+      value:
+        id: '3180'
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3180'
+        creationDate: '2022-05-31T07:34:45.968Z'
+        description: >-
+          I do not accept the last VOD charge, since the movie was constantly interrupted, I had to
+          quick watching the movie in the middle 
+        expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+        lastUpdate: '2022-06-01T07:34:45.968Z'
+        name: complaint over last bill
+        priority: High
+        requestedResDateolutionDate: '2022-05-31T07:34:45.968Z'
+        resolutionDate: '2022-06-01T07:34:45.968Z'
+        severity: Major
+        status: resolved
+        statusChangeDate: '2022-06-01T07:34:45.968Z'
+        statusChangeReason: Give credit and resent bill to customer
+        ticketType: Bill Dispute
+        attachment:
+          - description: Scanned disputed bill
+            attachmentType: billCopy
+            mimeType: image/png
+            name: March Bill
+            url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+            '@type': AttachmentRef
+        channel:
+          id: '8774'
+          name: self service
+          '@type': ChannelRef
+        note:
+          - id: '77456'
+            author: Jack Smith
+            date: '2022-05-31T07:34:45.968Z'
+            text: 'This is quite important, please approach me as soon as possible'
+            '@type': Note
+        relatedEntity:
+          - id: '3472'
+            href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+            name: March 2022 Bill
+            role: disputedBill
+            '@type': RelatedEntity
+            '@referredType': CustomerBill
+        relatedParty:
+          - id: '9866'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/5/individual/9866'
+            name: Sandy Smith
+            role: member
+            '@type': PartyRef
+            '@referredType': Individual
+          - id: '9176'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/customer/9176'
+            name: Jack Smith
+            role: customer
+            '@type': PartyRoleRef
+            '@referredType': Customer
+        statusChangeHistory:
+          - statusChangeDate: '2022-05-31T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            status: pending
+            '@type': StatusChange
+          - changeDate: '2022-06-01T07:34:45.968Z'
+            changeReason: Give credit and resent bill to customer
+            status: resolved
+            '@type': StatusChange
+        troubleTicketRelationship:
+          - id: '567433'
+            href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/567433'
+            name: Network Coverage
+            relationshipType: dependecy
+            '@type': TroubleTicketRelationship
+        '@schemaLocation': 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/schema/troubleTicket.yml'
+        '@type': TroubleTicket
+      description: Response message
+    TroubleTicket_partialupdate_example_application_merge_json_request:
+      value:
+        '@type': TroubleTicket
+        status: resolved
+        statusChangeReason: Give credit and resent bill to customer
+      description: >-
+        Here's an example of a request for updating a trouble ticket - set status to resolved. This
+        example illustrating patch merge, When PATCH is implemeted merge syntaxt is mandatory
+    TroubleTicket_partialupdate_example_application_merge_json_response:
+      value:
+        id: '3180'
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3180'
+        creationDate: '2022-05-31T07:34:45.968Z'
+        description: >-
+          I do not accept the last VOD charge, since the movie was constantly interrupted, I had to
+          quick watching the movie in the middle 
+        expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+        lastUpdate: '2022-06-01T07:34:45.968Z'
+        name: complaint over last bill
+        priority: High
+        requestedResDateolutionDate: '2022-05-31T07:34:45.968Z'
+        resolutionDate: '2022-06-01T07:34:45.968Z'
+        severity: Major
+        status: resolved
+        statusChangeDate: '2022-06-01T07:34:45.968Z'
+        statusChangeReason: Give credit and resent bill to customer
+        ticketType: Bill Dispute
+        attachment:
+          - description: Scanned disputed bill
+            attachmentType: billCopy
+            mimeType: image/png
+            name: March Bill
+            url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+            '@type': AttachmentRef
+        channel:
+          id: '8774'
+          name: self service
+          '@type': ChannelRef
+        note:
+          - id: '77456'
+            author: Jack Smith
+            date: '2022-05-31T07:34:45.968Z'
+            text: 'This is quite important, please approach me as soon as possible'
+            '@type': Note
+        relatedEntity:
+          - id: '3472'
+            href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+            name: March 2022 Bill
+            role: disputedBill
+            '@type': RelatedEntity
+            '@referredType': CustomerBill
+        relatedParty:
+          - id: '9866'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/5/individual/9866'
+            name: Sandy Smith
+            role: member
+            '@type': PartyRef
+            '@referredType': Individual
+          - id: '9176'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/customer/9176'
+            name: Jack Smith
+            role: customer
+            '@type': PartyRoleRef
+            '@referredType': Customer
+        statusChangeHistory:
+          - statusChangeDate: '2022-05-31T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            status: pending
+            '@type': StatusChange
+          - changeDate: '2022-06-01T07:34:45.968Z'
+            changeReason: Give credit and resent bill to customer
+            status: resolved
+            '@type': StatusChange
+        troubleTicketRelationship:
+          - id: '567433'
+            href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/567433'
+            name: Network Coverage
+            relationshipType: dependecy
+            '@type': TroubleTicketRelationship
+        '@schemaLocation': 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/schema/troubleTicket.yml'
+        '@type': TroubleTicket
+      description: Response message
+    TroubleTicket_partialupdate_example_application_json_patch_request:
+      value:
+        - op: replace
+          path: /severity
+          value: Minor
+        - op: add
+          path: /note
+          value:
+            '@type': Note
+            id: '77456'
+            author: Jack Smith
+            text: 'This is quite important, please approach me as soon as possible'
+      description: >-
+        Here's an example of a request for updating a trouble ticket - set severity to Minor and add
+        new Note. This example illustrating patch json
+    TroubleTicket_partialupdate_example_application_json_patch_response:
+      value:
+        id: '3180'
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3180'
+        creationDate: '2022-05-31T07:34:45.968Z'
+        description: >-
+          I do not accept the last VOD charge, since the movie was constantly interrupted, I had to
+          quick watching the movie in the middle 
+        expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+        lastUpdate: '2022-05-31T07:34:45.968Z'
+        name: complaint over last bill
+        priority: Medium
+        requestedResolutionDate: '2022-05-31T07:34:45.968Z'
+        severity: Minor
+        status: pending
+        statusChangeDate: '2022-05-31T07:34:45.968Z'
+        statusChangeReason: Need more information from the customer
+        ticketType: Bill Dispute
+        attachment:
+          - description: Scanned disputed bill
+            attachmentType: billCopy
+            mimeType: image/png
+            name: March Bill
+            url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+            '@type': AttachmentRef
+        channel:
+          id: '8774'
+          name: self service
+          '@type': ChannelRef
+        note:
+          - id: '77456'
+            author: Jack Smith
+            date: '2019-05-31T07:34:45.968Z'
+            text: 'This is quite important, please approach me as soon as possible'
+            '@type': Note
+        relatedEntity:
+          - id: '3472'
+            href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+            name: March 2019 Bill
+            role: disputedBill
+            '@type': RelatedEntity
+            '@referredType': CustomerBill
+        relatedParty:
+          - id: '9866'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+            name: Sandy Smith
+            role: member
+            '@type': PartyRef
+            '@referredType': Individual
+          - id: '9176'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/customer/9176'
+            name: Jack Smith
+            role: customer
+            '@type': PartyRoleRef
+            '@referredType': Customer
+        statusChangeHistory:
+          - statusChangeDate: '2019-05-31T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            status: pending
+            '@type': StatusChange
+        troubleTicketRelationship:
+          - TroubleTicket:
+              id: '567433'
+              href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/567433'
+              name: Network Coverage
+              relationshipType: dependecy
+              '@type': TroubleTicketRelationship
+        '@schemaLocation': 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/schema/troubleTicket.yml'
+        '@type': TroubleTicket
+      description: Response message
+    TroubleTicket_partialupdate_example_application_json_patch_query_request:
+      value:
+        - op: replace
+          path: /sererity
+          value: Minor
+        - op: replace
+          path: /note?id=77456
+          value:
+            author: Jack Smith
+            text: Please approach me as soon as possible. Thanks in advance
+      description: >-
+        Here's an example of a request for updating a trouble ticket - set severity to Minor and
+        update a specific Nate. This example illustrating patch json
+    TroubleTicket_partialupdate_example_application_json_patch_query_response:
+      value:
+        id: '3180'
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/3180'
+        creationDate: '2022-05-31T07:34:45.968Z'
+        description: >-
+          I do not accept the last VOD charge, since the movie was constantly interrupted, I had to
+          quick watching the movie in the middle 
+        expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+        lastUpdate: '2022-05-31T07:34:45.968Z'
+        name: complaint over last bill
+        priority: High
+        requestedResolutionDate: '2022-05-31T07:34:45.968Z'
+        severity: Minor
+        status: pending
+        statusChangeDate: '2022-05-31T07:34:45.968Z'
+        statusChangeReason: Need more information from the customer
+        ticketType: Bill Dispute
+        attachment:
+          - description: Scanned disputed bill
+            attachmentType: billCopy
+            mimeType: image/png
+            name: March Bill
+            url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+            '@type': AttachmentRef
+        channel:
+          id: '8774'
+          name: self service
+          '@type': ChannelRef
+        note:
+          - id: '77456'
+            author: Jack Smith
+            date: '2022-05-31T07:34:45.968Z'
+            text: Please approach me as soon as possible. Thanks in advance
+            '@type': Note
+        relatedEntity:
+          - id: '3472'
+            href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+            name: March 2022 Bill
+            role: disputedBill
+            '@type': RelatedEntity
+            '@referredType': CustomerBill
+        relatedParty:
+          - id: '9866'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+            name: Sandy Smith
+            role: member
+            '@type': PartyRef
+            '@referredType': Individual
+          - id: '9176'
+            href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/customer/9176'
+            name: Jack Smith
+            role: customer
+            '@type': PartyRoleRef
+            '@referredType': Customer
+        statusChangeHistory:
+          - statusChangeDate: '2022-05-31T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            status: pending
+            '@type': StatusChange
+        troubleTicketRelationship:
+          - TroubleTicket:
+              id: '567433'
+              href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicket/567433'
+              name: Network Coverage
+              relationshipType: dependecy
+              '@type': TroubleTicketRelationship
+        '@schemaLocation': 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/schema/troubleTicket.yml'
+        '@type': TroubleTicket
+      description: Response message
+    TroubleTicketSpecification_partialupdate_application_json_request:
+      value:
+        lifecycleStatus: active
+        description: Bill Dispute Specification
+        '@type': TroubleTicketSpecification
+      description: >-
+        Here's an example of a request for updating a trouble ticket - set status to active and
+        update description. This example illustrating patch merge, When PATCH is implemeted merge
+        syntaxt is mandatory
+    TroubleTicketSpecification_partialupdate_application_json_response:
+      value:
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+        id: '25632415'
+        '@type': TroubleTicketSpecification
+        description: >-
+          This trouble ticket specification describes the characteristic and rules to apply when
+          creating a Trouble Ticket...
+        creationDate: '2022-05-22T10:36:30.709Z'
+        lastUpdate: '2022-06-22T10:36:30.709Z'
+        name: Bill Dispute Specification
+        relatedParty:
+          - role: approver
+            '@type': RelatedPartyRefOrPartyRoleRef
+            '@referredType': Individual
+            partyOrPartyRole:
+              id: '6678'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+              name: Sara Smith
+              '@type': PartyRef
+              '@referredType': Individual
+        lifecycleStatus: active
+        specCharacteristic:
+          - id: '1'
+            name: disputeAmount
+            valueType: number
+            configurable: true
+            description: >-
+              The amount that is on dispute, it can be the entire charge amount or partial amount of
+              the charge
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+          - id: '2'
+            name: creditAmount
+            valueType: number
+            configurable: true
+            description: >-
+              The positive amount to be credit, it can be equal or less than the dispute amount. In
+              case credit is given a credit reason must be provided. In case no credit is given a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            charSpecRelationship:
+              - '@type': CharacteristicSpecificationRelationship
+                '@baseType': string
+                '@schemaLocation': string
+                characteristicSpecificationId: '3'
+                name: creditReason
+                relationshipType: dependency
+                parentSpecificationId: '25632415'
+            '@type': CharacteristicSpecification
+          - id: '3'
+            name: creditReason
+            valueType: string
+            configurable: true
+            description: >-
+              The reason for giving the credit, in case credit apply. In case no credit apply a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+          - id: '4'
+            name: rejectReason
+            valueType: string
+            configurable: true
+            description: 'The reason for rejecting the dispute, in case no credit apply.'
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+          - id: '5'
+            name: currency
+            valueType: string
+            configurable: true
+            description: Currency (ISO4217 norm uses 3 letters to define the currency)
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+        validFor:
+          startDateTime: '2022-06-22T23:20:50.52Z'
+        version: '1'
+      description: Response message
+    TroubleTicketSpecification_partialupdate_application_merge_json_request:
+      value:
+        lifecycleStatus: active
+        description: Bill Dispute Specification
+        '@type': TroubleTicketSpecification
+      description: >-
+        Here's an example of a request for updating a trouble ticket - set status to active and
+        update description. This example illustrating patch merge, When PATCH is implemeted merge
+        syntaxt is mandatory
+    TroubleTicketSpecification_partialupdate_application_merge_json_response:
+      value:
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+        id: '25632415'
+        '@type': TroubleTicketSpecification
+        description: >-
+          This trouble ticket specification describes the characteristic and rules to apply when
+          creating a Trouble Ticket...
+        creationDate: '2022-05-22T10:36:30.709Z'
+        lastUpdate: '2022-06-22T10:36:30.709Z'
+        name: Bill Dispute Specification
+        relatedParty:
+          - role: approver
+            '@type': RelatedPartyRefOrPartyRoleRef
+            '@referredType': Individual
+            partyOrPartyRole:
+              id: '6678'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+              name: Sara Smith
+              '@type': PartyRef
+              '@referredType': Individual
+        lifecycleStatus: active
+        specCharacteristic:
+          - id: '1'
+            name: disputeAmount
+            valueType: number
+            configurable: true
+            description: >-
+              The amount that is on dispute, it can be the entire charge amount or partial amount of
+              the charge
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+          - id: '2'
+            name: creditAmount
+            valueType: number
+            configurable: true
+            description: >-
+              The positive amount to be credit, it can be equal or less than the dispute amount. In
+              case credit is given a credit reason must be provided. In case no credit is given a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            charSpecRelationship:
+              - '@type': CharacteristicSpecificationRelationship
+                '@baseType': string
+                '@schemaLocation': string
+                characteristicSpecificationId: '3'
+                name: creditReason
+                relationshipType: dependency
+                parentSpecificationId: '25632415'
+            '@type': CharacteristicSpecification
+          - id: '3'
+            name: creditReason
+            valueType: string
+            configurable: true
+            description: >-
+              The reason for giving the credit, in case credit apply. In case no credit apply a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+          - id: '4'
+            name: rejectReason
+            valueType: string
+            configurable: true
+            description: 'The reason for rejecting the dispute, in case no credit apply.'
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+          - id: '5'
+            name: currency
+            valueType: string
+            configurable: true
+            description: Currency (ISO4217 norm uses 3 letters to define the currency)
+            maxCardinality: 0
+            minCardinality: 1
+            '@type': CharacteristicSpecification
+        validFor:
+          startDateTime: '2022-06-22T23:20:50.52Z'
+        version: '1'
+      description: Response message
+    TroubleTicketSpecification_partialupdate_application_json_patch_request:
+      value:
+        - op: replace
+          path: /lifecycleStatus
+          value: active
+        - op: replace
+          path: /name
+          value: Bill Dispute Specification
+      description: >-
+        Here's an example of a request for updating a trouble ticket spesification - set status to
+        active and update description. This example illustrating patch json
+    TroubleTicketSpecification_partialupdate_application_json_patch_response:
+      value:
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+        id: '25632415'
+        '@type': TroubleTicketSpecification
+        description: >-
+          This trouble ticket specification describes the characteristic and rules to apply when
+          creating a Trouble Ticket...
+        creationDate: '2022-05-22T10:36:30.709Z'
+        lastUpdate: '2022-06-22T10:36:30.709Z'
+        name: Bill Dispute Specification
+        relatedParty:
+          - role: approver
+            '@type': RelatedPartyRefOrPartyRoleRef
+            '@referredType': Individual
+            partyOrPartyRole:
+              id: '6678'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+              name: Sara Smith
+              '@type': PartyRef
+              '@referredType': Individual
+        lifecycleStatus: active
+        specCharacteristic:
+          - id: '1'
+            configurable: true
+            description: >-
+              The amount that is on dispute, it can be the entire charge amount or partial amount of
+              the charge
+            maxCardinality: 0
+            minCardinality: 1
+            name: disputeAmount
+            valueType: number
+            '@type': CharacteristicSpecification
+          - id: '2'
+            configurable: true
+            description: >-
+              The positive amount to be credit, it can be equal or less than the dispute amount. In
+              case credit is given a credit reason must be provided. In case no credit is given a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditAmount
+            valueType: number
+            charSpecRelationship:
+              - '@type': CharacteristicSpecificationRelationship
+                '@schemaLocation': string
+                characteristicSpecificationId: '3'
+                name: creditReason
+                relationshipType: dependency
+                parentSpecificationId: '25632415'
+          - id: '3'
+            configurable: true
+            description: >-
+              The reason for giving the credit, in case credit apply. In case no credit apply a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditReason
+            valueType: string
+          - id: '4'
+            configurable: true
+            description: 'The reason for rejecting the dispute, in case no credit apply.'
+            maxCardinality: 0
+            minCardinality: 1
+            name: rejectReason
+            valueType: string
+          - id: '5'
+            configurable: true
+            description: Currency (ISO4217 norm uses 3 letters to define the currency)
+            maxCardinality: 0
+            minCardinality: 1
+            name: currency
+            valueType: string
+        validFor:
+          startDateTime: '2022-06-22T23:20:50.52Z'
+        version: '1'
+      description: Response message
+    TroubleTicketSpecification_partialupdate_application_json_patch_query_request:
+      value:
+        - op: replace
+          path: /specCharacteristic?id=5
+          value:
+            configurable: false
+      description: >-
+        Here's an example of a request for updating a trouble ticket - set characteristic id=5 to
+        readonly. This example illustrating patch query json
+    TroubleTicketSpecification_partialupdate_application_json_patch_query_response:
+      value:
+        href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+        id: '25632415'
+        '@type': TroubleTicketSpecification
+        description: >-
+          This trouble ticket specification describes the characteristic and rules to apply when
+          creating a Trouble Ticket...
+        creationDate: '2022-05-22T10:36:30.709Z'
+        lastUpdate: '2022-06-22T10:36:30.709Z'
+        name: Bill Dispute Specification
+        relatedParty:
+          - role: approver
+            '@type': RelatedPartyRefOrPartyRoleRef
+            '@referredType': Individual
+            partyOrPartyRole:
+              id: '6678'
+              href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+              name: Sara Smith
+              '@type': PartyRef
+              '@referredType': Individual
+        lifecycleStatus: active
+        specCharacteristic:
+          - id: '1'
+            configurable: true
+            description: >-
+              The amount that is on dispute, it can be the entire charge amount or partial amount of
+              the charge
+            maxCardinality: 0
+            minCardinality: 1
+            name: disputeAmount
+            valueType: number
+            '@type': CharacteristicSpecification
+          - id: '2'
+            configurable: true
+            description: >-
+              The positive amount to be credit, it can be equal or less than the dispute amount. In
+              case credit is given a credit reason must be provided. In case no credit is given a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditAmount
+            valueType: number
+            charSpecRelationship:
+              - '@type': string
+                '@baseType': string
+                '@schemaLocation': string
+                characteristicSpecificationId: '3'
+                name: creditReason
+                relationshipType: dependency
+                parentSpecificationId: '25632415'
+            '@type': CharacteristicSpecification
+          - id: '3'
+            configurable: true
+            description: >-
+              The reason for giving the credit, in case credit apply. In case no credit apply a
+              reject reason must be provided
+            maxCardinality: 0
+            minCardinality: 1
+            name: creditReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '4'
+            configurable: true
+            description: 'The reason for rejecting the dispute, in case no credit apply.'
+            maxCardinality: 0
+            minCardinality: 1
+            name: rejectReason
+            valueType: string
+            '@type': CharacteristicSpecification
+          - id: '5'
+            configurable: false
+            description: Currency (ISO4217 norm uses 3 letters to define the currency)
+            maxCardinality: 0
+            minCardinality: 1
+            name: currency
+            valueType: string
+            '@type': CharacteristicSpecification
+        validFor:
+          startDateTime: '2022-06-22T23:20:50.52Z'
+        version: '1'
+      description: Response message
+    TroubleTicketCreateEvent_request:
+      value:
+        correlationId: 95003dd3-e325
+        description: TroubleTicketCreateEvent illustration
+        domain: Commercial
+        eventId: 4010-9b59-509a64cf85a8
+        eventTime: '2022-08-25T12:18:12.171Z'
+        eventType: TroubleTicketCreateEvent
+        priority: '1'
+        timeOcurred: '2022-08-25T12:18:06.252Z'
+        title: TroubleTicketCreateEvent
+        event:
+          troubleTicket:
+            id: '3180'
+            href: 'http://servername/troubleTicket/3180'
+            creationDate: '2019-05-31T07:34:45.968Z'
+            description: >-
+              I do not accept the last VOD charge, since the movie was constantly interrupted, I had
+              to quick watching the movie in the middle 
+            expectedResolutionDate: '2019-06-10T07:34:45.968Z'
+            externalId: 213-9909
+            lastUpdate: '2019-05-31T07:34:45.968Z'
+            name: complaint over last bill
+            priority: High
+            requestedResolutionDate: '2019-05-31T07:34:45.968Z'
+            severity: Urgent
+            status: pending
+            statusChangeDate: '2019-05-31T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            ticketType: Bill Dispute
+            attachment:
+              - description: Scanned disputed bill
+                mimeType: image/png
+                name: March Bill
+                url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+                '@type': ' AttachmentRef'
+            channel:
+              id: '8774'
+              name: self service
+              '@type': ChannelRef
+            note:
+              - id: '77456'
+                author: Jack Smith
+                date: '2019-05-31T07:34:45.968Z'
+                text: 'This is quite important, please approach me as soon as possible'
+                '@type': Note
+            relatedEntity:
+              - role: disputedBill
+                '@type': RelatedEntity
+                entity:
+                  id: '3472'
+                  href: 'https://mycsp.com:8080/tmf-api/customerBillManagement/v5/customerBill/8297'
+                  name: March 2019 Bill
+                  '@type': EntityRef
+                  '@referredType': CustomerBill
+            relatedParty:
+              - role: member
+                '@type': RelatedPartyRefOrPartyRoleRef
+                partyOrPartyRole:
+                  id: '9866'
+                  href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9866'
+                  name: Sandy Smith
+                  '@type': PartyRef
+                  '@referredType': Individual
+              - role: reporter
+                '@type': RelatedPartyRefOrPartyRoleRef
+                partyOrPartyRole:
+                  id: '9867'
+                  href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/9867'
+                  name: Jacob Jac Miller
+                  '@type': PartyRef
+                  '@referredType': Individual
+              - role: customer
+                '@type': RelatedPartyRefOrPartyRoleRef
+                partyOrPartyRole:
+                  id: '9176'
+                  href: 'https://mycsp.com:8080/tmf-api/partyManagement/v4/customer/9176'
+                  name: Jack Smith
+                  '@type': PartyRoleRef
+                  '@referredType': Customer
+            statusChangeHistory:
+              - statusChangeDate: '2019-05-31T07:34:45.968Z'
+                statusChangeReason: Need more information from the customer
+                status: pending
+                '@type': StatusChange
+            troubleTicketRelationship:
+              - id: '567433'
+                href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v4/troubleTicket/567433'
+                name: Network Coverage
+                relationshipType: dependecy
+                '@type': TroubleTicketRelationship
+            '@type': TroubleTicket
+        reportingSystem:
+          id: '759'
+          name: APP-745
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: APP-317
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketCreateEvent
+      description: Message example for TroubleTicketCreateEvent event
+    TroubleTicketAttributeValueChangeEvent_request:
+      value:
+        correlationId: d107a5f0-9257
+        description: TroubleTicketAttributeValueChangeEvent illustration
+        domain: Commercial
+        eventId: 456b-8663-72338e38d4f0
+        eventTime: '2022-08-25T12:18:12.181Z'
+        eventType: TroubleTicketAttributeValueChangeEvent
+        priority: '1'
+        timeOcurred: '2022-08-25T12:18:11.750Z'
+        title: TroubleTicketAttributeValueChangeEvent
+        event:
+          troubleTicket:
+            href: 'https://host:port/troubleTicket/v5/troubleTicket/3180'
+            id: '3180'
+            '@type': TroubleTicket
+            attachment:
+              - description: Scanned disputed bill
+                attachmentType: billCopy
+                mimeType: image/png
+                name: March Bill
+                url: 'https://mycsp.com:7070/docloader?docnum=3534555'
+                '@type': AttachmentRef
+        reportingSystem:
+          id: '759'
+          name: APP-745
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: APP-317
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketAttributeValueChangeEvent
+      description: Message example for TroubleTicketAttributeValueChangeEvent event
+    TroubleTicketStatusChangeEvent_request:
+      value:
+        correlationId: 0f874cb9-c70d
+        description: TroubleTicketStatusChangeEvent illustration
+        domain: Commercial
+        eventId: 41cf-ad81-d65ea1c2840c
+        eventTime: '2022-08-25T12:18:12.191Z'
+        eventType: TroubleTicketStatusChangeEvent
+        priority: '5'
+        timeOcurred: '2022-08-25T12:18:08.202Z'
+        title: TroubleTicketStatusChangeEvent
+        event:
+          troubleTicket:
+            id: '3180'
+            href: 'https://host:port/troubleTicket/v5/troubleTicket/3180'
+            '@type': TroubleTicket
+            lastUpdate: '2019-05-31T07:34:45.968Z'
+            priority: High
+            status: pending
+            statusChangeDate: '2019-05-31T07:34:45.968Z'
+            statusChangeReason: Need more information from the customer
+            statusChangeHistory:
+              - statusChangeDate: '2019-05-31T07:34:45.968Z'
+                statusChangeReason: Need more information from the customer
+                status: pending
+                '@type': StatusChange
+        reportingSystem:
+          id: '759'
+          name: APP-745
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: APP-317
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketStatusChangeEvent
+      description: Message example for TroubleTicketStatusChangeEvent event
+    TroubleTicketDeleteEvent_request:
+      value:
+        correlationId: 90cfc73d-deb7
+        description: TroubleTicketDeleteEvent illustration
+        domain: Commercial
+        eventId: 47d6-9751-40e4f01440c9
+        eventTime: '2022-08-25T12:18:12.202Z'
+        eventType: TroubleTicketDeleteEvent
+        priority: '4'
+        timeOcurred: '2022-08-25T12:18:07.224Z'
+        title: TroubleTicketDeleteEvent
+        event:
+          troubleTicket:
+            id: '3180'
+            href: 'https://host:port/troubleTicket/v5/troubleTicket/3180'
+            '@type': TroubleTicket
+        reportingSystem:
+          id: '759'
+          name: APP-745
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: APP-317
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketDeleteEvent
+      description: Message example for TroubleTicketDeleteEvent event
+    TroubleTicketResolvedEvent_request:
+      value:
+        correlationId: 86c9c4c9-b7a5
+        description: TroubleTicketResolvedEvent illustration
+        domain: Commercial
+        eventId: 41ad-b3e1-aa39d233a157
+        eventTime: '2022-08-25T12:18:12.213Z'
+        eventType: TroubleTicketResolvedEvent
+        priority: '5'
+        timeOcurred: '2022-08-25T12:18:10.103Z'
+        title: TroubleTicketResolvedEvent
+        event:
+          troubleTicket:
+            id: '3180'
+            href: 'https://host:port/troubleTicket/v5/troubleTicket/3180'
+            '@type': TroubleTicket
+            status: resolved
+            statusChangeDate: '2019-05-31T07:34:45.968Z'
+            statusChangeReason: A refund was issued
+            statusChangeHistory:
+              - statusChangeDate: '2019-05-31T07:34:45.968Z'
+                statusChangeReason: Need more information from the customer
+                status: pending
+                '@type': StatusChange
+        reportingSystem:
+          id: '759'
+          name: APP-745
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: APP-317
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketResolvedEvent
+      description: Message example for TroubleTicketResolvedEvent event
+    TroubleTicketInformationRequiredEvent_request:
+      value:
+        correlationId: 23ad1947-6b0a
+        description: TroubleTicketInformationRequiredEvent illustration request for attachment
+        domain: Commercial
+        eventId: 4655-9378-c6258e688816
+        eventTime: '2022-08-25T12:18:12.224Z'
+        eventType: TroubleTicketInformationRequiredEvent
+        priority: '2'
+        timeOcurred: '2022-08-25T12:18:07.161Z'
+        title: TroubleTicketInformationRequiredEvent
+        event:
+          troubleTicket:
+            id: '3180'
+            href: 'https://host:port/troubleTicket/v5/troubleTicket/3180'
+            name: complaint over last bill
+            '@type': TroubleTicket
+          informationRequired:
+            op: add
+            path: /attachment
+        reportingSystem:
+          id: '759'
+          name: APP-745
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: APP-317
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketInformationRequiredEvent
+      description: Message example for TroubleTicketInformationRequiredEvent event
+    TroubleTicketSpecificationCreateEvent_request:
+      value:
+        correlationId: 95003dd3-e325
+        description: TroubleTicketSpecificationCreateEvent illustration
+        domain: Commercial
+        eventId: 4010-9b59-509a64cf85a8
+        eventTime: '2022-08-25T12:18:12.171Z'
+        eventType: TroubleTicketSpecificationCreateEvent
+        priority: '1'
+        timeOcurred: '2022-08-25T12:18:06.252Z'
+        title: TroubleTicketSpecificationCreateEvent
+        event:
+          troubleTicketSpecification:
+            href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+            id: '25632415'
+            '@type': TroubleTicketSpecification
+            description: >-
+              This trouble ticket specification describes the characteristic and rules to apply when
+              creating a Trouble Ticket...
+            creationDate: '2022-06-22T10:36:30.709Z'
+            name: Bill Dispute
+            relatedParty:
+              - role: approver
+                '@type': RelatedPartyOrPartyRole
+                partyOrPartyRole:
+                  id: '6678'
+                  href: 'https://mycsp.com:8080/tmf-api/partyManagement/v5/individual/6678'
+                  name: Sara Smith
+                  '@type': PartyRef
+                  '@referredType': Individual
+            lifecycleStatus: inDesign
+            specCharacteristic:
+              - id: '1'
+                name: disputeAmount
+                valueType: number
+                configurable: true
+                description: >-
+                  The amount that is on dispute, it can be the entire charge amount or partial
+                  amount of the charge
+                maxCardinality: 0
+                minCardinality: 1
+                '@type': CharacteristicSpecification
+              - id: '2'
+                name: creditAmount
+                valueType: number
+                configurable: true
+                description: >-
+                  The positive amount to be credit, it can be equal or less than the dispute amount.
+                  In case credit is given a credit reason must be provided. In case no credit is
+                  given a reject reason must be provided
+                maxCardinality: 0
+                minCardinality: 1
+                charSpecRelationship:
+                  - '@type': CharacteristicSpecificationRelationship
+                    characteristicSpecificationId: '3'
+                    name: creditReason
+                    relationshipType: dependency
+                '@type': CharacteristicSpecification
+              - id: '3'
+                name: creditReason
+                valueType: string
+                configurable: true
+                description: >-
+                  The reason for giving the credit, in case credit apply. In case no credit apply a
+                  reject reason must be provided
+                maxCardinality: 0
+                minCardinality: 1
+                '@type': CharacteristicSpecification
+              - id: '4'
+                name: rejectReason
+                valueType: string
+                configurable: true
+                description: 'The reason for rejecting the dispute, in case no credit apply.'
+                maxCardinality: 0
+                minCardinality: 1
+                '@type': CharacteristicSpecification
+              - id: '5'
+                name: currency
+                valueType: string
+                configurable: true
+                description: Currency (ISO4217 norm uses 3 letters to define the currency)
+                maxCardinality: 0
+                minCardinality: 1
+                '@type': CharacteristicSpecification
+            validFor:
+              startDateTime: '2022-06-22T23:20:50.52Z'
+            version: '1'
+        reportingSystem:
+          id: '759'
+          name: Catalog Publishing
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: Catalog Authoring
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketSpecificationCreateEvent
+      description: Message example for TroubleTicketSpecificationCreateEvent event
+    TroubleTicketSpecificationAttributeValueChangeEvent_request:
+      value:
+        correlationId: d107a5f0-9257
+        description: TroubleTicketSpecificationAttributeValueChangeEvent illustration
+        domain: Commercial
+        eventId: 456b-8663-72338e38d4f0
+        eventTime: '2022-08-25T12:18:12.181Z'
+        eventType: TroubleTicketSpecificationAttributeValueChangeEvent
+        priority: '1'
+        timeOcurred: '2022-08-25T12:18:11.750Z'
+        title: TroubleTicketSpecificationAttributeValueChangeEvent
+        event:
+          troubleTicketSpecification:
+            href: 'https://host:port/troubleTicketSpecification/v5/troubleTicketSpecification/3180'
+            id: '3180'
+            '@type': TroubleTicketSpecification
+            lifecycleStatus: active
+        reportingSystem:
+          id: '759'
+          name: APP-745
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: APP-317
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketSpecificationAttributeValueChangeEvent
+      description: Message example for TroubleTicketSpecificationAttributeValueChangeEvent event
+    TroubleTicketSpecificationStatusChangeEvent_request:
+      value:
+        correlationId: 95003dd3-e325
+        description: TroubleTicketSpecificationStatusChangeEvent illustration
+        domain: Commercial
+        eventId: 4010-9b59-509a64cf85a8
+        eventTime: '2022-08-25T12:18:12.171Z'
+        eventType: TroubleTicketSpecificationStatusChangeEvent
+        priority: '1'
+        timeOcurred: '2022-08-25T12:18:06.252Z'
+        title: TroubleTicketSpecificationStatusChangeEvent
+        event:
+          troubleTicketSpecification:
+            href: 'https://mycsp.com:8080/tmf-api/troubleTicket/v5/troubleTicketSpecification/25632415'
+            id: '25632415'
+            '@type': TroubleTicketSpecification
+            lastUpdate: '2022-06-22T10:36:30.709Z'
+            lifecycleStatus: active
+        reportingSystem:
+          id: '759'
+          name: Catalog Publishing
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: Catalog Authoring
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketSpecificationStatusChangeEvent
+      description: Message example for TroubleTicketSpecificationStatushangeEvent event
+    TroubleTicketSpecificationDeleteEvent_request:
+      value:
+        correlationId: 90cfc73d-deb7
+        description: TroubleTicketSpecificationDeleteEvent illustration
+        domain: Commercial
+        eventId: 47d6-9751-40e4f01440c9
+        eventTime: '2022-08-25T12:18:12.202Z'
+        eventType: TroubleTicketSpecificationDeleteEvent
+        priority: '4'
+        timeOcurred: '2022-08-25T12:18:07.224Z'
+        title: TroubleTicketSpecificationDeleteEvent
+        event:
+          troubleTicketSpecification:
+            id: '3180'
+            href: 'https://host:port/troubleTicket/v5/troubleTicketSpecification/4499'
+            '@type': TroubleTicketSpecification
+        reportingSystem:
+          id: '759'
+          name: Catalog Publishing
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        source:
+          id: '705'
+          name: Catalog Authoring
+          '@type': ReportingResource
+          '@referredType': LogicalResource
+        '@baseType': Event
+        '@type': TroubleTicketSpecificationDeleteEvent
+      description: Message example for TroubleTicketSpecificationDeleteEvent event