@inkandswitch/patchwork-pkg-base 0.0.54 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/package.json +1 -1
  2. package/packages/account/dist/{AccountPicker-HMEN6MEN.js → AccountPicker-HB6MDLKN.js} +390 -123
  3. package/packages/account/dist/AccountPicker-HB6MDLKN.js.map +7 -0
  4. package/packages/account/dist/{ContactAvatar-KCZOCABR.js → ContactAvatar-KM4BONY5.js} +7 -7
  5. package/packages/account/dist/ContactAvatar-KM4BONY5.js.map +7 -0
  6. package/packages/account/dist/{ContactCursor-RLXRAX65.js → ContactCursor-4FYCATG5.js} +6 -6
  7. package/packages/account/dist/ContactCursor-4FYCATG5.js.map +7 -0
  8. package/packages/account/dist/index.css +96 -15
  9. package/packages/account/dist/index.css.map +2 -2
  10. package/packages/account/dist/index.js +3 -3
  11. package/packages/codemirror-base/dist/{chunk-H5POLO74.js → chunk-AKNT5U37.js} +43 -28
  12. package/packages/codemirror-base/dist/chunk-AKNT5U37.js.map +7 -0
  13. package/packages/codemirror-base/dist/lib/codemirror.js +1 -1
  14. package/packages/codemirror-base/dist/tool.js +21 -3
  15. package/packages/codemirror-base/dist/tool.js.map +2 -2
  16. package/packages/comments-view/dist/assets/main-BPvgT7fH.js +1 -1
  17. package/packages/tldraw4/dist/tool.js +3 -23
  18. package/packages/tldraw4/dist/tool.js.map +2 -2
  19. package/packages/account/dist/AccountPicker-HMEN6MEN.js.map +0 -7
  20. package/packages/account/dist/ContactAvatar-KCZOCABR.js.map +0 -7
  21. package/packages/account/dist/ContactCursor-RLXRAX65.js.map +0 -7
  22. package/packages/account/dist/chunk-3YUNEZX6.js +0 -38
  23. package/packages/account/dist/chunk-3YUNEZX6.js.map +0 -7
  24. package/packages/codemirror-base/dist/chunk-H5POLO74.js.map +0 -7
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/codemirror.tsx", "../src/lib/extensions/decorations.ts", "../src/lib/extensions/readOnly.ts", "../src/lib/extensions/automerge.ts", "../src/vendor/automerge-codemirror/plugin.ts", "../src/vendor/automerge-codemirror/codeMirrorToAm.ts", "../src/vendor/automerge-codemirror/amToCodemirror.ts", "../node_modules/.pnpm/@codemirror+commands@6.10.3/node_modules/@codemirror/commands/dist/index.js", "../node_modules/.pnpm/@lezer+common@1.5.2/node_modules/@lezer/common/dist/index.js", "../src/vendor/automerge-codemirror/history.ts", "../src/vendor/automerge-codemirror/readOnly.ts", "../src/vendor/automerge-codemirror/index.ts", "../src/lib/extensions/diff.ts", "../src/lib/extensions/scrollHighlightIntoView.ts", "../src/lib/extensions/presence.ts"],
4
+ "sourcesContent": ["import { onCleanup, createEffect } from \"solid-js\";\nimport { EditorView } from \"@codemirror/view\";\nimport { EditorState, Compartment } from \"@codemirror/state\";\nimport { createAutomergeExtension, createReadOnlyExtension, createDecorationsExtension, createDiffExtension, createScrollHighlightIntoViewExtension, createPresenceExtension } from \"./extensions\";\nconst lookup = (doc, path) => {\n let current = doc;\n for (const key of path) {\n current = current[key];\n if (current === void 0) {\n return void 0;\n }\n }\n return current;\n};\nexport function CodeMirror(props) {\n const initialDoc = () => props.handle && lookup(props.handle.doc(), props.path) || \"\";\n const [automergeExtension, createEffectReconfigureAutomerge] = createAutomergeExtension(() => props.handle, () => props.path, initialDoc);\n const [readOnlyExtension, createEffectReconfigureReadOnly] = createReadOnlyExtension(() => !!props.readOnly);\n const [decorationsExtension, createEffectReconfigureDecorations] = createDecorationsExtension(() => props.decorations?.());\n const [diffExtension, createEffectReconfigureDiff] = createDiffExtension(() => props.handle, () => props.path, () => props.baseline?.() ?? null);\n const [scrollHighlightIntoViewExtension, createEffectScrollHighlightIntoView] = createScrollHighlightIntoViewExtension(() => props.scrollTarget?.() ?? null);\n const [presenceExtension, createEffectReconfigurePresence] = createPresenceExtension(() => props.handle, () => props.path, () => props.readOnly || props.handle.isReadOnly() ? null : props.contactUrl?.() ?? null, props.repo);\n const userExtensionsCompartment = new Compartment();\n const selectionExtension = EditorView.updateListener.of(update => {\n if (!props.onChangeSelection) return;\n if (update.selectionSet) {\n const sel = update.state.selection.main;\n props.onChangeSelection(sel.from, sel.to);\n }\n });\n const extensions = [selectionExtension, decorationsExtension,\n // automergeExtension must come before diffExtension so diff stays in sync with edits.\n automergeExtension, diffExtension, scrollHighlightIntoViewExtension, presenceExtension, userExtensionsCompartment.of(props.extensions || []), readOnlyExtension].filter(Boolean);\n const state = EditorState.create({\n doc: initialDoc(),\n extensions\n });\n const view = new EditorView({\n state\n });\n props.withView?.(view);\n createEffectReconfigureAutomerge(view);\n createEffectReconfigureReadOnly(view);\n createEffectReconfigureDecorations?.(view);\n createEffectReconfigureDiff(view);\n createEffectScrollHighlightIntoView(view);\n createEffectReconfigurePresence(view);\n createEffect(() => {\n view.dispatch({\n effects: userExtensionsCompartment.reconfigure(props.extensions || [])\n });\n });\n onCleanup(() => view.destroy());\n return view.dom;\n}", "import { createEffect } from \"solid-js\";\n\n/** CodeMirror */\nimport { Decoration, EditorView, type DecorationSet } from \"@codemirror/view\";\nimport { StateEffect, StateField } from \"@codemirror/state\";\n\n/**\n * Create a CodeMirror extension for managing decorations.\n * @param decorations An accessor function that returns the decorations (for reactivity).\n * @returns A tuple containing the extension and a function to create an effect for updating the\n decorations.\n */\nexport function createDecorationsExtension(decorations: () => DecorationSet) {\n const setDecorations = StateEffect.define<DecorationSet>();\n const decorationsField = StateField.define<DecorationSet>({\n create() {\n return Decoration.none;\n },\n update(value, tr) {\n for (const e of tr.effects) {\n if (e.is(setDecorations)) return e.value;\n }\n if (tr.docChanged) return value.map(tr.changes);\n return value;\n },\n provide: (f) => EditorView.decorations.from(f),\n });\n\n const createDecorationsEffect = (view: EditorView) =>\n createEffect(() => {\n decorations() &&\n view.dispatch({\n effects: setDecorations.of(decorations!()),\n });\n });\n\n return [decorationsField, createDecorationsEffect] as const;\n}\n", "import { createEffect } from \"solid-js\";\n\n/** CodeMirror */\nimport { EditorView } from \"@codemirror/view\";\nimport { Compartment, EditorState } from \"@codemirror/state\";\n\n/**\n * Force the editor read-only regardless of the handle's state.\n *\n * This is only the override: the handle's own read-only state (e.g. a\n * heads-pinned view, including flips when its backing is swapped in place)\n * is tracked by the vendored `automergeReadOnly`, installed via\n * `createAutomergeExtension`.\n *\n * @param force Forces read-only.\n * @returns A tuple containing the extension and a function to create the\n * effect that reconfigures the extension when `force` changes.\n */\nexport function createReadOnlyExtension(force: () => boolean) {\n const compartment = new Compartment();\n\n const extensions = () =>\n force()\n ? [EditorState.readOnly.of(true), EditorView.editable.of(false)]\n : [];\n\n const createReconfigureEffect = (view: EditorView) =>\n createEffect(() => {\n view.dispatch({\n effects: compartment.reconfigure(extensions()),\n });\n });\n\n return [compartment.of(extensions()), createReconfigureEffect] as const;\n}\n", "import { createEffect } from \"solid-js\";\n\n/** CodeMirror */\nimport { EditorView } from \"@codemirror/view\";\nimport { Compartment, Transaction } from \"@codemirror/state\";\n\n/** Automerge */\nimport type { Prop as AutomergeProp } from \"@automerge/automerge/slim\";\nimport type { DocHandle } from \"@automerge/automerge-repo/slim\";\nimport { automergePlugin } from \"../../vendor/automerge-codemirror/index.js\";\n\n/**\n * Returns a [Compartment extension, reconfig effect] tuple to sync a CodeMirror editor\n * with an Automerge handle+path. When reactive `handle` or `path` change, swaps the\n * plugin via Compartment and resets the doc from `initialDoc()` (kept off undo stack).\n */\nexport function createAutomergeExtension<T>(\n handle: () => DocHandle<T>,\n path: () => AutomergeProp[],\n initialDoc: () => string\n) {\n const compartment = new Compartment();\n\n const extension = () =>\n handle() && path()\n ? automergePlugin({\n handle: handle() as any, // typescript is confused by different version of doc handle\n path: path(),\n })\n : [];\n\n // Reconfigures the plugin and resets the doc to initialDoc() on reactive changes; this is synthetic remote state, so it bypasses the undo stack.\n const createReconfigureEffect = (view: EditorView) =>\n createEffect(() => {\n // handle()/path()/initialDoc() are tracked; changes rerun the rebuild.\n view.dispatch({\n effects: compartment.reconfigure(extension()),\n changes: {\n from: 0,\n to: view.state.doc.length,\n insert: initialDoc(),\n },\n annotations: [\n Transaction.addToHistory.of(false),\n Transaction.remote.of(true),\n ],\n });\n });\n\n return [compartment.of(extension()), createReconfigureEffect] as const;\n}\n", "import * as A from \"@automerge/automerge\"\nimport { EditorView, ViewPlugin, ViewUpdate } from \"@codemirror/view\"\nimport { Transaction, Annotation } from \"@codemirror/state\"\nimport { applyCmTransactionsToAmHandle } from \"./codeMirrorToAm.js\"\nimport { applyAmPatchesToCm } from \"./amToCodemirror.js\"\nimport type { DocHandle } from \"./DocHandle.js\"\n\nexport const reconcileAnnotationType = Annotation.define<unknown>()\n\nexport const isReconcileTx = (tr: Transaction): boolean =>\n !!tr.annotation(reconcileAnnotationType)\n\ntype AutomergeSyncPluginConfig = {\n handle: DocHandle<unknown>\n path: A.Prop[]\n}\n\nexport const automergeSyncPlugin = ({\n handle,\n path,\n}: AutomergeSyncPluginConfig) => {\n if (!handle.isReady()) {\n throw new Error(\n \"ensure the handle is ready before initializing the automergeSyncPlugin\"\n )\n }\n\n return ViewPlugin.fromClass(\n class {\n view: EditorView\n reconciledHeads = A.getHeads(handle.doc())\n isProcessingCmTransaction = false\n\n constructor(view: EditorView) {\n this.view = view\n\n this.onChange = this.onChange.bind(this)\n handle.on(\"change\", this.onChange)\n }\n\n update(update: ViewUpdate) {\n // start processing codemirror transaction\n // changes that are created through the transaction are ignored in the change listener on the handle\n this.isProcessingCmTransaction = true\n\n const newHeads = applyCmTransactionsToAmHandle(\n handle,\n path,\n update.transactions as Transaction[]\n )\n\n if (newHeads) {\n this.reconciledHeads = newHeads\n }\n\n // finish processing transaction\n this.isProcessingCmTransaction = false\n }\n\n // Changes with a replaced scope (the handle was re-pointed at a\n // different backing document) need no special-casing here. A.diff\n // ignores heads that aren't in the doc's history, treating that side\n // as the empty document: when the backings share history (heads\n // pinning, clones) it yields minimal patches that preserve the\n // selection, and when they share nothing it degenerates into\n // full-document patches that rebuild the editor wholesale. Either\n // way the patches are kept off the undo stack by applyAmPatchesToCm.\n // The history and read-only extensions are the ones that consume the\n // `scopeReplaced` flag.\n onChange = () => {\n // ignore changes that where triggered while processing a codemirror transaction\n if (this.isProcessingCmTransaction) {\n return\n }\n\n const currentHeads = A.getHeads(handle.doc())\n if (A.equals(currentHeads, this.reconciledHeads)) {\n return\n }\n\n // get the diff between the reconciled heads and the new heads\n // and apply that to the codemirror doc\n const patches = A.diff(handle.doc(), this.reconciledHeads, currentHeads)\n applyAmPatchesToCm(this.view, path, patches)\n this.reconciledHeads = currentHeads\n }\n\n destroy() {\n handle.off(\"change\", this.onChange)\n }\n }\n )\n}\n", "import * as A from \"@automerge/automerge\"\nimport { Text, Transaction } from \"@codemirror/state\"\nimport { isReconcileTx } from \"./plugin.js\"\nimport { type DocHandle } from \"./DocHandle.js\"\n\nexport const applyCmTransactionsToAmHandle = (\n handle: DocHandle<unknown>,\n path: A.Prop[],\n transactions: Transaction[]\n): A.Heads | undefined => {\n const transactionsWithChanges = transactions.filter(\n tr => !isReconcileTx(tr) && !tr.changes.empty\n )\n\n if (transactionsWithChanges.length === 0) {\n return\n }\n\n // A read-only handle (e.g. pinned to historical heads) rejects writes:\n // never forward editor changes to it. The automergeReadOnly extension\n // keeps the editor from producing such changes in the first place.\n if (handle.isReadOnly?.()) {\n return\n }\n\n handle.change((doc: A.Doc<unknown>) => {\n transactionsWithChanges.forEach(tr => {\n tr.changes.iterChanges(\n (\n fromA: number,\n toA: number,\n fromB: number,\n _toB: number,\n inserted: Text\n ) => {\n // We are cloning the path as `am.splice` calls `.unshift` on it, modifying it in place,\n // causing the path to be broken on subsequent changes\n A.splice(doc, path.slice(), fromB, toA - fromA, inserted.toString())\n }\n )\n })\n })\n\n return A.getHeads(handle.doc())\n}\n", "import type {\n DelPatch,\n InsertPatch,\n Patch,\n Prop,\n PutPatch,\n SpliceTextPatch,\n} from \"@automerge/automerge\"\nimport {\n ChangeSet,\n type ChangeSpec,\n EditorState,\n Transaction,\n} from \"@codemirror/state\"\nimport { EditorView } from \"@codemirror/view\"\nimport { reconcileAnnotationType } from \"./plugin.js\"\n\nexport const applyAmPatchesToCm = (\n view: EditorView,\n target: Prop[],\n patches: Patch[]\n) => {\n let selection = view.state.selection\n\n for (const patch of patches) {\n const changeSpec = handlePatch(patch, target, view.state)\n if (changeSpec != null) {\n const changeSet = ChangeSet.of(changeSpec, view.state.doc.length, \"\\n\")\n selection = selection.map(changeSet, 1)\n // Remote changes from automerge are excluded from local undo (addToHistory: false).\n view.dispatch({\n changes: changeSet,\n annotations: [\n reconcileAnnotationType.of({}),\n Transaction.addToHistory.of(false),\n Transaction.remote.of(true),\n ],\n })\n }\n }\n view.dispatch({\n selection,\n annotations: reconcileAnnotationType.of({}),\n })\n}\n\nfunction handlePatch(\n patch: Patch,\n target: Prop[],\n state: EditorState\n): ChangeSpec | null {\n if (patch.action === \"insert\") {\n return handleInsert(target, patch)\n } else if (patch.action === \"splice\") {\n return handleSplice(target, patch)\n } else if (patch.action === \"del\") {\n return handleDel(target, patch)\n } else if (patch.action === \"put\") {\n return handlePut(target, patch, state)\n } else {\n return null\n }\n}\n\nfunction handleInsert(target: Prop[], patch: InsertPatch): Array<ChangeSpec> {\n const index = charPath(target, patch.path)\n if (index == null) {\n return []\n }\n const text = patch.values.map(v => (v ? v.toString() : \"\")).join(\"\")\n return [{ from: index, to: index, insert: text }]\n}\n\nfunction handleSplice(\n target: Prop[],\n patch: SpliceTextPatch\n): Array<ChangeSpec> {\n const index = charPath(target, patch.path)\n if (index == null) {\n return []\n }\n return [{ from: index, insert: patch.value }]\n}\n\nfunction handleDel(target: Prop[], patch: DelPatch): Array<ChangeSpec> {\n const index = charPath(target, patch.path)\n if (index == null) {\n return []\n }\n const length = patch.length || 1\n return [{ from: index, to: index + length }]\n}\n\nfunction handlePut(\n target: Prop[],\n patch: PutPatch,\n state: EditorState\n): Array<ChangeSpec> {\n const index = charPath(target, [...patch.path, 0])\n if (index == null) {\n return []\n }\n const length = state.doc.length\n if (typeof patch.value !== \"string\") {\n return [] // TODO(dmaretskyi): How to handle non string values?\n }\n return [{ from: 0, to: length, insert: patch.value }]\n}\n\n// If the path of the patch is of the form [path, <index>] then we know this is\n// a path to a character within the sequence given by path\nfunction charPath(textPath: Prop[], candidatePath: Prop[]): number | null {\n if (candidatePath.length !== textPath.length + 1) return null\n for (let i = 0; i < textPath.length; i++) {\n if (textPath[i] !== candidatePath[i]) return null\n }\n const index = candidatePath[candidatePath.length - 1]\n if (typeof index === \"number\") return index\n return null\n}\n", "import { Annotation, Facet, combineConfig, StateField, Transaction, ChangeSet, ChangeDesc, EditorSelection, 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, 1);\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 if (toLine.from > fromLine.from && toLine.from == r.to)\n toLine = r.to == fromLine.to + 1 ? fromLine : state.doc.lineAt(r.to - 1);\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 ranges: for (let { from, to } of ranges) {\n let startI = lines.length, minIndent = 1e9, token;\n for (let pos = from; pos <= to;) {\n let line = state.doc.lineAt(pos);\n if (token == undefined) {\n token = getConfig(state, line.from).line;\n if (!token)\n continue ranges;\n }\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});\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 item = HistEvent.fromTransaction(tr, fromHist.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(StateEffect.mapEffects(event.effects, lastEvent.changes), 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, onlySelection) {\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], selection = event.selectionsAfter[0] ||\n (event.startSelection ? event.startSelection.map(event.changes.invertedDesc, 1) : state.selection);\n if (onlySelection && event.selectionsAfter.length) {\n return state.update({\n selection: event.selectionsAfter[event.selectionsAfter.length - 1],\n annotations: fromHistory.of({ side, rest: popSelection(branch), selection }),\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, selection }),\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, true))\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 byCharLogical(state, range, forward) {\n let pos = range.head, line = state.doc.lineAt(pos);\n if (pos == (forward ? line.to : line.from))\n pos = forward ? Math.min(state.doc.length, line.to + 1) : Math.max(0, line.from - 1);\n else\n pos = line.from + findClusterBreak(line.text, pos - line.from, forward);\n return EditorSelection.cursor(pos, forward ? -1 : 1);\n}\nfunction moveByCharLogical(target, forward) {\n return moveSel(target, range => range.empty ? byCharLogical(target.state, range, forward) : rangeEnd(range, forward));\n}\n/**\nMove the selection one character forward, in logical\n(non-text-direction-aware) string index order.\n*/\nconst cursorCharForwardLogical = target => moveByCharLogical(target, true);\n/**\nMove the selection one character backward, in logical string index\norder.\n*/\nconst cursorCharBackwardLogical = target => moveByCharLogical(target, 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);\nfunction toGroupStart(view, pos, start) {\n let categorize = view.state.charCategorizer(pos);\n let cat = categorize(start), initial = cat != CharCategory.Space;\n return (next) => {\n let nextCat = categorize(next);\n if (nextCat != CharCategory.Space)\n return initial && nextCat == cat;\n initial = false;\n return true;\n };\n}\n/**\nMove the cursor one group forward in the default Windows style,\nwhere it moves to the start of the next group.\n*/\nconst cursorGroupForwardWin = view => {\n return moveSel(view, range => range.empty\n ? view.moveByChar(range, true, start => toGroupStart(view, range.head, start))\n : rangeEnd(range, true));\n};\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(target, how) {\n let selection = updateSel(target.state.selection, range => {\n let head = how(range);\n return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined, head.assoc);\n });\n if (selection.eq(target.state.selection))\n return false;\n target.dispatch(setSel(target.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);\n/**\nMove the selection head one character forward by logical\n(non-direction aware) string index order.\n*/\nconst selectCharForwardLogical = target => extendSel(target, range => byCharLogical(target.state, range, true));\n/**\nMove the selection head one character backward by logical string\nindex order.\n*/\nconst selectCharBackwardLogical = target => extendSel(target, range => byCharLogical(target.state, range, 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);\n/**\nMove the selection head one group forward in the default Windows\nstyle, skipping to the start of the next group.\n*/\nconst selectGroupForwardWin = view => {\n return extendSel(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start)));\n};\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 let tree = syntaxTree(state), stack = tree.resolveStack(range.from, 1);\n if (range.empty) {\n let stackBefore = tree.resolveStack(range.from, -1);\n if (stackBefore.node.from >= stack.node.from && stackBefore.node.to <= stack.node.to)\n stack = stackBefore;\n }\n for (let cur = stack; cur; cur = cur.next) {\n let { node } = cur;\n if (((node.from < range.from && node.to >= range.to) ||\n (node.to > range.to && node.from <= range.from)) &&\n cur.next)\n return EditorSelection.range(node.to, node.from);\n }\n return range;\n });\n if (selection.eq(state.selection))\n return false;\n dispatch(setSel(state, selection));\n return true;\n};\nfunction addCursorVertically(view, forward) {\n let { state } = view, sel = state.selection, ranges = state.selection.ranges.slice();\n for (let range of state.selection.ranges) {\n let line = state.doc.lineAt(range.head);\n if (forward ? line.to < view.state.doc.length : line.from > 0)\n for (let cur = range;;) {\n let next = view.moveVertically(cur, forward);\n if (next.head < line.from || next.head > line.to) {\n if (!ranges.some(r => r.head == next.head))\n ranges.push(next);\n break;\n }\n else if (next.head == cur.head) {\n break;\n }\n else {\n cur = next;\n }\n }\n }\n if (ranges.length == sel.ranges.length)\n return false;\n view.dispatch(setSel(state, EditorSelection.create(ranges, ranges.length - 1)));\n return true;\n}\n/**\nExpand the selection by adding a cursor above the heads of\ncurrently selected ranges.\n*/\nconst addCursorAbove = view => addCursorVertically(view, false);\n/**\nExpand the selection by adding a cursor below the heads of\ncurrently selected ranges.\n*/\nconst addCursorBelow = view => addCursorVertically(view, true);\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(range);\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, from < range.head ? -1 : 1) };\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, byIndentUnit) => deleteBy(target, range => {\n let pos = range.from, { state } = target, line = state.doc.lineAt(pos), before, targetPos;\n if (byIndentUnit && !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 else if (!forward && /[\\ufe00-\\ufe0f]/.test(line.text.slice(targetPos - line.from, pos - line.from)))\n targetPos = findClusterBreak(line.text, targetPos - line.from, false, false) + line.from;\n }\n return targetPos;\n});\n/**\nDelete the selection, or, for cursor selections, the character or\nindentation unit before the cursor.\n*/\nconst deleteCharBackward = view => deleteByChar(view, false, true);\n/**\nDelete the selection or the character before the cursor. Does not\nimplement any extended behavior like deleting whole indentation\nunits in one go.\n*/\nconst deleteCharBackwardStrict = view => deleteByChar(view, false, false);\n/**\nDelete the selection or the character after the cursor.\n*/\nconst deleteCharForward = view => deleteByChar(view, true, false);\nconst deleteByGroup = (target, forward) => deleteBy(target, range => {\n let pos = range.head, { 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 == range.head && 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 != range.head)\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/**\nVariant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)\nthat uses the Windows convention of also deleting the whitespace\nafter a word.\n*/\nconst deleteGroupForwardWin = view => deleteBy(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start)).head);\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, range => {\n let lineEnd = view.lineBlockAt(range.head).to;\n return range.head < lineEnd ? lineEnd : Math.min(view.state.doc.length, range.head + 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, range => {\n let lineStart = view.lineBlockAt(range.head).from;\n return range.head > lineStart ? lineStart : Math.max(0, range.head - 1);\n});\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe start of the line or the next line wrap before the cursor.\n*/\nconst deleteLineBoundaryBackward = view => deleteBy(view, range => {\n let lineStart = view.moveToLineBoundary(range, false).head;\n return range.head > lineStart ? lineStart : Math.max(0, range.head - 1);\n});\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe end of the line or the next line wrap after the cursor.\n*/\nconst deleteLineBoundaryForward = view => deleteBy(view, range => {\n let lineStart = view.moveToLineBoundary(range, true).head;\n return range.head < lineStart ? lineStart : Math.min(view.state.doc.length, range.head + 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 let changeSet = state.changes(changes);\n dispatch(state.update({\n changes: changeSet,\n selection: state.selection.map(changeSet, forward ? 1 : -1),\n scrollIntoView: true,\n userEvent: \"input.copyline\"\n }));\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 => {\n let dist = undefined;\n if (view.lineWrapping) {\n let block = view.lineBlockAt(range.head), pos = view.coordsAtPos(range.head, range.assoc || 1);\n if (pos)\n dist = (block.bottom + view.documentTop) - pos.bottom + view.defaultLineHeight / 2;\n }\n return view.moveVertically(range, true, dist);\n }).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};\n/**\nReplace the selection with a newline and the same amount of\nindentation as the line above.\n*/\nconst insertNewlineKeepIndent = ({ state, dispatch }) => {\n dispatch(state.update(state.changeByRange(range => {\n let indent = /^\\s*/.exec(state.doc.lineAt(range.from).text)[0];\n return {\n changes: { from: range.from, to: range.to, insert: state.lineBreak + indent },\n range: EditorSelection.cursor(range.from + indent.length + 1)\n };\n }), { 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/**\nEnables or disables\n[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this\nprevents the editor's key bindings from capturing Tab or\nShift-Tab, making it possible for the user to move focus out of\nthe editor with the keyboard.\n*/\nconst toggleTabFocusMode = view => {\n view.setTabFocusMode();\n return true;\n};\n/**\nTemporarily enables [tab-focus\nmode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until\nanother key is pressed.\n*/\nconst temporarilySetTabFocusMode = view => {\n view.setTabFocusMode(2000);\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 and Shift-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): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward).\n - Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward).\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, shift: insertNewlineAndIndent },\n { key: \"Mod-a\", run: selectAll },\n { key: \"Backspace\", run: deleteCharBackward, shift: deleteCharBackward, preventDefault: true },\n { key: \"Delete\", run: deleteCharForward, preventDefault: true },\n { key: \"Mod-Backspace\", mac: \"Alt-Backspace\", run: deleteGroupBackward, preventDefault: true },\n { key: \"Mod-Delete\", mac: \"Alt-Delete\", run: deleteGroupForward, preventDefault: true },\n { mac: \"Mod-Backspace\", run: deleteLineBoundaryBackward, preventDefault: true },\n { mac: \"Mod-Delete\", run: deleteLineBoundaryForward, preventDefault: true }\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- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove).\n- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow).\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- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode).\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: \"Mod-Alt-ArrowUp\", run: addCursorAbove },\n { key: \"Mod-Alt-ArrowDown\", run: addCursorBelow },\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 { key: \"Ctrl-m\", mac: \"Shift-Alt-m\", run: toggleTabFocusMode },\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 { addCursorAbove, addCursorBelow, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteGroupForwardWin, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection };\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 this.combine = config.combine || null;\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 /**\n [Indicates](#common.IterMode.EnterBracketed) that the nested\n content is delineated with some kind\n of bracket token.\n */\n bracketed = false) {\n this.tree = tree;\n this.overlay = overlay;\n this.parser = parser;\n this.bracketed = bracketed;\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 let value = add[1], prop = add[0];\n if (prop.combine && prop.id in newProps)\n value = prop.combine(newProps[prop.id], value);\n newProps[prop.id] = value;\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 /**\n When set, positions on the boundary of a mounted overlay tree\n that has its [`bracketed`](#common.NestedParse.bracketed) flag\n set will enter that tree regardless of side. Only supported in\n [`enter`](#common.SyntaxNode.enter), not in cursors.\n */\n IterMode[IterMode[\"EnterBracketed\"] = 16] = \"EnterBracketed\";\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.parent, 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, mounted;\n if (!((mode & IterMode.EnterBracketed) && next instanceof Tree &&\n (mounted = MountedTree.get(next)) && !mounted.overlay && mounted.bracketed &&\n pos >= start && pos <= start + next.length) &&\n !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, mode);\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 prop(prop) { return this._tree.prop(prop); }\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, enterBracketed = (mode & IterMode.EnterBracketed) && mounted.bracketed;\n for (let { from, to } of mounted.overlay) {\n if ((side > 0 || enterBracketed ? from <= rPos : from < rPos) &&\n (side < 0 || enterBracketed ? 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 for (let found = false; !found;) {\n found = cur.type.is(before);\n if (!cur.nextSibling())\n return result;\n }\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; 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 prop(prop) { return this.type.prop(prop); }\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, mode = 0) {\n /**\n @internal\n */\n this.buffer = null;\n this.stack = [];\n /**\n @internal\n */\n this.index = 0;\n this.bufferNode = null;\n this.mode = mode & ~IterMode.EnterBracketed;\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 traversal. 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 (!depth)\n return;\n if (this.nextSibling())\n break;\n this.parent();\n depth--;\n mustLeave = true;\n }\n }\n }\n /**\n Test whether the current node matches a given context\u2014a 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.parent, 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._tree, 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, contextAtStart = contextHash;\n if (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, contextAtStart);\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, contextAtStart);\n localChildren.reverse();\n localPositions.reverse();\n if (localInRepeat > -1 && lastGroup > 0) {\n let make = makeBalanced(type, contextAtStart);\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, contextAtStart);\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, contextHash) {\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, contextHash);\n };\n }\n function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead, contextHash) {\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, contextHash));\n positions.push(from - base);\n }\n function makeTree(type, children, positions, length, lookAhead, contextHash, 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 */ || fork.size == -4 /* SpecialRecord.LookAhead */)\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, bracketed, target, from) {\n this.parser = parser;\n this.parse = parse;\n this.overlay = overlay;\n this.bracketed = bracketed;\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, bracketed, target, prev) {\n this.parser = parser;\n this.predicate = predicate;\n this.mounts = mounts;\n this.index = index;\n this.start = start;\n this.bracketed = bracketed;\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, inner.bracketed);\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 // materialize create one more level of nesting\n // we need to add depth to active overlay for going backwards\n if (overlay)\n overlay.depth++;\n if (covered)\n covered.depth++;\n }\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, !!nest.bracketed, 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, !!nest.bracketed, 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 let last = overlay.ranges.length - 1;\n if (last >= 0 && overlay.ranges[last].to == range.from)\n overlay.ranges[last] = { from: overlay.ranges[last].from, to: range.to };\n else\n overlay.ranges.push(range);\n }\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.bracketed, 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.to <= pos) {\n if (!cursor.next(false))\n this.done = true;\n // Moved to next node\n }\n else {\n break;\n }\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 { history, historyField, historyKeymap } from \"@codemirror/commands\"\nimport { Compartment, type Extension } from \"@codemirror/state\"\nimport { EditorView, ViewPlugin, keymap } from \"@codemirror/view\"\nimport type { DocHandle, DocHandleChangePayload } from \"./DocHandle.js\"\n\ntype AutomergeHistoryConfig = {\n handle: DocHandle<unknown>\n}\n\n/**\n * Undo/redo history that understands handles whose backing document can be\n * swapped in place: the stack is reset whenever the handle emits a `change`\n * with `scopeReplaced: true`, because the old entries describe a different\n * timeline and undo must only revert what the user has done since.\n *\n * Don't add another `history()` to the editor: the underlying history state\n * field is a module-level singleton in `@codemirror/commands`, so a second copy\n * elsewhere in the configuration keeps the field alive across the reset and defeats it.\n * If the user configures history on their own we detect this and warned about it at mount.\n */\nexport const automergeHistory = ({\n handle,\n}: AutomergeHistoryConfig): Extension => {\n const compartment = new Compartment()\n const historyExtension = () => [history(), keymap.of(historyKeymap)]\n\n const resetPlugin = ViewPlugin.fromClass(\n class {\n warned = false\n destroyed = false\n readonly view: EditorView\n\n constructor(view: EditorView) {\n this.view = view\n this.onChange = this.onChange.bind(this)\n handle.on(\"change\", this.onChange)\n // Probe once at mount, when the history is empty and cycling is\n // harmless: a duplicate history() warns immediately instead of on\n // the first swap. Deferred because dispatching isn't allowed while\n // the view is still initializing.\n queueMicrotask(() => {\n if (!this.destroyed) this.reset()\n })\n }\n\n onChange(payload?: DocHandleChangePayload) {\n if (payload?.scopeReplaced) this.reset()\n }\n\n // CodeMirror has no clear-history API; the sanctioned reset is cycling\n // the extension out of and back into the configuration, which drops\n // the history field's state and re-creates it empty.\n reset() {\n this.view.dispatch({ effects: compartment.reconfigure([]) })\n // With our copy out of the configuration the field must be gone; if\n // it survives, another history() is keeping it alive and the reset\n // is silently defeated.\n if (\n !this.warned &&\n this.view.state.field(historyField, false) !== undefined\n ) {\n this.warned = true\n console.warn(\n \"[automerge-codemirror] another history() extension is present\" +\n \" in this editor's configuration, so the undo history cannot\" +\n \" be reset when the handle's backing is swapped. Remove the\" +\n \" other copy \u2014 note that basicSetup includes one.\"\n )\n }\n this.view.dispatch({\n effects: compartment.reconfigure(historyExtension()),\n })\n }\n\n destroy() {\n this.destroyed = true\n handle.off(\"change\", this.onChange)\n }\n }\n )\n\n return [compartment.of(historyExtension()), resetPlugin]\n}\n", "import { Compartment, EditorState, type Extension } from \"@codemirror/state\"\nimport { EditorView, ViewPlugin } from \"@codemirror/view\"\nimport type { DocHandle, DocHandleChangePayload } from \"./DocHandle.js\"\n\ntype AutomergeReadOnlyConfig = {\n handle: DocHandle<unknown>\n}\n\n/**\n * Makes the editor read-only while the handle rejects writes\n * (`handle.isReadOnly()`, e.g. pinned to historical heads). This is a\n * correctness requirement of syncing, not a preference: an editable editor\n * bound to a read-only handle produces edits the write-back must drop.\n *\n * Tracked live: the flag can flip in place when the handle's backing is\n * swapped (a `change` event with `scopeReplaced: true`). Handles without\n * `isReadOnly` are treated as always writable.\n */\nexport const automergeReadOnly = ({\n handle,\n}: AutomergeReadOnlyConfig): Extension => {\n const compartment = new Compartment()\n const isReadOnly = () => !!handle.isReadOnly?.()\n const extensions = () =>\n isReadOnly()\n ? [EditorState.readOnly.of(true), EditorView.editable.of(false)]\n : []\n\n const trackPlugin = ViewPlugin.fromClass(\n class {\n wasPrevReadOnly = isReadOnly()\n destroyed = false\n readonly view: EditorView\n\n constructor(view: EditorView) {\n this.view = view\n this.onChange = this.onChange.bind(this)\n handle.on(\"change\", this.onChange)\n // The flag may have flipped between extension creation and mount;\n // deferred because dispatching isn't allowed while the view is\n // still initializing.\n queueMicrotask(() => {\n if (!this.destroyed) this.sync()\n })\n }\n\n onChange(payload?: DocHandleChangePayload) {\n if (payload?.scopeReplaced) this.sync()\n }\n\n sync() {\n const current = isReadOnly()\n if (current === this.wasPrevReadOnly) return\n this.wasPrevReadOnly = current\n this.view.dispatch({ effects: compartment.reconfigure(extensions()) })\n }\n\n destroy() {\n this.destroyed = true\n handle.off(\"change\", this.onChange)\n }\n }\n )\n\n return [compartment.of(extensions()), trackPlugin]\n}\n", "import type * as A from \"@automerge/automerge\"\nimport type { Extension } from \"@codemirror/state\"\nimport { automergeSyncPlugin } from \"./plugin.js\"\nimport { automergeHistory } from \"./history.js\"\nimport { automergeReadOnly } from \"./readOnly.js\"\nimport type { DocHandle } from \"./DocHandle.js\"\n\ntype AutomergePluginConfig = {\n handle: DocHandle<unknown>\n path: A.Prop[]\n}\n\n/**\n * The recommended entry point: two-way sync plus the pieces entangled with\n * it \u2014 undo history that resets when the handle's backing is swapped, and\n * read-only tracking for handles that reject writes.\n *\n * Don't add another `history()` to the editor (`basicSetup` includes one):\n * the bundled history must own the only copy for its reset to work. Each\n * piece is also exported individually for \u00E0-la-carte use.\n */\nexport const automergePlugin = ({\n handle,\n path,\n}: AutomergePluginConfig): Extension => [\n automergeSyncPlugin({ handle, path }),\n automergeHistory({ handle }),\n automergeReadOnly({ handle }),\n]\n\nexport { automergeSyncPlugin } from \"./plugin.js\"\nexport { automergeHistory } from \"./history.js\"\nexport { automergeReadOnly } from \"./readOnly.js\"\nexport type { DocHandle, DocHandleChangePayload } from \"./DocHandle.js\"\n", "import { createEffect } from \"solid-js\";\n\n/** CodeMirror */\nimport {\n Decoration,\n EditorView,\n ViewPlugin,\n WidgetType,\n type DecorationSet,\n type ViewUpdate,\n} from \"@codemirror/view\";\nimport { RangeSet, StateEffect, type Range } from \"@codemirror/state\";\n\n/** Automerge */\nimport { next as Automerge } from \"@automerge/automerge/slim\";\nimport type { Prop as AutomergeProp } from \"@automerge/automerge/slim\";\nimport {\n decodeHeads,\n type Doc,\n type DocHandle,\n type UrlHeads,\n} from \"@automerge/automerge-repo/slim\";\n\n// Carries the diff baseline (fork-point heads) from the provider subscription\n// into the editor. Dispatched only when the baseline changes (i.e. on fork),\n// which is rare -- per-edit recomputation is driven by `docChanged`, not this.\nconst setBaseline = StateEffect.define<UrlHeads | null>();\n\n/**\n * CodeMirror extension that renders a diff of the synced `path` against the\n * `baseline` heads. It recomputes its decorations on every doc change -- the\n * automerge sync plugin reflects both local and remote changes as editor\n * transactions -- so no external \"tick\" is needed. The baseline is pushed in\n * via a Solid effect because the editor can't observe a fork on its own.\n *\n * @returns the extension and an effect factory that feeds baseline changes in.\n */\nexport function createDiffExtension(\n handle: () => DocHandle<unknown>,\n path: () => AutomergeProp[],\n baseline: () => UrlHeads | null\n) {\n const plugin = ViewPlugin.fromClass(\n class {\n baseline: UrlHeads | null = null;\n decorations: DecorationSet = Decoration.none;\n\n update(update: ViewUpdate) {\n let baselineChanged = false;\n for (const tr of update.transactions) {\n for (const effect of tr.effects) {\n if (effect.is(setBaseline)) {\n this.baseline = effect.value;\n baselineChanged = true;\n }\n }\n }\n if (update.docChanged || baselineChanged) {\n this.decorations = this.build();\n }\n }\n\n build(): DecorationSet {\n const heads = this.baseline;\n const doc = handle()?.doc();\n if (!heads || !doc) return Decoration.none;\n return RangeSet.of(\n buildDiffDecorations(\n diffContent(doc, heads, path()),\n prefersDarkMode()\n ),\n true // sort ranges\n );\n }\n },\n { decorations: (v) => v.decorations }\n );\n\n const createReconfigureEffect = (view: EditorView) =>\n createEffect(() => {\n view.dispatch({ effects: setBaseline.of(baseline()) });\n });\n\n return [plugin, createReconfigureEffect] as const;\n}\n\ntype ContentDiff =\n | { type: \"added\"; from: number; to: number }\n | { type: \"deleted\"; at: number; text: string };\n\n// Diff the text at `path` between the baseline heads and the live doc using\n// Automerge patches directly (no annotations layer). A string field only ever\n// produces `splice` (insert) and `del` (delete) patches on `[...path, idx]`,\n// and their positions are in live-doc coordinates -- so `added` ranges map\n// straight to CodeMirror offsets. For `del` the removed text isn't in the\n// patch, so we recover it from the baseline view, tracking a running offset to\n// convert the live position back to a baseline position.\nfunction diffContent(\n doc: Doc<unknown>,\n baselineHeads: UrlHeads,\n path: AutomergeProp[]\n): ContentDiff[] {\n const before = decodeHeads(baselineHeads);\n const beforeContent = lookupString(Automerge.view(doc, before), path);\n const patches = Automerge.diff(doc, before, Automerge.getHeads(doc));\n\n const out: ContentDiff[] = [];\n let offset = 0;\n for (const patch of patches) {\n if (!isIndexedChildOf(patch.path, path)) continue;\n const pos = patch.path[path.length] as number;\n if (patch.action === \"splice\") {\n const len = (patch.value as string).length;\n out.push({ type: \"added\", from: pos, to: pos + len });\n offset -= len;\n } else if (patch.action === \"del\") {\n const len = patch.length ?? 1;\n const original = pos + offset;\n out.push({\n type: \"deleted\",\n at: pos,\n text: beforeContent.substring(original, original + len),\n });\n offset += len;\n }\n }\n return out;\n}\n\nfunction buildDiffDecorations(\n diffs: ContentDiff[],\n dark: boolean\n): Range<Decoration>[] {\n const out: Range<Decoration>[] = [];\n for (const diff of diffs) {\n if (diff.type === \"deleted\") {\n out.push(\n Decoration.widget({\n widget: new DeletionMarker(diff.text, false),\n side: 1,\n }).range(diff.at)\n );\n continue;\n }\n // Skip zero-length added ranges.\n if (diff.from === diff.to) continue;\n out.push(\n Decoration.mark({\n attributes: { style: addedDiffStyle(dark) },\n }).range(diff.from, diff.to)\n );\n }\n return out;\n}\n\n// True when `patchPath` addresses a direct indexed child of `path`, e.g.\n// `[\"content\", 5]` is an indexed child of `[\"content\"]`.\nfunction isIndexedChildOf(\n patchPath: readonly AutomergeProp[],\n path: AutomergeProp[]\n): boolean {\n if (patchPath.length !== path.length + 1) return false;\n for (let i = 0; i < path.length; i++) {\n if (patchPath[i] !== path[i]) return false;\n }\n return typeof patchPath[path.length] === \"number\";\n}\n\nfunction lookupString(doc: unknown, path: AutomergeProp[]): string {\n let current: unknown = doc;\n for (const key of path) {\n if (current == null) return \"\";\n current = (current as Record<AutomergeProp, unknown>)[key];\n }\n return typeof current === \"string\" ? current : \"\";\n}\n\nfunction addedDiffStyle(dark: boolean): string {\n return `\n border-bottom: 2px solid ${dark ? \"#4ade80\" : \"#22c55e\"};\n background-color: ${dark ? \"#14532d\" : \"#dcfce7\"};\n `;\n}\n\nfunction prefersDarkMode(): boolean {\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n}\n\nclass DeletionMarker extends WidgetType {\n deletedText: string;\n isActive: boolean;\n\n constructor(deletedText: string, isActive: boolean) {\n super();\n this.deletedText = deletedText;\n this.isActive = isActive;\n }\n\n toDOM(): HTMLElement {\n const box = document.createElement(\"div\");\n // Pin the badge to its own metrics so a tall line-height (e.g. on heading\n // lines) can't stretch it into a vertical rectangle. `position: relative`\n // anchors the hover tooltip to the badge so it can left-align to it.\n box.style.display = \"inline-block\";\n box.style.position = \"relative\";\n box.style.lineHeight = \"1\";\n box.style.verticalAlign = \"middle\";\n box.style.boxSizing = \"border-box\";\n box.style.padding = \"2px 3px\";\n box.style.color = \"rgb(239 68 68)\"; // red-500\n box.style.margin = \"0 4px\";\n box.style.fontSize = \"1.2em\";\n box.style.whiteSpace = \"nowrap\";\n box.style.backgroundColor = this.isActive\n ? \"rgb(239 68 68 / 20%)\" // red-500 with opacity\n : \"rgb(239 68 68 / 10%)\";\n box.style.borderRadius = \"3px\";\n box.style.cursor = \"default\";\n box.innerText = \"\\u232b\";\n\n const hoverText = document.createElement(\"div\");\n hoverText.style.position = \"absolute\";\n hoverText.style.top = \"100%\";\n hoverText.style.left = \"0\";\n hoverText.style.zIndex = \"1\";\n hoverText.style.padding = \"5px\";\n hoverText.style.backgroundColor = \"rgb(254 242 242)\"; // red-50\n hoverText.style.fontSize = \"15px\";\n hoverText.style.color = \"rgb(17 24 39)\"; // gray-900\n hoverText.style.border = \"1px solid rgb(185 28 28)\"; // red-700\n hoverText.style.boxShadow = \"0px 0px 6px rgba(0, 0, 0, 0.1)\";\n hoverText.style.borderRadius = \"3px\";\n hoverText.style.visibility = \"hidden\";\n hoverText.innerText = this.deletedText;\n\n const isDarkMode =\n document.documentElement.classList.contains(\"dark\") ||\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n\n if (isDarkMode) {\n box.style.color = \"rgb(248 113 113)\"; // red-400 for dark mode\n box.style.backgroundColor = this.isActive\n ? \"rgb(248 113 113 / 20%)\"\n : \"rgb(248 113 113 / 10%)\";\n hoverText.style.backgroundColor = \"rgb(69 10 10)\"; // red-950\n hoverText.style.color = \"rgb(254 226 226)\"; // red-100\n hoverText.style.border = \"1px solid rgb(153 27 27)\"; // red-800\n }\n\n box.appendChild(hoverText);\n\n box.onmouseover = function () {\n hoverText.style.visibility = \"visible\";\n };\n box.onmouseout = function () {\n hoverText.style.visibility = \"hidden\";\n };\n\n return box;\n }\n\n eq(other: DeletionMarker) {\n return (\n other.deletedText === this.deletedText && other.isActive === this.isActive\n );\n }\n\n ignoreEvent() {\n return true;\n }\n}\n", "import { createEffect } from \"solid-js\";\n\n/** CodeMirror */\nimport { EditorView } from \"@codemirror/view\";\nimport { EditorSelection, type Extension } from \"@codemirror/state\";\n\n/**\n * Create a CodeMirror extension that scrolls the highlighted range into view\n * when it changes.\n *\n * Uses the \"nearest\" scroll strategy, so a highlight that's already on screen\n * is left untouched and an off-screen one is scrolled just into frame -- i.e.\n * \"scroll the highlight into view only if it isn't already there\". Handy for\n * following focus/selection driven by other views (e.g. picking a comment).\n *\n * @param target An accessor returning the [from, to] range to reveal, or null.\n * @returns A tuple of the extension and a function to create the scroll effect.\n */\nexport function createScrollHighlightIntoViewExtension(\n target: () => readonly [number, number] | null\n) {\n // Scrolling is a fire-and-forget transaction effect with no editor state to\n // hold, so there's nothing to add to the editor. The empty extension just\n // keeps the [extension, effectFactory] shape shared with the siblings.\n const extension: Extension = [];\n\n const createScrollHighlightIntoViewEffect = (view: EditorView) =>\n createEffect(() => {\n const range = target();\n if (!range) return;\n // Clamp to the live doc: a target resolved against a slightly different\n // doc revision could otherwise point past the end and throw.\n const docLength = view.state.doc.length;\n const from = Math.min(range[0], docLength);\n const to = Math.min(range[1], docLength);\n view.dispatch({\n effects: EditorView.scrollIntoView(EditorSelection.range(from, to), {\n x: \"nearest\",\n y: \"nearest\",\n }),\n });\n });\n\n return [extension, createScrollHighlightIntoViewEffect] as const;\n}\n", "import { createEffect } from \"solid-js\";\n\n/** CodeMirror */\nimport {\n Decoration,\n EditorView,\n RectangleMarker,\n ViewPlugin,\n layer,\n type DecorationSet,\n type ViewUpdate,\n} from \"@codemirror/view\";\nimport {\n Compartment,\n EditorSelection,\n StateEffect,\n StateField,\n Transaction,\n type Extension,\n type Range,\n} from \"@codemirror/state\";\n\n/** Automerge */\nimport {\n next as A,\n type Prop as AutomergeProp,\n} from \"@automerge/automerge/slim\";\nimport {\n Presence,\n type AutomergeUrl,\n type DocHandle,\n type Repo,\n} from \"@automerge/automerge-repo/slim\";\n\n// The payload broadcast to peers: just the selection, as a pair of automerge\n// cursors rather than plain offsets, so every receiver resolves it against\n// its *own* view of the document and it stays glued to the text through\n// concurrent edits. Identity rides on Presence's own `userId` field (the\n// sender's contact url); receivers use it to look up the peer's contact doc\n// and read the color chosen there.\ntype PresenceSelection = {\n start: A.Cursor;\n end: A.Cursor;\n headAtStart: boolean;\n // Sender's Date.now(); used only as a change marker (not for clock comparison)\n lastMoved: number;\n};\ntype PresenceChannels = { selection: PresenceSelection | null };\n\n// A remote peer's selection resolved to positions in the current document.\n// `peerId` is unique per session, so two tabs of the same contact each get\n// their own caret.\ntype RemoteSelection = {\n peerId: string;\n contactUrl: AutomergeUrl | null;\n color: string;\n from: number;\n to: number;\n head: number;\n // Changes exactly when the peer acts (moves, types, refocuses) -- the\n // caret marker uses it to restart its nametag fade-out countdown.\n lastMoved: number;\n};\n\n/**\n * Create a CodeMirror extension for live remote cursors, reconfigurable via a\n * Compartment (same shape as the sync/diff/readOnly extensions).\n *\n * `contactUrl` is our identity: it travels as the Presence userId, and peers\n * use it to mount our \"contact-cursor\" token and read our chosen color. It\n * returning `null` renders no presence -- that's the state before the\n * identity has loaded, and permanently so for read-only views. When the\n * accessor changes, the compartment swaps the plugin wholesale: the outgoing\n * instance stops `Presence` (sending a goodbye to peers) and the new one\n * starts fresh with the new identity.\n *\n * `repo` is used to load each peer's contact doc, where their chosen\n * presence color lives.\n */\nexport function createPresenceExtension(\n handle: () => DocHandle<unknown>,\n path: () => AutomergeProp[],\n contactUrl: () => AutomergeUrl | null,\n repo: Repo\n) {\n const compartment = new Compartment();\n\n const extension = () => {\n const url = contactUrl();\n return url ? presence(handle(), path(), url, repo) : [];\n };\n\n const createReconfigureEffect = (view: EditorView) =>\n createEffect(() => {\n view.dispatch({ effects: compartment.reconfigure(extension()) });\n });\n\n return [compartment.of(extension()), createReconfigureEffect] as const;\n}\n\n/**\n * Live remote cursors for collaborative text, handling presence transport,\n * broadcasting/resolving selections, rendering colored ranges and contact-cursor carets.\n * Peers are keyed by session (peerId); idle carets hide their nametag after a timeout.\n * Lifetime matches the editor: reconfiguring or closing stops presence.\n */\nfunction presence(\n handle: DocHandle<unknown>,\n path: AutomergeProp[],\n contactUrl: AutomergeUrl,\n repo: Repo\n): Extension {\n const setRemoteSelections = StateEffect.define<RemoteSelection[]>();\n\n const remoteSelectionField = StateField.define<RemoteSelection[]>({\n create() {\n return [];\n },\n update(value, tr) {\n // Between re-resolutions, keep positions glued through edits.\n if (tr.docChanged) {\n value = value.map((sel) => ({\n ...sel,\n from: tr.changes.mapPos(sel.from),\n to: tr.changes.mapPos(sel.to),\n head: tr.changes.mapPos(sel.head),\n }));\n }\n for (const e of tr.effects) {\n if (e.is(setRemoteSelections)) value = e.value;\n }\n return value;\n },\n // Selection tints are plain mark decorations: they carry no stateful\n // DOM, so redrawing them is invisible.\n provide: (f) => EditorView.decorations.from(f, buildSelectionTints),\n });\n\n // Carets and their nametags are rendered in a layer (not as widget decorations)\n // to prevent remounts and visible flicker. This ensures the <patchwork-view>\n // element stays mounted and updated in place, even during edits.\n const caretLayer = layer({\n above: true,\n class: \"cm-presence-layer\",\n update: (update) =>\n update.docChanged ||\n update.transactions.some((tr) =>\n tr.effects.some((e) => e.is(setRemoteSelections))\n ),\n markers(view) {\n // Stable order, so the layer's pairwise DOM reuse matches each marker\n // with the same peer's existing element across redraws.\n const selections = [...view.state.field(remoteSelectionField)].sort(\n (a, b) => (a.peerId < b.peerId ? -1 : a.peerId > b.peerId ? 1 : 0)\n );\n const markers: PresenceCaretMarker[] = [];\n for (const sel of selections) {\n // Reuse drawSelection's measurement for a caret rectangle at head.\n const [rect] = RectangleMarker.forRange(\n view,\n \"cm-presence-caret\",\n EditorSelection.cursor(sel.head)\n );\n if (!rect) continue; // outside the rendered viewport\n markers.push(\n new PresenceCaretMarker(sel, rect.left, rect.top, rect.height)\n );\n }\n return markers;\n },\n });\n\n const plugin = ViewPlugin.fromClass(\n class {\n private view: EditorView;\n private presence: Presence<PresenceChannels>;\n private destroyed = false;\n private broadcastQueued = false;\n // Peers' contact docs, followed live so a color picked in the account\n // picker recolors that peer's caret and tint immediately. Keyed by\n // contact url; the stored function stops the subscription.\n private contactWatchers = new Map<AutomergeUrl, () => void>();\n private contactColors = new Map<AutomergeUrl, string>();\n\n constructor(view: EditorView) {\n this.view = view;\n this.presence = new Presence<PresenceChannels>({\n handle,\n userId: contactUrl,\n });\n this.presence.start({ initialState: { selection: null } });\n this.presence.on(\"update\", this.refresh);\n this.presence.on(\"snapshot\", this.refresh);\n this.presence.on(\"goodbye\", this.refresh);\n this.presence.on(\"pruned\", this.refresh);\n // Closing the page sends a goodbye, which removes us from peers\n // immediately instead of after the stale-peer timeout.\n window.addEventListener(\"pagehide\", this.stopPresence);\n }\n\n update(update: ViewUpdate) {\n // Typing is considered cursor movement; local edits may not set selection explicitly, so we also check userEvent annotations\n const typed =\n update.docChanged &&\n update.transactions.some(\n (tr) => tr.annotation(Transaction.userEvent) !== undefined\n );\n if (update.focusChanged && !update.view.hasFocus) {\n // Hide our caret on peers while blurred; the peer record itself\n // stays alive via heartbeats.\n if (this.presence.running) {\n this.presence.broadcast(\"selection\", null);\n }\n } else if (\n update.selectionSet ||\n typed ||\n (update.focusChanged && update.view.hasFocus)\n ) {\n this.scheduleBroadcast();\n }\n // Local and remote edits alike arrive as transactions (the sync\n // plugin turns automerge patches into transactions), so this\n // re-resolves peers' cursors against the updated doc. Deferred:\n // dispatching is not allowed from inside update().\n if (update.docChanged) {\n queueMicrotask(this.refresh);\n }\n }\n\n destroy() {\n this.destroyed = true;\n this.stopPresence();\n window.removeEventListener(\"pagehide\", this.stopPresence);\n for (const stop of this.contactWatchers.values()) stop();\n this.contactWatchers.clear();\n }\n\n // A peer's color is whatever their account says (contact doc `color`),\n // never derived locally. The doc is fetched once and followed; until it\n // loads (or if the contact never picked a color) the caret stays on the\n // neutral fallback.\n private trackContactColor(url: AutomergeUrl) {\n if (this.contactWatchers.has(url)) return;\n this.contactWatchers.set(url, () => {});\n repo\n .find<ContactDoc>(url)\n .then((contactHandle) => {\n if (this.destroyed) return;\n const read = () => {\n const color = contactHandle.doc()?.color;\n if (!color || this.contactColors.get(url) === color) return;\n this.contactColors.set(url, color);\n this.refresh();\n };\n contactHandle.on(\"change\", read);\n this.contactWatchers.set(url, () =>\n contactHandle.off(\"change\", read)\n );\n read();\n })\n .catch(() => {\n // Contact doc unavailable: the peer stays on the fallback color.\n });\n }\n\n private stopPresence = () => {\n if (this.presence.running) this.presence.stop();\n };\n\n // rAF-throttled (matching tldraw4) so drag-selections don't flood the\n // channel. The selection is read fresh at flush time.\n private scheduleBroadcast() {\n if (this.broadcastQueued) return;\n this.broadcastQueued = true;\n requestAnimationFrame(() => {\n this.broadcastQueued = false;\n if (this.destroyed || !this.presence.running) return;\n // Blurred in the meantime: the null broadcast already went out.\n if (!this.view.hasFocus) return;\n const doc = handle.doc();\n const sel = this.view.state.selection.main;\n this.presence.broadcast(\"selection\", {\n start: A.getCursor(doc, path, sel.from),\n end: A.getCursor(doc, path, sel.to),\n headAtStart: sel.to > sel.from && sel.head === sel.from,\n lastMoved: Date.now(),\n });\n });\n }\n\n // Re-resolve every peer's cursors against the current doc. A cursor can\n // briefly fail to resolve when a presence message races ahead of doc\n // sync -- the peer is skipped and picked up again on the next change.\n private refresh = () => {\n if (this.destroyed) return;\n const doc = handle.doc();\n const resolved: RemoteSelection[] = [];\n for (const peer of this.presence.getPeerStates().peers) {\n const peerId = String(peer.peerId);\n const selection = peer.value?.selection ?? null;\n if (!selection) continue;\n try {\n const from = A.getCursorPosition(doc, path, selection.start);\n const to = A.getCursorPosition(doc, path, selection.end);\n const peerContactUrl =\n (peer.userId as AutomergeUrl | undefined) ?? null;\n if (peerContactUrl) this.trackContactColor(peerContactUrl);\n resolved.push({\n peerId,\n contactUrl: peerContactUrl,\n // The color the peer chose in their account -- the same contact\n // doc the contact-cursor token renders from, so the tint and\n // the token can't drift apart.\n color:\n (peerContactUrl && this.contactColors.get(peerContactUrl)) ||\n FALLBACK_PRESENCE_COLOR,\n from,\n to,\n head: selection.headAtStart ? from : to,\n lastMoved: selection.lastMoved,\n });\n } catch {\n continue;\n }\n }\n this.view.dispatch({ effects: setRemoteSelections.of(resolved) });\n };\n }\n );\n\n return [remoteSelectionField, caretLayer, plugin, presenceTheme];\n}\n\nfunction buildSelectionTints(selections: RemoteSelection[]): DecorationSet {\n const ranges: Range<Decoration>[] = [];\n for (const sel of selections) {\n if (sel.from < sel.to) {\n ranges.push(\n Decoration.mark({\n class: \"cm-presence-range\",\n attributes: {\n style: `background-color: color-mix(in srgb, ${sel.color} 25%, transparent);`,\n },\n }).range(sel.from, sel.to)\n );\n }\n }\n return Decoration.set(ranges, true);\n}\n\n// A peer's nametag fades out once its selection has been still for this\n// long -- the caret itself stays visible. Moving the cursor or typing\n// brings it back.\nconst LABEL_TIMEOUT_MS = 2_000;\n\n// A layer marker for one peer's caret. Markers are throwaway value objects\n// (a fresh set arrives with every measure pass); the peer's DOM element is\n// what persists, via `update` mutating it in place. That persistence is the\n// point of the layer approach: the contact token inside must never remount.\nclass PresenceCaretMarker {\n private readonly sel: RemoteSelection;\n private readonly left: number;\n private readonly top: number;\n private readonly height: number;\n\n constructor(sel: RemoteSelection, left: number, top: number, height: number) {\n this.sel = sel;\n this.left = left;\n this.top = top;\n this.height = height;\n }\n\n eq(other: PresenceCaretMarker): boolean {\n return (\n other.sel.peerId === this.sel.peerId &&\n other.sel.contactUrl === this.sel.contactUrl &&\n other.sel.color === this.sel.color &&\n other.sel.lastMoved === this.sel.lastMoved &&\n other.left === this.left &&\n other.top === this.top &&\n other.height === this.height\n );\n }\n\n draw(): HTMLElement {\n const caret = document.createElement(\"div\");\n caret.className = \"cm-presence-caret\";\n caret.dataset.peerId = this.sel.peerId;\n if (this.sel.contactUrl) {\n const label = document.createElement(\"span\");\n label.className = \"cm-presence-caret-label\";\n const token = document.createElement(\"patchwork-view\");\n token.setAttribute(\"doc-url\", this.sel.contactUrl);\n token.setAttribute(\"tool-id\", \"contact-cursor\");\n token.style.display = \"block\";\n label.appendChild(token);\n caret.appendChild(label);\n }\n this.adjust(caret);\n restartIdleCountdown(caret);\n return caret;\n }\n\n // Reposition the peer's existing element instead of redrawing it, keeping\n // the mounted contact token alive (a remount re-renders asynchronously and\n // flickers -- see the layer comment in `presence`).\n update(dom: HTMLElement, prev: PresenceCaretMarker): boolean {\n // A different peer means a different contact token, which genuinely has\n // to remount. Only happens when peers join or leave.\n if (\n prev.sel.peerId !== this.sel.peerId ||\n prev.sel.contactUrl !== this.sel.contactUrl\n ) {\n return false;\n }\n this.adjust(dom);\n // Fresh activity restarts the nametag fade-out. Position shifts caused\n // by other people's edits deliberately don't.\n if (prev.sel.lastMoved !== this.sel.lastMoved) restartIdleCountdown(dom);\n return true;\n }\n\n private adjust(dom: HTMLElement) {\n dom.style.left = `${this.left}px`;\n dom.style.top = `${this.top}px`;\n dom.style.height = `${this.height}px`;\n dom.style.setProperty(\"--cm-presence-color\", this.sel.color);\n }\n}\n\n// Keyed on the DOM element rather than the marker, because marker instances\n// are replaced on every measure pass while the element lives on.\nconst idleTimers = new WeakMap<HTMLElement, ReturnType<typeof setTimeout>>();\n\nfunction restartIdleCountdown(caret: HTMLElement) {\n clearTimeout(idleTimers.get(caret));\n caret.classList.remove(\"cm-presence-caret--idle\");\n idleTimers.set(\n caret,\n setTimeout(\n () => caret.classList.add(\"cm-presence-caret--idle\"),\n LABEL_TIMEOUT_MS\n )\n );\n}\n\nconst presenceTheme = EditorView.baseTheme({\n // Positioned absolutely by the layer (document-relative); -1px centers\n // the 2px bar on the caret position.\n \".cm-presence-caret\": {\n borderLeft: \"2px solid var(--cm-presence-color)\",\n marginLeft: \"-1px\",\n pointerEvents: \"none\",\n },\n \".cm-presence-caret-label\": {\n position: \"absolute\",\n top: \"-1.4em\",\n left: \"-2px\",\n zIndex: \"150\",\n whiteSpace: \"nowrap\",\n pointerEvents: \"none\",\n userSelect: \"none\",\n opacity: \"1\",\n transition: \"opacity 200ms ease-in-out\",\n },\n \".cm-presence-caret--idle .cm-presence-caret-label\": {\n opacity: \"0\",\n },\n});\n\n// Shown until a peer's contact doc has loaded, and for contacts that never\n// picked a color. Matches the contact-cursor token's CSS fallback\n// (`var(--contact-cursor-color, #888)` in the account package).\nconst FALLBACK_PRESENCE_COLOR = \"#888\";\n\n// The subset of the account package's ContactDoc this extension reads.\ntype ContactDoc = { color?: string };\n"],
5
+ "mappings": ";AAAA,SAAS,WAAW,gBAAAA,qBAAoB;AACxC,SAAS,cAAAC,oBAAkB;AAC3B,SAAS,eAAAC,cAAa,eAAAC,oBAAmB;;;ACFzC,SAAS,oBAAoB;AAG7B,SAAS,YAAY,kBAAsC;AAC3D,SAAS,aAAa,kBAAkB;AAQjC,SAAS,2BAA2B,aAAkC;AAC3E,QAAM,iBAAiB,YAAY,OAAsB;AACzD,QAAM,mBAAmB,WAAW,OAAsB;AAAA,IACxD,SAAS;AACP,aAAO,WAAW;AAAA,IACpB;AAAA,IACA,OAAO,OAAO,IAAI;AAChB,iBAAW,KAAK,GAAG,SAAS;AAC1B,YAAI,EAAE,GAAG,cAAc,EAAG,QAAO,EAAE;AAAA,MACrC;AACA,UAAI,GAAG,WAAY,QAAO,MAAM,IAAI,GAAG,OAAO;AAC9C,aAAO;AAAA,IACT;AAAA,IACA,SAAS,CAAC,MAAM,WAAW,YAAY,KAAK,C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IAAkC;AAAA,IAAmB,0BAA0B,GAAG,MAAM,cAAc,CAAC,CAAC;AAAA,IAAG;AAAA,EAAiB,EAAE,OAAO,OAAO;AAC/K,QAAM,QAAQC,aAAY,OAAO;AAAA,IAC/B,KAAK,WAAW;AAAA,IAChB;AAAA,EACF,CAAC;AACD,QAAM,OAAO,IAAID,aAAW;AAAA,IAC1B;AAAA,EACF,CAAC;AACD,QAAM,WAAW,IAAI;AACrB,mCAAiC,IAAI;AACrC,kCAAgC,IAAI;AACpC,uCAAqC,IAAI;AACzC,8BAA4B,IAAI;AAChC,sCAAoC,IAAI;AACxC,kCAAgC,IAAI;AACpC,EAAAE,cAAa,MAAM;AACjB,SAAK,SAAS;AAAA,MACZ,SAAS,0BAA0B,YAAY,MAAM,cAAc,CAAC,CAAC;AAAA,IACvE,CAAC;AAAA,EACH,CAAC;AACD,YAAU,MAAM,KAAK,QAAQ,CAAC;AAC9B,SAAO,KAAK;AACd;",
6
+ "names": ["createEffect", "EditorView", "EditorState", "Compartment", "createEffect", "EditorView", "createEffect", "Compartment", "Transaction", "A", "Annotation", "StateField", "Transaction", "ChangeSet", "StateEffect", "EditorView", "IterMode", "mounted", "children", "positions", "node", "buffer", "data", "contextHash", "length", "lookAhead", "nodeSize", "from", "to", "Annotation", "isAdjacent", "StateField", "Transaction", "EditorView", "ChangeSet", "isAdjacent", "StateEffect", "Compartment", "ViewPlugin", "Compartment", "EditorState", "EditorView", "ViewPlugin", "Compartment", "createEffect", "Transaction", "createEffect", "Decoration", "ViewPlugin", "StateEffect", "diff", "createEffect", "EditorView", "EditorSelection", "createEffect", "Decoration", "EditorView", "ViewPlugin", "Compartment", "EditorSelection", "StateEffect", "StateField", "Transaction", "A", "Compartment", "EditorView", "EditorState", "createEffect"]
7
+ }