mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-12-12 06:15:27 +00:00
321d462311
Nested templates have background shading relative to their level of nesting. See the newly added test case as an example. Without these tokens registered, the styling won't show properly. Since these tokens aren't referenced directly by the StreamParser, nor do they have a parent Tag, we don't need them as constants like we do for other tokens. Bug: T348019 Change-Id: I87bb99d538344957987b2bd88f902a1427a36522
1 line
1.5 MiB
1 line
1.5 MiB
{"version":3,"file":"main.js","mappings":"mBAGA,MAAMA,EAIF,MAAAC,CAAOC,GACH,GAAIA,EAAM,GAAKA,EAAMC,KAAKC,OACtB,MAAM,IAAIC,WAAW,oBAAoBH,2BAA6BC,KAAKC,UAC/E,OAAOD,KAAKG,UAAUJ,GAAK,EAAO,EAAG,EACzC,CAIA,IAAAK,CAAKC,GACD,GAAIA,EAAI,GAAKA,EAAIL,KAAKM,MAClB,MAAM,IAAIJ,WAAW,uBAAuBG,QAAQL,KAAKM,uBAC7D,OAAON,KAAKG,UAAUE,GAAG,EAAM,EAAG,EACtC,CAIA,OAAAE,CAAQC,EAAMC,EAAIC,GACd,IAAIC,EAAQ,GAKZ,OAJAX,KAAKY,UAAU,EAAGJ,EAAMG,EAAO,GAC3BD,EAAKT,QACLS,EAAKE,UAAU,EAAGF,EAAKT,OAAQU,EAAO,GAC1CX,KAAKY,UAAUH,EAAIT,KAAKC,OAAQU,EAAO,GAChCE,EAASL,KAAKG,EAAOX,KAAKC,QAAUQ,EAAKD,GAAQE,EAAKT,OACjE,CAIA,MAAAa,CAAOC,GACH,OAAOf,KAAKO,QAAQP,KAAKC,OAAQD,KAAKC,OAAQc,EAClD,CAIA,KAAAC,CAAMR,EAAMC,EAAKT,KAAKC,QAClB,IAAIU,EAAQ,GAEZ,OADAX,KAAKY,UAAUJ,EAAMC,EAAIE,EAAO,GACzBE,EAASL,KAAKG,EAAOF,EAAKD,EACrC,CAIA,EAAAS,CAAGF,GACC,GAAIA,GAASf,KACT,OAAO,EACX,GAAIe,EAAMd,QA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.js","/w/extensions/CodeMirror/./node_modules/style-mod/src/style-mod.js","/w/extensions/CodeMirror/./node_modules/w3c-keyname/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/view/dist/index.js","/w/extensions/CodeMirror/./src/codemirror.js","/w/extensions/CodeMirror/./node_modules/@lezer/common/dist/index.js","/w/extensions/CodeMirror/./node_modules/@lezer/highlight/dist/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/language/dist/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/commands/dist/index.js","/w/extensions/CodeMirror/./node_modules/crelt/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/search/dist/index.js","/w/extensions/CodeMirror/./src/codemirror.wikieditor.js","/w/extensions/CodeMirror/./src/codemirror.mode.mediawiki.config.js","/w/extensions/CodeMirror/./src/codemirror.mode.mediawiki.js","/w/extensions/CodeMirror/./src/codemirror.wikieditor.mediawiki.js"],"sourcesContent":["/**\nThe data structure for documents. @nonabstract\n*/\nclass Text {\n /**\n Get the line description around the given position.\n */\n lineAt(pos) {\n if (pos < 0 || pos > this.length)\n throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);\n return this.lineInner(pos, false, 1, 0);\n }\n /**\n Get the description for the given (1-based) line number.\n */\n line(n) {\n if (n < 1 || n > this.lines)\n throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);\n return this.lineInner(n, true, 1, 0);\n }\n /**\n Replace a range of the text with the given content.\n */\n replace(from, to, text) {\n let parts = [];\n this.decompose(0, from, parts, 2 /* Open.To */);\n if (text.length)\n text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);\n this.decompose(to, this.length, parts, 1 /* Open.From */);\n return TextNode.from(parts, this.length - (to - from) + text.length);\n }\n /**\n Append another document to this one.\n */\n append(other) {\n return this.replace(this.length, this.length, other);\n }\n /**\n Retrieve the text between the given points.\n */\n slice(from, to = this.length) {\n let parts = [];\n this.decompose(from, to, parts, 0);\n return TextNode.from(parts, to - from);\n }\n /**\n Test whether this text is equal to another instance.\n */\n eq(other) {\n if (other == this)\n return true;\n if (other.length != this.length || other.lines != this.lines)\n return false;\n let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);\n let a = new RawTextCursor(this), b = new RawTextCursor(other);\n for (let skip = start, pos = start;;) {\n a.next(skip);\n b.next(skip);\n skip = 0;\n if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)\n return false;\n pos += a.value.length;\n if (a.done || pos >= end)\n return true;\n }\n }\n /**\n Iterate over the text. When `dir` is `-1`, iteration happens\n from end to start. This will return lines and the breaks between\n them as separate strings.\n */\n iter(dir = 1) { return new RawTextCursor(this, dir); }\n /**\n Iterate over a range of the text. When `from` > `to`, the\n iterator will run in reverse.\n */\n iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); }\n /**\n Return a cursor that iterates over the given range of lines,\n _without_ returning the line breaks between, and yielding empty\n strings for empty lines.\n \n When `from` and `to` are given, they should be 1-based line numbers.\n */\n iterLines(from, to) {\n let inner;\n if (from == null) {\n inner = this.iter();\n }\n else {\n if (to == null)\n to = this.lines + 1;\n let start = this.line(from).from;\n inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));\n }\n return new LineCursor(inner);\n }\n /**\n Return the document as a string, using newline characters to\n separate lines.\n */\n toString() { return this.sliceString(0); }\n /**\n Convert the document to an array of lines (which can be\n deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).\n */\n toJSON() {\n let lines = [];\n this.flatten(lines);\n return lines;\n }\n /**\n @internal\n */\n constructor() { }\n /**\n Create a `Text` instance for the given array of lines.\n */\n static of(text) {\n if (text.length == 0)\n throw new RangeError(\"A document must have at least one line\");\n if (text.length == 1 && !text[0])\n return Text.empty;\n return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));\n }\n}\n// Leaves store an array of line strings. There are always line breaks\n// between these strings. Leaves are limited in size and have to be\n// contained in TextNode instances for bigger documents.\nclass TextLeaf extends Text {\n constructor(text, length = textLength(text)) {\n super();\n this.text = text;\n this.length = length;\n }\n get lines() { return this.text.length; }\n get children() { return null; }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let string = this.text[i], end = offset + string.length;\n if ((isLine ? line : end) >= target)\n return new Line(offset, end, line, string);\n offset = end + 1;\n line++;\n }\n }\n decompose(from, to, target, open) {\n let text = from <= 0 && to >= this.length ? this\n : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));\n if (open & 1 /* Open.From */) {\n let prev = target.pop();\n let joined = appendText(text.text, prev.text.slice(), 0, text.length);\n if (joined.length <= 32 /* Tree.Branch */) {\n target.push(new TextLeaf(joined, prev.length + text.length));\n }\n else {\n let mid = joined.length >> 1;\n target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));\n }\n }\n else {\n target.push(text);\n }\n }\n replace(from, to, text) {\n if (!(text instanceof TextLeaf))\n return super.replace(from, to, text);\n let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);\n let newLen = this.length + text.length - (to - from);\n if (lines.length <= 32 /* Tree.Branch */)\n return new TextLeaf(lines, newLen);\n return TextNode.from(TextLeaf.split(lines, []), newLen);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n let result = \"\";\n for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {\n let line = this.text[i], end = pos + line.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += line.slice(Math.max(0, from - pos), to - pos);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let line of this.text)\n target.push(line);\n }\n scanIdentical() { return 0; }\n static split(text, target) {\n let part = [], len = -1;\n for (let line of text) {\n part.push(line);\n len += line.length + 1;\n if (part.length == 32 /* Tree.Branch */) {\n target.push(new TextLeaf(part, len));\n part = [];\n len = -1;\n }\n }\n if (len > -1)\n target.push(new TextLeaf(part, len));\n return target;\n }\n}\n// Nodes provide the tree structure of the `Text` type. They store a\n// number of other nodes or leaves, taking care to balance themselves\n// on changes. There are implied line breaks _between_ the children of\n// a node (but not before the first or after the last child).\nclass TextNode extends Text {\n constructor(children, length) {\n super();\n this.children = children;\n this.length = length;\n this.lines = 0;\n for (let child of children)\n this.lines += child.lines;\n }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;\n if ((isLine ? endLine : end) >= target)\n return child.lineInner(target, isLine, line, offset);\n offset = end + 1;\n line = endLine + 1;\n }\n }\n decompose(from, to, target, open) {\n for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (from <= end && to >= pos) {\n let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));\n if (pos >= from && end <= to && !childOpen)\n target.push(child);\n else\n child.decompose(from - pos, to - pos, target, childOpen);\n }\n pos = end + 1;\n }\n }\n replace(from, to, text) {\n if (text.lines < this.lines)\n for (let i = 0, pos = 0; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n // Fast path: if the change only affects one child and the\n // child's size remains in the acceptable range, only update\n // that child\n if (from >= pos && to <= end) {\n let updated = child.replace(from - pos, to - pos, text);\n let totalLines = this.lines - child.lines + updated.lines;\n if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&\n updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {\n let copy = this.children.slice();\n copy[i] = updated;\n return new TextNode(copy, this.length - (to - from) + text.length);\n }\n return super.replace(pos, end, updated);\n }\n pos = end + 1;\n }\n return super.replace(from, to, text);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n let result = \"\";\n for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {\n let child = this.children[i], end = pos + child.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += child.sliceString(from - pos, to - pos, lineSep);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let child of this.children)\n child.flatten(target);\n }\n scanIdentical(other, dir) {\n if (!(other instanceof TextNode))\n return 0;\n let length = 0;\n let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]\n : [this.children.length - 1, other.children.length - 1, -1, -1];\n for (;; iA += dir, iB += dir) {\n if (iA == eA || iB == eB)\n return length;\n let chA = this.children[iA], chB = other.children[iB];\n if (chA != chB)\n return length + chA.scanIdentical(chB, dir);\n length += chA.length + 1;\n }\n }\n static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {\n let lines = 0;\n for (let ch of children)\n lines += ch.lines;\n if (lines < 32 /* Tree.Branch */) {\n let flat = [];\n for (let ch of children)\n ch.flatten(flat);\n return new TextLeaf(flat, length);\n }\n let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;\n let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];\n function add(child) {\n let last;\n if (child.lines > maxChunk && child instanceof TextNode) {\n for (let node of child.children)\n add(node);\n }\n else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {\n flush();\n chunked.push(child);\n }\n else if (child instanceof TextLeaf && currentLines &&\n (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&\n child.lines + last.lines <= 32 /* Tree.Branch */) {\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);\n }\n else {\n if (currentLines + child.lines > chunk)\n flush();\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk.push(child);\n }\n }\n function flush() {\n if (currentLines == 0)\n return;\n chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));\n currentLen = -1;\n currentLines = currentChunk.length = 0;\n }\n for (let child of children)\n add(child);\n flush();\n return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);\n }\n}\nText.empty = /*@__PURE__*/new TextLeaf([\"\"], 0);\nfunction textLength(text) {\n let length = -1;\n for (let line of text)\n length += line.length + 1;\n return length;\n}\nfunction appendText(text, target, from = 0, to = 1e9) {\n for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {\n let line = text[i], end = pos + line.length;\n if (end >= from) {\n if (end > to)\n line = line.slice(0, to - pos);\n if (pos < from)\n line = line.slice(from - pos);\n if (first) {\n target[target.length - 1] += line;\n first = false;\n }\n else\n target.push(line);\n }\n pos = end + 1;\n }\n return target;\n}\nfunction sliceText(text, from, to) {\n return appendText(text, [\"\"], from, to);\n}\nclass RawTextCursor {\n constructor(text, dir = 1) {\n this.dir = dir;\n this.done = false;\n this.lineBreak = false;\n this.value = \"\";\n this.nodes = [text];\n this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];\n }\n nextInner(skip, dir) {\n this.done = this.lineBreak = false;\n for (;;) {\n let last = this.nodes.length - 1;\n let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;\n let size = top instanceof TextLeaf ? top.text.length : top.children.length;\n if (offset == (dir > 0 ? size : 0)) {\n if (last == 0) {\n this.done = true;\n this.value = \"\";\n return this;\n }\n if (dir > 0)\n this.offsets[last - 1]++;\n this.nodes.pop();\n this.offsets.pop();\n }\n else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {\n this.offsets[last] += dir;\n if (skip == 0) {\n this.lineBreak = true;\n this.value = \"\\n\";\n return this;\n }\n skip--;\n }\n else if (top instanceof TextLeaf) {\n // Move to the next string\n let next = top.text[offset + (dir < 0 ? -1 : 0)];\n this.offsets[last] += dir;\n if (next.length > Math.max(0, skip)) {\n this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);\n return this;\n }\n skip -= next.length;\n }\n else {\n let next = top.children[offset + (dir < 0 ? -1 : 0)];\n if (skip > next.length) {\n skip -= next.length;\n this.offsets[last] += dir;\n }\n else {\n if (dir < 0)\n this.offsets[last]--;\n this.nodes.push(next);\n this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);\n }\n }\n }\n }\n next(skip = 0) {\n if (skip < 0) {\n this.nextInner(-skip, (-this.dir));\n skip = this.value.length;\n }\n return this.nextInner(skip, this.dir);\n }\n}\nclass PartialTextCursor {\n constructor(text, start, end) {\n this.value = \"\";\n this.done = false;\n this.cursor = new RawTextCursor(text, start > end ? -1 : 1);\n this.pos = start > end ? text.length : 0;\n this.from = Math.min(start, end);\n this.to = Math.max(start, end);\n }\n nextInner(skip, dir) {\n if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {\n this.value = \"\";\n this.done = true;\n return this;\n }\n skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);\n let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;\n if (skip > limit)\n skip = limit;\n limit -= skip;\n let { value } = this.cursor.next(skip);\n this.pos += (value.length + skip) * dir;\n this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);\n this.done = !this.value;\n return this;\n }\n next(skip = 0) {\n if (skip < 0)\n skip = Math.max(skip, this.from - this.pos);\n else if (skip > 0)\n skip = Math.min(skip, this.to - this.pos);\n return this.nextInner(skip, this.cursor.dir);\n }\n get lineBreak() { return this.cursor.lineBreak && this.value != \"\"; }\n}\nclass LineCursor {\n constructor(inner) {\n this.inner = inner;\n this.afterBreak = true;\n this.value = \"\";\n this.done = false;\n }\n next(skip = 0) {\n let { done, lineBreak, value } = this.inner.next(skip);\n if (done) {\n this.done = true;\n this.value = \"\";\n }\n else if (lineBreak) {\n if (this.afterBreak) {\n this.value = \"\";\n }\n else {\n this.afterBreak = true;\n this.next();\n }\n }\n else {\n this.value = value;\n this.afterBreak = false;\n }\n return this;\n }\n get lineBreak() { return false; }\n}\nif (typeof Symbol != \"undefined\") {\n Text.prototype[Symbol.iterator] = function () { return this.iter(); };\n RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =\n LineCursor.prototype[Symbol.iterator] = function () { return this; };\n}\n/**\nThis type describes a line in the document. It is created\non-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).\n*/\nclass Line {\n /**\n @internal\n */\n constructor(\n /**\n The position of the start of the line.\n */\n from, \n /**\n The position at the end of the line (_before_ the line break,\n or at the end of document for the last line).\n */\n to, \n /**\n This line's line number (1-based).\n */\n number, \n /**\n The line's content.\n */\n text) {\n this.from = from;\n this.to = to;\n this.number = number;\n this.text = text;\n }\n /**\n The length of the line (not including any line break after it).\n */\n get length() { return this.to - this.from; }\n}\n\n// Compressed representation of the Grapheme_Cluster_Break=Extend\n// information from\n// http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.\n// Each pair of elements represents a range, as an offet from the\n// previous range and a length. Numbers are in base-36, with the empty\n// string being a shorthand for 1.\nlet 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);\n// Convert offsets into absolute values\nfor (let i = 1; i < extend.length; i++)\n extend[i] += extend[i - 1];\nfunction isExtendingChar(code) {\n for (let i = 1; i < extend.length; i += 2)\n if (extend[i] > code)\n return extend[i - 1] <= code;\n return false;\n}\nfunction isRegionalIndicator(code) {\n return code >= 0x1F1E6 && code <= 0x1F1FF;\n}\nconst ZWJ = 0x200d;\n/**\nReturns a next grapheme cluster break _after_ (not equal to)\n`pos`, if `forward` is true, or before otherwise. Returns `pos`\nitself if no further cluster break is available in the string.\nMoves across surrogate pairs, extending characters (when\n`includeExtending` is true), characters joined with zero-width\njoiners, and flag emoji.\n*/\nfunction findClusterBreak(str, pos, forward = true, includeExtending = true) {\n return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending);\n}\nfunction nextClusterBreak(str, pos, includeExtending) {\n if (pos == str.length)\n return pos;\n // If pos is in the middle of a surrogate pair, move to its start\n if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1)))\n pos--;\n let prev = codePointAt(str, pos);\n pos += codePointSize(prev);\n while (pos < str.length) {\n let next = codePointAt(str, pos);\n if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {\n pos += codePointSize(next);\n prev = next;\n }\n else if (isRegionalIndicator(next)) {\n let countBefore = 0, i = pos - 2;\n while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) {\n countBefore++;\n i -= 2;\n }\n if (countBefore % 2 == 0)\n break;\n else\n pos += 2;\n }\n else {\n break;\n }\n }\n return pos;\n}\nfunction prevClusterBreak(str, pos, includeExtending) {\n while (pos > 0) {\n let found = nextClusterBreak(str, pos - 2, includeExtending);\n if (found < pos)\n return found;\n pos--;\n }\n return 0;\n}\nfunction surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000; }\nfunction surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00; }\n/**\nFind the code point at the given position in a string (like the\n[`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)\nstring method).\n*/\nfunction codePointAt(str, pos) {\n let code0 = str.charCodeAt(pos);\n if (!surrogateHigh(code0) || pos + 1 == str.length)\n return code0;\n let code1 = str.charCodeAt(pos + 1);\n if (!surrogateLow(code1))\n return code0;\n return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;\n}\n/**\nGiven a Unicode codepoint, return the JavaScript string that\nrespresents it (like\n[`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).\n*/\nfunction fromCodePoint(code) {\n if (code <= 0xffff)\n return String.fromCharCode(code);\n code -= 0x10000;\n return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);\n}\n/**\nThe amount of positions a character takes up a JavaScript string.\n*/\nfunction codePointSize(code) { return code < 0x10000 ? 1 : 2; }\n\nconst DefaultSplit = /\\r\\n?|\\n/;\n/**\nDistinguishes different ways in which positions can be mapped.\n*/\nvar MapMode = /*@__PURE__*/(function (MapMode) {\n /**\n Map a position to a valid new position, even when its context\n was deleted.\n */\n MapMode[MapMode[\"Simple\"] = 0] = \"Simple\";\n /**\n Return null if deletion happens across the position.\n */\n MapMode[MapMode[\"TrackDel\"] = 1] = \"TrackDel\";\n /**\n Return null if the character _before_ the position is deleted.\n */\n MapMode[MapMode[\"TrackBefore\"] = 2] = \"TrackBefore\";\n /**\n Return null if the character _after_ the position is deleted.\n */\n MapMode[MapMode[\"TrackAfter\"] = 3] = \"TrackAfter\";\nreturn MapMode})(MapMode || (MapMode = {}));\n/**\nA change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)\nthat doesn't store the inserted text. As such, it can't be\napplied, but is cheaper to store and manipulate.\n*/\nclass ChangeDesc {\n // Sections are encoded as pairs of integers. The first is the\n // length in the current document, and the second is -1 for\n // unaffected sections, and the length of the replacement content\n // otherwise. So an insertion would be (0, n>0), a deletion (n>0,\n // 0), and a replacement two positive numbers.\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n sections) {\n this.sections = sections;\n }\n /**\n The length of the document before the change.\n */\n get length() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2)\n result += this.sections[i];\n return result;\n }\n /**\n The length of the document after the change.\n */\n get newLength() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2) {\n let ins = this.sections[i + 1];\n result += ins < 0 ? this.sections[i] : ins;\n }\n return result;\n }\n /**\n False when there are actual changes in this set.\n */\n get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }\n /**\n Iterate over the unchanged parts left by these changes. `posA`\n provides the position of the range in the old document, `posB`\n the new position in the changed document.\n */\n iterGaps(f) {\n for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0) {\n f(posA, posB, len);\n posB += len;\n }\n else {\n posB += ins;\n }\n posA += len;\n }\n }\n /**\n Iterate over the ranges changed by these changes. (See\n [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a\n variant that also provides you with the inserted text.)\n `fromA`/`toA` provides the extent of the change in the starting\n document, `fromB`/`toB` the extent of the replacement in the\n changed document.\n \n When `individual` is true, adjacent changes (which are kept\n separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are\n reported separately.\n */\n iterChangedRanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a description of the inverted form of these changes.\n */\n get invertedDesc() {\n let sections = [];\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0)\n sections.push(len, ins);\n else\n sections.push(ins, len);\n }\n return new ChangeDesc(sections);\n }\n /**\n Compute the combined effect of applying another set of changes\n after this one. The length of the document after this set should\n match the length before `other`.\n */\n composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets(this, other); }\n /**\n Map this description, which should start with the same document\n as `other`, over another set of changes, so that it can be\n applied after it. When `before` is true, map as if the changes\n in `other` happened before the ones in `this`.\n */\n mapDesc(other, before = false) { return other.empty ? this : mapSet(this, other, before); }\n mapPos(pos, assoc = -1, mode = MapMode.Simple) {\n let posA = 0, posB = 0;\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;\n if (ins < 0) {\n if (endA > pos)\n return posB + (pos - posA);\n posB += len;\n }\n else {\n if (mode != MapMode.Simple && endA >= pos &&\n (mode == MapMode.TrackDel && posA < pos && endA > pos ||\n mode == MapMode.TrackBefore && posA < pos ||\n mode == MapMode.TrackAfter && endA > pos))\n return null;\n if (endA > pos || endA == pos && assoc < 0 && !len)\n return pos == posA || assoc < 0 ? posB : posB + ins;\n posB += ins;\n }\n posA = endA;\n }\n if (pos > posA)\n throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);\n return posB;\n }\n /**\n Check whether these changes touch a given range. When one of the\n changes entirely covers the range, the string `\"cover\"` is\n returned.\n */\n touchesRange(from, to = from) {\n for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {\n let len = this.sections[i++], ins = this.sections[i++], end = pos + len;\n if (ins >= 0 && pos <= to && end >= from)\n return pos < from && end > to ? \"cover\" : true;\n pos = end;\n }\n return false;\n }\n /**\n @internal\n */\n toString() {\n let result = \"\";\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n result += (result ? \" \" : \"\") + len + (ins >= 0 ? \":\" + ins : \"\");\n }\n return result;\n }\n /**\n Serialize this change desc to a JSON-representable value.\n */\n toJSON() { return this.sections; }\n /**\n Create a change desc from its JSON representation (as produced\n by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != \"number\"))\n throw new RangeError(\"Invalid JSON representation of ChangeDesc\");\n return new ChangeDesc(json);\n }\n /**\n @internal\n */\n static create(sections) { return new ChangeDesc(sections); }\n}\n/**\nA change set represents a group of modifications to a document. It\nstores the document length, and can only be applied to documents\nwith exactly that length.\n*/\nclass ChangeSet extends ChangeDesc {\n constructor(sections, \n /**\n @internal\n */\n inserted) {\n super(sections);\n this.inserted = inserted;\n }\n /**\n Apply the changes to a document, returning the modified\n document.\n */\n apply(doc) {\n if (this.length != doc.length)\n throw new RangeError(\"Applying change set to a document with the wrong length\");\n iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);\n return doc;\n }\n mapDesc(other, before = false) { return mapSet(this, other, before, true); }\n /**\n Given the document as it existed _before_ the changes, return a\n change set that represents the inverse of this set, which could\n be used to go from the document created by the changes back to\n the document as it existed before the changes.\n */\n invert(doc) {\n let sections = this.sections.slice(), inserted = [];\n for (let i = 0, pos = 0; i < sections.length; i += 2) {\n let len = sections[i], ins = sections[i + 1];\n if (ins >= 0) {\n sections[i] = ins;\n sections[i + 1] = len;\n let index = i >> 1;\n while (inserted.length < index)\n inserted.push(Text.empty);\n inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);\n }\n pos += len;\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n Combine two subsequent change sets into a single set. `other`\n must start in the document produced by `this`. If `this` goes\n `docA` → `docB` and `other` represents `docB` → `docC`, the\n returned value will represent the change `docA` → `docC`.\n */\n compose(other) { return this.empty ? other : other.empty ? this : composeSets(this, other, true); }\n /**\n Given another change set starting in the same document, maps this\n change set over the other, producing a new change set that can be\n applied to the document produced by applying `other`. When\n `before` is `true`, order changes as if `this` comes before\n `other`, otherwise (the default) treat `other` as coming first.\n \n Given two changes `A` and `B`, `A.compose(B.map(A))` and\n `B.compose(A.map(B, true))` will produce the same document. This\n provides a basic form of [operational\n transformation](https://en.wikipedia.org/wiki/Operational_transformation),\n and can be used for collaborative editing.\n */\n map(other, before = false) { return other.empty ? this : mapSet(this, other, before, true); }\n /**\n Iterate over the changed ranges in the document, calling `f` for\n each, with the range in the original document (`fromA`-`toA`)\n and the range that replaces it in the new document\n (`fromB`-`toB`).\n \n When `individual` is true, adjacent changes are reported\n separately.\n */\n iterChanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change\n set.\n */\n get desc() { return ChangeDesc.create(this.sections); }\n /**\n @internal\n */\n filter(ranges) {\n let resultSections = [], resultInserted = [], filteredSections = [];\n let iter = new SectionIter(this);\n done: for (let i = 0, pos = 0;;) {\n let next = i == ranges.length ? 1e9 : ranges[i++];\n while (pos < next || pos == next && iter.len == 0) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, next - pos);\n addSection(filteredSections, len, -1);\n let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;\n addSection(resultSections, len, ins);\n if (ins > 0)\n addInsert(resultInserted, resultSections, iter.text);\n iter.forward(len);\n pos += len;\n }\n let end = ranges[i++];\n while (pos < end) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, end - pos);\n addSection(resultSections, len, -1);\n addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);\n iter.forward(len);\n pos += len;\n }\n }\n return { changes: new ChangeSet(resultSections, resultInserted),\n filtered: ChangeDesc.create(filteredSections) };\n }\n /**\n Serialize this change set to a JSON-representable value.\n */\n toJSON() {\n let parts = [];\n for (let i = 0; i < this.sections.length; i += 2) {\n let len = this.sections[i], ins = this.sections[i + 1];\n if (ins < 0)\n parts.push(len);\n else if (ins == 0)\n parts.push([len]);\n else\n parts.push([len].concat(this.inserted[i >> 1].toJSON()));\n }\n return parts;\n }\n /**\n Create a change set for the given changes, for a document of the\n given length, using `lineSep` as line separator.\n */\n static of(changes, length, lineSep) {\n let sections = [], inserted = [], pos = 0;\n let total = null;\n function flush(force = false) {\n if (!force && !sections.length)\n return;\n if (pos < length)\n addSection(sections, length - pos, -1);\n let set = new ChangeSet(sections, inserted);\n total = total ? total.compose(set.map(total)) : set;\n sections = [];\n inserted = [];\n pos = 0;\n }\n function process(spec) {\n if (Array.isArray(spec)) {\n for (let sub of spec)\n process(sub);\n }\n else if (spec instanceof ChangeSet) {\n if (spec.length != length)\n throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);\n flush();\n total = total ? total.compose(spec.map(total)) : spec;\n }\n else {\n let { from, to = from, insert } = spec;\n if (from > to || from < 0 || to > length)\n throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);\n let insText = !insert ? Text.empty : typeof insert == \"string\" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;\n let insLen = insText.length;\n if (from == to && insLen == 0)\n return;\n if (from < pos)\n flush();\n if (from > pos)\n addSection(sections, from - pos, -1);\n addSection(sections, to - from, insLen);\n addInsert(inserted, sections, insText);\n pos = to;\n }\n }\n process(changes);\n flush(!total);\n return total;\n }\n /**\n Create an empty changeset of the given length.\n */\n static empty(length) {\n return new ChangeSet(length ? [length, -1] : [], []);\n }\n /**\n Create a changeset from its JSON representation (as produced by\n [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json))\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n let sections = [], inserted = [];\n for (let i = 0; i < json.length; i++) {\n let part = json[i];\n if (typeof part == \"number\") {\n sections.push(part, -1);\n }\n else if (!Array.isArray(part) || typeof part[0] != \"number\" || part.some((e, i) => i && typeof e != \"string\")) {\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n }\n else if (part.length == 1) {\n sections.push(part[0], 0);\n }\n else {\n while (inserted.length < i)\n inserted.push(Text.empty);\n inserted[i] = Text.of(part.slice(1));\n sections.push(part[0], inserted[i].length);\n }\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n @internal\n */\n static createSet(sections, inserted) {\n return new ChangeSet(sections, inserted);\n }\n}\nfunction addSection(sections, len, ins, forceJoin = false) {\n if (len == 0 && ins <= 0)\n return;\n let last = sections.length - 2;\n if (last >= 0 && ins <= 0 && ins == sections[last + 1])\n sections[last] += len;\n else if (len == 0 && sections[last] == 0)\n sections[last + 1] += ins;\n else if (forceJoin) {\n sections[last] += len;\n sections[last + 1] += ins;\n }\n else\n sections.push(len, ins);\n}\nfunction addInsert(values, sections, value) {\n if (value.length == 0)\n return;\n let index = (sections.length - 2) >> 1;\n if (index < values.length) {\n values[values.length - 1] = values[values.length - 1].append(value);\n }\n else {\n while (values.length < index)\n values.push(Text.empty);\n values.push(value);\n }\n}\nfunction iterChanges(desc, f, individual) {\n let inserted = desc.inserted;\n for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {\n let len = desc.sections[i++], ins = desc.sections[i++];\n if (ins < 0) {\n posA += len;\n posB += len;\n }\n else {\n let endA = posA, endB = posB, text = Text.empty;\n for (;;) {\n endA += len;\n endB += ins;\n if (ins && inserted)\n text = text.append(inserted[(i - 2) >> 1]);\n if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)\n break;\n len = desc.sections[i++];\n ins = desc.sections[i++];\n }\n f(posA, endA, posB, endB, text);\n posA = endA;\n posB = endB;\n }\n }\n}\nfunction mapSet(setA, setB, before, mkSet = false) {\n // Produce a copy of setA that applies to the document after setB\n // has been applied (assuming both start at the same document).\n let sections = [], insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n // Iterate over both sets in parallel. inserted tracks, for changes\n // in A that have to be processed piece-by-piece, whether their\n // content has been inserted already, and refers to the section\n // index.\n for (let inserted = -1;;) {\n if (a.ins == -1 && b.ins == -1) {\n // Move across ranges skipped by both sets.\n let len = Math.min(a.len, b.len);\n addSection(sections, len, -1);\n a.forward(len);\n b.forward(len);\n }\n else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {\n // If there's a change in B that comes before the next change in\n // A (ordered by start pos, then len, then before flag), skip\n // that (and process any changes in A it covers).\n let len = b.len;\n addSection(sections, b.ins, -1);\n while (len) {\n let piece = Math.min(a.len, len);\n if (a.ins >= 0 && inserted < a.i && a.len <= piece) {\n addSection(sections, 0, a.ins);\n if (insert)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n }\n a.forward(piece);\n len -= piece;\n }\n b.next();\n }\n else if (a.ins >= 0) {\n // Process the part of a change in A up to the start of the next\n // non-deletion change in B (if overlapping).\n let len = 0, left = a.len;\n while (left) {\n if (b.ins == -1) {\n let piece = Math.min(left, b.len);\n len += piece;\n left -= piece;\n b.forward(piece);\n }\n else if (b.ins == 0 && b.len < left) {\n left -= b.len;\n b.next();\n }\n else {\n break;\n }\n }\n addSection(sections, len, inserted < a.i ? a.ins : 0);\n if (insert && inserted < a.i)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n a.forward(a.len - left);\n }\n else if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else {\n throw new Error(\"Mismatched change set lengths\");\n }\n }\n}\nfunction composeSets(setA, setB, mkSet = false) {\n let sections = [];\n let insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n for (let open = false;;) {\n if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else if (a.ins == 0) { // Deletion in A\n addSection(sections, a.len, 0, open);\n a.next();\n }\n else if (b.len == 0 && !b.done) { // Insertion in B\n addSection(sections, 0, b.ins, open);\n if (insert)\n addInsert(insert, sections, b.text);\n b.next();\n }\n else if (a.done || b.done) {\n throw new Error(\"Mismatched change set lengths\");\n }\n else {\n let len = Math.min(a.len2, b.len), sectionLen = sections.length;\n if (a.ins == -1) {\n let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;\n addSection(sections, len, insB, open);\n if (insert && insB)\n addInsert(insert, sections, b.text);\n }\n else if (b.ins == -1) {\n addSection(sections, a.off ? 0 : a.len, len, open);\n if (insert)\n addInsert(insert, sections, a.textBit(len));\n }\n else {\n addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);\n if (insert && !b.off)\n addInsert(insert, sections, b.text);\n }\n open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);\n a.forward2(len);\n b.forward(len);\n }\n }\n}\nclass SectionIter {\n constructor(set) {\n this.set = set;\n this.i = 0;\n this.next();\n }\n next() {\n let { sections } = this.set;\n if (this.i < sections.length) {\n this.len = sections[this.i++];\n this.ins = sections[this.i++];\n }\n else {\n this.len = 0;\n this.ins = -2;\n }\n this.off = 0;\n }\n get done() { return this.ins == -2; }\n get len2() { return this.ins < 0 ? this.len : this.ins; }\n get text() {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length ? Text.empty : inserted[index];\n }\n textBit(len) {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length && !len ? Text.empty\n : inserted[index].slice(this.off, len == null ? undefined : this.off + len);\n }\n forward(len) {\n if (len == this.len)\n this.next();\n else {\n this.len -= len;\n this.off += len;\n }\n }\n forward2(len) {\n if (this.ins == -1)\n this.forward(len);\n else if (len == this.ins)\n this.next();\n else {\n this.ins -= len;\n this.off += len;\n }\n }\n}\n\n/**\nA single selection range. When\n[`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)\nis enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold\nmultiple ranges. By default, selections hold exactly one range.\n*/\nclass SelectionRange {\n constructor(\n /**\n The lower boundary of the range.\n */\n from, \n /**\n The upper boundary of the range.\n */\n to, flags) {\n this.from = from;\n this.to = to;\n this.flags = flags;\n }\n /**\n The anchor of the range—the side that doesn't move when you\n extend it.\n */\n get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }\n /**\n The head of the range, which is moved when the range is\n [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).\n */\n get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }\n /**\n True when `anchor` and `head` are at the same position.\n */\n get empty() { return this.from == this.to; }\n /**\n If this is a cursor that is explicitly associated with the\n character on one of its sides, this returns the side. -1 means\n the character before its position, 1 the character after, and 0\n means no association.\n */\n get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }\n /**\n The bidirectional text level associated with this cursor, if\n any.\n */\n get bidiLevel() {\n let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;\n return level == 3 ? null : level;\n }\n /**\n The goal column (stored vertical offset) associated with a\n cursor. This is used to preserve the vertical position when\n [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across\n lines of different length.\n */\n get goalColumn() {\n let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;\n return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;\n }\n /**\n Map this range through a change, producing a valid range in the\n updated document.\n */\n map(change, assoc = -1) {\n let from, to;\n if (this.empty) {\n from = to = change.mapPos(this.from, assoc);\n }\n else {\n from = change.mapPos(this.from, 1);\n to = change.mapPos(this.to, -1);\n }\n return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);\n }\n /**\n Extend this range to cover at least `from` to `to`.\n */\n extend(from, to = from) {\n if (from <= this.anchor && to >= this.anchor)\n return EditorSelection.range(from, to);\n let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;\n return EditorSelection.range(this.anchor, head);\n }\n /**\n Compare this range to another range.\n */\n eq(other) {\n return this.anchor == other.anchor && this.head == other.head;\n }\n /**\n Return a JSON-serializable object representing the range.\n */\n toJSON() { return { anchor: this.anchor, head: this.head }; }\n /**\n Convert a JSON representation of a range to a `SelectionRange`\n instance.\n */\n static fromJSON(json) {\n if (!json || typeof json.anchor != \"number\" || typeof json.head != \"number\")\n throw new RangeError(\"Invalid JSON representation for SelectionRange\");\n return EditorSelection.range(json.anchor, json.head);\n }\n /**\n @internal\n */\n static create(from, to, flags) {\n return new SelectionRange(from, to, flags);\n }\n}\n/**\nAn editor selection holds one or more selection ranges.\n*/\nclass EditorSelection {\n constructor(\n /**\n The ranges in the selection, sorted by position. Ranges cannot\n overlap (but they may touch, if they aren't empty).\n */\n ranges, \n /**\n The index of the _main_ range in the selection (which is\n usually the range that was added last).\n */\n mainIndex) {\n this.ranges = ranges;\n this.mainIndex = mainIndex;\n }\n /**\n Map a selection through a change. Used to adjust the selection\n position for changes.\n */\n map(change, assoc = -1) {\n if (change.empty)\n return this;\n return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);\n }\n /**\n Compare this selection to another selection.\n */\n eq(other) {\n if (this.ranges.length != other.ranges.length ||\n this.mainIndex != other.mainIndex)\n return false;\n for (let i = 0; i < this.ranges.length; i++)\n if (!this.ranges[i].eq(other.ranges[i]))\n return false;\n return true;\n }\n /**\n Get the primary selection range. Usually, you should make sure\n your code applies to _all_ ranges, by using methods like\n [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).\n */\n get main() { return this.ranges[this.mainIndex]; }\n /**\n Make sure the selection only has one range. Returns a selection\n holding only the main range from this selection.\n */\n asSingle() {\n return this.ranges.length == 1 ? this : new EditorSelection([this.main], 0);\n }\n /**\n Extend this selection with an extra range.\n */\n addRange(range, main = true) {\n return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);\n }\n /**\n Replace a given range with another range, and then normalize the\n selection to merge and sort ranges if necessary.\n */\n replaceRange(range, which = this.mainIndex) {\n let ranges = this.ranges.slice();\n ranges[which] = range;\n return EditorSelection.create(ranges, this.mainIndex);\n }\n /**\n Convert this selection to an object that can be serialized to\n JSON.\n */\n toJSON() {\n return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };\n }\n /**\n Create a selection from a JSON representation.\n */\n static fromJSON(json) {\n if (!json || !Array.isArray(json.ranges) || typeof json.main != \"number\" || json.main >= json.ranges.length)\n throw new RangeError(\"Invalid JSON representation for EditorSelection\");\n return new EditorSelection(json.ranges.map((r) => SelectionRange.fromJSON(r)), json.main);\n }\n /**\n Create a selection holding a single range.\n */\n static single(anchor, head = anchor) {\n return new EditorSelection([EditorSelection.range(anchor, head)], 0);\n }\n /**\n Sort and merge the given set of ranges, creating a valid\n selection.\n */\n static create(ranges, mainIndex = 0) {\n if (ranges.length == 0)\n throw new RangeError(\"A selection needs at least one range\");\n for (let pos = 0, i = 0; i < ranges.length; i++) {\n let range = ranges[i];\n if (range.empty ? range.from <= pos : range.from < pos)\n return EditorSelection.normalized(ranges.slice(), mainIndex);\n pos = range.to;\n }\n return new EditorSelection(ranges, mainIndex);\n }\n /**\n Create a cursor selection range at the given position. You can\n safely ignore the optional arguments in most situations.\n */\n static cursor(pos, assoc = 0, bidiLevel, goalColumn) {\n return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |\n (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |\n ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));\n }\n /**\n Create a selection range.\n */\n static range(anchor, head, goalColumn, bidiLevel) {\n let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |\n (bidiLevel == null ? 3 : Math.min(2, bidiLevel));\n return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)\n : SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);\n }\n /**\n @internal\n */\n static normalized(ranges, mainIndex = 0) {\n let main = ranges[mainIndex];\n ranges.sort((a, b) => a.from - b.from);\n mainIndex = ranges.indexOf(main);\n for (let i = 1; i < ranges.length; i++) {\n let range = ranges[i], prev = ranges[i - 1];\n if (range.empty ? range.from <= prev.to : range.from < prev.to) {\n let from = prev.from, to = Math.max(range.to, prev.to);\n if (i <= mainIndex)\n mainIndex--;\n ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));\n }\n }\n return new EditorSelection(ranges, mainIndex);\n }\n}\nfunction checkSelection(selection, docLength) {\n for (let range of selection.ranges)\n if (range.to > docLength)\n throw new RangeError(\"Selection points outside of document\");\n}\n\nlet nextID = 0;\n/**\nA facet is a labeled value that is associated with an editor\nstate. It takes inputs from any number of extensions, and combines\nthose into a single output value.\n\nExamples of uses of facets are the [tab\nsize](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor\nattributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update\nlisteners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).\n*/\nclass Facet {\n constructor(\n /**\n @internal\n */\n combine, \n /**\n @internal\n */\n compareInput, \n /**\n @internal\n */\n compare, isStatic, enables) {\n this.combine = combine;\n this.compareInput = compareInput;\n this.compare = compare;\n this.isStatic = isStatic;\n /**\n @internal\n */\n this.id = nextID++;\n this.default = combine([]);\n this.extensions = typeof enables == \"function\" ? enables(this) : enables;\n }\n /**\n Define a new facet.\n */\n static define(config = {}) {\n 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);\n }\n /**\n Returns an extension that adds the given value to this facet.\n */\n of(value) {\n return new FacetProvider([], this, 0 /* Provider.Static */, value);\n }\n /**\n Create an extension that computes a value for the facet from a\n state. You must take care to declare the parts of the state that\n this value depends on, since your function is only called again\n for a new state when one of those parts changed.\n \n In cases where your value depends only on a single field, you'll\n want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.\n */\n compute(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 1 /* Provider.Single */, get);\n }\n /**\n Create an extension that computes zero or more values for this\n facet from a state.\n */\n computeN(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);\n }\n from(field, get) {\n if (!get)\n get = x => x;\n return this.compute([field], state => get(state.field(field)));\n }\n}\nfunction sameArray(a, b) {\n return a == b || a.length == b.length && a.every((e, i) => e === b[i]);\n}\nclass FacetProvider {\n constructor(dependencies, facet, type, value) {\n this.dependencies = dependencies;\n this.facet = facet;\n this.type = type;\n this.value = value;\n this.id = nextID++;\n }\n dynamicSlot(addresses) {\n var _a;\n let getter = this.value;\n let compare = this.facet.compareInput;\n let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;\n let depDoc = false, depSel = false, depAddrs = [];\n for (let dep of this.dependencies) {\n if (dep == \"doc\")\n depDoc = true;\n else if (dep == \"selection\")\n depSel = true;\n else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)\n depAddrs.push(addresses[dep.id]);\n }\n return {\n create(state) {\n state.values[idx] = getter(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {\n let newVal = getter(state);\n if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n }\n return 0;\n },\n reconfigure: (state, oldState) => {\n let newVal, oldAddr = oldState.config.address[id];\n if (oldAddr != null) {\n let oldVal = getAddr(oldState, oldAddr);\n if (this.dependencies.every(dep => {\n return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :\n dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;\n }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {\n state.values[idx] = oldVal;\n return 0;\n }\n }\n else {\n newVal = getter(state);\n }\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n}\nfunction compareArray(a, b, compare) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (!compare(a[i], b[i]))\n return false;\n return true;\n}\nfunction ensureAll(state, addrs) {\n let changed = false;\n for (let addr of addrs)\n if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)\n changed = true;\n return changed;\n}\nfunction dynamicFacetSlot(addresses, facet, providers) {\n let providerAddrs = providers.map(p => addresses[p.id]);\n let providerTypes = providers.map(p => p.type);\n let dynamic = providerAddrs.filter(p => !(p & 1));\n let idx = addresses[facet.id] >> 1;\n function get(state) {\n let values = [];\n for (let i = 0; i < providerAddrs.length; i++) {\n let value = getAddr(state, providerAddrs[i]);\n if (providerTypes[i] == 2 /* Provider.Multi */)\n for (let val of value)\n values.push(val);\n else\n values.push(value);\n }\n return facet.combine(values);\n }\n return {\n create(state) {\n for (let addr of providerAddrs)\n ensureAddr(state, addr);\n state.values[idx] = get(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if (!ensureAll(state, dynamic))\n return 0;\n let value = get(state);\n if (facet.compare(value, state.values[idx]))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure(state, oldState) {\n let depChanged = ensureAll(state, providerAddrs);\n let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);\n if (oldProviders && !depChanged && sameArray(providers, oldProviders)) {\n state.values[idx] = oldValue;\n return 0;\n }\n let value = get(state);\n if (facet.compare(value, oldValue)) {\n state.values[idx] = oldValue;\n return 0;\n }\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n }\n };\n}\nconst initField = /*@__PURE__*/Facet.define({ static: true });\n/**\nFields can store additional information in an editor state, and\nkeep it in sync with the rest of the state.\n*/\nclass StateField {\n constructor(\n /**\n @internal\n */\n id, createF, updateF, compareF, \n /**\n @internal\n */\n spec) {\n this.id = id;\n this.createF = createF;\n this.updateF = updateF;\n this.compareF = compareF;\n this.spec = spec;\n /**\n @internal\n */\n this.provides = undefined;\n }\n /**\n Define a state field.\n */\n static define(config) {\n let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);\n if (config.provide)\n field.provides = config.provide(field);\n return field;\n }\n create(state) {\n let init = state.facet(initField).find(i => i.field == this);\n return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);\n }\n /**\n @internal\n */\n slot(addresses) {\n let idx = addresses[this.id] >> 1;\n return {\n create: (state) => {\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n },\n update: (state, tr) => {\n let oldVal = state.values[idx];\n let value = this.updateF(oldVal, tr);\n if (this.compareF(oldVal, value))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure: (state, oldState) => {\n if (oldState.config.address[this.id] != null) {\n state.values[idx] = oldState.field(this);\n return 0;\n }\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n /**\n Returns an extension that enables this field and overrides the\n way it is initialized. Can be useful when you need to provide a\n non-default starting value for the field.\n */\n init(create) {\n return [this, initField.of({ field: this, create })];\n }\n /**\n State field instances can be used as\n [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a\n given state.\n */\n get extension() { return this; }\n}\nconst Prec_ = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };\nfunction prec(value) {\n return (ext) => new PrecExtension(ext, value);\n}\n/**\nBy default extensions are registered in the order they are found\nin the flattened form of nested array that was provided.\nIndividual extension values can be assigned a precedence to\noverride this. Extensions that do not have a precedence set get\nthe precedence of the nearest parent with a precedence, or\n[`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The\nfinal ordering of extensions is determined by first sorting by\nprecedence and then by order within each precedence.\n*/\nconst Prec = {\n /**\n The highest precedence level, for extensions that should end up\n near the start of the precedence ordering.\n */\n highest: /*@__PURE__*/prec(Prec_.highest),\n /**\n A higher-than-default precedence, for extensions that should\n come before those with default precedence.\n */\n high: /*@__PURE__*/prec(Prec_.high),\n /**\n The default precedence, which is also used for extensions\n without an explicit precedence.\n */\n default: /*@__PURE__*/prec(Prec_.default),\n /**\n A lower-than-default precedence.\n */\n low: /*@__PURE__*/prec(Prec_.low),\n /**\n The lowest precedence level. Meant for things that should end up\n near the end of the extension order.\n */\n lowest: /*@__PURE__*/prec(Prec_.lowest)\n};\nclass PrecExtension {\n constructor(inner, prec) {\n this.inner = inner;\n this.prec = prec;\n }\n}\n/**\nExtension compartments can be used to make a configuration\ndynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your\nconfiguration in a compartment, you can later\n[replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a\ntransaction.\n*/\nclass Compartment {\n /**\n Create an instance of this compartment to add to your [state\n configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).\n */\n of(ext) { return new CompartmentInstance(this, ext); }\n /**\n Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that\n reconfigures this compartment.\n */\n reconfigure(content) {\n return Compartment.reconfigure.of({ compartment: this, extension: content });\n }\n /**\n Get the current content of the compartment in the state, or\n `undefined` if it isn't present.\n */\n get(state) {\n return state.config.compartments.get(this);\n }\n}\nclass CompartmentInstance {\n constructor(compartment, inner) {\n this.compartment = compartment;\n this.inner = inner;\n }\n}\nclass Configuration {\n constructor(base, compartments, dynamicSlots, address, staticValues, facets) {\n this.base = base;\n this.compartments = compartments;\n this.dynamicSlots = dynamicSlots;\n this.address = address;\n this.staticValues = staticValues;\n this.facets = facets;\n this.statusTemplate = [];\n while (this.statusTemplate.length < dynamicSlots.length)\n this.statusTemplate.push(0 /* SlotStatus.Unresolved */);\n }\n staticFacet(facet) {\n let addr = this.address[facet.id];\n return addr == null ? facet.default : this.staticValues[addr >> 1];\n }\n static resolve(base, compartments, oldState) {\n let fields = [];\n let facets = Object.create(null);\n let newCompartments = new Map();\n for (let ext of flatten(base, compartments, newCompartments)) {\n if (ext instanceof StateField)\n fields.push(ext);\n else\n (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);\n }\n let address = Object.create(null);\n let staticValues = [];\n let dynamicSlots = [];\n for (let field of fields) {\n address[field.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => field.slot(a));\n }\n let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;\n for (let id in facets) {\n let providers = facets[id], facet = providers[0].facet;\n let oldProviders = oldFacets && oldFacets[id] || [];\n if (providers.every(p => p.type == 0 /* Provider.Static */)) {\n address[facet.id] = (staticValues.length << 1) | 1;\n if (sameArray(oldProviders, providers)) {\n staticValues.push(oldState.facet(facet));\n }\n else {\n let value = facet.combine(providers.map(p => p.value));\n staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);\n }\n }\n else {\n for (let p of providers) {\n if (p.type == 0 /* Provider.Static */) {\n address[p.id] = (staticValues.length << 1) | 1;\n staticValues.push(p.value);\n }\n else {\n address[p.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => p.dynamicSlot(a));\n }\n }\n address[facet.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));\n }\n }\n let dynamic = dynamicSlots.map(f => f(address));\n return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);\n }\n}\nfunction flatten(extension, compartments, newCompartments) {\n let result = [[], [], [], [], []];\n let seen = new Map();\n function inner(ext, prec) {\n let known = seen.get(ext);\n if (known != null) {\n if (known <= prec)\n return;\n let found = result[known].indexOf(ext);\n if (found > -1)\n result[known].splice(found, 1);\n if (ext instanceof CompartmentInstance)\n newCompartments.delete(ext.compartment);\n }\n seen.set(ext, prec);\n if (Array.isArray(ext)) {\n for (let e of ext)\n inner(e, prec);\n }\n else if (ext instanceof CompartmentInstance) {\n if (newCompartments.has(ext.compartment))\n throw new RangeError(`Duplicate use of compartment in extensions`);\n let content = compartments.get(ext.compartment) || ext.inner;\n newCompartments.set(ext.compartment, content);\n inner(content, prec);\n }\n else if (ext instanceof PrecExtension) {\n inner(ext.inner, ext.prec);\n }\n else if (ext instanceof StateField) {\n result[prec].push(ext);\n if (ext.provides)\n inner(ext.provides, prec);\n }\n else if (ext instanceof FacetProvider) {\n result[prec].push(ext);\n if (ext.facet.extensions)\n inner(ext.facet.extensions, Prec_.default);\n }\n else {\n let content = ext.extension;\n if (!content)\n throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);\n inner(content, prec);\n }\n }\n inner(extension, Prec_.default);\n return result.reduce((a, b) => a.concat(b));\n}\nfunction ensureAddr(state, addr) {\n if (addr & 1)\n return 2 /* SlotStatus.Computed */;\n let idx = addr >> 1;\n let status = state.status[idx];\n if (status == 4 /* SlotStatus.Computing */)\n throw new Error(\"Cyclic dependency between fields and/or facets\");\n if (status & 2 /* SlotStatus.Computed */)\n return status;\n state.status[idx] = 4 /* SlotStatus.Computing */;\n let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);\n return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;\n}\nfunction getAddr(state, addr) {\n return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];\n}\n\nconst languageData = /*@__PURE__*/Facet.define();\nconst allowMultipleSelections = /*@__PURE__*/Facet.define({\n combine: values => values.some(v => v),\n static: true\n});\nconst lineSeparator = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : undefined,\n static: true\n});\nconst changeFilter = /*@__PURE__*/Facet.define();\nconst transactionFilter = /*@__PURE__*/Facet.define();\nconst transactionExtender = /*@__PURE__*/Facet.define();\nconst readOnly = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : false\n});\n\n/**\nAnnotations are tagged values that are used to add metadata to\ntransactions in an extensible way. They should be used to model\nthings that effect the entire transaction (such as its [time\nstamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its\n[origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen\n_alongside_ the other changes made by the transaction, [state\neffects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.\n*/\nclass Annotation {\n /**\n @internal\n */\n constructor(\n /**\n The annotation type.\n */\n type, \n /**\n The value of this annotation.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Define a new type of annotation.\n */\n static define() { return new AnnotationType(); }\n}\n/**\nMarker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).\n*/\nclass AnnotationType {\n /**\n Create an instance of this annotation.\n */\n of(value) { return new Annotation(this, value); }\n}\n/**\nRepresentation of a type of state effect. Defined with\n[`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).\n*/\nclass StateEffectType {\n /**\n @internal\n */\n constructor(\n // The `any` types in these function types are there to work\n // around TypeScript issue #37631, where the type guard on\n // `StateEffect.is` mysteriously stops working when these properly\n // have type `Value`.\n /**\n @internal\n */\n map) {\n this.map = map;\n }\n /**\n Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this\n type.\n */\n of(value) { return new StateEffect(this, value); }\n}\n/**\nState effects can be used to represent additional effects\nassociated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They\nare often useful to model changes to custom [state\nfields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in\ndocument or selection changes.\n*/\nclass StateEffect {\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n type, \n /**\n The value of this effect.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Map this effect through a position mapping. Will return\n `undefined` when that ends up deleting the effect.\n */\n map(mapping) {\n let mapped = this.type.map(this.value, mapping);\n return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);\n }\n /**\n Tells you whether this effect object is of a given\n [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).\n */\n is(type) { return this.type == type; }\n /**\n Define a new effect type. The type parameter indicates the type\n of values that his effect holds. It should be a type that\n doesn't include `undefined`, since that is used in\n [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is\n removed.\n */\n static define(spec = {}) {\n return new StateEffectType(spec.map || (v => v));\n }\n /**\n Map an array of effects through a change set.\n */\n static mapEffects(effects, mapping) {\n if (!effects.length)\n return effects;\n let result = [];\n for (let effect of effects) {\n let mapped = effect.map(mapping);\n if (mapped)\n result.push(mapped);\n }\n return result;\n }\n}\n/**\nThis effect can be used to reconfigure the root extensions of\nthe editor. Doing this will discard any extensions\n[appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset\nthe content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)\ncompartments.\n*/\nStateEffect.reconfigure = /*@__PURE__*/StateEffect.define();\n/**\nAppend extensions to the top-level configuration of the editor.\n*/\nStateEffect.appendConfig = /*@__PURE__*/StateEffect.define();\n/**\nChanges to the editor state are grouped into transactions.\nTypically, a user action creates a single transaction, which may\ncontain any number of document changes, may change the selection,\nor have other effects. Create a transaction by calling\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately\ndispatch one by calling\n[`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).\n*/\nclass Transaction {\n constructor(\n /**\n The state from which the transaction starts.\n */\n startState, \n /**\n The document changes made by this transaction.\n */\n changes, \n /**\n The selection set by this transaction, or undefined if it\n doesn't explicitly set a selection.\n */\n selection, \n /**\n The effects added to the transaction.\n */\n effects, \n /**\n @internal\n */\n annotations, \n /**\n Whether the selection should be scrolled into view after this\n transaction is dispatched.\n */\n scrollIntoView) {\n this.startState = startState;\n this.changes = changes;\n this.selection = selection;\n this.effects = effects;\n this.annotations = annotations;\n this.scrollIntoView = scrollIntoView;\n /**\n @internal\n */\n this._doc = null;\n /**\n @internal\n */\n this._state = null;\n if (selection)\n checkSelection(selection, changes.newLength);\n if (!annotations.some((a) => a.type == Transaction.time))\n this.annotations = annotations.concat(Transaction.time.of(Date.now()));\n }\n /**\n @internal\n */\n static create(startState, changes, selection, effects, annotations, scrollIntoView) {\n return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);\n }\n /**\n The new document produced by the transaction. Contrary to\n [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't\n force the entire new state to be computed right away, so it is\n recommended that [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter\n when they need to look at the new document.\n */\n get newDoc() {\n return this._doc || (this._doc = this.changes.apply(this.startState.doc));\n }\n /**\n The new selection produced by the transaction. If\n [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,\n this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's\n current selection through the changes made by the transaction.\n */\n get newSelection() {\n return this.selection || this.startState.selection.map(this.changes);\n }\n /**\n The new state created by the transaction. Computed on demand\n (but retained for subsequent access), so it is recommended not to\n access it in [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.\n */\n get state() {\n if (!this._state)\n this.startState.applyTransaction(this);\n return this._state;\n }\n /**\n Get the value of the given annotation type, if any.\n */\n annotation(type) {\n for (let ann of this.annotations)\n if (ann.type == type)\n return ann.value;\n return undefined;\n }\n /**\n Indicates whether the transaction changed the document.\n */\n get docChanged() { return !this.changes.empty; }\n /**\n Indicates whether this transaction reconfigures the state\n (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or\n with a top-level configuration\n [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).\n */\n get reconfigured() { return this.startState.config != this.state.config; }\n /**\n Returns true if the transaction has a [user\n event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to\n or more specific than `event`. For example, if the transaction\n has `\"select.pointer\"` as user event, `\"select\"` and\n `\"select.pointer\"` will match it.\n */\n isUserEvent(event) {\n let e = this.annotation(Transaction.userEvent);\n return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == \".\"));\n }\n}\n/**\nAnnotation used to store transaction timestamps. Automatically\nadded to every transaction, holding `Date.now()`.\n*/\nTransaction.time = /*@__PURE__*/Annotation.define();\n/**\nAnnotation used to associate a transaction with a user interface\nevent. Holds a string identifying the event, using a\ndot-separated format to support attaching more specific\ninformation. The events used by the core libraries are:\n\n - `\"input\"` when content is entered\n - `\"input.type\"` for typed input\n - `\"input.type.compose\"` for composition\n - `\"input.paste\"` for pasted input\n - `\"input.drop\"` when adding content with drag-and-drop\n - `\"input.complete\"` when autocompleting\n - `\"delete\"` when the user deletes content\n - `\"delete.selection\"` when deleting the selection\n - `\"delete.forward\"` when deleting forward from the selection\n - `\"delete.backward\"` when deleting backward from the selection\n - `\"delete.cut\"` when cutting to the clipboard\n - `\"move\"` when content is moved\n - `\"move.drop\"` when content is moved within the editor through drag-and-drop\n - `\"select\"` when explicitly changing the selection\n - `\"select.pointer\"` when selecting with a mouse or other pointing device\n - `\"undo\"` and `\"redo\"` for history actions\n\nUse [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check\nwhether the annotation matches a given event.\n*/\nTransaction.userEvent = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating whether a transaction should be added to\nthe undo history or not.\n*/\nTransaction.addToHistory = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating (when present and true) that a transaction\nrepresents a change made by some other actor, not the user. This\nis used, for example, to tag other people's changes in\ncollaborative editing.\n*/\nTransaction.remote = /*@__PURE__*/Annotation.define();\nfunction joinRanges(a, b) {\n let result = [];\n for (let iA = 0, iB = 0;;) {\n let from, to;\n if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {\n from = a[iA++];\n to = a[iA++];\n }\n else if (iB < b.length) {\n from = b[iB++];\n to = b[iB++];\n }\n else\n return result;\n if (!result.length || result[result.length - 1] < from)\n result.push(from, to);\n else if (result[result.length - 1] < to)\n result[result.length - 1] = to;\n }\n}\nfunction mergeTransaction(a, b, sequential) {\n var _a;\n let mapForA, mapForB, changes;\n if (sequential) {\n mapForA = b.changes;\n mapForB = ChangeSet.empty(b.changes.length);\n changes = a.changes.compose(b.changes);\n }\n else {\n mapForA = b.changes.map(a.changes);\n mapForB = a.changes.mapDesc(b.changes, true);\n changes = a.changes.compose(mapForA);\n }\n return {\n changes,\n selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),\n effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),\n annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,\n scrollIntoView: a.scrollIntoView || b.scrollIntoView\n };\n}\nfunction resolveTransactionInner(state, spec, docSize) {\n let sel = spec.selection, annotations = asArray(spec.annotations);\n if (spec.userEvent)\n annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));\n return {\n changes: spec.changes instanceof ChangeSet ? spec.changes\n : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),\n selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),\n effects: asArray(spec.effects),\n annotations,\n scrollIntoView: !!spec.scrollIntoView\n };\n}\nfunction resolveTransaction(state, specs, filter) {\n let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);\n if (specs.length && specs[0].filter === false)\n filter = false;\n for (let i = 1; i < specs.length; i++) {\n if (specs[i].filter === false)\n filter = false;\n let seq = !!specs[i].sequential;\n s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);\n }\n let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);\n return extendTransaction(filter ? filterTransaction(tr) : tr);\n}\n// Finish a transaction by applying filters if necessary.\nfunction filterTransaction(tr) {\n let state = tr.startState;\n // Change filters\n let result = true;\n for (let filter of state.facet(changeFilter)) {\n let value = filter(tr);\n if (value === false) {\n result = false;\n break;\n }\n if (Array.isArray(value))\n result = result === true ? value : joinRanges(result, value);\n }\n if (result !== true) {\n let changes, back;\n if (result === false) {\n back = tr.changes.invertedDesc;\n changes = ChangeSet.empty(state.doc.length);\n }\n else {\n let filtered = tr.changes.filter(result);\n changes = filtered.changes;\n back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;\n }\n tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);\n }\n // Transaction filters\n let filters = state.facet(transactionFilter);\n for (let i = filters.length - 1; i >= 0; i--) {\n let filtered = filters[i](tr);\n if (filtered instanceof Transaction)\n tr = filtered;\n else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction)\n tr = filtered[0];\n else\n tr = resolveTransaction(state, asArray(filtered), false);\n }\n return tr;\n}\nfunction extendTransaction(tr) {\n let state = tr.startState, extenders = state.facet(transactionExtender), spec = tr;\n for (let i = extenders.length - 1; i >= 0; i--) {\n let extension = extenders[i](tr);\n if (extension && Object.keys(extension).length)\n spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);\n }\n return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);\n}\nconst none = [];\nfunction asArray(value) {\n return value == null ? none : Array.isArray(value) ? value : [value];\n}\n\n/**\nThe categories produced by a [character\ncategorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used\ndo things like selecting by word.\n*/\nvar CharCategory = /*@__PURE__*/(function (CharCategory) {\n /**\n Word characters.\n */\n CharCategory[CharCategory[\"Word\"] = 0] = \"Word\";\n /**\n Whitespace.\n */\n CharCategory[CharCategory[\"Space\"] = 1] = \"Space\";\n /**\n Anything else.\n */\n CharCategory[CharCategory[\"Other\"] = 2] = \"Other\";\nreturn CharCategory})(CharCategory || (CharCategory = {}));\nconst nonASCIISingleCaseWordChar = /[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/;\nlet wordChar;\ntry {\n wordChar = /*@__PURE__*/new RegExp(\"[\\\\p{Alphabetic}\\\\p{Number}_]\", \"u\");\n}\ncatch (_) { }\nfunction hasWordChar(str) {\n if (wordChar)\n return wordChar.test(str);\n for (let i = 0; i < str.length; i++) {\n let ch = str[i];\n if (/\\w/.test(ch) || ch > \"\\x80\" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)))\n return true;\n }\n return false;\n}\nfunction makeCategorizer(wordChars) {\n return (char) => {\n if (!/\\S/.test(char))\n return CharCategory.Space;\n if (hasWordChar(char))\n return CharCategory.Word;\n for (let i = 0; i < wordChars.length; i++)\n if (char.indexOf(wordChars[i]) > -1)\n return CharCategory.Word;\n return CharCategory.Other;\n };\n}\n\n/**\nThe editor state class is a persistent (immutable) data structure.\nTo update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a\n[transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state\ninstance, without modifying the original object.\n\nAs such, _never_ mutate properties of a state directly. That'll\njust break things.\n*/\nclass EditorState {\n constructor(\n /**\n @internal\n */\n config, \n /**\n The current document.\n */\n doc, \n /**\n The current selection.\n */\n selection, \n /**\n @internal\n */\n values, computeSlot, tr) {\n this.config = config;\n this.doc = doc;\n this.selection = selection;\n this.values = values;\n this.status = config.statusTemplate.slice();\n this.computeSlot = computeSlot;\n // Fill in the computed state immediately, so that further queries\n // for it made during the update return this state\n if (tr)\n tr._state = this;\n for (let i = 0; i < this.config.dynamicSlots.length; i++)\n ensureAddr(this, i << 1);\n this.computeSlot = null;\n }\n field(field, require = true) {\n let addr = this.config.address[field.id];\n if (addr == null) {\n if (require)\n throw new RangeError(\"Field is not present in this state\");\n return undefined;\n }\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this\n state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)\n can be passed. Unless\n [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the\n [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec\n are assumed to start in the _current_ document (not the document\n produced by previous specs), and its\n [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and\n [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer\n to the document created by its _own_ changes. The resulting\n transaction contains the combined effect of all the different\n specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later\n specs take precedence over earlier ones.\n */\n update(...specs) {\n return resolveTransaction(this, specs, true);\n }\n /**\n @internal\n */\n applyTransaction(tr) {\n let conf = this.config, { base, compartments } = conf;\n for (let effect of tr.effects) {\n if (effect.is(Compartment.reconfigure)) {\n if (conf) {\n compartments = new Map;\n conf.compartments.forEach((val, key) => compartments.set(key, val));\n conf = null;\n }\n compartments.set(effect.value.compartment, effect.value.extension);\n }\n else if (effect.is(StateEffect.reconfigure)) {\n conf = null;\n base = effect.value;\n }\n else if (effect.is(StateEffect.appendConfig)) {\n conf = null;\n base = asArray(base).concat(effect.value);\n }\n }\n let startValues;\n if (!conf) {\n conf = Configuration.resolve(base, compartments, this);\n let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);\n startValues = intermediateState.values;\n }\n else {\n startValues = tr.startState.values.slice();\n }\n new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);\n }\n /**\n Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that\n replaces every selection range with the given content.\n */\n replaceSelection(text) {\n if (typeof text == \"string\")\n text = this.toText(text);\n return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },\n range: EditorSelection.cursor(range.from + text.length) }));\n }\n /**\n Create a set of changes and a new selection by running the given\n function for each range in the active selection. The function\n can return an optional set of changes (in the coordinate space\n of the start document), plus an updated range (in the coordinate\n space of the document produced by the call's own changes). This\n method will merge all the changes and ranges into a single\n changeset and selection, and return it as a [transaction\n spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to\n [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).\n */\n changeByRange(f) {\n let sel = this.selection;\n let result1 = f(sel.ranges[0]);\n let changes = this.changes(result1.changes), ranges = [result1.range];\n let effects = asArray(result1.effects);\n for (let i = 1; i < sel.ranges.length; i++) {\n let result = f(sel.ranges[i]);\n let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);\n for (let j = 0; j < i; j++)\n ranges[j] = ranges[j].map(newMapped);\n let mapBy = changes.mapDesc(newChanges, true);\n ranges.push(result.range.map(mapBy));\n changes = changes.compose(newMapped);\n effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray(result.effects), mapBy));\n }\n return {\n changes,\n selection: EditorSelection.create(ranges, sel.mainIndex),\n effects\n };\n }\n /**\n Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change\n description, taking the state's document length and line\n separator into account.\n */\n changes(spec = []) {\n if (spec instanceof ChangeSet)\n return spec;\n return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));\n }\n /**\n Using the state's [line\n separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a\n [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.\n */\n toText(string) {\n return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));\n }\n /**\n Return the given range of the document as a string.\n */\n sliceDoc(from = 0, to = this.doc.length) {\n return this.doc.sliceString(from, to, this.lineBreak);\n }\n /**\n Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).\n */\n facet(facet) {\n let addr = this.config.address[facet.id];\n if (addr == null)\n return facet.default;\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Convert this state to a JSON-serializable object. When custom\n fields should be serialized, you can pass them in as an object\n mapping property names (in the resulting object, which should\n not use `doc` or `selection`) to fields.\n */\n toJSON(fields) {\n let result = {\n doc: this.sliceDoc(),\n selection: this.selection.toJSON()\n };\n if (fields)\n for (let prop in fields) {\n let value = fields[prop];\n if (value instanceof StateField && this.config.address[value.id] != null)\n result[prop] = value.spec.toJSON(this.field(fields[prop]), this);\n }\n return result;\n }\n /**\n Deserialize a state from its JSON representation. When custom\n fields should be deserialized, pass the same object you passed\n to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as\n third argument.\n */\n static fromJSON(json, config = {}, fields) {\n if (!json || typeof json.doc != \"string\")\n throw new RangeError(\"Invalid JSON representation for EditorState\");\n let fieldInit = [];\n if (fields)\n for (let prop in fields) {\n if (Object.prototype.hasOwnProperty.call(json, prop)) {\n let field = fields[prop], value = json[prop];\n fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));\n }\n }\n return EditorState.create({\n doc: json.doc,\n selection: EditorSelection.fromJSON(json.selection),\n extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit\n });\n }\n /**\n Create a new state. You'll usually only need this when\n initializing an editor—updated states are created by applying\n transactions.\n */\n static create(config = {}) {\n let configuration = Configuration.resolve(config.extensions || [], new Map);\n let doc = config.doc instanceof Text ? config.doc\n : Text.of((config.doc || \"\").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));\n let selection = !config.selection ? EditorSelection.single(0)\n : config.selection instanceof EditorSelection ? config.selection\n : EditorSelection.single(config.selection.anchor, config.selection.head);\n checkSelection(selection, doc.length);\n if (!configuration.staticFacet(allowMultipleSelections))\n selection = selection.asSingle();\n return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);\n }\n /**\n The size (in columns) of a tab in the document, determined by\n the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.\n */\n get tabSize() { return this.facet(EditorState.tabSize); }\n /**\n Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)\n string for this state.\n */\n get lineBreak() { return this.facet(EditorState.lineSeparator) || \"\\n\"; }\n /**\n Returns true when the editor is\n [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.\n */\n get readOnly() { return this.facet(readOnly); }\n /**\n Look up a translation for the given phrase (via the\n [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the\n original string if no translation is found.\n \n If additional arguments are passed, they will be inserted in\n place of markers like `$1` (for the first value) and `$2`, etc.\n A single `$` is equivalent to `$1`, and `$$` will produce a\n literal dollar sign.\n */\n phrase(phrase, ...insert) {\n for (let map of this.facet(EditorState.phrases))\n if (Object.prototype.hasOwnProperty.call(map, phrase)) {\n phrase = map[phrase];\n break;\n }\n if (insert.length)\n phrase = phrase.replace(/\\$(\\$|\\d*)/g, (m, i) => {\n if (i == \"$\")\n return \"$\";\n let n = +(i || 1);\n return !n || n > insert.length ? m : insert[n - 1];\n });\n return phrase;\n }\n /**\n Find the values for a given language data field, provided by the\n the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.\n \n Examples of language data fields are...\n \n - [`\"commentTokens\"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying\n comment syntax.\n - [`\"autocomplete\"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)\n for providing language-specific completion sources.\n - [`\"wordChars\"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding\n characters that should be considered part of words in this\n language.\n - [`\"closeBrackets\"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls\n bracket closing behavior.\n */\n languageDataAt(name, pos, side = -1) {\n let values = [];\n for (let provider of this.facet(languageData)) {\n for (let result of provider(this, pos, side)) {\n if (Object.prototype.hasOwnProperty.call(result, name))\n values.push(result[name]);\n }\n }\n return values;\n }\n /**\n Return a function that can categorize strings (expected to\n represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))\n into one of:\n \n - Word (contains an alphanumeric character or a character\n explicitly listed in the local language's `\"wordChars\"`\n language data, which should be a string)\n - Space (contains only whitespace)\n - Other (anything else)\n */\n charCategorizer(at) {\n return makeCategorizer(this.languageDataAt(\"wordChars\", at).join(\"\"));\n }\n /**\n Find the word at the given position, meaning the range\n containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters\n around it. If no word characters are adjacent to the position,\n this returns null.\n */\n wordAt(pos) {\n let { text, from, length } = this.doc.lineAt(pos);\n let cat = this.charCategorizer(pos);\n let start = pos - from, end = pos - from;\n while (start > 0) {\n let prev = findClusterBreak(text, start, false);\n if (cat(text.slice(prev, start)) != CharCategory.Word)\n break;\n start = prev;\n }\n while (end < length) {\n let next = findClusterBreak(text, end);\n if (cat(text.slice(end, next)) != CharCategory.Word)\n break;\n end = next;\n }\n return start == end ? null : EditorSelection.range(start + from, end + from);\n }\n}\n/**\nA facet that, when enabled, causes the editor to allow multiple\nranges to be selected. Be careful though, because by default the\neditor relies on the native DOM selection, which cannot handle\nmultiple selections. An extension like\n[`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make\nsecondary selections visible to the user.\n*/\nEditorState.allowMultipleSelections = allowMultipleSelections;\n/**\nConfigures the tab size to use in this state. The first\n(highest-precedence) value of the facet is used. If no value is\ngiven, this defaults to 4.\n*/\nEditorState.tabSize = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : 4\n});\n/**\nThe line separator to use. By default, any of `\"\\n\"`, `\"\\r\\n\"`\nand `\"\\r\"` is treated as a separator when splitting lines, and\nlines are joined with `\"\\n\"`.\n\nWhen you configure a value here, only that precise separator\nwill be used, allowing you to round-trip documents through the\neditor without normalizing line separators.\n*/\nEditorState.lineSeparator = lineSeparator;\n/**\nThis facet controls the value of the\n[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is\nconsulted by commands and extensions that implement editing\nfunctionality to determine whether they should apply. It\ndefaults to false, but when its highest-precedence value is\n`true`, such functionality disables itself.\n\nNot to be confused with\n[`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which\ncontrols whether the editor's DOM is set to be editable (and\nthus focusable).\n*/\nEditorState.readOnly = readOnly;\n/**\nRegisters translation phrases. The\n[`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through\nall objects registered with this facet to find translations for\nits argument.\n*/\nEditorState.phrases = /*@__PURE__*/Facet.define({\n compare(a, b) {\n let kA = Object.keys(a), kB = Object.keys(b);\n return kA.length == kB.length && kA.every(k => a[k] == b[k]);\n }\n});\n/**\nA facet used to register [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.\n*/\nEditorState.languageData = languageData;\n/**\nFacet used to register change filters, which are called for each\ntransaction (unless explicitly\n[disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress\npart of the transaction's changes.\n\nSuch a function can return `true` to indicate that it doesn't\nwant to do anything, `false` to completely stop the changes in\nthe transaction, or a set of ranges in which changes should be\nsuppressed. Such ranges are represented as an array of numbers,\nwith each pair of two numbers indicating the start and end of a\nrange. So for example `[10, 20, 100, 110]` suppresses changes\nbetween 10 and 20, and between 100 and 110.\n*/\nEditorState.changeFilter = changeFilter;\n/**\nFacet used to register a hook that gets a chance to update or\nreplace transaction specs before they are applied. This will\nonly be applied for transactions that don't have\n[`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You\ncan either return a single transaction spec (possibly the input\ntransaction), or an array of specs (which will be combined in\nthe same way as the arguments to\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).\n\nWhen possible, it is recommended to avoid accessing\n[`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,\nsince it will force creation of a state that will then be\ndiscarded again, if the transaction is actually filtered.\n\n(This functionality should be used with care. Indiscriminately\nmodifying transaction is likely to break something or degrade\nthe user experience.)\n*/\nEditorState.transactionFilter = transactionFilter;\n/**\nThis is a more limited form of\n[`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),\nwhich can only add\n[annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and\n[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type\nof filter runs even if the transaction has disabled regular\n[filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable\nfor effects that don't need to touch the changes or selection,\nbut do want to process every transaction.\n\nExtenders run _after_ filters, when both are present.\n*/\nEditorState.transactionExtender = transactionExtender;\nCompartment.reconfigure = /*@__PURE__*/StateEffect.define();\n\n/**\nUtility function for combining behaviors to fill in a config\nobject from an array of provided configs. `defaults` should hold\ndefault values for all optional fields in `Config`.\n\nThe function will, by default, error\nwhen a field gets two values that aren't `===`-equal, but you can\nprovide combine functions per field to do something else.\n*/\nfunction combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that\ncombine = {}) {\n let result = {};\n for (let config of configs)\n for (let key of Object.keys(config)) {\n let value = config[key], current = result[key];\n if (current === undefined)\n result[key] = value;\n else if (current === value || value === undefined) ; // No conflict\n else if (Object.hasOwnProperty.call(combine, key))\n result[key] = combine[key](current, value);\n else\n throw new Error(\"Config merge conflict for field \" + key);\n }\n for (let key in defaults)\n if (result[key] === undefined)\n result[key] = defaults[key];\n return result;\n}\n\n/**\nEach range is associated with a value, which must inherit from\nthis class.\n*/\nclass RangeValue {\n /**\n Compare this value with another value. Used when comparing\n rangesets. The default implementation compares by identity.\n Unless you are only creating a fixed number of unique instances\n of your value type, it is a good idea to implement this\n properly.\n */\n eq(other) { return this == other; }\n /**\n Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.\n */\n range(from, to = from) { return Range.create(from, to, this); }\n}\nRangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;\nRangeValue.prototype.point = false;\nRangeValue.prototype.mapMode = MapMode.TrackDel;\n/**\nA range associates a value with a range of positions.\n*/\nclass Range {\n constructor(\n /**\n The range's start position.\n */\n from, \n /**\n Its end position.\n */\n to, \n /**\n The value associated with this range.\n */\n value) {\n this.from = from;\n this.to = to;\n this.value = value;\n }\n /**\n @internal\n */\n static create(from, to, value) {\n return new Range(from, to, value);\n }\n}\nfunction cmpRange(a, b) {\n return a.from - b.from || a.value.startSide - b.value.startSide;\n}\nclass Chunk {\n constructor(from, to, value, \n // Chunks are marked with the largest point that occurs\n // in them (or -1 for no points), so that scans that are\n // only interested in points (such as the\n // heightmap-related logic) can skip range-only chunks.\n maxPoint) {\n this.from = from;\n this.to = to;\n this.value = value;\n this.maxPoint = maxPoint;\n }\n get length() { return this.to[this.to.length - 1]; }\n // Find the index of the given position and side. Use the ranges'\n // `from` pos when `end == false`, `to` when `end == true`.\n findIndex(pos, side, end, startAt = 0) {\n let arr = end ? this.to : this.from;\n for (let lo = startAt, hi = arr.length;;) {\n if (lo == hi)\n return lo;\n let mid = (lo + hi) >> 1;\n let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;\n if (mid == lo)\n return diff >= 0 ? lo : hi;\n if (diff >= 0)\n hi = mid;\n else\n lo = mid + 1;\n }\n }\n between(offset, from, to, f) {\n for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)\n if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)\n return false;\n }\n map(offset, changes) {\n let value = [], from = [], to = [], newPos = -1, maxPoint = -1;\n for (let i = 0; i < this.value.length; i++) {\n let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;\n if (curFrom == curTo) {\n let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);\n if (mapped == null)\n continue;\n newFrom = newTo = mapped;\n if (val.startSide != val.endSide) {\n newTo = changes.mapPos(curFrom, val.endSide);\n if (newTo < newFrom)\n continue;\n }\n }\n else {\n newFrom = changes.mapPos(curFrom, val.startSide);\n newTo = changes.mapPos(curTo, val.endSide);\n if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)\n continue;\n }\n if ((newTo - newFrom || val.endSide - val.startSide) < 0)\n continue;\n if (newPos < 0)\n newPos = newFrom;\n if (val.point)\n maxPoint = Math.max(maxPoint, newTo - newFrom);\n value.push(val);\n from.push(newFrom - newPos);\n to.push(newTo - newPos);\n }\n return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };\n }\n}\n/**\nA range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a\nway that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and\n[update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data\nstructure.\n*/\nclass RangeSet {\n constructor(\n /**\n @internal\n */\n chunkPos, \n /**\n @internal\n */\n chunk, \n /**\n @internal\n */\n nextLayer, \n /**\n @internal\n */\n maxPoint) {\n this.chunkPos = chunkPos;\n this.chunk = chunk;\n this.nextLayer = nextLayer;\n this.maxPoint = maxPoint;\n }\n /**\n @internal\n */\n static create(chunkPos, chunk, nextLayer, maxPoint) {\n return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);\n }\n /**\n @internal\n */\n get length() {\n let last = this.chunk.length - 1;\n return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);\n }\n /**\n The number of ranges in the set.\n */\n get size() {\n if (this.isEmpty)\n return 0;\n let size = this.nextLayer.size;\n for (let chunk of this.chunk)\n size += chunk.value.length;\n return size;\n }\n /**\n @internal\n */\n chunkEnd(index) {\n return this.chunkPos[index] + this.chunk[index].length;\n }\n /**\n Update the range set, optionally adding new ranges or filtering\n out existing ones.\n \n (Note: The type parameter is just there as a kludge to work\n around TypeScript variance issues that prevented `RangeSet<X>`\n from being a subtype of `RangeSet<Y>` when `X` is a subtype of\n `Y`.)\n */\n update(updateSpec) {\n let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;\n let filter = updateSpec.filter;\n if (add.length == 0 && !filter)\n return this;\n if (sort)\n add = add.slice().sort(cmpRange);\n if (this.isEmpty)\n return add.length ? RangeSet.of(add) : this;\n let cur = new LayerCursor(this, null, -1).goto(0), i = 0, spill = [];\n let builder = new RangeSetBuilder();\n while (cur.value || i < add.length) {\n if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {\n let range = add[i++];\n if (!builder.addInner(range.from, range.to, range.value))\n spill.push(range);\n }\n else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&\n (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&\n (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&\n builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {\n cur.nextChunk();\n }\n else {\n if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {\n if (!builder.addInner(cur.from, cur.to, cur.value))\n spill.push(Range.create(cur.from, cur.to, cur.value));\n }\n cur.next();\n }\n }\n return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty\n : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));\n }\n /**\n Map this range set through a set of changes, return the new set.\n */\n map(changes) {\n if (changes.empty || this.isEmpty)\n return this;\n let chunks = [], chunkPos = [], maxPoint = -1;\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n let touch = changes.touchesRange(start, start + chunk.length);\n if (touch === false) {\n maxPoint = Math.max(maxPoint, chunk.maxPoint);\n chunks.push(chunk);\n chunkPos.push(changes.mapPos(start));\n }\n else if (touch === true) {\n let { mapped, pos } = chunk.map(start, changes);\n if (mapped) {\n maxPoint = Math.max(maxPoint, mapped.maxPoint);\n chunks.push(mapped);\n chunkPos.push(pos);\n }\n }\n }\n let next = this.nextLayer.map(changes);\n return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);\n }\n /**\n Iterate over the ranges that touch the region `from` to `to`,\n calling `f` for each. There is no guarantee that the ranges will\n be reported in any specific order. When the callback returns\n `false`, iteration stops.\n */\n between(from, to, f) {\n if (this.isEmpty)\n return;\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n if (to >= start && from <= start + chunk.length &&\n chunk.between(start, from - start, to - start, f) === false)\n return;\n }\n this.nextLayer.between(from, to, f);\n }\n /**\n Iterate over the ranges in this set, in order, including all\n ranges that end at or after `from`.\n */\n iter(from = 0) {\n return HeapCursor.from([this]).goto(from);\n }\n /**\n @internal\n */\n get isEmpty() { return this.nextLayer == this; }\n /**\n Iterate over the ranges in a collection of sets, in order,\n starting from `from`.\n */\n static iter(sets, from = 0) {\n return HeapCursor.from(sets).goto(from);\n }\n /**\n Iterate over two groups of sets, calling methods on `comparator`\n to notify it of possible differences.\n */\n static compare(oldSets, newSets, \n /**\n This indicates how the underlying data changed between these\n ranges, and is needed to synchronize the iteration.\n */\n textDiff, comparator, \n /**\n Can be used to ignore all non-point ranges, and points below\n the given size. When -1, all ranges are compared.\n */\n minPointSize = -1) {\n let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let sharedChunks = findSharedChunks(a, b, textDiff);\n let sideA = new SpanCursor(a, sharedChunks, minPointSize);\n let sideB = new SpanCursor(b, sharedChunks, minPointSize);\n textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));\n if (textDiff.empty && textDiff.length == 0)\n compare(sideA, 0, sideB, 0, 0, comparator);\n }\n /**\n Compare the contents of two groups of range sets, returning true\n if they are equivalent in the given range.\n */\n static eq(oldSets, newSets, from = 0, to) {\n if (to == null)\n to = 1000000000 /* C.Far */ - 1;\n let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);\n let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);\n if (a.length != b.length)\n return false;\n if (!a.length)\n return true;\n let sharedChunks = findSharedChunks(a, b);\n let sideA = new SpanCursor(a, sharedChunks, 0).goto(from), sideB = new SpanCursor(b, sharedChunks, 0).goto(from);\n for (;;) {\n if (sideA.to != sideB.to ||\n !sameValues(sideA.active, sideB.active) ||\n sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))\n return false;\n if (sideA.to > to)\n return true;\n sideA.next();\n sideB.next();\n }\n }\n /**\n Iterate over a group of range sets at the same time, notifying\n the iterator about the ranges covering every given piece of\n content. Returns the open count (see\n [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end\n of the iteration.\n */\n static spans(sets, from, to, iterator, \n /**\n When given and greater than -1, only points of at least this\n size are taken into account.\n */\n minPointSize = -1) {\n let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;\n let openRanges = cursor.openStart;\n for (;;) {\n let curTo = Math.min(cursor.to, to);\n if (cursor.point) {\n let active = cursor.activeForPoint(cursor.to);\n let openCount = cursor.pointFrom < from ? active.length + 1 : Math.min(active.length, openRanges);\n iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);\n openRanges = Math.min(cursor.openEnd(curTo), active.length);\n }\n else if (curTo > pos) {\n iterator.span(pos, curTo, cursor.active, openRanges);\n openRanges = cursor.openEnd(curTo);\n }\n if (cursor.to > to)\n return openRanges + (cursor.point && cursor.to > to ? 1 : 0);\n pos = cursor.to;\n cursor.next();\n }\n }\n /**\n Create a range set for the given range or array of ranges. By\n default, this expects the ranges to be _sorted_ (by start\n position and, if two start at the same position,\n `value.startSide`). You can pass `true` as second argument to\n cause the method to sort them.\n */\n static of(ranges, sort = false) {\n let build = new RangeSetBuilder();\n for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges)\n build.add(range.from, range.to, range.value);\n return build.finish();\n }\n}\n/**\nThe empty set of ranges.\n*/\nRangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);\nfunction lazySort(ranges) {\n if (ranges.length > 1)\n for (let prev = ranges[0], i = 1; i < ranges.length; i++) {\n let cur = ranges[i];\n if (cmpRange(prev, cur) > 0)\n return ranges.slice().sort(cmpRange);\n prev = cur;\n }\n return ranges;\n}\nRangeSet.empty.nextLayer = RangeSet.empty;\n/**\nA range set builder is a data structure that helps build up a\n[range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating\nan array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.\n*/\nclass RangeSetBuilder {\n finishChunk(newArrays) {\n this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));\n this.chunkPos.push(this.chunkStart);\n this.chunkStart = -1;\n this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);\n this.maxPoint = -1;\n if (newArrays) {\n this.from = [];\n this.to = [];\n this.value = [];\n }\n }\n /**\n Create an empty builder.\n */\n constructor() {\n this.chunks = [];\n this.chunkPos = [];\n this.chunkStart = -1;\n this.last = null;\n this.lastFrom = -1000000000 /* C.Far */;\n this.lastTo = -1000000000 /* C.Far */;\n this.from = [];\n this.to = [];\n this.value = [];\n this.maxPoint = -1;\n this.setMaxPoint = -1;\n this.nextLayer = null;\n }\n /**\n Add a range. Ranges should be added in sorted (by `from` and\n `value.startSide`) order.\n */\n add(from, to, value) {\n if (!this.addInner(from, to, value))\n (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);\n }\n /**\n @internal\n */\n addInner(from, to, value) {\n let diff = from - this.lastTo || value.startSide - this.last.endSide;\n if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)\n throw new Error(\"Ranges must be added sorted by `from` position and `startSide`\");\n if (diff < 0)\n return false;\n if (this.from.length == 250 /* C.ChunkSize */)\n this.finishChunk(true);\n if (this.chunkStart < 0)\n this.chunkStart = from;\n this.from.push(from - this.chunkStart);\n this.to.push(to - this.chunkStart);\n this.last = value;\n this.lastFrom = from;\n this.lastTo = to;\n this.value.push(value);\n if (value.point)\n this.maxPoint = Math.max(this.maxPoint, to - from);\n return true;\n }\n /**\n @internal\n */\n addChunk(from, chunk) {\n if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)\n return false;\n if (this.from.length)\n this.finishChunk(true);\n this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);\n this.chunks.push(chunk);\n this.chunkPos.push(from);\n let last = chunk.value.length - 1;\n this.last = chunk.value[last];\n this.lastFrom = chunk.from[last] + from;\n this.lastTo = chunk.to[last] + from;\n return true;\n }\n /**\n Finish the range set. Returns the new set. The builder can't be\n used anymore after this has been called.\n */\n finish() { return this.finishInner(RangeSet.empty); }\n /**\n @internal\n */\n finishInner(next) {\n if (this.from.length)\n this.finishChunk(false);\n if (this.chunks.length == 0)\n return next;\n let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);\n this.from = null; // Make sure further `add` calls produce errors\n return result;\n }\n}\nfunction findSharedChunks(a, b, textDiff) {\n let inA = new Map();\n for (let set of a)\n for (let i = 0; i < set.chunk.length; i++)\n if (set.chunk[i].maxPoint <= 0)\n inA.set(set.chunk[i], set.chunkPos[i]);\n let shared = new Set();\n for (let set of b)\n for (let i = 0; i < set.chunk.length; i++) {\n let known = inA.get(set.chunk[i]);\n if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&\n !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))\n shared.add(set.chunk[i]);\n }\n return shared;\n}\nclass LayerCursor {\n constructor(layer, skip, minPoint, rank = 0) {\n this.layer = layer;\n this.skip = skip;\n this.minPoint = minPoint;\n this.rank = rank;\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n get endSide() { return this.value ? this.value.endSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.chunkIndex = this.rangeIndex = 0;\n this.gotoInner(pos, side, false);\n return this;\n }\n gotoInner(pos, side, forward) {\n while (this.chunkIndex < this.layer.chunk.length) {\n let next = this.layer.chunk[this.chunkIndex];\n if (!(this.skip && this.skip.has(next) ||\n this.layer.chunkEnd(this.chunkIndex) < pos ||\n next.maxPoint < this.minPoint))\n break;\n this.chunkIndex++;\n forward = false;\n }\n if (this.chunkIndex < this.layer.chunk.length) {\n let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);\n if (!forward || this.rangeIndex < rangeIndex)\n this.setRangeIndex(rangeIndex);\n }\n this.next();\n }\n forward(pos, side) {\n if ((this.to - pos || this.endSide - side) < 0)\n this.gotoInner(pos, side, true);\n }\n next() {\n for (;;) {\n if (this.chunkIndex == this.layer.chunk.length) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n break;\n }\n else {\n let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];\n let from = chunkPos + chunk.from[this.rangeIndex];\n this.from = from;\n this.to = chunkPos + chunk.to[this.rangeIndex];\n this.value = chunk.value[this.rangeIndex];\n this.setRangeIndex(this.rangeIndex + 1);\n if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)\n break;\n }\n }\n }\n setRangeIndex(index) {\n if (index == this.layer.chunk[this.chunkIndex].value.length) {\n this.chunkIndex++;\n if (this.skip) {\n while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))\n this.chunkIndex++;\n }\n this.rangeIndex = 0;\n }\n else {\n this.rangeIndex = index;\n }\n }\n nextChunk() {\n this.chunkIndex++;\n this.rangeIndex = 0;\n this.next();\n }\n compare(other) {\n return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||\n this.to - other.to || this.endSide - other.endSide;\n }\n}\nclass HeapCursor {\n constructor(heap) {\n this.heap = heap;\n }\n static from(sets, skip = null, minPoint = -1) {\n let heap = [];\n for (let i = 0; i < sets.length; i++) {\n for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {\n if (cur.maxPoint >= minPoint)\n heap.push(new LayerCursor(cur, skip, minPoint, i));\n }\n }\n return heap.length == 1 ? heap[0] : new HeapCursor(heap);\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n for (let cur of this.heap)\n cur.goto(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n this.next();\n return this;\n }\n forward(pos, side) {\n for (let cur of this.heap)\n cur.forward(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n if ((this.to - pos || this.value.endSide - side) < 0)\n this.next();\n }\n next() {\n if (this.heap.length == 0) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n this.rank = -1;\n }\n else {\n let top = this.heap[0];\n this.from = top.from;\n this.to = top.to;\n this.value = top.value;\n this.rank = top.rank;\n if (top.value)\n top.next();\n heapBubble(this.heap, 0);\n }\n }\n}\nfunction heapBubble(heap, index) {\n for (let cur = heap[index];;) {\n let childIndex = (index << 1) + 1;\n if (childIndex >= heap.length)\n break;\n let child = heap[childIndex];\n if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {\n child = heap[childIndex + 1];\n childIndex++;\n }\n if (cur.compare(child) < 0)\n break;\n heap[childIndex] = cur;\n heap[index] = child;\n index = childIndex;\n }\n}\nclass SpanCursor {\n constructor(sets, skip, minPoint) {\n this.minPoint = minPoint;\n this.active = [];\n this.activeTo = [];\n this.activeRank = [];\n this.minActive = -1;\n // A currently active point range, if any\n this.point = null;\n this.pointFrom = 0;\n this.pointRank = 0;\n this.to = -1000000000 /* C.Far */;\n this.endSide = 0;\n // The amount of open active ranges at the start of the iterator.\n // Not including points.\n this.openStart = -1;\n this.cursor = HeapCursor.from(sets, skip, minPoint);\n }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.cursor.goto(pos, side);\n this.active.length = this.activeTo.length = this.activeRank.length = 0;\n this.minActive = -1;\n this.to = pos;\n this.endSide = side;\n this.openStart = -1;\n this.next();\n return this;\n }\n forward(pos, side) {\n while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)\n this.removeActive(this.minActive);\n this.cursor.forward(pos, side);\n }\n removeActive(index) {\n remove(this.active, index);\n remove(this.activeTo, index);\n remove(this.activeRank, index);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n addActive(trackOpen) {\n let i = 0, { value, to, rank } = this.cursor;\n while (i < this.activeRank.length && this.activeRank[i] <= rank)\n i++;\n insert(this.active, i, value);\n insert(this.activeTo, i, to);\n insert(this.activeRank, i, rank);\n if (trackOpen)\n insert(trackOpen, i, this.cursor.from);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n // After calling this, if `this.point` != null, the next range is a\n // point. Otherwise, it's a regular range, covered by `this.active`.\n next() {\n let from = this.to, wasPoint = this.point;\n this.point = null;\n let trackOpen = this.openStart < 0 ? [] : null;\n for (;;) {\n let a = this.minActive;\n if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {\n if (this.activeTo[a] > from) {\n this.to = this.activeTo[a];\n this.endSide = this.active[a].endSide;\n break;\n }\n this.removeActive(a);\n if (trackOpen)\n remove(trackOpen, a);\n }\n else if (!this.cursor.value) {\n this.to = this.endSide = 1000000000 /* C.Far */;\n break;\n }\n else if (this.cursor.from > from) {\n this.to = this.cursor.from;\n this.endSide = this.cursor.startSide;\n break;\n }\n else {\n let nextVal = this.cursor.value;\n if (!nextVal.point) { // Opening a range\n this.addActive(trackOpen);\n this.cursor.next();\n }\n else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {\n // Ignore any non-empty points that end precisely at the end of the prev point\n this.cursor.next();\n }\n else { // New point\n this.point = nextVal;\n this.pointFrom = this.cursor.from;\n this.pointRank = this.cursor.rank;\n this.to = this.cursor.to;\n this.endSide = nextVal.endSide;\n this.cursor.next();\n this.forward(this.to, this.endSide);\n break;\n }\n }\n }\n if (trackOpen) {\n this.openStart = 0;\n for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)\n this.openStart++;\n }\n }\n activeForPoint(to) {\n if (!this.active.length)\n return this.active;\n let active = [];\n for (let i = this.active.length - 1; i >= 0; i--) {\n if (this.activeRank[i] < this.pointRank)\n break;\n if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)\n active.push(this.active[i]);\n }\n return active.reverse();\n }\n openEnd(to) {\n let open = 0;\n for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)\n open++;\n return open;\n }\n}\nfunction compare(a, startA, b, startB, length, comparator) {\n a.goto(startA);\n b.goto(startB);\n let endB = startB + length;\n let pos = startB, dPos = startB - startA;\n for (;;) {\n let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;\n let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);\n if (a.point || b.point) {\n if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&\n sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))\n comparator.comparePoint(pos, clipEnd, a.point, b.point);\n }\n else {\n if (clipEnd > pos && !sameValues(a.active, b.active))\n comparator.compareRange(pos, clipEnd, a.active, b.active);\n }\n if (end > endB)\n break;\n pos = end;\n if (diff <= 0)\n a.next();\n if (diff >= 0)\n b.next();\n }\n}\nfunction sameValues(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (a[i] != b[i] && !a[i].eq(b[i]))\n return false;\n return true;\n}\nfunction remove(array, index) {\n for (let i = index, e = array.length - 1; i < e; i++)\n array[i] = array[i + 1];\n array.pop();\n}\nfunction insert(array, index, value) {\n for (let i = array.length - 1; i >= index; i--)\n array[i + 1] = array[i];\n array[index] = value;\n}\nfunction findMinIndex(value, array) {\n let found = -1, foundPos = 1000000000 /* C.Far */;\n for (let i = 0; i < array.length; i++)\n if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {\n found = i;\n foundPos = array[i];\n }\n return found;\n}\n\n/**\nCount the column position at the given offset into the string,\ntaking extending characters and tab size into account.\n*/\nfunction countColumn(string, tabSize, to = string.length) {\n let n = 0;\n for (let i = 0; i < to;) {\n if (string.charCodeAt(i) == 9) {\n n += tabSize - (n % tabSize);\n i++;\n }\n else {\n n++;\n i = findClusterBreak(string, i);\n }\n }\n return n;\n}\n/**\nFind the offset that corresponds to the given column position in a\nstring, taking extending characters and tab size into account. By\ndefault, the string length is returned when it is too short to\nreach the column. Pass `strict` true to make it return -1 in that\nsituation.\n*/\nfunction findColumn(string, col, tabSize, strict) {\n for (let i = 0, n = 0;;) {\n if (n >= col)\n return i;\n if (i == string.length)\n break;\n n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;\n i = findClusterBreak(string, i);\n }\n return strict === true ? -1 : string.length;\n}\n\nexport { Annotation, AnnotationType, ChangeDesc, ChangeSet, CharCategory, Compartment, EditorSelection, EditorState, Facet, Line, MapMode, Prec, Range, RangeSet, RangeSetBuilder, RangeValue, SelectionRange, StateEffect, StateEffectType, StateField, Text, Transaction, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn, fromCodePoint };\n","const C = \"\\u037c\"\nconst COUNT = typeof Symbol == \"undefined\" ? \"__\" + C : Symbol.for(C)\nconst SET = typeof Symbol == \"undefined\" ? \"__styleSet\" + Math.floor(Math.random() * 1e8) : Symbol(\"styleSet\")\nconst top = typeof globalThis != \"undefined\" ? globalThis : typeof window != \"undefined\" ? window : {}\n\n// :: - Style modules encapsulate a set of CSS rules defined from\n// JavaScript. Their definitions are only available in a given DOM\n// root after it has been _mounted_ there with `StyleModule.mount`.\n//\n// Style modules should be created once and stored somewhere, as\n// opposed to re-creating them every time you need them. The amount of\n// CSS rules generated for a given DOM root is bounded by the amount\n// of style modules that were used. So to avoid leaking rules, don't\n// create these dynamically, but treat them as one-time allocations.\nexport class StyleModule {\n // :: (Object<Style>, ?{finish: ?(string) → string})\n // Create a style module from the given spec.\n //\n // When `finish` is given, it is called on regular (non-`@`)\n // selectors (after `&` expansion) to compute the final selector.\n constructor(spec, options) {\n this.rules = []\n let {finish} = options || {}\n\n function splitSelector(selector) {\n return /^@/.test(selector) ? [selector] : selector.split(/,\\s*/)\n }\n\n function render(selectors, spec, target, isKeyframes) {\n let local = [], isAt = /^@(\\w+)\\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == \"keyframes\"\n if (isAt && spec == null) return target.push(selectors[0] + \";\")\n for (let prop in spec) {\n let value = spec[prop]\n if (/&/.test(prop)) {\n render(prop.split(/,\\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),\n value, target)\n } else if (value && typeof value == \"object\") {\n if (!isAt) throw new RangeError(\"The value of a property (\" + prop + \") should be a primitive value.\")\n render(splitSelector(prop), value, local, keyframes)\n } else if (value != null) {\n local.push(prop.replace(/_.*/, \"\").replace(/[A-Z]/g, l => \"-\" + l.toLowerCase()) + \": \" + value + \";\")\n }\n }\n if (local.length || keyframes) {\n target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(\", \") +\n \" {\" + local.join(\" \") + \"}\")\n }\n }\n\n for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules)\n }\n\n // :: () → string\n // Returns a string containing the module's CSS rules.\n getRules() { return this.rules.join(\"\\n\") }\n\n // :: () → string\n // Generate a new unique CSS class name.\n static newName() {\n let id = top[COUNT] || 1\n top[COUNT] = id + 1\n return C + id.toString(36)\n }\n\n // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})\n //\n // Mount the given set of modules in the given DOM root, which ensures\n // that the CSS rules defined by the module are available in that\n // context.\n //\n // Rules are only added to the document once per root.\n //\n // Rule order will follow the order of the modules, so that rules from\n // modules later in the array take precedence of those from earlier\n // modules. If you call this function multiple times for the same root\n // in a way that changes the order of already mounted modules, the old\n // order will be changed.\n //\n // If a Content Security Policy nonce is provided, it is added to\n // the `<style>` tag generated by the library.\n static mount(root, modules, options) {\n let set = root[SET], nonce = options && options.nonce\n if (!set) set = new StyleSet(root, nonce)\n else if (nonce) set.setNonce(nonce)\n set.mount(Array.isArray(modules) ? modules : [modules])\n }\n}\n\nlet adoptedSet = new Map //<Document, StyleSet>\n\nclass StyleSet {\n constructor(root, nonce) {\n let doc = root.ownerDocument || root, win = doc.defaultView\n if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {\n let adopted = adoptedSet.get(doc)\n if (adopted) {\n root.adoptedStyleSheets = [adopted.sheet, ...root.adoptedStyleSheets]\n return root[SET] = adopted\n }\n this.sheet = new win.CSSStyleSheet\n root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets]\n adoptedSet.set(doc, this)\n } else {\n this.styleTag = doc.createElement(\"style\")\n if (nonce) this.styleTag.setAttribute(\"nonce\", nonce)\n let target = root.head || root\n target.insertBefore(this.styleTag, target.firstChild)\n }\n this.modules = []\n root[SET] = this\n }\n\n mount(modules) {\n let sheet = this.sheet\n let pos = 0 /* Current rule offset */, j = 0 /* Index into this.modules */\n for (let i = 0; i < modules.length; i++) {\n let mod = modules[i], index = this.modules.indexOf(mod)\n if (index < j && index > -1) { // Ordering conflict\n this.modules.splice(index, 1)\n j--\n index = -1\n }\n if (index == -1) {\n this.modules.splice(j++, 0, mod)\n if (sheet) for (let k = 0; k < mod.rules.length; k++)\n sheet.insertRule(mod.rules[k], pos++)\n } else {\n while (j < index) pos += this.modules[j++].rules.length\n pos += mod.rules.length\n j++\n }\n }\n\n if (!sheet) {\n let text = \"\"\n for (let i = 0; i < this.modules.length; i++)\n text += this.modules[i].getRules() + \"\\n\"\n this.styleTag.textContent = text\n }\n }\n\n setNonce(nonce) {\n if (this.styleTag && this.styleTag.getAttribute(\"nonce\") != nonce)\n this.styleTag.setAttribute(\"nonce\", nonce)\n }\n}\n\n// Style::Object<union<Style,string>>\n//\n// A style is an object that, in the simple case, maps CSS property\n// names to strings holding their values, as in `{color: \"red\",\n// fontWeight: \"bold\"}`. The property names can be given in\n// camel-case—the library will insert a dash before capital letters\n// when converting them to CSS.\n//\n// If you include an underscore in a property name, it and everything\n// after it will be removed from the output, which can be useful when\n// providing a property multiple times, for browser compatibility\n// reasons.\n//\n// A property in a style object can also be a sub-selector, which\n// extends the current context to add a pseudo-selector or a child\n// selector. Such a property should contain a `&` character, which\n// will be replaced by the current selector. For example `{\"&:before\":\n// {content: '\"hi\"'}}`. Sub-selectors and regular properties can\n// freely be mixed in a given object. Any property containing a `&` is\n// assumed to be a sub-selector.\n//\n// Finally, a property can specify an @-block to be wrapped around the\n// styles defined inside the object that's the property's value. For\n// example to create a media query you can do `{\"@media screen and\n// (min-width: 400px)\": {...}}`.\n","export var base = {\n 8: \"Backspace\",\n 9: \"Tab\",\n 10: \"Enter\",\n 12: \"NumLock\",\n 13: \"Enter\",\n 16: \"Shift\",\n 17: \"Control\",\n 18: \"Alt\",\n 20: \"CapsLock\",\n 27: \"Escape\",\n 32: \" \",\n 33: \"PageUp\",\n 34: \"PageDown\",\n 35: \"End\",\n 36: \"Home\",\n 37: \"ArrowLeft\",\n 38: \"ArrowUp\",\n 39: \"ArrowRight\",\n 40: \"ArrowDown\",\n 44: \"PrintScreen\",\n 45: \"Insert\",\n 46: \"Delete\",\n 59: \";\",\n 61: \"=\",\n 91: \"Meta\",\n 92: \"Meta\",\n 106: \"*\",\n 107: \"+\",\n 108: \",\",\n 109: \"-\",\n 110: \".\",\n 111: \"/\",\n 144: \"NumLock\",\n 145: \"ScrollLock\",\n 160: \"Shift\",\n 161: \"Shift\",\n 162: \"Control\",\n 163: \"Control\",\n 164: \"Alt\",\n 165: \"Alt\",\n 173: \"-\",\n 186: \";\",\n 187: \"=\",\n 188: \",\",\n 189: \"-\",\n 190: \".\",\n 191: \"/\",\n 192: \"`\",\n 219: \"[\",\n 220: \"\\\\\",\n 221: \"]\",\n 222: \"'\"\n}\n\nexport var shift = {\n 48: \")\",\n 49: \"!\",\n 50: \"@\",\n 51: \"#\",\n 52: \"$\",\n 53: \"%\",\n 54: \"^\",\n 55: \"&\",\n 56: \"*\",\n 57: \"(\",\n 59: \":\",\n 61: \"+\",\n 173: \"_\",\n 186: \":\",\n 187: \"+\",\n 188: \"<\",\n 189: \"_\",\n 190: \">\",\n 191: \"?\",\n 192: \"~\",\n 219: \"{\",\n 220: \"|\",\n 221: \"}\",\n 222: \"\\\"\"\n}\n\nvar mac = typeof navigator != \"undefined\" && /Mac/.test(navigator.platform)\nvar ie = typeof navigator != \"undefined\" && /MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent)\n\n// Fill in the digit keys\nfor (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i)\n\n// The function keys\nfor (var i = 1; i <= 24; i++) base[i + 111] = \"F\" + i\n\n// And the alphabetic keys\nfor (var i = 65; i <= 90; i++) {\n base[i] = String.fromCharCode(i + 32)\n shift[i] = String.fromCharCode(i)\n}\n\n// For each code that doesn't have a shift-equivalent, copy the base name\nfor (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code]\n\nexport function keyName(event) {\n // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.\n // On IE, shift effect is never included in `.key`.\n var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||\n ie && event.shiftKey && event.key && event.key.length == 1 ||\n event.key == \"Unidentified\"\n var name = (!ignoreKey && event.key) ||\n (event.shiftKey ? shift : base)[event.keyCode] ||\n event.key || \"Unidentified\"\n // Edge sometimes produces wrong names (Issue #3)\n if (name == \"Esc\") name = \"Escape\"\n if (name == \"Del\") name = \"Delete\"\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/\n if (name == \"Left\") name = \"ArrowLeft\"\n if (name == \"Up\") name = \"ArrowUp\"\n if (name == \"Right\") name = \"ArrowRight\"\n if (name == \"Down\") name = \"ArrowDown\"\n return name\n}\n","import { Text, RangeSet, MapMode, RangeValue, Facet, StateEffect, ChangeSet, EditorSelection, findClusterBreak, findColumn, CharCategory, Annotation, EditorState, Transaction, Prec, codePointAt, codePointSize, combineConfig, StateField, RangeSetBuilder, countColumn } from '@codemirror/state';\nimport { StyleModule } from 'style-mod';\nimport { keyName, base, shift } from 'w3c-keyname';\n\nfunction getSelection(root) {\n let target;\n // Browsers differ on whether shadow roots have a getSelection\n // method. If it exists, use that, otherwise, call it on the\n // document.\n if (root.nodeType == 11) { // Shadow root\n target = root.getSelection ? root : root.ownerDocument;\n }\n else {\n target = root;\n }\n return target.getSelection();\n}\nfunction contains(dom, node) {\n return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;\n}\nfunction deepActiveElement(doc) {\n let elt = doc.activeElement;\n while (elt && elt.shadowRoot)\n elt = elt.shadowRoot.activeElement;\n return elt;\n}\nfunction hasSelection(dom, selection) {\n if (!selection.anchorNode)\n return false;\n try {\n // Firefox will raise 'permission denied' errors when accessing\n // properties of `sel.anchorNode` when it's in a generated CSS\n // element.\n return contains(dom, selection.anchorNode);\n }\n catch (_) {\n return false;\n }\n}\nfunction clientRectsFor(dom) {\n if (dom.nodeType == 3)\n return textRange(dom, 0, dom.nodeValue.length).getClientRects();\n else if (dom.nodeType == 1)\n return dom.getClientRects();\n else\n return [];\n}\n// Scans forward and backward through DOM positions equivalent to the\n// given one to see if the two are in the same place (i.e. after a\n// text node vs at the end of that text node)\nfunction isEquivalentPosition(node, off, targetNode, targetOff) {\n return targetNode ? (scanFor(node, off, targetNode, targetOff, -1) ||\n scanFor(node, off, targetNode, targetOff, 1)) : false;\n}\nfunction domIndex(node) {\n for (var index = 0;; index++) {\n node = node.previousSibling;\n if (!node)\n return index;\n }\n}\nfunction scanFor(node, off, targetNode, targetOff, dir) {\n for (;;) {\n if (node == targetNode && off == targetOff)\n return true;\n if (off == (dir < 0 ? 0 : maxOffset(node))) {\n if (node.nodeName == \"DIV\")\n return false;\n let parent = node.parentNode;\n if (!parent || parent.nodeType != 1)\n return false;\n off = domIndex(node) + (dir < 0 ? 0 : 1);\n node = parent;\n }\n else if (node.nodeType == 1) {\n node = node.childNodes[off + (dir < 0 ? -1 : 0)];\n if (node.nodeType == 1 && node.contentEditable == \"false\")\n return false;\n off = dir < 0 ? maxOffset(node) : 0;\n }\n else {\n return false;\n }\n }\n}\nfunction maxOffset(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;\n}\nfunction flattenRect(rect, left) {\n let x = left ? rect.left : rect.right;\n return { left: x, right: x, top: rect.top, bottom: rect.bottom };\n}\nfunction windowRect(win) {\n return { left: 0, right: win.innerWidth,\n top: 0, bottom: win.innerHeight };\n}\nfunction getScale(elt, rect) {\n let scaleX = rect.width / elt.offsetWidth;\n let scaleY = rect.height / elt.offsetHeight;\n if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX) || Math.abs(rect.width - elt.offsetWidth) < 1)\n scaleX = 1;\n if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY) || Math.abs(rect.height - elt.offsetHeight) < 1)\n scaleY = 1;\n return { scaleX, scaleY };\n}\nfunction scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {\n let doc = dom.ownerDocument, win = doc.defaultView || window;\n for (let cur = dom, stop = false; cur && !stop;) {\n if (cur.nodeType == 1) { // Element\n let bounding, top = cur == doc.body;\n let scaleX = 1, scaleY = 1;\n if (top) {\n bounding = windowRect(win);\n }\n else {\n if (/^(fixed|sticky)$/.test(getComputedStyle(cur).position))\n stop = true;\n if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {\n cur = cur.assignedSlot || cur.parentNode;\n continue;\n }\n let rect = cur.getBoundingClientRect();\n ({ scaleX, scaleY } = getScale(cur, rect));\n // Make sure scrollbar width isn't included in the rectangle\n bounding = { left: rect.left, right: rect.left + cur.clientWidth * scaleX,\n top: rect.top, bottom: rect.top + cur.clientHeight * scaleY };\n }\n let moveX = 0, moveY = 0;\n if (y == \"nearest\") {\n if (rect.top < bounding.top) {\n moveY = -(bounding.top - rect.top + yMargin);\n if (side > 0 && rect.bottom > bounding.bottom + moveY)\n moveY = rect.bottom - bounding.bottom + moveY + yMargin;\n }\n else if (rect.bottom > bounding.bottom) {\n moveY = rect.bottom - bounding.bottom + yMargin;\n if (side < 0 && (rect.top - moveY) < bounding.top)\n moveY = -(bounding.top + moveY - rect.top + yMargin);\n }\n }\n else {\n let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;\n let targetTop = y == \"center\" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :\n y == \"start\" || y == \"center\" && side < 0 ? rect.top - yMargin :\n rect.bottom - boundingHeight + yMargin;\n moveY = targetTop - bounding.top;\n }\n if (x == \"nearest\") {\n if (rect.left < bounding.left) {\n moveX = -(bounding.left - rect.left + xMargin);\n if (side > 0 && rect.right > bounding.right + moveX)\n moveX = rect.right - bounding.right + moveX + xMargin;\n }\n else if (rect.right > bounding.right) {\n moveX = rect.right - bounding.right + xMargin;\n if (side < 0 && rect.left < bounding.left + moveX)\n moveX = -(bounding.left + moveX - rect.left + xMargin);\n }\n }\n else {\n let targetLeft = x == \"center\" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :\n (x == \"start\") == ltr ? rect.left - xMargin :\n rect.right - (bounding.right - bounding.left) + xMargin;\n moveX = targetLeft - bounding.left;\n }\n if (moveX || moveY) {\n if (top) {\n win.scrollBy(moveX, moveY);\n }\n else {\n let movedX = 0, movedY = 0;\n if (moveY) {\n let start = cur.scrollTop;\n cur.scrollTop += moveY / scaleY;\n movedY = (cur.scrollTop - start) * scaleY;\n }\n if (moveX) {\n let start = cur.scrollLeft;\n cur.scrollLeft += moveX / scaleX;\n movedX = (cur.scrollLeft - start) * scaleX;\n }\n rect = { left: rect.left - movedX, top: rect.top - movedY,\n right: rect.right - movedX, bottom: rect.bottom - movedY };\n if (movedX && Math.abs(movedX - moveX) < 1)\n x = \"nearest\";\n if (movedY && Math.abs(movedY - moveY) < 1)\n y = \"nearest\";\n }\n }\n if (top)\n break;\n cur = cur.assignedSlot || cur.parentNode;\n }\n else if (cur.nodeType == 11) { // A shadow root\n cur = cur.host;\n }\n else {\n break;\n }\n }\n}\nfunction scrollableParent(dom) {\n let doc = dom.ownerDocument;\n for (let cur = dom.parentNode; cur;) {\n if (cur == doc.body) {\n break;\n }\n else if (cur.nodeType == 1) {\n if (cur.scrollHeight > cur.clientHeight || cur.scrollWidth > cur.clientWidth)\n return cur;\n cur = cur.assignedSlot || cur.parentNode;\n }\n else if (cur.nodeType == 11) {\n cur = cur.host;\n }\n else {\n break;\n }\n }\n return null;\n}\nclass DOMSelectionState {\n constructor() {\n this.anchorNode = null;\n this.anchorOffset = 0;\n this.focusNode = null;\n this.focusOffset = 0;\n }\n eq(domSel) {\n return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&\n this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;\n }\n setRange(range) {\n let { anchorNode, focusNode } = range;\n // Clip offsets to node size to avoid crashes when Safari reports bogus offsets (#1152)\n this.set(anchorNode, Math.min(range.anchorOffset, anchorNode ? maxOffset(anchorNode) : 0), focusNode, Math.min(range.focusOffset, focusNode ? maxOffset(focusNode) : 0));\n }\n set(anchorNode, anchorOffset, focusNode, focusOffset) {\n this.anchorNode = anchorNode;\n this.anchorOffset = anchorOffset;\n this.focusNode = focusNode;\n this.focusOffset = focusOffset;\n }\n}\nlet preventScrollSupported = null;\n// Feature-detects support for .focus({preventScroll: true}), and uses\n// a fallback kludge when not supported.\nfunction focusPreventScroll(dom) {\n if (dom.setActive)\n return dom.setActive(); // in IE\n if (preventScrollSupported)\n return dom.focus(preventScrollSupported);\n let stack = [];\n for (let cur = dom; cur; cur = cur.parentNode) {\n stack.push(cur, cur.scrollTop, cur.scrollLeft);\n if (cur == cur.ownerDocument)\n break;\n }\n dom.focus(preventScrollSupported == null ? {\n get preventScroll() {\n preventScrollSupported = { preventScroll: true };\n return true;\n }\n } : undefined);\n if (!preventScrollSupported) {\n preventScrollSupported = false;\n for (let i = 0; i < stack.length;) {\n let elt = stack[i++], top = stack[i++], left = stack[i++];\n if (elt.scrollTop != top)\n elt.scrollTop = top;\n if (elt.scrollLeft != left)\n elt.scrollLeft = left;\n }\n }\n}\nlet scratchRange;\nfunction textRange(node, from, to = from) {\n let range = scratchRange || (scratchRange = document.createRange());\n range.setEnd(node, to);\n range.setStart(node, from);\n return range;\n}\nfunction dispatchKey(elt, name, code) {\n let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };\n let down = new KeyboardEvent(\"keydown\", options);\n down.synthetic = true;\n elt.dispatchEvent(down);\n let up = new KeyboardEvent(\"keyup\", options);\n up.synthetic = true;\n elt.dispatchEvent(up);\n return down.defaultPrevented || up.defaultPrevented;\n}\nfunction getRoot(node) {\n while (node) {\n if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))\n return node;\n node = node.assignedSlot || node.parentNode;\n }\n return null;\n}\nfunction clearAttributes(node) {\n while (node.attributes.length)\n node.removeAttributeNode(node.attributes[0]);\n}\nfunction atElementStart(doc, selection) {\n let node = selection.focusNode, offset = selection.focusOffset;\n if (!node || selection.anchorNode != node || selection.anchorOffset != offset)\n return false;\n // Safari can report bogus offsets (#1152)\n offset = Math.min(offset, maxOffset(node));\n for (;;) {\n if (offset) {\n if (node.nodeType != 1)\n return false;\n let prev = node.childNodes[offset - 1];\n if (prev.contentEditable == \"false\")\n offset--;\n else {\n node = prev;\n offset = maxOffset(node);\n }\n }\n else if (node == doc) {\n return true;\n }\n else {\n offset = domIndex(node);\n node = node.parentNode;\n }\n }\n}\nfunction isScrolledToBottom(elt) {\n return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);\n}\n\nclass DOMPos {\n constructor(node, offset, precise = true) {\n this.node = node;\n this.offset = offset;\n this.precise = precise;\n }\n static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom), precise); }\n static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom) + 1, precise); }\n}\nconst noChildren = [];\nclass ContentView {\n constructor() {\n this.parent = null;\n this.dom = null;\n this.flags = 2 /* ViewFlag.NodeDirty */;\n }\n get overrideDOMText() { return null; }\n get posAtStart() {\n return this.parent ? this.parent.posBefore(this) : 0;\n }\n get posAtEnd() {\n return this.posAtStart + this.length;\n }\n posBefore(view) {\n let pos = this.posAtStart;\n for (let child of this.children) {\n if (child == view)\n return pos;\n pos += child.length + child.breakAfter;\n }\n throw new RangeError(\"Invalid child in posBefore\");\n }\n posAfter(view) {\n return this.posBefore(view) + view.length;\n }\n sync(view, track) {\n if (this.flags & 2 /* ViewFlag.NodeDirty */) {\n let parent = this.dom;\n let prev = null, next;\n for (let child of this.children) {\n if (child.flags & 7 /* ViewFlag.Dirty */) {\n if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {\n let contentView = ContentView.get(next);\n if (!contentView || !contentView.parent && contentView.canReuseDOM(child))\n child.reuseDOM(next);\n }\n child.sync(view, track);\n child.flags &= ~7 /* ViewFlag.Dirty */;\n }\n next = prev ? prev.nextSibling : parent.firstChild;\n if (track && !track.written && track.node == parent && next != child.dom)\n track.written = true;\n if (child.dom.parentNode == parent) {\n while (next && next != child.dom)\n next = rm$1(next);\n }\n else {\n parent.insertBefore(child.dom, next);\n }\n prev = child.dom;\n }\n next = prev ? prev.nextSibling : parent.firstChild;\n if (next && track && track.node == parent)\n track.written = true;\n while (next)\n next = rm$1(next);\n }\n else if (this.flags & 1 /* ViewFlag.ChildDirty */) {\n for (let child of this.children)\n if (child.flags & 7 /* ViewFlag.Dirty */) {\n child.sync(view, track);\n child.flags &= ~7 /* ViewFlag.Dirty */;\n }\n }\n }\n reuseDOM(_dom) { }\n localPosFromDOM(node, offset) {\n let after;\n if (node == this.dom) {\n after = this.dom.childNodes[offset];\n }\n else {\n let bias = maxOffset(node) == 0 ? 0 : offset == 0 ? -1 : 1;\n for (;;) {\n let parent = node.parentNode;\n if (parent == this.dom)\n break;\n if (bias == 0 && parent.firstChild != parent.lastChild) {\n if (node == parent.firstChild)\n bias = -1;\n else\n bias = 1;\n }\n node = parent;\n }\n if (bias < 0)\n after = node;\n else\n after = node.nextSibling;\n }\n if (after == this.dom.firstChild)\n return 0;\n while (after && !ContentView.get(after))\n after = after.nextSibling;\n if (!after)\n return this.length;\n for (let i = 0, pos = 0;; i++) {\n let child = this.children[i];\n if (child.dom == after)\n return pos;\n pos += child.length + child.breakAfter;\n }\n }\n domBoundsAround(from, to, offset = 0) {\n let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;\n for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (pos < from && end > to)\n return child.domBoundsAround(from, to, pos);\n if (end >= from && fromI == -1) {\n fromI = i;\n fromStart = pos;\n }\n if (pos > to && child.dom.parentNode == this.dom) {\n toI = i;\n toEnd = prevEnd;\n break;\n }\n prevEnd = end;\n pos = end + child.breakAfter;\n }\n return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,\n startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,\n endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };\n }\n markDirty(andParent = false) {\n this.flags |= 2 /* ViewFlag.NodeDirty */;\n this.markParentsDirty(andParent);\n }\n markParentsDirty(childList) {\n for (let parent = this.parent; parent; parent = parent.parent) {\n if (childList)\n parent.flags |= 2 /* ViewFlag.NodeDirty */;\n if (parent.flags & 1 /* ViewFlag.ChildDirty */)\n return;\n parent.flags |= 1 /* ViewFlag.ChildDirty */;\n childList = false;\n }\n }\n setParent(parent) {\n if (this.parent != parent) {\n this.parent = parent;\n if (this.flags & 7 /* ViewFlag.Dirty */)\n this.markParentsDirty(true);\n }\n }\n setDOM(dom) {\n if (this.dom == dom)\n return;\n if (this.dom)\n this.dom.cmView = null;\n this.dom = dom;\n dom.cmView = this;\n }\n get rootView() {\n for (let v = this;;) {\n let parent = v.parent;\n if (!parent)\n return v;\n v = parent;\n }\n }\n replaceChildren(from, to, children = noChildren) {\n this.markDirty();\n for (let i = from; i < to; i++) {\n let child = this.children[i];\n if (child.parent == this && children.indexOf(child) < 0)\n child.destroy();\n }\n this.children.splice(from, to - from, ...children);\n for (let i = 0; i < children.length; i++)\n children[i].setParent(this);\n }\n ignoreMutation(_rec) { return false; }\n ignoreEvent(_event) { return false; }\n childCursor(pos = this.length) {\n return new ChildCursor(this.children, pos, this.children.length);\n }\n childPos(pos, bias = 1) {\n return this.childCursor().findPos(pos, bias);\n }\n toString() {\n let name = this.constructor.name.replace(\"View\", \"\");\n return name + (this.children.length ? \"(\" + this.children.join() + \")\" :\n this.length ? \"[\" + (name == \"Text\" ? this.text : this.length) + \"]\" : \"\") +\n (this.breakAfter ? \"#\" : \"\");\n }\n static get(node) { return node.cmView; }\n get isEditable() { return true; }\n get isWidget() { return false; }\n get isHidden() { return false; }\n merge(from, to, source, hasStart, openStart, openEnd) {\n return false;\n }\n become(other) { return false; }\n canReuseDOM(other) {\n return other.constructor == this.constructor && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);\n }\n // When this is a zero-length view with a side, this should return a\n // number <= 0 to indicate it is before its position, or a\n // number > 0 when after its position.\n getSide() { return 0; }\n destroy() {\n for (let child of this.children)\n if (child.parent == this)\n child.destroy();\n this.parent = null;\n }\n}\nContentView.prototype.breakAfter = 0;\n// Remove a DOM node and return its next sibling.\nfunction rm$1(dom) {\n let next = dom.nextSibling;\n dom.parentNode.removeChild(dom);\n return next;\n}\nclass ChildCursor {\n constructor(children, pos, i) {\n this.children = children;\n this.pos = pos;\n this.i = i;\n this.off = 0;\n }\n findPos(pos, bias = 1) {\n for (;;) {\n if (pos > this.pos || pos == this.pos &&\n (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {\n this.off = pos - this.pos;\n return this;\n }\n let next = this.children[--this.i];\n this.pos -= next.length + next.breakAfter;\n }\n }\n}\nfunction replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {\n let { children } = parent;\n let before = children.length ? children[fromI] : null;\n let last = insert.length ? insert[insert.length - 1] : null;\n let breakAtEnd = last ? last.breakAfter : breakAtStart;\n // Change within a single child\n if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&\n before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))\n return;\n if (toI < children.length) {\n let after = children[toI];\n // Make sure the end of the child after the update is preserved in `after`\n if (after && (toOff < after.length || after.breakAfter && (last === null || last === void 0 ? void 0 : last.breakAfter))) {\n // If we're splitting a child, separate part of it to avoid that\n // being mangled when updating the child before the update.\n if (fromI == toI) {\n after = after.split(toOff);\n toOff = 0;\n }\n // If the element after the replacement should be merged with\n // the last replacing element, update `content`\n if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {\n insert[insert.length - 1] = after;\n }\n else {\n // Remove the start of the after element, if necessary, and\n // add it to `content`.\n if (toOff || after.children.length && !after.children[0].length)\n after.merge(0, toOff, null, false, 0, openEnd);\n insert.push(after);\n }\n }\n else if (after === null || after === void 0 ? void 0 : after.breakAfter) {\n // The element at `toI` is entirely covered by this range.\n // Preserve its line break, if any.\n if (last)\n last.breakAfter = 1;\n else\n breakAtStart = 1;\n }\n // Since we've handled the next element from the current elements\n // now, make sure `toI` points after that.\n toI++;\n }\n if (before) {\n before.breakAfter = breakAtStart;\n if (fromOff > 0) {\n if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {\n before.breakAfter = insert.shift().breakAfter;\n }\n else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {\n before.merge(fromOff, before.length, null, false, openStart, 0);\n }\n fromI++;\n }\n }\n // Try to merge widgets on the boundaries of the replacement\n while (fromI < toI && insert.length) {\n if (children[toI - 1].become(insert[insert.length - 1])) {\n toI--;\n insert.pop();\n openEnd = insert.length ? 0 : openStart;\n }\n else if (children[fromI].become(insert[0])) {\n fromI++;\n insert.shift();\n openStart = insert.length ? 0 : openEnd;\n }\n else {\n break;\n }\n }\n if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&\n children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))\n fromI--;\n if (fromI < toI || insert.length)\n parent.replaceChildren(fromI, toI, insert);\n}\nfunction mergeChildrenInto(parent, from, to, insert, openStart, openEnd) {\n let cur = parent.childCursor();\n let { i: toI, off: toOff } = cur.findPos(to, 1);\n let { i: fromI, off: fromOff } = cur.findPos(from, -1);\n let dLen = from - to;\n for (let view of insert)\n dLen += view.length;\n parent.length += dLen;\n replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);\n}\n\nlet nav = typeof navigator != \"undefined\" ? navigator : { userAgent: \"\", vendor: \"\", platform: \"\" };\nlet doc = typeof document != \"undefined\" ? document : { documentElement: { style: {} } };\nconst ie_edge = /*@__PURE__*//Edge\\/(\\d+)/.exec(nav.userAgent);\nconst ie_upto10 = /*@__PURE__*//MSIE \\d/.test(nav.userAgent);\nconst ie_11up = /*@__PURE__*//Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(nav.userAgent);\nconst ie = !!(ie_upto10 || ie_11up || ie_edge);\nconst gecko = !ie && /*@__PURE__*//gecko\\/(\\d+)/i.test(nav.userAgent);\nconst chrome = !ie && /*@__PURE__*//Chrome\\/(\\d+)/.exec(nav.userAgent);\nconst webkit = \"webkitFontSmoothing\" in doc.documentElement.style;\nconst safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);\nconst ios = safari && (/*@__PURE__*//Mobile\\/\\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);\nvar browser = {\n mac: ios || /*@__PURE__*//Mac/.test(nav.platform),\n windows: /*@__PURE__*//Win/.test(nav.platform),\n linux: /*@__PURE__*//Linux|X11/.test(nav.platform),\n ie,\n ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,\n gecko,\n gecko_version: gecko ? +(/*@__PURE__*//Firefox\\/(\\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,\n chrome: !!chrome,\n chrome_version: chrome ? +chrome[1] : 0,\n ios,\n android: /*@__PURE__*//Android\\b/.test(nav.userAgent),\n webkit,\n safari,\n webkit_version: webkit ? +(/*@__PURE__*//\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,\n tabSize: doc.documentElement.style.tabSize != null ? \"tab-size\" : \"-moz-tab-size\"\n};\n\nconst MaxJoinLen = 256;\nclass TextView extends ContentView {\n constructor(text) {\n super();\n this.text = text;\n }\n get length() { return this.text.length; }\n createDOM(textDOM) {\n this.setDOM(textDOM || document.createTextNode(this.text));\n }\n sync(view, track) {\n if (!this.dom)\n this.createDOM();\n if (this.dom.nodeValue != this.text) {\n if (track && track.node == this.dom)\n track.written = true;\n this.dom.nodeValue = this.text;\n }\n }\n reuseDOM(dom) {\n if (dom.nodeType == 3)\n this.createDOM(dom);\n }\n merge(from, to, source) {\n if ((this.flags & 8 /* ViewFlag.Composition */) ||\n source && (!(source instanceof TextView) ||\n this.length - (to - from) + source.length > MaxJoinLen ||\n (source.flags & 8 /* ViewFlag.Composition */)))\n return false;\n this.text = this.text.slice(0, from) + (source ? source.text : \"\") + this.text.slice(to);\n this.markDirty();\n return true;\n }\n split(from) {\n let result = new TextView(this.text.slice(from));\n this.text = this.text.slice(0, from);\n this.markDirty();\n result.flags |= this.flags & 8 /* ViewFlag.Composition */;\n return result;\n }\n localPosFromDOM(node, offset) {\n return node == this.dom ? offset : offset ? this.text.length : 0;\n }\n domAtPos(pos) { return new DOMPos(this.dom, pos); }\n domBoundsAround(_from, _to, offset) {\n return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };\n }\n coordsAt(pos, side) {\n return textCoords(this.dom, pos, side);\n }\n}\nclass MarkView extends ContentView {\n constructor(mark, children = [], length = 0) {\n super();\n this.mark = mark;\n this.children = children;\n this.length = length;\n for (let ch of children)\n ch.setParent(this);\n }\n setAttrs(dom) {\n clearAttributes(dom);\n if (this.mark.class)\n dom.className = this.mark.class;\n if (this.mark.attrs)\n for (let name in this.mark.attrs)\n dom.setAttribute(name, this.mark.attrs[name]);\n return dom;\n }\n canReuseDOM(other) {\n return super.canReuseDOM(other) && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);\n }\n reuseDOM(node) {\n if (node.nodeName == this.mark.tagName.toUpperCase()) {\n this.setDOM(node);\n this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;\n }\n }\n sync(view, track) {\n if (!this.dom)\n this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));\n else if (this.flags & 4 /* ViewFlag.AttrsDirty */)\n this.setAttrs(this.dom);\n super.sync(view, track);\n }\n merge(from, to, source, _hasStart, openStart, openEnd) {\n if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||\n (from && openStart <= 0) || (to < this.length && openEnd <= 0)))\n return false;\n mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart - 1, openEnd - 1);\n this.markDirty();\n return true;\n }\n split(from) {\n let result = [], off = 0, detachFrom = -1, i = 0;\n for (let elt of this.children) {\n let end = off + elt.length;\n if (end > from)\n result.push(off < from ? elt.split(from - off) : elt);\n if (detachFrom < 0 && off >= from)\n detachFrom = i;\n off = end;\n i++;\n }\n let length = this.length - from;\n this.length = from;\n if (detachFrom > -1) {\n this.children.length = detachFrom;\n this.markDirty();\n }\n return new MarkView(this.mark, result, length);\n }\n domAtPos(pos) {\n return inlineDOMAtPos(this, pos);\n }\n coordsAt(pos, side) {\n return coordsInChildren(this, pos, side);\n }\n}\nfunction textCoords(text, pos, side) {\n let length = text.nodeValue.length;\n if (pos > length)\n pos = length;\n let from = pos, to = pos, flatten = 0;\n if (pos == 0 && side < 0 || pos == length && side >= 0) {\n if (!(browser.chrome || browser.gecko)) { // These browsers reliably return valid rectangles for empty ranges\n if (pos) {\n from--;\n flatten = 1;\n } // FIXME this is wrong in RTL text\n else if (to < length) {\n to++;\n flatten = -1;\n }\n }\n }\n else {\n if (side < 0)\n from--;\n else if (to < length)\n to++;\n }\n let rects = textRange(text, from, to).getClientRects();\n if (!rects.length)\n return null;\n let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];\n if (browser.safari && !flatten && rect.width == 0)\n rect = Array.prototype.find.call(rects, r => r.width) || rect;\n return flatten ? flattenRect(rect, flatten < 0) : rect || null;\n}\n// Also used for collapsed ranges that don't have a placeholder widget!\nclass WidgetView extends ContentView {\n static create(widget, length, side) {\n return new WidgetView(widget, length, side);\n }\n constructor(widget, length, side) {\n super();\n this.widget = widget;\n this.length = length;\n this.side = side;\n this.prevWidget = null;\n }\n split(from) {\n let result = WidgetView.create(this.widget, this.length - from, this.side);\n this.length -= from;\n return result;\n }\n sync(view) {\n if (!this.dom || !this.widget.updateDOM(this.dom, view)) {\n if (this.dom && this.prevWidget)\n this.prevWidget.destroy(this.dom);\n this.prevWidget = null;\n this.setDOM(this.widget.toDOM(view));\n this.dom.contentEditable = \"false\";\n }\n }\n getSide() { return this.side; }\n merge(from, to, source, hasStart, openStart, openEnd) {\n if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||\n from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))\n return false;\n this.length = from + (source ? source.length : 0) + (this.length - to);\n return true;\n }\n become(other) {\n if (other instanceof WidgetView && other.side == this.side &&\n this.widget.constructor == other.widget.constructor) {\n if (!this.widget.compare(other.widget))\n this.markDirty(true);\n if (this.dom && !this.prevWidget)\n this.prevWidget = this.widget;\n this.widget = other.widget;\n this.length = other.length;\n return true;\n }\n return false;\n }\n ignoreMutation() { return true; }\n ignoreEvent(event) { return this.widget.ignoreEvent(event); }\n get overrideDOMText() {\n if (this.length == 0)\n return Text.empty;\n let top = this;\n while (top.parent)\n top = top.parent;\n let { view } = top, text = view && view.state.doc, start = this.posAtStart;\n return text ? text.slice(start, start + this.length) : Text.empty;\n }\n domAtPos(pos) {\n return (this.length ? pos == 0 : this.side > 0)\n ? DOMPos.before(this.dom)\n : DOMPos.after(this.dom, pos == this.length);\n }\n domBoundsAround() { return null; }\n coordsAt(pos, side) {\n let custom = this.widget.coordsAt(this.dom, pos, side);\n if (custom)\n return custom;\n let rects = this.dom.getClientRects(), rect = null;\n if (!rects.length)\n return null;\n let fromBack = this.side ? this.side < 0 : pos > 0;\n for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {\n rect = rects[i];\n if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)\n break;\n }\n return flattenRect(rect, !fromBack);\n }\n get isEditable() { return false; }\n get isWidget() { return true; }\n get isHidden() { return this.widget.isHidden; }\n destroy() {\n super.destroy();\n if (this.dom)\n this.widget.destroy(this.dom);\n }\n}\n// These are drawn around uneditable widgets to avoid a number of\n// browser bugs that show up when the cursor is directly next to\n// uneditable inline content.\nclass WidgetBufferView extends ContentView {\n constructor(side) {\n super();\n this.side = side;\n }\n get length() { return 0; }\n merge() { return false; }\n become(other) {\n return other instanceof WidgetBufferView && other.side == this.side;\n }\n split() { return new WidgetBufferView(this.side); }\n sync() {\n if (!this.dom) {\n let dom = document.createElement(\"img\");\n dom.className = \"cm-widgetBuffer\";\n dom.setAttribute(\"aria-hidden\", \"true\");\n this.setDOM(dom);\n }\n }\n getSide() { return this.side; }\n domAtPos(pos) { return this.side > 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom); }\n localPosFromDOM() { return 0; }\n domBoundsAround() { return null; }\n coordsAt(pos) {\n return this.dom.getBoundingClientRect();\n }\n get overrideDOMText() {\n return Text.empty;\n }\n get isHidden() { return true; }\n}\nTextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;\nfunction inlineDOMAtPos(parent, pos) {\n let dom = parent.dom, { children } = parent, i = 0;\n for (let off = 0; i < children.length; i++) {\n let child = children[i], end = off + child.length;\n if (end == off && child.getSide() <= 0)\n continue;\n if (pos > off && pos < end && child.dom.parentNode == dom)\n return child.domAtPos(pos - off);\n if (pos <= off)\n break;\n off = end;\n }\n for (let j = i; j > 0; j--) {\n let prev = children[j - 1];\n if (prev.dom.parentNode == dom)\n return prev.domAtPos(prev.length);\n }\n for (let j = i; j < children.length; j++) {\n let next = children[j];\n if (next.dom.parentNode == dom)\n return next.domAtPos(0);\n }\n return new DOMPos(dom, 0);\n}\n// Assumes `view`, if a mark view, has precisely 1 child.\nfunction joinInlineInto(parent, view, open) {\n let last, { children } = parent;\n if (open > 0 && view instanceof MarkView && children.length &&\n (last = children[children.length - 1]) instanceof MarkView && last.mark.eq(view.mark)) {\n joinInlineInto(last, view.children[0], open - 1);\n }\n else {\n children.push(view);\n view.setParent(parent);\n }\n parent.length += view.length;\n}\nfunction coordsInChildren(view, pos, side) {\n let before = null, beforePos = -1, after = null, afterPos = -1;\n function scan(view, pos) {\n for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {\n let child = view.children[i], end = off + child.length;\n if (end >= pos) {\n if (child.children.length) {\n scan(child, pos - off);\n }\n else if ((!after || after.isHidden && side > 0) &&\n (end > pos || off == end && child.getSide() > 0)) {\n after = child;\n afterPos = pos - off;\n }\n else if (off < pos || (off == end && child.getSide() < 0) && !child.isHidden) {\n before = child;\n beforePos = pos - off;\n }\n }\n off = end;\n }\n }\n scan(view, pos);\n let target = (side < 0 ? before : after) || before || after;\n if (target)\n return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);\n return fallbackRect(view);\n}\nfunction fallbackRect(view) {\n let last = view.dom.lastChild;\n if (!last)\n return view.dom.getBoundingClientRect();\n let rects = clientRectsFor(last);\n return rects[rects.length - 1] || null;\n}\n\nfunction combineAttrs(source, target) {\n for (let name in source) {\n if (name == \"class\" && target.class)\n target.class += \" \" + source.class;\n else if (name == \"style\" && target.style)\n target.style += \";\" + source.style;\n else\n target[name] = source[name];\n }\n return target;\n}\nconst noAttrs = /*@__PURE__*/Object.create(null);\nfunction attrsEq(a, b, ignore) {\n if (a == b)\n return true;\n if (!a)\n a = noAttrs;\n if (!b)\n b = noAttrs;\n let keysA = Object.keys(a), keysB = Object.keys(b);\n if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) !=\n keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0))\n return false;\n for (let key of keysA) {\n if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key]))\n return false;\n }\n return true;\n}\nfunction updateAttrs(dom, prev, attrs) {\n let changed = false;\n if (prev)\n for (let name in prev)\n if (!(attrs && name in attrs)) {\n changed = true;\n if (name == \"style\")\n dom.style.cssText = \"\";\n else\n dom.removeAttribute(name);\n }\n if (attrs)\n for (let name in attrs)\n if (!(prev && prev[name] == attrs[name])) {\n changed = true;\n if (name == \"style\")\n dom.style.cssText = attrs[name];\n else\n dom.setAttribute(name, attrs[name]);\n }\n return changed;\n}\nfunction getAttrs(dom) {\n let attrs = Object.create(null);\n for (let i = 0; i < dom.attributes.length; i++) {\n let attr = dom.attributes[i];\n attrs[attr.name] = attr.value;\n }\n return attrs;\n}\n\nclass LineView extends ContentView {\n constructor() {\n super(...arguments);\n this.children = [];\n this.length = 0;\n this.prevAttrs = undefined;\n this.attrs = null;\n this.breakAfter = 0;\n }\n // Consumes source\n merge(from, to, source, hasStart, openStart, openEnd) {\n if (source) {\n if (!(source instanceof LineView))\n return false;\n if (!this.dom)\n source.transferDOM(this); // Reuse source.dom when appropriate\n }\n if (hasStart)\n this.setDeco(source ? source.attrs : null);\n mergeChildrenInto(this, from, to, source ? source.children.slice() : [], openStart, openEnd);\n return true;\n }\n split(at) {\n let end = new LineView;\n end.breakAfter = this.breakAfter;\n if (this.length == 0)\n return end;\n let { i, off } = this.childPos(at);\n if (off) {\n end.append(this.children[i].split(off), 0);\n this.children[i].merge(off, this.children[i].length, null, false, 0, 0);\n i++;\n }\n for (let j = i; j < this.children.length; j++)\n end.append(this.children[j], 0);\n while (i > 0 && this.children[i - 1].length == 0)\n this.children[--i].destroy();\n this.children.length = i;\n this.markDirty();\n this.length = at;\n return end;\n }\n transferDOM(other) {\n if (!this.dom)\n return;\n this.markDirty();\n other.setDOM(this.dom);\n other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;\n this.prevAttrs = undefined;\n this.dom = null;\n }\n setDeco(attrs) {\n if (!attrsEq(this.attrs, attrs)) {\n if (this.dom) {\n this.prevAttrs = this.attrs;\n this.markDirty();\n }\n this.attrs = attrs;\n }\n }\n append(child, openStart) {\n joinInlineInto(this, child, openStart);\n }\n // Only called when building a line view in ContentBuilder\n addLineDeco(deco) {\n let attrs = deco.spec.attributes, cls = deco.spec.class;\n if (attrs)\n this.attrs = combineAttrs(attrs, this.attrs || {});\n if (cls)\n this.attrs = combineAttrs({ class: cls }, this.attrs || {});\n }\n domAtPos(pos) {\n return inlineDOMAtPos(this, pos);\n }\n reuseDOM(node) {\n if (node.nodeName == \"DIV\") {\n this.setDOM(node);\n this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;\n }\n }\n sync(view, track) {\n var _a;\n if (!this.dom) {\n this.setDOM(document.createElement(\"div\"));\n this.dom.className = \"cm-line\";\n this.prevAttrs = this.attrs ? null : undefined;\n }\n else if (this.flags & 4 /* ViewFlag.AttrsDirty */) {\n clearAttributes(this.dom);\n this.dom.className = \"cm-line\";\n this.prevAttrs = this.attrs ? null : undefined;\n }\n if (this.prevAttrs !== undefined) {\n updateAttrs(this.dom, this.prevAttrs, this.attrs);\n this.dom.classList.add(\"cm-line\");\n this.prevAttrs = undefined;\n }\n super.sync(view, track);\n let last = this.dom.lastChild;\n while (last && ContentView.get(last) instanceof MarkView)\n last = last.lastChild;\n if (!last || !this.length ||\n last.nodeName != \"BR\" && ((_a = ContentView.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&\n (!browser.ios || !this.children.some(ch => ch instanceof TextView))) {\n let hack = document.createElement(\"BR\");\n hack.cmIgnore = true;\n this.dom.appendChild(hack);\n }\n }\n measureTextSize() {\n if (this.children.length == 0 || this.length > 20)\n return null;\n let totalWidth = 0, textHeight;\n for (let child of this.children) {\n if (!(child instanceof TextView) || /[^ -~]/.test(child.text))\n return null;\n let rects = clientRectsFor(child.dom);\n if (rects.length != 1)\n return null;\n totalWidth += rects[0].width;\n textHeight = rects[0].height;\n }\n return !totalWidth ? null : {\n lineHeight: this.dom.getBoundingClientRect().height,\n charWidth: totalWidth / this.length,\n textHeight\n };\n }\n coordsAt(pos, side) {\n let rect = coordsInChildren(this, pos, side);\n // Correct rectangle height for empty lines when the returned\n // height is larger than the text height.\n if (!this.children.length && rect && this.parent) {\n let { heightOracle } = this.parent.view.viewState, height = rect.bottom - rect.top;\n if (Math.abs(height - heightOracle.lineHeight) < 2 && heightOracle.textHeight < height) {\n let dist = (height - heightOracle.textHeight) / 2;\n return { top: rect.top + dist, bottom: rect.bottom - dist, left: rect.left, right: rect.left };\n }\n }\n return rect;\n }\n become(_other) { return false; }\n covers() { return true; }\n static find(docView, pos) {\n for (let i = 0, off = 0; i < docView.children.length; i++) {\n let block = docView.children[i], end = off + block.length;\n if (end >= pos) {\n if (block instanceof LineView)\n return block;\n if (end > pos)\n break;\n }\n off = end + block.breakAfter;\n }\n return null;\n }\n}\nclass BlockWidgetView extends ContentView {\n constructor(widget, length, deco) {\n super();\n this.widget = widget;\n this.length = length;\n this.deco = deco;\n this.breakAfter = 0;\n this.prevWidget = null;\n }\n merge(from, to, source, _takeDeco, openStart, openEnd) {\n if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||\n from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))\n return false;\n this.length = from + (source ? source.length : 0) + (this.length - to);\n return true;\n }\n domAtPos(pos) {\n return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);\n }\n split(at) {\n let len = this.length - at;\n this.length = at;\n let end = new BlockWidgetView(this.widget, len, this.deco);\n end.breakAfter = this.breakAfter;\n return end;\n }\n get children() { return noChildren; }\n sync(view) {\n if (!this.dom || !this.widget.updateDOM(this.dom, view)) {\n if (this.dom && this.prevWidget)\n this.prevWidget.destroy(this.dom);\n this.prevWidget = null;\n this.setDOM(this.widget.toDOM(view));\n this.dom.contentEditable = \"false\";\n }\n }\n get overrideDOMText() {\n return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;\n }\n domBoundsAround() { return null; }\n become(other) {\n if (other instanceof BlockWidgetView &&\n other.widget.constructor == this.widget.constructor) {\n if (!other.widget.compare(this.widget))\n this.markDirty(true);\n if (this.dom && !this.prevWidget)\n this.prevWidget = this.widget;\n this.widget = other.widget;\n this.length = other.length;\n this.deco = other.deco;\n this.breakAfter = other.breakAfter;\n return true;\n }\n return false;\n }\n ignoreMutation() { return true; }\n ignoreEvent(event) { return this.widget.ignoreEvent(event); }\n get isEditable() { return false; }\n get isWidget() { return true; }\n coordsAt(pos, side) {\n return this.widget.coordsAt(this.dom, pos, side);\n }\n destroy() {\n super.destroy();\n if (this.dom)\n this.widget.destroy(this.dom);\n }\n covers(side) {\n let { startSide, endSide } = this.deco;\n return startSide == endSide ? false : side < 0 ? startSide < 0 : endSide > 0;\n }\n}\n\n/**\nWidgets added to the content are described by subclasses of this\nclass. Using a description object like that makes it possible to\ndelay creating of the DOM structure for a widget until it is\nneeded, and to avoid redrawing widgets even if the decorations\nthat define them are recreated.\n*/\nclass WidgetType {\n /**\n Compare this instance to another instance of the same type.\n (TypeScript can't express this, but only instances of the same\n specific class will be passed to this method.) This is used to\n avoid redrawing widgets when they are replaced by a new\n decoration of the same type. The default implementation just\n returns `false`, which will cause new instances of the widget to\n always be redrawn.\n */\n eq(widget) { return false; }\n /**\n Update a DOM element created by a widget of the same type (but\n different, non-`eq` content) to reflect this widget. May return\n true to indicate that it could update, false to indicate it\n couldn't (in which case the widget will be redrawn). The default\n implementation just returns false.\n */\n updateDOM(dom, view) { return false; }\n /**\n @internal\n */\n compare(other) {\n return this == other || this.constructor == other.constructor && this.eq(other);\n }\n /**\n The estimated height this widget will have, to be used when\n estimating the height of content that hasn't been drawn. May\n return -1 to indicate you don't know. The default implementation\n returns -1.\n */\n get estimatedHeight() { return -1; }\n /**\n For inline widgets that are displayed inline (as opposed to\n `inline-block`) and introduce line breaks (through `<br>` tags\n or textual newlines), this must indicate the amount of line\n breaks they introduce. Defaults to 0.\n */\n get lineBreaks() { return 0; }\n /**\n Can be used to configure which kinds of events inside the widget\n should be ignored by the editor. The default is to ignore all\n events.\n */\n ignoreEvent(event) { return true; }\n /**\n Override the way screen coordinates for positions at/in the\n widget are found. `pos` will be the offset into the widget, and\n `side` the side of the position that is being queried—less than\n zero for before, greater than zero for after, and zero for\n directly at that position.\n */\n coordsAt(dom, pos, side) { return null; }\n /**\n @internal\n */\n get isHidden() { return false; }\n /**\n This is called when the an instance of the widget is removed\n from the editor view.\n */\n destroy(dom) { }\n}\n/**\nThe different types of blocks that can occur in an editor view.\n*/\nvar BlockType = /*@__PURE__*/(function (BlockType) {\n /**\n A line of text.\n */\n BlockType[BlockType[\"Text\"] = 0] = \"Text\";\n /**\n A block widget associated with the position after it.\n */\n BlockType[BlockType[\"WidgetBefore\"] = 1] = \"WidgetBefore\";\n /**\n A block widget associated with the position before it.\n */\n BlockType[BlockType[\"WidgetAfter\"] = 2] = \"WidgetAfter\";\n /**\n A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.\n */\n BlockType[BlockType[\"WidgetRange\"] = 3] = \"WidgetRange\";\nreturn BlockType})(BlockType || (BlockType = {}));\n/**\nA decoration provides information on how to draw or style a piece\nof content. You'll usually use it wrapped in a\n[`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.\n@nonabstract\n*/\nclass Decoration extends RangeValue {\n constructor(\n /**\n @internal\n */\n startSide, \n /**\n @internal\n */\n endSide, \n /**\n @internal\n */\n widget, \n /**\n The config object used to create this decoration. You can\n include additional properties in there to store metadata about\n your decoration.\n */\n spec) {\n super();\n this.startSide = startSide;\n this.endSide = endSide;\n this.widget = widget;\n this.spec = spec;\n }\n /**\n @internal\n */\n get heightRelevant() { return false; }\n /**\n Create a mark decoration, which influences the styling of the\n content in its range. Nested mark decorations will cause nested\n DOM elements to be created. Nesting order is determined by\n precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with\n the higher-precedence decorations creating the inner DOM nodes.\n Such elements are split on line boundaries and on the boundaries\n of lower-precedence decorations.\n */\n static mark(spec) {\n return new MarkDecoration(spec);\n }\n /**\n Create a widget decoration, which displays a DOM element at the\n given position.\n */\n static widget(spec) {\n let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;\n side += (block && !spec.inlineOrder)\n ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */)\n : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);\n return new PointDecoration(spec, side, side, block, spec.widget || null, false);\n }\n /**\n Create a replace decoration which replaces the given range with\n a widget, or simply hides it.\n */\n static replace(spec) {\n let block = !!spec.block, startSide, endSide;\n if (spec.isBlockGap) {\n startSide = -500000000 /* Side.GapStart */;\n endSide = 400000000 /* Side.GapEnd */;\n }\n else {\n let { start, end } = getInclusive(spec, block);\n startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;\n endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;\n }\n return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);\n }\n /**\n Create a line decoration, which can add DOM attributes to the\n line starting at the given position.\n */\n static line(spec) {\n return new LineDecoration(spec);\n }\n /**\n Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given\n decorated range or ranges. If the ranges aren't already sorted,\n pass `true` for `sort` to make the library sort them for you.\n */\n static set(of, sort = false) {\n return RangeSet.of(of, sort);\n }\n /**\n @internal\n */\n hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }\n}\n/**\nThe empty set of decorations.\n*/\nDecoration.none = RangeSet.empty;\nclass MarkDecoration extends Decoration {\n constructor(spec) {\n let { start, end } = getInclusive(spec);\n super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);\n this.tagName = spec.tagName || \"span\";\n this.class = spec.class || \"\";\n this.attrs = spec.attributes || null;\n }\n eq(other) {\n var _a, _b;\n return this == other ||\n other instanceof MarkDecoration &&\n this.tagName == other.tagName &&\n (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)) &&\n attrsEq(this.attrs, other.attrs, \"class\");\n }\n range(from, to = from) {\n if (from >= to)\n throw new RangeError(\"Mark decorations may not be empty\");\n return super.range(from, to);\n }\n}\nMarkDecoration.prototype.point = false;\nclass LineDecoration extends Decoration {\n constructor(spec) {\n super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);\n }\n eq(other) {\n return other instanceof LineDecoration &&\n this.spec.class == other.spec.class &&\n attrsEq(this.spec.attributes, other.spec.attributes);\n }\n range(from, to = from) {\n if (to != from)\n throw new RangeError(\"Line decoration ranges must be zero-length\");\n return super.range(from, to);\n }\n}\nLineDecoration.prototype.mapMode = MapMode.TrackBefore;\nLineDecoration.prototype.point = true;\nclass PointDecoration extends Decoration {\n constructor(spec, startSide, endSide, block, widget, isReplace) {\n super(startSide, endSide, widget, spec);\n this.block = block;\n this.isReplace = isReplace;\n this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter;\n }\n // Only relevant when this.block == true\n get type() {\n return this.startSide != this.endSide ? BlockType.WidgetRange\n : this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;\n }\n get heightRelevant() {\n return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);\n }\n eq(other) {\n return other instanceof PointDecoration &&\n widgetsEq(this.widget, other.widget) &&\n this.block == other.block &&\n this.startSide == other.startSide && this.endSide == other.endSide;\n }\n range(from, to = from) {\n if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))\n throw new RangeError(\"Invalid range for replacement decoration\");\n if (!this.isReplace && to != from)\n throw new RangeError(\"Widget decorations can only have zero-length ranges\");\n return super.range(from, to);\n }\n}\nPointDecoration.prototype.point = true;\nfunction getInclusive(spec, block = false) {\n let { inclusiveStart: start, inclusiveEnd: end } = spec;\n if (start == null)\n start = spec.inclusive;\n if (end == null)\n end = spec.inclusive;\n return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };\n}\nfunction widgetsEq(a, b) {\n return a == b || !!(a && b && a.compare(b));\n}\nfunction addRange(from, to, ranges, margin = 0) {\n let last = ranges.length - 1;\n if (last >= 0 && ranges[last] + margin >= from)\n ranges[last] = Math.max(ranges[last], to);\n else\n ranges.push(from, to);\n}\n\nclass ContentBuilder {\n constructor(doc, pos, end, disallowBlockEffectsFor) {\n this.doc = doc;\n this.pos = pos;\n this.end = end;\n this.disallowBlockEffectsFor = disallowBlockEffectsFor;\n this.content = [];\n this.curLine = null;\n this.breakAtStart = 0;\n this.pendingBuffer = 0 /* Buf.No */;\n this.bufferMarks = [];\n // Set to false directly after a widget that covers the position after it\n this.atCursorPos = true;\n this.openStart = -1;\n this.openEnd = -1;\n this.text = \"\";\n this.textOff = 0;\n this.cursor = doc.iter();\n this.skip = pos;\n }\n posCovered() {\n if (this.content.length == 0)\n return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;\n let last = this.content[this.content.length - 1];\n return !(last.breakAfter || last instanceof BlockWidgetView && last.deco.endSide < 0);\n }\n getLine() {\n if (!this.curLine) {\n this.content.push(this.curLine = new LineView);\n this.atCursorPos = true;\n }\n return this.curLine;\n }\n flushBuffer(active = this.bufferMarks) {\n if (this.pendingBuffer) {\n this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);\n this.pendingBuffer = 0 /* Buf.No */;\n }\n }\n addBlockWidget(view) {\n this.flushBuffer();\n this.curLine = null;\n this.content.push(view);\n }\n finish(openEnd) {\n if (this.pendingBuffer && openEnd <= this.bufferMarks.length)\n this.flushBuffer();\n else\n this.pendingBuffer = 0 /* Buf.No */;\n if (!this.posCovered() &&\n !(openEnd && this.content.length && this.content[this.content.length - 1] instanceof BlockWidgetView))\n this.getLine();\n }\n buildText(length, active, openStart) {\n while (length > 0) {\n if (this.textOff == this.text.length) {\n let { value, lineBreak, done } = this.cursor.next(this.skip);\n this.skip = 0;\n if (done)\n throw new Error(\"Ran out of text content when drawing inline views\");\n if (lineBreak) {\n if (!this.posCovered())\n this.getLine();\n if (this.content.length)\n this.content[this.content.length - 1].breakAfter = 1;\n else\n this.breakAtStart = 1;\n this.flushBuffer();\n this.curLine = null;\n this.atCursorPos = true;\n length--;\n continue;\n }\n else {\n this.text = value;\n this.textOff = 0;\n }\n }\n let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);\n this.flushBuffer(active.slice(active.length - openStart));\n this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);\n this.atCursorPos = true;\n this.textOff += take;\n length -= take;\n openStart = 0;\n }\n }\n span(from, to, active, openStart) {\n this.buildText(to - from, active, openStart);\n this.pos = to;\n if (this.openStart < 0)\n this.openStart = openStart;\n }\n point(from, to, deco, active, openStart, index) {\n if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration) {\n if (deco.block)\n throw new RangeError(\"Block decorations may not be specified via plugins\");\n if (to > this.doc.lineAt(this.pos).to)\n throw new RangeError(\"Decorations that replace line breaks may not be specified via plugins\");\n }\n let len = to - from;\n if (deco instanceof PointDecoration) {\n if (deco.block) {\n if (deco.startSide > 0 && !this.posCovered())\n this.getLine();\n this.addBlockWidget(new BlockWidgetView(deco.widget || new NullWidget(\"div\"), len, deco));\n }\n else {\n let view = WidgetView.create(deco.widget || new NullWidget(\"span\"), len, len ? 0 : deco.startSide);\n let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length &&\n (from < to || deco.startSide > 0);\n let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);\n let line = this.getLine();\n if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore && !view.isEditable)\n this.pendingBuffer = 0 /* Buf.No */;\n this.flushBuffer(active);\n if (cursorBefore) {\n line.append(wrapMarks(new WidgetBufferView(1), active), openStart);\n openStart = active.length + Math.max(0, openStart - active.length);\n }\n line.append(wrapMarks(view, active), openStart);\n this.atCursorPos = cursorAfter;\n this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to || openStart > active.length ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;\n if (this.pendingBuffer)\n this.bufferMarks = active.slice();\n }\n }\n else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration\n this.getLine().addLineDeco(deco);\n }\n if (len) {\n // Advance the iterator past the replaced content\n if (this.textOff + len <= this.text.length) {\n this.textOff += len;\n }\n else {\n this.skip += len - (this.text.length - this.textOff);\n this.text = \"\";\n this.textOff = 0;\n }\n this.pos = to;\n }\n if (this.openStart < 0)\n this.openStart = openStart;\n }\n static build(text, from, to, decorations, dynamicDecorationMap) {\n let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);\n builder.openEnd = RangeSet.spans(decorations, from, to, builder);\n if (builder.openStart < 0)\n builder.openStart = builder.openEnd;\n builder.finish(builder.openEnd);\n return builder;\n }\n}\nfunction wrapMarks(view, active) {\n for (let mark of active)\n view = new MarkView(mark, [view], view.length);\n return view;\n}\nclass NullWidget extends WidgetType {\n constructor(tag) {\n super();\n this.tag = tag;\n }\n eq(other) { return other.tag == this.tag; }\n toDOM() { return document.createElement(this.tag); }\n updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }\n get isHidden() { return true; }\n}\n\nconst clickAddsSelectionRange = /*@__PURE__*/Facet.define();\nconst dragMovesSelection$1 = /*@__PURE__*/Facet.define();\nconst mouseSelectionStyle = /*@__PURE__*/Facet.define();\nconst exceptionSink = /*@__PURE__*/Facet.define();\nconst updateListener = /*@__PURE__*/Facet.define();\nconst inputHandler = /*@__PURE__*/Facet.define();\nconst focusChangeEffect = /*@__PURE__*/Facet.define();\nconst perLineTextDirection = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\nconst nativeSelectionHidden = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\nclass ScrollTarget {\n constructor(range, y = \"nearest\", x = \"nearest\", yMargin = 5, xMargin = 5, \n // This data structure is abused to also store precise scroll\n // snapshots, instead of a `scrollIntoView` request. When this\n // flag is `true`, `range` points at a position in the reference\n // line, `yMargin` holds the difference between the top of that\n // line and the top of the editor, and `xMargin` holds the\n // editor's `scrollLeft`.\n isSnapshot = false) {\n this.range = range;\n this.y = y;\n this.x = x;\n this.yMargin = yMargin;\n this.xMargin = xMargin;\n this.isSnapshot = isSnapshot;\n }\n map(changes) {\n return changes.empty ? this :\n new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);\n }\n clip(state) {\n return this.range.to <= state.doc.length ? this :\n new ScrollTarget(EditorSelection.cursor(state.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);\n }\n}\nconst scrollIntoView = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });\n/**\nLog or report an unhandled exception in client code. Should\nprobably only be used by extension code that allows client code to\nprovide functions, and calls those functions in a context where an\nexception can't be propagated to calling code in a reasonable way\n(for example when in an event handler).\n\nEither calls a handler registered with\n[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),\n`window.onerror`, if defined, or `console.error` (in which case\nit'll pass `context`, when given, as first argument).\n*/\nfunction logException(state, exception, context) {\n let handler = state.facet(exceptionSink);\n if (handler.length)\n handler[0](exception);\n else if (window.onerror)\n window.onerror(String(exception), context, undefined, undefined, exception);\n else if (context)\n console.error(context + \":\", exception);\n else\n console.error(exception);\n}\nconst editable = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : true });\nlet nextPluginID = 0;\nconst viewPlugin = /*@__PURE__*/Facet.define();\n/**\nView plugins associate stateful values with a view. They can\ninfluence the way the content is drawn, and are notified of things\nthat happen in the view.\n*/\nclass ViewPlugin {\n constructor(\n /**\n @internal\n */\n id, \n /**\n @internal\n */\n create, \n /**\n @internal\n */\n domEventHandlers, \n /**\n @internal\n */\n domEventObservers, buildExtensions) {\n this.id = id;\n this.create = create;\n this.domEventHandlers = domEventHandlers;\n this.domEventObservers = domEventObservers;\n this.extension = buildExtensions(this);\n }\n /**\n Define a plugin from a constructor function that creates the\n plugin's value, given an editor view.\n */\n static define(create, spec) {\n const { eventHandlers, eventObservers, provide, decorations: deco } = spec || {};\n return new ViewPlugin(nextPluginID++, create, eventHandlers, eventObservers, plugin => {\n let ext = [viewPlugin.of(plugin)];\n if (deco)\n ext.push(decorations.of(view => {\n let pluginInst = view.plugin(plugin);\n return pluginInst ? deco(pluginInst) : Decoration.none;\n }));\n if (provide)\n ext.push(provide(plugin));\n return ext;\n });\n }\n /**\n Create a plugin for a class whose constructor takes a single\n editor view as argument.\n */\n static fromClass(cls, spec) {\n return ViewPlugin.define(view => new cls(view), spec);\n }\n}\nclass PluginInstance {\n constructor(spec) {\n this.spec = spec;\n // When starting an update, all plugins have this field set to the\n // update object, indicating they need to be updated. When finished\n // updating, it is set to `false`. Retrieving a plugin that needs to\n // be updated with `view.plugin` forces an eager update.\n this.mustUpdate = null;\n // This is null when the plugin is initially created, but\n // initialized on the first update.\n this.value = null;\n }\n update(view) {\n if (!this.value) {\n if (this.spec) {\n try {\n this.value = this.spec.create(view);\n }\n catch (e) {\n logException(view.state, e, \"CodeMirror plugin crashed\");\n this.deactivate();\n }\n }\n }\n else if (this.mustUpdate) {\n let update = this.mustUpdate;\n this.mustUpdate = null;\n if (this.value.update) {\n try {\n this.value.update(update);\n }\n catch (e) {\n logException(update.state, e, \"CodeMirror plugin crashed\");\n if (this.value.destroy)\n try {\n this.value.destroy();\n }\n catch (_) { }\n this.deactivate();\n }\n }\n }\n return this;\n }\n destroy(view) {\n var _a;\n if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {\n try {\n this.value.destroy();\n }\n catch (e) {\n logException(view.state, e, \"CodeMirror plugin crashed\");\n }\n }\n }\n deactivate() {\n this.spec = this.value = null;\n }\n}\nconst editorAttributes = /*@__PURE__*/Facet.define();\nconst contentAttributes = /*@__PURE__*/Facet.define();\n// Provide decorations\nconst decorations = /*@__PURE__*/Facet.define();\nconst atomicRanges = /*@__PURE__*/Facet.define();\nconst bidiIsolatedRanges = /*@__PURE__*/Facet.define();\nfunction getIsolatedRanges(view, from, to) {\n let isolates = view.state.facet(bidiIsolatedRanges);\n if (!isolates.length)\n return isolates;\n let sets = isolates.map(i => i instanceof Function ? i(view) : i);\n let result = [];\n RangeSet.spans(sets, from, to, {\n point() { },\n span(from, to, active, open) {\n let level = result;\n for (let i = active.length - 1; i >= 0; i--, open--) {\n let iso = active[i].spec.bidiIsolate, update;\n if (iso == null)\n continue;\n if (open > 0 && level.length &&\n (update = level[level.length - 1]).to == from && update.direction == iso) {\n update.to = to;\n level = update.inner;\n }\n else {\n let add = { from, to, direction: iso, inner: [] };\n level.push(add);\n level = add.inner;\n }\n }\n }\n });\n return result;\n}\nconst scrollMargins = /*@__PURE__*/Facet.define();\nfunction getScrollMargins(view) {\n let left = 0, right = 0, top = 0, bottom = 0;\n for (let source of view.state.facet(scrollMargins)) {\n let m = source(view);\n if (m) {\n if (m.left != null)\n left = Math.max(left, m.left);\n if (m.right != null)\n right = Math.max(right, m.right);\n if (m.top != null)\n top = Math.max(top, m.top);\n if (m.bottom != null)\n bottom = Math.max(bottom, m.bottom);\n }\n }\n return { left, right, top, bottom };\n}\nconst styleModule = /*@__PURE__*/Facet.define();\nclass ChangedRange {\n constructor(fromA, toA, fromB, toB) {\n this.fromA = fromA;\n this.toA = toA;\n this.fromB = fromB;\n this.toB = toB;\n }\n join(other) {\n 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));\n }\n addToSet(set) {\n let i = set.length, me = this;\n for (; i > 0; i--) {\n let range = set[i - 1];\n if (range.fromA > me.toA)\n continue;\n if (range.toA < me.fromA)\n break;\n me = me.join(range);\n set.splice(i - 1, 1);\n }\n set.splice(i, 0, me);\n return set;\n }\n static extendWithRanges(diff, ranges) {\n if (ranges.length == 0)\n return diff;\n let result = [];\n for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {\n let next = dI == diff.length ? null : diff[dI], off = posA - posB;\n let end = next ? next.fromB : 1e9;\n while (rI < ranges.length && ranges[rI] < end) {\n let from = ranges[rI], to = ranges[rI + 1];\n let fromB = Math.max(posB, from), toB = Math.min(end, to);\n if (fromB <= toB)\n new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);\n if (to > end)\n break;\n else\n rI += 2;\n }\n if (!next)\n return result;\n new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);\n posA = next.toA;\n posB = next.toB;\n }\n }\n}\n/**\nView [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this\nclass, which describe what happened, whenever the view is updated.\n*/\nclass ViewUpdate {\n constructor(\n /**\n The editor view that the update is associated with.\n */\n view, \n /**\n The new editor state.\n */\n state, \n /**\n The transactions involved in the update. May be empty.\n */\n transactions) {\n this.view = view;\n this.state = state;\n this.transactions = transactions;\n /**\n @internal\n */\n this.flags = 0;\n this.startState = view.state;\n this.changes = ChangeSet.empty(this.startState.doc.length);\n for (let tr of transactions)\n this.changes = this.changes.compose(tr.changes);\n let changedRanges = [];\n this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));\n this.changedRanges = changedRanges;\n }\n /**\n @internal\n */\n static create(view, state, transactions) {\n return new ViewUpdate(view, state, transactions);\n }\n /**\n Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or\n [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this\n update.\n */\n get viewportChanged() {\n return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;\n }\n /**\n Indicates whether the height of a block element in the editor\n changed in this update.\n */\n get heightChanged() {\n return (this.flags & 2 /* UpdateFlag.Height */) > 0;\n }\n /**\n Returns true when the document was modified or the size of the\n editor, or elements within the editor, changed.\n */\n get geometryChanged() {\n return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;\n }\n /**\n True when this update indicates a focus change.\n */\n get focusChanged() {\n return (this.flags & 1 /* UpdateFlag.Focus */) > 0;\n }\n /**\n Whether the document changed in this update.\n */\n get docChanged() {\n return !this.changes.empty;\n }\n /**\n Whether the selection was explicitly set in this update.\n */\n get selectionSet() {\n return this.transactions.some(tr => tr.selection);\n }\n /**\n @internal\n */\n get empty() { return this.flags == 0 && this.transactions.length == 0; }\n}\n\n/**\nUsed to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).\n*/\nvar Direction = /*@__PURE__*/(function (Direction) {\n // (These are chosen to match the base levels, in bidi algorithm\n // terms, of spans in that direction.)\n /**\n Left-to-right.\n */\n Direction[Direction[\"LTR\"] = 0] = \"LTR\";\n /**\n Right-to-left.\n */\n Direction[Direction[\"RTL\"] = 1] = \"RTL\";\nreturn Direction})(Direction || (Direction = {}));\nconst LTR = Direction.LTR, RTL = Direction.RTL;\n// Decode a string with each type encoded as log2(type)\nfunction dec(str) {\n let result = [];\n for (let i = 0; i < str.length; i++)\n result.push(1 << +str[i]);\n return result;\n}\n// Character types for codepoints 0 to 0xf8\nconst LowTypes = /*@__PURE__*/dec(\"88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008\");\n// Character types for codepoints 0x600 to 0x6f9\nconst ArabicTypes = /*@__PURE__*/dec(\"4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333\");\nconst Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];\n// There's a lot more in\n// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,\n// which are left out to keep code size down.\nfor (let p of [\"()\", \"[]\", \"{}\"]) {\n let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);\n Brackets[l] = r;\n Brackets[r] = -l;\n}\nfunction charType(ch) {\n return ch <= 0xf7 ? LowTypes[ch] :\n 0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :\n 0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :\n 0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :\n 0x2000 <= ch && ch <= 0x200c ? 256 /* T.NI */ :\n 0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ : 1 /* T.L */;\n}\nconst BidiRE = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac\\ufb50-\\ufdff]/;\n/**\nRepresents a contiguous range of text that has a single direction\n(as in left-to-right or right-to-left).\n*/\nclass BidiSpan {\n /**\n The direction of this span.\n */\n get dir() { return this.level % 2 ? RTL : LTR; }\n /**\n @internal\n */\n constructor(\n /**\n The start of the span (relative to the start of the line).\n */\n from, \n /**\n The end of the span.\n */\n to, \n /**\n The [\"bidi\n level\"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)\n of the span (in this context, 0 means\n left-to-right, 1 means right-to-left, 2 means left-to-right\n number inside right-to-left text).\n */\n level) {\n this.from = from;\n this.to = to;\n this.level = level;\n }\n /**\n @internal\n */\n side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }\n /**\n @internal\n */\n static find(order, index, level, assoc) {\n let maybe = -1;\n for (let i = 0; i < order.length; i++) {\n let span = order[i];\n if (span.from <= index && span.to >= index) {\n if (span.level == level)\n return i;\n // When multiple spans match, if assoc != 0, take the one that\n // covers that side, otherwise take the one with the minimum\n // level.\n if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))\n maybe = i;\n }\n }\n if (maybe < 0)\n throw new RangeError(\"Index out of range\");\n return maybe;\n }\n}\nfunction isolatesEq(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n let iA = a[i], iB = b[i];\n if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))\n return false;\n }\n return true;\n}\n// Reused array of character types\nconst types = [];\n// Fill in the character types (in `types`) from `from` to `to` and\n// apply W normalization rules.\nfunction computeCharTypes(line, rFrom, rTo, isolates, outerType) {\n for (let iI = 0; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n let prevType = iI ? 256 /* T.NI */ : outerType;\n // W1. Examine each non-spacing mark (NSM) in the level run, and\n // change the type of the NSM to the type of the previous\n // character. If the NSM is at the start of the level run, it will\n // get the type of sor.\n // W2. Search backwards from each instance of a European number\n // until the first strong type (R, L, AL, or sor) is found. If an\n // AL is found, change the type of the European number to Arabic\n // number.\n // W3. Change all ALs to R.\n // (Left after this: L, R, EN, AN, ET, CS, NI)\n for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {\n let type = charType(line.charCodeAt(i));\n if (type == 512 /* T.NSM */)\n type = prev;\n else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)\n type = 16 /* T.AN */;\n types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;\n if (type & 7 /* T.Strong */)\n prevStrong = type;\n prev = type;\n }\n // W5. A sequence of European terminators adjacent to European\n // numbers changes to all European numbers.\n // W6. Otherwise, separators and terminators change to Other\n // Neutral.\n // W7. Search backwards from each instance of a European number\n // until the first strong type (R, L, or sor) is found. If an L is\n // found, then change the type of the European number to L.\n // (Left after this: L, R, EN+AN, NI)\n for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {\n let type = types[i];\n if (type == 128 /* T.CS */) {\n if (i < to - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))\n type = types[i] = prev;\n else\n types[i] = 256 /* T.NI */;\n }\n else if (type == 64 /* T.ET */) {\n let end = i + 1;\n while (end < to && types[end] == 64 /* T.ET */)\n end++;\n 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 */;\n for (let j = i; j < end; j++)\n types[j] = replace;\n i = end - 1;\n }\n else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {\n types[i] = 1 /* T.L */;\n }\n prev = type;\n if (type & 7 /* T.Strong */)\n prevStrong = type;\n }\n }\n}\n// Process brackets throughout a run sequence.\nfunction processBracketPairs(line, rFrom, rTo, isolates, outerType) {\n let oppositeType = outerType == 1 /* T.L */ ? 2 /* T.R */ : 1 /* T.L */;\n for (let iI = 0, sI = 0, context = 0; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n // N0. Process bracket pairs in an isolating run sequence\n // sequentially in the logical order of the text positions of the\n // opening paired brackets using the logic given below. Within this\n // scope, bidirectional types EN and AN are treated as R.\n for (let i = from, ch, br, type; i < to; i++) {\n // Keeps [startIndex, type, strongSeen] triples for each open\n // bracket on BracketStack.\n if (br = Brackets[ch = line.charCodeAt(i)]) {\n if (br < 0) { // Closing bracket\n for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {\n if (BracketStack[sJ + 1] == -br) {\n let flags = BracketStack[sJ + 2];\n let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :\n !(flags & 4 /* Bracketed.OppositeInside */) ? 0 :\n (flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;\n if (type)\n types[i] = types[BracketStack[sJ]] = type;\n sI = sJ;\n break;\n }\n }\n }\n else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {\n break;\n }\n else {\n BracketStack[sI++] = i;\n BracketStack[sI++] = ch;\n BracketStack[sI++] = context;\n }\n }\n else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {\n let embed = type == outerType;\n context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;\n for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {\n let cur = BracketStack[sJ + 2];\n if (cur & 2 /* Bracketed.EmbedInside */)\n break;\n if (embed) {\n BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;\n }\n else {\n if (cur & 4 /* Bracketed.OppositeInside */)\n break;\n BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;\n }\n }\n }\n }\n }\n}\nfunction processNeutrals(rFrom, rTo, isolates, outerType) {\n for (let iI = 0, prev = outerType; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n // N1. A sequence of neutrals takes the direction of the\n // surrounding strong text if the text on both sides has the same\n // direction. European and Arabic numbers act as if they were R in\n // terms of their influence on neutrals. Start-of-level-run (sor)\n // and end-of-level-run (eor) are used at level run boundaries.\n // N2. Any remaining neutrals take the embedding direction.\n // (Left after this: L, R, EN+AN)\n for (let i = from; i < to;) {\n let type = types[i];\n if (type == 256 /* T.NI */) {\n let end = i + 1;\n for (;;) {\n if (end == to) {\n if (iI == isolates.length)\n break;\n end = isolates[iI++].to;\n to = iI < isolates.length ? isolates[iI].from : rTo;\n }\n else if (types[end] == 256 /* T.NI */) {\n end++;\n }\n else {\n break;\n }\n }\n let beforeL = prev == 1 /* T.L */;\n let afterL = (end < rTo ? types[end] : outerType) == 1 /* T.L */;\n let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;\n for (let j = end, jI = iI, fromJ = jI ? isolates[jI - 1].to : rFrom; j > i;) {\n if (j == fromJ) {\n j = isolates[--jI].from;\n fromJ = jI ? isolates[jI - 1].to : rFrom;\n }\n types[--j] = replace;\n }\n i = end;\n }\n else {\n prev = type;\n i++;\n }\n }\n }\n}\n// Find the contiguous ranges of character types in a given range, and\n// emit spans for them. Flip the order of the spans as appropriate\n// based on the level, and call through to compute the spans for\n// isolates at the proper point.\nfunction emitSpans(line, from, to, level, baseLevel, isolates, order) {\n let ourType = level % 2 ? 2 /* T.R */ : 1 /* T.L */;\n if ((level % 2) == (baseLevel % 2)) { // Same dir as base direction, don't flip\n for (let iCh = from, iI = 0; iCh < to;) {\n // Scan a section of characters in direction ourType, unless\n // there's another type of char right after iCh, in which case\n // we scan a section of other characters (which, if ourType ==\n // T.L, may contain both T.R and T.AN chars).\n let sameDir = true, isNum = false;\n if (iI == isolates.length || iCh < isolates[iI].from) {\n let next = types[iCh];\n if (next != ourType) {\n sameDir = false;\n isNum = next == 16 /* T.AN */;\n }\n }\n // Holds an array of isolates to pass to a recursive call if we\n // must recurse (to distinguish T.AN inside an RTL section in\n // LTR text), null if we can emit directly\n let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;\n let localLevel = sameDir ? level : level + 1;\n let iScan = iCh;\n run: for (;;) {\n if (iI < isolates.length && iScan == isolates[iI].from) {\n if (isNum)\n break run;\n let iso = isolates[iI];\n // Scan ahead to verify that there is another char in this dir after the isolate(s)\n if (!sameDir)\n for (let upto = iso.to, jI = iI + 1;;) {\n if (upto == to)\n break run;\n if (jI < isolates.length && isolates[jI].from == upto)\n upto = isolates[jI++].to;\n else if (types[upto] == ourType)\n break run;\n else\n break;\n }\n iI++;\n if (recurse) {\n recurse.push(iso);\n }\n else {\n if (iso.from > iCh)\n order.push(new BidiSpan(iCh, iso.from, localLevel));\n let dirSwap = (iso.direction == LTR) != !(localLevel % 2);\n computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);\n iCh = iso.to;\n }\n iScan = iso.to;\n }\n else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {\n break;\n }\n else {\n iScan++;\n }\n }\n if (recurse)\n emitSpans(line, iCh, iScan, level + 1, baseLevel, recurse, order);\n else if (iCh < iScan)\n order.push(new BidiSpan(iCh, iScan, localLevel));\n iCh = iScan;\n }\n }\n else {\n // Iterate in reverse to flip the span order. Same code again, but\n // going from the back of the section to the front\n for (let iCh = to, iI = isolates.length; iCh > from;) {\n let sameDir = true, isNum = false;\n if (!iI || iCh > isolates[iI - 1].to) {\n let next = types[iCh - 1];\n if (next != ourType) {\n sameDir = false;\n isNum = next == 16 /* T.AN */;\n }\n }\n let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;\n let localLevel = sameDir ? level : level + 1;\n let iScan = iCh;\n run: for (;;) {\n if (iI && iScan == isolates[iI - 1].to) {\n if (isNum)\n break run;\n let iso = isolates[--iI];\n // Scan ahead to verify that there is another char in this dir after the isolate(s)\n if (!sameDir)\n for (let upto = iso.from, jI = iI;;) {\n if (upto == from)\n break run;\n if (jI && isolates[jI - 1].to == upto)\n upto = isolates[--jI].from;\n else if (types[upto - 1] == ourType)\n break run;\n else\n break;\n }\n if (recurse) {\n recurse.push(iso);\n }\n else {\n if (iso.to < iCh)\n order.push(new BidiSpan(iso.to, iCh, localLevel));\n let dirSwap = (iso.direction == LTR) != !(localLevel % 2);\n computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);\n iCh = iso.from;\n }\n iScan = iso.from;\n }\n else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {\n break;\n }\n else {\n iScan--;\n }\n }\n if (recurse)\n emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);\n else if (iScan < iCh)\n order.push(new BidiSpan(iScan, iCh, localLevel));\n iCh = iScan;\n }\n }\n}\nfunction computeSectionOrder(line, level, baseLevel, isolates, from, to, order) {\n let outerType = (level % 2 ? 2 /* T.R */ : 1 /* T.L */);\n computeCharTypes(line, from, to, isolates, outerType);\n processBracketPairs(line, from, to, isolates, outerType);\n processNeutrals(from, to, isolates, outerType);\n emitSpans(line, from, to, level, baseLevel, isolates, order);\n}\nfunction computeOrder(line, direction, isolates) {\n if (!line)\n return [new BidiSpan(0, 0, direction == RTL ? 1 : 0)];\n if (direction == LTR && !isolates.length && !BidiRE.test(line))\n return trivialOrder(line.length);\n if (isolates.length)\n while (line.length > types.length)\n types[types.length] = 256 /* T.NI */; // Make sure types array has no gaps\n let order = [], level = direction == LTR ? 0 : 1;\n computeSectionOrder(line, level, level, isolates, 0, line.length, order);\n return order;\n}\nfunction trivialOrder(length) {\n return [new BidiSpan(0, length, 0)];\n}\nlet movedOver = \"\";\nfunction moveVisually(line, order, dir, start, forward) {\n var _a;\n let startIndex = start.head - line.from, spanI = -1;\n if (startIndex == 0) {\n if (!forward || !line.length)\n return null;\n if (order[0].level != dir) {\n startIndex = order[0].side(false, dir);\n spanI = 0;\n }\n }\n else if (startIndex == line.length) {\n if (forward)\n return null;\n let last = order[order.length - 1];\n if (last.level != dir) {\n startIndex = last.side(true, dir);\n spanI = order.length - 1;\n }\n }\n if (spanI < 0)\n spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);\n let span = order[spanI];\n // End of span. (But not end of line--that was checked for above.)\n if (startIndex == span.side(forward, dir)) {\n span = order[spanI += forward ? 1 : -1];\n startIndex = span.side(!forward, dir);\n }\n let indexForward = forward == (span.dir == dir);\n let nextIndex = findClusterBreak(line.text, startIndex, indexForward);\n movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));\n if (nextIndex > span.from && nextIndex < span.to)\n return EditorSelection.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);\n let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];\n if (!nextSpan && span.level != dir)\n return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);\n if (nextSpan && nextSpan.level < span.level)\n return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);\n return EditorSelection.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);\n}\n\nclass DocView extends ContentView {\n get length() { return this.view.state.doc.length; }\n constructor(view) {\n super();\n this.view = view;\n this.decorations = [];\n this.dynamicDecorationMap = [];\n this.domChanged = null;\n this.hasComposition = null;\n this.markedForComposition = new Set;\n // Track a minimum width for the editor. When measuring sizes in\n // measureVisibleLineHeights, this is updated to point at the width\n // of a given element and its extent in the document. When a change\n // happens in that range, these are reset. That way, once we've seen\n // a line/element of a given length, we keep the editor wide enough\n // to fit at least that element, until it is changed, at which point\n // we forget it again.\n this.minWidth = 0;\n this.minWidthFrom = 0;\n this.minWidthTo = 0;\n // Track whether the DOM selection was set in a lossy way, so that\n // we don't mess it up when reading it back it\n this.impreciseAnchor = null;\n this.impreciseHead = null;\n this.forceSelection = false;\n // Used by the resize observer to ignore resizes that we caused\n // ourselves\n this.lastUpdate = Date.now();\n this.setDOM(view.contentDOM);\n this.children = [new LineView];\n this.children[0].setParent(this);\n this.updateDeco();\n this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0, null);\n }\n // Update the document view to a given state.\n update(update) {\n var _a;\n let changedRanges = update.changedRanges;\n if (this.minWidth > 0 && changedRanges.length) {\n if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {\n this.minWidth = this.minWidthFrom = this.minWidthTo = 0;\n }\n else {\n this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);\n this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);\n }\n }\n let readCompositionAt = -1;\n if (this.view.inputState.composing >= 0) {\n if ((_a = this.domChanged) === null || _a === void 0 ? void 0 : _a.newSel)\n readCompositionAt = this.domChanged.newSel.head;\n else if (!touchesComposition(update.changes, this.hasComposition) && !update.selectionSet)\n readCompositionAt = update.state.selection.main.head;\n }\n let composition = readCompositionAt > -1 ? findCompositionRange(this.view, update.changes, readCompositionAt) : null;\n this.domChanged = null;\n if (this.hasComposition) {\n this.markedForComposition.clear();\n let { from, to } = this.hasComposition;\n changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))\n .addToSet(changedRanges.slice());\n }\n this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;\n // When the DOM nodes around the selection are moved to another\n // parent, Chrome sometimes reports a different selection through\n // getSelection than the one that it actually shows to the user.\n // This forces a selection update when lines are joined to work\n // around that. Issue #54\n if ((browser.ie || browser.chrome) && !composition && update &&\n update.state.doc.lines != update.startState.doc.lines)\n this.forceSelection = true;\n let prevDeco = this.decorations, deco = this.updateDeco();\n let decoDiff = findChangedDeco(prevDeco, deco, update.changes);\n changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);\n if (!(this.flags & 7 /* ViewFlag.Dirty */) && changedRanges.length == 0) {\n return false;\n }\n else {\n this.updateInner(changedRanges, update.startState.doc.length, composition);\n if (update.transactions.length)\n this.lastUpdate = Date.now();\n return true;\n }\n }\n // Used by update and the constructor do perform the actual DOM\n // update\n updateInner(changes, oldLength, composition) {\n this.view.viewState.mustMeasureContent = true;\n this.updateChildren(changes, oldLength, composition);\n let { observer } = this.view;\n observer.ignore(() => {\n // Lock the height during redrawing, since Chrome sometimes\n // messes with the scroll position during DOM mutation (though\n // no relayout is triggered and I cannot imagine how it can\n // recompute the scroll position without a layout)\n this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + \"px\";\n this.dom.style.flexBasis = this.minWidth ? this.minWidth + \"px\" : \"\";\n // Chrome will sometimes, when DOM mutations occur directly\n // around the selection, get confused and report a different\n // selection from the one it displays (issue #218). This tries\n // to detect that situation.\n let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;\n this.sync(this.view, track);\n this.flags &= ~7 /* ViewFlag.Dirty */;\n if (track && (track.written || observer.selectionRange.focusNode != track.node))\n this.forceSelection = true;\n this.dom.style.height = \"\";\n });\n this.markedForComposition.forEach(cView => cView.flags &= ~8 /* ViewFlag.Composition */);\n let gaps = [];\n if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)\n for (let child of this.children)\n if (child instanceof BlockWidgetView && child.widget instanceof BlockGapWidget)\n gaps.push(child.dom);\n observer.updateGaps(gaps);\n }\n updateChildren(changes, oldLength, composition) {\n let ranges = composition ? composition.range.addToSet(changes.slice()) : changes;\n let cursor = this.childCursor(oldLength);\n for (let i = ranges.length - 1;; i--) {\n let next = i >= 0 ? ranges[i] : null;\n if (!next)\n break;\n let { fromA, toA, fromB, toB } = next, content, breakAtStart, openStart, openEnd;\n if (composition && composition.range.fromB < toB && composition.range.toB > fromB) {\n let before = ContentBuilder.build(this.view.state.doc, fromB, composition.range.fromB, this.decorations, this.dynamicDecorationMap);\n let after = ContentBuilder.build(this.view.state.doc, composition.range.toB, toB, this.decorations, this.dynamicDecorationMap);\n breakAtStart = before.breakAtStart;\n openStart = before.openStart;\n openEnd = after.openEnd;\n let compLine = this.compositionView(composition);\n if (after.breakAtStart) {\n compLine.breakAfter = 1;\n }\n else if (after.content.length &&\n compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {\n compLine.breakAfter = after.content[0].breakAfter;\n after.content.shift();\n }\n if (before.content.length &&\n compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {\n before.content.pop();\n }\n content = before.content.concat(compLine).concat(after.content);\n }\n else {\n ({ content, breakAtStart, openStart, openEnd } =\n ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap));\n }\n let { i: toI, off: toOff } = cursor.findPos(toA, 1);\n let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);\n replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);\n }\n if (composition)\n this.fixCompositionDOM(composition);\n }\n compositionView(composition) {\n let cur = new TextView(composition.text.nodeValue);\n cur.flags |= 8 /* ViewFlag.Composition */;\n for (let { deco } of composition.marks)\n cur = new MarkView(deco, [cur], cur.length);\n let line = new LineView;\n line.append(cur, 0);\n return line;\n }\n fixCompositionDOM(composition) {\n let fix = (dom, cView) => {\n cView.flags |= 8 /* ViewFlag.Composition */ | (cView.children.some(c => c.flags & 7 /* ViewFlag.Dirty */) ? 1 /* ViewFlag.ChildDirty */ : 0);\n this.markedForComposition.add(cView);\n let prev = ContentView.get(dom);\n if (prev && prev != cView)\n prev.dom = null;\n cView.setDOM(dom);\n };\n let pos = this.childPos(composition.range.fromB, 1);\n let cView = this.children[pos.i];\n fix(composition.line, cView);\n for (let i = composition.marks.length - 1; i >= -1; i--) {\n pos = cView.childPos(pos.off, 1);\n cView = cView.children[pos.i];\n fix(i >= 0 ? composition.marks[i].node : composition.text, cView);\n }\n }\n // Sync the DOM selection to this.state.selection\n updateSelection(mustRead = false, fromPointer = false) {\n if (mustRead || !this.view.observer.selectionRange.focusNode)\n this.view.observer.readSelectionRange();\n let activeElt = this.view.root.activeElement, focused = activeElt == this.dom;\n let selectionNotFocus = !focused &&\n hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));\n if (!(focused || fromPointer || selectionNotFocus))\n return;\n let force = this.forceSelection;\n this.forceSelection = false;\n let main = this.view.state.selection.main;\n let anchor = this.moveToLine(this.domAtPos(main.anchor));\n let head = main.empty ? anchor : this.moveToLine(this.domAtPos(main.head));\n // Always reset on Firefox when next to an uneditable node to\n // avoid invisible cursor bugs (#111)\n if (browser.gecko && main.empty && !this.hasComposition && betweenUneditable(anchor)) {\n let dummy = document.createTextNode(\"\");\n this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));\n anchor = head = new DOMPos(dummy, 0);\n force = true;\n }\n let domSel = this.view.observer.selectionRange;\n // If the selection is already here, or in an equivalent position, don't touch it\n if (force || !domSel.focusNode ||\n !isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||\n !isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {\n this.view.observer.ignore(() => {\n // Chrome Android will hide the virtual keyboard when tapping\n // inside an uneditable node, and not bring it back when we\n // move the cursor to its proper position. This tries to\n // restore the keyboard by cycling focus.\n if (browser.android && browser.chrome && this.dom.contains(domSel.focusNode) &&\n inUneditable(domSel.focusNode, this.dom)) {\n this.dom.blur();\n this.dom.focus({ preventScroll: true });\n }\n let rawSel = getSelection(this.view.root);\n if (!rawSel) ;\n else if (main.empty) {\n // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076\n if (browser.gecko) {\n let nextTo = nextToUneditable(anchor.node, anchor.offset);\n if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {\n let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);\n if (text)\n anchor = new DOMPos(text.node, text.offset);\n }\n }\n rawSel.collapse(anchor.node, anchor.offset);\n if (main.bidiLevel != null && rawSel.caretBidiLevel !== undefined)\n rawSel.caretBidiLevel = main.bidiLevel;\n }\n else if (rawSel.extend) {\n // Selection.extend can be used to create an 'inverted' selection\n // (one where the focus is before the anchor), but not all\n // browsers support it yet.\n rawSel.collapse(anchor.node, anchor.offset);\n // Safari will ignore the call above when the editor is\n // hidden, and then raise an error on the call to extend\n // (#940).\n try {\n rawSel.extend(head.node, head.offset);\n }\n catch (_) { }\n }\n else {\n // Primitive (IE) way\n let range = document.createRange();\n if (main.anchor > main.head)\n [anchor, head] = [head, anchor];\n range.setEnd(head.node, head.offset);\n range.setStart(anchor.node, anchor.offset);\n rawSel.removeAllRanges();\n rawSel.addRange(range);\n }\n if (selectionNotFocus && this.view.root.activeElement == this.dom) {\n this.dom.blur();\n if (activeElt)\n activeElt.focus();\n }\n });\n this.view.observer.setSelectionRange(anchor, head);\n }\n this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);\n this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);\n }\n enforceCursorAssoc() {\n if (this.hasComposition)\n return;\n let { view } = this, cursor = view.state.selection.main;\n let sel = getSelection(view.root);\n let { anchorNode, anchorOffset } = view.observer.selectionRange;\n if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)\n return;\n let line = LineView.find(this, cursor.head);\n if (!line)\n return;\n let lineStart = line.posAtStart;\n if (cursor.head == lineStart || cursor.head == lineStart + line.length)\n return;\n let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);\n if (!before || !after || before.bottom > after.top)\n return;\n let dom = this.domAtPos(cursor.head + cursor.assoc);\n sel.collapse(dom.node, dom.offset);\n sel.modify(\"move\", cursor.assoc < 0 ? \"forward\" : \"backward\", \"lineboundary\");\n // This can go wrong in corner cases like single-character lines,\n // so check and reset if necessary.\n view.observer.readSelectionRange();\n let newRange = view.observer.selectionRange;\n if (view.docView.posFromDOM(newRange.anchorNode, newRange.anchorOffset) != cursor.from)\n sel.collapse(anchorNode, anchorOffset);\n }\n // If a position is in/near a block widget, move it to a nearby text\n // line, since we don't want the cursor inside a block widget.\n moveToLine(pos) {\n // Block widgets will return positions before/after them, which\n // are thus directly in the document DOM element.\n let dom = this.dom, newPos;\n if (pos.node != dom)\n return pos;\n for (let i = pos.offset; !newPos && i < dom.childNodes.length; i++) {\n let view = ContentView.get(dom.childNodes[i]);\n if (view instanceof LineView)\n newPos = view.domAtPos(0);\n }\n for (let i = pos.offset - 1; !newPos && i >= 0; i--) {\n let view = ContentView.get(dom.childNodes[i]);\n if (view instanceof LineView)\n newPos = view.domAtPos(view.length);\n }\n return newPos ? new DOMPos(newPos.node, newPos.offset, true) : pos;\n }\n nearest(dom) {\n for (let cur = dom; cur;) {\n let domView = ContentView.get(cur);\n if (domView && domView.rootView == this)\n return domView;\n cur = cur.parentNode;\n }\n return null;\n }\n posFromDOM(node, offset) {\n let view = this.nearest(node);\n if (!view)\n throw new RangeError(\"Trying to find position for a DOM position outside of the document\");\n return view.localPosFromDOM(node, offset) + view.posAtStart;\n }\n domAtPos(pos) {\n let { i, off } = this.childCursor().findPos(pos, -1);\n for (; i < this.children.length - 1;) {\n let child = this.children[i];\n if (off < child.length || child instanceof LineView)\n break;\n i++;\n off = 0;\n }\n return this.children[i].domAtPos(off);\n }\n coordsAt(pos, side) {\n let best = null, bestPos = 0;\n for (let off = this.length, i = this.children.length - 1; i >= 0; i--) {\n let child = this.children[i], end = off - child.breakAfter, start = end - child.length;\n if (end < pos)\n break;\n if (start <= pos && (start < pos || child.covers(-1)) && (end > pos || child.covers(1)) &&\n (!best || child instanceof LineView && !(best instanceof LineView && side >= 0))) {\n best = child;\n bestPos = start;\n }\n off = start;\n }\n return best ? best.coordsAt(pos - bestPos, side) : null;\n }\n coordsForChar(pos) {\n let { i, off } = this.childPos(pos, 1), child = this.children[i];\n if (!(child instanceof LineView))\n return null;\n while (child.children.length) {\n let { i, off: childOff } = child.childPos(off, 1);\n for (;; i++) {\n if (i == child.children.length)\n return null;\n if ((child = child.children[i]).length)\n break;\n }\n off = childOff;\n }\n if (!(child instanceof TextView))\n return null;\n let end = findClusterBreak(child.text, off);\n if (end == off)\n return null;\n let rects = textRange(child.dom, off, end).getClientRects();\n for (let i = 0; i < rects.length; i++) {\n let rect = rects[i];\n if (i == rects.length - 1 || rect.top < rect.bottom && rect.left < rect.right)\n return rect;\n }\n return null;\n }\n measureVisibleLineHeights(viewport) {\n let result = [], { from, to } = viewport;\n let contentWidth = this.view.contentDOM.clientWidth;\n let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;\n let widest = -1, ltr = this.view.textDirection == Direction.LTR;\n for (let pos = 0, i = 0; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (end > to)\n break;\n if (pos >= from) {\n let childRect = child.dom.getBoundingClientRect();\n result.push(childRect.height);\n if (isWider) {\n let last = child.dom.lastChild;\n let rects = last ? clientRectsFor(last) : [];\n if (rects.length) {\n let rect = rects[rects.length - 1];\n let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;\n if (width > widest) {\n widest = width;\n this.minWidth = contentWidth;\n this.minWidthFrom = pos;\n this.minWidthTo = end;\n }\n }\n }\n }\n pos = end + child.breakAfter;\n }\n return result;\n }\n textDirectionAt(pos) {\n let { i } = this.childPos(pos, 1);\n return getComputedStyle(this.children[i].dom).direction == \"rtl\" ? Direction.RTL : Direction.LTR;\n }\n measureTextSize() {\n for (let child of this.children) {\n if (child instanceof LineView) {\n let measure = child.measureTextSize();\n if (measure)\n return measure;\n }\n }\n // If no workable line exists, force a layout of a measurable element\n let dummy = document.createElement(\"div\"), lineHeight, charWidth, textHeight;\n dummy.className = \"cm-line\";\n dummy.style.width = \"99999px\";\n dummy.style.position = \"absolute\";\n dummy.textContent = \"abc def ghi jkl mno pqr stu\";\n this.view.observer.ignore(() => {\n this.dom.appendChild(dummy);\n let rect = clientRectsFor(dummy.firstChild)[0];\n lineHeight = dummy.getBoundingClientRect().height;\n charWidth = rect ? rect.width / 27 : 7;\n textHeight = rect ? rect.height : lineHeight;\n dummy.remove();\n });\n return { lineHeight, charWidth, textHeight };\n }\n childCursor(pos = this.length) {\n // Move back to start of last element when possible, so that\n // `ChildCursor.findPos` doesn't have to deal with the edge case\n // of being after the last element.\n let i = this.children.length;\n if (i)\n pos -= this.children[--i].length;\n return new ChildCursor(this.children, pos, i);\n }\n computeBlockGapDeco() {\n let deco = [], vs = this.view.viewState;\n for (let pos = 0, i = 0;; i++) {\n let next = i == vs.viewports.length ? null : vs.viewports[i];\n let end = next ? next.from - 1 : this.length;\n if (end > pos) {\n let height = (vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top) / this.view.scaleY;\n deco.push(Decoration.replace({\n widget: new BlockGapWidget(height),\n block: true,\n inclusive: true,\n isBlockGap: true,\n }).range(pos, end));\n }\n if (!next)\n break;\n pos = next.to + 1;\n }\n return Decoration.set(deco);\n }\n updateDeco() {\n let allDeco = this.view.state.facet(decorations).map((d, i) => {\n let dynamic = this.dynamicDecorationMap[i] = typeof d == \"function\";\n return dynamic ? d(this.view) : d;\n });\n for (let i = allDeco.length; i < allDeco.length + 3; i++)\n this.dynamicDecorationMap[i] = false;\n return this.decorations = [\n ...allDeco,\n this.computeBlockGapDeco(),\n this.view.viewState.lineGapDeco\n ];\n }\n scrollIntoView(target) {\n if (target.isSnapshot) {\n let ref = this.view.viewState.lineBlockAt(target.range.head);\n this.view.scrollDOM.scrollTop = ref.top - target.yMargin;\n this.view.scrollDOM.scrollLeft = target.xMargin;\n return;\n }\n let { range } = target;\n let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;\n if (!rect)\n return;\n if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))\n rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),\n right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };\n let margins = getScrollMargins(this.view);\n let targetRect = {\n left: rect.left - margins.left, top: rect.top - margins.top,\n right: rect.right + margins.right, bottom: rect.bottom + margins.bottom\n };\n let { offsetWidth, offsetHeight } = this.view.scrollDOM;\n 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);\n }\n}\nfunction betweenUneditable(pos) {\n return pos.node.nodeType == 1 && pos.node.firstChild &&\n (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == \"false\") &&\n (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == \"false\");\n}\nclass BlockGapWidget extends WidgetType {\n constructor(height) {\n super();\n this.height = height;\n }\n toDOM() {\n let elt = document.createElement(\"div\");\n this.updateDOM(elt);\n return elt;\n }\n eq(other) { return other.height == this.height; }\n updateDOM(elt) {\n elt.style.height = this.height + \"px\";\n return true;\n }\n get estimatedHeight() { return this.height; }\n}\nfunction findCompositionNode(view, headPos) {\n let sel = view.observer.selectionRange;\n let textNode = sel.focusNode && nearbyTextNode(sel.focusNode, sel.focusOffset, 0);\n if (!textNode)\n return null;\n let from = headPos - textNode.offset;\n return { from, to: from + textNode.node.nodeValue.length, node: textNode.node };\n}\nfunction findCompositionRange(view, changes, headPos) {\n let found = findCompositionNode(view, headPos);\n if (!found)\n return null;\n let { node: textNode, from, to } = found, text = textNode.nodeValue;\n // Don't try to preserve multi-line compositions\n if (/[\\n\\r]/.test(text))\n return null;\n if (view.state.doc.sliceString(found.from, found.to) != text)\n return null;\n let inv = changes.invertedDesc;\n let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);\n let marks = [];\n for (let parent = textNode.parentNode;; parent = parent.parentNode) {\n let parentView = ContentView.get(parent);\n if (parentView instanceof MarkView)\n marks.push({ node: parent, deco: parentView.mark });\n else if (parentView instanceof LineView || parent.nodeName == \"DIV\" && parent.parentNode == view.contentDOM)\n return { range, text: textNode, marks, line: parent };\n else if (parent != view.contentDOM)\n marks.push({ node: parent, deco: new MarkDecoration({\n inclusive: true,\n attributes: getAttrs(parent),\n tagName: parent.tagName.toLowerCase()\n }) });\n else\n return null;\n }\n}\nfunction nearbyTextNode(startNode, startOffset, side) {\n if (side <= 0)\n for (let node = startNode, offset = startOffset;;) {\n if (node.nodeType == 3)\n return { node: node, offset: offset };\n if (node.nodeType == 1 && offset > 0) {\n node = node.childNodes[offset - 1];\n offset = maxOffset(node);\n }\n else {\n break;\n }\n }\n if (side >= 0)\n for (let node = startNode, offset = startOffset;;) {\n if (node.nodeType == 3)\n return { node: node, offset: offset };\n if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {\n node = node.childNodes[offset];\n offset = 0;\n }\n else {\n break;\n }\n }\n return null;\n}\nfunction nextToUneditable(node, offset) {\n if (node.nodeType != 1)\n return 0;\n return (offset && node.childNodes[offset - 1].contentEditable == \"false\" ? 1 /* NextTo.Before */ : 0) |\n (offset < node.childNodes.length && node.childNodes[offset].contentEditable == \"false\" ? 2 /* NextTo.After */ : 0);\n}\nlet DecorationComparator$1 = class DecorationComparator {\n constructor() {\n this.changes = [];\n }\n compareRange(from, to) { addRange(from, to, this.changes); }\n comparePoint(from, to) { addRange(from, to, this.changes); }\n};\nfunction findChangedDeco(a, b, diff) {\n let comp = new DecorationComparator$1;\n RangeSet.compare(a, b, diff, comp);\n return comp.changes;\n}\nfunction inUneditable(node, inside) {\n for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {\n if (cur.nodeType == 1 && cur.contentEditable == 'false') {\n return true;\n }\n }\n return false;\n}\nfunction touchesComposition(changes, composition) {\n let touched = false;\n if (composition)\n changes.iterChangedRanges((from, to) => {\n if (from < composition.to && to > composition.from)\n touched = true;\n });\n return touched;\n}\n\nfunction groupAt(state, pos, bias = 1) {\n let categorize = state.charCategorizer(pos);\n let line = state.doc.lineAt(pos), linePos = pos - line.from;\n if (line.length == 0)\n return EditorSelection.cursor(pos);\n if (linePos == 0)\n bias = 1;\n else if (linePos == line.length)\n bias = -1;\n let from = linePos, to = linePos;\n if (bias < 0)\n from = findClusterBreak(line.text, linePos, false);\n else\n to = findClusterBreak(line.text, linePos);\n let cat = categorize(line.text.slice(from, to));\n while (from > 0) {\n let prev = findClusterBreak(line.text, from, false);\n if (categorize(line.text.slice(prev, from)) != cat)\n break;\n from = prev;\n }\n while (to < line.length) {\n let next = findClusterBreak(line.text, to);\n if (categorize(line.text.slice(to, next)) != cat)\n break;\n to = next;\n }\n return EditorSelection.range(from + line.from, to + line.from);\n}\n// Search the DOM for the {node, offset} position closest to the given\n// coordinates. Very inefficient and crude, but can usually be avoided\n// by calling caret(Position|Range)FromPoint instead.\nfunction getdx(x, rect) {\n return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);\n}\nfunction getdy(y, rect) {\n return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);\n}\nfunction yOverlap(a, b) {\n return a.top < b.bottom - 1 && a.bottom > b.top + 1;\n}\nfunction upTop(rect, top) {\n return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;\n}\nfunction upBot(rect, bottom) {\n return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;\n}\nfunction domPosAtCoords(parent, x, y) {\n let closest, closestRect, closestX, closestY, closestOverlap = false;\n let above, below, aboveRect, belowRect;\n for (let child = parent.firstChild; child; child = child.nextSibling) {\n let rects = clientRectsFor(child);\n for (let i = 0; i < rects.length; i++) {\n let rect = rects[i];\n if (closestRect && yOverlap(closestRect, rect))\n rect = upTop(upBot(rect, closestRect.bottom), closestRect.top);\n let dx = getdx(x, rect), dy = getdy(y, rect);\n if (dx == 0 && dy == 0)\n return child.nodeType == 3 ? domPosInText(child, x, y) : domPosAtCoords(child, x, y);\n if (!closest || closestY > dy || closestY == dy && closestX > dx) {\n closest = child;\n closestRect = rect;\n closestX = dx;\n closestY = dy;\n let side = dy ? (y < rect.top ? -1 : 1) : dx ? (x < rect.left ? -1 : 1) : 0;\n closestOverlap = !side || (side > 0 ? i < rects.length - 1 : i > 0);\n }\n if (dx == 0) {\n if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {\n above = child;\n aboveRect = rect;\n }\n else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {\n below = child;\n belowRect = rect;\n }\n }\n else if (aboveRect && yOverlap(aboveRect, rect)) {\n aboveRect = upBot(aboveRect, rect.bottom);\n }\n else if (belowRect && yOverlap(belowRect, rect)) {\n belowRect = upTop(belowRect, rect.top);\n }\n }\n }\n if (aboveRect && aboveRect.bottom >= y) {\n closest = above;\n closestRect = aboveRect;\n }\n else if (belowRect && belowRect.top <= y) {\n closest = below;\n closestRect = belowRect;\n }\n if (!closest)\n return { node: parent, offset: 0 };\n let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));\n if (closest.nodeType == 3)\n return domPosInText(closest, clipX, y);\n if (closestOverlap && closest.contentEditable != \"false\")\n return domPosAtCoords(closest, clipX, y);\n let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +\n (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);\n return { node: parent, offset };\n}\nfunction domPosInText(node, x, y) {\n let len = node.nodeValue.length;\n let closestOffset = -1, closestDY = 1e9, generalSide = 0;\n for (let i = 0; i < len; i++) {\n let rects = textRange(node, i, i + 1).getClientRects();\n for (let j = 0; j < rects.length; j++) {\n let rect = rects[j];\n if (rect.top == rect.bottom)\n continue;\n if (!generalSide)\n generalSide = x - rect.left;\n let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;\n if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {\n let right = x >= (rect.left + rect.right) / 2, after = right;\n if (browser.chrome || browser.gecko) {\n // Check for RTL on browsers that support getting client\n // rects for empty ranges.\n let rectBefore = textRange(node, i).getBoundingClientRect();\n if (rectBefore.left == rect.right)\n after = !right;\n }\n if (dy <= 0)\n return { node, offset: i + (after ? 1 : 0) };\n closestOffset = i + (after ? 1 : 0);\n closestDY = dy;\n }\n }\n }\n return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };\n}\nfunction posAtCoords(view, coords, precise, bias = -1) {\n var _a, _b;\n let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;\n let block, { docHeight } = view.viewState;\n let { x, y } = coords, yOffset = y - docTop;\n if (yOffset < 0)\n return 0;\n if (yOffset > docHeight)\n return view.state.doc.length;\n // Scan for a text block near the queried y position\n for (let halfLine = view.viewState.heightOracle.textHeight / 2, bounced = false;;) {\n block = view.elementAtHeight(yOffset);\n if (block.type == BlockType.Text)\n break;\n for (;;) {\n // Move the y position out of this block\n yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;\n if (yOffset >= 0 && yOffset <= docHeight)\n break;\n // If the document consists entirely of replaced widgets, we\n // won't find a text block, so return 0\n if (bounced)\n return precise ? null : 0;\n bounced = true;\n bias = -bias;\n }\n }\n y = docTop + yOffset;\n let lineStart = block.from;\n // If this is outside of the rendered viewport, we can't determine a position\n if (lineStart < view.viewport.from)\n return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise(view, content, block, x, y);\n if (lineStart > view.viewport.to)\n return view.viewport.to == view.state.doc.length ? view.state.doc.length :\n precise ? null : posAtCoordsImprecise(view, content, block, x, y);\n // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not\n let doc = view.dom.ownerDocument;\n let root = view.root.elementFromPoint ? view.root : doc;\n let element = root.elementFromPoint(x, y);\n if (element && !view.contentDOM.contains(element))\n element = null;\n // If the element is unexpected, clip x at the sides of the content area and try again\n if (!element) {\n x = Math.max(content.left + 1, Math.min(content.right - 1, x));\n element = root.elementFromPoint(x, y);\n if (element && !view.contentDOM.contains(element))\n element = null;\n }\n // There's visible editor content under the point, so we can try\n // using caret(Position|Range)FromPoint as a shortcut\n let node, offset = -1;\n if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {\n if (doc.caretPositionFromPoint) {\n let pos = doc.caretPositionFromPoint(x, y);\n if (pos)\n ({ offsetNode: node, offset } = pos);\n }\n else if (doc.caretRangeFromPoint) {\n let range = doc.caretRangeFromPoint(x, y);\n if (range) {\n ({ startContainer: node, startOffset: offset } = range);\n if (!view.contentDOM.contains(node) ||\n browser.safari && isSuspiciousSafariCaretResult(node, offset, x) ||\n browser.chrome && isSuspiciousChromeCaretResult(node, offset, x))\n node = undefined;\n }\n }\n }\n // No luck, do our own (potentially expensive) search\n if (!node || !view.docView.dom.contains(node)) {\n let line = LineView.find(view.docView, lineStart);\n if (!line)\n return yOffset > block.top + block.height / 2 ? block.to : block.from;\n ({ node, offset } = domPosAtCoords(line.dom, x, y));\n }\n let nearest = view.docView.nearest(node);\n if (!nearest)\n return null;\n if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {\n let rect = nearest.dom.getBoundingClientRect();\n return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2\n ? nearest.posAtStart : nearest.posAtEnd;\n }\n else {\n return nearest.localPosFromDOM(node, offset) + nearest.posAtStart;\n }\n}\nfunction posAtCoordsImprecise(view, contentRect, block, x, y) {\n let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);\n if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {\n let textHeight = view.viewState.heightOracle.textHeight;\n let line = Math.floor((y - block.top - (view.defaultLineHeight - textHeight) * 0.5) / textHeight);\n into += line * view.viewState.heightOracle.lineLength;\n }\n let content = view.state.sliceDoc(block.from, block.to);\n return block.from + findColumn(content, into, view.state.tabSize);\n}\n// In case of a high line height, Safari's caretRangeFromPoint treats\n// the space between lines as belonging to the last character of the\n// line before. This is used to detect such a result so that it can be\n// ignored (issue #401).\nfunction isSuspiciousSafariCaretResult(node, offset, x) {\n let len;\n if (node.nodeType != 3 || offset != (len = node.nodeValue.length))\n return false;\n for (let next = node.nextSibling; next; next = next.nextSibling)\n if (next.nodeType != 1 || next.nodeName != \"BR\")\n return false;\n return textRange(node, len - 1, len).getBoundingClientRect().left > x;\n}\n// Chrome will move positions between lines to the start of the next line\nfunction isSuspiciousChromeCaretResult(node, offset, x) {\n if (offset != 0)\n return false;\n for (let cur = node;;) {\n let parent = cur.parentNode;\n if (!parent || parent.nodeType != 1 || parent.firstChild != cur)\n return false;\n if (parent.classList.contains(\"cm-line\"))\n break;\n cur = parent;\n }\n let rect = node.nodeType == 1 ? node.getBoundingClientRect()\n : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();\n return x - rect.left > 5;\n}\nfunction blockAt(view, pos) {\n let line = view.lineBlockAt(pos);\n if (Array.isArray(line.type))\n for (let l of line.type) {\n if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))\n return l;\n }\n return line;\n}\nfunction moveToLineBoundary(view, start, forward, includeWrap) {\n let line = blockAt(view, start.head);\n let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null\n : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);\n if (coords) {\n let editorRect = view.dom.getBoundingClientRect();\n let direction = view.textDirectionAt(line.from);\n let pos = view.posAtCoords({ x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,\n y: (coords.top + coords.bottom) / 2 });\n if (pos != null)\n return EditorSelection.cursor(pos, forward ? -1 : 1);\n }\n return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);\n}\nfunction moveByChar(view, start, forward, by) {\n let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);\n let direction = view.textDirectionAt(line.from);\n for (let cur = start, check = null;;) {\n let next = moveVisually(line, spans, direction, cur, forward), char = movedOver;\n if (!next) {\n if (line.number == (forward ? view.state.doc.lines : 1))\n return cur;\n char = \"\\n\";\n line = view.state.doc.line(line.number + (forward ? 1 : -1));\n spans = view.bidiSpans(line);\n next = EditorSelection.cursor(forward ? line.from : line.to);\n }\n if (!check) {\n if (!by)\n return next;\n check = by(char);\n }\n else if (!check(char)) {\n return cur;\n }\n cur = next;\n }\n}\nfunction byGroup(view, pos, start) {\n let categorize = view.state.charCategorizer(pos);\n let cat = categorize(start);\n return (next) => {\n let nextCat = categorize(next);\n if (cat == CharCategory.Space)\n cat = nextCat;\n return cat == nextCat;\n };\n}\nfunction moveVertically(view, start, forward, distance) {\n let startPos = start.head, dir = forward ? 1 : -1;\n if (startPos == (forward ? view.state.doc.length : 0))\n return EditorSelection.cursor(startPos, start.assoc);\n let goal = start.goalColumn, startY;\n let rect = view.contentDOM.getBoundingClientRect();\n let startCoords = view.coordsAtPos(startPos, start.assoc || -1), docTop = view.documentTop;\n if (startCoords) {\n if (goal == null)\n goal = startCoords.left - rect.left;\n startY = dir < 0 ? startCoords.top : startCoords.bottom;\n }\n else {\n let line = view.viewState.lineBlockAt(startPos);\n if (goal == null)\n goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));\n startY = (dir < 0 ? line.top : line.bottom) + docTop;\n }\n let resolvedGoal = rect.left + goal;\n let dist = distance !== null && distance !== void 0 ? distance : (view.viewState.heightOracle.textHeight >> 1);\n for (let extra = 0;; extra += 10) {\n let curY = startY + (dist + extra) * dir;\n let pos = posAtCoords(view, { x: resolvedGoal, y: curY }, false, dir);\n if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos)) {\n let charRect = view.docView.coordsForChar(pos);\n let assoc = !charRect || curY < charRect.top ? -1 : 1;\n return EditorSelection.cursor(pos, assoc, undefined, goal);\n }\n }\n}\nfunction skipAtomicRanges(atoms, pos, bias) {\n for (;;) {\n let moved = 0;\n for (let set of atoms) {\n set.between(pos - 1, pos + 1, (from, to, value) => {\n if (pos > from && pos < to) {\n let side = moved || bias || (pos - from < to - pos ? -1 : 1);\n pos = side < 0 ? from : to;\n moved = side;\n }\n });\n }\n if (!moved)\n return pos;\n }\n}\nfunction skipAtoms(view, oldPos, pos) {\n let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);\n return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);\n}\n\n// This will also be where dragging info and such goes\nclass InputState {\n setSelectionOrigin(origin) {\n this.lastSelectionOrigin = origin;\n this.lastSelectionTime = Date.now();\n }\n constructor(view) {\n this.view = view;\n this.lastKeyCode = 0;\n this.lastKeyTime = 0;\n this.lastTouchTime = 0;\n this.lastFocusTime = 0;\n this.lastScrollTop = 0;\n this.lastScrollLeft = 0;\n // On iOS, some keys need to have their default behavior happen\n // (after which we retroactively handle them and reset the DOM) to\n // avoid messing up the virtual keyboard state.\n this.pendingIOSKey = undefined;\n this.lastSelectionOrigin = null;\n this.lastSelectionTime = 0;\n this.lastEscPress = 0;\n this.lastContextMenu = 0;\n this.scrollHandlers = [];\n this.handlers = Object.create(null);\n // -1 means not in a composition. Otherwise, this counts the number\n // of changes made during the composition. The count is used to\n // avoid treating the start state of the composition, before any\n // changes have been made, as part of the composition.\n this.composing = -1;\n // Tracks whether the next change should be marked as starting the\n // composition (null means no composition, true means next is the\n // first, false means first has already been marked for this\n // composition)\n this.compositionFirstChange = null;\n // End time of the previous composition\n this.compositionEndedAt = 0;\n // Used in a kludge to detect when an Enter keypress should be\n // considered part of the composition on Safari, which fires events\n // in the wrong order\n this.compositionPendingKey = false;\n // Used to categorize changes as part of a composition, even when\n // the mutation events fire shortly after the compositionend event\n this.compositionPendingChange = false;\n this.mouseSelection = null;\n // When a drag from the editor is active, this points at the range\n // being dragged.\n this.draggedContent = null;\n this.handleEvent = this.handleEvent.bind(this);\n this.notifiedFocused = view.hasFocus;\n // On Safari adding an input event handler somehow prevents an\n // issue where the composition vanishes when you press enter.\n if (browser.safari)\n view.contentDOM.addEventListener(\"input\", () => null);\n if (browser.gecko)\n firefoxCopyCutHack(view.contentDOM.ownerDocument);\n }\n handleEvent(event) {\n if (!eventBelongsToEditor(this.view, event) || this.ignoreDuringComposition(event))\n return;\n if (event.type == \"keydown\" && this.keydown(event))\n return;\n this.runHandlers(event.type, event);\n }\n runHandlers(type, event) {\n let handlers = this.handlers[type];\n if (handlers) {\n for (let observer of handlers.observers)\n observer(this.view, event);\n for (let handler of handlers.handlers) {\n if (event.defaultPrevented)\n break;\n if (handler(this.view, event)) {\n event.preventDefault();\n break;\n }\n }\n }\n }\n ensureHandlers(plugins) {\n let handlers = computeHandlers(plugins), prev = this.handlers, dom = this.view.contentDOM;\n for (let type in handlers)\n if (type != \"scroll\") {\n let passive = !handlers[type].handlers.length;\n let exists = prev[type];\n if (exists && passive != !exists.handlers.length) {\n dom.removeEventListener(type, this.handleEvent);\n exists = null;\n }\n if (!exists)\n dom.addEventListener(type, this.handleEvent, { passive });\n }\n for (let type in prev)\n if (type != \"scroll\" && !handlers[type])\n dom.removeEventListener(type, this.handleEvent);\n this.handlers = handlers;\n }\n keydown(event) {\n // Must always run, even if a custom handler handled the event\n this.lastKeyCode = event.keyCode;\n this.lastKeyTime = Date.now();\n if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)\n return true;\n if (event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)\n this.view.inputState.lastEscPress = 0;\n // Chrome for Android usually doesn't fire proper key events, but\n // occasionally does, usually surrounded by a bunch of complicated\n // composition changes. When an enter or backspace key event is\n // seen, hold off on handling DOM events for a bit, and then\n // dispatch it.\n if (browser.android && browser.chrome && !event.synthetic &&\n (event.keyCode == 13 || event.keyCode == 8)) {\n this.view.observer.delayAndroidKey(event.key, event.keyCode);\n return true;\n }\n // Preventing the default behavior of Enter on iOS makes the\n // virtual keyboard get stuck in the wrong (lowercase)\n // state. So we let it go through, and then, in\n // applyDOMChange, notify key handlers of it and reset to\n // the state they produce.\n let pending;\n if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&\n ((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||\n EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {\n this.pendingIOSKey = pending || event;\n setTimeout(() => this.flushIOSKey(), 250);\n return true;\n }\n if (event.keyCode != 229)\n this.view.observer.forceFlush();\n return false;\n }\n flushIOSKey() {\n let key = this.pendingIOSKey;\n if (!key)\n return false;\n this.pendingIOSKey = undefined;\n return dispatchKey(this.view.contentDOM, key.key, key.keyCode);\n }\n ignoreDuringComposition(event) {\n if (!/^key/.test(event.type))\n return false;\n if (this.composing > 0)\n return true;\n // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.\n // On some input method editors (IMEs), the Enter key is used to\n // confirm character selection. On Safari, when Enter is pressed,\n // compositionend and keydown events are sometimes emitted in the\n // wrong order. The key event should still be ignored, even when\n // it happens after the compositionend event.\n if (browser.safari && !browser.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100) {\n this.compositionPendingKey = false;\n return true;\n }\n return false;\n }\n startMouseSelection(mouseSelection) {\n if (this.mouseSelection)\n this.mouseSelection.destroy();\n this.mouseSelection = mouseSelection;\n }\n update(update) {\n if (this.mouseSelection)\n this.mouseSelection.update(update);\n if (this.draggedContent && update.docChanged)\n this.draggedContent = this.draggedContent.map(update.changes);\n if (update.transactions.length)\n this.lastKeyCode = this.lastSelectionTime = 0;\n }\n destroy() {\n if (this.mouseSelection)\n this.mouseSelection.destroy();\n }\n}\nfunction bindHandler(plugin, handler) {\n return (view, event) => {\n try {\n return handler.call(plugin, event, view);\n }\n catch (e) {\n logException(view.state, e);\n }\n };\n}\nfunction computeHandlers(plugins) {\n let result = Object.create(null);\n function record(type) {\n return result[type] || (result[type] = { observers: [], handlers: [] });\n }\n for (let plugin of plugins) {\n let spec = plugin.spec;\n if (spec && spec.domEventHandlers)\n for (let type in spec.domEventHandlers) {\n let f = spec.domEventHandlers[type];\n if (f)\n record(type).handlers.push(bindHandler(plugin.value, f));\n }\n if (spec && spec.domEventObservers)\n for (let type in spec.domEventObservers) {\n let f = spec.domEventObservers[type];\n if (f)\n record(type).observers.push(bindHandler(plugin.value, f));\n }\n }\n for (let type in handlers)\n record(type).handlers.push(handlers[type]);\n for (let type in observers)\n record(type).observers.push(observers[type]);\n return result;\n}\nconst PendingKeys = [\n { key: \"Backspace\", keyCode: 8, inputType: \"deleteContentBackward\" },\n { key: \"Enter\", keyCode: 13, inputType: \"insertParagraph\" },\n { key: \"Enter\", keyCode: 13, inputType: \"insertLineBreak\" },\n { key: \"Delete\", keyCode: 46, inputType: \"deleteContentForward\" }\n];\nconst EmacsyPendingKeys = \"dthko\";\n// Key codes for modifier keys\nconst modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];\nconst dragScrollMargin = 6;\nfunction dragScrollSpeed(dist) {\n return Math.max(0, dist) * 0.7 + 8;\n}\nfunction dist(a, b) {\n return Math.max(Math.abs(a.clientX - b.clientX), Math.abs(a.clientY - b.clientY));\n}\nclass MouseSelection {\n constructor(view, startEvent, style, mustSelect) {\n this.view = view;\n this.startEvent = startEvent;\n this.style = style;\n this.mustSelect = mustSelect;\n this.scrollSpeed = { x: 0, y: 0 };\n this.scrolling = -1;\n this.lastEvent = startEvent;\n this.scrollParent = scrollableParent(view.contentDOM);\n this.atoms = view.state.facet(atomicRanges).map(f => f(view));\n let doc = view.contentDOM.ownerDocument;\n doc.addEventListener(\"mousemove\", this.move = this.move.bind(this));\n doc.addEventListener(\"mouseup\", this.up = this.up.bind(this));\n this.extend = startEvent.shiftKey;\n this.multiple = view.state.facet(EditorState.allowMultipleSelections) && addsSelectionRange(view, startEvent);\n this.dragging = isInPrimarySelection(view, startEvent) && getClickType(startEvent) == 1 ? null : false;\n }\n start(event) {\n // When clicking outside of the selection, immediately apply the\n // effect of starting the selection\n if (this.dragging === false)\n this.select(event);\n }\n move(event) {\n var _a;\n if (event.buttons == 0)\n return this.destroy();\n if (this.dragging || this.dragging == null && dist(this.startEvent, event) < 10)\n return;\n this.select(this.lastEvent = event);\n let sx = 0, sy = 0;\n let rect = ((_a = this.scrollParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect())\n || { left: 0, top: 0, right: this.view.win.innerWidth, bottom: this.view.win.innerHeight };\n let margins = getScrollMargins(this.view);\n if (event.clientX - margins.left <= rect.left + dragScrollMargin)\n sx = -dragScrollSpeed(rect.left - event.clientX);\n else if (event.clientX + margins.right >= rect.right - dragScrollMargin)\n sx = dragScrollSpeed(event.clientX - rect.right);\n if (event.clientY - margins.top <= rect.top + dragScrollMargin)\n sy = -dragScrollSpeed(rect.top - event.clientY);\n else if (event.clientY + margins.bottom >= rect.bottom - dragScrollMargin)\n sy = dragScrollSpeed(event.clientY - rect.bottom);\n this.setScrollSpeed(sx, sy);\n }\n up(event) {\n if (this.dragging == null)\n this.select(this.lastEvent);\n if (!this.dragging)\n event.preventDefault();\n this.destroy();\n }\n destroy() {\n this.setScrollSpeed(0, 0);\n let doc = this.view.contentDOM.ownerDocument;\n doc.removeEventListener(\"mousemove\", this.move);\n doc.removeEventListener(\"mouseup\", this.up);\n this.view.inputState.mouseSelection = this.view.inputState.draggedContent = null;\n }\n setScrollSpeed(sx, sy) {\n this.scrollSpeed = { x: sx, y: sy };\n if (sx || sy) {\n if (this.scrolling < 0)\n this.scrolling = setInterval(() => this.scroll(), 50);\n }\n else if (this.scrolling > -1) {\n clearInterval(this.scrolling);\n this.scrolling = -1;\n }\n }\n scroll() {\n if (this.scrollParent) {\n this.scrollParent.scrollLeft += this.scrollSpeed.x;\n this.scrollParent.scrollTop += this.scrollSpeed.y;\n }\n else {\n this.view.win.scrollBy(this.scrollSpeed.x, this.scrollSpeed.y);\n }\n if (this.dragging === false)\n this.select(this.lastEvent);\n }\n skipAtoms(sel) {\n let ranges = null;\n for (let i = 0; i < sel.ranges.length; i++) {\n let range = sel.ranges[i], updated = null;\n if (range.empty) {\n let pos = skipAtomicRanges(this.atoms, range.from, 0);\n if (pos != range.from)\n updated = EditorSelection.cursor(pos, -1);\n }\n else {\n let from = skipAtomicRanges(this.atoms, range.from, -1);\n let to = skipAtomicRanges(this.atoms, range.to, 1);\n if (from != range.from || to != range.to)\n updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);\n }\n if (updated) {\n if (!ranges)\n ranges = sel.ranges.slice();\n ranges[i] = updated;\n }\n }\n return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;\n }\n select(event) {\n let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));\n if (this.mustSelect || !selection.eq(view.state.selection) ||\n selection.main.assoc != view.state.selection.main.assoc && this.dragging === false)\n this.view.dispatch({\n selection,\n userEvent: \"select.pointer\"\n });\n this.mustSelect = false;\n }\n update(update) {\n if (this.style.update(update))\n setTimeout(() => this.select(this.lastEvent), 20);\n }\n}\nfunction addsSelectionRange(view, event) {\n let facet = view.state.facet(clickAddsSelectionRange);\n return facet.length ? facet[0](event) : browser.mac ? event.metaKey : event.ctrlKey;\n}\nfunction dragMovesSelection(view, event) {\n let facet = view.state.facet(dragMovesSelection$1);\n return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;\n}\nfunction isInPrimarySelection(view, event) {\n let { main } = view.state.selection;\n if (main.empty)\n return false;\n // On boundary clicks, check whether the coordinates are inside the\n // selection's client rectangles\n let sel = getSelection(view.root);\n if (!sel || sel.rangeCount == 0)\n return true;\n let rects = sel.getRangeAt(0).getClientRects();\n for (let i = 0; i < rects.length; i++) {\n let rect = rects[i];\n if (rect.left <= event.clientX && rect.right >= event.clientX &&\n rect.top <= event.clientY && rect.bottom >= event.clientY)\n return true;\n }\n return false;\n}\nfunction eventBelongsToEditor(view, event) {\n if (!event.bubbles)\n return true;\n if (event.defaultPrevented)\n return false;\n for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)\n if (!node || node.nodeType == 11 || ((cView = ContentView.get(node)) && cView.ignoreEvent(event)))\n return false;\n return true;\n}\nconst handlers = /*@__PURE__*/Object.create(null);\nconst observers = /*@__PURE__*/Object.create(null);\n// This is very crude, but unfortunately both these browsers _pretend_\n// that they have a clipboard API—all the objects and methods are\n// there, they just don't work, and they are hard to test.\nconst brokenClipboardAPI = (browser.ie && browser.ie_version < 15) ||\n (browser.ios && browser.webkit_version < 604);\nfunction capturePaste(view) {\n let parent = view.dom.parentNode;\n if (!parent)\n return;\n let target = parent.appendChild(document.createElement(\"textarea\"));\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.focus();\n setTimeout(() => {\n view.focus();\n target.remove();\n doPaste(view, target.value);\n }, 50);\n}\nfunction doPaste(view, input) {\n let { state } = view, changes, i = 1, text = state.toText(input);\n let byLine = text.lines == state.selection.ranges.length;\n let linewise = lastLinewiseCopy != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy == text.toString();\n if (linewise) {\n let lastLine = -1;\n changes = state.changeByRange(range => {\n let line = state.doc.lineAt(range.from);\n if (line.from == lastLine)\n return { range };\n lastLine = line.from;\n let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);\n return { changes: { from: line.from, insert },\n range: EditorSelection.cursor(range.from + insert.length) };\n });\n }\n else if (byLine) {\n changes = state.changeByRange(range => {\n let line = text.line(i++);\n return { changes: { from: range.from, to: range.to, insert: line.text },\n range: EditorSelection.cursor(range.from + line.length) };\n });\n }\n else {\n changes = state.replaceSelection(text);\n }\n view.dispatch(changes, {\n userEvent: \"input.paste\",\n scrollIntoView: true\n });\n}\nobservers.scroll = view => {\n view.inputState.lastScrollTop = view.scrollDOM.scrollTop;\n view.inputState.lastScrollLeft = view.scrollDOM.scrollLeft;\n};\nhandlers.keydown = (view, event) => {\n view.inputState.setSelectionOrigin(\"select\");\n if (event.keyCode == 27)\n view.inputState.lastEscPress = Date.now();\n return false;\n};\nobservers.touchstart = (view, e) => {\n view.inputState.lastTouchTime = Date.now();\n view.inputState.setSelectionOrigin(\"select.pointer\");\n};\nobservers.touchmove = view => {\n view.inputState.setSelectionOrigin(\"select.pointer\");\n};\nhandlers.mousedown = (view, event) => {\n view.observer.flush();\n if (view.inputState.lastTouchTime > Date.now() - 2000)\n return false; // Ignore touch interaction\n let style = null;\n for (let makeStyle of view.state.facet(mouseSelectionStyle)) {\n style = makeStyle(view, event);\n if (style)\n break;\n }\n if (!style && event.button == 0)\n style = basicMouseSelection(view, event);\n if (style) {\n let mustFocus = !view.hasFocus;\n view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));\n if (mustFocus)\n view.observer.ignore(() => focusPreventScroll(view.contentDOM));\n let mouseSel = view.inputState.mouseSelection;\n if (mouseSel) {\n mouseSel.start(event);\n return mouseSel.dragging === false;\n }\n }\n return false;\n};\nfunction rangeForClick(view, pos, bias, type) {\n if (type == 1) { // Single click\n return EditorSelection.cursor(pos, bias);\n }\n else if (type == 2) { // Double click\n return groupAt(view.state, pos, bias);\n }\n else { // Triple click\n let visual = LineView.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);\n let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;\n if (to < view.state.doc.length && to == line.to)\n to++;\n return EditorSelection.range(from, to);\n }\n}\nlet insideY = (y, rect) => y >= rect.top && y <= rect.bottom;\nlet inside = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right;\n// Try to determine, for the given coordinates, associated with the\n// given position, whether they are related to the element before or\n// the element after the position.\nfunction findPositionSide(view, pos, x, y) {\n let line = LineView.find(view.docView, pos);\n if (!line)\n return 1;\n let off = pos - line.posAtStart;\n // Line boundaries point into the line\n if (off == 0)\n return 1;\n if (off == line.length)\n return -1;\n // Positions on top of an element point at that element\n let before = line.coordsAt(off, -1);\n if (before && inside(x, y, before))\n return -1;\n let after = line.coordsAt(off, 1);\n if (after && inside(x, y, after))\n return 1;\n // This is probably a line wrap point. Pick before if the point is\n // beside it.\n return before && insideY(y, before) ? -1 : 1;\n}\nfunction queryPos(view, event) {\n let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };\n}\nconst BadMouseDetail = browser.ie && browser.ie_version <= 11;\nlet lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;\nfunction getClickType(event) {\n if (!BadMouseDetail)\n return event.detail;\n let last = lastMouseDown, lastTime = lastMouseDownTime;\n lastMouseDown = event;\n lastMouseDownTime = Date.now();\n return lastMouseDownCount = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&\n Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;\n}\nfunction basicMouseSelection(view, event) {\n let start = queryPos(view, event), type = getClickType(event);\n let startSel = view.state.selection;\n return {\n update(update) {\n if (update.docChanged) {\n start.pos = update.changes.mapPos(start.pos);\n startSel = startSel.map(update.changes);\n }\n },\n get(event, extend, multiple) {\n let cur = queryPos(view, event), removed;\n let range = rangeForClick(view, cur.pos, cur.bias, type);\n if (start.pos != cur.pos && !extend) {\n let startRange = rangeForClick(view, start.pos, start.bias, type);\n let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);\n range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);\n }\n if (extend)\n return startSel.replaceRange(startSel.main.extend(range.from, range.to));\n else if (multiple && type == 1 && startSel.ranges.length > 1 && (removed = removeRangeAround(startSel, cur.pos)))\n return removed;\n else if (multiple)\n return startSel.addRange(range);\n else\n return EditorSelection.create([range]);\n }\n };\n}\nfunction removeRangeAround(sel, pos) {\n for (let i = 0; i < sel.ranges.length; i++) {\n let { from, to } = sel.ranges[i];\n if (from <= pos && to >= pos)\n 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));\n }\n return null;\n}\nhandlers.dragstart = (view, event) => {\n let { selection: { main: range } } = view.state;\n if (event.target.draggable) {\n let cView = view.docView.nearest(event.target);\n if (cView && cView.isWidget) {\n let from = cView.posAtStart, to = from + cView.length;\n if (from >= range.to || to <= range.from)\n range = EditorSelection.range(from, to);\n }\n }\n let { inputState } = view;\n if (inputState.mouseSelection)\n inputState.mouseSelection.dragging = true;\n inputState.draggedContent = range;\n if (event.dataTransfer) {\n event.dataTransfer.setData(\"Text\", view.state.sliceDoc(range.from, range.to));\n event.dataTransfer.effectAllowed = \"copyMove\";\n }\n return false;\n};\nhandlers.dragend = view => {\n view.inputState.draggedContent = null;\n return false;\n};\nfunction dropText(view, event, text, direct) {\n if (!text)\n return;\n let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n let { draggedContent } = view.inputState;\n let del = direct && draggedContent && dragMovesSelection(view, event)\n ? { from: draggedContent.from, to: draggedContent.to } : null;\n let ins = { from: dropPos, insert: text };\n let changes = view.state.changes(del ? [del, ins] : ins);\n view.focus();\n view.dispatch({\n changes,\n selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },\n userEvent: del ? \"move.drop\" : \"input.drop\"\n });\n view.inputState.draggedContent = null;\n}\nhandlers.drop = (view, event) => {\n if (!event.dataTransfer)\n return false;\n if (view.state.readOnly)\n return true;\n let files = event.dataTransfer.files;\n if (files && files.length) { // For a file drop, read the file's text.\n let text = Array(files.length), read = 0;\n let finishFile = () => {\n if (++read == files.length)\n dropText(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);\n };\n for (let i = 0; i < files.length; i++) {\n let reader = new FileReader;\n reader.onerror = finishFile;\n reader.onload = () => {\n if (!/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(reader.result))\n text[i] = reader.result;\n finishFile();\n };\n reader.readAsText(files[i]);\n }\n return true;\n }\n else {\n let text = event.dataTransfer.getData(\"Text\");\n if (text) {\n dropText(view, event, text, true);\n return true;\n }\n }\n return false;\n};\nhandlers.paste = (view, event) => {\n if (view.state.readOnly)\n return true;\n view.observer.flush();\n let data = brokenClipboardAPI ? null : event.clipboardData;\n if (data) {\n doPaste(view, data.getData(\"text/plain\") || data.getData(\"text/uri-text\"));\n return true;\n }\n else {\n capturePaste(view);\n return false;\n }\n};\nfunction captureCopy(view, text) {\n // The extra wrapper is somehow necessary on IE/Edge to prevent the\n // content from being mangled when it is put onto the clipboard\n let parent = view.dom.parentNode;\n if (!parent)\n return;\n let target = parent.appendChild(document.createElement(\"textarea\"));\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.value = text;\n target.focus();\n target.selectionEnd = text.length;\n target.selectionStart = 0;\n setTimeout(() => {\n target.remove();\n view.focus();\n }, 50);\n}\nfunction copiedRange(state) {\n let content = [], ranges = [], linewise = false;\n for (let range of state.selection.ranges)\n if (!range.empty) {\n content.push(state.sliceDoc(range.from, range.to));\n ranges.push(range);\n }\n if (!content.length) {\n // Nothing selected, do a line-wise copy\n let upto = -1;\n for (let { from } of state.selection.ranges) {\n let line = state.doc.lineAt(from);\n if (line.number > upto) {\n content.push(line.text);\n ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });\n }\n upto = line.number;\n }\n linewise = true;\n }\n return { text: content.join(state.lineBreak), ranges, linewise };\n}\nlet lastLinewiseCopy = null;\nhandlers.copy = handlers.cut = (view, event) => {\n let { text, ranges, linewise } = copiedRange(view.state);\n if (!text && !linewise)\n return false;\n lastLinewiseCopy = linewise ? text : null;\n if (event.type == \"cut\" && !view.state.readOnly)\n view.dispatch({\n changes: ranges,\n scrollIntoView: true,\n userEvent: \"delete.cut\"\n });\n let data = brokenClipboardAPI ? null : event.clipboardData;\n if (data) {\n data.clearData();\n data.setData(\"text/plain\", text);\n return true;\n }\n else {\n captureCopy(view, text);\n return false;\n }\n};\nconst isFocusChange = /*@__PURE__*/Annotation.define();\nfunction focusChangeTransaction(state, focus) {\n let effects = [];\n for (let getEffect of state.facet(focusChangeEffect)) {\n let effect = getEffect(state, focus);\n if (effect)\n effects.push(effect);\n }\n return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;\n}\nfunction updateForFocusChange(view) {\n setTimeout(() => {\n let focus = view.hasFocus;\n if (focus != view.inputState.notifiedFocused) {\n let tr = focusChangeTransaction(view.state, focus);\n if (tr)\n view.dispatch(tr);\n else\n view.update([]);\n }\n }, 10);\n}\nobservers.focus = view => {\n view.inputState.lastFocusTime = Date.now();\n // When focusing reset the scroll position, move it back to where it was\n if (!view.scrollDOM.scrollTop && (view.inputState.lastScrollTop || view.inputState.lastScrollLeft)) {\n view.scrollDOM.scrollTop = view.inputState.lastScrollTop;\n view.scrollDOM.scrollLeft = view.inputState.lastScrollLeft;\n }\n updateForFocusChange(view);\n};\nobservers.blur = view => {\n view.observer.clearSelectionRange();\n updateForFocusChange(view);\n};\nobservers.compositionstart = observers.compositionupdate = view => {\n if (view.inputState.compositionFirstChange == null)\n view.inputState.compositionFirstChange = true;\n if (view.inputState.composing < 0) {\n // FIXME possibly set a timeout to clear it again on Android\n view.inputState.composing = 0;\n }\n};\nobservers.compositionend = view => {\n view.inputState.composing = -1;\n view.inputState.compositionEndedAt = Date.now();\n view.inputState.compositionPendingKey = true;\n view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;\n view.inputState.compositionFirstChange = null;\n if (browser.chrome && browser.android) {\n // Delay flushing for a bit on Android because it'll often fire a\n // bunch of contradictory changes in a row at end of compositon\n view.observer.flushSoon();\n }\n else if (view.inputState.compositionPendingChange) {\n // If we found pending records, schedule a flush.\n Promise.resolve().then(() => view.observer.flush());\n }\n else {\n // Otherwise, make sure that, if no changes come in soon, the\n // composition view is cleared.\n setTimeout(() => {\n if (view.inputState.composing < 0 && view.docView.hasComposition)\n view.update([]);\n }, 50);\n }\n};\nobservers.contextmenu = view => {\n view.inputState.lastContextMenu = Date.now();\n};\nhandlers.beforeinput = (view, event) => {\n var _a;\n // Because Chrome Android doesn't fire useful key events, use\n // beforeinput to detect backspace (and possibly enter and delete,\n // but those usually don't even seem to fire beforeinput events at\n // the moment) and fake a key event for it.\n //\n // (preventDefault on beforeinput, though supported in the spec,\n // seems to do nothing at all on Chrome).\n let pending;\n if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {\n view.observer.delayAndroidKey(pending.key, pending.keyCode);\n if (pending.key == \"Backspace\" || pending.key == \"Delete\") {\n let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;\n setTimeout(() => {\n var _a;\n // Backspacing near uneditable nodes on Chrome Android sometimes\n // closes the virtual keyboard. This tries to crudely detect\n // that and refocus to get it back.\n if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {\n view.contentDOM.blur();\n view.focus();\n }\n }, 100);\n }\n }\n return false;\n};\nconst appliedFirefoxHack = /*@__PURE__*/new Set;\n// In Firefox, when cut/copy handlers are added to the document, that\n// somehow avoids a bug where those events aren't fired when the\n// selection is empty. See https://github.com/codemirror/dev/issues/1082\n// and https://bugzilla.mozilla.org/show_bug.cgi?id=995961\nfunction firefoxCopyCutHack(doc) {\n if (!appliedFirefoxHack.has(doc)) {\n appliedFirefoxHack.add(doc);\n doc.addEventListener(\"copy\", () => { });\n doc.addEventListener(\"cut\", () => { });\n }\n}\n\nconst wrappingWhiteSpace = [\"pre-wrap\", \"normal\", \"pre-line\", \"break-spaces\"];\nclass HeightOracle {\n constructor(lineWrapping) {\n this.lineWrapping = lineWrapping;\n this.doc = Text.empty;\n this.heightSamples = {};\n this.lineHeight = 14; // The height of an entire line (line-height)\n this.charWidth = 7;\n this.textHeight = 14; // The height of the actual font (font-size)\n this.lineLength = 30;\n // Used to track, during updateHeight, if any actual heights changed\n this.heightChanged = false;\n }\n heightForGap(from, to) {\n let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;\n if (this.lineWrapping)\n lines += Math.max(0, Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength));\n return this.lineHeight * lines;\n }\n heightForLine(length) {\n if (!this.lineWrapping)\n return this.lineHeight;\n let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));\n return lines * this.lineHeight;\n }\n setDoc(doc) { this.doc = doc; return this; }\n mustRefreshForWrapping(whiteSpace) {\n return (wrappingWhiteSpace.indexOf(whiteSpace) > -1) != this.lineWrapping;\n }\n mustRefreshForHeights(lineHeights) {\n let newHeight = false;\n for (let i = 0; i < lineHeights.length; i++) {\n let h = lineHeights[i];\n if (h < 0) {\n i++;\n }\n else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels\n newHeight = true;\n this.heightSamples[Math.floor(h * 10)] = true;\n }\n }\n return newHeight;\n }\n refresh(whiteSpace, lineHeight, charWidth, textHeight, lineLength, knownHeights) {\n let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;\n let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;\n this.lineWrapping = lineWrapping;\n this.lineHeight = lineHeight;\n this.charWidth = charWidth;\n this.textHeight = textHeight;\n this.lineLength = lineLength;\n if (changed) {\n this.heightSamples = {};\n for (let i = 0; i < knownHeights.length; i++) {\n let h = knownHeights[i];\n if (h < 0)\n i++;\n else\n this.heightSamples[Math.floor(h * 10)] = true;\n }\n }\n return changed;\n }\n}\n// This object is used by `updateHeight` to make DOM measurements\n// arrive at the right nides. The `heights` array is a sequence of\n// block heights, starting from position `from`.\nclass MeasuredHeights {\n constructor(from, heights) {\n this.from = from;\n this.heights = heights;\n this.index = 0;\n }\n get more() { return this.index < this.heights.length; }\n}\n/**\nRecord used to represent information about a block-level element\nin the editor view.\n*/\nclass BlockInfo {\n /**\n @internal\n */\n constructor(\n /**\n The start of the element in the document.\n */\n from, \n /**\n The length of the element.\n */\n length, \n /**\n The top position of the element (relative to the top of the\n document).\n */\n top, \n /**\n Its height.\n */\n height, \n /**\n @internal Weird packed field that holds an array of children\n for composite blocks, a decoration for block widgets, and a\n number indicating the amount of widget-create line breaks for\n text blocks.\n */\n _content) {\n this.from = from;\n this.length = length;\n this.top = top;\n this.height = height;\n this._content = _content;\n }\n /**\n The type of element this is. When querying lines, this may be\n an array of all the blocks that make up the line.\n */\n get type() {\n return typeof this._content == \"number\" ? BlockType.Text :\n Array.isArray(this._content) ? this._content : this._content.type;\n }\n /**\n The end of the element as a document position.\n */\n get to() { return this.from + this.length; }\n /**\n The bottom position of the element.\n */\n get bottom() { return this.top + this.height; }\n /**\n If this is a widget block, this will return the widget\n associated with it.\n */\n get widget() {\n return this._content instanceof PointDecoration ? this._content.widget : null;\n }\n /**\n If this is a textblock, this holds the number of line breaks\n that appear in widgets inside the block.\n */\n get widgetLineBreaks() {\n return typeof this._content == \"number\" ? this._content : 0;\n }\n /**\n @internal\n */\n join(other) {\n let content = (Array.isArray(this._content) ? this._content : [this])\n .concat(Array.isArray(other._content) ? other._content : [other]);\n return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);\n }\n}\nvar QueryType = /*@__PURE__*/(function (QueryType) {\n QueryType[QueryType[\"ByPos\"] = 0] = \"ByPos\";\n QueryType[QueryType[\"ByHeight\"] = 1] = \"ByHeight\";\n QueryType[QueryType[\"ByPosNoHeight\"] = 2] = \"ByPosNoHeight\";\nreturn QueryType})(QueryType || (QueryType = {}));\nconst Epsilon = 1e-3;\nclass HeightMap {\n constructor(length, // The number of characters covered\n height, // Height of this part of the document\n flags = 2 /* Flag.Outdated */) {\n this.length = length;\n this.height = height;\n this.flags = flags;\n }\n get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }\n set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }\n setHeight(oracle, height) {\n if (this.height != height) {\n if (Math.abs(this.height - height) > Epsilon)\n oracle.heightChanged = true;\n this.height = height;\n }\n }\n // Base case is to replace a leaf node, which simply builds a tree\n // from the new nodes and returns that (HeightMapBranch and\n // HeightMapGap override this to actually use from/to)\n replace(_from, _to, nodes) {\n return HeightMap.of(nodes);\n }\n // Again, these are base cases, and are overridden for branch and gap nodes.\n decomposeLeft(_to, result) { result.push(this); }\n decomposeRight(_from, result) { result.push(this); }\n applyChanges(decorations, oldDoc, oracle, changes) {\n let me = this, doc = oracle.doc;\n for (let i = changes.length - 1; i >= 0; i--) {\n let { fromA, toA, fromB, toB } = changes[i];\n let start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle.setDoc(oldDoc), 0, 0);\n let end = start.to >= toA ? start : me.lineAt(toA, QueryType.ByPosNoHeight, oracle, 0, 0);\n toB += end.to - toA;\n toA = end.to;\n while (i > 0 && start.from <= changes[i - 1].toA) {\n fromA = changes[i - 1].fromA;\n fromB = changes[i - 1].fromB;\n i--;\n if (fromA < start.from)\n start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle, 0, 0);\n }\n fromB += start.from - fromA;\n fromA = start.from;\n let nodes = NodeBuilder.build(oracle.setDoc(doc), decorations, fromB, toB);\n me = me.replace(fromA, toA, nodes);\n }\n return me.updateHeight(oracle, 0);\n }\n static empty() { return new HeightMapText(0, 0); }\n // nodes uses null values to indicate the position of line breaks.\n // There are never line breaks at the start or end of the array, or\n // two line breaks next to each other, and the array isn't allowed\n // to be empty (same restrictions as return value from the builder).\n static of(nodes) {\n if (nodes.length == 1)\n return nodes[0];\n let i = 0, j = nodes.length, before = 0, after = 0;\n for (;;) {\n if (i == j) {\n if (before > after * 2) {\n let split = nodes[i - 1];\n if (split.break)\n nodes.splice(--i, 1, split.left, null, split.right);\n else\n nodes.splice(--i, 1, split.left, split.right);\n j += 1 + split.break;\n before -= split.size;\n }\n else if (after > before * 2) {\n let split = nodes[j];\n if (split.break)\n nodes.splice(j, 1, split.left, null, split.right);\n else\n nodes.splice(j, 1, split.left, split.right);\n j += 2 + split.break;\n after -= split.size;\n }\n else {\n break;\n }\n }\n else if (before < after) {\n let next = nodes[i++];\n if (next)\n before += next.size;\n }\n else {\n let next = nodes[--j];\n if (next)\n after += next.size;\n }\n }\n let brk = 0;\n if (nodes[i - 1] == null) {\n brk = 1;\n i--;\n }\n else if (nodes[i] == null) {\n brk = 1;\n j++;\n }\n return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));\n }\n}\nHeightMap.prototype.size = 1;\nclass HeightMapBlock extends HeightMap {\n constructor(length, height, deco) {\n super(length, height);\n this.deco = deco;\n }\n blockAt(_height, _oracle, top, offset) {\n return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);\n }\n lineAt(_value, _type, oracle, top, offset) {\n return this.blockAt(0, oracle, top, offset);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n if (from <= offset + this.length && to >= offset)\n f(this.blockAt(0, oracle, top, offset));\n }\n updateHeight(oracle, offset = 0, _force = false, measured) {\n if (measured && measured.from <= offset && measured.more)\n this.setHeight(oracle, measured.heights[measured.index++]);\n this.outdated = false;\n return this;\n }\n toString() { return `block(${this.length})`; }\n}\nclass HeightMapText extends HeightMapBlock {\n constructor(length, height) {\n super(length, height, null);\n this.collapsed = 0; // Amount of collapsed content in the line\n this.widgetHeight = 0; // Maximum inline widget height\n this.breaks = 0; // Number of widget-introduced line breaks on the line\n }\n blockAt(_height, _oracle, top, offset) {\n return new BlockInfo(offset, this.length, top, this.height, this.breaks);\n }\n replace(_from, _to, nodes) {\n let node = nodes[0];\n if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&\n Math.abs(this.length - node.length) < 10) {\n if (node instanceof HeightMapGap)\n node = new HeightMapText(node.length, this.height);\n else\n node.height = this.height;\n if (!this.outdated)\n node.outdated = false;\n return node;\n }\n else {\n return HeightMap.of(nodes);\n }\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n if (measured && measured.from <= offset && measured.more)\n this.setHeight(oracle, measured.heights[measured.index++]);\n else if (force || this.outdated)\n this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +\n this.breaks * oracle.lineHeight);\n this.outdated = false;\n return this;\n }\n toString() {\n return `line(${this.length}${this.collapsed ? -this.collapsed : \"\"}${this.widgetHeight ? \":\" + this.widgetHeight : \"\"})`;\n }\n}\nclass HeightMapGap extends HeightMap {\n constructor(length) { super(length, 0); }\n heightMetrics(oracle, offset) {\n let firstLine = oracle.doc.lineAt(offset).number, lastLine = oracle.doc.lineAt(offset + this.length).number;\n let lines = lastLine - firstLine + 1;\n let perLine, perChar = 0;\n if (oracle.lineWrapping) {\n let totalPerLine = Math.min(this.height, oracle.lineHeight * lines);\n perLine = totalPerLine / lines;\n if (this.length > lines + 1)\n perChar = (this.height - totalPerLine) / (this.length - lines - 1);\n }\n else {\n perLine = this.height / lines;\n }\n return { firstLine, lastLine, perLine, perChar };\n }\n blockAt(height, oracle, top, offset) {\n let { firstLine, lastLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n if (oracle.lineWrapping) {\n let guess = offset + Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length);\n let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;\n let lineTop = Math.max(top, height - lineHeight / 2);\n return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);\n }\n else {\n let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));\n let { from, length } = oracle.doc.line(firstLine + line);\n return new BlockInfo(from, length, top + perLine * line, perLine, 0);\n }\n }\n lineAt(value, type, oracle, top, offset) {\n if (type == QueryType.ByHeight)\n return this.blockAt(value, oracle, top, offset);\n if (type == QueryType.ByPosNoHeight) {\n let { from, to } = oracle.doc.lineAt(value);\n return new BlockInfo(from, to - from, 0, 0, 0);\n }\n let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;\n let linesAbove = line.number - firstLine;\n let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);\n return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n from = Math.max(from, offset);\n to = Math.min(to, offset + this.length);\n let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n for (let pos = from, lineTop = top; pos <= to;) {\n let line = oracle.doc.lineAt(pos);\n if (pos == from) {\n let linesAbove = line.number - firstLine;\n lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);\n }\n let lineHeight = perLine + perChar * line.length;\n f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));\n lineTop += lineHeight;\n pos = line.to + 1;\n }\n }\n replace(from, to, nodes) {\n let after = this.length - to;\n if (after > 0) {\n let last = nodes[nodes.length - 1];\n if (last instanceof HeightMapGap)\n nodes[nodes.length - 1] = new HeightMapGap(last.length + after);\n else\n nodes.push(null, new HeightMapGap(after - 1));\n }\n if (from > 0) {\n let first = nodes[0];\n if (first instanceof HeightMapGap)\n nodes[0] = new HeightMapGap(from + first.length);\n else\n nodes.unshift(new HeightMapGap(from - 1), null);\n }\n return HeightMap.of(nodes);\n }\n decomposeLeft(to, result) {\n result.push(new HeightMapGap(to - 1), null);\n }\n decomposeRight(from, result) {\n result.push(null, new HeightMapGap(this.length - from - 1));\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n let end = offset + this.length;\n if (measured && measured.from <= offset + this.length && measured.more) {\n // Fill in part of this gap with measured lines. We know there\n // can't be widgets or collapsed ranges in those lines, because\n // they would already have been added to the heightmap (gaps\n // only contain plain text).\n let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;\n if (measured.from > offset)\n nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));\n while (pos <= end && measured.more) {\n let len = oracle.doc.lineAt(pos).length;\n if (nodes.length)\n nodes.push(null);\n let height = measured.heights[measured.index++];\n if (singleHeight == -1)\n singleHeight = height;\n else if (Math.abs(height - singleHeight) >= Epsilon)\n singleHeight = -2;\n let line = new HeightMapText(len, height);\n line.outdated = false;\n nodes.push(line);\n pos += len + 1;\n }\n if (pos <= end)\n nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));\n let result = HeightMap.of(nodes);\n if (singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon ||\n Math.abs(singleHeight - this.heightMetrics(oracle, offset).perLine) >= Epsilon)\n oracle.heightChanged = true;\n return result;\n }\n else if (force || this.outdated) {\n this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));\n this.outdated = false;\n }\n return this;\n }\n toString() { return `gap(${this.length})`; }\n}\nclass HeightMapBranch extends HeightMap {\n constructor(left, brk, right) {\n super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));\n this.left = left;\n this.right = right;\n this.size = left.size + right.size;\n }\n get break() { return this.flags & 1 /* Flag.Break */; }\n blockAt(height, oracle, top, offset) {\n let mid = top + this.left.height;\n return height < mid ? this.left.blockAt(height, oracle, top, offset)\n : this.right.blockAt(height, oracle, mid, offset + this.left.length + this.break);\n }\n lineAt(value, type, oracle, top, offset) {\n let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;\n let left = type == QueryType.ByHeight ? value < rightTop : value < rightOffset;\n let base = left ? this.left.lineAt(value, type, oracle, top, offset)\n : this.right.lineAt(value, type, oracle, rightTop, rightOffset);\n if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))\n return base;\n let subQuery = type == QueryType.ByPosNoHeight ? QueryType.ByPosNoHeight : QueryType.ByPos;\n if (left)\n return base.join(this.right.lineAt(rightOffset, subQuery, oracle, rightTop, rightOffset));\n else\n return this.left.lineAt(rightOffset, subQuery, oracle, top, offset).join(base);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;\n if (this.break) {\n if (from < rightOffset)\n this.left.forEachLine(from, to, oracle, top, offset, f);\n if (to >= rightOffset)\n this.right.forEachLine(from, to, oracle, rightTop, rightOffset, f);\n }\n else {\n let mid = this.lineAt(rightOffset, QueryType.ByPos, oracle, top, offset);\n if (from < mid.from)\n this.left.forEachLine(from, mid.from - 1, oracle, top, offset, f);\n if (mid.to >= from && mid.from <= to)\n f(mid);\n if (to > mid.to)\n this.right.forEachLine(mid.to + 1, to, oracle, rightTop, rightOffset, f);\n }\n }\n replace(from, to, nodes) {\n let rightStart = this.left.length + this.break;\n if (to < rightStart)\n return this.balanced(this.left.replace(from, to, nodes), this.right);\n if (from > this.left.length)\n return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));\n let result = [];\n if (from > 0)\n this.decomposeLeft(from, result);\n let left = result.length;\n for (let node of nodes)\n result.push(node);\n if (from > 0)\n mergeGaps(result, left - 1);\n if (to < this.length) {\n let right = result.length;\n this.decomposeRight(to, result);\n mergeGaps(result, right);\n }\n return HeightMap.of(result);\n }\n decomposeLeft(to, result) {\n let left = this.left.length;\n if (to <= left)\n return this.left.decomposeLeft(to, result);\n result.push(this.left);\n if (this.break) {\n left++;\n if (to >= left)\n result.push(null);\n }\n if (to > left)\n this.right.decomposeLeft(to - left, result);\n }\n decomposeRight(from, result) {\n let left = this.left.length, right = left + this.break;\n if (from >= right)\n return this.right.decomposeRight(from - right, result);\n if (from < left)\n this.left.decomposeRight(from, result);\n if (this.break && from < right)\n result.push(null);\n result.push(this.right);\n }\n balanced(left, right) {\n if (left.size > 2 * right.size || right.size > 2 * left.size)\n return HeightMap.of(this.break ? [left, null, right] : [left, right]);\n this.left = left;\n this.right = right;\n this.height = left.height + right.height;\n this.outdated = left.outdated || right.outdated;\n this.size = left.size + right.size;\n this.length = left.length + this.break + right.length;\n return this;\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;\n if (measured && measured.from <= offset + left.length && measured.more)\n rebalance = left = left.updateHeight(oracle, offset, force, measured);\n else\n left.updateHeight(oracle, offset, force);\n if (measured && measured.from <= rightStart + right.length && measured.more)\n rebalance = right = right.updateHeight(oracle, rightStart, force, measured);\n else\n right.updateHeight(oracle, rightStart, force);\n if (rebalance)\n return this.balanced(left, right);\n this.height = this.left.height + this.right.height;\n this.outdated = false;\n return this;\n }\n toString() { return this.left + (this.break ? \" \" : \"-\") + this.right; }\n}\nfunction mergeGaps(nodes, around) {\n let before, after;\n if (nodes[around] == null &&\n (before = nodes[around - 1]) instanceof HeightMapGap &&\n (after = nodes[around + 1]) instanceof HeightMapGap)\n nodes.splice(around - 1, 3, new HeightMapGap(before.length + 1 + after.length));\n}\nconst relevantWidgetHeight = 5;\nclass NodeBuilder {\n constructor(pos, oracle) {\n this.pos = pos;\n this.oracle = oracle;\n this.nodes = [];\n this.lineStart = -1;\n this.lineEnd = -1;\n this.covering = null;\n this.writtenTo = pos;\n }\n get isCovered() {\n return this.covering && this.nodes[this.nodes.length - 1] == this.covering;\n }\n span(_from, to) {\n if (this.lineStart > -1) {\n let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];\n if (last instanceof HeightMapText)\n last.length += end - this.pos;\n else if (end > this.pos || !this.isCovered)\n this.nodes.push(new HeightMapText(end - this.pos, -1));\n this.writtenTo = end;\n if (to > end) {\n this.nodes.push(null);\n this.writtenTo++;\n this.lineStart = -1;\n }\n }\n this.pos = to;\n }\n point(from, to, deco) {\n if (from < to || deco.heightRelevant) {\n let height = deco.widget ? deco.widget.estimatedHeight : 0;\n let breaks = deco.widget ? deco.widget.lineBreaks : 0;\n if (height < 0)\n height = this.oracle.lineHeight;\n let len = to - from;\n if (deco.block) {\n this.addBlock(new HeightMapBlock(len, height, deco));\n }\n else if (len || breaks || height >= relevantWidgetHeight) {\n this.addLineDeco(height, breaks, len);\n }\n }\n else if (to > from) {\n this.span(from, to);\n }\n if (this.lineEnd > -1 && this.lineEnd < this.pos)\n this.lineEnd = this.oracle.doc.lineAt(this.pos).to;\n }\n enterLine() {\n if (this.lineStart > -1)\n return;\n let { from, to } = this.oracle.doc.lineAt(this.pos);\n this.lineStart = from;\n this.lineEnd = to;\n if (this.writtenTo < from) {\n if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)\n this.nodes.push(this.blankContent(this.writtenTo, from - 1));\n this.nodes.push(null);\n }\n if (this.pos > from)\n this.nodes.push(new HeightMapText(this.pos - from, -1));\n this.writtenTo = this.pos;\n }\n blankContent(from, to) {\n let gap = new HeightMapGap(to - from);\n if (this.oracle.doc.lineAt(from).to == to)\n gap.flags |= 4 /* Flag.SingleLine */;\n return gap;\n }\n ensureLine() {\n this.enterLine();\n let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;\n if (last instanceof HeightMapText)\n return last;\n let line = new HeightMapText(0, -1);\n this.nodes.push(line);\n return line;\n }\n addBlock(block) {\n this.enterLine();\n let deco = block.deco;\n if (deco && deco.startSide > 0 && !this.isCovered)\n this.ensureLine();\n this.nodes.push(block);\n this.writtenTo = this.pos = this.pos + block.length;\n if (deco && deco.endSide > 0)\n this.covering = block;\n }\n addLineDeco(height, breaks, length) {\n let line = this.ensureLine();\n line.length += length;\n line.collapsed += length;\n line.widgetHeight = Math.max(line.widgetHeight, height);\n line.breaks += breaks;\n this.writtenTo = this.pos = this.pos + length;\n }\n finish(from) {\n let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];\n if (this.lineStart > -1 && !(last instanceof HeightMapText) && !this.isCovered)\n this.nodes.push(new HeightMapText(0, -1));\n else if (this.writtenTo < this.pos || last == null)\n this.nodes.push(this.blankContent(this.writtenTo, this.pos));\n let pos = from;\n for (let node of this.nodes) {\n if (node instanceof HeightMapText)\n node.updateHeight(this.oracle, pos);\n pos += node ? node.length : 1;\n }\n return this.nodes;\n }\n // Always called with a region that on both sides either stretches\n // to a line break or the end of the document.\n // The returned array uses null to indicate line breaks, but never\n // starts or ends in a line break, or has multiple line breaks next\n // to each other.\n static build(oracle, decorations, from, to) {\n let builder = new NodeBuilder(from, oracle);\n RangeSet.spans(decorations, from, to, builder, 0);\n return builder.finish(from);\n }\n}\nfunction heightRelevantDecoChanges(a, b, diff) {\n let comp = new DecorationComparator;\n RangeSet.compare(a, b, diff, comp, 0);\n return comp.changes;\n}\nclass DecorationComparator {\n constructor() {\n this.changes = [];\n }\n compareRange() { }\n comparePoint(from, to, a, b) {\n if (from < to || a && a.heightRelevant || b && b.heightRelevant)\n addRange(from, to, this.changes, 5);\n }\n}\n\nfunction visiblePixelRange(dom, paddingTop) {\n let rect = dom.getBoundingClientRect();\n let doc = dom.ownerDocument, win = doc.defaultView || window;\n let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);\n let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);\n for (let parent = dom.parentNode; parent && parent != doc.body;) {\n if (parent.nodeType == 1) {\n let elt = parent;\n let style = window.getComputedStyle(elt);\n if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&\n style.overflow != \"visible\") {\n let parentRect = elt.getBoundingClientRect();\n left = Math.max(left, parentRect.left);\n right = Math.min(right, parentRect.right);\n top = Math.max(top, parentRect.top);\n bottom = parent == dom.parentNode ? parentRect.bottom : Math.min(bottom, parentRect.bottom);\n }\n parent = style.position == \"absolute\" || style.position == \"fixed\" ? elt.offsetParent : elt.parentNode;\n }\n else if (parent.nodeType == 11) { // Shadow root\n parent = parent.host;\n }\n else {\n break;\n }\n }\n return { left: left - rect.left, right: Math.max(left, right) - rect.left,\n top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };\n}\nfunction fullPixelRange(dom, paddingTop) {\n let rect = dom.getBoundingClientRect();\n return { left: 0, right: rect.right - rect.left,\n top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };\n}\n// Line gaps are placeholder widgets used to hide pieces of overlong\n// lines within the viewport, as a kludge to keep the editor\n// responsive when a ridiculously long line is loaded into it.\nclass LineGap {\n constructor(from, to, size) {\n this.from = from;\n this.to = to;\n this.size = size;\n }\n static same(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n let gA = a[i], gB = b[i];\n if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)\n return false;\n }\n return true;\n }\n draw(viewState, wrapping) {\n return Decoration.replace({\n widget: new LineGapWidget(this.size * (wrapping ? viewState.scaleY : viewState.scaleX), wrapping)\n }).range(this.from, this.to);\n }\n}\nclass LineGapWidget extends WidgetType {\n constructor(size, vertical) {\n super();\n this.size = size;\n this.vertical = vertical;\n }\n eq(other) { return other.size == this.size && other.vertical == this.vertical; }\n toDOM() {\n let elt = document.createElement(\"div\");\n if (this.vertical) {\n elt.style.height = this.size + \"px\";\n }\n else {\n elt.style.width = this.size + \"px\";\n elt.style.height = \"2px\";\n elt.style.display = \"inline-block\";\n }\n return elt;\n }\n get estimatedHeight() { return this.vertical ? this.size : -1; }\n}\nclass ViewState {\n constructor(state) {\n this.state = state;\n // These are contentDOM-local coordinates\n this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };\n this.inView = true;\n this.paddingTop = 0; // Padding above the document, scaled\n this.paddingBottom = 0; // Padding below the document, scaled\n this.contentDOMWidth = 0; // contentDOM.getBoundingClientRect().width\n this.contentDOMHeight = 0; // contentDOM.getBoundingClientRect().height\n this.editorHeight = 0; // scrollDOM.clientHeight, unscaled\n this.editorWidth = 0; // scrollDOM.clientWidth, unscaled\n this.scrollTop = 0; // Last seen scrollDOM.scrollTop, scaled\n this.scrolledToBottom = true;\n // The CSS-transformation scale of the editor (transformed size /\n // concrete size)\n this.scaleX = 1;\n this.scaleY = 1;\n // The vertical position (document-relative) to which to anchor the\n // scroll position. -1 means anchor to the end of the document.\n this.scrollAnchorPos = 0;\n // The height at the anchor position. Set by the DOM update phase.\n // -1 means no height available.\n this.scrollAnchorHeight = -1;\n // See VP.MaxDOMHeight\n this.scaler = IdScaler;\n this.scrollTarget = null;\n // Briefly set to true when printing, to disable viewport limiting\n this.printing = false;\n // Flag set when editor content was redrawn, so that the next\n // measure stage knows it must read DOM layout\n this.mustMeasureContent = true;\n this.defaultTextDirection = Direction.LTR;\n this.visibleRanges = [];\n // Cursor 'assoc' is only significant when the cursor is on a line\n // wrap point, where it must stick to the character that it is\n // associated with. Since browsers don't provide a reasonable\n // interface to set or query this, when a selection is set that\n // might cause this to be significant, this flag is set. The next\n // measure phase will check whether the cursor is on a line-wrapping\n // boundary and, if so, reset it to make sure it is positioned in\n // the right place.\n this.mustEnforceCursorAssoc = false;\n let guessWrapping = state.facet(contentAttributes).some(v => typeof v != \"function\" && v.class == \"cm-lineWrapping\");\n this.heightOracle = new HeightOracle(guessWrapping);\n this.stateDeco = state.facet(decorations).filter(d => typeof d != \"function\");\n this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);\n this.viewport = this.getViewport(0, null);\n this.updateViewportLines();\n this.updateForViewport();\n this.lineGaps = this.ensureLineGaps([]);\n this.lineGapDeco = Decoration.set(this.lineGaps.map(gap => gap.draw(this, false)));\n this.computeVisibleRanges();\n }\n updateForViewport() {\n let viewports = [this.viewport], { main } = this.state.selection;\n for (let i = 0; i <= 1; i++) {\n let pos = i ? main.head : main.anchor;\n if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {\n let { from, to } = this.lineBlockAt(pos);\n viewports.push(new Viewport(from, to));\n }\n }\n this.viewports = viewports.sort((a, b) => a.from - b.from);\n this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :\n new BigScaler(this.heightOracle, this.heightMap, this.viewports);\n }\n updateViewportLines() {\n this.viewportLines = [];\n this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, block => {\n this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock(block, this.scaler));\n });\n }\n update(update, scrollTarget = null) {\n this.state = update.state;\n let prevDeco = this.stateDeco;\n this.stateDeco = this.state.facet(decorations).filter(d => typeof d != \"function\");\n let contentChanges = update.changedRanges;\n let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));\n let prevHeight = this.heightMap.height;\n let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);\n this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);\n if (this.heightMap.height != prevHeight)\n update.flags |= 2 /* UpdateFlag.Height */;\n if (scrollAnchor) {\n this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);\n this.scrollAnchorHeight = scrollAnchor.top;\n }\n else {\n this.scrollAnchorPos = -1;\n this.scrollAnchorHeight = this.heightMap.height;\n }\n let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;\n if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||\n !this.viewportIsAppropriate(viewport))\n viewport = this.getViewport(0, scrollTarget);\n let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||\n viewport.from != this.viewport.from || viewport.to != this.viewport.to;\n this.viewport = viewport;\n this.updateForViewport();\n if (updateLines)\n this.updateViewportLines();\n if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))\n this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));\n update.flags |= this.computeVisibleRanges();\n if (scrollTarget)\n this.scrollTarget = scrollTarget;\n if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&\n update.state.selection.main.empty && update.state.selection.main.assoc &&\n !update.state.facet(nativeSelectionHidden))\n this.mustEnforceCursorAssoc = true;\n }\n measure(view) {\n let dom = view.contentDOM, style = window.getComputedStyle(dom);\n let oracle = this.heightOracle;\n let whiteSpace = style.whiteSpace;\n this.defaultTextDirection = style.direction == \"rtl\" ? Direction.RTL : Direction.LTR;\n let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);\n let domRect = dom.getBoundingClientRect();\n let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != domRect.height;\n this.contentDOMHeight = domRect.height;\n this.mustMeasureContent = false;\n let result = 0, bias = 0;\n if (domRect.width && domRect.height) {\n let { scaleX, scaleY } = getScale(dom, domRect);\n if (this.scaleX != scaleX || this.scaleY != scaleY) {\n this.scaleX = scaleX;\n this.scaleY = scaleY;\n result |= 8 /* UpdateFlag.Geometry */;\n refresh = measureContent = true;\n }\n }\n // Vertical padding\n let paddingTop = (parseInt(style.paddingTop) || 0) * this.scaleY;\n let paddingBottom = (parseInt(style.paddingBottom) || 0) * this.scaleY;\n if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {\n this.paddingTop = paddingTop;\n this.paddingBottom = paddingBottom;\n result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;\n }\n if (this.editorWidth != view.scrollDOM.clientWidth) {\n if (oracle.lineWrapping)\n measureContent = true;\n this.editorWidth = view.scrollDOM.clientWidth;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n let scrollTop = view.scrollDOM.scrollTop * this.scaleY;\n if (this.scrollTop != scrollTop) {\n this.scrollAnchorHeight = -1;\n this.scrollTop = scrollTop;\n }\n this.scrolledToBottom = isScrolledToBottom(view.scrollDOM);\n // Pixel viewport\n let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);\n let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;\n this.pixelViewport = pixelViewport;\n let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;\n if (inView != this.inView) {\n this.inView = inView;\n if (inView)\n measureContent = true;\n }\n if (!this.inView && !this.scrollTarget)\n return 0;\n let contentWidth = domRect.width;\n if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {\n this.contentDOMWidth = domRect.width;\n this.editorHeight = view.scrollDOM.clientHeight;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n if (measureContent) {\n let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);\n if (oracle.mustRefreshForHeights(lineHeights))\n refresh = true;\n if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {\n let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();\n refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);\n if (refresh) {\n view.docView.minWidth = 0;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n }\n if (dTop > 0 && dBottom > 0)\n bias = Math.max(dTop, dBottom);\n else if (dTop < 0 && dBottom < 0)\n bias = Math.min(dTop, dBottom);\n oracle.heightChanged = false;\n for (let vp of this.viewports) {\n let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);\n 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));\n }\n if (oracle.heightChanged)\n result |= 2 /* UpdateFlag.Height */;\n }\n let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||\n this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||\n this.scrollTarget.range.head > this.viewport.to);\n if (viewportChange)\n this.viewport = this.getViewport(bias, this.scrollTarget);\n this.updateForViewport();\n if ((result & 2 /* UpdateFlag.Height */) || viewportChange)\n this.updateViewportLines();\n if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))\n this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));\n result |= this.computeVisibleRanges();\n if (this.mustEnforceCursorAssoc) {\n this.mustEnforceCursorAssoc = false;\n // This is done in the read stage, because moving the selection\n // to a line end is going to trigger a layout anyway, so it\n // can't be a pure write. It should be rare that it does any\n // writing.\n view.docView.enforceCursorAssoc();\n }\n return result;\n }\n get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }\n get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }\n getViewport(bias, scrollTarget) {\n // This will divide VP.Margin between the top and the\n // bottom, depending on the bias (the change in viewport position\n // since the last update). It'll hold a number between 0 and 1\n let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));\n let map = this.heightMap, oracle = this.heightOracle;\n let { visibleTop, visibleBottom } = this;\n 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);\n // If scrollTarget is given, make sure the viewport includes that position\n if (scrollTarget) {\n let { head } = scrollTarget.range;\n if (head < viewport.from || head > viewport.to) {\n let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);\n let block = map.lineAt(head, QueryType.ByPos, oracle, 0, 0), topPos;\n if (scrollTarget.y == \"center\")\n topPos = (block.top + block.bottom) / 2 - viewHeight / 2;\n else if (scrollTarget.y == \"start\" || scrollTarget.y == \"nearest\" && head < viewport.from)\n topPos = block.top;\n else\n topPos = block.bottom - viewHeight;\n 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);\n }\n }\n return viewport;\n }\n mapViewport(viewport, changes) {\n let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);\n 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);\n }\n // Checks if a given viewport covers the visible part of the\n // document and not too much beyond that.\n viewportIsAppropriate({ from, to }, bias = 0) {\n if (!this.inView)\n return true;\n let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);\n let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);\n let { visibleTop, visibleBottom } = this;\n return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&\n (to == this.state.doc.length ||\n bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&\n (top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);\n }\n mapLineGaps(gaps, changes) {\n if (!gaps.length || changes.empty)\n return gaps;\n let mapped = [];\n for (let gap of gaps)\n if (!changes.touchesRange(gap.from, gap.to))\n mapped.push(new LineGap(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));\n return mapped;\n }\n // Computes positions in the viewport where the start or end of a\n // line should be hidden, trying to reuse existing line gaps when\n // appropriate to avoid unneccesary redraws.\n // Uses crude character-counting for the positioning and sizing,\n // since actual DOM coordinates aren't always available and\n // predictable. Relies on generous margins (see LG.Margin) to hide\n // the artifacts this might produce from the user.\n ensureLineGaps(current, mayMeasure) {\n let wrapping = this.heightOracle.lineWrapping;\n let margin = wrapping ? 10000 /* LG.MarginWrap */ : 2000 /* LG.Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;\n // The non-wrapping logic won't work at all in predominantly right-to-left text.\n if (this.defaultTextDirection != Direction.LTR && !wrapping)\n return [];\n let gaps = [];\n let addGap = (from, to, line, structure) => {\n if (to - from < halfMargin)\n return;\n let sel = this.state.selection.main, avoid = [sel.from];\n if (!sel.empty)\n avoid.push(sel.to);\n for (let pos of avoid) {\n if (pos > from && pos < to) {\n addGap(from, pos - 10 /* LG.SelectionMargin */, line, structure);\n addGap(pos + 10 /* LG.SelectionMargin */, to, line, structure);\n return;\n }\n }\n let gap = find(current, gap => gap.from >= line.from && gap.to <= line.to &&\n Math.abs(gap.from - from) < halfMargin && Math.abs(gap.to - to) < halfMargin &&\n !avoid.some(pos => gap.from < pos && gap.to > pos));\n if (!gap) {\n // When scrolling down, snap gap ends to line starts to avoid shifts in wrapping\n if (to < line.to && mayMeasure && wrapping &&\n mayMeasure.visibleRanges.some(r => r.from <= to && r.to >= to)) {\n let lineStart = mayMeasure.moveToLineBoundary(EditorSelection.cursor(to), false, true).head;\n if (lineStart > from)\n to = lineStart;\n }\n gap = new LineGap(from, to, this.gapSize(line, from, to, structure));\n }\n gaps.push(gap);\n };\n for (let line of this.viewportLines) {\n if (line.length < doubleMargin)\n continue;\n let structure = lineStructure(line.from, line.to, this.stateDeco);\n if (structure.total < doubleMargin)\n continue;\n let target = this.scrollTarget ? this.scrollTarget.range.head : null;\n let viewFrom, viewTo;\n if (wrapping) {\n let marginHeight = (margin / this.heightOracle.lineLength) * this.heightOracle.lineHeight;\n let top, bot;\n if (target != null) {\n let targetFrac = findFraction(structure, target);\n let spaceFrac = ((this.visibleBottom - this.visibleTop) / 2 + marginHeight) / line.height;\n top = targetFrac - spaceFrac;\n bot = targetFrac + spaceFrac;\n }\n else {\n top = (this.visibleTop - line.top - marginHeight) / line.height;\n bot = (this.visibleBottom - line.top + marginHeight) / line.height;\n }\n viewFrom = findPosition(structure, top);\n viewTo = findPosition(structure, bot);\n }\n else {\n let totalWidth = structure.total * this.heightOracle.charWidth;\n let marginWidth = margin * this.heightOracle.charWidth;\n let left, right;\n if (target != null) {\n let targetFrac = findFraction(structure, target);\n let spaceFrac = ((this.pixelViewport.right - this.pixelViewport.left) / 2 + marginWidth) / totalWidth;\n left = targetFrac - spaceFrac;\n right = targetFrac + spaceFrac;\n }\n else {\n left = (this.pixelViewport.left - marginWidth) / totalWidth;\n right = (this.pixelViewport.right + marginWidth) / totalWidth;\n }\n viewFrom = findPosition(structure, left);\n viewTo = findPosition(structure, right);\n }\n if (viewFrom > line.from)\n addGap(line.from, viewFrom, line, structure);\n if (viewTo < line.to)\n addGap(viewTo, line.to, line, structure);\n }\n return gaps;\n }\n gapSize(line, from, to, structure) {\n let fraction = findFraction(structure, to) - findFraction(structure, from);\n if (this.heightOracle.lineWrapping) {\n return line.height * fraction;\n }\n else {\n return structure.total * this.heightOracle.charWidth * fraction;\n }\n }\n updateLineGaps(gaps) {\n if (!LineGap.same(gaps, this.lineGaps)) {\n this.lineGaps = gaps;\n this.lineGapDeco = Decoration.set(gaps.map(gap => gap.draw(this, this.heightOracle.lineWrapping)));\n }\n }\n computeVisibleRanges() {\n let deco = this.stateDeco;\n if (this.lineGaps.length)\n deco = deco.concat(this.lineGapDeco);\n let ranges = [];\n RangeSet.spans(deco, this.viewport.from, this.viewport.to, {\n span(from, to) { ranges.push({ from, to }); },\n point() { }\n }, 20);\n let changed = ranges.length != this.visibleRanges.length ||\n this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);\n this.visibleRanges = ranges;\n return changed ? 4 /* UpdateFlag.Viewport */ : 0;\n }\n lineBlockAt(pos) {\n return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||\n scaleBlock(this.heightMap.lineAt(pos, QueryType.ByPos, this.heightOracle, 0, 0), this.scaler);\n }\n lineBlockAtHeight(height) {\n return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.heightOracle, 0, 0), this.scaler);\n }\n scrollAnchorAt(scrollTop) {\n let block = this.lineBlockAtHeight(scrollTop + 8);\n return block.from >= this.viewport.from || this.viewportLines[0].top - scrollTop > 200 ? block : this.viewportLines[0];\n }\n elementAtHeight(height) {\n return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.heightOracle, 0, 0), this.scaler);\n }\n get docHeight() {\n return this.scaler.toDOM(this.heightMap.height);\n }\n get contentHeight() {\n return this.docHeight + this.paddingTop + this.paddingBottom;\n }\n}\nclass Viewport {\n constructor(from, to) {\n this.from = from;\n this.to = to;\n }\n}\nfunction lineStructure(from, to, stateDeco) {\n let ranges = [], pos = from, total = 0;\n RangeSet.spans(stateDeco, from, to, {\n span() { },\n point(from, to) {\n if (from > pos) {\n ranges.push({ from: pos, to: from });\n total += from - pos;\n }\n pos = to;\n }\n }, 20); // We're only interested in collapsed ranges of a significant size\n if (pos < to) {\n ranges.push({ from: pos, to });\n total += to - pos;\n }\n return { total, ranges };\n}\nfunction findPosition({ total, ranges }, ratio) {\n if (ratio <= 0)\n return ranges[0].from;\n if (ratio >= 1)\n return ranges[ranges.length - 1].to;\n let dist = Math.floor(total * ratio);\n for (let i = 0;; i++) {\n let { from, to } = ranges[i], size = to - from;\n if (dist <= size)\n return from + dist;\n dist -= size;\n }\n}\nfunction findFraction(structure, pos) {\n let counted = 0;\n for (let { from, to } of structure.ranges) {\n if (pos <= to) {\n counted += pos - from;\n break;\n }\n counted += to - from;\n }\n return counted / structure.total;\n}\nfunction find(array, f) {\n for (let val of array)\n if (f(val))\n return val;\n return undefined;\n}\n// Don't scale when the document height is within the range of what\n// the DOM can handle.\nconst IdScaler = {\n toDOM(n) { return n; },\n fromDOM(n) { return n; },\n scale: 1\n};\n// When the height is too big (> VP.MaxDOMHeight), scale down the\n// regions outside the viewports so that the total height is\n// VP.MaxDOMHeight.\nclass BigScaler {\n constructor(oracle, heightMap, viewports) {\n let vpHeight = 0, base = 0, domBase = 0;\n this.viewports = viewports.map(({ from, to }) => {\n let top = heightMap.lineAt(from, QueryType.ByPos, oracle, 0, 0).top;\n let bottom = heightMap.lineAt(to, QueryType.ByPos, oracle, 0, 0).bottom;\n vpHeight += bottom - top;\n return { from, to, top, bottom, domTop: 0, domBottom: 0 };\n });\n this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);\n for (let obj of this.viewports) {\n obj.domTop = domBase + (obj.top - base) * this.scale;\n domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);\n base = obj.bottom;\n }\n }\n toDOM(n) {\n for (let i = 0, base = 0, domBase = 0;; i++) {\n let vp = i < this.viewports.length ? this.viewports[i] : null;\n if (!vp || n < vp.top)\n return domBase + (n - base) * this.scale;\n if (n <= vp.bottom)\n return vp.domTop + (n - vp.top);\n base = vp.bottom;\n domBase = vp.domBottom;\n }\n }\n fromDOM(n) {\n for (let i = 0, base = 0, domBase = 0;; i++) {\n let vp = i < this.viewports.length ? this.viewports[i] : null;\n if (!vp || n < vp.domTop)\n return base + (n - domBase) / this.scale;\n if (n <= vp.domBottom)\n return vp.top + (n - vp.domTop);\n base = vp.bottom;\n domBase = vp.domBottom;\n }\n }\n}\nfunction scaleBlock(block, scaler) {\n if (scaler.scale == 1)\n return block;\n let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);\n return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);\n}\n\nconst theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(\" \") });\nconst darkTheme = /*@__PURE__*/Facet.define({ combine: values => values.indexOf(true) > -1 });\nconst baseThemeID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();\nconst lightDarkIDs = { \"&light\": \".\" + baseLightID, \"&dark\": \".\" + baseDarkID };\nfunction buildTheme(main, spec, scopes) {\n return new StyleModule(spec, {\n finish(sel) {\n return /&/.test(sel) ? sel.replace(/&\\w*/, m => {\n if (m == \"&\")\n return main;\n if (!scopes || !scopes[m])\n throw new RangeError(`Unsupported selector: ${m}`);\n return scopes[m];\n }) : main + \" \" + sel;\n }\n });\n}\nconst baseTheme$1 = /*@__PURE__*/buildTheme(\".\" + baseThemeID, {\n \"&\": {\n position: \"relative !important\",\n boxSizing: \"border-box\",\n \"&.cm-focused\": {\n // Provide a simple default outline to make sure a focused\n // editor is visually distinct. Can't leave the default behavior\n // because that will apply to the content element, which is\n // inside the scrollable container and doesn't include the\n // gutters. We also can't use an 'auto' outline, since those\n // are, for some reason, drawn behind the element content, which\n // will cause things like the active line background to cover\n // the outline (#297).\n outline: \"1px dotted #212121\"\n },\n display: \"flex !important\",\n flexDirection: \"column\"\n },\n \".cm-scroller\": {\n display: \"flex !important\",\n alignItems: \"flex-start !important\",\n fontFamily: \"monospace\",\n lineHeight: 1.4,\n height: \"100%\",\n overflowX: \"auto\",\n position: \"relative\",\n zIndex: 0\n },\n \".cm-content\": {\n margin: 0,\n flexGrow: 2,\n flexShrink: 0,\n display: \"block\",\n whiteSpace: \"pre\",\n wordWrap: \"normal\",\n boxSizing: \"border-box\",\n minHeight: \"100%\",\n padding: \"4px 0\",\n outline: \"none\",\n \"&[contenteditable=true]\": {\n WebkitUserModify: \"read-write-plaintext-only\",\n }\n },\n \".cm-lineWrapping\": {\n whiteSpace_fallback: \"pre-wrap\",\n whiteSpace: \"break-spaces\",\n wordBreak: \"break-word\",\n overflowWrap: \"anywhere\",\n flexShrink: 1\n },\n \"&light .cm-content\": { caretColor: \"black\" },\n \"&dark .cm-content\": { caretColor: \"white\" },\n \".cm-line\": {\n display: \"block\",\n padding: \"0 2px 0 6px\"\n },\n \".cm-layer\": {\n position: \"absolute\",\n left: 0,\n top: 0,\n contain: \"size style\",\n \"& > *\": {\n position: \"absolute\"\n }\n },\n \"&light .cm-selectionBackground\": {\n background: \"#d9d9d9\"\n },\n \"&dark .cm-selectionBackground\": {\n background: \"#222\"\n },\n \"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground\": {\n background: \"#d7d4f0\"\n },\n \"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground\": {\n background: \"#233\"\n },\n \".cm-cursorLayer\": {\n pointerEvents: \"none\"\n },\n \"&.cm-focused > .cm-scroller > .cm-cursorLayer\": {\n animation: \"steps(1) cm-blink 1.2s infinite\"\n },\n // Two animations defined so that we can switch between them to\n // restart the animation without forcing another style\n // recomputation.\n \"@keyframes cm-blink\": { \"0%\": {}, \"50%\": { opacity: 0 }, \"100%\": {} },\n \"@keyframes cm-blink2\": { \"0%\": {}, \"50%\": { opacity: 0 }, \"100%\": {} },\n \".cm-cursor, .cm-dropCursor\": {\n borderLeft: \"1.2px solid black\",\n marginLeft: \"-0.6px\",\n pointerEvents: \"none\",\n },\n \".cm-cursor\": {\n display: \"none\"\n },\n \"&dark .cm-cursor\": {\n borderLeftColor: \"#444\"\n },\n \".cm-dropCursor\": {\n position: \"absolute\"\n },\n \"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor\": {\n display: \"block\"\n },\n \".cm-announced\": {\n position: \"fixed\",\n top: \"-10000px\"\n },\n \"@media print\": {\n \".cm-announced\": { display: \"none\" }\n },\n \"&light .cm-activeLine\": { backgroundColor: \"#cceeff44\" },\n \"&dark .cm-activeLine\": { backgroundColor: \"#99eeff33\" },\n \"&light .cm-specialChar\": { color: \"red\" },\n \"&dark .cm-specialChar\": { color: \"#f78\" },\n \".cm-gutters\": {\n flexShrink: 0,\n display: \"flex\",\n height: \"100%\",\n boxSizing: \"border-box\",\n insetInlineStart: 0,\n zIndex: 200\n },\n \"&light .cm-gutters\": {\n backgroundColor: \"#f5f5f5\",\n color: \"#6c6c6c\",\n borderRight: \"1px solid #ddd\"\n },\n \"&dark .cm-gutters\": {\n backgroundColor: \"#333338\",\n color: \"#ccc\"\n },\n \".cm-gutter\": {\n display: \"flex !important\",\n flexDirection: \"column\",\n flexShrink: 0,\n boxSizing: \"border-box\",\n minHeight: \"100%\",\n overflow: \"hidden\"\n },\n \".cm-gutterElement\": {\n boxSizing: \"border-box\"\n },\n \".cm-lineNumbers .cm-gutterElement\": {\n padding: \"0 3px 0 5px\",\n minWidth: \"20px\",\n textAlign: \"right\",\n whiteSpace: \"nowrap\"\n },\n \"&light .cm-activeLineGutter\": {\n backgroundColor: \"#e2f2ff\"\n },\n \"&dark .cm-activeLineGutter\": {\n backgroundColor: \"#222227\"\n },\n \".cm-panels\": {\n boxSizing: \"border-box\",\n position: \"sticky\",\n left: 0,\n right: 0\n },\n \"&light .cm-panels\": {\n backgroundColor: \"#f5f5f5\",\n color: \"black\"\n },\n \"&light .cm-panels-top\": {\n borderBottom: \"1px solid #ddd\"\n },\n \"&light .cm-panels-bottom\": {\n borderTop: \"1px solid #ddd\"\n },\n \"&dark .cm-panels\": {\n backgroundColor: \"#333338\",\n color: \"white\"\n },\n \".cm-tab\": {\n display: \"inline-block\",\n overflow: \"hidden\",\n verticalAlign: \"bottom\"\n },\n \".cm-widgetBuffer\": {\n verticalAlign: \"text-top\",\n height: \"1em\",\n width: 0,\n display: \"inline\"\n },\n \".cm-placeholder\": {\n color: \"#888\",\n display: \"inline-block\",\n verticalAlign: \"top\",\n },\n \".cm-highlightSpace:before\": {\n content: \"attr(data-display)\",\n position: \"absolute\",\n pointerEvents: \"none\",\n color: \"#888\"\n },\n \".cm-highlightTab\": {\n 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>')`,\n backgroundSize: \"auto 100%\",\n backgroundPosition: \"right 90%\",\n backgroundRepeat: \"no-repeat\"\n },\n \".cm-trailingSpace\": {\n backgroundColor: \"#ff332255\"\n },\n \".cm-button\": {\n verticalAlign: \"middle\",\n color: \"inherit\",\n fontSize: \"70%\",\n padding: \".2em 1em\",\n borderRadius: \"1px\"\n },\n \"&light .cm-button\": {\n backgroundImage: \"linear-gradient(#eff1f5, #d9d9df)\",\n border: \"1px solid #888\",\n \"&:active\": {\n backgroundImage: \"linear-gradient(#b4b4b4, #d0d3d6)\"\n }\n },\n \"&dark .cm-button\": {\n backgroundImage: \"linear-gradient(#393939, #111)\",\n border: \"1px solid #888\",\n \"&:active\": {\n backgroundImage: \"linear-gradient(#111, #333)\"\n }\n },\n \".cm-textfield\": {\n verticalAlign: \"middle\",\n color: \"inherit\",\n fontSize: \"70%\",\n border: \"1px solid silver\",\n padding: \".2em .5em\"\n },\n \"&light .cm-textfield\": {\n backgroundColor: \"white\"\n },\n \"&dark .cm-textfield\": {\n border: \"1px solid #555\",\n backgroundColor: \"inherit\"\n }\n}, lightDarkIDs);\n\nconst LineBreakPlaceholder = \"\\uffff\";\nclass DOMReader {\n constructor(points, state) {\n this.points = points;\n this.text = \"\";\n this.lineSeparator = state.facet(EditorState.lineSeparator);\n }\n append(text) {\n this.text += text;\n }\n lineBreak() {\n this.text += LineBreakPlaceholder;\n }\n readRange(start, end) {\n if (!start)\n return this;\n let parent = start.parentNode;\n for (let cur = start;;) {\n this.findPointBefore(parent, cur);\n let oldLen = this.text.length;\n this.readNode(cur);\n let next = cur.nextSibling;\n if (next == end)\n break;\n let view = ContentView.get(cur), nextView = ContentView.get(next);\n if (view && nextView ? view.breakAfter :\n (view ? view.breakAfter : isBlockElement(cur)) ||\n (isBlockElement(next) && (cur.nodeName != \"BR\" || cur.cmIgnore) && this.text.length > oldLen))\n this.lineBreak();\n cur = next;\n }\n this.findPointBefore(parent, end);\n return this;\n }\n readTextNode(node) {\n let text = node.nodeValue;\n for (let point of this.points)\n if (point.node == node)\n point.pos = this.text.length + Math.min(point.offset, text.length);\n for (let off = 0, re = this.lineSeparator ? null : /\\r\\n?|\\n/g;;) {\n let nextBreak = -1, breakSize = 1, m;\n if (this.lineSeparator) {\n nextBreak = text.indexOf(this.lineSeparator, off);\n breakSize = this.lineSeparator.length;\n }\n else if (m = re.exec(text)) {\n nextBreak = m.index;\n breakSize = m[0].length;\n }\n this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));\n if (nextBreak < 0)\n break;\n this.lineBreak();\n if (breakSize > 1)\n for (let point of this.points)\n if (point.node == node && point.pos > this.text.length)\n point.pos -= breakSize - 1;\n off = nextBreak + breakSize;\n }\n }\n readNode(node) {\n if (node.cmIgnore)\n return;\n let view = ContentView.get(node);\n let fromView = view && view.overrideDOMText;\n if (fromView != null) {\n this.findPointInside(node, fromView.length);\n for (let i = fromView.iter(); !i.next().done;) {\n if (i.lineBreak)\n this.lineBreak();\n else\n this.append(i.value);\n }\n }\n else if (node.nodeType == 3) {\n this.readTextNode(node);\n }\n else if (node.nodeName == \"BR\") {\n if (node.nextSibling)\n this.lineBreak();\n }\n else if (node.nodeType == 1) {\n this.readRange(node.firstChild, null);\n }\n }\n findPointBefore(node, next) {\n for (let point of this.points)\n if (point.node == node && node.childNodes[point.offset] == next)\n point.pos = this.text.length;\n }\n findPointInside(node, length) {\n for (let point of this.points)\n if (node.nodeType == 3 ? point.node == node : node.contains(point.node))\n point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);\n }\n}\nfunction isAtEnd(parent, node, offset) {\n for (;;) {\n if (!node || offset < maxOffset(node))\n return false;\n if (node == parent)\n return true;\n offset = domIndex(node) + 1;\n node = node.parentNode;\n }\n}\nfunction isBlockElement(node) {\n return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\\d|SECTION|PRE)$/.test(node.nodeName);\n}\nclass DOMPoint {\n constructor(node, offset) {\n this.node = node;\n this.offset = offset;\n this.pos = -1;\n }\n}\n\nclass DOMChange {\n constructor(view, start, end, typeOver) {\n this.typeOver = typeOver;\n this.bounds = null;\n this.text = \"\";\n let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;\n if (view.state.readOnly && start > -1) {\n // Ignore changes when the editor is read-only\n this.newSel = null;\n }\n else if (start > -1 && (this.bounds = view.docView.domBoundsAround(start, end, 0))) {\n let selPoints = iHead || iAnchor ? [] : selectionPoints(view);\n let reader = new DOMReader(selPoints, view.state);\n reader.readRange(this.bounds.startDOM, this.bounds.endDOM);\n this.text = reader.text;\n this.newSel = selectionFromPoints(selPoints, this.bounds.from);\n }\n else {\n let domSel = view.observer.selectionRange;\n let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||\n !contains(view.contentDOM, domSel.focusNode)\n ? view.state.selection.main.head\n : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);\n let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||\n !contains(view.contentDOM, domSel.anchorNode)\n ? view.state.selection.main.anchor\n : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);\n this.newSel = EditorSelection.single(anchor, head);\n }\n }\n}\nfunction applyDOMChange(view, domChange) {\n let change;\n let { newSel } = domChange, sel = view.state.selection.main;\n let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;\n if (domChange.bounds) {\n let { from, to } = domChange.bounds;\n let preferredPos = sel.from, preferredSide = null;\n // Prefer anchoring to end when Backspace is pressed (or, on\n // Android, when something was deleted)\n if (lastKey === 8 || browser.android && domChange.text.length < to - from) {\n preferredPos = sel.to;\n preferredSide = \"end\";\n }\n let diff = findDiff(view.state.doc.sliceString(from, to, LineBreakPlaceholder), domChange.text, preferredPos - from, preferredSide);\n if (diff) {\n // Chrome inserts two newlines when pressing shift-enter at the\n // end of a line. DomChange drops one of those.\n if (browser.chrome && lastKey == 13 &&\n diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)\n diff.toB--;\n change = { from: from + diff.from, to: from + diff.toA,\n insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };\n }\n }\n else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {\n newSel = null;\n }\n if (!change && !newSel)\n return false;\n if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {\n // Heuristic to notice typing over a selected character\n change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };\n }\n else if (change && change.from >= sel.from && change.to <= sel.to &&\n (change.from != sel.from || change.to != sel.to) &&\n (sel.to - sel.from) - (change.to - change.from) <= 4) {\n // If the change is inside the selection and covers most of it,\n // assume it is a selection replace (with identical characters at\n // the start/end not included in the diff)\n change = {\n from: sel.from, to: sel.to,\n insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))\n };\n }\n else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&\n /^\\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute(\"autocorrect\") == \"off\") {\n // Detect insert-period-on-double-space Mac and Android behavior,\n // and transform it into a regular space insert.\n if (newSel && change.insert.length == 2)\n newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);\n change = { from: sel.from, to: sel.to, insert: Text.of([\" \"]) };\n }\n else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&\n change.insert.toString() == \"\\n \" && view.lineWrapping) {\n // In Chrome, if you insert a space at the start of a wrapped\n // line, it will actually insert a newline and a space, causing a\n // bogus new line to be created in CodeMirror (#968)\n if (newSel)\n newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);\n change = { from: sel.from, to: sel.to, insert: Text.of([\" \"]) };\n }\n if (change) {\n if (browser.ios && view.inputState.flushIOSKey())\n return true;\n // Android browsers don't fire reasonable key events for enter,\n // backspace, or delete. So this detects changes that look like\n // they're caused by those keys, and reinterprets them as key\n // events. (Some of these keys are also handled by beforeinput\n // events and the pendingAndroidKey mechanism, but that's not\n // reliable in all situations.)\n if (browser.android &&\n ((change.from == sel.from && change.to == sel.to &&\n change.insert.length == 1 && change.insert.lines == 2 &&\n dispatchKey(view.contentDOM, \"Enter\", 13)) ||\n ((change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 ||\n lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) &&\n dispatchKey(view.contentDOM, \"Backspace\", 8)) ||\n (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&\n dispatchKey(view.contentDOM, \"Delete\", 46))))\n return true;\n let text = change.insert.toString();\n if (view.inputState.composing >= 0)\n view.inputState.composing++;\n let defaultTr;\n let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));\n if (!view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text, defaultInsert)))\n view.dispatch(defaultInsert());\n return true;\n }\n else if (newSel && !newSel.main.eq(sel)) {\n let scrollIntoView = false, userEvent = \"select\";\n if (view.inputState.lastSelectionTime > Date.now() - 50) {\n if (view.inputState.lastSelectionOrigin == \"select\")\n scrollIntoView = true;\n userEvent = view.inputState.lastSelectionOrigin;\n }\n view.dispatch({ selection: newSel, scrollIntoView, userEvent });\n return true;\n }\n else {\n return false;\n }\n}\nfunction applyDefaultInsert(view, change, newSel) {\n let tr, startState = view.state, sel = startState.selection.main;\n if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&\n (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&\n view.inputState.composing < 0) {\n let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : \"\";\n let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : \"\";\n tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));\n }\n else {\n let changes = startState.changes(change);\n let mainSel = newSel && newSel.main.to <= changes.newLength ? newSel.main : undefined;\n // Try to apply a composition change to all cursors\n if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&\n change.to <= sel.to && change.to >= sel.to - 10) {\n let replaced = view.state.sliceDoc(change.from, change.to);\n let compositionRange, composition = newSel && findCompositionNode(view, newSel.main.head);\n if (composition) {\n let dLen = change.insert.length - (change.to - change.from);\n compositionRange = { from: composition.from, to: composition.to - dLen };\n }\n else {\n compositionRange = view.state.doc.lineAt(sel.head);\n }\n let offset = sel.to - change.to, size = sel.to - sel.from;\n tr = startState.changeByRange(range => {\n if (range.from == sel.from && range.to == sel.to)\n return { changes, range: mainSel || range.map(changes) };\n let to = range.to - offset, from = to - replaced.length;\n if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||\n // Unfortunately, there's no way to make multiple\n // changes in the same node work without aborting\n // composition, so cursors in the composition range are\n // ignored.\n range.to >= compositionRange.from && range.from <= compositionRange.to)\n return { range };\n let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;\n return {\n changes: rangeChanges,\n range: !mainSel ? range.map(rangeChanges) :\n EditorSelection.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))\n };\n });\n }\n else {\n tr = {\n changes,\n selection: mainSel && startState.selection.replaceRange(mainSel)\n };\n }\n }\n let userEvent = \"input.type\";\n if (view.composing ||\n view.inputState.compositionPendingChange && view.inputState.compositionEndedAt > Date.now() - 50) {\n view.inputState.compositionPendingChange = false;\n userEvent += \".compose\";\n if (view.inputState.compositionFirstChange) {\n userEvent += \".start\";\n view.inputState.compositionFirstChange = false;\n }\n }\n return startState.update(tr, { userEvent, scrollIntoView: true });\n}\nfunction findDiff(a, b, preferredPos, preferredSide) {\n let minLen = Math.min(a.length, b.length);\n let from = 0;\n while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))\n from++;\n if (from == minLen && a.length == b.length)\n return null;\n let toA = a.length, toB = b.length;\n while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {\n toA--;\n toB--;\n }\n if (preferredSide == \"end\") {\n let adjust = Math.max(0, from - Math.min(toA, toB));\n preferredPos -= toA + adjust - from;\n }\n if (toA < from && a.length < b.length) {\n let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;\n from -= move;\n toB = from + (toB - toA);\n toA = from;\n }\n else if (toB < from) {\n let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;\n from -= move;\n toA = from + (toA - toB);\n toB = from;\n }\n return { from, toA, toB };\n}\nfunction selectionPoints(view) {\n let result = [];\n if (view.root.activeElement != view.contentDOM)\n return result;\n let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;\n if (anchorNode) {\n result.push(new DOMPoint(anchorNode, anchorOffset));\n if (focusNode != anchorNode || focusOffset != anchorOffset)\n result.push(new DOMPoint(focusNode, focusOffset));\n }\n return result;\n}\nfunction selectionFromPoints(points, base) {\n if (points.length == 0)\n return null;\n let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;\n return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;\n}\n\nconst observeOptions = {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n characterDataOldValue: true\n};\n// IE11 has very broken mutation observers, so we also listen to\n// DOMCharacterDataModified there\nconst useCharData = browser.ie && browser.ie_version <= 11;\nclass DOMObserver {\n constructor(view) {\n this.view = view;\n this.active = false;\n // The known selection. Kept in our own object, as opposed to just\n // directly accessing the selection because:\n // - Safari doesn't report the right selection in shadow DOM\n // - Reading from the selection forces a DOM layout\n // - This way, we can ignore selectionchange events if we have\n // already seen the 'new' selection\n this.selectionRange = new DOMSelectionState;\n // Set when a selection change is detected, cleared on flush\n this.selectionChanged = false;\n this.delayedFlush = -1;\n this.resizeTimeout = -1;\n this.queue = [];\n this.delayedAndroidKey = null;\n this.flushingAndroidKey = -1;\n this.lastChange = 0;\n this.scrollTargets = [];\n this.intersection = null;\n this.resizeScroll = null;\n this.intersecting = false;\n this.gapIntersection = null;\n this.gaps = [];\n // Timeout for scheduling check of the parents that need scroll handlers\n this.parentCheck = -1;\n this.dom = view.contentDOM;\n this.observer = new MutationObserver(mutations => {\n for (let mut of mutations)\n this.queue.push(mut);\n // IE11 will sometimes (on typing over a selection or\n // backspacing out a single character text node) call the\n // observer callback before actually updating the DOM.\n //\n // Unrelatedly, iOS Safari will, when ending a composition,\n // sometimes first clear it, deliver the mutations, and then\n // reinsert the finished text. CodeMirror's handling of the\n // deletion will prevent the reinsertion from happening,\n // breaking composition.\n if ((browser.ie && browser.ie_version <= 11 || browser.ios && view.composing) &&\n mutations.some(m => m.type == \"childList\" && m.removedNodes.length ||\n m.type == \"characterData\" && m.oldValue.length > m.target.nodeValue.length))\n this.flushSoon();\n else\n this.flush();\n });\n if (useCharData)\n this.onCharData = (event) => {\n this.queue.push({ target: event.target,\n type: \"characterData\",\n oldValue: event.prevValue });\n this.flushSoon();\n };\n this.onSelectionChange = this.onSelectionChange.bind(this);\n this.onResize = this.onResize.bind(this);\n this.onPrint = this.onPrint.bind(this);\n this.onScroll = this.onScroll.bind(this);\n if (typeof ResizeObserver == \"function\") {\n this.resizeScroll = new ResizeObserver(() => {\n var _a;\n if (((_a = this.view.docView) === null || _a === void 0 ? void 0 : _a.lastUpdate) < Date.now() - 75)\n this.onResize();\n });\n this.resizeScroll.observe(view.scrollDOM);\n }\n this.addWindowListeners(this.win = view.win);\n this.start();\n if (typeof IntersectionObserver == \"function\") {\n this.intersection = new IntersectionObserver(entries => {\n if (this.parentCheck < 0)\n this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);\n if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {\n this.intersecting = !this.intersecting;\n if (this.intersecting != this.view.inView)\n this.onScrollChanged(document.createEvent(\"Event\"));\n }\n }, { threshold: [0, .001] });\n this.intersection.observe(this.dom);\n this.gapIntersection = new IntersectionObserver(entries => {\n if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)\n this.onScrollChanged(document.createEvent(\"Event\"));\n }, {});\n }\n this.listenForScroll();\n this.readSelectionRange();\n }\n onScrollChanged(e) {\n this.view.inputState.runHandlers(\"scroll\", e);\n if (this.intersecting)\n this.view.measure();\n }\n onScroll(e) {\n if (this.intersecting)\n this.flush(false);\n this.onScrollChanged(e);\n }\n onResize() {\n if (this.resizeTimeout < 0)\n this.resizeTimeout = setTimeout(() => {\n this.resizeTimeout = -1;\n this.view.requestMeasure();\n }, 50);\n }\n onPrint() {\n this.view.viewState.printing = true;\n this.view.measure();\n setTimeout(() => {\n this.view.viewState.printing = false;\n this.view.requestMeasure();\n }, 500);\n }\n updateGaps(gaps) {\n if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {\n this.gapIntersection.disconnect();\n for (let gap of gaps)\n this.gapIntersection.observe(gap);\n this.gaps = gaps;\n }\n }\n onSelectionChange(event) {\n let wasChanged = this.selectionChanged;\n if (!this.readSelectionRange() || this.delayedAndroidKey)\n return;\n let { view } = this, sel = this.selectionRange;\n if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel))\n return;\n let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);\n if (context && context.ignoreEvent(event)) {\n if (!wasChanged)\n this.selectionChanged = false;\n return;\n }\n // Deletions on IE11 fire their events in the wrong order, giving\n // us a selection change event before the DOM changes are\n // reported.\n // Chrome Android has a similar issue when backspacing out a\n // selection (#645).\n if ((browser.ie && browser.ie_version <= 11 || browser.android && browser.chrome) && !view.state.selection.main.empty &&\n // (Selection.isCollapsed isn't reliable on IE)\n sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))\n this.flushSoon();\n else\n this.flush(false);\n }\n readSelectionRange() {\n let { view } = this;\n // The Selection object is broken in shadow roots in Safari. See\n // https://github.com/codemirror/dev/issues/414\n let range = browser.safari && view.root.nodeType == 11 &&\n deepActiveElement(this.dom.ownerDocument) == this.dom &&\n safariSelectionRangeHack(this.view) || getSelection(view.root);\n if (!range || this.selectionRange.eq(range))\n return false;\n let local = hasSelection(this.dom, range);\n // Detect the situation where the browser has, on focus, moved the\n // selection to the start of the content element. Reset it to the\n // position from the editor state.\n if (local && !this.selectionChanged &&\n view.inputState.lastFocusTime > Date.now() - 200 &&\n view.inputState.lastTouchTime < Date.now() - 300 &&\n atElementStart(this.dom, range)) {\n this.view.inputState.lastFocusTime = 0;\n view.docView.updateSelection();\n return false;\n }\n this.selectionRange.setRange(range);\n if (local)\n this.selectionChanged = true;\n return true;\n }\n setSelectionRange(anchor, head) {\n this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);\n this.selectionChanged = false;\n }\n clearSelectionRange() {\n this.selectionRange.set(null, 0, null, 0);\n }\n listenForScroll() {\n this.parentCheck = -1;\n let i = 0, changed = null;\n for (let dom = this.dom; dom;) {\n if (dom.nodeType == 1) {\n if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)\n i++;\n else if (!changed)\n changed = this.scrollTargets.slice(0, i);\n if (changed)\n changed.push(dom);\n dom = dom.assignedSlot || dom.parentNode;\n }\n else if (dom.nodeType == 11) { // Shadow root\n dom = dom.host;\n }\n else {\n break;\n }\n }\n if (i < this.scrollTargets.length && !changed)\n changed = this.scrollTargets.slice(0, i);\n if (changed) {\n for (let dom of this.scrollTargets)\n dom.removeEventListener(\"scroll\", this.onScroll);\n for (let dom of this.scrollTargets = changed)\n dom.addEventListener(\"scroll\", this.onScroll);\n }\n }\n ignore(f) {\n if (!this.active)\n return f();\n try {\n this.stop();\n return f();\n }\n finally {\n this.start();\n this.clear();\n }\n }\n start() {\n if (this.active)\n return;\n this.observer.observe(this.dom, observeOptions);\n if (useCharData)\n this.dom.addEventListener(\"DOMCharacterDataModified\", this.onCharData);\n this.active = true;\n }\n stop() {\n if (!this.active)\n return;\n this.active = false;\n this.observer.disconnect();\n if (useCharData)\n this.dom.removeEventListener(\"DOMCharacterDataModified\", this.onCharData);\n }\n // Throw away any pending changes\n clear() {\n this.processRecords();\n this.queue.length = 0;\n this.selectionChanged = false;\n }\n // Chrome Android, especially in combination with GBoard, not only\n // doesn't reliably fire regular key events, but also often\n // surrounds the effect of enter or backspace with a bunch of\n // composition events that, when interrupted, cause text duplication\n // or other kinds of corruption. This hack makes the editor back off\n // from handling DOM changes for a moment when such a key is\n // detected (via beforeinput or keydown), and then tries to flush\n // them or, if that has no effect, dispatches the given key.\n delayAndroidKey(key, keyCode) {\n var _a;\n if (!this.delayedAndroidKey) {\n let flush = () => {\n let key = this.delayedAndroidKey;\n if (key) {\n this.clearDelayedAndroidKey();\n this.view.inputState.lastKeyCode = key.keyCode;\n this.view.inputState.lastKeyTime = Date.now();\n let flushed = this.flush();\n if (!flushed && key.force)\n dispatchKey(this.dom, key.key, key.keyCode);\n }\n };\n this.flushingAndroidKey = this.view.win.requestAnimationFrame(flush);\n }\n // Since backspace beforeinput is sometimes signalled spuriously,\n // Enter always takes precedence.\n if (!this.delayedAndroidKey || key == \"Enter\")\n this.delayedAndroidKey = {\n key, keyCode,\n // Only run the key handler when no changes are detected if\n // this isn't coming right after another change, in which case\n // it is probably part of a weird chain of updates, and should\n // be ignored if it returns the DOM to its previous state.\n force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)\n };\n }\n clearDelayedAndroidKey() {\n this.win.cancelAnimationFrame(this.flushingAndroidKey);\n this.delayedAndroidKey = null;\n this.flushingAndroidKey = -1;\n }\n flushSoon() {\n if (this.delayedFlush < 0)\n this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });\n }\n forceFlush() {\n if (this.delayedFlush >= 0) {\n this.view.win.cancelAnimationFrame(this.delayedFlush);\n this.delayedFlush = -1;\n }\n this.flush();\n }\n pendingRecords() {\n for (let mut of this.observer.takeRecords())\n this.queue.push(mut);\n return this.queue;\n }\n processRecords() {\n let records = this.pendingRecords();\n if (records.length)\n this.queue = [];\n let from = -1, to = -1, typeOver = false;\n for (let record of records) {\n let range = this.readMutation(record);\n if (!range)\n continue;\n if (range.typeOver)\n typeOver = true;\n if (from == -1) {\n ({ from, to } = range);\n }\n else {\n from = Math.min(range.from, from);\n to = Math.max(range.to, to);\n }\n }\n return { from, to, typeOver };\n }\n readChange() {\n let { from, to, typeOver } = this.processRecords();\n let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);\n if (from < 0 && !newSel)\n return null;\n if (from > -1)\n this.lastChange = Date.now();\n this.view.inputState.lastFocusTime = 0;\n this.selectionChanged = false;\n let change = new DOMChange(this.view, from, to, typeOver);\n this.view.docView.domChanged = { newSel: change.newSel ? change.newSel.main : null };\n return change;\n }\n // Apply pending changes, if any\n flush(readSelection = true) {\n // Completely hold off flushing when pending keys are set—the code\n // managing those will make sure processRecords is called and the\n // view is resynchronized after\n if (this.delayedFlush >= 0 || this.delayedAndroidKey)\n return false;\n if (readSelection)\n this.readSelectionRange();\n let domChange = this.readChange();\n if (!domChange) {\n this.view.requestMeasure();\n return false;\n }\n let startState = this.view.state;\n let handled = applyDOMChange(this.view, domChange);\n // The view wasn't updated\n if (this.view.state == startState)\n this.view.update([]);\n return handled;\n }\n readMutation(rec) {\n let cView = this.view.docView.nearest(rec.target);\n if (!cView || cView.ignoreMutation(rec))\n return null;\n cView.markDirty(rec.type == \"attributes\");\n if (rec.type == \"attributes\")\n cView.flags |= 4 /* ViewFlag.AttrsDirty */;\n if (rec.type == \"childList\") {\n let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);\n let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);\n return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,\n to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };\n }\n else if (rec.type == \"characterData\") {\n return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };\n }\n else {\n return null;\n }\n }\n setWindow(win) {\n if (win != this.win) {\n this.removeWindowListeners(this.win);\n this.win = win;\n this.addWindowListeners(this.win);\n }\n }\n addWindowListeners(win) {\n win.addEventListener(\"resize\", this.onResize);\n win.addEventListener(\"beforeprint\", this.onPrint);\n win.addEventListener(\"scroll\", this.onScroll);\n win.document.addEventListener(\"selectionchange\", this.onSelectionChange);\n }\n removeWindowListeners(win) {\n win.removeEventListener(\"scroll\", this.onScroll);\n win.removeEventListener(\"resize\", this.onResize);\n win.removeEventListener(\"beforeprint\", this.onPrint);\n win.document.removeEventListener(\"selectionchange\", this.onSelectionChange);\n }\n destroy() {\n var _a, _b, _c;\n this.stop();\n (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();\n (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();\n (_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();\n for (let dom of this.scrollTargets)\n dom.removeEventListener(\"scroll\", this.onScroll);\n this.removeWindowListeners(this.win);\n clearTimeout(this.parentCheck);\n clearTimeout(this.resizeTimeout);\n this.win.cancelAnimationFrame(this.delayedFlush);\n this.win.cancelAnimationFrame(this.flushingAndroidKey);\n }\n}\nfunction findChild(cView, dom, dir) {\n while (dom) {\n let curView = ContentView.get(dom);\n if (curView && curView.parent == cView)\n return curView;\n let parent = dom.parentNode;\n dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;\n }\n return null;\n}\n// Used to work around a Safari Selection/shadow DOM bug (#414)\nfunction safariSelectionRangeHack(view) {\n let found = null;\n // Because Safari (at least in 2018-2021) doesn't provide regular\n // access to the selection inside a shadowroot, we have to perform a\n // ridiculous hack to get at it—using `execCommand` to trigger a\n // `beforeInput` event so that we can read the target range from the\n // event.\n function read(event) {\n event.preventDefault();\n event.stopImmediatePropagation();\n found = event.getTargetRanges()[0];\n }\n view.contentDOM.addEventListener(\"beforeinput\", read, true);\n view.dom.ownerDocument.execCommand(\"indent\");\n view.contentDOM.removeEventListener(\"beforeinput\", read, true);\n if (!found)\n return null;\n let anchorNode = found.startContainer, anchorOffset = found.startOffset;\n let focusNode = found.endContainer, focusOffset = found.endOffset;\n let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);\n // Since such a range doesn't distinguish between anchor and head,\n // use a heuristic that flips it around if its end matches the\n // current anchor.\n if (isEquivalentPosition(curAnchor.node, curAnchor.offset, focusNode, focusOffset))\n [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];\n return { anchorNode, anchorOffset, focusNode, focusOffset };\n}\n\n// The editor's update state machine looks something like this:\n//\n// Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle\n// ↑ ↓\n// Updating (measure)\n//\n// The difference between 'Idle' and 'Idle (unchecked)' lies in\n// whether a layout check has been scheduled. A regular update through\n// the `update` method updates the DOM in a write-only fashion, and\n// relies on a check (scheduled with `requestAnimationFrame`) to make\n// sure everything is where it should be and the viewport covers the\n// visible code. That check continues to measure and then optionally\n// update until it reaches a coherent state.\n/**\nAn editor view represents the editor's user interface. It holds\nthe editable DOM surface, and possibly other elements such as the\nline number gutter. It handles events and dispatches state\ntransactions for editing actions.\n*/\nclass EditorView {\n /**\n The current editor state.\n */\n get state() { return this.viewState.state; }\n /**\n To be able to display large documents without consuming too much\n memory or overloading the browser, CodeMirror only draws the\n code that is visible (plus a margin around it) to the DOM. This\n property tells you the extent of the current drawn viewport, in\n document positions.\n */\n get viewport() { return this.viewState.viewport; }\n /**\n When there are, for example, large collapsed ranges in the\n viewport, its size can be a lot bigger than the actual visible\n content. Thus, if you are doing something like styling the\n content in the viewport, it is preferable to only do so for\n these ranges, which are the subset of the viewport that is\n actually drawn.\n */\n get visibleRanges() { return this.viewState.visibleRanges; }\n /**\n Returns false when the editor is entirely scrolled out of view\n or otherwise hidden.\n */\n get inView() { return this.viewState.inView; }\n /**\n Indicates whether the user is currently composing text via\n [IME](https://en.wikipedia.org/wiki/Input_method), and at least\n one change has been made in the current composition.\n */\n get composing() { return this.inputState.composing > 0; }\n /**\n Indicates whether the user is currently in composing state. Note\n that on some platforms, like Android, this will be the case a\n lot, since just putting the cursor on a word starts a\n composition there.\n */\n get compositionStarted() { return this.inputState.composing >= 0; }\n /**\n The document or shadow root that the view lives in.\n */\n get root() { return this._root; }\n /**\n @internal\n */\n get win() { return this.dom.ownerDocument.defaultView || window; }\n /**\n Construct a new view. You'll want to either provide a `parent`\n option, or put `view.dom` into your document after creating a\n view, so that the user can see the editor.\n */\n constructor(config = {}) {\n this.plugins = [];\n this.pluginMap = new Map;\n this.editorAttrs = {};\n this.contentAttrs = {};\n this.bidiCache = [];\n this.destroyed = false;\n /**\n @internal\n */\n this.updateState = 2 /* UpdateState.Updating */;\n /**\n @internal\n */\n this.measureScheduled = -1;\n /**\n @internal\n */\n this.measureRequests = [];\n this.contentDOM = document.createElement(\"div\");\n this.scrollDOM = document.createElement(\"div\");\n this.scrollDOM.tabIndex = -1;\n this.scrollDOM.className = \"cm-scroller\";\n this.scrollDOM.appendChild(this.contentDOM);\n this.announceDOM = document.createElement(\"div\");\n this.announceDOM.className = \"cm-announced\";\n this.announceDOM.setAttribute(\"aria-live\", \"polite\");\n this.dom = document.createElement(\"div\");\n this.dom.appendChild(this.announceDOM);\n this.dom.appendChild(this.scrollDOM);\n let { dispatch } = config;\n this.dispatchTransactions = config.dispatchTransactions ||\n (dispatch && ((trs) => trs.forEach(tr => dispatch(tr, this)))) ||\n ((trs) => this.update(trs));\n this.dispatch = this.dispatch.bind(this);\n this._root = (config.root || getRoot(config.parent) || document);\n this.viewState = new ViewState(config.state || EditorState.create(config));\n if (config.scrollTo && config.scrollTo.is(scrollIntoView))\n this.viewState.scrollTarget = config.scrollTo.value.clip(this.viewState.state);\n this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));\n for (let plugin of this.plugins)\n plugin.update(this);\n this.observer = new DOMObserver(this);\n this.inputState = new InputState(this);\n this.inputState.ensureHandlers(this.plugins);\n this.docView = new DocView(this);\n this.mountStyles();\n this.updateAttrs();\n this.updateState = 0 /* UpdateState.Idle */;\n this.requestMeasure();\n if (config.parent)\n config.parent.appendChild(this.dom);\n }\n dispatch(...input) {\n let trs = input.length == 1 && input[0] instanceof Transaction ? input\n : input.length == 1 && Array.isArray(input[0]) ? input[0]\n : [this.state.update(...input)];\n this.dispatchTransactions(trs, this);\n }\n /**\n Update the view for the given array of transactions. This will\n update the visible document and selection to match the state\n produced by the transactions, and notify view plugins of the\n change. You should usually call\n [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this\n as a primitive.\n */\n update(transactions) {\n if (this.updateState != 0 /* UpdateState.Idle */)\n throw new Error(\"Calls to EditorView.update are not allowed while an update is in progress\");\n let redrawn = false, attrsChanged = false, update;\n let state = this.state;\n for (let tr of transactions) {\n if (tr.startState != state)\n throw new RangeError(\"Trying to update state with a transaction that doesn't start from the previous state.\");\n state = tr.state;\n }\n if (this.destroyed) {\n this.viewState.state = state;\n return;\n }\n let focus = this.hasFocus, focusFlag = 0, dispatchFocus = null;\n if (transactions.some(tr => tr.annotation(isFocusChange))) {\n this.inputState.notifiedFocused = focus;\n // If a focus-change transaction is being dispatched, set this update flag.\n focusFlag = 1 /* UpdateFlag.Focus */;\n }\n else if (focus != this.inputState.notifiedFocused) {\n this.inputState.notifiedFocused = focus;\n // Schedule a separate focus transaction if necessary, otherwise\n // add a flag to this update\n dispatchFocus = focusChangeTransaction(state, focus);\n if (!dispatchFocus)\n focusFlag = 1 /* UpdateFlag.Focus */;\n }\n // If there was a pending DOM change, eagerly read it and try to\n // apply it after the given transactions.\n let pendingKey = this.observer.delayedAndroidKey, domChange = null;\n if (pendingKey) {\n this.observer.clearDelayedAndroidKey();\n domChange = this.observer.readChange();\n // Only try to apply DOM changes if the transactions didn't\n // change the doc or selection.\n if (domChange && !this.state.doc.eq(state.doc) || !this.state.selection.eq(state.selection))\n domChange = null;\n }\n else {\n this.observer.clear();\n }\n // When the phrases change, redraw the editor\n if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases))\n return this.setState(state);\n update = ViewUpdate.create(this, state, transactions);\n update.flags |= focusFlag;\n let scrollTarget = this.viewState.scrollTarget;\n try {\n this.updateState = 2 /* UpdateState.Updating */;\n for (let tr of transactions) {\n if (scrollTarget)\n scrollTarget = scrollTarget.map(tr.changes);\n if (tr.scrollIntoView) {\n let { main } = tr.state.selection;\n scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1));\n }\n for (let e of tr.effects)\n if (e.is(scrollIntoView))\n scrollTarget = e.value.clip(this.state);\n }\n this.viewState.update(update, scrollTarget);\n this.bidiCache = CachedOrder.update(this.bidiCache, update.changes);\n if (!update.empty) {\n this.updatePlugins(update);\n this.inputState.update(update);\n }\n redrawn = this.docView.update(update);\n if (this.state.facet(styleModule) != this.styleModules)\n this.mountStyles();\n attrsChanged = this.updateAttrs();\n this.showAnnouncements(transactions);\n this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent(\"select.pointer\")));\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n }\n if (update.startState.facet(theme) != update.state.facet(theme))\n this.viewState.mustMeasureContent = true;\n if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)\n this.requestMeasure();\n if (!update.empty)\n for (let listener of this.state.facet(updateListener)) {\n try {\n listener(update);\n }\n catch (e) {\n logException(this.state, e, \"update listener\");\n }\n }\n if (dispatchFocus || domChange)\n Promise.resolve().then(() => {\n if (dispatchFocus && this.state == dispatchFocus.startState)\n this.dispatch(dispatchFocus);\n if (domChange) {\n if (!applyDOMChange(this, domChange) && pendingKey.force)\n dispatchKey(this.contentDOM, pendingKey.key, pendingKey.keyCode);\n }\n });\n }\n /**\n Reset the view to the given state. (This will cause the entire\n document to be redrawn and all view plugins to be reinitialized,\n so you should probably only use it when the new state isn't\n derived from the old state. Otherwise, use\n [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)\n */\n setState(newState) {\n if (this.updateState != 0 /* UpdateState.Idle */)\n throw new Error(\"Calls to EditorView.setState are not allowed while an update is in progress\");\n if (this.destroyed) {\n this.viewState.state = newState;\n return;\n }\n this.updateState = 2 /* UpdateState.Updating */;\n let hadFocus = this.hasFocus;\n try {\n for (let plugin of this.plugins)\n plugin.destroy(this);\n this.viewState = new ViewState(newState);\n this.plugins = newState.facet(viewPlugin).map(spec => new PluginInstance(spec));\n this.pluginMap.clear();\n for (let plugin of this.plugins)\n plugin.update(this);\n this.docView.destroy();\n this.docView = new DocView(this);\n this.inputState.ensureHandlers(this.plugins);\n this.mountStyles();\n this.updateAttrs();\n this.bidiCache = [];\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n }\n if (hadFocus)\n this.focus();\n this.requestMeasure();\n }\n updatePlugins(update) {\n let prevSpecs = update.startState.facet(viewPlugin), specs = update.state.facet(viewPlugin);\n if (prevSpecs != specs) {\n let newPlugins = [];\n for (let spec of specs) {\n let found = prevSpecs.indexOf(spec);\n if (found < 0) {\n newPlugins.push(new PluginInstance(spec));\n }\n else {\n let plugin = this.plugins[found];\n plugin.mustUpdate = update;\n newPlugins.push(plugin);\n }\n }\n for (let plugin of this.plugins)\n if (plugin.mustUpdate != update)\n plugin.destroy(this);\n this.plugins = newPlugins;\n this.pluginMap.clear();\n }\n else {\n for (let p of this.plugins)\n p.mustUpdate = update;\n }\n for (let i = 0; i < this.plugins.length; i++)\n this.plugins[i].update(this);\n if (prevSpecs != specs)\n this.inputState.ensureHandlers(this.plugins);\n }\n /**\n @internal\n */\n measure(flush = true) {\n if (this.destroyed)\n return;\n if (this.measureScheduled > -1)\n this.win.cancelAnimationFrame(this.measureScheduled);\n if (this.observer.delayedAndroidKey) {\n this.measureScheduled = -1;\n this.requestMeasure();\n return;\n }\n this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame\n if (flush)\n this.observer.forceFlush();\n let updated = null;\n let sDOM = this.scrollDOM, scrollTop = sDOM.scrollTop * this.scaleY;\n let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;\n if (Math.abs(scrollTop - this.viewState.scrollTop) > 1)\n scrollAnchorHeight = -1;\n this.viewState.scrollAnchorHeight = -1;\n try {\n for (let i = 0;; i++) {\n if (scrollAnchorHeight < 0) {\n if (isScrolledToBottom(sDOM)) {\n scrollAnchorPos = -1;\n scrollAnchorHeight = this.viewState.heightMap.height;\n }\n else {\n let block = this.viewState.scrollAnchorAt(scrollTop);\n scrollAnchorPos = block.from;\n scrollAnchorHeight = block.top;\n }\n }\n this.updateState = 1 /* UpdateState.Measuring */;\n let changed = this.viewState.measure(this);\n if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)\n break;\n if (i > 5) {\n console.warn(this.measureRequests.length\n ? \"Measure loop restarted more than 5 times\"\n : \"Viewport failed to stabilize\");\n break;\n }\n let measuring = [];\n // Only run measure requests in this cycle when the viewport didn't change\n if (!(changed & 4 /* UpdateFlag.Viewport */))\n [this.measureRequests, measuring] = [measuring, this.measureRequests];\n let measured = measuring.map(m => {\n try {\n return m.read(this);\n }\n catch (e) {\n logException(this.state, e);\n return BadMeasure;\n }\n });\n let update = ViewUpdate.create(this, this.state, []), redrawn = false;\n update.flags |= changed;\n if (!updated)\n updated = update;\n else\n updated.flags |= changed;\n this.updateState = 2 /* UpdateState.Updating */;\n if (!update.empty) {\n this.updatePlugins(update);\n this.inputState.update(update);\n this.updateAttrs();\n redrawn = this.docView.update(update);\n }\n for (let i = 0; i < measuring.length; i++)\n if (measured[i] != BadMeasure) {\n try {\n let m = measuring[i];\n if (m.write)\n m.write(measured[i], this);\n }\n catch (e) {\n logException(this.state, e);\n }\n }\n if (redrawn)\n this.docView.updateSelection(true);\n if (!update.viewportChanged && this.measureRequests.length == 0) {\n if (this.viewState.editorHeight) {\n if (this.viewState.scrollTarget) {\n this.docView.scrollIntoView(this.viewState.scrollTarget);\n this.viewState.scrollTarget = null;\n scrollAnchorHeight = -1;\n continue;\n }\n else {\n let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :\n this.viewState.lineBlockAt(scrollAnchorPos).top;\n let diff = newAnchorHeight - scrollAnchorHeight;\n if (diff > 1 || diff < -1) {\n scrollTop = scrollTop + diff;\n sDOM.scrollTop = scrollTop / this.scaleY;\n scrollAnchorHeight = -1;\n continue;\n }\n }\n }\n break;\n }\n }\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n this.measureScheduled = -1;\n }\n if (updated && !updated.empty)\n for (let listener of this.state.facet(updateListener))\n listener(updated);\n }\n /**\n Get the CSS classes for the currently active editor themes.\n */\n get themeClasses() {\n return baseThemeID + \" \" +\n (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + \" \" +\n this.state.facet(theme);\n }\n updateAttrs() {\n let editorAttrs = attrsFromFacet(this, editorAttributes, {\n class: \"cm-editor\" + (this.hasFocus ? \" cm-focused \" : \" \") + this.themeClasses\n });\n let contentAttrs = {\n spellcheck: \"false\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n translate: \"no\",\n contenteditable: !this.state.facet(editable) ? \"false\" : \"true\",\n class: \"cm-content\",\n style: `${browser.tabSize}: ${this.state.tabSize}`,\n role: \"textbox\",\n \"aria-multiline\": \"true\"\n };\n if (this.state.readOnly)\n contentAttrs[\"aria-readonly\"] = \"true\";\n attrsFromFacet(this, contentAttributes, contentAttrs);\n let changed = this.observer.ignore(() => {\n let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);\n let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);\n return changedContent || changedEditor;\n });\n this.editorAttrs = editorAttrs;\n this.contentAttrs = contentAttrs;\n return changed;\n }\n showAnnouncements(trs) {\n let first = true;\n for (let tr of trs)\n for (let effect of tr.effects)\n if (effect.is(EditorView.announce)) {\n if (first)\n this.announceDOM.textContent = \"\";\n first = false;\n let div = this.announceDOM.appendChild(document.createElement(\"div\"));\n div.textContent = effect.value;\n }\n }\n mountStyles() {\n this.styleModules = this.state.facet(styleModule);\n let nonce = this.state.facet(EditorView.cspNonce);\n StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse(), nonce ? { nonce } : undefined);\n }\n readMeasured() {\n if (this.updateState == 2 /* UpdateState.Updating */)\n throw new Error(\"Reading the editor layout isn't allowed during an update\");\n if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)\n this.measure(false);\n }\n /**\n Schedule a layout measurement, optionally providing callbacks to\n do custom DOM measuring followed by a DOM write phase. Using\n this is preferable reading DOM layout directly from, for\n example, an event handler, because it'll make sure measuring and\n drawing done by other components is synchronized, avoiding\n unnecessary DOM layout computations.\n */\n requestMeasure(request) {\n if (this.measureScheduled < 0)\n this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());\n if (request) {\n if (this.measureRequests.indexOf(request) > -1)\n return;\n if (request.key != null)\n for (let i = 0; i < this.measureRequests.length; i++) {\n if (this.measureRequests[i].key === request.key) {\n this.measureRequests[i] = request;\n return;\n }\n }\n this.measureRequests.push(request);\n }\n }\n /**\n Get the value of a specific plugin, if present. Note that\n plugins that crash can be dropped from a view, so even when you\n know you registered a given plugin, it is recommended to check\n the return value of this method.\n */\n plugin(plugin) {\n let known = this.pluginMap.get(plugin);\n if (known === undefined || known && known.spec != plugin)\n this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);\n return known && known.update(this).value;\n }\n /**\n The top position of the document, in screen coordinates. This\n may be negative when the editor is scrolled down. Points\n directly to the top of the first line, not above the padding.\n */\n get documentTop() {\n return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;\n }\n /**\n Reports the padding above and below the document.\n */\n get documentPadding() {\n return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };\n }\n /**\n If the editor is transformed with CSS, this provides the scale\n along the X axis. Otherwise, it will just be 1. Note that\n transforms other than translation and scaling are not supported.\n */\n get scaleX() { return this.viewState.scaleX; }\n /**\n Provide the CSS transformed scale along the Y axis.\n */\n get scaleY() { return this.viewState.scaleY; }\n /**\n Find the text line or block widget at the given vertical\n position (which is interpreted as relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).\n */\n elementAtHeight(height) {\n this.readMeasured();\n return this.viewState.elementAtHeight(height);\n }\n /**\n Find the line block (see\n [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given\n height, again interpreted relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).\n */\n lineBlockAtHeight(height) {\n this.readMeasured();\n return this.viewState.lineBlockAtHeight(height);\n }\n /**\n Get the extent and vertical position of all [line\n blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions\n are relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);\n */\n get viewportLineBlocks() {\n return this.viewState.viewportLines;\n }\n /**\n Find the line block around the given document position. A line\n block is a range delimited on both sides by either a\n non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the\n start/end of the document. It will usually just hold a line of\n text, but may be broken into multiple textblocks by block\n widgets.\n */\n lineBlockAt(pos) {\n return this.viewState.lineBlockAt(pos);\n }\n /**\n The editor's total content height.\n */\n get contentHeight() {\n return this.viewState.contentHeight;\n }\n /**\n Move a cursor position by [grapheme\n cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether\n the motion is away from the line start, or towards it. In\n bidirectional text, the line is traversed in visual order, using\n the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).\n When the start position was the last one on the line, the\n returned position will be across the line break. If there is no\n further line, the original position is returned.\n \n By default, this method moves over a single cluster. The\n optional `by` argument can be used to move across more. It will\n be called with the first cluster as argument, and should return\n a predicate that determines, for each subsequent cluster,\n whether it should also be moved over.\n */\n moveByChar(start, forward, by) {\n return skipAtoms(this, start, moveByChar(this, start, forward, by));\n }\n /**\n Move a cursor position across the next group of either\n [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter\n non-whitespace characters.\n */\n moveByGroup(start, forward) {\n return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));\n }\n /**\n Move to the next line boundary in the given direction. If\n `includeWrap` is true, line wrapping is on, and there is a\n further wrap point on the current line, the wrap point will be\n returned. Otherwise this function will return the start or end\n of the line.\n */\n moveToLineBoundary(start, forward, includeWrap = true) {\n return moveToLineBoundary(this, start, forward, includeWrap);\n }\n /**\n Move a cursor position vertically. When `distance` isn't given,\n it defaults to moving to the next line (including wrapped\n lines). Otherwise, `distance` should provide a positive distance\n in pixels.\n \n When `start` has a\n [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical\n motion will use that as a target horizontal position. Otherwise,\n the cursor's own horizontal position is used. The returned\n cursor will have its goal column set to whichever column was\n used.\n */\n moveVertically(start, forward, distance) {\n return skipAtoms(this, start, moveVertically(this, start, forward, distance));\n }\n /**\n Find the DOM parent node and offset (child offset if `node` is\n an element, character offset when it is a text node) at the\n given document position.\n \n Note that for positions that aren't currently in\n `visibleRanges`, the resulting DOM position isn't necessarily\n meaningful (it may just point before or after a placeholder\n element).\n */\n domAtPos(pos) {\n return this.docView.domAtPos(pos);\n }\n /**\n Find the document position at the given DOM node. Can be useful\n for associating positions with DOM events. Will raise an error\n when `node` isn't part of the editor content.\n */\n posAtDOM(node, offset = 0) {\n return this.docView.posFromDOM(node, offset);\n }\n posAtCoords(coords, precise = true) {\n this.readMeasured();\n return posAtCoords(this, coords, precise);\n }\n /**\n Get the screen coordinates at the given document position.\n `side` determines whether the coordinates are based on the\n element before (-1) or after (1) the position (if no element is\n available on the given side, the method will transparently use\n another strategy to get reasonable coordinates).\n */\n coordsAtPos(pos, side = 1) {\n this.readMeasured();\n let rect = this.docView.coordsAt(pos, side);\n if (!rect || rect.left == rect.right)\n return rect;\n let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);\n let span = order[BidiSpan.find(order, pos - line.from, -1, side)];\n return flattenRect(rect, (span.dir == Direction.LTR) == (side > 0));\n }\n /**\n Return the rectangle around a given character. If `pos` does not\n point in front of a character that is in the viewport and\n rendered (i.e. not replaced, not a line break), this will return\n null. For space characters that are a line wrap point, this will\n return the position before the line break.\n */\n coordsForChar(pos) {\n this.readMeasured();\n return this.docView.coordsForChar(pos);\n }\n /**\n The default width of a character in the editor. May not\n accurately reflect the width of all characters (given variable\n width fonts or styling of invididual ranges).\n */\n get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }\n /**\n The default height of a line in the editor. May not be accurate\n for all lines.\n */\n get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }\n /**\n The text direction\n ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)\n CSS property) of the editor's content element.\n */\n get textDirection() { return this.viewState.defaultTextDirection; }\n /**\n Find the text direction of the block at the given position, as\n assigned by CSS. If\n [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)\n isn't enabled, or the given position is outside of the viewport,\n this will always return the same as\n [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that\n this may trigger a DOM layout.\n */\n textDirectionAt(pos) {\n let perLine = this.state.facet(perLineTextDirection);\n if (!perLine || pos < this.viewport.from || pos > this.viewport.to)\n return this.textDirection;\n this.readMeasured();\n return this.docView.textDirectionAt(pos);\n }\n /**\n Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)\n (as determined by the\n [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)\n CSS property of its content element).\n */\n get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }\n /**\n Returns the bidirectional text structure of the given line\n (which should be in the current document) as an array of span\n objects. The order of these spans matches the [text\n direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is\n left-to-right, the leftmost spans come first, otherwise the\n rightmost spans come first.\n */\n bidiSpans(line) {\n if (line.length > MaxBidiLine)\n return trivialOrder(line.length);\n let dir = this.textDirectionAt(line.from), isolates;\n for (let entry of this.bidiCache) {\n if (entry.from == line.from && entry.dir == dir &&\n (entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line.from, line.to))))\n return entry.order;\n }\n if (!isolates)\n isolates = getIsolatedRanges(this, line.from, line.to);\n let order = computeOrder(line.text, dir, isolates);\n this.bidiCache.push(new CachedOrder(line.from, line.to, dir, isolates, true, order));\n return order;\n }\n /**\n Check whether the editor has focus.\n */\n get hasFocus() {\n var _a;\n // Safari return false for hasFocus when the context menu is open\n // or closing, which leads us to ignore selection changes from the\n // context menu because it looks like the editor isn't focused.\n // This kludges around that.\n return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&\n this.root.activeElement == this.contentDOM;\n }\n /**\n Put focus on the editor.\n */\n focus() {\n this.observer.ignore(() => {\n focusPreventScroll(this.contentDOM);\n this.docView.updateSelection();\n });\n }\n /**\n Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only\n necessary when moving the editor's existing DOM to a new window or shadow root.\n */\n setRoot(root) {\n if (this._root != root) {\n this._root = root;\n this.observer.setWindow((root.nodeType == 9 ? root : root.ownerDocument).defaultView || window);\n this.mountStyles();\n }\n }\n /**\n Clean up this editor view, removing its element from the\n document, unregistering event handlers, and notifying\n plugins. The view instance can no longer be used after\n calling this.\n */\n destroy() {\n for (let plugin of this.plugins)\n plugin.destroy(this);\n this.plugins = [];\n this.inputState.destroy();\n this.docView.destroy();\n this.dom.remove();\n this.observer.destroy();\n if (this.measureScheduled > -1)\n this.win.cancelAnimationFrame(this.measureScheduled);\n this.destroyed = true;\n }\n /**\n Returns an effect that can be\n [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to\n cause it to scroll the given position or range into view.\n */\n static scrollIntoView(pos, options = {}) {\n return scrollIntoView.of(new ScrollTarget(typeof pos == \"number\" ? EditorSelection.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));\n }\n /**\n Return an effect that resets the editor to its current (at the\n time this method was called) scroll position. Note that this\n only affects the editor's own scrollable element, not parents.\n See also\n [`EditorViewConfig.scrollTo`](https://codemirror.net/6/docs/ref/#view.EditorViewConfig.scrollTo).\n \n The effect should be used with a document identical to the one\n it was created for. Failing to do so is not an error, but may\n not scroll to the expected position. You can\n [map](https://codemirror.net/6/docs/ref/#state.StateEffect.map) the effect to account for changes.\n */\n scrollSnapshot() {\n let { scrollTop, scrollLeft } = this.scrollDOM;\n let ref = this.viewState.scrollAnchorAt(scrollTop);\n return scrollIntoView.of(new ScrollTarget(EditorSelection.cursor(ref.from), \"start\", \"start\", ref.top - scrollTop, scrollLeft, true));\n }\n /**\n Returns an extension that can be used to add DOM event handlers.\n The value should be an object mapping event names to handler\n functions. For any given event, such functions are ordered by\n extension precedence, and the first handler to return true will\n be assumed to have handled that event, and no other handlers or\n built-in behavior will be activated for it. These are registered\n on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except\n for `scroll` handlers, which will be called any time the\n editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of\n its parent nodes is scrolled.\n */\n static domEventHandlers(handlers) {\n return ViewPlugin.define(() => ({}), { eventHandlers: handlers });\n }\n /**\n Create an extension that registers DOM event observers. Contrary\n to event [handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers),\n observers can't be prevented from running by a higher-precedence\n handler returning true. They also don't prevent other handlers\n and observers from running when they return true, and should not\n call `preventDefault`.\n */\n static domEventObservers(observers) {\n return ViewPlugin.define(() => ({}), { eventObservers: observers });\n }\n /**\n Create a theme extension. The first argument can be a\n [`style-mod`](https://github.com/marijnh/style-mod#documentation)\n style spec providing the styles for the theme. These will be\n prefixed with a generated class for the style.\n \n Because the selectors will be prefixed with a scope class, rule\n that directly match the editor's [wrapper\n element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be\n added—need to be explicitly differentiated by adding an `&` to\n the selector for that element—for example\n `&.cm-focused`.\n \n When `dark` is set to true, the theme will be marked as dark,\n which will cause the `&dark` rules from [base\n themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to\n `&light` when a light theme is active).\n */\n static theme(spec, options) {\n let prefix = StyleModule.newName();\n let result = [theme.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];\n if (options && options.dark)\n result.push(darkTheme.of(true));\n return result;\n }\n /**\n Create an extension that adds styles to the base theme. Like\n with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the\n place of the editor wrapper element when directly targeting\n that. You can also use `&dark` or `&light` instead to only\n target editors with a dark or light theme.\n */\n static baseTheme(spec) {\n return Prec.lowest(styleModule.of(buildTheme(\".\" + baseThemeID, spec, lightDarkIDs)));\n }\n /**\n Retrieve an editor view instance from the view's DOM\n representation.\n */\n static findFromDOM(dom) {\n var _a;\n let content = dom.querySelector(\".cm-content\");\n let cView = content && ContentView.get(content) || ContentView.get(dom);\n return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;\n }\n}\n/**\nFacet to add a [style\nmodule](https://github.com/marijnh/style-mod#documentation) to\nan editor view. The view will ensure that the module is\nmounted in its [document\nroot](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).\n*/\nEditorView.styleModule = styleModule;\n/**\nAn input handler can override the way changes to the editable\nDOM content are handled. Handlers are passed the document\npositions between which the change was found, and the new\ncontent. When one returns true, no further input handlers are\ncalled and the default behavior is prevented.\n\nThe `insert` argument can be used to get the default transaction\nthat would be applied for this input. This can be useful when\ndispatching the custom behavior as a separate transaction.\n*/\nEditorView.inputHandler = inputHandler;\n/**\nThis facet can be used to provide functions that create effects\nto be dispatched when the editor's focus state changes.\n*/\nEditorView.focusChangeEffect = focusChangeEffect;\n/**\nBy default, the editor assumes all its content has the same\n[text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`\nvalue to make it read the text direction of every (rendered)\nline separately.\n*/\nEditorView.perLineTextDirection = perLineTextDirection;\n/**\nAllows you to provide a function that should be called when the\nlibrary catches an exception from an extension (mostly from view\nplugins, but may be used by other extensions to route exceptions\nfrom user-code-provided callbacks). This is mostly useful for\ndebugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).\n*/\nEditorView.exceptionSink = exceptionSink;\n/**\nA facet that can be used to register a function to be called\nevery time the view updates.\n*/\nEditorView.updateListener = updateListener;\n/**\nFacet that controls whether the editor content DOM is editable.\nWhen its highest-precedence value is `false`, the element will\nnot have its `contenteditable` attribute set. (Note that this\ndoesn't affect API calls that change the editor content, even\nwhen those are bound to keys or buttons. See the\n[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)\n*/\nEditorView.editable = editable;\n/**\nAllows you to influence the way mouse selection happens. The\nfunctions in this facet will be called for a `mousedown` event\non the editor, and can return an object that overrides the way a\nselection is computed from that mouse click or drag.\n*/\nEditorView.mouseSelectionStyle = mouseSelectionStyle;\n/**\nFacet used to configure whether a given selection drag event\nshould move or copy the selection. The given predicate will be\ncalled with the `mousedown` event, and can return `true` when\nthe drag should move the content.\n*/\nEditorView.dragMovesSelection = dragMovesSelection$1;\n/**\nFacet used to configure whether a given selecting click adds a\nnew range to the existing selection or replaces it entirely. The\ndefault behavior is to check `event.metaKey` on macOS, and\n`event.ctrlKey` elsewhere.\n*/\nEditorView.clickAddsSelectionRange = clickAddsSelectionRange;\n/**\nA facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)\nare shown in the view. Decorations can be provided in two\nways—directly, or via a function that takes an editor view.\n\nOnly decoration sets provided directly are allowed to influence\nthe editor's vertical layout structure. The ones provided as\nfunctions are called _after_ the new viewport has been computed,\nand thus **must not** introduce block widgets or replacing\ndecorations that cover line breaks.\n\nIf you want decorated ranges to behave like atomic units for\ncursor motion and deletion purposes, also provide the range set\ncontaining the decorations to\n[`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).\n*/\nEditorView.decorations = decorations;\n/**\nUsed to provide ranges that should be treated as atoms as far as\ncursor motion is concerned. This causes methods like\n[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and\n[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the\ncommands built on top of them) to skip across such regions when\na selection endpoint would enter them. This does _not_ prevent\ndirect programmatic [selection\nupdates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such\nregions.\n*/\nEditorView.atomicRanges = atomicRanges;\n/**\nWhen range decorations add a `unicode-bidi: isolate` style, they\nshould also include a\n[`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property\nin their decoration spec, and be exposed through this facet, so\nthat the editor can compute the proper text order. (Other values\nfor `unicode-bidi`, except of course `normal`, are not\nsupported.)\n*/\nEditorView.bidiIsolatedRanges = bidiIsolatedRanges;\n/**\nFacet that allows extensions to provide additional scroll\nmargins (space around the sides of the scrolling element that\nshould be considered invisible). This can be useful when the\nplugin introduces elements that cover part of that element (for\nexample a horizontally fixed gutter).\n*/\nEditorView.scrollMargins = scrollMargins;\n/**\nThis facet records whether a dark theme is active. The extension\nreturned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically\nincludes an instance of this when the `dark` option is set to\ntrue.\n*/\nEditorView.darkTheme = darkTheme;\n/**\nProvides a Content Security Policy nonce to use when creating\nthe style sheets for the editor. Holds the empty string when no\nnonce has been provided.\n*/\nEditorView.cspNonce = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : \"\" });\n/**\nFacet that provides additional DOM attributes for the editor's\neditable DOM element.\n*/\nEditorView.contentAttributes = contentAttributes;\n/**\nFacet that provides DOM attributes for the editor's outer\nelement.\n*/\nEditorView.editorAttributes = editorAttributes;\n/**\nAn extension that enables line wrapping in the editor (by\nsetting CSS `white-space` to `pre-wrap` in the content).\n*/\nEditorView.lineWrapping = /*@__PURE__*/EditorView.contentAttributes.of({ \"class\": \"cm-lineWrapping\" });\n/**\nState effect used to include screen reader announcements in a\ntransaction. These will be added to the DOM in a visually hidden\nelement with `aria-live=\"polite\"` set, and should be used to\ndescribe effects that are visually obvious but may not be\nnoticed by screen reader users (such as moving to the next\nsearch match).\n*/\nEditorView.announce = /*@__PURE__*/StateEffect.define();\n// Maximum line length for which we compute accurate bidi info\nconst MaxBidiLine = 4096;\nconst BadMeasure = {};\nclass CachedOrder {\n constructor(from, to, dir, isolates, fresh, order) {\n this.from = from;\n this.to = to;\n this.dir = dir;\n this.isolates = isolates;\n this.fresh = fresh;\n this.order = order;\n }\n static update(cache, changes) {\n if (changes.empty && !cache.some(c => c.fresh))\n return cache;\n let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction.LTR;\n for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {\n let entry = cache[i];\n if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))\n result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.isolates, false, entry.order));\n }\n return result;\n }\n}\nfunction attrsFromFacet(view, facet, base) {\n for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {\n let source = sources[i], value = typeof source == \"function\" ? source(view) : source;\n if (value)\n combineAttrs(value, base);\n }\n return base;\n}\n\nconst currentPlatform = browser.mac ? \"mac\" : browser.windows ? \"win\" : browser.linux ? \"linux\" : \"key\";\nfunction normalizeKeyName(name, platform) {\n const parts = name.split(/-(?!$)/);\n let result = parts[parts.length - 1];\n if (result == \"Space\")\n result = \" \";\n let alt, ctrl, shift, meta;\n for (let i = 0; i < parts.length - 1; ++i) {\n const mod = parts[i];\n if (/^(cmd|meta|m)$/i.test(mod))\n meta = true;\n else if (/^a(lt)?$/i.test(mod))\n alt = true;\n else if (/^(c|ctrl|control)$/i.test(mod))\n ctrl = true;\n else if (/^s(hift)?$/i.test(mod))\n shift = true;\n else if (/^mod$/i.test(mod)) {\n if (platform == \"mac\")\n meta = true;\n else\n ctrl = true;\n }\n else\n throw new Error(\"Unrecognized modifier name: \" + mod);\n }\n if (alt)\n result = \"Alt-\" + result;\n if (ctrl)\n result = \"Ctrl-\" + result;\n if (meta)\n result = \"Meta-\" + result;\n if (shift)\n result = \"Shift-\" + result;\n return result;\n}\nfunction modifiers(name, event, shift) {\n if (event.altKey)\n name = \"Alt-\" + name;\n if (event.ctrlKey)\n name = \"Ctrl-\" + name;\n if (event.metaKey)\n name = \"Meta-\" + name;\n if (shift !== false && event.shiftKey)\n name = \"Shift-\" + name;\n return name;\n}\nconst handleKeyEvents = /*@__PURE__*/Prec.default(/*@__PURE__*/EditorView.domEventHandlers({\n keydown(event, view) {\n return runHandlers(getKeymap(view.state), event, view, \"editor\");\n }\n}));\n/**\nFacet used for registering keymaps.\n\nYou can add multiple keymaps to an editor. Their priorities\ndetermine their precedence (the ones specified early or with high\npriority get checked first). When a handler has returned `true`\nfor a given key, no further handlers are called.\n*/\nconst keymap = /*@__PURE__*/Facet.define({ enables: handleKeyEvents });\nconst Keymaps = /*@__PURE__*/new WeakMap();\n// This is hidden behind an indirection, rather than directly computed\n// by the facet, to keep internal types out of the facet's type.\nfunction getKeymap(state) {\n let bindings = state.facet(keymap);\n let map = Keymaps.get(bindings);\n if (!map)\n Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));\n return map;\n}\n/**\nRun the key handlers registered for a given scope. The event\nobject should be a `\"keydown\"` event. Returns true if any of the\nhandlers handled it.\n*/\nfunction runScopeHandlers(view, event, scope) {\n return runHandlers(getKeymap(view.state), event, view, scope);\n}\nlet storedPrefix = null;\nconst PrefixTimeout = 4000;\nfunction buildKeymap(bindings, platform = currentPlatform) {\n let bound = Object.create(null);\n let isPrefix = Object.create(null);\n let checkPrefix = (name, is) => {\n let current = isPrefix[name];\n if (current == null)\n isPrefix[name] = is;\n else if (current != is)\n throw new Error(\"Key binding \" + name + \" is used both as a regular binding and as a multi-stroke prefix\");\n };\n let add = (scope, key, command, preventDefault, stopPropagation) => {\n var _a, _b;\n let scopeObj = bound[scope] || (bound[scope] = Object.create(null));\n let parts = key.split(/ (?!$)/).map(k => normalizeKeyName(k, platform));\n for (let i = 1; i < parts.length; i++) {\n let prefix = parts.slice(0, i).join(\" \");\n checkPrefix(prefix, true);\n if (!scopeObj[prefix])\n scopeObj[prefix] = {\n preventDefault: true,\n stopPropagation: false,\n run: [(view) => {\n let ourObj = storedPrefix = { view, prefix, scope };\n setTimeout(() => { if (storedPrefix == ourObj)\n storedPrefix = null; }, PrefixTimeout);\n return true;\n }]\n };\n }\n let full = parts.join(\" \");\n checkPrefix(full, false);\n let binding = scopeObj[full] || (scopeObj[full] = {\n preventDefault: false,\n stopPropagation: false,\n run: ((_b = (_a = scopeObj._any) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.slice()) || []\n });\n if (command)\n binding.run.push(command);\n if (preventDefault)\n binding.preventDefault = true;\n if (stopPropagation)\n binding.stopPropagation = true;\n };\n for (let b of bindings) {\n let scopes = b.scope ? b.scope.split(\" \") : [\"editor\"];\n if (b.any)\n for (let scope of scopes) {\n let scopeObj = bound[scope] || (bound[scope] = Object.create(null));\n if (!scopeObj._any)\n scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };\n for (let key in scopeObj)\n scopeObj[key].run.push(b.any);\n }\n let name = b[platform] || b.key;\n if (!name)\n continue;\n for (let scope of scopes) {\n add(scope, name, b.run, b.preventDefault, b.stopPropagation);\n if (b.shift)\n add(scope, \"Shift-\" + name, b.shift, b.preventDefault, b.stopPropagation);\n }\n }\n return bound;\n}\nfunction runHandlers(map, event, view, scope) {\n let name = keyName(event);\n let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != \" \";\n let prefix = \"\", handled = false, prevented = false, stopPropagation = false;\n if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {\n prefix = storedPrefix.prefix + \" \";\n if (modifierCodes.indexOf(event.keyCode) < 0) {\n prevented = true;\n storedPrefix = null;\n }\n }\n let ran = new Set;\n let runFor = (binding) => {\n if (binding) {\n for (let cmd of binding.run)\n if (!ran.has(cmd)) {\n ran.add(cmd);\n if (cmd(view, event)) {\n if (binding.stopPropagation)\n stopPropagation = true;\n return true;\n }\n }\n if (binding.preventDefault) {\n if (binding.stopPropagation)\n stopPropagation = true;\n prevented = true;\n }\n }\n return false;\n };\n let scopeObj = map[scope], baseName, shiftName;\n if (scopeObj) {\n if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {\n handled = true;\n }\n else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&\n // Ctrl-Alt may be used for AltGr on Windows\n !(browser.windows && event.ctrlKey && event.altKey) &&\n (baseName = base[event.keyCode]) && baseName != name) {\n if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {\n handled = true;\n }\n else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName &&\n runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) {\n handled = true;\n }\n }\n else if (isChar && event.shiftKey &&\n runFor(scopeObj[prefix + modifiers(name, event, true)])) {\n handled = true;\n }\n if (!handled && runFor(scopeObj._any))\n handled = true;\n }\n if (prevented)\n handled = true;\n if (handled && stopPropagation)\n event.stopPropagation();\n return handled;\n}\n\n/**\nImplementation of [`LayerMarker`](https://codemirror.net/6/docs/ref/#view.LayerMarker) that creates\na rectangle at a given set of coordinates.\n*/\nclass RectangleMarker {\n /**\n Create a marker with the given class and dimensions. If `width`\n is null, the DOM element will get no width style.\n */\n constructor(className, \n /**\n The left position of the marker (in pixels, document-relative).\n */\n left, \n /**\n The top position of the marker.\n */\n top, \n /**\n The width of the marker, or null if it shouldn't get a width assigned.\n */\n width, \n /**\n The height of the marker.\n */\n height) {\n this.className = className;\n this.left = left;\n this.top = top;\n this.width = width;\n this.height = height;\n }\n draw() {\n let elt = document.createElement(\"div\");\n elt.className = this.className;\n this.adjust(elt);\n return elt;\n }\n update(elt, prev) {\n if (prev.className != this.className)\n return false;\n this.adjust(elt);\n return true;\n }\n adjust(elt) {\n elt.style.left = this.left + \"px\";\n elt.style.top = this.top + \"px\";\n if (this.width != null)\n elt.style.width = this.width + \"px\";\n elt.style.height = this.height + \"px\";\n }\n eq(p) {\n return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&\n this.className == p.className;\n }\n /**\n Create a set of rectangles for the given selection range,\n assigning them theclass`className`. Will create a single\n rectangle for empty ranges, and a set of selection-style\n rectangles covering the range's content (in a bidi-aware\n way) for non-empty ones.\n */\n static forRange(view, className, range) {\n if (range.empty) {\n let pos = view.coordsAtPos(range.head, range.assoc || 1);\n if (!pos)\n return [];\n let base = getBase(view);\n return [new RectangleMarker(className, pos.left - base.left, pos.top - base.top, null, pos.bottom - pos.top)];\n }\n else {\n return rectanglesForRange(view, className, range);\n }\n }\n}\nfunction getBase(view) {\n let rect = view.scrollDOM.getBoundingClientRect();\n let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth * view.scaleX;\n return { left: left - view.scrollDOM.scrollLeft * view.scaleX, top: rect.top - view.scrollDOM.scrollTop * view.scaleY };\n}\nfunction wrappedLine(view, pos, inside) {\n let range = EditorSelection.cursor(pos);\n return { from: Math.max(inside.from, view.moveToLineBoundary(range, false, true).from),\n to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),\n type: BlockType.Text };\n}\nfunction rectanglesForRange(view, className, range) {\n if (range.to <= view.viewport.from || range.from >= view.viewport.to)\n return [];\n let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);\n let ltr = view.textDirection == Direction.LTR;\n let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);\n let lineElt = content.querySelector(\".cm-line\"), lineStyle = lineElt && window.getComputedStyle(lineElt);\n let leftSide = contentRect.left +\n (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);\n let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);\n let startBlock = blockAt(view, from), endBlock = blockAt(view, to);\n let visualStart = startBlock.type == BlockType.Text ? startBlock : null;\n let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;\n if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))\n visualStart = wrappedLine(view, from, visualStart);\n if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))\n visualEnd = wrappedLine(view, to, visualEnd);\n if (visualStart && visualEnd && visualStart.from == visualEnd.from) {\n return pieces(drawForLine(range.from, range.to, visualStart));\n }\n else {\n let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);\n let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);\n let between = [];\n if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||\n startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)\n between.push(piece(leftSide, top.bottom, rightSide, bottom.top));\n else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text)\n top.bottom = bottom.top = (top.bottom + bottom.top) / 2;\n return pieces(top).concat(between).concat(pieces(bottom));\n }\n function piece(left, top, right, bottom) {\n return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */);\n }\n function pieces({ top, bottom, horizontal }) {\n let pieces = [];\n for (let i = 0; i < horizontal.length; i += 2)\n pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));\n return pieces;\n }\n // Gets passed from/to in line-local positions\n function drawForLine(from, to, line) {\n let top = 1e9, bottom = -1e9, horizontal = [];\n function addSpan(from, fromOpen, to, toOpen, dir) {\n // Passing 2/-2 is a kludge to force the view to return\n // coordinates on the proper side of block widgets, since\n // normalizing the side there, though appropriate for most\n // coordsAtPos queries, would break selection drawing.\n let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));\n let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));\n if (!fromCoords || !toCoords)\n return;\n top = Math.min(fromCoords.top, toCoords.top, top);\n bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);\n if (dir == Direction.LTR)\n horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);\n else\n horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);\n }\n let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;\n // Split the range by visible range and document line\n for (let r of view.visibleRanges)\n if (r.to > start && r.from < end) {\n for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {\n let docLine = view.state.doc.lineAt(pos);\n for (let span of view.bidiSpans(docLine)) {\n let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;\n if (spanFrom >= endPos)\n break;\n if (spanTo > pos)\n addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);\n }\n pos = docLine.to + 1;\n if (pos >= endPos)\n break;\n }\n }\n if (horizontal.length == 0)\n addSpan(start, from == null, end, to == null, view.textDirection);\n return { top, bottom, horizontal };\n }\n function drawForWidget(block, top) {\n let y = contentRect.top + (top ? block.top : block.bottom);\n return { top: y, bottom: y, horizontal: [] };\n }\n}\nfunction sameMarker(a, b) {\n return a.constructor == b.constructor && a.eq(b);\n}\nclass LayerView {\n constructor(view, layer) {\n this.view = view;\n this.layer = layer;\n this.drawn = [];\n this.scaleX = 1;\n this.scaleY = 1;\n this.measureReq = { read: this.measure.bind(this), write: this.draw.bind(this) };\n this.dom = view.scrollDOM.appendChild(document.createElement(\"div\"));\n this.dom.classList.add(\"cm-layer\");\n if (layer.above)\n this.dom.classList.add(\"cm-layer-above\");\n if (layer.class)\n this.dom.classList.add(layer.class);\n this.scale();\n this.dom.setAttribute(\"aria-hidden\", \"true\");\n this.setOrder(view.state);\n view.requestMeasure(this.measureReq);\n if (layer.mount)\n layer.mount(this.dom, view);\n }\n update(update) {\n if (update.startState.facet(layerOrder) != update.state.facet(layerOrder))\n this.setOrder(update.state);\n if (this.layer.update(update, this.dom) || update.geometryChanged) {\n this.scale();\n update.view.requestMeasure(this.measureReq);\n }\n }\n setOrder(state) {\n let pos = 0, order = state.facet(layerOrder);\n while (pos < order.length && order[pos] != this.layer)\n pos++;\n this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - pos);\n }\n measure() {\n return this.layer.markers(this.view);\n }\n scale() {\n let { scaleX, scaleY } = this.view;\n if (scaleX != this.scaleX || scaleY != this.scaleY) {\n this.scaleX = scaleX;\n this.scaleY = scaleY;\n this.dom.style.transform = `scale(${1 / scaleX}, ${1 / scaleY})`;\n }\n }\n draw(markers) {\n if (markers.length != this.drawn.length || markers.some((p, i) => !sameMarker(p, this.drawn[i]))) {\n let old = this.dom.firstChild, oldI = 0;\n for (let marker of markers) {\n if (marker.update && old && marker.constructor && this.drawn[oldI].constructor &&\n marker.update(old, this.drawn[oldI])) {\n old = old.nextSibling;\n oldI++;\n }\n else {\n this.dom.insertBefore(marker.draw(), old);\n }\n }\n while (old) {\n let next = old.nextSibling;\n old.remove();\n old = next;\n }\n this.drawn = markers;\n }\n }\n destroy() {\n if (this.layer.destroy)\n this.layer.destroy(this.dom, this.view);\n this.dom.remove();\n }\n}\nconst layerOrder = /*@__PURE__*/Facet.define();\n/**\nDefine a layer.\n*/\nfunction layer(config) {\n return [\n ViewPlugin.define(v => new LayerView(v, config)),\n layerOrder.of(config)\n ];\n}\n\nconst CanHidePrimary = !browser.ios; // FIXME test IE\nconst selectionConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n cursorBlinkRate: 1200,\n drawRangeCursor: true\n }, {\n cursorBlinkRate: (a, b) => Math.min(a, b),\n drawRangeCursor: (a, b) => a || b\n });\n }\n});\n/**\nReturns an extension that hides the browser's native selection and\ncursor, replacing the selection with a background behind the text\n(with the `cm-selectionBackground` class), and the\ncursors with elements overlaid over the code (using\n`cm-cursor-primary` and `cm-cursor-secondary`).\n\nThis allows the editor to display secondary selection ranges, and\ntends to produce a type of selection more in line with that users\nexpect in a text editor (the native selection styling will often\nleave gaps between lines and won't fill the horizontal space after\na line when the selection continues past it).\n\nIt does have a performance cost, in that it requires an extra DOM\nlayout cycle for many updates (the selection is drawn based on DOM\nlayout information that's only available after laying out the\ncontent).\n*/\nfunction drawSelection(config = {}) {\n return [\n selectionConfig.of(config),\n cursorLayer,\n selectionLayer,\n hideNativeSelection,\n nativeSelectionHidden.of(true)\n ];\n}\n/**\nRetrieve the [`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) configuration\nfor this state. (Note that this will return a set of defaults even\nif `drawSelection` isn't enabled.)\n*/\nfunction getDrawSelectionConfig(state) {\n return state.facet(selectionConfig);\n}\nfunction configChanged(update) {\n return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);\n}\nconst cursorLayer = /*@__PURE__*/layer({\n above: true,\n markers(view) {\n let { state } = view, conf = state.facet(selectionConfig);\n let cursors = [];\n for (let r of state.selection.ranges) {\n let prim = r == state.selection.main;\n if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {\n let className = prim ? \"cm-cursor cm-cursor-primary\" : \"cm-cursor cm-cursor-secondary\";\n let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);\n for (let piece of RectangleMarker.forRange(view, className, cursor))\n cursors.push(piece);\n }\n }\n return cursors;\n },\n update(update, dom) {\n if (update.transactions.some(tr => tr.selection))\n dom.style.animationName = dom.style.animationName == \"cm-blink\" ? \"cm-blink2\" : \"cm-blink\";\n let confChange = configChanged(update);\n if (confChange)\n setBlinkRate(update.state, dom);\n return update.docChanged || update.selectionSet || confChange;\n },\n mount(dom, view) {\n setBlinkRate(view.state, dom);\n },\n class: \"cm-cursorLayer\"\n});\nfunction setBlinkRate(state, dom) {\n dom.style.animationDuration = state.facet(selectionConfig).cursorBlinkRate + \"ms\";\n}\nconst selectionLayer = /*@__PURE__*/layer({\n above: false,\n markers(view) {\n return view.state.selection.ranges.map(r => r.empty ? [] : RectangleMarker.forRange(view, \"cm-selectionBackground\", r))\n .reduce((a, b) => a.concat(b));\n },\n update(update, dom) {\n return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);\n },\n class: \"cm-selectionLayer\"\n});\nconst themeSpec = {\n \".cm-line\": {\n \"& ::selection\": { backgroundColor: \"transparent !important\" },\n \"&::selection\": { backgroundColor: \"transparent !important\" }\n }\n};\nif (CanHidePrimary) {\n themeSpec[\".cm-line\"].caretColor = \"transparent !important\";\n themeSpec[\".cm-content\"] = { caretColor: \"transparent !important\" };\n}\nconst hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));\n\nconst setDropCursorPos = /*@__PURE__*/StateEffect.define({\n map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }\n});\nconst dropCursorPos = /*@__PURE__*/StateField.define({\n create() { return null; },\n update(pos, tr) {\n if (pos != null)\n pos = tr.changes.mapPos(pos);\n return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);\n }\n});\nconst drawDropCursor = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.cursor = null;\n this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };\n }\n update(update) {\n var _a;\n let cursorPos = update.state.field(dropCursorPos);\n if (cursorPos == null) {\n if (this.cursor != null) {\n (_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();\n this.cursor = null;\n }\n }\n else {\n if (!this.cursor) {\n this.cursor = this.view.scrollDOM.appendChild(document.createElement(\"div\"));\n this.cursor.className = \"cm-dropCursor\";\n }\n if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)\n this.view.requestMeasure(this.measureReq);\n }\n }\n readPos() {\n let { view } = this;\n let pos = view.state.field(dropCursorPos);\n let rect = pos != null && view.coordsAtPos(pos);\n if (!rect)\n return null;\n let outer = view.scrollDOM.getBoundingClientRect();\n return {\n left: rect.left - outer.left + view.scrollDOM.scrollLeft * view.scaleX,\n top: rect.top - outer.top + view.scrollDOM.scrollTop * view.scaleY,\n height: rect.bottom - rect.top\n };\n }\n drawCursor(pos) {\n if (this.cursor) {\n let { scaleX, scaleY } = this.view;\n if (pos) {\n this.cursor.style.left = pos.left / scaleX + \"px\";\n this.cursor.style.top = pos.top / scaleY + \"px\";\n this.cursor.style.height = pos.height / scaleY + \"px\";\n }\n else {\n this.cursor.style.left = \"-100000px\";\n }\n }\n }\n destroy() {\n if (this.cursor)\n this.cursor.remove();\n }\n setDropPos(pos) {\n if (this.view.state.field(dropCursorPos) != pos)\n this.view.dispatch({ effects: setDropCursorPos.of(pos) });\n }\n}, {\n eventObservers: {\n dragover(event) {\n this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));\n },\n dragleave(event) {\n if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))\n this.setDropPos(null);\n },\n dragend() {\n this.setDropPos(null);\n },\n drop() {\n this.setDropPos(null);\n }\n }\n});\n/**\nDraws a cursor at the current drop position when something is\ndragged over the editor.\n*/\nfunction dropCursor() {\n return [dropCursorPos, drawDropCursor];\n}\n\nfunction iterMatches(doc, re, from, to, f) {\n re.lastIndex = 0;\n for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {\n if (!cursor.lineBreak)\n while (m = re.exec(cursor.value))\n f(pos + m.index, m);\n }\n}\nfunction matchRanges(view, maxLength) {\n let visible = view.visibleRanges;\n if (visible.length == 1 && visible[0].from == view.viewport.from &&\n visible[0].to == view.viewport.to)\n return visible;\n let result = [];\n for (let { from, to } of visible) {\n from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);\n to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);\n if (result.length && result[result.length - 1].to >= from)\n result[result.length - 1].to = to;\n else\n result.push({ from, to });\n }\n return result;\n}\n/**\nHelper class used to make it easier to maintain decorations on\nvisible code that matches a given regular expression. To be used\nin a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object\nrepresent a matching configuration.\n*/\nclass MatchDecorator {\n /**\n Create a decorator.\n */\n constructor(config) {\n const { regexp, decoration, decorate, boundary, maxLength = 1000 } = config;\n if (!regexp.global)\n throw new RangeError(\"The regular expression given to MatchDecorator should have its 'g' flag set\");\n this.regexp = regexp;\n if (decorate) {\n this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);\n }\n else if (typeof decoration == \"function\") {\n this.addMatch = (match, view, from, add) => {\n let deco = decoration(match, view, from);\n if (deco)\n add(from, from + match[0].length, deco);\n };\n }\n else if (decoration) {\n this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);\n }\n else {\n throw new RangeError(\"Either 'decorate' or 'decoration' should be provided to MatchDecorator\");\n }\n this.boundary = boundary;\n this.maxLength = maxLength;\n }\n /**\n Compute the full set of decorations for matches in the given\n view's viewport. You'll want to call this when initializing your\n plugin.\n */\n createDeco(view) {\n let build = new RangeSetBuilder(), add = build.add.bind(build);\n for (let { from, to } of matchRanges(view, this.maxLength))\n iterMatches(view.state.doc, this.regexp, from, to, (from, m) => this.addMatch(m, view, from, add));\n return build.finish();\n }\n /**\n Update a set of decorations for a view update. `deco` _must_ be\n the set of decorations produced by _this_ `MatchDecorator` for\n the view state before the update.\n */\n updateDeco(update, deco) {\n let changeFrom = 1e9, changeTo = -1;\n if (update.docChanged)\n update.changes.iterChanges((_f, _t, from, to) => {\n if (to > update.view.viewport.from && from < update.view.viewport.to) {\n changeFrom = Math.min(from, changeFrom);\n changeTo = Math.max(to, changeTo);\n }\n });\n if (update.viewportChanged || changeTo - changeFrom > 1000)\n return this.createDeco(update.view);\n if (changeTo > -1)\n return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);\n return deco;\n }\n updateRange(view, deco, updateFrom, updateTo) {\n for (let r of view.visibleRanges) {\n let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);\n if (to > from) {\n let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;\n let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);\n if (this.boundary) {\n for (; from > fromLine.from; from--)\n if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {\n start = from;\n break;\n }\n for (; to < toLine.to; to++)\n if (this.boundary.test(toLine.text[to - toLine.from])) {\n end = to;\n break;\n }\n }\n let ranges = [], m;\n let add = (from, to, deco) => ranges.push(deco.range(from, to));\n if (fromLine == toLine) {\n this.regexp.lastIndex = start - fromLine.from;\n while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from)\n this.addMatch(m, view, m.index + fromLine.from, add);\n }\n else {\n iterMatches(view.state.doc, this.regexp, start, end, (from, m) => this.addMatch(m, view, from, add));\n }\n deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });\n }\n }\n return deco;\n }\n}\n\nconst UnicodeRegexpSupport = /x/.unicode != null ? \"gu\" : \"g\";\nconst 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);\nconst Names = {\n 0: \"null\",\n 7: \"bell\",\n 8: \"backspace\",\n 10: \"newline\",\n 11: \"vertical tab\",\n 13: \"carriage return\",\n 27: \"escape\",\n 8203: \"zero width space\",\n 8204: \"zero width non-joiner\",\n 8205: \"zero width joiner\",\n 8206: \"left-to-right mark\",\n 8207: \"right-to-left mark\",\n 8232: \"line separator\",\n 8237: \"left-to-right override\",\n 8238: \"right-to-left override\",\n 8294: \"left-to-right isolate\",\n 8295: \"right-to-left isolate\",\n 8297: \"pop directional isolate\",\n 8233: \"paragraph separator\",\n 65279: \"zero width no-break space\",\n 65532: \"object replacement\"\n};\nlet _supportsTabSize = null;\nfunction supportsTabSize() {\n var _a;\n if (_supportsTabSize == null && typeof document != \"undefined\" && document.body) {\n let styles = document.body.style;\n _supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;\n }\n return _supportsTabSize || false;\n}\nconst specialCharConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n let config = combineConfig(configs, {\n render: null,\n specialChars: Specials,\n addSpecialChars: null\n });\n if (config.replaceTabs = !supportsTabSize())\n config.specialChars = new RegExp(\"\\t|\" + config.specialChars.source, UnicodeRegexpSupport);\n if (config.addSpecialChars)\n config.specialChars = new RegExp(config.specialChars.source + \"|\" + config.addSpecialChars.source, UnicodeRegexpSupport);\n return config;\n }\n});\n/**\nReturns an extension that installs highlighting of special\ncharacters.\n*/\nfunction highlightSpecialChars(\n/**\nConfiguration options.\n*/\nconfig = {}) {\n return [specialCharConfig.of(config), specialCharPlugin()];\n}\nlet _plugin = null;\nfunction specialCharPlugin() {\n return _plugin || (_plugin = ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.decorations = Decoration.none;\n this.decorationCache = Object.create(null);\n this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));\n this.decorations = this.decorator.createDeco(view);\n }\n makeDecorator(conf) {\n return new MatchDecorator({\n regexp: conf.specialChars,\n decoration: (m, view, pos) => {\n let { doc } = view.state;\n let code = codePointAt(m[0], 0);\n if (code == 9) {\n let line = doc.lineAt(pos);\n let size = view.state.tabSize, col = countColumn(line.text, size, pos - line.from);\n return Decoration.replace({\n widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth / this.view.scaleX)\n });\n }\n return this.decorationCache[code] ||\n (this.decorationCache[code] = Decoration.replace({ widget: new SpecialCharWidget(conf, code) }));\n },\n boundary: conf.replaceTabs ? undefined : /[^]/\n });\n }\n update(update) {\n let conf = update.state.facet(specialCharConfig);\n if (update.startState.facet(specialCharConfig) != conf) {\n this.decorator = this.makeDecorator(conf);\n this.decorations = this.decorator.createDeco(update.view);\n }\n else {\n this.decorations = this.decorator.updateDeco(update, this.decorations);\n }\n }\n }, {\n decorations: v => v.decorations\n }));\n}\nconst DefaultPlaceholder = \"\\u2022\";\n// Assigns placeholder characters from the Control Pictures block to\n// ASCII control characters\nfunction placeholder$1(code) {\n if (code >= 32)\n return DefaultPlaceholder;\n if (code == 10)\n return \"\\u2424\";\n return String.fromCharCode(9216 + code);\n}\nclass SpecialCharWidget extends WidgetType {\n constructor(options, code) {\n super();\n this.options = options;\n this.code = code;\n }\n eq(other) { return other.code == this.code; }\n toDOM(view) {\n let ph = placeholder$1(this.code);\n let desc = view.state.phrase(\"Control character\") + \" \" + (Names[this.code] || \"0x\" + this.code.toString(16));\n let custom = this.options.render && this.options.render(this.code, desc, ph);\n if (custom)\n return custom;\n let span = document.createElement(\"span\");\n span.textContent = ph;\n span.title = desc;\n span.setAttribute(\"aria-label\", desc);\n span.className = \"cm-specialChar\";\n return span;\n }\n ignoreEvent() { return false; }\n}\nclass TabWidget extends WidgetType {\n constructor(width) {\n super();\n this.width = width;\n }\n eq(other) { return other.width == this.width; }\n toDOM() {\n let span = document.createElement(\"span\");\n span.textContent = \"\\t\";\n span.className = \"cm-tab\";\n span.style.width = this.width + \"px\";\n return span;\n }\n ignoreEvent() { return false; }\n}\n\nconst plugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor() {\n this.height = 1000;\n this.attrs = { style: \"padding-bottom: 1000px\" };\n }\n update(update) {\n let { view } = update;\n let height = view.viewState.editorHeight * view.scaleY -\n view.defaultLineHeight - view.documentPadding.top - 0.5;\n if (height >= 0 && height != this.height) {\n this.height = height;\n this.attrs = { style: `padding-bottom: ${height}px` };\n }\n }\n});\n/**\nReturns an extension that makes sure the content has a bottom\nmargin equivalent to the height of the editor, minus one line\nheight, so that every line in the document can be scrolled to the\ntop of the editor.\n\nThis is only meaningful when the editor is scrollable, and should\nnot be enabled in editors that take the size of their content.\n*/\nfunction scrollPastEnd() {\n return [plugin, contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.attrs) || null; })];\n}\n\n/**\nMark lines that have a cursor on them with the `\"cm-activeLine\"`\nDOM class.\n*/\nfunction highlightActiveLine() {\n return activeLineHighlighter;\n}\nconst lineDeco = /*@__PURE__*/Decoration.line({ class: \"cm-activeLine\" });\nconst activeLineHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.decorations = this.getDeco(view);\n }\n update(update) {\n if (update.docChanged || update.selectionSet)\n this.decorations = this.getDeco(update.view);\n }\n getDeco(view) {\n let lastLineStart = -1, deco = [];\n for (let r of view.state.selection.ranges) {\n let line = view.lineBlockAt(r.head);\n if (line.from > lastLineStart) {\n deco.push(lineDeco.range(line.from));\n lastLineStart = line.from;\n }\n }\n return Decoration.set(deco);\n }\n}, {\n decorations: v => v.decorations\n});\n\nclass Placeholder extends WidgetType {\n constructor(content) {\n super();\n this.content = content;\n }\n toDOM() {\n let wrap = document.createElement(\"span\");\n wrap.className = \"cm-placeholder\";\n wrap.style.pointerEvents = \"none\";\n wrap.appendChild(typeof this.content == \"string\" ? document.createTextNode(this.content) : this.content);\n if (typeof this.content == \"string\")\n wrap.setAttribute(\"aria-label\", \"placeholder \" + this.content);\n else\n wrap.setAttribute(\"aria-hidden\", \"true\");\n return wrap;\n }\n coordsAt(dom) {\n let rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];\n if (!rects.length)\n return null;\n let style = window.getComputedStyle(dom.parentNode);\n let rect = flattenRect(rects[0], style.direction != \"rtl\");\n let lineHeight = parseInt(style.lineHeight);\n if (rect.bottom - rect.top > lineHeight * 1.5)\n return { left: rect.left, right: rect.right, top: rect.top, bottom: rect.top + lineHeight };\n return rect;\n }\n ignoreEvent() { return false; }\n}\n/**\nExtension that enables a placeholder—a piece of example content\nto show when the editor is empty.\n*/\nfunction placeholder(content) {\n return ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.placeholder = content\n ? Decoration.set([Decoration.widget({ widget: new Placeholder(content), side: 1 }).range(0)])\n : Decoration.none;\n }\n get decorations() { return this.view.state.doc.length ? Decoration.none : this.placeholder; }\n }, { decorations: v => v.decorations });\n}\n\n// Don't compute precise column positions for line offsets above this\n// (since it could get expensive). Assume offset==column for them.\nconst MaxOff = 2000;\nfunction rectangleFor(state, a, b) {\n let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);\n let ranges = [];\n if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {\n let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);\n for (let i = startLine; i <= endLine; i++) {\n let line = state.doc.line(i);\n if (line.length <= endOff)\n ranges.push(EditorSelection.range(line.from + startOff, line.to + endOff));\n }\n }\n else {\n let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);\n for (let i = startLine; i <= endLine; i++) {\n let line = state.doc.line(i);\n let start = findColumn(line.text, startCol, state.tabSize, true);\n if (start < 0) {\n ranges.push(EditorSelection.cursor(line.to));\n }\n else {\n let end = findColumn(line.text, endCol, state.tabSize);\n ranges.push(EditorSelection.range(line.from + start, line.from + end));\n }\n }\n }\n return ranges;\n}\nfunction absoluteColumn(view, x) {\n let ref = view.coordsAtPos(view.viewport.from);\n return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;\n}\nfunction getPos(view, event) {\n let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n let line = view.state.doc.lineAt(offset), off = offset - line.from;\n let col = off > MaxOff ? -1\n : off == line.length ? absoluteColumn(view, event.clientX)\n : countColumn(line.text, view.state.tabSize, offset - line.from);\n return { line: line.number, col, off };\n}\nfunction rectangleSelectionStyle(view, event) {\n let start = getPos(view, event), startSel = view.state.selection;\n if (!start)\n return null;\n return {\n update(update) {\n if (update.docChanged) {\n let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);\n let newLine = update.state.doc.lineAt(newStart);\n start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };\n startSel = startSel.map(update.changes);\n }\n },\n get(event, _extend, multiple) {\n let cur = getPos(view, event);\n if (!cur)\n return startSel;\n let ranges = rectangleFor(view.state, start, cur);\n if (!ranges.length)\n return startSel;\n if (multiple)\n return EditorSelection.create(ranges.concat(startSel.ranges));\n else\n return EditorSelection.create(ranges);\n }\n };\n}\n/**\nCreate an extension that enables rectangular selections. By\ndefault, it will react to left mouse drag with the Alt key held\ndown. When such a selection occurs, the text within the rectangle\nthat was dragged over will be selected, as one selection\n[range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.\n*/\nfunction rectangularSelection(options) {\n let filter = (options === null || options === void 0 ? void 0 : options.eventFilter) || (e => e.altKey && e.button == 0);\n return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);\n}\nconst keys = {\n Alt: [18, e => !!e.altKey],\n Control: [17, e => !!e.ctrlKey],\n Shift: [16, e => !!e.shiftKey],\n Meta: [91, e => !!e.metaKey]\n};\nconst showCrosshair = { style: \"cursor: crosshair\" };\n/**\nReturns an extension that turns the pointer cursor into a\ncrosshair when a given modifier key, defaulting to Alt, is held\ndown. Can serve as a visual hint that rectangular selection is\ngoing to happen when paired with\n[`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).\n*/\nfunction crosshairCursor(options = {}) {\n let [code, getter] = keys[options.key || \"Alt\"];\n let plugin = ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.isDown = false;\n }\n set(isDown) {\n if (this.isDown != isDown) {\n this.isDown = isDown;\n this.view.update([]);\n }\n }\n }, {\n eventObservers: {\n keydown(e) {\n this.set(e.keyCode == code || getter(e));\n },\n keyup(e) {\n if (e.keyCode == code || !getter(e))\n this.set(false);\n },\n mousemove(e) {\n this.set(getter(e));\n }\n }\n });\n return [\n plugin,\n EditorView.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })\n ];\n}\n\nconst Outside = \"-10000px\";\nclass TooltipViewManager {\n constructor(view, facet, createTooltipView) {\n this.facet = facet;\n this.createTooltipView = createTooltipView;\n this.input = view.state.facet(facet);\n this.tooltips = this.input.filter(t => t);\n this.tooltipViews = this.tooltips.map(createTooltipView);\n }\n update(update, above) {\n var _a;\n let input = update.state.facet(this.facet);\n let tooltips = input.filter(x => x);\n if (input === this.input) {\n for (let t of this.tooltipViews)\n if (t.update)\n t.update(update);\n return false;\n }\n let tooltipViews = [], newAbove = above ? [] : null;\n for (let i = 0; i < tooltips.length; i++) {\n let tip = tooltips[i], known = -1;\n if (!tip)\n continue;\n for (let i = 0; i < this.tooltips.length; i++) {\n let other = this.tooltips[i];\n if (other && other.create == tip.create)\n known = i;\n }\n if (known < 0) {\n tooltipViews[i] = this.createTooltipView(tip);\n if (newAbove)\n newAbove[i] = !!tip.above;\n }\n else {\n let tooltipView = tooltipViews[i] = this.tooltipViews[known];\n if (newAbove)\n newAbove[i] = above[known];\n if (tooltipView.update)\n tooltipView.update(update);\n }\n }\n for (let t of this.tooltipViews)\n if (tooltipViews.indexOf(t) < 0) {\n t.dom.remove();\n (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);\n }\n if (above) {\n newAbove.forEach((val, i) => above[i] = val);\n above.length = newAbove.length;\n }\n this.input = input;\n this.tooltips = tooltips;\n this.tooltipViews = tooltipViews;\n return true;\n }\n}\n/**\nCreates an extension that configures tooltip behavior.\n*/\nfunction tooltips(config = {}) {\n return tooltipConfig.of(config);\n}\nfunction windowSpace(view) {\n let { win } = view;\n return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };\n}\nconst tooltipConfig = /*@__PURE__*/Facet.define({\n combine: values => {\n var _a, _b, _c;\n return ({\n position: browser.ios ? \"absolute\" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || \"fixed\",\n parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,\n tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,\n });\n }\n});\nconst knownHeight = /*@__PURE__*/new WeakMap();\nconst tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.above = [];\n this.inView = true;\n this.madeAbsolute = false;\n this.lastTransaction = 0;\n this.measureTimeout = -1;\n let config = view.state.facet(tooltipConfig);\n this.position = config.position;\n this.parent = config.parent;\n this.classes = view.themeClasses;\n this.createContainer();\n this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };\n this.manager = new TooltipViewManager(view, showTooltip, t => this.createTooltip(t));\n this.intersectionObserver = typeof IntersectionObserver == \"function\" ? new IntersectionObserver(entries => {\n if (Date.now() > this.lastTransaction - 50 &&\n entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)\n this.measureSoon();\n }, { threshold: [1] }) : null;\n this.observeIntersection();\n view.win.addEventListener(\"resize\", this.measureSoon = this.measureSoon.bind(this));\n this.maybeMeasure();\n }\n createContainer() {\n if (this.parent) {\n this.container = document.createElement(\"div\");\n this.container.style.position = \"relative\";\n this.container.className = this.view.themeClasses;\n this.parent.appendChild(this.container);\n }\n else {\n this.container = this.view.dom;\n }\n }\n observeIntersection() {\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect();\n for (let tooltip of this.manager.tooltipViews)\n this.intersectionObserver.observe(tooltip.dom);\n }\n }\n measureSoon() {\n if (this.measureTimeout < 0)\n this.measureTimeout = setTimeout(() => {\n this.measureTimeout = -1;\n this.maybeMeasure();\n }, 50);\n }\n update(update) {\n if (update.transactions.length)\n this.lastTransaction = Date.now();\n let updated = this.manager.update(update, this.above);\n if (updated)\n this.observeIntersection();\n let shouldMeasure = updated || update.geometryChanged;\n let newConfig = update.state.facet(tooltipConfig);\n if (newConfig.position != this.position && !this.madeAbsolute) {\n this.position = newConfig.position;\n for (let t of this.manager.tooltipViews)\n t.dom.style.position = this.position;\n shouldMeasure = true;\n }\n if (newConfig.parent != this.parent) {\n if (this.parent)\n this.container.remove();\n this.parent = newConfig.parent;\n this.createContainer();\n for (let t of this.manager.tooltipViews)\n this.container.appendChild(t.dom);\n shouldMeasure = true;\n }\n else if (this.parent && this.view.themeClasses != this.classes) {\n this.classes = this.container.className = this.view.themeClasses;\n }\n if (shouldMeasure)\n this.maybeMeasure();\n }\n createTooltip(tooltip) {\n let tooltipView = tooltip.create(this.view);\n tooltipView.dom.classList.add(\"cm-tooltip\");\n if (tooltip.arrow && !tooltipView.dom.querySelector(\".cm-tooltip > .cm-tooltip-arrow\")) {\n let arrow = document.createElement(\"div\");\n arrow.className = \"cm-tooltip-arrow\";\n tooltipView.dom.appendChild(arrow);\n }\n tooltipView.dom.style.position = this.position;\n tooltipView.dom.style.top = Outside;\n tooltipView.dom.style.left = \"0px\";\n this.container.appendChild(tooltipView.dom);\n if (tooltipView.mount)\n tooltipView.mount(this.view);\n return tooltipView;\n }\n destroy() {\n var _a, _b;\n this.view.win.removeEventListener(\"resize\", this.measureSoon);\n for (let tooltipView of this.manager.tooltipViews) {\n tooltipView.dom.remove();\n (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);\n }\n if (this.parent)\n this.container.remove();\n (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n clearTimeout(this.measureTimeout);\n }\n readMeasure() {\n let editor = this.view.dom.getBoundingClientRect();\n let scaleX = 1, scaleY = 1, makeAbsolute = false;\n if (this.position == \"fixed\" && this.manager.tooltipViews.length) {\n let { dom } = this.manager.tooltipViews[0];\n if (browser.gecko) {\n // Firefox sets the element's `offsetParent` to the\n // transformed element when a transform interferes with fixed\n // positioning.\n makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;\n }\n else {\n // On other browsers, we have to awkwardly try and use other\n // information to detect a transform.\n if (this.view.scaleX != 1 || this.view.scaleY != 1) {\n makeAbsolute = true;\n }\n else if (dom.style.top == Outside && dom.style.left == \"0px\") {\n let rect = dom.getBoundingClientRect();\n makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;\n }\n }\n }\n if (makeAbsolute || this.position == \"absolute\") {\n if (this.parent) {\n let rect = this.parent.getBoundingClientRect();\n if (rect.width && rect.height) {\n scaleX = rect.width / this.parent.offsetWidth;\n scaleY = rect.height / this.parent.offsetHeight;\n }\n }\n else {\n ({ scaleX, scaleY } = this.view.viewState);\n }\n }\n return {\n editor,\n parent: this.parent ? this.container.getBoundingClientRect() : editor,\n pos: this.manager.tooltips.map((t, i) => {\n let tv = this.manager.tooltipViews[i];\n return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);\n }),\n size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),\n space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),\n scaleX, scaleY, makeAbsolute\n };\n }\n writeMeasure(measured) {\n var _a;\n if (measured.makeAbsolute) {\n this.madeAbsolute = true;\n this.position = \"absolute\";\n for (let t of this.manager.tooltipViews)\n t.dom.style.position = \"absolute\";\n }\n let { editor, space, scaleX, scaleY } = measured;\n let others = [];\n for (let i = 0; i < this.manager.tooltips.length; i++) {\n let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;\n let pos = measured.pos[i], size = measured.size[i];\n // Hide tooltips that are outside of the editor.\n if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||\n pos.top >= Math.min(editor.bottom, space.bottom) ||\n pos.right < Math.max(editor.left, space.left) - .1 ||\n pos.left > Math.min(editor.right, space.right) + .1) {\n dom.style.top = Outside;\n continue;\n }\n let arrow = tooltip.arrow ? tView.dom.querySelector(\".cm-tooltip-arrow\") : null;\n let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;\n let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;\n let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;\n let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)\n : ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)\n : Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);\n let above = this.above[i];\n if (!tooltip.strictSide && (above\n ? pos.top - (size.bottom - size.top) - offset.y < space.top\n : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&\n above == (space.bottom - pos.bottom > pos.top - space.top))\n above = this.above[i] = !above;\n let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;\n if (spaceVert < height && tView.resize !== false) {\n if (spaceVert < this.view.defaultLineHeight) {\n dom.style.top = Outside;\n continue;\n }\n knownHeight.set(tView, height);\n dom.style.height = (height = spaceVert) / scaleY + \"px\";\n }\n else if (dom.style.height) {\n dom.style.height = \"\";\n }\n let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;\n let right = left + width;\n if (tView.overlap !== true)\n for (let r of others)\n if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)\n top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;\n if (this.position == \"absolute\") {\n dom.style.top = (top - measured.parent.top) / scaleY + \"px\";\n dom.style.left = (left - measured.parent.left) / scaleX + \"px\";\n }\n else {\n dom.style.top = top / scaleY + \"px\";\n dom.style.left = left / scaleX + \"px\";\n }\n if (arrow) {\n let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);\n arrow.style.left = arrowLeft / scaleX + \"px\";\n }\n if (tView.overlap !== true)\n others.push({ left, top, right, bottom: top + height });\n dom.classList.toggle(\"cm-tooltip-above\", above);\n dom.classList.toggle(\"cm-tooltip-below\", !above);\n if (tView.positioned)\n tView.positioned(measured.space);\n }\n }\n maybeMeasure() {\n if (this.manager.tooltips.length) {\n if (this.view.inView)\n this.view.requestMeasure(this.measureReq);\n if (this.inView != this.view.inView) {\n this.inView = this.view.inView;\n if (!this.inView)\n for (let tv of this.manager.tooltipViews)\n tv.dom.style.top = Outside;\n }\n }\n }\n}, {\n eventObservers: {\n scroll() { this.maybeMeasure(); }\n }\n});\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-tooltip\": {\n zIndex: 100,\n boxSizing: \"border-box\"\n },\n \"&light .cm-tooltip\": {\n border: \"1px solid #bbb\",\n backgroundColor: \"#f5f5f5\"\n },\n \"&light .cm-tooltip-section:not(:first-child)\": {\n borderTop: \"1px solid #bbb\",\n },\n \"&dark .cm-tooltip\": {\n backgroundColor: \"#333338\",\n color: \"white\"\n },\n \".cm-tooltip-arrow\": {\n height: `${7 /* Arrow.Size */}px`,\n width: `${7 /* Arrow.Size */ * 2}px`,\n position: \"absolute\",\n zIndex: -1,\n overflow: \"hidden\",\n \"&:before, &:after\": {\n content: \"''\",\n position: \"absolute\",\n width: 0,\n height: 0,\n borderLeft: `${7 /* Arrow.Size */}px solid transparent`,\n borderRight: `${7 /* Arrow.Size */}px solid transparent`,\n },\n \".cm-tooltip-above &\": {\n bottom: `-${7 /* Arrow.Size */}px`,\n \"&:before\": {\n borderTop: `${7 /* Arrow.Size */}px solid #bbb`,\n },\n \"&:after\": {\n borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,\n bottom: \"1px\"\n }\n },\n \".cm-tooltip-below &\": {\n top: `-${7 /* Arrow.Size */}px`,\n \"&:before\": {\n borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,\n },\n \"&:after\": {\n borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,\n top: \"1px\"\n }\n },\n },\n \"&dark .cm-tooltip .cm-tooltip-arrow\": {\n \"&:before\": {\n borderTopColor: \"#333338\",\n borderBottomColor: \"#333338\"\n },\n \"&:after\": {\n borderTopColor: \"transparent\",\n borderBottomColor: \"transparent\"\n }\n }\n});\nconst noOffset = { x: 0, y: 0 };\n/**\nFacet to which an extension can add a value to show a tooltip.\n*/\nconst showTooltip = /*@__PURE__*/Facet.define({\n enables: [tooltipPlugin, baseTheme]\n});\nconst showHoverTooltip = /*@__PURE__*/Facet.define();\nclass HoverTooltipHost {\n // Needs to be static so that host tooltip instances always match\n static create(view) {\n return new HoverTooltipHost(view);\n }\n constructor(view) {\n this.view = view;\n this.mounted = false;\n this.dom = document.createElement(\"div\");\n this.dom.classList.add(\"cm-tooltip-hover\");\n this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));\n }\n createHostedView(tooltip) {\n let hostedView = tooltip.create(this.view);\n hostedView.dom.classList.add(\"cm-tooltip-section\");\n this.dom.appendChild(hostedView.dom);\n if (this.mounted && hostedView.mount)\n hostedView.mount(this.view);\n return hostedView;\n }\n mount(view) {\n for (let hostedView of this.manager.tooltipViews) {\n if (hostedView.mount)\n hostedView.mount(view);\n }\n this.mounted = true;\n }\n positioned(space) {\n for (let hostedView of this.manager.tooltipViews) {\n if (hostedView.positioned)\n hostedView.positioned(space);\n }\n }\n update(update) {\n this.manager.update(update);\n }\n destroy() {\n var _a;\n for (let t of this.manager.tooltipViews)\n (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);\n }\n passProp(name) {\n let value = undefined;\n for (let view of this.manager.tooltipViews) {\n let given = view[name];\n if (given !== undefined) {\n if (value === undefined)\n value = given;\n else if (value !== given)\n return undefined;\n }\n }\n return value;\n }\n get offset() { return this.passProp(\"offset\"); }\n get getCoords() { return this.passProp(\"getCoords\"); }\n get overlap() { return this.passProp(\"overlap\"); }\n get resize() { return this.passProp(\"resize\"); }\n}\nconst showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {\n let tooltips = state.facet(showHoverTooltip).filter(t => t);\n if (tooltips.length === 0)\n return null;\n return {\n pos: Math.min(...tooltips.map(t => t.pos)),\n end: Math.max(...tooltips.map(t => { var _a; return (_a = t.end) !== null && _a !== void 0 ? _a : t.pos; })),\n create: HoverTooltipHost.create,\n above: tooltips[0].above,\n arrow: tooltips.some(t => t.arrow),\n };\n});\nclass HoverPlugin {\n constructor(view, source, field, setHover, hoverTime) {\n this.view = view;\n this.source = source;\n this.field = field;\n this.setHover = setHover;\n this.hoverTime = hoverTime;\n this.hoverTimeout = -1;\n this.restartTimeout = -1;\n this.pending = null;\n this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };\n this.checkHover = this.checkHover.bind(this);\n view.dom.addEventListener(\"mouseleave\", this.mouseleave = this.mouseleave.bind(this));\n view.dom.addEventListener(\"mousemove\", this.mousemove = this.mousemove.bind(this));\n }\n update() {\n if (this.pending) {\n this.pending = null;\n clearTimeout(this.restartTimeout);\n this.restartTimeout = setTimeout(() => this.startHover(), 20);\n }\n }\n get active() {\n return this.view.state.field(this.field);\n }\n checkHover() {\n this.hoverTimeout = -1;\n if (this.active)\n return;\n let hovered = Date.now() - this.lastMove.time;\n if (hovered < this.hoverTime)\n this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);\n else\n this.startHover();\n }\n startHover() {\n clearTimeout(this.restartTimeout);\n let { view, lastMove } = this;\n let desc = view.docView.nearest(lastMove.target);\n if (!desc)\n return;\n let pos, side = 1;\n if (desc instanceof WidgetView) {\n pos = desc.posAtStart;\n }\n else {\n pos = view.posAtCoords(lastMove);\n if (pos == null)\n return;\n let posCoords = view.coordsAtPos(pos);\n if (!posCoords ||\n lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||\n lastMove.x < posCoords.left - view.defaultCharacterWidth ||\n lastMove.x > posCoords.right + view.defaultCharacterWidth)\n return;\n let bidi = view.bidiSpans(view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);\n let rtl = bidi && bidi.dir == Direction.RTL ? -1 : 1;\n side = (lastMove.x < posCoords.left ? -rtl : rtl);\n }\n let open = this.source(view, pos, side);\n if (open === null || open === void 0 ? void 0 : open.then) {\n let pending = this.pending = { pos };\n open.then(result => {\n if (this.pending == pending) {\n this.pending = null;\n if (result)\n view.dispatch({ effects: this.setHover.of(result) });\n }\n }, e => logException(view.state, e, \"hover tooltip\"));\n }\n else if (open) {\n view.dispatch({ effects: this.setHover.of(open) });\n }\n }\n get tooltip() {\n let plugin = this.view.plugin(tooltipPlugin);\n let index = plugin ? plugin.manager.tooltips.findIndex(t => t.create == HoverTooltipHost.create) : -1;\n return index > -1 ? plugin.manager.tooltipViews[index] : null;\n }\n mousemove(event) {\n var _a;\n this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };\n if (this.hoverTimeout < 0)\n this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);\n let { active, tooltip } = this;\n if (active && tooltip && !isInTooltip(tooltip.dom, event) || this.pending) {\n let { pos } = active || this.pending, end = (_a = active === null || active === void 0 ? void 0 : active.end) !== null && _a !== void 0 ? _a : pos;\n if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos\n : !isOverRange(this.view, pos, end, event.clientX, event.clientY))) {\n this.view.dispatch({ effects: this.setHover.of(null) });\n this.pending = null;\n }\n }\n }\n mouseleave(event) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = -1;\n let { active } = this;\n if (active) {\n let { tooltip } = this;\n let inTooltip = tooltip && tooltip.dom.contains(event.relatedTarget);\n if (!inTooltip)\n this.view.dispatch({ effects: this.setHover.of(null) });\n else\n this.watchTooltipLeave(tooltip.dom);\n }\n }\n watchTooltipLeave(tooltip) {\n let watch = (event) => {\n tooltip.removeEventListener(\"mouseleave\", watch);\n if (this.active && !this.view.dom.contains(event.relatedTarget))\n this.view.dispatch({ effects: this.setHover.of(null) });\n };\n tooltip.addEventListener(\"mouseleave\", watch);\n }\n destroy() {\n clearTimeout(this.hoverTimeout);\n this.view.dom.removeEventListener(\"mouseleave\", this.mouseleave);\n this.view.dom.removeEventListener(\"mousemove\", this.mousemove);\n }\n}\nconst tooltipMargin = 4;\nfunction isInTooltip(tooltip, event) {\n let rect = tooltip.getBoundingClientRect();\n return event.clientX >= rect.left - tooltipMargin && event.clientX <= rect.right + tooltipMargin &&\n event.clientY >= rect.top - tooltipMargin && event.clientY <= rect.bottom + tooltipMargin;\n}\nfunction isOverRange(view, from, to, x, y, margin) {\n let rect = view.scrollDOM.getBoundingClientRect();\n let docBottom = view.documentTop + view.documentPadding.top + view.contentHeight;\n if (rect.left > x || rect.right < x || rect.top > y || Math.min(rect.bottom, docBottom) < y)\n return false;\n let pos = view.posAtCoords({ x, y }, false);\n return pos >= from && pos <= to;\n}\n/**\nSet up a hover tooltip, which shows up when the pointer hovers\nover ranges of text. The callback is called when the mouse hovers\nover the document text. It should, if there is a tooltip\nassociated with position `pos`, return the tooltip description\n(either directly or in a promise). The `side` argument indicates\non which side of the position the pointer is—it will be -1 if the\npointer is before the position, 1 if after the position.\n\nNote that all hover tooltips are hosted within a single tooltip\ncontainer element. This allows multiple tooltips over the same\nrange to be \"merged\" together without overlapping.\n*/\nfunction hoverTooltip(source, options = {}) {\n let setHover = StateEffect.define();\n let hoverState = StateField.define({\n create() { return null; },\n update(value, tr) {\n if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||\n options.hideOn && options.hideOn(tr, value)))\n return null;\n if (value && tr.docChanged) {\n let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);\n if (newPos == null)\n return null;\n let copy = Object.assign(Object.create(null), value);\n copy.pos = newPos;\n if (value.end != null)\n copy.end = tr.changes.mapPos(value.end);\n value = copy;\n }\n for (let effect of tr.effects) {\n if (effect.is(setHover))\n value = effect.value;\n if (effect.is(closeHoverTooltipEffect))\n value = null;\n }\n return value;\n },\n provide: f => showHoverTooltip.from(f)\n });\n return [\n hoverState,\n ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),\n showHoverTooltipHost\n ];\n}\n/**\nGet the active tooltip view for a given tooltip, if available.\n*/\nfunction getTooltip(view, tooltip) {\n let plugin = view.plugin(tooltipPlugin);\n if (!plugin)\n return null;\n let found = plugin.manager.tooltips.indexOf(tooltip);\n return found < 0 ? null : plugin.manager.tooltipViews[found];\n}\n/**\nReturns true if any hover tooltips are currently active.\n*/\nfunction hasHoverTooltips(state) {\n return state.facet(showHoverTooltip).some(x => x);\n}\nconst closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();\n/**\nTransaction effect that closes all hover tooltips.\n*/\nconst closeHoverTooltips = /*@__PURE__*/closeHoverTooltipEffect.of(null);\n/**\nTell the tooltip extension to recompute the position of the active\ntooltips. This can be useful when something happens (such as a\nre-positioning or CSS change affecting the editor) that could\ninvalidate the existing tooltip positions.\n*/\nfunction repositionTooltips(view) {\n let plugin = view.plugin(tooltipPlugin);\n if (plugin)\n plugin.maybeMeasure();\n}\n\nconst panelConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n let topContainer, bottomContainer;\n for (let c of configs) {\n topContainer = topContainer || c.topContainer;\n bottomContainer = bottomContainer || c.bottomContainer;\n }\n return { topContainer, bottomContainer };\n }\n});\n/**\nConfigures the panel-managing extension.\n*/\nfunction panels(config) {\n return config ? [panelConfig.of(config)] : [];\n}\n/**\nGet the active panel created by the given constructor, if any.\nThis can be useful when you need access to your panels' DOM\nstructure.\n*/\nfunction getPanel(view, panel) {\n let plugin = view.plugin(panelPlugin);\n let index = plugin ? plugin.specs.indexOf(panel) : -1;\n return index > -1 ? plugin.panels[index] : null;\n}\nconst panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.input = view.state.facet(showPanel);\n this.specs = this.input.filter(s => s);\n this.panels = this.specs.map(spec => spec(view));\n let conf = view.state.facet(panelConfig);\n this.top = new PanelGroup(view, true, conf.topContainer);\n this.bottom = new PanelGroup(view, false, conf.bottomContainer);\n this.top.sync(this.panels.filter(p => p.top));\n this.bottom.sync(this.panels.filter(p => !p.top));\n for (let p of this.panels) {\n p.dom.classList.add(\"cm-panel\");\n if (p.mount)\n p.mount();\n }\n }\n update(update) {\n let conf = update.state.facet(panelConfig);\n if (this.top.container != conf.topContainer) {\n this.top.sync([]);\n this.top = new PanelGroup(update.view, true, conf.topContainer);\n }\n if (this.bottom.container != conf.bottomContainer) {\n this.bottom.sync([]);\n this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);\n }\n this.top.syncClasses();\n this.bottom.syncClasses();\n let input = update.state.facet(showPanel);\n if (input != this.input) {\n let specs = input.filter(x => x);\n let panels = [], top = [], bottom = [], mount = [];\n for (let spec of specs) {\n let known = this.specs.indexOf(spec), panel;\n if (known < 0) {\n panel = spec(update.view);\n mount.push(panel);\n }\n else {\n panel = this.panels[known];\n if (panel.update)\n panel.update(update);\n }\n panels.push(panel);\n (panel.top ? top : bottom).push(panel);\n }\n this.specs = specs;\n this.panels = panels;\n this.top.sync(top);\n this.bottom.sync(bottom);\n for (let p of mount) {\n p.dom.classList.add(\"cm-panel\");\n if (p.mount)\n p.mount();\n }\n }\n else {\n for (let p of this.panels)\n if (p.update)\n p.update(update);\n }\n }\n destroy() {\n this.top.sync([]);\n this.bottom.sync([]);\n }\n}, {\n provide: plugin => EditorView.scrollMargins.of(view => {\n let value = view.plugin(plugin);\n return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };\n })\n});\nclass PanelGroup {\n constructor(view, top, container) {\n this.view = view;\n this.top = top;\n this.container = container;\n this.dom = undefined;\n this.classes = \"\";\n this.panels = [];\n this.syncClasses();\n }\n sync(panels) {\n for (let p of this.panels)\n if (p.destroy && panels.indexOf(p) < 0)\n p.destroy();\n this.panels = panels;\n this.syncDOM();\n }\n syncDOM() {\n if (this.panels.length == 0) {\n if (this.dom) {\n this.dom.remove();\n this.dom = undefined;\n }\n return;\n }\n if (!this.dom) {\n this.dom = document.createElement(\"div\");\n this.dom.className = this.top ? \"cm-panels cm-panels-top\" : \"cm-panels cm-panels-bottom\";\n this.dom.style[this.top ? \"top\" : \"bottom\"] = \"0\";\n let parent = this.container || this.view.dom;\n parent.insertBefore(this.dom, this.top ? parent.firstChild : null);\n }\n let curDOM = this.dom.firstChild;\n for (let panel of this.panels) {\n if (panel.dom.parentNode == this.dom) {\n while (curDOM != panel.dom)\n curDOM = rm(curDOM);\n curDOM = curDOM.nextSibling;\n }\n else {\n this.dom.insertBefore(panel.dom, curDOM);\n }\n }\n while (curDOM)\n curDOM = rm(curDOM);\n }\n scrollMargin() {\n return !this.dom || this.container ? 0\n : Math.max(0, this.top ?\n this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :\n Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);\n }\n syncClasses() {\n if (!this.container || this.classes == this.view.themeClasses)\n return;\n for (let cls of this.classes.split(\" \"))\n if (cls)\n this.container.classList.remove(cls);\n for (let cls of (this.classes = this.view.themeClasses).split(\" \"))\n if (cls)\n this.container.classList.add(cls);\n }\n}\nfunction rm(node) {\n let next = node.nextSibling;\n node.remove();\n return next;\n}\n/**\nOpening a panel is done by providing a constructor function for\nthe panel through this facet. (The panel is closed again when its\nconstructor is no longer provided.) Values of `null` are ignored.\n*/\nconst showPanel = /*@__PURE__*/Facet.define({\n enables: panelPlugin\n});\n\n/**\nA gutter marker represents a bit of information attached to a line\nin a specific gutter. Your own custom markers have to extend this\nclass.\n*/\nclass GutterMarker extends RangeValue {\n /**\n @internal\n */\n compare(other) {\n return this == other || this.constructor == other.constructor && this.eq(other);\n }\n /**\n Compare this marker to another marker of the same type.\n */\n eq(other) { return false; }\n /**\n Called if the marker has a `toDOM` method and its representation\n was removed from a gutter.\n */\n destroy(dom) { }\n}\nGutterMarker.prototype.elementClass = \"\";\nGutterMarker.prototype.toDOM = undefined;\nGutterMarker.prototype.mapMode = MapMode.TrackBefore;\nGutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;\nGutterMarker.prototype.point = true;\n/**\nFacet used to add a class to all gutter elements for a given line.\nMarkers given to this facet should _only_ define an\n[`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a\n[`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear\nin all gutters for the line).\n*/\nconst gutterLineClass = /*@__PURE__*/Facet.define();\nconst defaults = {\n class: \"\",\n renderEmptyElements: false,\n elementStyle: \"\",\n markers: () => RangeSet.empty,\n lineMarker: () => null,\n widgetMarker: () => null,\n lineMarkerChange: null,\n initialSpacer: null,\n updateSpacer: null,\n domEventHandlers: {}\n};\nconst activeGutters = /*@__PURE__*/Facet.define();\n/**\nDefine an editor gutter. The order in which the gutters appear is\ndetermined by their extension priority.\n*/\nfunction gutter(config) {\n return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults), config))];\n}\nconst unfixGutters = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\n/**\nThe gutter-drawing plugin is automatically enabled when you add a\ngutter, but you can use this function to explicitly configure it.\n\nUnless `fixed` is explicitly set to `false`, the gutters are\nfixed, meaning they don't scroll along with the content\nhorizontally (except on Internet Explorer, which doesn't support\nCSS [`position:\nsticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).\n*/\nfunction gutters(config) {\n let result = [\n gutterView,\n ];\n if (config && config.fixed === false)\n result.push(unfixGutters.of(true));\n return result;\n}\nconst gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.prevViewport = view.viewport;\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutters\";\n this.dom.setAttribute(\"aria-hidden\", \"true\");\n this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + \"px\";\n this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));\n for (let gutter of this.gutters)\n this.dom.appendChild(gutter.dom);\n this.fixed = !view.state.facet(unfixGutters);\n if (this.fixed) {\n // FIXME IE11 fallback, which doesn't support position: sticky,\n // by using position: relative + event handlers that realign the\n // gutter (or just force fixed=false on IE11?)\n this.dom.style.position = \"sticky\";\n }\n this.syncGutters(false);\n view.scrollDOM.insertBefore(this.dom, view.contentDOM);\n }\n update(update) {\n if (this.updateGutters(update)) {\n // Detach during sync when the viewport changed significantly\n // (such as during scrolling), since for large updates that is\n // faster.\n let vpA = this.prevViewport, vpB = update.view.viewport;\n let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);\n this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);\n }\n if (update.geometryChanged)\n this.dom.style.minHeight = this.view.contentHeight + \"px\";\n if (this.view.state.facet(unfixGutters) != !this.fixed) {\n this.fixed = !this.fixed;\n this.dom.style.position = this.fixed ? \"sticky\" : \"\";\n }\n this.prevViewport = update.view.viewport;\n }\n syncGutters(detach) {\n let after = this.dom.nextSibling;\n if (detach)\n this.dom.remove();\n let lineClasses = RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);\n let classSet = [];\n let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));\n for (let line of this.view.viewportLineBlocks) {\n if (classSet.length)\n classSet = [];\n if (Array.isArray(line.type)) {\n let first = true;\n for (let b of line.type) {\n if (b.type == BlockType.Text && first) {\n advanceCursor(lineClasses, classSet, b.from);\n for (let cx of contexts)\n cx.line(this.view, b, classSet);\n first = false;\n }\n else if (b.widget) {\n for (let cx of contexts)\n cx.widget(this.view, b);\n }\n }\n }\n else if (line.type == BlockType.Text) {\n advanceCursor(lineClasses, classSet, line.from);\n for (let cx of contexts)\n cx.line(this.view, line, classSet);\n }\n else if (line.widget) {\n for (let cx of contexts)\n cx.widget(this.view, line);\n }\n }\n for (let cx of contexts)\n cx.finish();\n if (detach)\n this.view.scrollDOM.insertBefore(this.dom, after);\n }\n updateGutters(update) {\n let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);\n let change = update.docChanged || update.heightChanged || update.viewportChanged ||\n !RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);\n if (prev == cur) {\n for (let gutter of this.gutters)\n if (gutter.update(update))\n change = true;\n }\n else {\n change = true;\n let gutters = [];\n for (let conf of cur) {\n let known = prev.indexOf(conf);\n if (known < 0) {\n gutters.push(new SingleGutterView(this.view, conf));\n }\n else {\n this.gutters[known].update(update);\n gutters.push(this.gutters[known]);\n }\n }\n for (let g of this.gutters) {\n g.dom.remove();\n if (gutters.indexOf(g) < 0)\n g.destroy();\n }\n for (let g of gutters)\n this.dom.appendChild(g.dom);\n this.gutters = gutters;\n }\n return change;\n }\n destroy() {\n for (let view of this.gutters)\n view.destroy();\n this.dom.remove();\n }\n}, {\n provide: plugin => EditorView.scrollMargins.of(view => {\n let value = view.plugin(plugin);\n if (!value || value.gutters.length == 0 || !value.fixed)\n return null;\n return view.textDirection == Direction.LTR\n ? { left: value.dom.offsetWidth * view.scaleX }\n : { right: value.dom.offsetWidth * view.scaleX };\n })\n});\nfunction asArray(val) { return (Array.isArray(val) ? val : [val]); }\nfunction advanceCursor(cursor, collect, pos) {\n while (cursor.value && cursor.from <= pos) {\n if (cursor.from == pos)\n collect.push(cursor.value);\n cursor.next();\n }\n}\nclass UpdateContext {\n constructor(gutter, viewport, height) {\n this.gutter = gutter;\n this.height = height;\n this.i = 0;\n this.cursor = RangeSet.iter(gutter.markers, viewport.from);\n }\n addElement(view, block, markers) {\n let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;\n if (this.i == gutter.elements.length) {\n let newElt = new GutterElement(view, height, above, markers);\n gutter.elements.push(newElt);\n gutter.dom.appendChild(newElt.dom);\n }\n else {\n gutter.elements[this.i].update(view, height, above, markers);\n }\n this.height = block.bottom;\n this.i++;\n }\n line(view, line, extraMarkers) {\n let localMarkers = [];\n advanceCursor(this.cursor, localMarkers, line.from);\n if (extraMarkers.length)\n localMarkers = localMarkers.concat(extraMarkers);\n let forLine = this.gutter.config.lineMarker(view, line, localMarkers);\n if (forLine)\n localMarkers.unshift(forLine);\n let gutter = this.gutter;\n if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)\n return;\n this.addElement(view, line, localMarkers);\n }\n widget(view, block) {\n let marker = this.gutter.config.widgetMarker(view, block.widget, block);\n if (marker)\n this.addElement(view, block, [marker]);\n }\n finish() {\n let gutter = this.gutter;\n while (gutter.elements.length > this.i) {\n let last = gutter.elements.pop();\n gutter.dom.removeChild(last.dom);\n last.destroy();\n }\n }\n}\nclass SingleGutterView {\n constructor(view, config) {\n this.view = view;\n this.config = config;\n this.elements = [];\n this.spacer = null;\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutter\" + (this.config.class ? \" \" + this.config.class : \"\");\n for (let prop in config.domEventHandlers) {\n this.dom.addEventListener(prop, (event) => {\n let target = event.target, y;\n if (target != this.dom && this.dom.contains(target)) {\n while (target.parentNode != this.dom)\n target = target.parentNode;\n let rect = target.getBoundingClientRect();\n y = (rect.top + rect.bottom) / 2;\n }\n else {\n y = event.clientY;\n }\n let line = view.lineBlockAtHeight(y - view.documentTop);\n if (config.domEventHandlers[prop](view, line, event))\n event.preventDefault();\n });\n }\n this.markers = asArray(config.markers(view));\n if (config.initialSpacer) {\n this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);\n this.dom.appendChild(this.spacer.dom);\n this.spacer.dom.style.cssText += \"visibility: hidden; pointer-events: none\";\n }\n }\n update(update) {\n let prevMarkers = this.markers;\n this.markers = asArray(this.config.markers(update.view));\n if (this.spacer && this.config.updateSpacer) {\n let updated = this.config.updateSpacer(this.spacer.markers[0], update);\n if (updated != this.spacer.markers[0])\n this.spacer.update(update.view, 0, 0, [updated]);\n }\n let vp = update.view.viewport;\n return !RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||\n (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);\n }\n destroy() {\n for (let elt of this.elements)\n elt.destroy();\n }\n}\nclass GutterElement {\n constructor(view, height, above, markers) {\n this.height = -1;\n this.above = 0;\n this.markers = [];\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutterElement\";\n this.update(view, height, above, markers);\n }\n update(view, height, above, markers) {\n if (this.height != height) {\n this.height = height;\n this.dom.style.height = height + \"px\";\n }\n if (this.above != above)\n this.dom.style.marginTop = (this.above = above) ? above + \"px\" : \"\";\n if (!sameMarkers(this.markers, markers))\n this.setMarkers(view, markers);\n }\n setMarkers(view, markers) {\n let cls = \"cm-gutterElement\", domPos = this.dom.firstChild;\n for (let iNew = 0, iOld = 0;;) {\n let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;\n if (marker) {\n let c = marker.elementClass;\n if (c)\n cls += \" \" + c;\n for (let i = iOld; i < this.markers.length; i++)\n if (this.markers[i].compare(marker)) {\n skipTo = i;\n matched = true;\n break;\n }\n }\n else {\n skipTo = this.markers.length;\n }\n while (iOld < skipTo) {\n let next = this.markers[iOld++];\n if (next.toDOM) {\n next.destroy(domPos);\n let after = domPos.nextSibling;\n domPos.remove();\n domPos = after;\n }\n }\n if (!marker)\n break;\n if (marker.toDOM) {\n if (matched)\n domPos = domPos.nextSibling;\n else\n this.dom.insertBefore(marker.toDOM(view), domPos);\n }\n if (matched)\n iOld++;\n }\n this.dom.className = cls;\n this.markers = markers;\n }\n destroy() {\n this.setMarkers(null, []); // First argument not used unless creating markers\n }\n}\nfunction sameMarkers(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (!a[i].compare(b[i]))\n return false;\n return true;\n}\n/**\nFacet used to provide markers to the line number gutter.\n*/\nconst lineNumberMarkers = /*@__PURE__*/Facet.define();\nconst lineNumberConfig = /*@__PURE__*/Facet.define({\n combine(values) {\n return combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {\n domEventHandlers(a, b) {\n let result = Object.assign({}, a);\n for (let event in b) {\n let exists = result[event], add = b[event];\n result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;\n }\n return result;\n }\n });\n }\n});\nclass NumberMarker extends GutterMarker {\n constructor(number) {\n super();\n this.number = number;\n }\n eq(other) { return this.number == other.number; }\n toDOM() { return document.createTextNode(this.number); }\n}\nfunction formatNumber(view, number) {\n return view.state.facet(lineNumberConfig).formatNumber(number, view.state);\n}\nconst lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({\n class: \"cm-lineNumbers\",\n renderEmptyElements: false,\n markers(view) { return view.state.facet(lineNumberMarkers); },\n lineMarker(view, line, others) {\n if (others.some(m => m.toDOM))\n return null;\n return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));\n },\n widgetMarker: () => null,\n lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),\n initialSpacer(view) {\n return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));\n },\n updateSpacer(spacer, update) {\n let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));\n return max == spacer.number ? spacer : new NumberMarker(max);\n },\n domEventHandlers: state.facet(lineNumberConfig).domEventHandlers\n}));\n/**\nCreate a line number gutter extension.\n*/\nfunction lineNumbers(config = {}) {\n return [\n lineNumberConfig.of(config),\n gutters(),\n lineNumberGutter\n ];\n}\nfunction maxLineNumber(lines) {\n let last = 9;\n while (last < lines)\n last = last * 10 + 9;\n return last;\n}\nconst activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker {\n constructor() {\n super(...arguments);\n this.elementClass = \"cm-activeLineGutter\";\n }\n};\nconst activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass.compute([\"selection\"], state => {\n let marks = [], last = -1;\n for (let range of state.selection.ranges) {\n let linePos = state.doc.lineAt(range.head).from;\n if (linePos > last) {\n last = linePos;\n marks.push(activeLineGutterMarker.range(linePos));\n }\n }\n return RangeSet.of(marks);\n});\n/**\nReturns an extension that adds a `cm-activeLineGutter` class to\nall gutter elements on the [active\nline](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).\n*/\nfunction highlightActiveLineGutter() {\n return activeLineGutterHighlighter;\n}\n\nconst WhitespaceDeco = /*@__PURE__*/new Map();\nfunction getWhitespaceDeco(space) {\n let deco = WhitespaceDeco.get(space);\n if (!deco)\n WhitespaceDeco.set(space, deco = Decoration.mark({\n attributes: space === \"\\t\" ? {\n class: \"cm-highlightTab\",\n } : {\n class: \"cm-highlightSpace\",\n \"data-display\": space.replace(/ /g, \"·\")\n }\n }));\n return deco;\n}\nfunction matcher(decorator) {\n return ViewPlugin.define(view => ({\n decorations: decorator.createDeco(view),\n update(u) {\n this.decorations = decorator.updateDeco(u, this.decorations);\n },\n }), {\n decorations: v => v.decorations\n });\n}\nconst whitespaceHighlighter = /*@__PURE__*/matcher(/*@__PURE__*/new MatchDecorator({\n regexp: /\\t| +/g,\n decoration: match => getWhitespaceDeco(match[0]),\n boundary: /\\S/,\n}));\n/**\nReturns an extension that highlights whitespace, adding a\n`cm-highlightSpace` class to stretches of spaces, and a\n`cm-highlightTab` class to individual tab characters. By default,\nthe former are shown as faint dots, and the latter as arrows.\n*/\nfunction highlightWhitespace() {\n return whitespaceHighlighter;\n}\nconst trailingHighlighter = /*@__PURE__*/matcher(/*@__PURE__*/new MatchDecorator({\n regexp: /\\s+$/g,\n decoration: /*@__PURE__*/Decoration.mark({ class: \"cm-trailingSpace\" }),\n boundary: /\\S/,\n}));\n/**\nReturns an extension that adds a `cm-trailingSpace` class to all\ntrailing whitespace.\n*/\nfunction highlightTrailingWhitespace() {\n return trailingHighlighter;\n}\n\n/**\n@internal\n*/\nconst __test = { HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange, computeOrder, moveVisually };\n\nexport { BidiSpan, BlockInfo, BlockType, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, __test, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getDrawSelectionConfig, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };\n","import { EditorSelection, EditorState, Extension } from '@codemirror/state';\nimport { EditorView, lineNumbers, highlightSpecialChars } from '@codemirror/view';\n\n/**\n * @class CodeMirror\n * @property {jQuery} $textarea\n * @property {EditorView} view\n * @property {EditorState} state\n */\nexport default class CodeMirror {\n\t/**\n\t * @constructor\n\t * @param {HTMLTextAreaElement|jQuery|string} textarea Textarea to add syntax highlighting to.\n\t */\n\tconstructor( textarea ) {\n\t\tthis.$textarea = $( textarea );\n\t\tthis.view = null;\n\t\tthis.state = null;\n\t}\n\n\t/**\n\t * Extensions here should be applicable to all theoretical uses of CodeMirror in MediaWiki.\n\t * Don't assume CodeMirror is used for editing (i.e. \"View source\" of a protected page).\n\t * Subclasses are safe to override this method if needed.\n\t *\n\t * @see https://codemirror.net/docs/ref/#state.Extension\n\t * @return {Extension[]}\n\t */\n\tget defaultExtensions() {\n\t\tconst extensions = [\n\t\t\tthis.contentAttributesExtension,\n\t\t\tthis.phrasesExtension,\n\t\t\tthis.specialCharsExtension,\n\t\t\tthis.heightExtension\n\t\t];\n\t\tconst namespaces = mw.config.get( 'wgCodeMirrorLineNumberingNamespaces' );\n\n\t\t// Set to [] to disable everywhere, or null to enable everywhere\n\t\tif ( !namespaces || namespaces.includes( mw.config.get( 'wgNamespaceNumber' ) ) ) {\n\t\t\textensions.push( lineNumbers() );\n\t\t}\n\t\treturn extensions;\n\t}\n\n\t/**\n\t * This extension sets the height of the CodeMirror editor to match the textarea.\n\t * Override this method to change the height of the editor.\n\t *\n\t * @return {Extension}\n\t * @stable\n\t */\n\tget heightExtension() {\n\t\treturn EditorView.theme( {\n\t\t\t'&': {\n\t\t\t\theight: `${ this.$textarea.outerHeight() }px`\n\t\t\t},\n\t\t\t'.cm-scroller': {\n\t\t\t\toverflow: 'auto'\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * This specifies which attributes get added to the .cm-content element.\n\t * If you need to add more, add another Extension on initialization for the contentAttributes\n\t * Facet in the form of EditorView.contentAttributes.of( {Object} ).\n\t * Subclasses are safe to override this method, but attributes here are considered vital.\n\t *\n\t * @see https://codemirror.net/docs/ref/#view.EditorView^contentAttributes\n\t * @return {Extension}\n\t */\n\tget contentAttributesExtension() {\n\t\tconst classList = [];\n\t\t// T245568: Sync text editor font preferences with CodeMirror\n\t\tconst fontClass = Array.from( this.$textarea[ 0 ].classList )\n\t\t\t.find( ( style ) => style.startsWith( 'mw-editfont-' ) );\n\t\tif ( fontClass ) {\n\t\t\tclassList.push( fontClass );\n\t\t}\n\t\t// Add colorblind mode if preference is set.\n\t\t// This currently is only to be used for the MediaWiki markup language.\n\t\tif (\n\t\t\tmw.user.options.get( 'usecodemirror-colorblind' ) &&\n\t\t\tmw.config.get( 'wgPageContentModel' ) === 'wikitext'\n\t\t) {\n\t\t\tclassList.push( 'cm-mw-colorblind-colors' );\n\t\t}\n\n\t\treturn EditorView.contentAttributes.of( {\n\t\t\t// T259347: Use accesskey of the original textbox\n\t\t\taccesskey: this.$textarea.attr( 'accesskey' ),\n\t\t\t// use direction and language of the original textbox\n\t\t\tdir: this.$textarea.attr( 'dir' ),\n\t\t\tlang: this.$textarea.attr( 'lang' ),\n\t\t\tclass: classList.join( ' ' )\n\t\t} );\n\t}\n\n\t/**\n\t * These are all potential messages used in a full-featured CodeMirror setup.\n\t * We lump them all here and supply it as default extensions because it is only a small cost\n\t * and we don't want localization to be overlooked by CodeMirror clients and subclasses.\n\t *\n\t * @see https://codemirror.net/examples/translate/\n\t * @return {Extension}\n\t */\n\tget phrasesExtension() {\n\t\treturn EditorState.phrases.of( {\n\t\t\tFind: mw.msg( 'codemirror-find' ),\n\t\t\tnext: mw.msg( 'codemirror-next' ),\n\t\t\tprevious: mw.msg( 'codemirror-previous' ),\n\t\t\tall: mw.msg( 'codemirror-all' ),\n\t\t\t'match case': mw.msg( 'codemirror-match-case' ),\n\t\t\tregexp: mw.msg( 'codemirror-regexp' ),\n\t\t\t'by word': mw.msg( 'codemirror-by-word' ),\n\t\t\treplace: mw.msg( 'codemirror-replace' ),\n\t\t\tReplace: mw.msg( 'codemirror-replace-placeholder' ),\n\t\t\t'replace all': mw.msg( 'codemirror-replace-all' ),\n\t\t\t'Control character': mw.msg( 'codemirror-control-character' )\n\t\t} );\n\t}\n\n\t/**\n\t * We give a small subset of special characters a tooltip explaining what they are.\n\t * The messages and for what characters are defined here.\n\t * Any character that does not have a message will instead use CM6 defaults,\n\t * which is the localization of 'codemirror-control-character' followed by the Unicode number.\n\t *\n\t * @see https://codemirror.net/docs/ref/#view.highlightSpecialChars\n\t * @return {Extension}\n\t */\n\tget specialCharsExtension() {\n\t\t// Keys are the decimal unicode number, values are the messages.\n\t\tconst messages = {\n\t\t\t0: mw.msg( 'codemirror-special-char-null' ),\n\t\t\t7: mw.msg( 'codemirror-special-char-bell' ),\n\t\t\t8: mw.msg( 'codemirror-special-char-backspace' ),\n\t\t\t10: mw.msg( 'codemirror-special-char-newline' ),\n\t\t\t11: mw.msg( 'codemirror-special-char-vertical-tab' ),\n\t\t\t13: mw.msg( 'codemirror-special-char-carriage-return' ),\n\t\t\t27: mw.msg( 'codemirror-special-char-escape' ),\n\t\t\t160: mw.msg( 'codemirror-special-char-nbsp' ),\n\t\t\t8203: mw.msg( 'codemirror-special-char-zero-width-space' ),\n\t\t\t8204: mw.msg( 'codemirror-special-char-zero-width-non-joiner' ),\n\t\t\t8205: mw.msg( 'codemirror-special-char-zero-width-joiner' ),\n\t\t\t8206: mw.msg( 'codemirror-special-char-left-to-right-mark' ),\n\t\t\t8207: mw.msg( 'codemirror-special-char-right-to-left-mark' ),\n\t\t\t8232: mw.msg( 'codemirror-special-char-line-separator' ),\n\t\t\t8237: mw.msg( 'codemirror-special-char-left-to-right-override' ),\n\t\t\t8238: mw.msg( 'codemirror-special-char-right-to-left-override' ),\n\t\t\t8239: mw.msg( 'codemirror-special-char-narrow-nbsp' ),\n\t\t\t8294: mw.msg( 'codemirror-special-char-left-to-right-isolate' ),\n\t\t\t8295: mw.msg( 'codemirror-special-char-right-to-left-isolate' ),\n\t\t\t8297: mw.msg( 'codemirror-special-char-pop-directional-isolate' ),\n\t\t\t8233: mw.msg( 'codemirror-special-char-paragraph-separator' ),\n\t\t\t65279: mw.msg( 'codemirror-special-char-zero-width-no-break-space' ),\n\t\t\t65532: mw.msg( 'codemirror-special-char-object-replacement' )\n\t\t};\n\n\t\treturn highlightSpecialChars( {\n\t\t\trender: ( code, description, placeholder ) => {\n\t\t\t\tdescription = messages[ code ] || mw.msg( 'codemirror-control-character', code );\n\t\t\t\tconst span = document.createElement( 'span' );\n\t\t\t\tspan.className = 'cm-specialChar';\n\n\t\t\t\t// Special case non-breaking spaces (T181677).\n\t\t\t\tif ( code === 160 || code === 8239 ) {\n\t\t\t\t\tplaceholder = '·';\n\t\t\t\t\tspan.className = 'cm-special-char-nbsp';\n\t\t\t\t}\n\n\t\t\t\tspan.textContent = placeholder;\n\t\t\t\tspan.title = description;\n\t\t\t\tspan.setAttribute( 'aria-label', description );\n\t\t\t\treturn span;\n\t\t\t},\n\t\t\t// Highlight non-breaking spaces (T181677)\n\t\t\taddSpecialChars: /\\u00a0|\\u202f/g\n\t\t} );\n\t}\n\n\t/**\n\t * Setup CodeMirror and add it to the DOM. This will hide the original textarea.\n\t *\n\t * @param {Extension[]} extensions\n\t * @stable\n\t */\n\tinitialize( extensions = this.defaultExtensions ) {\n\t\tmw.hook( 'ext.CodeMirror.initialize' ).fire( this.$textarea );\n\n\t\t// Set up the initial EditorState of CodeMirror with contents of the native textarea.\n\t\tthis.state = EditorState.create( {\n\t\t\tdoc: this.$textarea.textSelection( 'getContents' ),\n\t\t\textensions\n\t\t} );\n\n\t\t// Add CodeMirror view to the DOM.\n\t\tthis.view = new EditorView( {\n\t\t\tstate: this.state,\n\t\t\tparent: this.$textarea.parent()[ 0 ]\n\t\t} );\n\n\t\t// Hide native textarea and sync CodeMirror contents upon submission.\n\t\tthis.$textarea.hide();\n\t\tif ( this.$textarea[ 0 ].form ) {\n\t\t\tthis.$textarea[ 0 ].form.addEventListener( 'submit', () => {\n\t\t\t\tthis.$textarea.val( this.view.state.doc.toString() );\n\t\t\t\tconst scrollTop = document.getElementById( 'wpScrolltop' );\n\t\t\t\tif ( scrollTop ) {\n\t\t\t\t\tscrollTop.value = this.view.scrollDOM.scrollTop;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Register $.textSelection() on the .cm-editor element.\n\t\t$( this.view.dom ).textSelection( 'register', this.cmTextSelection );\n\t\t// Also override textSelection() functions for the \"real\" hidden textarea to route to\n\t\t// CodeMirror. We unregister this when switching to normal textarea mode.\n\t\tthis.$textarea.textSelection( 'register', this.cmTextSelection );\n\n\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( true, $( this.view.dom ) );\n\t}\n\n\t/**\n\t * Log usage of CodeMirror.\n\t *\n\t * @param {Object} data\n\t * @stable\n\t */\n\tlogUsage( data ) {\n\t\t/* eslint-disable camelcase */\n\t\tconst event = Object.assign( {\n\t\t\tsession_token: mw.user.sessionId(),\n\t\t\tuser_id: mw.user.getId()\n\t\t}, data );\n\t\tconst editCountBucket = mw.config.get( 'wgUserEditCountBucket' );\n\t\tif ( editCountBucket !== null ) {\n\t\t\tevent.user_edit_count_bucket = editCountBucket;\n\t\t}\n\t\t/* eslint-enable camelcase */\n\t\tmw.track( 'event.CodeMirrorUsage', event );\n\t}\n\n\t/**\n\t * Save CodeMirror enabled preference.\n\t *\n\t * @param {boolean} prefValue True, if CodeMirror should be enabled by default, otherwise false.\n\t * @stable\n\t */\n\tsetCodeMirrorPreference( prefValue ) {\n\t\t// Skip for unnamed users\n\t\tif ( !mw.user.isNamed() ) {\n\t\t\treturn;\n\t\t}\n\t\tnew mw.Api().saveOption( 'usecodemirror', prefValue ? 1 : 0 );\n\t\tmw.user.options.set( 'usecodemirror', prefValue ? 1 : 0 );\n\t}\n\n\t/**\n\t * jQuery.textSelection overrides for CodeMirror.\n\t *\n\t * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/jQuery.plugin.textSelection\n\t * @return {Object}\n\t */\n\tget cmTextSelection() {\n\t\tconst $cmDom = $( this.view.dom );\n\t\treturn {\n\t\t\tgetContents: () => this.view.state.doc.toString(),\n\t\t\tsetContents: ( content ) => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\tchanges: {\n\t\t\t\t\t\tfrom: 0,\n\t\t\t\t\t\tto: this.view.state.doc.length,\n\t\t\t\t\t\tinsert: content\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\tgetSelection: () => {\n\t\t\t\treturn this.view.state.sliceDoc(\n\t\t\t\t\tthis.view.state.selection.main.from,\n\t\t\t\t\tthis.view.state.selection.main.to\n\t\t\t\t);\n\t\t\t},\n\t\t\tsetSelection: ( options = { start: 0, end: 0 } ) => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\tselection: { anchor: options.start, head: ( options.end || options.start ) }\n\t\t\t\t} );\n\t\t\t\tthis.view.focus();\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\tencapsulateSelection: ( options ) => {\n\t\t\t\t// First set the selection, if applicable.\n\t\t\t\tif ( options.selectionStart || options.selectionEnd ) {\n\t\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\t\tselection: {\n\t\t\t\t\t\t\tanchor: options.selectionStart,\n\t\t\t\t\t\t\thead: ( options.selectionEnd || options.selectionStart )\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\t// Do the actual replacements.\n\t\t\t\tthis.view.dispatch( this.view.state.changeByRange( ( range ) => ( {\n\t\t\t\t\tchanges: [\n\t\t\t\t\t\t{ from: range.from, insert: options.pre },\n\t\t\t\t\t\t{ from: range.to, insert: options.post }\n\t\t\t\t\t],\n\t\t\t\t\trange: EditorSelection.range(\n\t\t\t\t\t\trange.from,\n\t\t\t\t\t\trange.to + options.pre.length + options.post.length\n\t\t\t\t\t)\n\t\t\t\t} ) ) );\n\t\t\t\tthis.view.focus();\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\treplaceSelection: ( value ) => {\n\t\t\t\tthis.view.dispatch(\n\t\t\t\t\tthis.view.state.replaceSelection( value )\n\t\t\t\t);\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\tgetCaretPosition: ( options ) => {\n\t\t\t\tif ( !options.startAndEnd ) {\n\t\t\t\t\treturn this.view.state.selection.main.head;\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tthis.view.state.selection.main.from,\n\t\t\t\t\tthis.view.state.selection.main.to\n\t\t\t\t];\n\t\t\t},\n\t\t\tscrollToCaretPosition: () => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\teffects: EditorView.scrollIntoView( this.view.state.selection.main.head )\n\t\t\t\t} );\n\t\t\t\treturn $cmDom;\n\t\t\t}\n\t\t};\n\t}\n}\n","/**\nThe default maximum length of a `TreeBuffer` node.\n*/\nconst DefaultBufferLength = 1024;\nlet nextPropID = 0;\nclass Range {\n constructor(from, to) {\n this.from = from;\n this.to = to;\n }\n}\n/**\nEach [node type](#common.NodeType) or [individual tree](#common.Tree)\ncan have metadata associated with it in props. Instances of this\nclass represent prop names.\n*/\nclass NodeProp {\n /**\n Create a new node prop type.\n */\n constructor(config = {}) {\n this.id = nextPropID++;\n this.perNode = !!config.perNode;\n this.deserialize = config.deserialize || (() => {\n throw new Error(\"This node type doesn't define a deserialize function\");\n });\n }\n /**\n This is meant to be used with\n [`NodeSet.extend`](#common.NodeSet.extend) or\n [`LRParser.configure`](#lr.ParserConfig.props) to compute\n prop values for each node type in the set. Takes a [match\n object](#common.NodeType^match) or function that returns undefined\n if the node type doesn't get this prop, and the prop's value if\n it does.\n */\n add(match) {\n if (this.perNode)\n throw new RangeError(\"Can't add per-node props to node types\");\n if (typeof match != \"function\")\n match = NodeType.match(match);\n return (type) => {\n let result = match(type);\n return result === undefined ? null : [this, result];\n };\n }\n}\n/**\nProp that is used to describe matching delimiters. For opening\ndelimiters, this holds an array of node names (written as a\nspace-separated string when declaring this prop in a grammar)\nfor the node types of closing delimiters that match it.\n*/\nNodeProp.closedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nThe inverse of [`closedBy`](#common.NodeProp^closedBy). This is\nattached to closing delimiters, holding an array of node names\nof types of matching opening delimiters.\n*/\nNodeProp.openedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nUsed to assign node types to groups (for example, all node\ntypes that represent an expression could be tagged with an\n`\"Expression\"` group).\n*/\nNodeProp.group = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nAttached to nodes to indicate these should be\n[displayed](https://codemirror.net/docs/ref/#language.syntaxTree)\nin a bidirectional text isolate, so that direction-neutral\ncharacters on their sides don't incorrectly get associated with\nsurrounding text. You'll generally want to set this for nodes\nthat contain arbitrary text, like strings and comments, and for\nnodes that appear _inside_ arbitrary text, like HTML tags. When\nnot given a value, in a grammar declaration, defaults to\n`\"auto\"`.\n*/\nNodeProp.isolate = new NodeProp({ deserialize: value => {\n if (value && value != \"rtl\" && value != \"ltr\" && value != \"auto\")\n throw new RangeError(\"Invalid value for isolate: \" + value);\n return value || \"auto\";\n } });\n/**\nThe hash of the [context](#lr.ContextTracker.constructor)\nthat the node was parsed in, if any. Used to limit reuse of\ncontextual nodes.\n*/\nNodeProp.contextHash = new NodeProp({ perNode: true });\n/**\nThe distance beyond the end of the node that the tokenizer\nlooked ahead for any of the tokens inside the node. (The LR\nparser only stores this when it is larger than 25, for\nefficiency reasons.)\n*/\nNodeProp.lookAhead = new NodeProp({ perNode: true });\n/**\nThis per-node prop is used to replace a given node, or part of a\nnode, with another tree. This is useful to include trees from\ndifferent languages in mixed-language parsers.\n*/\nNodeProp.mounted = new NodeProp({ perNode: true });\n/**\nA mounted tree, which can be [stored](#common.NodeProp^mounted) on\na tree node to indicate that parts of its content are\nrepresented by another tree.\n*/\nclass MountedTree {\n constructor(\n /**\n The inner tree.\n */\n tree, \n /**\n If this is null, this tree replaces the entire node (it will\n be included in the regular iteration instead of its host\n node). If not, only the given ranges are considered to be\n covered by this tree. This is used for trees that are mixed in\n a way that isn't strictly hierarchical. Such mounted trees are\n only entered by [`resolveInner`](#common.Tree.resolveInner)\n and [`enter`](#common.SyntaxNode.enter).\n */\n overlay, \n /**\n The parser used to create this subtree.\n */\n parser) {\n this.tree = tree;\n this.overlay = overlay;\n this.parser = parser;\n }\n /**\n @internal\n */\n static get(tree) {\n return tree && tree.props && tree.props[NodeProp.mounted.id];\n }\n}\nconst noProps = Object.create(null);\n/**\nEach node in a syntax tree has a node type associated with it.\n*/\nclass NodeType {\n /**\n @internal\n */\n constructor(\n /**\n The name of the node type. Not necessarily unique, but if the\n grammar was written properly, different node types with the\n same name within a node set should play the same semantic\n role.\n */\n name, \n /**\n @internal\n */\n props, \n /**\n The id of this node in its set. Corresponds to the term ids\n used in the parser.\n */\n id, \n /**\n @internal\n */\n flags = 0) {\n this.name = name;\n this.props = props;\n this.id = id;\n this.flags = flags;\n }\n /**\n Define a node type.\n */\n static define(spec) {\n let props = spec.props && spec.props.length ? Object.create(null) : noProps;\n let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |\n (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);\n let type = new NodeType(spec.name || \"\", props, spec.id, flags);\n if (spec.props)\n for (let src of spec.props) {\n if (!Array.isArray(src))\n src = src(type);\n if (src) {\n if (src[0].perNode)\n throw new RangeError(\"Can't store a per-node prop on a node type\");\n props[src[0].id] = src[1];\n }\n }\n return type;\n }\n /**\n Retrieves a node prop for this type. Will return `undefined` if\n the prop isn't present on this node.\n */\n prop(prop) { return this.props[prop.id]; }\n /**\n True when this is the top node of a grammar.\n */\n get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }\n /**\n True when this node is produced by a skip rule.\n */\n get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }\n /**\n Indicates whether this is an error node.\n */\n get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }\n /**\n When true, this node type doesn't correspond to a user-declared\n named node, for example because it is used to cache repetition.\n */\n get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }\n /**\n Returns true when this node's name or one of its\n [groups](#common.NodeProp^group) matches the given string.\n */\n is(name) {\n if (typeof name == 'string') {\n if (this.name == name)\n return true;\n let group = this.prop(NodeProp.group);\n return group ? group.indexOf(name) > -1 : false;\n }\n return this.id == name;\n }\n /**\n Create a function from node types to arbitrary values by\n specifying an object whose property names are node or\n [group](#common.NodeProp^group) names. Often useful with\n [`NodeProp.add`](#common.NodeProp.add). You can put multiple\n names, separated by spaces, in a single property name to map\n multiple node names to a single value.\n */\n static match(map) {\n let direct = Object.create(null);\n for (let prop in map)\n for (let name of prop.split(\" \"))\n direct[name] = map[prop];\n return (node) => {\n for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {\n let found = direct[i < 0 ? node.name : groups[i]];\n if (found)\n return found;\n }\n };\n }\n}\n/**\nAn empty dummy node type to use when no actual type is available.\n*/\nNodeType.none = new NodeType(\"\", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);\n/**\nA node set holds a collection of node types. It is used to\ncompactly represent trees by storing their type ids, rather than a\nfull pointer to the type object, in a numeric array. Each parser\n[has](#lr.LRParser.nodeSet) a node set, and [tree\nbuffers](#common.TreeBuffer) can only store collections of nodes\nfrom the same set. A set can have a maximum of 2**16 (65536) node\ntypes in it, so that the ids fit into 16-bit typed array slots.\n*/\nclass NodeSet {\n /**\n Create a set with the given types. The `id` property of each\n type should correspond to its position within the array.\n */\n constructor(\n /**\n The node types in this set, by id.\n */\n types) {\n this.types = types;\n for (let i = 0; i < types.length; i++)\n if (types[i].id != i)\n throw new RangeError(\"Node type ids should correspond to array positions when creating a node set\");\n }\n /**\n Create a copy of this set with some node properties added. The\n arguments to this method can be created with\n [`NodeProp.add`](#common.NodeProp.add).\n */\n extend(...props) {\n let newTypes = [];\n for (let type of this.types) {\n let newProps = null;\n for (let source of props) {\n let add = source(type);\n if (add) {\n if (!newProps)\n newProps = Object.assign({}, type.props);\n newProps[add[0].id] = add[1];\n }\n }\n newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);\n }\n return new NodeSet(newTypes);\n }\n}\nconst CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();\n/**\nOptions that control iteration. Can be combined with the `|`\noperator to enable multiple ones.\n*/\nvar IterMode;\n(function (IterMode) {\n /**\n When enabled, iteration will only visit [`Tree`](#common.Tree)\n objects, not nodes packed into\n [`TreeBuffer`](#common.TreeBuffer)s.\n */\n IterMode[IterMode[\"ExcludeBuffers\"] = 1] = \"ExcludeBuffers\";\n /**\n Enable this to make iteration include anonymous nodes (such as\n the nodes that wrap repeated grammar constructs into a balanced\n tree).\n */\n IterMode[IterMode[\"IncludeAnonymous\"] = 2] = \"IncludeAnonymous\";\n /**\n By default, regular [mounted](#common.NodeProp^mounted) nodes\n replace their base node in iteration. Enable this to ignore them\n instead.\n */\n IterMode[IterMode[\"IgnoreMounts\"] = 4] = \"IgnoreMounts\";\n /**\n This option only applies in\n [`enter`](#common.SyntaxNode.enter)-style methods. It tells the\n library to not enter mounted overlays if one covers the given\n position.\n */\n IterMode[IterMode[\"IgnoreOverlays\"] = 8] = \"IgnoreOverlays\";\n})(IterMode || (IterMode = {}));\n/**\nA piece of syntax tree. There are two ways to approach these\ntrees: the way they are actually stored in memory, and the\nconvenient way.\n\nSyntax trees are stored as a tree of `Tree` and `TreeBuffer`\nobjects. By packing detail information into `TreeBuffer` leaf\nnodes, the representation is made a lot more memory-efficient.\n\nHowever, when you want to actually work with tree nodes, this\nrepresentation is very awkward, so most client code will want to\nuse the [`TreeCursor`](#common.TreeCursor) or\n[`SyntaxNode`](#common.SyntaxNode) interface instead, which provides\na view on some part of this data structure, and can be used to\nmove around to adjacent nodes.\n*/\nclass Tree {\n /**\n Construct a new tree. See also [`Tree.build`](#common.Tree^build).\n */\n constructor(\n /**\n The type of the top node.\n */\n type, \n /**\n This node's child nodes.\n */\n children, \n /**\n The positions (offsets relative to the start of this tree) of\n the children.\n */\n positions, \n /**\n The total length of this tree\n */\n length, \n /**\n Per-node [node props](#common.NodeProp) to associate with this node.\n */\n props) {\n this.type = type;\n this.children = children;\n this.positions = positions;\n this.length = length;\n /**\n @internal\n */\n this.props = null;\n if (props && props.length) {\n this.props = Object.create(null);\n for (let [prop, value] of props)\n this.props[typeof prop == \"number\" ? prop : prop.id] = value;\n }\n }\n /**\n @internal\n */\n toString() {\n let mounted = MountedTree.get(this);\n if (mounted && !mounted.overlay)\n return mounted.tree.toString();\n let children = \"\";\n for (let ch of this.children) {\n let str = ch.toString();\n if (str) {\n if (children)\n children += \",\";\n children += str;\n }\n }\n return !this.type.name ? children :\n (/\\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +\n (children.length ? \"(\" + children + \")\" : \"\");\n }\n /**\n Get a [tree cursor](#common.TreeCursor) positioned at the top of\n the tree. Mode can be used to [control](#common.IterMode) which\n nodes the cursor visits.\n */\n cursor(mode = 0) {\n return new TreeCursor(this.topNode, mode);\n }\n /**\n Get a [tree cursor](#common.TreeCursor) pointing into this tree\n at the given position and side (see\n [`moveTo`](#common.TreeCursor.moveTo).\n */\n cursorAt(pos, side = 0, mode = 0) {\n let scope = CachedNode.get(this) || this.topNode;\n let cursor = new TreeCursor(scope);\n cursor.moveTo(pos, side);\n CachedNode.set(this, cursor._tree);\n return cursor;\n }\n /**\n Get a [syntax node](#common.SyntaxNode) object for the top of the\n tree.\n */\n get topNode() {\n return new TreeNode(this, 0, 0, null);\n }\n /**\n Get the [syntax node](#common.SyntaxNode) at the given position.\n If `side` is -1, this will move into nodes that end at the\n position. If 1, it'll move into nodes that start at the\n position. With 0, it'll only enter nodes that cover the position\n from both sides.\n \n Note that this will not enter\n [overlays](#common.MountedTree.overlay), and you often want\n [`resolveInner`](#common.Tree.resolveInner) instead.\n */\n resolve(pos, side = 0) {\n let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);\n CachedNode.set(this, node);\n return node;\n }\n /**\n Like [`resolve`](#common.Tree.resolve), but will enter\n [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node\n pointing into the innermost overlaid tree at the given position\n (with parent links going through all parent structure, including\n the host trees).\n */\n resolveInner(pos, side = 0) {\n let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);\n CachedInnerNode.set(this, node);\n return node;\n }\n /**\n In some situations, it can be useful to iterate through all\n nodes around a position, including those in overlays that don't\n directly cover the position. This method gives you an iterator\n that will produce all nodes, from small to big, around the given\n position.\n */\n resolveStack(pos, side = 0) {\n return stackIterator(this, pos, side);\n }\n /**\n Iterate over the tree and its children, calling `enter` for any\n node that touches the `from`/`to` region (if given) before\n running over such a node's children, and `leave` (if given) when\n leaving the node. When `enter` returns `false`, that node will\n not have its children iterated over (or `leave` called).\n */\n iterate(spec) {\n let { enter, leave, from = 0, to = this.length } = spec;\n let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;\n for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {\n let entered = false;\n if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {\n if (c.firstChild())\n continue;\n entered = true;\n }\n for (;;) {\n if (entered && leave && (anon || !c.type.isAnonymous))\n leave(c);\n if (c.nextSibling())\n break;\n if (!c.parent())\n return;\n entered = true;\n }\n }\n }\n /**\n Get the value of the given [node prop](#common.NodeProp) for this\n node. Works with both per-node and per-type props.\n */\n prop(prop) {\n return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;\n }\n /**\n Returns the node's [per-node props](#common.NodeProp.perNode) in a\n format that can be passed to the [`Tree`](#common.Tree)\n constructor.\n */\n get propValues() {\n let result = [];\n if (this.props)\n for (let id in this.props)\n result.push([+id, this.props[id]]);\n return result;\n }\n /**\n Balance the direct children of this tree, producing a copy of\n which may have children grouped into subtrees with type\n [`NodeType.none`](#common.NodeType^none).\n */\n balance(config = {}) {\n return this.children.length <= 8 /* Balance.BranchFactor */ ? this :\n 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)));\n }\n /**\n Build a tree from a postfix-ordered buffer of node information,\n or a cursor over such a buffer.\n */\n static build(data) { return buildTree(data); }\n}\n/**\nThe empty tree\n*/\nTree.empty = new Tree(NodeType.none, [], [], 0);\nclass FlatBufferCursor {\n constructor(buffer, index) {\n this.buffer = buffer;\n this.index = index;\n }\n get id() { return this.buffer[this.index - 4]; }\n get start() { return this.buffer[this.index - 3]; }\n get end() { return this.buffer[this.index - 2]; }\n get size() { return this.buffer[this.index - 1]; }\n get pos() { return this.index; }\n next() { this.index -= 4; }\n fork() { return new FlatBufferCursor(this.buffer, this.index); }\n}\n/**\nTree buffers contain (type, start, end, endIndex) quads for each\nnode. In such a buffer, nodes are stored in prefix order (parents\nbefore children, with the endIndex of the parent indicating which\nchildren belong to it).\n*/\nclass TreeBuffer {\n /**\n Create a tree buffer.\n */\n constructor(\n /**\n The buffer's content.\n */\n buffer, \n /**\n The total length of the group of nodes in the buffer.\n */\n length, \n /**\n The node set used in this buffer.\n */\n set) {\n this.buffer = buffer;\n this.length = length;\n this.set = set;\n }\n /**\n @internal\n */\n get type() { return NodeType.none; }\n /**\n @internal\n */\n toString() {\n let result = [];\n for (let index = 0; index < this.buffer.length;) {\n result.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result.join(\",\");\n }\n /**\n @internal\n */\n childString(index) {\n let id = this.buffer[index], endIndex = this.buffer[index + 3];\n let type = this.set.types[id], result = type.name;\n if (/\\W/.test(result) && !type.isError)\n result = JSON.stringify(result);\n index += 4;\n if (endIndex == index)\n return result;\n let children = [];\n while (index < endIndex) {\n children.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result + \"(\" + children.join(\",\") + \")\";\n }\n /**\n @internal\n */\n findChild(startIndex, endIndex, dir, pos, side) {\n let { buffer } = this, pick = -1;\n for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {\n if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {\n pick = i;\n if (dir > 0)\n break;\n }\n }\n return pick;\n }\n /**\n @internal\n */\n slice(startI, endI, from) {\n let b = this.buffer;\n let copy = new Uint16Array(endI - startI), len = 0;\n for (let i = startI, j = 0; i < endI;) {\n copy[j++] = b[i++];\n copy[j++] = b[i++] - from;\n let to = copy[j++] = b[i++] - from;\n copy[j++] = b[i++] - startI;\n len = Math.max(len, to);\n }\n return new TreeBuffer(copy, len, this.set);\n }\n}\nfunction checkSide(side, pos, from, to) {\n switch (side) {\n case -2 /* Side.Before */: return from < pos;\n case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;\n case 0 /* Side.Around */: return from < pos && to > pos;\n case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;\n case 2 /* Side.After */: return to > pos;\n case 4 /* Side.DontCare */: return true;\n }\n}\nfunction resolveNode(node, pos, side, overlays) {\n var _a;\n // Move up to a node that actually holds the position, if possible\n while (node.from == node.to ||\n (side < 1 ? node.from >= pos : node.from > pos) ||\n (side > -1 ? node.to <= pos : node.to < pos)) {\n let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;\n if (!parent)\n return node;\n node = parent;\n }\n let mode = overlays ? 0 : IterMode.IgnoreOverlays;\n // Must go up out of overlays when those do not overlap with pos\n if (overlays)\n for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {\n if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)\n node = parent;\n }\n for (;;) {\n let inner = node.enter(pos, side, mode);\n if (!inner)\n return node;\n node = inner;\n }\n}\nclass BaseNode {\n cursor(mode = 0) { return new TreeCursor(this, mode); }\n getChild(type, before = null, after = null) {\n let r = getChildren(this, type, before, after);\n return r.length ? r[0] : null;\n }\n getChildren(type, before = null, after = null) {\n return getChildren(this, type, before, after);\n }\n resolve(pos, side = 0) {\n return resolveNode(this, pos, side, false);\n }\n resolveInner(pos, side = 0) {\n return resolveNode(this, pos, side, true);\n }\n matchContext(context) {\n return matchNodeContext(this, context);\n }\n enterUnfinishedNodesBefore(pos) {\n let scan = this.childBefore(pos), node = this;\n while (scan) {\n let last = scan.lastChild;\n if (!last || last.to != scan.to)\n break;\n if (last.type.isError && last.from == last.to) {\n node = scan;\n scan = last.prevSibling;\n }\n else {\n scan = last;\n }\n }\n return node;\n }\n get node() { return this; }\n get next() { return this.parent; }\n}\nclass TreeNode extends BaseNode {\n constructor(_tree, from, \n // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)\n index, _parent) {\n super();\n this._tree = _tree;\n this.from = from;\n this.index = index;\n this._parent = _parent;\n }\n get type() { return this._tree.type; }\n get name() { return this._tree.type.name; }\n get to() { return this.from + this._tree.length; }\n nextChild(i, dir, pos, side, mode = 0) {\n for (let parent = this;;) {\n for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {\n let next = children[i], start = positions[i] + parent.from;\n if (!checkSide(side, pos, start, start + next.length))\n continue;\n if (next instanceof TreeBuffer) {\n if (mode & IterMode.ExcludeBuffers)\n continue;\n let index = next.findChild(0, next.buffer.length, dir, pos - start, side);\n if (index > -1)\n return new BufferNode(new BufferContext(parent, next, i, start), null, index);\n }\n else if ((mode & IterMode.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {\n let mounted;\n if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)\n return new TreeNode(mounted.tree, start, i, parent);\n let inner = new TreeNode(next, start, i, parent);\n return (mode & IterMode.IncludeAnonymous) || !inner.type.isAnonymous ? inner\n : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);\n }\n }\n if ((mode & IterMode.IncludeAnonymous) || !parent.type.isAnonymous)\n return null;\n if (parent.index >= 0)\n i = parent.index + dir;\n else\n i = dir < 0 ? -1 : parent._parent._tree.children.length;\n parent = parent._parent;\n if (!parent)\n return null;\n }\n }\n get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); }\n get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }\n childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }\n childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }\n enter(pos, side, mode = 0) {\n let mounted;\n if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {\n let rPos = pos - this.from;\n for (let { from, to } of mounted.overlay) {\n if ((side > 0 ? from <= rPos : from < rPos) &&\n (side < 0 ? to >= rPos : to > rPos))\n return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);\n }\n }\n return this.nextChild(0, 1, pos, side, mode);\n }\n nextSignificantParent() {\n let val = this;\n while (val.type.isAnonymous && val._parent)\n val = val._parent;\n return val;\n }\n get parent() {\n return this._parent ? this._parent.nextSignificantParent() : null;\n }\n get nextSibling() {\n return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null;\n }\n get prevSibling() {\n return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null;\n }\n get tree() { return this._tree; }\n toTree() { return this._tree; }\n /**\n @internal\n */\n toString() { return this._tree.toString(); }\n}\nfunction getChildren(node, type, before, after) {\n let cur = node.cursor(), result = [];\n if (!cur.firstChild())\n return result;\n if (before != null)\n while (!cur.type.is(before))\n if (!cur.nextSibling())\n return result;\n for (;;) {\n if (after != null && cur.type.is(after))\n return result;\n if (cur.type.is(type))\n result.push(cur.node);\n if (!cur.nextSibling())\n return after == null ? result : [];\n }\n}\nfunction matchNodeContext(node, context, i = context.length - 1) {\n for (let p = node.parent; i >= 0; p = p.parent) {\n if (!p)\n return false;\n if (!p.type.isAnonymous) {\n if (context[i] && context[i] != p.name)\n return false;\n i--;\n }\n }\n return true;\n}\nclass BufferContext {\n constructor(parent, buffer, index, start) {\n this.parent = parent;\n this.buffer = buffer;\n this.index = index;\n this.start = start;\n }\n}\nclass BufferNode extends BaseNode {\n get name() { return this.type.name; }\n get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }\n get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }\n constructor(context, _parent, index) {\n super();\n this.context = context;\n this._parent = _parent;\n this.index = index;\n this.type = context.buffer.set.types[context.buffer.buffer[index]];\n }\n child(dir, pos, side) {\n let { buffer } = this.context;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);\n return index < 0 ? null : new BufferNode(this.context, this, index);\n }\n get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }\n get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }\n childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }\n childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }\n enter(pos, side, mode = 0) {\n if (mode & IterMode.ExcludeBuffers)\n return null;\n let { buffer } = this.context;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);\n return index < 0 ? null : new BufferNode(this.context, this, index);\n }\n get parent() {\n return this._parent || this.context.parent.nextSignificantParent();\n }\n externalSibling(dir) {\n return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */);\n }\n get nextSibling() {\n let { buffer } = this.context;\n let after = buffer.buffer[this.index + 3];\n if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))\n return new BufferNode(this.context, this._parent, after);\n return this.externalSibling(1);\n }\n get prevSibling() {\n let { buffer } = this.context;\n let parentStart = this._parent ? this._parent.index + 4 : 0;\n if (this.index == parentStart)\n return this.externalSibling(-1);\n return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));\n }\n get tree() { return null; }\n toTree() {\n let children = [], positions = [];\n let { buffer } = this.context;\n let startI = this.index + 4, endI = buffer.buffer[this.index + 3];\n if (endI > startI) {\n let from = buffer.buffer[this.index + 1];\n children.push(buffer.slice(startI, endI, from));\n positions.push(0);\n }\n return new Tree(this.type, children, positions, this.to - this.from);\n }\n /**\n @internal\n */\n toString() { return this.context.buffer.childString(this.index); }\n}\nfunction iterStack(heads) {\n if (!heads.length)\n return null;\n let pick = 0, picked = heads[0];\n for (let i = 1; i < heads.length; i++) {\n let node = heads[i];\n if (node.from > picked.from || node.to < picked.to) {\n picked = node;\n pick = i;\n }\n }\n let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;\n let newHeads = heads.slice();\n if (next)\n newHeads[pick] = next;\n else\n newHeads.splice(pick, 1);\n return new StackIterator(newHeads, picked);\n}\nclass StackIterator {\n constructor(heads, node) {\n this.heads = heads;\n this.node = node;\n }\n get next() { return iterStack(this.heads); }\n}\nfunction stackIterator(tree, pos, side) {\n let inner = tree.resolveInner(pos, side), layers = null;\n for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {\n if (scan.index < 0) { // This is an overlay root\n let parent = scan.parent;\n (layers || (layers = [inner])).push(parent.resolve(pos, side));\n scan = parent;\n }\n else {\n let mount = MountedTree.get(scan.tree);\n // Relevant overlay branching off\n if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {\n let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);\n (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));\n }\n }\n }\n return layers ? iterStack(layers) : inner;\n}\n/**\nA tree cursor object focuses on a given node in a syntax tree, and\nallows you to move to adjacent nodes.\n*/\nclass TreeCursor {\n /**\n Shorthand for `.type.name`.\n */\n get name() { return this.type.name; }\n /**\n @internal\n */\n constructor(node, \n /**\n @internal\n */\n mode = 0) {\n this.mode = mode;\n /**\n @internal\n */\n this.buffer = null;\n this.stack = [];\n /**\n @internal\n */\n this.index = 0;\n this.bufferNode = null;\n if (node instanceof TreeNode) {\n this.yieldNode(node);\n }\n else {\n this._tree = node.context.parent;\n this.buffer = node.context;\n for (let n = node._parent; n; n = n._parent)\n this.stack.unshift(n.index);\n this.bufferNode = node;\n this.yieldBuf(node.index);\n }\n }\n yieldNode(node) {\n if (!node)\n return false;\n this._tree = node;\n this.type = node.type;\n this.from = node.from;\n this.to = node.to;\n return true;\n }\n yieldBuf(index, type) {\n this.index = index;\n let { start, buffer } = this.buffer;\n this.type = type || buffer.set.types[buffer.buffer[index]];\n this.from = start + buffer.buffer[index + 1];\n this.to = start + buffer.buffer[index + 2];\n return true;\n }\n /**\n @internal\n */\n yield(node) {\n if (!node)\n return false;\n if (node instanceof TreeNode) {\n this.buffer = null;\n return this.yieldNode(node);\n }\n this.buffer = node.context;\n return this.yieldBuf(node.index, node.type);\n }\n /**\n @internal\n */\n toString() {\n return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();\n }\n /**\n @internal\n */\n enterChild(dir, pos, side) {\n if (!this.buffer)\n return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));\n let { buffer } = this.buffer;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);\n if (index < 0)\n return false;\n this.stack.push(this.index);\n return this.yieldBuf(index);\n }\n /**\n Move the cursor to this node's first child. When this returns\n false, the node has no child, and the cursor has not been moved.\n */\n firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); }\n /**\n Move the cursor to this node's last child.\n */\n lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); }\n /**\n Move the cursor to the first child that ends after `pos`.\n */\n childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); }\n /**\n Move to the last child that starts before `pos`.\n */\n childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); }\n /**\n Move the cursor to the child around `pos`. If side is -1 the\n child may end at that position, when 1 it may start there. This\n will also enter [overlaid](#common.MountedTree.overlay)\n [mounted](#common.NodeProp^mounted) trees unless `overlays` is\n set to false.\n */\n enter(pos, side, mode = this.mode) {\n if (!this.buffer)\n return this.yield(this._tree.enter(pos, side, mode));\n return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);\n }\n /**\n Move to the node's parent node, if this isn't the top node.\n */\n parent() {\n if (!this.buffer)\n return this.yieldNode((this.mode & IterMode.IncludeAnonymous) ? this._tree._parent : this._tree.parent);\n if (this.stack.length)\n return this.yieldBuf(this.stack.pop());\n let parent = (this.mode & IterMode.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();\n this.buffer = null;\n return this.yieldNode(parent);\n }\n /**\n @internal\n */\n sibling(dir) {\n if (!this.buffer)\n return !this._tree._parent ? false\n : this.yield(this._tree.index < 0 ? null\n : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode));\n let { buffer } = this.buffer, d = this.stack.length - 1;\n if (dir < 0) {\n let parentStart = d < 0 ? 0 : this.stack[d] + 4;\n if (this.index != parentStart)\n return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));\n }\n else {\n let after = buffer.buffer[this.index + 3];\n if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))\n return this.yieldBuf(after);\n }\n return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false;\n }\n /**\n Move to this node's next sibling, if any.\n */\n nextSibling() { return this.sibling(1); }\n /**\n Move to this node's previous sibling, if any.\n */\n prevSibling() { return this.sibling(-1); }\n atLastNode(dir) {\n let index, parent, { buffer } = this;\n if (buffer) {\n if (dir > 0) {\n if (this.index < buffer.buffer.buffer.length)\n return false;\n }\n else {\n for (let i = 0; i < this.index; i++)\n if (buffer.buffer.buffer[i + 3] < this.index)\n return false;\n }\n ({ index, parent } = buffer);\n }\n else {\n ({ index, _parent: parent } = this._tree);\n }\n for (; parent; { index, _parent: parent } = parent) {\n if (index > -1)\n for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {\n let child = parent._tree.children[i];\n if ((this.mode & IterMode.IncludeAnonymous) ||\n child instanceof TreeBuffer ||\n !child.type.isAnonymous ||\n hasChild(child))\n return false;\n }\n }\n return true;\n }\n move(dir, enter) {\n if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */))\n return true;\n for (;;) {\n if (this.sibling(dir))\n return true;\n if (this.atLastNode(dir) || !this.parent())\n return false;\n }\n }\n /**\n Move to the next node in a\n [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)\n traversal, going from a node to its first child or, if the\n current node is empty or `enter` is false, its next sibling or\n the next sibling of the first parent node that has one.\n */\n next(enter = true) { return this.move(1, enter); }\n /**\n Move to the next node in a last-to-first pre-order traveral. A\n node is followed by its last child or, if it has none, its\n previous sibling or the previous sibling of the first parent\n node that has one.\n */\n prev(enter = true) { return this.move(-1, enter); }\n /**\n Move the cursor to the innermost node that covers `pos`. If\n `side` is -1, it will enter nodes that end at `pos`. If it is 1,\n it will enter nodes that start at `pos`.\n */\n moveTo(pos, side = 0) {\n // Move up to a node that actually holds the position, if possible\n while (this.from == this.to ||\n (side < 1 ? this.from >= pos : this.from > pos) ||\n (side > -1 ? this.to <= pos : this.to < pos))\n if (!this.parent())\n break;\n // Then scan down into child nodes as far as possible\n while (this.enterChild(1, pos, side)) { }\n return this;\n }\n /**\n Get a [syntax node](#common.SyntaxNode) at the cursor's current\n position.\n */\n get node() {\n if (!this.buffer)\n return this._tree;\n let cache = this.bufferNode, result = null, depth = 0;\n if (cache && cache.context == this.buffer) {\n scan: for (let index = this.index, d = this.stack.length; d >= 0;) {\n for (let c = cache; c; c = c._parent)\n if (c.index == index) {\n if (index == this.index)\n return c;\n result = c;\n depth = d + 1;\n break scan;\n }\n index = this.stack[--d];\n }\n }\n for (let i = depth; i < this.stack.length; i++)\n result = new BufferNode(this.buffer, result, this.stack[i]);\n return this.bufferNode = new BufferNode(this.buffer, result, this.index);\n }\n /**\n Get the [tree](#common.Tree) that represents the current node, if\n any. Will return null when the node is in a [tree\n buffer](#common.TreeBuffer).\n */\n get tree() {\n return this.buffer ? null : this._tree._tree;\n }\n /**\n Iterate over the current node and all its descendants, calling\n `enter` when entering a node and `leave`, if given, when leaving\n one. When `enter` returns `false`, any children of that node are\n skipped, and `leave` isn't called for it.\n */\n iterate(enter, leave) {\n for (let depth = 0;;) {\n let mustLeave = false;\n if (this.type.isAnonymous || enter(this) !== false) {\n if (this.firstChild()) {\n depth++;\n continue;\n }\n if (!this.type.isAnonymous)\n mustLeave = true;\n }\n for (;;) {\n if (mustLeave && leave)\n leave(this);\n mustLeave = this.type.isAnonymous;\n if (this.nextSibling())\n break;\n if (!depth)\n return;\n this.parent();\n depth--;\n mustLeave = true;\n }\n }\n }\n /**\n Test whether the current node matches a given context—a sequence\n of direct parent node names. Empty strings in the context array\n are treated as wildcards.\n */\n matchContext(context) {\n if (!this.buffer)\n return matchNodeContext(this.node, context);\n let { buffer } = this.buffer, { types } = buffer.set;\n for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {\n if (d < 0)\n return matchNodeContext(this.node, context, i);\n let type = types[buffer.buffer[this.stack[d]]];\n if (!type.isAnonymous) {\n if (context[i] && context[i] != type.name)\n return false;\n i--;\n }\n }\n return true;\n }\n}\nfunction hasChild(tree) {\n return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));\n}\nfunction buildTree(data) {\n var _a;\n let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;\n let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;\n let types = nodeSet.types;\n let contextHash = 0, lookAhead = 0;\n function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {\n let { id, start, end, size } = cursor;\n let lookAheadAtStart = lookAhead;\n while (size < 0) {\n cursor.next();\n if (size == -1 /* SpecialRecord.Reuse */) {\n let node = reused[id];\n children.push(node);\n positions.push(start - parentStart);\n return;\n }\n else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change\n contextHash = id;\n return;\n }\n else if (size == -4 /* SpecialRecord.LookAhead */) {\n lookAhead = id;\n return;\n }\n else {\n throw new RangeError(`Unrecognized record size: ${size}`);\n }\n }\n let type = types[id], node, buffer;\n let startPos = start - parentStart;\n if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {\n // Small enough for a buffer, and no reused nodes inside\n let data = new Uint16Array(buffer.size - buffer.skip);\n let endPos = cursor.pos - buffer.size, index = data.length;\n while (cursor.pos > endPos)\n index = copyToBuffer(buffer.start, data, index);\n node = new TreeBuffer(data, end - buffer.start, nodeSet);\n startPos = buffer.start - parentStart;\n }\n else { // Make it a node\n let endPos = cursor.pos - size;\n cursor.next();\n let localChildren = [], localPositions = [];\n let localInRepeat = id >= minRepeatType ? id : -1;\n let lastGroup = 0, lastEnd = end;\n while (cursor.pos > endPos) {\n if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {\n if (cursor.end <= lastEnd - maxBufferLength) {\n makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);\n lastGroup = localChildren.length;\n lastEnd = cursor.end;\n }\n cursor.next();\n }\n else if (depth > 2500 /* CutOff.Depth */) {\n takeFlatNode(start, endPos, localChildren, localPositions);\n }\n else {\n takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);\n }\n }\n if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)\n makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);\n localChildren.reverse();\n localPositions.reverse();\n if (localInRepeat > -1 && lastGroup > 0) {\n let make = makeBalanced(type);\n node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);\n }\n else {\n node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);\n }\n }\n children.push(node);\n positions.push(startPos);\n }\n function takeFlatNode(parentStart, minPos, children, positions) {\n let nodes = []; // Temporary, inverted array of leaf nodes found, with absolute positions\n let nodeCount = 0, stopAt = -1;\n while (cursor.pos > minPos) {\n let { id, start, end, size } = cursor;\n if (size > 4) { // Not a leaf\n cursor.next();\n }\n else if (stopAt > -1 && start < stopAt) {\n break;\n }\n else {\n if (stopAt < 0)\n stopAt = end - maxBufferLength;\n nodes.push(id, start, end);\n nodeCount++;\n cursor.next();\n }\n }\n if (nodeCount) {\n let buffer = new Uint16Array(nodeCount * 4);\n let start = nodes[nodes.length - 2];\n for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {\n buffer[j++] = nodes[i];\n buffer[j++] = nodes[i + 1] - start;\n buffer[j++] = nodes[i + 2] - start;\n buffer[j++] = j;\n }\n children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));\n positions.push(start - parentStart);\n }\n }\n function makeBalanced(type) {\n return (children, positions, length) => {\n let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;\n if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {\n if (!lastI && last.type == type && last.length == length)\n return last;\n if (lookAheadProp = last.prop(NodeProp.lookAhead))\n lookAhead = positions[lastI] + last.length + lookAheadProp;\n }\n return makeTree(type, children, positions, length, lookAhead);\n };\n }\n function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {\n let localChildren = [], localPositions = [];\n while (children.length > i) {\n localChildren.push(children.pop());\n localPositions.push(positions.pop() + base - from);\n }\n children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));\n positions.push(from - base);\n }\n function makeTree(type, children, positions, length, lookAhead = 0, props) {\n if (contextHash) {\n let pair = [NodeProp.contextHash, contextHash];\n props = props ? [pair].concat(props) : [pair];\n }\n if (lookAhead > 25) {\n let pair = [NodeProp.lookAhead, lookAhead];\n props = props ? [pair].concat(props) : [pair];\n }\n return new Tree(type, children, positions, length, props);\n }\n function findBufferSize(maxSize, inRepeat) {\n // Scan through the buffer to find previous siblings that fit\n // together in a TreeBuffer, and don't contain any reused nodes\n // (which can't be stored in a buffer).\n // If `inRepeat` is > -1, ignore node boundaries of that type for\n // nesting, but make sure the end falls either at the start\n // (`maxSize`) or before such a node.\n let fork = cursor.fork();\n let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;\n let result = { size: 0, start: 0, skip: 0 };\n scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {\n let nodeSize = fork.size;\n // Pretend nested repeat nodes of the same type don't exist\n if (fork.id == inRepeat && nodeSize >= 0) {\n // Except that we store the current state as a valid return\n // value.\n result.size = size;\n result.start = start;\n result.skip = skip;\n skip += 4;\n size += 4;\n fork.next();\n continue;\n }\n let startPos = fork.pos - nodeSize;\n if (nodeSize < 0 || startPos < minPos || fork.start < minStart)\n break;\n let localSkipped = fork.id >= minRepeatType ? 4 : 0;\n let nodeStart = fork.start;\n fork.next();\n while (fork.pos > startPos) {\n if (fork.size < 0) {\n if (fork.size == -3 /* SpecialRecord.ContextChange */)\n localSkipped += 4;\n else\n break scan;\n }\n else if (fork.id >= minRepeatType) {\n localSkipped += 4;\n }\n fork.next();\n }\n start = nodeStart;\n size += nodeSize;\n skip += localSkipped;\n }\n if (inRepeat < 0 || size == maxSize) {\n result.size = size;\n result.start = start;\n result.skip = skip;\n }\n return result.size > 4 ? result : undefined;\n }\n function copyToBuffer(bufferStart, buffer, index) {\n let { id, start, end, size } = cursor;\n cursor.next();\n if (size >= 0 && id < minRepeatType) {\n let startIndex = index;\n if (size > 4) {\n let endPos = cursor.pos - (size - 4);\n while (cursor.pos > endPos)\n index = copyToBuffer(bufferStart, buffer, index);\n }\n buffer[--index] = startIndex;\n buffer[--index] = end - bufferStart;\n buffer[--index] = start - bufferStart;\n buffer[--index] = id;\n }\n else if (size == -3 /* SpecialRecord.ContextChange */) {\n contextHash = id;\n }\n else if (size == -4 /* SpecialRecord.LookAhead */) {\n lookAhead = id;\n }\n return index;\n }\n let children = [], positions = [];\n while (cursor.pos > 0)\n takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);\n let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);\n return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);\n}\nconst nodeSizeCache = new WeakMap;\nfunction nodeSize(balanceType, node) {\n if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)\n return 1;\n let size = nodeSizeCache.get(node);\n if (size == null) {\n size = 1;\n for (let child of node.children) {\n if (child.type != balanceType || !(child instanceof Tree)) {\n size = 1;\n break;\n }\n size += nodeSize(balanceType, child);\n }\n nodeSizeCache.set(node, size);\n }\n return size;\n}\nfunction balanceRange(\n// The type the balanced tree's inner nodes.\nbalanceType, \n// The direct children and their positions\nchildren, positions, \n// The index range in children/positions to use\nfrom, to, \n// The start position of the nodes, relative to their parent.\nstart, \n// Length of the outer node\nlength, \n// Function to build the top node of the balanced tree\nmkTop, \n// Function to build internal nodes for the balanced tree\nmkTree) {\n let total = 0;\n for (let i = from; i < to; i++)\n total += nodeSize(balanceType, children[i]);\n let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);\n let localChildren = [], localPositions = [];\n function divide(children, positions, from, to, offset) {\n for (let i = from; i < to;) {\n let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);\n i++;\n for (; i < to; i++) {\n let nextSize = nodeSize(balanceType, children[i]);\n if (groupSize + nextSize >= maxChild)\n break;\n groupSize += nextSize;\n }\n if (i == groupFrom + 1) {\n if (groupSize > maxChild) {\n let only = children[groupFrom]; // Only trees can have a size > 1\n divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);\n continue;\n }\n localChildren.push(children[groupFrom]);\n }\n else {\n let length = positions[i - 1] + children[i - 1].length - groupStart;\n localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));\n }\n localPositions.push(groupStart + offset - start);\n }\n }\n divide(children, positions, from, to, 0);\n return (mkTop || mkTree)(localChildren, localPositions, length);\n}\n/**\nProvides a way to associate values with pieces of trees. As long\nas that part of the tree is reused, the associated values can be\nretrieved from an updated tree.\n*/\nclass NodeWeakMap {\n constructor() {\n this.map = new WeakMap();\n }\n setBuffer(buffer, index, value) {\n let inner = this.map.get(buffer);\n if (!inner)\n this.map.set(buffer, inner = new Map);\n inner.set(index, value);\n }\n getBuffer(buffer, index) {\n let inner = this.map.get(buffer);\n return inner && inner.get(index);\n }\n /**\n Set the value for this syntax node.\n */\n set(node, value) {\n if (node instanceof BufferNode)\n this.setBuffer(node.context.buffer, node.index, value);\n else if (node instanceof TreeNode)\n this.map.set(node.tree, value);\n }\n /**\n Retrieve value for this syntax node, if it exists in the map.\n */\n get(node) {\n return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index)\n : node instanceof TreeNode ? this.map.get(node.tree) : undefined;\n }\n /**\n Set the value for the node that a cursor currently points to.\n */\n cursorSet(cursor, value) {\n if (cursor.buffer)\n this.setBuffer(cursor.buffer.buffer, cursor.index, value);\n else\n this.map.set(cursor.tree, value);\n }\n /**\n Retrieve the value for the node that a cursor currently points\n to.\n */\n cursorGet(cursor) {\n return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);\n }\n}\n\n/**\nTree fragments are used during [incremental\nparsing](#common.Parser.startParse) to track parts of old trees\nthat can be reused in a new parse. An array of fragments is used\nto track regions of an old tree whose nodes might be reused in new\nparses. Use the static\n[`applyChanges`](#common.TreeFragment^applyChanges) method to\nupdate fragments for document changes.\n*/\nclass TreeFragment {\n /**\n Construct a tree fragment. You'll usually want to use\n [`addTree`](#common.TreeFragment^addTree) and\n [`applyChanges`](#common.TreeFragment^applyChanges) instead of\n calling this directly.\n */\n constructor(\n /**\n The start of the unchanged range pointed to by this fragment.\n This refers to an offset in the _updated_ document (as opposed\n to the original tree).\n */\n from, \n /**\n The end of the unchanged range.\n */\n to, \n /**\n The tree that this fragment is based on.\n */\n tree, \n /**\n The offset between the fragment's tree and the document that\n this fragment can be used against. Add this when going from\n document to tree positions, subtract it to go from tree to\n document positions.\n */\n offset, openStart = false, openEnd = false) {\n this.from = from;\n this.to = to;\n this.tree = tree;\n this.offset = offset;\n this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0);\n }\n /**\n Whether the start of the fragment represents the start of a\n parse, or the end of a change. (In the second case, it may not\n be safe to reuse some nodes at the start, depending on the\n parsing algorithm.)\n */\n get openStart() { return (this.open & 1 /* Open.Start */) > 0; }\n /**\n Whether the end of the fragment represents the end of a\n full-document parse, or the start of a change.\n */\n get openEnd() { return (this.open & 2 /* Open.End */) > 0; }\n /**\n Create a set of fragments from a freshly parsed tree, or update\n an existing set of fragments by replacing the ones that overlap\n with a tree with content from the new tree. When `partial` is\n true, the parse is treated as incomplete, and the resulting\n fragment has [`openEnd`](#common.TreeFragment.openEnd) set to\n true.\n */\n static addTree(tree, fragments = [], partial = false) {\n let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];\n for (let f of fragments)\n if (f.to > tree.length)\n result.push(f);\n return result;\n }\n /**\n Apply a set of edits to an array of fragments, removing or\n splitting fragments as necessary to remove edited ranges, and\n adjusting offsets for fragments that moved.\n */\n static applyChanges(fragments, changes, minGap = 128) {\n if (!changes.length)\n return fragments;\n let result = [];\n let fI = 1, nextF = fragments.length ? fragments[0] : null;\n for (let cI = 0, pos = 0, off = 0;; cI++) {\n let nextC = cI < changes.length ? changes[cI] : null;\n let nextPos = nextC ? nextC.fromA : 1e9;\n if (nextPos - pos >= minGap)\n while (nextF && nextF.from < nextPos) {\n let cut = nextF;\n if (pos >= cut.from || nextPos <= cut.to || off) {\n let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;\n cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);\n }\n if (cut)\n result.push(cut);\n if (nextF.to > nextPos)\n break;\n nextF = fI < fragments.length ? fragments[fI++] : null;\n }\n if (!nextC)\n break;\n pos = nextC.toA;\n off = nextC.toA - nextC.toB;\n }\n return result;\n }\n}\n/**\nA superclass that parsers should extend.\n*/\nclass Parser {\n /**\n Start a parse, returning a [partial parse](#common.PartialParse)\n object. [`fragments`](#common.TreeFragment) can be passed in to\n make the parse incremental.\n \n By default, the entire input is parsed. You can pass `ranges`,\n which should be a sorted array of non-empty, non-overlapping\n ranges, to parse only those ranges. The tree returned in that\n case will start at `ranges[0].from`.\n */\n startParse(input, fragments, ranges) {\n if (typeof input == \"string\")\n input = new StringInput(input);\n ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map(r => new Range(r.from, r.to)) : [new Range(0, 0)];\n return this.createParse(input, fragments || [], ranges);\n }\n /**\n Run a full parse, returning the resulting tree.\n */\n parse(input, fragments, ranges) {\n let parse = this.startParse(input, fragments, ranges);\n for (;;) {\n let done = parse.advance();\n if (done)\n return done;\n }\n }\n}\nclass StringInput {\n constructor(string) {\n this.string = string;\n }\n get length() { return this.string.length; }\n chunk(from) { return this.string.slice(from); }\n get lineChunks() { return false; }\n read(from, to) { return this.string.slice(from, to); }\n}\n\n/**\nCreate a parse wrapper that, after the inner parse completes,\nscans its tree for mixed language regions with the `nest`\nfunction, runs the resulting [inner parses](#common.NestedParse),\nand then [mounts](#common.NodeProp^mounted) their results onto the\ntree.\n*/\nfunction parseMixed(nest) {\n return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);\n}\nclass InnerParse {\n constructor(parser, parse, overlay, target, from) {\n this.parser = parser;\n this.parse = parse;\n this.overlay = overlay;\n this.target = target;\n this.from = from;\n }\n}\nfunction checkRanges(ranges) {\n if (!ranges.length || ranges.some(r => r.from >= r.to))\n throw new RangeError(\"Invalid inner parse ranges given: \" + JSON.stringify(ranges));\n}\nclass ActiveOverlay {\n constructor(parser, predicate, mounts, index, start, target, prev) {\n this.parser = parser;\n this.predicate = predicate;\n this.mounts = mounts;\n this.index = index;\n this.start = start;\n this.target = target;\n this.prev = prev;\n this.depth = 0;\n this.ranges = [];\n }\n}\nconst stoppedInner = new NodeProp({ perNode: true });\nclass MixedParse {\n constructor(base, nest, input, fragments, ranges) {\n this.nest = nest;\n this.input = input;\n this.fragments = fragments;\n this.ranges = ranges;\n this.inner = [];\n this.innerDone = 0;\n this.baseTree = null;\n this.stoppedAt = null;\n this.baseParse = base;\n }\n advance() {\n if (this.baseParse) {\n let done = this.baseParse.advance();\n if (!done)\n return null;\n this.baseParse = null;\n this.baseTree = done;\n this.startInner();\n if (this.stoppedAt != null)\n for (let inner of this.inner)\n inner.parse.stopAt(this.stoppedAt);\n }\n if (this.innerDone == this.inner.length) {\n let result = this.baseTree;\n if (this.stoppedAt != null)\n result = new Tree(result.type, result.children, result.positions, result.length, result.propValues.concat([[stoppedInner, this.stoppedAt]]));\n return result;\n }\n let inner = this.inner[this.innerDone], done = inner.parse.advance();\n if (done) {\n this.innerDone++;\n // This is a somewhat dodgy but super helpful hack where we\n // patch up nodes created by the inner parse (and thus\n // presumably not aliased anywhere else) to hold the information\n // about the inner parse.\n let props = Object.assign(Object.create(null), inner.target.props);\n props[NodeProp.mounted.id] = new MountedTree(done, inner.overlay, inner.parser);\n inner.target.props = props;\n }\n return null;\n }\n get parsedPos() {\n if (this.baseParse)\n return 0;\n let pos = this.input.length;\n for (let i = this.innerDone; i < this.inner.length; i++) {\n if (this.inner[i].from < pos)\n pos = Math.min(pos, this.inner[i].parse.parsedPos);\n }\n return pos;\n }\n stopAt(pos) {\n this.stoppedAt = pos;\n if (this.baseParse)\n this.baseParse.stopAt(pos);\n else\n for (let i = this.innerDone; i < this.inner.length; i++)\n this.inner[i].parse.stopAt(pos);\n }\n startInner() {\n let fragmentCursor = new FragmentCursor(this.fragments);\n let overlay = null;\n let covered = null;\n let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);\n scan: for (let nest, isCovered;;) {\n let enter = true, range;\n if (this.stoppedAt != null && cursor.from >= this.stoppedAt) {\n enter = false;\n }\n else if (fragmentCursor.hasNode(cursor)) {\n if (overlay) {\n let match = overlay.mounts.find(m => m.frag.from <= cursor.from && m.frag.to >= cursor.to && m.mount.overlay);\n if (match)\n for (let r of match.mount.overlay) {\n let from = r.from + match.pos, to = r.to + match.pos;\n if (from >= cursor.from && to <= cursor.to && !overlay.ranges.some(r => r.from < to && r.to > from))\n overlay.ranges.push({ from, to });\n }\n }\n enter = false;\n }\n else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) {\n enter = isCovered != 2 /* Cover.Full */;\n }\n else if (!cursor.type.isAnonymous && (nest = this.nest(cursor, this.input)) &&\n (cursor.from < cursor.to || !nest.overlay)) {\n if (!cursor.tree)\n materialize(cursor);\n let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);\n if (typeof nest.overlay == \"function\") {\n overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, cursor.tree, overlay);\n }\n else {\n let ranges = punchRanges(this.ranges, nest.overlay ||\n (cursor.from < cursor.to ? [new Range(cursor.from, cursor.to)] : []));\n if (ranges.length)\n checkRanges(ranges);\n if (ranges.length || !nest.overlay)\n this.inner.push(new InnerParse(nest.parser, ranges.length ? nest.parser.startParse(this.input, enterFragments(oldMounts, ranges), ranges)\n : nest.parser.startParse(\"\"), nest.overlay ? nest.overlay.map(r => new Range(r.from - cursor.from, r.to - cursor.from)) : null, cursor.tree, ranges.length ? ranges[0].from : cursor.from));\n if (!nest.overlay)\n enter = false;\n else if (ranges.length)\n covered = { ranges, depth: 0, prev: covered };\n }\n }\n else if (overlay && (range = overlay.predicate(cursor))) {\n if (range === true)\n range = new Range(cursor.from, cursor.to);\n if (range.from < range.to)\n overlay.ranges.push(range);\n }\n if (enter && cursor.firstChild()) {\n if (overlay)\n overlay.depth++;\n if (covered)\n covered.depth++;\n }\n else {\n for (;;) {\n if (cursor.nextSibling())\n break;\n if (!cursor.parent())\n break scan;\n if (overlay && !--overlay.depth) {\n let ranges = punchRanges(this.ranges, overlay.ranges);\n if (ranges.length) {\n checkRanges(ranges);\n this.inner.splice(overlay.index, 0, new InnerParse(overlay.parser, overlay.parser.startParse(this.input, enterFragments(overlay.mounts, ranges), ranges), overlay.ranges.map(r => new Range(r.from - overlay.start, r.to - overlay.start)), overlay.target, ranges[0].from));\n }\n overlay = overlay.prev;\n }\n if (covered && !--covered.depth)\n covered = covered.prev;\n }\n }\n }\n }\n}\nfunction checkCover(covered, from, to) {\n for (let range of covered) {\n if (range.from >= to)\n break;\n if (range.to > from)\n return range.from <= from && range.to >= to ? 2 /* Cover.Full */ : 1 /* Cover.Partial */;\n }\n return 0 /* Cover.None */;\n}\n// Take a piece of buffer and convert it into a stand-alone\n// TreeBuffer.\nfunction sliceBuf(buf, startI, endI, nodes, positions, off) {\n if (startI < endI) {\n let from = buf.buffer[startI + 1];\n nodes.push(buf.slice(startI, endI, from));\n positions.push(from - off);\n }\n}\n// This function takes a node that's in a buffer, and converts it, and\n// its parent buffer nodes, into a Tree. This is again acting on the\n// assumption that the trees and buffers have been constructed by the\n// parse that was ran via the mix parser, and thus aren't shared with\n// any other code, making violations of the immutability safe.\nfunction materialize(cursor) {\n let { node } = cursor, stack = [];\n let buffer = node.context.buffer;\n // Scan up to the nearest tree\n do {\n stack.push(cursor.index);\n cursor.parent();\n } while (!cursor.tree);\n // Find the index of the buffer in that tree\n let base = cursor.tree, i = base.children.indexOf(buffer);\n let buf = base.children[i], b = buf.buffer, newStack = [i];\n // Split a level in the buffer, putting the nodes before and after\n // the child that contains `node` into new buffers.\n function split(startI, endI, type, innerOffset, length, stackPos) {\n let targetI = stack[stackPos];\n let children = [], positions = [];\n sliceBuf(buf, startI, targetI, children, positions, innerOffset);\n let from = b[targetI + 1], to = b[targetI + 2];\n newStack.push(children.length);\n let child = stackPos\n ? split(targetI + 4, b[targetI + 3], buf.set.types[b[targetI]], from, to - from, stackPos - 1)\n : node.toTree();\n children.push(child);\n positions.push(from - innerOffset);\n sliceBuf(buf, b[targetI + 3], endI, children, positions, innerOffset);\n return new Tree(type, children, positions, length);\n }\n base.children[i] = split(0, b.length, NodeType.none, 0, buf.length, stack.length - 1);\n // Move the cursor back to the target node\n for (let index of newStack) {\n let tree = cursor.tree.children[index], pos = cursor.tree.positions[index];\n cursor.yield(new TreeNode(tree, pos + cursor.from, index, cursor._tree));\n }\n}\nclass StructureCursor {\n constructor(root, offset) {\n this.offset = offset;\n this.done = false;\n this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);\n }\n // Move to the first node (in pre-order) that starts at or after `pos`.\n moveTo(pos) {\n let { cursor } = this, p = pos - this.offset;\n while (!this.done && cursor.from < p) {\n if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers)) ;\n else if (!cursor.next(false))\n this.done = true;\n }\n }\n hasNode(cursor) {\n this.moveTo(cursor.from);\n if (!this.done && this.cursor.from + this.offset == cursor.from && this.cursor.tree) {\n for (let tree = this.cursor.tree;;) {\n if (tree == cursor.tree)\n return true;\n if (tree.children.length && tree.positions[0] == 0 && tree.children[0] instanceof Tree)\n tree = tree.children[0];\n else\n break;\n }\n }\n return false;\n }\n}\nclass FragmentCursor {\n constructor(fragments) {\n var _a;\n this.fragments = fragments;\n this.curTo = 0;\n this.fragI = 0;\n if (fragments.length) {\n let first = this.curFrag = fragments[0];\n this.curTo = (_a = first.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : first.to;\n this.inner = new StructureCursor(first.tree, -first.offset);\n }\n else {\n this.curFrag = this.inner = null;\n }\n }\n hasNode(node) {\n while (this.curFrag && node.from >= this.curTo)\n this.nextFrag();\n return this.curFrag && this.curFrag.from <= node.from && this.curTo >= node.to && this.inner.hasNode(node);\n }\n nextFrag() {\n var _a;\n this.fragI++;\n if (this.fragI == this.fragments.length) {\n this.curFrag = this.inner = null;\n }\n else {\n let frag = this.curFrag = this.fragments[this.fragI];\n this.curTo = (_a = frag.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : frag.to;\n this.inner = new StructureCursor(frag.tree, -frag.offset);\n }\n }\n findMounts(pos, parser) {\n var _a;\n let result = [];\n if (this.inner) {\n this.inner.cursor.moveTo(pos, 1);\n for (let pos = this.inner.cursor.node; pos; pos = pos.parent) {\n let mount = (_a = pos.tree) === null || _a === void 0 ? void 0 : _a.prop(NodeProp.mounted);\n if (mount && mount.parser == parser) {\n for (let i = this.fragI; i < this.fragments.length; i++) {\n let frag = this.fragments[i];\n if (frag.from >= pos.to)\n break;\n if (frag.tree == this.curFrag.tree)\n result.push({\n frag,\n pos: pos.from - frag.offset,\n mount\n });\n }\n }\n }\n }\n return result;\n }\n}\nfunction punchRanges(outer, ranges) {\n let copy = null, current = ranges;\n for (let i = 1, j = 0; i < outer.length; i++) {\n let gapFrom = outer[i - 1].to, gapTo = outer[i].from;\n for (; j < current.length; j++) {\n let r = current[j];\n if (r.from >= gapTo)\n break;\n if (r.to <= gapFrom)\n continue;\n if (!copy)\n current = copy = ranges.slice();\n if (r.from < gapFrom) {\n copy[j] = new Range(r.from, gapFrom);\n if (r.to > gapTo)\n copy.splice(j + 1, 0, new Range(gapTo, r.to));\n }\n else if (r.to > gapTo) {\n copy[j--] = new Range(gapTo, r.to);\n }\n else {\n copy.splice(j--, 1);\n }\n }\n }\n return current;\n}\nfunction findCoverChanges(a, b, from, to) {\n let iA = 0, iB = 0, inA = false, inB = false, pos = -1e9;\n let result = [];\n for (;;) {\n let nextA = iA == a.length ? 1e9 : inA ? a[iA].to : a[iA].from;\n let nextB = iB == b.length ? 1e9 : inB ? b[iB].to : b[iB].from;\n if (inA != inB) {\n let start = Math.max(pos, from), end = Math.min(nextA, nextB, to);\n if (start < end)\n result.push(new Range(start, end));\n }\n pos = Math.min(nextA, nextB);\n if (pos == 1e9)\n break;\n if (nextA == pos) {\n if (!inA)\n inA = true;\n else {\n inA = false;\n iA++;\n }\n }\n if (nextB == pos) {\n if (!inB)\n inB = true;\n else {\n inB = false;\n iB++;\n }\n }\n }\n return result;\n}\n// Given a number of fragments for the outer tree, and a set of ranges\n// to parse, find fragments for inner trees mounted around those\n// ranges, if any.\nfunction enterFragments(mounts, ranges) {\n let result = [];\n for (let { pos, mount, frag } of mounts) {\n let startPos = pos + (mount.overlay ? mount.overlay[0].from : 0), endPos = startPos + mount.tree.length;\n let from = Math.max(frag.from, startPos), to = Math.min(frag.to, endPos);\n if (mount.overlay) {\n let overlay = mount.overlay.map(r => new Range(r.from + pos, r.to + pos));\n let changes = findCoverChanges(ranges, overlay, from, to);\n for (let i = 0, pos = from;; i++) {\n let last = i == changes.length, end = last ? to : changes[i].from;\n if (end > pos)\n result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos || frag.openStart, frag.to <= end || frag.openEnd));\n if (last)\n break;\n pos = changes[i].to;\n }\n }\n else {\n result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));\n }\n }\n return result;\n}\n\nexport { DefaultBufferLength, IterMode, MountedTree, NodeProp, NodeSet, NodeType, NodeWeakMap, Parser, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };\n","import { NodeProp } from '@lezer/common';\n\nlet nextTagID = 0;\n/**\nHighlighting tags are markers that denote a highlighting category.\nThey are [associated](#highlight.styleTags) with parts of a syntax\ntree by a language mode, and then mapped to an actual CSS style by\na [highlighter](#highlight.Highlighter).\n\nBecause syntax tree node types and highlight styles have to be\nable to talk the same language, CodeMirror uses a mostly _closed_\n[vocabulary](#highlight.tags) of syntax tags (as opposed to\ntraditional open string-based systems, which make it hard for\nhighlighting themes to cover all the tokens produced by the\nvarious languages).\n\nIt _is_ possible to [define](#highlight.Tag^define) your own\nhighlighting tags for system-internal use (where you control both\nthe language package and the highlighter), but such tags will not\nbe picked up by regular highlighters (though you can derive them\nfrom standard tags to allow highlighters to fall back to those).\n*/\nclass Tag {\n /**\n @internal\n */\n constructor(\n /**\n The set of this tag and all its parent tags, starting with\n this one itself and sorted in order of decreasing specificity.\n */\n set, \n /**\n The base unmodified tag that this one is based on, if it's\n modified @internal\n */\n base, \n /**\n The modifiers applied to this.base @internal\n */\n modified) {\n this.set = set;\n this.base = base;\n this.modified = modified;\n /**\n @internal\n */\n this.id = nextTagID++;\n }\n /**\n Define a new tag. If `parent` is given, the tag is treated as a\n sub-tag of that parent, and\n [highlighters](#highlight.tagHighlighter) that don't mention\n this tag will try to fall back to the parent tag (or grandparent\n tag, etc).\n */\n static define(parent) {\n if (parent === null || parent === void 0 ? void 0 : parent.base)\n throw new Error(\"Can not derive from a modified tag\");\n let tag = new Tag([], null, []);\n tag.set.push(tag);\n if (parent)\n for (let t of parent.set)\n tag.set.push(t);\n return tag;\n }\n /**\n Define a tag _modifier_, which is a function that, given a tag,\n will return a tag that is a subtag of the original. Applying the\n same modifier to a twice tag will return the same value (`m1(t1)\n == m1(t1)`) and applying multiple modifiers will, regardless or\n order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).\n \n When multiple modifiers are applied to a given base tag, each\n smaller set of modifiers is registered as a parent, so that for\n example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,\n `m1(m3(t1)`, and so on.\n */\n static defineModifier() {\n let mod = new Modifier;\n return (tag) => {\n if (tag.modified.indexOf(mod) > -1)\n return tag;\n return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));\n };\n }\n}\nlet nextModifierID = 0;\nclass Modifier {\n constructor() {\n this.instances = [];\n this.id = nextModifierID++;\n }\n static get(base, mods) {\n if (!mods.length)\n return base;\n let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));\n if (exists)\n return exists;\n let set = [], tag = new Tag(set, base, mods);\n for (let m of mods)\n m.instances.push(tag);\n let configs = powerSet(mods);\n for (let parent of base.set)\n if (!parent.modified.length)\n for (let config of configs)\n set.push(Modifier.get(parent, config));\n return tag;\n }\n}\nfunction sameArray(a, b) {\n return a.length == b.length && a.every((x, i) => x == b[i]);\n}\nfunction powerSet(array) {\n let sets = [[]];\n for (let i = 0; i < array.length; i++) {\n for (let j = 0, e = sets.length; j < e; j++) {\n sets.push(sets[j].concat(array[i]));\n }\n }\n return sets.sort((a, b) => b.length - a.length);\n}\n/**\nThis function is used to add a set of tags to a language syntax\nvia [`NodeSet.extend`](#common.NodeSet.extend) or\n[`LRParser.configure`](#lr.LRParser.configure).\n\nThe argument object maps node selectors to [highlighting\ntags](#highlight.Tag) or arrays of tags.\n\nNode selectors may hold one or more (space-separated) node paths.\nSuch a path can be a [node name](#common.NodeType.name), or\nmultiple node names (or `*` wildcards) separated by slash\ncharacters, as in `\"Block/Declaration/VariableName\"`. Such a path\nmatches the final node but only if its direct parent nodes are the\nother nodes mentioned. A `*` in such a path matches any parent,\nbut only a single level—wildcards that match multiple parents\naren't supported, both for efficiency reasons and because Lezer\ntrees make it rather hard to reason about what they would match.)\n\nA path can be ended with `/...` to indicate that the tag assigned\nto the node should also apply to all child nodes, even if they\nmatch their own style (by default, only the innermost style is\nused).\n\nWhen a path ends in `!`, as in `Attribute!`, no further matching\nhappens for the node's child nodes, and the entire node gets the\ngiven style.\n\nIn this notation, node names that contain `/`, `!`, `*`, or `...`\nmust be quoted as JSON strings.\n\nFor example:\n\n```javascript\nparser.withProps(\n styleTags({\n // Style Number and BigNumber nodes\n \"Number BigNumber\": tags.number,\n // Style Escape nodes whose parent is String\n \"String/Escape\": tags.escape,\n // Style anything inside Attributes nodes\n \"Attributes!\": tags.meta,\n // Add a style to all content inside Italic nodes\n \"Italic/...\": tags.emphasis,\n // Style InvalidString nodes as both `string` and `invalid`\n \"InvalidString\": [tags.string, tags.invalid],\n // Style the node named \"/\" as punctuation\n '\"/\"': tags.punctuation\n })\n)\n```\n*/\nfunction styleTags(spec) {\n let byName = Object.create(null);\n for (let prop in spec) {\n let tags = spec[prop];\n if (!Array.isArray(tags))\n tags = [tags];\n for (let part of prop.split(\" \"))\n if (part) {\n let pieces = [], mode = 2 /* Mode.Normal */, rest = part;\n for (let pos = 0;;) {\n if (rest == \"...\" && pos > 0 && pos + 3 == part.length) {\n mode = 1 /* Mode.Inherit */;\n break;\n }\n let m = /^\"(?:[^\"\\\\]|\\\\.)*?\"|[^\\/!]+/.exec(rest);\n if (!m)\n throw new RangeError(\"Invalid path: \" + part);\n pieces.push(m[0] == \"*\" ? \"\" : m[0][0] == '\"' ? JSON.parse(m[0]) : m[0]);\n pos += m[0].length;\n if (pos == part.length)\n break;\n let next = part[pos++];\n if (pos == part.length && next == \"!\") {\n mode = 0 /* Mode.Opaque */;\n break;\n }\n if (next != \"/\")\n throw new RangeError(\"Invalid path: \" + part);\n rest = part.slice(pos);\n }\n let last = pieces.length - 1, inner = pieces[last];\n if (!inner)\n throw new RangeError(\"Invalid path: \" + part);\n let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);\n byName[inner] = rule.sort(byName[inner]);\n }\n }\n return ruleNodeProp.add(byName);\n}\nconst ruleNodeProp = new NodeProp();\nclass Rule {\n constructor(tags, mode, context, next) {\n this.tags = tags;\n this.mode = mode;\n this.context = context;\n this.next = next;\n }\n get opaque() { return this.mode == 0 /* Mode.Opaque */; }\n get inherit() { return this.mode == 1 /* Mode.Inherit */; }\n sort(other) {\n if (!other || other.depth < this.depth) {\n this.next = other;\n return this;\n }\n other.next = this.sort(other.next);\n return other;\n }\n get depth() { return this.context ? this.context.length : 0; }\n}\nRule.empty = new Rule([], 2 /* Mode.Normal */, null);\n/**\nDefine a [highlighter](#highlight.Highlighter) from an array of\ntag/class pairs. Classes associated with more specific tags will\ntake precedence.\n*/\nfunction tagHighlighter(tags, options) {\n let map = Object.create(null);\n for (let style of tags) {\n if (!Array.isArray(style.tag))\n map[style.tag.id] = style.class;\n else\n for (let tag of style.tag)\n map[tag.id] = style.class;\n }\n let { scope, all = null } = options || {};\n return {\n style: (tags) => {\n let cls = all;\n for (let tag of tags) {\n for (let sub of tag.set) {\n let tagClass = map[sub.id];\n if (tagClass) {\n cls = cls ? cls + \" \" + tagClass : tagClass;\n break;\n }\n }\n }\n return cls;\n },\n scope\n };\n}\nfunction highlightTags(highlighters, tags) {\n let result = null;\n for (let highlighter of highlighters) {\n let value = highlighter.style(tags);\n if (value)\n result = result ? result + \" \" + value : value;\n }\n return result;\n}\n/**\nHighlight the given [tree](#common.Tree) with the given\n[highlighter](#highlight.Highlighter). Often, the higher-level\n[`highlightCode`](#highlight.highlightCode) function is easier to\nuse.\n*/\nfunction highlightTree(tree, highlighter, \n/**\nAssign styling to a region of the text. Will be called, in order\nof position, for any ranges where more than zero classes apply.\n`classes` is a space separated string of CSS classes.\n*/\nputStyle, \n/**\nThe start of the range to highlight.\n*/\nfrom = 0, \n/**\nThe end of the range.\n*/\nto = tree.length) {\n let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);\n builder.highlightRange(tree.cursor(), from, to, \"\", builder.highlighters);\n builder.flush(to);\n}\n/**\nHighlight the given tree with the given highlighter, calling\n`putText` for every piece of text, either with a set of classes or\nwith the empty string when unstyled, and `putBreak` for every line\nbreak.\n*/\nfunction highlightCode(code, tree, highlighter, putText, putBreak, from = 0, to = code.length) {\n let pos = from;\n function writeTo(p, classes) {\n if (p <= pos)\n return;\n for (let text = code.slice(pos, p), i = 0;;) {\n let nextBreak = text.indexOf(\"\\n\", i);\n let upto = nextBreak < 0 ? text.length : nextBreak;\n if (upto > i)\n putText(text.slice(i, upto), classes);\n if (nextBreak < 0)\n break;\n putBreak();\n i = nextBreak + 1;\n }\n pos = p;\n }\n highlightTree(tree, highlighter, (from, to, classes) => {\n writeTo(from, \"\");\n writeTo(to, classes);\n }, from, to);\n writeTo(to, \"\");\n}\nclass HighlightBuilder {\n constructor(at, highlighters, span) {\n this.at = at;\n this.highlighters = highlighters;\n this.span = span;\n this.class = \"\";\n }\n startSpan(at, cls) {\n if (cls != this.class) {\n this.flush(at);\n if (at > this.at)\n this.at = at;\n this.class = cls;\n }\n }\n flush(to) {\n if (to > this.at && this.class)\n this.span(this.at, to, this.class);\n }\n highlightRange(cursor, from, to, inheritedClass, highlighters) {\n let { type, from: start, to: end } = cursor;\n if (start >= to || end <= from)\n return;\n if (type.isTop)\n highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));\n let cls = inheritedClass;\n let rule = getStyleTags(cursor) || Rule.empty;\n let tagCls = highlightTags(highlighters, rule.tags);\n if (tagCls) {\n if (cls)\n cls += \" \";\n cls += tagCls;\n if (rule.mode == 1 /* Mode.Inherit */)\n inheritedClass += (inheritedClass ? \" \" : \"\") + tagCls;\n }\n this.startSpan(Math.max(from, start), cls);\n if (rule.opaque)\n return;\n let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);\n if (mounted && mounted.overlay) {\n let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);\n let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));\n let hasChild = cursor.firstChild();\n for (let i = 0, pos = start;; i++) {\n let next = i < mounted.overlay.length ? mounted.overlay[i] : null;\n let nextPos = next ? next.from + start : end;\n let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);\n if (rangeFrom < rangeTo && hasChild) {\n while (cursor.from < rangeTo) {\n this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);\n this.startSpan(Math.min(rangeTo, cursor.to), cls);\n if (cursor.to >= nextPos || !cursor.nextSibling())\n break;\n }\n }\n if (!next || nextPos > to)\n break;\n pos = next.to + start;\n if (pos > from) {\n this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), \"\", innerHighlighters);\n this.startSpan(Math.min(to, pos), cls);\n }\n }\n if (hasChild)\n cursor.parent();\n }\n else if (cursor.firstChild()) {\n if (mounted)\n inheritedClass = \"\";\n do {\n if (cursor.to <= from)\n continue;\n if (cursor.from >= to)\n break;\n this.highlightRange(cursor, from, to, inheritedClass, highlighters);\n this.startSpan(Math.min(to, cursor.to), cls);\n } while (cursor.nextSibling());\n cursor.parent();\n }\n }\n}\n/**\nMatch a syntax node's [highlight rules](#highlight.styleTags). If\nthere's a match, return its set of tags, and whether it is\nopaque (uses a `!`) or applies to all child nodes (`/...`).\n*/\nfunction getStyleTags(node) {\n let rule = node.type.prop(ruleNodeProp);\n while (rule && rule.context && !node.matchContext(rule.context))\n rule = rule.next;\n return rule || null;\n}\nconst t = Tag.define;\nconst 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();\n/**\nThe default set of highlighting [tags](#highlight.Tag).\n\nThis collection is heavily biased towards programming languages,\nand necessarily incomplete. A full ontology of syntactic\nconstructs would fill a stack of books, and be impractical to\nwrite themes for. So try to make do with this set. If all else\nfails, [open an\nissue](https://github.com/codemirror/codemirror.next) to propose a\nnew tag, or [define](#highlight.Tag^define) a local custom tag for\nyour use case.\n\nNote that it is not obligatory to always attach the most specific\ntag possible to an element—if your grammar can't easily\ndistinguish a certain type of element (such as a local variable),\nit is okay to style it as its more general variant (a variable).\n\nFor tags that extend some parent tag, the documentation links to\nthe parent.\n*/\nconst tags = {\n /**\n A comment.\n */\n comment,\n /**\n A line [comment](#highlight.tags.comment).\n */\n lineComment: t(comment),\n /**\n A block [comment](#highlight.tags.comment).\n */\n blockComment: t(comment),\n /**\n A documentation [comment](#highlight.tags.comment).\n */\n docComment: t(comment),\n /**\n Any kind of identifier.\n */\n name,\n /**\n The [name](#highlight.tags.name) of a variable.\n */\n variableName: t(name),\n /**\n A type [name](#highlight.tags.name).\n */\n typeName: typeName,\n /**\n A tag name (subtag of [`typeName`](#highlight.tags.typeName)).\n */\n tagName: t(typeName),\n /**\n A property or field [name](#highlight.tags.name).\n */\n propertyName: propertyName,\n /**\n An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).\n */\n attributeName: t(propertyName),\n /**\n The [name](#highlight.tags.name) of a class.\n */\n className: t(name),\n /**\n A label [name](#highlight.tags.name).\n */\n labelName: t(name),\n /**\n A namespace [name](#highlight.tags.name).\n */\n namespace: t(name),\n /**\n The [name](#highlight.tags.name) of a macro.\n */\n macroName: t(name),\n /**\n A literal value.\n */\n literal,\n /**\n A string [literal](#highlight.tags.literal).\n */\n string,\n /**\n A documentation [string](#highlight.tags.string).\n */\n docString: t(string),\n /**\n A character literal (subtag of [string](#highlight.tags.string)).\n */\n character: t(string),\n /**\n An attribute value (subtag of [string](#highlight.tags.string)).\n */\n attributeValue: t(string),\n /**\n A number [literal](#highlight.tags.literal).\n */\n number,\n /**\n An integer [number](#highlight.tags.number) literal.\n */\n integer: t(number),\n /**\n A floating-point [number](#highlight.tags.number) literal.\n */\n float: t(number),\n /**\n A boolean [literal](#highlight.tags.literal).\n */\n bool: t(literal),\n /**\n Regular expression [literal](#highlight.tags.literal).\n */\n regexp: t(literal),\n /**\n An escape [literal](#highlight.tags.literal), for example a\n backslash escape in a string.\n */\n escape: t(literal),\n /**\n A color [literal](#highlight.tags.literal).\n */\n color: t(literal),\n /**\n A URL [literal](#highlight.tags.literal).\n */\n url: t(literal),\n /**\n A language keyword.\n */\n keyword,\n /**\n The [keyword](#highlight.tags.keyword) for the self or this\n object.\n */\n self: t(keyword),\n /**\n The [keyword](#highlight.tags.keyword) for null.\n */\n null: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) denoting some atomic value.\n */\n atom: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that represents a unit.\n */\n unit: t(keyword),\n /**\n A modifier [keyword](#highlight.tags.keyword).\n */\n modifier: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that acts as an operator.\n */\n operatorKeyword: t(keyword),\n /**\n A control-flow related [keyword](#highlight.tags.keyword).\n */\n controlKeyword: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that defines something.\n */\n definitionKeyword: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) related to defining or\n interfacing with modules.\n */\n moduleKeyword: t(keyword),\n /**\n An operator.\n */\n operator,\n /**\n An [operator](#highlight.tags.operator) that dereferences something.\n */\n derefOperator: t(operator),\n /**\n Arithmetic-related [operator](#highlight.tags.operator).\n */\n arithmeticOperator: t(operator),\n /**\n Logical [operator](#highlight.tags.operator).\n */\n logicOperator: t(operator),\n /**\n Bit [operator](#highlight.tags.operator).\n */\n bitwiseOperator: t(operator),\n /**\n Comparison [operator](#highlight.tags.operator).\n */\n compareOperator: t(operator),\n /**\n [Operator](#highlight.tags.operator) that updates its operand.\n */\n updateOperator: t(operator),\n /**\n [Operator](#highlight.tags.operator) that defines something.\n */\n definitionOperator: t(operator),\n /**\n Type-related [operator](#highlight.tags.operator).\n */\n typeOperator: t(operator),\n /**\n Control-flow [operator](#highlight.tags.operator).\n */\n controlOperator: t(operator),\n /**\n Program or markup punctuation.\n */\n punctuation,\n /**\n [Punctuation](#highlight.tags.punctuation) that separates\n things.\n */\n separator: t(punctuation),\n /**\n Bracket-style [punctuation](#highlight.tags.punctuation).\n */\n bracket,\n /**\n Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`\n tokens).\n */\n angleBracket: t(bracket),\n /**\n Square [brackets](#highlight.tags.bracket) (usually `[` and `]`\n tokens).\n */\n squareBracket: t(bracket),\n /**\n Parentheses (usually `(` and `)` tokens). Subtag of\n [bracket](#highlight.tags.bracket).\n */\n paren: t(bracket),\n /**\n Braces (usually `{` and `}` tokens). Subtag of\n [bracket](#highlight.tags.bracket).\n */\n brace: t(bracket),\n /**\n Content, for example plain text in XML or markup documents.\n */\n content,\n /**\n [Content](#highlight.tags.content) that represents a heading.\n */\n heading,\n /**\n A level 1 [heading](#highlight.tags.heading).\n */\n heading1: t(heading),\n /**\n A level 2 [heading](#highlight.tags.heading).\n */\n heading2: t(heading),\n /**\n A level 3 [heading](#highlight.tags.heading).\n */\n heading3: t(heading),\n /**\n A level 4 [heading](#highlight.tags.heading).\n */\n heading4: t(heading),\n /**\n A level 5 [heading](#highlight.tags.heading).\n */\n heading5: t(heading),\n /**\n A level 6 [heading](#highlight.tags.heading).\n */\n heading6: t(heading),\n /**\n A prose separator (such as a horizontal rule).\n */\n contentSeparator: t(content),\n /**\n [Content](#highlight.tags.content) that represents a list.\n */\n list: t(content),\n /**\n [Content](#highlight.tags.content) that represents a quote.\n */\n quote: t(content),\n /**\n [Content](#highlight.tags.content) that is emphasized.\n */\n emphasis: t(content),\n /**\n [Content](#highlight.tags.content) that is styled strong.\n */\n strong: t(content),\n /**\n [Content](#highlight.tags.content) that is part of a link.\n */\n link: t(content),\n /**\n [Content](#highlight.tags.content) that is styled as code or\n monospace.\n */\n monospace: t(content),\n /**\n [Content](#highlight.tags.content) that has a strike-through\n style.\n */\n strikethrough: t(content),\n /**\n Inserted text in a change-tracking format.\n */\n inserted: t(),\n /**\n Deleted text.\n */\n deleted: t(),\n /**\n Changed text.\n */\n changed: t(),\n /**\n An invalid or unsyntactic element.\n */\n invalid: t(),\n /**\n Metadata or meta-instruction.\n */\n meta,\n /**\n [Metadata](#highlight.tags.meta) that applies to the entire\n document.\n */\n documentMeta: t(meta),\n /**\n [Metadata](#highlight.tags.meta) that annotates or adds\n attributes to a given syntactic element.\n */\n annotation: t(meta),\n /**\n Processing instruction or preprocessor directive. Subtag of\n [meta](#highlight.tags.meta).\n */\n processingInstruction: t(meta),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates that a\n given element is being defined. Expected to be used with the\n various [name](#highlight.tags.name) tags.\n */\n definition: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates that\n something is constant. Mostly expected to be used with\n [variable names](#highlight.tags.variableName).\n */\n constant: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) used to indicate that\n a [variable](#highlight.tags.variableName) or [property\n name](#highlight.tags.propertyName) is being called or defined\n as a function.\n */\n function: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that can be applied to\n [names](#highlight.tags.name) to indicate that they belong to\n the language's standard environment.\n */\n standard: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates a given\n [names](#highlight.tags.name) is local to some scope.\n */\n local: Tag.defineModifier(),\n /**\n A generic variant [modifier](#highlight.Tag^defineModifier) that\n can be used to tag language-specific alternative variants of\n some common tag. It is recommended for themes to define special\n forms of at least the [string](#highlight.tags.string) and\n [variable name](#highlight.tags.variableName) tags, since those\n come up a lot.\n */\n special: Tag.defineModifier()\n};\n/**\nThis is a highlighter that adds stable, predictable classes to\ntokens, for styling with external CSS.\n\nThe following tags are mapped to their name prefixed with `\"tok-\"`\n(for example `\"tok-comment\"`):\n\n* [`link`](#highlight.tags.link)\n* [`heading`](#highlight.tags.heading)\n* [`emphasis`](#highlight.tags.emphasis)\n* [`strong`](#highlight.tags.strong)\n* [`keyword`](#highlight.tags.keyword)\n* [`atom`](#highlight.tags.atom)\n* [`bool`](#highlight.tags.bool)\n* [`url`](#highlight.tags.url)\n* [`labelName`](#highlight.tags.labelName)\n* [`inserted`](#highlight.tags.inserted)\n* [`deleted`](#highlight.tags.deleted)\n* [`literal`](#highlight.tags.literal)\n* [`string`](#highlight.tags.string)\n* [`number`](#highlight.tags.number)\n* [`variableName`](#highlight.tags.variableName)\n* [`typeName`](#highlight.tags.typeName)\n* [`namespace`](#highlight.tags.namespace)\n* [`className`](#highlight.tags.className)\n* [`macroName`](#highlight.tags.macroName)\n* [`propertyName`](#highlight.tags.propertyName)\n* [`operator`](#highlight.tags.operator)\n* [`comment`](#highlight.tags.comment)\n* [`meta`](#highlight.tags.meta)\n* [`punctuation`](#highlight.tags.punctuation)\n* [`invalid`](#highlight.tags.invalid)\n\nIn addition, these mappings are provided:\n\n* [`regexp`](#highlight.tags.regexp),\n [`escape`](#highlight.tags.escape), and\n [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)\n are mapped to `\"tok-string2\"`\n* [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName2\"`\n* [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName tok-local\"`\n* [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName tok-definition\"`\n* [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)\n to `\"tok-propertyName tok-definition\"`\n*/\nconst classHighlighter = tagHighlighter([\n { tag: tags.link, class: \"tok-link\" },\n { tag: tags.heading, class: \"tok-heading\" },\n { tag: tags.emphasis, class: \"tok-emphasis\" },\n { tag: tags.strong, class: \"tok-strong\" },\n { tag: tags.keyword, class: \"tok-keyword\" },\n { tag: tags.atom, class: \"tok-atom\" },\n { tag: tags.bool, class: \"tok-bool\" },\n { tag: tags.url, class: \"tok-url\" },\n { tag: tags.labelName, class: \"tok-labelName\" },\n { tag: tags.inserted, class: \"tok-inserted\" },\n { tag: tags.deleted, class: \"tok-deleted\" },\n { tag: tags.literal, class: \"tok-literal\" },\n { tag: tags.string, class: \"tok-string\" },\n { tag: tags.number, class: \"tok-number\" },\n { tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: \"tok-string2\" },\n { tag: tags.variableName, class: \"tok-variableName\" },\n { tag: tags.local(tags.variableName), class: \"tok-variableName tok-local\" },\n { tag: tags.definition(tags.variableName), class: \"tok-variableName tok-definition\" },\n { tag: tags.special(tags.variableName), class: \"tok-variableName2\" },\n { tag: tags.definition(tags.propertyName), class: \"tok-propertyName tok-definition\" },\n { tag: tags.typeName, class: \"tok-typeName\" },\n { tag: tags.namespace, class: \"tok-namespace\" },\n { tag: tags.className, class: \"tok-className\" },\n { tag: tags.macroName, class: \"tok-macroName\" },\n { tag: tags.propertyName, class: \"tok-propertyName\" },\n { tag: tags.operator, class: \"tok-operator\" },\n { tag: tags.comment, class: \"tok-comment\" },\n { tag: tags.meta, class: \"tok-meta\" },\n { tag: tags.invalid, class: \"tok-invalid\" },\n { tag: tags.punctuation, class: \"tok-punctuation\" }\n]);\n\nexport { Tag, classHighlighter, getStyleTags, highlightCode, highlightTree, styleTags, tagHighlighter, tags };\n","import { NodeProp, IterMode, Tree, TreeFragment, Parser, NodeType, NodeSet } from '@lezer/common';\nimport { StateEffect, StateField, Facet, EditorState, countColumn, combineConfig, RangeSet, RangeSetBuilder, Prec } from '@codemirror/state';\nimport { ViewPlugin, logException, EditorView, Decoration, WidgetType, gutter, GutterMarker } from '@codemirror/view';\nimport { tags, tagHighlighter, highlightTree, styleTags } from '@lezer/highlight';\nimport { StyleModule } from 'style-mod';\n\nvar _a;\n/**\nNode prop stored in a parser's top syntax node to provide the\nfacet that stores language-specific data for that language.\n*/\nconst languageDataProp = /*@__PURE__*/new NodeProp();\n/**\nHelper function to define a facet (to be added to the top syntax\nnode(s) for a language via\n[`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be\nused to associate language data with the language. You\nprobably only need this when subclassing\n[`Language`](https://codemirror.net/6/docs/ref/#language.Language).\n*/\nfunction defineLanguageFacet(baseData) {\n return Facet.define({\n combine: baseData ? values => values.concat(baseData) : undefined\n });\n}\n/**\nSyntax node prop used to register sublanguages. Should be added to\nthe top level node type for the language.\n*/\nconst sublanguageProp = /*@__PURE__*/new NodeProp();\n/**\nA language object manages parsing and per-language\n[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is\nmanaged as a [Lezer](https://lezer.codemirror.net) tree. The class\ncan be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)\nsubclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or\nvia the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass\nfor stream parsers.\n*/\nclass Language {\n /**\n Construct a language object. If you need to invoke this\n directly, first define a data facet with\n [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then\n configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it\n to the language's outer syntax node.\n */\n constructor(\n /**\n The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet\n used for this language.\n */\n data, parser, extraExtensions = [], \n /**\n A language name.\n */\n name = \"\") {\n this.data = data;\n this.name = name;\n // Kludge to define EditorState.tree as a debugging helper,\n // without the EditorState package actually knowing about\n // languages and lezer trees.\n if (!EditorState.prototype.hasOwnProperty(\"tree\"))\n Object.defineProperty(EditorState.prototype, \"tree\", { get() { return syntaxTree(this); } });\n this.parser = parser;\n this.extension = [\n language.of(this),\n EditorState.languageData.of((state, pos, side) => {\n let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);\n if (!data)\n return [];\n let base = state.facet(data), sub = top.type.prop(sublanguageProp);\n if (sub) {\n let innerNode = top.resolve(pos - top.from, side);\n for (let sublang of sub)\n if (sublang.test(innerNode, state)) {\n let data = state.facet(sublang.facet);\n return sublang.type == \"replace\" ? data : data.concat(base);\n }\n }\n return base;\n })\n ].concat(extraExtensions);\n }\n /**\n Query whether this language is active at the given position.\n */\n isActiveAt(state, pos, side = -1) {\n return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;\n }\n /**\n Find the document regions that were parsed using this language.\n The returned regions will _include_ any nested languages rooted\n in this language, when those exist.\n */\n findRegions(state) {\n let lang = state.facet(language);\n if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)\n return [{ from: 0, to: state.doc.length }];\n if (!lang || !lang.allowsNesting)\n return [];\n let result = [];\n let explore = (tree, from) => {\n if (tree.prop(languageDataProp) == this.data) {\n result.push({ from, to: from + tree.length });\n return;\n }\n let mount = tree.prop(NodeProp.mounted);\n if (mount) {\n if (mount.tree.prop(languageDataProp) == this.data) {\n if (mount.overlay)\n for (let r of mount.overlay)\n result.push({ from: r.from + from, to: r.to + from });\n else\n result.push({ from: from, to: from + tree.length });\n return;\n }\n else if (mount.overlay) {\n let size = result.length;\n explore(mount.tree, mount.overlay[0].from + from);\n if (result.length > size)\n return;\n }\n }\n for (let i = 0; i < tree.children.length; i++) {\n let ch = tree.children[i];\n if (ch instanceof Tree)\n explore(ch, tree.positions[i] + from);\n }\n };\n explore(syntaxTree(state), 0);\n return result;\n }\n /**\n Indicates whether this language allows nested languages. The\n default implementation returns true.\n */\n get allowsNesting() { return true; }\n}\n/**\n@internal\n*/\nLanguage.setState = /*@__PURE__*/StateEffect.define();\nfunction topNodeAt(state, pos, side) {\n let topLang = state.facet(language), tree = syntaxTree(state).topNode;\n if (!topLang || topLang.allowsNesting) {\n for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers))\n if (node.type.isTop)\n tree = node;\n }\n return tree;\n}\n/**\nA subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer\n[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)\nparsers.\n*/\nclass LRLanguage extends Language {\n constructor(data, parser, name) {\n super(data, parser, [], name);\n this.parser = parser;\n }\n /**\n Define a language from a parser.\n */\n static define(spec) {\n let data = defineLanguageFacet(spec.languageData);\n return new LRLanguage(data, spec.parser.configure({\n props: [languageDataProp.add(type => type.isTop ? data : undefined)]\n }), spec.name);\n }\n /**\n Create a new instance of this language with a reconfigured\n version of its parser and optionally a new name.\n */\n configure(options, name) {\n return new LRLanguage(this.data, this.parser.configure(options), name || this.name);\n }\n get allowsNesting() { return this.parser.hasWrappers(); }\n}\n/**\nGet the syntax tree for a state, which is the current (possibly\nincomplete) parse tree of the active\n[language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no\nlanguage available.\n*/\nfunction syntaxTree(state) {\n let field = state.field(Language.state, false);\n return field ? field.tree : Tree.empty;\n}\n/**\nTry to get a parse tree that spans at least up to `upto`. The\nmethod will do at most `timeout` milliseconds of work to parse\nup to that point if the tree isn't already available.\n*/\nfunction ensureSyntaxTree(state, upto, timeout = 50) {\n var _a;\n let parse = (_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context;\n if (!parse)\n return null;\n let oldVieport = parse.viewport;\n parse.updateViewport({ from: 0, to: upto });\n let result = parse.isDone(upto) || parse.work(timeout, upto) ? parse.tree : null;\n parse.updateViewport(oldVieport);\n return result;\n}\n/**\nQueries whether there is a full syntax tree available up to the\ngiven document position. If there isn't, the background parse\nprocess _might_ still be working and update the tree further, but\nthere is no guarantee of that—the parser will [stop\nworking](https://codemirror.net/6/docs/ref/#language.syntaxParserRunning) when it has spent a\ncertain amount of time or has moved beyond the visible viewport.\nAlways returns false if no language has been enabled.\n*/\nfunction syntaxTreeAvailable(state, upto = state.doc.length) {\n var _a;\n return ((_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context.isDone(upto)) || false;\n}\n/**\nMove parsing forward, and update the editor state afterwards to\nreflect the new tree. Will work for at most `timeout`\nmilliseconds. Returns true if the parser managed get to the given\nposition in that time.\n*/\nfunction forceParsing(view, upto = view.viewport.to, timeout = 100) {\n let success = ensureSyntaxTree(view.state, upto, timeout);\n if (success != syntaxTree(view.state))\n view.dispatch({});\n return !!success;\n}\n/**\nTells you whether the language parser is planning to do more\nparsing work (in a `requestIdleCallback` pseudo-thread) or has\nstopped running, either because it parsed the entire document,\nbecause it spent too much time and was cut off, or because there\nis no language parser enabled.\n*/\nfunction syntaxParserRunning(view) {\n var _a;\n return ((_a = view.plugin(parseWorker)) === null || _a === void 0 ? void 0 : _a.isWorking()) || false;\n}\n/**\nLezer-style\n[`Input`](https://lezer.codemirror.net/docs/ref#common.Input)\nobject for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.\n*/\nclass DocInput {\n /**\n Create an input object for the given document.\n */\n constructor(doc) {\n this.doc = doc;\n this.cursorPos = 0;\n this.string = \"\";\n this.cursor = doc.iter();\n }\n get length() { return this.doc.length; }\n syncTo(pos) {\n this.string = this.cursor.next(pos - this.cursorPos).value;\n this.cursorPos = pos + this.string.length;\n return this.cursorPos - this.string.length;\n }\n chunk(pos) {\n this.syncTo(pos);\n return this.string;\n }\n get lineChunks() { return true; }\n read(from, to) {\n let stringStart = this.cursorPos - this.string.length;\n if (from < stringStart || to >= this.cursorPos)\n return this.doc.sliceString(from, to);\n else\n return this.string.slice(from - stringStart, to - stringStart);\n }\n}\nlet currentContext = null;\n/**\nA parse context provided to parsers working on the editor content.\n*/\nclass ParseContext {\n constructor(parser, \n /**\n The current editor state.\n */\n state, \n /**\n Tree fragments that can be reused by incremental re-parses.\n */\n fragments = [], \n /**\n @internal\n */\n tree, \n /**\n @internal\n */\n treeLen, \n /**\n The current editor viewport (or some overapproximation\n thereof). Intended to be used for opportunistically avoiding\n work (in which case\n [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)\n should be called to make sure the parser is restarted when the\n skipped region becomes visible).\n */\n viewport, \n /**\n @internal\n */\n skipped, \n /**\n This is where skipping parsers can register a promise that,\n when resolved, will schedule a new parse. It is cleared when\n the parse worker picks up the promise. @internal\n */\n scheduleOn) {\n this.parser = parser;\n this.state = state;\n this.fragments = fragments;\n this.tree = tree;\n this.treeLen = treeLen;\n this.viewport = viewport;\n this.skipped = skipped;\n this.scheduleOn = scheduleOn;\n this.parse = null;\n /**\n @internal\n */\n this.tempSkipped = [];\n }\n /**\n @internal\n */\n static create(parser, state, viewport) {\n return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);\n }\n startParse() {\n return this.parser.startParse(new DocInput(this.state.doc), this.fragments);\n }\n /**\n @internal\n */\n work(until, upto) {\n if (upto != null && upto >= this.state.doc.length)\n upto = undefined;\n if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {\n this.takeTree();\n return true;\n }\n return this.withContext(() => {\n var _a;\n if (typeof until == \"number\") {\n let endTime = Date.now() + until;\n until = () => Date.now() > endTime;\n }\n if (!this.parse)\n this.parse = this.startParse();\n if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&\n upto < this.state.doc.length)\n this.parse.stopAt(upto);\n for (;;) {\n let done = this.parse.advance();\n if (done) {\n this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));\n this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;\n this.tree = done;\n this.parse = null;\n if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))\n this.parse = this.startParse();\n else\n return true;\n }\n if (until())\n return false;\n }\n });\n }\n /**\n @internal\n */\n takeTree() {\n let pos, tree;\n if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {\n if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)\n this.parse.stopAt(pos);\n this.withContext(() => { while (!(tree = this.parse.advance())) { } });\n this.treeLen = pos;\n this.tree = tree;\n this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));\n this.parse = null;\n }\n }\n withContext(f) {\n let prev = currentContext;\n currentContext = this;\n try {\n return f();\n }\n finally {\n currentContext = prev;\n }\n }\n withoutTempSkipped(fragments) {\n for (let r; r = this.tempSkipped.pop();)\n fragments = cutFragments(fragments, r.from, r.to);\n return fragments;\n }\n /**\n @internal\n */\n changes(changes, newState) {\n let { fragments, tree, treeLen, viewport, skipped } = this;\n this.takeTree();\n if (!changes.empty) {\n let ranges = [];\n changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));\n fragments = TreeFragment.applyChanges(fragments, ranges);\n tree = Tree.empty;\n treeLen = 0;\n viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };\n if (this.skipped.length) {\n skipped = [];\n for (let r of this.skipped) {\n let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);\n if (from < to)\n skipped.push({ from, to });\n }\n }\n }\n return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);\n }\n /**\n @internal\n */\n updateViewport(viewport) {\n if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)\n return false;\n this.viewport = viewport;\n let startLen = this.skipped.length;\n for (let i = 0; i < this.skipped.length; i++) {\n let { from, to } = this.skipped[i];\n if (from < viewport.to && to > viewport.from) {\n this.fragments = cutFragments(this.fragments, from, to);\n this.skipped.splice(i--, 1);\n }\n }\n if (this.skipped.length >= startLen)\n return false;\n this.reset();\n return true;\n }\n /**\n @internal\n */\n reset() {\n if (this.parse) {\n this.takeTree();\n this.parse = null;\n }\n }\n /**\n Notify the parse scheduler that the given region was skipped\n because it wasn't in view, and the parse should be restarted\n when it comes into view.\n */\n skipUntilInView(from, to) {\n this.skipped.push({ from, to });\n }\n /**\n Returns a parser intended to be used as placeholder when\n asynchronously loading a nested parser. It'll skip its input and\n mark it as not-really-parsed, so that the next update will parse\n it again.\n \n When `until` is given, a reparse will be scheduled when that\n promise resolves.\n */\n static getSkippingParser(until) {\n return new class extends Parser {\n createParse(input, fragments, ranges) {\n let from = ranges[0].from, to = ranges[ranges.length - 1].to;\n let parser = {\n parsedPos: from,\n advance() {\n let cx = currentContext;\n if (cx) {\n for (let r of ranges)\n cx.tempSkipped.push(r);\n if (until)\n cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;\n }\n this.parsedPos = to;\n return new Tree(NodeType.none, [], [], to - from);\n },\n stoppedAt: null,\n stopAt() { }\n };\n return parser;\n }\n };\n }\n /**\n @internal\n */\n isDone(upto) {\n upto = Math.min(upto, this.state.doc.length);\n let frags = this.fragments;\n return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;\n }\n /**\n Get the context for the current parse, or `null` if no editor\n parse is in progress.\n */\n static get() { return currentContext; }\n}\nfunction cutFragments(fragments, from, to) {\n return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);\n}\nclass LanguageState {\n constructor(\n // A mutable parse state that is used to preserve work done during\n // the lifetime of a state when moving to the next state.\n context) {\n this.context = context;\n this.tree = context.tree;\n }\n apply(tr) {\n if (!tr.docChanged && this.tree == this.context.tree)\n return this;\n let newCx = this.context.changes(tr.changes, tr.state);\n // If the previous parse wasn't done, go forward only up to its\n // end position or the end of the viewport, to avoid slowing down\n // state updates with parse work beyond the viewport.\n let upto = this.context.treeLen == tr.startState.doc.length ? undefined\n : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);\n if (!newCx.work(20 /* Work.Apply */, upto))\n newCx.takeTree();\n return new LanguageState(newCx);\n }\n static init(state) {\n let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);\n let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });\n if (!parseState.work(20 /* Work.Apply */, vpTo))\n parseState.takeTree();\n return new LanguageState(parseState);\n }\n}\nLanguage.state = /*@__PURE__*/StateField.define({\n create: LanguageState.init,\n update(value, tr) {\n for (let e of tr.effects)\n if (e.is(Language.setState))\n return e.value;\n if (tr.startState.facet(language) != tr.state.facet(language))\n return LanguageState.init(tr.state);\n return value.apply(tr);\n }\n});\nlet requestIdle = (callback) => {\n let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);\n return () => clearTimeout(timeout);\n};\nif (typeof requestIdleCallback != \"undefined\")\n requestIdle = (callback) => {\n let idle = -1, timeout = setTimeout(() => {\n idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });\n }, 100 /* Work.MinPause */);\n return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);\n };\nconst isInputPending = typeof navigator != \"undefined\" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)\n ? () => navigator.scheduling.isInputPending() : null;\nconst parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {\n constructor(view) {\n this.view = view;\n this.working = null;\n this.workScheduled = 0;\n // End of the current time chunk\n this.chunkEnd = -1;\n // Milliseconds of budget left for this chunk\n this.chunkBudget = -1;\n this.work = this.work.bind(this);\n this.scheduleWork();\n }\n update(update) {\n let cx = this.view.state.field(Language.state).context;\n if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)\n this.scheduleWork();\n if (update.docChanged || update.selectionSet) {\n if (this.view.hasFocus)\n this.chunkBudget += 50 /* Work.ChangeBonus */;\n this.scheduleWork();\n }\n this.checkAsyncSchedule(cx);\n }\n scheduleWork() {\n if (this.working)\n return;\n let { state } = this.view, field = state.field(Language.state);\n if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))\n this.working = requestIdle(this.work);\n }\n work(deadline) {\n this.working = null;\n let now = Date.now();\n if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk\n this.chunkEnd = now + 30000 /* Work.ChunkTime */;\n this.chunkBudget = 3000 /* Work.ChunkBudget */;\n }\n if (this.chunkBudget <= 0)\n return; // No more budget\n let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);\n if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))\n return;\n let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);\n let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;\n let done = field.context.work(() => {\n return isInputPending && isInputPending() || Date.now() > endTime;\n }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));\n this.chunkBudget -= Date.now() - now;\n if (done || this.chunkBudget <= 0) {\n field.context.takeTree();\n this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });\n }\n if (this.chunkBudget > 0 && !(done && !viewportFirst))\n this.scheduleWork();\n this.checkAsyncSchedule(field.context);\n }\n checkAsyncSchedule(cx) {\n if (cx.scheduleOn) {\n this.workScheduled++;\n cx.scheduleOn\n .then(() => this.scheduleWork())\n .catch(err => logException(this.view.state, err))\n .then(() => this.workScheduled--);\n cx.scheduleOn = null;\n }\n }\n destroy() {\n if (this.working)\n this.working();\n }\n isWorking() {\n return !!(this.working || this.workScheduled > 0);\n }\n}, {\n eventHandlers: { focus() { this.scheduleWork(); } }\n});\n/**\nThe facet used to associate a language with an editor state. Used\nby `Language` object's `extension` property (so you don't need to\nmanually wrap your languages in this). Can be used to access the\ncurrent language on a state.\n*/\nconst language = /*@__PURE__*/Facet.define({\n combine(languages) { return languages.length ? languages[0] : null; },\n enables: language => [\n Language.state,\n parseWorker,\n EditorView.contentAttributes.compute([language], state => {\n let lang = state.facet(language);\n return lang && lang.name ? { \"data-language\": lang.name } : {};\n })\n ]\n});\n/**\nThis class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an\noptional set of supporting extensions. Language packages are\nencouraged to export a function that optionally takes a\nconfiguration object and returns a `LanguageSupport` instance, as\nthe main way for client code to use the package.\n*/\nclass LanguageSupport {\n /**\n Create a language support object.\n */\n constructor(\n /**\n The language object.\n */\n language, \n /**\n An optional set of supporting extensions. When nesting a\n language in another language, the outer language is encouraged\n to include the supporting extensions for its inner languages\n in its own set of support extensions.\n */\n support = []) {\n this.language = language;\n this.support = support;\n this.extension = [language, support];\n }\n}\n/**\nLanguage descriptions are used to store metadata about languages\nand to dynamically load them. Their main role is finding the\nappropriate language for a filename or dynamically loading nested\nparsers.\n*/\nclass LanguageDescription {\n constructor(\n /**\n The name of this language.\n */\n name, \n /**\n Alternative names for the mode (lowercased, includes `this.name`).\n */\n alias, \n /**\n File extensions associated with this language.\n */\n extensions, \n /**\n Optional filename pattern that should be associated with this\n language.\n */\n filename, loadFunc, \n /**\n If the language has been loaded, this will hold its value.\n */\n support = undefined) {\n this.name = name;\n this.alias = alias;\n this.extensions = extensions;\n this.filename = filename;\n this.loadFunc = loadFunc;\n this.support = support;\n this.loading = null;\n }\n /**\n Start loading the the language. Will return a promise that\n resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)\n object when the language successfully loads.\n */\n load() {\n return this.loading || (this.loading = this.loadFunc().then(support => this.support = support, err => { this.loading = null; throw err; }));\n }\n /**\n Create a language description.\n */\n static of(spec) {\n let { load, support } = spec;\n if (!load) {\n if (!support)\n throw new RangeError(\"Must pass either 'load' or 'support' to LanguageDescription.of\");\n load = () => Promise.resolve(support);\n }\n return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, load, support);\n }\n /**\n Look for a language in the given array of descriptions that\n matches the filename. Will first match\n [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,\n and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),\n and return the first language that matches.\n */\n static matchFilename(descs, filename) {\n for (let d of descs)\n if (d.filename && d.filename.test(filename))\n return d;\n let ext = /\\.([^.]+)$/.exec(filename);\n if (ext)\n for (let d of descs)\n if (d.extensions.indexOf(ext[1]) > -1)\n return d;\n return null;\n }\n /**\n Look for a language whose name or alias matches the the given\n name (case-insensitively). If `fuzzy` is true, and no direct\n matchs is found, this'll also search for a language whose name\n or alias occurs in the string (for names shorter than three\n characters, only when surrounded by non-word characters).\n */\n static matchLanguageName(descs, name, fuzzy = true) {\n name = name.toLowerCase();\n for (let d of descs)\n if (d.alias.some(a => a == name))\n return d;\n if (fuzzy)\n for (let d of descs)\n for (let a of d.alias) {\n let found = name.indexOf(a);\n if (found > -1 && (a.length > 2 || !/\\w/.test(name[found - 1]) && !/\\w/.test(name[found + a.length])))\n return d;\n }\n return null;\n }\n}\n\n/**\nFacet that defines a way to provide a function that computes the\nappropriate indentation depth, as a column number (see\n[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given\nline. A return value of `null` indicates no indentation can be\ndetermined, and the line should inherit the indentation of the one\nabove it. A return value of `undefined` defers to the next indent\nservice.\n*/\nconst indentService = /*@__PURE__*/Facet.define();\n/**\nFacet for overriding the unit by which indentation happens. Should\nbe a string consisting either entirely of the same whitespace\ncharacter. When not set, this defaults to 2 spaces.\n*/\nconst indentUnit = /*@__PURE__*/Facet.define({\n combine: values => {\n if (!values.length)\n return \" \";\n let unit = values[0];\n if (!unit || /\\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))\n throw new Error(\"Invalid indent unit: \" + JSON.stringify(values[0]));\n return unit;\n }\n});\n/**\nReturn the _column width_ of an indent unit in the state.\nDetermined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)\nfacet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that\ncontains tabs.\n*/\nfunction getIndentUnit(state) {\n let unit = state.facet(indentUnit);\n return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;\n}\n/**\nCreate an indentation string that covers columns 0 to `cols`.\nWill use tabs for as much of the columns as possible when the\n[`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains\ntabs.\n*/\nfunction indentString(state, cols) {\n let result = \"\", ts = state.tabSize, ch = state.facet(indentUnit)[0];\n if (ch == \"\\t\") {\n while (cols >= ts) {\n result += \"\\t\";\n cols -= ts;\n }\n ch = \" \";\n }\n for (let i = 0; i < cols; i++)\n result += ch;\n return result;\n}\n/**\nGet the indentation, as a column number, at the given position.\nWill first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)\nthat are registered, and if none of those return an indentation,\nthis will check the syntax tree for the [indent node\nprop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a\nnumber when an indentation could be determined, and null\notherwise.\n*/\nfunction getIndentation(context, pos) {\n if (context instanceof EditorState)\n context = new IndentContext(context);\n for (let service of context.state.facet(indentService)) {\n let result = service(context, pos);\n if (result !== undefined)\n return result;\n }\n let tree = syntaxTree(context.state);\n return tree.length >= pos ? syntaxIndentation(context, tree, pos) : null;\n}\n/**\nCreate a change set that auto-indents all lines touched by the\ngiven document range.\n*/\nfunction indentRange(state, from, to) {\n let updated = Object.create(null);\n let context = new IndentContext(state, { overrideIndentation: start => { var _a; return (_a = updated[start]) !== null && _a !== void 0 ? _a : -1; } });\n let changes = [];\n for (let pos = from; pos <= to;) {\n let line = state.doc.lineAt(pos);\n pos = line.to + 1;\n let indent = getIndentation(context, line.from);\n if (indent == null)\n continue;\n if (!/\\S/.test(line.text))\n indent = 0;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm) {\n updated[line.from] = indent;\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n }\n return state.changes(changes);\n}\n/**\nIndentation contexts are used when calling [indentation\nservices](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities\nuseful in indentation logic, and can selectively override the\nindentation reported for some lines.\n*/\nclass IndentContext {\n /**\n Create an indent context.\n */\n constructor(\n /**\n The editor state.\n */\n state, \n /**\n @internal\n */\n options = {}) {\n this.state = state;\n this.options = options;\n this.unit = getIndentUnit(state);\n }\n /**\n Get a description of the line at the given position, taking\n [simulated line\n breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)\n into account. If there is such a break at `pos`, the `bias`\n argument determines whether the part of the line line before or\n after the break is used.\n */\n lineAt(pos, bias = 1) {\n let line = this.state.doc.lineAt(pos);\n let { simulateBreak, simulateDoubleBreak } = this.options;\n if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {\n if (simulateDoubleBreak && simulateBreak == pos)\n return { text: \"\", from: pos };\n else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)\n return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };\n else\n return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };\n }\n return line;\n }\n /**\n Get the text directly after `pos`, either the entire line\n or the next 100 characters, whichever is shorter.\n */\n textAfterPos(pos, bias = 1) {\n if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)\n return \"\";\n let { text, from } = this.lineAt(pos, bias);\n return text.slice(pos - from, Math.min(text.length, pos + 100 - from));\n }\n /**\n Find the column for the given position.\n */\n column(pos, bias = 1) {\n let { text, from } = this.lineAt(pos, bias);\n let result = this.countColumn(text, pos - from);\n let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;\n if (override > -1)\n result += override - this.countColumn(text, text.search(/\\S|$/));\n return result;\n }\n /**\n Find the column position (taking tabs into account) of the given\n position in the given string.\n */\n countColumn(line, pos = line.length) {\n return countColumn(line, this.state.tabSize, pos);\n }\n /**\n Find the indentation column of the line at the given point.\n */\n lineIndent(pos, bias = 1) {\n let { text, from } = this.lineAt(pos, bias);\n let override = this.options.overrideIndentation;\n if (override) {\n let overriden = override(from);\n if (overriden > -1)\n return overriden;\n }\n return this.countColumn(text, text.search(/\\S|$/));\n }\n /**\n Returns the [simulated line\n break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)\n for this context, if any.\n */\n get simulatedBreak() {\n return this.options.simulateBreak || null;\n }\n}\n/**\nA syntax tree node prop used to associate indentation strategies\nwith node types. Such a strategy is a function from an indentation\ncontext to a column number (see also\n[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null\nindicates that no definitive indentation can be determined.\n*/\nconst indentNodeProp = /*@__PURE__*/new NodeProp();\n// Compute the indentation for a given position from the syntax tree.\nfunction syntaxIndentation(cx, ast, pos) {\n let stack = ast.resolveStack(pos);\n let inner = stack.node.enterUnfinishedNodesBefore(pos);\n if (inner != stack.node) {\n let add = [];\n for (let cur = inner; cur != stack.node; cur = cur.parent)\n add.push(cur);\n for (let i = add.length - 1; i >= 0; i--)\n stack = { node: add[i], next: stack };\n }\n return indentFor(stack, cx, pos);\n}\nfunction indentFor(stack, cx, pos) {\n for (let cur = stack; cur; cur = cur.next) {\n let strategy = indentStrategy(cur.node);\n if (strategy)\n return strategy(TreeIndentContext.create(cx, pos, cur));\n }\n return 0;\n}\nfunction ignoreClosed(cx) {\n return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;\n}\nfunction indentStrategy(tree) {\n let strategy = tree.type.prop(indentNodeProp);\n if (strategy)\n return strategy;\n let first = tree.firstChild, close;\n if (first && (close = first.type.prop(NodeProp.closedBy))) {\n let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;\n return cx => delimitedStrategy(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);\n }\n return tree.parent == null ? topIndent : null;\n}\nfunction topIndent() { return 0; }\n/**\nObjects of this type provide context information and helper\nmethods to indentation functions registered on syntax nodes.\n*/\nclass TreeIndentContext extends IndentContext {\n constructor(base, \n /**\n The position at which indentation is being computed.\n */\n pos, \n /**\n @internal\n */\n context) {\n super(base.state, base.options);\n this.base = base;\n this.pos = pos;\n this.context = context;\n }\n /**\n The syntax tree node to which the indentation strategy\n applies.\n */\n get node() { return this.context.node; }\n /**\n @internal\n */\n static create(base, pos, context) {\n return new TreeIndentContext(base, pos, context);\n }\n /**\n Get the text directly after `this.pos`, either the entire line\n or the next 100 characters, whichever is shorter.\n */\n get textAfter() {\n return this.textAfterPos(this.pos);\n }\n /**\n Get the indentation at the reference line for `this.node`, which\n is the line on which it starts, unless there is a node that is\n _not_ a parent of this node covering the start of that line. If\n so, the line at the start of that node is tried, again skipping\n on if it is covered by another such node.\n */\n get baseIndent() {\n return this.baseIndentFor(this.node);\n }\n /**\n Get the indentation for the reference line of the given node\n (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).\n */\n baseIndentFor(node) {\n let line = this.state.doc.lineAt(node.from);\n // Skip line starts that are covered by a sibling (or cousin, etc)\n for (;;) {\n let atBreak = node.resolve(line.from);\n while (atBreak.parent && atBreak.parent.from == atBreak.from)\n atBreak = atBreak.parent;\n if (isParent(atBreak, node))\n break;\n line = this.state.doc.lineAt(atBreak.from);\n }\n return this.lineIndent(line.from);\n }\n /**\n Continue looking for indentations in the node's parent nodes,\n and return the result of that.\n */\n continue() {\n return indentFor(this.context.next, this.base, this.pos);\n }\n}\nfunction isParent(parent, of) {\n for (let cur = of; cur; cur = cur.parent)\n if (parent == cur)\n return true;\n return false;\n}\n// Check whether a delimited node is aligned (meaning there are\n// non-skipped nodes on the same line as the opening delimiter). And\n// if so, return the opening token.\nfunction bracketedAligned(context) {\n let tree = context.node;\n let openToken = tree.childAfter(tree.from), last = tree.lastChild;\n if (!openToken)\n return null;\n let sim = context.options.simulateBreak;\n let openLine = context.state.doc.lineAt(openToken.from);\n let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);\n for (let pos = openToken.to;;) {\n let next = tree.childAfter(pos);\n if (!next || next == last)\n return null;\n if (!next.type.isSkipped)\n return next.from < lineEnd ? openToken : null;\n pos = next.to;\n }\n}\n/**\nAn indentation strategy for delimited (usually bracketed) nodes.\nWill, by default, indent one unit more than the parent's base\nindent unless the line starts with a closing token. When `align`\nis true and there are non-skipped nodes on the node's opening\nline, the content of the node will be aligned with the end of the\nopening node, like this:\n\n foo(bar,\n baz)\n*/\nfunction delimitedIndent({ closing, align = true, units = 1 }) {\n return (context) => delimitedStrategy(context, align, units, closing);\n}\nfunction delimitedStrategy(context, align, units, closing, closedAt) {\n let after = context.textAfter, space = after.match(/^\\s*/)[0].length;\n let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;\n let aligned = align ? bracketedAligned(context) : null;\n if (aligned)\n return closed ? context.column(aligned.from) : context.column(aligned.to);\n return context.baseIndent + (closed ? 0 : context.unit * units);\n}\n/**\nAn indentation strategy that aligns a node's content to its base\nindentation.\n*/\nconst flatIndent = (context) => context.baseIndent;\n/**\nCreates an indentation strategy that, by default, indents\ncontinued lines one unit more than the node's base indentation.\nYou can provide `except` to prevent indentation of lines that\nmatch a pattern (for example `/^else\\b/` in `if`/`else`\nconstructs), and you can change the amount of units used with the\n`units` option.\n*/\nfunction continuedIndent({ except, units = 1 } = {}) {\n return (context) => {\n let matchExcept = except && except.test(context.textAfter);\n return context.baseIndent + (matchExcept ? 0 : units * context.unit);\n };\n}\nconst DontIndentBeyond = 200;\n/**\nEnables reindentation on input. When a language defines an\n`indentOnInput` field in its [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular\nexpression, the line at the cursor will be reindented whenever new\ntext is typed and the input from the start of the line up to the\ncursor matches that regexp.\n\nTo avoid unneccesary reindents, it is recommended to start the\nregexp with `^` (usually followed by `\\s*`), and end it with `$`.\nFor example, `/^\\s*\\}$/` will reindent when a closing brace is\nadded at the start of a line.\n*/\nfunction indentOnInput() {\n return EditorState.transactionFilter.of(tr => {\n if (!tr.docChanged || !tr.isUserEvent(\"input.type\") && !tr.isUserEvent(\"input.complete\"))\n return tr;\n let rules = tr.startState.languageDataAt(\"indentOnInput\", tr.startState.selection.main.head);\n if (!rules.length)\n return tr;\n let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);\n if (head > line.from + DontIndentBeyond)\n return tr;\n let lineStart = doc.sliceString(line.from, head);\n if (!rules.some(r => r.test(lineStart)))\n return tr;\n let { state } = tr, last = -1, changes = [];\n for (let { head } of state.selection.ranges) {\n let line = state.doc.lineAt(head);\n if (line.from == last)\n continue;\n last = line.from;\n let indent = getIndentation(state, line.from);\n if (indent == null)\n continue;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm)\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n return changes.length ? [tr, { changes, sequential: true }] : tr;\n });\n}\n\n/**\nA facet that registers a code folding service. When called with\nthe extent of a line, such a function should return a foldable\nrange that starts on that line (but continues beyond it), if one\ncan be found.\n*/\nconst foldService = /*@__PURE__*/Facet.define();\n/**\nThis node prop is used to associate folding information with\nsyntax node types. Given a syntax node, it should check whether\nthat tree is foldable and return the range that can be collapsed\nwhen it is.\n*/\nconst foldNodeProp = /*@__PURE__*/new NodeProp();\n/**\n[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but\nthe first and the last child of a syntax node. Useful for nodes\nthat start and end with delimiters.\n*/\nfunction foldInside(node) {\n let first = node.firstChild, last = node.lastChild;\n return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;\n}\nfunction syntaxFolding(state, start, end) {\n let tree = syntaxTree(state);\n if (tree.length < end)\n return null;\n let stack = tree.resolveStack(end, 1);\n let found = null;\n for (let iter = stack; iter; iter = iter.next) {\n let cur = iter.node;\n if (cur.to <= end || cur.from > end)\n continue;\n if (found && cur.from < start)\n break;\n let prop = cur.type.prop(foldNodeProp);\n if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {\n let value = prop(cur, state);\n if (value && value.from <= end && value.from >= start && value.to > end)\n found = value;\n }\n }\n return found;\n}\nfunction isUnfinished(node) {\n let ch = node.lastChild;\n return ch && ch.to == node.to && ch.type.isError;\n}\n/**\nCheck whether the given line is foldable. First asks any fold\nservices registered through\n[`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return\na result, tries to query the [fold node\nprop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end\nof the line.\n*/\nfunction foldable(state, lineStart, lineEnd) {\n for (let service of state.facet(foldService)) {\n let result = service(state, lineStart, lineEnd);\n if (result)\n return result;\n }\n return syntaxFolding(state, lineStart, lineEnd);\n}\nfunction mapRange(range, mapping) {\n let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);\n return from >= to ? undefined : { from, to };\n}\n/**\nState effect that can be attached to a transaction to fold the\ngiven range. (You probably only need this in exceptional\ncircumstances—usually you'll just want to let\n[`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold\ngutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)\n*/\nconst foldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });\n/**\nState effect that unfolds the given range (if it was folded).\n*/\nconst unfoldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });\nfunction selectedLines(view) {\n let lines = [];\n for (let { head } of view.state.selection.ranges) {\n if (lines.some(l => l.from <= head && l.to >= head))\n continue;\n lines.push(view.lineBlockAt(head));\n }\n return lines;\n}\n/**\nThe state field that stores the folded ranges (as a [decoration\nset](https://codemirror.net/6/docs/ref/#view.DecorationSet)). Can be passed to\n[`EditorState.toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) and\n[`fromJSON`](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) to serialize the fold\nstate.\n*/\nconst foldState = /*@__PURE__*/StateField.define({\n create() {\n return Decoration.none;\n },\n update(folded, tr) {\n folded = folded.map(tr.changes);\n for (let e of tr.effects) {\n if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {\n let { preparePlaceholder } = tr.state.facet(foldConfig);\n let widget = !preparePlaceholder ? foldWidget :\n Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });\n folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });\n }\n else if (e.is(unfoldEffect)) {\n folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,\n filterFrom: e.value.from, filterTo: e.value.to });\n }\n }\n // Clear folded ranges that cover the selection head\n if (tr.selection) {\n let onSelection = false, { head } = tr.selection.main;\n folded.between(head, head, (a, b) => { if (a < head && b > head)\n onSelection = true; });\n if (onSelection)\n folded = folded.update({\n filterFrom: head,\n filterTo: head,\n filter: (a, b) => b <= head || a >= head\n });\n }\n return folded;\n },\n provide: f => EditorView.decorations.from(f),\n toJSON(folded, state) {\n let ranges = [];\n folded.between(0, state.doc.length, (from, to) => { ranges.push(from, to); });\n return ranges;\n },\n fromJSON(value) {\n if (!Array.isArray(value) || value.length % 2)\n throw new RangeError(\"Invalid JSON for fold state\");\n let ranges = [];\n for (let i = 0; i < value.length;) {\n let from = value[i++], to = value[i++];\n if (typeof from != \"number\" || typeof to != \"number\")\n throw new RangeError(\"Invalid JSON for fold state\");\n ranges.push(foldWidget.range(from, to));\n }\n return Decoration.set(ranges, true);\n }\n});\n/**\nGet a [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) containing the folded ranges\nin the given state.\n*/\nfunction foldedRanges(state) {\n return state.field(foldState, false) || RangeSet.empty;\n}\nfunction findFold(state, from, to) {\n var _a;\n let found = null;\n (_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {\n if (!found || found.from > from)\n found = { from, to };\n });\n return found;\n}\nfunction foldExists(folded, from, to) {\n let found = false;\n folded.between(from, from, (a, b) => { if (a == from && b == to)\n found = true; });\n return found;\n}\nfunction maybeEnable(state, other) {\n return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));\n}\n/**\nFold the lines that are selected, if possible.\n*/\nconst foldCode = view => {\n for (let line of selectedLines(view)) {\n let range = foldable(view.state, line.from, line.to);\n if (range) {\n view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });\n return true;\n }\n }\n return false;\n};\n/**\nUnfold folded ranges on selected lines.\n*/\nconst unfoldCode = view => {\n if (!view.state.field(foldState, false))\n return false;\n let effects = [];\n for (let line of selectedLines(view)) {\n let folded = findFold(view.state, line.from, line.to);\n if (folded)\n effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));\n }\n if (effects.length)\n view.dispatch({ effects });\n return effects.length > 0;\n};\nfunction announceFold(view, range, fold = true) {\n let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;\n return EditorView.announce.of(`${view.state.phrase(fold ? \"Folded lines\" : \"Unfolded lines\")} ${lineFrom} ${view.state.phrase(\"to\")} ${lineTo}.`);\n}\n/**\nFold all top-level foldable ranges. Note that, in most cases,\nfolding information will depend on the [syntax\ntree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work\nreliably when the document hasn't been fully parsed (either\nbecause the editor state was only just initialized, or because the\ndocument is so big that the parser decided not to parse it\nentirely).\n*/\nconst foldAll = view => {\n let { state } = view, effects = [];\n for (let pos = 0; pos < state.doc.length;) {\n let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);\n if (range)\n effects.push(foldEffect.of(range));\n pos = (range ? view.lineBlockAt(range.to) : line).to + 1;\n }\n if (effects.length)\n view.dispatch({ effects: maybeEnable(view.state, effects) });\n return !!effects.length;\n};\n/**\nUnfold all folded code.\n*/\nconst unfoldAll = view => {\n let field = view.state.field(foldState, false);\n if (!field || !field.size)\n return false;\n let effects = [];\n field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });\n view.dispatch({ effects });\n return true;\n};\n// Find the foldable region containing the given line, if one exists\nfunction foldableContainer(view, lineBlock) {\n // Look backwards through line blocks until we find a foldable region that\n // intersects with the line\n for (let line = lineBlock;;) {\n let foldableRegion = foldable(view.state, line.from, line.to);\n if (foldableRegion && foldableRegion.to > lineBlock.from)\n return foldableRegion;\n if (!line.from)\n return null;\n line = view.lineBlockAt(line.from - 1);\n }\n}\n/**\nToggle folding at cursors. Unfolds if there is an existing fold\nstarting in that line, tries to find a foldable range around it\notherwise.\n*/\nconst toggleFold = (view) => {\n let effects = [];\n for (let line of selectedLines(view)) {\n let folded = findFold(view.state, line.from, line.to);\n if (folded) {\n effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));\n }\n else {\n let foldRange = foldableContainer(view, line);\n if (foldRange)\n effects.push(foldEffect.of(foldRange), announceFold(view, foldRange));\n }\n }\n if (effects.length > 0)\n view.dispatch({ effects: maybeEnable(view.state, effects) });\n return !!effects.length;\n};\n/**\nDefault fold-related key bindings.\n\n - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).\n - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).\n - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).\n - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).\n*/\nconst foldKeymap = [\n { key: \"Ctrl-Shift-[\", mac: \"Cmd-Alt-[\", run: foldCode },\n { key: \"Ctrl-Shift-]\", mac: \"Cmd-Alt-]\", run: unfoldCode },\n { key: \"Ctrl-Alt-[\", run: foldAll },\n { key: \"Ctrl-Alt-]\", run: unfoldAll }\n];\nconst defaultConfig = {\n placeholderDOM: null,\n preparePlaceholder: null,\n placeholderText: \"…\"\n};\nconst foldConfig = /*@__PURE__*/Facet.define({\n combine(values) { return combineConfig(values, defaultConfig); }\n});\n/**\nCreate an extension that configures code folding.\n*/\nfunction codeFolding(config) {\n let result = [foldState, baseTheme$1];\n if (config)\n result.push(foldConfig.of(config));\n return result;\n}\nfunction widgetToDOM(view, prepared) {\n let { state } = view, conf = state.facet(foldConfig);\n let onclick = (event) => {\n let line = view.lineBlockAt(view.posAtDOM(event.target));\n let folded = findFold(view.state, line.from, line.to);\n if (folded)\n view.dispatch({ effects: unfoldEffect.of(folded) });\n event.preventDefault();\n };\n if (conf.placeholderDOM)\n return conf.placeholderDOM(view, onclick, prepared);\n let element = document.createElement(\"span\");\n element.textContent = conf.placeholderText;\n element.setAttribute(\"aria-label\", state.phrase(\"folded code\"));\n element.title = state.phrase(\"unfold\");\n element.className = \"cm-foldPlaceholder\";\n element.onclick = onclick;\n return element;\n}\nconst foldWidget = /*@__PURE__*/Decoration.replace({ widget: /*@__PURE__*/new class extends WidgetType {\n toDOM(view) { return widgetToDOM(view, null); }\n } });\nclass PreparedFoldWidget extends WidgetType {\n constructor(value) {\n super();\n this.value = value;\n }\n eq(other) { return this.value == other.value; }\n toDOM(view) { return widgetToDOM(view, this.value); }\n}\nconst foldGutterDefaults = {\n openText: \"⌄\",\n closedText: \"›\",\n markerDOM: null,\n domEventHandlers: {},\n foldingChanged: () => false\n};\nclass FoldMarker extends GutterMarker {\n constructor(config, open) {\n super();\n this.config = config;\n this.open = open;\n }\n eq(other) { return this.config == other.config && this.open == other.open; }\n toDOM(view) {\n if (this.config.markerDOM)\n return this.config.markerDOM(this.open);\n let span = document.createElement(\"span\");\n span.textContent = this.open ? this.config.openText : this.config.closedText;\n span.title = view.state.phrase(this.open ? \"Fold line\" : \"Unfold line\");\n return span;\n }\n}\n/**\nCreate an extension that registers a fold gutter, which shows a\nfold status indicator before foldable lines (which can be clicked\nto fold or unfold the line).\n*/\nfunction foldGutter(config = {}) {\n let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);\n let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);\n let markers = ViewPlugin.fromClass(class {\n constructor(view) {\n this.from = view.viewport.from;\n this.markers = this.buildMarkers(view);\n }\n update(update) {\n if (update.docChanged || update.viewportChanged ||\n update.startState.facet(language) != update.state.facet(language) ||\n update.startState.field(foldState, false) != update.state.field(foldState, false) ||\n syntaxTree(update.startState) != syntaxTree(update.state) ||\n fullConfig.foldingChanged(update))\n this.markers = this.buildMarkers(update.view);\n }\n buildMarkers(view) {\n let builder = new RangeSetBuilder();\n for (let line of view.viewportLineBlocks) {\n let mark = findFold(view.state, line.from, line.to) ? canUnfold\n : foldable(view.state, line.from, line.to) ? canFold : null;\n if (mark)\n builder.add(line.from, line.from, mark);\n }\n return builder.finish();\n }\n });\n let { domEventHandlers } = fullConfig;\n return [\n markers,\n gutter({\n class: \"cm-foldGutter\",\n markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet.empty; },\n initialSpacer() {\n return new FoldMarker(fullConfig, false);\n },\n domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {\n if (domEventHandlers.click && domEventHandlers.click(view, line, event))\n return true;\n let folded = findFold(view.state, line.from, line.to);\n if (folded) {\n view.dispatch({ effects: unfoldEffect.of(folded) });\n return true;\n }\n let range = foldable(view.state, line.from, line.to);\n if (range) {\n view.dispatch({ effects: foldEffect.of(range) });\n return true;\n }\n return false;\n } })\n }),\n codeFolding()\n ];\n}\nconst baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({\n \".cm-foldPlaceholder\": {\n backgroundColor: \"#eee\",\n border: \"1px solid #ddd\",\n color: \"#888\",\n borderRadius: \".2em\",\n margin: \"0 1px\",\n padding: \"0 1px\",\n cursor: \"pointer\"\n },\n \".cm-foldGutter span\": {\n padding: \"0 1px\",\n cursor: \"pointer\"\n }\n});\n\n/**\nA highlight style associates CSS styles with higlighting\n[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).\n*/\nclass HighlightStyle {\n constructor(\n /**\n The tag styles used to create this highlight style.\n */\n specs, options) {\n this.specs = specs;\n let modSpec;\n function def(spec) {\n let cls = StyleModule.newName();\n (modSpec || (modSpec = Object.create(null)))[\".\" + cls] = spec;\n return cls;\n }\n const all = typeof options.all == \"string\" ? options.all : options.all ? def(options.all) : undefined;\n const scopeOpt = options.scope;\n this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data\n : scopeOpt ? (type) => type == scopeOpt : undefined;\n this.style = tagHighlighter(specs.map(style => ({\n tag: style.tag,\n class: style.class || def(Object.assign({}, style, { tag: null }))\n })), {\n all,\n }).style;\n this.module = modSpec ? new StyleModule(modSpec) : null;\n this.themeType = options.themeType;\n }\n /**\n Create a highlighter style that associates the given styles to\n the given tags. The specs must be objects that hold a style tag\n or array of tags in their `tag` property, and either a single\n `class` property providing a static CSS class (for highlighter\n that rely on external styling), or a\n [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style\n set of CSS properties (which define the styling for those tags).\n \n The CSS rules created for a highlighter will be emitted in the\n order of the spec's properties. That means that for elements that\n have multiple tags associated with them, styles defined further\n down in the list will have a higher CSS precedence than styles\n defined earlier.\n */\n static define(specs, options) {\n return new HighlightStyle(specs, options || {});\n }\n}\nconst highlighterFacet = /*@__PURE__*/Facet.define();\nconst fallbackHighlighter = /*@__PURE__*/Facet.define({\n combine(values) { return values.length ? [values[0]] : null; }\n});\nfunction getHighlighters(state) {\n let main = state.facet(highlighterFacet);\n return main.length ? main : state.facet(fallbackHighlighter);\n}\n/**\nWrap a highlighter in an editor extension that uses it to apply\nsyntax highlighting to the editor content.\n\nWhen multiple (non-fallback) styles are provided, the styling\napplied is the union of the classes they emit.\n*/\nfunction syntaxHighlighting(highlighter, options) {\n let ext = [treeHighlighter], themeType;\n if (highlighter instanceof HighlightStyle) {\n if (highlighter.module)\n ext.push(EditorView.styleModule.of(highlighter.module));\n themeType = highlighter.themeType;\n }\n if (options === null || options === void 0 ? void 0 : options.fallback)\n ext.push(fallbackHighlighter.of(highlighter));\n else if (themeType)\n ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {\n return state.facet(EditorView.darkTheme) == (themeType == \"dark\") ? [highlighter] : [];\n }));\n else\n ext.push(highlighterFacet.of(highlighter));\n return ext;\n}\n/**\nReturns the CSS classes (if any) that the highlighters active in\nthe state would assign to the given style\n[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag) and\n(optional) language\n[scope](https://codemirror.net/6/docs/ref/#language.HighlightStyle^define^options.scope).\n*/\nfunction highlightingFor(state, tags, scope) {\n let highlighters = getHighlighters(state);\n let result = null;\n if (highlighters)\n for (let highlighter of highlighters) {\n if (!highlighter.scope || scope && highlighter.scope(scope)) {\n let cls = highlighter.style(tags);\n if (cls)\n result = result ? result + \" \" + cls : cls;\n }\n }\n return result;\n}\nclass TreeHighlighter {\n constructor(view) {\n this.markCache = Object.create(null);\n this.tree = syntaxTree(view.state);\n this.decorations = this.buildDeco(view, getHighlighters(view.state));\n }\n update(update) {\n let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);\n let styleChange = highlighters != getHighlighters(update.startState);\n if (tree.length < update.view.viewport.to && !styleChange && tree.type == this.tree.type) {\n this.decorations = this.decorations.map(update.changes);\n }\n else if (tree != this.tree || update.viewportChanged || styleChange) {\n this.tree = tree;\n this.decorations = this.buildDeco(update.view, highlighters);\n }\n }\n buildDeco(view, highlighters) {\n if (!highlighters || !this.tree.length)\n return Decoration.none;\n let builder = new RangeSetBuilder();\n for (let { from, to } of view.visibleRanges) {\n highlightTree(this.tree, highlighters, (from, to, style) => {\n builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));\n }, from, to);\n }\n return builder.finish();\n }\n}\nconst treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {\n decorations: v => v.decorations\n}));\n/**\nA default highlight style (works well with light themes).\n*/\nconst defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([\n { tag: tags.meta,\n color: \"#404740\" },\n { tag: tags.link,\n textDecoration: \"underline\" },\n { tag: tags.heading,\n textDecoration: \"underline\",\n fontWeight: \"bold\" },\n { tag: tags.emphasis,\n fontStyle: \"italic\" },\n { tag: tags.strong,\n fontWeight: \"bold\" },\n { tag: tags.strikethrough,\n textDecoration: \"line-through\" },\n { tag: tags.keyword,\n color: \"#708\" },\n { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],\n color: \"#219\" },\n { tag: [tags.literal, tags.inserted],\n color: \"#164\" },\n { tag: [tags.string, tags.deleted],\n color: \"#a11\" },\n { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],\n color: \"#e40\" },\n { tag: /*@__PURE__*/tags.definition(tags.variableName),\n color: \"#00f\" },\n { tag: /*@__PURE__*/tags.local(tags.variableName),\n color: \"#30a\" },\n { tag: [tags.typeName, tags.namespace],\n color: \"#085\" },\n { tag: tags.className,\n color: \"#167\" },\n { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],\n color: \"#256\" },\n { tag: /*@__PURE__*/tags.definition(tags.propertyName),\n color: \"#00c\" },\n { tag: tags.comment,\n color: \"#940\" },\n { tag: tags.invalid,\n color: \"#f00\" }\n]);\n\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \"&.cm-focused .cm-matchingBracket\": { backgroundColor: \"#328c8252\" },\n \"&.cm-focused .cm-nonmatchingBracket\": { backgroundColor: \"#bb555544\" }\n});\nconst DefaultScanDist = 10000, DefaultBrackets = \"()[]{}\";\nconst bracketMatchingConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n afterCursor: true,\n brackets: DefaultBrackets,\n maxScanDistance: DefaultScanDist,\n renderMatch: defaultRenderMatch\n });\n }\n});\nconst matchingMark = /*@__PURE__*/Decoration.mark({ class: \"cm-matchingBracket\" }), nonmatchingMark = /*@__PURE__*/Decoration.mark({ class: \"cm-nonmatchingBracket\" });\nfunction defaultRenderMatch(match) {\n let decorations = [];\n let mark = match.matched ? matchingMark : nonmatchingMark;\n decorations.push(mark.range(match.start.from, match.start.to));\n if (match.end)\n decorations.push(mark.range(match.end.from, match.end.to));\n return decorations;\n}\nconst bracketMatchingState = /*@__PURE__*/StateField.define({\n create() { return Decoration.none; },\n update(deco, tr) {\n if (!tr.docChanged && !tr.selection)\n return deco;\n let decorations = [];\n let config = tr.state.facet(bracketMatchingConfig);\n for (let range of tr.state.selection.ranges) {\n if (!range.empty)\n continue;\n let match = matchBrackets(tr.state, range.head, -1, config)\n || (range.head > 0 && matchBrackets(tr.state, range.head - 1, 1, config))\n || (config.afterCursor &&\n (matchBrackets(tr.state, range.head, 1, config) ||\n (range.head < tr.state.doc.length && matchBrackets(tr.state, range.head + 1, -1, config))));\n if (match)\n decorations = decorations.concat(config.renderMatch(match, tr.state));\n }\n return Decoration.set(decorations, true);\n },\n provide: f => EditorView.decorations.from(f)\n});\nconst bracketMatchingUnique = [\n bracketMatchingState,\n baseTheme\n];\n/**\nCreate an extension that enables bracket matching. Whenever the\ncursor is next to a bracket, that bracket and the one it matches\nare highlighted. Or, when no matching bracket is found, another\nhighlighting style is used to indicate this.\n*/\nfunction bracketMatching(config = {}) {\n return [bracketMatchingConfig.of(config), bracketMatchingUnique];\n}\n/**\nWhen larger syntax nodes, such as HTML tags, are marked as\nopening/closing, it can be a bit messy to treat the whole node as\na matchable bracket. This node prop allows you to define, for such\na node, a ‘handle’—the part of the node that is highlighted, and\nthat the cursor must be on to activate highlighting in the first\nplace.\n*/\nconst bracketMatchingHandle = /*@__PURE__*/new NodeProp();\nfunction matchingNodes(node, dir, brackets) {\n let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);\n if (byProp)\n return byProp;\n if (node.name.length == 1) {\n let index = brackets.indexOf(node.name);\n if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))\n return [brackets[index + dir]];\n }\n return null;\n}\nfunction findHandle(node) {\n let hasHandle = node.type.prop(bracketMatchingHandle);\n return hasHandle ? hasHandle(node.node) : node;\n}\n/**\nFind the matching bracket for the token at `pos`, scanning\ndirection `dir`. Only the `brackets` and `maxScanDistance`\nproperties are used from `config`, if given. Returns null if no\nbracket was found at `pos`, or a match result otherwise.\n*/\nfunction matchBrackets(state, pos, dir, config = {}) {\n let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;\n let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);\n for (let cur = node; cur; cur = cur.parent) {\n let matches = matchingNodes(cur.type, dir, brackets);\n if (matches && cur.from < cur.to) {\n let handle = findHandle(cur);\n if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))\n return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);\n }\n }\n return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);\n}\nfunction matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {\n let parent = token.parent, firstToken = { from: handle.from, to: handle.to };\n let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();\n if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))\n do {\n if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {\n if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {\n let endHandle = findHandle(cursor);\n return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : undefined, matched: true };\n }\n else if (matchingNodes(cursor.type, dir, brackets)) {\n depth++;\n }\n else if (matchingNodes(cursor.type, -dir, brackets)) {\n if (depth == 0) {\n let endHandle = findHandle(cursor);\n return {\n start: firstToken,\n end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : undefined,\n matched: false\n };\n }\n depth--;\n }\n }\n } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());\n return { start: firstToken, matched: false };\n}\nfunction matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {\n let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);\n let bracket = brackets.indexOf(startCh);\n if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))\n return null;\n let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };\n let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;\n for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {\n let text = iter.value;\n if (dir < 0)\n distance += text.length;\n let basePos = pos + distance * dir;\n for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {\n let found = brackets.indexOf(text[pos]);\n if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType)\n continue;\n if ((found % 2 == 0) == (dir > 0)) {\n depth++;\n }\n else if (depth == 1) { // Closing\n return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };\n }\n else {\n depth--;\n }\n }\n if (dir > 0)\n distance += text.length;\n }\n return iter.done ? { start: startToken, matched: false } : null;\n}\n\n// Counts the column offset in a string, taking tabs into account.\n// Used mostly to find indentation.\nfunction countCol(string, end, tabSize, startIndex = 0, startValue = 0) {\n if (end == null) {\n end = string.search(/[^\\s\\u00a0]/);\n if (end == -1)\n end = string.length;\n }\n let n = startValue;\n for (let i = startIndex; i < end; i++) {\n if (string.charCodeAt(i) == 9)\n n += tabSize - (n % tabSize);\n else\n n++;\n }\n return n;\n}\n/**\nEncapsulates a single line of input. Given to stream syntax code,\nwhich uses it to tokenize the content.\n*/\nclass StringStream {\n /**\n Create a stream.\n */\n constructor(\n /**\n The line.\n */\n string, tabSize, \n /**\n The current indent unit size.\n */\n indentUnit, overrideIndent) {\n this.string = string;\n this.tabSize = tabSize;\n this.indentUnit = indentUnit;\n this.overrideIndent = overrideIndent;\n /**\n The current position on the line.\n */\n this.pos = 0;\n /**\n The start position of the current token.\n */\n this.start = 0;\n this.lastColumnPos = 0;\n this.lastColumnValue = 0;\n }\n /**\n True if we are at the end of the line.\n */\n eol() { return this.pos >= this.string.length; }\n /**\n True if we are at the start of the line.\n */\n sol() { return this.pos == 0; }\n /**\n Get the next code unit after the current position, or undefined\n if we're at the end of the line.\n */\n peek() { return this.string.charAt(this.pos) || undefined; }\n /**\n Read the next code unit and advance `this.pos`.\n */\n next() {\n if (this.pos < this.string.length)\n return this.string.charAt(this.pos++);\n }\n /**\n Match the next character against the given string, regular\n expression, or predicate. Consume and return it if it matches.\n */\n eat(match) {\n let ch = this.string.charAt(this.pos);\n let ok;\n if (typeof match == \"string\")\n ok = ch == match;\n else\n ok = ch && (match instanceof RegExp ? match.test(ch) : match(ch));\n if (ok) {\n ++this.pos;\n return ch;\n }\n }\n /**\n Continue matching characters that match the given string,\n regular expression, or predicate function. Return true if any\n characters were consumed.\n */\n eatWhile(match) {\n let start = this.pos;\n while (this.eat(match)) { }\n return this.pos > start;\n }\n /**\n Consume whitespace ahead of `this.pos`. Return true if any was\n found.\n */\n eatSpace() {\n let start = this.pos;\n while (/[\\s\\u00a0]/.test(this.string.charAt(this.pos)))\n ++this.pos;\n return this.pos > start;\n }\n /**\n Move to the end of the line.\n */\n skipToEnd() { this.pos = this.string.length; }\n /**\n Move to directly before the given character, if found on the\n current line.\n */\n skipTo(ch) {\n let found = this.string.indexOf(ch, this.pos);\n if (found > -1) {\n this.pos = found;\n return true;\n }\n }\n /**\n Move back `n` characters.\n */\n backUp(n) { this.pos -= n; }\n /**\n Get the column position at `this.pos`.\n */\n column() {\n if (this.lastColumnPos < this.start) {\n this.lastColumnValue = countCol(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);\n this.lastColumnPos = this.start;\n }\n return this.lastColumnValue;\n }\n /**\n Get the indentation column of the current line.\n */\n indentation() {\n var _a;\n return (_a = this.overrideIndent) !== null && _a !== void 0 ? _a : countCol(this.string, null, this.tabSize);\n }\n /**\n Match the input against the given string or regular expression\n (which should start with a `^`). Return true or the regexp match\n if it matches.\n \n Unless `consume` is set to `false`, this will move `this.pos`\n past the matched text.\n \n When matching a string `caseInsensitive` can be set to true to\n make the match case-insensitive.\n */\n match(pattern, consume, caseInsensitive) {\n if (typeof pattern == \"string\") {\n let cased = (str) => caseInsensitive ? str.toLowerCase() : str;\n let substr = this.string.substr(this.pos, pattern.length);\n if (cased(substr) == cased(pattern)) {\n if (consume !== false)\n this.pos += pattern.length;\n return true;\n }\n else\n return null;\n }\n else {\n let match = this.string.slice(this.pos).match(pattern);\n if (match && match.index > 0)\n return null;\n if (match && consume !== false)\n this.pos += match[0].length;\n return match;\n }\n }\n /**\n Get the current token.\n */\n current() { return this.string.slice(this.start, this.pos); }\n}\n\nfunction fullParser(spec) {\n return {\n name: spec.name || \"\",\n token: spec.token,\n blankLine: spec.blankLine || (() => { }),\n startState: spec.startState || (() => true),\n copyState: spec.copyState || defaultCopyState,\n indent: spec.indent || (() => null),\n languageData: spec.languageData || {},\n tokenTable: spec.tokenTable || noTokens\n };\n}\nfunction defaultCopyState(state) {\n if (typeof state != \"object\")\n return state;\n let newState = {};\n for (let prop in state) {\n let val = state[prop];\n newState[prop] = (val instanceof Array ? val.slice() : val);\n }\n return newState;\n}\nconst IndentedFrom = /*@__PURE__*/new WeakMap();\n/**\nA [language](https://codemirror.net/6/docs/ref/#language.Language) class based on a CodeMirror\n5-style [streaming parser](https://codemirror.net/6/docs/ref/#language.StreamParser).\n*/\nclass StreamLanguage extends Language {\n constructor(parser) {\n let data = defineLanguageFacet(parser.languageData);\n let p = fullParser(parser), self;\n let impl = new class extends Parser {\n createParse(input, fragments, ranges) {\n return new Parse(self, input, fragments, ranges);\n }\n };\n super(data, impl, [indentService.of((cx, pos) => this.getIndent(cx, pos))], parser.name);\n this.topNode = docID(data);\n self = this;\n this.streamParser = p;\n this.stateAfter = new NodeProp({ perNode: true });\n this.tokenTable = parser.tokenTable ? new TokenTable(p.tokenTable) : defaultTokenTable;\n }\n /**\n Define a stream language.\n */\n static define(spec) { return new StreamLanguage(spec); }\n getIndent(cx, pos) {\n let tree = syntaxTree(cx.state), at = tree.resolve(pos);\n while (at && at.type != this.topNode)\n at = at.parent;\n if (!at)\n return null;\n let from = undefined;\n let { overrideIndentation } = cx.options;\n if (overrideIndentation) {\n from = IndentedFrom.get(cx.state);\n if (from != null && from < pos - 1e4)\n from = undefined;\n }\n let start = findState(this, tree, 0, at.from, from !== null && from !== void 0 ? from : pos), statePos, state;\n if (start) {\n state = start.state;\n statePos = start.pos + 1;\n }\n else {\n state = this.streamParser.startState(cx.unit);\n statePos = 0;\n }\n if (pos - statePos > 10000 /* C.MaxIndentScanDist */)\n return null;\n while (statePos < pos) {\n let line = cx.state.doc.lineAt(statePos), end = Math.min(pos, line.to);\n if (line.length) {\n let indentation = overrideIndentation ? overrideIndentation(line.from) : -1;\n let stream = new StringStream(line.text, cx.state.tabSize, cx.unit, indentation < 0 ? undefined : indentation);\n while (stream.pos < end - line.from)\n readToken(this.streamParser.token, stream, state);\n }\n else {\n this.streamParser.blankLine(state, cx.unit);\n }\n if (end == pos)\n break;\n statePos = line.to + 1;\n }\n let line = cx.lineAt(pos);\n if (overrideIndentation && from == null)\n IndentedFrom.set(cx.state, line.from);\n return this.streamParser.indent(state, /^\\s*(.*)/.exec(line.text)[1], cx);\n }\n get allowsNesting() { return false; }\n}\nfunction findState(lang, tree, off, startPos, before) {\n let state = off >= startPos && off + tree.length <= before && tree.prop(lang.stateAfter);\n if (state)\n return { state: lang.streamParser.copyState(state), pos: off + tree.length };\n for (let i = tree.children.length - 1; i >= 0; i--) {\n let child = tree.children[i], pos = off + tree.positions[i];\n let found = child instanceof Tree && pos < before && findState(lang, child, pos, startPos, before);\n if (found)\n return found;\n }\n return null;\n}\nfunction cutTree(lang, tree, from, to, inside) {\n if (inside && from <= 0 && to >= tree.length)\n return tree;\n if (!inside && tree.type == lang.topNode)\n inside = true;\n for (let i = tree.children.length - 1; i >= 0; i--) {\n let pos = tree.positions[i], child = tree.children[i], inner;\n if (pos < to && child instanceof Tree) {\n if (!(inner = cutTree(lang, child, from - pos, to - pos, inside)))\n break;\n return !inside ? inner\n : new Tree(tree.type, tree.children.slice(0, i).concat(inner), tree.positions.slice(0, i + 1), pos + inner.length);\n }\n }\n return null;\n}\nfunction findStartInFragments(lang, fragments, startPos, editorState) {\n for (let f of fragments) {\n let from = f.from + (f.openStart ? 25 : 0), to = f.to - (f.openEnd ? 25 : 0);\n let found = from <= startPos && to > startPos && findState(lang, f.tree, 0 - f.offset, startPos, to), tree;\n if (found && (tree = cutTree(lang, f.tree, startPos + f.offset, found.pos + f.offset, false)))\n return { state: found.state, tree };\n }\n return { state: lang.streamParser.startState(editorState ? getIndentUnit(editorState) : 4), tree: Tree.empty };\n}\nclass Parse {\n constructor(lang, input, fragments, ranges) {\n this.lang = lang;\n this.input = input;\n this.fragments = fragments;\n this.ranges = ranges;\n this.stoppedAt = null;\n this.chunks = [];\n this.chunkPos = [];\n this.chunk = [];\n this.chunkReused = undefined;\n this.rangeIndex = 0;\n this.to = ranges[ranges.length - 1].to;\n let context = ParseContext.get(), from = ranges[0].from;\n let { state, tree } = findStartInFragments(lang, fragments, from, context === null || context === void 0 ? void 0 : context.state);\n this.state = state;\n this.parsedPos = this.chunkStart = from + tree.length;\n for (let i = 0; i < tree.children.length; i++) {\n this.chunks.push(tree.children[i]);\n this.chunkPos.push(tree.positions[i]);\n }\n if (context && this.parsedPos < context.viewport.from - 100000 /* C.MaxDistanceBeforeViewport */) {\n this.state = this.lang.streamParser.startState(getIndentUnit(context.state));\n context.skipUntilInView(this.parsedPos, context.viewport.from);\n this.parsedPos = context.viewport.from;\n }\n this.moveRangeIndex();\n }\n advance() {\n let context = ParseContext.get();\n let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);\n let end = Math.min(parseEnd, this.chunkStart + 2048 /* C.ChunkSize */);\n if (context)\n end = Math.min(end, context.viewport.to);\n while (this.parsedPos < end)\n this.parseLine(context);\n if (this.chunkStart < this.parsedPos)\n this.finishChunk();\n if (this.parsedPos >= parseEnd)\n return this.finish();\n if (context && this.parsedPos >= context.viewport.to) {\n context.skipUntilInView(this.parsedPos, parseEnd);\n return this.finish();\n }\n return null;\n }\n stopAt(pos) {\n this.stoppedAt = pos;\n }\n lineAfter(pos) {\n let chunk = this.input.chunk(pos);\n if (!this.input.lineChunks) {\n let eol = chunk.indexOf(\"\\n\");\n if (eol > -1)\n chunk = chunk.slice(0, eol);\n }\n else if (chunk == \"\\n\") {\n chunk = \"\";\n }\n return pos + chunk.length <= this.to ? chunk : chunk.slice(0, this.to - pos);\n }\n nextLine() {\n let from = this.parsedPos, line = this.lineAfter(from), end = from + line.length;\n for (let index = this.rangeIndex;;) {\n let rangeEnd = this.ranges[index].to;\n if (rangeEnd >= end)\n break;\n line = line.slice(0, rangeEnd - (end - line.length));\n index++;\n if (index == this.ranges.length)\n break;\n let rangeStart = this.ranges[index].from;\n let after = this.lineAfter(rangeStart);\n line += after;\n end = rangeStart + after.length;\n }\n return { line, end };\n }\n skipGapsTo(pos, offset, side) {\n for (;;) {\n let end = this.ranges[this.rangeIndex].to, offPos = pos + offset;\n if (side > 0 ? end > offPos : end >= offPos)\n break;\n let start = this.ranges[++this.rangeIndex].from;\n offset += start - end;\n }\n return offset;\n }\n moveRangeIndex() {\n while (this.ranges[this.rangeIndex].to < this.parsedPos)\n this.rangeIndex++;\n }\n emitToken(id, from, to, size, offset) {\n if (this.ranges.length > 1) {\n offset = this.skipGapsTo(from, offset, 1);\n from += offset;\n let len0 = this.chunk.length;\n offset = this.skipGapsTo(to, offset, -1);\n to += offset;\n size += this.chunk.length - len0;\n }\n this.chunk.push(id, from, to, size);\n return offset;\n }\n parseLine(context) {\n let { line, end } = this.nextLine(), offset = 0, { streamParser } = this.lang;\n let stream = new StringStream(line, context ? context.state.tabSize : 4, context ? getIndentUnit(context.state) : 2);\n if (stream.eol()) {\n streamParser.blankLine(this.state, stream.indentUnit);\n }\n else {\n while (!stream.eol()) {\n let token = readToken(streamParser.token, stream, this.state);\n if (token)\n offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, 4, offset);\n if (stream.start > 10000 /* C.MaxLineLength */)\n break;\n }\n }\n this.parsedPos = end;\n this.moveRangeIndex();\n if (this.parsedPos < this.to)\n this.parsedPos++;\n }\n finishChunk() {\n let tree = Tree.build({\n buffer: this.chunk,\n start: this.chunkStart,\n length: this.parsedPos - this.chunkStart,\n nodeSet,\n topID: 0,\n maxBufferLength: 2048 /* C.ChunkSize */,\n reused: this.chunkReused\n });\n tree = new Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);\n this.chunks.push(tree);\n this.chunkPos.push(this.chunkStart - this.ranges[0].from);\n this.chunk = [];\n this.chunkReused = undefined;\n this.chunkStart = this.parsedPos;\n }\n finish() {\n return new Tree(this.lang.topNode, this.chunks, this.chunkPos, this.parsedPos - this.ranges[0].from).balance();\n }\n}\nfunction readToken(token, stream, state) {\n stream.start = stream.pos;\n for (let i = 0; i < 10; i++) {\n let result = token(stream, state);\n if (stream.pos > stream.start)\n return result;\n }\n throw new Error(\"Stream parser failed to advance stream.\");\n}\nconst noTokens = /*@__PURE__*/Object.create(null);\nconst typeArray = [NodeType.none];\nconst nodeSet = /*@__PURE__*/new NodeSet(typeArray);\nconst warned = [];\n// Cache of node types by name and tags\nconst byTag = /*@__PURE__*/Object.create(null);\nconst defaultTable = /*@__PURE__*/Object.create(null);\nfor (let [legacyName, name] of [\n [\"variable\", \"variableName\"],\n [\"variable-2\", \"variableName.special\"],\n [\"string-2\", \"string.special\"],\n [\"def\", \"variableName.definition\"],\n [\"tag\", \"tagName\"],\n [\"attribute\", \"attributeName\"],\n [\"type\", \"typeName\"],\n [\"builtin\", \"variableName.standard\"],\n [\"qualifier\", \"modifier\"],\n [\"error\", \"invalid\"],\n [\"header\", \"heading\"],\n [\"property\", \"propertyName\"]\n])\n defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);\nclass TokenTable {\n constructor(extra) {\n this.extra = extra;\n this.table = Object.assign(Object.create(null), defaultTable);\n }\n resolve(tag) {\n return !tag ? 0 : this.table[tag] || (this.table[tag] = createTokenType(this.extra, tag));\n }\n}\nconst defaultTokenTable = /*@__PURE__*/new TokenTable(noTokens);\nfunction warnForPart(part, msg) {\n if (warned.indexOf(part) > -1)\n return;\n warned.push(part);\n console.warn(msg);\n}\nfunction createTokenType(extra, tagStr) {\n let tags$1 = [];\n for (let name of tagStr.split(\" \")) {\n let found = [];\n for (let part of name.split(\".\")) {\n let value = (extra[part] || tags[part]);\n if (!value) {\n warnForPart(part, `Unknown highlighting tag ${part}`);\n }\n else if (typeof value == \"function\") {\n if (!found.length)\n warnForPart(part, `Modifier ${part} used at start of tag`);\n else\n found = found.map(value);\n }\n else {\n if (found.length)\n warnForPart(part, `Tag ${part} used as modifier`);\n else\n found = Array.isArray(value) ? value : [value];\n }\n }\n for (let tag of found)\n tags$1.push(tag);\n }\n if (!tags$1.length)\n return 0;\n let name = tagStr.replace(/ /g, \"_\"), key = name + \" \" + tags$1.map(t => t.id);\n let known = byTag[key];\n if (known)\n return known.id;\n let type = byTag[key] = NodeType.define({\n id: typeArray.length,\n name,\n props: [styleTags({ [name]: tags$1 })]\n });\n typeArray.push(type);\n return type.id;\n}\nfunction docID(data) {\n let type = NodeType.define({ id: typeArray.length, name: \"Document\", props: [languageDataProp.add(() => data)], top: true });\n typeArray.push(type);\n return type;\n}\n\nexport { DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, ParseContext, StreamLanguage, StringStream, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentRange, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, toggleFold, unfoldAll, unfoldCode, unfoldEffect };\n","import { Annotation, Facet, combineConfig, StateField, EditorSelection, Transaction, ChangeSet, ChangeDesc, StateEffect, Text, findClusterBreak, countColumn, CharCategory } from '@codemirror/state';\nimport { EditorView, Direction } from '@codemirror/view';\nimport { IndentContext, getIndentation, indentString, matchBrackets, syntaxTree, getIndentUnit, indentUnit } from '@codemirror/language';\nimport { NodeProp } from '@lezer/common';\n\n/**\nComment or uncomment the current selection. Will use line comments\nif available, otherwise falling back to block comments.\n*/\nconst toggleComment = target => {\n let { state } = target, line = state.doc.lineAt(state.selection.main.from), config = getConfig(target.state, line.from);\n return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;\n};\nfunction command(f, option) {\n return ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let tr = f(option, state);\n if (!tr)\n return false;\n dispatch(state.update(tr));\n return true;\n };\n}\n/**\nComment or uncomment the current selection using line comments.\nThe line comment syntax is taken from the\n[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).\n*/\nconst toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */);\n/**\nComment the current selection using line comments.\n*/\nconst lineComment = /*@__PURE__*/command(changeLineComment, 1 /* CommentOption.Comment */);\n/**\nUncomment the current selection using line comments.\n*/\nconst lineUncomment = /*@__PURE__*/command(changeLineComment, 2 /* CommentOption.Uncomment */);\n/**\nComment or uncomment the current selection using block comments.\nThe block comment syntax is taken from the\n[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).\n*/\nconst toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */);\n/**\nComment the current selection using block comments.\n*/\nconst blockComment = /*@__PURE__*/command(changeBlockComment, 1 /* CommentOption.Comment */);\n/**\nUncomment the current selection using block comments.\n*/\nconst blockUncomment = /*@__PURE__*/command(changeBlockComment, 2 /* CommentOption.Uncomment */);\n/**\nComment or uncomment the lines around the current selection using\nblock comments.\n*/\nconst toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);\nfunction getConfig(state, pos) {\n let data = state.languageDataAt(\"commentTokens\", pos);\n return data.length ? data[0] : {};\n}\nconst SearchMargin = 50;\n/**\nDetermines if the given range is block-commented in the given\nstate.\n*/\nfunction findBlockComment(state, { open, close }, from, to) {\n let textBefore = state.sliceDoc(from - SearchMargin, from);\n let textAfter = state.sliceDoc(to, to + SearchMargin);\n let spaceBefore = /\\s*$/.exec(textBefore)[0].length, spaceAfter = /^\\s*/.exec(textAfter)[0].length;\n let beforeOff = textBefore.length - spaceBefore;\n if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&\n textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {\n return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },\n close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };\n }\n let startText, endText;\n if (to - from <= 2 * SearchMargin) {\n startText = endText = state.sliceDoc(from, to);\n }\n else {\n startText = state.sliceDoc(from, from + SearchMargin);\n endText = state.sliceDoc(to - SearchMargin, to);\n }\n let startSpace = /^\\s*/.exec(startText)[0].length, endSpace = /\\s*$/.exec(endText)[0].length;\n let endOff = endText.length - endSpace - close.length;\n if (startText.slice(startSpace, startSpace + open.length) == open &&\n endText.slice(endOff, endOff + close.length) == close) {\n return { open: { pos: from + startSpace + open.length,\n margin: /\\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },\n close: { pos: to - endSpace - close.length,\n margin: /\\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };\n }\n return null;\n}\nfunction selectedLineRanges(state) {\n let ranges = [];\n for (let r of state.selection.ranges) {\n let fromLine = state.doc.lineAt(r.from);\n let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);\n let last = ranges.length - 1;\n if (last >= 0 && ranges[last].to > fromLine.from)\n ranges[last].to = toLine.to;\n else\n ranges.push({ from: fromLine.from + /^\\s*/.exec(fromLine.text)[0].length, to: toLine.to });\n }\n return ranges;\n}\n// Performs toggle, comment and uncomment of block comments in\n// languages that support them.\nfunction changeBlockComment(option, state, ranges = state.selection.ranges) {\n let tokens = ranges.map(r => getConfig(state, r.from).block);\n if (!tokens.every(c => c))\n return null;\n let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));\n if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {\n return { changes: state.changes(ranges.map((range, i) => {\n if (comments[i])\n return [];\n return [{ from: range.from, insert: tokens[i].open + \" \" }, { from: range.to, insert: \" \" + tokens[i].close }];\n })) };\n }\n else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {\n let changes = [];\n for (let i = 0, comment; i < comments.length; i++)\n if (comment = comments[i]) {\n let token = tokens[i], { open, close } = comment;\n changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });\n }\n return { changes };\n }\n return null;\n}\n// Performs toggle, comment and uncomment of line comments.\nfunction changeLineComment(option, state, ranges = state.selection.ranges) {\n let lines = [];\n let prevLine = -1;\n for (let { from, to } of ranges) {\n let startI = lines.length, minIndent = 1e9;\n let token = getConfig(state, from).line;\n if (!token)\n continue;\n for (let pos = from; pos <= to;) {\n let line = state.doc.lineAt(pos);\n if (line.from > prevLine && (from == to || to > line.from)) {\n prevLine = line.from;\n let indent = /^\\s*/.exec(line.text)[0].length;\n let empty = indent == line.length;\n let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;\n if (indent < line.text.length && indent < minIndent)\n minIndent = indent;\n lines.push({ line, comment, token, indent, empty, single: false });\n }\n pos = line.to + 1;\n }\n if (minIndent < 1e9)\n for (let i = startI; i < lines.length; i++)\n if (lines[i].indent < lines[i].line.text.length)\n lines[i].indent = minIndent;\n if (lines.length == startI + 1)\n lines[startI].single = true;\n }\n if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {\n let changes = [];\n for (let { line, token, indent, empty, single } of lines)\n if (single || !empty)\n changes.push({ from: line.from + indent, insert: token + \" \" });\n let changeSet = state.changes(changes);\n return { changes: changeSet, selection: state.selection.map(changeSet, 1) };\n }\n else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {\n let changes = [];\n for (let { line, comment, token } of lines)\n if (comment >= 0) {\n let from = line.from + comment, to = from + token.length;\n if (line.text[to - line.from] == \" \")\n to++;\n changes.push({ from, to });\n }\n return { changes };\n }\n return null;\n}\n\nconst fromHistory = /*@__PURE__*/Annotation.define();\n/**\nTransaction annotation that will prevent that transaction from\nbeing combined with other transactions in the undo history. Given\n`\"before\"`, it'll prevent merging with previous transactions. With\n`\"after\"`, subsequent transactions won't be combined with this\none. With `\"full\"`, the transaction is isolated on both sides.\n*/\nconst isolateHistory = /*@__PURE__*/Annotation.define();\n/**\nThis facet provides a way to register functions that, given a\ntransaction, provide a set of effects that the history should\nstore when inverting the transaction. This can be used to\nintegrate some kinds of effects in the history, so that they can\nbe undone (and redone again).\n*/\nconst invertedEffects = /*@__PURE__*/Facet.define();\nconst historyConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n minDepth: 100,\n newGroupDelay: 500,\n joinToEvent: (_t, isAdjacent) => isAdjacent,\n }, {\n minDepth: Math.max,\n newGroupDelay: Math.min,\n joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj)\n });\n }\n});\nfunction changeEnd(changes) {\n let end = 0;\n changes.iterChangedRanges((_, to) => end = to);\n return end;\n}\nconst historyField_ = /*@__PURE__*/StateField.define({\n create() {\n return HistoryState.empty;\n },\n update(state, tr) {\n let config = tr.state.facet(historyConfig);\n let fromHist = tr.annotation(fromHistory);\n if (fromHist) {\n let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;\n let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;\n let other = from == 0 /* BranchName.Done */ ? state.undone : state.done;\n if (item)\n other = updateBranch(other, other.length, config.minDepth, item);\n else\n other = addSelection(other, tr.startState.selection);\n return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);\n }\n let isolate = tr.annotation(isolateHistory);\n if (isolate == \"full\" || isolate == \"before\")\n state = state.isolate();\n if (tr.annotation(Transaction.addToHistory) === false)\n return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;\n let event = HistEvent.fromTransaction(tr);\n let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent);\n if (event)\n state = state.addChanges(event, time, userEvent, config, tr);\n else if (tr.selection)\n state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);\n if (isolate == \"full\" || isolate == \"after\")\n state = state.isolate();\n return state;\n },\n toJSON(value) {\n return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };\n },\n fromJSON(json) {\n return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));\n }\n});\n/**\nCreate a history extension with the given configuration.\n*/\nfunction history(config = {}) {\n return [\n historyField_,\n historyConfig.of(config),\n EditorView.domEventHandlers({\n beforeinput(e, view) {\n let command = e.inputType == \"historyUndo\" ? undo : e.inputType == \"historyRedo\" ? redo : null;\n if (!command)\n return false;\n e.preventDefault();\n return command(view);\n }\n })\n ];\n}\n/**\nThe state field used to store the history data. Should probably\nonly be used when you want to\n[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or\n[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way\nthat preserves history.\n*/\nconst historyField = historyField_;\nfunction cmd(side, selection) {\n return function ({ state, dispatch }) {\n if (!selection && state.readOnly)\n return false;\n let historyState = state.field(historyField_, false);\n if (!historyState)\n return false;\n let tr = historyState.pop(side, state, selection);\n if (!tr)\n return false;\n dispatch(tr);\n return true;\n };\n}\n/**\nUndo a single group of history events. Returns false if no group\nwas available.\n*/\nconst undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false);\n/**\nRedo a group of history events. Returns false if no group was\navailable.\n*/\nconst redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false);\n/**\nUndo a change or selection change.\n*/\nconst undoSelection = /*@__PURE__*/cmd(0 /* BranchName.Done */, true);\n/**\nRedo a change or selection change.\n*/\nconst redoSelection = /*@__PURE__*/cmd(1 /* BranchName.Undone */, true);\nfunction depth(side) {\n return function (state) {\n let histState = state.field(historyField_, false);\n if (!histState)\n return 0;\n let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone;\n return branch.length - (branch.length && !branch[0].changes ? 1 : 0);\n };\n}\n/**\nThe amount of undoable change events available in a given state.\n*/\nconst undoDepth = /*@__PURE__*/depth(0 /* BranchName.Done */);\n/**\nThe amount of redoable change events available in a given state.\n*/\nconst redoDepth = /*@__PURE__*/depth(1 /* BranchName.Undone */);\n// History events store groups of changes or effects that need to be\n// undone/redone together.\nclass HistEvent {\n constructor(\n // The changes in this event. Normal events hold at least one\n // change or effect. But it may be necessary to store selection\n // events before the first change, in which case a special type of\n // instance is created which doesn't hold any changes, with\n // changes == startSelection == undefined\n changes, \n // The effects associated with this event\n effects, \n // Accumulated mapping (from addToHistory==false) that should be\n // applied to events below this one.\n mapped, \n // The selection before this event\n startSelection, \n // Stores selection changes after this event, to be used for\n // selection undo/redo.\n selectionsAfter) {\n this.changes = changes;\n this.effects = effects;\n this.mapped = mapped;\n this.startSelection = startSelection;\n this.selectionsAfter = selectionsAfter;\n }\n setSelAfter(after) {\n return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);\n }\n toJSON() {\n var _a, _b, _c;\n return {\n changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),\n mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),\n startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),\n selectionsAfter: this.selectionsAfter.map(s => s.toJSON())\n };\n }\n static fromJSON(json) {\n 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));\n }\n // This does not check `addToHistory` and such, it assumes the\n // transaction needs to be converted to an item. Returns null when\n // there are no changes or effects in the transaction.\n static fromTransaction(tr, selection) {\n let effects = none;\n for (let invert of tr.startState.facet(invertedEffects)) {\n let result = invert(tr);\n if (result.length)\n effects = effects.concat(result);\n }\n if (!effects.length && tr.changes.empty)\n return null;\n return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none);\n }\n static selection(selections) {\n return new HistEvent(undefined, none, undefined, undefined, selections);\n }\n}\nfunction updateBranch(branch, to, maxLen, newEvent) {\n let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;\n let newBranch = branch.slice(start, to);\n newBranch.push(newEvent);\n return newBranch;\n}\nfunction isAdjacent(a, b) {\n let ranges = [], isAdjacent = false;\n a.iterChangedRanges((f, t) => ranges.push(f, t));\n b.iterChangedRanges((_f, _t, f, t) => {\n for (let i = 0; i < ranges.length;) {\n let from = ranges[i++], to = ranges[i++];\n if (t >= from && f <= to)\n isAdjacent = true;\n }\n });\n return isAdjacent;\n}\nfunction eqSelectionShape(a, b) {\n return a.ranges.length == b.ranges.length &&\n a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;\n}\nfunction conc(a, b) {\n return !a.length ? b : !b.length ? a : a.concat(b);\n}\nconst none = [];\nconst MaxSelectionsPerEvent = 200;\nfunction addSelection(branch, selection) {\n if (!branch.length) {\n return [HistEvent.selection([selection])];\n }\n else {\n let lastEvent = branch[branch.length - 1];\n let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));\n if (sels.length && sels[sels.length - 1].eq(selection))\n return branch;\n sels.push(selection);\n return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));\n }\n}\n// Assumes the top item has one or more selectionAfter values\nfunction popSelection(branch) {\n let last = branch[branch.length - 1];\n let newBranch = branch.slice();\n newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));\n return newBranch;\n}\n// Add a mapping to the top event in the given branch. If this maps\n// away all the changes and effects in that item, drop it and\n// propagate the mapping to the next item.\nfunction addMappingToBranch(branch, mapping) {\n if (!branch.length)\n return branch;\n let length = branch.length, selections = none;\n while (length) {\n let event = mapEvent(branch[length - 1], mapping, selections);\n if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping\n let result = branch.slice(0, length);\n result[length - 1] = event;\n return result;\n }\n else { // Drop this event, since there's no changes or effects left\n mapping = event.mapped;\n length--;\n selections = event.selectionsAfter;\n }\n }\n return selections.length ? [HistEvent.selection(selections)] : none;\n}\nfunction mapEvent(event, mapping, extraSelections) {\n let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none, extraSelections);\n // Change-less events don't store mappings (they are always the last event in a branch)\n if (!event.changes)\n return HistEvent.selection(selections);\n let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);\n let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;\n return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);\n}\nconst joinableUserEvent = /^(input\\.type|delete)($|\\.)/;\nclass HistoryState {\n constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {\n this.done = done;\n this.undone = undone;\n this.prevTime = prevTime;\n this.prevUserEvent = prevUserEvent;\n }\n isolate() {\n return this.prevTime ? new HistoryState(this.done, this.undone) : this;\n }\n addChanges(event, time, userEvent, config, tr) {\n let done = this.done, lastEvent = done[done.length - 1];\n if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&\n (!userEvent || joinableUserEvent.test(userEvent)) &&\n ((!lastEvent.selectionsAfter.length &&\n time - this.prevTime < config.newGroupDelay &&\n config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes))) ||\n // For compose (but not compose.start) events, always join with previous event\n userEvent == \"input.type.compose\")) {\n done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));\n }\n else {\n done = updateBranch(done, done.length, config.minDepth, event);\n }\n return new HistoryState(done, none, time, userEvent);\n }\n addSelection(selection, time, userEvent, newGroupDelay) {\n let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none;\n if (last.length > 0 &&\n time - this.prevTime < newGroupDelay &&\n userEvent == this.prevUserEvent && userEvent && /^select($|\\.)/.test(userEvent) &&\n eqSelectionShape(last[last.length - 1], selection))\n return this;\n return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);\n }\n addMapping(mapping) {\n return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);\n }\n pop(side, state, selection) {\n let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;\n if (branch.length == 0)\n return null;\n let event = branch[branch.length - 1];\n if (selection && event.selectionsAfter.length) {\n return state.update({\n selection: event.selectionsAfter[event.selectionsAfter.length - 1],\n annotations: fromHistory.of({ side, rest: popSelection(branch) }),\n userEvent: side == 0 /* BranchName.Done */ ? \"select.undo\" : \"select.redo\",\n scrollIntoView: true\n });\n }\n else if (!event.changes) {\n return null;\n }\n else {\n let rest = branch.length == 1 ? none : branch.slice(0, branch.length - 1);\n if (event.mapped)\n rest = addMappingToBranch(rest, event.mapped);\n return state.update({\n changes: event.changes,\n selection: event.startSelection,\n effects: event.effects,\n annotations: fromHistory.of({ side, rest }),\n filter: false,\n userEvent: side == 0 /* BranchName.Done */ ? \"undo\" : \"redo\",\n scrollIntoView: true\n });\n }\n }\n}\nHistoryState.empty = /*@__PURE__*/new HistoryState(none, none);\n/**\nDefault key bindings for the undo history.\n\n- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).\n- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).\n- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).\n- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).\n*/\nconst historyKeymap = [\n { key: \"Mod-z\", run: undo, preventDefault: true },\n { key: \"Mod-y\", mac: \"Mod-Shift-z\", run: redo, preventDefault: true },\n { linux: \"Ctrl-Shift-z\", run: redo, preventDefault: true },\n { key: \"Mod-u\", run: undoSelection, preventDefault: true },\n { key: \"Alt-u\", mac: \"Mod-Shift-u\", run: redoSelection, preventDefault: true }\n];\n\nfunction updateSel(sel, by) {\n return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);\n}\nfunction setSel(state, selection) {\n return state.update({ selection, scrollIntoView: true, userEvent: \"select\" });\n}\nfunction moveSel({ state, dispatch }, how) {\n let selection = updateSel(state.selection, how);\n if (selection.eq(state.selection))\n return false;\n dispatch(setSel(state, selection));\n return true;\n}\nfunction rangeEnd(range, forward) {\n return EditorSelection.cursor(forward ? range.to : range.from);\n}\nfunction cursorByChar(view, forward) {\n return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));\n}\nfunction ltrAtCursor(view) {\n return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;\n}\n/**\nMove the selection one character to the left (which is backward in\nleft-to-right text, forward in right-to-left text).\n*/\nconst cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));\n/**\nMove the selection one character to the right.\n*/\nconst cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));\n/**\nMove the selection one character forward.\n*/\nconst cursorCharForward = view => cursorByChar(view, true);\n/**\nMove the selection one character backward.\n*/\nconst cursorCharBackward = view => cursorByChar(view, false);\nfunction cursorByGroup(view, forward) {\n return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));\n}\n/**\nMove the selection to the left across one group of word or\nnon-word (but also non-space) characters.\n*/\nconst cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));\n/**\nMove the selection one group to the right.\n*/\nconst cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));\n/**\nMove the selection one group forward.\n*/\nconst cursorGroupForward = view => cursorByGroup(view, true);\n/**\nMove the selection one group backward.\n*/\nconst cursorGroupBackward = view => cursorByGroup(view, false);\nconst segmenter = typeof Intl != \"undefined\" && Intl.Segmenter ?\n /*@__PURE__*/new (Intl.Segmenter)(undefined, { granularity: \"word\" }) : null;\nfunction moveBySubword(view, range, forward) {\n let categorize = view.state.charCategorizer(range.from);\n let cat = CharCategory.Space, pos = range.from, steps = 0;\n let done = false, sawUpper = false, sawLower = false;\n let step = (next) => {\n if (done)\n return false;\n pos += forward ? next.length : -next.length;\n let nextCat = categorize(next), ahead;\n if (nextCat == CharCategory.Word && next.charCodeAt(0) < 128 && /[\\W_]/.test(next))\n nextCat = -1; // Treat word punctuation specially\n if (cat == CharCategory.Space)\n cat = nextCat;\n if (cat != nextCat)\n return false;\n if (cat == CharCategory.Word) {\n if (next.toLowerCase() == next) {\n if (!forward && sawUpper)\n return false;\n sawLower = true;\n }\n else if (sawLower) {\n if (forward)\n return false;\n done = true;\n }\n else {\n if (sawUpper && forward && categorize(ahead = view.state.sliceDoc(pos, pos + 1)) == CharCategory.Word &&\n ahead.toLowerCase() == ahead)\n return false;\n sawUpper = true;\n }\n }\n steps++;\n return true;\n };\n let end = view.moveByChar(range, forward, start => {\n step(start);\n return step;\n });\n if (segmenter && cat == CharCategory.Word && end.from == range.from + steps * (forward ? 1 : -1)) {\n let from = Math.min(range.head, end.head), to = Math.max(range.head, end.head);\n let skipped = view.state.sliceDoc(from, to);\n if (skipped.length > 1 && /[\\u4E00-\\uffff]/.test(skipped)) {\n let segments = Array.from(segmenter.segment(skipped));\n if (segments.length > 1) {\n if (forward)\n return EditorSelection.cursor(range.head + segments[1].index, -1);\n return EditorSelection.cursor(end.head + segments[segments.length - 1].index, 1);\n }\n }\n }\n return end;\n}\nfunction cursorBySubword(view, forward) {\n return moveSel(view, range => range.empty ? moveBySubword(view, range, forward) : rangeEnd(range, forward));\n}\n/**\nMove the selection one group or camel-case subword forward.\n*/\nconst cursorSubwordForward = view => cursorBySubword(view, true);\n/**\nMove the selection one group or camel-case subword backward.\n*/\nconst cursorSubwordBackward = view => cursorBySubword(view, false);\nfunction interestingNode(state, node, bracketProp) {\n if (node.type.prop(bracketProp))\n return true;\n let len = node.to - node.from;\n return len && (len > 2 || /[^\\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;\n}\nfunction moveBySyntax(state, start, forward) {\n let pos = syntaxTree(state).resolveInner(start.head);\n let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy;\n // Scan forward through child nodes to see if there's an interesting\n // node ahead.\n for (let at = start.head;;) {\n let next = forward ? pos.childAfter(at) : pos.childBefore(at);\n if (!next)\n break;\n if (interestingNode(state, next, bracketProp))\n pos = next;\n else\n at = forward ? next.to : next.from;\n }\n let bracket = pos.type.prop(bracketProp), match, newPos;\n if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched)\n newPos = forward ? match.end.to : match.end.from;\n else\n newPos = forward ? pos.to : pos.from;\n return EditorSelection.cursor(newPos, forward ? -1 : 1);\n}\n/**\nMove the cursor over the next syntactic element to the left.\n*/\nconst cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));\n/**\nMove the cursor over the next syntactic element to the right.\n*/\nconst cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));\nfunction cursorByLine(view, forward) {\n return moveSel(view, range => {\n if (!range.empty)\n return rangeEnd(range, forward);\n let moved = view.moveVertically(range, forward);\n return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);\n });\n}\n/**\nMove the selection one line up.\n*/\nconst cursorLineUp = view => cursorByLine(view, false);\n/**\nMove the selection one line down.\n*/\nconst cursorLineDown = view => cursorByLine(view, true);\nfunction pageInfo(view) {\n let selfScroll = view.scrollDOM.clientHeight < view.scrollDOM.scrollHeight - 2;\n let marginTop = 0, marginBottom = 0, height;\n if (selfScroll) {\n for (let source of view.state.facet(EditorView.scrollMargins)) {\n let margins = source(view);\n if (margins === null || margins === void 0 ? void 0 : margins.top)\n marginTop = Math.max(margins === null || margins === void 0 ? void 0 : margins.top, marginTop);\n if (margins === null || margins === void 0 ? void 0 : margins.bottom)\n marginBottom = Math.max(margins === null || margins === void 0 ? void 0 : margins.bottom, marginBottom);\n }\n height = view.scrollDOM.clientHeight - marginTop - marginBottom;\n }\n else {\n height = (view.dom.ownerDocument.defaultView || window).innerHeight;\n }\n return { marginTop, marginBottom, selfScroll,\n height: Math.max(view.defaultLineHeight, height - 5) };\n}\nfunction cursorByPage(view, forward) {\n let page = pageInfo(view);\n let { state } = view, selection = updateSel(state.selection, range => {\n return range.empty ? view.moveVertically(range, forward, page.height)\n : rangeEnd(range, forward);\n });\n if (selection.eq(state.selection))\n return false;\n let effect;\n if (page.selfScroll) {\n let startPos = view.coordsAtPos(state.selection.main.head);\n let scrollRect = view.scrollDOM.getBoundingClientRect();\n let scrollTop = scrollRect.top + page.marginTop, scrollBottom = scrollRect.bottom - page.marginBottom;\n if (startPos && startPos.top > scrollTop && startPos.bottom < scrollBottom)\n effect = EditorView.scrollIntoView(selection.main.head, { y: \"start\", yMargin: startPos.top - scrollTop });\n }\n view.dispatch(setSel(state, selection), { effects: effect });\n return true;\n}\n/**\nMove the selection one page up.\n*/\nconst cursorPageUp = view => cursorByPage(view, false);\n/**\nMove the selection one page down.\n*/\nconst cursorPageDown = view => cursorByPage(view, true);\nfunction moveByLineBoundary(view, start, forward) {\n let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward);\n if (moved.head == start.head && moved.head != (forward ? line.to : line.from))\n moved = view.moveToLineBoundary(start, forward, false);\n if (!forward && moved.head == line.from && line.length) {\n let space = /^\\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;\n if (space && start.head != line.from + space)\n moved = EditorSelection.cursor(line.from + space);\n }\n return moved;\n}\n/**\nMove the selection to the next line wrap point, or to the end of\nthe line if there isn't one left on this line.\n*/\nconst cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));\n/**\nMove the selection to previous line wrap point, or failing that to\nthe start of the line. If the line is indented, and the cursor\nisn't already at the end of the indentation, this will move to the\nend of the indentation instead of the start of the line.\n*/\nconst cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));\n/**\nMove the selection one line wrap point to the left.\n*/\nconst cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));\n/**\nMove the selection one line wrap point to the right.\n*/\nconst cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));\n/**\nMove the selection to the start of the line.\n*/\nconst cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));\n/**\nMove the selection to the end of the line.\n*/\nconst cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1));\nfunction toMatchingBracket(state, dispatch, extend) {\n let found = false, selection = updateSel(state.selection, range => {\n let matching = matchBrackets(state, range.head, -1)\n || matchBrackets(state, range.head, 1)\n || (range.head > 0 && matchBrackets(state, range.head - 1, 1))\n || (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1));\n if (!matching || !matching.end)\n return range;\n found = true;\n let head = matching.start.from == range.head ? matching.end.to : matching.end.from;\n return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head);\n });\n if (!found)\n return false;\n dispatch(setSel(state, selection));\n return true;\n}\n/**\nMove the selection to the bracket matching the one it is currently\non, if any.\n*/\nconst cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, false);\n/**\nExtend the selection to the bracket matching the one the selection\nhead is currently on, if any.\n*/\nconst selectMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, true);\nfunction extendSel(view, how) {\n let selection = updateSel(view.state.selection, range => {\n let head = how(range);\n return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined);\n });\n if (selection.eq(view.state.selection))\n return false;\n view.dispatch(setSel(view.state, selection));\n return true;\n}\nfunction selectByChar(view, forward) {\n return extendSel(view, range => view.moveByChar(range, forward));\n}\n/**\nMove the selection head one character to the left, while leaving\nthe anchor in place.\n*/\nconst selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));\n/**\nMove the selection head one character to the right.\n*/\nconst selectCharRight = view => selectByChar(view, ltrAtCursor(view));\n/**\nMove the selection head one character forward.\n*/\nconst selectCharForward = view => selectByChar(view, true);\n/**\nMove the selection head one character backward.\n*/\nconst selectCharBackward = view => selectByChar(view, false);\nfunction selectByGroup(view, forward) {\n return extendSel(view, range => view.moveByGroup(range, forward));\n}\n/**\nMove the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to\nthe left.\n*/\nconst selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));\n/**\nMove the selection head one group to the right.\n*/\nconst selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));\n/**\nMove the selection head one group forward.\n*/\nconst selectGroupForward = view => selectByGroup(view, true);\n/**\nMove the selection head one group backward.\n*/\nconst selectGroupBackward = view => selectByGroup(view, false);\nfunction selectBySubword(view, forward) {\n return extendSel(view, range => moveBySubword(view, range, forward));\n}\n/**\nMove the selection head one group or camel-case subword forward.\n*/\nconst selectSubwordForward = view => selectBySubword(view, true);\n/**\nMove the selection head one group or subword backward.\n*/\nconst selectSubwordBackward = view => selectBySubword(view, false);\n/**\nMove the selection head over the next syntactic element to the left.\n*/\nconst selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));\n/**\nMove the selection head over the next syntactic element to the right.\n*/\nconst selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));\nfunction selectByLine(view, forward) {\n return extendSel(view, range => view.moveVertically(range, forward));\n}\n/**\nMove the selection head one line up.\n*/\nconst selectLineUp = view => selectByLine(view, false);\n/**\nMove the selection head one line down.\n*/\nconst selectLineDown = view => selectByLine(view, true);\nfunction selectByPage(view, forward) {\n return extendSel(view, range => view.moveVertically(range, forward, pageInfo(view).height));\n}\n/**\nMove the selection head one page up.\n*/\nconst selectPageUp = view => selectByPage(view, false);\n/**\nMove the selection head one page down.\n*/\nconst selectPageDown = view => selectByPage(view, true);\n/**\nMove the selection head to the next line boundary.\n*/\nconst selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));\n/**\nMove the selection head to the previous line boundary.\n*/\nconst selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));\n/**\nMove the selection head one line boundary to the left.\n*/\nconst selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));\n/**\nMove the selection head one line boundary to the right.\n*/\nconst selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));\n/**\nMove the selection head to the start of the line.\n*/\nconst selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));\n/**\nMove the selection head to the end of the line.\n*/\nconst selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to));\n/**\nMove the selection to the start of the document.\n*/\nconst cursorDocStart = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: 0 }));\n return true;\n};\n/**\nMove the selection to the end of the document.\n*/\nconst cursorDocEnd = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.doc.length }));\n return true;\n};\n/**\nMove the selection head to the start of the document.\n*/\nconst selectDocStart = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 }));\n return true;\n};\n/**\nMove the selection head to the end of the document.\n*/\nconst selectDocEnd = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length }));\n return true;\n};\n/**\nSelect the entire document.\n*/\nconst selectAll = ({ state, dispatch }) => {\n dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: \"select\" }));\n return true;\n};\n/**\nExpand the selection to cover entire lines.\n*/\nconst selectLine = ({ state, dispatch }) => {\n let ranges = selectedLineBlocks(state).map(({ from, to }) => EditorSelection.range(from, Math.min(to + 1, state.doc.length)));\n dispatch(state.update({ selection: EditorSelection.create(ranges), userEvent: \"select\" }));\n return true;\n};\n/**\nSelect the next syntactic construct that is larger than the\nselection. Note that this will only work insofar as the language\n[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full\nsyntax tree.\n*/\nconst selectParentSyntax = ({ state, dispatch }) => {\n let selection = updateSel(state.selection, range => {\n var _a;\n let context = syntaxTree(state).resolveInner(range.head, 1);\n while (!((context.from < range.from && context.to >= range.to) ||\n (context.to > range.to && context.from <= range.from) ||\n !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent)))\n context = context.parent;\n return EditorSelection.range(context.to, context.from);\n });\n dispatch(setSel(state, selection));\n return true;\n};\n/**\nSimplify the current selection. When multiple ranges are selected,\nreduce it to its main range. Otherwise, if the selection is\nnon-empty, convert it to a cursor selection.\n*/\nconst simplifySelection = ({ state, dispatch }) => {\n let cur = state.selection, selection = null;\n if (cur.ranges.length > 1)\n selection = EditorSelection.create([cur.main]);\n else if (!cur.main.empty)\n selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]);\n if (!selection)\n return false;\n dispatch(setSel(state, selection));\n return true;\n};\nfunction deleteBy(target, by) {\n if (target.state.readOnly)\n return false;\n let event = \"delete.selection\", { state } = target;\n let changes = state.changeByRange(range => {\n let { from, to } = range;\n if (from == to) {\n let towards = by(from);\n if (towards < from) {\n event = \"delete.backward\";\n towards = skipAtomic(target, towards, false);\n }\n else if (towards > from) {\n event = \"delete.forward\";\n towards = skipAtomic(target, towards, true);\n }\n from = Math.min(from, towards);\n to = Math.max(to, towards);\n }\n else {\n from = skipAtomic(target, from, false);\n to = skipAtomic(target, to, true);\n }\n return from == to ? { range } : { changes: { from, to }, range: EditorSelection.cursor(from) };\n });\n if (changes.changes.empty)\n return false;\n target.dispatch(state.update(changes, {\n scrollIntoView: true,\n userEvent: event,\n effects: event == \"delete.selection\" ? EditorView.announce.of(state.phrase(\"Selection deleted\")) : undefined\n }));\n return true;\n}\nfunction skipAtomic(target, pos, forward) {\n if (target instanceof EditorView)\n for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target)))\n ranges.between(pos, pos, (from, to) => {\n if (from < pos && to > pos)\n pos = forward ? to : from;\n });\n return pos;\n}\nconst deleteByChar = (target, forward) => deleteBy(target, pos => {\n let { state } = target, line = state.doc.lineAt(pos), before, targetPos;\n if (!forward && pos > line.from && pos < line.from + 200 &&\n !/[^ \\t]/.test(before = line.text.slice(0, pos - line.from))) {\n if (before[before.length - 1] == \"\\t\")\n return pos - 1;\n let col = countColumn(before, state.tabSize), drop = col % getIndentUnit(state) || getIndentUnit(state);\n for (let i = 0; i < drop && before[before.length - 1 - i] == \" \"; i++)\n pos--;\n targetPos = pos;\n }\n else {\n targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from;\n if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))\n targetPos += forward ? 1 : -1;\n }\n return targetPos;\n});\n/**\nDelete the selection, or, for cursor selections, the character\nbefore the cursor.\n*/\nconst deleteCharBackward = view => deleteByChar(view, false);\n/**\nDelete the selection or the character after the cursor.\n*/\nconst deleteCharForward = view => deleteByChar(view, true);\nconst deleteByGroup = (target, forward) => deleteBy(target, start => {\n let pos = start, { state } = target, line = state.doc.lineAt(pos);\n let categorize = state.charCategorizer(pos);\n for (let cat = null;;) {\n if (pos == (forward ? line.to : line.from)) {\n if (pos == start && line.number != (forward ? state.doc.lines : 1))\n pos += forward ? 1 : -1;\n break;\n }\n let next = findClusterBreak(line.text, pos - line.from, forward) + line.from;\n let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);\n let nextCat = categorize(nextChar);\n if (cat != null && nextCat != cat)\n break;\n if (nextChar != \" \" || pos != start)\n cat = nextCat;\n pos = next;\n }\n return pos;\n});\n/**\nDelete the selection or backward until the end of the next\n[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of\nwhitespace when they consist of a single space.\n*/\nconst deleteGroupBackward = target => deleteByGroup(target, false);\n/**\nDelete the selection or forward until the end of the next group.\n*/\nconst deleteGroupForward = target => deleteByGroup(target, true);\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe end of the line. If the cursor is directly at the end of the\nline, delete the line break after it.\n*/\nconst deleteToLineEnd = view => deleteBy(view, pos => {\n let lineEnd = view.lineBlockAt(pos).to;\n return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);\n});\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe start of the line. If the cursor is directly at the start of the\nline, delete the line break before it.\n*/\nconst deleteToLineStart = view => deleteBy(view, pos => {\n let lineStart = view.lineBlockAt(pos).from;\n return pos > lineStart ? lineStart : Math.max(0, pos - 1);\n});\n/**\nDelete all whitespace directly before a line end from the\ndocument.\n*/\nconst deleteTrailingWhitespace = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = [];\n for (let pos = 0, prev = \"\", iter = state.doc.iter();;) {\n iter.next();\n if (iter.lineBreak || iter.done) {\n let trailing = prev.search(/\\s+$/);\n if (trailing > -1)\n changes.push({ from: pos - (prev.length - trailing), to: pos });\n if (iter.done)\n break;\n prev = \"\";\n }\n else {\n prev = iter.value;\n }\n pos += iter.value.length;\n }\n if (!changes.length)\n return false;\n dispatch(state.update({ changes, userEvent: \"delete\" }));\n return true;\n};\n/**\nReplace each selection range with a line break, leaving the cursor\non the line before the break.\n*/\nconst splitLine = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n return { changes: { from: range.from, to: range.to, insert: Text.of([\"\", \"\"]) },\n range: EditorSelection.cursor(range.from) };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\n/**\nFlip the characters before and after the cursor(s).\n*/\nconst transposeChars = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n if (!range.empty || range.from == 0 || range.from == state.doc.length)\n return { range };\n let pos = range.from, line = state.doc.lineAt(pos);\n let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from;\n let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from;\n return { changes: { from, to, insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos)) },\n range: EditorSelection.cursor(to) };\n });\n if (changes.changes.empty)\n return false;\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"move.character\" }));\n return true;\n};\nfunction selectedLineBlocks(state) {\n let blocks = [], upto = -1;\n for (let range of state.selection.ranges) {\n let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to);\n if (!range.empty && range.to == endLine.from)\n endLine = state.doc.lineAt(range.to - 1);\n if (upto >= startLine.number) {\n let prev = blocks[blocks.length - 1];\n prev.to = endLine.to;\n prev.ranges.push(range);\n }\n else {\n blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] });\n }\n upto = endLine.number + 1;\n }\n return blocks;\n}\nfunction moveLine(state, dispatch, forward) {\n if (state.readOnly)\n return false;\n let changes = [], ranges = [];\n for (let block of selectedLineBlocks(state)) {\n if (forward ? block.to == state.doc.length : block.from == 0)\n continue;\n let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);\n let size = nextLine.length + 1;\n if (forward) {\n changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state.lineBreak });\n for (let r of block.ranges)\n ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));\n }\n else {\n changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text });\n for (let r of block.ranges)\n ranges.push(EditorSelection.range(r.anchor - size, r.head - size));\n }\n }\n if (!changes.length)\n return false;\n dispatch(state.update({\n changes,\n scrollIntoView: true,\n selection: EditorSelection.create(ranges, state.selection.mainIndex),\n userEvent: \"move.line\"\n }));\n return true;\n}\n/**\nMove the selected lines up one line.\n*/\nconst moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false);\n/**\nMove the selected lines down one line.\n*/\nconst moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true);\nfunction copyLine(state, dispatch, forward) {\n if (state.readOnly)\n return false;\n let changes = [];\n for (let block of selectedLineBlocks(state)) {\n if (forward)\n changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak });\n else\n changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) });\n }\n dispatch(state.update({ changes, scrollIntoView: true, userEvent: \"input.copyline\" }));\n return true;\n}\n/**\nCreate a copy of the selected lines. Keep the selection in the top copy.\n*/\nconst copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false);\n/**\nCreate a copy of the selected lines. Keep the selection in the bottom copy.\n*/\nconst copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true);\n/**\nDelete selected lines.\n*/\nconst deleteLine = view => {\n if (view.state.readOnly)\n return false;\n let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => {\n if (from > 0)\n from--;\n else if (to < state.doc.length)\n to++;\n return { from, to };\n }));\n let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);\n view.dispatch({ changes, selection, scrollIntoView: true, userEvent: \"delete.line\" });\n return true;\n};\n/**\nReplace the selection with a newline.\n*/\nconst insertNewline = ({ state, dispatch }) => {\n dispatch(state.update(state.replaceSelection(state.lineBreak), { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\nfunction isBetweenBrackets(state, pos) {\n if (/\\(\\)|\\[\\]|\\{\\}/.test(state.sliceDoc(pos - 1, pos + 1)))\n return { from: pos, to: pos };\n let context = syntaxTree(state).resolveInner(pos);\n let before = context.childBefore(pos), after = context.childAfter(pos), closedBy;\n if (before && after && before.to <= pos && after.from >= pos &&\n (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 &&\n state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from &&\n !/\\S/.test(state.sliceDoc(before.to, after.from)))\n return { from: before.to, to: after.from };\n return null;\n}\n/**\nReplace the selection with a newline and indent the newly created\nline(s). If the current line consists only of whitespace, this\nwill also delete that whitespace. When the cursor is between\nmatching brackets, an additional newline will be inserted after\nthe cursor.\n*/\nconst insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);\n/**\nCreate a blank, indented line below the current line.\n*/\nconst insertBlankLine = /*@__PURE__*/newlineAndIndent(true);\nfunction newlineAndIndent(atEof) {\n return ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n let { from, to } = range, line = state.doc.lineAt(from);\n let explode = !atEof && from == to && isBetweenBrackets(state, from);\n if (atEof)\n from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;\n let cx = new IndentContext(state, { simulateBreak: from, simulateDoubleBreak: !!explode });\n let indent = getIndentation(cx, from);\n if (indent == null)\n indent = countColumn(/^\\s*/.exec(state.doc.lineAt(from).text)[0], state.tabSize);\n while (to < line.to && /\\s/.test(line.text[to - line.from]))\n to++;\n if (explode)\n ({ from, to } = explode);\n else if (from > line.from && from < line.from + 100 && !/\\S/.test(line.text.slice(0, from)))\n from = line.from;\n let insert = [\"\", indentString(state, indent)];\n if (explode)\n insert.push(indentString(state, cx.lineIndent(line.from, -1)));\n return { changes: { from, to, insert: Text.of(insert) },\n range: EditorSelection.cursor(from + 1 + insert[1].length) };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n };\n}\nfunction changeBySelectedLine(state, f) {\n let atLine = -1;\n return state.changeByRange(range => {\n let changes = [];\n for (let pos = range.from; pos <= range.to;) {\n let line = state.doc.lineAt(pos);\n if (line.number > atLine && (range.empty || range.to > line.from)) {\n f(line, changes, range);\n atLine = line.number;\n }\n pos = line.to + 1;\n }\n let changeSet = state.changes(changes);\n return { changes,\n range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) };\n });\n}\n/**\nAuto-indent the selected lines. This uses the [indentation service\nfacet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent\ninformation.\n*/\nconst indentSelection = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let updated = Object.create(null);\n let context = new IndentContext(state, { overrideIndentation: start => {\n let found = updated[start];\n return found == null ? -1 : found;\n } });\n let changes = changeBySelectedLine(state, (line, changes, range) => {\n let indent = getIndentation(context, line.from);\n if (indent == null)\n return;\n if (!/\\S/.test(line.text))\n indent = 0;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm || range.from < line.from + cur.length) {\n updated[line.from] = indent;\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n });\n if (!changes.changes.empty)\n dispatch(state.update(changes, { userEvent: \"indent\" }));\n return true;\n};\n/**\nAdd a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected\nlines.\n*/\nconst indentMore = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n dispatch(state.update(changeBySelectedLine(state, (line, changes) => {\n changes.push({ from: line.from, insert: state.facet(indentUnit) });\n }), { userEvent: \"input.indent\" }));\n return true;\n};\n/**\nRemove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all\nselected lines.\n*/\nconst indentLess = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n dispatch(state.update(changeBySelectedLine(state, (line, changes) => {\n let space = /^\\s*/.exec(line.text)[0];\n if (!space)\n return;\n let col = countColumn(space, state.tabSize), keep = 0;\n let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));\n while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep))\n keep++;\n changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) });\n }), { userEvent: \"delete.dedent\" }));\n return true;\n};\n/**\nInsert a tab character at the cursor or, if something is selected,\nuse [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire\nselection.\n*/\nconst insertTab = ({ state, dispatch }) => {\n if (state.selection.ranges.some(r => !r.empty))\n return indentMore({ state, dispatch });\n dispatch(state.update(state.replaceSelection(\"\\t\"), { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\n/**\nArray of key bindings containing the Emacs-style bindings that are\navailable on macOS by default.\n\n - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)\n - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)\n - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)\n - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)\n - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)\n - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)\n - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)\n - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)\n - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)\n - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)\n - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)\n - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)\n - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)\n - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)\n*/\nconst emacsStyleKeymap = [\n { key: \"Ctrl-b\", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },\n { key: \"Ctrl-f\", run: cursorCharRight, shift: selectCharRight },\n { key: \"Ctrl-p\", run: cursorLineUp, shift: selectLineUp },\n { key: \"Ctrl-n\", run: cursorLineDown, shift: selectLineDown },\n { key: \"Ctrl-a\", run: cursorLineStart, shift: selectLineStart },\n { key: \"Ctrl-e\", run: cursorLineEnd, shift: selectLineEnd },\n { key: \"Ctrl-d\", run: deleteCharForward },\n { key: \"Ctrl-h\", run: deleteCharBackward },\n { key: \"Ctrl-k\", run: deleteToLineEnd },\n { key: \"Ctrl-Alt-h\", run: deleteGroupBackward },\n { key: \"Ctrl-o\", run: splitLine },\n { key: \"Ctrl-t\", run: transposeChars },\n { key: \"Ctrl-v\", run: cursorPageDown },\n];\n/**\nAn array of key bindings closely sticking to platform-standard or\nwidely used bindings. (This includes the bindings from\n[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`\nproperty changed to `mac`.)\n\n - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)\n - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)\n - 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)\n - 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)\n - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)\n - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)\n - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)\n - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)\n - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)\n - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)\n - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)\n - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)\n - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)\n - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)\n - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)\n - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)\n - 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)\n - 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)\n - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)\n - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)\n - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)\n - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)\n - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)\n - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)\n - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).\n - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).\n*/\nconst standardKeymap = /*@__PURE__*/[\n { key: \"ArrowLeft\", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },\n { key: \"Mod-ArrowLeft\", mac: \"Alt-ArrowLeft\", run: cursorGroupLeft, shift: selectGroupLeft, preventDefault: true },\n { mac: \"Cmd-ArrowLeft\", run: cursorLineBoundaryLeft, shift: selectLineBoundaryLeft, preventDefault: true },\n { key: \"ArrowRight\", run: cursorCharRight, shift: selectCharRight, preventDefault: true },\n { key: \"Mod-ArrowRight\", mac: \"Alt-ArrowRight\", run: cursorGroupRight, shift: selectGroupRight, preventDefault: true },\n { mac: \"Cmd-ArrowRight\", run: cursorLineBoundaryRight, shift: selectLineBoundaryRight, preventDefault: true },\n { key: \"ArrowUp\", run: cursorLineUp, shift: selectLineUp, preventDefault: true },\n { mac: \"Cmd-ArrowUp\", run: cursorDocStart, shift: selectDocStart },\n { mac: \"Ctrl-ArrowUp\", run: cursorPageUp, shift: selectPageUp },\n { key: \"ArrowDown\", run: cursorLineDown, shift: selectLineDown, preventDefault: true },\n { mac: \"Cmd-ArrowDown\", run: cursorDocEnd, shift: selectDocEnd },\n { mac: \"Ctrl-ArrowDown\", run: cursorPageDown, shift: selectPageDown },\n { key: \"PageUp\", run: cursorPageUp, shift: selectPageUp },\n { key: \"PageDown\", run: cursorPageDown, shift: selectPageDown },\n { key: \"Home\", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true },\n { key: \"Mod-Home\", run: cursorDocStart, shift: selectDocStart },\n { key: \"End\", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true },\n { key: \"Mod-End\", run: cursorDocEnd, shift: selectDocEnd },\n { key: \"Enter\", run: insertNewlineAndIndent },\n { key: \"Mod-a\", run: selectAll },\n { key: \"Backspace\", run: deleteCharBackward, shift: deleteCharBackward },\n { key: \"Delete\", run: deleteCharForward },\n { key: \"Mod-Backspace\", mac: \"Alt-Backspace\", run: deleteGroupBackward },\n { key: \"Mod-Delete\", mac: \"Alt-Delete\", run: deleteGroupForward },\n { mac: \"Mod-Backspace\", run: deleteToLineStart },\n { mac: \"Mod-Delete\", run: deleteToLineEnd }\n].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));\n/**\nThe default keymap. Includes all bindings from\n[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:\n\n- 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)\n- 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)\n- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)\n- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)\n- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)\n- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)\n- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)\n- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)\n- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)\n- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)\n- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)\n- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)\n- Ctrl-Alt-\\\\ (Cmd-Alt-\\\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)\n- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)\n- Shift-Ctrl-\\\\ (Shift-Cmd-\\\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)\n- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).\n- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).\n*/\nconst defaultKeymap = /*@__PURE__*/[\n { key: \"Alt-ArrowLeft\", mac: \"Ctrl-ArrowLeft\", run: cursorSyntaxLeft, shift: selectSyntaxLeft },\n { key: \"Alt-ArrowRight\", mac: \"Ctrl-ArrowRight\", run: cursorSyntaxRight, shift: selectSyntaxRight },\n { key: \"Alt-ArrowUp\", run: moveLineUp },\n { key: \"Shift-Alt-ArrowUp\", run: copyLineUp },\n { key: \"Alt-ArrowDown\", run: moveLineDown },\n { key: \"Shift-Alt-ArrowDown\", run: copyLineDown },\n { key: \"Escape\", run: simplifySelection },\n { key: \"Mod-Enter\", run: insertBlankLine },\n { key: \"Alt-l\", mac: \"Ctrl-l\", run: selectLine },\n { key: \"Mod-i\", run: selectParentSyntax, preventDefault: true },\n { key: \"Mod-[\", run: indentLess },\n { key: \"Mod-]\", run: indentMore },\n { key: \"Mod-Alt-\\\\\", run: indentSelection },\n { key: \"Shift-Mod-k\", run: deleteLine },\n { key: \"Shift-Mod-\\\\\", run: cursorMatchingBracket },\n { key: \"Mod-/\", run: toggleComment },\n { key: \"Alt-A\", run: toggleBlockComment }\n].concat(standardKeymap);\n/**\nA binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and\nShift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).\nPlease see the [Tab example](../../examples/tab/) before using\nthis.\n*/\nconst indentWithTab = { key: \"Tab\", run: indentMore, shift: indentLess };\n\nexport { blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };\n","export default function crelt() {\n var elt = arguments[0]\n if (typeof elt == \"string\") elt = document.createElement(elt)\n var i = 1, next = arguments[1]\n if (next && typeof next == \"object\" && next.nodeType == null && !Array.isArray(next)) {\n for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {\n var value = next[name]\n if (typeof value == \"string\") elt.setAttribute(name, value)\n else if (value != null) elt[name] = value\n }\n i++\n }\n for (; i < arguments.length; i++) add(elt, arguments[i])\n return elt\n}\n\nfunction add(elt, child) {\n if (typeof child == \"string\") {\n elt.appendChild(document.createTextNode(child))\n } else if (child == null) {\n } else if (child.nodeType != null) {\n elt.appendChild(child)\n } else if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) add(elt, child[i])\n } else {\n throw new RangeError(\"Unsupported child node: \" + child)\n }\n}\n","import { showPanel, EditorView, getPanel, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view';\nimport { codePointAt, fromCodePoint, codePointSize, StateEffect, StateField, EditorSelection, Facet, combineConfig, CharCategory, RangeSetBuilder, Prec, EditorState, findClusterBreak } from '@codemirror/state';\nimport elt from 'crelt';\n\nconst basicNormalize = typeof String.prototype.normalize == \"function\"\n ? x => x.normalize(\"NFKD\") : x => x;\n/**\nA search cursor provides an iterator over text matches in a\ndocument.\n*/\nclass SearchCursor {\n /**\n Create a text cursor. The query is the search string, `from` to\n `to` provides the region to search.\n \n When `normalize` is given, it will be called, on both the query\n string and the content it is matched against, before comparing.\n You can, for example, create a case-insensitive search by\n passing `s => s.toLowerCase()`.\n \n Text is always normalized with\n [`.normalize(\"NFKD\")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)\n (when supported).\n */\n constructor(text, query, from = 0, to = text.length, normalize, test) {\n this.test = test;\n /**\n The current match (only holds a meaningful value after\n [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when\n `done` is false).\n */\n this.value = { from: 0, to: 0 };\n /**\n Whether the end of the iterated region has been reached.\n */\n this.done = false;\n this.matches = [];\n this.buffer = \"\";\n this.bufferPos = 0;\n this.iter = text.iterRange(from, to);\n this.bufferStart = from;\n this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;\n this.query = this.normalize(query);\n }\n peek() {\n if (this.bufferPos == this.buffer.length) {\n this.bufferStart += this.buffer.length;\n this.iter.next();\n if (this.iter.done)\n return -1;\n this.bufferPos = 0;\n this.buffer = this.iter.value;\n }\n return codePointAt(this.buffer, this.bufferPos);\n }\n /**\n Look for the next match. Updates the iterator's\n [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and\n [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called\n at least once before using the cursor.\n */\n next() {\n while (this.matches.length)\n this.matches.pop();\n return this.nextOverlapping();\n }\n /**\n The `next` method will ignore matches that partially overlap a\n previous match. This method behaves like `next`, but includes\n such matches.\n */\n nextOverlapping() {\n for (;;) {\n let next = this.peek();\n if (next < 0) {\n this.done = true;\n return this;\n }\n let str = fromCodePoint(next), start = this.bufferStart + this.bufferPos;\n this.bufferPos += codePointSize(next);\n let norm = this.normalize(str);\n for (let i = 0, pos = start;; i++) {\n let code = norm.charCodeAt(i);\n let match = this.match(code, pos);\n if (i == norm.length - 1) {\n if (match) {\n this.value = match;\n return this;\n }\n break;\n }\n if (pos == start && i < str.length && str.charCodeAt(i) == code)\n pos++;\n }\n }\n }\n match(code, pos) {\n let match = null;\n for (let i = 0; i < this.matches.length; i += 2) {\n let index = this.matches[i], keep = false;\n if (this.query.charCodeAt(index) == code) {\n if (index == this.query.length - 1) {\n match = { from: this.matches[i + 1], to: pos + 1 };\n }\n else {\n this.matches[i]++;\n keep = true;\n }\n }\n if (!keep) {\n this.matches.splice(i, 2);\n i -= 2;\n }\n }\n if (this.query.charCodeAt(0) == code) {\n if (this.query.length == 1)\n match = { from: pos, to: pos + 1 };\n else\n this.matches.push(1, pos);\n }\n if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferStart))\n match = null;\n return match;\n }\n}\nif (typeof Symbol != \"undefined\")\n SearchCursor.prototype[Symbol.iterator] = function () { return this; };\n\nconst empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec(\"\") };\nconst baseFlags = \"gm\" + (/x/.unicode == null ? \"\" : \"u\");\n/**\nThis class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)\nbut searches for a regular expression pattern instead of a plain\nstring.\n*/\nclass RegExpCursor {\n /**\n Create a cursor that will search the given range in the given\n document. `query` should be the raw pattern (as you'd pass it to\n `new RegExp`).\n */\n constructor(text, query, options, from = 0, to = text.length) {\n this.text = text;\n this.to = to;\n this.curLine = \"\";\n /**\n Set to `true` when the cursor has reached the end of the search\n range.\n */\n this.done = false;\n /**\n Will contain an object with the extent of the match and the\n match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)\n sucessfully finds a match.\n */\n this.value = empty;\n if (/\\\\[sWDnr]|\\n|\\r|\\[\\^/.test(query))\n return new MultilineRegExpCursor(text, query, options, from, to);\n this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? \"i\" : \"\"));\n this.test = options === null || options === void 0 ? void 0 : options.test;\n this.iter = text.iter();\n let startLine = text.lineAt(from);\n this.curLineStart = startLine.from;\n this.matchPos = toCharEnd(text, from);\n this.getLine(this.curLineStart);\n }\n getLine(skip) {\n this.iter.next(skip);\n if (this.iter.lineBreak) {\n this.curLine = \"\";\n }\n else {\n this.curLine = this.iter.value;\n if (this.curLineStart + this.curLine.length > this.to)\n this.curLine = this.curLine.slice(0, this.to - this.curLineStart);\n this.iter.next();\n }\n }\n nextLine() {\n this.curLineStart = this.curLineStart + this.curLine.length + 1;\n if (this.curLineStart > this.to)\n this.curLine = \"\";\n else\n this.getLine(0);\n }\n /**\n Move to the next match, if there is one.\n */\n next() {\n for (let off = this.matchPos - this.curLineStart;;) {\n this.re.lastIndex = off;\n let match = this.matchPos <= this.to && this.re.exec(this.curLine);\n if (match) {\n let from = this.curLineStart + match.index, to = from + match[0].length;\n this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));\n if (from == this.curLineStart + this.curLine.length)\n this.nextLine();\n if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {\n this.value = { from, to, match };\n return this;\n }\n off = this.matchPos - this.curLineStart;\n }\n else if (this.curLineStart + this.curLine.length < this.to) {\n this.nextLine();\n off = 0;\n }\n else {\n this.done = true;\n return this;\n }\n }\n }\n}\nconst flattened = /*@__PURE__*/new WeakMap();\n// Reusable (partially) flattened document strings\nclass FlattenedDoc {\n constructor(from, text) {\n this.from = from;\n this.text = text;\n }\n get to() { return this.from + this.text.length; }\n static get(doc, from, to) {\n let cached = flattened.get(doc);\n if (!cached || cached.from >= to || cached.to <= from) {\n let flat = new FlattenedDoc(from, doc.sliceString(from, to));\n flattened.set(doc, flat);\n return flat;\n }\n if (cached.from == from && cached.to == to)\n return cached;\n let { text, from: cachedFrom } = cached;\n if (cachedFrom > from) {\n text = doc.sliceString(from, cachedFrom) + text;\n cachedFrom = from;\n }\n if (cached.to < to)\n text += doc.sliceString(cached.to, to);\n flattened.set(doc, new FlattenedDoc(cachedFrom, text));\n return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));\n }\n}\nclass MultilineRegExpCursor {\n constructor(text, query, options, from, to) {\n this.text = text;\n this.to = to;\n this.done = false;\n this.value = empty;\n this.matchPos = toCharEnd(text, from);\n this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? \"i\" : \"\"));\n this.test = options === null || options === void 0 ? void 0 : options.test;\n this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Chunk.Base */));\n }\n chunkEnd(pos) {\n return pos >= this.to ? this.to : this.text.lineAt(pos).to;\n }\n next() {\n for (;;) {\n let off = this.re.lastIndex = this.matchPos - this.flat.from;\n let match = this.re.exec(this.flat.text);\n // Skip empty matches directly after the last match\n if (match && !match[0] && match.index == off) {\n this.re.lastIndex = off + 1;\n match = this.re.exec(this.flat.text);\n }\n if (match) {\n let from = this.flat.from + match.index, to = from + match[0].length;\n // If a match goes almost to the end of a noncomplete chunk, try\n // again, since it'll likely be able to match more\n if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) &&\n (!this.test || this.test(from, to, match))) {\n this.value = { from, to, match };\n this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));\n return this;\n }\n }\n if (this.flat.to == this.to) {\n this.done = true;\n return this;\n }\n // Grow the flattened doc\n this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));\n }\n }\n}\nif (typeof Symbol != \"undefined\") {\n RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] =\n function () { return this; };\n}\nfunction validRegExp(source) {\n try {\n new RegExp(source, baseFlags);\n return true;\n }\n catch (_a) {\n return false;\n }\n}\nfunction toCharEnd(text, pos) {\n if (pos >= text.length)\n return pos;\n let line = text.lineAt(pos), next;\n while (pos < line.to && (next = line.text.charCodeAt(pos - line.from)) >= 0xDC00 && next < 0xE000)\n pos++;\n return pos;\n}\n\nfunction createLineDialog(view) {\n let line = String(view.state.doc.lineAt(view.state.selection.main.head).number);\n let input = elt(\"input\", { class: \"cm-textfield\", name: \"line\", value: line });\n let dom = elt(\"form\", {\n class: \"cm-gotoLine\",\n onkeydown: (event) => {\n if (event.keyCode == 27) { // Escape\n event.preventDefault();\n view.dispatch({ effects: dialogEffect.of(false) });\n view.focus();\n }\n else if (event.keyCode == 13) { // Enter\n event.preventDefault();\n go();\n }\n },\n onsubmit: (event) => {\n event.preventDefault();\n go();\n }\n }, elt(\"label\", view.state.phrase(\"Go to line\"), \": \", input), \" \", elt(\"button\", { class: \"cm-button\", type: \"submit\" }, view.state.phrase(\"go\")));\n function go() {\n let match = /^([+-])?(\\d+)?(:\\d+)?(%)?$/.exec(input.value);\n if (!match)\n return;\n let { state } = view, startLine = state.doc.lineAt(state.selection.main.head);\n let [, sign, ln, cl, percent] = match;\n let col = cl ? +cl.slice(1) : 0;\n let line = ln ? +ln : startLine.number;\n if (ln && percent) {\n let pc = line / 100;\n if (sign)\n pc = pc * (sign == \"-\" ? -1 : 1) + (startLine.number / state.doc.lines);\n line = Math.round(state.doc.lines * pc);\n }\n else if (ln && sign) {\n line = line * (sign == \"-\" ? -1 : 1) + startLine.number;\n }\n let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));\n let selection = EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length)));\n view.dispatch({\n effects: [dialogEffect.of(false), EditorView.scrollIntoView(selection.from, { y: 'center' })],\n selection,\n });\n view.focus();\n }\n return { dom };\n}\nconst dialogEffect = /*@__PURE__*/StateEffect.define();\nconst dialogField = /*@__PURE__*/StateField.define({\n create() { return true; },\n update(value, tr) {\n for (let e of tr.effects)\n if (e.is(dialogEffect))\n value = e.value;\n return value;\n },\n provide: f => showPanel.from(f, val => val ? createLineDialog : null)\n});\n/**\nCommand that shows a dialog asking the user for a line number, and\nwhen a valid position is provided, moves the cursor to that line.\n\nSupports line numbers, relative line offsets prefixed with `+` or\n`-`, document percentages suffixed with `%`, and an optional\ncolumn position by adding `:` and a second number after the line\nnumber.\n*/\nconst gotoLine = view => {\n let panel = getPanel(view, createLineDialog);\n if (!panel) {\n let effects = [dialogEffect.of(true)];\n if (view.state.field(dialogField, false) == null)\n effects.push(StateEffect.appendConfig.of([dialogField, baseTheme$1]));\n view.dispatch({ effects });\n panel = getPanel(view, createLineDialog);\n }\n if (panel)\n panel.dom.querySelector(\"input\").select();\n return true;\n};\nconst baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({\n \".cm-panel.cm-gotoLine\": {\n padding: \"2px 6px 4px\",\n \"& label\": { fontSize: \"80%\" }\n }\n});\n\nconst defaultHighlightOptions = {\n highlightWordAroundCursor: false,\n minSelectionLength: 1,\n maxMatches: 100,\n wholeWords: false\n};\nconst highlightConfig = /*@__PURE__*/Facet.define({\n combine(options) {\n return combineConfig(options, defaultHighlightOptions, {\n highlightWordAroundCursor: (a, b) => a || b,\n minSelectionLength: Math.min,\n maxMatches: Math.min\n });\n }\n});\n/**\nThis extension highlights text that matches the selection. It uses\nthe `\"cm-selectionMatch\"` class for the highlighting. When\n`highlightWordAroundCursor` is enabled, the word at the cursor\nitself will be highlighted with `\"cm-selectionMatch-main\"`.\n*/\nfunction highlightSelectionMatches(options) {\n let ext = [defaultTheme, matchHighlighter];\n if (options)\n ext.push(highlightConfig.of(options));\n return ext;\n}\nconst matchDeco = /*@__PURE__*/Decoration.mark({ class: \"cm-selectionMatch\" });\nconst mainMatchDeco = /*@__PURE__*/Decoration.mark({ class: \"cm-selectionMatch cm-selectionMatch-main\" });\n// Whether the characters directly outside the given positions are non-word characters\nfunction insideWordBoundaries(check, state, from, to) {\n return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory.Word) &&\n (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory.Word);\n}\n// Whether the characters directly at the given positions are word characters\nfunction insideWord(check, state, from, to) {\n return check(state.sliceDoc(from, from + 1)) == CharCategory.Word\n && check(state.sliceDoc(to - 1, to)) == CharCategory.Word;\n}\nconst matchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.decorations = this.getDeco(view);\n }\n update(update) {\n if (update.selectionSet || update.docChanged || update.viewportChanged)\n this.decorations = this.getDeco(update.view);\n }\n getDeco(view) {\n let conf = view.state.facet(highlightConfig);\n let { state } = view, sel = state.selection;\n if (sel.ranges.length > 1)\n return Decoration.none;\n let range = sel.main, query, check = null;\n if (range.empty) {\n if (!conf.highlightWordAroundCursor)\n return Decoration.none;\n let word = state.wordAt(range.head);\n if (!word)\n return Decoration.none;\n check = state.charCategorizer(range.head);\n query = state.sliceDoc(word.from, word.to);\n }\n else {\n let len = range.to - range.from;\n if (len < conf.minSelectionLength || len > 200)\n return Decoration.none;\n if (conf.wholeWords) {\n query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?\n check = state.charCategorizer(range.head);\n if (!(insideWordBoundaries(check, state, range.from, range.to)\n && insideWord(check, state, range.from, range.to)))\n return Decoration.none;\n }\n else {\n query = state.sliceDoc(range.from, range.to).trim();\n if (!query)\n return Decoration.none;\n }\n }\n let deco = [];\n for (let part of view.visibleRanges) {\n let cursor = new SearchCursor(state.doc, query, part.from, part.to);\n while (!cursor.next().done) {\n let { from, to } = cursor.value;\n if (!check || insideWordBoundaries(check, state, from, to)) {\n if (range.empty && from <= range.from && to >= range.to)\n deco.push(mainMatchDeco.range(from, to));\n else if (from >= range.to || to <= range.from)\n deco.push(matchDeco.range(from, to));\n if (deco.length > conf.maxMatches)\n return Decoration.none;\n }\n }\n }\n return Decoration.set(deco);\n }\n}, {\n decorations: v => v.decorations\n});\nconst defaultTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-selectionMatch\": { backgroundColor: \"#99ff7780\" },\n \".cm-searchMatch .cm-selectionMatch\": { backgroundColor: \"transparent\" }\n});\n// Select the words around the cursors.\nconst selectWord = ({ state, dispatch }) => {\n let { selection } = state;\n let newSel = EditorSelection.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection.cursor(range.head)), selection.mainIndex);\n if (newSel.eq(selection))\n return false;\n dispatch(state.update({ selection: newSel }));\n return true;\n};\n// Find next occurrence of query relative to last cursor. Wrap around\n// the document if there are no more matches.\nfunction findNextOccurrence(state, query) {\n let { main, ranges } = state.selection;\n let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;\n for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {\n cursor.next();\n if (cursor.done) {\n if (cycled)\n return null;\n cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));\n cycled = true;\n }\n else {\n if (cycled && ranges.some(r => r.from == cursor.value.from))\n continue;\n if (fullWord) {\n let word = state.wordAt(cursor.value.from);\n if (!word || word.from != cursor.value.from || word.to != cursor.value.to)\n continue;\n }\n return cursor.value;\n }\n }\n}\n/**\nSelect next occurrence of the current selection. Expand selection\nto the surrounding word when the selection is empty.\n*/\nconst selectNextOccurrence = ({ state, dispatch }) => {\n let { ranges } = state.selection;\n if (ranges.some(sel => sel.from === sel.to))\n return selectWord({ state, dispatch });\n let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);\n if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText))\n return false;\n let range = findNextOccurrence(state, searchedText);\n if (!range)\n return false;\n dispatch(state.update({\n selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),\n effects: EditorView.scrollIntoView(range.to)\n }));\n return true;\n};\n\nconst searchConfigFacet = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n top: false,\n caseSensitive: false,\n literal: false,\n regexp: false,\n wholeWord: false,\n createPanel: view => new SearchPanel(view),\n scrollToMatch: range => EditorView.scrollIntoView(range)\n });\n }\n});\n/**\nAdd search state to the editor configuration, and optionally\nconfigure the search extension.\n([`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) will automatically\nenable this if it isn't already on).\n*/\nfunction search(config) {\n return config ? [searchConfigFacet.of(config), searchExtensions] : searchExtensions;\n}\n/**\nA search query. Part of the editor's search state.\n*/\nclass SearchQuery {\n /**\n Create a query object.\n */\n constructor(config) {\n this.search = config.search;\n this.caseSensitive = !!config.caseSensitive;\n this.literal = !!config.literal;\n this.regexp = !!config.regexp;\n this.replace = config.replace || \"\";\n this.valid = !!this.search && (!this.regexp || validRegExp(this.search));\n this.unquoted = this.unquote(this.search);\n this.wholeWord = !!config.wholeWord;\n }\n /**\n @internal\n */\n unquote(text) {\n return this.literal ? text :\n text.replace(/\\\\([nrt\\\\])/g, (_, ch) => ch == \"n\" ? \"\\n\" : ch == \"r\" ? \"\\r\" : ch == \"t\" ? \"\\t\" : \"\\\\\");\n }\n /**\n Compare this query to another query.\n */\n eq(other) {\n return this.search == other.search && this.replace == other.replace &&\n this.caseSensitive == other.caseSensitive && this.regexp == other.regexp &&\n this.wholeWord == other.wholeWord;\n }\n /**\n @internal\n */\n create() {\n return this.regexp ? new RegExpQuery(this) : new StringQuery(this);\n }\n /**\n Get a search cursor for this query, searching through the given\n range in the given state.\n */\n getCursor(state, from = 0, to) {\n let st = state.doc ? state : EditorState.create({ doc: state });\n if (to == null)\n to = st.doc.length;\n return this.regexp ? regexpCursor(this, st, from, to) : stringCursor(this, st, from, to);\n }\n}\nclass QueryType {\n constructor(spec) {\n this.spec = spec;\n }\n}\nfunction stringCursor(spec, state, from, to) {\n return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);\n}\nfunction stringWordTest(doc, categorizer) {\n return (from, to, buf, bufPos) => {\n if (bufPos > from || bufPos + buf.length < to) {\n bufPos = Math.max(0, from - 2);\n buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));\n }\n return (categorizer(charBefore(buf, from - bufPos)) != CharCategory.Word ||\n categorizer(charAfter(buf, from - bufPos)) != CharCategory.Word) &&\n (categorizer(charAfter(buf, to - bufPos)) != CharCategory.Word ||\n categorizer(charBefore(buf, to - bufPos)) != CharCategory.Word);\n };\n}\nclass StringQuery extends QueryType {\n constructor(spec) {\n super(spec);\n }\n nextMatch(state, curFrom, curTo) {\n let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();\n if (cursor.done)\n cursor = stringCursor(this.spec, state, 0, curFrom).nextOverlapping();\n return cursor.done ? null : cursor.value;\n }\n // Searching in reverse is, rather than implementing an inverted search\n // cursor, done by scanning chunk after chunk forward.\n prevMatchInRange(state, from, to) {\n for (let pos = to;;) {\n let start = Math.max(from, pos - 10000 /* FindPrev.ChunkSize */ - this.spec.unquoted.length);\n let cursor = stringCursor(this.spec, state, start, pos), range = null;\n while (!cursor.nextOverlapping().done)\n range = cursor.value;\n if (range)\n return range;\n if (start == from)\n return null;\n pos -= 10000 /* FindPrev.ChunkSize */;\n }\n }\n prevMatch(state, curFrom, curTo) {\n return this.prevMatchInRange(state, 0, curFrom) ||\n this.prevMatchInRange(state, curTo, state.doc.length);\n }\n getReplacement(_result) { return this.spec.unquote(this.spec.replace); }\n matchAll(state, limit) {\n let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];\n while (!cursor.next().done) {\n if (ranges.length >= limit)\n return null;\n ranges.push(cursor.value);\n }\n return ranges;\n }\n highlight(state, from, to, add) {\n let cursor = stringCursor(this.spec, state, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, state.doc.length));\n while (!cursor.next().done)\n add(cursor.value.from, cursor.value.to);\n }\n}\nfunction regexpCursor(spec, state, from, to) {\n return new RegExpCursor(state.doc, spec.search, {\n ignoreCase: !spec.caseSensitive,\n test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined\n }, from, to);\n}\nfunction charBefore(str, index) {\n return str.slice(findClusterBreak(str, index, false), index);\n}\nfunction charAfter(str, index) {\n return str.slice(index, findClusterBreak(str, index));\n}\nfunction regexpWordTest(categorizer) {\n return (_from, _to, match) => !match[0].length ||\n (categorizer(charBefore(match.input, match.index)) != CharCategory.Word ||\n categorizer(charAfter(match.input, match.index)) != CharCategory.Word) &&\n (categorizer(charAfter(match.input, match.index + match[0].length)) != CharCategory.Word ||\n categorizer(charBefore(match.input, match.index + match[0].length)) != CharCategory.Word);\n}\nclass RegExpQuery extends QueryType {\n nextMatch(state, curFrom, curTo) {\n let cursor = regexpCursor(this.spec, state, curTo, state.doc.length).next();\n if (cursor.done)\n cursor = regexpCursor(this.spec, state, 0, curFrom).next();\n return cursor.done ? null : cursor.value;\n }\n prevMatchInRange(state, from, to) {\n for (let size = 1;; size++) {\n let start = Math.max(from, to - size * 10000 /* FindPrev.ChunkSize */);\n let cursor = regexpCursor(this.spec, state, start, to), range = null;\n while (!cursor.next().done)\n range = cursor.value;\n if (range && (start == from || range.from > start + 10))\n return range;\n if (start == from)\n return null;\n }\n }\n prevMatch(state, curFrom, curTo) {\n return this.prevMatchInRange(state, 0, curFrom) ||\n this.prevMatchInRange(state, curTo, state.doc.length);\n }\n getReplacement(result) {\n return this.spec.unquote(this.spec.replace.replace(/\\$([$&\\d+])/g, (m, i) => i == \"$\" ? \"$\"\n : i == \"&\" ? result.match[0]\n : i != \"0\" && +i < result.match.length ? result.match[i]\n : m));\n }\n matchAll(state, limit) {\n let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];\n while (!cursor.next().done) {\n if (ranges.length >= limit)\n return null;\n ranges.push(cursor.value);\n }\n return ranges;\n }\n highlight(state, from, to, add) {\n let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250 /* RegExp.HighlightMargin */), Math.min(to + 250 /* RegExp.HighlightMargin */, state.doc.length));\n while (!cursor.next().done)\n add(cursor.value.from, cursor.value.to);\n }\n}\n/**\nA state effect that updates the current search query. Note that\nthis only has an effect if the search state has been initialized\n(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or\nby running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least\nonce).\n*/\nconst setSearchQuery = /*@__PURE__*/StateEffect.define();\nconst togglePanel = /*@__PURE__*/StateEffect.define();\nconst searchState = /*@__PURE__*/StateField.define({\n create(state) {\n return new SearchState(defaultQuery(state).create(), null);\n },\n update(value, tr) {\n for (let effect of tr.effects) {\n if (effect.is(setSearchQuery))\n value = new SearchState(effect.value.create(), value.panel);\n else if (effect.is(togglePanel))\n value = new SearchState(value.query, effect.value ? createSearchPanel : null);\n }\n return value;\n },\n provide: f => showPanel.from(f, val => val.panel)\n});\n/**\nGet the current search query from an editor state.\n*/\nfunction getSearchQuery(state) {\n let curState = state.field(searchState, false);\n return curState ? curState.query.spec : defaultQuery(state);\n}\n/**\nQuery whether the search panel is open in the given editor state.\n*/\nfunction searchPanelOpen(state) {\n var _a;\n return ((_a = state.field(searchState, false)) === null || _a === void 0 ? void 0 : _a.panel) != null;\n}\nclass SearchState {\n constructor(query, panel) {\n this.query = query;\n this.panel = panel;\n }\n}\nconst matchMark = /*@__PURE__*/Decoration.mark({ class: \"cm-searchMatch\" }), selectedMatchMark = /*@__PURE__*/Decoration.mark({ class: \"cm-searchMatch cm-searchMatch-selected\" });\nconst searchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.decorations = this.highlight(view.state.field(searchState));\n }\n update(update) {\n let state = update.state.field(searchState);\n if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged)\n this.decorations = this.highlight(state);\n }\n highlight({ query, panel }) {\n if (!panel || !query.spec.valid)\n return Decoration.none;\n let { view } = this;\n let builder = new RangeSetBuilder();\n for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {\n let { from, to } = ranges[i];\n while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* RegExp.HighlightMargin */)\n to = ranges[++i].to;\n query.highlight(view.state, from, to, (from, to) => {\n let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);\n builder.add(from, to, selected ? selectedMatchMark : matchMark);\n });\n }\n return builder.finish();\n }\n}, {\n decorations: v => v.decorations\n});\nfunction searchCommand(f) {\n return view => {\n let state = view.state.field(searchState, false);\n return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);\n };\n}\n/**\nOpen the search panel if it isn't already open, and move the\nselection to the first match after the current main selection.\nWill wrap around to the start of the document when it reaches the\nend.\n*/\nconst findNext = /*@__PURE__*/searchCommand((view, { query }) => {\n let { to } = view.state.selection.main;\n let next = query.nextMatch(view.state, to, to);\n if (!next)\n return false;\n let selection = EditorSelection.single(next.from, next.to);\n let config = view.state.facet(searchConfigFacet);\n view.dispatch({\n selection,\n effects: [announceMatch(view, next), config.scrollToMatch(selection.main, view)],\n userEvent: \"select.search\"\n });\n selectSearchInput(view);\n return true;\n});\n/**\nMove the selection to the previous instance of the search query,\nbefore the current main selection. Will wrap past the start\nof the document to start searching at the end again.\n*/\nconst findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {\n let { state } = view, { from } = state.selection.main;\n let prev = query.prevMatch(state, from, from);\n if (!prev)\n return false;\n let selection = EditorSelection.single(prev.from, prev.to);\n let config = view.state.facet(searchConfigFacet);\n view.dispatch({\n selection,\n effects: [announceMatch(view, prev), config.scrollToMatch(selection.main, view)],\n userEvent: \"select.search\"\n });\n selectSearchInput(view);\n return true;\n});\n/**\nSelect all instances of the search query.\n*/\nconst selectMatches = /*@__PURE__*/searchCommand((view, { query }) => {\n let ranges = query.matchAll(view.state, 1000);\n if (!ranges || !ranges.length)\n return false;\n view.dispatch({\n selection: EditorSelection.create(ranges.map(r => EditorSelection.range(r.from, r.to))),\n userEvent: \"select.search.matches\"\n });\n return true;\n});\n/**\nSelect all instances of the currently selected text.\n*/\nconst selectSelectionMatches = ({ state, dispatch }) => {\n let sel = state.selection;\n if (sel.ranges.length > 1 || sel.main.empty)\n return false;\n let { from, to } = sel.main;\n let ranges = [], main = 0;\n for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {\n if (ranges.length > 1000)\n return false;\n if (cur.value.from == from)\n main = ranges.length;\n ranges.push(EditorSelection.range(cur.value.from, cur.value.to));\n }\n dispatch(state.update({\n selection: EditorSelection.create(ranges, main),\n userEvent: \"select.search.matches\"\n }));\n return true;\n};\n/**\nReplace the current match of the search query.\n*/\nconst replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {\n let { state } = view, { from, to } = state.selection.main;\n if (state.readOnly)\n return false;\n let next = query.nextMatch(state, from, from);\n if (!next)\n return false;\n let changes = [], selection, replacement;\n let effects = [];\n if (next.from == from && next.to == to) {\n replacement = state.toText(query.getReplacement(next));\n changes.push({ from: next.from, to: next.to, insert: replacement });\n next = query.nextMatch(state, next.from, next.to);\n effects.push(EditorView.announce.of(state.phrase(\"replaced match on line $\", state.doc.lineAt(from).number) + \".\"));\n }\n if (next) {\n let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;\n selection = EditorSelection.single(next.from - off, next.to - off);\n effects.push(announceMatch(view, next));\n effects.push(state.facet(searchConfigFacet).scrollToMatch(selection.main, view));\n }\n view.dispatch({\n changes, selection, effects,\n userEvent: \"input.replace\"\n });\n return true;\n});\n/**\nReplace all instances of the search query with the given\nreplacement.\n*/\nconst replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {\n if (view.state.readOnly)\n return false;\n let changes = query.matchAll(view.state, 1e9).map(match => {\n let { from, to } = match;\n return { from, to, insert: query.getReplacement(match) };\n });\n if (!changes.length)\n return false;\n let announceText = view.state.phrase(\"replaced $ matches\", changes.length) + \".\";\n view.dispatch({\n changes,\n effects: EditorView.announce.of(announceText),\n userEvent: \"input.replace.all\"\n });\n return true;\n});\nfunction createSearchPanel(view) {\n return view.state.facet(searchConfigFacet).createPanel(view);\n}\nfunction defaultQuery(state, fallback) {\n var _a, _b, _c, _d, _e;\n let sel = state.selection.main;\n let selText = sel.empty || sel.to > sel.from + 100 ? \"\" : state.sliceDoc(sel.from, sel.to);\n if (fallback && !selText)\n return fallback;\n let config = state.facet(searchConfigFacet);\n return new SearchQuery({\n search: ((_a = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _a !== void 0 ? _a : config.literal) ? selText : selText.replace(/\\n/g, \"\\\\n\"),\n caseSensitive: (_b = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _b !== void 0 ? _b : config.caseSensitive,\n literal: (_c = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _c !== void 0 ? _c : config.literal,\n regexp: (_d = fallback === null || fallback === void 0 ? void 0 : fallback.regexp) !== null && _d !== void 0 ? _d : config.regexp,\n wholeWord: (_e = fallback === null || fallback === void 0 ? void 0 : fallback.wholeWord) !== null && _e !== void 0 ? _e : config.wholeWord\n });\n}\nfunction getSearchInput(view) {\n let panel = getPanel(view, createSearchPanel);\n return panel && panel.dom.querySelector(\"[main-field]\");\n}\nfunction selectSearchInput(view) {\n let input = getSearchInput(view);\n if (input && input == view.root.activeElement)\n input.select();\n}\n/**\nMake sure the search panel is open and focused.\n*/\nconst openSearchPanel = view => {\n let state = view.state.field(searchState, false);\n if (state && state.panel) {\n let searchInput = getSearchInput(view);\n if (searchInput && searchInput != view.root.activeElement) {\n let query = defaultQuery(view.state, state.query.spec);\n if (query.valid)\n view.dispatch({ effects: setSearchQuery.of(query) });\n searchInput.focus();\n searchInput.select();\n }\n }\n else {\n view.dispatch({ effects: [\n togglePanel.of(true),\n state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect.appendConfig.of(searchExtensions)\n ] });\n }\n return true;\n};\n/**\nClose the search panel.\n*/\nconst closeSearchPanel = view => {\n let state = view.state.field(searchState, false);\n if (!state || !state.panel)\n return false;\n let panel = getPanel(view, createSearchPanel);\n if (panel && panel.dom.contains(view.root.activeElement))\n view.focus();\n view.dispatch({ effects: togglePanel.of(false) });\n return true;\n};\n/**\nDefault search-related key bindings.\n\n - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)\n - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)\n - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)\n - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)\n - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)\n*/\nconst searchKeymap = [\n { key: \"Mod-f\", run: openSearchPanel, scope: \"editor search-panel\" },\n { key: \"F3\", run: findNext, shift: findPrevious, scope: \"editor search-panel\", preventDefault: true },\n { key: \"Mod-g\", run: findNext, shift: findPrevious, scope: \"editor search-panel\", preventDefault: true },\n { key: \"Escape\", run: closeSearchPanel, scope: \"editor search-panel\" },\n { key: \"Mod-Shift-l\", run: selectSelectionMatches },\n { key: \"Alt-g\", run: gotoLine },\n { key: \"Mod-d\", run: selectNextOccurrence, preventDefault: true },\n];\nclass SearchPanel {\n constructor(view) {\n this.view = view;\n let query = this.query = view.state.field(searchState).query.spec;\n this.commit = this.commit.bind(this);\n this.searchField = elt(\"input\", {\n value: query.search,\n placeholder: phrase(view, \"Find\"),\n \"aria-label\": phrase(view, \"Find\"),\n class: \"cm-textfield\",\n name: \"search\",\n form: \"\",\n \"main-field\": \"true\",\n onchange: this.commit,\n onkeyup: this.commit\n });\n this.replaceField = elt(\"input\", {\n value: query.replace,\n placeholder: phrase(view, \"Replace\"),\n \"aria-label\": phrase(view, \"Replace\"),\n class: \"cm-textfield\",\n name: \"replace\",\n form: \"\",\n onchange: this.commit,\n onkeyup: this.commit\n });\n this.caseField = elt(\"input\", {\n type: \"checkbox\",\n name: \"case\",\n form: \"\",\n checked: query.caseSensitive,\n onchange: this.commit\n });\n this.reField = elt(\"input\", {\n type: \"checkbox\",\n name: \"re\",\n form: \"\",\n checked: query.regexp,\n onchange: this.commit\n });\n this.wordField = elt(\"input\", {\n type: \"checkbox\",\n name: \"word\",\n form: \"\",\n checked: query.wholeWord,\n onchange: this.commit\n });\n function button(name, onclick, content) {\n return elt(\"button\", { class: \"cm-button\", name, onclick, type: \"button\" }, content);\n }\n this.dom = elt(\"div\", { onkeydown: (e) => this.keydown(e), class: \"cm-search\" }, [\n this.searchField,\n button(\"next\", () => findNext(view), [phrase(view, \"next\")]),\n button(\"prev\", () => findPrevious(view), [phrase(view, \"previous\")]),\n button(\"select\", () => selectMatches(view), [phrase(view, \"all\")]),\n elt(\"label\", null, [this.caseField, phrase(view, \"match case\")]),\n elt(\"label\", null, [this.reField, phrase(view, \"regexp\")]),\n elt(\"label\", null, [this.wordField, phrase(view, \"by word\")]),\n ...view.state.readOnly ? [] : [\n elt(\"br\"),\n this.replaceField,\n button(\"replace\", () => replaceNext(view), [phrase(view, \"replace\")]),\n button(\"replaceAll\", () => replaceAll(view), [phrase(view, \"replace all\")])\n ],\n elt(\"button\", {\n name: \"close\",\n onclick: () => closeSearchPanel(view),\n \"aria-label\": phrase(view, \"close\"),\n type: \"button\"\n }, [\"×\"])\n ]);\n }\n commit() {\n let query = new SearchQuery({\n search: this.searchField.value,\n caseSensitive: this.caseField.checked,\n regexp: this.reField.checked,\n wholeWord: this.wordField.checked,\n replace: this.replaceField.value,\n });\n if (!query.eq(this.query)) {\n this.query = query;\n this.view.dispatch({ effects: setSearchQuery.of(query) });\n }\n }\n keydown(e) {\n if (runScopeHandlers(this.view, e, \"search-panel\")) {\n e.preventDefault();\n }\n else if (e.keyCode == 13 && e.target == this.searchField) {\n e.preventDefault();\n (e.shiftKey ? findPrevious : findNext)(this.view);\n }\n else if (e.keyCode == 13 && e.target == this.replaceField) {\n e.preventDefault();\n replaceNext(this.view);\n }\n }\n update(update) {\n for (let tr of update.transactions)\n for (let effect of tr.effects) {\n if (effect.is(setSearchQuery) && !effect.value.eq(this.query))\n this.setQuery(effect.value);\n }\n }\n setQuery(query) {\n this.query = query;\n this.searchField.value = query.search;\n this.replaceField.value = query.replace;\n this.caseField.checked = query.caseSensitive;\n this.reField.checked = query.regexp;\n this.wordField.checked = query.wholeWord;\n }\n mount() {\n this.searchField.select();\n }\n get pos() { return 80; }\n get top() { return this.view.state.facet(searchConfigFacet).top; }\n}\nfunction phrase(view, phrase) { return view.state.phrase(phrase); }\nconst AnnounceMargin = 30;\nconst Break = /[\\s\\.,:;?!]/;\nfunction announceMatch(view, { from, to }) {\n let line = view.state.doc.lineAt(from), lineEnd = view.state.doc.lineAt(to).to;\n let start = Math.max(line.from, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);\n let text = view.state.sliceDoc(start, end);\n if (start != line.from) {\n for (let i = 0; i < AnnounceMargin; i++)\n if (!Break.test(text[i + 1]) && Break.test(text[i])) {\n text = text.slice(i);\n break;\n }\n }\n if (end != lineEnd) {\n for (let i = text.length - 1; i > text.length - AnnounceMargin; i--)\n if (!Break.test(text[i - 1]) && Break.test(text[i])) {\n text = text.slice(0, i);\n break;\n }\n }\n return EditorView.announce.of(`${view.state.phrase(\"current match\")}. ${text} ${view.state.phrase(\"on line\")} ${line.number}.`);\n}\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-panel.cm-search\": {\n padding: \"2px 6px 4px\",\n position: \"relative\",\n \"& [name=close]\": {\n position: \"absolute\",\n top: \"0\",\n right: \"4px\",\n backgroundColor: \"inherit\",\n border: \"none\",\n font: \"inherit\",\n padding: 0,\n margin: 0\n },\n \"& input, & button, & label\": {\n margin: \".2em .6em .2em 0\"\n },\n \"& input[type=checkbox]\": {\n marginRight: \".2em\"\n },\n \"& label\": {\n fontSize: \"80%\",\n whiteSpace: \"pre\"\n }\n },\n \"&light .cm-searchMatch\": { backgroundColor: \"#ffff0054\" },\n \"&dark .cm-searchMatch\": { backgroundColor: \"#00ffff8a\" },\n \"&light .cm-searchMatch-selected\": { backgroundColor: \"#ff6a0054\" },\n \"&dark .cm-searchMatch-selected\": { backgroundColor: \"#ff00ff8a\" }\n});\nconst searchExtensions = [\n searchState,\n /*@__PURE__*/Prec.low(searchHighlighter),\n baseTheme\n];\n\nexport { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };\n","import CodeMirror from './codemirror';\nimport { EditorState, EditorSelection, Extension } from '@codemirror/state';\nimport { EditorView, drawSelection, keymap } from '@codemirror/view';\nimport { defaultKeymap, history, historyKeymap } from '@codemirror/commands';\nimport { searchKeymap } from '@codemirror/search';\nimport { bracketMatching } from '@codemirror/language';\n\n// Necessary so that `require` doesn't get mangled into `__webpack_require__`,\n// which ResourceLoader won't recognize and thus be unable to load the virtual file.\n// See https://webpack-v3.jsx.app/api/module-variables/#__non_webpack_require__-webpack-specific-\n__non_webpack_require__( '../ext.CodeMirror.data.js' );\n\n/**\n * @class CodeMirrorWikiEditor\n */\nexport default class CodeMirrorWikiEditor extends CodeMirror {\n\tconstructor( $textarea, langExtension ) {\n\t\tsuper( $textarea );\n\t\tthis.langExtension = langExtension;\n\t\tthis.editRecoveryHandler = null;\n\t\tthis.useCodeMirror = mw.user.options.get( 'usecodemirror' ) > 0;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tsetCodeMirrorPreference( prefValue ) {\n\t\tthis.useCodeMirror = prefValue; // Save state for function updateToolbarButton()\n\t\tsuper.setCodeMirrorPreference( prefValue );\n\t}\n\n\t/**\n\t * Replaces the default textarea with CodeMirror\n\t */\n\tenableCodeMirror() {\n\t\t// If CodeMirror is already loaded, abort.\n\t\tif ( this.view ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst selectionStart = this.$textarea.prop( 'selectionStart' ),\n\t\t\tselectionEnd = this.$textarea.prop( 'selectionEnd' ),\n\t\t\tscrollTop = this.$textarea.scrollTop(),\n\t\t\thasFocus = this.$textarea.is( ':focus' );\n\n\t\t/*\n\t\t * Default configuration, which we may conditionally add to later.\n\t\t * @see https://codemirror.net/docs/ref/#state.Extension\n\t\t */\n\t\tconst extensions = [\n\t\t\t...this.defaultExtensions,\n\t\t\tthis.langExtension,\n\t\t\tbracketMatching(),\n\t\t\thistory(),\n\t\t\t// See also the default attributes at contentAttributesExtension() in the parent class.\n\t\t\tEditorView.contentAttributes.of( {\n\t\t\t\tspellcheck: 'true'\n\t\t\t} ),\n\t\t\tEditorView.domEventHandlers( {\n\t\t\t\tblur: () => this.$textarea.triggerHandler( 'blur' ),\n\t\t\t\tfocus: () => this.$textarea.triggerHandler( 'focus' )\n\t\t\t} ),\n\t\t\tEditorView.updateListener.of( ( update ) => {\n\t\t\t\tif ( update.docChanged && typeof this.editRecoveryHandler === 'function' ) {\n\t\t\t\t\tthis.editRecoveryHandler();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\tEditorView.lineWrapping,\n\t\t\tEditorState.allowMultipleSelections.of( true ),\n\t\t\tdrawSelection(),\n\t\t\tkeymap.of( [\n\t\t\t\t...defaultKeymap,\n\t\t\t\t...searchKeymap,\n\t\t\t\t...historyKeymap\n\t\t\t] )\n\t\t];\n\n\t\tmw.hook( 'editRecovery.loadEnd' ).add( ( data ) => {\n\t\t\tthis.editRecoveryHandler = data.fieldChangeHandler;\n\t\t} );\n\n\t\tthis.initialize( extensions );\n\n\t\t// Sync scroll position, selections, and focus state.\n\t\trequestAnimationFrame( () => {\n\t\t\tthis.view.scrollDOM.scrollTop = scrollTop;\n\t\t} );\n\t\tif ( selectionStart !== 0 || selectionEnd !== 0 ) {\n\t\t\tconst range = EditorSelection.range( selectionStart, selectionEnd ),\n\t\t\t\tscrollEffect = EditorView.scrollIntoView( range );\n\t\t\tscrollEffect.value.isSnapshot = true;\n\t\t\tthis.view.dispatch( {\n\t\t\t\tselection: EditorSelection.create( [ range ] ),\n\t\t\t\teffects: scrollEffect\n\t\t\t} );\n\t\t}\n\t\tif ( hasFocus ) {\n\t\t\tthis.view.focus();\n\t\t}\n\n\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( true, $( this.view.dom ) );\n\t}\n\n\t/**\n\t * @inheritDoc\n\t *\n\t * Realtime Preview's ResizingDragBar makes the editor resizable,\n\t * so we need to set the height to 100%.\n\t *\n\t * @return {Extension}\n\t */\n\tget heightExtension() {\n\t\tif ( mw.loader.getState( 'ext.wikiEditor.realtimepreview' ) === 'ready' ) {\n\t\t\treturn EditorView.theme( {\n\t\t\t\t'&': { height: '100%' }\n\t\t\t} );\n\t\t}\n\t\treturn super.heightExtension;\n\t}\n\n\t/**\n\t * Adds the CodeMirror button to WikiEditor\n\t */\n\taddCodeMirrorToWikiEditor() {\n\t\tconst context = this.$textarea.data( 'wikiEditor-context' );\n\t\tconst toolbar = context && context.modules && context.modules.toolbar;\n\n\t\t// Guard against something having removed WikiEditor (T271457)\n\t\tif ( !toolbar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.$textarea.wikiEditor(\n\t\t\t'addToToolbar',\n\t\t\t{\n\t\t\t\tsection: 'main',\n\t\t\t\tgroups: {\n\t\t\t\t\tcodemirror: {\n\t\t\t\t\t\ttools: {\n\t\t\t\t\t\t\tCodeMirror: {\n\t\t\t\t\t\t\t\tlabel: mw.msg( 'codemirror-toggle-label' ),\n\t\t\t\t\t\t\t\ttype: 'toggle',\n\t\t\t\t\t\t\t\toouiIcon: 'highlight',\n\t\t\t\t\t\t\t\taction: {\n\t\t\t\t\t\t\t\t\ttype: 'callback',\n\t\t\t\t\t\t\t\t\texecute: () => this.switchCodeMirror()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tconst $codeMirrorButton = toolbar.$toolbar.find( '.tool[rel=CodeMirror]' );\n\t\t$codeMirrorButton\n\t\t\t.attr( 'id', 'mw-editbutton-codemirror' );\n\n\t\tif ( this.useCodeMirror ) {\n\t\t\tthis.enableCodeMirror();\n\t\t}\n\t\tthis.updateToolbarButton();\n\n\t\tthis.logUsage( {\n\t\t\teditor: 'wikitext',\n\t\t\tenabled: this.useCodeMirror,\n\t\t\ttoggled: false,\n\t\t\t// eslint-disable-next-line no-jquery/no-global-selector,camelcase\n\t\t\tedit_start_ts_ms: parseInt( $( 'input[name=\"wpStarttime\"]' ).val(), 10 ) * 1000 || 0\n\t\t} );\n\t}\n\n\t/**\n\t * Updates CodeMirror button on the toolbar according to the current state (on/off)\n\t */\n\tupdateToolbarButton() {\n\t\t// eslint-disable-next-line no-jquery/no-global-selector\n\t\tconst $button = $( '#mw-editbutton-codemirror' );\n\t\t$button.toggleClass( 'mw-editbutton-codemirror-active', this.useCodeMirror );\n\n\t\t// WikiEditor2010 OOUI ToggleButtonWidget\n\t\tif ( $button.data( 'setActive' ) ) {\n\t\t\t$button.data( 'setActive' )( this.useCodeMirror );\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables CodeMirror\n\t */\n\tswitchCodeMirror() {\n\t\tif ( this.view ) {\n\t\t\tthis.setCodeMirrorPreference( false );\n\t\t\tconst scrollTop = this.view.scrollDOM.scrollTop;\n\t\t\tconst hasFocus = this.view.hasFocus;\n\t\t\tconst { from, to } = this.view.state.selection.ranges[ 0 ];\n\t\t\t$( this.view.dom ).textSelection( 'unregister' );\n\t\t\tthis.$textarea.textSelection( 'unregister' );\n\t\t\tthis.$textarea.val( this.view.state.doc.toString() );\n\t\t\tthis.view.destroy();\n\t\t\tthis.view = null;\n\t\t\tthis.$textarea.show();\n\t\t\tif ( hasFocus ) {\n\t\t\t\tthis.$textarea.trigger( 'focus' );\n\t\t\t}\n\t\t\tthis.$textarea.prop( 'selectionStart', Math.min( from, to ) )\n\t\t\t\t.prop( 'selectionEnd', Math.max( to, from ) );\n\t\t\tthis.$textarea.scrollTop( scrollTop );\n\t\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( false, this.$textarea );\n\t\t} else {\n\t\t\tthis.enableCodeMirror();\n\t\t\tthis.setCodeMirrorPreference( true );\n\t\t}\n\t\tthis.updateToolbarButton();\n\n\t\tthis.logUsage( {\n\t\t\teditor: 'wikitext',\n\t\t\tenabled: this.useCodeMirror,\n\t\t\ttoggled: true,\n\t\t\t// eslint-disable-next-line no-jquery/no-global-selector,camelcase\n\t\t\tedit_start_ts_ms: parseInt( $( 'input[name=\"wpStarttime\"]' ).val(), 10 ) * 1000 || 0\n\t\t} );\n\t}\n}\n","import { Tag, tags } from '@lezer/highlight';\nimport { TagStyle, StreamParser } from '@codemirror/language';\n\n/**\n * Configuration for the MediaWiki highlighting mode for CodeMirror.\n * This is a separate class mainly to keep static configuration out of\n * the logic in CodeMirrorModeMediaWiki.\n *\n * @class CodeMirrorModeMediaWikiConfig\n */\nclass CodeMirrorModeMediaWikiConfig {\n\n\tconstructor() {\n\t\tthis.extHighlightStyles = [];\n\t\tthis.tokenTable = this.defaultTokenTable;\n\t}\n\n\t/**\n\t * Register a token for the given tag in CodeMirror. The generated CSS class will be of\n\t * the form 'cm-mw-ext-tagname'. This is for internal use to dynamically register tags\n\t * from other MediaWiki extensions.\n\t *\n\t * @see https://www.mediawiki.org/wiki/Extension:CodeMirror#Extension_integration\n\t * @param {string} tag\n\t * @param {Tag} [parent]\n\t * @internal\n\t */\n\taddTag( tag, parent = null ) {\n\t\tif ( this.tokenTable[ `mw-tag-${ tag }` ] ) {\n\t\t\treturn;\n\t\t}\n\t\tthis.addToken( `mw-tag-${ tag }`, parent );\n\t\tthis.addToken( `mw-ext-${ tag }`, parent );\n\t}\n\n\t/**\n\t * Dynamically register a token in CodeMirror.\n\t * This is solely for use by this.addTag() and CodeMirrorModeMediaWiki.makeLocalStyle().\n\t *\n\t * @param {string} token\n\t * @param {Tag} [parent]\n\t * @internal\n\t */\n\taddToken( token, parent = null ) {\n\t\tif ( this.tokenTable[ token ] ) {\n\t\t\treturn;\n\t\t}\n\t\tthis.tokenTable[ token ] = Tag.define( parent );\n\t\tthis.extHighlightStyles.push( {\n\t\t\ttag: this.tokenTable[ token ],\n\t\t\tclass: `cm-${ token }`\n\t\t} );\n\t}\n\n\t/**\n\t * All HTML/XML tags permitted in MediaWiki Core.\n\t *\n\t * Extensions should use the CodeMirrorTagModes extension attribute to register tags\n\t * instead of adding them here.\n\t *\n\t * @see https://www.mediawiki.org/wiki/Extension:CodeMirror#Extension_integration\n\t * @return {Object}\n\t */\n\tget permittedHtmlTags() {\n\t\treturn {\n\t\t\tb: true, bdi: true, del: true, i: true, ins: true,\n\t\t\tu: true, font: true, big: true, small: true, sub: true, sup: true,\n\t\t\th1: true, h2: true, h3: true, h4: true, h5: true, h6: true, cite: true,\n\t\t\tcode: true, em: true, s: true, strike: true, strong: true, tt: true,\n\t\t\tvar: true, div: true, center: true, blockquote: true, q: true, ol: true, ul: true,\n\t\t\tdl: true, table: true, caption: true, pre: true, ruby: true, rb: true,\n\t\t\trp: true, rt: true, rtc: true, p: true, span: true, abbr: true, dfn: true,\n\t\t\tkbd: true, samp: true, data: true, time: true, mark: true, br: true,\n\t\t\twbr: true, hr: true, li: true, dt: true, dd: true, td: true, th: true,\n\t\t\ttr: true, noinclude: true, includeonly: true, onlyinclude: true\n\t\t};\n\t}\n\n\t/**\n\t * HTML tags that are only self-closing.\n\t *\n\t * @return {Object}\n\t */\n\tget implicitlyClosedHtmlTags() {\n\t\treturn {\n\t\t\tbr: true, hr: true, wbr: true\n\t\t};\n\t}\n\n\t/**\n\t * Mapping of MediaWiki-esque token identifiers to a standardized lezer highlighting tag.\n\t * Values are one of the default highlighting tags. The idea is to use as many default tags as\n\t * possible so that theming (such as dark mode) can be applied with minimal effort. The\n\t * semantic meaning of the tag may not really match how it is used, but as per CodeMirror docs,\n\t * this is fine. It's still better to make use of the standard tags in some way.\n\t *\n\t * Once we allow use of other themes, we may want to tweak these values for aesthetic reasons.\n\t * The values here can freely be changed. The actual CSS class used is defined further down\n\t * in highlightStyle().\n\t *\n\t * @see https://lezer.codemirror.net/docs/ref/#highlight.tags\n\t * @return {Object<string>}\n\t * @internal\n\t */\n\tget tags() {\n\t\treturn {\n\t\t\tapostrophes: 'character',\n\t\t\tapostrophesBold: 'strong',\n\t\t\tapostrophesItalic: 'emphasis',\n\t\t\tcomment: 'comment',\n\t\t\tdoubleUnderscore: 'controlKeyword',\n\t\t\textLink: 'url',\n\t\t\textLinkBracket: 'modifier',\n\t\t\textLinkProtocol: 'namespace',\n\t\t\textLinkText: 'labelName',\n\t\t\thr: 'contentSeparator',\n\t\t\thtmlTagAttribute: 'attributeName',\n\t\t\thtmlTagBracket: 'angleBracket',\n\t\t\thtmlTagName: 'tagName',\n\t\t\tindenting: 'operatorKeyword',\n\t\t\tlinkBracket: 'squareBracket',\n\t\t\tlinkDelimiter: 'operator',\n\t\t\tlinkText: 'string',\n\t\t\tlinkToSection: 'className',\n\t\t\tlist: 'list',\n\t\t\tparserFunction: 'unit',\n\t\t\tparserFunctionBracket: 'paren',\n\t\t\tparserFunctionDelimiter: 'punctuation',\n\t\t\tparserFunctionName: 'keyword',\n\t\t\tsectionHeader: 'heading',\n\t\t\tsectionHeader1: 'heading1',\n\t\t\tsectionHeader2: 'heading2',\n\t\t\tsectionHeader3: 'heading3',\n\t\t\tsectionHeader4: 'heading4',\n\t\t\tsectionHeader5: 'heading5',\n\t\t\tsectionHeader6: 'heading6',\n\t\t\tsignature: 'quote',\n\t\t\ttableBracket: 'null',\n\t\t\ttableDefinition: 'definitionOperator',\n\t\t\ttableDelimiter: 'typeOperator',\n\t\t\ttemplate: 'attributeValue',\n\t\t\ttemplateArgumentName: 'definitionKeyword',\n\t\t\ttemplateBracket: 'bracket',\n\t\t\ttemplateDelimiter: 'separator',\n\t\t\ttemplateName: 'moduleKeyword',\n\t\t\ttemplateVariable: 'atom',\n\t\t\ttemplateVariableBracket: 'brace',\n\t\t\ttemplateVariableName: 'variableName',\n\t\t\t...this.#customTags\n\t\t};\n\t}\n\n\t/**\n\t * Custom tags. These are not mapped to any standard highlighting tag.\n\t * These are here so that they, like tags(), serve as constants that we can\n\t * reference in CodeMirrorModeMediaWiki.\n\t *\n\t * IMPORTANT: There should be a row in defaultTokenTable() for each of these.\n\t *\n\t * @return {Object<string>}\n\t * @private\n\t */\n\tget #customTags() {\n\t\treturn {\n\t\t\tem: 'mw-em',\n\t\t\terror: 'mw-error',\n\t\t\textNowiki: 'mw-ext-nowiki',\n\t\t\textPre: 'mw-ext-pre',\n\t\t\textTag: 'mw-exttag',\n\t\t\textTagAttribute: 'mw-exttag-attribute',\n\t\t\textTagBracket: 'mw-exttag-bracket',\n\t\t\textTagName: 'mw-exttag-name',\n\t\t\tfreeExtLink: 'mw-free-extlink',\n\t\t\tfreeExtLinkProtocol: 'mw-free-extlink-protocol',\n\t\t\thtmlEntity: 'mw-html-entity',\n\t\t\tlink: 'mw-link',\n\t\t\tlinkPageName: 'mw-link-pagename',\n\t\t\tnowiki: 'mw-tag-nowiki',\n\t\t\tpageName: 'mw-pagename',\n\t\t\tpre: 'mw-tag-pre',\n\t\t\tsection: 'mw-section',\n\t\t\tskipFormatting: 'mw-skipformatting',\n\t\t\tstrong: 'mw-strong',\n\t\t\ttableCaption: 'mw-table-caption',\n\t\t\ttemplateVariableDelimiter: 'mw-templatevariable-delimiter'\n\t\t};\n\t}\n\n\t/**\n\t * These are custom tokens (a.k.a. tags) that aren't mapped to any of the standardized tags.\n\t * Make sure these are also defined in #customTags() above.\n\t *\n\t * TODO: pass parent Tags in Tag.define() where appropriate for better theming.\n\t *\n\t * @see https://codemirror.net/docs/ref/#language.StreamParser.tokenTable\n\t * @see https://lezer.codemirror.net/docs/ref/#highlight.Tag%5Edefine\n\t * @return {Object<Tag>}\n\t */\n\tget defaultTokenTable() {\n\t\treturn {\n\t\t\t[ this.tags.em ]: Tag.define(),\n\t\t\t[ this.tags.error ]: Tag.define(),\n\t\t\t[ this.tags.extNowiki ]: Tag.define(),\n\t\t\t[ this.tags.extPre ]: Tag.define(),\n\t\t\t[ this.tags.extTag ]: Tag.define(),\n\t\t\t[ this.tags.extTagAttribute ]: Tag.define(),\n\t\t\t[ this.tags.extTagBracket ]: Tag.define(),\n\t\t\t[ this.tags.extTagName ]: Tag.define(),\n\t\t\t[ this.tags.freeExtLink ]: Tag.define(),\n\t\t\t[ this.tags.freeExtLinkProtocol ]: Tag.define(),\n\t\t\t[ this.tags.htmlEntity ]: Tag.define(),\n\t\t\t[ this.tags.link ]: Tag.define(),\n\t\t\t[ this.tags.linkPageName ]: Tag.define(),\n\t\t\t[ this.tags.nowiki ]: Tag.define(),\n\t\t\t[ this.tags.pageName ]: Tag.define(),\n\t\t\t[ this.tags.pre ]: Tag.define(),\n\t\t\t[ this.tags.section ]: Tag.define(),\n\t\t\t[ this.tags.skipFormatting ]: Tag.define(),\n\t\t\t[ this.tags.strong ]: Tag.define(),\n\t\t\t[ this.tags.tableCaption ]: Tag.define(),\n\t\t\t[ this.tags.templateVariableDelimiter ]: Tag.define()\n\t\t};\n\t}\n\n\t/**\n\t * This defines the actual CSS class assigned to each tag/token.\n\t * Keep this in sync and in the same order as tags().\n\t *\n\t * @see https://codemirror.net/docs/ref/#language.TagStyle\n\t * @param {StreamParser} context\n\t * @return {TagStyle[]}\n\t */\n\tgetTagStyles( context ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.apostrophes ],\n\t\t\t\tclass: 'cm-mw-apostrophes'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.apostrophesBold ],\n\t\t\t\tclass: 'cm-mw-apostrophes-bold'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.apostrophesItalic ],\n\t\t\t\tclass: 'cm-mw-apostrophes-italic'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.comment ],\n\t\t\t\tclass: 'cm-mw-comment'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.doubleUnderscore ],\n\t\t\t\tclass: 'cm-mw-double-underscore'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.extLink ],\n\t\t\t\tclass: 'cm-mw-extlink'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.extLinkBracket ],\n\t\t\t\tclass: 'cm-mw-extlink-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.extLinkProtocol ],\n\t\t\t\tclass: 'cm-mw-extlink-protocol'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.extLinkText ],\n\t\t\t\tclass: 'cm-mw-extlink-text'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.hr ],\n\t\t\t\tclass: 'cm-mw-hr'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.htmlTagAttribute ],\n\t\t\t\tclass: 'cm-mw-htmltag-attribute'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.htmlTagBracket ],\n\t\t\t\tclass: 'cm-mw-htmltag-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.htmlTagName ],\n\t\t\t\tclass: 'cm-mw-htmltag-name'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.indenting ],\n\t\t\t\tclass: 'cm-mw-indenting'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.linkBracket ],\n\t\t\t\tclass: 'cm-mw-link-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.linkDelimiter ],\n\t\t\t\tclass: 'cm-mw-link-delimiter'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.linkText ],\n\t\t\t\tclass: 'cm-mw-link-text'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.linkToSection ],\n\t\t\t\tclass: 'cm-mw-link-tosection'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.list ],\n\t\t\t\tclass: 'cm-mw-list'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.parserFunction ],\n\t\t\t\tclass: 'cm-mw-parserfunction'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.parserFunctionBracket ],\n\t\t\t\tclass: 'cm-mw-parserfunction-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.parserFunctionDelimiter ],\n\t\t\t\tclass: 'cm-mw-parserfunction-delimiter'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.parserFunctionName ],\n\t\t\t\tclass: 'cm-mw-parserfunction-name'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.sectionHeader ],\n\t\t\t\tclass: 'cm-mw-section-header'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.sectionHeader1 ],\n\t\t\t\tclass: 'cm-mw-section-1'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.sectionHeader2 ],\n\t\t\t\tclass: 'cm-mw-section-2'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.sectionHeader3 ],\n\t\t\t\tclass: 'cm-mw-section-3'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.sectionHeader4 ],\n\t\t\t\tclass: 'cm-mw-section-4'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.sectionHeader5 ],\n\t\t\t\tclass: 'cm-mw-section-5'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.sectionHeader6 ],\n\t\t\t\tclass: 'cm-mw-section-6'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.signature ],\n\t\t\t\tclass: 'cm-mw-signature'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.tableBracket ],\n\t\t\t\tclass: 'cm-mw-table-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.tableDefinition ],\n\t\t\t\tclass: 'cm-mw-table-definition'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.tableDelimiter ],\n\t\t\t\tclass: 'cm-mw-table-delimiter'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.template ],\n\t\t\t\tclass: 'cm-mw-template'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.templateArgumentName ],\n\t\t\t\tclass: 'cm-mw-template-argument-name'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.templateBracket ],\n\t\t\t\tclass: 'cm-mw-template-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.templateDelimiter ],\n\t\t\t\tclass: 'cm-mw-template-delimiter'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.templateName ],\n\t\t\t\tclass: 'cm-mw-pagename cm-mw-template-name'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.templateVariable ],\n\t\t\t\tclass: 'cm-mw-templatevariable'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.templateVariableBracket ],\n\t\t\t\tclass: 'cm-mw-templatevariable-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: tags[ this.tags.templateVariableName ],\n\t\t\t\tclass: 'cm-mw-templatevariable-name'\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Custom tags.\n\t\t\t * IMPORTANT: These need to reference the CodeMirrorModeMediaWiki context.\n\t\t\t */\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.em ],\n\t\t\t\tclass: 'cm-mw-em'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.error ],\n\t\t\t\tclass: 'cm-mw-error'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.extNowiki ],\n\t\t\t\tclass: 'cm-mw-ext-nowiki'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.extPre ],\n\t\t\t\tclass: 'cm-mw-ext-pre'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.extTagBracket ],\n\t\t\t\tclass: 'cm-mw-exttag-bracket'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.extTag ],\n\t\t\t\tclass: 'cm-mw-exttag'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.extTagAttribute ],\n\t\t\t\tclass: 'cm-mw-exttag-attribute'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.extTagName ],\n\t\t\t\tclass: 'cm-mw-exttag-name'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.freeExtLink ],\n\t\t\t\tclass: 'cm-mw-free-extlink'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.freeExtLinkProtocol ],\n\t\t\t\tclass: 'cm-mw-free-extlink-protocol'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.htmlEntity ],\n\t\t\t\tclass: 'cm-mw-html-entity'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.linkPageName ],\n\t\t\t\tclass: 'cm-mw-link-pagename'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.nowiki ],\n\t\t\t\tclass: 'cm-mw-tag-nowiki'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.pageName ],\n\t\t\t\tclass: 'cm-mw-pagename'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.pre ],\n\t\t\t\tclass: 'cm-mw-tag-pre'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.section ],\n\t\t\t\tclass: 'cm-mw-section'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.skipFormatting ],\n\t\t\t\tclass: 'cm-mw-skipformatting'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.strong ],\n\t\t\t\tclass: 'cm-mw-strong'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.tableCaption ],\n\t\t\t\tclass: 'cm-mw-table-caption'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttag: context.tokenTable[ this.tags.templateVariableDelimiter ],\n\t\t\t\tclass: 'cm-mw-templatevariable-delimiter'\n\t\t\t},\n\n\t\t\t...this.extHighlightStyles\n\t\t];\n\t}\n}\n\nexport const mwModeConfig = new CodeMirrorModeMediaWikiConfig();\n","import {\n\tHighlightStyle,\n\tLanguageSupport,\n\tStreamLanguage,\n\tStreamParser,\n\tStringStream,\n\tsyntaxHighlighting\n} from '@codemirror/language';\nimport { mwModeConfig as modeConfig } from './codemirror.mode.mediawiki.config';\nimport { Tag } from '@lezer/highlight';\n\n/**\n * Adapted from the original CodeMirror 5 stream parser by Pavel Astakhov\n *\n * @class CodeMirrorModeMediaWiki\n */\nclass CodeMirrorModeMediaWiki {\n\t/**\n\t * @param {Object} config\n\t */\n\tconstructor( config ) {\n\t\tthis.config = config;\n\t\t// eslint-disable-next-line security/detect-non-literal-regexp\n\t\tthis.urlProtocols = new RegExp( `^(?:${ this.config.urlProtocols })(?=[^\\\\s\\u00a0{[\\\\]<>~).,'])`, 'i' );\n\t\tthis.isBold = false;\n\t\tthis.wasBold = false;\n\t\tthis.isItalic = false;\n\t\tthis.wasItalic = false;\n\t\tthis.firstSingleLetterWord = null;\n\t\tthis.firstMultiLetterWord = null;\n\t\tthis.firstSpace = null;\n\t\tthis.oldStyle = null;\n\t\tthis.tokens = [];\n\t\tthis.oldTokens = [];\n\t\tthis.tokenTable = modeConfig.tokenTable;\n\t\tthis.registerGroundTokens();\n\n\t\t// Dynamically register any tags that aren't already in CodeMirrorModeMediaWikiConfig\n\t\tObject.keys( this.config.tags ).forEach( ( tag ) => modeConfig.addTag( tag ) );\n\t}\n\n\t/**\n\t * Register the ground tokens. These aren't referenced directly in the StreamParser, nor do\n\t * they have a parent Tag, so we don't need them as constants like we do for other tokens.\n\t * See this.makeLocalStyle() for how these tokens are used.\n\t */\n\tregisterGroundTokens() {\n\t\t[\n\t\t\t'mw-ext-ground',\n\t\t\t'mw-ext-link-ground',\n\t\t\t'mw-ext2-ground',\n\t\t\t'mw-ext2-link-ground',\n\t\t\t'mw-ext3-ground',\n\t\t\t'mw-ext3-link-ground',\n\t\t\t'mw-link-ground',\n\t\t\t'mw-template-ext-ground',\n\t\t\t'mw-template-ext-link-ground',\n\t\t\t'mw-template-ext2-ground',\n\t\t\t'mw-template-ext2-link-ground',\n\t\t\t'mw-template-ext3-ground',\n\t\t\t'mw-template-ext3-link-ground',\n\t\t\t'mw-template-ground',\n\t\t\t'mw-template-link-ground',\n\t\t\t'mw-template2-ext-ground',\n\t\t\t'mw-template2-ext-link-ground',\n\t\t\t'mw-template2-ext2-ground',\n\t\t\t'mw-template2-ext2-link-ground',\n\t\t\t'mw-template2-ext3-ground',\n\t\t\t'mw-template2-ext3-link-ground',\n\t\t\t'mw-template2-ground',\n\t\t\t'mw-template2-link-ground',\n\t\t\t'mw-template3-ext-ground',\n\t\t\t'mw-template3-ext-link-ground',\n\t\t\t'mw-template3-ext2-ground',\n\t\t\t'mw-template3-ext2-link-ground',\n\t\t\t'mw-template3-ext3-ground',\n\t\t\t'mw-template3-ext3-link-ground',\n\t\t\t'mw-template3-ground',\n\t\t\t'mw-template3-link-ground'\n\t\t].forEach( ( ground ) => modeConfig.addToken( ground ) );\n\t}\n\n\teatHtmlEntity( stream, style ) {\n\t\tlet ok;\n\t\tif ( stream.eat( '#' ) ) {\n\t\t\tif ( stream.eat( 'x' ) ) {\n\t\t\t\tok = stream.eatWhile( /[a-fA-F\\d]/ ) && stream.eat( ';' );\n\t\t\t} else {\n\t\t\t\tok = stream.eatWhile( /[\\d]/ ) && stream.eat( ';' );\n\t\t\t}\n\t\t} else {\n\t\t\tok = stream.eatWhile( /[\\w.\\-:]/ ) && stream.eat( ';' );\n\t\t}\n\t\tif ( ok ) {\n\t\t\treturn modeConfig.tags.htmlEntity;\n\t\t}\n\t\treturn style;\n\t}\n\n\tmakeStyle( style, state, endGround ) {\n\t\tif ( this.isBold ) {\n\t\t\tstyle += ' ' + modeConfig.tags.strong;\n\t\t}\n\t\tif ( this.isItalic ) {\n\t\t\tstyle += ' ' + modeConfig.tags.em;\n\t\t}\n\t\treturn this.makeLocalStyle( style, state, endGround );\n\t}\n\n\tmakeLocalStyle( style, state, endGround ) {\n\t\tlet ground = '';\n\t\tswitch ( state.nTemplate ) {\n\t\t\tcase 0:\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tground += '-template';\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tground += '-template2';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tground += '-template3';\n\t\t\t\tbreak;\n\t\t}\n\t\tswitch ( state.nExt ) {\n\t\t\tcase 0:\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tground += '-ext';\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tground += '-ext2';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tground += '-ext3';\n\t\t\t\tbreak;\n\t\t}\n\t\tif ( state.nLink > 0 ) {\n\t\t\tground += '-link';\n\t\t}\n\t\tif ( ground !== '' ) {\n\t\t\tstyle = `mw${ ground }-ground ${ style }`;\n\t\t}\n\t\tif ( endGround ) {\n\t\t\tstate[ endGround ]--;\n\t\t}\n\t\treturn style.trim();\n\t}\n\n\teatBlock( style, terminator, consumeLast ) {\n\t\treturn ( stream, state ) => {\n\t\t\tif ( stream.skipTo( terminator ) ) {\n\t\t\t\tif ( consumeLast !== false ) {\n\t\t\t\t\tstream.match( terminator );\n\t\t\t\t}\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t} else {\n\t\t\t\tstream.skipToEnd();\n\t\t\t}\n\t\t\treturn this.makeLocalStyle( style, state );\n\t\t};\n\t}\n\n\teatEnd( style ) {\n\t\treturn ( stream, state ) => {\n\t\t\tstream.skipToEnd();\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( style, state );\n\t\t};\n\t}\n\n\teatChar( char, style ) {\n\t\treturn ( stream, state ) => {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\tif ( stream.eat( char ) ) {\n\t\t\t\treturn this.makeLocalStyle( style, state );\n\t\t\t}\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.error, state );\n\t\t};\n\t}\n\n\teatSectionHeader( count ) {\n\t\treturn ( stream, state ) => {\n\t\t\tif ( stream.match( /^[^&<[{~]+/ ) ) {\n\t\t\t\tif ( stream.eol() ) {\n\t\t\t\t\tstream.backUp( count );\n\t\t\t\t\tstate.tokenize = this.eatEnd( modeConfig.tags.sectionHeader );\n\t\t\t\t} else if ( stream.match( /^<!--(?!.*?-->.*?=)/, false ) ) {\n\t\t\t\t\t// T171074: handle trailing comments\n\t\t\t\t\tstream.backUp( count );\n\t\t\t\t\tstate.tokenize = this.eatBlock( modeConfig.tags.sectionHeader, '<!--', false );\n\t\t\t\t}\n\t\t\t\treturn modeConfig.tags.section; // style is null\n\t\t\t}\n\t\t\treturn this.eatWikiText( modeConfig.tags.section )( stream, state );\n\t\t};\n\t}\n\n\tinVariable( stream, state ) {\n\t\tif ( stream.match( /^[^{}|]+/ ) ) {\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateVariableName, state );\n\t\t}\n\t\tif ( stream.eat( '|' ) ) {\n\t\t\tstate.tokenize = this.inVariableDefault.bind( this );\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateVariableDelimiter, state );\n\t\t}\n\t\tif ( stream.match( '}}}' ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateVariableBracket, state );\n\t\t}\n\t\tif ( stream.match( '{{{' ) ) {\n\t\t\tstate.stack.push( state.tokenize );\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateVariableBracket, state );\n\t\t}\n\t\tstream.next();\n\t\treturn this.makeLocalStyle( modeConfig.tags.templateVariableName, state );\n\t}\n\n\tinVariableDefault( stream, state ) {\n\t\tif ( stream.match( /^[^{}[<&~]+/ ) ) {\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateVariable, state );\n\t\t}\n\t\tif ( stream.match( '}}}' ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateVariableBracket, state );\n\t\t}\n\t\treturn this.eatWikiText( modeConfig.tags.templateVariable )( stream, state );\n\t}\n\n\tinParserFunctionName( stream, state ) {\n\t\t// FIXME: {{#name}} and {{uc}} are wrong, must have ':'\n\t\tif ( stream.match( /^#?[^:}{~]+/ ) ) {\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.parserFunctionName, state );\n\t\t}\n\t\tif ( stream.eat( ':' ) ) {\n\t\t\tstate.tokenize = this.inParserFunctionArguments.bind( this );\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.parserFunctionDelimiter, state );\n\t\t}\n\t\tif ( stream.match( '}}' ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.parserFunctionBracket, state, 'nExt' );\n\t\t}\n\t\treturn this.eatWikiText( modeConfig.tags.parserFunction )( stream, state );\n\t}\n\n\tinParserFunctionArguments( stream, state ) {\n\t\tif ( stream.match( /^[^|}{[<&~]+/ ) ) {\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.parserFunction, state );\n\t\t} else if ( stream.eat( '|' ) ) {\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.parserFunctionDelimiter, state );\n\t\t} else if ( stream.match( '}}' ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.parserFunctionBracket, state, 'nExt' );\n\t\t}\n\t\treturn this.eatWikiText( modeConfig.tags.parserFunction )( stream, state );\n\t}\n\n\teatTemplatePageName( haveAte ) {\n\t\treturn ( stream, state ) => {\n\t\t\tif ( stream.match( /^[\\s\\u00a0]*\\|[\\s\\u00a0]*/ ) ) {\n\t\t\t\tstate.tokenize = this.eatTemplateArgument( true );\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateDelimiter, state );\n\t\t\t}\n\t\t\tif ( stream.match( /^[\\s\\u00a0]*\\}\\}/ ) ) {\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateBracket, state, 'nTemplate' );\n\t\t\t}\n\t\t\tif ( stream.match( /^[\\s\\u00a0]*<!--.*?-->/ ) ) {\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.comment, state );\n\t\t\t}\n\t\t\tif ( haveAte && stream.sol() ) {\n\t\t\t\t// @todo error message\n\t\t\t\tstate.nTemplate--;\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( stream.match( /^[\\s\\u00a0]*[^\\s\\u00a0|}<{&~]+/ ) ) {\n\t\t\t\tstate.tokenize = this.eatTemplatePageName( true );\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateName, state );\n\t\t\t} else if ( stream.eatSpace() ) {\n\t\t\t\tif ( stream.eol() === true ) {\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateName, state );\n\t\t\t\t}\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateName, state );\n\t\t\t}\n\t\t\treturn this.eatWikiText( modeConfig.tags.templateName )( stream, state );\n\t\t};\n\t}\n\n\teatTemplateArgument( expectArgName ) {\n\t\treturn ( stream, state ) => {\n\t\t\tif ( expectArgName && stream.eatWhile( /[^=|}{[<&~]/ ) ) {\n\t\t\t\tif ( stream.eat( '=' ) ) {\n\t\t\t\t\tstate.tokenize = this.eatTemplateArgument( false );\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateArgumentName, state );\n\t\t\t\t}\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.template, state );\n\t\t\t} else if ( stream.eatWhile( /[^|}{[<&~]/ ) ) {\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.template, state );\n\t\t\t} else if ( stream.eat( '|' ) ) {\n\t\t\t\tstate.tokenize = this.eatTemplateArgument( true );\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateDelimiter, state );\n\t\t\t} else if ( stream.match( '}}' ) ) {\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateBracket, state, 'nTemplate' );\n\t\t\t}\n\t\t\treturn this.eatWikiText( modeConfig.tags.template )( stream, state );\n\t\t};\n\t}\n\n\teatExternalLinkProtocol( chars ) {\n\t\treturn ( stream, state ) => {\n\t\t\twhile ( chars > 0 ) {\n\t\t\t\tchars--;\n\t\t\t\tstream.next();\n\t\t\t}\n\t\t\tif ( stream.eol() ) {\n\t\t\t\tstate.nLink--;\n\t\t\t\t// @todo error message\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t} else {\n\t\t\t\tstate.tokenize = this.inExternalLink.bind( this );\n\t\t\t}\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.extLinkProtocol, state );\n\t\t};\n\t}\n\n\tinExternalLink( stream, state ) {\n\t\tif ( stream.sol() ) {\n\t\t\tstate.nLink--;\n\t\t\t// @todo error message\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn;\n\t\t}\n\t\tif ( stream.match( /^[\\s\\u00a0]*\\]/ ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.extLinkBracket, state, 'nLink' );\n\t\t}\n\t\tif ( stream.eatSpace() ) {\n\t\t\tstate.tokenize = this.inExternalLinkText.bind( this );\n\t\t\treturn this.makeStyle( '', state );\n\t\t}\n\t\tif ( stream.match( /^[^\\s\\u00a0\\]{&~']+/ ) || stream.eatSpace() ) {\n\t\t\tif ( stream.peek() === '\\'' ) {\n\t\t\t\tif ( stream.match( '\\'\\'', false ) ) {\n\t\t\t\t\tstate.tokenize = this.inExternalLinkText.bind( this );\n\t\t\t\t} else {\n\t\t\t\t\tstream.next();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this.makeStyle( modeConfig.tags.extLink, state );\n\t\t}\n\t\treturn this.eatWikiText( modeConfig.tags.extLink )( stream, state );\n\t}\n\n\tinExternalLinkText( stream, state ) {\n\t\tif ( stream.sol() ) {\n\t\t\tstate.nLink--;\n\t\t\t// @todo error message\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn;\n\t\t}\n\t\tif ( stream.eat( ']' ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.extLinkBracket, state, 'nLink' );\n\t\t}\n\t\tif ( stream.match( /^[^'\\]{&~<]+/ ) ) {\n\t\t\treturn this.makeStyle( modeConfig.tags.extLinkText, state );\n\t\t}\n\t\treturn this.eatWikiText( modeConfig.tags.extLinkText )( stream, state );\n\t}\n\n\tinLink( stream, state ) {\n\t\tif ( stream.sol() ) {\n\t\t\tstate.nLink--;\n\t\t\t// @todo error message\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn;\n\t\t}\n\t\tif ( stream.match( /^[\\s\\u00a0]*#[\\s\\u00a0]*/ ) ) {\n\t\t\tstate.tokenize = this.inLinkToSection.bind( this );\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.link, state );\n\t\t}\n\t\tif ( stream.match( /^[\\s\\u00a0]*\\|[\\s\\u00a0]*/ ) ) {\n\t\t\tstate.tokenize = this.eatLinkText();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.linkDelimiter, state );\n\t\t}\n\t\tif ( stream.match( /^[\\s\\u00a0]*\\]\\]/ ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.linkBracket, state, 'nLink' );\n\t\t}\n\t\tif ( stream.match( /^[\\s\\u00a0]*[^\\s\\u00a0#|\\]&~{]+/ ) || stream.eatSpace() ) {\n\t\t\treturn this.makeStyle(\n\t\t\t\t`${ modeConfig.tags.linkPageName } ${ modeConfig.tags.pageName }`,\n\t\t\t\tstate\n\t\t\t);\n\t\t}\n\t\treturn this.eatWikiText(\n\t\t\t`${ modeConfig.tags.linkPageName } ${ modeConfig.tags.pageName }`\n\t\t)( stream, state );\n\t}\n\n\tinLinkToSection( stream, state ) {\n\t\tif ( stream.sol() ) {\n\t\t\t// @todo error message\n\t\t\tstate.nLink--;\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn;\n\t\t}\n\t\t// FIXME '{{' breaks links, example: [[z{{page]]\n\t\tif ( stream.match( /^[^|\\]&~{}]+/ ) ) {\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.linkToSection, state );\n\t\t}\n\t\tif ( stream.eat( '|' ) ) {\n\t\t\tstate.tokenize = this.eatLinkText();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.linkDelimiter, state );\n\t\t}\n\t\tif ( stream.match( ']]' ) ) {\n\t\t\tstate.tokenize = state.stack.pop();\n\t\t\treturn this.makeLocalStyle( modeConfig.tags.linkBracket, state, 'nLink' );\n\t\t}\n\t\treturn this.eatWikiText( modeConfig.tags.linkToSection )( stream, state );\n\t}\n\n\teatLinkText() {\n\t\tlet linkIsBold, linkIsItalic;\n\t\treturn ( stream, state ) => {\n\t\t\tlet tmpstyle;\n\t\t\tif ( stream.match( ']]' ) ) {\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.linkBracket, state, 'nLink' );\n\t\t\t}\n\t\t\tif ( stream.match( '\\'\\'\\'' ) ) {\n\t\t\t\tlinkIsBold = !linkIsBold;\n\t\t\t\treturn this.makeLocalStyle(\n\t\t\t\t\t`${ modeConfig.tags.linkText } ${ modeConfig.tags.apostrophes }`,\n\t\t\t\t\tstate\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( stream.match( '\\'\\'' ) ) {\n\t\t\t\tlinkIsItalic = !linkIsItalic;\n\t\t\t\treturn this.makeLocalStyle(\n\t\t\t\t\t`${ modeConfig.tags.linkText } ${ modeConfig.tags.apostrophes }`,\n\t\t\t\t\tstate\n\t\t\t\t);\n\t\t\t}\n\t\t\ttmpstyle = modeConfig.tags.linkText;\n\t\t\tif ( linkIsBold ) {\n\t\t\t\ttmpstyle += ' ' + modeConfig.tags.strong;\n\t\t\t}\n\t\t\tif ( linkIsItalic ) {\n\t\t\t\ttmpstyle += ' ' + modeConfig.tags.em;\n\t\t\t}\n\t\t\tif ( stream.match( /^[^'\\]{&~<]+/ ) ) {\n\t\t\t\treturn this.makeStyle( tmpstyle, state );\n\t\t\t}\n\t\t\treturn this.eatWikiText( tmpstyle )( stream, state );\n\t\t};\n\t}\n\n\teatTagName( chars, isCloseTag, isHtmlTag ) {\n\t\treturn ( stream, state ) => {\n\t\t\tlet name = '';\n\t\t\twhile ( chars > 0 ) {\n\t\t\t\tchars--;\n\t\t\t\tname = name + stream.next();\n\t\t\t}\n\t\t\tstream.eatSpace();\n\t\t\tname = name.toLowerCase();\n\n\t\t\tif ( isHtmlTag ) {\n\t\t\t\tif ( isCloseTag && !modeConfig.implicitlyClosedHtmlTags[ name ] ) {\n\t\t\t\t\tstate.tokenize = this.eatChar( '>', modeConfig.tags.htmlTagBracket );\n\t\t\t\t} else {\n\t\t\t\t\tstate.tokenize = this.eatHtmlTagAttribute( name );\n\t\t\t\t}\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.htmlTagName, state );\n\t\t\t}\n\t\t\t// it is the extension tag\n\t\t\tif ( isCloseTag ) {\n\t\t\t\tstate.tokenize = this.eatChar(\n\t\t\t\t\t'>',\n\t\t\t\t\t`${ modeConfig.tags.extTagBracket } mw-ext-${ name }`\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tstate.tokenize = this.eatExtTagAttribute( name );\n\t\t\t}\n\t\t\treturn this.makeLocalStyle( `${ modeConfig.tags.extTagName } mw-ext-${ name }`, state );\n\t\t};\n\t}\n\n\teatHtmlTagAttribute( name ) {\n\t\treturn ( stream, state ) => {\n\t\t\t// eslint-disable-next-line security/detect-unsafe-regex\n\t\t\tif ( stream.match( /^(?:\"[^<\">]*\"|'[^<'>]*'|[^>/<{&~])+/ ) ) {\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.htmlTagAttribute, state );\n\t\t\t}\n\t\t\tif ( stream.eat( '>' ) ) {\n\t\t\t\tif ( !( name in modeConfig.implicitlyClosedHtmlTags ) ) {\n\t\t\t\t\tstate.inHtmlTag.push( name );\n\t\t\t\t}\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.htmlTagBracket, state );\n\t\t\t}\n\t\t\tif ( stream.match( '/>' ) ) {\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.htmlTagBracket, state );\n\t\t\t}\n\t\t\treturn this.eatWikiText( modeConfig.tags.htmlTagAttribute )( stream, state );\n\t\t};\n\t}\n\n\teatNowiki() {\n\t\treturn ( stream ) => {\n\t\t\tif ( stream.match( /^[^&]+/ ) ) {\n\t\t\t\treturn '';\n\t\t\t}\n\t\t\t// eat &\n\t\t\tstream.next();\n\t\t\treturn this.eatHtmlEntity( stream, '' );\n\t\t};\n\t}\n\n\teatExtTagAttribute( name ) {\n\t\treturn ( stream, state ) => {\n\t\t\t// eslint-disable-next-line security/detect-unsafe-regex\n\t\t\tif ( stream.match( /^(?:\"[^\">]*\"|'[^'>]*'|[^>/<{&~])+/ ) ) {\n\t\t\t\treturn this.makeLocalStyle( `${ modeConfig.tags.extTagAttribute } mw-ext-${ name }`, state );\n\t\t\t}\n\t\t\tif ( stream.eat( '>' ) ) {\n\t\t\t\tstate.extName = name;\n\n\t\t\t\t// FIXME: remove nowiki and pre from TagModes in extension.json after CM6 upgrade\n\t\t\t\t// leverage the tagModes system for <nowiki> and <pre>\n\t\t\t\tif ( name === 'nowiki' || name === 'pre' ) {\n\t\t\t\t\t// There's no actual processing within these tags (apart from HTML entities),\n\t\t\t\t\t// so startState and copyState can be no-ops.\n\t\t\t\t\tstate.extMode = {\n\t\t\t\t\t\tstartState: () => {},\n\t\t\t\t\t\tcopyState: () => {},\n\t\t\t\t\t\ttoken: this.eatNowiki()\n\t\t\t\t\t};\n\t\t\t\t} else if ( name in this.config.tagModes ) {\n\t\t\t\t\tconst mode = this.config.tagModes[ name ];\n\t\t\t\t\tif ( mode === 'mediawiki' || mode === 'text/mediawiki' ) {\n\t\t\t\t\t\tstate.extMode = this.mediawiki;\n\t\t\t\t\t\tstate.extState = state.extMode.startState();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstate.tokenize = this.eatExtTagArea( name );\n\t\t\t\treturn this.makeLocalStyle( `${ modeConfig.tags.extTagBracket } mw-ext-${ name }`, state );\n\t\t\t}\n\t\t\tif ( stream.match( '/>' ) ) {\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\treturn this.makeLocalStyle( `${ modeConfig.tags.extTagBracket } mw-ext-${ name }`, state );\n\t\t\t}\n\t\t\treturn this.eatWikiText( `${ modeConfig.tags.extTagAttribute } mw-ext-${ name }` )( stream, state );\n\t\t};\n\t}\n\n\teatExtTagArea( name ) {\n\t\treturn ( stream, state ) => {\n\t\t\tconst from = stream.pos,\n\t\t\t\t// eslint-disable-next-line security/detect-non-literal-regexp\n\t\t\t\tpattern = new RegExp( `</${ name }\\\\s*>`, 'i' ),\n\t\t\t\tm = pattern.exec( from ? stream.string.slice( from ) : stream.string );\n\t\t\tlet origString = false,\n\t\t\t\tto;\n\n\t\t\tif ( m ) {\n\t\t\t\tif ( m.index === 0 ) {\n\t\t\t\t\tstate.tokenize = this.eatExtCloseTag( name );\n\t\t\t\t\tstate.extName = false;\n\t\t\t\t\tif ( state.extMode !== false ) {\n\t\t\t\t\t\tstate.extMode = false;\n\t\t\t\t\t\tstate.extState = false;\n\t\t\t\t\t}\n\t\t\t\t\treturn state.tokenize( stream, state );\n\t\t\t\t}\n\t\t\t\tto = m.index + from;\n\t\t\t\torigString = stream.string;\n\t\t\t\tstream.string = origString.slice( 0, to );\n\t\t\t}\n\n\t\t\tstate.stack.push( state.tokenize );\n\t\t\tstate.tokenize = this.eatExtTokens( origString );\n\t\t\treturn state.tokenize( stream, state );\n\t\t};\n\t}\n\n\teatExtCloseTag( name ) {\n\t\treturn ( stream, state ) => {\n\t\t\tstream.next(); // eat <\n\t\t\tstream.next(); // eat /\n\t\t\tstate.tokenize = this.eatTagName( name.length, true, false );\n\t\t\treturn this.makeLocalStyle( `${ modeConfig.tags.extTagBracket } mw-ext-${ name }`, state );\n\t\t};\n\t}\n\n\teatExtTokens( origString ) {\n\t\treturn ( stream, state ) => {\n\t\t\tlet ret;\n\t\t\tif ( state.extMode === false ) {\n\t\t\t\tret = modeConfig.tags.extTag;\n\t\t\t\tstream.skipToEnd();\n\t\t\t} else {\n\t\t\t\tret = `mw-tag-${ state.extName } ` +\n\t\t\t\t\tstate.extMode.token( stream, state.extState, origString === false );\n\t\t\t}\n\t\t\tif ( stream.eol() ) {\n\t\t\t\tif ( origString !== false ) {\n\t\t\t\t\tstream.string = origString;\n\t\t\t\t}\n\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t}\n\t\t\treturn this.makeLocalStyle( ret, state );\n\t\t};\n\t}\n\n\teatStartTable( stream, state ) {\n\t\tstream.match( '{|' );\n\t\tstream.eatSpace();\n\t\tstate.tokenize = this.inTableDefinition.bind( this );\n\t\treturn modeConfig.tags.tableBracket;\n\t}\n\n\tinTableDefinition( stream, state ) {\n\t\tif ( stream.sol() ) {\n\t\t\tstate.tokenize = this.inTable.bind( this );\n\t\t\treturn this.inTable( stream, state );\n\t\t}\n\t\treturn this.eatWikiText( modeConfig.tags.tableDefinition )( stream, state );\n\t}\n\n\tinTable( stream, state ) {\n\t\tif ( stream.sol() ) {\n\t\t\tstream.eatSpace();\n\t\t\tif ( stream.eat( '|' ) ) {\n\t\t\t\tif ( stream.eat( '-' ) ) {\n\t\t\t\t\tstream.eatSpace();\n\t\t\t\t\tstate.tokenize = this.inTableDefinition.bind( this );\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.tableDelimiter, state );\n\t\t\t\t}\n\t\t\t\tif ( stream.eat( '+' ) ) {\n\t\t\t\t\tstream.eatSpace();\n\t\t\t\t\tstate.tokenize = this.eatTableRow( true, false, true );\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.tableDelimiter, state );\n\t\t\t\t}\n\t\t\t\tif ( stream.eat( '}' ) ) {\n\t\t\t\t\tstate.tokenize = state.stack.pop();\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.tableBracket, state );\n\t\t\t\t}\n\t\t\t\tstream.eatSpace();\n\t\t\t\tstate.tokenize = this.eatTableRow( true, false );\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.tableDelimiter, state );\n\t\t\t}\n\t\t\tif ( stream.eat( '!' ) ) {\n\t\t\t\tstream.eatSpace();\n\t\t\t\tstate.tokenize = this.eatTableRow( true, true );\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.tableDelimiter, state );\n\t\t\t}\n\t\t}\n\t\treturn this.eatWikiText( '' )( stream, state );\n\t}\n\n\t// isStart actually means whether there may be attributes */\n\teatTableRow( isStart, isHead, isCaption ) {\n\t\tlet tag = '';\n\t\tif ( isCaption ) {\n\t\t\ttag = modeConfig.tags.tableCaption;\n\t\t} else if ( isHead ) {\n\t\t\ttag = modeConfig.tags.strong;\n\t\t}\n\t\treturn ( stream, state ) => {\n\t\t\tif ( stream.sol() ) {\n\t\t\t\tif ( stream.match( /^[\\s\\u00a0]*[|!]/, false ) ) {\n\t\t\t\t\tstate.tokenize = this.inTable.bind( this );\n\t\t\t\t\treturn this.inTable( stream, state );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( stream.match( /^[^'|{[<&~!]+/ ) ) {\n\t\t\t\t\treturn this.makeStyle( tag, state );\n\t\t\t\t}\n\t\t\t\tif ( stream.match( '||' ) || ( isHead && stream.match( '!!' ) ) ) {\n\t\t\t\t\tthis.isBold = false;\n\t\t\t\t\tthis.isItalic = false;\n\t\t\t\t\tstate.tokenize = this.eatTableRow( true, isHead, isCaption );\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.tableDelimiter, state );\n\t\t\t\t}\n\t\t\t\tif ( isStart && stream.eat( '|' ) ) {\n\t\t\t\t\tstate.tokenize = this.eatTableRow( false, isHead, isCaption );\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.tableDelimiter, state );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn this.eatWikiText( tag )( stream, state );\n\t\t};\n\t}\n\n\teatFreeExternalLinkProtocol( stream, state ) {\n\t\tstream.match( this.urlProtocols );\n\t\tstate.tokenize = this.eatFreeExternalLink.bind( this );\n\t\treturn this.makeLocalStyle( modeConfig.tags.freeExtLinkProtocol, state );\n\t}\n\n\teatFreeExternalLink( stream, state ) {\n\t\tif ( stream.eol() ) {\n\t\t\t// @todo error message\n\t\t} else if ( stream.match( /^[^\\s\\u00a0{[\\]<>~).,']*/ ) ) {\n\t\t\tif ( stream.peek() === '~' ) {\n\t\t\t\tif ( !stream.match( /^~~~+/, false ) ) {\n\t\t\t\t\tstream.match( /^~*/ );\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.freeExtLink, state );\n\t\t\t\t}\n\t\t\t} else if ( stream.peek() === '{' ) {\n\t\t\t\tif ( !stream.match( '{{', false ) ) {\n\t\t\t\t\tstream.next();\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.freeExtLink, state );\n\t\t\t\t}\n\t\t\t} else if ( stream.peek() === '\\'' ) {\n\t\t\t\tif ( !stream.match( '\\'\\'', false ) ) {\n\t\t\t\t\tstream.next();\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.freeExtLink, state );\n\t\t\t\t}\n\t\t\t} else if ( stream.match( /^[).,]+(?=[^\\s\\u00a0{[\\]<>~).,])/ ) ) {\n\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.freeExtLink, state );\n\t\t\t}\n\t\t}\n\t\tstate.tokenize = state.stack.pop();\n\t\treturn this.makeLocalStyle( modeConfig.tags.freeExtLink, state );\n\t}\n\n\t/**\n\t * @param {string} style\n\t * @return {string|Function}\n\t */\n\teatWikiText( style ) {\n\t\treturn ( stream, state ) => {\n\t\t\tlet ch, tmp, mt, name, isCloseTag, tagname;\n\t\t\tconst sol = stream.sol();\n\n\t\t\tfunction chain( parser ) {\n\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\tstate.tokenize = parser;\n\t\t\t\treturn parser( stream, state );\n\t\t\t}\n\n\t\t\tif ( sol ) {\n\t\t\t\t// highlight free external links, see T108448\n\t\t\t\tif ( !stream.match( '//', false ) && stream.match( this.urlProtocols ) ) {\n\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\tstate.tokenize = this.eatFreeExternalLink.bind( this );\n\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.freeExtLinkProtocol, state );\n\t\t\t\t}\n\t\t\t\tch = stream.next();\n\t\t\t\tswitch ( ch ) {\n\t\t\t\t\tcase '-':\n\t\t\t\t\t\tif ( stream.match( /^---+/ ) ) {\n\t\t\t\t\t\t\treturn modeConfig.tags.hr;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '=':\n\t\t\t\t\t\t// eslint-disable-next-line security/detect-unsafe-regex\n\t\t\t\t\t\ttmp = stream.match( /^(={0,5})(.+?(=\\1\\s*)(<!--(?!.*-->.*\\S).*?)?)$/ );\n\t\t\t\t\t\t// Title\n\t\t\t\t\t\tif ( tmp ) {\n\t\t\t\t\t\t\tstream.backUp( tmp[ 2 ].length );\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.eatSectionHeader( tmp[ 3 ].length );\n\t\t\t\t\t\t\treturn modeConfig.tags.sectionHeader + ' ' +\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Tokens used here include:\n\t\t\t\t\t\t\t\t * - cm-mw-section-1\n\t\t\t\t\t\t\t\t * - cm-mw-section-2\n\t\t\t\t\t\t\t\t * - cm-mw-section-3\n\t\t\t\t\t\t\t\t * - cm-mw-section-4\n\t\t\t\t\t\t\t\t * - cm-mw-section-5\n\t\t\t\t\t\t\t\t * - cm-mw-section-6\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tmodeConfig.tags[ `sectionHeader${ tmp[ 1 ].length + 1 }` ];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase '*':\n\t\t\t\t\tcase '#':\n\t\t\t\t\tcase ';':\n\t\t\t\t\t\t// Just consume all nested list and indention syntax when there is more\n\t\t\t\t\t\tstream.match( /^[*#;:]*/ );\n\t\t\t\t\t\treturn modeConfig.tags.list;\n\t\t\t\t\tcase ':':\n\t\t\t\t\t\t// Highlight indented tables :{|, bug T108454\n\t\t\t\t\t\tif ( stream.match( /^:*{\\|/, false ) ) {\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.eatStartTable.bind( this );\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Just consume all nested list and indention syntax when there is more\n\t\t\t\t\t\tstream.match( /^[*#;:]*/ );\n\t\t\t\t\t\treturn modeConfig.tags.indenting;\n\t\t\t\t\tcase ' ':\n\t\t\t\t\t\t// Leading spaces is valid syntax for tables, bug T108454\n\t\t\t\t\t\tif ( stream.match( /^[\\s\\u00a0]*:*{\\|/, false ) ) {\n\t\t\t\t\t\t\tstream.eatSpace();\n\t\t\t\t\t\t\tif ( stream.match( /^:+/ ) ) { // ::{|\n\t\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\t\tstate.tokenize = this.eatStartTable.bind( this );\n\t\t\t\t\t\t\t\treturn modeConfig.tags.indenting;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstream.eat( '{' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn modeConfig.tags.skipFormatting;\n\t\t\t\t\t\t}\n\t\t\t\t\t// break is not necessary here\n\t\t\t\t\t// falls through\n\t\t\t\t\tcase '{':\n\t\t\t\t\t\tif ( stream.eat( '|' ) ) {\n\t\t\t\t\t\t\tstream.eatSpace();\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.inTableDefinition.bind( this );\n\t\t\t\t\t\t\treturn modeConfig.tags.tableBracket;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tch = stream.next();\n\t\t\t}\n\n\t\t\tswitch ( ch ) {\n\t\t\t\tcase '&':\n\t\t\t\t\treturn this.makeStyle(\n\t\t\t\t\t\tthis.eatHtmlEntity( stream, style ),\n\t\t\t\t\t\tstate\n\t\t\t\t\t);\n\t\t\t\tcase '\\'':\n\t\t\t\t\t// skip the irrelevant apostrophes ( >5 or =4 )\n\t\t\t\t\tif ( stream.match( /^'*(?=''''')/ ) || stream.match( /^'''(?!')/, false ) ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif ( stream.match( '\\'\\'' ) ) { // bold\n\t\t\t\t\t\tif ( !( this.firstSingleLetterWord || stream.match( '\\'\\'', false ) ) ) {\n\t\t\t\t\t\t\tthis.prepareItalicForCorrection( stream );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.isBold = !this.isBold;\n\t\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.apostrophesBold, state );\n\t\t\t\t\t} else if ( stream.eat( '\\'' ) ) { // italic\n\t\t\t\t\t\tthis.isItalic = !this.isItalic;\n\t\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.apostrophesItalic, state );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase '[':\n\t\t\t\t\tif ( stream.eat( '[' ) ) { // Link Example: [[ Foo | Bar ]]\n\t\t\t\t\t\tstream.eatSpace();\n\t\t\t\t\t\tif ( /[^\\]|[]/.test( stream.peek() ) ) {\n\t\t\t\t\t\t\tstate.nLink++;\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.inLink.bind( this );\n\t\t\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.linkBracket, state );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmt = stream.match( this.urlProtocols );\n\t\t\t\t\t\tif ( mt ) {\n\t\t\t\t\t\t\tstate.nLink++;\n\t\t\t\t\t\t\tstream.backUp( mt[ 0 ].length );\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.eatExternalLinkProtocol( mt[ 0 ].length );\n\t\t\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.extLinkBracket, state );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase '{':\n\t\t\t\t\t// Can't be a variable when it starts with more than 3 brackets (T108450) or\n\t\t\t\t\t// a single { followed by a template. E.g. {{{!}} starts a table (T292967).\n\t\t\t\t\tif ( stream.match( /^{{(?!{|[^{}]*}}(?!}))/ ) ) {\n\t\t\t\t\t\tstream.eatSpace();\n\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\tstate.tokenize = this.inVariable.bind( this );\n\t\t\t\t\t\treturn this.makeLocalStyle(\n\t\t\t\t\t\t\tmodeConfig.tags.templateVariableBracket,\n\t\t\t\t\t\t\tstate\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if ( stream.match( /^{(?!{(?!{))[\\s\\u00a0]*/ ) ) {\n\t\t\t\t\t\t// Parser function\n\t\t\t\t\t\tif ( stream.peek() === '#' ) {\n\t\t\t\t\t\t\tstate.nExt++;\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.inParserFunctionName.bind( this );\n\t\t\t\t\t\t\treturn this.makeLocalStyle(\n\t\t\t\t\t\t\t\tmodeConfig.tags.parserFunctionBracket,\n\t\t\t\t\t\t\t\tstate\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Check for parser function without '#'\n\t\t\t\t\t\t// eslint-disable-next-line security/detect-unsafe-regex\n\t\t\t\t\t\tname = stream.match( /^([^\\s\\u00a0}[\\]<{'|&:]+)(:|[\\s\\u00a0]*)(\\}\\}?)?(.)?/ );\n\t\t\t\t\t\tif ( name ) {\n\t\t\t\t\t\t\tstream.backUp( name[ 0 ].length );\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t( name[ 2 ] === ':' || name[ 4 ] === undefined || name[ 3 ] === '}}' ) &&\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tname[ 1 ].toLowerCase() in this.config.functionSynonyms[ 0 ] ||\n\t\t\t\t\t\t\t\t\tname[ 1 ] in this.config.functionSynonyms[ 1 ]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tstate.nExt++;\n\t\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\t\tstate.tokenize = this.inParserFunctionName.bind( this );\n\t\t\t\t\t\t\t\treturn this.makeLocalStyle(\n\t\t\t\t\t\t\t\t\tmodeConfig.tags.parserFunctionBracket,\n\t\t\t\t\t\t\t\t\tstate\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Template\n\t\t\t\t\t\tstate.nTemplate++;\n\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\tstate.tokenize = this.eatTemplatePageName( false );\n\t\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.templateBracket, state );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase '<':\n\t\t\t\t\tisCloseTag = !!stream.eat( '/' );\n\t\t\t\t\ttagname = stream.match( /^[^>/\\s\\u00a0.*,[\\]{}$^+?|/\\\\'`~<=!@#%&()-]+/ );\n\t\t\t\t\tif ( stream.match( '!--' ) ) { // comment\n\t\t\t\t\t\treturn chain( this.eatBlock( modeConfig.tags.comment, '-->' ) );\n\t\t\t\t\t}\n\t\t\t\t\tif ( tagname ) {\n\t\t\t\t\t\ttagname = tagname[ 0 ].toLowerCase();\n\t\t\t\t\t\tif ( tagname in this.config.tags ) {\n\t\t\t\t\t\t\t// Parser function\n\t\t\t\t\t\t\tif ( isCloseTag === true ) {\n\t\t\t\t\t\t\t\treturn modeConfig.tags.error;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstream.backUp( tagname.length );\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.eatTagName( tagname.length, isCloseTag, false );\n\t\t\t\t\t\t\treturn this.makeLocalStyle( `${ modeConfig.tags.extTagBracket } mw-ext-${ tagname }`, state );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( tagname in modeConfig.permittedHtmlTags ) {\n\t\t\t\t\t\t\t// Html tag\n\t\t\t\t\t\t\tif ( isCloseTag === true && tagname !== state.inHtmlTag.pop() ) {\n\t\t\t\t\t\t\t\t// Increment position so that the closing '>' gets highlighted red.\n\t\t\t\t\t\t\t\tstream.pos++;\n\t\t\t\t\t\t\t\treturn modeConfig.tags.error;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tisCloseTag === true &&\n\t\t\t\t\t\t\t\ttagname in modeConfig.implicitlyClosedHtmlTags\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn modeConfig.tags.error;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstream.backUp( tagname.length );\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.eatTagName(\n\t\t\t\t\t\t\t\ttagname.length,\n\t\t\t\t\t\t\t\t// Opening void tags should also be treated as the closing tag.\n\t\t\t\t\t\t\t\tisCloseTag ||\n\t\t\t\t\t\t\t\t\t( tagname in modeConfig.implicitlyClosedHtmlTags ),\n\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn this.makeLocalStyle( modeConfig.tags.htmlTagBracket, state );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstream.backUp( tagname.length );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase '~':\n\t\t\t\t\tif ( stream.match( /^~{2,4}/ ) ) {\n\t\t\t\t\t\treturn modeConfig.tags.signature;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t// Maybe double underscored Magic Word such as __TOC__\n\t\t\t\tcase '_':\n\t\t\t\t\ttmp = 1;\n\t\t\t\t\t// Optimize processing of many underscore symbols\n\t\t\t\t\twhile ( stream.eat( '_' ) ) {\n\t\t\t\t\t\ttmp++;\n\t\t\t\t\t}\n\t\t\t\t\t// Many underscore symbols\n\t\t\t\t\tif ( tmp > 2 ) {\n\t\t\t\t\t\tif ( !stream.eol() ) {\n\t\t\t\t\t\t\t// Leave last two underscore symbols for processing in next iteration\n\t\t\t\t\t\t\tstream.backUp( 2 );\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Optimization: skip regex function for EOL and backup-ed symbols\n\t\t\t\t\t\treturn this.makeStyle( style, state );\n\t\t\t\t\t// Check on double underscore Magic Word\n\t\t\t\t\t} else if ( tmp === 2 ) {\n\t\t\t\t\t\t// The same as the end of function except '_' inside and '__' at the end.\n\t\t\t\t\t\tname = stream.match( /^([^\\s\\u00a0>}[\\]<{'|&:~]+?)__/ );\n\t\t\t\t\t\tif ( name && name[ 0 ] ) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t'__' + name[ 0 ].toLowerCase() in this.config.doubleUnderscore[ 0 ] ||\n\t\t\t\t\t\t\t\t'__' + name[ 0 ] in this.config.doubleUnderscore[ 1 ]\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn modeConfig.tags.doubleUnderscore;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( !stream.eol() ) {\n\t\t\t\t\t\t\t\t// Two underscore symbols at the end can be the\n\t\t\t\t\t\t\t\t// beginning of another double underscored Magic Word\n\t\t\t\t\t\t\t\tstream.backUp( 2 );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Optimization: skip regex for EOL and backup-ed symbols\n\t\t\t\t\t\t\treturn this.makeStyle( style, state );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tif ( /[\\s\\u00a0]/.test( ch ) ) {\n\t\t\t\t\t\tstream.eatSpace();\n\t\t\t\t\t\t// highlight free external links, bug T108448\n\t\t\t\t\t\tif ( stream.match( this.urlProtocols, false ) && !stream.match( '//' ) ) {\n\t\t\t\t\t\t\tstate.stack.push( state.tokenize );\n\t\t\t\t\t\t\tstate.tokenize = this.eatFreeExternalLinkProtocol.bind( this );\n\t\t\t\t\t\t\treturn this.makeStyle( style, state );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tstream.match( /^[^\\s\\u00a0_>}[\\]<{'|&:~=]+/ );\n\t\t\treturn this.makeStyle( style, state );\n\t\t};\n\t}\n\n\t/**\n\t * Remembers position and status for rollbacking.\n\t * It is needed for changing from bold to italic with apostrophes before it, if required.\n\t *\n\t * @see https://phabricator.wikimedia.org/T108455\n\t *\n\t * @param {StringStream} stream\n\t */\n\tprepareItalicForCorrection( stream ) {\n\t\t// See Parser::doQuotes() in MediaWiki Core, it works similarly.\n\t\t// this.firstSingleLetterWord has maximum priority\n\t\t// this.firstMultiLetterWord has medium priority\n\t\t// this.firstSpace has low priority\n\t\tconst end = stream.pos,\n\t\t\tstr = stream.string.slice( 0, end - 3 ),\n\t\t\tx1 = str.slice( -1 ),\n\t\t\tx2 = str.slice( -2, -1 );\n\n\t\t// this.firstSingleLetterWord always is undefined here\n\t\tif ( x1 === ' ' ) {\n\t\t\tif ( this.firstMultiLetterWord || this.firstSpace ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.firstSpace = end;\n\t\t} else if ( x2 === ' ' ) {\n\t\t\tthis.firstSingleLetterWord = end;\n\t\t} else if ( this.firstMultiLetterWord ) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tthis.firstMultiLetterWord = end;\n\t\t}\n\t\t// remember bold and italic state for later restoration\n\t\tthis.wasBold = this.isBold;\n\t\tthis.wasItalic = this.isItalic;\n\t}\n\n\t/**\n\t * @see https://codemirror.net/docs/ref/#language.StreamParser\n\t * @return {StreamParser}\n\t */\n\tget mediawiki() {\n\t\treturn {\n\t\t\tname: 'mediawiki',\n\n\t\t\t/**\n\t\t\t * Initial State for the parser.\n\t\t\t *\n\t\t\t * @return {Object}\n\t\t\t */\n\t\t\tstartState: () => {\n\t\t\t\treturn {\n\t\t\t\t\ttokenize: this.eatWikiText( '' ),\n\t\t\t\t\tstack: [],\n\t\t\t\t\tinHtmlTag: [],\n\t\t\t\t\textName: false,\n\t\t\t\t\textMode: false,\n\t\t\t\t\textState: false,\n\t\t\t\t\tnTemplate: 0,\n\t\t\t\t\tnLink: 0,\n\t\t\t\t\tnExt: 0\n\t\t\t\t};\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Copies the given state.\n\t\t\t *\n\t\t\t * @param {Object} state\n\t\t\t * @return {Object}\n\t\t\t */\n\t\t\tcopyState: ( state ) => {\n\t\t\t\treturn {\n\t\t\t\t\ttokenize: state.tokenize,\n\t\t\t\t\tstack: state.stack.concat( [] ),\n\t\t\t\t\tinHtmlTag: state.inHtmlTag.concat( [] ),\n\t\t\t\t\textName: state.extName,\n\t\t\t\t\textMode: state.extMode,\n\t\t\t\t\textState: state.extMode !== false && state.extMode.copyState( state.extState ),\n\t\t\t\t\tnTemplate: state.nTemplate,\n\t\t\t\t\tnLink: state.nLink,\n\t\t\t\t\tnExt: state.nExt\n\t\t\t\t};\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Reads one token, advancing the stream past it,\n\t\t\t * and returning a string indicating the token's style tag.\n\t\t\t *\n\t\t\t * @param {StringStream} stream\n\t\t\t * @param {Object} state\n\t\t\t * @return {string|null}\n\t\t\t */\n\t\t\ttoken: ( stream, state ) => {\n\t\t\t\tlet style, p, t, f,\n\t\t\t\t\treadyTokens = [],\n\t\t\t\t\ttmpTokens = [];\n\n\t\t\t\tif ( this.oldTokens.length > 0 ) {\n\t\t\t\t\t// just send saved tokens till they exists\n\t\t\t\t\tt = this.oldTokens.shift();\n\t\t\t\t\tstream.pos = t.pos;\n\t\t\t\t\tstate = t.state;\n\t\t\t\t\treturn t.style;\n\t\t\t\t}\n\n\t\t\t\tif ( stream.sol() ) {\n\t\t\t\t\t// reset bold and italic status in every new line\n\t\t\t\t\tthis.isBold = false;\n\t\t\t\t\tthis.isItalic = false;\n\t\t\t\t\tthis.firstSingleLetterWord = null;\n\t\t\t\t\tthis.firstMultiLetterWord = null;\n\t\t\t\t\tthis.firstSpace = null;\n\t\t\t\t}\n\n\t\t\t\tdo {\n\t\t\t\t\t// get token style\n\t\t\t\t\tstyle = state.tokenize( stream, state );\n\t\t\t\t\tf = this.firstSingleLetterWord || this.firstMultiLetterWord || this.firstSpace;\n\t\t\t\t\tif ( f ) {\n\t\t\t\t\t\t// rollback point exists\n\t\t\t\t\t\tif ( f !== p ) {\n\t\t\t\t\t\t\t// new rollback point\n\t\t\t\t\t\t\tp = f;\n\t\t\t\t\t\t\t// it's not first rollback point\n\t\t\t\t\t\t\tif ( tmpTokens.length > 0 ) {\n\t\t\t\t\t\t\t\t// save tokens\n\t\t\t\t\t\t\t\treadyTokens = readyTokens.concat( tmpTokens );\n\t\t\t\t\t\t\t\ttmpTokens = [];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// save token\n\t\t\t\t\t\ttmpTokens.push( {\n\t\t\t\t\t\t\tpos: stream.pos,\n\t\t\t\t\t\t\tstyle,\n\t\t\t\t\t\t\tstate: ( state.extMode || this.mediawiki ).copyState( state )\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// rollback point does not exist\n\t\t\t\t\t\t// remember style before possible rollback point\n\t\t\t\t\t\tthis.oldStyle = style;\n\t\t\t\t\t\t// just return token style\n\t\t\t\t\t\treturn style;\n\t\t\t\t\t}\n\t\t\t\t} while ( !stream.eol() );\n\n\t\t\t\tif ( this.isBold && this.isItalic ) {\n\t\t\t\t\t// needs to rollback\n\t\t\t\t\t// restore status\n\t\t\t\t\tthis.isItalic = this.wasItalic;\n\t\t\t\t\tthis.isBold = this.wasBold;\n\t\t\t\t\tthis.firstSingleLetterWord = null;\n\t\t\t\t\tthis.firstMultiLetterWord = null;\n\t\t\t\t\tthis.firstSpace = null;\n\t\t\t\t\tif ( readyTokens.length > 0 ) {\n\t\t\t\t\t\t// it contains tickets before the point of rollback\n\t\t\t\t\t\t// add one apostrophe, next token will be italic (two apostrophes)\n\t\t\t\t\t\treadyTokens[ readyTokens.length - 1 ].pos++;\n\t\t\t\t\t\t// for sending tokens till the point of rollback\n\t\t\t\t\t\tthis.oldTokens = readyTokens;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// there are no tickets before the point of rollback\n\t\t\t\t\t\tstream.pos = tmpTokens[ 0 ].pos - 2; // eat( '\\'')\n\t\t\t\t\t\t// send saved Style\n\t\t\t\t\t\treturn this.oldStyle;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// do not need to rollback\n\t\t\t\t\t// send all saved tokens\n\t\t\t\t\tthis.oldTokens = readyTokens.concat( tmpTokens );\n\t\t\t\t}\n\t\t\t\t// return first saved token\n\t\t\t\tt = this.oldTokens.shift();\n\t\t\t\tstream.pos = t.pos;\n\t\t\t\tstate = t.state;\n\t\t\t\treturn t.style;\n\t\t\t},\n\n\t\t\tblankLine: ( state ) => {\n\t\t\t\tif ( state.extMode && state.extMode.blankLine ) {\n\t\t\t\t\tstate.extMode.blankLine( state.extState );\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Extra tokens to use in this parser.\n\t\t\t *\n\t\t\t * @see CodeMirrorModeMediaWikiConfig.tokenTable\n\t\t\t * @return {Object<Tag>}\n\t\t\t */\n\t\t\ttokenTable: this.tokenTable\n\t\t};\n\t}\n}\n\n/**\n * Gets a LanguageSupport instance for the MediaWiki mode.\n *\n * @example\n * import { mediaWikiLang } from './codemirror.mode.mediawiki';\n * const cm = new CodeMirror( textarea );\n * cm.initialize( [ ...cm.defaultExtensions, mediaWikiLang() ] );\n *\n * @param {Object|null} [config] Used only by unit tests.\n * @return {LanguageSupport}\n */\nexport const mediaWikiLang = ( config = null ) => {\n\tconst mode = new CodeMirrorModeMediaWiki(\n\t\tconfig || mw.config.get( 'extCodeMirrorConfig' )\n\t);\n\tconst parser = mode.mediawiki;\n\tconst lang = StreamLanguage.define( parser );\n\tconst highlighter = syntaxHighlighting(\n\t\tHighlightStyle.define(\n\t\t\tmodeConfig.getTagStyles( parser )\n\t\t)\n\t);\n\treturn new LanguageSupport( lang, highlighter );\n};\n","import CodeMirrorWikiEditor from './codemirror.wikieditor';\nimport { mediaWikiLang } from './codemirror.mode.mediawiki';\n\nif ( mw.loader.getState( 'ext.wikiEditor' ) ) {\n\tmw.hook( 'wikiEditor.toolbarReady' ).add( ( $textarea ) => {\n\t\tconst cmWE = new CodeMirrorWikiEditor( $textarea, mediaWikiLang() );\n\t\tcmWE.addCodeMirrorToWikiEditor();\n\t} );\n}\n"],"names":["Text","lineAt","pos","this","length","RangeError","lineInner","line","n","lines","replace","from","to","text","parts","decompose","TextNode","append","other","slice","eq","start","scanIdentical","end","a","RawTextCursor","b","skip","next","lineBreak","done","value","iter","dir","iterRange","PartialTextCursor","iterLines","inner","Math","max","LineCursor","toString","sliceString","toJSON","flatten","constructor","of","TextLeaf","split","empty","textLength","super","children","target","isLine","offset","i","string","Line","open","sliceText","min","prev","pop","joined","appendText","push","mid","newLen","lineSep","result","part","len","child","endLine","childOpen","updated","totalLines","copy","iA","iB","eA","eB","chA","chB","reduce","l","ch","flat","chunk","maxChunk","minChunk","chunked","currentLines","currentLen","currentChunk","add","last","node","flush","concat","first","nodes","offsets","nextInner","top","offsetValue","size","cursor","limit","afterBreak","Symbol","prototype","iterator","number","extend","map","s","parseInt","isExtendingChar","code","isRegionalIndicator","ZWJ","findClusterBreak","str","forward","includeExtending","nextClusterBreak","prevClusterBreak","surrogateLow","charCodeAt","surrogateHigh","codePointAt","codePointSize","countBefore","found","code0","code1","fromCodePoint","String","fromCharCode","DefaultSplit","MapMode","ChangeDesc","sections","newLength","ins","iterGaps","f","posA","posB","iterChangedRanges","individual","iterChanges","invertedDesc","composeDesc","composeSets","mapDesc","before","mapSet","mapPos","assoc","mode","Simple","endA","TrackDel","TrackBefore","TrackAfter","touchesRange","fromJSON","json","Array","isArray","some","create","ChangeSet","inserted","apply","doc","fromA","toA","fromB","_toB","invert","index","compose","desc","filter","ranges","resultSections","resultInserted","filteredSections","SectionIter","addSection","off","addInsert","changes","filtered","total","force","set","process","spec","sub","insert","insText","insLen","e","createSet","forceJoin","values","endB","setA","setB","mkSet","piece","Error","left","len2","sectionLen","insB","textBit","forward2","undefined","SelectionRange","flags","anchor","head","bidiLevel","level","goalColumn","change","range","abs","mainIndex","r","main","asSingle","addRange","replaceRange","which","single","normalized","sort","indexOf","splice","checkSelection","selection","docLength","nextID","Facet","combine","compareInput","compare","isStatic","enables","id","default","extensions","define","config","sameArray","static","FacetProvider","compute","deps","get","computeN","field","x","state","every","dependencies","facet","type","dynamicSlot","addresses","_a","getter","idx","multi","depDoc","depSel","depAddrs","dep","update","tr","docChanged","ensureAll","newVal","compareArray","reconfigure","oldState","oldAddr","address","oldVal","getAddr","addrs","changed","addr","ensureAddr","dynamicFacetSlot","providers","providerAddrs","p","providerTypes","dynamic","val","depChanged","oldProviders","facets","oldValue","initField","createF","updateF","compareF","provides","provide","init","find","slot","extension","prec","ext","PrecExtension","Prec","highest","high","low","lowest","Compartment","CompartmentInstance","content","compartment","compartments","Configuration","base","dynamicSlots","staticValues","statusTemplate","staticFacet","resolve","fields","Object","newCompartments","Map","seen","known","delete","has","oldFacets","status","computeSlot","languageData","allowMultipleSelections","v","lineSeparator","changeFilter","transactionFilter","transactionExtender","readOnly","Annotation","AnnotationType","StateEffectType","mapping","mapped","is","mapEffects","effects","effect","appendConfig","Transaction","startState","annotations","scrollIntoView","_doc","_state","time","Date","now","newDoc","newSelection","applyTransaction","annotation","ann","reconfigured","isUserEvent","event","userEvent","joinRanges","mergeTransaction","sequential","mapForA","mapForB","resolveTransactionInner","docSize","sel","asArray","resolveTransaction","specs","seq","extenders","keys","extendTransaction","back","filters","filterTransaction","addToHistory","remote","none","CharCategory","nonASCIISingleCaseWordChar","wordChar","RegExp","_","require","startValues","conf","forEach","key","replaceSelection","toText","changeByRange","result1","newChanges","newMapped","j","mapBy","sliceDoc","prop","fieldInit","hasOwnProperty","call","configuration","tabSize","phrase","phrases","m","languageDataAt","name","side","provider","charCategorizer","at","wordChars","join","char","test","Space","toUpperCase","toLowerCase","hasWordChar","Word","Other","wordAt","cat","combineConfig","configs","defaults","current","kA","kB","k","RangeValue","Range","startSide","endSide","point","mapMode","cmpRange","Chunk","maxPoint","findIndex","startAt","arr","lo","hi","diff","between","newPos","newFrom","newTo","curFrom","curTo","chunkPos","nextLayer","chunkEnd","isEmpty","updateSpec","filterFrom","filterTo","cur","LayerCursor","goto","spill","builder","addInner","rangeIndex","chunkIndex","addChunk","nextChunk","finishInner","chunks","touch","HeapCursor","sets","oldSets","newSets","textDiff","comparator","minPointSize","sharedChunks","findSharedChunks","sideA","SpanCursor","sideB","sameValues","active","spans","openRanges","openStart","activeForPoint","openCount","pointFrom","pointRank","openEnd","span","build","lazySort","finish","finishChunk","newArrays","chunkStart","setMaxPoint","lastFrom","lastTo","inA","shared","Set","layer","minPoint","rank","gotoInner","setRangeIndex","heap","heapBubble","childIndex","activeTo","activeRank","minActive","removeActive","remove","findMinIndex","addActive","trackOpen","wasPoint","nextVal","reverse","startA","startB","dPos","clipEnd","comparePoint","compareRange","array","foundPos","COUNT","for","SET","floor","random","globalThis","window","StyleModule","options","rules","splitSelector","selector","render","selectors","isKeyframes","local","isAt","exec","keyframes","getRules","newName","mount","root","modules","nonce","setNonce","StyleSet","adoptedSet","ownerDocument","win","defaultView","adoptedStyleSheets","CSSStyleSheet","adopted","sheet","styleTag","createElement","setAttribute","insertBefore","firstChild","mod","insertRule","textContent","getAttribute","shift","mac","navigator","platform","ie","userAgent","getSelection","nodeType","contains","dom","parentNode","hasSelection","anchorNode","clientRectsFor","textRange","nodeValue","getClientRects","isEquivalentPosition","targetNode","targetOff","scanFor","domIndex","previousSibling","maxOffset","nodeName","parent","childNodes","contentEditable","flattenRect","rect","right","bottom","windowRect","innerWidth","innerHeight","getScale","elt","scaleX","width","offsetWidth","scaleY","height","offsetHeight","isFinite","DOMSelectionState","anchorOffset","focusNode","focusOffset","domSel","setRange","scratchRange","preventScrollSupported","focusPreventScroll","setActive","focus","stack","scrollTop","scrollLeft","preventScroll","document","createRange","setEnd","setStart","dispatchKey","keyCode","cancelable","down","KeyboardEvent","synthetic","dispatchEvent","up","defaultPrevented","clearAttributes","attributes","removeAttributeNode","isScrolledToBottom","scrollHeight","clientHeight","DOMPos","precise","after","noChildren","ContentView","overrideDOMText","posAtStart","posBefore","posAtEnd","view","breakAfter","posAfter","sync","track","nextSibling","contentView","canReuseDOM","reuseDOM","written","rm$1","_dom","localPosFromDOM","bias","lastChild","domBoundsAround","fromI","fromStart","toI","toEnd","prevEnd","startDOM","endDOM","markDirty","andParent","markParentsDirty","childList","setParent","setDOM","cmView","rootView","replaceChildren","destroy","ignoreMutation","_rec","ignoreEvent","_event","childCursor","ChildCursor","childPos","findPos","isEditable","isWidget","isHidden","merge","source","hasStart","become","getSide","removeChild","fromOff","toOff","breakAtStart","breakAtEnd","mergeChildrenInto","dLen","nav","vendor","documentElement","style","ie_edge","ie_upto10","ie_11up","gecko","chrome","webkit","safari","ios","maxTouchPoints","browser","windows","linux","ie_version","documentMode","gecko_version","chrome_version","android","webkit_version","TextView","createDOM","textDOM","createTextNode","domAtPos","_from","_to","coordsAt","rects","textCoords","MarkView","mark","setAttrs","class","className","attrs","tagName","_hasStart","detachFrom","inlineDOMAtPos","coordsInChildren","WidgetView","widget","prevWidget","updateDOM","toDOM","custom","fromBack","WidgetBufferView","getBoundingClientRect","joinInlineInto","beforePos","afterPos","scan","fallbackRect","combineAttrs","noAttrs","attrsEq","ignore","keysA","keysB","updateAttrs","cssText","removeAttribute","getAttrs","attr","LineView","arguments","prevAttrs","transferDOM","setDeco","addLineDeco","deco","cls","classList","hack","cmIgnore","appendChild","measureTextSize","textHeight","totalWidth","lineHeight","charWidth","heightOracle","viewState","dist","_other","covers","docView","block","BlockWidgetView","_takeDeco","WidgetType","estimatedHeight","lineBreaks","BlockType","Decoration","heightRelevant","MarkDecoration","inlineOrder","PointDecoration","isBlockGap","getInclusive","LineDecoration","hasHeight","_b","isReplace","WidgetRange","WidgetBefore","WidgetAfter","inclusiveStart","inclusiveEnd","inclusive","margin","ContentBuilder","disallowBlockEffectsFor","curLine","pendingBuffer","bufferMarks","atCursorPos","textOff","posCovered","getLine","flushBuffer","wrapMarks","addBlockWidget","buildText","take","NullWidget","cursorBefore","cursorAfter","decorations","dynamicDecorationMap","tag","clickAddsSelectionRange","dragMovesSelection$1","mouseSelectionStyle","exceptionSink","updateListener","inputHandler","focusChangeEffect","perLineTextDirection","nativeSelectionHidden","ScrollTarget","y","yMargin","xMargin","isSnapshot","clip","t","logException","exception","context","handler","onerror","console","error","editable","nextPluginID","viewPlugin","domEventHandlers","domEventObservers","buildExtensions","eventHandlers","eventObservers","plugin","pluginInst","fromClass","PluginInstance","mustUpdate","deactivate","editorAttributes","contentAttributes","atomicRanges","bidiIsolatedRanges","getIsolatedRanges","isolates","Function","iso","bidiIsolate","direction","scrollMargins","getScrollMargins","styleModule","ChangedRange","toB","addToSet","me","extendWithRanges","dI","rI","ViewUpdate","transactions","changedRanges","viewportChanged","heightChanged","geometryChanged","focusChanged","selectionSet","Direction","LTR","RTL","dec","LowTypes","ArabicTypes","Brackets","BracketStack","BidiRE","BidiSpan","order","maybe","isolatesEq","types","emitSpans","baseLevel","ourType","iCh","iI","sameDir","isNum","recurse","localLevel","iScan","run","upto","jI","computeSectionOrder","outerType","rFrom","rTo","prevType","prevStrong","computeCharTypes","oppositeType","sI","br","sJ","embed","processBracketPairs","beforeL","fromJ","processNeutrals","trivialOrder","movedOver","moveVisually","startIndex","spanI","indexForward","nextIndex","nextSpan","DocView","domChanged","hasComposition","markedForComposition","minWidth","minWidthFrom","minWidthTo","impreciseAnchor","impreciseHead","forceSelection","lastUpdate","contentDOM","updateDeco","updateInner","readCompositionAt","inputState","composing","newSel","composition","touched","touchesComposition","headPos","findCompositionNode","textNode","inv","marks","parentView","findCompositionRange","clear","decoDiff","comp","DecorationComparator$1","findChangedDeco","oldLength","mustMeasureContent","updateChildren","observer","contentHeight","flexBasis","selectionRange","cView","gaps","viewport","BlockGapWidget","updateGaps","compLine","compositionView","fixCompositionDOM","fix","c","updateSelection","mustRead","fromPointer","readSelectionRange","activeElt","activeElement","focused","selectionNotFocus","moveToLine","dummy","inside","assignedSlot","inUneditable","blur","rawSel","nextTo","nearbyTextNode","collapse","caretBidiLevel","removeAllRanges","setSelectionRange","enforceCursorAssoc","modify","lineStart","newRange","posFromDOM","nearest","domView","best","bestPos","coordsForChar","childOff","measureVisibleLineHeights","contentWidth","clientWidth","isWider","scrollDOM","widest","ltr","textDirection","childRect","textDirectionAt","getComputedStyle","measure","position","computeBlockGapDeco","vs","viewports","lineBlockAt","allDeco","d","lineGapDeco","ref","margins","targetRect","stop","bounding","body","scrollWidth","moveX","moveY","rectHeight","boundingHeight","scrollBy","movedX","movedY","host","scrollRectIntoView","startNode","startOffset","getdx","getdy","yOverlap","upTop","upBot","domPosAtCoords","closest","closestRect","closestX","closestY","above","below","aboveRect","belowRect","closestOverlap","dx","dy","domPosInText","clipX","closestOffset","closestDY","generalSide","posAtCoords","coords","docTop","paddingTop","docHeight","yOffset","halfLine","bounced","elementAtHeight","posAtCoordsImprecise","elementFromPoint","element","caretPositionFromPoint","offsetNode","caretRangeFromPoint","startContainer","isSuspiciousSafariCaretResult","isSuspiciousChromeCaretResult","contentRect","into","round","defaultCharacterWidth","lineWrapping","defaultLineHeight","lineLength","col","strict","blockAt","moveByChar","by","bidiSpans","check","skipAtomicRanges","atoms","moved","skipAtoms","oldPos","InputState","setSelectionOrigin","origin","lastSelectionOrigin","lastSelectionTime","lastKeyCode","lastKeyTime","lastTouchTime","lastFocusTime","lastScrollTop","lastScrollLeft","pendingIOSKey","lastEscPress","lastContextMenu","scrollHandlers","handlers","compositionFirstChange","compositionEndedAt","compositionPendingKey","compositionPendingChange","mouseSelection","draggedContent","handleEvent","bind","notifiedFocused","hasFocus","addEventListener","appliedFirefoxHack","firefoxCopyCutHack","bubbles","eventBelongsToEditor","ignoreDuringComposition","keydown","runHandlers","observers","preventDefault","ensureHandlers","plugins","computeHandlers","passive","exists","removeEventListener","modifierCodes","delayAndroidKey","pending","altKey","metaKey","PendingKeys","ctrlKey","EmacsyPendingKeys","shiftKey","forceFlush","setTimeout","flushIOSKey","startMouseSelection","bindHandler","record","inputType","dragScrollSpeed","MouseSelection","startEvent","mustSelect","scrollSpeed","scrolling","lastEvent","scrollParent","scrollableParent","move","multiple","addsSelectionRange","dragging","rangeCount","getRangeAt","clientX","clientY","isInPrimarySelection","getClickType","select","buttons","sx","sy","setScrollSpeed","setInterval","scroll","clearInterval","dispatch","brokenClipboardAPI","doPaste","input","byLine","lastLinewiseCopy","lastLine","rangeForClick","categorize","linePos","groupAt","visual","touchstart","touchmove","mousedown","makeStyle","button","queryPos","startSel","removed","startRange","removeRangeAround","basicMouseSelection","mustFocus","mouseSel","insideY","findPositionSide","BadMouseDetail","lastMouseDown","lastMouseDownCount","lastMouseDownTime","detail","lastTime","dropText","direct","dropPos","del","dragMovesSelection","dragstart","draggable","dataTransfer","setData","effectAllowed","dragend","drop","files","read","finishFile","reader","FileReader","onload","readAsText","getData","paste","data","clipboardData","capturePaste","cut","linewise","copiedRange","clearData","selectionEnd","selectionStart","captureCopy","isFocusChange","focusChangeTransaction","getEffect","updateForFocusChange","clearSelectionRange","compositionstart","compositionupdate","compositionend","pendingRecords","flushSoon","Promise","then","contextmenu","beforeinput","startViewHeight","visualViewport","wrappingWhiteSpace","HeightOracle","heightSamples","heightForGap","ceil","heightForLine","setDoc","mustRefreshForWrapping","whiteSpace","mustRefreshForHeights","lineHeights","newHeight","h","refresh","knownHeights","MeasuredHeights","heights","more","BlockInfo","_content","widgetLineBreaks","QueryType","Epsilon","HeightMap","outdated","setHeight","oracle","decomposeLeft","decomposeRight","applyChanges","oldDoc","ByPosNoHeight","NodeBuilder","updateHeight","HeightMapText","break","brk","HeightMapBranch","HeightMapBlock","_height","_oracle","_value","_type","forEachLine","_force","measured","collapsed","widgetHeight","breaks","HeightMapGap","heightMetrics","perLine","firstLine","perChar","totalPerLine","guess","lineTop","ByHeight","linesAbove","unshift","singleHeight","rightTop","rightOffset","subQuery","ByPos","rightStart","balanced","mergeGaps","rebalance","around","lineEnd","covering","writtenTo","isCovered","addBlock","enterLine","blankContent","gap","ensureLine","DecorationComparator","visiblePixelRange","overflow","parentRect","offsetParent","fullPixelRange","LineGap","same","gA","gB","draw","wrapping","LineGapWidget","vertical","display","ViewState","pixelViewport","inView","paddingBottom","contentDOMWidth","contentDOMHeight","editorHeight","editorWidth","scrolledToBottom","scrollAnchorPos","scrollAnchorHeight","scaler","IdScaler","scrollTarget","printing","defaultTextDirection","visibleRanges","mustEnforceCursorAssoc","guessWrapping","stateDeco","heightMap","getViewport","updateViewportLines","updateForViewport","lineGaps","ensureLineGaps","computeVisibleRanges","Viewport","BigScaler","viewportLines","scale","scaleBlock","prevDeco","contentChanges","heightChanges","heightRelevantDecoChanges","prevHeight","scrollAnchor","scrollAnchorAt","mapViewport","viewportIsAppropriate","updateLines","updateLineGaps","mapLineGaps","domRect","measureContent","dTop","dBottom","vp","viewportChange","visibleTop","fromDOM","visibleBottom","marginTop","topPos","viewHeight","mayMeasure","halfMargin","doubleMargin","addGap","structure","avoid","moveToLineBoundary","gapSize","lineStructure","viewFrom","viewTo","bot","marginHeight","targetFrac","findFraction","spaceFrac","findPosition","marginWidth","fraction","lineBlockAtHeight","ratio","counted","vpHeight","domBase","domTop","domBottom","obj","bTop","bBottom","theme","strs","darkTheme","baseThemeID","baseLightID","baseDarkID","lightDarkIDs","buildTheme","scopes","baseTheme$1","boxSizing","outline","flexDirection","alignItems","fontFamily","overflowX","zIndex","flexGrow","flexShrink","wordWrap","minHeight","padding","WebkitUserModify","whiteSpace_fallback","wordBreak","overflowWrap","caretColor","contain","background","pointerEvents","animation","opacity","borderLeft","marginLeft","borderLeftColor","backgroundColor","color","insetInlineStart","borderRight","textAlign","borderBottom","borderTop","verticalAlign","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat","fontSize","borderRadius","border","LineBreakPlaceholder","DOMReader","points","readRange","findPointBefore","oldLen","readNode","nextView","isBlockElement","readTextNode","re","nextBreak","breakSize","fromView","findPointInside","isAtEnd","DOMPoint","DOMChange","typeOver","bounds","iHead","iAnchor","selPoints","selectionPoints","selectionFromPoints","applyDOMChange","domChange","lastKey","preferredPos","preferredSide","minLen","findDiff","defaultTr","defaultInsert","mainSel","compositionRange","replaced","rangeChanges","selOff","applyDefaultInsert","observeOptions","characterData","subtree","characterDataOldValue","useCharData","DOMObserver","selectionChanged","delayedFlush","resizeTimeout","queue","delayedAndroidKey","flushingAndroidKey","lastChange","scrollTargets","intersection","resizeScroll","intersecting","gapIntersection","parentCheck","MutationObserver","mutations","mut","removedNodes","onCharData","prevValue","onSelectionChange","onResize","onPrint","onScroll","ResizeObserver","observe","addWindowListeners","IntersectionObserver","entries","listenForScroll","intersectionRatio","onScrollChanged","createEvent","threshold","requestMeasure","g","disconnect","wasChanged","shadowRoot","deepActiveElement","stopImmediatePropagation","getTargetRanges","execCommand","endContainer","endOffset","curAnchor","safariSelectionRangeHack","atElementStart","processRecords","clearDelayedAndroidKey","requestAnimationFrame","cancelAnimationFrame","takeRecords","records","readMutation","readChange","readSelection","handled","rec","childBefore","findChild","childAfter","setWindow","removeWindowListeners","_c","clearTimeout","curView","EditorView","compositionStarted","_root","pluginMap","editorAttrs","contentAttrs","bidiCache","destroyed","updateState","measureScheduled","measureRequests","tabIndex","announceDOM","dispatchTransactions","trs","getRoot","scrollTo","mountStyles","redrawn","attrsChanged","focusFlag","dispatchFocus","pendingKey","setState","CachedOrder","updatePlugins","styleModules","showAnnouncements","listener","newState","hadFocus","prevSpecs","newPlugins","sDOM","warn","measuring","BadMeasure","write","themeClasses","attrsFromFacet","spellcheck","autocorrect","autocapitalize","translate","contenteditable","role","changedContent","changedEditor","announce","cspNonce","readMeasured","request","documentTop","documentPadding","viewportLineBlocks","moveByGroup","initial","nextCat","byGroup","includeWrap","coordsAtPos","editorRect","moveVertically","distance","startPos","startY","goal","startCoords","resolvedGoal","extra","curY","charRect","posAtDOM","MaxBidiLine","entry","fresh","computeOrder","setRoot","scrollSnapshot","prefix","dark","baseTheme","findFromDOM","querySelector","cache","lastDir","sources","currentPlatform","modifiers","handleKeyEvents","getKeymap","keymap","Keymaps","WeakMap","bindings","bound","isPrefix","checkPrefix","scope","command","stopPropagation","scopeObj","alt","ctrl","meta","normalizeKeyName","ourObj","storedPrefix","PrefixTimeout","full","binding","_any","any","buildKeymap","keyName","isChar","prevented","baseName","shiftName","ran","runFor","cmd","RectangleMarker","adjust","forRange","getBase","lineElt","lineStyle","leftSide","paddingLeft","textIndent","rightSide","paddingRight","startBlock","endBlock","visualStart","visualEnd","wrappedLine","pieces","drawForLine","drawForWidget","horizontal","addSpan","fromOpen","toOpen","fromCoords","toCoords","endPos","docLine","spanFrom","spanTo","rectanglesForRange","LayerView","drawn","measureReq","setOrder","layerOrder","markers","transform","old","oldI","marker","CanHidePrimary","selectionConfig","cursorBlinkRate","drawRangeCursor","drawSelection","cursorLayer","selectionLayer","hideNativeSelection","configChanged","cursors","prim","animationName","confChange","setBlinkRate","animationDuration","themeSpec","iterMatches","lastIndex","MatchDecorator","regexp","decoration","decorate","boundary","maxLength","global","addMatch","match","_view","createDeco","visible","matchRanges","changeFrom","changeTo","_f","_t","updateRange","updateFrom","updateTo","fromLine","toLine","UnicodeRegexpSupport","unicode","Specials","Names","_supportsTabSize","specialCharConfig","specialChars","addSpecialChars","replaceTabs","styles","MozTabSize","supportsTabSize","_plugin","SpecialCharWidget","ph","placeholder$1","title","TabWidget","panelConfig","topContainer","bottomContainer","getPanel","panel","panelPlugin","panels","showPanel","PanelGroup","container","syncClasses","scrollMargin","classes","syncDOM","curDOM","rm","elementClass","gutterLineClass","activeGutters","unfixGutters","gutters","gutterView","fixed","prevViewport","SingleGutterView","gutter","syncGutters","updateGutters","vpA","vpB","vpOverlap","detach","lineClasses","classSet","contexts","UpdateContext","advanceCursor","cx","collect","addElement","elements","newElt","GutterElement","extraMarkers","localMarkers","forLine","lineMarker","renderEmptyElements","widgetMarker","spacer","initialSpacer","prevMarkers","updateSpacer","lineMarkerChange","sameMarkers","setMarkers","domPos","iNew","iOld","skipTo","matched","lineNumberMarkers","lineNumberConfig","formatNumber","assign","NumberMarker","lineNumberGutter","others","maxLineNumber","CodeMirror","textarea","_classCallCheck","$textarea","$","contentAttributesExtension","phrasesExtension","specialCharsExtension","heightExtension","namespaces","mw","includes","lineNumbers","outerHeight","fontClass","startsWith","user","accesskey","lang","EditorState","Find","msg","previous","all","Replace","messages","decorationCache","decorator","makeDecorator","highlightSpecialChars","description","placeholder","_this","defaultExtensions","hook","fire","textSelection","hide","form","getElementById","cmTextSelection","session_token","sessionId","user_id","getId","editCountBucket","user_edit_count_bucket","prefValue","isNamed","Api","saveOption","_this2","$cmDom","getContents","setContents","setSelection","encapsulateSelection","pre","post","EditorSelection","getCaretPosition","startAndEnd","scrollToCaretPosition","DefaultBufferLength","nextPropID","NodeProp","perNode","deserialize","NodeType","closedBy","openedBy","group","isolate","contextHash","lookAhead","mounted","MountedTree","tree","overlay","parser","props","noProps","skipped","src","isTop","isSkipped","isError","isAnonymous","groups","NodeSet","newTypes","newProps","CachedNode","CachedInnerNode","IterMode","Tree","positions","JSON","stringify","TreeCursor","topNode","cursorAt","moveTo","_tree","TreeNode","resolveNode","resolveInner","resolveStack","layers","iterStack","stackIterator","iterate","enter","leave","anon","IncludeAnonymous","entered","propValues","balance","balanceRange","makeTree","buffer","nodeSet","maxBufferLength","reused","minRepeatType","FlatBufferCursor","takeNode","parentStart","minPos","inRepeat","depth","lookAheadAtStart","maxSize","fork","minStart","nodeSize","localSkipped","nodeStart","findBufferSize","Uint16Array","copyToBuffer","TreeBuffer","localChildren","localPositions","localInRepeat","lastGroup","lastEnd","makeRepeatLeaf","takeFlatNode","make","lookAheadProp","lastI","makeBalanced","nodeCount","stopAt","pair","bufferStart","topID","buildTree","childString","endIndex","pick","checkSide","startI","endI","overlays","IgnoreOverlays","BaseNode","getChild","getChildren","matchContext","matchNodeContext","enterUnfinishedNodesBefore","prevSibling","_parent","nextChild","ExcludeBuffers","BufferNode","BufferContext","hasChild","IgnoreMounts","rPos","nextSignificantParent","toTree","externalSibling","heads","picked","newHeads","StackIterator","bufferNode","yieldNode","yieldBuf","yield","enterChild","sibling","atLastNode","mustLeave","nodeSizeCache","balanceType","mkTop","mkTree","maxChild","divide","groupFrom","groupStart","groupSize","nextSize","only","TreeFragment","addTree","fragments","partial","minGap","fI","nextF","cI","nextC","nextPos","fFrom","fTo","Parser","startParse","StringInput","createParse","parse","advance","lineChunks","nextTagID","Tag","modified","defineModifier","Modifier","nextModifierID","instances","mods","powerSet","styleTags","byName","tags","rest","rule","Rule","ruleNodeProp","opaque","inherit","tagHighlighter","tagClass","highlightTree","highlighter","putStyle","HighlightBuilder","highlightRange","highlighters","startSpan","inheritedClass","getStyleTags","tagCls","highlightTags","innerHighlighters","rangeFrom","rangeTo","comment","typeName","propertyName","literal","heading","keyword","operator","punctuation","bracket","lineComment","blockComment","docComment","variableName","attributeName","labelName","namespace","macroName","docString","character","attributeValue","integer","float","bool","escape","url","self","null","atom","unit","modifier","operatorKeyword","controlKeyword","definitionKeyword","moduleKeyword","derefOperator","arithmeticOperator","logicOperator","bitwiseOperator","compareOperator","updateOperator","definitionOperator","typeOperator","controlOperator","separator","angleBracket","squareBracket","paren","brace","heading1","heading2","heading3","heading4","heading5","heading6","contentSeparator","list","quote","emphasis","strong","link","monospace","strikethrough","deleted","invalid","documentMeta","processingInstruction","definition","constant","function","standard","special","languageDataProp","sublanguageProp","Language","extraExtensions","defineProperty","syntaxTree","language","topNodeAt","innerNode","sublang","isActiveAt","findRegions","allowsNesting","explore","topLang","DocInput","cursorPos","syncTo","stringStart","currentContext","ParseContext","treeLen","scheduleOn","tempSkipped","work","until","isDone","takeTree","withContext","endTime","stoppedAt","withoutTempSkipped","parsedPos","cutFragments","updateViewport","startLen","reset","skipUntilInView","getSkippingParser","frags","LanguageState","newCx","vpTo","parseState","requestIdle","callback","timeout","requestIdleCallback","idle","cancelIdleCallback","isInputPending","scheduling","parseWorker","working","workScheduled","chunkBudget","scheduleWork","checkAsyncSchedule","deadline","timeRemaining","viewportFirst","catch","err","isWorking","languages","LanguageSupport","support","indentService","indentUnit","getIndentUnit","indentString","cols","ts","getIndentation","IndentContext","service","ast","indentFor","syntaxIndentation","simulateBreak","simulateDoubleBreak","textAfterPos","column","countColumn","override","overrideIndentation","search","lineIndent","overriden","simulatedBreak","indentNodeProp","strategy","indentStrategy","TreeIndentContext","close","closed","align","units","closing","closedAt","textAfter","space","aligned","openToken","sim","openLine","bracketedAligned","baseIndent","delimitedStrategy","ignoreClosed","topIndent","baseIndentFor","atBreak","isParent","HighlightStyle","modSpec","def","scopeOpt","module","themeType","highlighterFacet","fallbackHighlighter","getHighlighters","TreeHighlighter","markCache","buildDeco","styleChange","treeHighlighter","DefaultScanDist","DefaultBrackets","bracketMatchingConfig","afterCursor","brackets","maxScanDistance","renderMatch","defaultRenderMatch","matchingMark","nonmatchingMark","bracketMatchingState","matchBrackets","bracketMatchingUnique","bracketMatching","bracketMatchingHandle","matchingNodes","byProp","findHandle","hasHandle","matches","handle","matchMarkedBrackets","tokenType","startCh","startToken","basePos","matchPlainBrackets","_pos","token","matching","firstToken","endHandle","countCol","startValue","StringStream","overrideIndent","lastColumnPos","lastColumnValue","eol","sol","peek","charAt","eat","ok","eatWhile","eatSpace","skipToEnd","backUp","indentation","pattern","consume","caseInsensitive","cased","substr","defaultCopyState","IndentedFrom","StreamLanguage","baseData","blankLine","copyState","indent","tokenTable","noTokens","Parse","getIndent","typeArray","docID","streamParser","stateAfter","TokenTable","defaultTokenTable","statePos","findState","stream","readToken","cutTree","chunkReused","editorState","findStartInFragments","moveRangeIndex","parseEnd","parseLine","lineAfter","nextLine","rangeEnd","rangeStart","skipGapsTo","offPos","emitToken","len0","warned","byTag","defaultTable","legacyName","createTokenType","table","warnForPart","tagStr","tags$1","option","toggleLineComment","changeLineComment","toggleBlockComment","changeBlockComment","toggleBlockCommentByLine","o","selectedLineRanges","getConfig","SearchMargin","tokens","comments","startText","endText","textBefore","spaceBefore","spaceAfter","beforeOff","startSpace","endSpace","endOff","findBlockComment","prevLine","minIndent","changeSet","fromHistory","isolateHistory","invertedEffects","historyConfig","minDepth","newGroupDelay","joinToEvent","isAdjacent","adj","historyField_","HistoryState","fromHist","changeEnd","item","HistEvent","fromTransaction","undone","updateBranch","addSelection","addMapping","addChanges","undo","redo","historyState","undoSelection","redoSelection","startSelection","selectionsAfter","setSelAfter","selections","branch","maxLen","newEvent","newBranch","conc","MaxSelectionsPerEvent","sels","popSelection","addMappingToBranch","mapEvent","extraSelections","mappedChanges","fullMapping","joinableUserEvent","prevTime","prevUserEvent","historyKeymap","updateSel","setSel","moveSel","how","cursorByChar","ltrAtCursor","cursorCharLeft","cursorCharRight","cursorByGroup","interestingNode","bracketProp","moveBySyntax","cursorByLine","Intl","Segmenter","cursorLineUp","cursorLineDown","pageInfo","selfScroll","marginBottom","cursorByPage","page","scrollRect","scrollBottom","cursorPageUp","cursorPageDown","moveByLineBoundary","extendSel","selectByChar","selectCharLeft","selectCharRight","selectByGroup","selectByLine","selectLineUp","selectLineDown","selectByPage","selectPageUp","selectPageDown","cursorDocStart","cursorDocEnd","selectDocStart","selectDocEnd","deleteBy","towards","skipAtomic","deleteByChar","targetPos","deleteCharBackward","deleteCharForward","deleteByGroup","nextChar","deleteGroupBackward","deleteToLineEnd","selectedLineBlocks","blocks","startLine","moveLine","copyLine","insertNewlineAndIndent","newlineAndIndent","atEof","explode","isBetweenBrackets","changeBySelectedLine","atLine","defaultKeymap","keep","norm","toMatchingBracket","crelt","basicNormalize","normalize","SearchCursor","query","bufferPos","nextOverlapping","baseFlags","RegExpCursor","MultilineRegExpCursor","ignoreCase","curLineStart","matchPos","toCharEnd","flattened","FlattenedDoc","cached","cachedFrom","createLineDialog","go","sign","ln","cl","percent","pc","dialogEffect","onkeydown","onsubmit","dialogField","searchConfigFacet","caseSensitive","wholeWord","createPanel","SearchPanel","scrollToMatch","SearchQuery","valid","validRegExp","unquoted","unquote","RegExpQuery","StringQuery","getCursor","st","regexpCursor","stringCursor","categorizer","buf","bufPos","charBefore","charAfter","stringWordTest","nextMatch","prevMatchInRange","prevMatch","getReplacement","_result","matchAll","highlight","setSearchQuery","togglePanel","searchState","SearchState","defaultQuery","createSearchPanel","matchMark","selectedMatchMark","searchHighlighter","selected","searchCommand","openSearchPanel","findNext","announceMatch","selectSearchInput","findPrevious","selectMatches","replaceNext","replacement","replaceAll","announceText","fallback","_d","_e","selText","getSearchInput","searchInput","searchExtensions","closeSearchPanel","searchKeymap","selectWord","searchedText","word","fullWord","cycled","findNextOccurrence","onclick","commit","searchField","onchange","onkeyup","replaceField","caseField","checked","reField","wordField","setQuery","AnnounceMargin","Break","font","marginRight","__non_webpack_require__","CodeMirrorWikiEditor","_CodeMirror","langExtension","_callSuper","editRecoveryHandler","useCodeMirror","_inherits","_get","_getPrototypeOf","_toConsumableArray","history","triggerHandler","fieldChangeHandler","initialize","scrollEffect","loader","getState","_this3","toolbar","wikiEditor","section","codemirror","tools","label","oouiIcon","action","execute","switchCodeMirror","$toolbar","enableCodeMirror","updateToolbarButton","logUsage","editor","enabled","toggled","edit_start_ts_ms","$button","toggleClass","setCodeMirrorPreference","_this$view$state$sele","show","trigger","_customTags","CodeMirrorModeMediaWikiConfig","_get_customTags","extHighlightStyles","addToken","bdi","u","big","small","sup","h1","h2","h3","h4","h5","h6","cite","em","strike","tt","var","div","center","blockquote","q","ol","ul","dl","caption","ruby","rb","rp","rt","rtc","abbr","dfn","kbd","samp","wbr","hr","li","dt","dd","td","th","noinclude","includeonly","onlyinclude","_objectSpread","apostrophes","apostrophesBold","apostrophesItalic","doubleUnderscore","extLink","extLinkBracket","extLinkProtocol","extLinkText","htmlTagAttribute","htmlTagBracket","htmlTagName","indenting","linkBracket","linkDelimiter","linkText","linkToSection","parserFunction","parserFunctionBracket","parserFunctionDelimiter","parserFunctionName","sectionHeader","sectionHeader1","sectionHeader2","sectionHeader3","sectionHeader4","sectionHeader5","sectionHeader6","signature","tableBracket","tableDefinition","tableDelimiter","template","templateArgumentName","templateBracket","templateDelimiter","templateName","templateVariable","templateVariableBracket","templateVariableName","_ref","_defineProperty","extNowiki","extPre","extTag","extTagAttribute","extTagBracket","extTagName","freeExtLink","freeExtLinkProtocol","htmlEntity","linkPageName","nowiki","pageName","skipFormatting","tableCaption","templateVariableDelimiter","mwModeConfig","CodeMirrorModeMediaWiki","urlProtocols","isBold","wasBold","isItalic","wasItalic","firstSingleLetterWord","firstMultiLetterWord","firstSpace","oldStyle","oldTokens","modeConfig","registerGroundTokens","addTag","ground","endGround","makeLocalStyle","nTemplate","nExt","nLink","trim","terminator","consumeLast","tokenize","count","_this4","eatEnd","eatBlock","eatWikiText","inVariableDefault","inParserFunctionArguments","haveAte","_this5","eatTemplateArgument","eatTemplatePageName","expectArgName","_this6","chars","_this7","inExternalLink","inExternalLinkText","inLinkToSection","eatLinkText","linkIsBold","linkIsItalic","_this8","tmpstyle","isCloseTag","isHtmlTag","_this9","implicitlyClosedHtmlTags","eatChar","eatHtmlTagAttribute","eatExtTagAttribute","_this10","inHtmlTag","_this11","eatHtmlEntity","_this12","extName","extMode","eatNowiki","tagModes","mediawiki","extState","eatExtTagArea","_this13","origString","eatExtCloseTag","eatExtTokens","_this14","eatTagName","_this15","ret","inTableDefinition","inTable","eatTableRow","isStart","isHead","isCaption","_this16","eatFreeExternalLink","_this17","tmp","mt","tagname","eatSectionHeader","eatStartTable","prepareItalicForCorrection","inLink","eatExternalLinkProtocol","inVariable","inParserFunctionName","functionSynonyms","permittedHtmlTags","eatFreeExternalLinkProtocol","x1","x2","_this18","readyTokens","tmpTokens","syntaxHighlighting","getTagStyles","mediaWikiLang","addCodeMirrorToWikiEditor"],"sourceRoot":""} |